Skip to content

[test][stdlib] Add strto*_l stubs for OpenBSD. #32395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions stdlib/public/stubs/Stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,28 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
#if defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__) || defined(__OpenBSD__)
#if defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__)
#include <sstream>
#include <cmath>
#elif defined(__OpenBSD__)
#include <locale.h>

static double swift_strtod_l(const char *nptr, char **endptr, locale_t loc) {
return strtod(nptr, endptr);
}

static float swift_strtof_l(const char *nptr, char **endptr, locale_t loc) {
return strtof(nptr, endptr);
}

static long double swift_strtold_l(const char *nptr, char **endptr,
locale_t loc) {
return strtold(nptr, endptr);
}

#define strtod_l swift_strtod_l
#define strtof_l swift_strtof_l
#define strtold_l swift_strtold_l
#elif defined(__ANDROID__)
#include <locale.h>

Expand Down Expand Up @@ -369,7 +388,7 @@ static bool swift_stringIsSignalingNaN(const char *nptr) {
return strcasecmp(nptr, "snan") == 0;
}

#if defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__) || defined(__OpenBSD__)
#if defined(__CYGWIN__) || defined(_WIN32) || defined(__HAIKU__)
// Cygwin does not support uselocale(), but we can use the locale feature
// in stringstream object.
template <typename T>
Expand Down