vadefs.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the mingw-w64 runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5. */
  6. #ifndef _INC_VADEFS
  7. #define _INC_VADEFS
  8. #include <_mingw.h>
  9. #ifndef __WIDL__
  10. #undef _CRT_PACKING
  11. #define _CRT_PACKING 8
  12. #pragma pack(push,_CRT_PACKING)
  13. #endif
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #if defined (__GNUC__)
  18. #ifndef __GNUC_VA_LIST
  19. #define __GNUC_VA_LIST
  20. typedef __builtin_va_list __gnuc_va_list;
  21. #endif
  22. #endif /* __GNUC__ */
  23. #ifndef _VA_LIST_DEFINED /* if stdargs.h didn't define it */
  24. #define _VA_LIST_DEFINED
  25. #if defined(__GNUC__)
  26. typedef __gnuc_va_list va_list;
  27. #elif defined(_MSC_VER)
  28. typedef char * va_list;
  29. #elif !defined(__WIDL__)
  30. #error VARARGS not implemented for this compiler
  31. #endif
  32. #endif /* _VA_LIST_DEFINED */
  33. #ifdef __cplusplus
  34. #define _ADDRESSOF(v) (&reinterpret_cast<const char &>(v))
  35. #else
  36. #define _ADDRESSOF(v) (&(v))
  37. #endif
  38. #if defined (__GNUC__)
  39. /* Use GCC builtins */
  40. #define _crt_va_start(v,l) __builtin_va_start(v,l)
  41. #define _crt_va_arg(v,l) __builtin_va_arg(v,l)
  42. #define _crt_va_end(v) __builtin_va_end(v)
  43. #define _crt_va_copy(d,s) __builtin_va_copy(d,s)
  44. #elif defined(_MSC_VER)
  45. /* MSVC specific */
  46. #if defined(_M_IA64)
  47. #define _VA_ALIGN 8
  48. #define _SLOTSIZEOF(t) ((sizeof(t) + _VA_ALIGN - 1) & ~(_VA_ALIGN - 1))
  49. #define _VA_STRUCT_ALIGN 16
  50. #define _ALIGNOF(ap) ((((ap)+_VA_STRUCT_ALIGN - 1) & ~(_VA_STRUCT_ALIGN -1)) - (ap))
  51. #define _APALIGN(t,ap) (__alignof(t) > 8 ? _ALIGNOF((uintptr_t) ap) : 0)
  52. #else
  53. #define _SLOTSIZEOF(t) (sizeof(t))
  54. #define _APALIGN(t,ap) (__alignof(t))
  55. #endif
  56. #if defined(_M_IX86)
  57. #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
  58. #define _crt_va_start(v,l) ((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l))
  59. #define _crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l)))
  60. #define _crt_va_end(v) ((v) = (va_list)0)
  61. #define _crt_va_copy(d,s) ((d) = (s))
  62. #elif defined(_M_AMD64)
  63. #define _PTRSIZEOF(n) ((sizeof(n) + sizeof(void*) - 1) & ~(sizeof(void*) - 1))
  64. #define _ISSTRUCT(t) ((sizeof(t) > sizeof(void*)) || (sizeof(t) & (sizeof(t) - 1)) != 0)
  65. #define _crt_va_start(v,l) ((v) = (va_list)_ADDRESSOF(l) + _PTRSIZEOF(l))
  66. #define _crt_va_arg(v,t) _ISSTRUCT(t) ? \
  67. (**(t**)(((v) += sizeof(void*)) - sizeof(void*))) : \
  68. ( *(t *)(((v) += sizeof(void*)) - sizeof(void*)))
  69. #define _crt_va_end(v) ((v) = (va_list)0)
  70. #define _crt_va_copy(d,s) ((d) = (s))
  71. #elif defined(_M_IA64)
  72. #error VARARGS not implemented for IA64
  73. #else
  74. #error VARARGS not implemented for this TARGET
  75. #endif /* cpu ifdefs */
  76. #endif /* compiler ifdefs */
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #ifndef __WIDL__
  81. #pragma pack(pop)
  82. #endif
  83. #endif /* _INC_VADEFS */