6-1.c

来自「fsmlabs的real time linux的内核」· C语言 代码 · 共 58 行

C
58
字号
/*    * 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_gettime() sets errno = EINVAL if no timers have been * created yet and it is called with a bogus timer ID. */#include <time.h>#include <errno.h>#include "compat.h"#include "posixtest.h"// RTLinux has not memory protection#define BOGUSTID (PAGE_OFFSET+9999)pthread_t th;void *th_code(void *arg){	timer_t tid;	struct itimerspec its;	tid = BOGUSTID;	if (timer_gettime(tid, &its) == -1) {		if (EINVAL == errno) {			printf("Test PASSED\n");			return PTS_PASS;		} else {			printf("returned -1, but errno not set\n");			return PTS_FAIL;		}	} else {		printf("timer_settime() did not return failure\n");		return PTS_UNRESOLVED;	}	printf("This code should not be executed\n");	return PTS_UNRESOLVED;}int init_module(void){  int err=0;  err=pthread_create(&th,NULL,th_code,0);  return err;}void cleanup_module(void){  pthread_delete_np(th);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?