Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11image.c @ 166:39877400bd1e
Fixed Solaris nitpicks (thanks Mattias!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 04 Sep 2001 22:48:09 +0000 |
parents | eb6b76a95f2d |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
165:6a4e09bbbbc0 | 166:39877400bd1e |
---|---|
24 static char rcsid = | 24 static char rcsid = |
25 "@(#) $Id$"; | 25 "@(#) $Id$"; |
26 #endif | 26 #endif |
27 | 27 |
28 #include <stdlib.h> | 28 #include <stdlib.h> |
29 #include <unistd.h> | |
29 | 30 |
30 #include "SDL_error.h" | 31 #include "SDL_error.h" |
31 #include "SDL_endian.h" | 32 #include "SDL_endian.h" |
32 #include "SDL_events_c.h" | 33 #include "SDL_events_c.h" |
33 #include "SDL_x11image_c.h" | 34 #include "SDL_x11image_c.h" |
34 | |
35 #if defined(__USLC__) | |
36 #ifdef HAVE_KSTAT | |
37 #undef HAVE_KSTAT | |
38 #endif | |
39 #include <unistd.h> | |
40 #endif | |
41 | |
42 #ifdef HAVE_KSTAT | |
43 #include <kstat.h> | |
44 #endif | |
45 | 35 |
46 #ifndef NO_SHARED_MEMORY | 36 #ifndef NO_SHARED_MEMORY |
47 | 37 |
48 /* Shared memory information */ | 38 /* Shared memory information */ |
49 extern int XShmQueryExtension(Display *dpy); /* Not in X11 headers */ | 39 extern int XShmQueryExtension(Display *dpy); /* Not in X11 headers */ |
175 if ( screen ) { | 165 if ( screen ) { |
176 screen->pixels = NULL; | 166 screen->pixels = NULL; |
177 } | 167 } |
178 } | 168 } |
179 | 169 |
180 /* This is a hack to see whether this system has more than 1 CPU */ | 170 /* Determine the number of CPUs in the system */ |
181 static int num_CPU(void) | 171 static int num_CPU(void) |
182 { | 172 { |
183 static int num_cpus = 0; | 173 static int num_cpus = 0; |
184 | 174 |
185 if(!num_cpus) { | 175 if(!num_cpus) { |
186 #ifdef linux | 176 #if defined(__linux) |
187 char line[BUFSIZ]; | 177 char line[BUFSIZ]; |
188 FILE *pstat = fopen("/proc/stat", "r"); | 178 FILE *pstat = fopen("/proc/stat", "r"); |
189 if ( pstat ) { | 179 if ( pstat ) { |
190 while ( fgets(line, sizeof(line), pstat) ) { | 180 while ( fgets(line, sizeof(line), pstat) ) { |
191 if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { | 181 if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') { |
192 ++num_cpus; | 182 ++num_cpus; |
193 } | 183 } |
194 } | 184 } |
195 fclose(pstat); | 185 fclose(pstat); |
196 } | 186 } |
197 #elif defined(HAVE_KSTAT) | 187 #elif defined(_SC_NPROCESSORS_ONLN) |
198 kstat_ctl_t *kc = kstat_open(); | 188 /* number of processors online (SVR4.0MP compliant machines) */ |
199 kstat_t *ks; | 189 num_cpus = sysconf(_SC_NPROCESSORS_ONLN); |
200 kstat_named_t *kn; | 190 #elif defined(_SC_NPROCESSORS_CONF) |
201 if(kc) { | 191 /* number of processors configured (SVR4.0MP compliant machines) */ |
202 if((ks = kstat_lookup(kc, "unix", -1, "system_misc")) | 192 num_cpus = sysconf(_SC_NPROCESSORS_CONF); |
203 && kstat_read(kc, ks, NULL) != -1 | |
204 && (kn = kstat_data_lookup(ks, "ncpus"))) | |
205 #ifdef KSTAT_DATA_UINT32 | |
206 num_cpus = kn->value.ui32; | |
207 #else | |
208 num_cpus = kn->value.ul; /* needed in solaris <2.6 */ | |
209 #endif | |
210 kstat_close(kc); | |
211 } | |
212 #elif defined(__USLC__) | |
213 num_cpus = (int)sysconf(_SC_NPROCESSORS_CONF); | |
214 #endif | 193 #endif |
215 if ( num_cpus <= 0 ) { | 194 if ( num_cpus <= 0 ) { |
216 num_cpus = 1; | 195 num_cpus = 1; |
217 } | 196 } |
218 } | 197 } |