alarm.c

来自「ucLinux is a very good embeded sytem. Mo」· C语言 代码 · 共 35 行

C
35
字号
/* vi: set sw=4 ts=4: *//* * alarm() for uClibc * * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org> * * GNU Library General Public License (LGPL) version 2 or later. */#include "syscalls.h"#include <unistd.h>#ifdef __NR_alarm_syscall1(unsigned int, alarm, unsigned int, seconds);#else#include <sys/time.h>unsigned int alarm(unsigned int seconds){	struct itimerval old, new;	unsigned int retval;	new.it_value.tv_usec = 0;	new.it_interval.tv_sec = 0;	new.it_interval.tv_usec = 0;	new.it_value.tv_sec = (long int) seconds;	if (setitimer(ITIMER_REAL, &new, &old) < 0) {		return 0;	}	retval = old.it_value.tv_sec;	if (old.it_value.tv_usec) {		++retval;	}	return retval;}#endif

⌨️ 快捷键说明

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