From aa1e42a3320764b8e688f0ab95e406941bf18896 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 18 Jan 2020 20:26:05 -0500 Subject: [PATCH] libroot: Replace swab() with the musl version. This was the last function remaining in the glibc "string" directory, so now we can remove that directory and a bunch of related files that are no longer needed. --- src/system/libroot/Jamfile | 1 - src/system/libroot/posix/glibc/Jamfile | 1 - src/system/libroot/posix/glibc/string/Jamfile | 18 ---------- src/system/libroot/posix/glibc/string/swab.c | 34 ------------------- src/system/libroot/posix/musl/string/Jamfile | 1 + src/system/libroot/posix/musl/string/swab.c | 17 ++++++++++ 6 files changed, 18 insertions(+), 54 deletions(-) delete mode 100644 src/system/libroot/posix/glibc/string/Jamfile delete mode 100644 src/system/libroot/posix/glibc/string/swab.c create mode 100644 src/system/libroot/posix/musl/string/swab.c diff --git a/src/system/libroot/Jamfile b/src/system/libroot/Jamfile index bc948a52a0..9c2cd6ded9 100644 --- a/src/system/libroot/Jamfile +++ b/src/system/libroot/Jamfile @@ -47,7 +47,6 @@ for architectureObject in [ MultiArchSubDirSetup ] { posix_gnu_regex.o posix_gnu_stdio.o posix_gnu_stdlib.o - posix_gnu_string.o posix_gnu_wcsmbs.o posix_stdlib.o posix_string.o diff --git a/src/system/libroot/posix/glibc/Jamfile b/src/system/libroot/posix/glibc/Jamfile index 9cae4017a3..3259db6cd7 100644 --- a/src/system/libroot/posix/glibc/Jamfile +++ b/src/system/libroot/posix/glibc/Jamfile @@ -15,5 +15,4 @@ SubInclude HAIKU_TOP src system libroot posix glibc misc ; SubInclude HAIKU_TOP src system libroot posix glibc regex ; SubInclude HAIKU_TOP src system libroot posix glibc stdio-common ; SubInclude HAIKU_TOP src system libroot posix glibc stdlib ; -SubInclude HAIKU_TOP src system libroot posix glibc string ; SubInclude HAIKU_TOP src system libroot posix glibc wcsmbs ; diff --git a/src/system/libroot/posix/glibc/string/Jamfile b/src/system/libroot/posix/glibc/string/Jamfile deleted file mode 100644 index f79671cdad..0000000000 --- a/src/system/libroot/posix/glibc/string/Jamfile +++ /dev/null @@ -1,18 +0,0 @@ -SubDir HAIKU_TOP src system libroot posix glibc string ; - -local architectureObject ; -for architectureObject in [ MultiArchSubDirSetup ] { - on $(architectureObject) { - local architecture = $(TARGET_PACKAGING_ARCH) ; - - SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch - $(TARGET_ARCH) ; - SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch - generic ; - SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ; - - MergeObject <$(architecture)>posix_gnu_string.o : - swab.c - ; - } -} diff --git a/src/system/libroot/posix/glibc/string/swab.c b/src/system/libroot/posix/glibc/string/swab.c deleted file mode 100644 index 102058ab66..0000000000 --- a/src/system/libroot/posix/glibc/string/swab.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 1992, 1996, 1997 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - 02111-1307 USA. */ - -#include - -void -swab (const void *bfrom, void *bto, ssize_t n) -{ - const char *from = (const char *) bfrom; - char *to = (char *) bto; - - n &= ~((ssize_t) 1); - while (n > 1) - { - const char b0 = from[--n], b1 = from[--n]; - to[n] = b0; - to[n + 1] = b1; - } -} diff --git a/src/system/libroot/posix/musl/string/Jamfile b/src/system/libroot/posix/musl/string/Jamfile index 3c08aad354..157ab76686 100644 --- a/src/system/libroot/posix/musl/string/Jamfile +++ b/src/system/libroot/posix/musl/string/Jamfile @@ -10,6 +10,7 @@ for architectureObject in [ MultiArchSubDirSetup ] { MergeObject <$(architecture)>posix_musl_string.o : memrchr.c + swab.c ; } } diff --git a/src/system/libroot/posix/musl/string/swab.c b/src/system/libroot/posix/musl/string/swab.c new file mode 100644 index 0000000000..4c4956cdbb --- /dev/null +++ b/src/system/libroot/posix/musl/string/swab.c @@ -0,0 +1,17 @@ +#include + +#if __GNUC__ < 4 +#define restrict +#endif + +void swab(const void *restrict _src, void *restrict _dest, ssize_t n) +{ + const char *src = _src; + char *dest = _dest; + for (; n>1; n-=2) { + dest[0] = src[1]; + dest[1] = src[0]; + dest += 2; + src += 2; + } +}