mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Greatly expand system() shell code features
The cosmopolitan command interpreter now has 13 builtin commands, variable support, support for ; / && / || syntax, asynchronous support, and plenty of unit tests with bug fixes. This change fixes a bug in posix_spawn() with null envp arg. strace logging now uses atomic writes for scatter functions. Breaking change renaming GetCpuCount() to _getcpucount(). TurfWar is now updated to use the new token bucket algorithm. WIN32 affinity masks now inherit across fork() and execve().
This commit is contained in:
parent
e7329b7cba
commit
b41f91c658
80 changed files with 1370 additions and 344 deletions
42
libc/sock/struct/cmsghdr.h
Normal file
42
libc/sock/struct/cmsghdr.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define CMSG_DATA(cmsg) ((unsigned char *)(((struct cmsghdr *)(cmsg)) + 1))
|
||||
|
||||
#define CMSG_FIRSTHDR(mhdr) \
|
||||
((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \
|
||||
? (struct cmsghdr *)(mhdr)->msg_control \
|
||||
: (struct cmsghdr *)0)
|
||||
|
||||
#define CMSG_NXTHDR(mhdr, cmsg) \
|
||||
((cmsg)->cmsg_len < sizeof(struct cmsghdr) || \
|
||||
__CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= \
|
||||
__MHDR_END(mhdr) - (unsigned char *)(cmsg) \
|
||||
? 0 \
|
||||
: (struct cmsghdr *)__CMSG_NEXT(cmsg))
|
||||
|
||||
#define CMSG_ALIGN(len) \
|
||||
(((len) + sizeof(size_t) - 1) & (size_t) ~(sizeof(size_t) - 1))
|
||||
|
||||
#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
|
||||
|
||||
#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
|
||||
|
||||
#define __CMSG_LEN(cmsg) \
|
||||
(((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
|
||||
#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
|
||||
#define __MHDR_END(mhdr) \
|
||||
((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
|
||||
|
||||
struct cmsghdr { /* linux abi */
|
||||
uint32_t cmsg_len;
|
||||
uint32_t __pad1;
|
||||
int32_t cmsg_level;
|
||||
int32_t cmsg_type;
|
||||
};
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_H_ */
|
14
libc/sock/struct/cmsghdr.internal.h
Normal file
14
libc/sock/struct/cmsghdr.internal.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_INTERNAL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct cmsghdr_bsd {
|
||||
uint32_t cmsg_len;
|
||||
int32_t cmsg_level;
|
||||
int32_t cmsg_type;
|
||||
};
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_INTERNAL_H_ */
|
|
@ -8,9 +8,9 @@ struct msghdr { /* Linux+NT ABI */
|
|||
void *msg_name; /* optional address */
|
||||
uint32_t msg_namelen; /* size of msg_name */
|
||||
struct iovec *msg_iov; /* scatter/gather array */
|
||||
int msg_iovlen; /* iovec count */
|
||||
void *msg_control; /* credentials and stuff */
|
||||
uint32_t msg_controllen; /* size of msg_control */
|
||||
int msg_iovlen; /* # elements in msg_iov */
|
||||
void *msg_control; /* ancillary data c. cmsghdr */
|
||||
uint32_t msg_controllen; /* ancillary data buffer len */
|
||||
uint32_t __pad0; /* reconcile abi */
|
||||
int msg_flags; /* MSG_XXX */
|
||||
};
|
||||
|
|
|
@ -41,8 +41,8 @@ int bind(int, const struct sockaddr *, uint32_t);
|
|||
int connect(int, const struct sockaddr *, uint32_t);
|
||||
int getsockname(int, struct sockaddr *, uint32_t *);
|
||||
int getpeername(int, struct sockaddr *, uint32_t *);
|
||||
ssize_t recvfrom(int, void *, size_t, uint32_t, struct sockaddr *, uint32_t *);
|
||||
ssize_t sendto(int, const void *, size_t, uint32_t, const struct sockaddr *,
|
||||
ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, uint32_t *);
|
||||
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
|
||||
uint32_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue