* Rewrote headers as necessary; only Errors.h and Debug.h still originate from a Be header now;

feel free to change that ;-)
* Cleaned up existing headers.
* Coding style guide update to BBufferIO (renamed m_* members to f*).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19972 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-01-26 16:36:29 +00:00
parent 03d79ead32
commit 087882c26e
16 changed files with 589 additions and 791 deletions
+104 -116
View File
@@ -1,21 +1,19 @@
// Modified BeOS header. Just here to be able to compile and test BResources.
// To be replaced by the OpenBeOS version to be provided by the IK Team.
/*
* Copyright 2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _BYTEORDER_H
#define _BYTEORDER_H
#ifndef _sk_byte_order_h_
#define _sk_byte_order_h_
#include <BeBuild.h>
#include <endian.h>
#include <SupportDefs.h>
#include <TypeConstants.h> /* For convenience */
#include <TypeConstants.h>
// for convenience
#ifdef __cplusplus
extern "C" {
#endif
/*----------------------------------------------------------------------*/
/*------- Swap-direction constants, and swapping functions -------------*/
// swap directions
typedef enum {
B_SWAP_HOST_TO_LENDIAN,
B_SWAP_HOST_TO_BENDIAN,
@@ -24,121 +22,111 @@ typedef enum {
B_SWAP_ALWAYS
} swap_action;
extern status_t swap_data(type_code type, void *data, size_t length,
swap_action action);
extern bool is_type_swapped(type_code type);
/*-----------------------------------------------------------------------*/
/*----- Private implementations -----------------------------------------*/
extern double __swap_double(double arg);
extern float __swap_float(float arg);
extern uint64 __swap_int64(uint64 uarg);
extern uint32 __swap_int32(uint32 uarg);
extern uint16 __swap_int16(uint16 uarg);
/*-------------------------------------------------------------*/
// BSD/networking macros
#ifndef htonl
# define htonl(x) B_HOST_TO_BENDIAN_INT32(x)
# define ntohl(x) B_BENDIAN_TO_HOST_INT32(x)
# define htons(x) B_HOST_TO_BENDIAN_INT16(x)
# define ntohs(x) B_BENDIAN_TO_HOST_INT16(x)
#endif
/*-------------------------------------------------------------*/
/*--------- Host is Little --------------------------------------*/
#if BYTE_ORDER == __LITTLE_ENDIAN
#define B_HOST_IS_LENDIAN 1
#define B_HOST_IS_BENDIAN 0
/*--------- Host Native -> Little --------------------*/
#define B_HOST_TO_LENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) (uint16)(arg)
/*--------- Host Native -> Big ------------------------*/
#define B_HOST_TO_BENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) __swap_int16(arg)
/*--------- Little -> Host Native ---------------------*/
#define B_LENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
/*--------- Big -> Host Native ------------------------*/
#define B_BENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
#else /* __LITTLE_ENDIAN */
/*-------------------------------------------------------------*/
/*--------- Host is Big --------------------------------------*/
#define B_HOST_IS_LENDIAN 0
#define B_HOST_IS_BENDIAN 1
/*--------- Host Native -> Little -------------------*/
#define B_HOST_TO_LENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) __swap_int16(arg)
/*--------- Host Native -> Big ------------------------*/
#define B_HOST_TO_BENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) (uint16)(arg)
/*--------- Little -> Host Native ----------------------*/
#define B_LENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
/*--------- Big -> Host Native -------------------------*/
#define B_BENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
#endif /* __LITTLE_ENDIAN */
/*-------------------------------------------------------------*/
/*--------- Just-do-it macros ---------------------------------*/
// always swap macros
#define B_SWAP_DOUBLE(arg) __swap_double(arg)
#define B_SWAP_FLOAT(arg) __swap_float(arg)
#define B_SWAP_INT64(arg) __swap_int64(arg)
#define B_SWAP_INT32(arg) __swap_int32(arg)
#define B_SWAP_INT16(arg) __swap_int16(arg)
#if BYTE_ORDER == __LITTLE_ENDIAN
// Host is little endian
/*-------------------------------------------------------------*/
/*---------Berkeley macros -----------------------------------*/
#ifndef htonl /* avoid collision with <netinet/in.h> */
#define htonl(x) B_HOST_TO_BENDIAN_INT32(x)
#define ntohl(x) B_BENDIAN_TO_HOST_INT32(x)
#define htons(x) B_HOST_TO_BENDIAN_INT16(x)
#define ntohs(x) B_BENDIAN_TO_HOST_INT16(x)
#endif
#define B_HOST_IS_LENDIAN 1
#define B_HOST_IS_BENDIAN 0
// Host native to little endian
#define B_HOST_TO_LENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) (uint16)(arg)
// Little endian to host native
#define B_LENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
// Host native to big endian
#define B_HOST_TO_BENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) __swap_int16(arg)
// Big endian to host native
#define B_BENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
#else // BYTE_ORDER
// Host is big endian
#define B_HOST_IS_LENDIAN 0
#define B_HOST_IS_BENDIAN 1
// Host native to little endian
#define B_HOST_TO_LENDIAN_DOUBLE(arg) __swap_double(arg)
#define B_HOST_TO_LENDIAN_FLOAT(arg) __swap_float(arg)
#define B_HOST_TO_LENDIAN_INT64(arg) __swap_int64(arg)
#define B_HOST_TO_LENDIAN_INT32(arg) __swap_int32(arg)
#define B_HOST_TO_LENDIAN_INT16(arg) __swap_int16(arg)
// Little endian to host native
#define B_LENDIAN_TO_HOST_DOUBLE(arg) __swap_double(arg)
#define B_LENDIAN_TO_HOST_FLOAT(arg) __swap_float(arg)
#define B_LENDIAN_TO_HOST_INT64(arg) __swap_int64(arg)
#define B_LENDIAN_TO_HOST_INT32(arg) __swap_int32(arg)
#define B_LENDIAN_TO_HOST_INT16(arg) __swap_int16(arg)
// Host native to big endian
#define B_HOST_TO_BENDIAN_DOUBLE(arg) (double)(arg)
#define B_HOST_TO_BENDIAN_FLOAT(arg) (float)(arg)
#define B_HOST_TO_BENDIAN_INT64(arg) (uint64)(arg)
#define B_HOST_TO_BENDIAN_INT32(arg) (uint32)(arg)
#define B_HOST_TO_BENDIAN_INT16(arg) (uint16)(arg)
// Big endian to host native
#define B_BENDIAN_TO_HOST_DOUBLE(arg) (double)(arg)
#define B_BENDIAN_TO_HOST_FLOAT(arg) (float)(arg)
#define B_BENDIAN_TO_HOST_INT64(arg) (uint64)(arg)
#define B_BENDIAN_TO_HOST_INT32(arg) (uint32)(arg)
#define B_BENDIAN_TO_HOST_INT16(arg) (uint16)(arg)
#endif // BYTE_ORDER
#ifdef __cplusplus
extern "C" {
#endif
extern status_t swap_data(type_code type, void *data, size_t length,
swap_action action);
extern bool is_type_swapped(type_code type);
// Private implementations
extern double __swap_double(double arg);
extern float __swap_float(float arg);
extern uint64 __swap_int64(uint64 arg);
extern uint32 __swap_int32(uint32 arg);
extern uint16 __swap_int16(uint16 arg);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#endif // _sk_byte_order_h_
#endif // _BYTEORDER_H