GNOME Bugzilla – Bug 747692
check build error on osx: pipelines/tcp.c:161:34: error: use of undeclared identifier 'SOCK_CLOEXEC'
Last modified: 2015-04-26 19:16:04 UTC
The fix is to add:
#define SOCK_CLOEXEC 02000000
Created attachment 301686 [details] [review]
tests: use FD_CLOEXEC when SOCK_CLOEXEC is not available
I did not know the problem was already reported so I made another solution based on glib/gio/gsocket.c::g_socket.
Review of attachment 301686 [details] [review]:
@@ +36,3 @@
@@ +124,3 @@
Shouldn't this be #ifndef SOCK_CLOEXEC for symmetry?
@@ +168,3 @@
It seems SOCK_CLOEXEC is not available on G_OS_WIN32.
I simplified a bit https://git.gnome.org/browse/glib/tree/gio/gsocket.c#n454 which also handles the case where SOCK_CLOEXEC is defined in libc header but not available in the kernel: "/* It's possible that libc has SOCK_CLOEXEC but the kernel does not */".
I skipped this as this is a unit test but I can re-add.
Note that I should have put: #if !defined(SOCK_CLOEXEC) && !defined(G_OS_WIN32) instead of just #ifndef G_OS_WIN32 maybe this is your question.
Yes, or some explanation why the #ifdefs are inconsistent :) And what happens if neither of those code blocks is actually used.
My question is: why is SOCK_CLOEXEC needed here at all? Can't it just be removed?
(In reply to Tim-Philipp Müller from comment #5)
> My question is: why is SOCK_CLOEXEC needed here at all? Can't it just be
Force of habit I suppose. I don't think it's necessary.
Great, thanks for confirming. Let's keep it simple then:
Author: Tim-Philipp Müller <email@example.com>
Date: Sun Apr 26 20:13:01 2015 +0100
tests: tcp: remove SOCK_CLOEXEC which causes build problems on OS/X
It's not needed here.