_info.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "config.h"
  4. /**
  5. * alignof - ALIGNOF() macro to determine alignment of a type.
  6. *
  7. * Many platforms have requirements that certain types must be aligned
  8. * to certain address boundaries, such as ints needing to be on 4-byte
  9. * boundaries. Attempting to access variables with incorrect
  10. * alignment may cause performance loss or even program failure (eg. a
  11. * bus signal).
  12. *
  13. * There are times which it's useful to be able to programatically
  14. * access these requirements, such as for dynamic allocators.
  15. *
  16. * Example:
  17. * #include <stdio.h>
  18. * #include "alignof/alignoff.h"
  19. *
  20. * int main(int argc, char *argv[])
  21. * {
  22. * char arr[sizeof(int)];
  23. *
  24. * if ((unsigned long)arr % ALIGNOF(int)) {
  25. * printf("arr %p CANNOT hold an int\n", arr);
  26. * exit(1);
  27. * } else {
  28. * printf("arr %p CAN hold an int\n", arr);
  29. * exit(0);
  30. * }
  31. * }
  32. */
  33. int main(int argc, char *argv[])
  34. {
  35. if (argc != 2)
  36. return 1;
  37. if (strcmp(argv[1], "depends") == 0) {
  38. printf("build_assert\n");
  39. return 0;
  40. }
  41. return 1;
  42. }