macros.h 832 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef LIBDPKG_MACROS_H
  2. #define LIBDPKG_MACROS_H
  3. /* Language definitions. */
  4. #if HAVE_C_ATTRIBUTE
  5. #define DPKG_ATTR_UNUSED __attribute__((unused))
  6. #define DPKG_ATTR_CONST __attribute__((const))
  7. #define DPKG_ATTR_NORET __attribute__((noreturn))
  8. #define DPKG_ATTR_PRINTF(n) __attribute__((format(printf, n, n + 1)))
  9. #else
  10. #define DPKG_ATTR_UNUSED
  11. #define DPKG_ATTR_CONST
  12. #define DPKG_ATTR_NORET
  13. #define DPKG_ATTR_PRINTF(n)
  14. #endif
  15. #ifdef __cplusplus
  16. #define DPKG_BEGIN_DECLS extern "C" {
  17. #define DPKG_END_DECLS }
  18. #else
  19. #define DPKG_BEGIN_DECLS
  20. #define DPKG_END_DECLS
  21. #endif
  22. #ifndef sizeof_array
  23. #define sizeof_array(a) (sizeof(a) / sizeof((a)[0]))
  24. #endif
  25. #ifndef min
  26. #define min(a, b) ((a) < (b) ? (a) : (b))
  27. #endif
  28. #ifndef max
  29. #define max(a, b) ((a) > (b) ? (a) : (b))
  30. #endif
  31. #endif /* LIBDPKG_MACROS_H */