Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2017-03-26 00:20:31 +0300
committerChristopher Haster <chaster@utexas.edu>2017-03-26 03:23:26 +0300
commit84a57642e53616e1b9f8050e58dd21eecf168184 (patch)
treed4986b73926097e4c9ca7149bda9c39b5d5600fb /lfs_util.h
parentf5668462234a5b216c3ed018efb22048146d5047 (diff)
Restructured the major interfaces of the filesystem
Diffstat (limited to 'lfs_util.h')
-rw-r--r--lfs_util.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/lfs_util.h b/lfs_util.h
new file mode 100644
index 0000000..6211328
--- /dev/null
+++ b/lfs_util.h
@@ -0,0 +1,38 @@
+/*
+ * lfs utility functions
+ *
+ * Copyright (c) 2017 Christopher Haster
+ * Distributed under the MIT license
+ */
+#ifndef LFS_UTIL_H
+#define LFS_UTIL_H
+
+#include "lfs_config.h"
+
+
+// Builtin functions
+static inline uint32_t lfs_max(uint32_t a, uint32_t b) {
+ return (a > b) ? a : b;
+}
+
+static inline uint32_t lfs_min(uint32_t a, uint32_t b) {
+ return (a < b) ? a : b;
+}
+
+static inline uint32_t lfs_ctz(uint32_t a) {
+ return __builtin_ctz(a);
+}
+
+static inline uint32_t lfs_npw2(uint32_t a) {
+ return 32 - __builtin_clz(a-1);
+}
+
+static inline int lfs_scmp(uint32_t a, uint32_t b) {
+ return (int)(unsigned)(a - b);
+}
+
+uint32_t lfs_crc(const void *buffer, lfs_size_t size, uint32_t crc);
+
+
+
+#endif