]>
git.saurik.com Git - apple/xnu.git/blob - bsd/hfs/hfs_endian.h
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 #ifndef __HFS_ENDIAN_H__
23 #define __HFS_ENDIAN_H__
28 * This file prototypes endian swapping routines for the HFS/HFS Plus
32 #include "hfscommon/headers/BTreesInternal.h"
33 #include <architecture/byte_order.h>
35 /*********************/
36 /* BIG ENDIAN Macros */
37 /*********************/
38 #if BYTE_ORDER == BIG_ENDIAN
40 /* HFS is always big endian, make swaps into no-ops */
41 #define SWAP_BE16(__a) (__a)
42 #define SWAP_BE32(__a) (__a)
43 #define SWAP_BE64(__a) (__a)
45 /* HFS is always big endian, no swapping needed */
46 #define SWAP_HFS_PLUS_FORK_DATA(__a)
47 #define SWAP_BT_NODE(__a, __b, __c)
49 /************************/
50 /* LITTLE ENDIAN Macros */
51 /************************/
52 #elif BYTE_ORDER == LITTLE_ENDIAN
54 /* HFS is always big endian, make swaps actually swap */
55 #define SWAP_BE16(__a) NXSwapBigShortToHost (__a)
56 #define SWAP_BE32(__a) NXSwapBigLongToHost (__a)
57 #define SWAP_BE64(__a) NXSwapBigLongLongToHost (__a)
59 #define SWAP_HFS_PLUS_FORK_DATA(__a) hfs_swap_HFSPlusForkData ((__a))
60 #define SWAP_BT_NODE(__a, __b, __c, __d) hfs_swap_BTNode ((__a), (__b), (__c), (__d))
63 #warning Unknown byte order
71 void hfs_swap_HFSPlusForkData (HFSPlusForkData
*src
);
72 int hfs_swap_BTNode (BlockDescriptor
*src
, int isHFSPlus
, HFSCatalogNodeID fileID
, int unswap
);
78 #endif /* __HFS_FORMAT__ */