Move pthread includes into separate header
This commit is contained in:
parent
bc21ec7551
commit
6fe4baf1de
@ -5,16 +5,7 @@
|
|||||||
* Distributed under terms of the GPL3 license.
|
* Distributed under terms of the GPL3 license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#include "threading.h"
|
||||||
#include <pthread.h>
|
|
||||||
// I cant figure out how to get pthread.h to include this definition on macOS. MACOSX_DEPLOYMENT_TARGET does not work.
|
|
||||||
extern int pthread_setname_np(const char *name);
|
|
||||||
#else
|
|
||||||
// Need _GNU_SOURCE for pthread_setname_np on linux
|
|
||||||
#define _GNU_SOURCE
|
|
||||||
#include <pthread.h>
|
|
||||||
#undef _GNU_SOURCE
|
|
||||||
#endif
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
@ -78,17 +69,6 @@ static uint8_t drain_buf[1024];
|
|||||||
static int signal_fds[2], wakeup_fds[2];
|
static int signal_fds[2], wakeup_fds[2];
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
|
||||||
set_thread_name(const char *name) {
|
|
||||||
int ret = 0;
|
|
||||||
#ifdef __APPLE__
|
|
||||||
ret = pthread_setname_np(name);
|
|
||||||
#else
|
|
||||||
ret = pthread_setname_np(pthread_self(), name);
|
|
||||||
#endif
|
|
||||||
if (ret != 0) perror("Failed to set thread name");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Main thread functions {{{
|
// Main thread functions {{{
|
||||||
|
|
||||||
|
|||||||
30
kitty/threading.h
Normal file
30
kitty/threading.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
*
|
||||||
|
* Distributed under terms of the GPL3 license.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <pthread.h>
|
||||||
|
// I cant figure out how to get pthread.h to include this definition on macOS. MACOSX_DEPLOYMENT_TARGET does not work.
|
||||||
|
extern int pthread_setname_np(const char *name);
|
||||||
|
#else
|
||||||
|
// Need _GNU_SOURCE for pthread_setname_np on linux
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <pthread.h>
|
||||||
|
#undef _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
set_thread_name(const char *name) {
|
||||||
|
int ret = 0;
|
||||||
|
#ifdef __APPLE__
|
||||||
|
ret = pthread_setname_np(name);
|
||||||
|
#else
|
||||||
|
ret = pthread_setname_np(pthread_self(), name);
|
||||||
|
#endif
|
||||||
|
if (ret != 0) perror("Failed to set thread name");
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user