mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Introduce #include <cosmo.h>
to toolchain users
This change improves the way internal APIs are being hidden behind the `COSMO` define. The cosmo.h header will take care of defining that, so that a separate define statement isn't needed. This change also does a lot more to define which APIs are standard, and which belong to Cosmo.
This commit is contained in:
parent
9b55dbe417
commit
4a59210008
115 changed files with 699 additions and 422 deletions
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dos.h"
|
||||
#include "libc/dos.internal.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/check.h"
|
||||
|
@ -29,7 +29,7 @@
|
|||
#include "libc/time/struct/tm.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "net/http/http.h"
|
||||
#include "third_party/zlib/zlib.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "tool/build/lib/loader.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/elf/elf.h"
|
||||
|
@ -34,7 +35,6 @@
|
|||
#include "third_party/xed/x86.h"
|
||||
#include "tool/build/lib/argv.h"
|
||||
#include "tool/build/lib/endian.h"
|
||||
#include "tool/build/lib/loader.h"
|
||||
#include "tool/build/lib/machine.h"
|
||||
#include "tool/build/lib/memory.h"
|
||||
|
||||
|
@ -105,7 +105,7 @@ static void LoadBin(struct Machine *m, intptr_t base, const char *prog,
|
|||
.p_vaddr = base,
|
||||
.p_paddr = base,
|
||||
.p_filesz = codesize,
|
||||
.p_memsz = ROUNDUP(codesize + FRAMESIZE, BIGPAGESIZE),
|
||||
.p_memsz = ROUNDUP(codesize + FRAMESIZE, 0x200000),
|
||||
.p_align = PAGESIZE,
|
||||
};
|
||||
LoadElfLoadSegment(m, code, codesize, &phdr);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "libc/calls/pledge.internal.h"
|
||||
#include "libc/calls/struct/rlimit.h"
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#include "libc/calls/struct/seccomp.h"
|
||||
#include "libc/calls/struct/seccomp.internal.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/calls/struct/sysinfo.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
|
@ -373,24 +373,6 @@ int UnveilIfExists(const char *path, const char *perm) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MakeProcessNice(void) {
|
||||
if (!g_nice) return;
|
||||
if (setpriority(PRIO_PROCESS, 0, 19) == -1) {
|
||||
kprintf("error: setpriority(PRIO_PROCESS, 0, 19) failed: %m\n");
|
||||
exit(23);
|
||||
}
|
||||
if (ioprio_set(IOPRIO_WHO_PROCESS, 0,
|
||||
IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)) == -1) {
|
||||
kprintf("error: ioprio_set() failed: %m\n");
|
||||
exit(23);
|
||||
}
|
||||
struct sched_param p = {sched_get_priority_min(SCHED_IDLE)};
|
||||
if (sched_setscheduler(0, SCHED_IDLE, &p) == -1) {
|
||||
kprintf("error: sched_setscheduler(SCHED_IDLE) failed: %m\n");
|
||||
exit(23);
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyFilesystemPolicy(unsigned long ipromises) {
|
||||
const char *p;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "libc/sysv/consts/map.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "third_party/getopt/getopt.h"
|
||||
#include "tool/build/lib/elfwriter.h"
|
||||
#include "tool/build/lib/stripcomponents.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/nt/enum/fileflagandattributes.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "tool/decode/lib/zipnames.h"
|
||||
|
||||
const struct IdName kZipCompressionNames[] = {
|
||||
|
|
|
@ -70,10 +70,10 @@
|
|||
├────────────┼─────────────┼────────────────────────────────┼────────────┤
|
||||
│ [ ? ] │ About │ this page │ │
|
||||
└────────────┴─────────────┴────────────────────────────────┴────────────┘ */
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/str/strwidth.h"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/x/xiso8601.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "tool/decode/lib/asmcodegen.h"
|
||||
#include "tool/decode/lib/disassemblehex.h"
|
||||
#include "tool/decode/lib/zipnames.h"
|
||||
|
|
|
@ -1773,12 +1773,9 @@ Keywords={
|
|||
"__SAUCE__",
|
||||
"PAGESIZE",
|
||||
"FRAMESIZE",
|
||||
"BIGPAGESIZE",
|
||||
"STACKSIZE",
|
||||
"ARG_MAX",
|
||||
"PATH_MAX",
|
||||
"BUFSIZ",
|
||||
"CACHELINE",
|
||||
"CHAR_BIT",
|
||||
"NAME_MAX",
|
||||
"NSIG",
|
||||
|
|
|
@ -177,14 +177,12 @@
|
|||
(defconst cosmo-cpp-constants-cosmopolitan
|
||||
'("__SAUCE__"
|
||||
"PAGESIZE"
|
||||
"GUARDSIZE"
|
||||
"APE_STACKSIZE"
|
||||
"APE_GUARDSIZE"
|
||||
"FRAMESIZE"
|
||||
"BIGPAGESIZE"
|
||||
"STACKSIZE"
|
||||
"ARG_MAX"
|
||||
"PATH_MAX"
|
||||
"BUFSIZ"
|
||||
"CACHELINE"
|
||||
"CHAR_BIT"
|
||||
"NAME_MAX"
|
||||
"NSIG"
|
||||
|
|
|
@ -98,7 +98,7 @@ static struct DecodeJson Parse(struct lua_State *L, const char *p,
|
|||
if (UNLIKELY(!depth)) {
|
||||
return (struct DecodeJson){-1, "maximum depth exceeded"};
|
||||
}
|
||||
if (UNLIKELY(!HaveStackMemory(GUARDSIZE))) {
|
||||
if (UNLIKELY(!HaveStackMemory(APE_GUARDSIZE))) {
|
||||
return (struct DecodeJson){-1, "out of stack"};
|
||||
}
|
||||
for (a = p, d = +1; p < e;) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/dns/dns.h"
|
||||
#include "libc/dns/hoststxt.h"
|
||||
#include "libc/dos.h"
|
||||
#include "libc/dos.internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
|
@ -104,7 +104,7 @@
|
|||
#include "libc/thread/tls.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/zip.internal.h"
|
||||
#include "net/http/escape.h"
|
||||
#include "net/http/http.h"
|
||||
#include "net/http/ip.h"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_TOOL_NET_SANDBOX_H_
|
||||
#define COSMOPOLITAN_TOOL_NET_SANDBOX_H_
|
||||
#include "libc/calls/struct/bpf.h"
|
||||
#include "libc/calls/struct/filter.h"
|
||||
#include "libc/calls/struct/seccomp.h"
|
||||
#include "libc/calls/struct/bpf.internal.h"
|
||||
#include "libc/calls/struct/filter.internal.h"
|
||||
#include "libc/calls/struct/seccomp.internal.h"
|
||||
#include "libc/sysv/consts/audit.h"
|
||||
// clang-format off
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
#include "libc/intrin/bits.h"
|
||||
#include "libc/intrin/kprintf.h"
|
||||
#include "libc/log/color.internal.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/gc.h"
|
||||
#include "libc/nexgen32e/cpuid4.internal.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/nexgen32e/rdtscp.h"
|
||||
#include "libc/nexgen32e/x86feature.h"
|
||||
#include "libc/nexgen32e/x86info.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "libc/x/xasprintf.h"
|
||||
|
|
|
@ -481,17 +481,17 @@ static void *NewBoard(size_t *out_size) {
|
|||
char *p;
|
||||
size_t s, n, k;
|
||||
s = (byn * bxn) >> 3;
|
||||
k = GUARDSIZE + ROUNDUP(s, GUARDSIZE);
|
||||
n = ROUNDUP(k + GUARDSIZE, FRAMESIZE);
|
||||
k = APE_GUARDSIZE + ROUNDUP(s, APE_GUARDSIZE);
|
||||
n = ROUNDUP(k + APE_GUARDSIZE, FRAMESIZE);
|
||||
p = _mapanon(n);
|
||||
mprotect(p, GUARDSIZE, 0);
|
||||
mprotect(p, APE_GUARDSIZE, 0);
|
||||
mprotect(p + k, n - k, 0);
|
||||
if (out_size) *out_size = n;
|
||||
return p + GUARDSIZE;
|
||||
return p + APE_GUARDSIZE;
|
||||
}
|
||||
|
||||
static void FreeBoard(void *p, size_t n) {
|
||||
munmap((char *)p - GUARDSIZE, n);
|
||||
munmap((char *)p - APE_GUARDSIZE, n);
|
||||
}
|
||||
|
||||
static void AllocateBoardsWithHardwareAcceleratedMemorySafety(void) {
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/x/xgetline.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue