summaryrefslogtreecommitdiffstats
path: root/libc-bottom-half/sources/__wasilibc_dt.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 13:54:38 +0000
commit8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch)
treedf55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-bottom-half/sources/__wasilibc_dt.c
parentInitial commit. (diff)
downloadwasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz
wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-bottom-half/sources/__wasilibc_dt.c')
-rw-r--r--libc-bottom-half/sources/__wasilibc_dt.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libc-bottom-half/sources/__wasilibc_dt.c b/libc-bottom-half/sources/__wasilibc_dt.c
new file mode 100644
index 0000000..b06460f
--- /dev/null
+++ b/libc-bottom-half/sources/__wasilibc_dt.c
@@ -0,0 +1,34 @@
+#include <__header_dirent.h>
+#include <__mode_t.h>
+
+int __wasilibc_iftodt(int x) {
+ switch (x) {
+ case S_IFDIR: return DT_DIR;
+ case S_IFCHR: return DT_CHR;
+ case S_IFBLK: return DT_BLK;
+ case S_IFREG: return DT_REG;
+ case S_IFIFO: return DT_FIFO;
+ case S_IFLNK: return DT_LNK;
+#ifdef DT_SOCK
+ case S_IFSOCK: return DT_SOCK;
+#endif
+ default: return DT_UNKNOWN;
+ }
+}
+
+int __wasilibc_dttoif(int x) {
+ switch (x) {
+ case DT_DIR: return S_IFDIR;
+ case DT_CHR: return S_IFCHR;
+ case DT_BLK: return S_IFBLK;
+ case DT_REG: return S_IFREG;
+ case DT_FIFO: return S_IFIFO;
+ case DT_LNK: return S_IFLNK;
+#ifdef DT_SOCK
+ case DT_SOCK: return S_IFSOCK;
+#endif
+ case DT_UNKNOWN:
+ default:
+ return S_IFSOCK;
+ }
+}