···1+diff --git a/src/gen-lock-obj.sh b/src/gen-lock-obj.sh
2+index a710f0c..258eec6 100755
3+--- a/src/gen-lock-obj.sh
4++++ b/src/gen-lock-obj.sh
5+@@ -1,136 +1,136 @@
6+ #! /bin/sh
7+ #
8+ # gen-lock-obj.sh - Build tool to construct the lock object.
9+ #
10+ # Copyright (C) 2020, 2021 g10 Code GmbH
11+ #
12+ # This file is part of libgpg-error.
13+ #
14+ # libgpg-error is free software; you can redistribute it and/or
15+ # modify it under the terms of the GNU Lesser General Public License
16+ # as published by the Free Software Foundation; either version 2.1 of
17+ # the License, or (at your option) any later version.
18+ #
19+ # libgpg-error is distributed in the hope that it will be useful, but
20+ # WITHOUT ANY WARRANTY; without even the implied warranty of
21+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+ # Lesser General Public License for more details.
23+ #
24+ # You should have received a copy of the GNU Lesser General Public
25+ # License along with this program; if not, see <https://www.gnu.org/licenses/>.
26+ #
27+28+ #
29+ # Following variables should be defined to invoke this script
30+ #
31+ # CC
32+ # OBJDUMP
33+ # AWK
34+ # ac_ext
35+ # ac_object
36+ # host
37+ # LOCK_ABI_VERSION
38+ #
39+ # An example:
40+ #
41+ # LOCK_ABI_VERSION=1 host=x86_64-pc-linux-gnu host_alias=x86_64-linux-gnu \
42+ # CC=$host_alias-gcc OBJDUMP=$host_alias-objdump ac_ext=c ac_objext=o \
43+ # AWK=gawk ./gen-lock-obj.sh
44+ #
45+46+-if test -n `echo -n`; then
47++if test -n "`echo -n`"; then
48+ ECHO_C='\c'
49+ ECHO_N=''
50+ else
51+ ECHO_C=''
52+ ECHO_N='-n'
53+ fi
54+55+ if test "$1" = --disable-threads; then
56+ cat <<EOF
57+ ## lock-obj-pub.$host.h - NO LOCK SUPPORT
58+ ## File created by gen-lock-obj.sh - DO NOT EDIT
59+ ## To be included by mkheader into gpg-error.h
60+61+ /* Dummy object - no locking available. */
62+ typedef struct
63+ {
64+ long _vers;
65+ } gpgrt_lock_t;
66+67+ #define GPGRT_LOCK_INITIALIZER {-1}
68+ EOF
69+ else
70+ AWK_VERSION_OUTPUT=$($AWK 'BEGIN { print PROCINFO["version"] }')
71+ if test -n "$AWK_VERSION_OUTPUT"; then
72+ # It's GNU awk, which supports PROCINFO.
73+ AWK_OPTION=--non-decimal-data
74+ fi
75+76+ cat <<'EOF' >conftest.$ac_ext
77+ #include <pthread.h>
78+ pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
79+ EOF
80+81+ if $CC -c conftest.$ac_ext; then :
82+ ac_mtx_size=$($OBJDUMP -j .bss -t conftest.$ac_objext \
83+ | $AWK $AWK_OPTION '
84+ /mtx$/ { mtx_size = int("0x" $5) }
85+ END { print mtx_size }')
86+ else
87+ echo "Can't determine mutex size"
88+ exit 1
89+ fi
90+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
91+92+ cat <<EOF
93+ ## lock-obj-pub.$host.h
94+ ## File created by gen-lock-obj.sh - DO NOT EDIT
95+ ## To be included by mkheader into gpg-error.h
96+97+ typedef struct
98+ {
99+ long _vers;
100+ union {
101+ volatile char _priv[$ac_mtx_size];
102+ long _x_align;
103+ long *_xp_align;
104+ } u;
105+ } gpgrt_lock_t;
106+107+ EOF
108+109+ # FIXME: Support different alignment conditions of:
110+ #
111+ # USE_16BYTE_ALIGNMENT
112+ # USE_DOUBLE_FOR_ALIGNMENT
113+ # USE_LONG_DOUBLE_FOR_ALIGNMENT
114+ #
115+116+ echo ${ECHO_N} "#define GPGRT_LOCK_INITIALIZER {$LOCK_ABI_VERSION,{{${ECHO_C}"
117+118+ i=0
119+ while test "$i" -lt $ac_mtx_size; do
120+ if test "$i" -ne 0 -a "$(( $i % 8 ))" -eq 0; then
121+ echo ' \'
122+ echo ${ECHO_N} " ${ECHO_C}"
123+ fi
124+ echo ${ECHO_N} "0${ECHO_C}"
125+ if test "$i" -lt $(($ac_mtx_size - 1)); then
126+ echo ${ECHO_N} ",${ECHO_C}"
127+ fi
128+ i=$(( i + 1 ))
129+ done
130+ fi
131+132+ cat <<'EOF'
133+ }}}
134+ ##
135+ ## Local Variables:
136+ ## mode: c
137+ ## buffer-read-only: t
138+ ## End:
139+ ##
140+ EOF
141+142+ exit 0