diff --git a/games/fortune/fortune/fortune.c b/games/fortune/fortune/fortune.c index 844892fa97b0..2cd7de79cfc3 100644 --- a/games/fortune/fortune/fortune.c +++ b/games/fortune/fortune/fortune.c @@ -48,9 +48,10 @@ static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ -# include # include +# include + # include # include # include diff --git a/games/fortune/strfile/strfile.c b/games/fortune/strfile/strfile.c index 607f572a0d8a..7dfd9cf21813 100644 --- a/games/fortune/strfile/strfile.c +++ b/games/fortune/strfile/strfile.c @@ -50,6 +50,7 @@ static const char rcsid[] = #endif /* not lint */ # include +# include # include # include # include diff --git a/games/fortune/unstr/unstr.c b/games/fortune/unstr/unstr.c index 8d4a57292372..2f5fff02a2ae 100644 --- a/games/fortune/unstr/unstr.c +++ b/games/fortune/unstr/unstr.c @@ -63,6 +63,7 @@ static const char rcsid[] = */ # include +# include # include # include # include diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 7ac95e59423c..3ac128d1ed9a 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -47,9 +47,7 @@ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. - */ - -/* + * * @(#)inet.h 8.1 (Berkeley) 6/2/93 * From: Id: inet.h,v 8.5 1997/01/29 08:48:09 vixie Exp $ * $FreeBSD$ @@ -63,6 +61,9 @@ #include #include +/* Required for byteorder(3) functions. */ +#include + #ifndef _IN_ADDR_T_DECLARED_ typedef __uint32_t in_addr_t; #define _IN_ADDR_T_DECLARED_ @@ -114,14 +115,23 @@ struct in_addr { #define inet_nsap_ntoa __inet_nsap_ntoa #endif /* !_POSIX_SOURCE */ +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif + __BEGIN_DECLS +__uint32_t htonl(__uint32_t); +__uint16_t htons(__uint16_t); in_addr_t inet_addr __P((const char *)); char *inet_ntoa __P((struct in_addr)); const char *inet_ntop __P((int, const void *, char *, socklen_t)); int inet_pton __P((int, const char *, void *)); -/* - * XXX missing: ntohl() family. - */ +__uint32_t ntohl(__uint32_t); +__uint16_t ntohs(__uint16_t); /* Nonstandard functions. */ #ifndef _POSIX_SOURCE diff --git a/include/rpc/xdr.h b/include/rpc/xdr.h index d38aa4989e6f..9867b252152b 100644 --- a/include/rpc/xdr.h +++ b/include/rpc/xdr.h @@ -261,13 +261,13 @@ struct xdr_discrim { * N.B. and frozen for all time: each data type here uses 4 bytes * of external representation. */ -#define IXDR_GET_INT32(buf) ((int32_t)ntohl((u_int32_t)*(buf)++)) -#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) +#define IXDR_GET_INT32(buf) ((int32_t)__ntohl((u_int32_t)*(buf)++)) +#define IXDR_PUT_INT32(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v)) #define IXDR_GET_U_INT32(buf) ((u_int32_t)IXDR_GET_INT32(buf)) #define IXDR_PUT_U_INT32(buf, v) IXDR_PUT_INT32((buf), ((int32_t)(v))) -#define IXDR_GET_LONG(buf) ((long)ntohl((u_int32_t)*(buf)++)) -#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)htonl((u_int32_t)v)) +#define IXDR_GET_LONG(buf) ((long)__ntohl((u_int32_t)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ =(int32_t)__htonl((u_int32_t)v)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) #define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) diff --git a/lib/libc/alpha/net/byte_swap_2.S b/lib/libc/alpha/net/byte_swap_2.S index fab3c58d8471..ebcbeda22f81 100644 --- a/lib/libc/alpha/net/byte_swap_2.S +++ b/lib/libc/alpha/net/byte_swap_2.S @@ -25,12 +25,14 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ #include -#ifndef NAME -#define NAME byte_swap_2 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -38,6 +40,7 @@ * * Argument is an unsigned 2-byte integer (u_int16_t). */ +XLEAF(ALIAS, 1) LEAF(NAME, 1) /* a0 contains 0x0123 */ extbl a0, 0, t0 /* t0 = 0x 23 */ extbl a0, 1, t1 /* t1 = 0x 01 */ diff --git a/lib/libc/alpha/net/byte_swap_4.S b/lib/libc/alpha/net/byte_swap_4.S index 8dbb83ca2484..ddfd1e9970c2 100644 --- a/lib/libc/alpha/net/byte_swap_4.S +++ b/lib/libc/alpha/net/byte_swap_4.S @@ -25,12 +25,14 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ #include -#ifndef NAME -#define NAME byte_swap_4 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -38,6 +40,7 @@ * * Argument is an unsigned 4-byte integer (u_int32_t). */ +XLEAF(ALIAS, 1) LEAF(NAME, 1) /* a0 contains 0x01234567 */ extbl a0, 0, t0 /* t0 = 0x 67 */ extbl a0, 1, t1 /* t1 = 0x 45 */ diff --git a/lib/libc/alpha/net/htonl.S b/lib/libc/alpha/net/htonl.S index bacab1ede388..90d94415d58e 100644 --- a/lib/libc/alpha/net/htonl.S +++ b/lib/libc/alpha/net/htonl.S @@ -25,8 +25,11 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ -#define NAME htonl +#define ALIAS htonl +#define NAME __htonl #include "byte_swap_4.S" diff --git a/lib/libc/alpha/net/htons.S b/lib/libc/alpha/net/htons.S index fb082223a9d1..405d5378a23e 100644 --- a/lib/libc/alpha/net/htons.S +++ b/lib/libc/alpha/net/htons.S @@ -25,8 +25,11 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ -#define NAME htons +#define ALIAS htons +#define NAME __htons #include "byte_swap_2.S" diff --git a/lib/libc/alpha/net/ntohl.S b/lib/libc/alpha/net/ntohl.S index b571647342f7..54ea68dba613 100644 --- a/lib/libc/alpha/net/ntohl.S +++ b/lib/libc/alpha/net/ntohl.S @@ -25,8 +25,11 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ -#define NAME ntohl +#define ALIAS ntohl +#define NAME __ntohl #include "byte_swap_4.S" diff --git a/lib/libc/alpha/net/ntohs.S b/lib/libc/alpha/net/ntohs.S index 6db996176806..f841a7a8b4a3 100644 --- a/lib/libc/alpha/net/ntohs.S +++ b/lib/libc/alpha/net/ntohs.S @@ -25,8 +25,11 @@ * * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. + * + * $FreeBSD$ */ -#define NAME ntohs +#define ALIAS ntohs +#define NAME __ntohs #include "byte_swap_2.S" diff --git a/lib/libc/amd64/net/htonl.S b/lib/libc/amd64/net/htonl.S index af3354f54795..6658b69025a6 100644 --- a/lib/libc/amd64/net/htonl.S +++ b/lib/libc/amd64/net/htonl.S @@ -43,7 +43,9 @@ #include -ENTRY(htonl) + .weak CNAME(htonl) + .set CNAME(htonl),CNAME(__htonl) +ENTRY(__htonl) movl 4(%esp),%eax xchgb %al,%ah roll $16,%eax diff --git a/lib/libc/amd64/net/htons.S b/lib/libc/amd64/net/htons.S index c78b1088b42a..c354eaa0c94e 100644 --- a/lib/libc/amd64/net/htons.S +++ b/lib/libc/amd64/net/htons.S @@ -43,7 +43,9 @@ #include -ENTRY(htons) + .weak CNAME(htons) + .set CNAME(htons),CNAME(__htons) +ENTRY(__htons) movzwl 4(%esp),%eax xchgb %al,%ah ret diff --git a/lib/libc/amd64/net/ntohl.S b/lib/libc/amd64/net/ntohl.S index 3a2c2025c84d..46ff54e32202 100644 --- a/lib/libc/amd64/net/ntohl.S +++ b/lib/libc/amd64/net/ntohl.S @@ -43,7 +43,9 @@ #include -ENTRY(ntohl) + .weak CNAME(ntohl) + .set CNAME(ntohl),CNAME(__ntohl) +ENTRY(__ntohl) movl 4(%esp),%eax xchgb %al,%ah roll $16,%eax diff --git a/lib/libc/amd64/net/ntohs.S b/lib/libc/amd64/net/ntohs.S index 110faf7b6d77..3f0a36ab6ea2 100644 --- a/lib/libc/amd64/net/ntohs.S +++ b/lib/libc/amd64/net/ntohs.S @@ -43,7 +43,9 @@ #include -ENTRY(ntohs) + .weak CNAME(ntohs) + .set CNAME(ntohs),CNAME(__ntohs) +ENTRY(__ntohs) movzwl 4(%esp),%eax xchgb %al,%ah ret diff --git a/lib/libc/i386/net/htonl.S b/lib/libc/i386/net/htonl.S index af3354f54795..6658b69025a6 100644 --- a/lib/libc/i386/net/htonl.S +++ b/lib/libc/i386/net/htonl.S @@ -43,7 +43,9 @@ #include -ENTRY(htonl) + .weak CNAME(htonl) + .set CNAME(htonl),CNAME(__htonl) +ENTRY(__htonl) movl 4(%esp),%eax xchgb %al,%ah roll $16,%eax diff --git a/lib/libc/i386/net/htons.S b/lib/libc/i386/net/htons.S index c78b1088b42a..c354eaa0c94e 100644 --- a/lib/libc/i386/net/htons.S +++ b/lib/libc/i386/net/htons.S @@ -43,7 +43,9 @@ #include -ENTRY(htons) + .weak CNAME(htons) + .set CNAME(htons),CNAME(__htons) +ENTRY(__htons) movzwl 4(%esp),%eax xchgb %al,%ah ret diff --git a/lib/libc/i386/net/ntohl.S b/lib/libc/i386/net/ntohl.S index 3a2c2025c84d..46ff54e32202 100644 --- a/lib/libc/i386/net/ntohl.S +++ b/lib/libc/i386/net/ntohl.S @@ -43,7 +43,9 @@ #include -ENTRY(ntohl) + .weak CNAME(ntohl) + .set CNAME(ntohl),CNAME(__ntohl) +ENTRY(__ntohl) movl 4(%esp),%eax xchgb %al,%ah roll $16,%eax diff --git a/lib/libc/i386/net/ntohs.S b/lib/libc/i386/net/ntohs.S index 110faf7b6d77..3f0a36ab6ea2 100644 --- a/lib/libc/i386/net/ntohs.S +++ b/lib/libc/i386/net/ntohs.S @@ -43,7 +43,9 @@ #include -ENTRY(ntohs) + .weak CNAME(ntohs) + .set CNAME(ntohs),CNAME(__ntohs) +ENTRY(__ntohs) movzwl 4(%esp),%eax xchgb %al,%ah ret diff --git a/lib/libc/ia64/net/byte_swap_2.S b/lib/libc/ia64/net/byte_swap_2.S index fbee3c862515..19d0eefbec8f 100644 --- a/lib/libc/ia64/net/byte_swap_2.S +++ b/lib/libc/ia64/net/byte_swap_2.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_2 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 2-byte integer (u_int16_t). */ +WEAK_ALIAS(ALIAS, NAME) ENTRY(NAME, 1) mux1 r16=in0,@rev ;; diff --git a/lib/libc/ia64/net/byte_swap_4.S b/lib/libc/ia64/net/byte_swap_4.S index d1836442c287..71019ba4c4c8 100644 --- a/lib/libc/ia64/net/byte_swap_4.S +++ b/lib/libc/ia64/net/byte_swap_4.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_4 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 4-byte integer (u_int32_t). */ +WEAK_ALIAS(ALIAS, NAME) ENTRY(NAME, 1) mux1 r16=in0,@rev ;; diff --git a/lib/libc/ia64/net/htonl.S b/lib/libc/ia64/net/htonl.S index 20d86afe399a..7a71a29d90ee 100644 --- a/lib/libc/ia64/net/htonl.S +++ b/lib/libc/ia64/net/htonl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htonl +#define ALIAS htonl +#define NAME __htonl #include "byte_swap_4.S" diff --git a/lib/libc/ia64/net/htons.S b/lib/libc/ia64/net/htons.S index 5082d882eaf8..689b367938ee 100644 --- a/lib/libc/ia64/net/htons.S +++ b/lib/libc/ia64/net/htons.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htons +#define ALIAS htons +#define NAME __htons #include "byte_swap_2.S" diff --git a/lib/libc/ia64/net/ntohl.S b/lib/libc/ia64/net/ntohl.S index 54299c4aae7f..9e2c612d618c 100644 --- a/lib/libc/ia64/net/ntohl.S +++ b/lib/libc/ia64/net/ntohl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohl +#define ALIAS ntohl +#define NAME __ntohl #include "byte_swap_4.S" diff --git a/lib/libc/ia64/net/ntohs.S b/lib/libc/ia64/net/ntohs.S index 1eec14b543aa..16a884b924bf 100644 --- a/lib/libc/ia64/net/ntohs.S +++ b/lib/libc/ia64/net/ntohs.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohs +#define ALIAS ntohs +#define NAME __ntohs #include "byte_swap_2.S" diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c index f0a54907c917..a6b890d3df97 100644 --- a/lib/libc/locale/rune.c +++ b/lib/libc/locale/rune.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include "namespace.h" +#include #include #include #include diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index cd4449fbb86f..5ffb6d26e17c 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -31,12 +31,18 @@ * SUCH DAMAGE. */ +#if 0 #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#endif 0 + +#include +__FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libc/net/ns_addr.c b/lib/libc/net/ns_addr.c index 75449ed98b94..e00f20d2086b 100644 --- a/lib/libc/net/ns_addr.c +++ b/lib/libc/net/ns_addr.c @@ -41,6 +41,7 @@ static char sccsid[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93"; #endif /* LIBC_SCCS and not lint */ #include +#include #include #include #include diff --git a/lib/libc/net/ns_ntoa.c b/lib/libc/net/ns_ntoa.c index de5f30588710..6ba2caf41197 100644 --- a/lib/libc/net/ns_ntoa.c +++ b/lib/libc/net/ns_ntoa.c @@ -31,11 +31,17 @@ * SUCH DAMAGE. */ +#if 0 #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ +#endif + +#include +__FBSDID("$FreeBSD$"); #include +#include #include #include diff --git a/lib/libc/rpc/auth_des.c b/lib/libc/rpc/auth_des.c index e7aef6419504..6a7da3a05036 100644 --- a/lib/libc/rpc/auth_des.c +++ b/lib/libc/rpc/auth_des.c @@ -48,7 +48,6 @@ #include #include #include -#include /* XXX: just to get htonl() and ntohl() */ #include #undef NIS #include diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index 59869bf7271c..5ca88d3f88f7 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -52,6 +52,7 @@ static char sccsid[] = "@(#)clnt_dg.c 1.19 89/03/16 Copyr 1988 Sun Micro"; #include #include #include +#include #include #include #include diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index d2d01785cb46..b96822efe9c5 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -65,6 +65,7 @@ static char sccsid[] = "@(#)clnt_vc.c 1.19 89/03/16 Copyr 1988 Sun Micro"; #include #include +#include #include #include #include diff --git a/lib/libc/rpc/pmap_getmaps.c b/lib/libc/rpc/pmap_getmaps.c index 4c8397f412d4..3fdc44ff01b0 100644 --- a/lib/libc/rpc/pmap_getmaps.c +++ b/lib/libc/rpc/pmap_getmaps.c @@ -49,6 +49,7 @@ static char *rcsid = "$FreeBSD$"; #include #include +#include #include #include diff --git a/lib/libc/rpc/pmap_getport.c b/lib/libc/rpc/pmap_getport.c index ff75c9ff1d62..02946d32a50e 100644 --- a/lib/libc/rpc/pmap_getport.c +++ b/lib/libc/rpc/pmap_getport.c @@ -47,6 +47,7 @@ static char *rcsid = "$FreeBSD$"; #include #include +#include #include #include diff --git a/lib/libc/sparc64/net/htonl.S b/lib/libc/sparc64/net/htonl.S index c47961529397..c3d10e5997c2 100644 --- a/lib/libc/sparc64/net/htonl.S +++ b/lib/libc/sparc64/net/htonl.S @@ -53,7 +53,9 @@ #endif /* SYSLIBC_RCS and not lint */ /* netorder = htonl(hostorder) */ -ENTRY(htonl) + .weak CNAME(htonl) + .set CNAME(htonl),CNAME(__htonl) +ENTRY(__htonl) retl srl %o0, 0, %o0 /* zero extend -- or do we sign extend? */ -END(htonl) +END(__htonl) diff --git a/lib/libc/sparc64/net/htons.S b/lib/libc/sparc64/net/htons.S index 70cd0cce87f5..6f1fa7070b32 100644 --- a/lib/libc/sparc64/net/htons.S +++ b/lib/libc/sparc64/net/htons.S @@ -53,9 +53,11 @@ #endif /* SYSLIBC_RCS and not lint */ /* netorder = htons(hostorder) */ -ENTRY(htons) + .weak CNAME(htons) + .set CNAME(htons),CNAME(__htons) +ENTRY(__htons) sethi %hi(0xffff0000), %o1 signx %o1, %o1 retl andn %o0, %o1, %o0 -END(htons) +END(__htons) diff --git a/lib/libc/sparc64/net/ntohl.S b/lib/libc/sparc64/net/ntohl.S index 3ed47ee66222..4a546913536d 100644 --- a/lib/libc/sparc64/net/ntohl.S +++ b/lib/libc/sparc64/net/ntohl.S @@ -53,7 +53,9 @@ #endif /* SYSLIBC_RCS and not lint */ /* hostorder = ntohl(netorder) */ -ENTRY(ntohl) + .weak CNAME(ntohl) + .set CNAME(ntohl),CNAME(__ntohl) +ENTRY(__ntohl) retl signx %o0, %o0 -END(ntohl) +END(__ntohl) diff --git a/lib/libc/sparc64/net/ntohs.S b/lib/libc/sparc64/net/ntohs.S index f3a5e19e3f46..1b144a90affb 100644 --- a/lib/libc/sparc64/net/ntohs.S +++ b/lib/libc/sparc64/net/ntohs.S @@ -53,9 +53,11 @@ #endif /* SYSLIBC_RCS and not lint */ /* hostorder = ntohs(netorder) */ -ENTRY(ntohs) + .weak CNAME(ntohs) + .set CNAME(ntohs),CNAME(__ntohs) +ENTRY(__ntohs) sethi %hi(0xffff0000), %o1 signx %o1, %o1 retl andn %o0, %o1, %o0 -END(ntohs) +END(__ntohs) diff --git a/lib/libc/xdr/xdr_stdio.c b/lib/libc/xdr/xdr_stdio.c index c4328ec181a8..e49cb44a37f5 100644 --- a/lib/libc/xdr/xdr_stdio.c +++ b/lib/libc/xdr/xdr_stdio.c @@ -49,6 +49,7 @@ static char *rcsid = "$FreeBSD$"; #include "namespace.h" #include +#include #include #include #include "un-namespace.h" diff --git a/lib/libc/yp/yplib.c b/lib/libc/yp/yplib.c index 0a4bc7e09a70..9f9ffbac096a 100644 --- a/lib/libc/yp/yplib.c +++ b/lib/libc/yp/yplib.c @@ -38,6 +38,7 @@ static char *rcsid = "$FreeBSD$"; #include #include #include +#include #include #include #include diff --git a/lib/libipx/ipx_addr.c b/lib/libipx/ipx_addr.c index 051d28b4dc95..7a4c6b8afe7d 100644 --- a/lib/libipx/ipx_addr.c +++ b/lib/libipx/ipx_addr.c @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)ipx_addr.c"; #endif /* LIBC_SCCS and not lint */ #include +#include #include #include #include diff --git a/lib/libipx/ipx_ntoa.c b/lib/libipx/ipx_ntoa.c index b73d72cbc3b0..437a2b30c27e 100644 --- a/lib/libipx/ipx_ntoa.c +++ b/lib/libipx/ipx_ntoa.c @@ -39,6 +39,7 @@ static char sccsid[] = "@(#)ipx_ntoa.c"; #endif /* LIBC_SCCS and not lint */ #include +#include #include #include diff --git a/lib/libncp/ipx.c b/lib/libncp/ipx.c index b55b58b41f81..9f0a21e16212 100644 --- a/lib/libncp/ipx.c +++ b/lib/libncp/ipx.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libncp/ncpl_bind.c b/lib/libncp/ncpl_bind.c index e7bbb1cd8c49..ab591eb44fc9 100644 --- a/lib/libncp/ncpl_bind.c +++ b/lib/libncp/ncpl_bind.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include diff --git a/lib/libncp/ncpl_file.c b/lib/libncp/ncpl_file.c index 4f611c5c9010..2ffcc466a6ec 100644 --- a/lib/libncp/ncpl_file.c +++ b/lib/libncp/ncpl_file.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libncp/ncpl_misc.c b/lib/libncp/ncpl_misc.c index c145fda71437..16a54c5db15b 100644 --- a/lib/libncp/ncpl_misc.c +++ b/lib/libncp/ncpl_misc.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libncp/ncpl_rpc.c b/lib/libncp/ncpl_rpc.c index 1299ac9ad356..f2240e3b1301 100644 --- a/lib/libncp/ncpl_rpc.c +++ b/lib/libncp/ncpl_rpc.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include diff --git a/lib/libncp/sap.c b/lib/libncp/sap.c index b9f95a9606bf..a0c7d0cf205b 100644 --- a/lib/libncp/sap.c +++ b/lib/libncp/sap.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/lib/libstand/net.c b/lib/libstand/net.c index 6ac0de818984..06d9dbf56baa 100644 --- a/lib/libstand/net.c +++ b/lib/libstand/net.c @@ -231,7 +231,7 @@ intoa(addr) register int n; static char buf[17]; /* strlen(".255.255.255.255") + 1 */ - NTOHL(addr); + addr = ntohl(addr); cp = &buf[sizeof buf]; *--cp = '\0'; diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h index b9e31ad1626c..e3570f9a9ee4 100644 --- a/lib/libstand/stand.h +++ b/lib/libstand/stand.h @@ -371,6 +371,19 @@ extern void panic(const char *, ...) __dead2; extern struct fs_ops *file_system[]; extern struct devsw *devsw[]; +/* + * Expose byteorder(3) functions. + */ +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) + +extern uint32_t htonl(uint32_t); +extern uint16_t htons(uint16_t); +extern uint32_t ntohl(uint32_t); +extern uint16_t ntohs(uint16_t); + #if 0 static inline void * diff --git a/libexec/rpc.rwalld/rwalld.c b/libexec/rpc.rwalld/rwalld.c index d35240606ca9..9fa71b376452 100644 --- a/libexec/rpc.rwalld/rwalld.c +++ b/libexec/rpc.rwalld/rwalld.c @@ -39,6 +39,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include diff --git a/libexec/talkd/print.c b/libexec/talkd/print.c index 94b87b48f7f6..355910c2fe2d 100644 --- a/libexec/talkd/print.c +++ b/libexec/talkd/print.c @@ -43,6 +43,7 @@ static const char rcsid[] = #include #include +#include #include #include #include diff --git a/sbin/mount_cd9660/mount_cd9660.c b/sbin/mount_cd9660/mount_cd9660.c index 3ea3d39dd0d5..dff7ac84c6e0 100644 --- a/sbin/mount_cd9660/mount_cd9660.c +++ b/sbin/mount_cd9660/mount_cd9660.c @@ -58,6 +58,8 @@ static const char rcsid[] = #include #include +#include + #include #include #include diff --git a/sbin/routed/if.c b/sbin/routed/if.c index b439767cc506..55da15fd03fb 100644 --- a/sbin/routed/if.c +++ b/sbin/routed/if.c @@ -284,7 +284,7 @@ iflookup(naddr addr) naddr /* host byte order */ std_mask(naddr addr) /* network byte order */ { - NTOHL(addr); /* was a host, not a network */ + addr = ntohl(addr); /* was a host, not a network */ if (addr == 0) /* default route has mask 0 */ return 0; @@ -372,7 +372,7 @@ ripv1_mask_host(naddr addr, /* in network byte order */ int /* 0=bad */ check_dst(naddr addr) { - NTOHL(addr); + addr = ntohl(addr); if (IN_CLASSA(addr)) { if (addr == 0) diff --git a/sbin/routed/input.c b/sbin/routed/input.c index dd94fd6fd2c1..6d258f1e78d8 100644 --- a/sbin/routed/input.c +++ b/sbin/routed/input.c @@ -277,7 +277,7 @@ input(struct sockaddr_in *from, /* received from this IP address */ clr_ws_buf(&v12buf, ap); do { - NTOHL(n->n_metric); + n->n_metric = ntohl(n->n_metric); /* A single entry with family RIP_AF_UNSPEC and * metric HOPCNT_INFINITY means "all routes". @@ -413,7 +413,7 @@ input(struct sockaddr_in *from, /* received from this IP address */ v12buf.n->n_nhop = rt->rt_gate; } } - HTONL(v12buf.n->n_metric); + v12buf.n->n_metric = htonl(v12buf.n->n_metric); /* Stop paying attention if we fill the output buffer. */ @@ -582,7 +582,7 @@ input(struct sockaddr_in *from, /* received from this IP address */ if (n->n_family == RIP_AF_AUTH) continue; - NTOHL(n->n_metric); + n->n_metric = ntohl(n->n_metric); dst = n->n_dst; if (n->n_family != RIP_AF_INET && (n->n_family != RIP_AF_UNSPEC diff --git a/sbin/routed/output.c b/sbin/routed/output.c index 013edd2ab70b..0077ba01c28a 100644 --- a/sbin/routed/output.c +++ b/sbin/routed/output.c @@ -419,7 +419,7 @@ supply_out(struct ag_info *ag) wb->n->n_metric = ((stopint || ag->ag_metric < 1) ? HOPCNT_INFINITY : ag->ag_metric); - HTONL(wb->n->n_metric); + wb->n->n_metric = htonl(wb->n->n_metric); /* Any non-zero bits in the supposedly unused RIPv1 fields * cause the old `routed` to ignore the route. * That means the mask and so forth cannot be sent diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c index 057dae969ef6..3e1b0abb50a8 100644 --- a/sbin/routed/parms.c +++ b/sbin/routed/parms.c @@ -249,7 +249,8 @@ gwkludge(void) dname, lptr); continue; } - HTONL(dst); /* make network # into IP address */ + /* Turn network # into IP address. */ + dst = htonl(dst); } else { msglog("bad \"%s\" in "_PATH_GATEWAYS " entry \"%s\"", net_host, lptr); @@ -612,7 +613,7 @@ parse_parms(char *line, free(intnetp); return bad_str(line); } - HTONL(intnetp->intnet_addr); + intnetp->intnet_addr = htonl(intnetp->intnet_addr); intnetp->intnet_next = intnets; intnets = intnetp; return 0; @@ -945,7 +946,7 @@ getnet(char *name, if (0 == (in.s_addr & 0xff000000)) in.s_addr <<= 8; } else if (inet_aton(name, &in) == 1) { - NTOHL(in.s_addr); + in.s_addr = ntohl(in.s_addr); } else if (!mname && !strcasecmp(name,"default")) { in.s_addr = RIP_DEFAULT; } else { diff --git a/sbin/routed/rtquery/rtquery.c b/sbin/routed/rtquery/rtquery.c index 1441699f1aea..a41c0fd9b0b1 100644 --- a/sbin/routed/rtquery/rtquery.c +++ b/sbin/routed/rtquery/rtquery.c @@ -782,7 +782,7 @@ rip_input(struct sockaddr_in *from, static u_int std_mask(u_int addr) /* in network order */ { - NTOHL(addr); /* was a host, not a network */ + addr = ntohl(addr); /* was a host, not a network */ if (addr == 0) /* default route has mask 0 */ return 0; @@ -825,7 +825,7 @@ getnet(char *name, if (nentp != 0) { in.s_addr = nentp->n_net; } else if (inet_aton(name, &in) == 1) { - NTOHL(in.s_addr); + in.s_addr = ntohl(in.s_addr); } else { return 0; } diff --git a/sbin/routed/table.c b/sbin/routed/table.c index acfc76fcd554..a8ea949e20b9 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -298,7 +298,7 @@ ag_check(naddr dst, naddr xaddr; int x; - NTOHL(dst); + dst = ntohl(dst); /* Punt non-contiguous subnet masks. * diff --git a/secure/lib/libcipher/crypt.c b/secure/lib/libcipher/crypt.c index 4798371b251a..baf09e2b88fb 100644 --- a/secure/lib/libcipher/crypt.c +++ b/secure/lib/libcipher/crypt.c @@ -53,6 +53,7 @@ */ #include #include +#include #include #ifdef DEBUG diff --git a/secure/lib/libcrypt/crypt-des.c b/secure/lib/libcrypt/crypt-des.c index 5538cc84664d..2e86eac43a36 100644 --- a/secure/lib/libcrypt/crypt-des.c +++ b/secure/lib/libcrypt/crypt-des.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include "crypt.h" diff --git a/sys/alpha/include/endian.h b/sys/alpha/include/endian.h index 0ba53cd0e986..d9e64c8dee37 100644 --- a/sys/alpha/include/endian.h +++ b/sys/alpha/include/endian.h @@ -1,7 +1,4 @@ -/* $FreeBSD$ */ -/* From: NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp */ - -/* +/*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -34,10 +31,14 @@ * SUCH DAMAGE. * * @(#)endian.h 8.1 (Berkeley) 6/10/93 + * $NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp $ + * $FreeBSD$ */ -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include /* * Define the order of 32-bit words in 64-bit words. @@ -45,52 +46,16 @@ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 -#ifndef _POSIX_SOURCE /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER LITTLE_ENDIAN - -#ifndef _KERNEL -#include -#endif -#include - -__BEGIN_DECLS -__uint32_t htonl __P((__uint32_t)); -__uint16_t htons __P((__uint16_t)); -__uint32_t ntohl __P((__uint32_t)); -__uint16_t ntohs __P((__uint16_t)); -__uint16_t bswap16 __P((__uint16_t)); -__uint32_t bswap32 __P((__uint32_t)); -__uint64_t bswap64 __P((__uint64_t)); -__END_DECLS - -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else - -#define NTOHL(x) (x) = ntohl((__uint32_t)x) -#define NTOHS(x) (x) = ntohs((__uint16_t)x) -#define HTONL(x) (x) = htonl((__uint32_t)x) -#define HTONS(x) (x) = htons((__uint16_t)x) -#endif #endif /* !_POSIX_SOURCE */ -#endif /* !_ENDIAN_H_ */ + +#endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 7ac3195351ac..550ef41fa843 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -1991,7 +1991,7 @@ cdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td) bcd2bin(th->starting_track); th->ending_track = bcd2bin(th->ending_track); } - NTOHS(th->len); + th->len = ntohs(th->len); bcopy(th, addr, sizeof(*th)); free(th, M_TEMP); } diff --git a/sys/i386/include/endian.h b/sys/i386/include/endian.h index be87af2f7c5d..f22988baf031 100644 --- a/sys/i386/include/endian.h +++ b/sys/i386/include/endian.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 1987, 1991 Regents of the University of California. * All rights reserved. * @@ -30,55 +30,37 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)endian.h 7.8 (Berkeley) 4/3/91 + * @(#)endian.h 7.8 (Berkeley) 4/3/91 * $FreeBSD$ */ #ifndef _MACHINE_ENDIAN_H_ #define _MACHINE_ENDIAN_H_ +#include + /* * Define the order of 32-bit words in 64-bit words. */ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 -#ifndef _POSIX_SOURCE - /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER LITTLE_ENDIAN - -#ifndef _KERNEL -#include -#endif -#include - -__BEGIN_DECLS -__uint32_t htonl(__uint32_t); -__uint16_t htons(__uint16_t); -__uint32_t ntohl(__uint32_t); -__uint16_t ntohs(__uint16_t); -__END_DECLS +#endif /* ! _POSIX_SOURCE */ #ifdef __GNUC__ static __inline __uint32_t -__uint16_swap_uint32(__uint32_t __x) -{ - __asm ("rorl $16, %0" : "+r" (__x)); - - return __x; -} - -static __inline __uint32_t -__uint8_swap_uint32(__uint32_t __x) +__htonl(__uint32_t __x) { #if defined(_KERNEL) && (defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU)) && !defined(I386_CPU) __asm ("bswap %0" : "+r" (__x)); @@ -92,29 +74,27 @@ __uint8_swap_uint32(__uint32_t __x) } static __inline __uint16_t -__uint8_swap_uint16(__uint16_t __x) +__htons(__uint16_t __x) { __asm ("xchgb %h0, %b0" : "+q" (__x)); return __x; } -/* - * Macros for network/external number representation conversion. - */ -#define ntohl __uint8_swap_uint32 -#define ntohs __uint8_swap_uint16 -#define htonl __uint8_swap_uint32 -#define htons __uint8_swap_uint16 +static __inline __uint32_t +__ntohl(__uint32_t __x) +{ -#endif /* __GNUC__ */ + return (__htonl(__x)); +} -#define NTOHL(x) ((x) = ntohl(x)) -#define NTOHS(x) ((x) = ntohs(x)) -#define HTONL(x) ((x) = htonl(x)) -#define HTONS(x) ((x) = htons(x)) +static __inline __uint16_t +__ntohs(__uint16_t __x) +{ + return (__htons(__x)); +} -#endif /* ! _POSIX_SOURCE */ +#endif /* __GNUC__ */ #endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/ia64/include/endian.h b/sys/ia64/include/endian.h index b4b5a0be3bf5..bfc2381ac686 100644 --- a/sys/ia64/include/endian.h +++ b/sys/ia64/include/endian.h @@ -1,7 +1,4 @@ -/* $FreeBSD$ */ -/* From: NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp */ - -/* +/*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -34,10 +31,14 @@ * SUCH DAMAGE. * * @(#)endian.h 8.1 (Berkeley) 6/10/93 + * $NetBSD: endian.h,v 1.5 1997/10/09 15:42:19 bouyer Exp $ + * $FreeBSD$ */ -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include /* * Define the order of 32-bit words in 64-bit words. @@ -45,44 +46,17 @@ #define _QUAD_HIGHWORD 1 #define _QUAD_LOWWORD 0 -#ifndef _POSIX_SOURCE /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER LITTLE_ENDIAN - -#ifndef _KERNEL -#include -#endif -#include - -__BEGIN_DECLS -__uint32_t htonl __P((__uint32_t)); -__uint16_t htons __P((__uint16_t)); -__uint32_t ntohl __P((__uint32_t)); -__uint16_t ntohs __P((__uint16_t)); -__END_DECLS - -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else +#endif /* !_POSIX_SOURCE */ #ifdef __GNUC__ @@ -96,31 +70,33 @@ __uint8_swap_uint64(__uint64_t __x) } static __inline __uint32_t -__uint8_swap_uint32(__uint32_t __x) +__htonl(__uint32_t __x) { - return __uint8_swap_uint64(__x) >> 32; + + return (__uint8_swap_uint64(__x) >> 32); } static __inline __uint16_t -__uint8_swap_uint16(__uint16_t __x) +__htons(__uint16_t __x) { - return __uint8_swap_uint64(__x) >> 48; + + return (__uint8_swap_uint64(__x) >> 48); } -/* - * Macros for network/external number representation conversion. - */ -#define ntohl __uint8_swap_uint32 -#define ntohs __uint8_swap_uint16 -#define htonl __uint8_swap_uint32 -#define htons __uint8_swap_uint16 +static __inline __uint32_t +__ntohl(__uint32_t __x) +{ -#endif /* __GNUC__ */ + return (__uint8_swap_uint64(__x) >> 32); +} -#define NTOHL(x) (x) = ntohl((__uint32_t)x) -#define NTOHS(x) (x) = ntohs((__uint16_t)x) -#define HTONL(x) (x) = htonl((__uint32_t)x) -#define HTONS(x) (x) = htons((__uint16_t)x) -#endif -#endif /* !_POSIX_SOURCE */ -#endif /* !_ENDIAN_H_ */ +static __inline __uint16_t +__ntohs(__uint16_t __x) +{ + + return (__uint8_swap_uint64(__x) >> 48); +} + +#endif /* __GNUC__ */ + +#endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/libkern/alpha/byte_swap_2.S b/sys/libkern/alpha/byte_swap_2.S index a9d70a968e44..8111918d9b4c 100644 --- a/sys/libkern/alpha/byte_swap_2.S +++ b/sys/libkern/alpha/byte_swap_2.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_2 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 2-byte integer (u_int16_t). */ +XLEAF(ALIAS, 1) LEAF(NAME, 1) /* a0 contains 0x0123 */ extbl a0, 0, t0 /* t0 = 0x 23 */ extbl a0, 1, t1 /* t1 = 0x 01 */ diff --git a/sys/libkern/alpha/byte_swap_4.S b/sys/libkern/alpha/byte_swap_4.S index 9f6df346f260..d31bbe8cd9a8 100644 --- a/sys/libkern/alpha/byte_swap_4.S +++ b/sys/libkern/alpha/byte_swap_4.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_4 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 4-byte integer (u_int32_t). */ +XLEAF(ALIAS, 1) LEAF(NAME, 1) /* a0 contains 0x01234567 */ extbl a0, 0, t0 /* t0 = 0x 67 */ extbl a0, 1, t1 /* t1 = 0x 45 */ diff --git a/sys/libkern/alpha/htonl.S b/sys/libkern/alpha/htonl.S index b5ebaa51d740..2604034b38d3 100644 --- a/sys/libkern/alpha/htonl.S +++ b/sys/libkern/alpha/htonl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htonl +#define ALIAS htonl +#define NAME __htonl #include diff --git a/sys/libkern/alpha/htons.S b/sys/libkern/alpha/htons.S index 9ffabf4a86f9..6b8ea164cba0 100644 --- a/sys/libkern/alpha/htons.S +++ b/sys/libkern/alpha/htons.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htons +#define ALIAS htons +#define NAME __htons #include diff --git a/sys/libkern/alpha/ntohl.S b/sys/libkern/alpha/ntohl.S index f86a4042b03e..590203af1ef8 100644 --- a/sys/libkern/alpha/ntohl.S +++ b/sys/libkern/alpha/ntohl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohl +#define ALIAS ntohl +#define NAME __ntohl #include diff --git a/sys/libkern/alpha/ntohs.S b/sys/libkern/alpha/ntohs.S index 496f75c78a6f..93068811e450 100644 --- a/sys/libkern/alpha/ntohs.S +++ b/sys/libkern/alpha/ntohs.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohs +#define ALIAS ntohs +#define NAME __ntohs #include diff --git a/sys/libkern/ia64/byte_swap_2.S b/sys/libkern/ia64/byte_swap_2.S index fbee3c862515..19d0eefbec8f 100644 --- a/sys/libkern/ia64/byte_swap_2.S +++ b/sys/libkern/ia64/byte_swap_2.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_2 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 2-byte integer (u_int16_t). */ +WEAK_ALIAS(ALIAS, NAME) ENTRY(NAME, 1) mux1 r16=in0,@rev ;; diff --git a/sys/libkern/ia64/byte_swap_4.S b/sys/libkern/ia64/byte_swap_4.S index d1836442c287..71019ba4c4c8 100644 --- a/sys/libkern/ia64/byte_swap_4.S +++ b/sys/libkern/ia64/byte_swap_4.S @@ -30,8 +30,8 @@ #include -#ifndef NAME -#define NAME byte_swap_4 +#if !defined(ALIAS) || !defined(NAME) +#error ALIAS or NAME not defined #endif /* @@ -39,6 +39,7 @@ * * Argument is an unsigned 4-byte integer (u_int32_t). */ +WEAK_ALIAS(ALIAS, NAME) ENTRY(NAME, 1) mux1 r16=in0,@rev ;; diff --git a/sys/libkern/ia64/htonl.S b/sys/libkern/ia64/htonl.S index 666f70288f9e..f0c89f4daea3 100644 --- a/sys/libkern/ia64/htonl.S +++ b/sys/libkern/ia64/htonl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htonl +#define ALIAS htonl +#define NAME __htonl #include diff --git a/sys/libkern/ia64/htons.S b/sys/libkern/ia64/htons.S index aaea4da97ed8..16a83d600bf2 100644 --- a/sys/libkern/ia64/htons.S +++ b/sys/libkern/ia64/htons.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME htons +#define ALIAS htons +#define NAME __htons #include diff --git a/sys/libkern/ia64/ntohl.S b/sys/libkern/ia64/ntohl.S index b3062229d598..2f2e7ba86211 100644 --- a/sys/libkern/ia64/ntohl.S +++ b/sys/libkern/ia64/ntohl.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohl +#define ALIAS ntohl +#define NAME __ntohl #include diff --git a/sys/libkern/ia64/ntohs.S b/sys/libkern/ia64/ntohs.S index ddd7344de523..051f10380e97 100644 --- a/sys/libkern/ia64/ntohs.S +++ b/sys/libkern/ia64/ntohs.S @@ -28,6 +28,7 @@ * rights to redistribute these changes. */ -#define NAME ntohs +#define ALIAS ntohs +#define NAME __ntohs #include diff --git a/sys/net/bridge.c b/sys/net/bridge.c index f05221ca9ae3..f3412b51b877 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -867,8 +867,8 @@ bdg_forward(struct mbuf *m0, struct ether_header *const eh, struct ifnet *dst) * here we assume the pkt is an IP one and the header is contiguous */ ip = mtod(m0, struct ip *); - NTOHS(ip->ip_len); - NTOHS(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); /* * The third parameter to the firewall code is the dst. interface. @@ -881,11 +881,11 @@ bdg_forward(struct mbuf *m0, struct ether_header *const eh, struct ifnet *dst) return m0 ; /* * If we get here, the firewall has passed the pkt, but the mbuf - * pointer might have changed. Restore ip and the fields NTOHS()'d. + * pointer might have changed. Restore ip and the fields ntohs()'d. */ ip = mtod(m0, struct ip *); - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); if (i == 0) /* a PASS rule. */ goto forward ; diff --git a/sys/netgraph/ng_mppc.c b/sys/netgraph/ng_mppc.c index 0ebd7d22e2f5..ec1428fa1e2f 100644 --- a/sys/netgraph/ng_mppc.c +++ b/sys/netgraph/ng_mppc.c @@ -574,7 +574,7 @@ ng_mppc_decompress(node_p node, struct mbuf *m, struct mbuf **resultp) if (m->m_pkthdr.len < MPPC_HDRLEN) return (EINVAL); m_copydata(m, 0, MPPC_HDRLEN, (caddr_t)&header); - NTOHS(header); + header = ntohs(header); cc = (header & MPPC_CCOUNT_MASK); /* Copy payload into a contiguous region of memory */ diff --git a/sys/netinet/in.h b/sys/netinet/in.h index cf72e57a6e98..cfd55ca7bf51 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -496,6 +496,23 @@ char *inet_ntoa_r __P((struct in_addr ina, char *buf)); /* in libkern */ #define sintosa(sin) ((struct sockaddr *)(sin)) #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) +#else /* !_KERNEL */ + +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) #endif +__BEGIN_DECLS +__uint32_t htonl __P((__uint32_t)); +__uint16_t htons __P((__uint16_t)); +__uint32_t ntohl __P((__uint32_t)); +__uint16_t ntohs __P((__uint16_t)); +__END_DECLS + +#endif /* _KERNEL */ + #endif diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 1341e18af98c..2fa823f627f9 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -291,8 +291,8 @@ div_output(so, m, addr, control) } /* Convert fields to host order for ip_output() */ - NTOHS(ip->ip_len); - NTOHS(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); /* Send packet to output processing */ ipstat.ips_rawout++; /* XXX */ diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index b17651228e7b..5c6e1555a9a8 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -1575,8 +1575,8 @@ ip_fw_chk(struct ip **pip, int hlen, ti.ti_i = *((struct ipovly *) ip); ti.ti_t = *tcp; bcopy(&ti, ip, sizeof(ti)); - NTOHL(tip->ti_seq); - NTOHL(tip->ti_ack); + tip->ti_seq = ntohl(tip->ti_seq); + tip->ti_ack = ntohl(tip->ti_ack); tip->ti_len = ip_len - hlen - (tip->ti_off << 2); if (tcp->th_flags & TH_ACK) { tcp_respond(NULL, (void *)ip, tcp, *m, diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index b1d37dcff6b2..e19c642c2ddb 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -193,8 +193,8 @@ icmp_error(n, type, code, dest, destifp) /* * Convert fields to network representation. */ - HTONS(nip->ip_len); - HTONS(nip->ip_off); + nip->ip_len = htons(nip->ip_len); + nip->ip_off = htons(nip->ip_off); /* * Now, copy old ip header (without options) @@ -363,7 +363,7 @@ icmp_input(m, off) icmpstat.icps_badlen++; goto freeit; } - NTOHS(icp->icmp_ip.ip_len); + icp->icmp_ip.ip_len = ntohs(icp->icmp_ip.ip_len); /* Discard ICMP's in response to multicast packets */ if (IN_MULTICAST(ntohl(icp->icmp_ip.ip_dst.s_addr))) goto badcode; diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 9a4c248193f7..e82e66fa0dea 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -369,12 +369,12 @@ ip_input(struct mbuf *m) /* * Convert fields to host representation. */ - NTOHS(ip->ip_len); + ip->ip_len = ntohs(ip->ip_len); if (ip->ip_len < hlen) { ipstat.ips_badlen++; goto bad; } - NTOHS(ip->ip_off); + ip->ip_off = ntohs(ip->ip_off); /* * Check that the amount of data in the buffers @@ -762,15 +762,15 @@ ip_input(struct mbuf *m) /* Restore original checksum before diverting packet */ if (divert_info != 0) { ip->ip_len += hlen; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (hlen == sizeof(struct ip)) ip->ip_sum = in_cksum_hdr(ip); else ip->ip_sum = in_cksum(m, hlen); - NTOHS(ip->ip_off); - NTOHS(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); ip->ip_len -= hlen; } #endif @@ -793,8 +793,8 @@ ip_input(struct mbuf *m) /* Restore packet header fields to original values */ ip->ip_len += hlen; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); /* Deliver packet to divert input routine */ ip_divert_cookie = divert_cookie; diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 956c46655e0a..54d5cd72f582 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -1661,8 +1661,8 @@ encap_send(ip, vifp, m) */ ip = (struct ip *)((caddr_t)ip_copy + sizeof(multicast_encap_iphdr)); --ip->ip_ttl; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; mb_copy->m_data += sizeof(multicast_encap_iphdr); ip->ip_sum = in_cksum(mb_copy, ip->ip_hl << 2); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index aab04c935849..d6ee7614c2c1 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -513,8 +513,8 @@ ip_output(m0, opt, ro, flags, imo) m->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA; } - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); error = ipsec4_output(&state, sp, flags); @@ -573,8 +573,8 @@ ip_output(m0, opt, ro, flags, imo) } /* make it flipped, again. */ - NTOHS(ip->ip_len); - NTOHS(ip->ip_off); + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); skip_ipsec: #endif /*IPSEC*/ @@ -681,8 +681,8 @@ ip_output(m0, opt, ro, flags, imo) } /* Restore packet header fields to original values */ - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); /* Deliver packet to divert input routine */ ip_divert_cookie = divert_cookie; @@ -755,8 +755,8 @@ ip_output(m0, opt, ro, flags, imo) } m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED | CSUM_IP_VALID; - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip_input(m); goto done; } @@ -837,8 +837,8 @@ ip_output(m0, opt, ro, flags, imo) */ if ((u_short)ip->ip_len <= ifp->if_mtu || ifp->if_hwassist & CSUM_FRAGMENT) { - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (ip->ip_vhl == IP_VHL_BORING) { @@ -943,7 +943,7 @@ ip_output(m0, opt, ro, flags, imo) m->m_pkthdr.len = mhlen + len; m->m_pkthdr.rcvif = (struct ifnet *)0; m->m_pkthdr.csum_flags = m0->m_pkthdr.csum_flags; - HTONS(mhip->ip_off); + mhip->ip_off = htons(mhip->ip_off); mhip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (mhip->ip_vhl == IP_VHL_BORING) { @@ -972,7 +972,7 @@ ip_output(m0, opt, ro, flags, imo) m->m_pkthdr.len = hlen + firstlen; ip->ip_len = htons((u_short)m->m_pkthdr.len); ip->ip_off |= IP_MF; - HTONS(ip->ip_off); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (sw_csum & CSUM_DELAY_IP) { if (ip->ip_vhl == IP_VHL_BORING) { @@ -1950,8 +1950,8 @@ ip_mloopback(ifp, m, dst, hlen) * than the interface's MTU. Can this possibly matter? */ ip = mtod(copym, struct ip *); - HTONS(ip->ip_len); - HTONS(ip->ip_off); + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); ip->ip_sum = 0; if (ip->ip_vhl == IP_VHL_BORING) { ip->ip_sum = in_cksum_hdr(ip); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index d6a1760346f5..dc063289bcab 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -424,7 +424,7 @@ tcp_input(m, off0) len = sizeof (struct ip) + tlen; bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); ipov->ih_len = (u_short)tlen; - HTONS(ipov->ih_len); + ipov->ih_len = htons(ipov->ih_len); th->th_sum = in_cksum(m, len); } if (th->th_sum) { @@ -486,10 +486,10 @@ tcp_input(m, off0) /* * Convert TCP protocol specific fields to host format. */ - NTOHL(th->th_seq); - NTOHL(th->th_ack); - NTOHS(th->th_win); - NTOHS(th->th_urp); + th->th_seq = ntohl(th->th_seq); + th->th_ack = ntohl(th->th_ack); + th->th_win = ntohs(th->th_win); + th->th_urp = ntohs(th->th_urp); /* * Delay droping TCP, IP headers, IPv6 ext headers, and TCP options, @@ -2246,7 +2246,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_MSS; bcopy((char *)cp + 2, (char *)&to->to_mss, sizeof(to->to_mss)); - NTOHS(to->to_mss); + to->to_mss = ntohs(to->to_mss); break; case TCPOPT_WINDOW: if (optlen != TCPOLEN_WINDOW) @@ -2262,10 +2262,10 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_TS; bcopy((char *)cp + 2, (char *)&to->to_tsval, sizeof(to->to_tsval)); - NTOHL(to->to_tsval); + to->to_tsval = ntohl(to->to_tsval); bcopy((char *)cp + 6, (char *)&to->to_tsecr, sizeof(to->to_tsecr)); - NTOHL(to->to_tsecr); + to->to_tsecr = ntohl(to->to_tsecr); break; case TCPOPT_CC: if (optlen != TCPOLEN_CC) @@ -2273,7 +2273,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CC; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCNEW: if (optlen != TCPOLEN_CC) @@ -2283,7 +2283,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCNEW; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCECHO: if (optlen != TCPOLEN_CC) @@ -2293,7 +2293,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCECHO; bcopy((char *)cp + 2, (char *)&to->to_ccecho, sizeof(to->to_ccecho)); - NTOHL(to->to_ccecho); + to->to_ccecho = ntohl(to->to_ccecho); break; default: continue; diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index d6a1760346f5..dc063289bcab 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -424,7 +424,7 @@ tcp_input(m, off0) len = sizeof (struct ip) + tlen; bzero(ipov->ih_x1, sizeof(ipov->ih_x1)); ipov->ih_len = (u_short)tlen; - HTONS(ipov->ih_len); + ipov->ih_len = htons(ipov->ih_len); th->th_sum = in_cksum(m, len); } if (th->th_sum) { @@ -486,10 +486,10 @@ tcp_input(m, off0) /* * Convert TCP protocol specific fields to host format. */ - NTOHL(th->th_seq); - NTOHL(th->th_ack); - NTOHS(th->th_win); - NTOHS(th->th_urp); + th->th_seq = ntohl(th->th_seq); + th->th_ack = ntohl(th->th_ack); + th->th_win = ntohs(th->th_win); + th->th_urp = ntohs(th->th_urp); /* * Delay droping TCP, IP headers, IPv6 ext headers, and TCP options, @@ -2246,7 +2246,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_MSS; bcopy((char *)cp + 2, (char *)&to->to_mss, sizeof(to->to_mss)); - NTOHS(to->to_mss); + to->to_mss = ntohs(to->to_mss); break; case TCPOPT_WINDOW: if (optlen != TCPOLEN_WINDOW) @@ -2262,10 +2262,10 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_TS; bcopy((char *)cp + 2, (char *)&to->to_tsval, sizeof(to->to_tsval)); - NTOHL(to->to_tsval); + to->to_tsval = ntohl(to->to_tsval); bcopy((char *)cp + 6, (char *)&to->to_tsecr, sizeof(to->to_tsecr)); - NTOHL(to->to_tsecr); + to->to_tsecr = ntohl(to->to_tsecr); break; case TCPOPT_CC: if (optlen != TCPOLEN_CC) @@ -2273,7 +2273,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CC; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCNEW: if (optlen != TCPOLEN_CC) @@ -2283,7 +2283,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCNEW; bcopy((char *)cp + 2, (char *)&to->to_cc, sizeof(to->to_cc)); - NTOHL(to->to_cc); + to->to_cc = ntohl(to->to_cc); break; case TCPOPT_CCECHO: if (optlen != TCPOLEN_CC) @@ -2293,7 +2293,7 @@ tcp_dooptions(to, cp, cnt, is_syn) to->to_flags |= TOF_CCECHO; bcopy((char *)cp + 2, (char *)&to->to_ccecho, sizeof(to->to_ccecho)); - NTOHL(to->to_ccecho); + to->to_ccecho = ntohl(to->to_ccecho); break; default: continue; diff --git a/sys/netinet6/ip6_fw.c b/sys/netinet6/ip6_fw.c index a861e65d7a33..468400c29afe 100644 --- a/sys/netinet6/ip6_fw.c +++ b/sys/netinet6/ip6_fw.c @@ -756,8 +756,8 @@ ip6_fw_chk(struct ip6_hdr **pip6, ti.ip6 = *ip6; ti.th = *tcp; - NTOHL(ti.th.th_seq); - NTOHL(ti.th.th_ack); + ti.th.th_seq = ntohl(ti.th.th_seq); + ti.th.th_ack = ntohl(ti.th.th_ack); ti.ip6.ip6_nxt = IPPROTO_TCP; if (ti.th.th_flags & TH_ACK) { ack = 0; diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 268884d59507..d84ba59b9a65 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -269,7 +269,7 @@ nd6_ra_input(m, off, icmp6len) dr0.advints_lost = 0; /* Mobile IPv6 */ /* unspecified or not? (RFC 2461 6.3.4) */ if (advreachable) { - NTOHL(advreachable); + advreachable = ntohl(advreachable); if (advreachable <= MAX_REACHABLE_TIME && ndi->basereachable != advreachable) { ndi->basereachable = advreachable; diff --git a/sys/powerpc/include/endian.h b/sys/powerpc/include/endian.h index a1f5ce64c213..3b45b73e64f1 100644 --- a/sys/powerpc/include/endian.h +++ b/sys/powerpc/include/endian.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -35,8 +35,10 @@ * $FreeBSD$ */ -#ifndef _ENDIAN_H_ -#define _ENDIAN_H_ +#ifndef _MACHINE_ENDIAN_H_ +#define _MACHINE_ENDIAN_H_ + +#include /* * Define the order of 32-bit words in 64-bit words. @@ -44,53 +46,32 @@ #define _QUAD_HIGHWORD 0 #define _QUAD_LOWWORD 1 -#ifndef _POSIX_SOURCE /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER BIG_ENDIAN +#endif /* !_POSIX_SOURCE */ #ifndef _KERNEL #include -#endif -#include __BEGIN_DECLS -__uint32_t htonl __P((__uint32_t)); -__uint16_t htons __P((__uint16_t)); -__uint32_t ntohl __P((__uint32_t)); -__uint16_t ntohs __P((__uint16_t)); -__uint16_t bswap16 __P((__uint16_t)); -__uint32_t bswap32 __P((__uint32_t)); -__uint64_t bswap64 __P((__uint64_t)); +__uint32_t __htonl __P((__uint32_t)); +__uint16_t __htons __P((__uint16_t)); +__uint32_t __ntohl __P((__uint32_t)); +__uint16_t __ntohs __P((__uint16_t)); __END_DECLS +#endif /* _KERNEL */ -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) +#define __htonl(x) (x) +#define __htons(x) (x) +#define __ntohl(x) (x) +#define __ntohs(x) (x) -#define NTOHL(x) (x) -#define NTOHS(x) (x) -#define HTONL(x) (x) -#define HTONS(x) (x) - -#else - -#define NTOHL(x) (x) = ntohl((__uint32_t)(x)) -#define NTOHS(x) (x) = ntohs((__uint16_t)(x)) -#define HTONL(x) (x) = htonl((__uint32_t)(x)) -#define HTONS(x) (x) = htons((__uint16_t)(x)) -#endif - -#endif /* !_POSIX_SOURCE */ -#endif /* !_ENDIAN_H_ */ +#endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/sparc64/include/endian.h b/sys/sparc64/include/endian.h index 54cc62474012..532daabd9bb9 100644 --- a/sys/sparc64/include/endian.h +++ b/sys/sparc64/include/endian.h @@ -1,4 +1,4 @@ -/* +/*- * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. All rights reserved. * @@ -10,6 +10,13 @@ * 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. 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 @@ -30,58 +37,29 @@ #ifndef _MACHINE_ENDIAN_H_ #define _MACHINE_ENDIAN_H_ +#include + /* * Define the order of 32-bit words in 64-bit words. */ #define _QUAD_HIGHWORD 0 #define _QUAD_LOWWORD 1 -#ifndef _POSIX_SOURCE /* * Definitions for byte order, according to byte significance from low * address to high. */ +#ifndef _POSIX_SOURCE #define LITTLE_ENDIAN 1234 /* LSB first: i386, vax */ #define BIG_ENDIAN 4321 /* MSB first: 68000, ibm, net */ #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long */ #define BYTE_ORDER BIG_ENDIAN - -#ifndef _KERNEL -#include -#endif -#include - -__BEGIN_DECLS -__uint32_t htonl __P((__uint32_t)); -__uint16_t htons __P((__uint16_t)); -__uint32_t ntohl __P((__uint32_t)); -__uint16_t ntohs __P((__uint16_t)); -__uint16_t bswap16 __P((__uint16_t)); -__uint32_t bswap32 __P((__uint32_t)); -__uint64_t bswap64 __P((__uint64_t)); -__END_DECLS - -/* - * Macros for network/external number representation conversion. - */ -#if BYTE_ORDER == BIG_ENDIAN && !defined(lint) -#define ntohl(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define htons(x) (x) - -#define NTOHL(x) -#define NTOHS(x) -#define HTONL(x) -#define HTONS(x) - -#else - -#define NTOHL(x) (x) = ntohl((in_addr_t)x) -#define NTOHS(x) (x) = ntohs((in_port_t)x) -#define HTONL(x) (x) = htonl((in_addr_t)x) -#define HTONS(x) (x) = htons((in_port_t)x) -#endif #endif /* !_POSIX_SOURCE */ + +#define __htonl(x) (x) +#define __htons(x) (x) +#define __ntohl(x) (x) +#define __ntohs(x) (x) + #endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/sys/imgact_aout.h b/sys/sys/imgact_aout.h index 39d6baff5c2f..4b20b8787d75 100644 --- a/sys/sys/imgact_aout.h +++ b/sys/sys/imgact_aout.h @@ -50,14 +50,14 @@ ((mag) & 0xffff) ) #define N_GETMAGIC_NET(ex) \ - (ntohl((ex).a_midmag) & 0xffff) + (__ntohl((ex).a_midmag) & 0xffff) #define N_GETMID_NET(ex) \ - ((ntohl((ex).a_midmag) >> 16) & 0x03ff) + ((__ntohl((ex).a_midmag) >> 16) & 0x03ff) #define N_GETFLAG_NET(ex) \ - ((ntohl((ex).a_midmag) >> 26) & 0x3f) + ((__ntohl((ex).a_midmag) >> 26) & 0x3f) #define N_SETMAGIC_NET(ex,mag,mid,flag) \ - ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \ - (((mag)&0xffff)) ) ) + ( (ex).a_midmag = __htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) \ + | (((mag)&0xffff)) ) ) #define N_ALIGN(ex,x) \ (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \ diff --git a/sys/sys/mchain.h b/sys/sys/mchain.h index e79fbfb03524..57278f4ad8d1 100644 --- a/sys/sys/mchain.h +++ b/sys/sys/mchain.h @@ -48,23 +48,23 @@ #define htoleq(x) ((int64_t)(x)) #define letohq(x) ((int64_t)(x)) -#define htobes(x) (htons(x)) -#define betohs(x) (ntohs(x)) -#define htobel(x) (htonl(x)) -#define betohl(x) (ntohl(x)) +#define htobes(x) (__htons(x)) +#define betohs(x) (__ntohs(x)) +#define htobel(x) (__htonl(x)) +#define betohl(x) (__ntohl(x)) static __inline int64_t htobeq(int64_t x) { - return (int64_t)htonl((u_int32_t)(x >> 32)) | - (int64_t)htonl((u_int32_t)(x & 0xffffffff)) << 32; + return (int64_t)__htonl((u_int32_t)(x >> 32)) | + (int64_t)__htonl((u_int32_t)(x & 0xffffffff)) << 32; } static __inline int64_t betohq(int64_t x) { - return (int64_t)ntohl((u_int32_t)(x >> 32)) | - (int64_t)ntohl((u_int32_t)(x & 0xffffffff)) << 32; + return (int64_t)__ntohl((u_int32_t)(x >> 32)) | + (int64_t)__ntohl((u_int32_t)(x & 0xffffffff)) << 32; } #else /* (BYTE_ORDER == LITTLE_ENDIAN) */ diff --git a/sys/sys/param.h b/sys/sys/param.h index fe7723295efd..90cc586427e7 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -188,6 +188,30 @@ #define MAX(a,b) (((a)>(b))?(a):(b)) #endif +/* + * Kernel exposed versions of byteorder(3) functions. + * + * XXX this section should only be defined in the kernel, but some userland + * software utilizes it. + */ +#ifndef _BYTEORDER_FUNC_DEFINED +#define _BYTEORDER_FUNC_DEFINED +#define htonl(x) __htonl(x) +#define htons(x) __htons(x) +#define ntohl(x) __ntohl(x) +#define ntohs(x) __ntohs(x) +#endif + +/* + * XXX deprecated uppercase variants for byteorder(3) functions. + */ +#ifndef _POSIX_SOURCE +#define NTOHL(x) ((x) = __ntohl(x)) +#define NTOHS(x) ((x) = __ntohs(x)) +#define HTONL(x) ((x) = __htonl(x)) +#define HTONS(x) ((x) = __htons(x)) +#endif /* _POSIX_SOURCE */ + /* * Constants for setting the parameters of the kernel memory allocator. * diff --git a/sys/sys/types.h b/sys/sys/types.h index f01d9852d919..e80462baa948 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -46,6 +46,7 @@ /* Machine type dependent parameters. */ #include /* includes */ +#include #include #ifndef _POSIX_SOURCE @@ -122,12 +123,6 @@ typedef u_int32_t dev_t; /* device number */ #endif /* !_KERNEL */ -/* - * XXX: Deprecated; - * byteorder(3) functions now defined in . - */ -#include - #ifdef _BSD_CLOCK_T_ typedef _BSD_CLOCK_T_ clock_t; #undef _BSD_CLOCK_T_ @@ -143,18 +138,6 @@ typedef _BSD_FFLAGS_T_ fflags_t; /* file flags */ #undef _BSD_FFLAGS_T_ #endif -/* XXX: Deprecated; now defined in . */ -#ifndef _IN_ADDR_T_DECLARED_ -typedef __uint32_t in_addr_t; -#define _IN_ADDR_T_DECLARED_ -#endif - -/* XXX: Deprecated; now defined in . */ -#ifndef _IN_PORT_T_DECLARED_ -typedef __uint16_t in_port_t; -#define _IN_PORT_T_DECLARED_ -#endif - #ifdef _BSD_SIZE_T_ typedef _BSD_SIZE_T_ size_t; #undef _BSD_SIZE_T_ diff --git a/usr.bin/locate/locate/util.c b/usr.bin/locate/locate/util.c index feaa32a27d51..4fee1f346968 100644 --- a/usr.bin/locate/locate/util.c +++ b/usr.bin/locate/locate/util.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include "locate.h" diff --git a/usr.bin/mklocale/yacc.y b/usr.bin/mklocale/yacc.y index 7ad1d3759457..51378f144e3d 100644 --- a/usr.bin/mklocale/yacc.y +++ b/usr.bin/mklocale/yacc.y @@ -40,6 +40,8 @@ static char sccsid[] = "@(#)yacc.y 8.1 (Berkeley) 6/6/93"; static char rcsid[] = "$FreeBSD$"; #endif /* not lint */ +#include + #include #include #include diff --git a/usr.bin/talk/ctl_transact.c b/usr.bin/talk/ctl_transact.c index 1d68b695af4c..0871febe7361 100644 --- a/usr.bin/talk/ctl_transact.c +++ b/usr.bin/talk/ctl_transact.c @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); static const char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93"; #endif +#include + #include #include diff --git a/usr.sbin/IPXrouted/defs.h b/usr.sbin/IPXrouted/defs.h index 3a1e6ac803ce..c2b28a7a0d81 100644 --- a/usr.sbin/IPXrouted/defs.h +++ b/usr.sbin/IPXrouted/defs.h @@ -40,6 +40,7 @@ #include #include +#include #include #include #if defined(vax) || defined(pdp11) diff --git a/usr.sbin/ancontrol/ancontrol.c b/usr.sbin/ancontrol/ancontrol.c index 6323965147d4..6fb1cd36ccec 100644 --- a/usr.sbin/ancontrol/ancontrol.c +++ b/usr.sbin/ancontrol/ancontrol.c @@ -39,11 +39,12 @@ static const char rcsid[] = #include #include -#include #include #include #include +#include + #include #include #include diff --git a/usr.sbin/burncd/burncd.c b/usr.sbin/burncd/burncd.c index 88132b201242..daea1a48cedc 100644 --- a/usr.sbin/burncd/burncd.c +++ b/usr.sbin/burncd/burncd.c @@ -28,6 +28,7 @@ * $FreeBSD$ */ +#include #include #include #include diff --git a/usr.sbin/cdcontrol/cdcontrol.c b/usr.sbin/cdcontrol/cdcontrol.c index eadf8dc5cfec..8bd3f4be88b7 100644 --- a/usr.sbin/cdcontrol/cdcontrol.c +++ b/usr.sbin/cdcontrol/cdcontrol.c @@ -27,6 +27,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include diff --git a/usr.sbin/ppp/mppe.c b/usr.sbin/ppp/mppe.c index 09dccff200fc..6278ad1679aa 100644 --- a/usr.sbin/ppp/mppe.c +++ b/usr.sbin/ppp/mppe.c @@ -28,6 +28,8 @@ #include +#include + #include #include #include diff --git a/usr.sbin/timed/timedc/cmds.c b/usr.sbin/timed/timedc/cmds.c index 950a2cf5ab94..edb41d135f71 100644 --- a/usr.sbin/timed/timedc/cmds.c +++ b/usr.sbin/timed/timedc/cmds.c @@ -42,6 +42,8 @@ static const char rcsid[] = #include "timedc.h" #include +#include + #include #include #include diff --git a/usr.sbin/ypbind/yp_ping.c b/usr.sbin/ypbind/yp_ping.c index 3983ff30a634..9252a7462478 100644 --- a/usr.sbin/ypbind/yp_ping.c +++ b/usr.sbin/ypbind/yp_ping.c @@ -90,6 +90,7 @@ static const char rcsid[] = #include #include #include +#include #include #include "yp_ping.h"