Changeset 34bd549 in network-game for common/Common.cpp
- Timestamp:
- Jun 19, 2014, 1:34:15 AM (11 years ago)
- Branches:
- master
- Children:
- 3ea1839
- Parents:
- 883bb5d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Common.cpp
r883bb5d r34bd549 8 8 #include <fcntl.h> 9 9 #include <assert.h> 10 #elif defined MAC 11 #include <fcntl.h> 12 #include <assert.h> 13 #include <mach/clock.h> 14 #include <mach/mach.h> 10 15 #endif 11 16 … … 50 55 assert(flags != -1); 51 56 fcntl(sock, F_SETFL, flags | O_NONBLOCK); 57 #elif defined MAC 58 int flags = fcntl(sock, F_GETFL,0); 59 assert(flags != -1); 60 fcntl(sock, F_SETFL, flags | O_NONBLOCK); 52 61 #endif 53 62 } … … 62 71 timespec curTime; 63 72 clock_gettime(CLOCK_REALTIME, &curTime); 73 74 numMilliseconds = curTime.tv_sec*(unsigned long long)1000+curTime.tv_nsec/(unsigned long long)1000000; 75 # elif defined MAC 76 timespec curTime; 77 78 clock_serv_t cclock; 79 mach_timespec_t mts; 80 host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); 81 clock_get_time(cclock, &mts); 82 mach_port_deallocate(mach_task_self(), cclock); 83 curTime.tv_sec = mts.tv_sec; 84 curTime.tv_nsec = mts.tv_nsec; 64 85 65 86 numMilliseconds = curTime.tv_sec*(unsigned long long)1000+curTime.tv_nsec/(unsigned long long)1000000;
Note:
See TracChangeset
for help on using the changeset viewer.