memory.h 1.2 KB

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