OLD | NEW |
| (Empty) |
1 /* Copyright (C)2004 Landmark Graphics Corporation | |
2 * Copyright (C)2005 Sun Microsystems, Inc. | |
3 * Copyright (C)2010 D. R. Commander | |
4 * | |
5 * This library is free software and may be redistributed and/or modified under | |
6 * the terms of the wxWindows Library License, Version 3.1 or (at your option) | |
7 * any later version. The full license is in the LICENSE.txt file included | |
8 * with this distribution. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * wxWindows Library License for more details. | |
14 */ | |
15 | |
16 #ifndef __RRUTIL_H__ | |
17 #define __RRUTIL_H__ | |
18 | |
19 #ifdef _WIN32 | |
20 #include <windows.h> | |
21 #define sleep(t) Sleep((t)*1000) | |
22 #define usleep(t) Sleep((t)/1000) | |
23 #else | |
24 #include <unistd.h> | |
25 #define stricmp strcasecmp | |
26 #define strnicmp strncasecmp | |
27 #endif | |
28 | |
29 #ifndef min | |
30 #define min(a,b) ((a)<(b)?(a):(b)) | |
31 #endif | |
32 | |
33 #ifndef max | |
34 #define max(a,b) ((a)>(b)?(a):(b)) | |
35 #endif | |
36 | |
37 #define pow2(i) (1<<(i)) | |
38 #define isPow2(x) (((x)&(x-1))==0) | |
39 | |
40 #ifdef sgi | |
41 #define _SC_NPROCESSORS_CONF _SC_NPROC_CONF | |
42 #endif | |
43 | |
44 #ifdef sun | |
45 #define __inline inline | |
46 #endif | |
47 | |
48 static __inline int numprocs(void) | |
49 { | |
50 #ifdef _WIN32 | |
51 DWORD_PTR ProcAff, SysAff, i; int count=0; | |
52 if(!GetProcessAffinityMask(GetCurrentProcess(), &ProcAff, &SysAff)) retu
rn(1); | |
53 for(i=0; i<sizeof(long*)*8; i++) if(ProcAff&(1LL<<i)) count++; | |
54 return(count); | |
55 #elif defined (__APPLE__) | |
56 return(1); | |
57 #else | |
58 long count=1; | |
59 if((count=sysconf(_SC_NPROCESSORS_CONF))!=-1) return((int)count); | |
60 else return(1); | |
61 #endif | |
62 } | |
63 | |
64 #define byteswap(i) ( \ | |
65 (((i) & 0xff000000) >> 24) | \ | |
66 (((i) & 0x00ff0000) >> 8) | \ | |
67 (((i) & 0x0000ff00) << 8) | \ | |
68 (((i) & 0x000000ff) << 24) ) | |
69 | |
70 #define byteswap16(i) ( \ | |
71 (((i) & 0xff00) >> 8) | \ | |
72 (((i) & 0x00ff) << 8) ) | |
73 | |
74 static __inline int littleendian(void) | |
75 { | |
76 unsigned int value=1; | |
77 unsigned char *ptr=(unsigned char *)(&value); | |
78 if(ptr[0]==1 && ptr[3]==0) return 1; | |
79 else return 0; | |
80 } | |
81 | |
82 #endif | |
OLD | NEW |