Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
freebsd: Use more relaxed version conditions in bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Nov 19, 2020
1 parent cdac184 commit 86df9f3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/core/sys/freebsd/config.d
Expand Up @@ -11,6 +11,8 @@ public import core.sys.posix.config;

// https://svnweb.freebsd.org/base/head/sys/sys/param.h?view=markup
// __FreeBSD_version numbers are documented in the Porter's Handbook.
// NOTE: When adding newer versions of FreeBSD, verify all current versioned
// bindings are still compatible with the release.
version (FreeBSD_12) enum __FreeBSD_version = 1202000;
else version (FreeBSD_11) enum __FreeBSD_version = 1104000;
else version (FreeBSD_10) enum __FreeBSD_version = 1004000;
Expand Down
6 changes: 2 additions & 4 deletions src/core/sys/freebsd/sys/event.d
Expand Up @@ -39,7 +39,7 @@ enum
EVFILT_SYSCOUNT = 11,
}

static if (__FreeBSD_version >= 1200000 && __FreeBSD_version < 1300000)
static if (__FreeBSD_version >= 1200000)
{
struct kevent_t
{
Expand All @@ -52,7 +52,7 @@ static if (__FreeBSD_version >= 1200000 && __FreeBSD_version < 1300000)
ulong[4] ext;
}
}
else static if (__FreeBSD_version < 1200000)
else
{
struct kevent_t
{
Expand All @@ -64,8 +64,6 @@ else static if (__FreeBSD_version < 1200000)
void *udata; /* opaque user data identifier */
}
}
else
static assert(0, "Unsupported version of FreeBSD");

extern(D) void EV_SET(kevent_t* kevp, typeof(kevent_t.tupleof) args)
{
Expand Down
6 changes: 2 additions & 4 deletions src/core/sys/freebsd/sys/mount.d
Expand Up @@ -34,18 +34,16 @@ struct fid

enum MFSNAMELEN = 16;

static if (__FreeBSD_version >= 1200000 && __FreeBSD_version < 1300000)
static if (__FreeBSD_version >= 1200000)
{
enum MNAMELEN = 1024;
enum STATFS_VERSION = 0x20140518;
}
else static if (__FreeBSD_version < 1200000)
else
{
enum MNAMELEN = 88;
enum STATFS_VERSION = 0x20030518;
}
else
static assert(0, "Unsupported version of FreeBSD");

struct statfs_t
{
Expand Down
6 changes: 2 additions & 4 deletions src/core/sys/posix/dirent.d
Expand Up @@ -157,7 +157,7 @@ else version (FreeBSD)
DT_WHT = 14
}

static if (__FreeBSD_version >= 1200000 && __FreeBSD_version < 1300000)
static if (__FreeBSD_version >= 1200000)
{
struct dirent
{
Expand All @@ -170,7 +170,7 @@ else version (FreeBSD)
char[256] d_name = 0;
}
}
else static if (__FreeBSD_version < 1200000)
else
{
align(4)
struct dirent
Expand All @@ -182,8 +182,6 @@ else version (FreeBSD)
char[256] d_name = 0;
}
}
else
static assert(0, "Unsupported version of FreeBSD");

alias void* DIR;

Expand Down
6 changes: 2 additions & 4 deletions src/core/sys/posix/sys/types.d
Expand Up @@ -197,22 +197,20 @@ else version (FreeBSD)
// https://github.com/freebsd/freebsd/blob/master/sys/sys/_types.h
alias long blkcnt_t;

static if (__FreeBSD_version >= 1200000 && __FreeBSD_version < 1300000)
static if (__FreeBSD_version >= 1200000)
{
alias ulong blksize_t;
alias ulong dev_t;
alias ulong ino_t;
alias ulong nlink_t;
}
else static if (__FreeBSD_version < 1200000)
else
{
alias uint blksize_t;
alias uint dev_t;
alias uint ino_t;
alias ushort nlink_t;
}
else
static assert(0, "Unsupported version of FreeBSD");

alias uint gid_t;
alias ushort mode_t;
Expand Down

0 comments on commit 86df9f3

Please sign in to comment.