patch-utils_h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. $OpenBSD: patch-utils_h,v 1.3 2015/05/01 14:17:37 ajacoutot Exp $
  2. --- utils.h.orig Sun Oct 14 09:43:07 2007
  3. +++ utils.h Wed Apr 9 11:05:18 2008
  4. @@ -14,6 +14,7 @@
  5. #include <netinet/in.h>
  6. #include <pthread.h>
  7. #include <signal.h>
  8. +#include <endian.h>
  9. /* True/False definitions */
  10. #ifndef FALSE
  11. @@ -42,6 +43,9 @@
  12. #define ARCH_BIG_ENDIAN 0x4321
  13. #define ARCH_LITTLE_ENDIAN 0x1234
  14. +#ifdef BYTE_ORDER
  15. +#define ARCH_BYTE_ORDER BYTE_ORDER
  16. +#else
  17. #if defined(PPC) || defined(__powerpc__) || defined(__ppc__)
  18. #define ARCH_BYTE_ORDER ARCH_BIG_ENDIAN
  19. #elif defined(__sparc) || defined(__sparc__)
  20. @@ -55,6 +59,7 @@
  21. #elif defined(__ia64__)
  22. #define ARCH_BYTE_ORDER ARCH_LITTLE_ENDIAN
  23. #endif
  24. +#endif
  25. #ifndef ARCH_BYTE_ORDER
  26. #error Please define your architecture in utils.h!
  27. @@ -84,7 +89,7 @@
  28. #define fastcall __attribute__((regparm(3)))
  29. #if __GNUC__ > 2
  30. -#define forced_inline inline __attribute__((always_inline))
  31. +#define forced_inline inline __attribute__ ((always_inline))
  32. #define no_inline __attribute__ ((noinline))
  33. #else
  34. #define forced_inline inline
  35. @@ -255,12 +260,15 @@ static inline u_int normalize_size(u_int val,u_int nb,
  36. return(((val+nb-1) & ~(nb-1)) >> shift);
  37. }
  38. +#ifndef swap16
  39. /* Convert a 16-bit number between little and big endian */
  40. static forced_inline m_uint16_t swap16(m_uint16_t value)
  41. {
  42. return((value >> 8) | ((value & 0xFF) << 8));
  43. }
  44. +#endif
  45. +#ifndef swap32
  46. /* Convert a 32-bit number between little and big endian */
  47. static forced_inline m_uint32_t swap32(m_uint32_t value)
  48. {
  49. @@ -272,7 +280,9 @@ static forced_inline m_uint32_t swap32(m_uint32_t valu
  50. result |= (value & 0xff) << 24;
  51. return(result);
  52. }
  53. +#endif
  54. +#ifndef swap64
  55. /* Convert a 64-bit number between little and big endian */
  56. static forced_inline m_uint64_t swap64(m_uint64_t value)
  57. {
  58. @@ -282,6 +292,7 @@ static forced_inline m_uint64_t swap64(m_uint64_t valu
  59. result |= swap32(value >> 32);
  60. return(result);
  61. }
  62. +#endif
  63. /* Get current time in number of msec since epoch */
  64. static inline m_tmcnt_t m_gettime(void)