mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Remove some dead code
This commit is contained in:
parent
168d1c157e
commit
73c0faa1b5
66 changed files with 324 additions and 7705 deletions
|
@ -3,8 +3,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern bool __assert_disable;
|
||||
void __assert_fail(const char *, const char *, int) _Hide relegated;
|
||||
void __assert_fail(const char *, const char *, int) relegated;
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(x) ((void)0)
|
||||
|
@ -16,6 +15,8 @@ void __assert_fail(const char *, const char *, int) _Hide relegated;
|
|||
#define static_assert _Static_assert
|
||||
#endif
|
||||
|
||||
#ifdef COSMO
|
||||
extern bool __assert_disable;
|
||||
#ifndef NDEBUG
|
||||
#define _unassert(x) __assert_macro(x, #x)
|
||||
#define _npassert(x) __assert_macro(x, #x)
|
||||
|
@ -42,7 +43,8 @@ void __assert_fail(const char *, const char *, int) _Hide relegated;
|
|||
} \
|
||||
(void)0; \
|
||||
})
|
||||
#endif
|
||||
#endif /* NDEBUG */
|
||||
#endif /* COSMO */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
|
@ -17,17 +17,18 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/atomic.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
||||
privileged void __assert_fail(const char *expr, const char *file, int line) {
|
||||
static atomic_bool once;
|
||||
/**
|
||||
* Handles assert() failure.
|
||||
*/
|
||||
void __assert_fail(const char *expr, const char *file, int line) {
|
||||
char ibuf[12];
|
||||
if (!__assert_disable) {
|
||||
if (!atomic_exchange(&once, true)) {
|
||||
kprintf("%s:%d: assert(%s) failed (tid %P) %m\n", file, line, expr);
|
||||
}
|
||||
__builtin_trap();
|
||||
FormatInt32(ibuf, line);
|
||||
tinyprint(2, file, ":", ibuf, ": assert(", expr, ") failed\n", NULL);
|
||||
abort();
|
||||
}
|
||||
}
|
|
@ -62,7 +62,7 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
typedef int sig_atomic_t;
|
||||
|
||||
bool32 isatty(int) nosideeffect;
|
||||
bool32 isatty(int);
|
||||
char *get_current_dir_name(void) dontdiscard;
|
||||
char *getcwd(char *, size_t);
|
||||
char *realpath(const char *, char *);
|
||||
|
|
|
@ -24,11 +24,8 @@
|
|||
/**
|
||||
* Writes error messages to standard error.
|
||||
*/
|
||||
void perror(const char *message) {
|
||||
int err;
|
||||
const char *estr;
|
||||
estr = _strerdoc(errno);
|
||||
if (!message) message = "";
|
||||
if (!estr) estr = "Unknown error";
|
||||
tinyprint(2, message, *message ? ": " : "", estr, "\n", NULL);
|
||||
void perror(const char *thing) {
|
||||
const char *reason;
|
||||
if (!(reason = _strerdoc(errno))) reason = "Unknown error";
|
||||
tinyprint(2, thing ? thing : "", thing ? ": " : "", reason, "\n", NULL);
|
||||
}
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
// stub version of abort() for low-dependency apps
|
||||
// stub version of abort() to keep the build a dag
|
||||
__attribute__((__noreturn__, __weak__)) void abort(void) {
|
||||
__builtin_trap();
|
||||
}
|
||||
|
|
24
libc/intrin/assertfail.c
Normal file
24
libc/intrin/assertfail.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
// stub version of assert() to keep the build a dag
|
||||
__attribute__((__weak__)) void __assert_fail(const char *expr, const char *file,
|
||||
int line) {
|
||||
__builtin_trap();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_ALLOCA_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_ALLOCA_H_
|
||||
#ifndef _ALLOCA_H
|
||||
#define _ALLOCA_H
|
||||
#include "libc/mem/alloca.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_ALLOCA_H_ */
|
||||
#endif /* _ALLOCA_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_AR_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_AR_H_
|
||||
#ifndef _AR_H
|
||||
#define _AR_H
|
||||
#include "libc/ar.h"
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_AR_H_ */
|
||||
#endif /* _AR_H */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_ISYSTEM_COSMO_H_
|
||||
#define COSMOPOLITAN_LIBC_ISYSTEM_COSMO_H_
|
||||
#ifndef _COSMO_H
|
||||
#define _COSMO_H
|
||||
|
||||
#ifdef COSMO
|
||||
#define COSMO_ALREADY_DEFINED
|
||||
|
@ -65,4 +65,4 @@
|
|||
#undef COSMO
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_ISYSTEM_COSMO_H_ */
|
||||
#endif /* _COSMO_H */
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_MEM_ALLOCA_H_
|
||||
#define COSMOPOLITAN_LIBC_MEM_ALLOCA_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
#define alloca(size) __builtin_alloca(size)
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_MEM_ALLOCA_H_ */
|
||||
|
|
|
@ -153,7 +153,7 @@ textstartup void cosmo(long *sp, struct Syslib *m1) {
|
|||
__envp = envp;
|
||||
__auxv = auxv;
|
||||
environ = envp;
|
||||
if (argc) program_invocation_name = argv[0];
|
||||
program_invocation_name = argv[0];
|
||||
|
||||
// initialize program
|
||||
_init();
|
||||
|
|
|
@ -60,8 +60,8 @@
|
|||
? __ckd_##op##ll((__ckd_dword *)(res), (x), (y)) \
|
||||
: __ckd_trap()))
|
||||
|
||||
__funline wontreturn int __ckd_trap(void) {
|
||||
*(volatile int *)0 = 0;
|
||||
__funline int __ckd_trap(void) {
|
||||
return *(volatile int *)0 = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -240,9 +240,10 @@ static int __fmt_ntoa_format(int out(const char *, void *, size_t), void *arg,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int ntoa2(int out(const char *, void *, size_t), void *arg,
|
||||
uint128_t value, bool neg, unsigned log2base, unsigned prec,
|
||||
unsigned width, unsigned flags, const char *alphabet) {
|
||||
static int __fmt_ntoa2(int out(const char *, void *, size_t), void *arg,
|
||||
uint128_t value, bool neg, unsigned log2base,
|
||||
unsigned prec, unsigned width, unsigned flags,
|
||||
const char *alphabet) {
|
||||
uint128_t remainder;
|
||||
unsigned len, count, digit;
|
||||
char buf[BUFFER_SIZE];
|
||||
|
@ -314,7 +315,7 @@ static int __fmt_ntoa(int out(const char *, void *, size_t), void *arg,
|
|||
}
|
||||
}
|
||||
|
||||
return ntoa2(out, arg, value, neg, log2base, prec, width, flags, lang);
|
||||
return __fmt_ntoa2(out, arg, value, neg, log2base, prec, width, flags, lang);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue