2021-01-28 03:34:02 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
|
2022-09-10 18:55:39 +00:00
|
|
|
#include "libc/intrin/nopl.internal.h"
|
2021-01-28 03:34:02 +00:00
|
|
|
#include "libc/stdio/stdio.h"
|
2022-10-03 20:43:52 +00:00
|
|
|
#include "libc/thread/thread.h"
|
|
|
|
#include "libc/thread/tls.h"
|
2021-01-28 03:34:02 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
|
|
|
struct StdioFlushHandles {
|
|
|
|
size_t i, n;
|
|
|
|
FILE **p;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct StdioFlush {
|
|
|
|
struct StdioFlushHandles handles;
|
|
|
|
FILE *handles_initmem[8];
|
|
|
|
};
|
|
|
|
|
2023-07-24 15:31:54 +00:00
|
|
|
extern struct StdioFlush __fflush;
|
|
|
|
extern pthread_mutex_t __fflush_lock_obj;
|
2021-01-28 03:34:02 +00:00
|
|
|
|
2022-06-12 18:47:20 +00:00
|
|
|
void __fflush_lock(void);
|
|
|
|
void __fflush_unlock(void);
|
2022-06-13 02:33:42 +00:00
|
|
|
|
2022-06-26 09:58:36 +00:00
|
|
|
#ifdef _NOPL0
|
2022-06-13 02:33:42 +00:00
|
|
|
#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock)
|
|
|
|
#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock)
|
|
|
|
#else
|
2022-06-12 18:47:20 +00:00
|
|
|
#define __fflush_lock() (__threaded ? __fflush_lock() : 0)
|
|
|
|
#define __fflush_unlock() (__threaded ? __fflush_unlock() : 0)
|
2022-06-13 02:33:42 +00:00
|
|
|
#endif
|
2022-06-12 18:47:20 +00:00
|
|
|
|
2021-01-28 03:34:02 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */
|