!254 libpthread-2.17.so 部分开源用例不通过

From: @yang_yanchao
Reviewed-by: 
Signed-off-by:
This commit is contained in:
openeuler-ci-bot 2021-11-25 07:17:32 +00:00 committed by Gitee
commit 7f83d0d27e
11 changed files with 6258 additions and 9561 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
From 7cb15fbef45361db6ad718077a4f0a6d2dc845f2 Mon Sep 17 00:00:00 2001
From: Yang Yanchao <yangyanchao6@huawei.com>
Date: Wed Nov 24 09:31:31 2021 +0800
Subject: [PATCH 3/9] build extra lipthreadcond so
Add the build script and file of libpthread-2.17.so
---
nptl_2_17/Makefile | 52 +++++++++++++++++++++++++++
nptl_2_17/build_libpthread-2.17.so.sh | 10 ++++++
nptl_2_17/libpthread-2.17-aarch64.map | 14 ++++++++
nptl_2_17/libpthread-2.17-x86_64.map | 14 ++++++++
4 files changed, 90 insertions(+)
create mode 100644 nptl_2_17/Makefile
create mode 100644 nptl_2_17/build_libpthread-2.17.so.sh
create mode 100644 nptl_2_17/libpthread-2.17-aarch64.map
create mode 100644 nptl_2_17/libpthread-2.17-x86_64.map
diff --git a/nptl_2_17/Makefile b/nptl_2_17/Makefile
new file mode 100644
index 00000000..f248ce56
--- /dev/null
+++ b/nptl_2_17/Makefile
@@ -0,0 +1,52 @@
+include libpthread-2.17_config
+subdir=libpthread-2.17
+objdir=../$(build_dir)/
+
+
+ifdef subdir
+.. := ../
+endif
+
+objpfx := $(patsubst %//,%/,$(objdir)/$(subdir)/)
+common-objpfx = $(objdir)/
+common-objdir = $(objdir)
+
+sysdep_dir := $(..)sysdeps
+export sysdep_dir := $(sysdep_dir)
+
+include $(common-objpfx)soversions.mk
+include $(common-objpfx)config.make
+
+uses-callbacks = -fexceptions
+
+sysdirs := $(foreach D,$(config-sysdirs),$(firstword $(filter /%,$D) $(..)$D))
+
++sysdep_dirs = $(sysdirs)
++sysdep_dirs := $(objdir) $(+sysdep_dirs)
+
++sysdep-includes := $(foreach dir,$(+sysdep_dirs), $(addprefix -I,$(wildcard $(dir)/include) $(dir)))
+
+compile_obj = pthread_cond_wait_2_17.os pthread_cond_signal_2_17.os pthread_cond_broadcast_2_17.os pthread_cond_init_2_17.os pthread_cond_destroy_2_17.os pthread_condattr_getclock_2_17.os pthread_condattr_getpshared_2_17.os pthread_condattr_init_2_17.os pthread_condattr_setclock_2_17.os cleanup_compat_2_17.os pthread_mutex_lock_2_17.os pthread_mutex_unlock_2_17.os tpp_2_17.os vars_2_17.os pause_nocancel_2_17.os lll_timedlock_wait_2_17.os pthread_mutex_cond_lock_2_17.os cancellation_2_17.os lowlevellock_2_17.os unwind_2_17.os
+
+ifeq (x86_64, $(arch))
+compile_obj += elision-timed_2_17.os elision-trylock_2_17.os elision-lock_2_17.os elision-unlock_2_17.os
+endif
+
+exist_obj_dir = $(foreach n,$(exist_obj),../$(build_dir)/nptl/$(n))
+
+compile_obj_dir = $(foreach n,$(compile_obj),../$(build_dir)/nptl/$(n))
+
+CFLAGS = -c -std=gnu11 -fgnu89-inline -fPIE -DNDEBUG -O2 -Wall -Werror -Wp,-D_GLIBCXX_ASSERTIONS -Wundef -Wwrite-strings -fasynchronous-unwind-tables -fmerge-all-constants -frounding-math -fstack-clash-protection -fstack-protector-strong -g -mtune=generic -Wstrict-prototypes -Wold-style-definition -fno-math-errno -fPIC -fexceptions -fasynchronous-unwind-tables -ftls-model=initial-exec -D_FORTIFY_SOURCE=2 -DSHARED -DTOP_NAMESPACE=glibc
+
+Headers = -I../include -I../$(build_dir)/nptl $(+sysdep-includes) -I../nptl_2_17 -I../nptl -I../libio -I../. -D_LIBC_REENTRANT -include ../$(build_dir)/libc-modules.h -include include/libc-symbols.h
+
+all: libpthread-2.17.so
+
+libpthread-2.17.so : $(compile_obj) libpthread-2.17_pic.a
+ gcc -shared -static-libgcc -Wl,-O1 -Wl,-z,defs -Wl,-dynamic-linker=/usr/local/lib/$(ld.so-version) -B../$(build_dir)/csu/ -Wl,--version-script=libpthread-2.17-$(arch).map -Wl,-soname=libpthread-2.17.so.0 -Wl,-z,noexecstack -Wtrampolines -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,now -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst -L../$(build_dir) -L../$(build_dir)/math -L../$(build_dir)/elf -L../$(build_dir)/dlfcn -L../$(build_dir)/nss -L../$(build_dir)/nis -L../$(build_dir)/rt -L../$(build_dir)/resolv -L../$(build_dir)/mathvec -L../$(build_dir)/support -L../$(build_dir)/crypt -L../$(build_dir)/nptl -Wl,-rpath-link=../$(build_dir):../$(build_dir)/math:../$(build_dir)/elf:../$(build_dir)/dlfcn:../$(build_dir)/nss:../$(build_dir)/nis:../$(build_dir)/rt:../$(build_dir)/resolv:../$(build_dir)/mathvec:../$(build_dir)/support:../$(build_dir)/crypt:../$(build_dir)/nptl -o ../$(build_dir)/nptl/libpthread-2.17.so ../$(build_dir)/csu/abi-note.o -Wl,--whole-archive ../$(build_dir)/nptl/libpthread-2.17_pic.a -Wl,--no-whole-archive -Wl,--start-group ../$(build_dir)/libc.so ../$(build_dir)/libc_nonshared.a -Wl,--as-needed ../$(build_dir)/elf/ld.so -Wl,--no-as-needed -Wl,--end-group
+
+libpthread-2.17_pic.a : $(compile_obj_dir) $(exist_obj_dir)
+ ar cruv ../$(build_dir)/nptl/$@ $^
+
+$(compile_obj) : %.os : %.c
+ gcc $< $(CFLAGS) $(Headers) -o ../$(build_dir)/nptl/$@ -MD -MP -MF ../$(build_dir)/nptl/$@.dt -MT ../$(build_dir)/nptl/$@
diff --git a/nptl_2_17/build_libpthread-2.17.so.sh b/nptl_2_17/build_libpthread-2.17.so.sh
new file mode 100644
index 00000000..bdb97d0f
--- /dev/null
+++ b/nptl_2_17/build_libpthread-2.17.so.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+build_arch=$1
+build_dir=$2
+config_dir=libpthread-2.17_config
+
+echo arch=${build_arch} > ${config_dir}
+echo build_dir=${build_dir} >> ${config_dir}
+make
+rm -rf ${config_dir}
diff --git a/nptl_2_17/libpthread-2.17-aarch64.map b/nptl_2_17/libpthread-2.17-aarch64.map
new file mode 100644
index 00000000..2c49fe17
--- /dev/null
+++ b/nptl_2_17/libpthread-2.17-aarch64.map
@@ -0,0 +1,14 @@
+GLIBC_2.17 {
+ global:
+ pthread_cond_init; pthread_cond_destroy;
+ pthread_cond_signal; pthread_cond_broadcast;
+ pthread_cond_wait; pthread_cond_timedwait;
+ local:
+ *;
+};
+GLIBC_2.34 {
+ global:
+ pthread_cond_clockwait;
+ local:
+ *;
+};
diff --git a/nptl_2_17/libpthread-2.17-x86_64.map b/nptl_2_17/libpthread-2.17-x86_64.map
new file mode 100644
index 00000000..b01e7d0d
--- /dev/null
+++ b/nptl_2_17/libpthread-2.17-x86_64.map
@@ -0,0 +1,14 @@
+GLIBC_2.3.2 {
+ global:
+ pthread_cond_init; pthread_cond_destroy;
+ pthread_cond_signal; pthread_cond_broadcast;
+ pthread_cond_wait; pthread_cond_timedwait;
+ local:
+ *;
+};
+GLIBC_2.34 {
+ global:
+ pthread_cond_clockwait;
+ local:
+ *;
+};
--
2.30.0

View File

@ -0,0 +1,166 @@
From d6e6184b4f10ef2cbdec09eae60350ced71e3de7 Mon Sep 17 00:00:00 2001
From: Yang Yanchao <yangyanchao6@huawei.com>
Date: Wed Nov 24 09:31:31 2021 +0800
Subject: [PATCH 4/9] build extra lipthreadcond so
For compatibility with glibc2.17, two header files are added with some
deleted macros.
---
nptl_2_17/compat_pthread_2_17.h | 61 +++++++++++++++++++++++++++
nptl_2_17/old_macros_2_17.h | 75 +++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+)
create mode 100644 nptl_2_17/compat_pthread_2_17.h
create mode 100644 nptl_2_17/old_macros_2_17.h
diff --git a/nptl_2_17/compat_pthread_2_17.h b/nptl_2_17/compat_pthread_2_17.h
new file mode 100644
index 00000000..d13051ba
--- /dev/null
+++ b/nptl_2_17/compat_pthread_2_17.h
@@ -0,0 +1,61 @@
+#ifndef _COMPAT_PTHREAD_2_17_H
+#define _COMPAT_PTHREAD_2_17_H 1
+
+#include <bits/struct_rwlock.h>
+#include <unistd.h>
+
+#ifdef __x86_64__
+#define __PTHREAD_COMPAT_PADDING_MID
+#define __PTHREAD_COMPAT_PADDING_END
+#define __PTHREAD_MUTEX_LOCK_ELISION 1
+# define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
+# define __PTHREAD_MUTEX_USE_UNION 0
+//# define ENABLE_ELISION_SUPPORT 1
+#else
+#define __PTHREAD_COMPAT_PADDING_MID
+#define __PTHREAD_COMPAT_PADDING_END
+#define __PTHREAD_MUTEX_LOCK_ELISION 0
+#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
+#define __PTHREAD_MUTEX_USE_UNION 0
+#endif
+
+#define CANCELSTATE_BIT 0
+#define CANCELSTATE_BITMASK (0x01 << CANCELSTATE_BIT)
+ /* Bit set if asynchronous cancellation mode is selected. */
+#define CANCELTYPE_BIT 1
+#define CANCELTYPE_BITMASK (0x01 << CANCELTYPE_BIT)
+ /* Bit set if canceling has been initiated. */
+#define CANCELING_BIT 2
+#define CANCELING_BITMASK (0x01 << CANCELING_BIT)
+ /* Bit set if canceled. */
+#define CANCELED_BIT 3
+#define CANCELED_BITMASK (0x01 << CANCELED_BIT)
+ /* Bit set if thread is exiting. */
+#define EXITING_BIT 4
+#define EXITING_BITMASK (0x01 << EXITING_BIT)
+ /* Bit set if thread terminated and TCB is freed. */
+#define TERMINATED_BIT 5
+#define TERMINATED_BITMASK (0x01 << TERMINATED_BIT)
+ /* Bit set if thread is supposed to change XID. */
+#define SETXID_BIT 6
+#define SETXID_BITMASK (0x01 << SETXID_BIT)
+ /* Mask for the rest. Helps the compiler to optimize. */
+#define CANCEL_RESTMASK 0xffffff80
+
+
+#define CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS(value) \
+ (((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK \
+ | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK)) \
+ == (CANCELTYPE_BITMASK | CANCELED_BITMASK))
+
+# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
+
+/*
+ * __pause_nocancel delete by fbb4a3143724ef3f044a4f05351,add it
+ */
+
+__typeof (pause) __pause_nocancel;
+hidden_proto (__pause_nocancel)
+
+#endif
+
diff --git a/nptl_2_17/old_macros_2_17.h b/nptl_2_17/old_macros_2_17.h
new file mode 100644
index 00000000..334b2ab1
--- /dev/null
+++ b/nptl_2_17/old_macros_2_17.h
@@ -0,0 +1,75 @@
+#ifndef _OLD_MACROS_2_17_H
+#define _OLD_MACROS_2_17_H 1
+
+/*
+ * Contains macros that have been defined in glibc2.34.
+ * Cancel the definition and use the old version.
+ * This header file needs to be included at the end.
+ */
+#undef __lll_unlock
+#define __lll_unlock(futex, private) \
+ ((void) \
+ ({ \
+ int *__futex = (futex); \
+ int __private = (private); \
+ int __oldval = atomic_exchange_rel (__futex, 0); \
+ if (__glibc_unlikely (__oldval > 1)) \
+ lll_futex_wake (__futex, 1, __private); \
+ }))
+
+#undef lll_unlock
+#define lll_unlock(futex, private) \
+ __lll_unlock (&(futex), private)
+
+extern int __lll_timedlock_wait (int *futex, const struct timespec *,
+ int private) attribute_hidden;
+
+
+/* As __lll_lock, but with a timeout. If the timeout occurs then return
+ ETIMEDOUT. If ABSTIME is invalid, return EINVAL. */
+#define __lll_timedlock(futex, abstime, private) \
+ ({ \
+ int *__futex = (futex); \
+ int __val = 0; \
+ \
+ if (__glibc_unlikely \
+ (atomic_compare_and_exchange_bool_acq (__futex, 1, 0))) \
+ __val = __lll_timedlock_wait (__futex, abstime, private); \
+ __val; \
+ })
+#define lll_timedlock(futex, abstime, private) \
+ __lll_timedlock (&(futex), abstime, private)
+
+/* Verify whether the supplied clockid is supported by
+ lll_futex_clock_wait_bitset. */
+#define lll_futex_supported_clockid(clockid) \
+ ((clockid) == CLOCK_REALTIME || (clockid) == CLOCK_MONOTONIC)
+
+/* The kernel currently only supports CLOCK_MONOTONIC or
+ CLOCK_REALTIME timeouts for FUTEX_WAIT_BITSET. We could attempt to
+ convert others here but currently do not. */
+#define lll_futex_clock_wait_bitset(futexp, val, clockid, timeout, private) \
+ ({ \
+ long int __ret; \
+ if (lll_futex_supported_clockid (clockid)) \
+ { \
+ const unsigned int clockbit = \
+ (clockid == CLOCK_REALTIME) ? FUTEX_CLOCK_REALTIME : 0; \
+ const int op = \
+ __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private); \
+ \
+ __ret = lll_futex_syscall (6, futexp, op, val, \
+ timeout, NULL /* Unused. */, \
+ FUTEX_BITSET_MATCH_ANY); \
+ } \
+ else \
+ __ret = -EINVAL; \
+ __ret; \
+ })
+
+# undef INTERNAL_VSYSCALL
+# define INTERNAL_VSYSCALL INTERNAL_SYSCALL
+# undef INLINE_VSYSCALL
+# define INLINE_VSYSCALL INLINE_SYSCALL
+
+#endif
--
2.30.0

