Skip to content

Commit 4185b95

Browse files
committed
Fix build for FreeBSD
Some libc features need __BSD_VISIBLE set to 1 to be enabled on FreeBSD
1 parent 46a010f commit 4185b95

File tree

9 files changed

+54
-1
lines changed

9 files changed

+54
-1
lines changed

src/libbson/examples/bson-streaming-reader.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
#ifdef __FreeBSD__
18+
#ifndef __BSD_VISIBLE
19+
#define __BSD_VISIBLE 1
20+
#endif /* __BSD_VISIBLE */
21+
#endif /* __FreeBSD__ */
22+
1723
#include <bson/bson.h>
1824
#include <stdio.h>
1925
#include <stdlib.h>

src/libbson/src/bson/bson-string.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17+
#ifdef __FreeBSD__
18+
#ifndef __BSD_VISIBLE
19+
#define __BSD_VISIBLE 1
20+
#endif /* __BSD_VISIBLE */
21+
#endif /* __FreeBSD__ */
1722

1823
#include <limits.h>
1924
#include <stdarg.h>

src/libbson/tests/test-json.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* required on old Windows for rand_s to be defined */
22
#define _CRT_RAND_S
33

4+
#ifdef __FreeBSD__
5+
#ifndef __BSD_VISIBLE
6+
#define __BSD_VISIBLE 1
7+
#endif /* __BSD_VISIBLE */
8+
#endif /* __FreeBSD__ */
9+
410
#include <bson/bson.h>
511
#include <math.h>
612

@@ -2114,7 +2120,7 @@ test_bson_json_double (void)
21142120
ASSERT_CMPDOUBLE (bson_iter_double (&iter), ==, 0.0);
21152121

21162122
/* check that "x" is -0.0. signbit not available on Solaris or VS 2010 */
2117-
#if !defined(__sun) && (!defined(_MSC_VER) || (_MSC_VER >= 1800))
2123+
#if !defined(__sun) && !defined(__FreeBSD__) && (!defined(_MSC_VER) || (_MSC_VER >= 1800))
21182124
BSON_ASSERT (signbit (bson_iter_double (&iter)));
21192125
#endif
21202126

src/libmongoc/src/mongoc/mongoc-util.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#define _CRT_RAND_S
1919
#endif
2020

21+
#ifdef __FreeBSD__
22+
#ifndef __BSD_VISIBLE
23+
#define __BSD_VISIBLE 1
24+
#endif /* __BSD_VISIBLE */
25+
#endif /* __FreeBSD__ */
26+
2127
#include <string.h>
2228

2329
#include "bson/bson.h"

src/libmongoc/tests/ssl-test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef __FreeBSD__
2+
#ifndef __BSD_VISIBLE
3+
#define __BSD_VISIBLE 1
4+
#endif /* __BSD_VISIBLE */
5+
#endif /* __FreeBSD__ */
6+
17
#include <bson/bson.h>
28
#include <errno.h>
39

src/libmongoc/tests/test-mongoc-async.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef __FreeBSD__
2+
#ifndef __BSD_VISIBLE
3+
#define __BSD_VISIBLE 1
4+
#endif /* __BSD_VISIBLE */
5+
#endif /* __FreeBSD__ */
6+
17
#include <mongoc/mongoc.h>
28
#include <mongoc/mongoc-client-private.h>
39

src/libmongoc/tests/test-mongoc-client-side-encryption.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17+
#ifdef __FreeBSD__
18+
#ifndef __BSD_VISIBLE
19+
#define __BSD_VISIBLE 1
20+
#endif /* __BSD_VISIBLE */
21+
#endif /* __FreeBSD__ */
22+
1723
#include "json-test.h"
1824
#include "test-libmongoc.h"
1925

src/libmongoc/tests/test-mongoc-socket.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef __FreeBSD__
2+
#ifndef __BSD_VISIBLE
3+
#define __BSD_VISIBLE 1
4+
#endif /* __BSD_VISIBLE */
5+
#endif /* __FreeBSD__ */
6+
17
#include <fcntl.h>
28
#include <mongoc/mongoc.h>
39
#include <mongoc/mongoc-util-private.h>

src/libmongoc/tests/test-mongoc-stream-tls-error.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#ifdef __FreeBSD__
2+
#ifndef __BSD_VISIBLE
3+
#define __BSD_VISIBLE 1
4+
#endif /* __BSD_VISIBLE */
5+
#endif /* __FreeBSD__ */
6+
17
#include <mongoc/mongoc.h>
28
#include <mongoc/mongoc-thread-private.h>
39
#include <mongoc/mongoc-util-private.h>

0 commit comments

Comments
 (0)