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