diff --git a/client/Makefile b/client/Makefile index ec59355..6f386cb 100644 --- a/client/Makefile +++ b/client/Makefile @@ -31,9 +31,15 @@ else ifeq ($(platform),Darwin) LUAPLATFORM = macosx else - LUALIB += -ldl - LDLIBS += -ltermcap -lncurses - LUAPLATFORM = linux + ifeq ($(platform),NetBSD) + LDLIBS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib + LDLIBS += -ltermcap -lncurses + LUAPLATFORM = netbsd + else + LUALIB += -ldl + LDLIBS += -ltermcap -lncurses + LUAPLATFORM = linux + endif endif endif diff --git a/client/hardnested/hardnested_bf_core.c b/client/hardnested/hardnested_bf_core.c index 3c0c044..b9c0691 100644 --- a/client/hardnested/hardnested_bf_core.c +++ b/client/hardnested/hardnested_bf_core.c @@ -146,7 +146,7 @@ bitslice_test_nonces_t bitslice_test_nonces_dispatch; #if defined (_WIN32) #define malloc_bitslice(x) __builtin_assume_aligned(_aligned_malloc((x), MAX_BITSLICES/8), MAX_BITSLICES/8) #define free_bitslice(x) _aligned_free(x) -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined(__NetBSD__) static void *malloc_bitslice(size_t x) { char *allocated_memory; if (posix_memalign((void**)&allocated_memory, MAX_BITSLICES/8, x)) { diff --git a/client/hardnested/hardnested_bitarray_core.c b/client/hardnested/hardnested_bitarray_core.c index aca4f14..4127d96 100644 --- a/client/hardnested/hardnested_bitarray_core.c +++ b/client/hardnested/hardnested_bitarray_core.c @@ -147,7 +147,7 @@ inline uint32_t *MALLOC_BITARRAY(uint32_t x) { #if defined (_WIN32) return __builtin_assume_aligned(_aligned_malloc((x), __BIGGEST_ALIGNMENT__), __BIGGEST_ALIGNMENT__); -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined(__NetBSD__) uint32_t *allocated_memory; if (posix_memalign((void**)&allocated_memory, __BIGGEST_ALIGNMENT__, x)) { return NULL; diff --git a/client/util.c b/client/util.c index 7e6b407..c7d8134 100644 --- a/client/util.c +++ b/client/util.c @@ -704,6 +704,9 @@ void xor(unsigned char *dst, unsigned char *src, size_t len) { int32_t le24toh (uint8_t data[3]) { return (data[2] << 16) | (data[1] << 8) | data[0]; } +#ifdef le32toh +# undef le32toh +#endif uint32_t le32toh (uint8_t *data) { return (uint32_t)( (data[3]<<24) | (data[2]<<16) | (data[1]<<8) | data[0]); } diff --git a/client/util.h b/client/util.h index 8dc56f8..c7dbc7e 100644 --- a/client/util.h +++ b/client/util.h @@ -82,6 +82,9 @@ void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length); void xor(unsigned char *dst, unsigned char *src, size_t len); int32_t le24toh(uint8_t data[3]); +#ifdef le32toh +# undef le32toh +#endif uint32_t le32toh (uint8_t *data); void rol(uint8_t *data, const size_t len); diff --git a/client/whereami.c b/client/whereami.c index 6e5e85f..8cc49da 100644 --- a/client/whereami.c +++ b/client/whereami.c @@ -559,6 +559,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) defined(__FreeBSD_kernel__) || defined(__NetBSD__) #include +#include #include #include #include @@ -576,7 +577,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length) for (;;) { +#ifdef KERN_PROC_ARGV + int mib[4] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; +#else int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; +#endif size_t size = sizeof(buffer1); if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0) diff --git a/liblua/Makefile b/liblua/Makefile index 5525606..346afae 100644 --- a/liblua/Makefile +++ b/liblua/Makefile @@ -26,7 +26,7 @@ MYOBJS= # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= -PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris +PLATS= aix ansi bsd freebsd generic linux macosx mingw netbsd posix solaris LUA_A= liblua.a CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \ @@ -114,6 +114,9 @@ mingw: "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe $(MAKE) "LUAC_T=luac.exe" luac.exe +netbsd: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLDFLAGS="-L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib" SYSLIBS="-Wl,-E -lreadline -ltermcap -lncurses" + posix: $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX"