simple-ipc: correct ifdefs when NO_PTHREADS is defined
PATCH 1/1 simple-ipc: correct ifdefs when NO_PTHREADS is defined
From: Jeff Hostetler <[email protected]>
Simple IPC always requires threads (in addition to various platform-specific IPC support). Fix the ifdefs in the Makefile to define SUPPORTS_SIMPLE_IPC when appropriate.
Previously, the Unix version of the code would only verify that Unix domain sockets were available.
This problem was reported here:
https://lore.kernel.org/git/YKN5lXs4AoK%[email protected]/T/#m08be8f1942ea8a2c36cfee0e51cdf06489fdeafc
---
simple-ipc: correct ifdefs when NO_PTHREADS is defined
Simple IPC always requires threads (in addition to various platform-specific IPC support). Fix the ifdefs in the Makefile to define SUPPORTS_SIMPLE_IPC when appropriate.
Previously, the Unix version of the code would only verify that Unix domain sockets were available.
This problem was reported here:
https://lore.kernel.org/git/YKN5lXs4AoK%[email protected]/T/#m08be8f1942ea8a2c36cfee0e51cdf06489fdeafc
King [email protected] Signed-off-by: Jeff Hostetler [email protected]
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-955%2Fjeffhostetler%2Ffixup-simple-ipc-no-pthreads-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-955/jeffhostetler/fixup-simple-ipc-no-pthreads-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/955
Makefile | 14 ++++++++++++-- compat/simple-ipc/ipc-unix-socket.c | 8 ++++++++ compat/simple-ipc/ipc-win32.c | 4 ++++ simple-ipc.h | 4 ---- 4 files changed, 24 insertions(+), 6 deletions(-)
Makefile +12 -2
@@ -1687,13 +1687,23 @@ ifdef NO_UNIX_SOCKETS else LIB_OBJS += unix-socket.o LIB_OBJS += unix-stream-server.o - LIB_OBJS += compat/simple-ipc/ipc-shared.o - LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o endif +# Simple-ipc requires threads and platform-specific IPC support. +# (We group all Unix variants in the top-level else because Windows +# also defines NO_UNIX_SOCKETS.) ifdef USE_WIN32_IPC + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC LIB_OBJS += compat/simple-ipc/ipc-shared.o LIB_OBJS += compat/simple-ipc/ipc-win32.o +else +ifndef NO_PTHREADS +ifndef NO_UNIX_SOCKETS + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC + LIB_OBJS += compat/simple-ipc/ipc-shared.o + LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o +endif +endif endif ifdef NO_ICONV
compat/simple-ipc/ipc-unix-socket.c +8 -0
@@ -6,10 +6,16 @@#include "unix-socket.h" #include "unix-stream-server.h" +#ifdef SUPPORTS_SIMPLE_IPC +#ifdef NO_UNIX_SOCKETS #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets#endif +#ifdef NO_PTHREADS +#error compat/simple-ipc/ipc-unix-socket.c requires pthreads +#endif +enum ipc_active_state ipc_get_active_state (const char *path) {enum ipc_active_state state =IPC_STATE__OTHER_ERROR ;
@@ -997,3 +1003,5 @@ void ipc_server_free(struct ipc_server_data *server_data)free (server_data->fifo_fds); free(server_data); } + +#endif /* SUPPORTS_SIMPLE_IPC */
compat/simple-ipc/ipc-win32.c +4 -0
@@ -4,6 +4,8 @@#include "pkt-line.h" #include "thread-utils.h" +#ifdef SUPPORTS_SIMPLE_IPC +#ifndef GIT_WINDOWS_NATIVE #error This file can only be compiled on Windows#endif
@@ -749,3 +751,5 @@ void ipc_server_free(struct ipc_server_data *server_data) free(server_data); } + +#endif /* SUPPORTS_SIMPLE_IPC */
simple-ipc.h +0 -4
@@ -5,10 +5,6 @@* See Documentation/technical/api-simple-ipc.txt */ -#if defined(GIT_WINDOWS_NATIVE ) || !defined(NO_UNIX_SOCKETS ) -#define SUPPORTS_SIMPLE_IPC -#endif -#ifdef SUPPORTS_SIMPLE_IPC #include "pkt-line.h"
base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e
Signature · 1 line
gitgitgadget
Quoted 5 lines · Jeff Hostetler via GitGitGadget
Makefile +4
-0+# Simple-ipc requires threads and platform-specific IPC support. +# (We group all Unix variants in the top-level else because Windows +# also defines NO_UNIX_SOCKETS.) ifdef USE_WIN32_IPC + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC
Makefile ifdef NO_UNIX_SOCKETS · line 1706
Quoted 10 lines
Makefile +8
-0LIB_OBJS += compat/simple-ipc/ipc-shared.o LIB_OBJS += compat/simple-ipc/ipc-win32.o +else +ifndef NO_PTHREADS +ifndef NO_UNIX_SOCKETS + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC + LIB_OBJS += compat/simple-ipc/ipc-shared.o + LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o +endif +endif
OK, so "!defined(NO_PTHREADS) && !defined(NO_UNIX_SOCKETS)" is the requirement for SIMPLE_IPC unless you are on Windows.
Quoted 8 lines
compat/simple-ipc/ipc-unix-socket.c +0
-0@@ -6,10 +6,16 @@#include "unix-socket.h" #include "unix-stream-server.h"
compat/simple-ipc/ipc-unix-socket.c line 18
Quoted 10 lines
compat/simple-ipc/ipc-unix-socket.c +6
-0+#ifdef SUPPORTS_SIMPLE_IPC +#ifdef NO_UNIX_SOCKETS #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets#endif +#ifdef NO_PTHREADS +#error compat/simple-ipc/ipc-unix-socket.c requires pthreads +#endif +
Do we want to duplicate the requirement here and risk them drifting apart?
compat/simple-ipc/ipc-unix-socket.c void ipc_server_free(struct ipc_server_data *server_data) · line 1007
Quoted 6 lines
compat/simple-ipc/ipc-unix-socket.c +2
-0@@ -997,3 +1003,5 @@ void ipc_server_free(struct ipc_server_data *server_data)free (server_data->fifo_fds); free(server_data); } + +#endif /* SUPPORTS_SIMPLE_IPC */
If anything, I do not think we want a huge #ifdef/#endif around the whole file. Feeding this source to your compiler when these three C proprocessor macros do not agree with its use is an error, so perhaps lose all of these #ifdef/#endif around the three macros and refer human readers to the top-level Makefile with a comment, e.g.
/*
* Non Windows platforms need !NO_UNIX_SOCKETS and !NO_PTHREADS
* to compile and use this file. See the top-level Makefile. */
if we really wanted to have a way to help builders identify the reason why their build is failing.
Quoted 56 lines · Junio C Hamano
Quoted 5 lines · Jeff Hostetler via GitGitGadget
Makefile +4
-0+# Simple-ipc requires threads and platform-specific IPC support. +# (We group all Unix variants in the top-level else because Windows +# also defines NO_UNIX_SOCKETS.) ifdef USE_WIN32_IPC + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPCMakefile ifdef NO_UNIX_SOCKETS · line 1706
Quoted 10 lines
Makefile +8
-0LIB_OBJS += compat/simple-ipc/ipc-shared.o LIB_OBJS += compat/simple-ipc/ipc-win32.o +else +ifndef NO_PTHREADS +ifndef NO_UNIX_SOCKETS + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC + LIB_OBJS += compat/simple-ipc/ipc-shared.o + LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o +endif +endifOK, so "!defined(NO_PTHREADS) && !defined(NO_UNIX_SOCKETS)" is the requirement for
SIMPLE_IPCunless you are on Windows.Quoted 8 lines
compat/simple-ipc/ipc-unix-socket.c +0
-0@@ -6,10 +6,16 @@#include "unix-socket.h" #include "unix-stream-server.h" compat/simple-ipc/ipc-unix-socket.c line 18
Quoted 10 lines
compat/simple-ipc/ipc-unix-socket.c +6
-0+#ifdef SUPPORTS_SIMPLE_IPC +#ifdef NO_UNIX_SOCKETS #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets#endif +#ifdef NO_PTHREADS +#error compat/simple-ipc/ipc-unix-socket.c requires pthreads +#endif +Do we want to duplicate the requirement here and risk them drifting apart?
compat/simple-ipc/ipc-unix-socket.c void ipc_server_free(struct ipc_server_data *server_data) · line 1007
Quoted 6 lines
compat/simple-ipc/ipc-unix-socket.c +2
-0@@ -997,3 +1003,5 @@ void ipc_server_free(struct ipc_server_data *server_data)free (server_data->fifo_fds); free(server_data); } + +#endif /* SUPPORTS_SIMPLE_IPC */ If anything, I do not think we want a huge #ifdef/#endif around the whole file. Feeding this source to your compiler when these three C proprocessor macros do not agree with its use is an error, so perhaps lose all of these #ifdef/#endif around the three macros and refer human readers to the top-level
Makefilewith a comment, e.g.
Quoted 8 lines
/*
* Non Windows platforms need !NO_UNIX_SOCKETS and !NO_PTHREADS
* to compile and use this file. See the top-levelMakefile. */if we really wanted to have a way to help builders identify the reason why their build is failing.
Would it be better to just have something like the following at the top of the source files and leave the details to the Makefile:
#ifndef SUPPORTS_SIMPLE_IPC
/*
* This source file should only be included when Simple IPC
* is supported. See the top-level Makefile.
*/
#error SUPPORTS_SIMPLE_IPC not defined
#endif
Quoted 14 lines · Jeff Hostetler
Quoted 10 lines
compat/simple-ipc/ipc-unix-socket.c line 18
Quoted 7 lines
#ifdef NO_UNIX_SOCKETS #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets #endif +#ifdef NO_PTHREADScompat/simple-ipc/ipc-unix-socket.c +3
-0+#error compat/simple-ipc/ipc-unix-socket.c requires pthreads +#endif +Do we want to duplicate the requirement here and risk them drifting apart?
...Would it be better to just have something like the following at the top of the source files and leave the details to the
Makefile:
Quoted 7 lines
#ifndef
SUPPORTS_SIMPLE_IPC
/*
* This source file should only be included when Simple IPC
* is supported. See the top-levelMakefile.
*/
#errorSUPPORTS_SIMPLE_IPCnot defined
#endif
Yeah, that is a much better message, with even less duplication, than what I sent.
I do not think #ifndef/#error/#endif adds much value, though. After all, the Makefile does not even tell us to feed this file to the compiler when the C preprocessor macro is not defined, so presumably whoever hits the #error knows s/he is doing something not supported, and the point of the new message is to help those who we failed by leaving the rest of the source file unbuildable even when we defined the C preprocessor macro in the Makefile (like the mistaken dependency on pthreads that we missed).
Thanks.
PATCH v2 1/1 simple-ipc: correct ifdefs when NO_PTHREADS is defined
In reply to Jeff Hostetler via GitGitGadgetFrom: Jeff Hostetler <[email protected]>
Simple IPC always requires threads (in addition to various platform-specific IPC support). Fix the ifdefs in the Makefile to define SUPPORTS_SIMPLE_IPC when appropriate.
Previously, the Unix version of the code would only verify that Unix domain sockets were available.
This problem was reported here:
https://lore.kernel.org/git/YKN5lXs4AoK%[email protected]/T/#m08be8f1942ea8a2c36cfee0e51cdf06489fdeafc
---
simple-ipc: correct ifdefs when NO_PTHREADS is defined
Here is V2 of this fixup. I've removed the whole file ifdefs and replaced them with a simple #ifndef/#error/#endif as a warning.
Jeff
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-955%2Fjeffhostetler%2Ffixup-simple-ipc-no-pthreads-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-955/jeffhostetler/fixup-simple-ipc-no-pthreads-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/955
Range-diff vs v1:
1: 4adcf35ea6e4 ! 1: 119412f52ff5 simple-ipc: correct ifdefs when NO_PTHREADS is defined
@@ Makefile: ifdef NO_UNIX_SOCKETS
- LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o
endif
-+# Simple-ipc requires threads and platform-specific IPC support. -+# (We group all Unix variants in the top-level else because Windows -+# also defines NO_UNIX_SOCKETS.)
++# Simple IPC requires threads and platform-specific IPC support. ++# Only platforms that have both should include these source files ++# in the build.
++#
++# On Windows-based systems, Simple IPC requires threads and Windows ++# Named Pipes. These are always available, so Simple IPC support ++# is optional.
++#
++# On Unix-based systems, Simple IPC requires pthreads and Unix ++# domain sockets. So support is only enabled when both are present.
++#
ifdef USE_WIN32_IPC
+ BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC
LIB_OBJS += compat/simple-ipc/ipc-shared.o
@@ Makefile: ifdef NO_UNIX_SOCKETS
ifdef NO_ICONV
+ ## compat/simple-ipc/ipc-shared.c ##
+@@
+ #include "pkt-line.h"
+ #include "thread-utils.h"
+
+-#ifdef SUPPORTS_SIMPLE_IPC
++#ifndef SUPPORTS_SIMPLE_IPC
++/*
++ * This source file should only be compiled when Simple IPC is supported.
++ * See the top-level Makefile.
++ */
++#error SUPPORTS_SIMPLE_IPC not defined
++#endif
+
+ int ipc_server_run(const char *path, const struct ipc_server_opts *opts,
+ ipc_server_application_cb *application_cb,
+@@ compat/simple-ipc/ipc-shared.c: int ipc_server_run(const char *path, const struct ipc_server_opts *opts, +
+ return ret;
+ }
+-
+-#endif /* SUPPORTS_SIMPLE_IPC */
+
## compat/simple-ipc/ipc-unix-socket.c ##
@@
#include "unix-socket.h"
#include "unix-stream-server.h"
-+#ifdef SUPPORTS_SIMPLE_IPC
-+
- #ifdef NO_UNIX_SOCKETS
- #error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets +-#ifdef NO_UNIX_SOCKETS
+-#error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets ++#ifndef SUPPORTS_SIMPLE_IPC
++/*
++ * This source file should only be compiled when Simple IPC is supported. ++ * See the top-level Makefile.
++ */
++#error SUPPORTS_SIMPLE_IPC not defined
#endif
-+#ifdef NO_PTHREADS
-+#error compat/simple-ipc/ipc-unix-socket.c requires pthreads
-+#endif
-+
enum ipc_active_state ipc_get_active_state(const char *path)
- {
- enum ipc_active_state state = IPC_STATE__OTHER_ERROR;
-@@ compat/simple-ipc/ipc-unix-socket.c: void ipc_server_free(struct ipc_server_data *server_data)
- free(server_data->fifo_fds);
- free(server_data);
- }
-+
-+#endif /* SUPPORTS_SIMPLE_IPC */
## compat/simple-ipc/ipc-win32.c ##
@@
#include "pkt-line.h"
#include "thread-utils.h"
-+#ifdef SUPPORTS_SIMPLE_IPC
-+
- #ifndef GIT_WINDOWS_NATIVE
- #error This file can only be compiled on Windows
+-#ifndef GIT_WINDOWS_NATIVE
+-#error This file can only be compiled on Windows
++#ifndef SUPPORTS_SIMPLE_IPC
++/*
++ * This source file should only be compiled when Simple IPC is supported. ++ * See the top-level Makefile.
++ */
++#error SUPPORTS_SIMPLE_IPC not defined
#endif
-@@ compat/simple-ipc/ipc-win32.c: void ipc_server_free(struct ipc_server_data *server_data)
- free(server_data);
- }
-+
-+#endif /* SUPPORTS_SIMPLE_IPC */
+ static int initialize_pipe_name(const char *path, wchar_t *wpath, size_t alloc)
## simple-ipc.h ##
@@
Makefile | 22 ++++++++++++++++++++-- compat/simple-ipc/ipc-shared.c | 10 +++++++--- compat/simple-ipc/ipc-unix-socket.c | 8 ++++++-- compat/simple-ipc/ipc-win32.c | 8 ++++++-- simple-ipc.h | 4 ---- 5 files changed, 39 insertions(+), 13 deletions(-)
Makefile +20 -2
@@ -1687,13 +1687,31 @@ ifdef NO_UNIX_SOCKETS else LIB_OBJS += unix-socket.o LIB_OBJS += unix-stream-server.o - LIB_OBJS += compat/simple-ipc/ipc-shared.o - LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o endif +# Simple IPC requires threads and platform-specific IPC support. +# Only platforms that have both should include these source files +# in the build. +# +# On Windows-based systems, Simple IPC requires threads and Windows +# Named Pipes. These are always available, so Simple IPC support +# is optional. +# +# On Unix-based systems, Simple IPC requires pthreads and Unix +# domain sockets. So support is only enabled when both are present. +# ifdef USE_WIN32_IPC + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC LIB_OBJS += compat/simple-ipc/ipc-shared.o LIB_OBJS += compat/simple-ipc/ipc-win32.o +else +ifndef NO_PTHREADS +ifndef NO_UNIX_SOCKETS + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC + LIB_OBJS += compat/simple-ipc/ipc-shared.o + LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o +endif +endif endif ifdef NO_ICONV
compat/simple-ipc/ipc-shared.c +7 -3
@@ -4,7 +4,13 @@#include "pkt-line.h" #include "thread-utils.h" -#ifdef SUPPORTS_SIMPLE_IPC +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined +#endif int ipc_server_run(const char *path, const struct ipc_server_opts *opts, ipc_server_application_cb *application_cb,
@@ -24,5 +30,3 @@ int ipc_server_run(const char *path, const struct ipc_server_opts *opts,return ret; } - -#endif /* SUPPORTS_SIMPLE_IPC */
compat/simple-ipc/ipc-unix-socket.c +6 -2
@@ -6,8 +6,12 @@#include "unix-socket.h" #include "unix-stream-server.h" -#ifdef NO_UNIX_SOCKETS -#error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined#endif enum ipc_active_state ipc_get_active_state (const char *path)
compat/simple-ipc/ipc-win32.c +6 -2
@@ -4,8 +4,12 @@#include "pkt-line.h" #include "thread-utils.h" -#ifndef GIT_WINDOWS_NATIVE -#error This file can only be compiled on Windows +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined#endif static int initialize_pipe_name (const char *path,wchar_t *wpath,size_t alloc)
simple-ipc.h +0 -4
@@ -5,10 +5,6 @@* See Documentation/technical/api-simple-ipc.txt */ -#if defined(GIT_WINDOWS_NATIVE ) || !defined(NO_UNIX_SOCKETS ) -#define SUPPORTS_SIMPLE_IPC -#endif -#ifdef SUPPORTS_SIMPLE_IPC #include "pkt-line.h"
base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e
Signature · 1 line
gitgitgadget
Quoted 6 lines · Jeff Hostetler via GitGitGadget
From: Jeff Hostetler <[email protected]>
Simple IPC always requires threads (in addition to various platform-specific IPC support). Fix the ifdefs in the
Makefileto defineSUPPORTS_SIMPLE_IPCwhen appropriate.
I got in a hurry this morning and forgot to update the CMake script. I'll look at that now.
Jeff
PATCH v3 1/1 simple-ipc: correct ifdefs when NO_PTHREADS is defined
In reply to Jeff Hostetler via GitGitGadgetFrom: Jeff Hostetler <[email protected]>
Simple IPC always requires threads (in addition to various platform-specific IPC support). Fix the ifdefs in the Makefile to define SUPPORTS_SIMPLE_IPC when appropriate.
Previously, the Unix version of the code would only verify that Unix domain sockets were available.
This problem was reported here:
https://lore.kernel.org/git/YKN5lXs4AoK%[email protected]/T/#m08be8f1942ea8a2c36cfee0e51cdf06489fdeafc
---
simple-ipc: correct ifdefs when NO_PTHREADS is defined
Here is V3 of this fixup. I've added fixups for the CMake builds.
Jeff
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-955%2Fjeffhostetler%2Ffixup-simple-ipc-no-pthreads-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-955/jeffhostetler/fixup-simple-ipc-no-pthreads-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/955
Range-diff vs v2:
1: 119412f52ff5 ! 1: d4f4170414e3 simple-ipc: correct ifdefs when NO_PTHREADS is defined
@@ compat/simple-ipc/ipc-win32.c
static int initialize_pipe_name(const char *path, wchar_t *wpath, size_t alloc)
+ ## contrib/buildsystems/CMakeLists.txt ##
+@@ contrib/buildsystems/CMakeLists.txt: endif()
+
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-win32.c)
++ add_compile_definitions(SUPPORTS_SIMPLE_IPC)
++ set(SUPPORTS_SIMPLE_IPC 1)
+ else()
+- list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c)
++ # Simple IPC requires both Unix sockets and pthreads on Unix-based systems.
++ if(NOT NO_UNIX_SOCKETS AND NOT NO_PTHREADS)
++ list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c)
++ add_compile_definitions(SUPPORTS_SIMPLE_IPC)
++ set(SUPPORTS_SIMPLE_IPC 1)
++ endif()
+ endif()
+
+ set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
+@@ contrib/buildsystems/CMakeLists.txt: file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
+ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
+ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
+ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
++file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC}'\n")
+ if(WIN32)
+ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
+ endif()
+
## simple-ipc.h ##
@@
* See Documentation/technical/api-simple-ipc.txt
Makefile | 22 ++++++++++++++++++++-- compat/simple-ipc/ipc-shared.c | 10 +++++++--- compat/simple-ipc/ipc-unix-socket.c | 8 ++++++-- compat/simple-ipc/ipc-win32.c | 8 ++++++-- contrib/buildsystems/CMakeLists.txt | 10 +++++++++- simple-ipc.h | 4 ---- 6 files changed, 48 insertions(+), 14 deletions(-)
Makefile +20 -2
@@ -1687,13 +1687,31 @@ ifdef NO_UNIX_SOCKETS else LIB_OBJS += unix-socket.o LIB_OBJS += unix-stream-server.o - LIB_OBJS += compat/simple-ipc/ipc-shared.o - LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o endif +# Simple IPC requires threads and platform-specific IPC support. +# Only platforms that have both should include these source files +# in the build. +# +# On Windows-based systems, Simple IPC requires threads and Windows +# Named Pipes. These are always available, so Simple IPC support +# is optional. +# +# On Unix-based systems, Simple IPC requires pthreads and Unix +# domain sockets. So support is only enabled when both are present. +# ifdef USE_WIN32_IPC + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC LIB_OBJS += compat/simple-ipc/ipc-shared.o LIB_OBJS += compat/simple-ipc/ipc-win32.o +else +ifndef NO_PTHREADS +ifndef NO_UNIX_SOCKETS + BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC + LIB_OBJS += compat/simple-ipc/ipc-shared.o + LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o +endif +endif endif ifdef NO_ICONV
compat/simple-ipc/ipc-shared.c +7 -3
@@ -4,7 +4,13 @@#include "pkt-line.h" #include "thread-utils.h" -#ifdef SUPPORTS_SIMPLE_IPC +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined +#endif int ipc_server_run(const char *path, const struct ipc_server_opts *opts, ipc_server_application_cb *application_cb,
@@ -24,5 +30,3 @@ int ipc_server_run(const char *path, const struct ipc_server_opts *opts,return ret; } - -#endif /* SUPPORTS_SIMPLE_IPC */
compat/simple-ipc/ipc-unix-socket.c +6 -2
@@ -6,8 +6,12 @@#include "unix-socket.h" #include "unix-stream-server.h" -#ifdef NO_UNIX_SOCKETS -#error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined#endif enum ipc_active_state ipc_get_active_state (const char *path)
compat/simple-ipc/ipc-win32.c +6 -2
@@ -4,8 +4,12 @@#include "pkt-line.h" #include "thread-utils.h" -#ifndef GIT_WINDOWS_NATIVE -#error This file can only be compiled on Windows +#ifndef SUPPORTS_SIMPLE_IPC +/* +* This source file should only be compiled when Simple IPC is supported. +* See the top-level Makefile. +*/ +#error SUPPORTS_SIMPLE_IPC not defined#endif static int initialize_pipe_name (const char *path,wchar_t *wpath,size_t alloc)
contrib/buildsystems/CMakeLists.txt +9 -1
@@ -252,8 +252,15 @@ endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-win32.c) + add_compile_definitions(SUPPORTS_SIMPLE_IPC) + set(SUPPORTS_SIMPLE_IPC 1) else() - list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c) + # Simple IPC requires both Unix sockets and pthreads on Unix-based systems. + if(NOT NO_UNIX_SOCKETS AND NOT NO_PTHREADS) + list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c) + add_compile_definitions(SUPPORTS_SIMPLE_IPC) + set(SUPPORTS_SIMPLE_IPC 1) + endif() endif() set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
@@ -974,6 +981,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n") file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n") file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n") file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n") +file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC}'\n") if(WIN32) file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n") endif()
simple-ipc.h +0 -4
@@ -5,10 +5,6 @@* See Documentation/technical/api-simple-ipc.txt */ -#if defined(GIT_WINDOWS_NATIVE ) || !defined(NO_UNIX_SOCKETS ) -#define SUPPORTS_SIMPLE_IPC -#endif -#ifdef SUPPORTS_SIMPLE_IPC #include "pkt-line.h"
base-commit: bf949ade81106fbda068c1fdb2c6fd1cb1babe7e
Signature · 1 line
gitgitgadget
Quoted 17 lines · Jeff Hostetler via GitGitGadget
Makefile | 22 ++++++++++++++++++++-- compat/simple-ipc/ipc-shared.c | 10 +++++++--- compat/simple-ipc/ipc-unix-socket.c | 8 ++++++-- compat/simple-ipc/ipc-win32.c | 8 ++++++-- contrib/buildsystems/CMakeLists.txt | 10 +++++++++- simple-ipc.h | 4 ---- 6 files changed, 48 insertions(+), 14 deletions(-)Makefile +0
-1@@ -1687,13 +1687,31 @@ ifdef NO_UNIX_SOCKETS else LIB_OBJS += unix-socket.o LIB_OBJS += unix-stream-server.o - LIB_OBJS += compat/simple-ipc/ipc-shared.o
Makefile ifdef NO_UNIX_SOCKETS · line 1698
Quoted 10 lines
Makefile +7
-1- LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o endif +# Simple IPC requires threads and platform-specific IPC support. +# Only platforms that have both should include these source files +# in the build. +# +# On Windows-based systems, Simple IPC requires threads and Windows +# Named Pipes. These are always available, so Simple IPC support +# is optional.
The last part for windows feels funny in that even if they were not always available, the builder can still choose to compile Simple IPC support out, hence it is optional (this is true for both Windows and others). In other words, "prereqs are always satisified" does not lead to "hence it is optional".
But let's leave it as-is. We could rewrite it to "..., so Simple IPC is always enabled", though.
Makefile ifdef NO_UNIX_SOCKETS · line 1701
Quoted 3 lines
Makefile +3
-0+# +# On Unix-based systems, Simple IPC requires pthreads and Unix +# domain sockets. So support is only enabled when both are present.
Other than that, looks good to me.
Will queue.