From bd5969fc876a10b18613302db7087ef3c40f18e1 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 7 Mar 2024 17:28:00 -0500 Subject: lib: Add mlibc Signed-off-by: Ian Moffett --- lib/mlibc/options/posix/include/dirent.h | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 lib/mlibc/options/posix/include/dirent.h (limited to 'lib/mlibc/options/posix/include/dirent.h') diff --git a/lib/mlibc/options/posix/include/dirent.h b/lib/mlibc/options/posix/include/dirent.h new file mode 100644 index 0000000..b50566d --- /dev/null +++ b/lib/mlibc/options/posix/include/dirent.h @@ -0,0 +1,76 @@ + +#ifndef _DIRENT_H +#define _DIRENT_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DT_UNKNOWN 0 +#define DT_FIFO 1 +#define DT_CHR 2 +#define DT_DIR 4 +#define DT_BLK 6 +#define DT_REG 8 +#define DT_LNK 10 +#define DT_SOCK 12 +#define DT_WHT 14 + +#define __MLIBC_DIRENT_BODY ino_t d_ino; \ + off_t d_off; \ + unsigned short d_reclen; \ + unsigned char d_type; \ + char d_name[1024]; + +struct dirent { + __MLIBC_DIRENT_BODY +}; + +struct dirent64 { + __MLIBC_DIRENT_BODY +}; + +#define d_fileno d_ino + +#undef __MLIBC_DIRENT_BODY + +#define IFTODT(mode) (((mode) & 0170000) >> 12) + +struct __mlibc_dir_struct { + int __handle; + __mlibc_size __ent_next; + __mlibc_size __ent_limit; + char __ent_buffer[2048]; + struct dirent __current; +}; + +typedef struct __mlibc_dir_struct DIR; + +#ifndef __MLIBC_ABI_ONLY + +int alphasort(const struct dirent **, const struct dirent **); +int closedir(DIR *); +int dirfd(DIR *); +DIR *fdopendir(int); +DIR *opendir(const char *); +struct dirent *readdir(DIR *); +int readdir_r(DIR *__restrict, struct dirent *__restrict, struct dirent **__restrict); +void rewinddir(DIR *); +int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), + int (*)(const struct dirent **, const struct dirent **)); +void seekdir(DIR *, long); +long telldir(DIR *); +int versionsort(const struct dirent **, const struct dirent **); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif // _DIRENT_H + -- cgit v1.2.3