source: rtems/cpukit/libcsupport/src/newlibc_reent.c @ fe09d8d

4.11
Last change on this file since fe09d8d was fe09d8d, checked in by Chris Johns <chrisj@…>, on 02/14/20 at 04:16:46

libcsupport/newlib: Call newlib's sinit to force reent initialisation

  • Newlib overtites any FILE pointers set in stdin, stdout or stderr.

Closes #3870

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Newlib Support
5 *  @ingroup libcsupport
6 */
7
8/*
9 *  COPYRIGHT (c) 1994 by Division Incorporated
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 *
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems.h>
22
23#if defined(RTEMS_NEWLIB)
24
25#include <sys/reent.h>
26#include <stdlib.h>
27#include <string.h>
28
29#include <rtems/libcsupport.h>
30#include <rtems/score/threadimpl.h>
31#include <rtems/score/wkspace.h>
32
33bool newlib_create_hook(
34  rtems_tcb *current_task __attribute__((unused)),
35  rtems_tcb *creating_task
36)
37{
38#if !defined(__DYNAMIC_REENT__)
39  if (_Thread_libc_reent == 0)
40  {
41    _REENT = _GLOBAL_REENT;
42
43    _Thread_Set_libc_reent (&_REENT);
44  }
45#endif
46
47  extern void __sinit (struct _reent *s);
48  struct _reent *reent = (struct _reent *) creating_task->libc_reent;
49  _REENT_INIT_PTR((reent)); /* GCC extension: structure constants */
50  __sinit( reent );
51
52  return true;
53}
54
55void newlib_terminate_hook(
56  rtems_tcb *current_task
57)
58{
59  _reclaim_reent(current_task->libc_reent);
60}
61
62#endif
Note: See TracBrowser for help on using the repository browser.