Clone of PhatAC @ https://github.com/floaterxk/PhatAC

byte_order_generic_x86.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. /*
  13. Optimized functions for the x86 architecture (_WIN32 included).
  14. x86 handles misaligned reads and writes just fine, so suppress
  15. UBSAN warnings for these functions.
  16. */
  17. static inline int16 sint2korr(const uchar *A) SUPPRESS_UBSAN;
  18. static inline int16 sint2korr(const uchar *A) { return *((int16*) A); }
  19. static inline int32 sint4korr(const uchar *A) SUPPRESS_UBSAN;
  20. static inline int32 sint4korr(const uchar *A) { return *((int32*) A); }
  21. static inline uint16 uint2korr(const uchar *A) SUPPRESS_UBSAN;
  22. static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); }
  23. static inline uint32 uint4korr(const uchar *A) SUPPRESS_UBSAN;
  24. static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); }
  25. static inline ulonglong uint8korr(const uchar *A) SUPPRESS_UBSAN;
  26. static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);}
  27. static inline longlong sint8korr(const uchar *A) SUPPRESS_UBSAN;
  28. static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); }
  29. static inline void int2store(uchar *T, uint16 A) SUPPRESS_UBSAN;
  30. static inline void int2store(uchar *T, uint16 A)
  31. {
  32. *((uint16*) T)= A;
  33. }
  34. static inline void int4store(uchar *T, uint32 A) SUPPRESS_UBSAN;
  35. static inline void int4store(uchar *T, uint32 A)
  36. {
  37. *((uint32*) T)= A;
  38. }
  39. static inline void int8store(uchar *T, ulonglong A) SUPPRESS_UBSAN;
  40. static inline void int8store(uchar *T, ulonglong A)
  41. {
  42. *((ulonglong*) T)= A;
  43. }