View File

@ -0,0 +1,140 @@
From 463dc947b4f9bc4137c9919ee72b896403926474 Mon Sep 17 00:00:00 2001
From: Roland McGrath <roland@hack.frob.com>
Date: Thu Jun 12 13:48:47 2014 -0700
Subject: [PATCH 5/9] build extra lipthreadcond so
add pthread-functions.h which delete by 1d67cf9e8a0194588e66fb3b7afcbdc3bf836a
---
nptl_2_17/pthread-functions_2_17.h | 119 +++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100644 nptl_2_17/pthread-functions_2_17.h
diff --git a/nptl_2_17/pthread-functions_2_17.h b/nptl_2_17/pthread-functions_2_17.h
new file mode 100644
index 00000000..07ca8e7e
--- /dev/null
+++ b/nptl_2_17/pthread-functions_2_17.h
@@ -0,0 +1,119 @@
+/* Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _PTHREAD_FUNCTIONS_H
+#define _PTHREAD_FUNCTIONS_H 1
+
+#include <pthread.h>
+#include <setjmp.h>
+#include <internaltypes.h>
+#include <sysdep.h>
+
+struct xid_command;
+
+/* Data type shared with libc. The libc uses it to pass on calls to
+ the thread functions. */
+struct pthread_functions
+{
+ int (*ptr_pthread_attr_destroy) (pthread_attr_t *);
+ int (*ptr___pthread_attr_init_2_0) (pthread_attr_t *);
+ int (*ptr___pthread_attr_init_2_1) (pthread_attr_t *);
+ int (*ptr_pthread_attr_getdetachstate) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setdetachstate) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getinheritsched) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setinheritsched) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getschedparam) (const pthread_attr_t *,
+ struct sched_param *);
+ int (*ptr_pthread_attr_setschedparam) (pthread_attr_t *,
+ const struct sched_param *);
+ int (*ptr_pthread_attr_getschedpolicy) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setschedpolicy) (pthread_attr_t *, int);
+ int (*ptr_pthread_attr_getscope) (const pthread_attr_t *, int *);
+ int (*ptr_pthread_attr_setscope) (pthread_attr_t *, int);
+ int (*ptr_pthread_condattr_destroy) (pthread_condattr_t *);
+ int (*ptr_pthread_condattr_init) (pthread_condattr_t *);
+ int (*ptr___pthread_cond_broadcast) (pthread_cond_t *);
+ int (*ptr___pthread_cond_destroy) (pthread_cond_t *);
+ int (*ptr___pthread_cond_init) (pthread_cond_t *,
+ const pthread_condattr_t *);
+ int (*ptr___pthread_cond_signal) (pthread_cond_t *);
+ int (*ptr___pthread_cond_wait) (pthread_cond_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait) (pthread_cond_t *, pthread_mutex_t *,
+ const struct timespec *);
+ int (*ptr___pthread_cond_clockwait) (pthread_cond_t *,
+ pthread_mutex_t *,
+ clockid_t,
+ const struct timespec *);
+ int (*ptr___pthread_cond_broadcast_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_destroy_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_init_2_0) (pthread_cond_2_0_t *,
+ const pthread_condattr_t *);
+ int (*ptr___pthread_cond_signal_2_0) (pthread_cond_2_0_t *);
+ int (*ptr___pthread_cond_wait_2_0) (pthread_cond_2_0_t *, pthread_mutex_t *);
+ int (*ptr___pthread_cond_timedwait_2_0) (pthread_cond_2_0_t *,
+ pthread_mutex_t *,
+ const struct timespec *);
+ int (*ptr_pthread_equal) (pthread_t, pthread_t);
+ void (*ptr___pthread_exit) (void *) __attribute__ ((__noreturn__));
+ int (*ptr_pthread_getschedparam) (pthread_t, int *, struct sched_param *);
+ int (*ptr_pthread_setschedparam) (pthread_t, int,
+ const struct sched_param *);
+ int (*ptr_pthread_mutex_destroy) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_init) (pthread_mutex_t *,
+ const pthread_mutexattr_t *);
+ int (*ptr_pthread_mutex_lock) (pthread_mutex_t *);
+ int (*ptr_pthread_mutex_unlock) (pthread_mutex_t *);
+ int (*ptr___pthread_setcancelstate) (int, int *);
+ int (*ptr_pthread_setcanceltype) (int, int *);
+ void (*ptr___pthread_cleanup_upto) (__jmp_buf, char *);
+ int (*ptr___pthread_once) (pthread_once_t *, void (*) (void));
+ int (*ptr___pthread_rwlock_rdlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_rwlock_wrlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_rwlock_unlock) (pthread_rwlock_t *);
+ int (*ptr___pthread_key_create) (pthread_key_t *, void (*) (void *));
+ void *(*ptr___pthread_getspecific) (pthread_key_t);
+ int (*ptr___pthread_setspecific) (pthread_key_t, const void *);
+ void (*ptr__pthread_cleanup_push_defer) (struct _pthread_cleanup_buffer *,
+ void (*) (void *), void *);
+ void (*ptr__pthread_cleanup_pop_restore) (struct _pthread_cleanup_buffer *,
+ int);
+#define HAVE_PTR_NTHREADS
+ unsigned int *ptr_nthreads;
+ void (*ptr___pthread_unwind) (__pthread_unwind_buf_t *)
+ __attribute ((noreturn)) __cleanup_fct_attribute;
+ void (*ptr__nptl_deallocate_tsd) (void);
+ int (*ptr__nptl_setxid) (struct xid_command *);
+ void (*ptr_set_robust) (struct pthread *);
+};
+
+/* Variable in libc.so. */
+extern struct pthread_functions __libc_pthread_functions attribute_hidden;
+extern int __libc_pthread_functions_init attribute_hidden;
+
+#ifdef PTR_DEMANGLE
+# define PTHFCT_CALL(fct, params) \
+ ({ __typeof (__libc_pthread_functions.fct) __p; \
+ __p = __libc_pthread_functions.fct; \
+ PTR_DEMANGLE (__p); \
+ __p params; })
+#else
+# define PTHFCT_CALL(fct, params) \
+ __libc_pthread_functions.fct params
+#endif
+
+#endif /* pthread-functions.h */
--
2.30.0

