Path: blob/main/core/posix-wasm/src/posix-wasm.c
1396 views
#include "posix-wasm.h"1#include "public.h"23// These two are missing from zig's libc for some reason. I don't think4// it is possible to express these in ziglang either.5#include <stdarg.h>6#include <stdio.h>7int fiprintf(FILE * stream, const char * format, ...) {8va_list va;9va_start(va, format);10int d = vfprintf(stream, format, va);11va_end(va);12return d;13}14PUBLIC(fiprintf)1516int __small_fprintf(FILE * stream, const char * format, ...) {17va_list va;18va_start(va, format);19int d = vfprintf(stream, format, va);20va_end(va);21return d;22}23PUBLIC(__small_fprintf)2425int siprintf(char * s, const char * format, ...) {26va_list va;27va_start(va, format);28int d = vsprintf(s, format, va);29va_end(va);30return d;31}32PUBLIC(siprintf)3334#include <signal.h>35// It is important to define this function to actually do something, rather36// than be a pure stub function, in the case we are asking for what the37// signal handler is. This is requested in Python's PyOS_getsig, and if38// we just don't set it, then the handler is considered random nonsense.39// That's not good, since then the proper handlers from python, e.g., the40// one for sigint, don't get setup in Python's signal_get_set_handlers function.41int sigaction(int signum, const struct sigaction *restrict act,42struct sigaction *restrict oldact) {43if(act == NULL && oldact != NULL) { // getting the signal info.44oldact->sa_handler = SIG_DFL; // only this matters for python45oldact->sa_mask = 0;46oldact->sa_flags = 0;47}48return 0;49}505152