From owner-freebsd-threads@FreeBSD.ORG Mon Dec 12 11:07:34 2011 Return-Path: Delivered-To: freebsd-threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A8089106564A for ; Mon, 12 Dec 2011 11:07:34 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7B3E18FC14 for ; Mon, 12 Dec 2011 11:07:34 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBCB7YRQ030174 for ; Mon, 12 Dec 2011 11:07:34 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBCB7Xsv030172 for freebsd-threads@FreeBSD.org; Mon, 12 Dec 2011 11:07:33 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 12 Dec 2011 11:07:33 GMT Message-Id: <201112121107.pBCB7Xsv030172@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-threads@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-threads@FreeBSD.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2011 11:07:34 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o threa/160708 threads possible security problem with RLIMIT_VMEM o threa/157040 threads [libthr] valgrind detects leaks in libthr.so.3 o threa/154893 threads pthread_sigmask don't work if mask and oldmask are pas o threa/150959 threads [libc] Stub pthread_once in libc should call _libc_onc o threa/149366 threads pthread_cleanup_pop never runs the configured routine o threa/148515 threads Memory / syslog strangeness in FreeBSD 8.x ( possible o threa/141721 threads rtprio(1): (id|rt)prio priority resets when new thread o threa/135673 threads databases/mysql50-server - MySQL query lock-ups on 7.2 o threa/128922 threads threads hang with xorg running o threa/127225 threads bug in lib/libthr/thread/thr_init.c o threa/122923 threads 'nice' does not prevent background process from steali o threa/121336 threads lang/neko threading ok on UP, broken on SMP (FreeBSD 7 o threa/116668 threads can no longer use jdk15 with libthr on -stable SMP o threa/115211 threads pthread_atfork misbehaves in initial thread o threa/110636 threads [request] gdb(1): using gdb with multi thread applicat o threa/110306 threads apache 2.0 segmentation violation when calling gethost o threa/103975 threads Implicit loading/unloading of libpthread.so may crash o threa/101323 threads [patch] fork(2) in threaded programs broken. s threa/84483 threads problems with devel/nspr and -lc_r on 4.x o threa/80992 threads abort() sometimes not caught by gdb depending on threa o threa/79683 threads svctcp_create() fails if multiple threads call at the s threa/76694 threads fork cause hang in dup()/close() function in child (-l s threa/48856 threads Setting SIGCHLD to SIG_IGN still leaves zombies under s threa/34536 threads accept() blocks other threads s threa/30464 threads [patch] pthread mutex attributes -- pshared 25 problems total. From owner-freebsd-threads@FreeBSD.ORG Fri Dec 16 21:49:15 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4B6910656A7; Fri, 16 Dec 2011 21:49:15 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 7B8B08FC12; Fri, 16 Dec 2011 21:49:14 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id 627E92A28E79; Fri, 16 Dec 2011 22:49:13 +0100 (CET) Date: Fri, 16 Dec 2011 22:49:13 +0100 From: Ed Schouten To: threads@freebsd.org, arch@freebsd.org Message-ID: <20111216214913.GA1771@hoeg.nl> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MvEh5MSbieV/1Yst" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Subject: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 21:49:15 -0000 --MvEh5MSbieV/1Yst Content-Type: multipart/mixed; boundary="HSVPcR81XVhxeM7P" Content-Disposition: inline --HSVPcR81XVhxeM7P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi folks, We can expect C11 (or C12) to be released in the nearby future. I already took the liberty of adding fallbacks for some of the language keywords to , but it seems the standard also includes a new threading API. In my opinion the ISO folks suffer a bit from the Not Invented Here syndrome. In an earlier revision of the C1X specification, they even described a `struct xtime', which had a purpose identical to `struct timespec'. The same holds for the threading API. It can be 1:1 mapped to a subset of pthread -- why not simply standardize that subset then? Putting my personal objections aside, I do think we should add support for the API by the time C1X is final. Attached is a patch that adds the new API to libthr. It simply wraps all the calls around pthread. Even the objects used by the API are type compatible with the ones used by pthread. The questions: - As this API is just a second-class citizen and will not be used by the C library, I suspect there is no need for underscore prefixing and weak aliasing. Is this correct? - When accompanied with man pages, are there any objections if I commit this to SVN when C1X is official? Thanks, --=20 Ed Schouten WWW: http://80386.nl/ --HSVPcR81XVhxeM7P Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="c1x-threads.diff" Content-Transfer-Encoding: quoted-printable Index: include/threads.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- include/threads.h (revision 0) +++ include/threads.h (working copy) @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _THREADS_H_ +#define _THREADS_H_ + +#include + +/* + * The C1X threads interface. + * + * This interface is implemented as a light-weight wrapper around + * . To prevent namespace pollution, the once_flag object, + * its corresponding ONCE_FLAG_INIT and TSS_DTOR_ITERATIONS have been + * copied from this header file. They must be kept in sync. + */ + +typedef struct pthread_cond *cnd_t; +typedef struct pthread_mutex *mtx_t; +typedef struct pthread *thrd_t; +typedef int tss_t; + +typedef struct { + int __state; + mtx_t __mutex; +} once_flag; + +typedef void (*tss_dtor_t)(void *); +typedef int (*thrd_start_t)(void *); + +enum { + mtx_plain =3D 0x1, + mtx_recursive =3D 0x2, + mtx_timed =3D 0x4 +}; + +enum { + thrd_busy =3D 1, + thrd_error =3D 2, + thrd_nomem =3D 3, + thrd_success =3D 4, + thrd_timedout =3D 5 +}; + +#if !defined(__cplusplus) || __cplusplus < 201103L +#define thread_local _Thread_local +#endif +#define ONCE_FLAG_INIT { 0, NULL } +#define TSS_DTOR_ITEARTIONS 4 + +__BEGIN_DECLS +void call_once(once_flag *, void (*)(void)); +int cnd_broadcast(cnd_t *); +void cnd_destroy(cnd_t *); +int cnd_init(cnd_t *); +int cnd_signal(cnd_t *); +int cnd_timedwait(cnd_t *__restrict, mtx_t *__restrict, + const struct timespec *__restrict); +int cnd_wait(cnd_t *, mtx_t *); +void mtx_destroy(mtx_t *); +int mtx_init(mtx_t *, int); +int mtx_lock(mtx_t *); +int mtx_timedlock(mtx_t *__restrict, const struct timespec *__restrict); +int mtx_trylock(mtx_t *); +int mtx_unlock(mtx_t *); +int thrd_create(thrd_t *, thrd_start_t, void *); +thrd_t thrd_current(void); +int thrd_detach(thrd_t); +int thrd_equal(thrd_t, thrd_t); +_Noreturn void + thrd_exit(int); +int thrd_join(thrd_t, int *); +int thrd_sleep(const struct timespec *, struct timespec *); +void thrd_yield(void); +int tss_create(tss_t *, tss_dtor_t); +void tss_delete(tss_t); +void * tss_get(tss_t); +int tss_set(tss_t, void *); +__END_DECLS + +#endif /* !_THREADS_H_ */ Index: lib/libthr/c1x/c1x_cnd.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/c1x_cnd.c (revision 0) +++ lib/libthr/c1x/c1x_cnd.c (working copy) @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include +#include "un-namespace.h" + +int +cnd_broadcast(cnd_t *cond) +{ + + if (_pthread_cond_broadcast(cond) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +void +cnd_destroy(cnd_t *cond) +{ + + (void)_pthread_cond_destroy(cond); +} + +int +cnd_init(cnd_t *cond) +{ + + if (_pthread_cond_init(cond, NULL) !=3D 0) + return (errno =3D=3D ENOMEM ? thrd_nomem : thrd_error); + return (thrd_success); +} + +int +cnd_signal(cnd_t *cond) +{ + + if (_pthread_cond_signal(cond) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +int +cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, + const struct timespec *restrict ts) +{ + + if (_pthread_cond_timedwait(cond, mtx, ts) !=3D 0) + return (errno =3D=3D ETIMEDOUT ? thrd_timedout : thrd_error); + return (thrd_success); +} + +int +cnd_wait(cnd_t *cond, mtx_t *mtx) +{ + + if (_pthread_cond_wait(cond, mtx) !=3D 0) + return (thrd_error); + return (thrd_success); +} Index: lib/libthr/c1x/c1x_mtx.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/c1x_mtx.c (revision 0) +++ lib/libthr/c1x/c1x_mtx.c (working copy) @@ -0,0 +1,108 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include +#include "un-namespace.h" + +void +mtx_destroy(mtx_t *mtx) +{ + + (void)_pthread_mutex_destroy(mtx); +} + +int +mtx_init(mtx_t *mtx, int type) +{ + pthread_mutexattr_t attr; + int mt; + + switch (type) { + case mtx_plain: + case mtx_timed: + mt =3D PTHREAD_MUTEX_NORMAL; + break; + case mtx_plain | mtx_recursive: + case mtx_timed | mtx_recursive: + mt =3D PTHREAD_MUTEX_RECURSIVE; + break; + default: + errno =3D EINVAL; + return (thrd_error); + } + + if (_pthread_mutexattr_init(&attr) !=3D 0) + return (thrd_error); + if (_pthread_mutexattr_settype(&attr, mt) !=3D 0) + return (thrd_error); + if (_pthread_mutex_init(mtx, &attr) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +int +mtx_lock(mtx_t *mtx) +{ + + if (_pthread_mutex_lock(mtx) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +int +mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts) +{ + + if (_pthread_mutex_timedlock(mtx, ts) !=3D 0) + return (errno =3D=3D ETIMEDOUT ? thrd_timedout : thrd_error); + return (thrd_success); +} + +int +mtx_trylock(mtx_t *mtx) +{ + + if (_pthread_mutex_lock(mtx) !=3D 0) + return (errno =3D=3D EBUSY ? thrd_busy : thrd_error); + return (thrd_success); +} + +int +mtx_unlock(mtx_t *mtx) +{ + + if (_pthread_mutex_unlock(mtx) !=3D 0) + return (thrd_error); + return (thrd_success); +} Index: lib/libthr/c1x/c1x_tss.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/c1x_tss.c (revision 0) +++ lib/libthr/c1x/c1x_tss.c (working copy) @@ -0,0 +1,67 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include "un-namespace.h" + +int +tss_create(tss_t *key, tss_dtor_t dtor) +{ + + if (_pthread_key_create(key, dtor) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +void +tss_delete(tss_t key) +{ + + (void)_pthread_key_delete(key); +} + +void * +tss_get(tss_t key) +{ + + return (_pthread_getspecific(key)); +} + +int +tss_set(tss_t key, void *val) +{ + + if (_pthread_setspecific(key, val) !=3D 0) + return (thrd_error); + return (thrd_success); +} Index: lib/libthr/c1x/Makefile.inc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/Makefile.inc (revision 0) +++ lib/libthr/c1x/Makefile.inc (working copy) @@ -0,0 +1,11 @@ +# $FreeBSD: head/lib/libthr/thread/Makefile.inc 218414 2011-02-07 21:26:46= Z jkim $ + +# thr sources +.PATH: ${.CURDIR}/c1x + +SRCS+=3D \ + c1x_call_once.c \ + c1x_cnd.c \ + c1x_mtx.c \ + c1x_thrd.c \ + c1x_tss.c Index: lib/libthr/c1x/c1x_call_once.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/c1x_call_once.c (revision 0) +++ lib/libthr/c1x/c1x_call_once.c (working copy) @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include "un-namespace.h" + +void +call_once(once_flag *flag, void (*func)(void)) +{ + + (void)_pthread_once((pthread_once_t *)flag, func); +} Index: lib/libthr/c1x/c1x_thrd.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/c1x/c1x_thrd.c (revision 0) +++ lib/libthr/c1x/c1x_thrd.c (working copy) @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 2012 Ed Schouten + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "namespace.h" +#include +#include +#include +#include +#include "un-namespace.h" + +struct thrd_param { + thrd_start_t func; + void *arg; +}; + +static void * +thrd_entry(void *arg) +{ + struct thrd_param tp; + + tp =3D *(struct thrd_param *)arg; + free(arg); + return ((void *)(intptr_t)tp.func(tp.arg)); +} + +int +thrd_create(thrd_t *thr, thrd_start_t func, void *arg) +{ + struct thrd_param *tp; + + /* + * Work around return type inconsistency. Wrap execution using + * a function conforming to pthread_create()'s start_routine. + */ + tp =3D malloc(sizeof(*tp)); + if (tp =3D=3D NULL) + return (thrd_nomem); + tp->func =3D func; + tp->arg =3D arg; + if (_pthread_create(thr, NULL, thrd_entry, tp) !=3D 0) { + free(tp); + return (thrd_error); + } + return (thrd_success); +} + +thrd_t +thrd_current(void) +{ + + return (_pthread_self()); +} + +int +thrd_detach(thrd_t thr) +{ + + if (_pthread_detach(thr) !=3D 0) + return (thrd_error); + return (thrd_success); +} + +int +thrd_equal(thrd_t thr0, thrd_t thr1) +{ + + return (_pthread_equal(thr0, thr1)); +} + +_Noreturn void +thrd_exit(int res) +{ + + _pthread_exit((void *)(intptr_t)res); +} + +int +thrd_join(thrd_t thr, int *res) +{ + void *value_ptr; + + if (_pthread_join(thr, &value_ptr) !=3D 0) + return (thrd_error); + *res =3D (intptr_t)value_ptr; + return (thrd_success); +} + +int +thrd_sleep(const struct timespec *duration, struct timespec *remaining) +{ + + return (_nanosleep(duration, remaining)); +} + +void +thrd_yield(void) +{ + + _pthread_yield(); +} Index: lib/libthr/pthread.map =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/pthread.map (revision 228590) +++ lib/libthr/pthread.map (working copy) @@ -408,3 +408,31 @@ setcontext; swapcontext; }; + +FBSD_1.3 { + call_once; + cnd_broadcast; + cnd_destroy; + cnd_init; + cnd_signal; + cnd_timedwait; + cnd_wait; + mtx_destroy; + mtx_init; + mtx_lock; + mtx_timedlock; + mtx_trylock; + mtx_unlock; + thrd_create; + thrd_current; + thrd_detach; + thrd_equal; + thrd_exit; + thrd_join; + thrd_sleep; + thrd_yield; + tss_create; + tss_delete; + tss_get; + tss_set; +}; Index: lib/libthr/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- lib/libthr/Makefile (revision 228590) +++ lib/libthr/Makefile (working copy) @@ -47,6 +47,7 @@ .PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH} =20 .include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc" +.include "${.CURDIR}/c1x/Makefile.inc" .include "${.CURDIR}/sys/Makefile.inc" .include "${.CURDIR}/thread/Makefile.inc" =20 --HSVPcR81XVhxeM7P-- --MvEh5MSbieV/1Yst Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQIbBAEBAgAGBQJO67zZAAoJEG5e2P40kaK7n7sP+KGuwANm6TUNjPHOMFfMewI6 4BBQjsJTzTzdFbqEEqQa5dNwd6fQOparlJ8A9jVHvIS/MD+IHGtbV8R9znb9a2um Fpsy0VCqt7jEcqOXARMYaupO0w8oVbwwSiuWEiIahYRkgxq76z7jEL80sM7n5HbN X7ftkjEQ5pcjEPqTHlSKQdD6HVP7M8qUqoanZ+r+HMHNgqwMKJuOXBHxKIpyMolC xZbGyH4etKGmLIiRVGqCOPrkzHDck/wMRb6OahZa0wuNNM7tRY//xOmw3OPw7P+0 +Br8jm9CAaDYWq4ajvPqLWOELlMY3Mm8rOaN5lrtFN8qk5Z5GE6LJG1QZIHqgmNR SGLvdaDskqi6QVGq4hTOaKbANTl+MJ0O+XWEBVq2yasQSYQt1b1jlBPIw3KIpAXh PsIolPEycGhwpvmhmOvfBGnVddh1HpFYIcMeq/N33R3CIDhtQtrypbK2H/t3qpN2 5AV1WyTqeLelfBeb6SNF4TM5BSewA1Bo2okx8ZGynzw5AjN8EXNnSgC6JCqMLxla u+Whj0bPNU+QT8BZfNO8Ci+wrvEcz1Vx15vfT5MJo/wRRW/STXhRuo4qzlwwMrK3 VxlLtCXUguFEvWxey/InuecVykZF4Fy9HIiF7MOxxpJhSYXHOtBODFg7p8qMHuAE UIX5gmzMOAXdCUnLUH0= =g8V1 -----END PGP SIGNATURE----- --MvEh5MSbieV/1Yst-- From owner-freebsd-threads@FreeBSD.ORG Fri Dec 16 22:20:00 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A1126106566B; Fri, 16 Dec 2011 22:20:00 +0000 (UTC) (envelope-from ed@hoeg.nl) Received: from mx0.hoeg.nl (mx0.hoeg.nl [IPv6:2a01:4f8:101:5343::aa]) by mx1.freebsd.org (Postfix) with ESMTP id 653148FC15; Fri, 16 Dec 2011 22:20:00 +0000 (UTC) Received: by mx0.hoeg.nl (Postfix, from userid 1000) id CA3382A28E7C; Fri, 16 Dec 2011 23:19:59 +0100 (CET) Date: Fri, 16 Dec 2011 23:19:59 +0100 From: Ed Schouten To: Kostik Belousov Message-ID: <20111216221959.GB1771@hoeg.nl> References: <20111216214913.GA1771@hoeg.nl> <20111216220914.GW50300@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8Bkcj4NmnZ79d4W7" Content-Disposition: inline In-Reply-To: <20111216220914.GW50300@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: threads@freebsd.org, arch@freebsd.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 22:20:00 -0000 --8Bkcj4NmnZ79d4W7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Kostik, * Kostik Belousov , 20111216 23:09: > If application that does not use the new interface supposed to be > able to implement function with new names, then the not-underscored > symbols must be weak. For example when an application wants to implement its own functions that are named thrd_*(), for example? > pthread_cond_init does not set errno, it returns error. > There are several more instances of such errno use in the patch. Oh wait. It returns the errno. Ugh. Fixed! > Do you have reference to the draft ? Yes, sure: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf Groetjes, --=20 Ed Schouten WWW: http://80386.nl/ --8Bkcj4NmnZ79d4W7 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQIcBAEBAgAGBQJO68QPAAoJEG5e2P40kaK7CT4P/ive+2G9Ho1eisHxqcIZydqV DM6ai+WYSL7xC5OyZm56c5wOwpkfYH5NiEefQGCk82FlO+ULViW5FdmA2isll3tF 8dJ10hExNhAo7ZnfTvA6CsgRbvGjLluHEb7ELHYoMNHz68j64xmvA9wREQ06hPF0 OSZrAbsTxT6vBXSv/ABP54ovflFLrpfYyZAlqz1VNXFlwSvfZexTHIgtMmUO10jg cEwJUtkdT6xM/0XkoMz0Ho+igfXEYGzZTaDiGZKi+AdODKe+VzWIINk9P2U5Jhud cT5Q/wlHicEvlhIxCIpiQxhDYGndIsHBAf1Jp2iSo09gTQTSTlRLofeOUP1wbb93 pmTSKhgm3suXTunygHnIw1Wno2NFSuf1fbEvhlcvte55La0fTmPwkFOwD/YRom19 234MbHdoMw/PrtdzJWwkv6bNrqwUdlZQii1oOMv8uRClrawxOsLfl6G85WN0Fc// Z//VYVrs8YRT5wWdXKUMNA6KHz7bmiGbDLoliRkZteU8h7oD99eR6EODP2iOAZ+/ tTKYC+ejozwDTaFPyGYDAXb8wQHgNO2WktlGr5Lj65EAkLPVMpHggz31QNEHBwvf y+28MJ/UxDIoKaMBd3kn4Amwk2yUM/DCMauJWkk7/USyS/uwpIiiPDHUsWIuRENJ hnkH0GJV7UD91o+cbctI =W6qY -----END PGP SIGNATURE----- --8Bkcj4NmnZ79d4W7-- From owner-freebsd-threads@FreeBSD.ORG Fri Dec 16 22:31:32 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9198C106566B; Fri, 16 Dec 2011 22:31:32 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id E6F408FC1D; Fri, 16 Dec 2011 22:31:31 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id pBGMVQ3j056545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Dec 2011 00:31:26 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id pBGMVQ7O054949; Sat, 17 Dec 2011 00:31:26 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id pBGMVQs8054948; Sat, 17 Dec 2011 00:31:26 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 17 Dec 2011 00:31:26 +0200 From: Kostik Belousov To: Ed Schouten Message-ID: <20111216223126.GX50300@deviant.kiev.zoral.com.ua> References: <20111216214913.GA1771@hoeg.nl> <20111216220914.GW50300@deviant.kiev.zoral.com.ua> <20111216221959.GB1771@hoeg.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="GJTx2ed35C3D1GF1" Content-Disposition: inline In-Reply-To: <20111216221959.GB1771@hoeg.nl> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: threads@freebsd.org, arch@freebsd.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 22:31:32 -0000 --GJTx2ed35C3D1GF1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 16, 2011 at 11:19:59PM +0100, Ed Schouten wrote: > Hello Kostik, >=20 > * Kostik Belousov , 20111216 23:09: > > If application that does not use the new interface supposed to be > > able to implement function with new names, then the not-underscored > > symbols must be weak. >=20 > For example when an application wants to implement its own functions > that are named thrd_*(), for example? Yes. The realistic example is the code written to C99/SUSv4 conformance that happens to define thrd_. It might be that easiest solution is to put the functions into separate library, besides defining them weak. >=20 > > pthread_cond_init does not set errno, it returns error. > > There are several more instances of such errno use in the patch. >=20 > Oh wait. It returns the errno. Ugh. Fixed! >=20 > > Do you have reference to the draft ? >=20 > Yes, sure: >=20 > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf BTW, it looks not very useful to add a bunch of threading functions without at least trying to specify the memory model. --GJTx2ed35C3D1GF1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk7rxr4ACgkQC3+MBN1Mb4jqNwCff+EFGr2qR0uU9jPSjtCQaTA5 JfcAoJa6EjoIPT4sttlyWCQ4n8qXEG/o =LlXk -----END PGP SIGNATURE----- --GJTx2ed35C3D1GF1-- From owner-freebsd-threads@FreeBSD.ORG Fri Dec 16 22:42:46 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B2E641065670 for ; Fri, 16 Dec 2011 22:42:46 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 13CE08FC08 for ; Fri, 16 Dec 2011 22:42:45 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id pBGM9F3W054901 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 17 Dec 2011 00:09:15 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id pBGM9FOB054834; Sat, 17 Dec 2011 00:09:15 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id pBGM9EbT054833; Sat, 17 Dec 2011 00:09:14 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 17 Dec 2011 00:09:14 +0200 From: Kostik Belousov To: Ed Schouten Message-ID: <20111216220914.GW50300@deviant.kiev.zoral.com.ua> References: <20111216214913.GA1771@hoeg.nl> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ubsQ1kiTK0VEt5fK" Content-Disposition: inline In-Reply-To: <20111216214913.GA1771@hoeg.nl> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: threads@freebsd.org, arch@freebsd.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Dec 2011 22:42:46 -0000 --ubsQ1kiTK0VEt5fK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 16, 2011 at 10:49:13PM +0100, Ed Schouten wrote: > Hi folks, >=20 > We can expect C11 (or C12) to be released in the nearby future. I > already took the liberty of adding fallbacks for some of the language > keywords to , but it seems the standard also includes a new > threading API. >=20 > In my opinion the ISO folks suffer a bit from the Not Invented Here > syndrome. In an earlier revision of the C1X specification, they even > described a `struct xtime', which had a purpose identical to `struct > timespec'. The same holds for the threading API. It can be 1:1 mapped to > a subset of pthread -- why not simply standardize that subset then? >=20 > Putting my personal objections aside, I do think we should add support > for the API by the time C1X is final. Attached is a patch that adds the > new API to libthr. It simply wraps all the calls around pthread. Even > the objects used by the API are type compatible with the ones used by > pthread. >=20 > The questions: >=20 > - As this API is just a second-class citizen and will not be used by the > C library, I suspect there is no need for underscore prefixing and > weak aliasing. Is this correct? If application that does not use the new interface supposed to be able to implement function with new names, then the not-underscored symbols must be weak. >=20 > - When accompanied with man pages, are there any objections if I commit > this to SVN when C1X is official? +int +cnd_init(cnd_t *cond) +{ + + if (_pthread_cond_init(cond, NULL) !=3D 0) + return (errno =3D=3D ENOMEM ? thrd_nomem : thrd_error); + return (thrd_success); +} pthread_cond_init does not set errno, it returns error. There are several more instances of such errno use in the patch. Do you have reference to the draft ? --ubsQ1kiTK0VEt5fK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (FreeBSD) iEYEARECAAYFAk7rwYoACgkQC3+MBN1Mb4gs5wCgzHFzXHOpcpSYL8VL9n9Zm2nz V7oAnjAWXKFwKlFwG6T3hXn6TF6qTMBh =llEm -----END PGP SIGNATURE----- --ubsQ1kiTK0VEt5fK-- From owner-freebsd-threads@FreeBSD.ORG Sat Dec 17 00:40:07 2011 Return-Path: Delivered-To: threads@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2AC4B106566B; Sat, 17 Dec 2011 00:40:07 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 989B58FC12; Sat, 17 Dec 2011 00:40:03 +0000 (UTC) Received: from [10.0.0.33] (99-195-103-194.dyn.centurytel.net [99.195.103.194]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id pBH0VIhF018743 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 16 Dec 2011 17:31:20 -0700 (MST) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <20111216223126.GX50300@deviant.kiev.zoral.com.ua> Date: Fri, 16 Dec 2011 17:31:14 -0700 Content-Transfer-Encoding: 7bit Message-Id: References: <20111216214913.GA1771@hoeg.nl> <20111216220914.GW50300@deviant.kiev.zoral.com.ua> <20111216221959.GB1771@hoeg.nl> <20111216223126.GX50300@deviant.kiev.zoral.com.ua> To: Kostik Belousov X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 16 Dec 2011 17:31:22 -0700 (MST) Cc: Ed Schouten , arch@FreeBSD.org, threads@FreeBSD.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2011 00:40:07 -0000 On Dec 16, 2011, at 3:31 PM, Kostik Belousov wrote: > On Fri, Dec 16, 2011 at 11:19:59PM +0100, Ed Schouten wrote: >> Hello Kostik, >> >> * Kostik Belousov , 20111216 23:09: >>> If application that does not use the new interface supposed to be >>> able to implement function with new names, then the not-underscored >>> symbols must be weak. >> >> For example when an application wants to implement its own functions >> that are named thrd_*(), for example? > Yes. The realistic example is the code written to C99/SUSv4 conformance > that happens to define thrd_. > > It might be that easiest solution is to put the functions into > separate library, besides defining them weak. I thought the canonical solution here was to say #if POSIX_VISIBLE >= 201201 #endif Except this isn't posix. :( Warner From owner-freebsd-threads@FreeBSD.ORG Sat Dec 17 03:38:47 2011 Return-Path: Delivered-To: threads@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D00C1106564A; Sat, 17 Dec 2011 03:38:47 +0000 (UTC) (envelope-from das@FreeBSD.ORG) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 920A98FC08; Sat, 17 Dec 2011 03:38:47 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id pBH3BVYb015232; Fri, 16 Dec 2011 22:11:31 -0500 (EST) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id pBH3BVuQ015231; Fri, 16 Dec 2011 22:11:31 -0500 (EST) (envelope-from das@FreeBSD.ORG) Date: Fri, 16 Dec 2011 22:11:31 -0500 From: David Schultz To: Warner Losh Message-ID: <20111217031131.GA15194@zim.MIT.EDU> Mail-Followup-To: Warner Losh , Kostik Belousov , Ed Schouten , arch@freebsd.org, threads@freebsd.org References: <20111216214913.GA1771@hoeg.nl> <20111216220914.GW50300@deviant.kiev.zoral.com.ua> <20111216221959.GB1771@hoeg.nl> <20111216223126.GX50300@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: Ed Schouten , threads@FreeBSD.ORG, arch@FreeBSD.ORG Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2011 03:38:47 -0000 On Fri, Dec 16, 2011, Warner Losh wrote: > > On Dec 16, 2011, at 3:31 PM, Kostik Belousov wrote: > > > On Fri, Dec 16, 2011 at 11:19:59PM +0100, Ed Schouten wrote: > >> Hello Kostik, > >> > >> * Kostik Belousov , 20111216 23:09: > >>> If application that does not use the new interface supposed to be > >>> able to implement function with new names, then the not-underscored > >>> symbols must be weak. > >> > >> For example when an application wants to implement its own functions > >> that are named thrd_*(), for example? > > Yes. The realistic example is the code written to C99/SUSv4 conformance > > that happens to define thrd_. > > > > It might be that easiest solution is to put the functions into > > separate library, besides defining them weak. > > I thought the canonical solution here was to say > > #if POSIX_VISIBLE >= 201201 > > #endif > > Except this isn't posix. :( In this case it's #if __ISO_C_VISIBLE >= x (with the appropriate changes in for the new standard). That deals with visibility issues in the compiler. The weak symbols deal with visibility issues in the linker. From owner-freebsd-threads@FreeBSD.ORG Sat Dec 17 21:22:01 2011 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4126106567A; Sat, 17 Dec 2011 21:22:01 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id A03678FC12; Sat, 17 Dec 2011 21:22:01 +0000 (UTC) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id 8377F5DAA; Sat, 17 Dec 2011 21:02:17 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id pBHL2HRE085478; Sat, 17 Dec 2011 21:02:17 GMT (envelope-from phk@phk.freebsd.dk) To: Kostik Belousov From: "Poul-Henning Kamp" In-Reply-To: Your message of "Sat, 17 Dec 2011 00:31:26 +0200." <20111216223126.GX50300@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1 Date: Sat, 17 Dec 2011 21:02:17 +0000 Message-ID: <85477.1324155737@critter.freebsd.dk> Cc: arch@freebsd.org, Ed Schouten , threads@freebsd.org Subject: Re: [Patch] C1X threading support X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Dec 2011 21:22:02 -0000 In message <20111216223126.GX50300@deviant.kiev.zoral.com.ua>, Kostik Belousov writes: >> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf >BTW, it looks not very useful to add a bunch of threading functions >without at least trying to specify the memory model. I have never fully understood what goal these sequential obesity-binges from ISO-C serve. Structure packing ? Nahh, nobody uses that. Big/Little Endian API ? Naah, nobody moves binary data between computers. Ohhh, but I know: Lets make a rival to the POSIX threads, we can do it much better and slightly incompatible, big market there I'm sure. What ? A "assert mutex is held" facility ? Why would you want that ? Just write perfect code to begin with! Bang! Bang! Bang! &c &c... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.