1/*
2** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3** Distributed under the terms of the OpenBeOS License.
4*/
5#ifndef BFS_ENDIAN_H
6#define BFS_ENDIAN_H
7
8
9#include <ByteOrder.h>
10
11
12#if !defined(BFS_LITTLE_ENDIAN_ONLY) && !defined(BFS_BIG_ENDIAN_ONLY)
13//	default setting; BFS is now primarily a little endian file system
14#	define BFS_LITTLE_ENDIAN_ONLY
15#endif
16
17
18#if defined(BFS_LITTLE_ENDIAN_ONLY) && B_HOST_IS_LENDIAN \
19	|| defined(BFS_BIG_ENDIAN_ONLY) && B_HOST_IS_BENDIAN
20		/* host is BFS endian */
21#	define BFS_ENDIAN_TO_HOST_INT16(value) value
22#	define BFS_ENDIAN_TO_HOST_INT32(value) value
23#	define BFS_ENDIAN_TO_HOST_INT64(value) value
24#	define HOST_ENDIAN_TO_BFS_INT16(value) value
25#	define HOST_ENDIAN_TO_BFS_INT32(value) value
26#	define HOST_ENDIAN_TO_BFS_INT64(value) value
27#elif defined(BFS_LITTLE_ENDIAN_ONLY) && B_HOST_IS_BENDIAN \
28	|| defined(BFS_BIG_ENDIAN_ONLY) && B_HOST_IS_LENDIAN
29		/* host is big endian, BFS is little endian or vice versa */
30#	define BFS_ENDIAN_TO_HOST_INT16(value) __swap_int16(value)
31#	define BFS_ENDIAN_TO_HOST_INT32(value) __swap_int32(value)
32#	define BFS_ENDIAN_TO_HOST_INT64(value) __swap_int64(value)
33#	define HOST_ENDIAN_TO_BFS_INT16(value) __swap_int16(value)
34#	define HOST_ENDIAN_TO_BFS_INT32(value) __swap_int32(value)
35#	define HOST_ENDIAN_TO_BFS_INT64(value) __swap_int64(value)
36#else
37	// ToDo: maybe build a version that supports both, big & little endian?
38	//		But since that will need some kind of global data (to
39	//		know of what type this file system is), it's probably
40	//		something for the boot loader; anything else would be
41	//		a major pain.
42#endif
43
44#endif	/* BFS_ENDIAN_H */
45