From 2edd9638904af6c7de3011c9d87849da8c2a6065 Mon Sep 17 00:00:00 2001 From: Dennis Bonke Date: Fri, 26 Jul 2024 16:52:06 +0200 Subject: [PATCH] options/posix: Implement swab --- options/posix/generic/unistd-stubs.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/options/posix/generic/unistd-stubs.cpp b/options/posix/generic/unistd-stubs.cpp index 444ad22da0..1ac4843073 100644 --- a/options/posix/generic/unistd-stubs.cpp +++ b/options/posix/generic/unistd-stubs.cpp @@ -666,9 +666,15 @@ int setuid(uid_t uid) { return 0; } -void swab(const void *__restrict, void *__restrict, ssize_t) { - __ensure(!"Not implemented"); - __builtin_unreachable(); +void swab(const void *_src, void *_dest, ssize_t n) { + const char *src = reinterpret_cast(_src); + char *dest = reinterpret_cast(_dest); + for(; n > 1; n -= 2) { + dest[0] = src[1]; + dest[1] = src[0]; + dest += 2; + src += 2; + } } int symlink(const char *target_path, const char *link_path) {