Skip to content

Commit 036d59f

Browse files
Merge pull request #8 from allmazz/freebsd-compatability
add compatability for freebsd
2 parents 67421c7 + eaf85ec commit 036d59f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libbson/src/bson/bson-error.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ bson_strerror_r (int err_code, /* IN */
130130
// required) by the POSIX spec (see:
131131
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html#tag_16_574_08).
132132
(void) strerror_r (err_code, buf, buflen);
133-
#elif defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700
133+
#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700) || \
134+
(defined(__FreeBSD_version) && __FreeBSD_version >= 1203500) || \
135+
defined(__MUSL__)
134136
// The behavior (of `strerror_l`) is undefined if the locale argument to
135137
// `strerror_l()` is the special locale object LC_GLOBAL_LOCALE or is not a
136138
// valid locale object handle.
@@ -170,6 +172,11 @@ bson_strerror_r (int err_code, /* IN */
170172
// Unlikely, but continue supporting use of GNU extension in cases where the
171173
// C Driver is being built without _XOPEN_SOURCE=700.
172174
ret = strerror_r (err_code, buf, buflen);
175+
#elif defined(__FreeBSD__)
176+
// FreeBSD has implemented strerror_l in 12.3 version, so this condition is needed for compatability.
177+
if (strerror_r (err_code, buf, buflen) != 0) {
178+
ret = NULL;
179+
}
173180
#else
174181
#error "Unable to find a supported strerror_r candidate"
175182
#endif

0 commit comments

Comments
 (0)