source: rtems/cpukit/posix/src/keyrundestructors.c @ 39cefdd

4.104.114.84.9
Last change on this file since 39cefdd was 39cefdd, checked in by Ralf Corsepius <ralf.corsepius@…>, on Mar 23, 2004 at 1:07:29 PM

2004-03-23 Ralf Corsepius <ralf_corsepius@…>

  • posix/include/rtems/posix/cond.h, posix/include/rtems/posix/intr.h, posix/include/rtems/posix/key.h, posix/include/rtems/posix/mqueue.h, posix/include/rtems/posix/mutex.h, posix/include/rtems/posix/pthread.h, posix/include/rtems/posix/semaphore.h, posix/include/rtems/posix/threadsup.h, posix/include/rtems/posix/timer.h, posix/src/cond.c, posix/src/intr.c, posix/src/key.c, posix/src/keycreate.c, posix/src/keydelete.c, posix/src/keygetspecific.c, posix/src/keyrundestructors.c, posix/src/keysetspecific.c, posix/src/killinfo.c, posix/src/mqueue.c, posix/src/mqueuerecvsupp.c, posix/src/mqueuesendsupp.c, posix/src/mqueuetranslatereturncode.c, posix/src/mutex.c, posix/src/posixintervaltotimespec.c, posix/src/posixtimespecsubtract.c, posix/src/psignal.c, posix/src/pthread.c, posix/src/ptimer1.c, posix/src/semaphore.c, posix/src/sysconf.c: Convert to using c99 fixed size types.
  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  $Id$
3 */
4
5#if HAVE_CONFIG_H
6#include "config.h"
7#endif
8
9#include <errno.h>
10#include <limits.h>
11#include <pthread.h>
12#include <string.h>
13
14#include <rtems/system.h>
15#include <rtems/score/thread.h>
16#include <rtems/score/wkspace.h>
17#include <rtems/posix/key.h>
18
19/*PAGE
20 *
21 *  _POSIX_Keys_Run_destructors
22 *
23 *  17.1.1 Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163
24 *
25 *  NOTE:  This is the routine executed when a thread exits to
26 *         run through all the keys and do the destructor action.
27 */
28
29void _POSIX_Keys_Run_destructors(
30  Thread_Control *thread
31)
32{
33  uint32_t             index;
34  uint32_t             pthread_index;
35  uint32_t             pthread_class;
36  uint32_t             iterations;
37  boolean              are_all_null;
38  POSIX_Keys_Control  *the_key;
39  void                *value;
40
41  pthread_index = _Objects_Get_index( thread->Object.id );
42  pthread_class = _Objects_Get_class( thread->Object.id );
43
44  iterations = 0;
45
46  for ( ; ; ) {
47
48    are_all_null = TRUE;
49
50    for ( index=1 ; index <= _POSIX_Keys_Information.maximum ; index++ ) {
51
52      the_key = (POSIX_Keys_Control *) 
53        _POSIX_Keys_Information.local_table[ index ];
54     
55      if ( the_key && the_key->is_active && the_key->destructor ) {
56        value = the_key->Values[ pthread_class ][ pthread_index ];
57        if ( value ) {
58          (*the_key->destructor)( value );
59          if ( the_key->Values[ pthread_class ][ pthread_index ] )
60            are_all_null = FALSE;
61        }
62      }
63    }
64
65    if ( are_all_null == TRUE ) 
66      return;
67
68    iterations++;
69
70    /*
71     *  The standard allows one to not do this and thus go into an infinite
72     *  loop.  It seems rude to unnecessarily lock up a system.
73     *
74     *  Reference: 17.1.1.2 P1003.1c/Draft 10, p. 163, line 99.
75     */
76
77    if ( iterations >= PTHREAD_DESTRUCTOR_ITERATIONS )
78      return; 
79  }
80}
Note: See TracBrowser for help on using the repository browser.