mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 16:28:30 +00:00
Add more missing libc functionality
This commit is contained in:
parent
cf93ecbbb2
commit
a8cf0f7e89
74 changed files with 6981 additions and 105 deletions
|
@ -123,6 +123,8 @@ ssize_t sys_sendmsg(int, const struct msghdr *, int) hidden;
|
|||
ssize_t sys_recvmsg(int, struct msghdr *, int) hidden;
|
||||
int32_t sys_select(int32_t, fd_set *, fd_set *, fd_set *,
|
||||
struct timeval *) hidden;
|
||||
int sys_pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
|
||||
const sigset_t *);
|
||||
int sys_setsockopt(int, int, int, const void *, uint32_t) hidden;
|
||||
int32_t sys_epoll_create(int32_t) hidden;
|
||||
int32_t sys_epoll_ctl(int32_t, int32_t, int32_t, void *) hidden;
|
||||
|
|
40
libc/sock/pselect.c
Normal file
40
libc/sock/pselect.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*-*- 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 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 │
|
||||
│ 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. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/strace.internal.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/sock/internal.h"
|
||||
#include "libc/sock/select.h"
|
||||
|
||||
/**
|
||||
* Does what poll() does except with bitset API.
|
||||
*
|
||||
* This system call is supported on all platforms. It's like select()
|
||||
* except that it atomically changes the sigprocmask() during the op.
|
||||
*/
|
||||
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
||||
const struct timespec *timeout, const sigset_t *sigmask) {
|
||||
int rc;
|
||||
sigset_t oldmask;
|
||||
rc = sys_pselect(nfds, readfds, writefds, exceptfds, timeout, sigmask);
|
||||
POLLTRACE("pselect(%d, %p, %p, %p, [%s], %s) → %d% m", nfds, readfds,
|
||||
writefds, exceptfds, DescribeTimeval(rc, timeout),
|
||||
DescribeSigset(0, sigmask), rc);
|
||||
return rc;
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_SELECT_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_SELECT_H_
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
@ -18,6 +20,8 @@ typedef struct fd_set {
|
|||
#define FD_ZERO(SET) bzero((SET)->fds_bits, sizeof((SET)->fds_bits))
|
||||
|
||||
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
|
||||
int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
|
||||
const sigset_t *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/sockaddr6.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/sock/struct/sockaddr6.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/af.h"
|
||||
#include "libc/sysv/consts/ipproto.h"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
|
22
libc/sock/struct/sockaddr6.h
Normal file
22
libc/sock/struct/sockaddr6.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_STRUCT_SOCKADDR6_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SOCKADDR6_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
||||
struct in6_addr {
|
||||
union {
|
||||
uint8_t s6_addr[16];
|
||||
uint16_t s6_addr16[8];
|
||||
uint32_t s6_addr32[4];
|
||||
};
|
||||
};
|
||||
|
||||
struct sockaddr_in6 { /* Linux+NT ABI */
|
||||
uint16_t sin6_family;
|
||||
uint16_t sin6_port;
|
||||
uint32_t sin6_flowinfo;
|
||||
struct in6_addr sin6_addr;
|
||||
uint32_t sin6_scope_id; /* rfc2553 */
|
||||
};
|
||||
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_SOCKADDR6_H_ */
|
|
@ -3,8 +3,6 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define LOG_PRI(p) (LOG_PRIMASK & (p))
|
||||
|
||||
int setlogmask(int);
|
||||
void openlog(const char *, int, int);
|
||||
void syslog(int, const char *, ...);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue