impl.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* This file essentially describes how the mallink info block
  7. is implemented.
  8. */
  9. #define MIN_SIZE (1<<LOG_MIN_SIZE)
  10. #define MAX_FLIST (LOG_MAX_SIZE - LOG_MIN_SIZE)
  11. #if ALIGNMENT != 4 && ALIGNMENT != 8 && ALIGNMENT != 16
  12. ALIGNMENT must be 4, 8, or 16
  13. #endif
  14. #if MIN_SIZE % ALIGNMENT
  15. ALIGNMENT must be a dividor of MIN_SIZE
  16. #endif
  17. #if ALIGNMENT == 4
  18. #define LOG_ALIGNMENT 2
  19. #endif
  20. #if ALIGNMENT == 8
  21. #define LOG_ALIGNMENT 3
  22. #endif
  23. #if ALIGNMENT == 16
  24. #define LOG_ALIGNMENT 4
  25. #endif
  26. #define align(n) (((n) + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1))
  27. union _inf {
  28. union _inf *ptr;
  29. size_type ui;
  30. };
  31. typedef union _inf mallink;
  32. #define MAL_NULL ((mallink *)0)
  33. /* Access macros; only these macros know where to find values.
  34. They are also lvalues.
  35. */
  36. #ifndef NON_STANDARD
  37. #define OFF_SET 0
  38. #else /* def NON_STANDARD */
  39. #define OFF_SET 2
  40. #endif /* NON_STANDARD */
  41. #define _log_prev_of(ml) ((ml)[-1+OFF_SET]).ptr
  42. #define _log_next_of(ml) ((ml)[-2+OFF_SET]).ptr
  43. #define _phys_prev_of(ml) ((ml)[-3+OFF_SET]).ptr
  44. #define _this_size_of(ml) ((ml)[-4+OFF_SET]).ui
  45. #ifndef CHECK
  46. #define N_WORDS 4
  47. #else /* ifdef CHECK */
  48. #define _checksum_of(ml) ((ml)[-5+OFF_SET]).ui
  49. #define _print_of(ml) ((ml)[-6+OFF_SET]).ui
  50. #define _mark_of(ml) ((ml)[-7+OFF_SET]).ui
  51. #define N_WORDS 7
  52. #endif /* CHECK */
  53. #define mallink_size() (unsigned int) \
  54. align((N_WORDS - OFF_SET) * sizeof (mallink))
  55. #ifdef CHECK
  56. #define set_mark(ml,e) (_mark_of(ml) = (e))
  57. #define mark_of(ml) (_mark_of(ml))
  58. #define set_checksum(ml,e) (_checksum_of(ml) = (e))
  59. #define checksum_of(ml) (_checksum_of(ml))
  60. #endif /* CHECK */
  61. #define new_mallink(ml) ( _log_prev_of(ml) = 0, \
  62. _log_next_of(ml) = 0, \
  63. _phys_prev_of(ml) = 0, \
  64. _this_size_of(ml) = 0 )
  65. #define block_of_mallink(ml) ((char *)ml)
  66. #define mallink_of_block(addr) ((mallink *)addr)
  67. #define public extern
  68. #define publicdata extern
  69. #ifndef EXTERN
  70. #define private static
  71. #define privatedata static
  72. #else /* def EXTERN */
  73. #define private extern
  74. #define privatedata
  75. #endif /* EXTERN */
  76. #ifdef ASSERT
  77. public m_assert();
  78. #define assert(b) (!(b) ? m_assert(__FILE__, __LINE__) : 0)
  79. #else /* ndef ASSERT */
  80. #define assert(b) 0
  81. #endif /* ASSERT */