Skip to content

Commit a15486f

Browse files
Fix asm2 compilation where __toread was used.
1 parent ea5facf commit a15486f

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

emcc

+1
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ try:
14621462
['stdio', [
14631463
'__overflow.c',
14641464
'__toread.c',
1465+
'__towrite.c',
14651466
'__uflow.c',
14661467
]],
14671468
['stdlib', [

system/lib/libc.symbols

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@
4141
W _ZnwjRKSt9nothrow_t
4242
T __floatscan
4343
T __overflow
44-
T __seek_on_exit
4544
T __shgetc
4645
T __shlim
4746
W __strtod_l
4847
W __strtof_l
4948
W __strtold_l
5049
T __toread
51-
W __towrite_used
50+
T __towrite
5251
T __uflow
5352
T _err
5453
T _errx

system/lib/libc/musl/readme.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ Differences from upstream musl include:
1010
* Disable FLOCK, FUNLOCK and FFINALLOCK
1111
* Simplify fputwc to not rely on musl stream internals
1212
* signgam is no longer a weak alias of __signgam.
13-
13+
* __toread and __towrite have had shutdown functionality removed.

system/lib/libc/musl/src/stdio/__toread.c

-10
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,3 @@ int __toread(FILE *f)
1212
f->rpos = f->rend = f->buf;
1313
return 0;
1414
}
15-
16-
static const int dummy = 0;
17-
weak_alias(dummy, __towrite_used);
18-
19-
void __stdio_exit(void);
20-
21-
void __seek_on_exit()
22-
{
23-
if (!__towrite_used) __stdio_exit();
24-
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "stdio_impl.h"
2+
3+
int __towrite(FILE *f)
4+
{
5+
f->mode |= f->mode-1;
6+
if (f->flags & (F_NOWR)) {
7+
f->flags |= F_ERR;
8+
return EOF;
9+
}
10+
/* Clear read buffer (easier than summoning nasal demons) */
11+
f->rpos = f->rend = 0;
12+
13+
/* Activate write through the buffer. */
14+
f->wpos = f->wbase = f->buf;
15+
f->wend = f->buf + f->buf_size;
16+
17+
return 0;
18+
}

0 commit comments

Comments
 (0)