source: rtems/cpukit/posix/src/keycreate.c @ b5c9064

4.115
Last change on this file since b5c9064 was b5c9064, checked in by Zhongwei Yao <ashi08104@…>, on Aug 5, 2013 at 1:20:45 PM

Unlimited objects support for POSIX keys

This patch enables unlimited model in POSIX key manger and have a decent
runtime on POSIX key searching, adding and deleting operations. Memory
overhead is lower than current implementation when the size of key and key
value becomes big.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Thread-Specific Data Key Create
5 * @ingroup POSIXAPI
6 */
7
8/*
9 * COPYRIGHT (c) 1989-2010.
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.1 Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163
33 */
34int pthread_key_create(
35  pthread_key_t  *key,
36  void          (*destructor)( void * )
37)
38{
39  POSIX_Keys_Control  *the_key;
40
41  _Thread_Disable_dispatch();
42
43  the_key = _POSIX_Keys_Allocate();
44
45  if ( !the_key ) {
46    _Thread_Enable_dispatch();
47    return EAGAIN;
48  }
49
50  the_key->destructor = destructor;
51  _Objects_Open_u32( &_POSIX_Keys_Information, &the_key->Object, 0 );
52  *key = the_key->Object.id;
53  _Thread_Enable_dispatch();
54  return 0;
55}
Note: See TracBrowser for help on using the repository browser.