OpenSDE Packages Database (without history before r20070)
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.

139 lines
5.2 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../dietlibc/byteswap_prot_h.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2004 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This patch file is dual-licensed. It is available under the license the
  11. # patched project is licensed under, as long as it is an OpenSource license
  12. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  13. # of the GNU General Public License as published by the Free Software
  14. # Foundation; either version 2 of the License, or (at your option) any later
  15. # version.
  16. # --- T2-COPYRIGHT-NOTE-END ---
  17. e2fsprogs >_<
  18. --- /dev/null Thu Jan 1 00:00:00 1970
  19. +++ ./include/byteswap_prot.h Sat Jan 11 01:23:36 2003
  20. @@ -0,0 +1,117 @@
  21. +/* Macros to swap the order of bytes in integer values.
  22. + Copyright (C) 1997, 1998, 2000, 2002 Free Software Foundation, Inc.
  23. + This file is part of the GNU C Library.
  24. +
  25. + The GNU C Library is free software; you can redistribute it and/or
  26. + modify it under the terms of the GNU Lesser General Public
  27. + License as published by the Free Software Foundation; either
  28. + version 2.1 of the License, or (at your option) any later version.
  29. +
  30. + The GNU C Library is distributed in the hope that it will be useful,
  31. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  33. + Lesser General Public License for more details.
  34. +
  35. + You should have received a copy of the GNU Lesser General Public
  36. + License along with the GNU C Library; if not, write to the Free
  37. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  38. + 02111-1307 USA. */
  39. +
  40. +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
  41. +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
  42. +#endif
  43. +
  44. +#ifndef _BITS_BYTESWAP_H
  45. +#define _BITS_BYTESWAP_H 1
  46. +
  47. +/* Swap bytes in 16 bit value. */
  48. +#define __bswap_constant_16(x) \
  49. + ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))
  50. +
  51. +#if defined __GNUC__ && __GNUC__ >= 2
  52. +# define __bswap_16(x) \
  53. + (__extension__ \
  54. + ({ register unsigned short int __v, __x = (x); \
  55. + if (__builtin_constant_p (__x)) \
  56. + __v = __bswap_constant_16 (__x); \
  57. + else \
  58. + __asm__ ("rorw $8, %w0" \
  59. + : "=r" (__v) \
  60. + : "0" (__x) \
  61. + : "cc"); \
  62. + __v; }))
  63. +#else
  64. +/* This is better than nothing. */
  65. +# define __bswap_16(x) \
  66. + (__extension__ \
  67. + ({ register unsigned short int __x = (x); __bswap_constant_16 (__x); }))
  68. +#endif
  69. +
  70. +
  71. +/* Swap bytes in 32 bit value. */
  72. +#define __bswap_constant_32(x) \
  73. + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
  74. + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
  75. +
  76. +#if defined __GNUC__ && __GNUC__ >= 2
  77. +/* To swap the bytes in a word the i486 processors and up provide the
  78. + `bswap' opcode. On i386 we have to use three instructions. */
  79. +# if !defined __i486__ && !defined __pentium__ && !defined __pentiumpro__
  80. +# define __bswap_32(x) \
  81. + (__extension__ \
  82. + ({ register unsigned int __v, __x = (x); \
  83. + if (__builtin_constant_p (__x)) \
  84. + __v = __bswap_constant_32 (__x); \
  85. + else \
  86. + __asm__ ("rorw $8, %w0;" \
  87. + "rorl $16, %0;" \
  88. + "rorw $8, %w0" \
  89. + : "=r" (__v) \
  90. + : "0" (__x) \
  91. + : "cc"); \
  92. + __v; }))
  93. +# else
  94. +# define __bswap_32(x) \
  95. + (__extension__ \
  96. + ({ register unsigned int __v, __x = (x); \
  97. + if (__builtin_constant_p (__x)) \
  98. + __v = __bswap_constant_32 (__x); \
  99. + else \
  100. + __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); \
  101. + __v; }))
  102. +# endif
  103. +#else
  104. +# define __bswap_16(x) \
  105. + (__extension__ \
  106. + ({ register unsigned int __x = (x); __bswap_constant_32 (__x); }))
  107. +#endif
  108. +
  109. +
  110. +#if defined __GNUC__ && __GNUC__ >= 2
  111. +/* Swap bytes in 64 bit value. */
  112. +#define __bswap_constant_64(x) \
  113. + ((((x) & 0xff00000000000000ull) >> 56) \
  114. + | (((x) & 0x00ff000000000000ull) >> 40) \
  115. + | (((x) & 0x0000ff0000000000ull) >> 24) \
  116. + | (((x) & 0x000000ff00000000ull) >> 8) \
  117. + | (((x) & 0x00000000ff000000ull) << 8) \
  118. + | (((x) & 0x0000000000ff0000ull) << 24) \
  119. + | (((x) & 0x000000000000ff00ull) << 40) \
  120. + | (((x) & 0x00000000000000ffull) << 56))
  121. +
  122. +# define __bswap_64(x) \
  123. + (__extension__ \
  124. + ({ union { __extension__ unsigned long long int __ll; \
  125. + unsigned long int __l[2]; } __w, __r; \
  126. + __w.__ll = (x); \
  127. + if (__builtin_constant_p (__w.__ll)) \
  128. + __r.__ll = __bswap_constant_64 (__w.__ll); \
  129. + else \
  130. + { \
  131. + __r.__l[0] = __bswap_32 (__w.__l[1]); \
  132. + __r.__l[1] = __bswap_32 (__w.__l[0]); \
  133. + } \
  134. + __r.__ll; }))
  135. +#endif
  136. +
  137. +#endif /* _BITS_BYTESWAP_H */