Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenBSD compatibility #169

Open
wants to merge 11 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ env.Replace(LIBPATH = [os.getenv('LIBPATH', '')])
env.Append(CPPFLAGS = ' -pthread')

# Freebsd ports are installed under /usr/local
if sysname == 'freebsd' or sysname == 'sunos':
if sysname == 'freebsd' or sysname == 'sunos' or sysname == 'openbsd':
env.Append(LIBPATH = ['/usr/local/lib'])
env.Append(CPPFLAGS = ' -I/usr/local/include ')
if sysname == 'sunos':
Expand Down Expand Up @@ -206,7 +206,7 @@ env.Append(CPPPATH = Split('''#
# '''))

# Preprocessor flags
if sysname != 'sunos' and sysname != 'darwin' and sysname != 'freebsd':
if sysname != 'sunos' and sysname != 'darwin' and sysname != 'freebsd' and sysname != 'openbsd':
env.Append(CPPFLAGS = ' -D_XOPEN_SOURCE=600')
if sysname == 'sunos':
env.Append(CPPFLAGS = ' -D__EXTENSIONS__')
Expand Down Expand Up @@ -251,7 +251,7 @@ if not conf.CheckLib('pthread'):
if 0 == x86:
conf.CheckLib('atomic')

if sysname != 'darwin':
if sysname != 'darwin' and sysname != 'openbsd':
if not conf.CheckLib('rt'):
print 'Error: rt library not found'
Exit(1)
Expand Down Expand Up @@ -390,8 +390,8 @@ if ssl == 1:
print 'ssl support required but asio/ssl.hpp not found or not usable'
print 'compile with ssl=0 or check that openssl devel headers are usable'
Exit(1)
if conf.CheckLib('ssl'):
conf.CheckLib('crypto')
if conf.CheckLib('crypto'):
conf.CheckLib('ssl')
else:
print 'ssl support required but openssl library not found'
print 'compile with ssl=0 or check that openssl library is usable'
Expand Down Expand Up @@ -437,7 +437,7 @@ if not conf.CheckLib('m'):
print 'Error: math library not found or not usable'
Exit(1)

if sysname != 'darwin':
if sysname != 'darwin' and sysname != 'openbsd':
if not conf.CheckLib('rt'):
print 'Error: realtime library not found or not usable'
Exit(1)
Expand Down
6 changes: 6 additions & 0 deletions galerautils/src/gu_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#elif defined(__APPLE__) || defined(__FreeBSD__)
# include <stdint.h>
# define GU_WORDSIZE __WORDSIZE
#elif defined(__OpenBSD__)
# if defined(__LP64__)
# define GU_WORDSIZE 64
# else
# define GU_WORDSIZE 32
# endif
#else
# include <bits/wordsize.h>
# define GU_WORDSIZE __WORDSIZE
Expand Down
2 changes: 1 addition & 1 deletion galerautils/src/gu_backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "gu_backtrace.h"
#include "gu_log.h"

#ifdef __GNUC__
#if defined(__GNUC__) && !defined(__OpenBSD__)
#include <execinfo.h>
#include <stdlib.h>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch should be removed since it is no longer relevant.

Expand Down
5 changes: 5 additions & 0 deletions galerautils/src/gu_byteswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ static GU_FORCE_INLINE uint64_t GU_ROTL64 (uint64_t x, int8_t r)
# define gu_bswap16 __bswap16_var
# define gu_bswap32 __bswap32_var
# define gu_bswap64 __bswap64_var
#elif defined(__OpenBSD__)
#include <endian.h>
#define gu_bswap16(x) __swap16(x)
#define gu_bswap32(x) __swap32(x)
#define gu_bswap64(x) __swap64(x)
#elif defined(__sun__)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robert used the swapX macros. Wonder if that makes more sense as they use the bswapX macros further down.

# define gu_bswap16 BSWAP_16
# define gu_bswap32 BSWAP_32
Expand Down
6 changes: 6 additions & 0 deletions galerautils/src/gu_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,11 @@
#ifndef ENODATA
# define ENODATA (GU_ELAST+6)
#endif
#ifndef EPROTO
# define EPROTO (GU_ELAST+7)
#endif
#ifndef EBADMSG
# define EBADMSG (GU_ELAST+8)
#endif

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch can be removed as it is no longer necessary.

