source: rtems/cpukit/posix/src/keydelete.c @ be1b8a7

4.115
Last change on this file since be1b8a7 was 2d2352b, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/13 at 09:48:57

score: Add and use _Objects_Put()

Add and use _Objects_Put_without_thread_dispatch(). These two functions
pair with the _Objects_Get() function. This helps to introduce object
specific SMP locks to avoid lock contention.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief Deletes Thread-specific Data Key Previously Returned by keycreate.c
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <errno.h>
22#include <limits.h>
23#include <pthread.h>
24#include <string.h>
25
26#include <rtems/system.h>
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/posix/key.h>
30
31/*
32 *  17.1.3 Thread-Specific Data Key Deletion, P1003.1c/Draft 10, p. 167
33 */
34int pthread_key_delete(
35  pthread_key_t  key
36)
37{
38  POSIX_Keys_Control *the_key;
39  Objects_Locations   location;
40
41  the_key = _POSIX_Keys_Get( key, &location );
42  switch ( location ) {
43
44    case OBJECTS_LOCAL:
45      _Objects_Close( &_POSIX_Keys_Information, &the_key->Object );
46
47      _POSIX_Keys_Free_memory( the_key );
48
49      /*
50       *  NOTE:  The destructor is not called and it is the responsibility
51       *         of the application to free the memory.
52       */
53      _POSIX_Keys_Free( the_key );
54      _Objects_Put( &the_key->Object );
55      return 0;
56
57#if defined(RTEMS_MULTIPROCESSING)
58    case OBJECTS_REMOTE:   /* should never happen */
59#endif
60    case OBJECTS_ERROR:
61      break;
62  }
63
64  return EINVAL;
65}
Note: See TracBrowser for help on using the repository browser.