Skip to content
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
4 changes: 4 additions & 0 deletions asio/asio/detail/impl/kqueue_reactor.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "asio/detail/push_options.hpp"

#if defined(__NetBSD__)
#include <sys/param.h>
#endif

#if defined(__NetBSD__) && __NetBSD_Version__ < 1000000000
# define ASIO_KQUEUE_EV_SET(ev, ident, filt, flags, fflags, data, udata) \
EV_SET(ev, ident, filt, flags, fflags, data, \
reinterpret_cast<intptr_t>(static_cast<void*>(udata)))
Expand Down
2 changes: 1 addition & 1 deletion cmake/crc32c.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main()
{
#if defined(__linux__)
(void)getauxval(AT_HWCAP);
#elif defined(__FreeBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__)
unsigned long info;
(void)elf_aux_info(AT_HWCAP, &info, sizeof(info));
#else
Expand Down
2 changes: 1 addition & 1 deletion galerautils/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if not crc32c_no_hardware:
{
#if defined(__linux__)
(void)getauxval(AT_HWCAP);
#elif defined(__FreeBSD__)
#elif defined(__FreeBSD__) || defined(__NetBSD__)
unsigned long info;
(void)elf_aux_info(AT_HWCAP, &info, sizeof(info));
#else
Expand Down
2 changes: 1 addition & 1 deletion galerautils/src/gu_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# error "Byte order not defined"
#endif

#if defined(__sun__)
#if defined(__sun__) || defined(__NetBSD__)
# if defined (_LP64)
# define GU_WORDSIZE 64
# else
Expand Down
4 changes: 2 additions & 2 deletions galerautils/src/gu_asio_socket_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static struct tcp_info get_tcp_info(Socket& socket)
{
struct tcp_info tcpi;
memset(&tcpi, 0, sizeof(tcpi));
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#if defined(__linux__)
static int const level(SOL_TCP);
#else /* FreeBSD */
Expand All @@ -162,7 +162,7 @@ static struct tcp_info get_tcp_info(Socket& socket)
gu_throw_error(err) << "Failed to read TCP info from socket: "
<< strerror(err);
}
#endif /* __linux__ || __FreeBSD__ */
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ */
return tcpi;
}

Expand Down
4 changes: 2 additions & 2 deletions galerautils/src/gu_crc32c_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gu_crc32c_arm64(gu_crc32c_t state, const void* data, size_t len)

#include <sys/auxv.h>

#if defined(__FreeBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__)
/* Imitate getauxval() interface */
static unsigned long int
getauxval(unsigned long int const type)
Expand All @@ -79,7 +79,7 @@ getauxval(unsigned long int const type)
if (0 != elf_aux_info(type, &ret, sizeof(ret))) ret = 0;
return ret;
}
#endif /* FreeBSD */
#endif /* FreeBSD || NetBSD */

#if defined(HWCAP_CRC32)
# define GU_AT_HWCAP AT_HWCAP
Expand Down
2 changes: 1 addition & 1 deletion galerautils/src/gu_errno.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <errno.h>

