Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | 6d023c9 | 1995-01-04 19:12:13 +0000 | [diff] [blame] | 2 | Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
| 3 | The Netherlands. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 4 | |
| 5 | All Rights Reserved |
| 6 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 7 | Permission to use, copy, modify, and distribute this software and its |
| 8 | documentation for any purpose and without fee is hereby granted, |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 9 | provided that the above copyright notice appear in all copies and that |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 10 | both that copyright notice and this permission notice appear in |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 11 | supporting documentation, and that the names of Stichting Mathematisch |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 12 | Centrum or CWI or Corporation for National Research Initiatives or |
| 13 | CNRI not be used in advertising or publicity pertaining to |
| 14 | distribution of the software without specific, written prior |
| 15 | permission. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 16 | |
Guido van Rossum | d266eb4 | 1996-10-25 14:44:06 +0000 | [diff] [blame] | 17 | While CWI is the initial source for this software, a modified version |
| 18 | is made available by the Corporation for National Research Initiatives |
| 19 | (CNRI) at the Internet address ftp://ftp.python.org. |
| 20 | |
| 21 | STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
| 22 | REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
| 23 | MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
| 24 | CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
| 25 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 26 | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 27 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 28 | PERFORMANCE OF THIS SOFTWARE. |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 29 | |
| 30 | ******************************************************************/ |
| 31 | |
| 32 | /* |
| 33 | * Initialization. |
| 34 | */ |
| 35 | static void _init_thread _P0() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Thread support. |
| 41 | */ |
| 42 | int 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 Rossum | e944da8 | 1994-05-23 12:43:41 +0000 | [diff] [blame] | 53 | long get_thread_ident _P0() |
| 54 | { |
| 55 | if (!initialized) |
| 56 | init_thread(); |
| 57 | } |
| 58 | |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 59 | static 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 | |
| 69 | void exit_thread _P0() |
| 70 | { |
| 71 | do_exit_thread(0); |
| 72 | } |
| 73 | |
| 74 | void _exit_thread _P0() |
| 75 | { |
| 76 | do_exit_thread(1); |
| 77 | } |
| 78 | |
| 79 | #ifndef NO_EXIT_PROG |
| 80 | static 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 | |
| 90 | void exit_prog _P1(status, int status) |
| 91 | { |
| 92 | do_exit_prog(status, 0); |
| 93 | } |
| 94 | |
| 95 | void _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 | */ |
| 104 | type_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 | |
| 115 | void free_lock _P1(lock, type_lock lock) |
| 116 | { |
| 117 | dprintf(("free_lock(%lx) called\n", (long)lock)); |
| 118 | } |
| 119 | |
| 120 | int 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 | |
| 129 | void release_lock _P1(lock, type_lock lock) |
| 130 | { |
| 131 | dprintf(("release_lock(%lx) called\n", (long)lock)); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | * Semaphore support. |
| 136 | */ |
| 137 | type_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 | |
| 147 | void free_sema _P1(sema, type_sema sema) |
| 148 | { |
| 149 | dprintf(("free_sema(%lx) called\n", (long) sema)); |
| 150 | } |
| 151 | |
Guido van Rossum | cf1474b | 1996-10-08 14:17:53 +0000 | [diff] [blame] | 152 | int down_sema _P2(sema, type_sema sema, waitflag, int waitflag) |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 153 | { |
Guido van Rossum | cf1474b | 1996-10-08 14:17:53 +0000 | [diff] [blame] | 154 | dprintf(("down_sema(%lx, %d) called\n", (long) sema, waitflag)); |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 155 | dprintf(("down_sema(%lx) return\n", (long) sema)); |
Guido van Rossum | cf1474b | 1996-10-08 14:17:53 +0000 | [diff] [blame] | 156 | return -1; |
Guido van Rossum | 2c8cb9f | 1994-05-09 15:12:46 +0000 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | void up_sema _P1(sema, type_sema sema) |
| 160 | { |
| 161 | dprintf(("up_sema(%lx)\n", (long) sema)); |
| 162 | } |