mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Prove that Makefile is fully defined
The whole repository is now buildable with GNU Make Landlock sandboxing. This proves that no Makefile targets exist which touch files other than their declared prerequisites. In order to do this, we had to: 1. Stop code morphing GCC output in package.com and instead run a newly introduced FIXUPOBJ.COM command after GCC invocations. 2. Disable all the crumby Python unit tests that do things like create files in the current directory, or rename() files between folders. This ended up being a lot of tests, but most of them are still ok. 3. Introduce an .UNSANDBOXED variable to GNU Make to disable Landlock. We currently only do this for things like `make tags`. 4. This change deletes some GNU Make code that was preventing the execve() optimization from working. This means it should no longer be necessary in most cases for command invocations to be indirected through the cocmd interpreter. 5. Missing dependencies had to be declared in certain places, in cases where they couldn't be automatically determined by MKDEPS.COM 6. The libcxx header situation has finally been tamed. One of the things that makes this difficult is MKDEPS.COM only wants to consider the first 64kb of a file, in order to go fast. But libcxx likes to have #include lines buried after huge documentation. 7. An .UNVEIL variable has been introduced to GNU Make just in case we ever wish to explicitly specify additional things that need to be whitelisted which aren't strictly prerequisites. This works in a manner similar to the recently introduced .EXTRA_PREREQS feature. There's now a new build/bootstrap/make.com prebuilt binary available. It should no longer be possible to write invalid Makefile code.
This commit is contained in:
parent
acdf591833
commit
cf93ecbbb2
181 changed files with 1902 additions and 1986 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/ifconf.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/iff.h"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "libc/mem/mem.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/ifconf.h"
|
||||
#include "libc/sock/struct/ifreq.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/sio.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
/*-*- 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 2022 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 │
|
||||
|
@ -16,30 +16,62 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/systeminfo.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#define kTmpPathMax 80
|
||||
/**
|
||||
* RII constant holding temporary file directory.
|
||||
*
|
||||
* The order of precedence is:
|
||||
*
|
||||
* - $TMPDIR/
|
||||
* - GetTempPath()
|
||||
* - /tmp/
|
||||
*
|
||||
* This guarantees trailing slash.
|
||||
*/
|
||||
char kTmpPath[PATH_MAX];
|
||||
|
||||
// RII constant holding /tmp/ directory.
|
||||
//
|
||||
// @note on win32 this is firstNonNull($TMP, $TEMP, $PWD)
|
||||
// @note guarantees trailing slash if non-empty
|
||||
.initbss 300,_init_kTmpPath
|
||||
kTmpPath:
|
||||
.zero kTmpPathMax
|
||||
.endobj kTmpPath,globl
|
||||
.previous
|
||||
static inline int IsAlpha(int c) {
|
||||
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
|
||||
}
|
||||
|
||||
.init.start 300,_init_kTmpPath
|
||||
movl $'/'|'t'<<010|'m'<<020|'p'<<030,(%rdi)
|
||||
movw $'/',4(%rdi)
|
||||
#if SupportsWindows()
|
||||
pushpop kTmpPathMax,%rdx
|
||||
ezlea GetTempPathA_flunk,ax
|
||||
call __getntsyspath
|
||||
#else
|
||||
add $kTmpPathMax,%rdi
|
||||
#endif
|
||||
.init.end 300,_init_kTmpPath
|
||||
__attribute__((__constructor__)) static void kTmpPathInit(void) {
|
||||
int i;
|
||||
char *s;
|
||||
uint32_t n;
|
||||
char16_t path16[PATH_MAX];
|
||||
|
||||
if ((s = getenv("TMPDIR")) && (n = strlen(s)) < PATH_MAX) {
|
||||
memcpy(kTmpPath, s, n);
|
||||
if (n && kTmpPath[n - 1] != '/') {
|
||||
kTmpPath[n + 0] = '/';
|
||||
kTmpPath[n + 1] = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsWindows() &&
|
||||
((n = GetTempPath(ARRAYLEN(path16), path16)) && n < ARRAYLEN(path16))) {
|
||||
// turn c:\foo\bar\ into c:/foo/bar/
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (path16[i] == '\\') {
|
||||
path16[i] = '/';
|
||||
}
|
||||
}
|
||||
// turn c:/... into /c/...
|
||||
if (IsAlpha(path16[0]) && path16[1] == ':' && path16[2] == '/') {
|
||||
path16[1] = path16[0];
|
||||
path16[0] = '/';
|
||||
path16[2] = '/';
|
||||
}
|
||||
tprecode16to8(kTmpPath, sizeof(kTmpPath), path16);
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(kTmpPath, "/tmp/");
|
||||
}
|
|
@ -7,6 +7,8 @@ struct iovec {
|
|||
size_t iov_len;
|
||||
};
|
||||
|
||||
ssize_t readv(int, const struct iovec *, int);
|
||||
ssize_t writev(int, const struct iovec *, int);
|
||||
ssize_t preadv(int, struct iovec *, int, int64_t);
|
||||
ssize_t pwritev(int, const struct iovec *, int, int64_t);
|
||||
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/dns/resolvconf.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
|
||||
#define DNS_PORT 53
|
||||
#define DNS_NAME_MAX 253
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
static struct ResolvConf *g_resolvconf;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_DNS_HOSTSTXT_H_
|
||||
#define COSMOPOLITAN_LIBC_DNS_HOSTSTXT_H_
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
|
@ -38,8 +38,8 @@ static textwindows noasan bool IsBeingDebugged(void) {
|
|||
*/
|
||||
int IsDebuggerPresent(bool force) {
|
||||
/* asan runtime depends on this function */
|
||||
int fd, res;
|
||||
ssize_t got;
|
||||
int e, fd, res;
|
||||
char *p, buf[1024];
|
||||
if (!force && IsGenuineCosmo()) return 0;
|
||||
if (!force && __getenv(environ, "HEISENDEBUG")) return 0;
|
||||
|
@ -47,6 +47,7 @@ int IsDebuggerPresent(bool force) {
|
|||
if (__isworker) return false;
|
||||
if (!PLEDGED(RPATH)) return false;
|
||||
res = 0;
|
||||
e = errno;
|
||||
if ((fd = __sysv_open("/proc/self/status", O_RDONLY, 0)) >= 0) {
|
||||
if ((got = __sysv_read(fd, buf, sizeof(buf) - 1)) > 0) {
|
||||
buf[got] = '\0';
|
||||
|
@ -57,5 +58,6 @@ int IsDebuggerPresent(bool force) {
|
|||
}
|
||||
__sysv_close(fd);
|
||||
}
|
||||
errno = e;
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ PKGS += LIBC
|
|||
|
||||
LIBC_HDRS = $(filter %.h,$(LIBC_FILES))
|
||||
LIBC_INCS = $(filter %.inc,$(LIBC_FILES))
|
||||
LIBC_FILES := $(wildcard libc/*)
|
||||
LIBC_FILES := $(wildcard libc/*) $(wildcard libc/isystem/*)
|
||||
LIBC_CHECKS = $(LIBC_HDRS:%=o/$(MODE)/%.ok)
|
||||
|
||||
.PHONY: o/$(MODE)/libc
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
.real
|
||||
.code16 # ∩ .code32 ∩ .code64
|
||||
|
||||
// Function Profiling Hook.
|
||||
// cc -pg adds this to the start of global functions.
|
||||
|
|
|
@ -143,7 +143,8 @@ o/libc/nt/ntdllimport.inc: \
|
|||
libc/nt/ntdllimport.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macros.internal.inc \
|
||||
libc/macros-cpp.internal.inc
|
||||
libc/macros-cpp.internal.inc \
|
||||
libc/intrin/asancodes.h
|
||||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
@ -368,11 +369,17 @@ $(LIBC_NT_PSAPI_A).pkg: \
|
|||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
$(LIBC_NT_OBJS): o/libc/nt/codegen.inc
|
||||
$(LIBC_NT_OBJS): \
|
||||
o/libc/nt/codegen.inc
|
||||
|
||||
o/libc/nt/codegen.inc: \
|
||||
ape/idata.internal.h \
|
||||
ape/macros.internal.h
|
||||
ape/macros.internal.h \
|
||||
ape/relocations.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macros.internal.inc \
|
||||
libc/macros-cpp.internal.inc \
|
||||
libc/intrin/asancodes.h
|
||||
|
||||
.PHONY: o/$(MODE)/libc/nt
|
||||
o/$(MODE)/libc/nt: \
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "libc/nt/struct/pollfd.h"
|
||||
#include "libc/nt/struct/timeval.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
/* ░▓█████████████████████████████████████████████▓▒
|
||||
░█▓░░░░░░░░░▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▒░
|
||||
░█▓░ ░▒▒▒▒ ▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▒▒
|
||||
|
|
|
@ -35,7 +35,7 @@ static double rt_log2(double x)
|
|||
|
||||
static int mp, sccfirst;
|
||||
static unsigned int monte[MONTEN];
|
||||
static long inmont, mcount;
|
||||
static long inmont, mcount_;
|
||||
static double cexp_, incirc, montex, montey, montepi,
|
||||
scc, sccun, sccu0, scclast, scct1, scct2, scct3,
|
||||
ent, chisq, datasum;
|
||||
|
@ -55,7 +55,7 @@ void rt_init(int binmode)
|
|||
datasum = 0.0; /* Clear sum of bytes for arithmetic mean */
|
||||
|
||||
mp = 0; /* Reset Monte Carlo accumulator pointer */
|
||||
mcount = 0; /* Clear Monte Carlo tries */
|
||||
mcount_ = 0; /* Clear Monte Carlo tries */
|
||||
inmont = 0; /* Clear Monte Carlo inside count */
|
||||
incirc = 65535.0 * 65535.0;/* In-circle distance for Monte Carlo */
|
||||
|
||||
|
@ -98,7 +98,7 @@ void rt_add(void *buf, int bufl)
|
|||
int mj;
|
||||
|
||||
mp = 0;
|
||||
mcount++;
|
||||
mcount_++;
|
||||
montex = montey = 0;
|
||||
for (mj = 0; mj < MONTEN / 2; mj++) {
|
||||
montex = (montex * 256.0) + monte[mj];
|
||||
|
@ -172,7 +172,7 @@ void rt_end(double *r_ent, double *r_chisq, double *r_mean,
|
|||
/* Calculate Monte Carlo value for PI from percentage of hits
|
||||
within the circle */
|
||||
|
||||
montepi = 4.0 * (((double) inmont) / mcount);
|
||||
montepi = 4.0 * (((double) inmont) / mcount_);
|
||||
|
||||
/* Return results through arguments */
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ extern char *program_invocation_name; /* RII */
|
|||
extern char *program_invocation_short_name; /* RII */
|
||||
extern uint64_t __syscount; /* RII */
|
||||
extern uint64_t kStartTsc; /* RII */
|
||||
extern const char kTmpPath[]; /* RII */
|
||||
extern char kTmpPath[]; /* RII */
|
||||
extern const char kNtSystemDirectory[]; /* RII */
|
||||
extern const char kNtWindowsDirectory[]; /* RII */
|
||||
extern unsigned char _base[] forcealign(PAGESIZE); /* αpε */
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/msghdr.h"
|
||||
|
||||
bool __asan_is_valid_msghdr(const struct msghdr *msg) {
|
||||
if (!__asan_is_valid(msg, sizeof(struct msghdr))) return false;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/so.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
|
||||
/**
|
||||
* Converts dotted IPv4 address string to network order binary.
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
asm(".ident\t\"\\n\\n\
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
|
||||
/**
|
||||
* Converts IPv4 network address to array.
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "libc/nt/winsock.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/msghdr.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
|
14
libc/sock/ppoll.h
Normal file
14
libc/sock/ppoll.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_PPOLL_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_PPOLL_H_
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int ppoll(struct pollfd *, uint64_t, const struct timespec *,
|
||||
const struct sigset *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_PPOLL_H_ */
|
|
@ -21,6 +21,7 @@
|
|||
#include "libc/macros.internal.h"
|
||||
#include "libc/nt/struct/linger.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
#include "libc/sock/syscall_fd.internal.h"
|
||||
#include "libc/sysv/consts/so.h"
|
||||
#include "libc/sysv/consts/sol.h"
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_SOCK_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_SOCK_H_
|
||||
#include "libc/bits/bswap.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/sock/struct/linger.h"
|
||||
#include "libc/sock/struct/msghdr.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
@ -20,63 +14,13 @@ COSMOPOLITAN_C_START_
|
|||
#define htonl(u32) bswap_32(u32)
|
||||
#define ntohl(u32) bswap_32(u32)
|
||||
|
||||
struct ip_mreq {
|
||||
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||
struct in_addr imr_interface; /* local IP address of interface */
|
||||
};
|
||||
|
||||
/*
|
||||
* Structure used in SIOCGIFCONF request.
|
||||
* Used to retrieve interface configuration
|
||||
* for machine (useful for programs which
|
||||
* must know all networks accessible).
|
||||
*/
|
||||
struct ifconf {
|
||||
uint64_t ifc_len; /* size of buffer */
|
||||
union {
|
||||
char *ifcu_buf;
|
||||
struct ifreq *ifcu_req;
|
||||
} ifc_ifcu;
|
||||
};
|
||||
|
||||
/* Shortcuts to the ifconf buffer or ifreq array */
|
||||
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
|
||||
#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
|
||||
|
||||
#define IFHWADDRLEN 6
|
||||
#define IF_NAMESIZE 16
|
||||
#define IFNAMSIZ IF_NAMESIZE
|
||||
|
||||
struct ifreq {
|
||||
union {
|
||||
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
|
||||
} ifr_ifrn;
|
||||
union {
|
||||
struct sockaddr ifru_addr; /* SIOCGIFADDR */
|
||||
struct sockaddr ifru_dstaddr; /* SIOCGIFDSTADDR */
|
||||
struct sockaddr ifru_netmask; /* SIOCGIFNETMASK */
|
||||
struct sockaddr ifru_broadaddr; /* SIOCGIFBRDADDR */
|
||||
short ifru_flags; /* SIOCGIFFLAGS */
|
||||
char ifru_pad[24]; /* ifru_map is the largest, just pad */
|
||||
} ifr_ifru;
|
||||
};
|
||||
|
||||
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
|
||||
#define ifr_addr ifr_ifru.ifru_addr /* address */
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask /* netmask */
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */
|
||||
#define ifr_flags ifr_ifru.ifru_flags /* flags */
|
||||
|
||||
#define _IOT_ifreq _IOT(_IOTS(char), IFNAMSIZ, _IOTS(char), 16, 0, 0)
|
||||
#define _IOT_ifreq_short _IOT(_IOTS(char), IFNAMSIZ, _IOTS(short), 1, 0, 0)
|
||||
#define _IOT_ifreq_int _IOT(_IOTS(char), IFNAMSIZ, _IOTS(int), 1, 0, 0)
|
||||
|
||||
const char *inet_ntop(int, const void *, char *, uint32_t);
|
||||
int inet_aton(const char *, struct in_addr *);
|
||||
int inet_pton(int, const char *, void *);
|
||||
uint32_t inet_addr(const char *);
|
||||
char *inet_ntoa(struct in_addr);
|
||||
int parseport(const char *);
|
||||
uint32_t *GetHostIps(void);
|
||||
|
||||
|
@ -91,18 +35,11 @@ int getsockname(int, void *, uint32_t *);
|
|||
int getpeername(int, void *, uint32_t *);
|
||||
ssize_t send(int, const void *, size_t, int);
|
||||
ssize_t recv(int, void *, size_t, int);
|
||||
ssize_t recvmsg(int, struct msghdr *, int);
|
||||
ssize_t recvfrom(int, void *, size_t, uint32_t, void *, uint32_t *);
|
||||
ssize_t sendmsg(int, const struct msghdr *, int);
|
||||
ssize_t readv(int, const struct iovec *, int);
|
||||
ssize_t writev(int, const struct iovec *, int);
|
||||
ssize_t sendfile(int, int, int64_t *, size_t);
|
||||
int getsockopt(int, int, int, void *, uint32_t *);
|
||||
int setsockopt(int, int, int, const void *, uint32_t);
|
||||
int socketpair(int, int, int, int[2]);
|
||||
int poll(struct pollfd *, uint64_t, int32_t);
|
||||
int ppoll(struct pollfd *, uint64_t, const struct timespec *,
|
||||
const struct sigset *);
|
||||
ssize_t sendto(int, const void *, size_t, uint32_t, const void *, uint32_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
27
libc/sock/struct/ifconf.h
Normal file
27
libc/sock/struct/ifconf.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IFCONF_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IFCONF_H_
|
||||
#include "libc/sock/struct/ifreq.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/*
|
||||
* Structure used in SIOCGIFCONF request.
|
||||
* Used to retrieve interface configuration
|
||||
* for machine (useful for programs which
|
||||
* must know all networks accessible).
|
||||
*/
|
||||
struct ifconf {
|
||||
uint64_t ifc_len; /* size of buffer */
|
||||
union {
|
||||
char *ifcu_buf;
|
||||
struct ifreq *ifcu_req;
|
||||
} ifc_ifcu;
|
||||
};
|
||||
|
||||
/* Shortcuts to the ifconf buffer or ifreq array */
|
||||
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
|
||||
#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_IFCONF_H_ */
|
30
libc/sock/struct/ifreq.h
Normal file
30
libc/sock/struct/ifreq.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct ifreq {
|
||||
union {
|
||||
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
|
||||
} ifr_ifrn;
|
||||
union {
|
||||
struct sockaddr ifru_addr; /* SIOCGIFADDR */
|
||||
struct sockaddr ifru_dstaddr; /* SIOCGIFDSTADDR */
|
||||
struct sockaddr ifru_netmask; /* SIOCGIFNETMASK */
|
||||
struct sockaddr ifru_broadaddr; /* SIOCGIFBRDADDR */
|
||||
short ifru_flags; /* SIOCGIFFLAGS */
|
||||
char ifru_pad[24]; /* ifru_map is the largest, just pad */
|
||||
} ifr_ifru;
|
||||
};
|
||||
|
||||
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
|
||||
#define ifr_addr ifr_ifru.ifru_addr /* address */
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask /* netmask */
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */
|
||||
#define ifr_flags ifr_ifru.ifru_flags /* flags */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_ */
|
13
libc/sock/struct/ip_mreq.h
Normal file
13
libc/sock/struct/ip_mreq.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct ip_mreq {
|
||||
struct in_addr imr_multiaddr; /* IP multicast address of group */
|
||||
struct in_addr imr_interface; /* local IP address of interface */
|
||||
};
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_ */
|
|
@ -14,6 +14,9 @@ struct msghdr { /* Linux+NT ABI */
|
|||
uint32_t msg_flags; /* MSG_XXX */
|
||||
};
|
||||
|
||||
ssize_t recvmsg(int, struct msghdr *, int);
|
||||
ssize_t sendmsg(int, const struct msghdr *, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_MSGHDR_H_ */
|
||||
|
|
|
@ -9,6 +9,8 @@ struct pollfd {
|
|||
int16_t revents;
|
||||
};
|
||||
|
||||
int poll(struct pollfd *, uint64_t, int32_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_POLLFD_H_ */
|
||||
|
|
|
@ -33,6 +33,9 @@ struct sockaddr_storage {
|
|||
};
|
||||
};
|
||||
|
||||
int inet_aton(const char *, struct in_addr *);
|
||||
char *inet_ntoa(struct in_addr);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_SOCKADDR_H_ */
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "libc/nt/events.h"
|
||||
#include "libc/nt/runtime.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#include "libc/sock/syslog.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/str/str.h"
|
||||
|
|
|
@ -75,6 +75,13 @@ o/libc/sysv/consts/syscon.internal.inc: \
|
|||
libc/sysv/consts/syscon.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/macros-cpp.internal.inc \
|
||||
libc/macros.internal.inc \
|
||||
libc/dce.h \
|
||||
libc/intrin/asancodes.h \
|
||||
ape/relocations.h
|
||||
|
||||
o/libc/sysv/macros.internal.inc: \
|
||||
libc/sysv/macros.internal.h \
|
||||
libc/macros.internal.inc
|
||||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
|
|
@ -127,6 +127,10 @@ $(LIBC_TESTLIB_A).pkg: \
|
|||
$(LIBC_TESTLIB_A_OBJS) \
|
||||
$(foreach x,$(LIBC_TESTLIB_A_DIRECTDEPS),$($(x)_A).pkg)
|
||||
|
||||
o/$(MODE)/libc/testlib/blocktronics.o: libc/testlib/blocktronics.txt
|
||||
o/$(MODE)/libc/testlib/hyperion.o: libc/testlib/hyperion.txt
|
||||
o/$(MODE)/libc/testlib/moby.o: libc/testlib/moby.txt
|
||||
|
||||
#───────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
LIBC_TESTLIB_ARTIFACTS += LIBC_TESTLIB_RUNNER_A
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "libc/runtime/symbols.internal.h"
|
||||
#include "libc/runtime/sysconf.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/pollfd.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/sysv/consts/ex.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue