Re: new module 'thread-optim'

2020-08-12 Thread Bruno Haible
Paul Eggert wrote: > True enough, but how about suggesting that people write something like the > following? > > bool mt = gl_multithreaded (); > if (mt) gl_lock_lock (file_cleanup_list_lock); > ... > if (mt) gl_lock_unlock (file_cleanup_list_lock); > > This is nearly as concise

Re: new module 'thread-optim'

2020-08-11 Thread Paul Eggert
On 8/9/20 2:44 AM, Bruno Haible wrote: To me, this variable '__libc_single_threaded' is not something that should be visible in source code - because it is so low-level, - because only one platform has it. True enough, but how about suggesting that people write something like the followi

Re: new module 'thread-optim'

2020-08-11 Thread Bruno Haible
There was also another blunder in the same file: IF_MT_DECL produces a warning: $ gcc -O2 -S -Wall foo.c foo.c: In function ‘foo’: foo.c:2:3: warning: statement with no effect [-Wunused-value] (void *)0; ^ $ clang -O2 -S -Wall foo.c foo.c:2:3: warning: expression result unused; should this

Re: new module 'thread-optim'

2020-08-09 Thread Bruno Haible
Hi Paul, > > +# define IF_MT_DECL char optimize_for_single_thread = > > __libc_single_threaded > > +# define IF_MT if (optimize_for_single_thread) > > That second line looks backward Oops, what a blunder! Thanks for noticing it. Fixed through the patch below. > Could you explain why mac

Re: new module 'thread-optim'

2020-08-09 Thread Paul Eggert
On 8/8/20 1:26 PM, Bruno Haible wrote: +# define IF_MT_DECL char optimize_for_single_thread = __libc_single_threaded +# define IF_MT if (optimize_for_single_thread) That second line looks backward; when optimize_for_single_thread is nonzero, the process is single-threaded so "IF_MT" is

new module 'thread-optim'

2020-08-08 Thread Bruno Haible
e IF_MT macro. * modules/fatal-signal (Depends-on): Add thread-optim. >From db6c51cb278392aee178a3e836f37e0f2a7b1990 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 8 Aug 2020 19:47:28 +0200 Subject: [PATCH 1/4] New module 'thread-optim'. * lib/thread