MacOS needs a ${CACHEDIR}/cores/ for core dumps to work
[arla.git] / rx / rx_event.h
blob562b1cd2ac9ce95c70bedc68ac5f0578e8755e6b
1 /*
2 ****************************************************************************
3 * Copyright IBM Corporation 1988, 1989 - All Rights Reserved *
4 * *
5 * Permission to use, copy, modify, and distribute this software and its *
6 * documentation for any purpose and without fee is hereby granted, *
7 * provided that the above copyright notice appear in all copies and *
8 * that both that copyright notice and this permission notice appear in *
9 * supporting documentation, and that the name of IBM not be used in *
10 * advertising or publicity pertaining to distribution of the software *
11 * without specific, written prior permission. *
12 * *
13 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL *
14 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL IBM *
15 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY *
16 * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER *
17 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING *
18 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 ****************************************************************************
22 /* Event package */
24 #ifndef _EVENT_
25 #define _EVENT_
27 #ifdef KERNEL
28 #include "../rx/rx_queue.h"
29 #include "../rx/rx_clock.h"
30 #else /* KERNEL */
31 #include "rx_queue.h"
32 #include "rx_clock.h"
33 #endif /* KERNEL */
36 * An event is something that will happen at (or after) a specified clock
37 * time, unless cancelled prematurely. The user routine (*func)() is called
38 * with arguments (event, arg, arg1) when the event occurs. Warnings:
39 * (1) The user supplied routine should NOT cause process preemption.
40 * (2) The event passed to the user is still on the event queue at that time.
41 * The user must not remove (event_Cancel) it explicitly, but the user may
42 * remove or schedule any OTHER event at this time.
45 struct rxevent {
46 struct rx_queue junk; /* Events are queued */
47 struct clock eventTime; /* When this event times out (in
48 * clock.c units) */
49 void (*func)(); /* Function to call when this expires */
50 void *arg; /* Argument to the function */
51 void *arg1; /* Another argument */
55 * Some macros to make macros more reasonable (this allows a block to be
56 * used within a macro which does not cause if statements to screw up).
57 * That is, you can use "if (...) macro_name(); else ...;" without having
58 * things blow up on the semi-colon.
61 #ifndef BEGIN
62 #define BEGIN do {
63 #define END } while(0)
64 #endif
67 * This routine must be called to initialize the event package.
68 * nEvents is the number of events to allocate in a batch whenever more
69 * are needed. If this is 0, a default number (10) will be allocated.
71 void rxevent_Init(int, void (*)());
74 * Arrange for the indicated event at the appointed time. When is a
75 * "struct clock", in the clock.c time base
77 struct rxevent *rxevent_Post(struct clock*, void (*)(), void*, void*);
80 * Remove the indicated event from the event queue. The event must be
81 * pending. Also see the warning, above. The event pointer supplied is
82 * zeroed.
84 void rxevent_Cancel_1(struct rxevent *);
86 #define rxevent_Cancel(event_ptr) \
87 BEGIN \
88 if (event_ptr) { \
89 rxevent_Cancel_1(event_ptr); \
90 event_ptr = (struct rxevent *) 0; \
91 } \
92 END
95 * The actions specified for each event that has reached the current clock
96 * time will be taken. The current time returned by GetTime is used
97 * (warning: this may be an old time if the user has not called clock_NewTime)
99 int rxevent_RaiseEvents(struct clock *);
101 #endif /* _EVENT_ */