source: rtems/cpukit/posix/src/cleanuppush.c @ ffa2def

4.115
Last change on this file since ffa2def was ffa2def, checked in by R. Diez <rdiezmail-rtems@…>, on Aug 6, 2013 at 8:58:58 AM

Fix compiler warnings

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 * @file
3 *
4 * @brief Establishing Cancellation Handlers
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <pthread.h>
22#include <errno.h>
23
24#include <rtems/system.h>
25#include <rtems/score/chainimpl.h>
26#include <rtems/score/isr.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/posix/cancel.h>
30#include <rtems/posix/pthreadimpl.h>
31#include <rtems/posix/threadsup.h>
32
33/*
34 *  18.2.3.1 Establishing Cancellation Handlers, P1003.1c/Draft 10, p. 184
35 */
36
37void pthread_cleanup_push(
38  void   (*routine)( void * ),
39  void    *arg
40)
41{
42  POSIX_Cancel_Handler_control      *handler;
43  Chain_Control                     *handler_stack;
44  POSIX_API_Control                 *thread_support;
45
46  /*
47   *  The POSIX standard does not address what to do when the routine
48   *  is NULL.  It also does not address what happens when we cannot
49   *  allocate memory or anything else bad happens.
50   */
51  if ( !routine )
52    return;
53
54  _Thread_Disable_dispatch();
55  handler = _Workspace_Allocate( sizeof( POSIX_Cancel_Handler_control ) );
56
57  if ( handler ) {
58    thread_support = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ];
59
60    handler_stack = &thread_support->Cancellation_Handlers;
61
62    handler->routine = routine;
63    handler->arg = arg;
64
65    _Chain_Append( handler_stack, &handler->Node );
66  }
67  _Thread_Enable_dispatch();
68}
Note: See TracBrowser for help on using the repository browser.