load-parallel0.m 1015 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef N
  2. #error -DN=n missing
  3. #endif
  4. #import <objc/objc-api.h>
  5. #include <stdio.h>
  6. #include <sched.h>
  7. #include <unistd.h>
  8. #include "test.h"
  9. extern atomic_int state;
  10. #define CLASS0(n,nn) \
  11. OBJC_ROOT_CLASS \
  12. @interface C_##n##_##nn @end \
  13. @implementation C_##n##_##nn \
  14. +(void)load { \
  15. atomic_fetch_add_explicit(&state, 1, memory_order_relaxed); \
  16. usleep(10); } \
  17. @end
  18. #define CLASS(n,nn) CLASS0(n,nn)
  19. CLASS(a,N)
  20. CLASS(b,N)
  21. CLASS(c,N)
  22. CLASS(d,N)
  23. CLASS(e,N)
  24. CLASS(f,N)
  25. CLASS(g,N)
  26. CLASS(h,N)
  27. CLASS(i,N)
  28. CLASS(j,N)
  29. CLASS(k,N)
  30. CLASS(l,N)
  31. CLASS(m,N)
  32. CLASS(n,N)
  33. CLASS(o,N)
  34. CLASS(p,N)
  35. CLASS(q,N)
  36. CLASS(r,N)
  37. CLASS(s,N)
  38. CLASS(t,N)
  39. CLASS(u,N)
  40. CLASS(v,N)
  41. CLASS(w,N)
  42. CLASS(x,N)
  43. CLASS(y,N)
  44. CLASS(z,N)