Changeset db7f70a in rtems
- Timestamp:
- 11/02/99 18:47:06 (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 68003979
- Parents:
- 43ed935
- Files:
-
- 12 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/posix/src/Makefile.in
r43ed935 rdb7f70a 18 18 19 19 # These are really in the stand but not really functional 20 BUILD_FOR_NOW_C_PIECES = aio cancelutsname20 BUILD_FOR_NOW_C_PIECES = aio utsname 21 21 22 22 ENOSYS_C_PIECES = execl execle execlp execv execve execvp fork pthreadatfork \ 23 23 wait waitpid 24 24 25 CANCEL_C_PIECES= cancel cancelrun cleanuppop cleanuppush setcancelstate \ 26 setcanceltype testcancel 27 25 28 CONDITION_VARIABLE_C_PIECES= cond condattrdestroy condattrgetpshared \ 26 29 condattrinit condattrsetpshared condbroadcast conddefaultattributes \ 27 condmp condsignal condsignalsupp condtimedwait condwait condwaitsupp 30 conddestroy condinit condmp condsignal condsignalsupp condtimedwait \ 31 condwait condwaitsupp 28 32 29 33 KEY_C_PIECES= key keycreate keydelete keygetspecific keyrundestructors \ 30 keysetspecific34 keysetspecific 31 35 32 36 MESSAGE_QUEUE_C_PIECES= mqueue mqueueclose mqueuecreatesupp mqueuedeletesupp \ … … 70 74 clockgetres clockgettime clocksetenableattr clocksettime nanosleep 71 75 72 C_PIECES = adasupp $(C ONDITION_VARIABLE_C_PIECES) \76 C_PIECES = adasupp $(CANCEL_C_PIECES) $(CONDITION_VARIABLE_C_PIECES) \ 73 77 getpid $(KEY_C_PIECES) $(MESSAGE_QUEUE_C_PIECES) \ 74 78 $(MUTEX_C_PIECES) $(PTHREAD_C_PIECES) \ -
c/src/exec/posix/src/cancel.c
r43ed935 rdb7f70a 14 14 #include <rtems/posix/pthread.h> 15 15 #include <rtems/posix/threadsup.h> 16 17 /*PAGE18 *19 * POSIX_Thread_cancel_run20 *21 */22 23 void POSIX_Thread_cancel_run(24 Thread_Control *the_thread25 )26 {27 int old_cancel_state;28 POSIX_Cancel_Handler_control *handler;29 Chain_Control *handler_stack;30 POSIX_API_Control *thread_support;31 ISR_Level level;32 33 thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];34 35 handler_stack = &thread_support->Cancellation_Handlers;36 37 old_cancel_state = thread_support->cancelability_state;38 39 thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;40 41 while ( !_Chain_Is_empty( handler_stack ) ) {42 _ISR_Disable( level );43 handler = (POSIX_Cancel_Handler_control *) _Chain_Tail( handler_stack );44 _Chain_Extract_unprotected( &handler->Node );45 _ISR_Enable( level );46 47 (*handler->routine)( handler->arg );48 49 _Workspace_Free( handler );50 }51 52 thread_support->cancelation_requested = 0;53 54 thread_support->cancelability_state = old_cancel_state;55 }56 16 57 17 /*PAGE … … 85 45 return POSIX_BOTTOM_REACHED(); 86 46 } 87 88 /*PAGE89 *90 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 18391 */92 93 int pthread_setcancelstate(94 int state,95 int *oldstate96 )97 {98 POSIX_API_Control *thread_support;99 100 if ( !oldstate )101 return EINVAL;102 103 if ( state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE )104 return EINVAL;105 106 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];107 108 *oldstate = thread_support->cancelability_state;109 thread_support->cancelability_state = state;110 111 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&112 thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&113 thread_support->cancelation_requested )114 POSIX_Thread_cancel_run( _Thread_Executing );115 116 return 0;117 }118 119 /*PAGE120 *121 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183122 */123 124 int pthread_setcanceltype(125 int type,126 int *oldtype127 )128 {129 POSIX_API_Control *thread_support;130 131 if ( !oldtype )132 return EINVAL;133 134 if ( type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS )135 return EINVAL;136 137 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];138 139 *oldtype = thread_support->cancelability_type;140 thread_support->cancelability_type = type;141 142 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&143 thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&144 thread_support->cancelation_requested )145 POSIX_Thread_cancel_run( _Thread_Executing );146 147 return 0;148 }149 150 /*PAGE151 *152 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183153 */154 155 void pthread_testcancel( void )156 {157 POSIX_API_Control *thread_support;158 159 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];160 161 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&162 thread_support->cancelation_requested )163 POSIX_Thread_cancel_run( _Thread_Executing );164 }165 166 /*PAGE167 *168 * 18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184169 */170 171 void pthread_cleanup_push(172 void (*routine)( void * ),173 void *arg174 )175 {176 POSIX_Cancel_Handler_control *handler;177 Chain_Control *handler_stack;178 POSIX_API_Control *thread_support;179 180 if ( !routine )181 return; /* XXX what to do really? */182 183 handler = _Workspace_Allocate( sizeof( POSIX_Cancel_Handler_control ) );184 185 if ( !handler )186 return; /* XXX what to do really? */187 188 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];189 190 handler_stack = &thread_support->Cancellation_Handlers;191 192 handler->routine = routine;193 handler->arg = arg;194 195 _Chain_Append( handler_stack, &handler->Node );196 }197 198 /*PAGE199 *200 * 18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184201 */202 203 void pthread_cleanup_pop(204 int execute205 )206 {207 POSIX_Cancel_Handler_control *handler;208 Chain_Control *handler_stack;209 POSIX_API_Control *thread_support;210 ISR_Level level;211 212 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];213 214 handler_stack = &thread_support->Cancellation_Handlers;215 216 if ( _Chain_Is_empty( handler_stack ) )217 return;218 219 _ISR_Disable( level );220 handler = (POSIX_Cancel_Handler_control *) _Chain_Tail( handler_stack );221 _Chain_Extract_unprotected( &handler->Node );222 _ISR_Enable( level );223 224 if ( execute )225 (*handler->routine)( handler->arg );226 227 _Workspace_Free( handler );228 } -
cpukit/posix/src/cancel.c
r43ed935 rdb7f70a 14 14 #include <rtems/posix/pthread.h> 15 15 #include <rtems/posix/threadsup.h> 16 17 /*PAGE18 *19 * POSIX_Thread_cancel_run20 *21 */22 23 void POSIX_Thread_cancel_run(24 Thread_Control *the_thread25 )26 {27 int old_cancel_state;28 POSIX_Cancel_Handler_control *handler;29 Chain_Control *handler_stack;30 POSIX_API_Control *thread_support;31 ISR_Level level;32 33 thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];34 35 handler_stack = &thread_support->Cancellation_Handlers;36 37 old_cancel_state = thread_support->cancelability_state;38 39 thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;40 41 while ( !_Chain_Is_empty( handler_stack ) ) {42 _ISR_Disable( level );43 handler = (POSIX_Cancel_Handler_control *) _Chain_Tail( handler_stack );44 _Chain_Extract_unprotected( &handler->Node );45 _ISR_Enable( level );46 47 (*handler->routine)( handler->arg );48 49 _Workspace_Free( handler );50 }51 52 thread_support->cancelation_requested = 0;53 54 thread_support->cancelability_state = old_cancel_state;55 }56 16 57 17 /*PAGE … … 85 45 return POSIX_BOTTOM_REACHED(); 86 46 } 87 88 /*PAGE89 *90 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 18391 */92 93 int pthread_setcancelstate(94 int state,95 int *oldstate96 )97 {98 POSIX_API_Control *thread_support;99 100 if ( !oldstate )101 return EINVAL;102 103 if ( state != PTHREAD_CANCEL_ENABLE && state != PTHREAD_CANCEL_DISABLE )104 return EINVAL;105 106 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];107 108 *oldstate = thread_support->cancelability_state;109 thread_support->cancelability_state = state;110 111 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&112 thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&113 thread_support->cancelation_requested )114 POSIX_Thread_cancel_run( _Thread_Executing );115 116 return 0;117 }118 119 /*PAGE120 *121 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183122 */123 124 int pthread_setcanceltype(125 int type,126 int *oldtype127 )128 {129 POSIX_API_Control *thread_support;130 131 if ( !oldtype )132 return EINVAL;133 134 if ( type != PTHREAD_CANCEL_DEFERRED && type != PTHREAD_CANCEL_ASYNCHRONOUS )135 return EINVAL;136 137 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];138 139 *oldtype = thread_support->cancelability_type;140 thread_support->cancelability_type = type;141 142 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&143 thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS &&144 thread_support->cancelation_requested )145 POSIX_Thread_cancel_run( _Thread_Executing );146 147 return 0;148 }149 150 /*PAGE151 *152 * 18.2.2 Setting Cancelability State, P1003.1c/Draft 10, p. 183153 */154 155 void pthread_testcancel( void )156 {157 POSIX_API_Control *thread_support;158 159 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];160 161 if ( thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&162 thread_support->cancelation_requested )163 POSIX_Thread_cancel_run( _Thread_Executing );164 }165 166 /*PAGE167 *168 * 18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184169 */170 171 void pthread_cleanup_push(172 void (*routine)( void * ),173 void *arg174 )175 {176 POSIX_Cancel_Handler_control *handler;177 Chain_Control *handler_stack;178 POSIX_API_Control *thread_support;179 180 if ( !routine )181 return; /* XXX what to do really? */182 183 handler = _Workspace_Allocate( sizeof( POSIX_Cancel_Handler_control ) );184 185 if ( !handler )186 return; /* XXX what to do really? */187 188 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];189 190 handler_stack = &thread_support->Cancellation_Handlers;191 192 handler->routine = routine;193 handler->arg = arg;194 195 _Chain_Append( handler_stack, &handler->Node );196 }197 198 /*PAGE199 *200 * 18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184201 */202 203 void pthread_cleanup_pop(204 int execute205 )206 {207 POSIX_Cancel_Handler_control *handler;208 Chain_Control *handler_stack;209 POSIX_API_Control *thread_support;210 ISR_Level level;211 212 thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];213 214 handler_stack = &thread_support->Cancellation_Handlers;215 216 if ( _Chain_Is_empty( handler_stack ) )217 return;218 219 _ISR_Disable( level );220 handler = (POSIX_Cancel_Handler_control *) _Chain_Tail( handler_stack );221 _Chain_Extract_unprotected( &handler->Node );222 _ISR_Enable( level );223 224 if ( execute )225 (*handler->routine)( handler->arg );226 227 _Workspace_Free( handler );228 }
Note: See TracChangeset
for help on using the changeset viewer.