1 // Header to handle CDSChecker bullshit.
2 // Handles most things, not just threads:
3 // - Catches C11 threads and forwards to C++11 threads.
4 // - Catches store_n and load_n and turns them into normal stores/loads.
5 // - Replaces user_main with just main.
17 #define thrd_t std::thread
18 typedef int (*thrd_start_t)(void *);
20 static std::map<std::string, std::thread> thrs;
22 #define thrd_create(T, F, A) new_thread(#T, F, A)
23 static void new_thread(const char *t, thrd_start_t f, void *args) {
24 assert(thrs.emplace(std::string(++t), std::thread(*f, args)).second);
27 #define thrd_join(T) end_thread(#T)
28 static void end_thread(const char *t) {
29 thrs[std::string(t)].join();
32 #define thrd_yield() std::this_thread::yield()
34 #define user_main main
38 #endif // __THREADS_H__