Date: Thu, 20 Mar 2008 08:32:16 +0100 From: Heiko Wundram <modelnine@modelnine.org> To: freebsd-stable@freebsd.org Subject: pthread_mutexattr_settype non-conformance to man-page and POSIX Message-ID: <200803200832.16340.modelnine@modelnine.org>
next in thread | raw e-mail | index | archive | help
I hit a bug in libthr with pthread_mutexattr_settype which (at least as far as I understand the POSIX reference and also the man-page) makes it non-conformant to the specifications. Quoting: """ RETURN VALUES If successful, these functions return 0. Otherwise, an error number is returned to indicate the error. ... ERRORS ... The pthread_mutexattr_settype() function will fail if: [EINVAL] Invalid value for attr, or invalid value for type. """ This does not happen (at least not in libthr): """ int _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { int ret; if (attr == NULL || *attr == NULL || type >= PTHREAD_MUTEX_TYPE_MAX) { errno = EINVAL; ret = -1; } else { (*attr)->m_type = type; ret = 0; } return(ret); } """ The error code EINVAL is stored to errno, and -1 is returned, which is wrong at least according to my understanding of the man-page, which pretty much says the same thing as POSIX. I haven't looked yet whether this code has always been this way for FreeBSD, but at least under glibc[+NPTL], the error-number is returned directly as the return value (from a quick skimming of the sources), just as I would understand the specifications. The code in question is similar to pretty much all other functions in libthr, which also set errno and return -1, so basically it's a systematic error in the implementation of libthr, if I'm not completely mistaken. Anybody else have any more insight on this? -- Heiko Wundram
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803200832.16340.modelnine>