8354 sync regcomp(3C) with upstream (fix make catalog)
[unleashed/tickless.git] / usr / src / lib / libast / common / port / astdynamic.c
blobfb038f29104288d1ca8660ba9a65deef5c35218f
1 /***********************************************************************
2 * *
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 *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
20 * *
21 ***********************************************************************/
22 #pragma prototyped
25 * ast dynamic data initialization
28 #ifdef _UWIN
30 #define _std_def_cfree 1
32 #include <sfio_t.h>
33 #include <ast.h>
35 #undef strcoll
37 #include <ast_windows.h>
39 extern Sfio_t _Sfstdin;
40 extern Sfio_t _Sfstdout;
41 extern Sfio_t _Sfstderr;
43 #include "sfhdr.h"
45 #undef sfstdin
46 #undef sfstdout
47 #undef sfstderr
49 #if defined(__EXPORT__)
50 #define extern __EXPORT__
51 #endif
54 * for backward compatibility with early UNIX
57 extern void
58 cfree(void* addr)
60 free(addr);
63 extern void
64 _ast_libinit(void* in, void* out, void* err)
66 Sfio_t* sp;
68 sp = (Sfio_t*)in;
69 *sp = _Sfstdin;
70 sfstdin = sp;
71 sp = (Sfio_t*)out;
72 *sp = _Sfstdout;
73 sfstdout = sp;
74 sp = (Sfio_t*)err;
75 *sp = _Sfstderr;
76 sfstderr = sp;
79 extern void
80 _ast_init(void)
82 struct _astdll* ap = _ast_getdll();
84 _ast_libinit(ap->_ast_stdin,ap->_ast_stdout,ap->_ast_stderr);
87 extern void
88 _ast_exit(void)
90 if (_Sfcleanup)
91 (*_Sfcleanup)();
94 BOOL WINAPI
95 DllMain(HINSTANCE hinst, DWORD reason, VOID* reserved)
97 switch (reason)
99 case DLL_PROCESS_ATTACH:
100 break;
101 case DLL_PROCESS_DETACH:
102 _ast_exit();
103 break;
105 return 1;
108 #else
110 #include <ast.h>
112 #if _dll_data_intercept && ( _DLL_BLD || _BLD_DLL )
114 #undef environ
116 extern char** environ;
118 struct _astdll _ast_dll = { &environ };
120 struct _astdll*
121 _ast_getdll(void)
123 return &_ast_dll;
126 #else
128 NoN(astdynamic)
130 #endif
132 #endif