impl.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 != 1 && ALIGNMENT != 2 && ALIGNMENT != 4 && ALIGNMENT != 8 &&\
  12. ALIGNMENT != 16
  13. ALIGNMENT must be a (small) power of two !!!
  14. #endif
  15. #define align(n) (((n) + (ALIGNMENT - 1)) & ~(ALIGNMENT - 1))
  16. union _inf {
  17. union _inf *ptr;
  18. unsigned int ui;
  19. };
  20. typedef union _inf mallink;
  21. #define MAL_NULL ((mallink *)0)
  22. /* Access macros; only these macros know where to find values.
  23. They are also lvalues.
  24. */
  25. #ifndef NON_STANDARD
  26. #define OFF_SET 0
  27. #else def NON_STANDARD
  28. #define OFF_SET 2
  29. #endif NON_STANDARD
  30. #define _log_prev_of(ml) ((ml)[-1+OFF_SET]).ptr
  31. #define _log_next_of(ml) ((ml)[-2+OFF_SET]).ptr
  32. #define _phys_prev_of(ml) ((ml)[-3+OFF_SET]).ptr
  33. #define _this_size_of(ml) ((ml)[-4+OFF_SET]).ui
  34. #ifndef CHECK
  35. #define N_WORDS 4
  36. #else ifdef CHECK
  37. #define _checksum_of(ml) ((ml)[-5+OFF_SET]).ui
  38. #define _print_of(ml) ((ml)[-6+OFF_SET]).ui
  39. #define _mark_of(ml) ((ml)[-7+OFF_SET]).ui
  40. #define N_WORDS 7
  41. #endif CHECK
  42. #define mallink_size() (unsigned int) \
  43. align((N_WORDS - OFF_SET) * sizeof (mallink))
  44. #ifdef CHECK
  45. #define set_mark(ml,e) (_mark_of(ml) = (e))
  46. #define mark_of(ml) (_mark_of(ml))
  47. #define set_checksum(ml,e) (_checksum_of(ml) = (e))
  48. #define checksum_of(ml) (_checksum_of(ml))
  49. #endif CHECK
  50. #define block_of_mallink(ml) ((char *)ml)
  51. #define mallink_of_block(addr) ((mallink *)addr)
  52. #define public extern
  53. #define publicdata
  54. #ifndef EXTERN
  55. #define private static
  56. #define privatedata static
  57. #else def EXTERN
  58. #define private extern
  59. #define privatedata
  60. #endif EXTERN
  61. #ifdef ASSERT
  62. public m_assert();
  63. #define assert(b) (!(b) ? m_assert(__FILE__, __LINE__) : 0)
  64. #else ndef ASSERT
  65. #define assert(b) 0
  66. #endif ASSERT