* Added missing cast in isonum_712().
* Added const-qualifiers. * Removed unnecessary duplicate prototypes. * Use the endian conversion functions from <sys/endian.h>.
This commit is contained in:
parent
0108d79ceb
commit
b70ba117e6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: iso.h,v 1.8 2006/02/16 20:17:19 perry Exp $ */
|
||||
/* $NetBSD: iso.h,v 1.9 2007/01/27 07:20:31 cbiere Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994
|
||||
@ -171,102 +171,67 @@ struct iso_extended_attributes {
|
||||
u_char len_au [ISODCL (247, 250)]; /* 723 */
|
||||
};
|
||||
|
||||
static __inline int isonum_711(u_char *) __attribute__ ((unused));
|
||||
static __inline int isonum_712(char *) __attribute__ ((unused));
|
||||
static __inline uint16_t isonum_721(u_char *) __attribute__ ((unused));
|
||||
static __inline uint16_t isonum_722(u_char *) __attribute__ ((unused));
|
||||
static __inline uint16_t isonum_723(u_char *) __attribute__ ((unused));
|
||||
static __inline uint32_t isonum_731(u_char *) __attribute__ ((unused));
|
||||
static __inline uint32_t isonum_732(u_char *) __attribute__ ((unused));
|
||||
static __inline uint32_t isonum_733(u_char *) __attribute__ ((unused));
|
||||
|
||||
/* 7.1.1: unsigned char */
|
||||
static __inline int
|
||||
isonum_711(u_char *p)
|
||||
static __inline __unused int
|
||||
isonum_711(const u_char *p)
|
||||
{
|
||||
return *p;
|
||||
}
|
||||
|
||||
/* 7.1.2: signed(?) char */
|
||||
static __inline int
|
||||
isonum_712(char *p)
|
||||
/* 7.1.2: signed char */
|
||||
static __inline __unused int
|
||||
isonum_712(const u_char *p)
|
||||
{
|
||||
return *p;
|
||||
return (signed char) *p;
|
||||
}
|
||||
|
||||
/* 7.2.1: unsigned little-endian 16-bit value. NOT USED IN KERNEL. */
|
||||
static __inline uint16_t
|
||||
isonum_721(u_char *p)
|
||||
static __inline __unused uint16_t
|
||||
isonum_721(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
return *(uint16_t *)p;
|
||||
#else
|
||||
return *p|((char)p[1] << 8);
|
||||
#endif
|
||||
return le16dec(p);
|
||||
}
|
||||
|
||||
/* 7.2.2: unsigned big-endian 16-bit value. NOT USED IN KERNEL. */
|
||||
static __inline uint16_t
|
||||
isonum_722(u_char *p)
|
||||
static __inline __unused uint16_t
|
||||
isonum_722(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == BIG_ENDIAN)
|
||||
return *(uint16_t *)p;
|
||||
#else
|
||||
return ((char)*p << 8)|p[1];
|
||||
#endif
|
||||
return be16dec(p);
|
||||
}
|
||||
|
||||
/* 7.2.3: unsigned both-endian (little, then big) 16-bit value */
|
||||
static __inline uint16_t
|
||||
isonum_723(u_char *p)
|
||||
static __inline __unused uint16_t
|
||||
isonum_723(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && \
|
||||
((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return *(uint16_t *)p;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
return be16dec(p + 2);
|
||||
#else
|
||||
return *(uint16_t *)(p + 2);
|
||||
#endif
|
||||
#else /* !UNALIGNED_ACCESS or weird byte order */
|
||||
return *p|(p[1] << 8);
|
||||
return le16dec(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 7.3.1: unsigned little-endian 32-bit value. NOT USED IN KERNEL. */
|
||||
static __inline uint32_t
|
||||
isonum_731(u_char *p)
|
||||
static __inline __unused uint32_t
|
||||
isonum_731(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
return *(uint32_t *)p;
|
||||
#else
|
||||
return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
|
||||
#endif
|
||||
return le32dec(p);
|
||||
}
|
||||
|
||||
/* 7.3.2: unsigned big-endian 32-bit value. NOT USED IN KERNEL. */
|
||||
static __inline uint32_t
|
||||
isonum_732(u_char *p)
|
||||
static __inline __unused uint32_t
|
||||
isonum_732(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && (BYTE_ORDER == BIG_ENDIAN)
|
||||
return *(uint32_t *)p;
|
||||
#else
|
||||
return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3];
|
||||
#endif
|
||||
return be32dec(p);
|
||||
}
|
||||
|
||||
/* 7.3.3: unsigned both-endian (little, then big) 32-bit value */
|
||||
static __inline uint32_t
|
||||
isonum_733(u_char *p)
|
||||
static __inline __unused uint32_t
|
||||
isonum_733(const u_char *p)
|
||||
{
|
||||
#if defined(UNALIGNED_ACCESS) && \
|
||||
((BYTE_ORDER == LITTLE_ENDIAN) || (BYTE_ORDER == BIG_ENDIAN))
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return *(uint32_t *)p;
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
return be32dec(p + 4);
|
||||
#else
|
||||
return *(uint32_t *)(p + 4);
|
||||
#endif
|
||||
#else /* !UNALIGNED_ACCESS or weird byte order */
|
||||
return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24);
|
||||
return le32dec(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user