newlib: esp: add dirent.h header file

Support dirent in *-esp-* toolchains
This commit is contained in:
Alexey Lapshin 2024-08-30 09:37:36 +00:00 committed by Corinna Vinschen
parent 48f1655c95
commit cc0d1bf2f1
4 changed files with 63 additions and 8 deletions

View File

@ -312,10 +312,10 @@ install-data-local: install-toollibLIBRARIES install-multi $(INSTALL_DATA_LOCAL)
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \
else true; fi ; \
done ; \
for i in $(srcdir)/libc/machine/$(machine_dir)/include/*.h; do \
if [ -f $$i ]; then \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/`basename $$i`; \
else true; fi ; \
for i in $(call rwildcard,$(srcdir)/libc/machine/$(machine_dir)/include/,*.h); do \
f=`echo $$i | sed s:^$(srcdir)/libc/machine/$(machine_dir)/::`; \
$(MKDIR_P) $(DESTDIR)$(tooldir)/`dirname $$f`; \
$(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/`dirname $$f`; \
done ; \
for i in $(srcdir)/libc/sys/$(sys_dir)/sys/*.h; do \
if [ -f $$i ]; then \

2
newlib/configure vendored
View File

@ -6263,7 +6263,7 @@ else
/* end confdefs.h. */
#define _LIBM
// targ-include does not exist yet, use relative path
#include "../sys/xtensa/include/xtensa/config/core-isa.h"
#include "../machine/xtensa/include/xtensa/config/core-isa.h"
#if (!XCHAL_HAVE_FP_SQRT)
# error "Have not XCHAL_HAVE_FP_SQRT"
#endif

View File

@ -446,6 +446,15 @@ case "${host}" in
sys_dir=tirtos
have_crt0="no"
;;
*-esp-*)
sys_dir=esp
have_crt0="no"
posix_dir=posix
newlib_cflags="${newlib_cflags} -D_NO_GLOB -D_NO_EXECVE -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT"
newlib_cflags="${newlib_cflags} -D_NO_GETPASS -D_NO_SIGSET -D_NO_WORDEXP -D_NO_POPEN -D_NO_POSIX_SPAWN"
newlib_cflags="${newlib_cflags} -DHAVE_FCNTL -DHAVE_BLKSIZE -DHAVE_OPENDIR -DHAVE_RENAME"
newlib_cflags="${newlib_cflags} -DGETREENT_PROVIDED -DSIGNAL_PROVIDED"
;;
a29k-*-*)
sys_dir=a29khif
signal_dir=
@ -579,9 +588,6 @@ case "${host}" in
w65-*-*)
sys_dir=w65
;;
xtensa*-*-*)
sys_dir=xtensa
;;
z8k-*-coff)
sys_dir=z8ksim
;;

View File

@ -0,0 +1,49 @@
#ifndef _SYS_DIRENT_H
#define _SYS_DIRENT_H
#include <sys/cdefs.h>
#include <sys/_types.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _INO_T_DECLARED
typedef __ino_t ino_t;
#define _INO_T_DECLARED
#endif
struct dirent {
ino_t d_ino; /* file number */
__uint8_t d_type; /* file type, see below */
char d_name[255 + 1]; /* zero-terminated file name */
};
typedef struct {
__uint16_t dd_vfs_idx; /*!< VFS index, not to be used by applications */
__uint16_t dd_rsv; /*!< field reserved for future extension */
/* remaining fields are defined by VFS implementation */
} DIR;
#if __BSD_VISIBLE
#define MAXNAMLEN 255
/* File types */
#define DT_UNKNOWN 0
#define DT_REG 1
#define DT_DIR 2
/* File types which are not defined for ESP.
* But must be present to build libstd++ */
#define DT_CHR 4
#define DT_BLK 6
#define DT_FIFO 8
#define DT_LNK 10
#define DT_SOCK 12
#define DT_WHT 14
#endif
#ifdef __cplusplus
}
#endif
#endif