Date: Sat, 27 Aug 2005 22:20:08 +0900 From: "R. Imura" <imura@ryu16.org> To: Marius Strobl <marius@alchemy.franken.de> Cc: John Nielsen <john@jnielsen.net>, freebsd-sparc64@freebsd.org Subject: Re: "fast data access mmu miss" on kernels w/o "makeoptions DEBUG=-g" Message-ID: <20050827132008.GA28954%imura@ryu16.org> In-Reply-To: <20050827145503.G19225@newtrinity.zeist.de> References: <200508110931.13802.john@jnielsen.net> <200508201453.40439.jhb@FreeBSD.org> <20050823081517.GB4956@rndsoft.co.kr> <200508230911.18163.john@jnielsen.net> <20050824010147.GD4956@rndsoft.co.kr> <20050824143940.GA65078%imura@ryu16.org> <20050824191437.A36508@newtrinity.zeist.de> <20050827055841.GB83681%imura@ryu16.org> <20050827145503.G19225@newtrinity.zeist.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Aug 27, 2005 at 02:55:03PM +0200, Marius Strobl wrote: > On Sat, Aug 27, 2005 at 02:58:41PM +0900, R. Imura wrote: > > Hi, > > > > On Wed, Aug 24, 2005 at 07:14:37PM +0200, Marius Strobl wrote: > > > > > smbfs does not work on sparc64 as smbfs assumes it runs on > > > > > architectures that allow on-aligned memory access. It also needs > > > > > big-endian clean up too.(See sys/mchain.h) > > > > > > > > To begin with, you might want this patch. :) > > > > > > > > > > You probably should go the NetBSD route and change the consumers > > > of these macros to use the byteorder(9) functions like htole16(9) > > > directly. Btw., NetBSD seems to also have fixed the alignment > > > issues. > > > > I was too rushed that these macros in my patch are no longer used > > in our system, so we can safe to remove them. > > > > Fixes are done in 3 years ago. > > http://docs.freebsd.org/cgi/mid.cgi?200212161620.gBGGK6uX080655 > > > > That commit only dealt with the kernel part, these macros are still > used in the userland part: > > grep -r htoles /usr/src/contrib/smbfs/* > /usr/src/contrib/smbfs/lib/smb/nb_name.c:#define NBENCODE(c) (htoles((u_short)(((u_char)(c) >> 4) | \ > > Marius I see. :) Then, could you test this patch? Index: contrib/smbfs/lib/smb/mbuf.c =================================================================== RCS file: /home/ncvs/src/contrib/smbfs/lib/smb/mbuf.c,v retrieving revision 1.2 diff -u -r1.2 mbuf.c --- contrib/smbfs/lib/smb/mbuf.c 19 Oct 2004 17:44:31 -0000 1.2 +++ contrib/smbfs/lib/smb/mbuf.c 27 Aug 2005 13:07:14 -0000 @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD: src/contrib/smbfs/lib/smb/mbuf.c,v 1.2 2004/10/19 17:44:31 obrien Exp $"); #include <sys/types.h> +#include <sys/endian.h> #include <sys/mchain.h> #include <arpa/inet.h> #include <ctype.h> @@ -268,7 +269,7 @@ mb_put_int64be(struct mbdata *mbp, int64_t x) { MB_PUT(int64_t); - *p = htobeq(x); + *p = htobe64(x); return 0; } @@ -276,7 +277,7 @@ mb_put_int64le(struct mbdata *mbp, int64_t x) { MB_PUT(int64_t); - *p = htoleq(x); + *p = htole64(x); return 0; } @@ -367,7 +368,7 @@ u_int16_t v; int error = mb_get_uint16(mbp, &v); - *x = letohs(v); + *x = le16toh(v); return error; } @@ -376,7 +377,7 @@ u_int16_t v; int error = mb_get_uint16(mbp, &v); - *x = betohs(v); + *x = be16toh(v); return error; } @@ -393,7 +394,7 @@ int error; error = mb_get_uint32(mbp, &v); - *x = betohl(v); + *x = be32toh(v); return error; } @@ -404,7 +405,7 @@ int error; error = mb_get_uint32(mbp, &v); - *x = letohl(v); + *x = le32toh(v); return error; } @@ -421,7 +422,7 @@ int error; error = mb_get_int64(mbp, &v); - *x = betohq(v); + *x = be64toh(v); return error; } @@ -432,7 +433,7 @@ int error; error = mb_get_int64(mbp, &v); - *x = letohq(v); + *x = le64toh(v); return error; } Index: contrib/smbfs/lib/smb/nb_name.c =================================================================== RCS file: /home/ncvs/src/contrib/smbfs/lib/smb/nb_name.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 nb_name.c --- contrib/smbfs/lib/smb/nb_name.c 20 Dec 2001 16:16:25 -0000 1.1.1.2 +++ contrib/smbfs/lib/smb/nb_name.c 27 Aug 2005 13:08:13 -0000 @@ -31,9 +31,9 @@ * * $Id: nb_name.c,v 1.2 2001/08/22 03:31:36 bp Exp $ */ +#include <sys/endian.h> #include <sys/param.h> #include <sys/socket.h> -#include <sys/mchain.h> /* for endiand macros */ #include <ctype.h> #include <err.h> @@ -139,7 +139,7 @@ return len; } -#define NBENCODE(c) (htoles((u_short)(((u_char)(c) >> 4) | \ +#define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \ (((u_char)(c) & 0xf) << 8)) + 0x4141)) static void Index: contrib/smbfs/lib/smb/rap.c =================================================================== RCS file: /home/ncvs/src/contrib/smbfs/lib/smb/rap.c,v retrieving revision 1.4 diff -u -r1.4 rap.c --- contrib/smbfs/lib/smb/rap.c 19 Jun 2004 19:03:01 -0000 1.4 +++ contrib/smbfs/lib/smb/rap.c 27 Aug 2005 13:10:08 -0000 @@ -35,6 +35,7 @@ * This is very simple implementation of RAP protocol. */ #include <sys/param.h> +#include <sys/endian.h> #include <sys/errno.h> #include <sys/stat.h> #include <ctype.h> @@ -45,8 +46,6 @@ #include <stdlib.h> #include <sysexits.h> -#include <sys/mchain.h> - #include <netsmb/smb_lib.h> #include <netsmb/smb_conn.h> #include <netsmb/smb_rap.h> @@ -290,7 +289,7 @@ return error; switch (ptype) { case 'h': - *value = letohs(*(u_int16_t*)rap->r_npbuf); + *value = le16toh(*(u_int16_t*)rap->r_npbuf); break; default: return EINVAL; @@ -320,8 +319,8 @@ if (error) return error; rp = (u_int16_t*)rap->r_pbuf; - rap->r_result = letohs(*rp++); - conv = letohs(*rp++); + rap->r_result = le16toh(*rp++); + conv = le16toh(*rp++); rap->r_npbuf = (char*)rp; rap->r_entries = entries = 0; done = 0; @@ -329,7 +328,7 @@ ptype = *p; switch (ptype) { case 'e': - rap->r_entries = entries = letohs(*(u_int16_t*)rap->r_npbuf); + rap->r_entries = entries = le16toh(*(u_int16_t*)rap->r_npbuf); rap->r_npbuf += 2; p++; break; Index: sys/sys/mchain.h =================================================================== RCS file: /home/ncvs/src/sys/sys/mchain.h,v retrieving revision 1.9 diff -u -r1.9 mchain.h --- sys/sys/mchain.h 29 Jul 2005 13:22:36 -0000 1.9 +++ sys/sys/mchain.h 27 Aug 2005 13:13:05 -0000 @@ -34,54 +34,6 @@ #ifndef _SYS_MCHAIN_H_ #define _SYS_MCHAIN_H_ -#include <machine/endian.h> - -#ifndef _KERNEL -/* - * This macros probably belongs to the endian.h - */ -#if (BYTE_ORDER == LITTLE_ENDIAN) - -#define htoles(x) ((u_int16_t)(x)) -#define letohs(x) ((u_int16_t)(x)) -#define htolel(x) ((u_int32_t)(x)) -#define letohl(x) ((u_int32_t)(x)) -#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)) - -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; -} - -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; -} - -#else /* (BYTE_ORDER == LITTLE_ENDIAN) */ - -#error "Macros for Big-Endians are incomplete" - -/* -#define htoles(x) ((u_int16_t)(x)) -#define letohs(x) ((u_int16_t)(x)) -#define htolel(x) ((u_int32_t)(x)) -#define letohl(x) ((u_int32_t)(x)) -*/ -#endif /* (BYTE_ORDER == LITTLE_ENDIAN) */ -#endif /* _KERNEL */ - - #ifdef _KERNEL /* Regards, - R. Imura
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050827132008.GA28954%imura>