#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
# define GU_ELAST ELAST
#else
/* must be high enough to not collide with system errnos but lower than 256 */
Expand Down
5 changes: 4 additions & 1 deletion galerautils/src/gu_fdesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,16 @@ namespace gu
#if defined(__APPLE__)
if (-1 == fcntl (fd_, F_SETSIZE, size_) && -1 == ftruncate (fd_, size_))
{
#elif defined(__NetBSD__)
if (-1 == ftruncate (fd_, size_) || 0 != posix_fallocate (fd_, start, diff))
{
#else
int const ret = posix_fallocate (fd_, start, diff);
if (0 != ret)
{
errno = ret;
#endif
if ((EINVAL == errno || ENOSYS == errno) && start >= 0 && diff > 0)
if ((EINVAL == errno || ENOSYS == errno || EOPNOTSUPP == errno) && start >= 0 && diff > 0)
{
// FS does not support the operation, try physical write
write_file (start);
Expand Down
24 changes: 22 additions & 2 deletions galerautils/src/gu_limits.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,33 @@ static inline size_t page_size() { return sysconf(_SC_PAGESIZE); }
static inline size_t phys_pages() { return sysconf(_SC_PHYS_PAGES); }
static inline size_t avphys_pages() { return freebsd_avphys_pages(); }

#else /* !__APPLE__ && !__FreeBSD__ */
#elif defined(__NetBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/vmmeter.h>

static long netbsd_avphys_pages (void)
{
struct vmtotal total;
static const int vmmeter_mib[] = { CTL_VM, VM_METER };
size_t size = sizeof(total);
if (sysctl(vmmeter_mib, 2, &total, &size, NULL, 0) == -1) {
gu_error("Can't get vmtotals");
return 0;
}
return (long)total.t_free;
}

static inline size_t page_size() { return sysconf(_SC_PAGESIZE); }
static inline size_t phys_pages() { return sysconf(_SC_PHYS_PAGES); }
static inline size_t avphys_pages() { return netbsd_avphys_pages(); }
#else /* !__APPLE__ && !__FreeBSD__ && !__NetBSD__ */

static inline size_t page_size() { return sysconf(_SC_PAGESIZE); }
static inline size_t phys_pages() { return sysconf(_SC_PHYS_PAGES); }
static inline size_t avphys_pages() { return sysconf(_SC_AVPHYS_PAGES); }

#endif /* !__APPLE__ && !__FreeBSD__ */
#endif /* !__APPLE__ && !__FreeBSD__ && !__NetBSD__ */

#define GU_DEFINE_FUNCTION(func) \
size_t gu_##func() \
Expand Down
14 changes: 7 additions & 7 deletions galerautils/src/gu_resolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <map>
#include <stdexcept>

#if defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
# include <ifaddrs.h>
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
Expand All @@ -27,7 +27,7 @@ extern "C" /* old style cast */
static int const GU_SIOCGIFCONF = SIOCGIFCONF;
static int const GU_SIOCGIFINDEX = SIOCGIFINDEX;
}
#endif /* !__APPLE__ && !__FreeBSD__ */
#endif /* !__APPLE__ && !__FreeBSD__ && !__NetBSD__ */

//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(__NetBSD__)
0, // FreeBSD gives ENOMEM error with non-zero value
#else
sizeof(struct sockaddr),
Expand Down Expand Up @@ -208,7 +208,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(__NetBSD__)
struct ifaddrs *if_addrs = NULL;
struct ifaddrs *if_addr = NULL;

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

out:
# else /* !__APPLE__ && !__FreeBSD__ */
# else /* !__APPLE__ && !__FreeBSD__ && !__NetBSD__ */
struct ifconf ifc;
memset(&ifc, 0, sizeof(struct ifconf));
ifc.ifc_len = 16*sizeof(struct ifreq);
Expand Down Expand Up @@ -272,7 +272,7 @@ static unsigned int get_ifindex_by_addr(const gu::net::Sockaddr& addr)
}
#if defined(__linux__) || defined(__GNU__)
idx = ifrp->ifr_ifindex;
#elif defined(__sun__) || defined(__FreeBSD_kernel__)
#elif defined(__sun__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
idx = ifrp->ifr_index;
#else
# error "Unsupported ifreq structure"
Expand All @@ -287,7 +287,7 @@ static unsigned int get_ifindex_by_addr(const gu::net::Sockaddr& addr)

out:
close(fd);
#endif /* !__APPLE__ && !__FreeBSD__ */
#endif /* !__APPLE__ && !__FreeBSD__ && !__NetBSD__ */
if (err != 0)
{
gu_throw_error(err) << "failed to get interface index";
Expand Down
2 changes: 1 addition & 1 deletion galerautils/src/gu_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" {

#if defined(__sun__)
# define GU_SYS_PROGRAM_NAME getexecname ()
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
# define GU_SYS_PROGRAM_NAME getprogname ()
#elif defined(__linux__)
# define GU_SYS_PROGRAM_NAME program_invocation_name
Expand Down
7 changes: 7 additions & 0 deletions galerautils/src/gu_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ void gu::thread_set_schedparam(pthread_t thd, const gu::ThreadSchedparam& sp)
struct sched_param spstr = { sp.prio(), { 0, } /* sched_pad array */};
#else
struct sched_param spstr = { sp.prio() };
#endif
#if defined(__NetBSD__)
if (sp.policy() == SCHED_OTHER)
{
/* NetBSD does not allow setting priorities for SCHED_OTHER */
return;
}
#endif
int err;
if ((err = pthread_setschedparam(thd, sp.policy(), &spstr)) != 0)
Expand Down
2 changes: 1 addition & 1 deletion gcs/src/gcs_spread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ GCS_BACKEND_CREATE_FN(gcs_spread_create)
if (spread_priv_name (spread->priv_name,
#if defined(__sun__)
getexecname (),
#elif defined(__APPLE__) || defined(__FreeBSD__)
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
getprogname (),
#elif defined(__linux__)
program_invocation_short_name,
Expand Down