mirror of the now-defunct rocklinux.org
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.

144 lines
5.4 KiB

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