Functions missing from Glibc

Hey everyone! I have no clue what version of Glibc swift imports by default in SwiftPM on ubuntu but for me it is missing some critical thread functions. As of some of the newer version of Glibc, threads.h is built in with some C thread functions. I wanted to use those functions from swift to do some multithreading as it will be a bit easier for me to target this library. I do know that GCD exists but I would really like to try and get these functions imported. Any idea how I can get the C11 ISO library from Glibc into swift? I could be totally clueless on how this stuff actually works I was just looking at the most recent 2.30 release of Glibc which is installed on my machine. Anyway, thank you all so much!

A few of the functions I'm trying to use from swift are (which are not imported when using import Glibc):

thrd_create (thrd_t *thr, thrd_start_t func, void *arg);
thrd_join (thrd_t thr, int *res);
thrd_detach (thrd_t thr)
thrd_exit (int res)

AFAIK, these are just wrappers over pthreads. The easiest way would be to just use the pthread functions.

If you are really trying to use these functions with these spellings, you could create a custom module that wraps threads.h with a module map to access them.

1 Like

Thank you so much! Yep all of the pthread functions are there. Will use those. YOU ARE AMAZING!

You're very welcome :slight_smile:

1 Like