mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
Add support for Musl. (#726)
Motivation: We would like to make this work for Musl so that we can build fully statically linked binaries that use AsyncHTTPClient. Modifications: Define `_GNU_SOURCE` as a compiler argument; doing it in a source file doesn't work properly with modular headers. Add imports of `Musl` in appropriate places. `Musl` doesn't have `strptime_l`, so avoid using that. Result: async-http-client will build for Musl.
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#if __APPLE__
|
||||
#include <xlocale.h>
|
||||
#elif __linux__
|
||||
#define _GNU_SOURCE
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
@@ -32,7 +31,11 @@ bool swiftahc_cshims_strptime(const char * string, const char * format, struct t
|
||||
|
||||
bool swiftahc_cshims_strptime_l(const char * string, const char * format, struct tm * result, void * locale) {
|
||||
// The pointer cast is fine as long we make sure it really points to a locale_t.
|
||||
#ifdef __musl__
|
||||
const char * firstNonProcessed = strptime(string, format, result);
|
||||
#else
|
||||
const char * firstNonProcessed = strptime_l(string, format, result, (locale_t)locale);
|
||||
#endif
|
||||
if (firstNonProcessed) {
|
||||
return *firstNonProcessed == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user