From 066afb3ccaff00be65eaedee194a9ddb173e8064 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Thu, 30 Dec 2021 21:14:18 +0000 Subject: [PATCH] devkitARM: remove can delete directories --- dkarm-eabi/patches/newlib-4.1.0.patch | 67 ++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/dkarm-eabi/patches/newlib-4.1.0.patch b/dkarm-eabi/patches/newlib-4.1.0.patch index a8ebdc2..3a1cae3 100644 --- a/dkarm-eabi/patches/newlib-4.1.0.patch +++ b/dkarm-eabi/patches/newlib-4.1.0.patch @@ -6704,10 +6704,10 @@ index 000000000..97a056a72 +} diff --git a/libgloss/libsysbase/rmdir.c b/libgloss/libsysbase/rmdir.c new file mode 100644 -index 000000000..2692a2997 +index 000000000..b8640b87d --- /dev/null +++ b/libgloss/libsysbase/rmdir.c -@@ -0,0 +1,25 @@ +@@ -0,0 +1,34 @@ +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> @@ -6715,24 +6715,33 @@ index 000000000..2692a2997 +#include +#include + -+int rmdir (const char *name) { -+ struct _reent *r = _REENT; ++int _rmdir_r (struct _reent *ptr, const char *name) { + int dev,ret=-1; + + dev = FindDevice(name); + if(dev!=-1) { + if(devoptab_list[dev]->rmdir_r) { -+ r->deviceData = devoptab_list[dev]->deviceData; -+ ret = devoptab_list[dev]->rmdir_r(r,name); ++ ptr->deviceData = devoptab_list[dev]->deviceData; ++ ret = devoptab_list[dev]->rmdir_r(ptr,name); + } else { -+ r->_errno = ENOSYS; ++ ptr->_errno = ENOSYS; + } + } else { -+ r->_errno = ENODEV; ++ ptr->_errno = ENODEV; + } + + return ret; +} ++ ++#ifndef _REENT_ONLY ++ ++int ++rmdir (const char *filename) ++{ ++ return _rmdir_r (_REENT, filename); ++} ++ ++#endif diff --git a/libgloss/libsysbase/sbrk.c b/libgloss/libsysbase/sbrk.c new file mode 100644 index 000000000..5dd550c5c @@ -7427,6 +7436,18 @@ index 5c293c83d..75ccf89f5 100644 /* Under Cygwin, wchar_t (or its extension wint_t) is Unicode */ #define _jp2uc(c) (c) #define _jp2uc_l(c, l) (c) +diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h +index 2b01fbe8f..7af875b81 100644 +--- a/newlib/libc/include/reent.h ++++ b/newlib/libc/include/reent.h +@@ -150,6 +150,7 @@ extern int _mkdir_r (struct _reent *, const char *, int); + extern int _open_r (struct _reent *, const char *, int, int); + extern _ssize_t _read_r (struct _reent *, int, void *, size_t); + extern int _rename_r (struct _reent *, const char *, const char *); ++extern int _rmdir_r (struct _reent *r, const char *name); + extern void *_sbrk_r (struct _reent *, ptrdiff_t); + extern int _stat_r (struct _reent *, const char *, struct stat *); + extern _CLOCK_T_ _times_r (struct _reent *, struct tms *); diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index ab18806e3..db77ebb2a 100644 --- a/newlib/libc/include/stdio.h @@ -8096,6 +8117,30 @@ index df8321461..9263e5829 100644 { /* no more input: return partial result */ #ifdef __SCLE +diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c +index d8dfdbd82..a85b5a99b 100644 +--- a/newlib/libc/stdio/remove.c ++++ b/newlib/libc/stdio/remove.c +@@ -57,13 +57,17 @@ Supporting OS subroutine required: <>. + #include <_ansi.h> + #include + #include ++#include + + int + _remove_r (struct _reent *ptr, + const char *filename) + { +- if (_unlink_r (ptr, filename) == -1) +- return -1; ++ if (_unlink_r (ptr, filename) == -1) { ++ errno = 0; ++ if (_rmdir_r(ptr, filename) == -1) ++ return -1; ++ } + + return 0; + } diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c index 1aaf05aa4..b67182a79 100644 --- a/newlib/libc/stdio/vfprintf.c @@ -8220,7 +8265,7 @@ index 000000000..40092f99f + diff --git a/newlib/libc/sys/arm/sys/lock.h b/newlib/libc/sys/arm/sys/lock.h new file mode 100644 -index 000000000..567fed56b +index 000000000..a755d6443 --- /dev/null +++ b/newlib/libc/sys/arm/sys/lock.h @@ -0,0 +1,66 @@ @@ -8254,10 +8299,10 @@ index 000000000..567fed56b +extern int __libc_lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock); + +#define __LOCK_INIT(CLASS,NAME) \ -+CLASS _LOCK_T NAME = 1; ++CLASS _LOCK_T NAME = 0; + +#define __LOCK_INIT_RECURSIVE(CLASS,NAME) \ -+CLASS _LOCK_RECURSIVE_T NAME = {1,0,0}; ++CLASS _LOCK_RECURSIVE_T NAME = {0,0,0}; + +#define __lock_init(NAME) \ + __libc_lock_init(&(NAME))