Opened 3 years ago

Closed 3 years ago

#17521 closed enhancement (fixed)

Add C11 Thread support (easy)

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: R1/beta4
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 (10)

comment:1 by tqh, 3 years ago

I guess there are some types as well?

comment:2 by kallisti5, 3 years 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, 3 years ago

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

comment:4 by kallisti5, 3 years ago

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

comment:7 by pulkomandy, 3 years 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, 3 years ago

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

Version 0, edited 3 years ago by pulkomandy (next)

comment:9 by pulkomandy, 3 years ago

Summary: Add C11 Thread supportAdd C11 Thread support (easy)

comment:10 by korli, 3 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Applied in hrev56041.

Note: See TracTickets for help on using tickets.