Skip to content

Commit 11bdb17

Browse files
authored
Another bunch of FreeBSD related portability fixes (#571)
* Provide CGlobalRNG::result_type Allows to use CGlobalRNG in std::shuffle, similar to fc61592 * Make bash shebang portable * Make version fetch failure message more verbose Let the package maintainer know which file is actually missing * Implement gettid() on FreeBSD * Fix rts/System/Platform/Misc.cpp on FreeBSD * Make manpages optional
1 parent 60cc0c5 commit 11bdb17

6 files changed

Lines changed: 17 additions & 4 deletions

File tree

doc/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
option(ENABLE_MANPAGES "Enable manpages" TRUE)
12

23
### make and install the man pages
3-
if (UNIX)
4+
if (UNIX AND ENABLE_MANPAGES)
45
find_package(SevenZip)
56
set(AsciiDoc_FIND_QUIETLY TRUE)
67
find_package(AsciiDoc)

doc/manpages/make_manpages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
ORIG_DIR=$(pwd)
44

rts/System/GlobalRNG.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ template<typename RNG, bool synced> class CGlobalRNG {
102102
typedef typename RNG::val_type rng_val_type;
103103
typedef typename RNG::res_type rng_res_type;
104104

105+
using result_type = rng_res_type;
106+
105107
static_assert(std::numeric_limits<float>::digits == 24, "sign plus mantissa bits should be 24");
106108

107109
void Seed(rng_val_type seed) { SetSeed(seed); }

rts/System/Platform/Linux/ThreadSupport.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <fstream>
99
#include <sys/syscall.h>
1010

11+
#if defined(__FreeBSD__)
12+
#include <pthread_np.h> // for pthread_getthreadid_np
13+
#endif
14+
1115
#include "System/Log/ILog.h"
1216
#include "System/Platform/Threading.h"
1317

@@ -42,7 +46,11 @@ enum LinuxThreadState {
4246
* There is no glibc wrapper for this system call, so you have to write one:
4347
*/
4448
static int gettid() {
49+
#if defined(__FreeBSD__)
50+
return pthread_getthreadid_np();
51+
#else
4552
return syscall(SYS_gettid);
53+
#endif
4654
}
4755

4856
/**

rts/System/Platform/Misc.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
#include <mach-o/dyld.h>
3030

3131
#elif defined( __FreeBSD__)
32+
#include <sys/types.h>
3233
#include <sys/sysctl.h>
34+
#include <ifaddrs.h>
3335

3436
#else
3537

@@ -714,7 +716,7 @@ namespace Platform
714716
return (GetMacType(macAddr, 0), macAddr);
715717
}
716718

717-
#elif defined(__APPLE__)
719+
#elif defined(__APPLE__) || defined (__FreeBSD__)
718720

719721
std::array<uint8_t, 6> GetRawMacAddr() {
720722
// TODO: http://lists.freebsd.org/pipermail/freebsd-hackers/2004-June/007415.html

rts/build/cmake/UtilVersion.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ macro (fetch_spring_version dir prefix)
183183
# Try to fetch version through VERSION file
184184
get_version_from_file(${prefix}_VERSION "${dir}/VERSION")
185185
if (${${prefix}_VERSION-NOTFOUND})
186-
message (FATAL_ERROR "Failed to fetch ${prefix} version.")
186+
message (FATAL_ERROR "Failed to fetch ${prefix} version from ${dir}/VERSION.")
187187
else ()
188188
message (STATUS "${prefix} version fetched from VERSION file: ${${prefix}_VERSION}")
189189
endif ()

0 commit comments

Comments
 (0)