yaffs: More clean up
[yaffs2.git] / yportenv_single.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2010 Aleph One Ltd.
5  *   for Toby Churchill Ltd and Brightstar Engineering
6  *
7  * Created by Charles Manning <charles@aleph1.co.uk>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License version 2.1 as
11  * published by the Free Software Foundation.
12  *
13  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
14  */
15
16
17 #ifndef __YPORTENV_LINUX_H__
18 #define __YPORTENV_LINUX_H__
19
20 #include <linux/version.h>
21 #include <linux/kernel.h>
22 #include <linux/mm.h>
23 #include <linux/sched.h>
24 #include <linux/string.h>
25 #include <linux/slab.h>
26 #include <linux/vmalloc.h>
27 #include <linux/xattr.h>
28 #include <linux/list.h>
29 #include <linux/types.h>
30 #include <linux/fs.h>
31 #include <linux/stat.h>
32 #include <linux/sort.h>
33
34 #define YCHAR char
35 #define YUCHAR unsigned char
36 #define _Y(x)     x
37 #define yaffs_strcat(a, b)     strcat(a, b)
38 #define yaffs_strcpy(a, b)     strcpy(a, b)
39 #define yaffs_strncpy(a, b, c) strncpy(a, b, c)
40 #define yaffs_strncmp(a, b, c) strncmp(a, b, c)
41 #define yaffs_strnlen(s,m)      strnlen(s,m)
42 #define yaffs_sprintf          sprintf
43 #define yaffs_toupper(a)       toupper(a)
44
45 #define yaffs_sort(base, n, sz, cmp_fn) sort(base, n, sz, cmp_fn, NULL)
46
47 #define Y_INLINE __inline__
48
49 #define YAFFS_LOSTNFOUND_NAME           "lost+found"
50 #define YAFFS_LOSTNFOUND_PREFIX         "obj"
51
52 #define YMALLOC(x) kmalloc(x, GFP_NOFS)
53 #define YFREE(x)   kfree(x)
54 #define YMALLOC_ALT(x) vmalloc(x)
55 #define YFREE_ALT(x)   vfree(x)
56 #define YMALLOC_DMA(x) YMALLOC(x)
57
58 #define YYIELD() schedule()
59 #define Y_DUMP_STACK() dump_stack()
60
61 #define YAFFS_ROOT_MODE                 0755
62 #define YAFFS_LOSTNFOUND_MODE           0700
63
64
65 #define Y_CURRENT_TIME CURRENT_TIME.tv_sec
66 #define Y_TIME_CONVERT(x) (x).tv_sec
67  
68 #define yaffs_sum_cmp(x, y) ((x) == (y))
69 #define yaffs_strcmp(a, b) strcmp(a, b)
70
71 #define TENDSTR "\n"
72 #define TSTR(x) KERN_DEBUG x
73 #define TCONT(x) x
74 #define TOUT(p) printk p
75
76 #define compile_time_assertion(assertion) \
77         ({ int x = __builtin_choose_expr(assertion, 0, (void)0); (void) x; })
78
79
80
81 #ifndef Y_DUMP_STACK
82 #define Y_DUMP_STACK() do { } while (0)
83 #endif
84
85 #ifndef YBUG
86 #define YBUG() do {\
87         T(YAFFS_TRACE_BUG,\
88                 (TSTR("==>> yaffs bug: " __FILE__ " %d" TENDSTR),\
89                 __LINE__));\
90         Y_DUMP_STACK();\
91 } while (0)
92 #endif
93
94
95 #endif