View File

@ -0,0 +1,587 @@
From 1cdbe579482c07e9f4bb3baa4864da2d3e7eb837 Mon Sep 17 00:00:00 2001
From: Andi Kleen <ak@linux.intel.com>
Date: Sat, 10 Nov 2012 00:51:26 -0800i
Subject: [PATCH 6/9] build extra lipthreadcond so
add elsion functions which moved to libc in glibc-2.34.
Some attributes are changed and cannot be directly referenced.
---
nptl_2_17/lll_timedlock_wait_2_17.c | 59 +++++++++++++++++++++++++++++
nptl_2_17/elision-conf_2_17.c | 138 +++++++++++++++++++++++++++++++
nptl_2_17/elision-lock_2_17.c | 107 ++++++++++++++++++++++++
nptl_2_17/elision-timed_2_17.c | 27 ++++++
nptl_2_17/elision-trylock_2_17.c | 75 +++++++++++++++++
nptl_2_17/elision-unlock_2_17.c | 34 ++++++++
nptl_2_17/hle_2_17.h | 75 +++++++++++++++++
6 files changed, 515
insertions(+)
create mode 100644 nptl_2_17/lll_timedlock_wait_2_17.c
create mode 100644 nptl_2_17/elision-conf_2_17.c
create mode 100644 nptl_2_17/elision-lock_2_17.c
create mode 100644 nptl_2_17/elision-timed_2_17.c
create mode 100644 nptl_2_17/elision-trylock_2_17.c
create mode 100644 nptl_2_17/elision-unlock_2_17.c
create mode 100644 nptl_2_17/hle_2_17.h
diff --git a/nptl_2_17/lll_timedlock_wait_2_17.c b/nptl_2_17/lll_timedlock_wait_2_17.c
new file mode 100644
index 00000000..91bf9637
--- /dev/null
+++ b/nptl_2_17/lll_timedlock_wait_2_17.c
@@ -0,0 +1,59 @@
+/* Timed low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <atomic.h>
+#include <errno.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+
+
+int
+__lll_timedlock_wait (int *futex, const struct timespec *abstime, int private)
+{
+ /* Reject invalid timeouts. */
+ if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
+ return EINVAL;
+
+ /* Try locking. */
+ while (atomic_exchange_acq (futex, 2) != 0)
+ {
+ struct timeval tv;
+
+ /* Get the current time. */
+ (void) __gettimeofday (&tv, NULL);
+
+ /* Compute relative timeout. */
+ struct timespec rt;
+ rt.tv_sec = abstime->tv_sec - tv.tv_sec;
+ rt.tv_nsec = abstime->tv_nsec - tv.tv_usec * 1000;
+ if (rt.tv_nsec < 0)
+ {
+ rt.tv_nsec += 1000000000;
+ --rt.tv_sec;
+ }
+
+ if (rt.tv_sec < 0)
+ return ETIMEDOUT;
+
+ /* If *futex == 2, wait until woken or timeout. */
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
+
+ return 0;
+}
diff --git a/nptl_2_17/elision-conf_2_17.c b/nptl_2_17/elision-conf_2_17.c
new file mode 100644
index 00000000..22af2944
--- /dev/null
+++ b/nptl_2_17/elision-conf_2_17.c
@@ -0,0 +1,138 @@
+/* elision-conf.c: Lock elision tunable parameters.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include <pthreadP.h>
+#include <init-arch.h>
+#include <elision-conf.h>
+#include <unistd.h>
+
+#if HAVE_TUNABLES
+# define TUNABLE_NAMESPACE elision
+#endif
+#include <elf/dl-tunables.h>
+
+/* Reasonable initial tuning values, may be revised in the future.
+ This is a conservative initial value. */
+
+struct elision_config __elision_aconf =
+ {
+ /* How often to not attempt to use elision if a transaction aborted
+ because the lock is already acquired. Expressed in number of lock
+ acquisition attempts. */
+ .skip_lock_busy = 3,
+ /* How often to not attempt to use elision if a transaction aborted due
+ to reasons other than other threads' memory accesses. Expressed in
+ number of lock acquisition attempts. */
+ .skip_lock_internal_abort = 3,
+ /* How often we retry using elision if there is chance for the transaction
+ to finish execution (e.g., it wasn't aborted due to the lock being
+ already acquired. */
+ .retry_try_xbegin = 3,
+ /* Same as SKIP_LOCK_INTERNAL_ABORT but for trylock. */
+ .skip_trylock_internal_abort = 3,
+ };
+
+/* Force elision for all new locks. This is used to decide whether existing
+ DEFAULT locks should be automatically upgraded to elision in
+ pthread_mutex_lock(). Disabled for suid programs. Only used when elision
+ is available. */
+
+int __pthread_force_elision attribute_hidden = 0;
+
+#if HAVE_TUNABLES
+static inline void
+__always_inline
+do_set_elision_enable (int32_t elision_enable)
+{
+ /* Enable elision if it's avaliable in hardware. It's not necessary to check
+ if __libc_enable_secure isn't enabled since elision_enable will be set
+ according to the default, which is disabled. */
+ if (elision_enable == 1)
+ __pthread_force_elision = HAS_CPU_FEATURE (RTM) ? 1 : 0;
+}
+
+/* The pthread->elision_enable tunable is 0 or 1 indicating that elision
+ should be disabled or enabled respectively. The feature will only be used
+ if it's supported by the hardware. */
+
+void
+TUNABLE_CALLBACK (set_elision_enable) (tunable_val_t *valp)
+{
+ int32_t elision_enable = (int32_t) valp->numval;
+ do_set_elision_enable (elision_enable);
+}
+
+#define TUNABLE_CALLBACK_FNDECL(__name, __type) \
+static inline void \
+__always_inline \
+do_set_elision_ ## __name (__type value) \
+{ \
+ __elision_aconf.__name = value; \
+} \
+void \
+TUNABLE_CALLBACK (set_elision_ ## __name) (tunable_val_t *valp) \
+{ \
+ __type value = (__type) (valp)->numval; \
+ do_set_elision_ ## __name (value); \
+}
+
+TUNABLE_CALLBACK_FNDECL (skip_lock_busy, int32_t);
+TUNABLE_CALLBACK_FNDECL (skip_lock_internal_abort, int32_t);
+TUNABLE_CALLBACK_FNDECL (retry_try_xbegin, int32_t);
+TUNABLE_CALLBACK_FNDECL (skip_trylock_internal_abort, int32_t);
+#endif
+
+/* Initialize elision. */
+
+static void
+elision_init (int argc __attribute__ ((unused)),
+ char **argv __attribute__ ((unused)),
+ char **environ)
+{
+#if HAVE_TUNABLES
+ /* Elision depends on tunables and must be explicitly turned on by setting
+ the appropriate tunable on a supported platform. */
+
+ TUNABLE_GET (enable, int32_t,
+ TUNABLE_CALLBACK (set_elision_enable));
+ TUNABLE_GET (skip_lock_busy, int32_t,
+ TUNABLE_CALLBACK (set_elision_skip_lock_busy));
+ TUNABLE_GET (skip_lock_internal_abort, int32_t,
+ TUNABLE_CALLBACK (set_elision_skip_lock_internal_abort));
+ TUNABLE_GET (tries, int32_t,
+ TUNABLE_CALLBACK (set_elision_retry_try_xbegin));
+ TUNABLE_GET (skip_trylock_internal_abort, int32_t,
+ TUNABLE_CALLBACK (set_elision_skip_trylock_internal_abort));
+#endif
+
+ if (!__pthread_force_elision)
+ __elision_aconf.retry_try_xbegin = 0; /* Disable elision on rwlocks. */
+}
+
+#ifdef SHARED
+# define INIT_SECTION ".init_array"
+#else
+# define INIT_SECTION ".preinit_array"
+#endif
+
+void (*const __pthread_init_array []) (int, char **, char **)
+ __attribute__ ((section (INIT_SECTION), aligned (sizeof (void *)))) =
+{
+ &elision_init
+};
diff --git a/nptl_2_17/elision-lock_2_17.c b/nptl_2_17/elision-lock_2_17.c
new file mode 100644
index 00000000..e6dbbc21
--- /dev/null
+++ b/nptl_2_17/elision-lock_2_17.c
@@ -0,0 +1,107 @@
+/* elision-lock.c: Elided pthread mutex lock.
+ Copyright (C) 2011-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread_2_17.h>
+#include "pthreadP_2_17.h"
+#include "lowlevellock.h"
+#include "hle_2_17.h"
+#include <elision-conf.h>
+
+#if !defined(LLL_LOCK) && !defined(EXTRAARG)
+/* Make sure the configuration code is always linked in for static
+ libraries. */
+#include "elision-conf_2_17.c"
+#endif
+
+#ifndef EXTRAARG
+#define EXTRAARG
+#endif
+#ifndef LLL_LOCK
+#define LLL_LOCK(a,b) lll_lock(a,b), 0
+#endif
+
+#define aconf __elision_aconf
+
+/* Adaptive lock using transactions.
+ By default the lock region is run as a transaction, and when it
+ aborts or the lock is busy the lock adapts itself. */
+
+int
+__lll_lock_elision (int *futex, short *adapt_count, EXTRAARG int private)
+{
+ /* adapt_count can be accessed concurrently; these accesses can be both
+ inside of transactions (if critical sections are nested and the outer
+ critical section uses lock elision) and outside of transactions. Thus,
+ we need to use atomic accesses to avoid data races. However, the
+ value of adapt_count is just a hint, so relaxed MO accesses are
+ sufficient. */
+ if (atomic_load_relaxed (adapt_count) <= 0)
+ {
+ unsigned status;
+ int try_xbegin;
+
+ for (try_xbegin = aconf.retry_try_xbegin;
+ try_xbegin > 0;
+ try_xbegin--)
+ {
+ if ((status = _xbegin()) == _XBEGIN_STARTED)
+ {
+ if (*futex == 0)
+ return 0;
+
+ /* Lock was busy. Fall back to normal locking.
+ Could also _xend here but xabort with 0xff code
+ is more visible in the profiler. */
+ _xabort (_ABORT_LOCK_BUSY);
+ }
+
+ if (!(status & _XABORT_RETRY))
+ {
+ if ((status & _XABORT_EXPLICIT)
+ && _XABORT_CODE (status) == _ABORT_LOCK_BUSY)
+ {
+ /* Right now we skip here. Better would be to wait a bit
+ and retry. This likely needs some spinning. See
+ above for why relaxed MO is sufficient. */
+ if (atomic_load_relaxed (adapt_count)
+ != aconf.skip_lock_busy)
+ atomic_store_relaxed (adapt_count, aconf.skip_lock_busy);
+ }
+ /* Internal abort. There is no chance for retry.
+ Use the normal locking and next time use lock.
+ Be careful to avoid writing to the lock. See above for why
+ relaxed MO is sufficient. */
+ else if (atomic_load_relaxed (adapt_count)
+ != aconf.skip_lock_internal_abort)
+ atomic_store_relaxed (adapt_count,
+ aconf.skip_lock_internal_abort);
+ break;
+ }
+ }
+ }
+ else
+ {
+ /* Use a normal lock until the threshold counter runs out.
+ Lost updates possible. */
+ atomic_store_relaxed (adapt_count,
+ atomic_load_relaxed (adapt_count) - 1);
+ }
+
+ /* Use a normal lock here. */
+ return LLL_LOCK ((*futex), private);
+}
diff --git a/nptl_2_17/elision-timed_2_17.c b/nptl_2_17/elision-timed_2_17.c
new file mode 100644
index 00000000..5050f2d1
--- /dev/null
+++ b/nptl_2_17/elision-timed_2_17.c
@@ -0,0 +1,27 @@
+/* elision-timed.c: Lock elision timed lock.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <time.h>
+#include <elision-conf.h>
+#include "lowlevellock.h"
+#include <old_macros_2_17.h>
+#define __lll_lock_elision __lll_timedlock_elision
+#define EXTRAARG const struct timespec *t,
+#undef LLL_LOCK
+#define LLL_LOCK(a, b) lll_timedlock(a, t, b)
+#include "elision-lock_2_17.c"
diff --git a/nptl_2_17/elision-trylock_2_17.c b/nptl_2_17/elision-trylock_2_17.c
new file mode 100644
index 00000000..70d8f8b9
--- /dev/null
+++ b/nptl_2_17/elision-trylock_2_17.c
@@ -0,0 +1,75 @@
+/* elision-trylock.c: Lock eliding trylock for pthreads.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <pthread_2_17.h>
+
+#include <lowlevellock.h>
+#include "hle_2_17.h"
+#include <elision-conf.h>
+
+#define aconf __elision_aconf
+
+/* Try to elide a futex trylock. FUTEX is the futex variable. ADAPT_COUNT is
+ the adaptation counter in the mutex. */
+
+int
+__lll_trylock_elision (int *futex, short *adapt_count)
+{
+ /* Implement POSIX semantics by forbiding nesting
+ trylock. Sorry. After the abort the code is re-executed
+ non transactional and if the lock was already locked
+ return an error. */
+ _xabort (_ABORT_NESTED_TRYLOCK);
+
+ /* Only try a transaction if it's worth it. See __lll_lock_elision for
+ why we need atomic accesses. Relaxed MO is sufficient because this is
+ just a hint. */
+ if (atomic_load_relaxed (adapt_count) <= 0)
+ {
+ unsigned status;
+
+ if ((status = _xbegin()) == _XBEGIN_STARTED)
+ {
+ if (*futex == 0)
+ return 0;
+
+ /* Lock was busy. Fall back to normal locking.
+ Could also _xend here but xabort with 0xff code
+ is more visible in the profiler. */
+ _xabort (_ABORT_LOCK_BUSY);
+ }
+
+ if (!(status & _XABORT_RETRY))
+ {
+ /* Internal abort. No chance for retry. For future
+ locks don't try speculation for some time. See above for MO. */
+ if (atomic_load_relaxed (adapt_count)
+ != aconf.skip_lock_internal_abort)
+ atomic_store_relaxed (adapt_count, aconf.skip_lock_internal_abort);
+ }
+ /* Could do some retries here. */
+ }
+ else
+ {
+ /* Lost updates are possible but harmless (see above). */
+ atomic_store_relaxed (adapt_count,
+ atomic_load_relaxed (adapt_count) - 1);
+ }
+
+ return lll_trylock (*futex);
+}
diff --git a/nptl_2_17/elision-unlock_2_17.c b/nptl_2_17/elision-unlock_2_17.c
new file mode 100644
index 00000000..b5d38c5f
--- /dev/null
+++ b/nptl_2_17/elision-unlock_2_17.c
@@ -0,0 +1,34 @@
+/* elision-unlock.c: Commit an elided pthread lock.
+ Copyright (C) 2013-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "pthreadP_2_17.h"
+#include "lowlevellock.h"
+#include "hle_2_17.h"
+#include <old_macros_2_17.h>
+
+int
+__lll_unlock_elision(int *lock, int private)
+{
+ /* When the lock was free we're in a transaction.
+ When you crash here you unlocked a free lock. */
+ if (*lock == 0)
+ _xend();
+ else
+ lll_unlock ((*lock), private);
+ return 0;
+}
diff --git a/nptl_2_17/hle_2_17.h b/nptl_2_17/hle_2_17.h
new file mode 100644
index 00000000..4a7b9e3b
--- /dev/null
+++ b/nptl_2_17/hle_2_17.h
@@ -0,0 +1,75 @@
+/* Shared RTM header. Emulate TSX intrinsics for compilers and assemblers
+ that do not support the intrinsics and instructions yet. */
+#ifndef _HLE_H
+#define _HLE_H 1
+
+#ifdef __ASSEMBLER__
+
+.macro XBEGIN target
+ .byte 0xc7,0xf8
+ .long \target-1f
+1:
+.endm
+
+.macro XEND
+ .byte 0x0f,0x01,0xd5
+.endm
+
+.macro XABORT code
+ .byte 0xc6,0xf8,\code
+.endm
+
+.macro XTEST
+ .byte 0x0f,0x01,0xd6
+.endm
+
+#endif
+
+/* Official RTM intrinsics interface matching gcc/icc, but works
+ on older gcc compatible compilers and binutils.
+ We should somehow detect if the compiler supports it, because
+ it may be able to generate slightly better code. */
+
+#define _XBEGIN_STARTED (~0u)
+#define _XABORT_EXPLICIT (1 << 0)
+#define _XABORT_RETRY (1 << 1)
+#define _XABORT_CONFLICT (1 << 2)
+#define _XABORT_CAPACITY (1 << 3)
+#define _XABORT_DEBUG (1 << 4)
+#define _XABORT_NESTED (1 << 5)
+#define _XABORT_CODE(x) (((x) >> 24) & 0xff)
+
+#define _ABORT_LOCK_BUSY 0xff
+#define _ABORT_LOCK_IS_LOCKED 0xfe
+#define _ABORT_NESTED_TRYLOCK 0xfd
+
+#ifndef __ASSEMBLER__
+
+#define __force_inline __attribute__((__always_inline__)) inline
+
+static __force_inline int _xbegin(void)
+{
+ int ret = _XBEGIN_STARTED;
+ asm volatile (".byte 0xc7,0xf8 ; .long 0" : "+a" (ret) :: "memory");
+ return ret;
+}
+
+static __force_inline void _xend(void)
+{
+ asm volatile (".byte 0x0f,0x01,0xd5" ::: "memory");
+}
+
+static __force_inline void _xabort(const unsigned int status)
+{
+ asm volatile (".byte 0xc6,0xf8,%P0" :: "i" (status) : "memory");
+}
+
+static __force_inline int _xtest(void)
+{
+ unsigned char out;
+ asm volatile (".byte 0x0f,0x01,0xd6 ; setnz %0" : "=r" (out) :: "memory");
+ return out;
+}
+
+#endif
+#endif
--
2.30.0

