unistd.h
Go to the documentation of this file.
1 
6 /*
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.0 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License
10  * at http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS"
13  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14  * the License for the specific language governing rights and
15  * limitations under the License.
16  *
17  * The Original Code is legOS code, released October 17, 1999.
18  *
19  * The Initial Developer of the Original Code is Markus L. Noga.
20  * Portions created by Markus L. Noga are Copyright (C) 1999
21  * Markus L. Noga. All Rights Reserved.
22  *
23  * Contributor(s): Markus L. Noga <markus@noga.de>
24  */
25 
26 #ifndef __unistd_h__
27 #define __unistd_h__
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <tm.h>
34 #include <time.h>
35 
37 //
38 // Functions
39 //
41 
42 #ifdef CONF_TM
43 
52 extern tid_t execi(int (*code_start) (int, char **), int argc, char **argv,
53  priority_t priority, size_t stack_size);
54 
58 extern void shutdown_task(tid_t tid);
59 
64 extern void shutdown_tasks(tflags_t flags);
65 
70 extern void kill(tid_t tid);
71 
76 extern void killall(priority_t p);
77 
81 extern void exit(int code) __attribute__((noreturn));
82 
83 //
85 //
86 extern void yield(void);
87 
94 extern wakeup_t wait_event(wakeup_t(*wakeup) (wakeup_t), wakeup_t data);
95 
96 
98 
102 extern unsigned int sleep(unsigned int sec);
103 
109 extern unsigned int msleep(unsigned int msec);
110 
111 #else
112 extern inline wakeup_t wait_event(wakeup_t(*wakeup) (wakeup_t), wakeup_t data)
113 {
114  wakeup_t res;
115 
116  while (!(res = wakeup(data)))
117  /* wait */;
118  return res;
119 }
120 
121 // Replacement for sleep/msleep if no TM
122 #define sleep(s) delay(1000*(s))
123 #define msleep(s) delay(s)
124 #endif
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif // __unistd_h__
Interface: Time-related data and types.
unsigned char priority_t
task priority type
Definition: tm.h:48
void shutdown_tasks(tflags_t flags)
signed int tid_t
task id type
Definition: tm.h:143
void killall(priority_t p)
unsigned long wakeup_t
wakeup data area type
Definition: tm.h:57
tid_t execi(int(*code_start)(int, char **), int argc, char **argv, priority_t priority, size_t stack_size)
void shutdown_task(tid_t tid)
Interface: task management.
volatile unsigned char tflags_t
task flags type
Definition: tm.h:46
void kill(tid_t tid)
void exit(int code) __attribute__((noreturn))
unsigned int sleep(unsigned int sec)
delay execution allowing other tasks to run
void yield(void)
current task yields the rest of timeslice
unsigned int msleep(unsigned int msec)
wakeup_t wait_event(wakeup_t(*wakeup)(wakeup_t), wakeup_t data)

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS C by doxygen 1.8.11