load-reentrant2.m 435 B

1234567891011121314151617181920212223
  1. #include "test.h"
  2. int state2 = 0;
  3. extern int state1;
  4. static void ctor(void) __attribute__((constructor));
  5. static void ctor(void)
  6. {
  7. // should be called during One's dlopen(), before Two's +load
  8. testassert(state1 == 111);
  9. testassert(state2 == 0);
  10. }
  11. OBJC_ROOT_CLASS
  12. @interface Two @end
  13. @implementation Two
  14. +(void) load
  15. {
  16. // Does not run until One's +load completes
  17. testassert(state1 == 1);
  18. state2 = 2;
  19. }
  20. @end