__bswap.c 847 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*====================================================================*
  2. *
  3. * __bswap.c - byte swap functions;
  4. *
  5. * endian.h
  6. *
  7. * alternative byte-swap functions for systems without them (such
  8. * as Microsoft Windows);
  9. *
  10. * Motley Tools by Charles Maier <cmaier@cmassoc.net>;
  11. * Copyright (c) 2001-2006 by Charles Maier Associates;
  12. * Licensed under the Internet Software Consortium License;
  13. *
  14. *--------------------------------------------------------------------*/
  15. #ifndef __BSWAP_SOURCE
  16. #define __BSWAP_SOURCE
  17. #include <stdint.h>
  18. #include "../tools/endian.h"
  19. uint16_t __bswap_16 (uint16_t x)
  20. {
  21. endian (& x, sizeof (x));
  22. return (x);
  23. }
  24. uint32_t __bswap_32 (uint32_t x)
  25. {
  26. endian (& x, sizeof (x));
  27. return (x);
  28. }
  29. uint64_t __bswap_64 (uint64_t x)
  30. {
  31. endian (& x, sizeof (x));
  32. return (x);
  33. }
  34. #endif