changeset 860:3c2e349df2d1

synch: remove barrier support This was added more than half a decade ago and gotten zero use. To make matters worse, macOS doesn't seem to have pthread_barrier_t. So let's just remove barrier support to aid portability and maintainability. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Fri, 13 Jan 2023 11:03:28 -0500
parents c5a5b39f464b
children 111936b70fcc
files include/jeffpc/synch.h mapfile-vers synch.c
diffstat 3 files changed, 2 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/include/jeffpc/synch.h	Fri Jan 13 10:40:17 2023 -0500
+++ b/include/jeffpc/synch.h	Fri Jan 13 11:03:28 2023 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2019 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2011-2019,2023 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -46,8 +46,6 @@
 			const char *condname; /* cond */
 			const char *lockname; /* mutex or rwlock */
 		};
-		/* barrier */
-		const char *barname; /* barrier */
 	};
 	const char *file;
 	int line;
@@ -77,10 +75,6 @@
 	pthread_cond_t cond;
 };
 
-struct barrier {
-	pthread_barrier_t bar;
-};
-
 /* the API */
 #define MXINIT(l, lc)	do { \
 				struct lock_context mx_ctx = { \
@@ -206,32 +200,6 @@
 				}; \
 				condbcast(&cond_ctx, (c)); \
 			} while (0)
-#define BARRIERINIT(b, c) \
-			do { \
-				struct lock_context bar_ctx = { \
-					.barname = #b, \
-					.file = __FILE__, \
-					.line = __LINE__, \
-				}; \
-				barrierinit(&bar_ctx, (b), (c)); \
-			} while (0)
-#define BARRIERDESTROY(b) \
-			do { \
-				struct lock_context bar_ctx = { \
-					.barname = #b, \
-					.file = __FILE__, \
-					.line = __LINE__, \
-				}; \
-				barrierdestroy(&bar_ctx, (b)); \
-			} while (0)
-#define BARRIERWAIT(b)	do { \
-				struct lock_context bar_ctx = { \
-					.barname = #b, \
-					.file = __FILE__, \
-					.line = __LINE__, \
-				}; \
-				barrierwait(&bar_ctx, (b)); \
-			} while (0)
 
 /* assert that this thread is not holding any locks */
 #ifdef JEFFPC_LOCK_TRACKING
@@ -262,9 +230,4 @@
 extern void condsig(const struct lock_context *where, struct cond *c);
 extern void condbcast(const struct lock_context *where, struct cond *c);
 
-extern void barrierinit(const struct lock_context *where, struct barrier *b,
-			unsigned count);
-extern void barrierdestroy(const struct lock_context *where, struct barrier *b);
-extern bool barrierwait(const struct lock_context *where, struct barrier *b);
-
 #endif
--- a/mapfile-vers	Fri Jan 13 10:40:17 2023 -0500
+++ b/mapfile-vers	Fri Jan 13 11:03:28 2023 -0500
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016-2022 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+# Copyright (c) 2016-2023 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to deal
@@ -272,9 +272,6 @@
 		str_vprintf;
 
 		# synch
-		barrierdestroy;
-		barrierinit;
-		barrierwait;
 		condbcast;
 		conddestroy;
 		condinit;
--- a/synch.c	Fri Jan 13 10:40:17 2023 -0500
+++ b/synch.c	Fri Jan 13 11:03:28 2023 -0500
@@ -962,39 +962,6 @@
 		      where->file, where->line, strerror(ret));
 }
 
-void barrierinit(const struct lock_context *where, struct barrier *b,
-		 unsigned count)
-{
-	int ret;
-
-	ret = pthread_barrier_init(&b->bar, NULL, count);
-	if (ret)
-		panic("barrier init failed @ %s:%d: %s",
-		      where->file, where->line, strerror(ret));
-}
-
-void barrierdestroy(const struct lock_context *where, struct barrier *b)
-{
-	int ret;
-
-	ret = pthread_barrier_destroy(&b->bar);
-	if (ret)
-		panic("barrier destroy failed @ %s:%d: %s",
-		      where->file, where->line, strerror(ret));
-}
-
-bool barrierwait(const struct lock_context *where, struct barrier *b)
-{
-	int ret;
-
-	ret = pthread_barrier_wait(&b->bar);
-	if ((ret != 0) && (ret != PTHREAD_BARRIER_SERIAL_THREAD))
-		panic("barrier wait failed @ %s:%d: %s",
-		      where->file, where->line, strerror(ret));
-
-	return (ret == PTHREAD_BARRIER_SERIAL_THREAD);
-}
-
 #undef lockdep_no_locks
 void lockdep_no_locks(void)
 {