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