summaryrefslogtreecommitdiff
path: root/0004-add-two-header-files-with-some-deleted-macros.patch
blob: 7acb8e2a42827573d8188fbf6d017f1383e8dac1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
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