1169689Skan/* Startup code for libgcc_s.nlm, necessary because we can't allow 2169689Skan libgcc_s to use libc's malloc & Co., which associate allocations 3169689Skan with the NLM owning the current (application) thread. 4169689Skan Contributed by Jan Beulich (jbeulich@novell.com) 5169689Skan Copyright (C) 2004 Free Software Foundation, Inc. 6169689Skan 7169689SkanThis file is part of GCC. 8169689Skan 9169689SkanGCC is free software; you can redistribute it and/or modify 10169689Skanit under the terms of the GNU General Public License as published by 11169689Skanthe Free Software Foundation; either version 2, or (at your option) 12169689Skanany later version. 13169689Skan 14169689SkanGCC is distributed in the hope that it will be useful, 15169689Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of 16169689SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17169689SkanGNU General Public License for more details. 18169689Skan 19169689SkanYou should have received a copy of the GNU General Public License 20169689Skanalong with GCC; see the file COPYING. If not, write to 21169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 22169689SkanBoston, MA 02110-1301, USA. */ 23169689Skan 24169689Skan#include <netware.h> 25169689Skan#include <stddef.h> 26169689Skan#include <stdlib.h> 27169689Skan#include <windows.h> 28169689Skan 29169689Skanstatic rtag_t allocRTag; 30169689Skan 31169689SkanBOOL 32169689SkanDllMain (HINSTANCE libraryId __attribute__ ((__unused__)), 33169689Skan DWORD reason, void *hModule) 34169689Skan{ 35169689Skan switch (reason) 36169689Skan { 37169689Skan case DLL_NLM_STARTUP: 38169689Skan allocRTag = AllocateResourceTag (hModule, 39169689Skan "libgcc memory", AllocSignature); 40169689Skan return allocRTag != NULL; 41169689Skan case DLL_NLM_SHUTDOWN: 42169689Skan /* This does not recover resources associated with the tag... 43169689Skan ReturnResourceTag (allocRTag, 0); */ 44169689Skan break; 45169689Skan } 46169689Skan return 1; 47169689Skan} 48169689Skan 49169689Skanvoid * 50169689Skanmalloc (size_t size) 51169689Skan{ 52169689Skan return AllocSleepOK (size, allocRTag, NULL); 53169689Skan} 54169689Skan 55169689Skanvoid 56169689Skanfree (void *ptr) 57169689Skan{ 58169689Skan Free (ptr); 59169689Skan} 60