_POSIX_TIMERS & _POSIX_THREAD_CPUTIME 在 unistd.h

头文件定义,但并未包含。之前写法不正确,可以工作只是巧合。
现改为,默认使用 clock_gettime,当为 Max OSX 平台时,使用兼容方法。
This commit is contained in:
Yecheng Fu
2012-12-20 16:25:20 +08:00
parent 5d83155334
commit 5eb87dc769
3 changed files with 11 additions and 11 deletions

View File

@@ -32,9 +32,9 @@ struct stat {
static void
_stat_begin(struct stat *S, struct timespec *ti) {
S->count++;
#if defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME)
#if !defined(__APPLE__)
clock_gettime(CLOCK_THREAD_CPUTIME_ID, ti);
#elif defined(__APPLE__)
#else
struct task_thread_times_info aTaskInfo;
mach_msg_type_number_t aTaskInfoCount = TASK_THREAD_TIMES_INFO_COUNT;
assert(KERN_SUCCESS == task_info(mach_task_self(), TASK_THREAD_TIMES_INFO, (task_info_t )&aTaskInfo, &aTaskInfoCount));