📄 2-1.c
字号:
/* * Copyright (c) 2002, Intel Corporation. All rights reserved. * Created by: julie.n.fleischer REMOVE-THIS AT intel DOT com * This file is licensed under the GPL license. For the full content * of this license, see the COPYING file at the top level of this * source tree. * Test that timer_create() returns a unique timer ID for the current * process. * For this test, signal SIGALRM will be used, clock CLOCK_REALTIME * will be used. */#include <time.h>#include <signal.h>#include "compat.h"#define PASS 0#define FAIL 1#define UNRESOLVED 2#define NUMTESTS 3009 // 3009 appears to be max allowable timerstimer_t tid;int tids[NUMTESTS];int init_module(void){ struct sigevent ev; int i,j; ev.sigev_notify = SIGEV_SIGNAL; ev.sigev_signo = SIGALRM; for (i=0; i<NUMTESTS;i++) { if (timer_create(CLOCK_REALTIME, &ev, &tid) != 0) { perror("timer_create() did not return success\n"); return UNRESOLVED; } tids[i] = tid->id; for (j=0; j<i; j++){ if (tids[j]== tid->id){ printf("Duplicate tid found %d\n", tid); printf("Test FAILED\n"); return FAIL; } } } printf("No duplicate tids found\n"); printf("Test PASSED\n"); return PASS;} void cleanup_module(void){ timer_delete(tid);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -