source: rtems/cpukit/posix/src/keydelete.c @ 12a191ae

4.104.115
Last change on this file since 12a191ae was 12a191ae, checked in by Joel Sherrill <joel.sherrill@…>, on 07/22/09 at 00:09:31

2009-07-21 Joel Sherrill <joel.sherrill@…>

  • posix/include/rtems/posix/key.h, posix/src/keycreate.c, posix/src/keydelete.c, posix/src/keyrundestructors.c: Restructure a bit to make it easier to do coverage analysis. Eliminate is_active member of control structure because it was redundant with very the key object was open or closed.
  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2007.
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 <errno.h>
17#include <limits.h>
18#include <pthread.h>
19#include <string.h>
20
21#include <rtems/system.h>
22#include <rtems/score/thread.h>
23#include <rtems/score/wkspace.h>
24#include <rtems/posix/key.h>
25
26/*PAGE
27 *
28 *  17.1.3 Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167
29 */
30
31int pthread_key_delete(
32  pthread_key_t  key
33)
34{
35  register POSIX_Keys_Control *the_key;
36  Objects_Locations            location;
37  uint32_t                     the_api;
38
39  the_key = _POSIX_Keys_Get( key, &location );
40  switch ( location ) {
41
42    case OBJECTS_LOCAL:
43      _Objects_Close( &_POSIX_Keys_Information, &the_key->Object );
44
45      for ( the_api = 1; the_api <= OBJECTS_APIS_LAST; the_api++ )
46        if ( the_key->Values[ the_api ] )
47          _Workspace_Free( the_key->Values[ the_api ] );
48
49      /*
50       *  NOTE:  The destructor is not called and it is the responsibility
51       *         of the application to free the memory.
52       */
53
54      _POSIX_Keys_Free( the_key );
55      _Thread_Enable_dispatch();
56      return 0;
57
58#if defined(RTEMS_MULTIPROCESSING)
59    case OBJECTS_REMOTE:   /* should never happen */
60#endif
61    case OBJECTS_ERROR:
62      break;
63  }
64
65  return EINVAL;
66}
Note: See TracBrowser for help on using the repository browser.