tanjent@gmail.com | f3b7897 | 2012-03-01 03:38:55 +0000 | [diff] [blame] | 1 | #include "Platform.h" |
| 2 | |
| 3 | #include <stdio.h> |
| 4 | |
| 5 | void testRDTSC ( void ) |
| 6 | { |
| 7 | int64_t temp = rdtsc(); |
| 8 | |
| 9 | printf("%d",(int)temp); |
| 10 | } |
| 11 | |
| 12 | #if defined(_MSC_VER) |
| 13 | |
| 14 | #include <windows.h> |
| 15 | |
| 16 | void SetAffinity ( int cpu ) |
| 17 | { |
| 18 | SetProcessAffinityMask(GetCurrentProcess(),cpu); |
| 19 | SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); |
| 20 | } |
| 21 | |
| 22 | #else |
| 23 | |
| 24 | #include <sched.h> |
| 25 | |
| 26 | void SetAffinity ( int /*cpu*/ ) |
| 27 | { |
tanjent@gmail.com | 6895dce | 2012-05-11 04:59:07 +0000 | [diff] [blame] | 28 | #if !defined(__CYGWIN__) && !defined(__APPLE__) |
tanjent@gmail.com | f3b7897 | 2012-03-01 03:38:55 +0000 | [diff] [blame] | 29 | cpu_set_t mask; |
| 30 | |
| 31 | CPU_ZERO(&mask); |
| 32 | |
| 33 | CPU_SET(2,&mask); |
| 34 | |
| 35 | if( sched_setaffinity(0,sizeof(mask),&mask) == -1) |
| 36 | { |
| 37 | printf("WARNING: Could not set CPU affinity\n"); |
| 38 | } |
| 39 | #endif |
| 40 | } |
| 41 | |
| 42 | #endif |