From ed759541c5fc4ccbc1a0be552fc63c7b344b66df Mon Sep 17 00:00:00 2001 From: naddy Date: Mon, 15 Apr 2024 14:30:48 +0000 Subject: [PATCH] drop htonl(), htons(), ntohl(), ntohs() MD functions from libc Userland code compiled in a normal fashion picks up the htonl(), htons(), ntohl(), ntohs() macros implemented by endian.h. The functions in libc are effectively unused. Keep the MI functions in case something looks for the symbols in libc or plays games with #undef, but change them to wrap the implementation from endian.h. tweaks suggested by claudio@, ok miod@ --- lib/libc/arch/aarch64/gen/byte_swap_2.S | 8 +--- lib/libc/arch/aarch64/gen/byte_swap_4.S | 8 +--- lib/libc/arch/aarch64/net/Makefile.inc | 5 -- lib/libc/arch/alpha/net/Makefile.inc | 4 -- lib/libc/arch/alpha/net/byte_swap_2.S | 48 ------------------- lib/libc/arch/alpha/net/byte_swap_4.S | 54 --------------------- lib/libc/arch/alpha/net/htonl.S | 33 ------------- lib/libc/arch/alpha/net/htons.S | 33 ------------- lib/libc/arch/alpha/net/ntohl.S | 33 ------------- lib/libc/arch/alpha/net/ntohs.S | 33 ------------- lib/libc/arch/amd64/net/Makefile.inc | 3 -- lib/libc/arch/amd64/net/htonl.S | 13 ----- lib/libc/arch/amd64/net/htons.S | 13 ----- lib/libc/arch/amd64/net/ntohl.S | 13 ----- lib/libc/arch/amd64/net/ntohs.S | 13 ----- lib/libc/arch/arm/gen/byte_swap_2.S | 8 +--- lib/libc/arch/arm/gen/byte_swap_4.S | 8 +--- lib/libc/arch/arm/net/Makefile.inc | 5 -- lib/libc/arch/hppa/net/Makefile.inc | 3 -- lib/libc/arch/i386/net/Makefile.inc | 3 -- lib/libc/arch/i386/net/htonl.S | 41 ---------------- lib/libc/arch/i386/net/htons.S | 39 --------------- lib/libc/arch/i386/net/ntohl.S | 41 ---------------- lib/libc/arch/i386/net/ntohs.S | 39 --------------- lib/libc/arch/m88k/net/Makefile.inc | 3 -- lib/libc/arch/m88k/net/htonl.S | 42 ----------------- lib/libc/arch/m88k/net/htons.S | 43 ----------------- lib/libc/arch/m88k/net/ntohl.S | 42 ----------------- lib/libc/arch/m88k/net/ntohs.S | 43 ----------------- lib/libc/arch/mips64/net/Makefile.inc | 3 -- lib/libc/arch/mips64/net/htonl.S | 60 ------------------------ lib/libc/arch/mips64/net/htons.S | 56 ---------------------- lib/libc/arch/powerpc/net/Makefile.inc | 1 - lib/libc/arch/powerpc64/net/Makefile.inc | 1 - lib/libc/arch/riscv64/net/Makefile.inc | 1 - lib/libc/arch/sh/net/Makefile.inc | 4 -- lib/libc/arch/sh/net/htonl.c | 58 ----------------------- lib/libc/arch/sh/net/htons.c | 52 -------------------- lib/libc/arch/sh/net/ntohl.c | 58 ----------------------- lib/libc/arch/sh/net/ntohs.c | 52 -------------------- lib/libc/arch/sparc64/net/Makefile.inc | 3 -- lib/libc/arch/sparc64/net/htonl.S | 45 ------------------ lib/libc/arch/sparc64/net/htons.S | 45 ------------------ lib/libc/arch/sparc64/net/ntohl.S | 43 ----------------- lib/libc/arch/sparc64/net/ntohs.S | 48 ------------------- lib/libc/net/Makefile.inc | 15 ++---- lib/libc/net/htonl.c | 14 ++---- lib/libc/net/htons.c | 14 ++---- lib/libc/net/ntohl.c | 14 ++---- lib/libc/net/ntohs.c | 14 ++---- 50 files changed, 25 insertions(+), 1250 deletions(-) delete mode 100644 lib/libc/arch/aarch64/net/Makefile.inc delete mode 100644 lib/libc/arch/alpha/net/Makefile.inc delete mode 100644 lib/libc/arch/alpha/net/byte_swap_2.S delete mode 100644 lib/libc/arch/alpha/net/byte_swap_4.S delete mode 100644 lib/libc/arch/alpha/net/htonl.S delete mode 100644 lib/libc/arch/alpha/net/htons.S delete mode 100644 lib/libc/arch/alpha/net/ntohl.S delete mode 100644 lib/libc/arch/alpha/net/ntohs.S delete mode 100644 lib/libc/arch/amd64/net/Makefile.inc delete mode 100644 lib/libc/arch/amd64/net/htonl.S delete mode 100644 lib/libc/arch/amd64/net/htons.S delete mode 100644 lib/libc/arch/amd64/net/ntohl.S delete mode 100644 lib/libc/arch/amd64/net/ntohs.S delete mode 100644 lib/libc/arch/arm/net/Makefile.inc delete mode 100644 lib/libc/arch/hppa/net/Makefile.inc delete mode 100644 lib/libc/arch/i386/net/Makefile.inc delete mode 100644 lib/libc/arch/i386/net/htonl.S delete mode 100644 lib/libc/arch/i386/net/htons.S delete mode 100644 lib/libc/arch/i386/net/ntohl.S delete mode 100644 lib/libc/arch/i386/net/ntohs.S delete mode 100644 lib/libc/arch/m88k/net/Makefile.inc delete mode 100644 lib/libc/arch/m88k/net/htonl.S delete mode 100644 lib/libc/arch/m88k/net/htons.S delete mode 100644 lib/libc/arch/m88k/net/ntohl.S delete mode 100644 lib/libc/arch/m88k/net/ntohs.S delete mode 100644 lib/libc/arch/mips64/net/Makefile.inc delete mode 100644 lib/libc/arch/mips64/net/htonl.S delete mode 100644 lib/libc/arch/mips64/net/htons.S delete mode 100644 lib/libc/arch/powerpc/net/Makefile.inc delete mode 100644 lib/libc/arch/powerpc64/net/Makefile.inc delete mode 100644 lib/libc/arch/riscv64/net/Makefile.inc delete mode 100644 lib/libc/arch/sh/net/Makefile.inc delete mode 100644 lib/libc/arch/sh/net/htonl.c delete mode 100644 lib/libc/arch/sh/net/htons.c delete mode 100644 lib/libc/arch/sh/net/ntohl.c delete mode 100644 lib/libc/arch/sh/net/ntohs.c delete mode 100644 lib/libc/arch/sparc64/net/Makefile.inc delete mode 100644 lib/libc/arch/sparc64/net/htonl.S delete mode 100644 lib/libc/arch/sparc64/net/htons.S delete mode 100644 lib/libc/arch/sparc64/net/ntohl.S delete mode 100644 lib/libc/arch/sparc64/net/ntohs.S diff --git a/lib/libc/arch/aarch64/gen/byte_swap_2.S b/lib/libc/arch/aarch64/gen/byte_swap_2.S index 306b40c0e3b..efbdbea6852 100644 --- a/lib/libc/arch/aarch64/gen/byte_swap_2.S +++ b/lib/libc/arch/aarch64/gen/byte_swap_2.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_2.S,v 1.3 2022/05/24 22:34:02 guenther Exp $ */ +/* $OpenBSD: byte_swap_2.S,v 1.4 2024/04/15 14:30:48 naddy Exp $ */ /* $NetBSD: byte_swap_2.S,v 1.3 2003/04/05 23:08:51 bjh21 Exp $ */ /*- @@ -33,16 +33,10 @@ #include "DEFS.h" _ENTRY(__bswap16) -_ENTRY_NB(ntohs) -ENTRY_NB(htons) RETGUARD_SETUP(__bswap16, x15) and w8, w0, #0xffff ubfx w0, w0, #8, #8 bfi w0, w8, #8, #16 RETGUARD_CHECK(__bswap16, x15) ret -END(htons) -_END(ntohs) _END(__bswap16) - .weak htons - .weak ntohs diff --git a/lib/libc/arch/aarch64/gen/byte_swap_4.S b/lib/libc/arch/aarch64/gen/byte_swap_4.S index 4d285b87c86..a16fbeb435c 100644 --- a/lib/libc/arch/aarch64/gen/byte_swap_4.S +++ b/lib/libc/arch/aarch64/gen/byte_swap_4.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_4.S,v 1.3 2022/05/24 22:34:02 guenther Exp $ */ +/* $OpenBSD: byte_swap_4.S,v 1.4 2024/04/15 14:30:48 naddy Exp $ */ /* $NetBSD: byte_swap_4.S,v 1.2 2003/04/05 23:08:51 bjh21 Exp $ */ /*- @@ -33,14 +33,8 @@ #include "DEFS.h" _ENTRY(__bswap32) -_ENTRY_NB(ntohl) -ENTRY_NB(htonl) RETGUARD_SETUP(__bswap32, x15) rev w0, w0 RETGUARD_CHECK(__bswap32, x15) ret -END(htonl) -_END(ntohl) _END(__bswap32) - .weak htonl - .weak ntohl diff --git a/lib/libc/arch/aarch64/net/Makefile.inc b/lib/libc/arch/aarch64/net/Makefile.inc deleted file mode 100644 index f88d6126c4e..00000000000 --- a/lib/libc/arch/aarch64/net/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 2017/01/11 18:09:24 patrick Exp $ -# $NetBSD: Makefile.inc,v 1.1 2000/12/29 20:13:53 bjh21 Exp $ - -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= diff --git a/lib/libc/arch/alpha/net/Makefile.inc b/lib/libc/arch/alpha/net/Makefile.inc deleted file mode 100644 index c3becef9618..00000000000 --- a/lib/libc/arch/alpha/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.4 1996/11/13 22:05:02 niklas Exp $ -# $NetBSD: Makefile.inc,v 1.2 1996/04/17 22:36:42 cgd Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/alpha/net/byte_swap_2.S b/lib/libc/arch/alpha/net/byte_swap_2.S deleted file mode 100644 index 6a509642d6f..00000000000 --- a/lib/libc/arch/alpha/net/byte_swap_2.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: byte_swap_2.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: byte_swap_2.S,v 1.2 1996/10/17 03:08:08 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -#ifndef NAME -#define NAME byte_swap_2 -#endif - -/* - * Byte-swap a 2-byte quantity. (Convert 0x0123 to 0x2301.) - * - * Argument is an unsigned 2-byte integer (u_int16_t). - */ -LEAF(NAME, 1) /* a0 contains 0x0123 */ - extbl a0, 0, t0 /* t0 = 0x 23 */ - extbl a0, 1, t1 /* t1 = 0x 01 */ - sll t0, 8, t0 /* t1 = 0x23 */ - or t0, t1, v0 /* v0 = 0x2301 */ - RET -END(NAME) diff --git a/lib/libc/arch/alpha/net/byte_swap_4.S b/lib/libc/arch/alpha/net/byte_swap_4.S deleted file mode 100644 index 3d10a1b828a..00000000000 --- a/lib/libc/arch/alpha/net/byte_swap_4.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: byte_swap_4.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: byte_swap_4.S,v 1.2 1996/10/17 03:08:09 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#include - -#ifndef NAME -#define NAME byte_swap_4 -#endif - -/* - * Byte-swap a 4-byte quantity. (Convert 0x01234567 to 0x67452301.) - * - * Argument is an unsigned 4-byte integer (u_int32_t). - */ -LEAF(NAME, 1) /* a0 contains 0x01234567 */ - extbl a0, 0, t0 /* t0 = 0x 67 */ - extbl a0, 1, t1 /* t1 = 0x 45 */ - extbl a0, 2, t2 /* t2 = 0x 23 */ - extbl a0, 3, t3 /* t3 = 0x 01 */ - sll t0, 24, t0 /* t0 = 0x67 */ - sll t1, 16, t1 /* t1 = 0x 45 */ - sll t2, 8, t2 /* t2 = 0x 23 */ - or t3, t0, v0 /* v0 = 0x67 01 */ - or t1, t2, t1 /* t1 = 0x 4523 */ - or t1, v0, v0 /* v0 = 0x67452301 */ - RET -END(NAME) diff --git a/lib/libc/arch/alpha/net/htonl.S b/lib/libc/arch/alpha/net/htonl.S deleted file mode 100644 index 22db4560bb4..00000000000 --- a/lib/libc/arch/alpha/net/htonl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: htonl.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: htonl.S,v 1.1 1996/04/17 22:36:52 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htonl - -#include "byte_swap_4.S" diff --git a/lib/libc/arch/alpha/net/htons.S b/lib/libc/arch/alpha/net/htons.S deleted file mode 100644 index a8074a157ba..00000000000 --- a/lib/libc/arch/alpha/net/htons.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: htons.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: htons.S,v 1.1 1996/04/17 22:36:54 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME htons - -#include "byte_swap_2.S" diff --git a/lib/libc/arch/alpha/net/ntohl.S b/lib/libc/arch/alpha/net/ntohl.S deleted file mode 100644 index 14a87f64040..00000000000 --- a/lib/libc/arch/alpha/net/ntohl.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: ntohl.S,v 1.1 1996/04/17 22:36:57 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohl - -#include "byte_swap_4.S" diff --git a/lib/libc/arch/alpha/net/ntohs.S b/lib/libc/arch/alpha/net/ntohs.S deleted file mode 100644 index 376aeb73c3a..00000000000 --- a/lib/libc/arch/alpha/net/ntohs.S +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.4 2009/10/28 06:49:54 deraadt Exp $ */ -/* $NetBSD: ntohs.S,v 1.1 1996/04/17 22:37:02 cgd Exp $ */ - -/* - * Copyright (c) 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#define NAME ntohs - -#include "byte_swap_2.S" diff --git a/lib/libc/arch/amd64/net/Makefile.inc b/lib/libc/arch/amd64/net/Makefile.inc deleted file mode 100644 index 8adcf1267d0..00000000000 --- a/lib/libc/arch/amd64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2012/09/04 03:10:42 okan Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/amd64/net/htonl.S b/lib/libc/arch/amd64/net/htonl.S deleted file mode 100644 index 2895aa4e612..00000000000 --- a/lib/libc/arch/amd64/net/htonl.S +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: htonl.S,v 1.3 2018/07/03 23:14:05 mortimer Exp $ */ - -/* Written by Artur Grabowski. Public Domain */ - -#include - -ENTRY(htonl) - RETGUARD_SETUP(htonl, r11) - movl %edi,%eax - bswapl %eax - RETGUARD_CHECK(htonl, r11) - ret -END(htonl) diff --git a/lib/libc/arch/amd64/net/htons.S b/lib/libc/arch/amd64/net/htons.S deleted file mode 100644 index 51a268d4e4e..00000000000 --- a/lib/libc/arch/amd64/net/htons.S +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: htons.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */ - -/* Written by Artur Grabowski. Public Domain */ - -#include - -ENTRY(htons) - RETGUARD_SETUP(htons, r11) - movl %edi,%eax - xchgb %ah,%al - RETGUARD_CHECK(htons, r11) - ret -END(htons) diff --git a/lib/libc/arch/amd64/net/ntohl.S b/lib/libc/arch/amd64/net/ntohl.S deleted file mode 100644 index cd4c34cc492..00000000000 --- a/lib/libc/arch/amd64/net/ntohl.S +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */ - -/* Written by Artur Grabowski. Public Domain */ - -#include - -ENTRY(ntohl) - RETGUARD_SETUP(ntohl, r11) - movl %edi,%eax - bswapl %eax - RETGUARD_CHECK(ntohl, r11) - ret -END(ntohl) diff --git a/lib/libc/arch/amd64/net/ntohs.S b/lib/libc/arch/amd64/net/ntohs.S deleted file mode 100644 index c5d740fd64c..00000000000 --- a/lib/libc/arch/amd64/net/ntohs.S +++ /dev/null @@ -1,13 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.4 2018/07/03 23:14:05 mortimer Exp $ */ - -/* Written by Artur Grabowski. Public Domain */ - -#include - -ENTRY(ntohs) - RETGUARD_SETUP(ntohs, r11) - movl %edi,%eax - xchgb %ah,%al - RETGUARD_CHECK(ntohs, r11) - ret -END(ntohs) diff --git a/lib/libc/arch/arm/gen/byte_swap_2.S b/lib/libc/arch/arm/gen/byte_swap_2.S index 3429741ed9e..9f242bdbe6a 100644 --- a/lib/libc/arch/arm/gen/byte_swap_2.S +++ b/lib/libc/arch/arm/gen/byte_swap_2.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_2.S,v 1.4 2022/05/24 17:15:23 guenther Exp $ */ +/* $OpenBSD: byte_swap_2.S,v 1.5 2024/04/15 14:30:48 naddy Exp $ */ /* $NetBSD: byte_swap_2.S,v 1.3 2003/04/05 23:08:51 bjh21 Exp $ */ /*- @@ -33,14 +33,8 @@ #include "DEFS.h" _ENTRY(__bswap16) -_ENTRY_NB(ntohs) -ENTRY_NB(htons) and r1, r0, #0xff mov r0, r0, lsr #8 orr r0, r0, r1, lsl #8 mov pc, lr -END(htons) -_END(ntohs) _END(__bswap16) - .weak htons - .weak ntohs diff --git a/lib/libc/arch/arm/gen/byte_swap_4.S b/lib/libc/arch/arm/gen/byte_swap_4.S index 408e95448ae..8194f3006fa 100644 --- a/lib/libc/arch/arm/gen/byte_swap_4.S +++ b/lib/libc/arch/arm/gen/byte_swap_4.S @@ -1,4 +1,4 @@ -/* $OpenBSD: byte_swap_4.S,v 1.4 2022/05/24 17:15:23 guenther Exp $ */ +/* $OpenBSD: byte_swap_4.S,v 1.5 2024/04/15 14:30:48 naddy Exp $ */ /* $NetBSD: byte_swap_4.S,v 1.2 2003/04/05 23:08:51 bjh21 Exp $ */ /*- @@ -33,15 +33,9 @@ #include "DEFS.h" _ENTRY(__bswap32) -_ENTRY_NB(ntohl) -ENTRY_NB(htonl) 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(htonl) -_END(ntohl) _END(__bswap32) - .weak htonl - .weak ntohl diff --git a/lib/libc/arch/arm/net/Makefile.inc b/lib/libc/arch/arm/net/Makefile.inc deleted file mode 100644 index 0a10862171b..00000000000 --- a/lib/libc/arch/arm/net/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2004/02/01 05:40:52 drahn Exp $ -# $NetBSD: Makefile.inc,v 1.1 2000/12/29 20:13:53 bjh21 Exp $ - -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= diff --git a/lib/libc/arch/hppa/net/Makefile.inc b/lib/libc/arch/hppa/net/Makefile.inc deleted file mode 100644 index 597df911f24..00000000000 --- a/lib/libc/arch/hppa/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2004/10/26 04:49:58 mickey Exp $ - -SRCS+= ntohl.c ntohs.c htons.c htonl.c diff --git a/lib/libc/arch/i386/net/Makefile.inc b/lib/libc/arch/i386/net/Makefile.inc deleted file mode 100644 index 80584144bcc..00000000000 --- a/lib/libc/arch/i386/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.4 2012/09/04 03:10:42 okan Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/i386/net/htonl.S b/lib/libc/arch/i386/net/htonl.S deleted file mode 100644 index 02dee68072b..00000000000 --- a/lib/libc/arch/i386/net/htonl.S +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* netorder = htonl(hostorder) */ -ENTRY(htonl) - movl 4(%esp),%eax - rorw $8,%ax - roll $16,%eax - rorw $8,%ax - ret diff --git a/lib/libc/arch/i386/net/htons.S b/lib/libc/arch/i386/net/htons.S deleted file mode 100644 index 20c516253bf..00000000000 --- a/lib/libc/arch/i386/net/htons.S +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* netorder = htons(hostorder) */ -ENTRY(htons) - movzwl 4(%esp),%eax - rorw $8,%ax - ret diff --git a/lib/libc/arch/i386/net/ntohl.S b/lib/libc/arch/i386/net/ntohl.S deleted file mode 100644 index 7b5a45067d8..00000000000 --- a/lib/libc/arch/i386/net/ntohl.S +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* hostorder = ntohl(netorder) */ -ENTRY(ntohl) - movl 4(%esp),%eax - rorw $8,%ax - roll $16,%eax - rorw $8,%ax - ret diff --git a/lib/libc/arch/i386/net/ntohs.S b/lib/libc/arch/i386/net/ntohs.S deleted file mode 100644 index b6dd406b5f5..00000000000 --- a/lib/libc/arch/i386/net/ntohs.S +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* hostorder = ntohs(netorder) */ -ENTRY(ntohs) - movzwl 4(%esp),%eax - rorw $8,%ax - ret diff --git a/lib/libc/arch/m88k/net/Makefile.inc b/lib/libc/arch/m88k/net/Makefile.inc deleted file mode 100644 index dc2ddf344cc..00000000000 --- a/lib/libc/arch/m88k/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 1995/02/25 14:58:55 cgd Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/m88k/net/htonl.S b/lib/libc/arch/m88k/net/htonl.S deleted file mode 100644 index be6ca8d9d3a..00000000000 --- a/lib/libc/arch/m88k/net/htonl.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: htonl.S,v 1.7 2013/01/11 21:23:24 miod Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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" - -/* netorder = htonl(hostorder) */ - -ENTRY(htonl) - jmp %r1 -END(htonl) diff --git a/lib/libc/arch/m88k/net/htons.S b/lib/libc/arch/m88k/net/htons.S deleted file mode 100644 index 02bad3e12b2..00000000000 --- a/lib/libc/arch/m88k/net/htons.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: htons.S,v 1.7 2013/01/11 21:23:24 miod Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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" - -/* hostorder = htons(netorder) */ - -ENTRY(htons) - jmp.n %r1 - clr %r2,%r2,16<16> /* clear the top 16 bits */ -END(htons) diff --git a/lib/libc/arch/m88k/net/ntohl.S b/lib/libc/arch/m88k/net/ntohl.S deleted file mode 100644 index 0df158020bd..00000000000 --- a/lib/libc/arch/m88k/net/ntohl.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.7 2013/01/11 21:23:24 miod Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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" - -/* hostorder = ntohl(netorder) */ - -ENTRY(ntohl) - jmp %r1 -END(ntohl) diff --git a/lib/libc/arch/m88k/net/ntohs.S b/lib/libc/arch/m88k/net/ntohs.S deleted file mode 100644 index 63dd922e819..00000000000 --- a/lib/libc/arch/m88k/net/ntohs.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.7 2013/01/11 21:23:24 miod Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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" - -/* hostorder = ntohs(netorder) */ - -ENTRY(ntohs) - jmp.n %r1 - clr %r2,%r2,16<16> /* clear the top 16 bits */ -END(ntohs) diff --git a/lib/libc/arch/mips64/net/Makefile.inc b/lib/libc/arch/mips64/net/Makefile.inc deleted file mode 100644 index 6e3a837c949..00000000000 --- a/lib/libc/arch/mips64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.2 2012/09/04 03:10:42 okan Exp $ - -SRCS+= htonl.S htons.S diff --git a/lib/libc/arch/mips64/net/htonl.S b/lib/libc/arch/mips64/net/htonl.S deleted file mode 100644 index 22a1d35ca86..00000000000 --- a/lib/libc/arch/mips64/net/htonl.S +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* - * netorder = htonl(hostorder) - * hostorder = ntohl(netorder) - */ -ALEAF(ntohl) -NLEAF(htonl, 0) # a0 = 0x11223344, return 0x44332211 - .set reorder -#ifdef __MIPSEL__ - srl v1, a0, 24 # v1 = 0x00000011 - sll v0, a0, 24 # v0 = 0x44000000 - or v0, v0, v1 - and v1, a0, 0xff00 - sll v1, v1, 8 # v1 = 0x00330000 - or v0, v0, v1 - srl v1, a0, 8 - and v1, v1, 0xff00 # v1 = 0x00002200 - or v0, v0, v1 -#else -#ifdef __MIPSEB__ - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htonl) diff --git a/lib/libc/arch/mips64/net/htons.S b/lib/libc/arch/mips64/net/htons.S deleted file mode 100644 index c936aae0338..00000000000 --- a/lib/libc/arch/mips64/net/htons.S +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Ralph Campbell. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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 - -/* - * netorder = htons(hostorder) - * hostorder = ntohs(netorder) - */ -ALEAF(ntohs) -NLEAF(htons, 0) - .set reorder -#ifdef __MIPSEL__ - srl v0, a0, 8 - and v0, v0, 0xff - sll v1, a0, 8 - and v1, v1, 0xff00 - or v0, v0, v1 -#else -#ifdef __MIPSEB__ - move v0, a0 -#else - ERROR -#endif -#endif - j ra -END(htons) diff --git a/lib/libc/arch/powerpc/net/Makefile.inc b/lib/libc/arch/powerpc/net/Makefile.inc deleted file mode 100644 index 1b8cd45dafb..00000000000 --- a/lib/libc/arch/powerpc/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -SRCS += ntohl.c ntohs.c htons.c htonl.c diff --git a/lib/libc/arch/powerpc64/net/Makefile.inc b/lib/libc/arch/powerpc64/net/Makefile.inc deleted file mode 100644 index 1b8cd45dafb..00000000000 --- a/lib/libc/arch/powerpc64/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -SRCS += ntohl.c ntohs.c htons.c htonl.c diff --git a/lib/libc/arch/riscv64/net/Makefile.inc b/lib/libc/arch/riscv64/net/Makefile.inc deleted file mode 100644 index 1b8cd45dafb..00000000000 --- a/lib/libc/arch/riscv64/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -SRCS += ntohl.c ntohs.c htons.c htonl.c diff --git a/lib/libc/arch/sh/net/Makefile.inc b/lib/libc/arch/sh/net/Makefile.inc deleted file mode 100644 index 13bfad7c42f..00000000000 --- a/lib/libc/arch/sh/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1.1.1 2006/10/10 22:07:10 miod Exp $ -# $NetBSD: Makefile.inc,v 1.1 2000/01/05 14:07:36 msaitoh Exp $ - -SRCS+= htonl.c htons.c ntohl.c ntohs.c diff --git a/lib/libc/arch/sh/net/htonl.c b/lib/libc/arch/sh/net/htonl.c deleted file mode 100644 index a515606f67e..00000000000 --- a/lib/libc/arch/sh/net/htonl.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: htonl.c,v 1.2 2014/07/21 01:51:10 guenther Exp $ */ -/* $NetBSD: htonl.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)htonl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include - -#undef htonl - -/* hostorder = htonl(netorder) */ -u_int32_t -htonl(x) - u_int32_t x; -{ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int32_t y = 0; - - __asm("swap.b %1, %0" : "=r" (y) : "r" (x)); - __asm("swap.w %1, %0" : "=r" (y) : "r" (y)); - __asm("swap.b %1, %0" : "=r" (y) : "r" (y)); - return y; -#else - return x; -#endif -} diff --git a/lib/libc/arch/sh/net/htons.c b/lib/libc/arch/sh/net/htons.c deleted file mode 100644 index 1d7a7de297c..00000000000 --- a/lib/libc/arch/sh/net/htons.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: htons.c,v 1.2 2014/07/21 01:51:10 guenther Exp $ */ -/* $NetBSD: htons.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)htonl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include - -#undef htons - -/* netorder = htons(hostorder) */ -u_int16_t -htons(x) - u_int16_t x; -{ -#if BYTE_ORDER == LITTLE_ENDIAN - __asm("swap.b %1, %0" : "=r" (x) : "r" (x)); -#endif - return x; -} diff --git a/lib/libc/arch/sh/net/ntohl.c b/lib/libc/arch/sh/net/ntohl.c deleted file mode 100644 index 78ca2462f15..00000000000 --- a/lib/libc/arch/sh/net/ntohl.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: ntohl.c,v 1.2 2014/07/21 01:51:10 guenther Exp $ */ -/* $NetBSD: ntohl.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include - -#undef ntohl - -/* netorder = ntohl(hostorder) */ -u_int32_t -ntohl(x) - u_int32_t x; -{ -#if BYTE_ORDER == LITTLE_ENDIAN - u_int32_t y = 0; - - __asm("swap.b %1, %0" : "=r" (y) : "r" (x)); - __asm("swap.w %1, %0" : "=r" (y) : "r" (y)); - __asm("swap.b %1, %0" : "=r" (y) : "r" (y)); - return y; -#else - return x; -#endif -} diff --git a/lib/libc/arch/sh/net/ntohs.c b/lib/libc/arch/sh/net/ntohs.c deleted file mode 100644 index f57c8a90d57..00000000000 --- a/lib/libc/arch/sh/net/ntohs.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: ntohs.c,v 1.2 2014/07/21 01:51:10 guenther Exp $ */ -/* $NetBSD: ntohs.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include - -#undef ntohs - -/* hostorder = ntohs(netorder) */ -u_int16_t -ntohs(x) - u_int16_t x; -{ -#if BYTE_ORDER == LITTLE_ENDIAN - __asm("swap.b %1, %0" : "=r" (x) : "r" (x)); -#endif - return x; -} diff --git a/lib/libc/arch/sparc64/net/Makefile.inc b/lib/libc/arch/sparc64/net/Makefile.inc deleted file mode 100644 index c6229ffbd2c..00000000000 --- a/lib/libc/arch/sparc64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.1 2001/08/28 22:06:44 art Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/sparc64/net/htonl.S b/lib/libc/arch/sparc64/net/htonl.S deleted file mode 100644 index 10ffa2de22b..00000000000 --- a/lib/libc/arch/sparc64/net/htonl.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: htonl.S,v 1.2 2003/06/02 20:18:32 millert Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Header: htonl.s,v 1.1 92/06/25 12:47:05 torek Exp - */ - -#include - -/* netorder = htonl(hostorder) */ - - -ENTRY(htonl) - retl - srl %o0, 0, %o0 /* zero extend -- or do we sign extend? */ diff --git a/lib/libc/arch/sparc64/net/htons.S b/lib/libc/arch/sparc64/net/htons.S deleted file mode 100644 index 334f090418c..00000000000 --- a/lib/libc/arch/sparc64/net/htons.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: htons.S,v 1.2 2003/06/02 20:18:32 millert Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Header: htons.s,v 1.1 92/06/25 12:47:05 torek Exp - */ - -#include - -/* netorder = htons(hostorder) */ -ENTRY(htons) - sethi %hi(0xffff0000), %o1 - signx %o1, %o1 - retl - andn %o0, %o1, %o0 diff --git a/lib/libc/arch/sparc64/net/ntohl.S b/lib/libc/arch/sparc64/net/ntohl.S deleted file mode 100644 index 9bc42b4ac58..00000000000 --- a/lib/libc/arch/sparc64/net/ntohl.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: ntohl.S,v 1.2 2003/06/02 20:18:32 millert Exp $ */ -/* $NetBSD: ntohl.S,v 1.1 1998/09/11 04:56:31 eeh Exp $ */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Header: ntohl.s,v 1.1 92/06/25 12:47:06 torek Exp - */ - -#include - -/* hostorder = ntohl(netorder) */ -ENTRY(ntohl) - retl - signx %o0, %o0 diff --git a/lib/libc/arch/sparc64/net/ntohs.S b/lib/libc/arch/sparc64/net/ntohs.S deleted file mode 100644 index 7a9b18215d9..00000000000 --- a/lib/libc/arch/sparc64/net/ntohs.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: ntohs.S,v 1.3 2009/10/28 06:49:55 deraadt Exp $ */ -/* $NetBSD: ntohs.S,v 1.1 1998/09/11 04:56:31 eeh Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Header: ntohs.s,v 1.1 92/06/25 12:47:07 torek Exp - */ - -#include - -/* hostorder = ntohs(netorder) */ - -ENTRY(ntohs) - sethi %hi(0xffff0000), %o1 - signx %o1, %o1 - retl - andn %o0, %o1, %o0 - diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc index 41a3164d6a9..db2c75dad67 100644 --- a/lib/libc/net/Makefile.inc +++ b/lib/libc/net/Makefile.inc @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile.inc,v 1.60 2019/08/30 18:33:17 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.61 2024/04/15 14:30:48 naddy Exp $ # net sources -.PATH: ${LIBCSRCDIR}/arch/${MACHINE_CPU}/net ${LIBCSRCDIR}/net +.PATH: ${LIBCSRCDIR}/net CFLAGS+=-DRESOLVSORT @@ -10,10 +10,11 @@ SRCS+= base64.c ethers.c freeaddrinfo.c \ getifaddrs.c getnameinfo.c getnetent.c \ getnetnamadr.c getpeereid.c getproto.c getprotoent.c getprotoname.c \ getservbyname.c getservbyport.c getservent.c getrrsetbyname.c \ - herror.c if_indextoname.c if_nameindex.c if_nametoindex.c inet_addr.c \ + herror.c htonl.c htons.c \ + if_indextoname.c if_nameindex.c if_nametoindex.c inet_addr.c \ inet_lnaof.c inet_makeaddr.c inet_neta.c inet_netof.c inet_network.c \ inet_net_ntop.c inet_net_pton.c inet_ntoa.c inet_ntop.c inet_pton.c \ - linkaddr.c rcmd.c rcmdsh.c ruserok.c \ + linkaddr.c ntohl.c ntohs.c rcmd.c rcmdsh.c ruserok.c \ rresvport.c recv.c res_comp.c res_data.c \ res_debug.c res_debug_syms.c res_init.c res_mkquery.c res_query.c \ res_random.c res_send.c \ @@ -22,12 +23,6 @@ SRCS+= base64.c ethers.c freeaddrinfo.c \ # IPv6 SRCS+= ip6opt.c rthdr.c vars6.c -# machine-dependent net sources -# m-d Makefile.inc must include sources for: -# htonl() htons() ntohl() ntohs() - -.include "${LIBCSRCDIR}/arch/${MACHINE_CPU}/net/Makefile.inc" - MAN+= htobe64.3 ether_aton.3 gai_strerror.3 getaddrinfo.3 gethostbyname.3 \ getifaddrs.3 getnameinfo.3 getnetent.3 getpeereid.3 getprotoent.3 \ getrrsetbyname.3 getservent.3 htonl.3 if_indextoname.3 \ diff --git a/lib/libc/net/htonl.c b/lib/libc/net/htonl.c index 6ee6e7efbf3..58bfb4699a7 100644 --- a/lib/libc/net/htonl.c +++ b/lib/libc/net/htonl.c @@ -1,6 +1,5 @@ -/* $OpenBSD: htonl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: htonl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef htonl -u_int32_t -htonl(u_int32_t x) +uint32_t +htonl(uint32_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *)&x; - return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); -#else - return x; -#endif + return htobe32(x); } diff --git a/lib/libc/net/htons.c b/lib/libc/net/htons.c index f48d91ee035..28b13cef986 100644 --- a/lib/libc/net/htons.c +++ b/lib/libc/net/htons.c @@ -1,6 +1,5 @@ -/* $OpenBSD: htons.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: htons.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef htons -u_int16_t -htons(u_int16_t x) +uint16_t +htons(uint16_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *) &x; - return (u_int16_t)(s[0] << 8 | s[1]); -#else - return x; -#endif + return htobe16(x); } diff --git a/lib/libc/net/ntohl.c b/lib/libc/net/ntohl.c index 0d05bac78a1..7592398e8ca 100644 --- a/lib/libc/net/ntohl.c +++ b/lib/libc/net/ntohl.c @@ -1,6 +1,5 @@ -/* $OpenBSD: ntohl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: ntohl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef ntohl -u_int32_t -ntohl(u_int32_t x) +uint32_t +ntohl(uint32_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *)&x; - return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]); -#else - return x; -#endif + return be32toh(x); } diff --git a/lib/libc/net/ntohs.c b/lib/libc/net/ntohs.c index b5ea361f830..ef22ea30680 100644 --- a/lib/libc/net/ntohs.c +++ b/lib/libc/net/ntohs.c @@ -1,6 +1,5 @@ -/* $OpenBSD: ntohs.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */ +/* $OpenBSD: ntohs.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */ /* - * Written by J.T. Conklin . * Public domain. */ @@ -9,13 +8,8 @@ #undef ntohs -u_int16_t -ntohs(u_int16_t x) +uint16_t +ntohs(uint16_t x) { -#if BYTE_ORDER == LITTLE_ENDIAN - u_char *s = (u_char *) &x; - return (u_int16_t)(s[0] << 8 | s[1]); -#else - return x; -#endif + return be16toh(x); } -- 2.20.1