byte_order_generic_x86.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. Without limiting anything contained in the foregoing, this file,
  12. which is part of C Driver for MySQL (Connector/C), is also subject to the
  13. Universal FOSS Exception, version 1.0, a copy of which can be found at
  14. http://oss.oracle.com/licenses/universal-foss-exception.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License, version 2.0, for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  22. /*
  23. Optimized functions for the x86 architecture (_WIN32 included).
  24. x86 handles misaligned reads and writes just fine, so suppress
  25. UBSAN warnings for these functions.
  26. */
  27. static inline int16 sint2korr(const uchar *A) SUPPRESS_UBSAN;
  28. static inline int16 sint2korr(const uchar *A) { return *((int16*) A); }
  29. static inline int32 sint4korr(const uchar *A) SUPPRESS_UBSAN;
  30. static inline int32 sint4korr(const uchar *A) { return *((int32*) A); }
  31. static inline uint16 uint2korr(const uchar *A) SUPPRESS_UBSAN;
  32. static inline uint16 uint2korr(const uchar *A) { return *((uint16*) A); }
  33. static inline uint32 uint4korr(const uchar *A) SUPPRESS_UBSAN;
  34. static inline uint32 uint4korr(const uchar *A) { return *((uint32*) A); }
  35. static inline ulonglong uint8korr(const uchar *A) SUPPRESS_UBSAN;
  36. static inline ulonglong uint8korr(const uchar *A) { return *((ulonglong*) A);}
  37. static inline longlong sint8korr(const uchar *A) SUPPRESS_UBSAN;
  38. static inline longlong sint8korr(const uchar *A) { return *((longlong*) A); }
  39. static inline void int2store(uchar *T, uint16 A) SUPPRESS_UBSAN;
  40. static inline void int2store(uchar *T, uint16 A)
  41. {
  42. *((uint16*) T)= A;
  43. }
  44. static inline void int4store(uchar *T, uint32 A) SUPPRESS_UBSAN;
  45. static inline void int4store(uchar *T, uint32 A)
  46. {
  47. *((uint32*) T)= A;
  48. }
  49. static inline void int8store(uchar *T, ulonglong A) SUPPRESS_UBSAN;
  50. static inline void int8store(uchar *T, ulonglong A)
  51. {
  52. *((ulonglong*) T)= A;
  53. }