Initial work on NetBSD port

This commit is contained in:
UnknownShadow200 2019-03-09 13:33:08 +11:00
parent d12e1c1b0b
commit 6602ae50c3
3 changed files with 47 additions and 17 deletions

View file

@ -73,6 +73,10 @@ Install libexecinfo package if needed.
```gcc *.c -o ClassiCube -isystem /usr/X11R6/include -isystem /usr/local/include -L /usr/X11R6/lib -L /usr/local/lib -lX11 -lGL -lcurl -lopenal -lexecinfo```
#### NetBSD
```gcc *.c -o ClassiCube -I /usr/X11R7/include -I /usr/pkg/include -L /usr/X11R7/lib -L /usr/pkg/lib -lX11 -lGL -lcurl -lopenal -lpthread -lexecinfo```
### Documentation
Functions and variables in .h files are mostly documented.

View file

@ -108,6 +108,11 @@ typedef struct TextureRec_ { float U1, V1, U2, V2; } TextureRec;
#define CC_BUILD_X11
#define CC_BUILD_POSIX
#endif
#ifdef __NetBSD__
#define CC_BUILD_NETBSD
#define CC_BUILD_X11
#define CC_BUILD_POSIX
#endif
#ifdef __EMSCRIPTEN__
#define CC_BUILD_WEB
#define CC_BUILD_SDL

View file

@ -93,6 +93,8 @@ const ReturnCode ReturnCode_SocketWouldBlock = EWOULDBLOCK;
#elif defined CC_BUILD_OPENBSD
#define CC_BUILD_UNIX
#include <sys/sysctl.h>
#elif defined CC_BUILD_NETBSD
#define CC_BUILD_UNIX
#elif defined CC_BUILD_SOLARIS
#define CC_BUILD_UNIX
#include <sys/filio.h>
@ -320,7 +322,18 @@ void DateTime_CurrentLocal(struct DateTime* time_) {
#define NS_PER_SEC 1000000000ULL
#endif
#if defined CC_BUILD_LINUX || defined CC_BUILD_FREEBSD || defined CC_BUILD_OPENBSD
/* clock_gettime is optional, see http://pubs.opengroup.org/onlinepubs/009696899/functions/clock_getres.html */
/* "... These functions are part of the Timers option and need not be available on all implementations..." */
#if defined CC_BUILD_WEB
uint64_t Stopwatch_Measure(void) {
/* time is a milliseconds double */
return (uint64_t)(emscripten_get_now() * 1000);
}
#elif defined CC_BUILD_OSX
uint64_t Stopwatch_Measure(void) { return mach_absolute_time(); }
#elif defined CC_BUILD_SOLARIS
uint64_t Stopwatch_Measure(void) { return gethrtime(); }
#elif defined CC_BUILD_UNIX
uint64_t Stopwatch_Measure(void) {
struct timespec t;
/* TODO: CLOCK_MONOTONIC_RAW ?? */
@ -328,22 +341,6 @@ uint64_t Stopwatch_Measure(void) {
return (uint64_t)t.tv_sec * NS_PER_SEC + t.tv_nsec;
}
#endif
#ifdef CC_BUILD_SOLARIS
uint64_t Stopwatch_Measure(void) {
return gethrtime();
}
#endif
#ifdef CC_BUILD_OSX
uint64_t Stopwatch_Measure(void) {
return mach_absolute_time();
}
#endif
#ifdef CC_BUILD_WEB
uint64_t Stopwatch_Measure(void) {
/* time is a milliseconds double */
return (uint64_t)(emscripten_get_now() * 1000);
}
#endif
/*########################################################################################################################*
@ -1247,6 +1244,12 @@ static void Font_Init(void) {
String_FromConst("C:/Windows/Fonts"),
String_FromConst("C:/WINNT/Fonts")
};
#elif defined CC_BUILD_NETBSD
const static String dirs[3] = {
String_FromConst("/usr/X11R7/lib/X11/fonts"),
String_FromConst("/usr/pkg/lib/X11/fonts"),
String_FromConst("/usr/pkg/share/fonts")
};
#elif defined CC_BUILD_UNIX
const static String dirs[2] = {
String_FromConst("/usr/share/fonts"),
@ -1945,6 +1948,24 @@ ReturnCode Process_GetExePath(String* path) {
return 0;
}
#endif
#ifdef CC_BUILD_NETBSD
ReturnCode Process_GetExePath(String* path) {
char str[600];
int mib[4];
size_t size = 600;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC_ARGS;
mib[2] = -1; /* self process id */
mib[2] = KERN_PROC_PATHNAME;
if (sysctl(mib, 4, str, &size, NULL, 0) == -1) return errno;
size = String_CalcLen(str, 600);
Convert_DecodeUtf8(path, str, size);
return 0;
}
#endif
#ifdef CC_BUILD_SOLARIS
ReturnCode Process_GetExePath(String* path) {
char str[600];