changeset 647:b3563ef89203

thread: convert xthr_create into a non-inline function This will allow us to do more sanity checking without blowing up the size of the call site. Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Tue, 01 Jan 2019 10:46:57 -0500
parents f2356832ac94
children fb8a377e80a2
files CMakeLists.txt include/jeffpc/thread.h mapfile-vers thread.c
diffstat 4 files changed, 40 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Tue Jan 01 11:11:31 2019 -0500
+++ b/CMakeLists.txt	Tue Jan 01 10:46:57 2019 -0500
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+# Copyright (c) 2016-2019 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
@@ -116,6 +116,7 @@
 	str.c
 	synch.c
 	taskq.c
+	thread.c
 	tree.c
 	urldecode.c
 	unicode.c
--- a/include/jeffpc/thread.h	Tue Jan 01 11:11:31 2019 -0500
+++ b/include/jeffpc/thread.h	Tue Jan 01 10:46:57 2019 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2016-2019 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
@@ -25,13 +25,8 @@
 
 #include <pthread.h>
 
-static inline int xthr_create(pthread_t *restrict thread, void *(*start)(void*),
-			      void *restrict arg)
-{
-	pthread_t tmp;
-
-	return -pthread_create(thread ? thread : &tmp, NULL, start, arg);
-}
+extern int xthr_create(pthread_t *restrict thread, void *(*start)(void*),
+		       void *restrict arg);
 
 static inline int xthr_join(pthread_t thread, void **status)
 {
--- a/mapfile-vers	Tue Jan 01 11:11:31 2019 -0500
+++ b/mapfile-vers	Tue Jan 01 10:46:57 2019 -0500
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2016-2018 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+# Copyright (c) 2016-2019 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
@@ -232,6 +232,9 @@
 		taskq_dispatch;
 		taskq_wait;
 
+		# thread
+		xthr_create;
+
 		# tree
 		tree_destroy_nodes;
 		tree_find;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/thread.c	Tue Jan 01 10:46:57 2019 -0500
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016-2019 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
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <jeffpc/thread.h>
+
+int xthr_create(pthread_t *restrict thread, void *(*start)(void*),
+		void *restrict arg)
+{
+	pthread_t tmp;
+
+	return -pthread_create(thread ? thread : &tmp, NULL, start, arg);
+}