]> git.saurik.com Git - apple/xnu.git/blame - bsd/hfs/hfs_endian.h
xnu-123.5.tar.gz
[apple/xnu.git] / bsd / hfs / hfs_endian.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#ifndef __HFS_ENDIAN_H__
23#define __HFS_ENDIAN_H__
24
25/*
26 * hfs_endian.h
27 *
28 * This file prototypes endian swapping routines for the HFS/HFS Plus
29 * volume format.
30 */
31#include "hfs.h"
32#include "hfscommon/headers/BTreesInternal.h"
33#include <architecture/byte_order.h>
34
35/*********************/
36/* BIG ENDIAN Macros */
37/*********************/
38#if BYTE_ORDER == BIG_ENDIAN
39
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)
44
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)
48
49/************************/
50/* LITTLE ENDIAN Macros */
51/************************/
52#elif BYTE_ORDER == LITTLE_ENDIAN
53
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)
58
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))
61
62#else
63#warning Unknown byte order
64#error
65#endif
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71void hfs_swap_HFSPlusForkData (HFSPlusForkData *src);
72int hfs_swap_BTNode (BlockDescriptor *src, int isHFSPlus, HFSCatalogNodeID fileID, int unswap);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* __HFS_FORMAT__ */