source: rtems/cpukit/posix/src/keyrundestructors.c @ 860c34e

4.104.114.95
Last change on this file since 860c34e was 1d0efc10, checked in by Joel Sherrill <joel.sherrill@…>, on 11/06/07 at 21:39:23

2007-11-06 Joel Sherrill <joel.sherrill@…>

PR 1266/cpukit

  • posix/src/keycreate.c, posix/src/keyrundestructors.c: Use API instead of class for key indexing.
  • 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             thread_index;
35  uint32_t             thread_api;
36  uint32_t             iterations;
37  boolean              are_all_null;
38  POSIX_Keys_Control  *the_key;
39  void                *value;
40
41  thread_index = _Objects_Get_index( thread->Object.id );
42  thread_api   = _Objects_Get_API( 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[ thread_api ][ thread_index ];
57        if ( value ) {
58          (*the_key->destructor)( value );
59          if ( the_key->Values[ thread_api ][ thread_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.