mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
util-lib: move is_main_thread() to process-util.[ch]
This commit is contained in:
parent
430f0182b7
commit
d4510856a0
@ -20,18 +20,19 @@
|
||||
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 "mempool.h"
|
||||
#include "process-util.h"
|
||||
#include "random-util.h"
|
||||
#include "set.h"
|
||||
#include "siphash24.h"
|
||||
#include "strv.h"
|
||||
#include "mempool.h"
|
||||
#include "random-util.h"
|
||||
#include "util.h"
|
||||
|
||||
#ifdef ENABLE_DEBUG_HASHMAP
|
||||
#include "list.h"
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user