Add basic NetBSD support

pull/241/head
Kamil Rytarowski 8 years ago
parent 475c66d2cc
commit 3c4ccd41fa

@ -306,6 +306,11 @@ LLVM:
# define POSH_OS_STRING "FreeBSD" # define POSH_OS_STRING "FreeBSD"
#endif #endif
#if defined __NetBSD__
# define POSH_OS_NETBSD 1
# define POSH_OS_STRING "NetBSD"
#endif
#if defined __OpenBSD__ #if defined __OpenBSD__
# define POSH_OS_OPENBSD 1 # define POSH_OS_OPENBSD 1
# define POSH_OS_STRING "OpenBSD" # define POSH_OS_STRING "OpenBSD"
@ -1027,5 +1032,3 @@ extern posh_i64_t POSH_ReadI64FromBig( const void *src );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -38,9 +38,12 @@ ENDIF(NVCORE_SHARED)
TARGET_LINK_LIBRARIES(nvcore ${LIBS}) TARGET_LINK_LIBRARIES(nvcore ${LIBS})
# On NetBSD backtrace() is provided by libexecinfo, not libc.
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
TARGET_LINK_LIBRARIES(nvcore execinfo)
endif()
INSTALL(TARGETS nvcore INSTALL(TARGETS nvcore
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION lib LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static) ARCHIVE DESTINATION lib/static)

@ -51,7 +51,7 @@
# endif # endif
#endif #endif
#if NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD #if NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD
# include <sys/types.h> # include <sys/types.h>
# include <sys/param.h> # include <sys/param.h>
# include <sys/sysctl.h> // sysctl # include <sys/sysctl.h> // sysctl
@ -635,6 +635,19 @@ namespace
# else # else
# error "Unknown CPU" # error "Unknown CPU"
# endif # endif
#elif NV_OS_NETBSD
# if NV_CPU_X86_64
ucontext_t * ucp = (ucontext_t *)secret;
return (void *)ucp->uc_mcontext.__gregs[_REG_RIP];
# elif NV_CPU_X86
ucontext_t * ucp = (ucontext_t *)secret;
return (void *)ucp->uc_mcontext.__gregs[_REG_EIP];
# elif NV_CPU_PPC
ucontext_t * ucp = (ucontext_t *)secret;
return (void *) ucp->uc_mcontext.__gregs[_REG_PC];
# else
# error "Unknown CPU"
# endif
#elif NV_OS_OPENBSD #elif NV_OS_OPENBSD
# if NV_CPU_X86_64 # if NV_CPU_X86_64
ucontext_t * ucp = (ucontext_t *)secret; ucontext_t * ucp = (ucontext_t *)secret;
@ -666,7 +679,7 @@ namespace
// How to obtain the instruction pointers in different platforms, from mlton's source code. // How to obtain the instruction pointers in different platforms, from mlton's source code.
// http://mlton.org/ // http://mlton.org/
// OpenBSD && NetBSD // OpenBSD
// ucp->sc_eip // ucp->sc_eip
// FreeBSD: // FreeBSD:
// ucp->uc_mcontext.mc_eip // ucp->uc_mcontext.mc_eip

@ -44,6 +44,9 @@
#elif defined POSH_OS_FREEBSD #elif defined POSH_OS_FREEBSD
# define NV_OS_FREEBSD 1 # define NV_OS_FREEBSD 1
# define NV_OS_UNIX 1 # define NV_OS_UNIX 1
#elif defined POSH_OS_NETBSD
# define NV_OS_NETBSD 1
# define NV_OS_UNIX 1
#elif defined POSH_OS_OPENBSD #elif defined POSH_OS_OPENBSD
# define NV_OS_OPENBSD 1 # define NV_OS_OPENBSD 1
# define NV_OS_UNIX 1 # define NV_OS_UNIX 1
@ -290,7 +293,7 @@ NV_COMPILER_CHECK(sizeof(uint32) == 4);
#elif NV_CC_GNUC #elif NV_CC_GNUC
# if NV_OS_LINUX # if NV_OS_LINUX
# include "DefsGnucLinux.h" # include "DefsGnucLinux.h"
# elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD # elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD
# include "DefsGnucDarwin.h" # include "DefsGnucDarwin.h"
# elif NV_OS_MINGW # elif NV_OS_MINGW
# include "DefsGnucWin32.h" # include "DefsGnucWin32.h"

@ -172,7 +172,7 @@ namespace nv
{ {
#if NV_OS_WIN32 || NV_OS_XBOX #if NV_OS_WIN32 || NV_OS_XBOX
return _finite(f) != 0; return _finite(f) != 0;
#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD || NV_OS_ORBIS #elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD || NV_OS_ORBIS
return isfinite(f); return isfinite(f);
#elif NV_OS_LINUX #elif NV_OS_LINUX
return finitef(f); return finitef(f);
@ -187,7 +187,7 @@ namespace nv
{ {
#if NV_OS_WIN32 || NV_OS_XBOX #if NV_OS_WIN32 || NV_OS_XBOX
return _isnan(f) != 0; return _isnan(f) != 0;
#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD || NV_OS_ORBIS #elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_NETBSD || NV_OS_OPENBSD || NV_OS_ORBIS
return isnan(f); return isnan(f);
#elif NV_OS_LINUX #elif NV_OS_LINUX
return isnanf(f); return isnanf(f);

@ -88,7 +88,7 @@ uint nv::processorCount() {
return 6; return 6;
#elif NV_OS_XBOX #elif NV_OS_XBOX
return 3; // or 6? return 3; // or 6?
#elif NV_OS_LINUX // Linux, Solaris, & AIX #elif NV_OS_LINUX || NV_OS_NETBSD // Linux, Solaris, & AIX
return sysconf(_SC_NPROCESSORS_ONLN); return sysconf(_SC_NPROCESSORS_ONLN);
#elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD #elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
int numCPU; int numCPU;
@ -329,4 +329,4 @@ uint nv::physicalProcessorCount() {
return processorCount(); return processorCount();
} }
#endif #endif

Loading…
Cancel
Save