1
0
Fork 0

jfs: get rid of homegrown endianness helpers

Get rid of le24 stuff, along with the bitfields use - all that stuff
can be done with standard stuff, in sparse-verifiable manner.  Moreover,
that way (shift-and-mask) often generates better code - gcc optimizer
sucks on bitfields...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
----
wifi-calibration
Al Viro 2014-12-19 06:51:26 +00:00 committed by Dave Kleikamp
parent 53262d12d1
commit e1f1fe798d
4 changed files with 44 additions and 89 deletions

View File

@ -1,49 +0,0 @@
/*
* Copyright (C) International Business Machines Corp., 2001
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_ENDIAN24
#define _H_ENDIAN24
/*
* endian24.h:
*
* Endian conversion for 24-byte data
*
*/
#define __swab24(x) \
({ \
__u32 __x = (x); \
((__u32)( \
((__x & (__u32)0x000000ffUL) << 16) | \
(__x & (__u32)0x0000ff00UL) | \
((__x & (__u32)0x00ff0000UL) >> 16) )); \
})
#if (defined(__KERNEL__) && defined(__LITTLE_ENDIAN)) || (defined(__BYTE_ORDER) && (__BYTE_ORDER == __LITTLE_ENDIAN))
#define __cpu_to_le24(x) ((__u32)(x))
#define __le24_to_cpu(x) ((__u32)(x))
#else
#define __cpu_to_le24(x) __swab24(x)
#define __le24_to_cpu(x) __swab24(x)
#endif
#ifdef __KERNEL__
#define cpu_to_le24 __cpu_to_le24
#define le24_to_cpu __le24_to_cpu
#endif
#endif /* !_H_ENDIAN24 */

View File

@ -1040,8 +1040,8 @@ static int dtSplitUp(tid_t tid,
pxdlist.maxnpxd = 1;
pxdlist.npxd = 0;
pxd = &pxdlist.pxd[0];
PXDaddress(pxd, nxaddr)
PXDlength(pxd, xlen + n);
PXDaddress(pxd, nxaddr);
PXDlength(pxd, xlen + n);
split->pxdlist = &pxdlist;
if ((rc = dtExtendPage(tid, ip, split, btstack))) {
nxaddr = addressPXD(pxd);

View File

@ -30,8 +30,6 @@
#include <linux/types.h>
#include <linux/nls.h>
#include "endian24.h"
/*
* transaction and lock id's
*
@ -59,26 +57,42 @@ struct timestruc_t {
/*
* physical xd (pxd)
*
* The leftmost 24 bits of len_addr are the extent length.
* The rightmost 8 bits of len_addr are the most signficant bits of
* the extent address
*/
typedef struct {
unsigned len:24;
unsigned addr1:8;
__le32 len_addr;
__le32 addr2;
} pxd_t;
/* xd_t field construction */
#define PXDlength(pxd, length32) ((pxd)->len = __cpu_to_le24(length32))
#define PXDaddress(pxd, address64)\
{\
(pxd)->addr1 = ((s64)address64) >> 32;\
(pxd)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
static inline void PXDlength(pxd_t *pxd, __u32 len)
{
pxd->len_addr = (pxd->len_addr & cpu_to_le32(~0xffffff)) |
cpu_to_le32(len & 0xffffff);
}
static inline void PXDaddress(pxd_t *pxd, __u64 addr)
{
pxd->len_addr = (pxd->len_addr & cpu_to_le32(0xffffff)) |
cpu_to_le32((addr >> 32)<<24);
pxd->addr2 = cpu_to_le32(addr & 0xffffffff);
}
/* xd_t field extraction */
#define lengthPXD(pxd) __le24_to_cpu((pxd)->len)
#define addressPXD(pxd)\
( ((s64)((pxd)->addr1)) << 32 | __le32_to_cpu((pxd)->addr2))
static inline __u32 lengthPXD(pxd_t *pxd)
{
return le32_to_cpu((pxd)->len_addr) & 0xffffff;
}
static inline __u64 addressPXD(pxd_t *pxd)
{
__u64 n = le32_to_cpu(pxd->len_addr) & ~0xffffff;
return (n << 8) + le32_to_cpu(pxd->addr2);
}
#define MAXTREEHEIGHT 8
/* pxd list */
@ -93,12 +107,10 @@ struct pxdlist {
* data extent descriptor (dxd)
*/
typedef struct {
unsigned flag:8; /* 1: flags */
unsigned rsrvd:24;
__u8 flag; /* 1: flags */
__u8 rsrvd[3];
__le32 size; /* 4: size in byte */
unsigned len:24; /* 3: length in unit of fsblksize */
unsigned addr1:8; /* 1: address in unit of fsblksize */
__le32 addr2; /* 4: address in unit of fsblksize */
pxd_t loc; /* 8: address and length in unit of fsblksize */
} dxd_t; /* - 16 - */
/* dxd_t flags */
@ -109,12 +121,11 @@ typedef struct {
#define DXD_CORRUPT 0x08 /* Inconsistency detected */
/* dxd_t field construction
* Conveniently, the PXD macros work for DXD
*/
#define DXDlength PXDlength
#define DXDaddress PXDaddress
#define lengthDXD lengthPXD
#define addressDXD addressPXD
#define DXDlength(dxd, len) PXDlength(&(dxd)->loc, len)
#define DXDaddress(dxd, addr) PXDaddress(&(dxd)->loc, addr)
#define lengthDXD(dxd) lengthPXD(&(dxd)->loc)
#define addressDXD(dxd) addressPXD(&(dxd)->loc)
#define DXDsize(dxd, size32) ((dxd)->size = cpu_to_le32(size32))
#define sizeDXD(dxd) le32_to_cpu((dxd)->size)

View File

@ -29,13 +29,11 @@
* extent allocation descriptor (xad)
*/
typedef struct xad {
unsigned flag:8; /* 1: flag */
unsigned rsvrd:16; /* 2: reserved */
unsigned off1:8; /* 1: offset in unit of fsblksize */
__le32 off2; /* 4: offset in unit of fsblksize */
unsigned len:24; /* 3: length in unit of fsblksize */
unsigned addr1:8; /* 1: address in unit of fsblksize */
__le32 addr2; /* 4: address in unit of fsblksize */
__u8 flag; /* 1: flag */
__u8 rsvrd[2]; /* 2: reserved */
__u8 off1; /* 1: offset in unit of fsblksize */
__le32 off2; /* 4: offset in unit of fsblksize */
pxd_t loc; /* 8: length and address in unit of fsblksize */
} xad_t; /* (16) */
#define MAXXLEN ((1 << 24) - 1)
@ -49,19 +47,14 @@ typedef struct xad {
(xad)->off1 = ((u64)offset64) >> 32;\
(xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\
}
#define XADaddress(xad, address64)\
{\
(xad)->addr1 = ((u64)address64) >> 32;\
(xad)->addr2 = __cpu_to_le32((address64) & 0xffffffff);\
}
#define XADlength(xad, length32) (xad)->len = __cpu_to_le24(length32)
#define XADaddress(xad, address64) PXDaddress(&(xad)->loc, address64)
#define XADlength(xad, length32) PXDlength(&(xad)->loc, length32)
/* xad_t field extraction */
#define offsetXAD(xad)\
( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2))
#define addressXAD(xad)\
( ((s64)((xad)->addr1)) << 32 | __le32_to_cpu((xad)->addr2))
#define lengthXAD(xad) __le24_to_cpu((xad)->len)
#define addressXAD(xad) addressPXD(&(xad)->loc)
#define lengthXAD(xad) lengthPXD(&(xad)->loc)
/* xad list */
struct xadlist {