1 /* Copyright (C) 1995,1996 Robert de Bath <rdebath@cix.compulink.co.uk>
2 * This file is part of the Linux-8086 C library and is distributed
3 * under the GNU Library General Public License.
13 /* This only for the various unix version */
16 /********************** Function time ************************************/
23 if( gettimeofday(&rv
, (void*)0) < 0 ) return -1;
24 if(where
) *where
= rv
.tv_sec
;
29 /********************** Function abort ************************************/
35 signal(SIGABRT
, SIG_DFL
);
36 kill(SIGABRT
, getpid()); /* Correct one */
37 pause(); /* System may just schedule */
38 signal(SIGKILL
, SIG_DFL
);
39 kill(SIGKILL
, getpid()); /* Can't trap this! */
40 __exit(255); /* WHAT!! */
44 /********************** Function wait ************************************/
51 return wait4(-1, status
, 0, (void*)0);
55 /********************** Function wait3 **************************************/
59 wait3(status
, opts
, usage
)
62 struct rusage
* usage
;
64 return wait4(-1, status
, opts
, usage
);
68 /********************** Function waitpid ************************************/
72 waitpid(pid
, status
, opts
)
77 return wait4(pid
, status
, opts
, (void*)0);
81 /********************** Function killpg ************************************/
92 return kill(-pid
, sig
);
98 /********************** Function setpgrp ************************************/
108 /********************** Function sleep ************************************/
113 /* This uses SIGALRM, it does keep the previous alarm call but will lose
114 * any alarms that go off during the sleep
117 static void alrm() { }
119 unsigned int sleep(seconds
)
120 unsigned int seconds
;
122 void (*last_alarm
)();
123 unsigned int prev_sec
;
126 if( prev_sec
<= seconds
) prev_sec
= 1; else prev_sec
-= seconds
;
128 last_alarm
= signal(SIGALRM
, alrm
);
131 seconds
= alarm(prev_sec
);
132 signal(SIGALRM
, last_alarm
);
137 /* Is this a better way ? If we have select of course :-) */
140 unsigned int seconds
;
142 struct timeval timeout
;
143 time_t start
= time((void*)0);
144 timeout
.tv_sec
= seconds
;
146 select(1, NULL
, NULL
, NULL
, &timeout
);
147 return seconds
- (time((void*)0) - start
);
153 /********************** Function usleep ************************************/
158 unsigned long useconds
;
160 struct timeval timeout
;
161 timeout
.tv_sec
= useconds
%1000000L;
162 timeout
.tv_usec
= useconds
/1000000L;
163 select(1, NULL
, NULL
, NULL
, &timeout
);
167 /********************** Function mkfifo ************************************/
175 return mknod(path
, mode
| S_IFIFO
, 0);
179 /********************** THE END ********************************************/
181 #endif /* __unix__ */