b2293a62fbdf4236092590d21e67ed5c451d93a7
[yaffs2.git] / direct / ydirectenv.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2011 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  * ydirectenv.h: Environment wrappers for YAFFS direct.
18  */
19
20 #ifndef __YDIRECTENV_H__
21 #define __YDIRECTENV_H__
22
23 #include "stdlib.h"
24 #include "stdio.h"
25 #include "string.h"
26 #include "yaffs_osglue.h"
27 #include "yaffs_hweight.h"
28
29 void yaffs_bug_fn(const char *file_name, int line_no);
30
31 #define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
32
33
34 #define YCHAR char
35 #define YUCHAR unsigned char
36 #define _Y(x) x
37
38 #ifndef Y_LOFF_T
39 #define Y_LOFF_T loff_t
40 #endif
41
42 #define yaffs_strcat(a, b)      strcat(a, b)
43 #define yaffs_strcpy(a, b)      strcpy(a, b)
44 #define yaffs_strncpy(a, b, c)  strncpy(a, b, c)
45 #define yaffs_strnlen(s, m)     strnlen(s, m)
46 #ifdef CONFIG_YAFFS_CASE_INSENSITIVE
47 #define yaffs_strcmp(a, b)      strcasecmp(a, b)
48 #define yaffs_strncmp(a, b, c)  strncasecmp(a, b, c)
49 #else
50 #define yaffs_strcmp(a, b)      strcmp(a, b)
51 #define yaffs_strncmp(a, b, c)  strncmp(a, b, c)
52 #endif
53
54 #define hweight8(x)     yaffs_hweight8(x)
55 #define hweight32(x)    yaffs_hweight32(x)
56
57 void yaffs_qsort(void *aa, size_t n, size_t es,
58                 int (*cmp)(const void *, const void *));
59
60 #define sort(base, n, sz, cmp_fn, swp) yaffs_qsort(base, n, sz, cmp_fn)
61
62 #define YAFFS_PATH_DIVIDERS  "/"
63
64 #ifdef NO_inline
65 #define inline
66 #else
67 #define inline __inline__
68 #endif
69
70 #define kmalloc(x, flags) yaffsfs_malloc(x)
71 #define kfree(x)   yaffsfs_free(x)
72 #define vmalloc(x) yaffsfs_malloc(x)
73 #define vfree(x) yaffsfs_free(x)
74
75 #define cond_resched()  do {} while (0)
76
77 #define yaffs_trace(msk, fmt, ...) do { \
78         if (yaffs_trace_mask & (msk)) \
79                 printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
80 } while (0)
81
82
83 #define YAFFS_LOSTNFOUND_NAME           "lost+found"
84 #define YAFFS_LOSTNFOUND_PREFIX         "obj"
85
86 #include "yaffscfg.h"
87
88 #define Y_CURRENT_TIME yaffsfs_CurrentTime()
89 #define Y_TIME_CONVERT(x) x
90
91 #define YAFFS_ROOT_MODE                 0666
92 #define YAFFS_LOSTNFOUND_MODE           0666
93
94 #include "yaffs_list.h"
95
96 #include "yaffsfs.h"
97
98 #endif
99
100