Skip to contentSkip to conversation

More latest glibc/gcc build fixes

PATCH New Jan Kiszka 1 participant 4 messages Oct 16, 2021

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover More latest glibc/gcc build fixes

Found while test-building against ALT linux.

Jan

CC Jan Kiszka <[email protected]>

Jan Kiszka (3):
testsuite/latency: Use corresponding pclose for popen lib/boilerplate: Convert pthread_mutexattr_setrobust_np stub into
inline function
lib: Switch to pthread_mutexattr_setrobust

 configure.ac                |  1 +
 include/boilerplate/libc.h  | 14 +++++++++++---
 lib/alchemy/mutex.c         |  4 ++--
 lib/vxworks/semLib.c        |  4 ++--
 testsuite/latency/latency.c |  2 +-
 5 files changed, 17 insertions(+), 8 deletions(-)

--
2.31.1

author
#1 lore raw

PATCH 1/3 testsuite/latency: Use corresponding pclose for popen

From: Jan Kiszka <[email protected]>

Was found by latest gcc-11 and -Werror=mismatched-dealloc.

---
 testsuite/latency/latency.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testsuite/latency/latency.c +1 -1
index a0e6f48260..6cd3a28b44 100644
@@ -412,7 +412,7 @@ static void dump_histo_gnuplot(int32_t *histogram, time_t duration)
 		fputs(buf, ofp);
 	}
 
-	fclose(ifp);
+	pclose(ifp);
 
 dump_data:
 	for (n = 0; n < histogram_size && histogram[n] == 0; n++)

--
2.31.1

author
#2 lore raw

PATCH 2/3 lib/boilerplate: Convert pthread_mutexattr_setrobust_np stub into inline function

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Recent glibc (at leasst 2.34) triggers

CC libposix_fork_a-posix-fork.o
In file included from posix-fork.c:11:
../../../include/boilerplate/libc.h:248:10: error: expected identifier or '(' before '{' token
248 | ({ ENOSYS; })
| ^

So switch to a static inline, like for all the other stubs.

---
 include/boilerplate/libc.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/boilerplate/libc.h +6 -2
index 75e2d1da43..41b2eb91bb 100644
@@ -244,8 +244,12 @@ __weak int shm_unlink(const char *name)
 #endif	/* !HAVE_SHM_UNLINK */
 
 #ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
-#define pthread_mutexattr_setrobust_np(__attr, __robust)	\
-	({ ENOSYS; })
+static inline
+int pthread_mutexattr_setrobust_np(const pthread_mutexattr_t *attr,
+				   int *robustness)
+{
+	return ENOSYS;
+}
 #endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP */
 
 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY)

--
2.31.1

author
#3 lore raw

PATCH 3/3 lib: Switch to pthread_mutexattr_setrobust

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

With recent glibc (at least 2.34), autoconf fails to detect pthread_mutexattr_setrobust_np. But that is long deprecated anyway. So switch to pthread_mutexattr_setrobust and only fall back to _np when needed.

---
 configure.ac               |  1 +
 include/boilerplate/libc.h | 10 +++++++---
 lib/alchemy/mutex.c        |  4 ++--
 lib/vxworks/semLib.c       |  4 ++--
 4 files changed, 12 insertions(+), 7 deletions(-)
configure.ac +1 -0
index 480a94768d..d39443a35e 100644
@@ -542,6 +542,7 @@ AC_CHECK_FUNCS([pthread_mutexattr_setprotocol	\
 		pthread_mutexattr_getprotocol	\
 		pthread_mutexattr_getprioceiling \
 		pthread_mutexattr_setprioceiling \
+		pthread_mutexattr_setrobust	\
 		pthread_mutexattr_setrobust_np	\
 		pthread_mutex_getprioceiling	\
 		pthread_mutex_setprioceiling	\
include/boilerplate/libc.h +7 -3
index 41b2eb91bb..797e377a2e 100644
@@ -243,14 +243,18 @@ __weak int shm_unlink(const char *name)
 }
 #endif	/* !HAVE_SHM_UNLINK */
 
-#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
+#ifndef HAVE_PTHREAD_MUTEXATTR_SETROBUST
+#ifdef HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP
+#define pthread_mutexattr_setrobust	pthread_mutexattr_setrobust_np
+#else
 static inline
-int pthread_mutexattr_setrobust_np(const pthread_mutexattr_t *attr,
-				   int *robustness)
+int pthread_mutexattr_setrobust(const pthread_mutexattr_t *attr,
+				int *robustness)
 {
 	return ENOSYS;
 }
 #endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST_NP */
+#endif /* !HAVE_PTHREAD_MUTEXATTR_SETROBUST */
 
 #if !defined(HAVE_PTHREAD_SETNAME_NP) && defined(CONFIG_XENO_MERCURY)
 static inline
lib/alchemy/mutex.c +2 -2
index 09eb1364ef..f893385864 100644
@@ -131,8 +131,8 @@ int rt_mutex_create(RT_MUTEX *mutex, const char *name)
 	pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
 	pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
-	/* pthread_mutexattr_setrobust_np() might not be implemented. */
-	pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
+	/* pthread_mutexattr_setrobust() might not be implemented. */
+	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
 	ret = __RT(pthread_mutex_init(&mcb->lock, &mattr));
 	if (ret) {
 		xnfree(mcb);
lib/vxworks/semLib.c +2 -2
index acce160ee1..180ed20005 100644
@@ -411,8 +411,8 @@ SEM_ID semMCreate(int options)
 	 */
 	pthread_mutexattr_init(&mattr);
 	pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
-	/* pthread_mutexattr_setrobust_np() might not be implemented. */
-	pthread_mutexattr_setrobust_np(&mattr, PTHREAD_MUTEX_ROBUST_NP);
+	/* pthread_mutexattr_setrobust() might not be implemented. */
+	pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST_NP);
 	if (options & SEM_INVERSION_SAFE)
 		pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
 	pthread_mutexattr_setpshared(&mattr, mutex_scope_attribute);

--
2.31.1