View File

@ -0,0 +1,68 @@
From 3df6f22e5fde470a6e0242e582e58919493bdd54 Mon Sep 17 00:00:00 2001
From: Roland McGrath <roland@hack.frob.com>
Date: Tue, 15 Jul 2014 15:23:06 -0700
Subject: [PATCH 7/9] build extra lipthreadcond so
since 78fe624d44b8f6489b2d0de9bfdc09290a719a7, lowlevellock.c depends futex-internal.h which uses the private symbol __GI___libc_fatal of glibc.
We can't reference it in libpthread-2.17.so. Therefore, recompile in libphtread-2.17.so
---
nptl_2_17/lowlevellock_2_17.c | 46 ++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 nptl_2_17/lowlevellock_2_17.c
diff --git a/nptl_2_17/lowlevellock_2_17.c b/nptl_2_17/lowlevellock_2_17.c
new file mode 100644
index 00000000..bf1ca6b9
--- /dev/null
+++ b/nptl_2_17/lowlevellock_2_17.c
@@ -0,0 +1,46 @@
+/* low level locking for pthread library. Generic futex-using version.
+ Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Paul Mackerras <paulus@au.ibm.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <sysdep.h>
+#include <lowlevellock.h>
+#include <sys/time.h>
+#include <atomic.h>
+
+void
+__lll_lock_wait_private (int *futex)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, LLL_PRIVATE); /* Wait if *futex == 2. */
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, LLL_PRIVATE); /* Wait if *futex == 2. */
+}
+
+
+/* This function doesn't get included in libc. */
+void
+__lll_lock_wait (int *futex, int private)
+{
+ if (*futex == 2)
+ lll_futex_wait (futex, 2, private); /* Wait if *futex == 2. */
+
+ while (atomic_exchange_acq (futex, 2) != 0)
+ lll_futex_wait (futex, 2, private); /* Wait if *futex == 2. */
+}
--
2.30.0

