Skip to content

Commit 066afb3

Browse files
committed
devkitARM: remove can delete directories
1 parent dd13eb9 commit 066afb3

1 file changed

Lines changed: 56 additions & 11 deletions

File tree

dkarm-eabi/patches/newlib-4.1.0.patch

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6704,35 +6704,44 @@ index 000000000..97a056a72
67046704
+}
67056705
diff --git a/libgloss/libsysbase/rmdir.c b/libgloss/libsysbase/rmdir.c
67066706
new file mode 100644
6707-
index 000000000..2692a2997
6707+
index 000000000..b8640b87d
67086708
--- /dev/null
67096709
+++ b/libgloss/libsysbase/rmdir.c
6710-
@@ -0,0 +1,25 @@
6710+
@@ -0,0 +1,34 @@
67116711
+#include "config.h"
67126712
+#include <_ansi.h>
67136713
+#include <_syslist.h>
67146714
+#include <reent.h>
67156715
+#include <errno.h>
67166716
+#include <sys/iosupport.h>
67176717
+
6718-
+int rmdir (const char *name) {
6719-
+ struct _reent *r = _REENT;
6718+
+int _rmdir_r (struct _reent *ptr, const char *name) {
67206719
+ int dev,ret=-1;
67216720
+
67226721
+ dev = FindDevice(name);
67236722
+ if(dev!=-1) {
67246723
+ if(devoptab_list[dev]->rmdir_r) {
6725-
+ r->deviceData = devoptab_list[dev]->deviceData;
6726-
+ ret = devoptab_list[dev]->rmdir_r(r,name);
6724+
+ ptr->deviceData = devoptab_list[dev]->deviceData;
6725+
+ ret = devoptab_list[dev]->rmdir_r(ptr,name);
67276726
+ } else {
6728-
+ r->_errno = ENOSYS;
6727+
+ ptr->_errno = ENOSYS;
67296728
+ }
67306729
+ } else {
6731-
+ r->_errno = ENODEV;
6730+
+ ptr->_errno = ENODEV;
67326731
+ }
67336732
+
67346733
+ return ret;
67356734
+}
6735+
+
6736+
+#ifndef _REENT_ONLY
6737+
+
6738+
+int
6739+
+rmdir (const char *filename)
6740+
+{
6741+
+ return _rmdir_r (_REENT, filename);
6742+
+}
6743+
+
6744+
+#endif
67366745
diff --git a/libgloss/libsysbase/sbrk.c b/libgloss/libsysbase/sbrk.c
67376746
new file mode 100644
67386747
index 000000000..5dd550c5c
@@ -7427,6 +7436,18 @@ index 5c293c83d..75ccf89f5 100644
74277436
/* Under Cygwin, wchar_t (or its extension wint_t) is Unicode */
74287437
#define _jp2uc(c) (c)
74297438
#define _jp2uc_l(c, l) (c)
7439+
diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h
7440+
index 2b01fbe8f..7af875b81 100644
7441+
--- a/newlib/libc/include/reent.h
7442+
+++ b/newlib/libc/include/reent.h
7443+
@@ -150,6 +150,7 @@ extern int _mkdir_r (struct _reent *, const char *, int);
7444+
extern int _open_r (struct _reent *, const char *, int, int);
7445+
extern _ssize_t _read_r (struct _reent *, int, void *, size_t);
7446+
extern int _rename_r (struct _reent *, const char *, const char *);
7447+
+extern int _rmdir_r (struct _reent *r, const char *name);
7448+
extern void *_sbrk_r (struct _reent *, ptrdiff_t);
7449+
extern int _stat_r (struct _reent *, const char *, struct stat *);
7450+
extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
74307451
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
74317452
index ab18806e3..db77ebb2a 100644
74327453
--- a/newlib/libc/include/stdio.h
@@ -8096,6 +8117,30 @@ index df8321461..9263e5829 100644
80968117
{
80978118
/* no more input: return partial result */
80988119
#ifdef __SCLE
8120+
diff --git a/newlib/libc/stdio/remove.c b/newlib/libc/stdio/remove.c
8121+
index d8dfdbd82..a85b5a99b 100644
8122+
--- a/newlib/libc/stdio/remove.c
8123+
+++ b/newlib/libc/stdio/remove.c
8124+
@@ -57,13 +57,17 @@ Supporting OS subroutine required: <<unlink>>.
8125+
#include <_ansi.h>
8126+
#include <reent.h>
8127+
#include <stdio.h>
8128+
+#include <errno.h>
8129+
8130+
int
8131+
_remove_r (struct _reent *ptr,
8132+
const char *filename)
8133+
{
8134+
- if (_unlink_r (ptr, filename) == -1)
8135+
- return -1;
8136+
+ if (_unlink_r (ptr, filename) == -1) {
8137+
+ errno = 0;
8138+
+ if (_rmdir_r(ptr, filename) == -1)
8139+
+ return -1;
8140+
+ }
8141+
8142+
return 0;
8143+
}
80998144
diff --git a/newlib/libc/stdio/vfprintf.c b/newlib/libc/stdio/vfprintf.c
81008145
index 1aaf05aa4..b67182a79 100644
81018146
--- a/newlib/libc/stdio/vfprintf.c
@@ -8220,7 +8265,7 @@ index 000000000..40092f99f
82208265
+
82218266
diff --git a/newlib/libc/sys/arm/sys/lock.h b/newlib/libc/sys/arm/sys/lock.h
82228267
new file mode 100644
8223-
index 000000000..567fed56b
8268+
index 000000000..a755d6443
82248269
--- /dev/null
82258270
+++ b/newlib/libc/sys/arm/sys/lock.h
82268271
@@ -0,0 +1,66 @@
@@ -8254,10 +8299,10 @@ index 000000000..567fed56b
82548299
+extern int __libc_lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock);
82558300
+
82568301
+#define __LOCK_INIT(CLASS,NAME) \
8257-
+CLASS _LOCK_T NAME = 1;
8302+
+CLASS _LOCK_T NAME = 0;
82588303
+
82598304
+#define __LOCK_INIT_RECURSIVE(CLASS,NAME) \
8260-
+CLASS _LOCK_RECURSIVE_T NAME = {1,0,0};
8305+
+CLASS _LOCK_RECURSIVE_T NAME = {0,0,0};
82618306
+
82628307
+#define __lock_init(NAME) \
82638308
+ __libc_lock_init(&(NAME))

0 commit comments

Comments
 (0)