[libc] Bring libc in-tree

Moving libc from its separate repo into this one, minor resulting build
fixes, and a hacky way to add -I for libc headers in builds.
This commit is contained in:
2020-08-23 17:21:08 -07:00
parent 28b800a497
commit 95a35cd0bf
216 changed files with 21033 additions and 12 deletions

View File

@@ -0,0 +1,58 @@
/* signal( int, void (*)( int ) )
This file is part of the Public Domain C Library (PDCLib).
Permission is granted to use, modify, and / or redistribute at will.
*/
#include <signal.h>
#include <stdlib.h>
void (*_PDCLIB_sigabrt)( int ) = SIG_DFL;
void (*_PDCLIB_sigfpe)( int ) = SIG_DFL;
void (*_PDCLIB_sigill)( int ) = SIG_DFL;
void (*_PDCLIB_sigint)( int ) = SIG_DFL;
void (*_PDCLIB_sigsegv)( int ) = SIG_DFL;
void (*_PDCLIB_sigterm)( int ) = SIG_DFL;
void (*signal( int sig, void (*func)( int ) ) )( int )
{
void (*oldhandler)( int );
if ( sig <= 0 || func == SIG_ERR )
{
return SIG_ERR;
}
switch ( sig )
{
case SIGABRT:
oldhandler = _PDCLIB_sigabrt;
_PDCLIB_sigabrt = func;
break;
case SIGFPE:
oldhandler = _PDCLIB_sigfpe;
_PDCLIB_sigfpe = func;
break;
case SIGILL:
oldhandler = _PDCLIB_sigill;
_PDCLIB_sigill = func;
break;
case SIGINT:
oldhandler = _PDCLIB_sigint;
_PDCLIB_sigint = func;
break;
case SIGSEGV:
oldhandler = _PDCLIB_sigsegv;
_PDCLIB_sigsegv = func;
break;
case SIGTERM:
oldhandler = _PDCLIB_sigterm;
_PDCLIB_sigterm = func;
break;
default:
/* The standard calls for an unspecified "positive value". You
will probably want to define a specific value for this.
*/
_PDCLIB_errno = 1;
return SIG_ERR;
}
return oldhandler;
}