/*
Copyright (c) 1993 Xerox Corporation.  All rights reserved.
*/
/*
$Id$

$Date$
 *
 * PCR ANSI and POSIX emulation per-thread data.
 */

#ifndef ←←PCR←EmuData←h
#define ←←PCR←EmuData←h 1

#include <config/PCR←StdTypes.h>
#include <th/PCR←ThData.h>

struct PCR←EmuData←IDataRep /* Inherited across fork */ {

    /* stdlib.h */
    void * eid←stdlib←env;
};
typedef struct PCR←EmuData←IDataRep PCR←EmuData←IData;

extern PCR←EmuData←IData *(PCR←EmuData←IGet(void));
#define PCR←EmuData←IGet() ( (PCR←EmuData←IData *) \
	(PCR←ThData←Get()->td←←emuIData) )
#define PCR←EmuData←IGET(eid) { (eid) = PCR←EmuData←IGet(); }


#include <grp.h>
#include <pwd.h>
#include <time.h>
#include <stdio.h>

struct PCR←EmuData←RDataRep /* Reset across fork */ {

    /* grp.h */
    struct group erd←grp←gr;
    char *erd←grp←buf;
    unsigned long erd←grp←bufBytes;

    /* pwd.h */
    struct passwd erd←pwd←pw;
    char *erd←pwd←buf;
    unsigned long erd←pwd←bufBytes;

    /* stdio.h */
    FILE * erd←stdio←stdStream[PCR←Stdio←numStdStreams];
        /*
        The actual streams used as std{in,out,err} by this thread.
        The global std{in,out,err} indirect to these.
        */
    FILE * erd←stdio←lclStreams;
        /*
        List of all open streams based on a local descriptor for
        this thread.
        */
    long erd←stdio←tmpnamID;

    /* stdlib.h */
    unsigned long int erd←stdlib←randNext;
    void (**erd←stdlib←atexitFuncList)(void);
    long erd←stdlib←atexitFuncCnt;

    /* string.h */
    char *erd←string←strtokBuf;
    char *erd←string←strtokP;
    char *erd←string←strerrorBuf;

    /* time.h */
    struct tm erd←time←tm;
    char *erd←time←buf;
    unsigned long erd←time←bufBytes;
    char *erd←stdlib←envVal;

    /* unistd.h */
    long erd←unistd←alarmSecs;
    PCR←ThData←T * erd←unistd←alarmNext;
};
typedef struct PCR←EmuData←RDataRep PCR←EmuData←RData;

extern PCR←EmuData←RData *(PCR←EmuData←←RGet(void));
extern PCR←EmuData←RData *(PCR←EmuData←RGet(void));


#define PCR←EmuData←RTry() (PCR←ThData←Get()->td←←emuRData)
#define PCR←EmuData←RGet() ( PCR←EmuData←RTry() \
	? PCR←EmuData←RTry() : PCR←EmuData←←RGet() )
#define PCR←EmuData←RGET(erd) {\
        if( ((erd) = PCR←EmuData←RTry()) == NIL ) {\
            (erd) = PCR←EmuData←←RGet(); \
        } }

/*
 * cleanup procs -- called just before thread exit ...
 */

void (*PCR←EmuData←atexitCleanup)(void);
void (*PCR←EmuData←stdioCleanup)(void);

#endif /* ! ←←PCR←EmuData←h */
/*
$Log$
*/