genericopenlibs/cstdlib/LINCSYS/REENT.H
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 /*
       
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * WARNING: All identifiers here must begin with an underscore.  This file is
       
    16 * included by stdio.h and others and we therefore must only use identifiers
       
    17 * in the namespace allotted to us.
       
    18 * 
       
    19 *
       
    20 */
       
    21 
       
    22 
       
    23 
       
    24 /**
       
    25  @file
       
    26  @publishedAll
       
    27  @released
       
    28 */
       
    29 
       
    30 #ifndef _SYS_REENT_H_
       
    31 #ifdef __cplusplus
       
    32 extern "C" {
       
    33 #endif
       
    34 
       
    35 #define _SYS_REENT_H_
       
    36 
       
    37 #include <_ansi.h>
       
    38 #include <sys/stdio_t.h>	/* _sFILE type */
       
    39 #include <time.h>		/* for struct tm */
       
    40 
       
    41 struct _glue 
       
    42 {
       
    43   struct _glue *_next;
       
    44   int _niobs;
       
    45   struct __sFILE *_iobs;
       
    46 };
       
    47 
       
    48 /**
       
    49 atexit() support
       
    50 */
       
    51 #define	_ATEXIT_SIZE 32	/* must be at least 32 to guarantee ANSI conformance */
       
    52 
       
    53 struct _atexit {
       
    54 	struct	_atexit *_next;			/* next in list */
       
    55 	int	_ind;				/* next index in this table */
       
    56 	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
       
    57 };
       
    58 
       
    59 
       
    60 /**
       
    61 struct _reent
       
    62 
       
    63 This structure contains *all* globals needed by the library.
       
    64 It's raison d'etre is to facilitate threads by making all library routines
       
    65 reentrant.  IE: All state information is contained here.
       
    66 */
       
    67 
       
    68 #define _ASCTIME_SIZE	(26+8)	/* 26 min, plus caution factor! */
       
    69 #define _MINNARROWBUFSIZE	100
       
    70 
       
    71 #ifdef __MWERKS__
       
    72     #pragma warn_padding off
       
    73 #endif
       
    74 
       
    75 struct _reent
       
    76 {
       
    77   /* local copy of errno */
       
    78   int _errno;
       
    79   struct __sFILE _sf[3];		/* first three file descriptors: stdin, stdout, stderr */
       
    80 
       
    81   char *_scanpoint;		/* used by strtok */
       
    82   char _asctime[_ASCTIME_SIZE];	/* used by asctime */
       
    83   struct tm _struct_tm;		/* used by gmtime */
       
    84   long _next[2];		/* used by rand/srand (64-bit seed for EPOC32) */
       
    85   int  _inc;			/* used by tmpnam */
       
    86   char _tmpnam[37];		/* used by tmpnam & inet_ntoa */
       
    87   wchar_t _wtmpnam[37];		/* used by tmpnam & inet_ntoa */
       
    88   void *_netdb;			/* used by gethostbyaddr and similar netdb functions */
       
    89  
       
    90   int _current_category;	/* used by setlocale */
       
    91   const char *_current_locale;
       
    92 
       
    93   int __sdidinit;		/* 1 means stdio has been init'd */
       
    94 
       
    95   void (*__cleanup)(struct _reent *);
       
    96 
       
    97   /* atexit stuff */
       
    98   struct _atexit *_atexit;	/* points to head of LIFO stack */
       
    99   struct _atexit _atexit0;	/* one guaranteed table, required by ANSI */
       
   100 
       
   101   /* signal info */
       
   102   void (**(_sig_func))();
       
   103 
       
   104   struct _glue __sglue;		/* root of glue chain for additional sFILE structures */
       
   105 
       
   106   char **environ;
       
   107   int environ_slots;
       
   108 
       
   109   char* _pNarrowEnvBuffer;
       
   110   int _NEBSize;
       
   111 
       
   112   void *_system;		/* Pointer to a C++ POSIX System object - Hands off! */
       
   113 };
       
   114 
       
   115 /**
       
   116 The struct _reent is managed on a per-thread basis by EPOC32, so there is no global
       
   117 variable _impure_pointer and everyone has to use _REENT (panics in the event of an
       
   118 error) or REENT2 (which returns a NULL pointer in the event of an error).
       
   119 */
       
   120 IMPORT_C void		_reclaim_reent	(struct _reent*);
       
   121 IMPORT_C void		_REENT_INIT	(struct _reent*);
       
   122 IMPORT_C struct _reent*	ImpurePtr	(void);
       
   123 IMPORT_C struct _reent* ImpurePtr2	(void);
       
   124 IMPORT_C void		_init_reent	(struct _reent*,void*);
       
   125 
       
   126 /** 
       
   127 Support for explicit release of all STDLIB resources belonging to this thread
       
   128 */
       
   129 IMPORT_C void CloseSTDLIB();
       
   130 
       
   131 #define _REENT (ImpurePtr())
       
   132 #define _REENT2 (ImpurePtr2())
       
   133 #define __errno_r(ptr) ((ptr)->_errno)
       
   134 
       
   135 #ifdef __cplusplus
       
   136 }
       
   137 #endif
       
   138 
       
   139 #endif /* _SYS_REENT_H_ */