More compilation clean up
[yaffs2.git] / yaffs_endian.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License version 2.1 as
11  * published by the Free Software Foundation.
12  *
13  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
14  */
15
16 #ifndef __YAFFS_ENDIAN_H__
17 #define __YAFFS_ENDIAN_H__
18 #include "yaffs_guts.h"
19 #include "yaffs_packedtags2.h"
20
21 static inline u32 swap_u32(u32 val)
22 {
23         return ((val >>24) & 0x000000ff) |
24                ((val >> 8) & 0x0000ff00) |
25                ((val << 8) & 0x00ff0000) |
26                ((val <<24) & 0xff000000);
27 }
28
29 #define swap_s32(val) \
30         (s32)(swap_u32((u32)(val)))
31
32 static inline Y_LOFF_T swap_loff_t(Y_LOFF_T lval)
33 {
34         u32 vall = swap_u32((u32) (lval & 0xffffffff));
35         u32 valh;
36
37         if (sizeof(Y_LOFF_T) == sizeof(u32))
38                 return (Y_LOFF_T) vall;
39
40         valh = swap_u32((u32) ((lval >> 32) & 0xffffffff));
41
42         return (Y_LOFF_T)((((u64)vall) << 32) | valh);
43 }
44
45 void yaffs_do_endian_s32(struct yaffs_dev *dev, s32 *val);
46 void yaffs_do_endian_u32(struct yaffs_dev *dev, u32 *val);
47 void yaffs_do_endian_oh(struct yaffs_dev *dev, struct yaffs_obj_hdr *oh);
48 void yaffs_do_endian_packed_tags2(struct yaffs_dev *dev,
49                                 struct yaffs_packed_tags2_tags_only *ptt);
50 void yaffs_endian_config(struct yaffs_dev *dev);
51
52 #endif