Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Cruft: rm unused __bswap{16,32} MD functions for arm/aarch64
To:
tech@openbsd.org
Date:
Sun, 14 Apr 2024 17:21:44 +0200

Download raw body.

Thread
On arm and aarch64, libc exports __bswap16() and __bswap32().

As far as I can tell, those are unused.  There are no other references
to them in the source tree.  I suspect they were accidentally brought
over from NetBSD.  Or am I missing something?

I propose to remove them, which requires a libc major bump.
Since a minor bump and libcrypto major bump are already scheduled,
maybe this could join it?

The diff below is on top of the "drop htonl() etc. from libc" change
and does not include the version bump.


diff 2a34e54f3d7bcfac1603733f23aacf03f3567705 5f59e8b4ff50f7585c529379addb08b7914af41e
commit - 2a34e54f3d7bcfac1603733f23aacf03f3567705
commit + 5f59e8b4ff50f7585c529379addb08b7914af41e
blob - 48d6f8f5c11fdc202b3d90215910fb4411910a23
blob + dbbd4860c85876fd8617c24641bf37638ea40f0e
--- lib/libc/arch/aarch64/Symbols.list
+++ lib/libc/arch/aarch64/Symbols.list
@@ -1,5 +1,3 @@
-__bswap16
-__bswap32
 __mcount
 __multf3
 _fpgetmask
blob - c52c3400e45afd8eb5e2a98bb2e77c5ae51d6d80
blob + e4f6f2a0be1e680db7ff1284e0ece3aacd1bf0aa
--- lib/libc/arch/aarch64/gen/Makefile.inc
+++ lib/libc/arch/aarch64/gen/Makefile.inc
@@ -1,7 +1,7 @@
 # $OpenBSD: Makefile.inc,v 1.2 2020/07/06 13:33:05 pirofti Exp $
 # $NetBSD: Makefile.inc,v 1.6 2003/08/01 17:03:47 lukem Exp $
 
-SRCS+=	byte_swap_2.S byte_swap_4.S fabs.c flt_rounds.c infinity.c
+SRCS+=	fabs.c flt_rounds.c infinity.c
 SRCS+=	ldexp.c modf.c nan.c
 SRCS+=	setjmp.S _setjmp.S sigsetjmp.S
 SRCS+=	clz_tab.c
blob - 1ca15676a229e04e44fb897a91df43e45f6f76a5 (mode 644)
blob + /dev/null
--- lib/libc/arch/aarch64/gen/byte_swap_2.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/*	$OpenBSD: byte_swap_2.S,v 1.3 2022/05/24 22:34:02 guenther Exp $	*/
-/*	$NetBSD: byte_swap_2.S,v 1.3 2003/04/05 23:08:51 bjh21 Exp $	*/
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "DEFS.h"
-
-_ENTRY(__bswap16)
-	RETGUARD_SETUP(__bswap16, x15)
-	and     w8, w0, #0xffff
-        ubfx    w0, w0, #8, #8
-	bfi     w0, w8, #8, #16
-	RETGUARD_CHECK(__bswap16, x15)
-	ret
-_END(__bswap16)
blob - 3b555baaee5eb111abb4125d94b2d26000b0c1a8 (mode 644)
blob + /dev/null
--- lib/libc/arch/aarch64/gen/byte_swap_4.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/*	$OpenBSD: byte_swap_4.S,v 1.3 2022/05/24 22:34:02 guenther Exp $	*/
-/*	$NetBSD: byte_swap_4.S,v 1.2 2003/04/05 23:08:51 bjh21 Exp $	*/
-
-/*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Neil A. Carson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "DEFS.h"
-
-_ENTRY(__bswap32)
-	RETGUARD_SETUP(__bswap32, x15)
-	rev	w0, w0
-	RETGUARD_CHECK(__bswap32, x15)
-	ret
-_END(__bswap32)
blob - 00e33ba569971f9b75c03f08071161dc6c5c01fd
blob + a57d3361b0c70113b0fad289dcdc9e91061ef7c9
--- lib/libc/arch/arm/Symbols.list
+++ lib/libc/arch/arm/Symbols.list
@@ -1,7 +1,5 @@
 __adddf3
 __addsf3
-__bswap16
-__bswap32
 __divdf3
 __divsf3
 __divsi3
blob - ae135f5885e4b0ea7a681f38f5e6410647f8aa02
blob + 2fccdcd68b02723065fe56d581df71a91e6187f7
--- lib/libc/arch/arm/gen/Makefile.inc
+++ lib/libc/arch/arm/gen/Makefile.inc
@@ -1,6 +1,6 @@
 # $OpenBSD: Makefile.inc,v 1.16 2020/07/06 13:33:05 pirofti Exp $
 # $NetBSD: Makefile.inc,v 1.6 2003/08/01 17:03:47 lukem Exp $
 
-SRCS+=	byte_swap_2.S byte_swap_4.S divsi3.S fabs.c flt_rounds.c infinity.c
+SRCS+=	divsi3.S fabs.c flt_rounds.c infinity.c
 SRCS+=	ldexp.c modf.c nan.c usertc.c
 SRCS+=	setjmp.S _setjmp.S sigsetjmp.S
blob - ac4e78b14b543f904c18a2a738c23f31ec7e7507 (mode 644)
blob + /dev/null
--- lib/libc/arch/arm/gen/byte_swap_2.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/*	$OpenBSD: byte_swap_2.S,v 1.4 2022/05/24 17:15:23 guenther Exp $	*/
-/*	$NetBSD: byte_swap_2.S,v 1.3 2003/04/05 23:08:51 bjh21 Exp $	*/
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "DEFS.h"
-
-_ENTRY(__bswap16)
-	and		r1, r0, #0xff
-	mov		r0, r0, lsr #8
-	orr		r0, r0, r1, lsl #8
-	mov		pc, lr  
-_END(__bswap16)
blob - 82f037452a4f3f52ce94801d4aab208039257492 (mode 644)
blob + /dev/null
--- lib/libc/arch/arm/gen/byte_swap_4.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/*	$OpenBSD: byte_swap_4.S,v 1.4 2022/05/24 17:15:23 guenther Exp $	*/
-/*	$NetBSD: byte_swap_4.S,v 1.2 2003/04/05 23:08:51 bjh21 Exp $	*/
-
-/*-
- * Copyright (c) 1997 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Neil A. Carson
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "DEFS.h"
-
-_ENTRY(__bswap32)
-	eor		r1, r0, r0, ror #16
-	bic		r1, r1, #0x00FF0000
-	mov		r0, r0, ror #8
-	eor		r0, r0, r1, lsr #8
-	mov		pc, lr
-_END(__bswap32)

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de