Skip to content

Commit 7ca755a

Browse files
committed
define FFS_BSD macro for known BSD
1 parent 2a50e49 commit 7ca755a

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

include/ffilesystem.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ typedef unsigned int mode_t;
2222
#endif
2323
#endif
2424

25+
#endif // _MSC_VER
26+
27+
#if !defined(__APPLE__) && (defined(BSD) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))
28+
#define FFS_BSD 1
2529
#endif
30+
31+
2632
#ifdef __cplusplus
2733

2834
#include <cstdint> // for uintmax_t

src/extra/exepath.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#elif defined(__linux__) || defined(__CYGWIN__)
2020
#include <unistd.h> // for readlink
2121
#include <sys/types.h> // for ssize_t
22-
#elif defined(BSD)
22+
#elif defined(FFS_BSD)
2323
#include <sys/sysctl.h> // for sysctl
2424
#include <cstddef> // for size_t
2525
#endif
@@ -64,7 +64,7 @@ std::string fs_exe_path()
6464
return path;
6565
}
6666
}
67-
#elif defined(BSD)
67+
#elif defined(FFS_BSD)
6868
// https://man.freebsd.org/cgi/man.cgi?sysctl(3)
6969
auto L = fs_get_max_path();
7070
std::string path;

src/os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ bool fs_is_unix() {
4646
}
4747

4848
bool fs_is_bsd() {
49-
#if defined(BSD)
50-
return !fs_is_macos();
49+
#if defined(FFS_BSD)
50+
return true;
5151
#else
5252
return false;
5353
#endif

src/partition.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@
44
#include <iostream>
55
#include <system_error>
66

7+
#include "ffilesystem.h"
8+
79
#if defined(__linux__) && (__has_include(<linux/magic.h>) || __has_include("linux/magic.h"))
810
// GCC < 10 doesn't detect <linux/magic.h>
911
// IWYU pragma: no_include <sys/statfs.h>
1012
#define HAVE_LINUX_MAGIC_H
1113
#include <sys/vfs.h> // IWYU pragma: keep
1214
#include <linux/magic.h>
1315
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/magic.h
14-
#elif defined(__APPLE__) || defined(BSD)
16+
#elif defined(__APPLE__) || defined(FFS_BSD)
1517
#include <sys/param.h>
1618
#include <sys/mount.h>
1719
#elif defined(_WIN32) || defined(__CYGWIN__)
1820
#define WIN32_LEAN_AND_MEAN
1921
#include <windows.h>
2022
#endif
2123

22-
#include "ffilesystem.h"
2324

2425

2526
#ifdef HAVE_LINUX_MAGIC_H
@@ -134,7 +135,7 @@ std::string fs_filesystem_type(std::string_view path)
134135
# else
135136
ec = std::make_error_code(std::errc::function_not_supported);
136137
# endif
137-
#elif defined(__APPLE__) || defined(BSD)
138+
#elif defined(__APPLE__) || defined(FFS_BSD)
138139
struct statfs s;
139140
const std::string cpath(path);
140141

0 commit comments

Comments
 (0)