#endif /* GU_STR_H */
2 changes: 2 additions & 0 deletions galerautils/src/gu_fdesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ namespace gu

#if defined(__APPLE__)
if (0 != fcntl (fd_, F_SETSIZE, size_) && 0 != ftruncate (fd_, size_))
#elif defined(__OpenBSD__)
errno = EINVAL; /* no means of allocating space */
#else
if (0 != posix_fallocate (fd_, start, diff))
#endif
Expand Down
4 changes: 2 additions & 2 deletions galerautils/src/gu_mmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ namespace gu
<< "' failed";
}

#if !defined(__sun__) && !defined(__APPLE__) && !defined(__FreeBSD__)
/* Solaris, Darwin, and FreeBSD do not have MADV_DONTFORK */
#if !defined(__sun__) && !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
/* Solaris, Darwin, FreeBSD and OpenBSD do not have MADV_DONTFORK */
if (posix_madvise (ptr, size, MADV_DONTFORK))
{
int const err(errno);
Expand Down
12 changes: 6 additions & 6 deletions galerautils/src/gu_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
#include <map>
#include <stdexcept>

#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
# include <ifaddrs.h>
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
#else /* !__APPLE__ && !__FreeBSD__ */
#else /* !__APPLE__ && !__FreeBSD__ && !__OpenBSD__ */
extern "C" /* old style cast */
{
static int const GU_SIOCGIFCONF = SIOCGIFCONF;
static int const GU_SIOCGIFINDEX = SIOCGIFINDEX;
}
#endif /* !__APPLE__ && !__FreeBSD__ */
#endif /* !__APPLE__ && !__FreeBSD__ && !__OpenBSD__ */

//using namespace std;
using std::make_pair;
Expand Down Expand Up @@ -79,7 +79,7 @@ class SchemeMap
family,
socktype,
protocol,
#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__OpenBSD__)
0, // FreeBSD gives ENOMEM error with non-zero value
#else
sizeof(struct sockaddr),
Expand Down Expand Up @@ -196,7 +196,7 @@ static unsigned int get_ifindex_by_addr(const gu::net::Sockaddr& addr)

unsigned int idx(-1);
int err(0);
#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
struct ifaddrs *if_addrs = NULL;
struct ifaddrs *if_addr = NULL;

Expand All @@ -223,7 +223,7 @@ static unsigned int get_ifindex_by_addr(const gu::net::Sockaddr& addr)
}

out:
# else /* !__APPLE__ && !__FreeBSD__ */
# else /* !__APPLE__ && !__FreeBSD__ && !__OpenBSD__ */
struct ifconf ifc;
memset(&ifc, 0, sizeof(struct ifconf));
ifc.ifc_len = 16*sizeof(struct ifreq);
Expand Down
2 changes: 1 addition & 1 deletion gcache/src/gcache_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ gcache::Page::drop_fs_cache() const
{
mmap_.dont_need();

#if !defined(__APPLE__)
#if !defined(__APPLE__) && !defined(__OpenBSD__)
int const err (posix_fadvise (fd_.get(), 0, fd_.size(),
POSIX_FADV_DONTNEED));
if (err != 0)
Expand Down
4 changes: 4 additions & 0 deletions www.evanjones.ca/crc32c.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ uint32_t crc32cSarwate (uint32_t crc, const void* data, size_t length);
uint32_t crc32cSlicingBy4(uint32_t crc, const void* data, size_t length);
uint32_t crc32cSlicingBy8(uint32_t crc, const void* data, size_t length);

#if !defined(__OpenBSD__)

#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64)
#define CRC32C_x86_64
#endif
Expand All @@ -44,6 +46,8 @@ uint32_t crc32cSlicingBy8(uint32_t crc, const void* data, size_t length);
#define CRC32C_x86
#endif

#endif

#if !defined(CRC32C_x86)
#define CRC32C_NO_HARDWARE
#endif
Expand Down