source: rtems/cpukit/posix/src/keycreate.c @ 5eaf0e7

5
Last change on this file since 5eaf0e7 was 5eaf0e7, checked in by Sebastian Huber <sebastian.huber@…>, on 03/17/16 at 06:56:31

posix: Use per-thread lookup tree for POSIX Keys

Yields higher performance on SMP systems.

Close #2625.

  • Property mode set to 100644
File size: 1.0 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 * Copyright (c) 2016 embedded brains GmbH.
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/posix/keyimpl.h>
23
24#include <errno.h>
25
26/**
27 *  17.1.1 Thread-Specific Data Key Create, P1003.1c/Draft 10, p. 163
28 */
29int pthread_key_create(
30  pthread_key_t  *key,
31  void          (*destructor)( void * )
32)
33{
34  POSIX_Keys_Control  *the_key;
35
36  the_key = _POSIX_Keys_Allocate();
37
38  if ( !the_key ) {
39    _Objects_Allocator_unlock();
40    return EAGAIN;
41  }
42
43  the_key->destructor = destructor;
44  _Chain_Initialize_empty( &the_key->Key_value_pairs );
45  _Objects_Open_u32( &_POSIX_Keys_Information, &the_key->Object, 0 );
46  *key = the_key->Object.id;
47  _Objects_Allocator_unlock();
48  return 0;
49}
Note: See TracBrowser for help on using the repository browser.