_info 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * endian - endian conversion macros for simple types
  6. *
  7. * Portable protocols (such as on-disk formats, or network protocols)
  8. * are often defined to be a particular endian: little-endian (least
  9. * significant bytes first) or big-endian (most significant bytes
  10. * first).
  11. *
  12. * Similarly, some CPUs lay out values in memory in little-endian
  13. * order (most commonly, Intel's 8086 and derivatives), or big-endian
  14. * order (almost everyone else).
  15. *
  16. * This module provides conversion routines, inspired by the linux kernel.
  17. *
  18. * Example:
  19. * #include <stdio.h>
  20. * #include <err.h>
  21. * #include <ccan/endian/endian.h>
  22. *
  23. * //
  24. * int main(int argc, char *argv[])
  25. * {
  26. * uint32_t value;
  27. *
  28. * if (argc != 2)
  29. * errx(1, "Usage: %s <value>", argv[0]);
  30. *
  31. * value = atoi(argv[1]);
  32. * printf("native: %08x\n", value);
  33. * printf("little-endian: %08x\n", cpu_to_le32(value));
  34. * printf("big-endian: %08x\n", cpu_to_be32(value));
  35. * printf("byte-reversed: %08x\n", swab_u32(value));
  36. * exit(0);
  37. * }
  38. *
  39. * License: LGPL (2 or any later version)
  40. * Author: Rusty Russell <rusty@rustcorp.com.au>
  41. */
  42. int main(int argc, char *argv[])
  43. {
  44. if (argc != 2)
  45. return 1;
  46. if (strcmp(argv[1], "depends") == 0)
  47. /* Nothing */
  48. return 0;
  49. return 1;
  50. }