UbixOS  2.0
fat_types.h
Go to the documentation of this file.
1 #ifndef __FAT_TYPES_H__
2 #define __FAT_TYPES_H__
3 
4 // Detect 64-bit compilation on GCC
5 #if defined(__GNUC__) && defined(__SIZEOF_LONG__)
6  #if __SIZEOF_LONG__ == 8
7  #define FATFS_DEF_UINT32_AS_INT
8  #endif
9 #endif
10 
11 //-------------------------------------------------------------
12 // System specific types
13 //-------------------------------------------------------------
14 #ifndef FATFS_NO_DEF_TYPES
15  typedef unsigned char uint8;
16  typedef unsigned short uint16;
17 
18  // If compiling on a 64-bit machine, use int as 32-bits
19  #ifdef FATFS_DEF_UINT32_AS_INT
20  typedef unsigned int uint32;
21  // Else for 32-bit machines & embedded systems, use long...
22  #else
23  typedef unsigned long uint32;
24  #endif
25 #endif
26 
27 #ifndef NULL
28  #define NULL 0
29 #endif
30 
31 //-------------------------------------------------------------
32 // Endian Macros
33 //-------------------------------------------------------------
34 // FAT is little endian so big endian systems need to swap words
35 
36 // Little Endian - No swap required
37 #if FATFS_IS_LITTLE_ENDIAN == 1
38 
39  #define FAT_HTONS(n) (n)
40  #define FAT_HTONL(n) (n)
41 
42 // Big Endian - Swap required
43 #else
44 
45  #define FAT_HTONS(n) ((((uint16)((n) & 0xff)) << 8) | (((n) & 0xff00) >> 8))
46  #define FAT_HTONL(n) (((((uint32)(n) & 0xFF)) << 24) | \
47  ((((uint32)(n) & 0xFF00)) << 8) | \
48  ((((uint32)(n) & 0xFF0000)) >> 8) | \
49  ((((uint32)(n) & 0xFF000000)) >> 24))
50 
51 #endif
52 
53 //-------------------------------------------------------------
54 // Structure Packing Compile Options
55 //-------------------------------------------------------------
56 #ifdef __GNUC__
57  #define STRUCT_PACK
58  #define STRUCT_PACK_BEGIN
59  #define STRUCT_PACK_END
60  #define STRUCT_PACKED __attribute__ ((packed))
61 #else
62  // Other compilers may require other methods of packing structures
63  #define STRUCT_PACK
64  #define STRUCT_PACK_BEGIN
65  #define STRUCT_PACK_END
66  #define STRUCT_PACKED
67 #endif
68 
69 #endif
uint8
unsigned char uint8
Definition: fat_types.h:15
uint16
unsigned short uint16
Definition: fat_types.h:16
uint32
unsigned long uint32
Definition: fat_types.h:23