1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LINCSYS/REENT.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,139 @@
1.4 +/*
1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* WARNING: All identifiers here must begin with an underscore. This file is
1.19 +* included by stdio.h and others and we therefore must only use identifiers
1.20 +* in the namespace allotted to us.
1.21 +*
1.22 +*
1.23 +*/
1.24 +
1.25 +
1.26 +
1.27 +/**
1.28 + @file
1.29 + @publishedAll
1.30 + @released
1.31 +*/
1.32 +
1.33 +#ifndef _SYS_REENT_H_
1.34 +#ifdef __cplusplus
1.35 +extern "C" {
1.36 +#endif
1.37 +
1.38 +#define _SYS_REENT_H_
1.39 +
1.40 +#include <_ansi.h>
1.41 +#include <sys/stdio_t.h> /* _sFILE type */
1.42 +#include <time.h> /* for struct tm */
1.43 +
1.44 +struct _glue
1.45 +{
1.46 + struct _glue *_next;
1.47 + int _niobs;
1.48 + struct __sFILE *_iobs;
1.49 +};
1.50 +
1.51 +/**
1.52 +atexit() support
1.53 +*/
1.54 +#define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */
1.55 +
1.56 +struct _atexit {
1.57 + struct _atexit *_next; /* next in list */
1.58 + int _ind; /* next index in this table */
1.59 + void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */
1.60 +};
1.61 +
1.62 +
1.63 +/**
1.64 +struct _reent
1.65 +
1.66 +This structure contains *all* globals needed by the library.
1.67 +It's raison d'etre is to facilitate threads by making all library routines
1.68 +reentrant. IE: All state information is contained here.
1.69 +*/
1.70 +
1.71 +#define _ASCTIME_SIZE (26+8) /* 26 min, plus caution factor! */
1.72 +#define _MINNARROWBUFSIZE 100
1.73 +
1.74 +#ifdef __MWERKS__
1.75 + #pragma warn_padding off
1.76 +#endif
1.77 +
1.78 +struct _reent
1.79 +{
1.80 + /* local copy of errno */
1.81 + int _errno;
1.82 + struct __sFILE _sf[3]; /* first three file descriptors: stdin, stdout, stderr */
1.83 +
1.84 + char *_scanpoint; /* used by strtok */
1.85 + char _asctime[_ASCTIME_SIZE]; /* used by asctime */
1.86 + struct tm _struct_tm; /* used by gmtime */
1.87 + long _next[2]; /* used by rand/srand (64-bit seed for EPOC32) */
1.88 + int _inc; /* used by tmpnam */
1.89 + char _tmpnam[37]; /* used by tmpnam & inet_ntoa */
1.90 + wchar_t _wtmpnam[37]; /* used by tmpnam & inet_ntoa */
1.91 + void *_netdb; /* used by gethostbyaddr and similar netdb functions */
1.92 +
1.93 + int _current_category; /* used by setlocale */
1.94 + const char *_current_locale;
1.95 +
1.96 + int __sdidinit; /* 1 means stdio has been init'd */
1.97 +
1.98 + void (*__cleanup)(struct _reent *);
1.99 +
1.100 + /* atexit stuff */
1.101 + struct _atexit *_atexit; /* points to head of LIFO stack */
1.102 + struct _atexit _atexit0; /* one guaranteed table, required by ANSI */
1.103 +
1.104 + /* signal info */
1.105 + void (**(_sig_func))();
1.106 +
1.107 + struct _glue __sglue; /* root of glue chain for additional sFILE structures */
1.108 +
1.109 + char **environ;
1.110 + int environ_slots;
1.111 +
1.112 + char* _pNarrowEnvBuffer;
1.113 + int _NEBSize;
1.114 +
1.115 + void *_system; /* Pointer to a C++ POSIX System object - Hands off! */
1.116 +};
1.117 +
1.118 +/**
1.119 +The struct _reent is managed on a per-thread basis by EPOC32, so there is no global
1.120 +variable _impure_pointer and everyone has to use _REENT (panics in the event of an
1.121 +error) or REENT2 (which returns a NULL pointer in the event of an error).
1.122 +*/
1.123 +IMPORT_C void _reclaim_reent (struct _reent*);
1.124 +IMPORT_C void _REENT_INIT (struct _reent*);
1.125 +IMPORT_C struct _reent* ImpurePtr (void);
1.126 +IMPORT_C struct _reent* ImpurePtr2 (void);
1.127 +IMPORT_C void _init_reent (struct _reent*,void*);
1.128 +
1.129 +/**
1.130 +Support for explicit release of all STDLIB resources belonging to this thread
1.131 +*/
1.132 +IMPORT_C void CloseSTDLIB();
1.133 +
1.134 +#define _REENT (ImpurePtr())
1.135 +#define _REENT2 (ImpurePtr2())
1.136 +#define __errno_r(ptr) ((ptr)->_errno)
1.137 +
1.138 +#ifdef __cplusplus
1.139 +}
1.140 +#endif
1.141 +
1.142 +#endif /* _SYS_REENT_H_ */