tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

reload.c (875B)


      1 #include "tricu.h"
      2 #include <assert.h>
      3 #include <dlfcn.h>
      4 #include <stdint.h>
      5 int main(int argc, char **argv) {
      6     assert(argc == 2);
      7     uint64_t previous = 0;
      8     for (int i = 0; i < 50; ++i) {
      9         void *library = dlopen(argv[1], RTLD_NOW | RTLD_LOCAL);
     10         assert(library);
     11         void (*init)(void) = dlsym(library, "tricu_init");
     12         tricu_status (*create)(tricu_context *) = dlsym(library, "tricu_context_new");
     13         tricu_status (*destroy)(tricu_context) = dlsym(library, "tricu_context_free");
     14         assert(init && create && destroy);
     15         init();
     16         tricu_context context;
     17         assert(create(&context) == TRICU_OK);
     18         assert(context > previous); /* The same process runtime survives dlclose. */
     19         previous = context;
     20         assert(destroy(context) == TRICU_OK);
     21         assert(dlclose(library) == 0);
     22     }
     23     return 0;
     24 }