brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · d77c679 Raw
63 lines · cpp
1#include <dlfcn.h>2#include <stdio.h>3#include <thread>4#include <unistd.h>5 6void f1() {7  while (1)8    sleep(1);9}10void f2() {11  while (1)12    sleep(1);13}14void f3() {15  while (1)16    sleep(1);17}18 19int main() {20  std::thread t1{f1};21  std::thread t2{f2};22  std::thread t3{f3};23 24  puts("break here");25 26  void *handle = dlopen("libfoo.dylib", RTLD_LAZY);27  int (*foo_ptr)() = (int (*)())dlsym(handle, "foo");28  int c = foo_ptr();29 30  // clang-format off31  // multiple function calls on a single source line so 'step'32  // and 'next' need to do multiple steps of work.33  puts("1"); puts("2"); puts("3"); puts("4"); puts("5");34  puts("6"); puts("7"); puts("8"); puts("9"); puts("10");35  puts("11"); puts("12"); puts("13"); puts("14"); puts("15");36  puts("16"); puts("17"); puts("18"); puts("19"); puts("20");37  puts("21"); puts("22"); puts("23"); puts("24"); puts("24");38  // clang-format on39  puts("one");40  puts("two");41  puts("three");42  puts("four");43  puts("five");44  puts("six");45  puts("seven");46  puts("eight");47  puts("nine");48  puts("ten");49  c++;50  c++;51  c++;52  c++;53  c++;54  c++;55  c++;56  c++;57  c++;58  c++;59  c++;60  c++;61  return c;62}63