Support NO_UNIX_SOCKETS

The year is 2011AD. Desktop computers are entirely occupied by
POSIX-conforming operating systems. Well, not entirely...! One small
operating system of indomitable APIs still holds out against the invaders,
their POSIX functions and datatypes... and their Unix sockets.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2011-08-06 15:04:48 +02:00
parent 85da8cb565
commit f04ee9c28e
2 changed files with 20 additions and 0 deletions

View File

@@ -258,6 +258,8 @@ all::
# dependency rules.
#
# Define NATIVE_CRLF if your platform uses CRLF for line endings.
#
# Define NO_UNIX_SOCKETS if your platform does not have them.
GIT-VERSION-FILE: FORCE
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1214,6 +1216,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_INET_NTOP = YesPlease
NO_POSIX_GOODIES = UnfortunatelyYes
NO_D_INO_IN_DIRENT = YesPlease
NO_UNIX_SOCKETS = UnfortunatelyNot
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/win32
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
COMPAT_OBJS += compat/mingw.o compat/winansi.o \
@@ -1624,6 +1627,9 @@ endif
ifdef GIT_TEST_CMP_USE_COPIED_CONTEXT
export GIT_TEST_CMP_USE_COPIED_CONTEXT
endif
ifdef NO_UNIX_SOCKETS
COMPAT_CFLAGS += -DNO_UNIX_SOCKETS=1
endif
ifeq ($(TCLTK_PATH),)
NO_TCLTK=NoThanks

View File

@@ -1,6 +1,19 @@
#include "cache.h"
#include "unix-socket.h"
#ifdef NO_UNIX_SOCKETS
int unix_stream_connect(const char *path)
{
errno = ENOSYS;
return -1;
}
int unix_stream_listen(const char *path)
{
errno = ENOSYS;
return -1;
}
#else
static int unix_stream_socket(void)
{
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -56,3 +69,4 @@ int unix_stream_listen(const char *path)
return fd;
}
#endif