src/video/x11/SDL_x11image.c
changeset 166 39877400bd1e
parent 161 eb6b76a95f2d
child 252 e8157fcb3114
     1.1 --- a/src/video/x11/SDL_x11image.c	Tue Sep 04 22:38:01 2001 +0000
     1.2 +++ b/src/video/x11/SDL_x11image.c	Tue Sep 04 22:48:09 2001 +0000
     1.3 @@ -26,23 +26,13 @@
     1.4  #endif
     1.5  
     1.6  #include <stdlib.h>
     1.7 +#include <unistd.h>
     1.8  
     1.9  #include "SDL_error.h"
    1.10  #include "SDL_endian.h"
    1.11  #include "SDL_events_c.h"
    1.12  #include "SDL_x11image_c.h"
    1.13  
    1.14 -#if defined(__USLC__)
    1.15 -#ifdef HAVE_KSTAT
    1.16 -#undef HAVE_KSTAT
    1.17 -#endif
    1.18 -#include <unistd.h>
    1.19 -#endif
    1.20 -
    1.21 -#ifdef HAVE_KSTAT
    1.22 -#include <kstat.h>
    1.23 -#endif
    1.24 -
    1.25  #ifndef NO_SHARED_MEMORY
    1.26  
    1.27  /* Shared memory information */
    1.28 @@ -177,13 +167,13 @@
    1.29  	}
    1.30  }
    1.31  
    1.32 -/* This is a hack to see whether this system has more than 1 CPU */
    1.33 +/* Determine the number of CPUs in the system */
    1.34  static int num_CPU(void)
    1.35  {
    1.36         static int num_cpus = 0;
    1.37  
    1.38         if(!num_cpus) {
    1.39 -#ifdef linux
    1.40 +#if defined(__linux)
    1.41             char line[BUFSIZ];
    1.42             FILE *pstat = fopen("/proc/stat", "r");
    1.43             if ( pstat ) {
    1.44 @@ -194,23 +184,12 @@
    1.45                 }
    1.46                 fclose(pstat);
    1.47             }
    1.48 -#elif defined(HAVE_KSTAT)
    1.49 -           kstat_ctl_t *kc = kstat_open();
    1.50 -           kstat_t *ks;
    1.51 -           kstat_named_t *kn;
    1.52 -           if(kc) {
    1.53 -               if((ks = kstat_lookup(kc, "unix", -1, "system_misc"))
    1.54 -                  && kstat_read(kc, ks, NULL) != -1
    1.55 -                  && (kn = kstat_data_lookup(ks, "ncpus")))
    1.56 -#ifdef KSTAT_DATA_UINT32
    1.57 -                   num_cpus = kn->value.ui32;
    1.58 -#else
    1.59 -                   num_cpus = kn->value.ul; /* needed in solaris <2.6 */
    1.60 -#endif
    1.61 -               kstat_close(kc);
    1.62 -           }
    1.63 -#elif defined(__USLC__)
    1.64 -           num_cpus = (int)sysconf(_SC_NPROCESSORS_CONF);
    1.65 +#elif defined(_SC_NPROCESSORS_ONLN)
    1.66 +	   /* number of processors online (SVR4.0MP compliant machines) */
    1.67 +           num_cpus = sysconf(_SC_NPROCESSORS_ONLN);
    1.68 +#elif defined(_SC_NPROCESSORS_CONF)
    1.69 +	   /* number of processors configured (SVR4.0MP compliant machines) */
    1.70 +           num_cpus = sysconf(_SC_NPROCESSORS_CONF);
    1.71  #endif
    1.72             if ( num_cpus <= 0 ) {
    1.73                 num_cpus = 1;