Merge pull request #721 from devnexen/solaris_build_fix

solairs/illumos build fix proposal.
This commit is contained in:
Yamagi 2021-06-14 16:12:45 +02:00 committed by GitHub
commit 495f8be7dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View file

@ -160,6 +160,9 @@ else()
else()
list(APPEND yquake2LinkerFlags "-lnetwork")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
list(APPEND yquake2LinkerFlags "-lsocket -lnsl")
endif()
endif()
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

View file

@ -339,6 +339,8 @@ else ifeq ($(YQ2_OSTYPE), Darwin)
override LDFLAGS += -arch $(YQ2_ARCH)
else ifeq ($(YQ2_OSTYPE), Haiku)
override LDFLAGS += -lm -lnetwork
else ifeq ($(YQ2_OSTYPE), SunOS)
override LDFLAGS += -lm -lsocket -lnsl
endif
ifneq ($(YQ2_OSTYPE), Darwin)

View file

@ -29,7 +29,7 @@
#include "../../common/header/shared.h"
#if defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#if defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__sun)
#include <unistd.h> // readlink(), amongst others
#endif
@ -73,14 +73,18 @@ static void SetExecutablePath(char* exePath)
exePath[0] = '\0';
}
#elif defined(__linux)
#elif defined(__linux) || defined(__sun)
// all the platforms that have /proc/$pid/exe or similar that symlink the
// real executable - basiscally Linux and the BSDs except for FreeBSD which
// doesn't enable proc by default and has a sysctl() for this. OpenBSD once
// had /proc but removed it for security reasons.
char buf[PATH_MAX] = {0};
#if defined(__linux)
snprintf(buf, sizeof(buf), "/proc/%d/exe", getpid());
#else
snprintf(buf, sizeof(buf), "/proc/%ld/path/a.out", getpid());
#endif
// readlink() doesn't null-terminate!
int len = readlink(buf, exePath, PATH_MAX-1);
if (len <= 0)

View file

@ -34,6 +34,12 @@
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#if defined(__sun)
#include <sys/filio.h>
#if !defined(MAX)
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#endif
#include <errno.h>
#include <arpa/inet.h>
#include <net/if.h>