1 /*
2 Low Level Interface Library
3
4 Copyright 1983-2000 Green Hills Software,Inc.
5
6 * This program is the property of Green Hills Software, Inc,
7 * its contents are proprietary information and no part of it
8 * is to be disclosed to anyone except employees of Green Hills
9 * Software, Inc., or as agreed in writing signed by the President
10 * of Green Hills Software, Inc.
11 */
12
13 #include "indos.h"
14 #include <signal.h>
15
16 #if defined(EMBEDDED)
17
18 /******************************************************************************/
19 /* __ualarmhandler is an interrupt procedure for dispatching alarms */
20 /******************************************************************************/
21 #if 0 && defined(__ARM)
22 /* This is an example of how to insert this handler into the ARM IRQ vector */
23 #if defined(__THUMB_AWARE) && defined(__THUMB)
24 # pragma ghs nothumb
25 #endif /* defined(__THUMB_AWARE) && defined(__THUMB) */
26 static void __ualarmhandler(void) {
27 raise(SIGALRM);
28 }
29 #pragma intvect __ualarmhandler 0x18
30 #if defined(__THUMB_AWARE) && defined(__THUMB)
31 # pragma ghs thumb
32 #endif /* defined(__THUMB_AWARE) && defined(__THUMB) */
33 #else
34
__ualarmhandler(void)35 static void __ualarmhandler(void) {
36 #pragma ghs interrupt
37 raise(SIGALRM);
38 }
39
40 #endif
41
42 /******************************************************************************/
43 /* unsigned int ualarm(unsigned int value, unsigned int interval); */
44 /* ualarm arranges for a SIGALRM to be delivered in _value_ microseconds and */
45 /* then every _interval_ microseconds thereafter, like the BSD ualarm() call.*/
46 /* If the environment does not support this facility, return ~0L. */
47 /* */
48 /* WARNING: _interval_ is not supported at this time and is ignored. */
49 /******************************************************************************/
50
ualarm(unsigned int value,unsigned int interval)51 unsigned int ualarm(unsigned int value, unsigned int interval) {
52 #pragma ghs nowarning 1547 /* Syscall prototypes might not match */
53 (void) __ghs_syscall(SYSCALL_HANDLER, __ualarmhandler);
54 return __ghs_syscall(SYSCALL_TIMEOUT, value);
55 #pragma ghs endnowarning 1547
56 }
57
58 /******************************************************************************/
59 /* unsigned int alarm(unsigned int seconds); */
60 /* ualarm arranges for a SIGALRM to be delivered in _seconds_ seconds. */
61 /* If the environment does not support this facility, return ~0. */
62 /******************************************************************************/
alarm(unsigned int seconds)63 unsigned int alarm(unsigned int seconds) {
64 return ualarm(seconds*1000000, 0);
65 }
66 #else
67 int alarm_empty_file_is_illegal;
68 #endif /* defined(EMBEDDED) */
69