git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] simple-ipc: correct ifdefs when NO_PTHREADS is defined

From
Junio C Hamano <gitster@pobox.com>
Date
May 19, 2021, 00:48 UTC
Message-ID
<xmqqk0nv1rc4.fsf@gitster.g>
In-Reply-To
<pull.955.git.1621352192238.gitgitgadget@gmail.com>
"Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 15 quoted lines
> +# 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

OK, so "!defined(NO_PTHREADS) && !defined(NO_UNIX_SOCKETS)" is the requirement for SIMPLE_IPC unless you are on Windows.

Show 18 quoted lines
> diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
> index 38689b278df3..c23b17973983 100644
> --- a/compat/simple-ipc/ipc-unix-socket.c
> +++ b/compat/simple-ipc/ipc-unix-socket.c
> @@ -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
> +

Do we want to duplicate the requirement here and risk them drifting apart?

Show 6 quoted lines
> @@ -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.

Previous: Jeff Hostetler via GitGitGadgetNext: Jeff Hostetler
Message 2 of 8 in “simple-ipc: correct ifdefs when NO_PTHREADS is defined”
  1. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 18, 2021
  2. Junio C HamanoMay 19, 2021
  3. Jeff HostetlerMay 19, 2021
  4. Junio C HamanoMay 19, 2021
  5. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 20, 2021
  6. Jeff HostetlerMay 20, 2021
  7. simple-ipc: correct ifdefs when NO_PTHREADS is definedJeff Hostetler via GitGitGadget, May 20, 2021
  8. Junio C HamanoMay 20, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.