Fix bugs and make improvements

- Get clone() working on FreeBSD
- Increase some Python build quotas
- Add more atomic builtins to chibicc
- Fix ASAN poisoning of alloca() memory
- Make MODE= mandatory link path tinier
- Improve the examples folder a little bit
- Start working on some more resource limits
- Make the linenoise auto-complete UI as good as GNU readline
- Update compile.com, avoiding AVX codegen on non-AVX systems
- Make sure empty path to syscalls like opendir raises ENOENT
- Correctly polyfill ENOENT vs. ENOTDIR on the New Technology
- Port bestline's paredit features to //third_party/linenoise
- Remove workarounds for RHEL 5.0 bugs that were fixed in 5.1
This commit is contained in:
Justine Tunney 2022-04-20 09:56:53 -07:00
parent c3fb624647
commit ae638c0850
181 changed files with 2994 additions and 1367 deletions

View file

@ -325,6 +325,9 @@ COSMOPOLITAN_C_START_
#define BPF_ADJ_ROOM_ENCAP_L2_MASK 0xff
#define BPF_ADJ_ROOM_ENCAP_L2_SHIFT 56
#define BPF_F_ADJ_ROOM_ENCAP_L2(len) \
(((uint64_t)len & BPF_ADJ_ROOM_ENCAP_L2_MASK) << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
#define BPF_F_SYSCTL_BASE_NAME (1ULL << 0)
#define BPF_LOCAL_STORAGE_GET_F_CREATE (1ULL << 0)
#define BPF_SK_STORAGE_GET_F_CREATE BPF_LOCAL_STORAGE_GET_F_CREATE
@ -352,7 +355,8 @@ COSMOPOLITAN_C_START_
#define BPF_F_BROADCAST (1ULL << 3)
#define BPF_F_EXCLUDE_INGRESS (1ULL << 4)
#define BPF_TAG_SIZE 8
#define XDP_PACKET_HEADROOM 256
#define BPF_TAG_SIZE 8
#define BPF_SOCK_OPS_RTO_CB_FLAG (1 << 0)
#define BPF_SOCK_OPS_RETRANS_CB_FLAG (1 << 1)
@ -451,10 +455,176 @@ COSMOPOLITAN_C_START_
#define BPF_REDIRECT 7
#define BPF_LWT_REROUTE 128
#define XDP_PACKET_HEADROOM 256
#define BPF_F_ADJ_ROOM_ENCAP_L2(len) \
(((uint64_t)len & BPF_ADJ_ROOM_ENCAP_L2_MASK) << BPF_ADJ_ROOM_ENCAP_L2_SHIFT)
#define BPF_FUNC_unspec 0
#define BPF_FUNC_map_lookup_elem 1
#define BPF_FUNC_map_update_elem 2
#define BPF_FUNC_map_delete_elem 3
#define BPF_FUNC_probe_read 4
#define BPF_FUNC_ktime_get_ns 5
#define BPF_FUNC_trace_printk 6
#define BPF_FUNC_get_prandom_u32 7
#define BPF_FUNC_get_smp_processor_id 8
#define BPF_FUNC_skb_store_bytes 9
#define BPF_FUNC_l3_csum_replace 10
#define BPF_FUNC_l4_csum_replace 11
#define BPF_FUNC_tail_call 12
#define BPF_FUNC_clone_redirect 13
#define BPF_FUNC_get_current_pid_tgid 14
#define BPF_FUNC_get_current_uid_gid 15
#define BPF_FUNC_get_current_comm 16
#define BPF_FUNC_get_cgroup_classid 17
#define BPF_FUNC_skb_vlan_push 18
#define BPF_FUNC_skb_vlan_pop 19
#define BPF_FUNC_skb_get_tunnel_key 20
#define BPF_FUNC_skb_set_tunnel_key 21
#define BPF_FUNC_perf_event_read 22
#define BPF_FUNC_redirect 23
#define BPF_FUNC_get_route_realm 24
#define BPF_FUNC_perf_event_output 25
#define BPF_FUNC_skb_load_bytes 26
#define BPF_FUNC_get_stackid 27
#define BPF_FUNC_csum_diff 28
#define BPF_FUNC_skb_get_tunnel_opt 29
#define BPF_FUNC_skb_set_tunnel_opt 30
#define BPF_FUNC_skb_change_proto 31
#define BPF_FUNC_skb_change_type 32
#define BPF_FUNC_skb_under_cgroup 33
#define BPF_FUNC_get_hash_recalc 34
#define BPF_FUNC_get_current_task 35
#define BPF_FUNC_probe_write_user 36
#define BPF_FUNC_current_task_under_cgroup 37
#define BPF_FUNC_skb_change_tail 38
#define BPF_FUNC_skb_pull_data 39
#define BPF_FUNC_csum_update 40
#define BPF_FUNC_set_hash_invalid 41
#define BPF_FUNC_get_numa_node_id 42
#define BPF_FUNC_skb_change_head 43
#define BPF_FUNC_xdp_adjust_head 44
#define BPF_FUNC_probe_read_str 45
#define BPF_FUNC_get_socket_cookie 46
#define BPF_FUNC_get_socket_uid 47
#define BPF_FUNC_set_hash 48
#define BPF_FUNC_setsockopt 49
#define BPF_FUNC_skb_adjust_room 50
#define BPF_FUNC_redirect_map 51
#define BPF_FUNC_sk_redirect_map 52
#define BPF_FUNC_sock_map_update 53
#define BPF_FUNC_xdp_adjust_meta 54
#define BPF_FUNC_perf_event_read_value 55
#define BPF_FUNC_perf_prog_read_value 56
#define BPF_FUNC_getsockopt 57
#define BPF_FUNC_override_return 58
#define BPF_FUNC_sock_ops_cb_flags_set 59
#define BPF_FUNC_msg_redirect_map 60
#define BPF_FUNC_msg_apply_bytes 61
#define BPF_FUNC_msg_cork_bytes 62
#define BPF_FUNC_msg_pull_data 63
#define BPF_FUNC_bind 64
#define BPF_FUNC_xdp_adjust_tail 65
#define BPF_FUNC_skb_get_xfrm_state 66
#define BPF_FUNC_get_stack 67
#define BPF_FUNC_skb_load_bytes_relative 68
#define BPF_FUNC_fib_lookup 69
#define BPF_FUNC_sock_hash_update 70
#define BPF_FUNC_msg_redirect_hash 71
#define BPF_FUNC_sk_redirect_hash 72
#define BPF_FUNC_lwt_push_encap 73
#define BPF_FUNC_lwt_seg6_store_bytes 74
#define BPF_FUNC_lwt_seg6_adjust_srh 75
#define BPF_FUNC_lwt_seg6_action 76
#define BPF_FUNC_rc_repeat 77
#define BPF_FUNC_rc_keydown 78
#define BPF_FUNC_skb_cgroup_id 79
#define BPF_FUNC_get_current_cgroup_id 80
#define BPF_FUNC_get_local_storage 81
#define BPF_FUNC_sk_select_reuseport 82
#define BPF_FUNC_skb_ancestor_cgroup_id 83
#define BPF_FUNC_sk_lookup_tcp 84
#define BPF_FUNC_sk_lookup_udp 85
#define BPF_FUNC_sk_release 86
#define BPF_FUNC_map_push_elem 87
#define BPF_FUNC_map_pop_elem 88
#define BPF_FUNC_map_peek_elem 89
#define BPF_FUNC_msg_push_data 90
#define BPF_FUNC_msg_pop_data 91
#define BPF_FUNC_rc_pointer_rel 92
#define BPF_FUNC_spin_lock 93
#define BPF_FUNC_spin_unlock 94
#define BPF_FUNC_sk_fullsock 95
#define BPF_FUNC_tcp_sock 96
#define BPF_FUNC_skb_ecn_set_ce 97
#define BPF_FUNC_get_listener_sock 98
#define BPF_FUNC_skc_lookup_tcp 99
#define BPF_FUNC_tcp_check_syncookie 100
#define BPF_FUNC_sysctl_get_name 101
#define BPF_FUNC_sysctl_get_current_value 102
#define BPF_FUNC_sysctl_get_new_value 103
#define BPF_FUNC_sysctl_set_new_value 104
#define BPF_FUNC_strtol 105
#define BPF_FUNC_strtoul 106
#define BPF_FUNC_sk_storage_get 107
#define BPF_FUNC_sk_storage_delete 108
#define BPF_FUNC_send_signal 109
#define BPF_FUNC_tcp_gen_syncookie 110
#define BPF_FUNC_skb_output 111
#define BPF_FUNC_probe_read_user 112
#define BPF_FUNC_probe_read_kernel 113
#define BPF_FUNC_probe_read_user_str 114
#define BPF_FUNC_probe_read_kernel_str 115
#define BPF_FUNC_tcp_send_ack 116
#define BPF_FUNC_send_signal_thread 117
#define BPF_FUNC_jiffies64 118
#define BPF_FUNC_read_branch_records 119
#define BPF_FUNC_get_ns_current_pid_tgid 120
#define BPF_FUNC_xdp_output 121
#define BPF_FUNC_get_netns_cookie 122
#define BPF_FUNC_get_current_ancestor_cgroup_id 123
#define BPF_FUNC_sk_assign 124
#define BPF_FUNC_ktime_get_boot_ns 125
#define BPF_FUNC_seq_printf 126
#define BPF_FUNC_seq_write 127
#define BPF_FUNC_sk_cgroup_id 128
#define BPF_FUNC_sk_ancestor_cgroup_id 129
#define BPF_FUNC_ringbuf_output 130
#define BPF_FUNC_ringbuf_reserve 131
#define BPF_FUNC_ringbuf_submit 132
#define BPF_FUNC_ringbuf_discard 133
#define BPF_FUNC_ringbuf_query 134
#define BPF_FUNC_csum_level 135
#define BPF_FUNC_skc_to_tcp6_sock 136
#define BPF_FUNC_skc_to_tcp_sock 137
#define BPF_FUNC_skc_to_tcp_timewait_sock 138
#define BPF_FUNC_skc_to_tcp_request_sock 139
#define BPF_FUNC_skc_to_udp6_sock 140
#define BPF_FUNC_get_task_stack 141
#define BPF_FUNC_load_hdr_opt 142
#define BPF_FUNC_store_hdr_opt 143
#define BPF_FUNC_reserve_hdr_opt 144
#define BPF_FUNC_inode_storage_get 145
#define BPF_FUNC_inode_storage_delete 146
#define BPF_FUNC_d_path 147
#define BPF_FUNC_copy_from_user 148
#define BPF_FUNC_snprintf_btf 149
#define BPF_FUNC_seq_printf_btf 150
#define BPF_FUNC_skb_cgroup_classid 151
#define BPF_FUNC_redirect_neigh 152
#define BPF_FUNC_per_cpu_ptr 153
#define BPF_FUNC_this_cpu_ptr 154
#define BPF_FUNC_redirect_peer 155
#define BPF_FUNC_task_storage_get 156
#define BPF_FUNC_task_storage_delete 157
#define BPF_FUNC_get_current_task_btf 158
#define BPF_FUNC_bprm_opts_set 159
#define BPF_FUNC_ktime_get_coarse_ns 160
#define BPF_FUNC_ima_inode_hash 161
#define BPF_FUNC_sock_from_file 162
#define BPF_FUNC_check_mtu 163
#define BPF_FUNC_for_each_map_elem 164
#define BPF_FUNC_snprintf 165
#define BPF_FUNC_sys_bpf 166
#define BPF_FUNC_btf_find_by_name_kind 167
#define BPF_FUNC_sys_close 168
#define __BPF_FUNC_MAX_ID 169
#define __bpf_md_ptr(type, name) \
union { \
@ -1157,185 +1327,6 @@ struct btf_ptr {
uint32_t flags;
};
/* clang-format off */
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
FN(map_lookup_elem), \
FN(map_update_elem), \
FN(map_delete_elem), \
FN(probe_read), \
FN(ktime_get_ns), \
FN(trace_printk), \
FN(get_prandom_u32), \
FN(get_smp_processor_id), \
FN(skb_store_bytes), \
FN(l3_csum_replace), \
FN(l4_csum_replace), \
FN(tail_call), \
FN(clone_redirect), \
FN(get_current_pid_tgid), \
FN(get_current_uid_gid), \
FN(get_current_comm), \
FN(get_cgroup_classid), \
FN(skb_vlan_push), \
FN(skb_vlan_pop), \
FN(skb_get_tunnel_key), \
FN(skb_set_tunnel_key), \
FN(perf_event_read), \
FN(redirect), \
FN(get_route_realm), \
FN(perf_event_output), \
FN(skb_load_bytes), \
FN(get_stackid), \
FN(csum_diff), \
FN(skb_get_tunnel_opt), \
FN(skb_set_tunnel_opt), \
FN(skb_change_proto), \
FN(skb_change_type), \
FN(skb_under_cgroup), \
FN(get_hash_recalc), \
FN(get_current_task), \
FN(probe_write_user), \
FN(current_task_under_cgroup), \
FN(skb_change_tail), \
FN(skb_pull_data), \
FN(csum_update), \
FN(set_hash_invalid), \
FN(get_numa_node_id), \
FN(skb_change_head), \
FN(xdp_adjust_head), \
FN(probe_read_str), \
FN(get_socket_cookie), \
FN(get_socket_uid), \
FN(set_hash), \
FN(setsockopt), \
FN(skb_adjust_room), \
FN(redirect_map), \
FN(sk_redirect_map), \
FN(sock_map_update), \
FN(xdp_adjust_meta), \
FN(perf_event_read_value), \
FN(perf_prog_read_value), \
FN(getsockopt), \
FN(override_return), \
FN(sock_ops_cb_flags_set), \
FN(msg_redirect_map), \
FN(msg_apply_bytes), \
FN(msg_cork_bytes), \
FN(msg_pull_data), \
FN(bind), \
FN(xdp_adjust_tail), \
FN(skb_get_xfrm_state), \
FN(get_stack), \
FN(skb_load_bytes_relative), \
FN(fib_lookup), \
FN(sock_hash_update), \
FN(msg_redirect_hash), \
FN(sk_redirect_hash), \
FN(lwt_push_encap), \
FN(lwt_seg6_store_bytes), \
FN(lwt_seg6_adjust_srh), \
FN(lwt_seg6_action), \
FN(rc_repeat), \
FN(rc_keydown), \
FN(skb_cgroup_id), \
FN(get_current_cgroup_id), \
FN(get_local_storage), \
FN(sk_select_reuseport), \
FN(skb_ancestor_cgroup_id), \
FN(sk_lookup_tcp), \
FN(sk_lookup_udp), \
FN(sk_release), \
FN(map_push_elem), \
FN(map_pop_elem), \
FN(map_peek_elem), \
FN(msg_push_data), \
FN(msg_pop_data), \
FN(rc_pointer_rel), \
FN(spin_lock), \
FN(spin_unlock), \
FN(sk_fullsock), \
FN(tcp_sock), \
FN(skb_ecn_set_ce), \
FN(get_listener_sock), \
FN(skc_lookup_tcp), \
FN(tcp_check_syncookie), \
FN(sysctl_get_name), \
FN(sysctl_get_current_value), \
FN(sysctl_get_new_value), \
FN(sysctl_set_new_value), \
FN(strtol), \
FN(strtoul), \
FN(sk_storage_get), \
FN(sk_storage_delete), \
FN(send_signal), \
FN(tcp_gen_syncookie), \
FN(skb_output), \
FN(probe_read_user), \
FN(probe_read_kernel), \
FN(probe_read_user_str), \
FN(probe_read_kernel_str), \
FN(tcp_send_ack), \
FN(send_signal_thread), \
FN(jiffies64), \
FN(read_branch_records), \
FN(get_ns_current_pid_tgid), \
FN(xdp_output), \
FN(get_netns_cookie), \
FN(get_current_ancestor_cgroup_id), \
FN(sk_assign), \
FN(ktime_get_boot_ns), \
FN(seq_printf), \
FN(seq_write), \
FN(sk_cgroup_id), \
FN(sk_ancestor_cgroup_id), \
FN(ringbuf_output), \
FN(ringbuf_reserve), \
FN(ringbuf_submit), \
FN(ringbuf_discard), \
FN(ringbuf_query), \
FN(csum_level), \
FN(skc_to_tcp6_sock), \
FN(skc_to_tcp_sock), \
FN(skc_to_tcp_timewait_sock), \
FN(skc_to_tcp_request_sock), \
FN(skc_to_udp6_sock), \
FN(get_task_stack), \
FN(load_hdr_opt), \
FN(store_hdr_opt), \
FN(reserve_hdr_opt), \
FN(inode_storage_get), \
FN(inode_storage_delete), \
FN(d_path), \
FN(copy_from_user), \
FN(snprintf_btf), \
FN(seq_printf_btf), \
FN(skb_cgroup_classid), \
FN(redirect_neigh), \
FN(per_cpu_ptr), \
FN(this_cpu_ptr), \
FN(redirect_peer), \
FN(task_storage_get), \
FN(task_storage_delete), \
FN(get_current_task_btf), \
FN(bprm_opts_set), \
FN(ktime_get_coarse_ns), \
FN(ima_inode_hash), \
FN(sock_from_file), \
FN(check_mtu), \
FN(for_each_map_elem), \
FN(snprintf), \
FN(sys_bpf), \
FN(btf_find_by_name_kind), \
FN(sys_close), \
/* clang-format on */
#define __BPF_ENUM_FN(x) BPF_FUNC_##x
enum bpf_func_id {
__BPF_FUNC_MAPPER(__BPF_ENUM_FN) __BPF_FUNC_MAX_ID,
};
#undef __BPF_ENUM_FN
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_CALLS_STRUCT_BPF_H_ */