diff --git a/lib/libstand/cd9660.c b/lib/libstand/cd9660.c index 1c43e7564b60..449480b5531e 100644 --- a/lib/libstand/cd9660.c +++ b/lib/libstand/cd9660.c @@ -118,21 +118,6 @@ struct ptable_ent { #define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE) -/* XXX these should be in the system headers */ -static __inline int -isonum_722(p) - u_char *p; -{ - return (*p << 8)|p[1]; -} - -static __inline int -isonum_732(p) - u_char *p; -{ - return (*p << 24)|(p[1] << 16)|(p[2] << 8)|p[3]; -} - static ISO_SUSP_HEADER * susp_lookup_record(struct open_file *f, const char *identifier, struct iso_directory_record *dp, int lenskip) diff --git a/sys/fs/cd9660/iso.h b/sys/fs/cd9660/iso.h index 8645f58ec021..085134141b1d 100644 --- a/sys/fs/cd9660/iso.h +++ b/sys/fs/cd9660/iso.h @@ -277,79 +277,65 @@ u_short sgetrune(const char *, size_t, char const **, int, void *); * outside the kernel. Thus we don't hide them here. */ -static __inline int isonum_711(u_char *); -static __inline int -isonum_711(p) - u_char *p; +/* + * 7xy + * x -> 1 = 8 bits, 2 = 16 bits, 3 = 32 bits + * y -> 1 = little-endian, 2 = big-endian, 3 = both (le then be) + */ + +static __inline uint8_t +isonum_711(unsigned char *p) { - return *p; + return p[0]; } -static __inline int isonum_712(char *); -static __inline int -isonum_712(p) - char *p; +static __inline uint8_t +isonum_712(unsigned char *p) { - return *p; + return p[0]; } -#ifndef UNALIGNED_ACCESS - -static __inline int isonum_723(u_char *); -static __inline int -isonum_723(p) - u_char *p; +static __inline uint8_t +isonum_713(unsigned char *p) { - return *p|(p[1] << 8); + return p[0]; } -static __inline int isonum_733(u_char *); -static __inline int -isonum_733(p) - u_char *p; +static __inline uint16_t +isonum_721(unsigned char *p) { - return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); + return (p[0] | p[1] << 8); } -#else /* UNALIGNED_ACCESS */ - -#if BYTE_ORDER == LITTLE_ENDIAN - -static __inline int -isonum_723(p) - u_char *p +static __inline uint16_t +isonum_722(unsigned char *p) { - return *(u_int16t *)p; + return (p[1] | p[0] << 8); } -static __inline int -isonum_733(p) - u_char *p; +static __inline uint16_t +isonum_723(unsigned char *p) { - return *(u_int32t *)p; + return (p[0] | p[1] << 8); } -#endif - -#if BYTE_ORDER == BIG_ENDIAN - -static __inline int -isonum_723(p) - u_char *p +static __inline uint32_t +isonum_731(unsigned char *p) { - return *(u_int16t *)(p + 2); + return (p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24); } -static __inline int -isonum_733(p) - u_char *p; +static __inline uint32_t +isonum_732(unsigned char *p) { - return *(u_int32t *)(p + 4); + return (p[3] | p[2] << 8 | p[1] << 16 | p[0] << 24); } -#endif - -#endif /* UNALIGNED_ACCESS */ +static __inline uint32_t +isonum_733(unsigned char *p) +{ + return (p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24); +} /* * Associated files have a leading '='. diff --git a/sys/isofs/cd9660/iso.h b/sys/isofs/cd9660/iso.h index 8645f58ec021..085134141b1d 100644 --- a/sys/isofs/cd9660/iso.h +++ b/sys/isofs/cd9660/iso.h @@ -277,79 +277,65 @@ u_short sgetrune(const char *, size_t, char const **, int, void *); * outside the kernel. Thus we don't hide them here. */ -static __inline int isonum_711(u_char *); -static __inline int -isonum_711(p) - u_char *p; +/* + * 7xy + * x -> 1 = 8 bits, 2 = 16 bits, 3 = 32 bits + * y -> 1 = little-endian, 2 = big-endian, 3 = both (le then be) + */ + +static __inline uint8_t +isonum_711(unsigned char *p) { - return *p; + return p[0]; } -static __inline int isonum_712(char *); -static __inline int -isonum_712(p) - char *p; +static __inline uint8_t +isonum_712(unsigned char *p) { - return *p; + return p[0]; } -#ifndef UNALIGNED_ACCESS - -static __inline int isonum_723(u_char *); -static __inline int -isonum_723(p) - u_char *p; +static __inline uint8_t +isonum_713(unsigned char *p) { - return *p|(p[1] << 8); + return p[0]; } -static __inline int isonum_733(u_char *); -static __inline int -isonum_733(p) - u_char *p; +static __inline uint16_t +isonum_721(unsigned char *p) { - return *p|(p[1] << 8)|(p[2] << 16)|(p[3] << 24); + return (p[0] | p[1] << 8); } -#else /* UNALIGNED_ACCESS */ - -#if BYTE_ORDER == LITTLE_ENDIAN - -static __inline int -isonum_723(p) - u_char *p +static __inline uint16_t +isonum_722(unsigned char *p) { - return *(u_int16t *)p; + return (p[1] | p[0] << 8); } -static __inline int -isonum_733(p) - u_char *p; +static __inline uint16_t +isonum_723(unsigned char *p) { - return *(u_int32t *)p; + return (p[0] | p[1] << 8); } -#endif - -#if BYTE_ORDER == BIG_ENDIAN - -static __inline int -isonum_723(p) - u_char *p +static __inline uint32_t +isonum_731(unsigned char *p) { - return *(u_int16t *)(p + 2); + return (p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24); } -static __inline int -isonum_733(p) - u_char *p; +static __inline uint32_t +isonum_732(unsigned char *p) { - return *(u_int32t *)(p + 4); + return (p[3] | p[2] << 8 | p[1] << 16 | p[0] << 24); } -#endif - -#endif /* UNALIGNED_ACCESS */ +static __inline uint32_t +isonum_733(unsigned char *p) +{ + return (p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24); +} /* * Associated files have a leading '='.