From: Juergen Perlinger Date: Sun, 16 Jan 2022 10:35:06 +0000 (+0100) Subject: [Bug 3741] 4.2.8p15 can't build with glibc 2.34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25ff5a14d05723679b747a166f626b6748676481;p=thirdparty%2Fntp.git [Bug 3741] 4.2.8p15 can't build with glibc 2.34 PTHREAD stack sizes can be runtime variant, so make all size adjustments runtime checks (as opposed to the compile time checks they were before) bk: 61e3f4da51hNselhp9D9bXx8xpSapg --- diff --git a/ChangeLog b/ChangeLog index eeceaa9f1..bed65246a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +--- +* [Bug 3741] 4.2.8p15 can't build with glibc 2.34 + --- (4.2.8p15) 2020/06/23 Released by Harlan Stenn diff --git a/libntp/work_thread.c b/libntp/work_thread.c index 03a5647be..a8e3e2766 100644 --- a/libntp/work_thread.c +++ b/libntp/work_thread.c @@ -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_internal( "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)