00001 /* Startup code for libgcc_s.nlm, necessary because we can't allow 00002 libgcc_s to use libc's malloc & Co., which associate allocations 00003 with the NLM owning the current (application) thread. 00004 Contributed by Jan Beulich (jbeulich@novell.com) 00005 Copyright (C) 2004 Free Software Foundation, Inc. 00006 00007 This file is part of GCC. 00008 00009 GCC is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2, or (at your option) 00012 any later version. 00013 00014 GCC is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with GCC; see the file COPYING. If not, write to 00021 the Free Software Foundation, 59 Temple Place - Suite 330, 00022 Boston, MA 02111-1307, USA. */ 00023 00024 #include <netware.h> 00025 #include <stddef.h> 00026 #include <stdlib.h> 00027 #include <windows.h> 00028 00029 static rtag_t allocRTag; 00030 00031 BOOL 00032 DllMain (HINSTANCE libraryId __attribute__ ((__unused__)), 00033 DWORD reason, void *hModule) 00034 { 00035 switch (reason) 00036 { 00037 case DLL_NLM_STARTUP: 00038 allocRTag = AllocateResourceTag (hModule, 00039 "libgcc memory", AllocSignature); 00040 return allocRTag != NULL; 00041 case DLL_NLM_SHUTDOWN: 00042 /* This does not recover resources associated with the tag... 00043 ReturnResourceTag (allocRTag, 0); */ 00044 break; 00045 } 00046 return 1; 00047 } 00048 00049 void * 00050 malloc (size_t size) 00051 { 00052 return AllocSleepOK (size, allocRTag, NULL); 00053 } 00054 00055 void 00056 free (void *ptr) 00057 { 00058 Free (ptr); 00059 }
1.5.6