mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Add more fixes for new cosmocc toolchain
We now have an `#include <cxxabi.h>` header which defines all the APIs Cosmopolitan's implemented so far. The `cosmocc` README.md file is now greatly expanded with documentation.
This commit is contained in:
parent
95124cacbe
commit
c6d3802d3a
32 changed files with 256 additions and 69 deletions
|
@ -34,15 +34,19 @@
|
|||
*
|
||||
* Note `SIG_DFL` still results in process death for most signals.
|
||||
*
|
||||
* POSIX defines raise() errors as returning non-zero and makes setting
|
||||
* `errno` optional. Every platform we've tested in our support vector
|
||||
* returns -1 with `errno` on error (like a normal system call).
|
||||
*
|
||||
* @param sig can be SIGALRM, SIGINT, SIGTERM, SIGKILL, etc.
|
||||
* @return 0 on success, or nonzero on failure
|
||||
* @return 0 on success, or -1 w/ errno
|
||||
* @raise EINVAL if `sig` is invalid
|
||||
* @asyncsignalsafe
|
||||
*/
|
||||
int raise(int sig) {
|
||||
int rc;
|
||||
if (IsXnuSilicon()) {
|
||||
rc = __syslib->__raise(sig);
|
||||
rc = _sysret(__syslib->__raise(sig));
|
||||
} else if (IsWindows()) {
|
||||
if (0 <= sig && sig <= 64) {
|
||||
__sig_raise(sig, SI_TKILL);
|
||||
|
|
17
libc/cxxabi.h
Normal file
17
libc/cxxabi.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef _CXXABI_H
|
||||
#define _CXXABI_H
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
union CxaGuardValue;
|
||||
|
||||
char *__cxa_demangle(const char *, char *, size_t *, int *);
|
||||
int __cxa_atexit(void (*)(void *), void *, void *) paramsnonnull((1)) dontthrow;
|
||||
int __cxa_guard_acquire(union CxaGuardValue *);
|
||||
int __cxa_thread_atexit(void *, void *, void *) dontthrow;
|
||||
void __cxa_finalize(void *);
|
||||
void __cxa_guard_abort(union CxaGuardValue *) dontthrow;
|
||||
void __cxa_guard_release(union CxaGuardValue *) dontthrow;
|
||||
void __cxa_pure_virtual(void) wontreturn;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* _CXXABI_H */
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/dns/hoststxt.h"
|
||||
#include "libc/dns/servicestxt.h"
|
||||
|
@ -64,7 +65,7 @@ const struct HostsTxt *GetHostsTxt(void) {
|
|||
init->ht.entries.p = init->entries;
|
||||
init->ht.strings.n = pushpop(ARRAYLEN(init->strings));
|
||||
init->ht.strings.p = init->strings;
|
||||
__cxa_atexit(FreeHostsTxt, &g_hoststxt, NULL);
|
||||
__cxa_atexit((void *)FreeHostsTxt, &g_hoststxt, NULL);
|
||||
if ((f = fopen(GetHostsTxtPath(pathbuf, sizeof(pathbuf)), "r"))) {
|
||||
if (ParseHostsTxt(g_hoststxt, f) == -1) {
|
||||
/* TODO(jart): Elevate robustness. */
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/dns/resolvconf.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
|
@ -48,7 +49,7 @@ const struct ResolvConf *GetResolvConf(void) {
|
|||
g_resolvconf = &init->rv;
|
||||
pushmov(&init->rv.nameservers.n, ARRAYLEN(init->nameservers));
|
||||
init->rv.nameservers.p = init->nameservers;
|
||||
__cxa_atexit(FreeResolvConf, &g_resolvconf, NULL);
|
||||
__cxa_atexit((void *)FreeResolvConf, &g_resolvconf, NULL);
|
||||
if (!IsWindows()) {
|
||||
if ((f = fopen("/etc/resolv.conf", "r"))) {
|
||||
rc = ParseResolvConf(g_resolvconf, f);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
/**
|
||||
|
@ -29,5 +30,5 @@
|
|||
* @return 0 on success or nonzero if out of space
|
||||
*/
|
||||
int atexit(void f(void)) {
|
||||
return __cxa_atexit(f, 0, 0);
|
||||
return __cxa_atexit((void *)f, 0, 0);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ void __cxa_lock(void);
|
|||
void __cxa_unlock(void);
|
||||
void __cxa_thread_finalize(void);
|
||||
void __cxa_printexits(FILE *, void *);
|
||||
int __cxa_thread_atexit(void *, void *, void *);
|
||||
int __cxa_thread_atexit_impl(void *, void *, void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "libc/log/libfatal.internal.h"
|
||||
#include "libc/nexgen32e/stackframe.h"
|
||||
|
||||
#define N 100
|
||||
#define N 160
|
||||
|
||||
dontinstrument const char *(DescribeBacktrace)(char buf[N],
|
||||
struct StackFrame *fr) {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
const char *DescribeBacktrace(char[100], struct StackFrame *);
|
||||
#define DescribeBacktrace(x) DescribeBacktrace(alloca(100), x)
|
||||
const char *DescribeBacktrace(char[160], struct StackFrame *);
|
||||
#define DescribeBacktrace(x) DescribeBacktrace(alloca(160), x)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include "libc/cxxabi.h"
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "libc/calls/struct/utsname.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/describebacktrace.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/limits.h"
|
||||
#include "third_party/nsync/futex.internal.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
|
|
|
@ -36,7 +36,6 @@ int ftrace_init(void);
|
|||
void ftrace_hook(void);
|
||||
void __morph_tls(void);
|
||||
void __enable_tls(void);
|
||||
void *__cxa_finalize(void *);
|
||||
void __stack_chk_fail(void) wontreturn relegated;
|
||||
void __stack_chk_fail_local(void) wontreturn relegated;
|
||||
long _setstack(void *, void *, ...);
|
||||
|
|
|
@ -36,7 +36,6 @@ void _exit(int) libcesque wontreturn;
|
|||
void _Exit(int) libcesque wontreturn;
|
||||
void quick_exit(int) wontreturn;
|
||||
void abort(void) wontreturn;
|
||||
int __cxa_atexit(void *, void *, void *) paramsnonnull((1)) libcesque;
|
||||
int atexit(void (*)(void)) paramsnonnull() libcesque;
|
||||
char *getenv(const char *) paramsnonnull() __wur nosideeffect libcesque;
|
||||
int putenv(char *);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
│ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/pushpop.internal.h"
|
||||
|
@ -111,7 +112,7 @@ textstartup int __fflush_register(FILE *f) {
|
|||
if (!sf->handles.p) {
|
||||
sf->handles.p = sf->handles_initmem;
|
||||
pushmov(&sf->handles.n, ARRAYLEN(sf->handles_initmem));
|
||||
__cxa_atexit(fflush_unlocked, 0, 0);
|
||||
__cxa_atexit((void *)fflush_unlocked, 0, 0);
|
||||
}
|
||||
for (i = sf->handles.i; i; --i) {
|
||||
if (!sf->handles.p[i - 1]) {
|
||||
|
|
|
@ -180,12 +180,6 @@ int fprintf_unlocked(FILE *, const char *, ...) printfesque(2)
|
|||
int vfprintf_unlocked(FILE *, const char *, va_list)
|
||||
paramsnonnull() dontthrow nocallback;
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § cxxabi ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
||||
char *__cxa_demangle(const char *, char *, size_t *, int *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_STDIO_H_ */
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/cxaatexit.internal.h"
|
||||
|
|
|
@ -38,7 +38,7 @@ struct CosmoTib {
|
|||
uint32_t tib_sigstack_flags;
|
||||
void **tib_keys;
|
||||
void *tib_nsync;
|
||||
void *tib_todo[63];
|
||||
void *tib_todo[7];
|
||||
};
|
||||
|
||||
extern int __threaded;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define LOCALTIME_IMPLEMENTATION
|
||||
#include "libc/calls/blockcancel.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/cxxabi.h"
|
||||
#include "libc/intrin/bits.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue