aboutsummaryrefslogtreecommitdiff
path: root/ubifs-utils/common/defs.h
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2024-11-11 16:36:54 +0800
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-11-11 10:32:45 +0100
commit5695488f61fd824c758979d055576c61599ecc57 (patch)
tree02da6786a32b720e1098674bdb0675447aeb56a2 /ubifs-utils/common/defs.h
parentd539a3951fc5eba852b1fd79e151e1879611a5df (diff)
ubifs-utils: Add common definitions in linux kernel
Add common definitions in linux kernel, which are used in UBIFS linux kernel libs. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'ubifs-utils/common/defs.h')
-rw-r--r--ubifs-utils/common/defs.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h
index 548d9df..ac46d83 100644
--- a/ubifs-utils/common/defs.h
+++ b/ubifs-utils/common/defs.h
@@ -11,8 +11,11 @@
#include <unistd.h>
#include <limits.h>
#include <errno.h>
+#include <time.h>
+#include <assert.h>
#include <execinfo.h>
+#include "linux_types.h"
#include "ubifs.h"
/* common.h requires the PROGRAM_NAME macro */
@@ -76,8 +79,41 @@ static inline void dump_stack(void)
free(strings);
}
+static inline u32 get_random_u32(void)
+{
+ srand(time(NULL));
+ return rand();
+}
+
+static inline time_t ktime_get_seconds(void)
+{
+ return time(NULL);
+}
+
+#define likely(x) (x)
#define unlikely(x) (x)
+#define cond_resched() do {} while(0)
+
+#define BUG() do { \
+ assert(0); \
+} while(0)
+#define BUG_ON(cond) do { \
+ assert(!cond); \
+} while(0)
+
+#define smp_wmb() do {} while(0)
+#define smp_rmb() do {} while(0)
+#define smp_mb__before_atomic() do {} while(0)
+#define smp_mb__after_atomic() do {} while(0)
+
+#define min3(x, y, z) min((typeof(x))min(x, y), z)
+
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+ return dividend / divisor;
+}
+
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \