Commit 3da8ef855d7d7b3da96a9f1cba55df276e112f11

Stefan Sperling 2021-09-21T11:05:06

tog: use sched_yield(2) instead of pthread_yield(3) for portability pthread_yield(3) is an optional POSIX 2001 extension while sched_yield(2) is part of POSIX 2008. On OpenBSD they are actually equivalent, albeit not documented as such. Using sched_yield(2) helps the -portable version. Patch by Quentin Rameau

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/tog/tog.c b/tog/tog.c
index 52159fc..cbf77a9 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -38,6 +38,7 @@
 #include <pthread.h>
 #include <libgen.h>
 #include <regex.h>
+#include <sched.h>
 
 #include "got_version.h"
 #include "got_error.h"
@@ -841,7 +842,7 @@ view_input(struct tog_view **new, int *done, struct tog_view *view,
 		if (errcode)
 			return got_error_set_errno(errcode,
 			    "pthread_mutex_unlock");
-		pthread_yield();
+		sched_yield();
 		errcode = pthread_mutex_lock(&tog_mutex);
 		if (errcode)
 			return got_error_set_errno(errcode,