Source code of Windows XP (NT5)
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.

69 lines
1.4 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. cpyuchr.h
  5. Abstract:
  6. A more central set of definitions for unpacking unaligned
  7. data (i.e. for unbpacking bios parameter blocks).
  8. Author:
  9. Revision History:
  10. --*/
  11. #ifndef CopyUchar1
  12. //
  13. // The following types and macros are used to help unpack the packed and
  14. // misaligned fields found in the Bios parameter block
  15. //
  16. typedef union _UCHAR1 {
  17. UCHAR Uchar[1];
  18. UCHAR ForceAlignment;
  19. } UCHAR1, *PUCHAR1;
  20. typedef union _UCHAR2 {
  21. UCHAR Uchar[2];
  22. USHORT ForceAlignment;
  23. } UCHAR2, *PUCHAR2;
  24. typedef union _UCHAR4 {
  25. UCHAR Uchar[4];
  26. ULONG ForceAlignment;
  27. } UCHAR4, *PUCHAR4;
  28. //
  29. // This macro copies an unaligned src byte to an aligned dst byte
  30. //
  31. #define CopyUchar1(Dst,Src) { \
  32. *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
  33. }
  34. //
  35. // This macro copies an unaligned src word to an aligned dst word
  36. //
  37. #define CopyUchar2(Dst,Src) { \
  38. *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
  39. }
  40. //
  41. // This macro copies an unaligned src longword to an aligned dsr longword
  42. //
  43. #define CopyUchar4(Dst,Src) { \
  44. *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
  45. }
  46. #define CopyU4char(Dst,Src) { \
  47. *((UNALIGNED UCHAR4 *)(Dst)) = *((UCHAR4 *)(Src)); \
  48. }
  49. #endif