1 /* 2 * Part of Scheme 48 1.9. See file COPYING for notices and license. 3 * 4 * Authors: David Frese 5 */ 6 7 #ifndef __S48_GC_MEMORY_H 8 #define __S48_GC_MEMORY_H 9 10 typedef char* s48_address; 11 12 /* bytes <--> cells */ 13 /* can't include scheme48.h, because of mutual inclusion: defines S48_LOG_BYTES_PER_CELL */ 14 #define S48_BYTES_PER_CELL (1L << S48_LOG_BYTES_PER_CELL) 15 16 #define S48_BYTES_TO_CELLS(b) (((unsigned long)(b + (S48_BYTES_PER_CELL - 1))) \ 17 >> S48_LOG_BYTES_PER_CELL) 18 19 #define S48_CELLS_TO_BYTES(c) ((c) << S48_LOG_BYTES_PER_CELL) 20 21 /* addressable units <--> cells */ 22 #define S48_LOG_A_UNITS_PER_CELL S48_LOG_BYTES_PER_CELL /* on byte-addressable platforms (the only ones we support at the moment) */ 23 #define S48_A_UNITS_PER_CELL (1L << S48_LOG_A_UNITS_PER_CELL) 24 25 #define S48_A_UNITS_TO_CELLS(a) (((unsigned long)a) >> S48_LOG_A_UNITS_PER_CELL) 26 #define S48_CELLS_TO_A_UNITS(c) ((c) << S48_LOG_A_UNITS_PER_CELL) 27 28 /* addressable units <--> bytes */ 29 #define S48_BYTES_TO_A_UNITS(b) S48_CELLS_TO_A_UNITS(S48_BYTES_TO_CELLS(b)) 30 #define S48_A_UNITS_TO_BYTES(a) S48_CELLS_TO_BYTES(S48_A_UNITS_TO_CELLS(a)) 31 32 /* address1+ */ 33 #define S48_ADDRESS_INC(address) ((s48_address)(address + S48_A_UNITS_PER_CELL)) 34 35 #endif 36