View File

@ -0,0 +1,56 @@
From 329ea513b451ae8322aa7a24ed84da13992af2dd Mon Sep 17 00:00:00 2001
From: Zack Weinberg <zackw@panix.com>
Date: Tue, 3 Apr 2018 18:26:44 -0400
Subject: [PATCH 8/9] build extra lipthreadcond so
since bb4a3143724ef3f044a4f05351fe041300ee382, Remove pause and nanosleep not cancel wrappers
To build libtphread-2.17.so, we added it back.
---
nptl_2_17/pause_nocancel_2_17.c | 34 +++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 nptl_2_17/pause_nocancel_2_17.c
diff --git a/nptl_2_17/pause_nocancel_2_17.c b/nptl_2_17/pause_nocancel_2_17.c
new file mode 100644
index 00000000..ab8e78d2
--- /dev/null
+++ b/nptl_2_17/pause_nocancel_2_17.c
@@ -0,0 +1,34 @@
+/* Linux pause syscall implementation -- non-cancellable.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <compat_pthread_2_17.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
+int
+__pause_nocancel (void)
+{
+#ifdef __NR_pause
+ return INLINE_SYSCALL_CALL (pause);
+#else
+ return INLINE_SYSCALL_CALL (ppoll, NULL, 0, NULL, NULL);
+#endif
+}
+hidden_def (__pause_nocancel)
--
2.30.0

View File

@ -0,0 +1,161 @@
From 09d65ff393e9183eecba1e5cb877e95dbdd3d4a4 Mon Sep 17 00:00:00 2001
From: Ulrich Drepper <drepper@redhat.com>
Date: Sat, 12 Apr 2003 00:58:26 +0000
Subject: [PATCH 9/9] build extra lipthreadcond so
since 6253bacdc00de132dec452ff7c6ce3ba7fa23d81, __libc_longjmp became a
private interface.We can't quote directly.
Change it to longjmp
---
nptl_2_17/unwind_2_17.c | 138 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 138 insertions(+)
create mode 100644 nptl_2_17/unwind_2_17.c
diff --git a/nptl_2_17/unwind_2_17.c b/nptl_2_17/unwind_2_17.c
new file mode 100644
index 00000000..ada8f74d
--- /dev/null
+++ b/nptl_2_17/unwind_2_17.c
@@ -0,0 +1,138 @@
+/* Copyright (C) 2003-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@redhat.com>
+ and Richard Henderson <rth@redhat.com>, 2003.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include "pthreadP_2_17.h"
+#include <setjmp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <jmpbuf-unwind.h>
+
+#ifdef _STACK_GROWS_DOWN
+# define FRAME_LEFT(frame, other, adj) \
+ ((uintptr_t) frame - adj >= (uintptr_t) other - adj)
+#elif _STACK_GROWS_UP
+# define FRAME_LEFT(frame, other, adj) \
+ ((uintptr_t) frame - adj <= (uintptr_t) other - adj)
+#else
+# error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP"
+#endif
+
+static _Unwind_Reason_Code
+unwind_stop (int version, _Unwind_Action actions,
+ _Unwind_Exception_Class exc_class,
+ struct _Unwind_Exception *exc_obj,
+ struct _Unwind_Context *context, void *stop_parameter)
+{
+ struct pthread_unwind_buf *buf = stop_parameter;
+ struct pthread *self = THREAD_SELF;
+ struct _pthread_cleanup_buffer *curp = THREAD_GETMEM (self, cleanup);
+ int do_longjump = 0;
+
+ /* Adjust all pointers used in comparisons, so that top of thread's
+ stack is at the top of address space. Without that, things break
+ if stack is allocated above the main stack. */
+ uintptr_t adj = (uintptr_t) self->stackblock + self->stackblock_size;
+
+ /* Do longjmp if we're at "end of stack", aka "end of unwind data".
+ We assume there are only C frame without unwind data in between
+ here and the jmp_buf target. Otherwise simply note that the CFA
+ of a function is NOT within it's stack frame; it's the SP of the
+ previous frame. */
+ if ((actions & _UA_END_OF_STACK)
+ || ! _JMPBUF_CFA_UNWINDS_ADJ (buf->cancel_jmp_buf[0].jmp_buf, context,
+ adj))
+ do_longjump = 1;
+
+ if (__glibc_unlikely (curp != NULL))
+ {
+ /* Handle the compatibility stuff. Execute all handlers
+ registered with the old method which would be unwound by this
+ step. */
+ struct _pthread_cleanup_buffer *oldp = buf->priv.data.cleanup;
+ void *cfa = (void *) (_Unwind_Ptr) _Unwind_GetCFA (context);
+
+ if (curp != oldp && (do_longjump || FRAME_LEFT (cfa, curp, adj)))
+ {
+ do
+ {
+ /* Pointer to the next element. */
+ struct _pthread_cleanup_buffer *nextp = curp->__prev;
+
+ /* Call the handler. */
+ curp->__routine (curp->__arg);
+
+ /* To the next. */
+ curp = nextp;
+ }
+ while (curp != oldp
+ && (do_longjump || FRAME_LEFT (cfa, curp, adj)));
+
+ /* Mark the current element as handled. */
+ THREAD_SETMEM (self, cleanup, curp);
+ }
+ }
+
+ if (do_longjump)
+ longjmp ((struct __jmp_buf_tag *) buf->cancel_jmp_buf, 1);
+
+ return _URC_NO_REASON;
+}
+
+
+static void
+unwind_cleanup (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc)
+{
+ /* When we get here a C++ catch block didn't rethrow the object. We
+ cannot handle this case and therefore abort. */
+ __libc_fatal ("FATAL: exception not rethrown\n");
+}
+
+
+void
+__cleanup_fct_attribute __attribute ((noreturn))
+__pthread_unwind (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+ struct pthread *self = THREAD_SELF;
+
+ /* This is not a catchable exception, so don't provide any details about
+ the exception type. We do need to initialize the field though. */
+ THREAD_SETMEM (self, exc.exception_class, 0);
+ THREAD_SETMEM (self, exc.exception_cleanup, &unwind_cleanup);
+
+ _Unwind_ForcedUnwind (&self->exc, unwind_stop, ibuf);
+ /* NOTREACHED */
+
+ /* We better do not get here. */
+ abort ();
+}
+hidden_def (__pthread_unwind)
+
+
+void
+__cleanup_fct_attribute __attribute ((noreturn))
+__pthread_unwind_next (__pthread_unwind_buf_t *buf)
+{
+ struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf;
+
+ __pthread_unwind ((__pthread_unwind_buf_t *) ibuf->priv.data.prev);
+}
+hidden_def (__pthread_unwind_next)
--
2.30.0

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@
############################################################################## ##############################################################################
Name: glibc Name: glibc
Version: 2.34 Version: 2.34
Release: 26 Release: 27
Summary: The GNU libc libraries Summary: The GNU libc libraries
License: %{all_license} License: %{all_license}
URL: http://www.gnu.org/software/glibc/ URL: http://www.gnu.org/software/glibc/
@ -136,7 +136,15 @@ Patch49: posix-Fix-attribute-access-mode-on-getcwd-BZ-27476.patch
#Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch #Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
Patch9002: compat-2.17-libpthreadcond-so.patch Patch9002: 0001-add-base-files-for-libphtread-condition-family.patch
Patch9003: 0002-add-header-files-for-libphtread_2_17_so.patch
Patch9004: 0003-add-build-script-and-files-of-libpthread_2_17_so.patch
Patch9005: 0004-add-two-header-files-with-some-deleted-macros.patch
Patch9006: 0005-add-pthread-functions_h.patch
Patch9007: 0006-add-elsion-function-which-moved-to-libc-in-glibc-2.34.patch
Patch9008: 0007-add-lowlevellock_2_17_c.patch
Patch9009: 0008-add-pause_nocancel_2_17.patch
Patch9010: 0009-add-unwind-with-longjmp.patch
Provides: ldconfig rtld(GNU_HASH) bundled(gnulib) Provides: ldconfig rtld(GNU_HASH) bundled(gnulib)
@ -765,7 +773,7 @@ touch compat-2.17.filelist
-e '\,.*/etc/\(localtime\|nsswitch.conf\|ld\.so\.conf\|ld\.so\.cache\|default\|rpc\|gai\.conf\),d' \ -e '\,.*/etc/\(localtime\|nsswitch.conf\|ld\.so\.conf\|ld\.so\.cache\|default\|rpc\|gai\.conf\),d' \
-e '\,.*/%{_libdir}/lib\(pcprofile\|memusage\)\.so,d' \ -e '\,.*/%{_libdir}/lib\(pcprofile\|memusage\)\.so,d' \
%if %{with compat_2_17} %if %{with compat_2_17}
-e '\,.*/%{_libdir}/libpthread-2.17.so,d' \ -e '\,.*%{_libdir}/libpthread-2.17.so,d' \
%endif %endif
-e '\,.*/bin/\(memusage\|mtrace\|xtrace\|pcprofiledump\),d' -e '\,.*/bin/\(memusage\|mtrace\|xtrace\|pcprofiledump\),d'
} | sort > master.filelist } | sort > master.filelist
@ -1322,6 +1330,10 @@ fi
%endif %endif
%changelog %changelog
* Wed Nov 24 2021 Yang Yanchao <yangyanchao6@huawei.com> - 2.34-27
- Refactor the libpthread-2.17.so code and pass all test cases.
delete libpthread-2.17.so from glibc-devel
* Fri Nov 19 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-26 * Fri Nov 19 2021 Qingqing Li <liqingqing3@huawei.com> - 2.34-26
- revert supress -Wcast-qual warnings in bsearch - revert supress -Wcast-qual warnings in bsearch