source: trunk/src/gcc/boehm-gc/MacOS.c@ 1126

Last change on this file since 1126 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.8 KB
Line 
1/*
2 MacOS.c
3
4 Some routines for the Macintosh OS port of the Hans-J. Boehm, Alan J. Demers
5 garbage collector.
6
7 <Revision History>
8
9 11/22/94 pcb StripAddress the temporary memory handle for 24-bit mode.
10 11/30/94 pcb Tracking all memory usage so we can deallocate it all at once.
11 02/10/96 pcb Added routine to perform a final collection when
12unloading shared library.
13
14 by Patrick C. Beard.
15 */
16/* Boehm, February 15, 1996 2:55 pm PST */
17
18#include <Resources.h>
19#include <Memory.h>
20#include <LowMem.h>
21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h>
24
25#include "gc.h"
26#include "gc_priv.h"
27
28// use 'CODE' resource 0 to get exact location of the beginning of global space.
29
30typedef struct {
31 unsigned long aboveA5;
32 unsigned long belowA5;
33 unsigned long JTSize;
34 unsigned long JTOffset;
35} *CodeZeroPtr, **CodeZeroHandle;
36
37void* GC_MacGetDataStart()
38{
39 CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0);
40 if (code0) {
41 long belowA5Size = (**code0).belowA5;
42 ReleaseResource((Handle)code0);
43 return (LMGetCurrentA5() - belowA5Size);
44 }
45 fprintf(stderr, "Couldn't load the jump table.");
46 exit(-1);
47 return 0;
48}
49
50/* track the use of temporary memory so it can be freed all at once. */
51
52typedef struct TemporaryMemoryBlock TemporaryMemoryBlock, **TemporaryMemoryHandle;
53
54struct TemporaryMemoryBlock {
55 TemporaryMemoryHandle nextBlock;
56 char data[];
57};
58
59static TemporaryMemoryHandle theTemporaryMemory = NULL;