From: Junio C Hamano <gitster@pobox.com>
To: "Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Jeff Hostetler <jeffhost@microsoft.com>
Subject: Re: [PATCH] simple-ipc: correct ifdefs when NO_PTHREADS is defined
Date: Wed, 19 May 2021 09:48:27 +0900 [thread overview]
Message-ID: <xmqqk0nv1rc4.fsf@gitster.g> (raw)
In-Reply-To: <pull.955.git.1621352192238.gitgitgadget@gmail.com> (Jeff Hostetler via GitGitGadget's message of "Tue, 18 May 2021 15:36:31 +0000")
"Jeff Hostetler via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +# 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.
> 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?
> @@ -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.
next prev parent reply other threads:[~2021-05-19 0:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 15:36 [PATCH] simple-ipc: correct ifdefs when NO_PTHREADS is defined Jeff Hostetler via GitGitGadget
2021-05-19 0:48 ` Junio C Hamano [this message]
2021-05-19 14:29 ` Jeff Hostetler
2021-05-19 22:03 ` Junio C Hamano
2021-05-20 14:22 ` [PATCH v2] " Jeff Hostetler via GitGitGadget
2021-05-20 15:11 ` Jeff Hostetler
2021-05-20 18:28 ` [PATCH v3] " Jeff Hostetler via GitGitGadget
2021-05-20 23:01 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqk0nv1rc4.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=jeffhost@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).