Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.4 KiB

  1. /*
  2. * A L I G N . H
  3. *
  4. * Alignment macros
  5. *
  6. * Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  7. */
  8. #ifndef _ALIGN_H_
  9. #define _ALIGN_H_
  10. // Alignments ----------------------------------------------------------------
  11. //
  12. #undef AlignN
  13. #undef Align2
  14. #undef Align4
  15. #undef Align8
  16. #undef AlignNatural
  17. #undef FIsAlignedCb
  18. #undef FIsAligned
  19. enum {
  20. ALIGN_NONE = 0,
  21. ALIGN_WORD,
  22. ALIGN_INTEL,
  23. ALIGN_RISC,
  24. ALIGN_16BYTE,
  25. ALIGN_128BYTE = 7,
  26. ALIGN_4K = 12,
  27. #if defined (_AMD64_) || defined (_IA64_)
  28. ALIGN_NATURAL = ALIGN_RISC
  29. #elif defined (WIN32)
  30. ALIGN_NATURAL = ALIGN_INTEL
  31. #endif
  32. };
  33. #define AlignN(x,n) (((x)+(1<<(n))-1) & ~((1<<(n))-1))
  34. #define PadN(x,n) (AlignN(x,n) - (x))
  35. #define Align2(x) AlignN((x),ALIGN_WORD)
  36. #define Align4(x) AlignN((x),ALIGN_INTEL)
  37. #define Align8(x) AlignN((x),ALIGN_RISC)
  38. #define Align16(x) AlignN((x),ALIGN_16BYTE)
  39. #define Align128(x) AlignN((x),ALIGN_128BYTE)
  40. #define Align4K(x) AlignN((x),ALIGN_4K)
  41. #define AlignNatural(x) AlignN((x),ALIGN_NATURAL)
  42. #define Pad2(x) PadN((x),ALIGN_WORD)
  43. #define Pad4(x) PadN((x),ALIGN_INTEL)
  44. #define Pad8(x) PadN((x),ALIGN_RISC)
  45. #define Pad16(x) PadN((x),ALIGN_16BYTE)
  46. #define Pad4K(x) PadN((x),ALIGN_4K)
  47. #define FIsAlignedCb(x) (AlignNatural((ULONG_PTR)(x)) == (ULONG_PTR)(x))
  48. #define FIsAligned(x) (FIsAlignedCb((LPVOID)(x)))
  49. #endif // _ALIGN_H_