__bswap.c 838 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;
  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. #include "../tools/memory.h"
  20. uint16_t __bswap_16 (uint16_t x)
  21. {
  22. reverse (&x, sizeof (x));
  23. return (x);
  24. }
  25. uint32_t __bswap_32 (uint32_t x)
  26. {
  27. reverse (&x, sizeof (x));
  28. return (x);
  29. }
  30. uint64_t __bswap_64 (uint64_t x)
  31. {
  32. reverse (&x, sizeof (x));
  33. return (x);
  34. }
  35. #endif