blob: 754eb26bbece1f702be349b7d1ce73baee924de3 [file] [log] [blame]
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00001/***********************************************************
Guido van Rossum6d023c91995-01-04 19:12:13 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00004
5 All Rights Reserved
6
Guido van Rossumd266eb41996-10-25 14:44:06 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +00009provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000010both that copyright notice and this permission notice appear in
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000011supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000012Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000016
Guido van Rossumd266eb41996-10-25 14:44:06 +000017While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000029
30******************************************************************/
31
32/*
33 * Initialization.
34 */
35static void _init_thread _P0()
36{
37}
38
39/*
40 * Thread support.
41 */
42int start_new_thread _P2(func, void (*func) _P((void *)), arg, void *arg)
43{
44 int success = 0; /* init not needed when SOLARIS_THREADS and */
45 /* C_THREADS implemented properly */
46
47 dprintf(("start_new_thread called\n"));
48 if (!initialized)
49 init_thread();
50 return success < 0 ? 0 : 1;
51}
52
Guido van Rossume944da81994-05-23 12:43:41 +000053long get_thread_ident _P0()
54{
55 if (!initialized)
56 init_thread();
57}
58
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +000059static void do_exit_thread _P1(no_cleanup, int no_cleanup)
60{
61 dprintf(("exit_thread called\n"));
62 if (!initialized)
63 if (no_cleanup)
64 _exit(0);
65 else
66 exit(0);
67}
68
69void exit_thread _P0()
70{
71 do_exit_thread(0);
72}
73
74void _exit_thread _P0()
75{
76 do_exit_thread(1);
77}
78
79#ifndef NO_EXIT_PROG
80static void do_exit_prog _P2(status, int status, no_cleanup, int no_cleanup)
81{
82 dprintf(("exit_prog(%d) called\n", status));
83 if (!initialized)
84 if (no_cleanup)
85 _exit(status);
86 else
87 exit(status);
88}
89
90void exit_prog _P1(status, int status)
91{
92 do_exit_prog(status, 0);
93}
94
95void _exit_prog _P1(status, int status)
96{
97 do_exit_prog(status, 1);
98}
99#endif /* NO_EXIT_PROG */
100
101/*
102 * Lock support.
103 */
104type_lock allocate_lock _P0()
105{
106
107 dprintf(("allocate_lock called\n"));
108 if (!initialized)
109 init_thread();
110
111 dprintf(("allocate_lock() -> %lx\n", (long)lock));
112 return (type_lock) lock;
113}
114
115void free_lock _P1(lock, type_lock lock)
116{
117 dprintf(("free_lock(%lx) called\n", (long)lock));
118}
119
120int acquire_lock _P2(lock, type_lock lock, waitflag, int waitflag)
121{
122 int success;
123
124 dprintf(("acquire_lock(%lx, %d) called\n", (long)lock, waitflag));
125 dprintf(("acquire_lock(%lx, %d) -> %d\n", (long)lock, waitflag, success));
126 return success;
127}
128
129void release_lock _P1(lock, type_lock lock)
130{
131 dprintf(("release_lock(%lx) called\n", (long)lock));
132}
133
134/*
135 * Semaphore support.
136 */
137type_sema allocate_sema _P1(value, int value)
138{
139 dprintf(("allocate_sema called\n"));
140 if (!initialized)
141 init_thread();
142
143 dprintf(("allocate_sema() -> %lx\n", (long) sema));
144 return (type_sema) sema;
145}
146
147void free_sema _P1(sema, type_sema sema)
148{
149 dprintf(("free_sema(%lx) called\n", (long) sema));
150}
151
Guido van Rossumcf1474b1996-10-08 14:17:53 +0000152int down_sema _P2(sema, type_sema sema, waitflag, int waitflag)
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +0000153{
Guido van Rossumcf1474b1996-10-08 14:17:53 +0000154 dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag));
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +0000155 dprintf(("down_sema(%lx) return\n", (long) sema));
Guido van Rossumcf1474b1996-10-08 14:17:53 +0000156 return -1;
Guido van Rossum2c8cb9f1994-05-09 15:12:46 +0000157}
158
159void up_sema _P1(sema, type_sema sema)
160{
161 dprintf(("up_sema(%lx)\n", (long) sema));
162}