mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Perform build and magnum tuning
Building o//third_party/python now takes 5 seconds on my PC This change works towards modifying Python to use runtime dispatching when appropriate. For example, when loading the magnums in the socket module, it's a good idea to check if the magnum is zero, because that means the local system platform doesn't support it.
This commit is contained in:
parent
ee7e296339
commit
d26d7ae0e4
1028 changed files with 6576 additions and 172777 deletions
156
third_party/python/Modules/socketmodule.h
vendored
156
third_party/python/Modules/socketmodule.h
vendored
|
@ -1,160 +1,18 @@
|
|||
/* Socket module header file */
|
||||
|
||||
/* Includes needed for the sockaddr_* symbols below */
|
||||
#ifndef MS_WINDOWS
|
||||
#ifdef __VMS
|
||||
# include <socket.h>
|
||||
# else
|
||||
# include <sys/socket.h>
|
||||
# endif
|
||||
// # include <netinet/in.h>
|
||||
# if !defined(__CYGWIN__)
|
||||
// # include <netinet/tcp.h>
|
||||
# endif
|
||||
|
||||
#else /* MS_WINDOWS */
|
||||
# include <winsock2.h>
|
||||
/* Windows 'supports' CMSG_LEN, but does not follow the POSIX standard
|
||||
* interface at all, so there is no point including the code that
|
||||
* attempts to use it.
|
||||
*/
|
||||
# ifdef PySocket_BUILDING_SOCKET
|
||||
# undef CMSG_LEN
|
||||
# endif
|
||||
# include <ws2tcpip.h>
|
||||
/* VC6 is shipped with old platform headers, and does not have MSTcpIP.h
|
||||
* Separate SDKs have all the functions we want, but older ones don't have
|
||||
* any version information.
|
||||
* I use SIO_GET_MULTICAST_FILTER to detect a decent SDK.
|
||||
*/
|
||||
# ifdef SIO_GET_MULTICAST_FILTER
|
||||
# include <MSTcpIP.h> /* for SIO_RCVALL */
|
||||
# define HAVE_ADDRINFO
|
||||
# define HAVE_SOCKADDR_STORAGE
|
||||
# define HAVE_GETADDRINFO
|
||||
# define HAVE_GETNAMEINFO
|
||||
# define ENABLE_IPV6
|
||||
# else
|
||||
typedef int socklen_t;
|
||||
# endif /* IPPROTO_IPV6 */
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#ifdef HAVE_SYS_UN_H
|
||||
// # include <sys/un.h>
|
||||
#else
|
||||
# undef AF_UNIX
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_NETLINK_H
|
||||
# ifdef HAVE_ASM_TYPES_H
|
||||
# include <asm/types.h>
|
||||
# endif
|
||||
# include <linux/netlink.h>
|
||||
#else
|
||||
# undef AF_NETLINK
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
#include <bluetooth/l2cap.h>
|
||||
#include <bluetooth/sco.h>
|
||||
#include <bluetooth/hci.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_H
|
||||
#include <bluetooth.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NET_IF_H
|
||||
# include <net/if.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
# include <sys/ioctl.h>
|
||||
# include <netpacket/packet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_TIPC_H
|
||||
# include <linux/tipc.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_CAN_H
|
||||
# include <linux/can.h>
|
||||
#else
|
||||
# undef AF_CAN
|
||||
# undef PF_CAN
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_CAN_RAW_H
|
||||
#include <linux/can/raw.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LINUX_CAN_BCM_H
|
||||
#include <linux/can/bcm.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SYS_DOMAIN_H
|
||||
#include <sys/sys_domain.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_KERN_CONTROL_H
|
||||
#include <sys/kern_control.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SOCKADDR_ALG
|
||||
#include <linux/if_alg.h>
|
||||
#ifndef AF_ALG
|
||||
#define AF_ALG 38
|
||||
#endif
|
||||
#ifndef SOL_ALG
|
||||
#define SOL_ALG 279
|
||||
#endif
|
||||
|
||||
/* Linux 3.19 */
|
||||
#ifndef ALG_SET_AEAD_ASSOCLEN
|
||||
#define ALG_SET_AEAD_ASSOCLEN 4
|
||||
#endif
|
||||
#ifndef ALG_SET_AEAD_AUTHSIZE
|
||||
#define ALG_SET_AEAD_AUTHSIZE 5
|
||||
#endif
|
||||
/* Linux 4.8 */
|
||||
#ifndef ALG_SET_PUBKEY
|
||||
#define ALG_SET_PUBKEY 6
|
||||
#endif
|
||||
|
||||
#ifndef ALG_OP_SIGN
|
||||
#define ALG_OP_SIGN 2
|
||||
#endif
|
||||
#ifndef ALG_OP_VERIFY
|
||||
#define ALG_OP_VERIFY 3
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_SOCKADDR_ALG */
|
||||
|
||||
|
||||
#ifndef Py__SOCKET_H
|
||||
#define Py__SOCKET_H
|
||||
#include "libc/sock/sock.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* clang-format off */
|
||||
|
||||
/* Python module and C API name */
|
||||
#define PySocket_MODULE_NAME "_socket"
|
||||
#define PySocket_CAPI_NAME "CAPI"
|
||||
#define PySocket_CAPSULE_NAME PySocket_MODULE_NAME "." PySocket_CAPI_NAME
|
||||
|
||||
/* Abstract the socket file descriptor type */
|
||||
#ifdef MS_WINDOWS
|
||||
typedef SOCKET SOCKET_T;
|
||||
# ifdef MS_WIN64
|
||||
# define SIZEOF_SOCKET_T 8
|
||||
# else
|
||||
# define SIZEOF_SOCKET_T 4
|
||||
# endif
|
||||
#else
|
||||
typedef int SOCKET_T;
|
||||
# define SIZEOF_SOCKET_T SIZEOF_INT
|
||||
#endif
|
||||
#define SIZEOF_SOCKET_T __SIZEOF_INT__
|
||||
|
||||
#if SIZEOF_SOCKET_T <= SIZEOF_LONG
|
||||
#define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd))
|
||||
|
@ -163,17 +21,12 @@ typedef int SOCKET_T;
|
|||
#define PyLong_FromSocket_t(fd) PyLong_FromLongLong((SOCKET_T)(fd))
|
||||
#define PyLong_AsSocket_t(fd) (SOCKET_T)PyLong_AsLongLong(fd)
|
||||
#endif
|
||||
|
||||
|
||||
/* Socket address */
|
||||
typedef union sock_addr {
|
||||
struct sockaddr_in in;
|
||||
struct sockaddr sa;
|
||||
#ifdef AF_UNIX
|
||||
struct sockaddr_un un;
|
||||
#endif
|
||||
#ifdef AF_NETLINK
|
||||
struct sockaddr_nl nl;
|
||||
#endif
|
||||
#ifdef ENABLE_IPV6
|
||||
struct sockaddr_in6 in6;
|
||||
struct sockaddr_storage storage;
|
||||
|
@ -276,6 +129,5 @@ typedef struct {
|
|||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* !Py__SOCKET_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue