Last change
on this file since 21916 was 21916, checked in by dmik, 14 years ago |
Merge branch gcc-kmk to trunk.
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | /** @file
|
---|
2 | *
|
---|
3 | * INITDLL library implementation.
|
---|
4 | *
|
---|
5 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
6 | */
|
---|
7 |
|
---|
8 | #define INCL_DOS
|
---|
9 | #define INCL_ERRORS
|
---|
10 | #include <os2.h>
|
---|
11 |
|
---|
12 | #include <initdll.h>
|
---|
13 |
|
---|
14 | static bool cleanupDone = false;
|
---|
15 | static ULONG moduleHandle = NULLHANDLE;
|
---|
16 |
|
---|
17 | static void cleanup(ULONG ulReason)
|
---|
18 | {
|
---|
19 | cleanupDone = true;
|
---|
20 | DLL_Term(moduleHandle);
|
---|
21 | DosExitList(EXLST_EXIT, cleanup);
|
---|
22 | }
|
---|
23 |
|
---|
24 | unsigned long _System _DLL_InitTerm(unsigned long hModule,
|
---|
25 | unsigned long ulFlag)
|
---|
26 | {
|
---|
27 | APIRET arc;
|
---|
28 |
|
---|
29 | if (ulFlag == 0)
|
---|
30 | {
|
---|
31 | ULONG order = DLL_Init(hModule);
|
---|
32 | if (order == -1) // failure?
|
---|
33 | {
|
---|
34 | // OS/2 will call us back with ulFlag = 1 on failure;
|
---|
35 | // uninit now on our own to retain the LIFO order
|
---|
36 | cleanupDone = true;
|
---|
37 | DLL_Term(hModule);
|
---|
38 | return 0;
|
---|
39 | }
|
---|
40 | arc = DosExitList (EXLST_ADD | (order & 0x0000FF00), cleanup);
|
---|
41 | if (arc != NO_ERROR)
|
---|
42 | {
|
---|
43 | // see above
|
---|
44 | cleanupDone = true;
|
---|
45 | DLL_Term(hModule);
|
---|
46 | return 0;
|
---|
47 | }
|
---|
48 | moduleHandle = hModule;
|
---|
49 | return 1;
|
---|
50 | }
|
---|
51 |
|
---|
52 | if (!cleanupDone)
|
---|
53 | {
|
---|
54 | cleanupDone = true;
|
---|
55 | DLL_Term(hModule);
|
---|
56 | DosExitList(EXLST_REMOVE, cleanup);
|
---|
57 | }
|
---|
58 | return 1;
|
---|
59 | }
|
---|
60 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.