source: rtems/c/src/exec/posix/src/keyrundestructors.c @ 089abb6d

4.104.114.84.95
Last change on this file since 089abb6d was f42b726, checked in by Joel Sherrill <joel.sherrill@…>, on 01/24/01 at 14:17:28

2001-01-24 Ralf Corsepius <corsepiu@…>

  • configure.in: Add src/config.h
  • src/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • src/.cvsignore: Add config.h and stamp-h
  • src/*.c: Add config.h support.
  • 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  unsigned32           index;
34  unsigned32           pthread_index;
35  unsigned32           pthread_class;
36  unsigned32           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.