epoc32/include/libc/sys/reent.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.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 
    26 
    27 
    28 /**
    29  @file
    30  @publishedAll
    31  @released
    32 */
    33 
    34 #ifndef _SYS_REENT_H_
    35 #ifdef __cplusplus
    36 extern "C" {
    37 #endif
    38 
    39 #define _SYS_REENT_H_
    40 
    41 #include <_ansi.h>
    42 #include <sys/stdio_t.h>	/* _sFILE type */
    43 #include <time.h>		/* for struct tm */
    44 
    45 struct _glue 
    46 {
    47   struct _glue *_next;
    48   int _niobs;
    49   struct __sFILE *_iobs;
    50 };
    51 
    52 /**
    53 atexit() support
    54 */
    55 #define	_ATEXIT_SIZE 32	/* must be at least 32 to guarantee ANSI conformance */
    56 
    57 struct _atexit {
    58 	struct	_atexit *_next;			/* next in list */
    59 	int	_ind;				/* next index in this table */
    60 	void	(*_fns[_ATEXIT_SIZE])(void);	/* the table itself */
    61 };
    62 
    63 
    64 /**
    65 struct _reent
    66 
    67 This structure contains *all* globals needed by the library.
    68 It's raison d'etre is to facilitate threads by making all library routines
    69 reentrant.  IE: All state information is contained here.
    70 */
    71 
    72 #define _ASCTIME_SIZE	(26+8)	/* 26 min, plus caution factor! */
    73 #define _MINNARROWBUFSIZE	100
    74 
    75 #ifdef __MWERKS__
    76     #pragma warn_padding off
    77 #endif
    78 
    79 struct _reent
    80 {
    81   /* local copy of errno */
    82   int _errno;
    83   struct __sFILE _sf[3];		/* first three file descriptors: stdin, stdout, stderr */
    84 
    85   char *_scanpoint;		/* used by strtok */
    86   char _asctime[_ASCTIME_SIZE];	/* used by asctime */
    87   struct tm _struct_tm;		/* used by gmtime */
    88   long _next[2];		/* used by rand/srand (64-bit seed for EPOC32) */
    89   int  _inc;			/* used by tmpnam */
    90   char _tmpnam[37];		/* used by tmpnam & inet_ntoa */
    91   wchar_t _wtmpnam[37];		/* used by tmpnam & inet_ntoa */
    92   void *_netdb;			/* used by gethostbyaddr and similar netdb functions */
    93  
    94   int _current_category;	/* used by setlocale */
    95   const char *_current_locale;
    96 
    97   int __sdidinit;		/* 1 means stdio has been init'd */
    98 
    99   void (*__cleanup)(struct _reent *);
   100 
   101   /* atexit stuff */
   102   struct _atexit *_atexit;	/* points to head of LIFO stack */
   103   struct _atexit _atexit0;	/* one guaranteed table, required by ANSI */
   104 
   105   /* signal info */
   106   void (**(_sig_func))();
   107 
   108   struct _glue __sglue;		/* root of glue chain for additional sFILE structures */
   109 
   110   char **environ;
   111   int environ_slots;
   112 
   113   char* _pNarrowEnvBuffer;
   114   int _NEBSize;
   115 
   116   void *_system;		/* Pointer to a C++ POSIX System object - Hands off! */
   117 };
   118 
   119 /**
   120 The struct _reent is managed on a per-thread basis by EPOC32, so there is no global
   121 variable _impure_pointer and everyone has to use _REENT (panics in the event of an
   122 error) or REENT2 (which returns a NULL pointer in the event of an error).
   123 */
   124 IMPORT_C void		_reclaim_reent	(struct _reent*);
   125 IMPORT_C void		_REENT_INIT	(struct _reent*);
   126 IMPORT_C struct _reent*	ImpurePtr	(void);
   127 IMPORT_C struct _reent* ImpurePtr2	(void);
   128 IMPORT_C void		_init_reent	(struct _reent*,void*);
   129 
   130 /** 
   131 Support for explicit release of all STDLIB resources belonging to this thread
   132 */
   133 IMPORT_C void CloseSTDLIB();
   134 
   135 #define _REENT (ImpurePtr())
   136 #define _REENT2 (ImpurePtr2())
   137 #define __errno_r(ptr) ((ptr)->_errno)
   138 
   139 #ifdef __cplusplus
   140 }
   141 #endif
   142 
   143 #endif /* _SYS_REENT_H_ */