*** 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 General Public License version 2 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-N-FOUND"\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 \r
61 \r
62 #define TENDSTR "\r\n"\r
63 #define TSTR(x) TEXT(x)\r
64 #define T(x) RETAILMSG(1, x)\r
65 \r
66 \r
67 #elif  defined __KERNEL__\r
68 \r
69 \r
70 \r
71 // Linux kernel\r
72 #include "linux/kernel.h"\r
73 #include "linux/mm.h"\r
74 #include "linux/string.h"\r
75 #include "linux/slab.h"\r
76 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
77 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
78 \r
79 #define YPRINTF(x) printk x\r
80 #define YMALLOC(x) kmalloc(x,GFP_KERNEL)\r
81 #define YFREE(x)   kfree(x)\r
82 \r
83 #define YAFFS_ROOT_MODE                         0666\r
84 \r
85 \r
86 #define yaffs_SumCompare(x,y) ((x) == (y))\r
87 #define yaffs_strcmp(a,b) strcmp(a,b)\r
88 \r
89 #define TENDSTR "\n"\r
90 #define TSTR(x) KERN_DEBUG x\r
91 #define T(x) printk x\r
92 \r
93 \r
94 #else\r
95 \r
96 // Linux application\r
97 #include "stdlib.h"\r
98 #include "stdio.h"\r
99 #include "string.h"\r
100 \r
101 #define YMALLOC(x) malloc(x)\r
102 #define YFREE(x)   free(x)\r
103 \r
104 \r
105 #define YINFO(s) YPRINTF(( __FILE__ " %d %s\n",__LINE__,s))\r
106 #define YALERT(s) YINFO(s)\r
107 \r
108 \r
109 #define TENDSTR "\n"\r
110 #define TSTR(x) x\r
111 #define T(x) printf x\r
112 \r
113 \r
114 #define YAFFS_LOSTNFOUND_NAME           "lost+found"\r
115 #define YAFFS_LOSTNFOUND_PREFIX         "obj"\r
116 #define YPRINTF(x) printf x\r
117 \r
118 #define CURRENT_TIME 0\r
119 #define YAFFS_ROOT_MODE                         0666\r
120 \r
121 #define yaffs_SumCompare(x,y) ((x) == (y))\r
122 #define yaffs_strcmp(a,b) strcmp(a,b)\r
123 \r
124 #endif \r
125 \r
126 \r
127 \r
128 #undef YINFO\r
129 \r
130 \r
131 #define YINFO(s) YPRINTF((KERN_DEBUG __FILE__ " %d %s\n",__LINE__,s))\r
132 #define YALERT(s) YINFO(s)\r
133 \r
134 \r
135 \r
136 #endif\r