OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [posix/] [src/] [keyrundestructors.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 *  $Id: keyrundestructors.c,v 1.2 2001-09-27 11:59:17 chris Exp $
3
 */
4
 
5
#include <errno.h>
6
#include <limits.h>
7
#include <pthread.h>
8
#include <string.h>
9
 
10
#include <rtems/system.h>
11
#include <rtems/score/thread.h>
12
#include <rtems/score/wkspace.h>
13
#include <rtems/posix/key.h>
14
 
15
#ifndef PTHREAD_DESTRUCTOR_ITERATIONS
16
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
17
#endif
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
 
29
void _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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.