mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add NetBSD Support (#2661)
* Add NetBSD Support Includes: - Hints to find non-compatibility libc functions - Struct and constant definitions for sockets, polling, etc. - Changes to the linker code to work around some quirks in the NetBSD dynamic linker - A target triple for netbsd aarch64 so llvm builds/links the compiler properly on this platform * Updated releasenotes and some compacting --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module std::os::posix @if(env::POSIX);
|
||||
import libc;
|
||||
|
||||
extern fn CInt clock_gettime(int type, TimeSpec *time);
|
||||
extern fn CInt clock_gettime(int type, TimeSpec *time) @cname(env::NETBSD ??? "__clock_gettime50" : "clock_gettime");
|
||||
|
||||
module std::os::posix @if(env::OPENBSD);
|
||||
const CLOCK_REALTIME = 0;
|
||||
|
||||
@@ -32,9 +32,9 @@ extern fn ZString getcwd(char* pwd, usz len);
|
||||
extern fn CInt pipe(CInt[2]* pipes);
|
||||
extern fn CFile fdopen(CInt fd, ZString mode);
|
||||
extern fn CInt access(ZString path, CInt mode);
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @cname("readdir") @if(!USE_DARWIN_INODE64) ;
|
||||
extern fn DIRPtr opendir(ZString);
|
||||
extern fn void closedir(DIRPtr);
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @cname(readdir_cname());
|
||||
extern fn DIRPtr opendir(ZString) @cname(env::NETBSD ??? "__opendir30" : "opendir");
|
||||
|
||||
const DT_UNKNOWN = 0;
|
||||
const DT_FIFO = 1;
|
||||
@@ -46,5 +46,12 @@ const DT_LNK = 10;
|
||||
const DT_SOCK = 12;
|
||||
const DT_WHT = 14;
|
||||
|
||||
const USE_DARWIN_INODE64 = env::DARWIN && env::X86_64;
|
||||
extern fn Posix_dirent* readdir(DIRPtr) @cname("readdir$INODE64") @if(USE_DARWIN_INODE64);
|
||||
|
||||
macro String readdir_cname() @local @const
|
||||
{
|
||||
$switch:
|
||||
$case env::DARWIN && env::X86_64: return "readdir$INODE64";
|
||||
$case env::NETBSD: return "__readdir30";
|
||||
$default: return "readdir";
|
||||
$endswitch
|
||||
}
|
||||
@@ -58,7 +58,7 @@ const CInt WUNTRACES = 2;
|
||||
JmpBuf backtrace_jmpbuf @local;
|
||||
alias BacktraceFn = fn CInt(void** buffer, CInt size);
|
||||
|
||||
extern fn CInt backtrace(void** buffer, CInt size) @if(env::OPENBSD);
|
||||
extern fn CInt backtrace(void** buffer, CInt size) @if(env::OPENBSD || env::NETBSD);
|
||||
|
||||
fn void install_signal_handler(CInt signal, SigActionFunction func)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ fn void install_signal_handler(CInt signal, SigActionFunction func)
|
||||
libc::sigaction(signal, &action, &old);
|
||||
}
|
||||
|
||||
fn CInt backtrace(void** buffer, CInt size) @if(!env::OPENBSD)
|
||||
fn CInt backtrace(void** buffer, CInt size) @if(!env::OPENBSD && !env::NETBSD)
|
||||
{
|
||||
if (size < 1) return 0;
|
||||
void* handle = libc::dlopen("libc.so.6", libc::RTLD_LAZY|libc::RTLD_NODELETE);
|
||||
|
||||
Reference in New Issue
Block a user