Changeset 927a0a1 in rtems for cpukit/posix/src/cancelrun.c


Ignore:
Timestamp:
Dec 2, 2013, 7:33:35 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
aaaedba
Parents:
8abf006
git-author:
Sebastian Huber <sebastian.huber@…> (12/02/13 07:33:35)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/02/13 08:24:51)
Message:

posix: Use cleanup contexts on the stack

Provide support for latest Newlib <pthread.h> change. The cleanup
contexts are stored on the thread stack. This is conformant with the
POSIX requirements for the pthread_cleanup_push() and
pthread_cleanup_pop() statement pair.

Passing an invalid pointer as the routine to pthread_cleanup_push() is
now a usage error and the behaviour is undefined.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/cancelrun.c

    r8abf006 r927a0a1  
    2020
    2121#include <pthread.h>
    22 #include <errno.h>
    2322
    24 #include <rtems/system.h>
     23#include <rtems/score/thread.h>
     24#include <rtems/score/threaddispatch.h>
     25#include <rtems/posix/cancel.h>
     26#include <rtems/posix/threadsup.h>
     27
     28#ifndef HAVE_STRUCT__PTHREAD_CLEANUP_CONTEXT
     29
    2530#include <rtems/score/chainimpl.h>
    2631#include <rtems/score/isr.h>
    27 #include <rtems/score/thread.h>
    2832#include <rtems/score/wkspace.h>
    29 #include <rtems/posix/cancel.h>
    3033#include <rtems/posix/pthreadimpl.h>
    31 #include <rtems/posix/threadsup.h>
    3234
    3335void _POSIX_Threads_cancel_run(
     
    5860  }
    5961}
     62
     63#else /* HAVE_STRUCT__PTHREAD_CLEANUP_CONTEXT */
     64
     65void _POSIX_Threads_cancel_run(
     66  Thread_Control *the_thread
     67)
     68{
     69  struct _pthread_cleanup_context *context;
     70  POSIX_API_Control               *thread_support;
     71
     72  _Thread_Disable_dispatch();
     73
     74  thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];
     75  thread_support->cancelability_state = PTHREAD_CANCEL_DISABLE;
     76
     77  context = thread_support->last_cleanup_context;
     78  thread_support->last_cleanup_context = NULL;
     79
     80  _Thread_Enable_dispatch();
     81
     82  while ( context != NULL ) {
     83    ( *context->_routine )( context->_arg );
     84
     85    context = context->_previous;
     86  }
     87}
     88
     89#endif /* HAVE_STRUCT__PTHREAD_CLEANUP_CONTEXT */
Note: See TracChangeset for help on using the changeset viewer.