···11+diff --git a/src/gen-lock-obj.sh b/src/gen-lock-obj.sh
22+index a710f0c..258eec6 100755
33+--- a/src/gen-lock-obj.sh
44++++ b/src/gen-lock-obj.sh
55+@@ -1,136 +1,136 @@
66+ #! /bin/sh
77+ #
88+ # gen-lock-obj.sh - Build tool to construct the lock object.
99+ #
1010+ # Copyright (C) 2020, 2021 g10 Code GmbH
1111+ #
1212+ # This file is part of libgpg-error.
1313+ #
1414+ # libgpg-error is free software; you can redistribute it and/or
1515+ # modify it under the terms of the GNU Lesser General Public License
1616+ # as published by the Free Software Foundation; either version 2.1 of
1717+ # the License, or (at your option) any later version.
1818+ #
1919+ # libgpg-error is distributed in the hope that it will be useful, but
2020+ # WITHOUT ANY WARRANTY; without even the implied warranty of
2121+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2222+ # Lesser General Public License for more details.
2323+ #
2424+ # You should have received a copy of the GNU Lesser General Public
2525+ # License along with this program; if not, see <https://www.gnu.org/licenses/>.
2626+ #
2727+2828+ #
2929+ # Following variables should be defined to invoke this script
3030+ #
3131+ # CC
3232+ # OBJDUMP
3333+ # AWK
3434+ # ac_ext
3535+ # ac_object
3636+ # host
3737+ # LOCK_ABI_VERSION
3838+ #
3939+ # An example:
4040+ #
4141+ # LOCK_ABI_VERSION=1 host=x86_64-pc-linux-gnu host_alias=x86_64-linux-gnu \
4242+ # CC=$host_alias-gcc OBJDUMP=$host_alias-objdump ac_ext=c ac_objext=o \
4343+ # AWK=gawk ./gen-lock-obj.sh
4444+ #
4545+4646+-if test -n `echo -n`; then
4747++if test -n "`echo -n`"; then
4848+ ECHO_C='\c'
4949+ ECHO_N=''
5050+ else
5151+ ECHO_C=''
5252+ ECHO_N='-n'
5353+ fi
5454+5555+ if test "$1" = --disable-threads; then
5656+ cat <<EOF
5757+ ## lock-obj-pub.$host.h - NO LOCK SUPPORT
5858+ ## File created by gen-lock-obj.sh - DO NOT EDIT
5959+ ## To be included by mkheader into gpg-error.h
6060+6161+ /* Dummy object - no locking available. */
6262+ typedef struct
6363+ {
6464+ long _vers;
6565+ } gpgrt_lock_t;
6666+6767+ #define GPGRT_LOCK_INITIALIZER {-1}
6868+ EOF
6969+ else
7070+ AWK_VERSION_OUTPUT=$($AWK 'BEGIN { print PROCINFO["version"] }')
7171+ if test -n "$AWK_VERSION_OUTPUT"; then
7272+ # It's GNU awk, which supports PROCINFO.
7373+ AWK_OPTION=--non-decimal-data
7474+ fi
7575+7676+ cat <<'EOF' >conftest.$ac_ext
7777+ #include <pthread.h>
7878+ pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
7979+ EOF
8080+8181+ if $CC -c conftest.$ac_ext; then :
8282+ ac_mtx_size=$($OBJDUMP -j .bss -t conftest.$ac_objext \
8383+ | $AWK $AWK_OPTION '
8484+ /mtx$/ { mtx_size = int("0x" $5) }
8585+ END { print mtx_size }')
8686+ else
8787+ echo "Can't determine mutex size"
8888+ exit 1
8989+ fi
9090+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
9191+9292+ cat <<EOF
9393+ ## lock-obj-pub.$host.h
9494+ ## File created by gen-lock-obj.sh - DO NOT EDIT
9595+ ## To be included by mkheader into gpg-error.h
9696+9797+ typedef struct
9898+ {
9999+ long _vers;
100100+ union {
101101+ volatile char _priv[$ac_mtx_size];
102102+ long _x_align;
103103+ long *_xp_align;
104104+ } u;
105105+ } gpgrt_lock_t;
106106+107107+ EOF
108108+109109+ # FIXME: Support different alignment conditions of:
110110+ #
111111+ # USE_16BYTE_ALIGNMENT
112112+ # USE_DOUBLE_FOR_ALIGNMENT
113113+ # USE_LONG_DOUBLE_FOR_ALIGNMENT
114114+ #
115115+116116+ echo ${ECHO_N} "#define GPGRT_LOCK_INITIALIZER {$LOCK_ABI_VERSION,{{${ECHO_C}"
117117+118118+ i=0
119119+ while test "$i" -lt $ac_mtx_size; do
120120+ if test "$i" -ne 0 -a "$(( $i % 8 ))" -eq 0; then
121121+ echo ' \'
122122+ echo ${ECHO_N} " ${ECHO_C}"
123123+ fi
124124+ echo ${ECHO_N} "0${ECHO_C}"
125125+ if test "$i" -lt $(($ac_mtx_size - 1)); then
126126+ echo ${ECHO_N} ",${ECHO_C}"
127127+ fi
128128+ i=$(( i + 1 ))
129129+ done
130130+ fi
131131+132132+ cat <<'EOF'
133133+ }}}
134134+ ##
135135+ ## Local Variables:
136136+ ## mode: c
137137+ ## buffer-read-only: t
138138+ ## End:
139139+ ##
140140+ EOF
141141+142142+ exit 0