Skip to content

Commit 556a2a2

Browse files
committed
devkitPPC: refill buffer for large reads
1 parent 6da9ea3 commit 556a2a2

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

dkppc/patches/newlib-3.3.0.patch

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8096,7 +8096,7 @@ index 022992b8d..bdf4c7bb0 100644
80968096
fp->_flags = flags;
80978097
fp->_cookie = (void *) fp;
80988098
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c
8099-
index b358d2b4a..95493cd66 100644
8099+
index b358d2b4a..78bb0df30 100644
81008100
--- a/newlib/libc/stdio/fread.c
81018101
+++ b/newlib/libc/stdio/fread.c
81028102
@@ -187,7 +187,6 @@ _fread_r (struct _reent * ptr,
@@ -8116,7 +8116,7 @@ index b358d2b4a..95493cd66 100644
81168116
resid -= fp->_r;
81178117
p += fp->_r;
81188118
fp->_r = 0;
8119-
@@ -225,7 +224,30 @@ _fread_r (struct _reent * ptr,
8119+
@@ -225,7 +224,29 @@ _fread_r (struct _reent * ptr,
81208120
/* fp->_r = 0 ... done in __srefill */
81218121
p += r;
81228122
resid -= r;
@@ -8130,7 +8130,7 @@ index b358d2b4a..95493cd66 100644
81308130
+ int old_size = fp->_bf._size;
81318131
+ /* allow __refill to use user's buffer */
81328132
+ fp->_bf._base = (unsigned char *) p;
8133-
+ fp->_bf._size = resid;
8133+
+ fp->_bf._size = resid - old_size;
81348134
+ fp->_p = (unsigned char *) p;
81358135
+ rc = __srefill_r (ptr, fp);
81368136
+ /* restore fp buffering back to original state */
@@ -8139,12 +8139,11 @@ index b358d2b4a..95493cd66 100644
81398139
+ fp->_p = old_base;
81408140
+ resid -= fp->_r;
81418141
+ p += fp->_r;
8142-
+ fp->_r = 0;
8143-
+
8144-
+ } else {
8145-
+ rc = __srefill_r (ptr, fp);
8142+
+ //fp->_r = 0;
81468143
+ }
8147-
+ if (rc)
8144+
+ rc = __srefill_r (ptr, fp);
8145+
+
8146+
+ if (rc)
81488147
{
81498148
/* no more input: return partial result */
81508149
#ifdef __SCLE

0 commit comments

Comments
 (0)