mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-01 06:28:21 +00:00
Calls to lock/unlock functions are now NOPs by default. The first time clone() is called, they get turned into CALL instructions. Doing this caused funcctions like fputc() to shrink from 85 bytes to 45+4 bytes. Since the ANSI solution of `(__threaded && lock())` inlines os much superfluous binary content into functions all over the place.
34 lines
939 B
C
34 lines
939 B
C
#ifndef COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
|
|
#define COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_
|
|
#include "libc/intrin/nopl.h"
|
|
#include "libc/intrin/pthread.h"
|
|
#include "libc/stdio/stdio.h"
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
COSMOPOLITAN_C_START_
|
|
|
|
struct StdioFlushHandles {
|
|
size_t i, n;
|
|
FILE **p;
|
|
};
|
|
|
|
struct StdioFlush {
|
|
struct StdioFlushHandles handles;
|
|
FILE *handles_initmem[8];
|
|
};
|
|
|
|
hidden extern struct StdioFlush __fflush;
|
|
|
|
void __fflush_lock(void);
|
|
void __fflush_unlock(void);
|
|
|
|
#if defined(__GNUC__) && !defined(__llvm__) && !defined(__STRICT_ANSI__)
|
|
#define __fflush_lock() _NOPL0("__threadcalls", __fflush_lock)
|
|
#define __fflush_unlock() _NOPL0("__threadcalls", __fflush_unlock)
|
|
#else
|
|
#define __fflush_lock() (__threaded ? __fflush_lock() : 0)
|
|
#define __fflush_unlock() (__threaded ? __fflush_unlock() : 0)
|
|
#endif
|
|
|
|
COSMOPOLITAN_C_END_
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
#endif /* COSMOPOLITAN_LIBC_STDIO_FFLUSH_H_ */
|