Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions | Variables
MacOS.c File Reference
#include <Resources.h>
#include <Memory.h>
#include <LowMem.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gc.h"
#include "gc_priv.h"

Go to the source code of this file.

Classes

struct  CodeZeroPtr
struct  TemporaryMemoryBlock

Typedefs

typedef struct CodeZeroPtr ** CodeZeroHandle
typedef struct TemporaryMemoryBlock
typedef struct ** TemporaryMemoryHandle

Functions

void GC_init_MacOS ()
voidGC_MacGetDataStart ()
void GC_MacFreeTemporaryMemory (void)
Ptr GC_MacTemporaryNewPtr (size_t size, Boolean clearMemory)
static void perform_final_collection ()

Variables

static TemporaryMemoryHandle theTemporaryMemory = NULL
static Boolean firstTime = true
word GC_fo_entries

Class Documentation

struct CodeZeroPtr

Definition at line 39 of file MacOS.c.

Class Members
unsigned long aboveA5
unsigned long belowA5
unsigned long JTOffset
unsigned long JTSize
struct TemporaryMemoryBlock

Definition at line 63 of file MacOS.c.

Class Members
char data
TemporaryMemoryHandle nextBlock

Typedef Documentation

typedef struct CodeZeroPtr ** CodeZeroHandle
typedef struct TemporaryMemoryBlock

Definition at line 61 of file MacOS.c.

typedef struct ** TemporaryMemoryHandle

Definition at line 61 of file MacOS.c.


Function Documentation

Definition at line 28 of file MacOS.c.

{
    int i;
    
    MaxApplZone();
    for (i = 0; i < 8; ++i)
        MoreMasters();
}

Here is the caller graph for this function:

Definition at line 122 of file MacOS.c.

{
# if defined(SHARED_LIBRARY_BUILD)
    /* if possible, collect all memory, and invoke all finalizers. */
      perform_final_collection();
# endif

    if (theTemporaryMemory != NULL) {
              long totalMemoryUsed = 0;
              TemporaryMemoryHandle tempMemBlock = theTemporaryMemory;
              while (tempMemBlock != NULL) {
                     TemporaryMemoryHandle nextBlock = (**tempMemBlock).nextBlock;
                     totalMemoryUsed += GetHandleSize((Handle)tempMemBlock);
                     DisposeHandle((Handle)tempMemBlock);
                     tempMemBlock = nextBlock;
              }
              theTemporaryMemory = NULL;

#       if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD)
          fprintf(stdout, "[total memory used:  %ld bytes.]\n",
                  totalMemoryUsed);
          fprintf(stdout, "[total collections:  %ld.]\n", GC_gc_no);
#       endif
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 46 of file MacOS.c.

{
       CodeZeroHandle code0 = (CodeZeroHandle)GetResource('CODE', 0);
       if (code0) {
              long belowA5Size = (**code0).belowA5;
              ReleaseResource((Handle)code0);
              return (LMGetCurrentA5() - belowA5Size);
       }
       fprintf(stderr, "Couldn't load the jump table.");
       exit(-1);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Ptr GC_MacTemporaryNewPtr ( size_t  size,
Boolean  clearMemory 
)

Definition at line 73 of file MacOS.c.

{
       static Boolean firstTime = true;
       OSErr result;
       TemporaryMemoryHandle tempMemBlock;
       Ptr tempPtr = nil;

       tempMemBlock = (TemporaryMemoryHandle)TempNewHandle(size + sizeof(TemporaryMemoryBlock), &result);
       if (tempMemBlock && result == noErr) {
              HLockHi((Handle)tempMemBlock);
              tempPtr = (**tempMemBlock).data;
              if (clearMemory) memset(tempPtr, 0, size);
              tempPtr = StripAddress(tempPtr);

              // keep track of the allocated blocks.
              (**tempMemBlock).nextBlock = theTemporaryMemory;
              theTemporaryMemory = tempMemBlock;
       }
       
#     if !defined(SHARED_LIBRARY_BUILD)
       // install an exit routine to clean up the memory used at the end.
       if (firstTime) {
              atexit(&GC_MacFreeTemporaryMemory);
              firstTime = false;
       }
#     endif
       
       return tempPtr;
}

Here is the call graph for this function:

static void perform_final_collection ( ) [static]

Definition at line 105 of file MacOS.c.

{
  unsigned i;
  word last_fo_entries = 0;
  
  /* adjust the stack bottom, because CFM calls us from another stack
     location. */
     GC_stackbottom = (ptr_t)&i;

  /* try to collect and finalize everything in sight */
    for (i = 0; i < 2 || GC_fo_entries < last_fo_entries; i++) {
        last_fo_entries = GC_fo_entries;
        GC_gcollect();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Boolean firstTime = true [static]

Definition at line 69 of file MacOS.c.

Definition at line 74 of file finalize.c.

Definition at line 68 of file MacOS.c.