mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix MODE=tinylinux build
This commit is contained in:
parent
8c645fa1ee
commit
6be030cd7c
8 changed files with 77 additions and 98 deletions
|
@ -16,39 +16,32 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/stdio/internal.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/thread/thread.h"
|
||||
|
||||
static FILE __stdout = {
|
||||
.fd = STDOUT_FILENO,
|
||||
.iomode = O_WRONLY,
|
||||
.buf = __stdout.mem,
|
||||
.size = sizeof(stdout->mem),
|
||||
.lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP,
|
||||
|
||||
// Unlike other C libraries we don't bother calling fstat() to check
|
||||
// if stdio is a character device and we instead choose to always
|
||||
// line buffer it. We need it because there's no way to use the
|
||||
// unbuffer command on a statically linked binary. This still goes
|
||||
// fast. We value latency more than throughput, and stdio isn't the
|
||||
// best api when the goal is throughput.
|
||||
.bufmode = _IOLBF,
|
||||
};
|
||||
|
||||
/**
|
||||
* Pointer to standard output stream.
|
||||
*/
|
||||
FILE *stdout;
|
||||
|
||||
static FILE __stdout;
|
||||
FILE *stdout = &__stdout;
|
||||
|
||||
__attribute__((__constructor__(60))) static textstartup void outinit(void) {
|
||||
stdout = &__stdout;
|
||||
|
||||
stdout->fd = STDOUT_FILENO;
|
||||
stdout->iomode = O_WRONLY;
|
||||
stdout->buf = stdout->mem;
|
||||
stdout->size = sizeof(stdout->mem);
|
||||
stdout->lock._word = PTHREAD_MUTEX_RECURSIVE;
|
||||
|
||||
/*
|
||||
* Unlike other C libraries we don't bother calling fstat() to check
|
||||
* if stdio is a character device and we instead choose to always line
|
||||
* buffer it. We need it because there's no way to use the unbuffer
|
||||
* command on a statically linked binary. This still goes fast. We
|
||||
* value latency more than throughput, and stdio isn't the best api
|
||||
* when the goal is throughput.
|
||||
*/
|
||||
stdout->bufmode = _IOLBF;
|
||||
|
||||
__fflush_register(stdout);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue