};
struct __libc {
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
int can_do_threads;
int threaded;
+#endif
+#ifdef __wasilibc_unmodified_upstream // WASI doesn't currently use any code that needs "secure" mode
int secure;
+#endif
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
volatile int threads_minus_1;
+#endif
+#ifdef __wasilibc_unmodified_upstream // WASI has no auxv
size_t *auxv;
+#endif
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
struct tls_module *tls_head;
size_t tls_size, tls_align, tls_cnt;
+#endif
+#ifdef __wasilibc_unmodified_upstream // WASI doesn't get the page size from auxv
size_t page_size;
+#endif
struct __locale_struct global_locale;
#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
#else
unsigned char *rpos, *rend;
int (*close)(FILE *);
unsigned char *wend, *wpos;
+#ifdef __wasilibc_unmodified_upstream // WASI doesn't need backwards-compatibility fields.
unsigned char *mustbezero_1;
+#endif
unsigned char *wbase;
size_t (*read)(FILE *, unsigned char *, size_t);
size_t (*write)(FILE *, const unsigned char *, size_t);
size_t buf_size;
FILE *prev, *next;
int fd;
+#ifdef __wasilibc_unmodified_upstream // WASI has no popen
int pipe_pid;
+#endif
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
long lockcount;
+#endif
int mode;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
volatile int lock;
+#endif
int lbf;
void *cookie;
off_t off;
char *getln_buf;
+#ifdef __wasilibc_unmodified_upstream // WASI doesn't need backwards-compatibility fields.
void *mustbezero_2;
+#endif
unsigned char *shend;
off_t shlim, shcnt;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
FILE *prev_locked, *next_locked;
+#endif
struct __locale_struct *locale;
};
f->seek = __stdio_seek;
f->close = __stdio_close;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
if (!libc.threaded) f->lock = -1;
+#endif
/* Add new FILE to open file list */
return __ofl_add(f);
f->read = __stdio_read;
f->seek = __stdio_seek;
f->close = __stdio_close;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
f->lock = -1;
+#endif
return f;
}
f->f.seek = mseek;
f->f.close = mclose;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
if (!libc.threaded) f->f.lock = -1;
+#endif
return __ofl_add(&f->f);
}
f->f.close = ms_close;
f->f.mode = -1;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
if (!libc.threaded) f->f.lock = -1;
+#endif
return __ofl_add(&f->f);
}
f->f.seek = wms_seek;
f->f.close = wms_close;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
if (!libc.threaded) f->f.lock = -1;
+#endif
fwide(&f->f, 1);
.write = __stdio_write,
.seek = __stdio_seek,
.close = __stdio_close,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1,
+#endif
};
FILE *const stderr = &__stderr_FILE;
FILE *volatile __stderr_used = &__stderr_FILE;
.read = __stdio_read,
.seek = __stdio_seek,
.close = __stdio_close,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1,
+#endif
};
FILE *const stdin = &__stdin_FILE;
FILE *volatile __stdin_used = &__stdin_FILE;
.write = __stdout_write,
.seek = __stdio_seek,
.close = __stdio_close,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1,
+#endif
};
FILE *const stdout = &__stdout_FILE;
FILE *volatile __stdout_used = &__stdout_FILE;
FILE f = {
.fd = fd, .lbf = EOF, .write = wrap_write,
.buf = (void *)fmt, .buf_size = 0,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1
+#endif
};
return vfprintf(&f, fmt, ap);
}
FILE f = {
.lbf = EOF,
.write = sn_write,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1,
+#endif
.buf = buf,
.cookie = &c,
};
{
FILE f = {
.buf = (void *)s, .cookie = (void *)s,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.read = do_read, .lock = -1
+#else
+ .read = do_read
+#endif
};
return vfscanf(&f, fmt, ap);
}
FILE f = {
.lbf = EOF,
.write = sw_write,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.lock = -1,
+#endif
.buf = buf,
.buf_size = sizeof buf,
.cookie = &c,
FILE f = {
.buf = buf, .buf_size = sizeof buf,
.cookie = (void *)s,
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
.read = wstring_read, .lock = -1
+#else
+ .read = wstring_read
+#endif
};
return vfwscanf(&f, fmt, ap);
}
f.rpos = f.rend = 0;
f.buf = buf + 4;
f.buf_size = sizeof buf - 4;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
f.lock = -1;
+#endif
f.read = do_read;
while (iswspace(*t)) t++;
f.cookie = (void *)t;
f.rpos = f.rend = 0;
f.buf = buf + 4;
f.buf_size = sizeof buf - 4;
+#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
f.lock = -1;
+#endif
f.read = do_read;
while (iswspace(*t)) t++;
f.cookie = (void *)t;