C:/Users/Dennis/src/lang/russell.orig/src/gc/gc_inline.h

Go to the documentation of this file.
00001 /* 
00002  * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
00003  * Copyright (c) 1991, 1992 by Xerox Corporation.  All rights reserved.
00004  *
00005  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
00006  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
00007  *
00008  * Permission is hereby granted to copy this garbage collector for any purpose,
00009  * provided the above notices are retained on all copies.
00010  */
00011  
00012 # ifndef GC_PRIVATE_H
00013 #   include "gc_private.h"
00014 # endif
00015 
00016 /* Allocate n words (NOT BYTES).  X is made to point to the result.     */
00017 /* It is assumed that n < MAXOBJSZ, and                                 */
00018 /* that n > 0.  On machines requiring double word alignment of some     */
00019 /* data, we also assume that n is 1 or even.  This bypasses the         */
00020 /* MERGE_SIZES mechanism.  In order to minimize the number of distinct  */
00021 /* free lists that are maintained, the caller should ensure that a      */
00022 /* small number of distinct values of n are used.  (The MERGE_SIZES     */
00023 /* mechanism normally does this by ensuring that only the leading three */
00024 /* bits of n may be nonzero.  See misc.c for details.)  We really       */
00025 /* recommend this only in cases in which n is a constant, and no        */
00026 /* locking is required.                                                 */
00027 /* In that case it may allow the compiler to perform substantial        */
00028 /* additional optimizations.                                            */
00029 # define GC_MALLOC_WORDS(result,n) \
00030 {       \
00031     register ptr_t op;  \
00032     register ptr_t *opp;        \
00033     DCL_LOCK_STATE;     \
00034         \
00035     opp = &(GC_objfreelist[n]); \
00036     FASTLOCK(); \
00037     if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) {   \
00038         FASTUNLOCK();   \
00039         (result) = GC_generic_malloc_words_small((n), NORMAL);  \
00040     } else {    \
00041         *opp = obj_link(op);    \
00042         obj_link(op) = 0;       \
00043         GC_words_allocd += (n); \
00044         FASTUNLOCK();   \
00045         (result) = (extern_ptr_t) op;   \
00046     }   \
00047 }
00048 
00049 
00050 /* The same for atomic objects: */
00051 # define GC_MALLOC_ATOMIC_WORDS(result,n) \
00052 {       \
00053     register ptr_t op;  \
00054     register ptr_t *opp;        \
00055     DCL_LOCK_STATE;     \
00056         \
00057     opp = &(GC_aobjfreelist[n]);        \
00058     FASTLOCK(); \
00059     if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) {   \
00060         FASTUNLOCK();   \
00061         (result) = GC_generic_malloc_words_small((n), PTRFREE); \
00062     } else {    \
00063         *opp = obj_link(op);    \
00064         obj_link(op) = 0;       \
00065         GC_words_allocd += (n); \
00066         FASTUNLOCK();   \
00067         (result) = (extern_ptr_t) op;   \
00068     }   \
00069 }
00070 
00071 /* And once more for two word initialized objects: */
00072 # define GC_CONS(result, first, second) \
00073 {       \
00074     register ptr_t op;  \
00075     register ptr_t *opp;        \
00076     DCL_LOCK_STATE;     \
00077         \
00078     opp = &(GC_objfreelist[2]); \
00079     FASTLOCK(); \
00080     if( !FASTLOCK_SUCCEEDED() || (op = *opp) == 0 ) {   \
00081         FASTUNLOCK();   \
00082         op = GC_generic_malloc_words_small(2, NORMAL);  \
00083     } else {    \
00084         *opp = obj_link(op);    \
00085         GC_words_allocd += 2;   \
00086         FASTUNLOCK();   \
00087     } \
00088     ((word *)op)[0] = (word)(first);    \
00089     ((word *)op)[1] = (word)(second);   \
00090     (result) = (extern_ptr_t) op;       \
00091 }

Generated on Fri Jan 25 10:39:45 2008 for russell by  doxygen 1.5.4