Skip to content

Commit 7b6bb28

Browse files
committed
Initial support for GNU/Hurd
Tweak configuration & tests so that most of abseil works on the Hurd: - enable available TLS ("__thread", in practice) - enable available mmap - enable available POSIX semaphores - enable available POSIX write() - disable the ELF symbolizer: while the object format is ELF, the symbolizer uses bits (i.e. "mmap" files in /proc) not currently available - use the available /proc/self/exe - tweak a log test for the different value of EBADF - tweak the strerror test for the GNU libc Hurd string representation of -1
1 parent 41253e4 commit 7b6bb28

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

absl/base/config.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
231231
#endif
232232

233233
// ABSL_HAVE_TLS is defined to 1 when __thread should be supported.
234-
// We assume __thread is supported on Linux when compiled with Clang or
234+
// We assume __thread is supported on Linux or Hurd when compiled with Clang or
235235
// compiled against libstdc++ with _GLIBCXX_HAVE_TLS defined.
236236
#ifdef ABSL_HAVE_TLS
237237
#error ABSL_HAVE_TLS cannot be directly set
238-
#elif (defined(__linux__)) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
238+
#elif (defined(__linux__) || defined(__GNU__)) && (defined(__clang__) || defined(_GLIBCXX_HAVE_TLS))
239239
#define ABSL_HAVE_TLS 1
240240
#elif defined(__INTEL_LLVM_COMPILER)
241241
#define ABSL_HAVE_TLS 1
@@ -364,6 +364,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
364364
// WebAssembly (Emscripten) __EMSCRIPTEN__
365365
// Fuchsia __Fuchsia__
366366
// WebAssembly (WASI) _WASI_EMULATED_MMAN (implies __wasi__)
367+
// GNU/Hurd __GNU__
367368
//
368369
// Note that since Android defines both __ANDROID__ and __linux__, one
369370
// may probe for either Linux or Android by simply testing for __linux__.
@@ -379,7 +380,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
379380
defined(__EMSCRIPTEN__) || defined(__Fuchsia__) || defined(__sun) || \
380381
defined(__myriad2__) || defined(__HAIKU__) || defined(__OpenBSD__) || \
381382
defined(__NetBSD__) || defined(__QNX__) || defined(__VXWORKS__) || \
382-
defined(__hexagon__) || defined(__XTENSA__) || \
383+
defined(__hexagon__) || defined(__XTENSA__) || defined(__GNU__) || \
383384
defined(_WASI_EMULATED_MMAN)
384385
#define ABSL_HAVE_MMAP 1
385386
#endif
@@ -427,7 +428,7 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
427428
// platforms.
428429
#ifdef ABSL_HAVE_SEMAPHORE_H
429430
#error ABSL_HAVE_SEMAPHORE_H cannot be directly set
430-
#elif defined(__linux__) || defined(__ros__) || defined(__VXWORKS__)
431+
#elif defined(__linux__) || defined(__ros__) || defined(__VXWORKS__) || defined(__GNU__)
431432
#define ABSL_HAVE_SEMAPHORE_H 1
432433
#endif
433434

absl/base/internal/raw_logging.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
// this, consider moving both to config.h instead.
4444
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
4545
defined(__hexagon__) || defined(__Fuchsia__) || defined(__OpenBSD__) || \
46-
defined(__EMSCRIPTEN__) || defined(__ASYLO__)
46+
defined(__EMSCRIPTEN__) || defined(__ASYLO__) || defined(__GNU__)
4747

4848
#include <unistd.h>
4949

absl/base/internal/strerror_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ TEST(StrErrorTest, InvalidErrorCode) {
4040
errno = ERANGE;
4141
EXPECT_THAT(absl::base_internal::StrError(-1),
4242
AnyOf(Eq("No error information"), Eq("Unknown error -1"),
43-
Eq("Unknown error")));
43+
Eq("Unknown error"),
44+
Eq("Error in unknown error system: FFFFFFFF")));
4445
EXPECT_THAT(errno, Eq(ERANGE));
4546
}
4647

absl/debugging/internal/symbolize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#ifdef ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE
3131
#error ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE cannot be directly set
3232
#elif defined(__ELF__) && defined(__GLIBC__) && !defined(__asmjs__) \
33-
&& !defined(__wasm__)
33+
&& !defined(__wasm__) && !defined(__GNU__)
3434
#define ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE 1
3535

3636
#include <elf.h>

absl/log/log_modifier_methods_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,14 @@ TEST(TailCallsModifiesTest, WithPerror) {
218218
Send(AllOf(
219219
TextMessage(AnyOf(Eq("hello world: Bad file number [9]"),
220220
Eq("hello world: Bad file descriptor [9]"),
221-
Eq("hello world: Bad file descriptor [8]"))),
221+
Eq("hello world: Bad file descriptor [8]"),
222+
Eq("hello world: Bad file descriptor [1073741833]"))),
222223
ENCODED_MESSAGE(HasValues(ElementsAre(
223224
ValueWithLiteral(Eq("hello world")), ValueWithLiteral(Eq(": ")),
224225
AnyOf(ValueWithStr(Eq("Bad file number")),
225226
ValueWithStr(Eq("Bad file descriptor"))),
226227
ValueWithLiteral(Eq(" [")),
227-
AnyOf(ValueWithStr(Eq("8")), ValueWithStr(Eq("9"))),
228+
AnyOf(ValueWithStr(Eq("8")), ValueWithStr(Eq("9")), ValueWithStr(Eq("1073741833"))),
228229
ValueWithLiteral(Eq("]"))))))));
229230

230231
test_sink.StartCapturingLogs();

absl/log/stripping_test.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class StrippingTest : public ::testing::Test {
170170
// Opens this program's executable file. Returns `nullptr` and writes to
171171
// `stderr` on failure.
172172
std::unique_ptr<FILE, std::function<void(FILE*)>> OpenTestExecutable() {
173-
#if defined(__linux__)
173+
#if defined(__linux__) || defined(__GNU__)
174174
std::unique_ptr<FILE, std::function<void(FILE*)>> fp(
175175
fopen("/proc/self/exe", "rb"), [](FILE* fp) { fclose(fp); });
176176
if (!fp) {

0 commit comments

Comments
 (0)