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