]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util-lib: move is_main_thread() to process-util.[ch]
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Oct 2015 23:02:45 +0000 (00:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 27 Oct 2015 12:25:57 +0000 (13:25 +0100)
src/basic/hashmap.c
src/basic/process-util.c
src/basic/process-util.h
src/basic/util.c
src/basic/util.h

index 20e7e51d9e223deebe7fe9e39a22f37c5abeba06..015cc629b17bf9287c3d35fc1087575f4135b905 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <stdlib.h>
 #include <errno.h>
 #include <pthread.h>
+#include <stdlib.h>
 
-#include "util.h"
 #include "hashmap.h"
-#include "set.h"
 #include "macro.h"
-#include "siphash24.h"
-#include "strv.h"
 #include "mempool.h"
+#include "process-util.h"
 #include "random-util.h"
+#include "set.h"
+#include "siphash24.h"
+#include "strv.h"
+#include "util.h"
 
 #ifdef ENABLE_DEBUG_HASHMAP
 #include "list.h"
index e0061d15b3def9cbc52769fc70ba4d0c662f1ecb..c5d7dc3089ea9f1383c8f78affdba93f5a257dd0 100644 (file)
@@ -585,3 +585,12 @@ bool pid_is_alive(pid_t pid) {
 
         return true;
 }
+
+bool is_main_thread(void) {
+        static thread_local int cached = 0;
+
+        if (_unlikely_(cached == 0))
+                cached = getpid() == gettid() ? 1 : -1;
+
+        return cached > 0;
+}
index 2c0d1af0006c5da205aed3a99b1507d5afc49c19..d17df5d81fcd6d85452fb386cc64b1ba52539a84 100644 (file)
@@ -66,3 +66,5 @@ int getenv_for_pid(pid_t pid, const char *field, char **_value);
 
 bool pid_is_alive(pid_t pid);
 bool pid_is_unwaited(pid_t pid);
+
+bool is_main_thread(void);
index b079e8af169ae8162490ff9fc3adf11132468a32..6fe4f47018f8f3fc2ea7e9646cde2ac5372682f3 100644 (file)
@@ -421,15 +421,6 @@ int glob_extend(char ***strv, const char *path) {
         return k;
 }
 
-bool is_main_thread(void) {
-        static thread_local int cached = 0;
-
-        if (_unlikely_(cached == 0))
-                cached = getpid() == gettid() ? 1 : -1;
-
-        return cached > 0;
-}
-
 int block_get_whole_disk(dev_t d, dev_t *ret) {
         char *p, *s;
         int r;
index e356f59cd5c6a416f06b4fa68fff9a6f3b091849..96be6ecaa855bdc7f35702d4bb454d511ec912ef 100644 (file)
@@ -103,8 +103,6 @@ int socket_from_display(const char *display, char **path);
 int glob_exists(const char *path);
 int glob_extend(char ***strv, const char *path);
 
-bool is_main_thread(void);
-
 int block_get_whole_disk(dev_t d, dev_t *ret);
 
 #define NULSTR_FOREACH(i, l)                                    \