source: rtems/cpukit/libcsupport/src/libio_init.c @ ba74ebde

5
Last change on this file since ba74ebde was ba74ebde, checked in by Sebastian Huber <sebastian.huber@…>, on Feb 14, 2020 at 6:09:56 PM

libio: Add POSIX user environment pointer to TCB

The IO library used a POSIX key to store an optional POSIX user
environment pointer. This pulled in the POSIX keys support in every
application configuration. Add a user environment pointer to the thread
control block (TCB) instead. Applications which do not need the POSIX
user environment will just get an overhead of one pointer per thread.

Close #3882.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS LibIO Initialization
5 *  @ingroup LibIO
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/libio_.h>
22
23#include <pthread.h>
24
25#include <rtems/sysinit.h>
26#include <rtems/score/apimutex.h>
27
28/*
29 *  File descriptor Table Information
30 */
31
32static API_Mutex_Control rtems_libio_mutex = API_MUTEX_INITIALIZER( "_Libio" );
33
34void rtems_libio_lock( void )
35{
36  _API_Mutex_Lock( &rtems_libio_mutex );
37}
38
39void rtems_libio_unlock( void )
40{
41  _API_Mutex_Unlock( &rtems_libio_mutex );
42}
43
44void *rtems_libio_iop_free_head;
45
46void **rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
47
48static void rtems_libio_init( void )
49{
50    uint32_t i;
51    rtems_libio_t *iop;
52
53    if (rtems_libio_number_iops > 0)
54    {
55        iop = rtems_libio_iop_free_head = &rtems_libio_iops[0];
56        for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++)
57          iop->data1 = iop + 1;
58        iop->data1 = NULL;
59        rtems_libio_iop_free_tail = &iop->data1;
60    }
61}
62
63RTEMS_SYSINIT_ITEM(
64  rtems_libio_init,
65  RTEMS_SYSINIT_LIBIO,
66  RTEMS_SYSINIT_ORDER_MIDDLE
67);
68
69RTEMS_SYSINIT_ITEM(
70  rtems_libio_post_driver,
71  RTEMS_SYSINIT_STD_FILE_DESCRIPTORS,
72  RTEMS_SYSINIT_ORDER_MIDDLE
73);
Note: See TracBrowser for help on using the repository browser.