Dash:
[t2.git] / package / filesystem / gpart / ntfs.patch
blob415466722a1759a36f11224f494892b034450e82
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../gpart/ntfs.patch
5 # Copyright (C) 2006 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 # --- T2-COPYRIGHT-NOTE-END ---
17 From Debian.
19 --- gpart-0.1h.orig/src/gm_ntfs.h
20 +++ gpart-0.1h/src/gm_ntfs.h
21 @@ -14,6 +14,9 @@
25 +#include <stdint.h>
26 +#include <asm/byteorder.h>
28 #ifndef _GM_NTFS_H
29 #define _GM_NTFS_H
31 @@ -29,32 +32,38 @@
32 /* 'NTFS' in little endian */
33 #define NTFS_SUPER_MAGIC 0x5346544E
35 -#if defined(i386) || defined(__i386__) || defined(__alpha__)
37 /* unsigned integral types */
38 #ifndef NTFS_INTEGRAL_TYPES
39 #define NTFS_INTEGRAL_TYPES
40 -typedef unsigned char ntfs_u8;
41 -typedef unsigned short ntfs_u16;
42 -typedef unsigned int ntfs_u32;
43 -typedef s64_t ntfs_u64;
44 +typedef uint8_t ntfs_u8;
45 +typedef uint16_t ntfs_u16;
46 +typedef uint32_t ntfs_u32;
47 +typedef uint64_t ntfs_u64;
48 +typedef int8_t ntfs_s8;
49 +typedef int16_t ntfs_s16;
50 #endif /* NTFS_INTEGRAL_TYPES */
51 -#endif /* defined(i386) || defined(__i386__) || defined(__alpha__) */
54 -/* Macros reading unsigned integers from a byte pointer */
55 -/* these should work for all little endian machines */
56 -#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
57 -#define NTFS_GETU16(p) (*(ntfs_u16*)(p))
58 -#define NTFS_GETU24(p) (NTFS_GETU32(p) & 0xFFFFFF)
59 -#define NTFS_GETU32(p) (*(ntfs_u32*)(p))
60 -#define NTFS_GETU64(p) (*(ntfs_u64*)(p))
62 -/* Macros reading signed integers, returning int */
63 -#define NTFS_GETS8(p) ((int)(*(char*)(p)))
64 -#define NTFS_GETS16(p) ((int)(*(short*)(p)))
65 -#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? (int)NTFS_GETU24(p) :
68 +#define CPU_TO_LE16(a) __cpu_to_le16(a)
69 +#define CPU_TO_LE32(a) __cpu_to_le32(a)
70 +#define CPU_TO_LE64(a) __cpu_to_le64(a)
72 +#define LE16_TO_CPU(a) __cpu_to_le16(a)
73 +#define LE32_TO_CPU(a) __cpu_to_le32(a)
74 +#define LE64_TO_CPU(a) __cpu_to_le64(a)
76 +/* Macros reading unsigned integers */
77 +#define NTFS_GETU8(p) (*(ntfs_u8*)(p))
78 +#define NTFS_GETU16(p) ((ntfs_u16)LE16_TO_CPU(*(ntfs_u16*)(p)))
79 +#define NTFS_GETU24(p) ((ntfs_u32)NTFS_GETU16(p) | \
80 + ((ntfs_u32)NTFS_GETU8(((char*)(p)) + 2) << 16))
81 +#define NTFS_GETU32(p) ((ntfs_u32)LE32_TO_CPU(*(ntfs_u32*)(p)))
82 +#define NTFS_GETU64(p) ((ntfs_u64)LE64_TO_CPU(*(ntfs_u64*)(p)))
84 +/* Macros reading signed integers */
85 +#define NTFS_GETS8(p) ((*(ntfs_s8*)(p)))
86 +#define NTFS_GETS16(p) ((ntfs_s16)LE16_TO_CPU(*(short*)(p)))
87 +#define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? \
88 + (int)NTFS_GETU24(p) : \
89 + (int)(NTFS_GETU24(p) - 0x1000000))
91 #endif /* _GM_NTFS_H */