0
|
1 /* Startup code for libgcc_s.nlm, necessary because we can't allow
|
|
2 libgcc_s to use libc's malloc & Co., which associate allocations
|
|
3 with the NLM owning the current (application) thread.
|
|
4 Contributed by Jan Beulich (jbeulich@novell.com)
|
|
5 Copyright (C) 2004, 2007 Free Software Foundation, Inc.
|
|
6
|
|
7 This file is part of GCC.
|
|
8
|
|
9 GCC is free software; you can redistribute it and/or modify
|
|
10 it under the terms of the GNU General Public License as published by
|
|
11 the Free Software Foundation; either version 3, or (at your option)
|
|
12 any later version.
|
|
13
|
|
14 GCC is distributed in the hope that it will be useful,
|
|
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
17 GNU General Public License for more details.
|
|
18
|
|
19 You should have received a copy of the GNU General Public License
|
|
20 along with GCC; see the file COPYING3. If not see
|
|
21 <http://www.gnu.org/licenses/>. */
|
|
22
|
|
23 #include <netware.h>
|
|
24 #include <stddef.h>
|
|
25 #include <stdlib.h>
|
|
26 #include <windows.h>
|
|
27
|
|
28 static rtag_t allocRTag;
|
|
29
|
|
30 BOOL
|
|
31 DllMain (HINSTANCE libraryId __attribute__ ((__unused__)),
|
|
32 DWORD reason, void *hModule)
|
|
33 {
|
|
34 switch (reason)
|
|
35 {
|
|
36 case DLL_NLM_STARTUP:
|
|
37 allocRTag = AllocateResourceTag (hModule,
|
|
38 "libgcc memory", AllocSignature);
|
|
39 return allocRTag != NULL;
|
|
40 case DLL_NLM_SHUTDOWN:
|
|
41 /* This does not recover resources associated with the tag...
|
|
42 ReturnResourceTag (allocRTag, 0); */
|
|
43 break;
|
|
44 }
|
|
45 return 1;
|
|
46 }
|
|
47
|
|
48 void *
|
|
49 malloc (size_t size)
|
|
50 {
|
|
51 return AllocSleepOK (size, allocRTag, NULL);
|
|
52 }
|
|
53
|
|
54 void
|
|
55 free (void *ptr)
|
|
56 {
|
|
57 Free (ptr);
|
|
58 }
|