Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Newsgroups: comp.lang.c,comp.programming.threads From: John Tsiombikas Subject: Re: Trivial C11 threads.h wrapper (public domain) References: <50643C6A.6020609@web.de> User-Agent: slrn/pre1.0.0-18 (Linux) Message-ID: Date: 27 Sep 2012 16:14:59 GMT Lines: 36 Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 83.169.41.117 X-Trace: news.sunsite.dk DXC=G`61ALZiPbjE406ddB4h2jYSB=nbEKnkk4jUYP[]DMMfE0=08en@m@g6EJNJ\54UWkTIG4S7l5;Fkelf:afgd\Hjd1Q_V1=0FKe]01T`Rm1cHh X-Complaints-To: staff@sunsite.dk Xref: csiph.com comp.lang.c:26727 comp.programming.threads:1101 On 2012-09-27, Markus Elfring wrote: > > I have looked at your source file. > https://github.com/jtsiomb/c11threads/blob/1fa0de734e204c1096d0dabac84d0c4497318944/c11threads.h > > I suggest to consider the following implementation details a bit more. > 1. Would you like to provide a "typedef" for each enumeration? Would I *like* to do that? probably not, but it's not a matter of preference. Unless I'm much mistaken, the C11 standard dictates int as the type of the second argument of mtx_init (where all the mtx_ enumerations go), and as the return of all functions that need to indicate success or failure (thrd_ enumerations). > 2. How do you think about to complete error detection and corresponding > exception handling? > 2.1 Mapping of error codes from the POSIX thread interface to the values that > are specified by the current standard for the C programming language. I just went through both docs and tried to map pthread error codes to corresponding C11-mandated error codes. Those that had no counterpart, I just ignored, or bundled them all together under thrd_error as appropriate. Do you propose a different strategy? > 2.2 pthread_mutexattr_init/destroy Yes that was the most hairy bit. This mechanism doesn't seem to map exactly to what C11 wants. For instance the C standard talks about the possibility of having a mtx_timed | mtx_recursive mutex, but as far as I can tell with pthreads I can specify either PTHREAD_MUTEX_RECURSIVE or PTHREAD_MUTEX_TIMED_NP (which is not even standard), but not both. -- John Tsiombikas http://nuclear.mutantstargoat.com/