From 8e84b21452e74acee43fe0042979928a2b56cf50 Mon Sep 17 00:00:00 2001 From: Robert Ricci Date: Sat, 2 Jun 2018 11:26:02 -0600 Subject: [PATCH 1/4] Re-order includes for "_POSIX_C_SOURCE" One FreeBSD, the build was getting errors about _POSIX_C_SOURCE being redefined. The fix for this is to make sure that Python.h gets included before any system libraries. --- kitty/child-monitor.c | 2 +- kitty/data-types.h | 5 ++--- kitty/glfw-wrapper.c | 2 +- kitty/keys.c | 2 +- kitty/shaders.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index ef895ecd8..a7f78f560 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -5,8 +5,8 @@ * Distributed under terms of the GPL3 license. */ -#include "threading.h" #include "state.h" +#include "threading.h" #include "screen.h" #include "fonts.h" #include diff --git a/kitty/data-types.h b/kitty/data-types.h index 236bcef24..47a915bcf 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -7,13 +7,12 @@ #pragma once - +#define PY_SSIZE_T_CLEAN +#include #include #include #include #include -#define PY_SSIZE_T_CLEAN -#include // Required minimum OpenGL version #define OPENGL_REQUIRED_VERSION_MAJOR 3 #define OPENGL_REQUIRED_VERSION_MINOR 3 diff --git a/kitty/glfw-wrapper.c b/kitty/glfw-wrapper.c index 1b142ca5c..677f49948 100644 --- a/kitty/glfw-wrapper.c +++ b/kitty/glfw-wrapper.c @@ -1,7 +1,7 @@ -#include #include "data-types.h" #include "glfw-wrapper.h" +#include static void* handle = NULL; diff --git a/kitty/keys.c b/kitty/keys.c index 2930d1364..2eb5e8f75 100644 --- a/kitty/keys.c +++ b/kitty/keys.c @@ -5,8 +5,8 @@ * Distributed under terms of the GPL3 license. */ -#include "keys.h" #include "state.h" +#include "keys.h" #include "screen.h" #include "glfw-wrapper.h" #include "control-codes.h" diff --git a/kitty/shaders.c b/kitty/shaders.c index 4c3844c91..874c70717 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -5,8 +5,8 @@ * Distributed under terms of the GPL3 license. */ -#include "gl.h" #include "fonts.h" +#include "gl.h" enum { CELL_PROGRAM, CELL_BG_PROGRAM, CELL_SPECIAL_PROGRAM, CELL_FG_PROGRAM, CURSOR_PROGRAM, BORDERS_PROGRAM, GRAPHICS_PROGRAM, GRAPHICS_PREMULT_PROGRAM, BLIT_PROGRAM, NUM_PROGRAMS }; enum { SPRITE_MAP_UNIT, GRAPHICS_UNIT, BLIT_UNIT }; From e7ad2637d80bebd49172bfa8641a7b33a2227135 Mon Sep 17 00:00:00 2001 From: Robert Ricci Date: Sat, 2 Jun 2018 11:46:10 -0600 Subject: [PATCH 2/4] Don't 'hardcode' linux joystick for x11 module The correct joystick module appears to be inserted in the list in glfw.py . This fixes the build on FreeBSD 11 --- glfw/source-info.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/glfw/source-info.json b/glfw/source-info.json index 9bb069df8..ee48cae69 100644 --- a/glfw/source-info.json +++ b/glfw/source-info.json @@ -113,8 +113,7 @@ "posix_thread.h", "glx_context.h", "egl_context.h", - "osmesa_context.h", - "linux_joystick.h" + "osmesa_context.h" ], "sources": [ "x11_init.c", @@ -125,8 +124,7 @@ "posix_thread.c", "glx_context.c", "egl_context.c", - "osmesa_context.c", - "linux_joystick.c" + "osmesa_context.c" ] } -} \ No newline at end of file +} From 80da4d1344a668c73c4fac723ac199535eb2e0df Mon Sep 17 00:00:00 2001 From: Robert Ricci Date: Sat, 2 Jun 2018 12:05:49 -0600 Subject: [PATCH 3/4] Handle pthread_setname_np on FreeBSD For some reason, the function has a slightly different name and signature --- kitty/threading.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kitty/threading.h b/kitty/threading.h index 6aa518c37..5ac6d9b57 100644 --- a/kitty/threading.h +++ b/kitty/threading.h @@ -12,17 +12,25 @@ // 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 +#ifdef __FreeBSD__ +void pthread_set_name_np(pthread_t tid, const char *name); +#else // Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc extern int pthread_setname_np(pthread_t, const char *name); #endif +#endif static inline void set_thread_name(const char *name) { int ret = 0; #ifdef __APPLE__ - ret = pthread_setname_np(name); + ret = pthreadset_name_np(name); +#else +#ifdef __FreeBSD__ + pthread_set_name_np(pthread_self(), name); #else ret = pthread_setname_np(pthread_self(), name); +#endif #endif if (ret != 0) perror("Failed to set thread name"); } From dc48e6c432699ce0e970b78c66944d0859dfc2a1 Mon Sep 17 00:00:00 2001 From: Robert Ricci Date: Sat, 2 Jun 2018 12:48:38 -0600 Subject: [PATCH 4/4] Clean up nested ifdefs --- kitty/threading.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/kitty/threading.h b/kitty/threading.h index 5ac6d9b57..085fe9c27 100644 --- a/kitty/threading.h +++ b/kitty/threading.h @@ -8,29 +8,26 @@ #include #include -#ifdef __APPLE__ +#if defined(__APPLE__) // 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 -#ifdef __FreeBSD__ +#elif defined(__FreeBSD__) +// Function has a different name on FreeBSD void pthread_set_name_np(pthread_t tid, const char *name); #else // Need _GNU_SOURCE for pthread_setname_np on linux and that causes other issues on systems with old glibc extern int pthread_setname_np(pthread_t, const char *name); #endif -#endif static inline void set_thread_name(const char *name) { int ret = 0; -#ifdef __APPLE__ +#if defined(__APPLE__) ret = pthreadset_name_np(name); -#else -#ifdef __FreeBSD__ +#elif defined(__FreeBSD__) pthread_set_name_np(pthread_self(), name); #else ret = pthread_setname_np(pthread_self(), name); -#endif #endif if (ret != 0) perror("Failed to set thread name"); }