From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 9E48B3858438 for ; Tue, 10 Oct 2023 13:43:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9E48B3858438 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 4D624300B302; Tue, 10 Oct 2023 15:43:34 +0200 (CEST) Received: by r6.localdomain (Postfix, from userid 1000) id 112F734031B; Tue, 10 Oct 2023 15:43:34 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: hsm2@rice.edu, Mark Wielaard Subject: [PATCH 01/16] lib: Add new once_define and once macros to eu-config.h Date: Tue, 10 Oct 2023 15:42:45 +0200 Message-ID: <20231010134300.53830-1-mark@klomp.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <301fac87e83ebbbd677750579ae9a3429b461bdf.camel@klomp.org> References: <301fac87e83ebbbd677750579ae9a3429b461bdf.camel@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3033.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Heather McIntyre * lib/eu-config.h New macros. [USE_LOCKS] (ONCE_CALL): (once_define, once) Signed-off-by: Heather S. McIntyre Signed-off-by: Mark Wielaard --- lib/eu-config.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/eu-config.h b/lib/eu-config.h index 78a5c4fe..feb079db 100644 --- a/lib/eu-config.h +++ b/lib/eu-config.h @@ -33,13 +33,18 @@ # include # include # define rwlock_define(class,name) class pthread_rwlock_t name +# define once_define(class,name) class pthread_once_t name = PTHREAD_ONCE_INIT # define RWLOCK_CALL(call) \ ({ int _err = pthread_rwlock_ ## call; assert_perror (_err); }) +# define ONCE_CALL(call) \ + ({ int _err = pthread_ ## call; assert_perror (_err); }) # define rwlock_init(lock) RWLOCK_CALL (init (&lock, NULL)) # define rwlock_fini(lock) RWLOCK_CALL (destroy (&lock)) # define rwlock_rdlock(lock) RWLOCK_CALL (rdlock (&lock)) # define rwlock_wrlock(lock) RWLOCK_CALL (wrlock (&lock)) # define rwlock_unlock(lock) RWLOCK_CALL (unlock (&lock)) +# define once(once_control, init_routine) \ + ONCE_CALL (once (&once_control, init_routine)) #else /* Eventually we will allow multi-threaded applications to use the libraries. Therefore we will add the necessary locking although @@ -50,6 +55,8 @@ # define rwlock_rdlock(lock) ((void) (lock)) # define rwlock_wrlock(lock) ((void) (lock)) # define rwlock_unlock(lock) ((void) (lock)) +# define once_define(class,name) +# define once(once_control, init_routine) init_routine() #endif /* USE_LOCKS */ #include -- 2.41.0