byteorder.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. Taken from libmemcached.
  3. */
  4. /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
  5. *
  6. * Gearmand client and server library.
  7. *
  8. * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are
  13. * met:
  14. *
  15. * * Redistributions of source code must retain the above copyright
  16. * notice, this list of conditions and the following disclaimer.
  17. *
  18. * * Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following disclaimer
  20. * in the documentation and/or other materials provided with the
  21. * distribution.
  22. *
  23. * * The names of its contributors may not be used to endorse or
  24. * promote products derived from this software without specific prior
  25. * written permission.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  30. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  31. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  32. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  33. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  34. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  35. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  36. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  37. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #pragma once
  41. #ifdef linux
  42. /* /usr/include/netinet/in.h defines macros from ntohs() to _bswap_nn to
  43. * optimize the conversion functions, but the prototypes generate warnings
  44. * from gcc. The conversion methods isn't the bottleneck for my app, so
  45. * just remove the warnings by undef'ing the optimization ..
  46. */
  47. #undef ntohs
  48. #undef ntohl
  49. #undef htons
  50. #undef htonl
  51. #endif