void-packages/srcpkgs/ntp/patches/compat-glibc-2.34.patch

56 lines
1.7 KiB
Diff

diff -Nru a/libntp/work_thread.c b/libntp/work_thread.c
--- a/libntp/work_thread.c 2022-01-16 11:35:17.290791372 +0100
+++ b/libntp/work_thread.c 2022-01-16 11:35:17.290791372 +0100
@@ -41,20 +41,10 @@
#ifndef THREAD_MINSTACKSIZE
# define THREAD_MINSTACKSIZE (64U * 1024)
#endif
-#ifndef __sun
-#if defined(PTHREAD_STACK_MIN) && THREAD_MINSTACKSIZE < PTHREAD_STACK_MIN
-# undef THREAD_MINSTACKSIZE
-# define THREAD_MINSTACKSIZE PTHREAD_STACK_MIN
-#endif
-#endif
#ifndef THREAD_MAXSTACKSIZE
# define THREAD_MAXSTACKSIZE (256U * 1024)
#endif
-#if THREAD_MAXSTACKSIZE < THREAD_MINSTACKSIZE
-# undef THREAD_MAXSTACKSIZE
-# define THREAD_MAXSTACKSIZE THREAD_MINSTACKSIZE
-#endif
/* need a good integer to store a pointer... */
#ifndef UINTPTR_T
@@ -594,12 +584,25 @@
"start_blocking_thread: pthread_attr_getstacksize() -> %s",
strerror(rc));
} else {
- if (ostacksize < THREAD_MINSTACKSIZE)
- nstacksize = THREAD_MINSTACKSIZE;
- else if (ostacksize > THREAD_MAXSTACKSIZE)
+ nstacksize = ostacksize;
+ /* order is important here: first clamp on upper limit,
+ * and the PTHREAD min stack size is ultimate override!
+ */
+ if (nstacksize > THREAD_MAXSTACKSIZE)
nstacksize = THREAD_MAXSTACKSIZE;
- else
- nstacksize = ostacksize;
+# ifdef PTHREAD_STACK_MAX
+ if (nstacksize > PTHREAD_STACK_MAX)
+ nstacksize = PTHREAD_STACK_MAX;
+# endif
+
+ /* now clamp on lower stack limit. */
+ if (nstacksize < THREAD_MINSTACKSIZE)
+ nstacksize = THREAD_MINSTACKSIZE;
+# ifdef PTHREAD_STACK_MIN
+ if (nstacksize < PTHREAD_STACK_MIN)
+ nstacksize = PTHREAD_STACK_MIN;
+# endif
+
if (nstacksize != ostacksize)
rc = pthread_attr_setstacksize(&thr_attr, nstacksize);
if (0 != rc)