store_test.c 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "test.h"
  2. /* Test store/load macros with offsets */
  3. int store_test(void)
  4. {
  5. unsigned char buf[24];
  6. unsigned long L, L1;
  7. int y;
  8. ulong64 LL, LL1;
  9. L = 0x12345678UL;
  10. for (y = 0; y < 4; y++) {
  11. STORE32L(L, buf + y);
  12. LOAD32L(L1, buf + y);
  13. if (L1 != L) {
  14. fprintf(stderr, "\n32L failed at offset %d\n", y);
  15. return 1;
  16. }
  17. STORE32H(L, buf + y);
  18. LOAD32H(L1, buf + y);
  19. if (L1 != L) {
  20. fprintf(stderr, "\n32H failed at offset %d\n", y);
  21. return 1;
  22. }
  23. }
  24. LL = CONST64 (0x01020304050607);
  25. for (y = 0; y < 8; y++) {
  26. STORE64L(LL, buf + y);
  27. LOAD64L(LL1, buf + y);
  28. if (LL1 != LL) {
  29. fprintf(stderr, "\n64L failed at offset %d\n", y);
  30. return 1;
  31. }
  32. STORE64H(LL, buf + y);
  33. LOAD64H(LL1, buf + y);
  34. if (LL1 != LL) {
  35. fprintf(stderr, "\n64H failed at offset %d\n", y);
  36. return 1;
  37. }
  38. }
  39. return 0;
  40. }