Update contrib.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // <<reent>>---definition of impure data.
18 // This module defines the impure data area used by the
19 // non-rentrant functions, such as strtok.
24 #include <sys/reent.h>
27 /* Interim cleanup code */
29 static void cleanup_glue (struct _glue *glue)
31 /* Have to reclaim these in reverse order: */
33 cleanup_glue (glue->_next);
40 The struct _reent is managed on a per-thread basis by EPOC32, so there is no
41 global variable _impure_pointer and everyone has to use _REENT (panics in the
42 event of an error) or REENT2 (which returns a NULL pointer in the event of an
49 _reclaim_reent (struct _reent *ptr)
52 if ((ptr->_atexit) && (ptr->_atexit != &ptr->_atexit0))
54 struct _atexit *p, *q;
55 for (p = ptr->_atexit; p != &ptr->_atexit0;)
71 /* cleanup won't reclaim memory 'coz usually it's run
72 before the program exits, and who wants to wait for that? */
74 if (ptr->__sglue._next)
75 cleanup_glue (ptr->__sglue._next);
78 // narrow environment buffer
79 if (ptr->_pNarrowEnvBuffer)
81 free(ptr->_pNarrowEnvBuffer);
82 ptr->_pNarrowEnvBuffer = 0;
85 MSystemInterface& sysIf=Interface(ptr);
91 EXPORT_C void _REENT_INIT(struct _reent *ptr)
93 MSystemInterface& sysIf=Interface(ImpurePtr());
94 _init_reent(ptr,&sysIf.Clone());
97 extern "C" void __sinit(struct _reent*); // LSTDIO/LOCAL.H
99 EXPORT_C void _init_reent(struct _reent *ptr, void* _system)
101 ptr->_system=_system;
106 ptr->_pNarrowEnvBuffer = 0;