compiler: better NetBSD and OpenBSD support in vfmt and $if

pull/4053/head
radare 2020-03-17 12:43:59 +01:00 committed by GitHub
parent e2eb0f17d7
commit f5e44fbef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 8 deletions

View File

@ -32,8 +32,11 @@ const (
['linux', '_lin.v', '_linux.v', '_nix.v'],
['macos', '_mac.v', '_darwin.v'],
['freebsd', '_bsd.v', '_freebsd.v'],
['netbsd', '_bsd.v', '_netbsd.v'],
['openbsd', '_bsd.v', '_openbsd.v'],
['solaris', '_solaris.v'],
['haiku', '_haiku.v'],
['qnx', '_qnx.v'],
]
FORMATTED_FILE_TOKEN = '\@\@\@' + 'FORMATTED_FILE: '
)

View File

@ -360,28 +360,40 @@ fn (v &V) platform_postfix_to_ifdefguard(name string) string {
return '#ifdef CUSTOM_DEFINE_${cdefine}'
}
s := match name {
'.v'{
'.v' {
''
} // no guard needed
'_win.v', '_windows.v'{
'_win.v', '_windows.v' {
'#ifdef _WIN32'
}
'_nix.v'{
'_nix.v' {
'#ifndef _WIN32'
}
'_lin.v', '_linux.v'{
'_qnx.v' {
'#ifndef __QNX__'
}
'_lin.v', '_linux.v' {
'#ifdef __linux__'
}
'_mac.v', '_darwin.v'{
'_mac.v', '_darwin.v' {
'#ifdef __APPLE__'
}
'_bsd.v', '_freebsd.v '{
'_freebsd.v' {
'#ifdef __FreeBSD__'
}
'_solaris.v'{
'_openbsd.v' {
'#ifdef __OpenBSD__'
}
'_netbsd.v' {
'#ifdef __NetBSD__'
}
'_bsd.v' {
'#ifdef __FreeBSD__ || __NetBSD__ || __OpenBSD__'
}
'_solaris.v' {
'#ifdef __sun'
}
'_haiku.v'{
'_haiku.v' {
'#ifdef __haiku__'
}
else {