netware-libgcc.c revision 303975
129088Smarkm/* Startup code for libgcc_s.nlm, necessary because we can't allow 229088Smarkm libgcc_s to use libc's malloc & Co., which associate allocations 329088Smarkm with the NLM owning the current (application) thread. 429088Smarkm Contributed by Jan Beulich (jbeulich@novell.com) 529088Smarkm Copyright (C) 2004 Free Software Foundation, Inc. 629088Smarkm 729088SmarkmThis file is part of GCC. 829088Smarkm 929088SmarkmGCC is free software; you can redistribute it and/or modify 1029088Smarkmit under the terms of the GNU General Public License as published by 1129088Smarkmthe Free Software Foundation; either version 2, or (at your option) 1229088Smarkmany later version. 1329088Smarkm 1429088SmarkmGCC is distributed in the hope that it will be useful, 1529088Smarkmbut WITHOUT ANY WARRANTY; without even the implied warranty of 1629088SmarkmMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1729088SmarkmGNU General Public License for more details. 1829088Smarkm 1929088SmarkmYou should have received a copy of the GNU General Public License 2029088Smarkmalong with GCC; see the file COPYING. If not, write to 2129088Smarkmthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 2229088SmarkmBoston, MA 02110-1301, USA. */ 2329088Smarkm 2429088Smarkm#include <netware.h> 2529088Smarkm#include <stddef.h> 2629088Smarkm#include <stdlib.h> 2729088Smarkm#include <windows.h> 2829088Smarkm 2929088Smarkmstatic rtag_t allocRTag; 3029088Smarkm 3129088SmarkmBOOL 3229088SmarkmDllMain (HINSTANCE libraryId __attribute__ ((__unused__)), 3329088Smarkm DWORD reason, void *hModule) 3487139Smarkm{ 3587139Smarkm switch (reason) 3687139Smarkm { 3787139Smarkm case DLL_NLM_STARTUP: 3829088Smarkm allocRTag = AllocateResourceTag (hModule, 3929181Smarkm "libgcc memory", AllocSignature); 4087139Smarkm return allocRTag != NULL; 4129088Smarkm case DLL_NLM_SHUTDOWN: 4229088Smarkm /* This does not recover resources associated with the tag... 4377095Sdillon ReturnResourceTag (allocRTag, 0); */ 4429088Smarkm break; 4529088Smarkm } 4629088Smarkm return 1; 4729088Smarkm} 4887139Smarkm 4987139Smarkmvoid * 5087139Smarkmmalloc (size_t size) 5129088Smarkm{ 5229088Smarkm return AllocSleepOK (size, allocRTag, NULL); 5387139Smarkm} 5487139Smarkm 5587139Smarkmvoid 5687139Smarkmfree (void *ptr) 5729181Smarkm{ 5829088Smarkm Free (ptr); 5929088Smarkm} 6081965Smarkm