From 29be44dae5d71c76b05fc7c5c56a5b5f8e381893 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 5 Apr 2002 18:11:12 +0000 Subject: [PATCH] Added byte ordering API. --- physfs.h | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/physfs.h b/physfs.h index 8bbf714d..a81340c1 100644 --- a/physfs.h +++ b/physfs.h @@ -866,6 +866,127 @@ __EXPORT__ int PHYSFS_seek(PHYSFS_file *handle, PHYSFS_uint64 pos); */ __EXPORT__ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle); + +/* Byteorder stuff... */ + +/** + * Take a 16-bit signed value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val); + + +/** + * Take a 16-bit unsigned value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val); + +/** + * Take a 32-bit signed value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val); + + +/** + * Take a 32-bit unsigned value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val); + +/** + * Take a 64-bit signed value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val); + + +/** + * Take a 64-bit unsigned value in littleendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val); + + +/** + * Take a 16-bit signed value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val); + + +/** + * Take a 16-bit unsigned value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val); + +/** + * Take a 32-bit signed value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val); + + +/** + * Take a 32-bit unsigned value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val); + + +/** + * Take a 64-bit signed value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val); + + +/** + * Take a 64-bit unsigned value in bigendian format and convert it to + * the platform's native byte order. + * + * @param val value to convert + * @return converted value. + */ +__EXPORT__ PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val); + + + #if 0 /* !!! FIXME: add this? */ #undef __EXPORT__ #endif