*** empty log message ***
[yaffs/.git] / yportenv.h
1 /*\r
2  * YAFFS: Yet another FFS. A NAND-flash specific file system. \r
3  * yportenv.h: Portable services used by yaffs. This is done to allow\r
4  * simple migration from kernel space into app space for testing.\r
5  *\r
6  * Copyright (C) 2002 Aleph One Ltd.\r
7  *   for Toby Churchill Ltd and Brightstar Engineering\r
8  *\r
9  * Created by Charles Manning <charles@aleph1.co.uk>\r
10  *\r
11  * This program is free software; you can redistribute it and/or modify\r
12  * it under the terms of the GNU Lesser General Public License version 2.1 as\r
13  * published by the Free Software Foundation.\r
14  *\r
15  */\r
16  \r
17 #ifndef __PORTENV_H__\r
18 #define __PORTENV_H__\r
19 \r
20 \r
21 #if defined WIN32\r
22 \r
23 // Win32\r
24 #include "stdlib.h"\r
25 #include "stdio.h"\r
26 #include "string.h"\r
27 \r
28 #define YMALLOC(x) malloc(x)\r
29 #define YFREE(x)   free(x)\r
30 \r
31 \r
32 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
33 #define YALERT(s) YINFO(s)\r
34 \r
35 #include <windows.h>\r
36 \r
37 #define YAFFS_LOSTNFOUND_NAME           "LOST_CLUSTERS"\r
38 #define YAFFS_LOSTNFOUND_PREFIX         "OBJ"\r
39 \r
40 #define YPRINTF(x)\r
41 \r
42 // Always pass the sum compare to overcome the case insensitivity issue\r
43 #define yaffs_SumCompare(x,y) 1\r
44 #define yaffs_strcmp(a,b) _stricmp(a,b)\r
45 \r
46 \r
47 #define u_char unsigned char\r
48 #define loff_t int\r
49 #define S_IFDIR                                         04000\r
50 \r
51 #define S_ISFIFO(x) 0\r
52 #define S_ISCHR(x) 0\r
53 #define S_ISBLK(x) 0\r
54 #define S_ISSOCK(x) 0\r
55 \r
56 extern unsigned yfsd_U32FileTimeNow(void);\r
57 \r
58 #define CURRENT_TIME                             yfsd_U32FileTimeNow()\r
59 #define YAFFS_ROOT_MODE                         FILE_ATTRIBUTE_ARCHIVE\r
60 #define YAFFS_LOSTNFOUND_MODE           (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN)\r
61 \r
62 \r
63 #define TENDSTR "\r\n"\r
64 #define TSTR(x) TEXT(x)\r
65 #define T(x) RETAILMSG(1, x)\r
66 \r
67 \r
68 #elif  defined __KERNEL__\r
69 \r
70 \r
71 \r
72 // Linux kernel\r
73 #include "linux/kernel.h"\r
74 #include "linux/mm.h"\r
75 #include "linux/string.h"\r
76 #include "linux/slab.h"\r
77 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
78 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
79 \r
80 #define YPRINTF(x) printk x\r
81 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)\r
82 #define YFREE(x)   kfree(x)\r
83 \r
84 #define YAFFS_ROOT_MODE                         0666\r
85 #define YAFFS_LOSTNFOUND_MODE           0666\r
86 \r
87 \r
88 #define yaffs_SumCompare(x,y) ((x) == (y))\r
89 #define yaffs_strcmp(a,b) strcmp(a,b)\r
90 \r
91 #define TENDSTR "\n"\r
92 #define TSTR(x) KERN_DEBUG x\r
93 #define T(x) printk x\r
94 \r
95 \r
96 #else\r
97 \r
98 // Linux application\r
99 #include "stdlib.h"\r
100 #include "stdio.h"\r
101 #include "string.h"\r
102 \r
103 #define YMALLOC(x) malloc(x)\r
104 #define YFREE(x)   free(x)\r
105 \r
106 \r
107 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
108 #define YALERT(s) YINFO(s)\r
109 \r
110 \r
111 #define TENDSTR "\n"\r
112 #define TSTR(x) x\r
113 #define T(x) printf x\r
114 \r
115 \r
116 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
117 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
118 #define YPRINTF(x) printf x\r
119 \r
120 #define CURRENT_TIME 0\r
121 #define YAFFS_ROOT_MODE                         0666\r
122 #define YAFFS_LOSTNFOUND_MODE           0666\r
123 \r
124 #define yaffs_SumCompare(x,y) ((x) == (y))\r
125 #define yaffs_strcmp(a,b) strcmp(a,b)\r
126 \r
127 #endif \r
128 \r
129 \r
130 \r
131 #undef YINFO\r
132 \r
133 \r
134 #define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))\r
135 #define YALERT(s) YINFO(s)\r
136 \r
137 #define YBUG() do{YINFO("bug");} while(0)\r
138 \r
139 \r
140 #endif\r