diff --git a/options/posix/generic/unistd-stubs.cpp b/options/posix/generic/unistd-stubs.cpp index 16ab8b74f9..d69c83bef2 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) { diff --git a/options/posix/include/unistd.h b/options/posix/include/unistd.h index 627f33a660..45789b4156 100644 --- a/options/posix/include/unistd.h +++ b/options/posix/include/unistd.h @@ -330,7 +330,7 @@ pid_t setsid(void); int setuid(uid_t); void setusershell(void); unsigned int sleep(unsigned int); -void swab(const void *__restrict, void *__restrict, ssize_t); +void swab(const void *_src, void *_dest, ssize_t n); int symlink(const char *, const char *); int symlinkat(const char *, int, const char *); void sync(void);