Merge branch 'time_upgrade'
[yaffs2.git] / direct / ydirectenv.h
1 /*
2  * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
3  *
4  * Copyright (C) 2002-2018 Aleph One Ltd.
5  *
6  * Created by Charles Manning <charles@aleph1.co.uk>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License version 2.1 as
10  * published by the Free Software Foundation.
11  *
12  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
13  */
14
15 /*
16  * ydirectenv.h: Environment wrappers for YAFFS direct.
17  */
18
19 #ifndef __YDIRECTENV_H__
20 #define __YDIRECTENV_H__
21
22 #include "stdlib.h"
23 #include "stdio.h"
24 #include "string.h"
25 #include "yaffs_osglue.h"
26 #include "yaffs_hweight.h"
27
28 void yaffs_bug_fn(const char *file_name, int line_no);
29
30 #define BUG() do { yaffs_bug_fn(__FILE__, __LINE__); } while (0)
31
32 #ifdef YAFFS_USE_32_BIT_TIME_T
33         #define YTIME_T u32
34 #else
35         #define YTIME_T u64
36 #endif
37
38 #define YCHAR char
39 #define YUCHAR unsigned char
40 #define _Y(x) x
41
42 #ifndef Y_LOFF_T
43 #define Y_LOFF_T loff_t
44 #endif
45
46 /* Some RTOSs (eg. VxWorks) need strnlen. */
47 size_t strnlen(const char *s, size_t maxlen);
48
49 #define yaffs_strcat(a, b)      strcat(a, b)
50 #define yaffs_strcpy(a, b)      strcpy(a, b)
51 #define yaffs_strncpy(a, b, c)  strncpy(a, b, c)
52 #define yaffs_strnlen(s, m)     strnlen(s, m)
53 #ifdef CONFIG_YAFFS_CASE_INSENSITIVE
54 #define yaffs_strcmp(a, b)      strcasecmp(a, b)
55 #define yaffs_strncmp(a, b, c)  strncasecmp(a, b, c)
56 #else
57 #define yaffs_strcmp(a, b)      strcmp(a, b)
58 #define yaffs_strncmp(a, b, c)  strncmp(a, b, c)
59 #endif
60
61 #define hweight8(x)     yaffs_hweight8(x)
62 #define hweight32(x)    yaffs_hweight32(x)
63
64 #define sort(base, n, sz, cmp_fn, swp) qsort(base, n, sz, cmp_fn)
65
66 #define YAFFS_PATH_DIVIDERS  "/"
67
68 #ifdef NO_inline
69 #define inline
70 #else
71 #define inline __inline__
72 #endif
73
74 #define kmalloc(x, flags) yaffsfs_malloc(x)
75 #define kfree(x)   yaffsfs_free(x)
76 #define vmalloc(x) yaffsfs_malloc(x)
77 #define vfree(x) yaffsfs_free(x)
78
79 #define cond_resched()  do {} while (0)
80
81 #ifdef CONFIG_YAFFS_NO_TRACE
82 #define yaffs_trace(...) do { } while (0)
83 #else
84 #define yaffs_trace(msk, fmt, ...) do { \
85         if (yaffs_trace_mask & (msk)) \
86                 printf("yaffs: " fmt "\n", ##__VA_ARGS__); \
87 } while (0)
88
89 #endif
90
91 #define YAFFS_LOSTNFOUND_NAME           "lost+found"
92 #define YAFFS_LOSTNFOUND_PREFIX         "obj"
93
94 #include "yaffscfg.h"
95
96 #define Y_CURRENT_TIME yaffsfs_CurrentTime()
97 #define Y_TIME_CONVERT(x) x
98
99 #define YAFFS_ROOT_MODE                 0666
100 #define YAFFS_LOSTNFOUND_MODE           0666
101
102 #include "yaffs_list.h"
103
104 #include "yaffsfs.h"
105
106 #endif
107
108