Skip to content

Commit 6aae0e2

Browse files
committed
Merge branch 'jh/simple-ipc-sans-pthread'
The "simple-ipc" did not compile without pthreads support, but the build procedure was not properly account for it. * jh/simple-ipc-sans-pthread: simple-ipc: correct ifdefs when NO_PTHREADS is defined
2 parents 99fe1c6 + 6aac70a commit 6aae0e2

File tree

6 files changed

+48
-14
lines changed

6 files changed

+48
-14
lines changed

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,13 +1687,31 @@ ifdef NO_UNIX_SOCKETS
16871687
else
16881688
LIB_OBJS += unix-socket.o
16891689
LIB_OBJS += unix-stream-server.o
1690-
LIB_OBJS += compat/simple-ipc/ipc-shared.o
1691-
LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o
16921690
endif
16931691

1692+
# Simple IPC requires threads and platform-specific IPC support.
1693+
# Only platforms that have both should include these source files
1694+
# in the build.
1695+
#
1696+
# On Windows-based systems, Simple IPC requires threads and Windows
1697+
# Named Pipes. These are always available, so Simple IPC support
1698+
# is optional.
1699+
#
1700+
# On Unix-based systems, Simple IPC requires pthreads and Unix
1701+
# domain sockets. So support is only enabled when both are present.
1702+
#
16941703
ifdef USE_WIN32_IPC
1704+
BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC
16951705
LIB_OBJS += compat/simple-ipc/ipc-shared.o
16961706
LIB_OBJS += compat/simple-ipc/ipc-win32.o
1707+
else
1708+
ifndef NO_PTHREADS
1709+
ifndef NO_UNIX_SOCKETS
1710+
BASIC_CFLAGS += -DSUPPORTS_SIMPLE_IPC
1711+
LIB_OBJS += compat/simple-ipc/ipc-shared.o
1712+
LIB_OBJS += compat/simple-ipc/ipc-unix-socket.o
1713+
endif
1714+
endif
16971715
endif
16981716

16991717
ifdef NO_ICONV

compat/simple-ipc/ipc-shared.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
#include "pkt-line.h"
55
#include "thread-utils.h"
66

7-
#ifdef SUPPORTS_SIMPLE_IPC
7+
#ifndef SUPPORTS_SIMPLE_IPC
8+
/*
9+
* This source file should only be compiled when Simple IPC is supported.
10+
* See the top-level Makefile.
11+
*/
12+
#error SUPPORTS_SIMPLE_IPC not defined
13+
#endif
814

915
int ipc_server_run(const char *path, const struct ipc_server_opts *opts,
1016
ipc_server_application_cb *application_cb,
@@ -24,5 +30,3 @@ int ipc_server_run(const char *path, const struct ipc_server_opts *opts,
2430

2531
return ret;
2632
}
27-
28-
#endif /* SUPPORTS_SIMPLE_IPC */

compat/simple-ipc/ipc-unix-socket.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66
#include "unix-socket.h"
77
#include "unix-stream-server.h"
88

9-
#ifdef NO_UNIX_SOCKETS
10-
#error compat/simple-ipc/ipc-unix-socket.c requires Unix sockets
9+
#ifndef SUPPORTS_SIMPLE_IPC
10+
/*
11+
* This source file should only be compiled when Simple IPC is supported.
12+
* See the top-level Makefile.
13+
*/
14+
#error SUPPORTS_SIMPLE_IPC not defined
1115
#endif
1216

1317
enum ipc_active_state ipc_get_active_state(const char *path)

compat/simple-ipc/ipc-win32.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
#include "pkt-line.h"
55
#include "thread-utils.h"
66

7-
#ifndef GIT_WINDOWS_NATIVE
8-
#error This file can only be compiled on Windows
7+
#ifndef SUPPORTS_SIMPLE_IPC
8+
/*
9+
* This source file should only be compiled when Simple IPC is supported.
10+
* See the top-level Makefile.
11+
*/
12+
#error SUPPORTS_SIMPLE_IPC not defined
913
#endif
1014

1115
static int initialize_pipe_name(const char *path, wchar_t *wpath, size_t alloc)

contrib/buildsystems/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,15 @@ endif()
252252

253253
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
254254
list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-win32.c)
255+
add_compile_definitions(SUPPORTS_SIMPLE_IPC)
256+
set(SUPPORTS_SIMPLE_IPC 1)
255257
else()
256-
list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c)
258+
# Simple IPC requires both Unix sockets and pthreads on Unix-based systems.
259+
if(NOT NO_UNIX_SOCKETS AND NOT NO_PTHREADS)
260+
list(APPEND compat_SOURCES compat/simple-ipc/ipc-shared.c compat/simple-ipc/ipc-unix-socket.c)
261+
add_compile_definitions(SUPPORTS_SIMPLE_IPC)
262+
set(SUPPORTS_SIMPLE_IPC 1)
263+
endif()
257264
endif()
258265

259266
set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
@@ -974,6 +981,7 @@ file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "X='${EXE_EXTENSION}'\n")
974981
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_GETTEXT='${NO_GETTEXT}'\n")
975982
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "RUNTIME_PREFIX='${RUNTIME_PREFIX}'\n")
976983
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "NO_PYTHON='${NO_PYTHON}'\n")
984+
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "SUPPORTS_SIMPLE_IPC='${SUPPORTS_SIMPLE_IPC}'\n")
977985
if(WIN32)
978986
file(APPEND ${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
979987
endif()

simple-ipc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
* See Documentation/technical/api-simple-ipc.txt
66
*/
77

8-
#if defined(GIT_WINDOWS_NATIVE) || !defined(NO_UNIX_SOCKETS)
9-
#define SUPPORTS_SIMPLE_IPC
10-
#endif
11-
128
#ifdef SUPPORTS_SIMPLE_IPC
139
#include "pkt-line.h"
1410

0 commit comments

Comments
 (0)