Import 2.1.112pre1
[davej-history.git] / fs / ntfs / types.h
blobeabcd8590b36a367ad8982644f27f4bbbe387df5
1 /*
2 * types.h
3 * This file defines four things:
4 * - generic platform independent fixed-size types (e.g. ntfs_u32)
5 * - specific fixed-size types (e.g. ntfs_offset_t)
6 * - macros that read and write those types from and to byte arrays
7 * - types derived from OS specific ones
9 * Copyright (C) 1996 Martin von Löwis
12 #ifdef NTFS_IN_LINUX_KERNEL
13 /* get installed types if we compile the kernel*/
14 #include <linux/fs.h>
15 #endif
17 #if defined(i386) || defined(__i386__) || defined(__alpha__)
19 /* unsigned integral types */
20 #ifndef NTFS_INTEGRAL_TYPES
21 #define NTFS_INTEGRAL_TYPES
22 typedef unsigned char ntfs_u8;
23 typedef unsigned short ntfs_u16;
24 typedef unsigned int ntfs_u32;
25 typedef unsigned long long ntfs_u64;
26 #endif
28 /* unicode character type */
29 #ifndef NTFS_WCHAR_T
30 #define NTFS_WCHAR_T
31 typedef unsigned short ntfs_wchar_t;
32 #endif
33 /* file offset */
34 #ifndef NTFS_OFFSET_T
35 #define NTFS_OFFSET_T
36 typedef unsigned long long ntfs_offset_t;
37 #endif
38 /* UTC */
39 #ifndef NTFS_TIME64_T
40 #define NTFS_TIME64_T
41 typedef unsigned long long ntfs_time64_t;
42 #endif
43 /* This is really unsigned long long. So we support only volumes up to 2 TB */
44 #ifndef NTFS_CLUSTER_T
45 #define NTFS_CLUSTER_T
46 typedef unsigned int ntfs_cluster_t;
47 #endif
49 /* Macros reading unsigned integers from a byte pointer */
50 /* these should work for all little endian machines */
51 #define NTFS_GETU8(p) (*(ntfs_u8*)(p))
52 #define NTFS_GETU16(p) (*(ntfs_u16*)(p))
53 #define NTFS_GETU24(p) (NTFS_GETU32(p) & 0xFFFFFF)
54 #define NTFS_GETU32(p) (*(ntfs_u32*)(p))
55 #define NTFS_GETU64(p) (*(ntfs_u64*)(p))
57 /* Macros writing unsigned integers */
58 #define NTFS_PUTU8(p,v) (*(ntfs_u8*)(p))=(v)
59 #define NTFS_PUTU16(p,v) (*(ntfs_u16*)(p))=(v)
60 #define NTFS_PUTU24(p,v) NTFS_PUTU16(p,(v) & 0xFFFF);\
61 NTFS_PUTU8(((char*)p)+2,(v)>>16)
62 #define NTFS_PUTU32(p,v) (*(ntfs_u32*)(p))=(v)
63 #define NTFS_PUTU64(p,v) (*(ntfs_u64*)(p))=(v)
65 /* Macros reading signed integers, returning int */
66 #define NTFS_GETS8(p) ((int)(*(char*)(p)))
67 #define NTFS_GETS16(p) ((int)(*(short*)(p)))
68 #define NTFS_GETS24(p) (NTFS_GETU24(p) < 0x800000 ? (int)NTFS_GETU24(p) : (int)(NTFS_GETU24(p) | 0xFF000000))
70 #define NTFS_PUTS8(p,v) NTFS_PUTU8(p,v)
71 #define NTFS_PUTS16(p,v) NTFS_PUTU16(p,v)
72 #define NTFS_PUTS24(p,v) NTFS_PUTU24(p,v)
73 #define NTFS_PUTS32(p,v) NTFS_PUTU32(p,v)
75 #else
76 #error Put your machine description here
77 #endif
79 /* architecture independent macros */
81 /* PUTU32 would not clear all bytes */
82 #define NTFS_PUTINUM(p,i) NTFS_PUTU64(p,i->i_number);\
83 NTFS_PUTU16(((char*)p)+6,i->sequence_number)
85 /* system dependent types */
86 #ifdef __linux__
87 /* We always need kernel types, because glibc makes them of different size */
88 #include <asm/posix_types.h>
89 /* Avoid a type redefinition with future include of glibc <stdlib.h> */
90 #undef __FD_ZERO
91 #undef __FD_SET
92 #undef __FD_CLR
93 #undef __FD_ISSET
94 #ifndef NTMODE_T
95 #define NTMODE_T
96 typedef __kernel_mode_t ntmode_t;
97 #endif
98 #ifndef NTFS_UID_T
99 #define NTFS_UID_T
100 typedef __kernel_uid_t ntfs_uid_t;
101 #endif
102 #ifndef NTFS_GID_T
103 #define NTFS_GID_T
104 typedef __kernel_gid_t ntfs_gid_t;
105 #endif
106 #ifndef NTFS_SIZE_T
107 #define NTFS_SIZE_T
108 typedef __kernel_size_t ntfs_size_t;
109 #endif
110 #ifndef NTFS_TIME_T
111 #define NTFS_TIME_T
112 typedef __kernel_time_t ntfs_time_t;
113 #endif
114 #else
115 #include <sys/types.h>
116 #include <sys/stat.h>
117 typedef mode_t ntmode_t;
118 typedef uid_t ntfs_uid_t;
119 typedef gid_t ntfs_gid_t;
120 typedef size_t ntfs_size_t;
121 typedef time_t ntfs_time_t;
122 #endif
125 * Local variables:
126 * c-file-style: "linux"
127 * End: