Mercurial > sdl-ios-xcode
comparison src/cpuinfo/SDL_cpuinfo.c @ 5122:b3f075368b1f
Added API function to get CPU cache line size.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Jan 2011 20:46:45 -0800 |
parents | 427998ff3bcf |
children | 6a65c1fc07af |
comparison
equal
deleted
inserted
replaced
5121:edd0f0617be4 | 5122:b3f075368b1f |
---|---|
302 } | 302 } |
303 | 303 |
304 static int SDL_CPUCount = 0; | 304 static int SDL_CPUCount = 0; |
305 | 305 |
306 int | 306 int |
307 SDL_GetCPUCount() | 307 SDL_GetCPUCount(void) |
308 { | 308 { |
309 if (!SDL_CPUCount) { | 309 if (!SDL_CPUCount) { |
310 #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) | 310 #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) |
311 if (SDL_CPUCount <= 0) { | 311 if (SDL_CPUCount <= 0) { |
312 SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN); | 312 SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN); |
333 return SDL_CPUCount; | 333 return SDL_CPUCount; |
334 } | 334 } |
335 | 335 |
336 /* Oh, such a sweet sweet trick, just not very useful. :) */ | 336 /* Oh, such a sweet sweet trick, just not very useful. :) */ |
337 static const char * | 337 static const char * |
338 SDL_GetCPUType() | 338 SDL_GetCPUType(void) |
339 { | 339 { |
340 static char SDL_CPUType[13]; | 340 static char SDL_CPUType[13]; |
341 | 341 |
342 if (!SDL_CPUType[0]) { | 342 if (!SDL_CPUType[0]) { |
343 int i = 0; | 343 int i = 0; |
364 } | 364 } |
365 return SDL_CPUType; | 365 return SDL_CPUType; |
366 } | 366 } |
367 | 367 |
368 static const char * | 368 static const char * |
369 SDL_GetCPUName() | 369 SDL_GetCPUName(void) |
370 { | 370 { |
371 static char SDL_CPUName[48]; | 371 static char SDL_CPUName[48]; |
372 | 372 |
373 if (!SDL_CPUName[0]) { | 373 if (!SDL_CPUName[0]) { |
374 int i = 0; | 374 int i = 0; |
435 } | 435 } |
436 } | 436 } |
437 return SDL_CPUName; | 437 return SDL_CPUName; |
438 } | 438 } |
439 | 439 |
440 static int | 440 int |
441 SDL_GetCPUCacheLineSize() | 441 SDL_GetCPUCacheLineSize(void) |
442 { | 442 { |
443 const char *cpuType = SDL_GetCPUType(); | 443 const char *cpuType = SDL_GetCPUType(); |
444 | 444 |
445 if (SDL_strcmp(cpuType, "GenuineIntel") == 0) { | 445 if (SDL_strcmp(cpuType, "GenuineIntel") == 0) { |
446 int a, b, c, d; | 446 int a, b, c, d; |