1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
24 /* External variables and functions used only by Sfio
25 ** Written by Kiem-Phong Vo
28 /* code to initialize mutexes */
29 static Vtmutex_t Sfmutex
;
30 static Vtonce_t Sfonce
= VTONCE_INITDATA
;
31 static void _sfoncef()
32 { (void)vtmtxopen(_Sfmutex
, VT_INIT
);
33 (void)vtmtxopen(&_Sfpool
.mutex
, VT_INIT
);
34 (void)vtmtxopen(sfstdin
->mutex
, VT_INIT
);
35 (void)vtmtxopen(sfstdout
->mutex
, VT_INIT
);
36 (void)vtmtxopen(sfstderr
->mutex
, VT_INIT
);
40 /* global variables used internally to the package */
41 Sfextern_t _Sfextern
=
43 { NIL(Sfpool_t
*), 0, 0, 0, NIL(Sfio_t
**) }, /* _Sfpool */
44 NIL(int(*)_ARG_((Sfio_t
*,int))), /* _Sfpmove */
45 NIL(Sfio_t
*(*)_ARG_((Sfio_t
*, Sfio_t
*))), /* _Sfstack */
46 NIL(void(*)_ARG_((Sfio_t
*, int, void*))), /* _Sfnotify */
47 NIL(int(*)_ARG_((Sfio_t
*))), /* _Sfstdsync */
48 { NIL(Sfread_f
), /* _Sfudisc */
54 NIL(void(*)_ARG_((void)) ), /* _Sfcleanup */
57 &Sfonce
, /* _Sfonce */
58 _sfoncef
, /* _Sfoncef */
59 &Sfmutex
/* _Sfmutex */
62 ssize_t _Sfi
= -1; /* value for a few fast macro functions */
64 ssize_t _Sfmaxr
= 256*1024; /* default maximum size for a record */
66 ssize_t _Sfmaxr
= 16*1024; /* default maximum size for a record */
70 static Vtmutex_t _Sfmtxin
, _Sfmtxout
, _Sfmtxerr
;
71 #define SFMTXIN (&_Sfmtxin)
72 #define SFMTXOUT (&_Sfmtxout)
73 #define SFMTXERR (&_Sfmtxerr)
74 #define SF_STDSAFE SF_MTSAFE
79 #define SF_STDSAFE (0)
82 Sfio_t _Sfstdin
= SFNEW(NIL(char*),-1,0,
83 (SF_READ
|SF_STATIC
|SF_STDSAFE
),NIL(Sfdisc_t
*),SFMTXIN
);
84 Sfio_t _Sfstdout
= SFNEW(NIL(char*),-1,1,
85 (SF_WRITE
|SF_STATIC
|SF_STDSAFE
),NIL(Sfdisc_t
*),SFMTXOUT
);
86 Sfio_t _Sfstderr
= SFNEW(NIL(char*),-1,2,
87 (SF_WRITE
|SF_STATIC
|SF_STDSAFE
),NIL(Sfdisc_t
*),SFMTXERR
);
93 Sfio_t
* sfstdin
= &_Sfstdin
;
94 Sfio_t
* sfstdout
= &_Sfstdout
;
95 Sfio_t
* sfstderr
= &_Sfstderr
;
97 __EXTERN__(ssize_t
,_Sfi
);
98 __EXTERN__(Sfio_t
,_Sfstdin
);
99 __EXTERN__(Sfio_t
,_Sfstdout
);
100 __EXTERN__(Sfio_t
,_Sfstderr
);
101 __EXTERN__(Sfio_t
*,sfstdin
);
102 __EXTERN__(Sfio_t
*,sfstdout
);
103 __EXTERN__(Sfio_t
*,sfstderr
);