source: rtems/cpukit/posix/src/cancel.c @ f8437c8

4.104.114.95
Last change on this file since f8437c8 was f8437c8, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 15:23:12

Convert to "bool".

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <pthread.h>
17#include <errno.h>
18
19#include <rtems/system.h>
20#include <rtems/score/chain.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/posix/cancel.h>
25#include <rtems/posix/pthread.h>
26#include <rtems/posix/threadsup.h>
27
28/*PAGE
29 *
30 *  18.2.1 Canceling Execution of a Thread, P1003.1c/Draft 10, p. 181
31 */
32
33int pthread_cancel(
34  pthread_t  thread
35)
36{
37  Thread_Control     *the_thread;
38  POSIX_API_Control  *thread_support;
39  Objects_Locations   location;
40  bool                cancel = false;
41
42  /*
43   *  Don't even think about deleting a resource from an ISR.
44   */
45
46  if ( _ISR_Is_in_progress() )
47    return EPROTO;
48
49  the_thread = _POSIX_Threads_Get( thread, &location );
50  switch ( location ) {
51
52    case OBJECTS_LOCAL:
53      thread_support = the_thread->API_Extensions[ THREAD_API_POSIX ];
54
55      thread_support->cancelation_requested = 1;
56
57      if (thread_support->cancelability_state == PTHREAD_CANCEL_ENABLE &&
58          thread_support->cancelability_type == PTHREAD_CANCEL_ASYNCHRONOUS)
59        cancel = true;
60
61      _Thread_Enable_dispatch();
62      if ( cancel )
63        _POSIX_Thread_Exit( the_thread, PTHREAD_CANCELED );
64      return 0;
65
66#if defined(RTEMS_MULTIPROCESSING)
67    case OBJECTS_REMOTE:
68#endif
69    case OBJECTS_ERROR:
70      break;
71  }
72
73  return EINVAL;
74}
Note: See TracBrowser for help on using the repository browser.