1/* GNU CHILL compiler regression test file
2 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING.  If not, write to
18the Free Software Foundation, 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA.  */
20
21/* As a special exception, if you link this library with other files,
22   some of which are compiled with GCC, to produce an executable,
23   this library does not by itself cause the resulting executable
24   to be covered by the GNU General Public License.
25   This exception does not however invalidate any other reasons why
26   the executable file might be covered by the GNU General Public License.  */
27
28#ifndef __rts_h_
29#define __rts_h_
30
31typedef enum
32{
33  UNUSED,
34  Process,
35  Signal,
36  Buffer,
37  Event,
38  Synonym,
39  Exception,
40  LAST_AND_UNUSED,
41} TaskingEnum;
42
43typedef void (*EntryPoint) ();
44
45typedef struct
46{
47  char       *name;
48  short      *value;
49  int         value_defined;
50  EntryPoint  entry;
51  unsigned char /*TaskingEnum*/ type;
52} TaskingStruct;
53
54/* how an INSTANCE is implemented */
55typedef struct
56{
57  short ptype;
58  short pcopy;
59} INSTANCE;
60
61/* interface to underlaying os */
62typedef enum
63{
64  wait_wait,
65  wait_buffer_send,
66  wait_buffer_receive,
67  wait_buffer_free,
68  wait_event_delay,
69  wait_event_free,
70} Delay_Reason;
71
72extern INSTANCE __whoami ();
73extern void *__xmalloc_ ();
74
75#define THIS  __whoami()
76/* for easier changing to something different,
77   i.e. allocate_memory */
78#define MALLOC(ADDR,SIZE)  ADDR = __xmalloc_(SIZE)
79#define FREE(ADDR)         free (ADDR)
80
81/* definitions for EVENTS */
82typedef struct EVENTQUEUE
83{
84  struct EVENTQUEUE    *forward;       /* next in the list */
85  struct EVENTQUEUE   **listhead;      /* pointer to EVENT location */
86  int                   priority;      /* prio for DELAY or DELAY CASE */
87  INSTANCE              this;          /* specify the instance is delayed */
88  struct EVENTQUEUE    *startlist;     /* start of the list */
89  struct EVENTQUEUE    *chain;         /* list of all events in an DELAY CASE */
90  int                   is_continued;  /* indicates a continue action on that event */
91  INSTANCE              who_continued; /* indicates who continued */
92} Event_Queue;
93
94typedef struct
95{
96  Event_Queue     **ev;
97  unsigned long     maxqueuelength;
98} Event_Descr;
99
100/* definitions for BUFFERS */
101struct BUFFERQUEUE;
102
103typedef struct BUFFER_WAIT_QUEUE
104{
105  struct BUFFER_WAIT_QUEUE   *forward;
106  struct BUFFERQUEUE        **bufferaddr;
107  INSTANCE                    this;
108  struct BUFFER_WAIT_QUEUE   *startlist;
109  struct BUFFER_WAIT_QUEUE   *chain;
110  int                         is_sent;
111  INSTANCE                    who_sent;     /* instance which have
112					       send a buffer */
113  unsigned long               datalen;
114  void                       *dataptr;
115} Buffer_Wait_Queue;
116
117typedef struct BUFFER_SEND_QUEUE
118{
119  struct BUFFER_SEND_QUEUE   *forward;
120  int                         priority;
121  INSTANCE                    this;
122  int                         is_delayed;
123  unsigned long               datalen;
124  void                       *dataptr;
125} Buffer_Send_Queue;
126
127typedef struct BUFFERQUEUE
128{
129  Buffer_Wait_Queue    *waitqueue;
130  unsigned long         waitqueuelength;
131  Buffer_Send_Queue    *sendqueue;
132  unsigned long         sendqueuelength;
133} Buffer_Queue;
134
135typedef struct
136{
137  Buffer_Queue    **buf;
138  unsigned long     maxqueuelength;
139} Buffer_Descr;
140
141/* descriptor for data */
142typedef struct
143{
144  void         *ptr;
145  int           length;
146} Data_Descr;
147
148/* time format runtime delivers */
149typedef struct
150{
151    unsigned long	secs;
152    unsigned long	nanosecs;
153} RtsTime;
154
155extern void __rtstime (RtsTime *t);
156extern int __delay_this (Delay_Reason reason, RtsTime *t, char *file, int lineno);
157extern void __continue_that (INSTANCE ins, int prio, char *file, int lineno);
158
159#endif /* __rts_h_ */
160