Opened 11 days ago

Last modified 10 days ago

#17521 new enhancement

Add C11 Thread support (easy)

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/POSIX Version: R1/beta3
Keywords: C11 Cc:
Blocked By: Blocking:
Platform: All

Description

Mesa was asking about us getting C11 threads. From what I can tell we don't offer this today.

C11 Threads    POSIX Threads
thrd_create()  pthread_create()
thrd_current() pthread_self()
thrd_detach()  pthread_detach()
thrd_equal()   pthread_equal()
thrd_exit()    pthread_exit()
thrd_join()    pthread_join()

Today we offer BeOS native things like thread_id find_thread(const char *name); , and POSIX threads like pthread_t pthread_self(void);

Change History (9)

comment:1 by tqh, 11 days ago

I guess there are some types as well?

comment:2 by kallisti5, 11 days ago

probably :-)

http://open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3631.pdf

Getting the C11 Standard
C11 and C++11 are available from the ANSI store.  For C11, use this link:
http://webstore.ansi.org/RecordDetail.aspx?sku=INCITS%2fISO%2fIEC+9899‐2012.  For C++11, use this
link: http://webstore.ansi.org/RecordDetail.aspx?sku=INCITS%2fISO%2fIEC+14882‐2012 .  Each costs
$30 USD for PDF. The whole process takes only a few minutes.

hm.

comment:3 by tqh, 11 days ago

Lets not buy it, we kind of do like challenges :)

comment:4 by kallisti5, 11 days ago

lol. we definitely should reverse engineer something that only costs $30

comment:7 by pulkomandy, 10 days ago

Apparently this does not require anything specific in GCC, so we should be able to copy an implementation from a C library as we usually do (glibc 2.28 or later, or *BSD or musl).

musl has some thrd_* things: https://git.musl-libc.org/cgit/musl/tree/src/thread/thrd_create.c , it seems to call into musl internals directly FreeBSD docs: https://www.freebsd.org/cgi/man.cgi?query=thrd_create&apropos=0&sektion=0&arch=default&format=html says they implement it as "a thin wrapper over pthreds" so that may be easy to reuse

comment:8 by pulkomandy, 10 days ago

It looks like we just need this one file from FreeBSD: https://xref.landonf.org/source/xref/freebsd-current/lib/libstdthreads/

Last edited 10 days ago by pulkomandy (previous) (diff)

comment:9 by pulkomandy, 10 days ago

Summary: Add C11 Thread supportAdd C11 Thread support (easy)
Note: See TracTickets for help on using tickets.