Changeset 391 for python/trunk/Python/thread_cthread.h
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Python/thread_cthread.h
r2 r391 15 15 { 16 16 #ifndef HURD_C_THREADS 17 18 19 cthread_init(); 17 /* Roland McGrath said this should not be used since this is 18 done while linking to threads */ 19 cthread_init(); 20 20 #else 21 21 /* do nothing */ 22 22 ; 23 23 #endif 24 24 } … … 30 30 PyThread_start_new_thread(void (*func)(void *), void *arg) 31 31 { 32 int success = 0;/* init not needed when SOLARIS_THREADS and */33 32 int success = 0; /* init not needed when SOLARIS_THREADS and */ 33 /* C_THREADS implemented properly */ 34 34 35 36 37 38 39 40 41 42 35 dprintf(("PyThread_start_new_thread called\n")); 36 if (!initialized) 37 PyThread_init_thread(); 38 /* looks like solaris detaches the thread to never rejoin 39 * so well do it here 40 */ 41 cthread_detach(cthread_fork((cthread_fn_t) func, arg)); 42 return success < 0 ? -1 : 0; 43 43 } 44 44 … … 46 46 PyThread_get_thread_ident(void) 47 47 { 48 if (!initialized) 49 PyThread_init_thread(); 50 return (long) cthread_self(); 51 } 52 53 static void 54 do_PyThread_exit_thread(int no_cleanup) 55 { 56 dprintf(("PyThread_exit_thread called\n")); 57 if (!initialized) 58 if (no_cleanup) 59 _exit(0); 60 else 61 exit(0); 62 cthread_exit(0); 48 if (!initialized) 49 PyThread_init_thread(); 50 return (long) cthread_self(); 63 51 } 64 52 … … 66 54 PyThread_exit_thread(void) 67 55 { 68 do_PyThread_exit_thread(0); 56 dprintf(("PyThread_exit_thread called\n")); 57 if (!initialized) 58 exit(0); 59 cthread_exit(0); 69 60 } 70 71 void72 PyThread__exit_thread(void)73 {74 do_PyThread_exit_thread(1);75 }76 77 #ifndef NO_EXIT_PROG78 static79 void do_PyThread_exit_prog(int status, int no_cleanup)80 {81 dprintf(("PyThread_exit_prog(%d) called\n", status));82 if (!initialized)83 if (no_cleanup)84 _exit(status);85 else86 exit(status);87 if (no_cleanup)88 _exit(status);89 else90 exit(status);91 }92 93 void94 PyThread_exit_prog(int status)95 {96 do_PyThread_exit_prog(status, 0);97 }98 99 void100 PyThread__exit_prog(int status)101 {102 do_PyThread_exit_prog(status, 1);103 }104 #endif /* NO_EXIT_PROG */105 61 106 62 /* … … 110 66 PyThread_allocate_lock(void) 111 67 { 112 68 mutex_t lock; 113 69 114 115 116 70 dprintf(("PyThread_allocate_lock called\n")); 71 if (!initialized) 72 PyThread_init_thread(); 117 73 118 119 120 121 122 123 124 125 74 lock = mutex_alloc(); 75 if (mutex_init(lock)) { 76 perror("mutex_init"); 77 free((void *) lock); 78 lock = 0; 79 } 80 dprintf(("PyThread_allocate_lock() -> %p\n", lock)); 81 return (PyThread_type_lock) lock; 126 82 } 127 83 … … 129 85 PyThread_free_lock(PyThread_type_lock lock) 130 86 { 131 132 87 dprintf(("PyThread_free_lock(%p) called\n", lock)); 88 mutex_free(lock); 133 89 } 134 90 … … 136 92 PyThread_acquire_lock(PyThread_type_lock lock, int waitflag) 137 93 { 138 94 int success = FALSE; 139 95 140 141 if (waitflag) {/* blocking */142 143 144 } else {/* non blocking */145 146 147 148 96 dprintf(("PyThread_acquire_lock(%p, %d) called\n", lock, waitflag)); 97 if (waitflag) { /* blocking */ 98 mutex_lock((mutex_t)lock); 99 success = TRUE; 100 } else { /* non blocking */ 101 success = mutex_try_lock((mutex_t)lock); 102 } 103 dprintf(("PyThread_acquire_lock(%p, %d) -> %d\n", lock, waitflag, success)); 104 return success; 149 105 } 150 106 … … 152 108 PyThread_release_lock(PyThread_type_lock lock) 153 109 { 154 155 110 dprintf(("PyThread_release_lock(%p) called\n", lock)); 111 mutex_unlock((mutex_t )lock); 156 112 }
Note:
See TracChangeset
for help on using the changeset viewer.