aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorLoris Cro <kappaloris@gmail.com>2023-06-18 09:06:40 +0200
committerGitHub <noreply@github.com>2023-06-18 09:06:40 +0200
commit216ef10dc471e4db60a30208be178d6c59efeaaf (patch)
tree8c239dab283ae9cb3b7fe099bae240bcc53f894e /lib/libc
parent0fc1d396495c1ab482197021dedac8bea3f9401c (diff)
parent729a051e9e38674233190aea23c0ac8c134f2d67 (diff)
downloadzig-216ef10dc471e4db60a30208be178d6c59efeaaf.tar.gz
zig-216ef10dc471e4db60a30208be178d6c59efeaaf.zip
Merge branch 'master' into autodoc-searchkey
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/glibc/README.md1
-rw-r--r--lib/libc/include/aarch64-linux-any/asm/hwcap.h26
-rw-r--r--lib/libc/include/aarch64-linux-any/asm/kvm.h51
-rw-r--r--lib/libc/include/aarch64-linux-any/asm/perf_regs.h7
-rw-r--r--lib/libc/include/aarch64-linux-any/asm/ptrace.h69
-rw-r--r--lib/libc/include/aarch64-linux-any/asm/sigcontext.h86
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/fcntl.h24
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/hugetlb_encode.h26
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/mman-common.h4
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/shmbuf.h4
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/siginfo.h7
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/signal.h2
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/socket.h4
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/termbits-common.h66
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/termbits.h239
-rw-r--r--lib/libc/include/any-linux-any/asm-generic/unistd.h9
-rw-r--r--lib/libc/include/any-linux-any/drm/amdgpu_drm.h87
-rw-r--r--lib/libc/include/any-linux-any/drm/drm.h18
-rw-r--r--lib/libc/include/any-linux-any/drm/drm_fourcc.h163
-rw-r--r--lib/libc/include/any-linux-any/drm/drm_mode.h151
-rw-r--r--lib/libc/include/any-linux-any/drm/habanalabs_accel.h (renamed from lib/libc/include/any-linux-any/misc/habanalabs.h)1107
-rw-r--r--lib/libc/include/any-linux-any/drm/i810_drm.h292
-rw-r--r--lib/libc/include/any-linux-any/drm/i915_drm.h797
-rw-r--r--lib/libc/include/any-linux-any/drm/ivpu_accel.h306
-rw-r--r--lib/libc/include/any-linux-any/drm/mga_drm.h429
-rw-r--r--lib/libc/include/any-linux-any/drm/msm_drm.h44
-rw-r--r--lib/libc/include/any-linux-any/drm/panfrost_drm.h55
-rw-r--r--lib/libc/include/any-linux-any/drm/r128_drm.h336
-rw-r--r--lib/libc/include/any-linux-any/drm/savage_drm.h220
-rw-r--r--lib/libc/include/any-linux-any/drm/sis_drm.h77
-rw-r--r--lib/libc/include/any-linux-any/drm/via_drm.h282
-rw-r--r--lib/libc/include/any-linux-any/drm/virtgpu_drm.h1
-rw-r--r--lib/libc/include/any-linux-any/drm/vmwgfx_drm.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/acct.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/acrn.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/agpgart.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/android/binder.h28
-rw-r--r--lib/libc/include/any-linux-any/linux/aspeed-video.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/atmbr2684.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/audit.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/auxvec.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/batadv_packet.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/blkzoned.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/bpf.h1205
-rw-r--r--lib/libc/include/any-linux-any/linux/btf.h24
-rw-r--r--lib/libc/include/any-linux-any/linux/btrfs.h208
-rw-r--r--lib/libc/include/any-linux-any/linux/btrfs_tree.h261
-rw-r--r--lib/libc/include/any-linux-any/linux/cachefiles.h68
-rw-r--r--lib/libc/include/any-linux-any/linux/can.h55
-rw-r--r--lib/libc/include/any-linux-any/linux/can/bcm.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/can/error.h20
-rw-r--r--lib/libc/include/any-linux-any/linux/can/isotp.h55
-rw-r--r--lib/libc/include/any-linux-any/linux/can/netlink.h13
-rw-r--r--lib/libc/include/any-linux-any/linux/can/raw.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/capability.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/cdrom.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/cec-funcs.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/cec.h22
-rw-r--r--lib/libc/include/any-linux-any/linux/comedi.h1528
-rw-r--r--lib/libc/include/any-linux-any/linux/connector.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/const.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/counter.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/cxl_mem.h44
-rw-r--r--lib/libc/include/any-linux-any/linux/cyclades.h35
-rw-r--r--lib/libc/include/any-linux-any/linux/cycx_cfm.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/dcbnl.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/devlink.h72
-rw-r--r--lib/libc/include/any-linux-any/linux/dlm.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/dm-ioctl.h12
-rw-r--r--lib/libc/include/any-linux-any/linux/dm-log-userspace.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/dma-buf.h88
-rw-r--r--lib/libc/include/any-linux-any/linux/dn.h149
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/audio.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/ca.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/dmx.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/frontend.h77
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/net.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/osd.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/version.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dvb/video.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/dw100.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/elf-em.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/elf.h37
-rw-r--r--lib/libc/include/any-linux-any/linux/ethtool.h159
-rw-r--r--lib/libc/include/any-linux-any/linux/ethtool_netlink.h121
-rw-r--r--lib/libc/include/any-linux-any/linux/eventpoll.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/f2fs.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/fanotify.h53
-rw-r--r--lib/libc/include/any-linux-any/linux/fb.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/fcntl.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/fiemap.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/firewire-cdev.h12
-rw-r--r--lib/libc/include/any-linux-any/linux/fou.h56
-rw-r--r--lib/libc/include/any-linux-any/linux/fs.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/fscrypt.h7
-rw-r--r--lib/libc/include/any-linux-any/linux/fsi.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/fsmap.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/fuse.h118
-rw-r--r--lib/libc/include/any-linux-any/linux/genetlink.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/gpio.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/gsmmux.h17
-rw-r--r--lib/libc/include/any-linux-any/linux/gtp.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/hid.h26
-rw-r--r--lib/libc/include/any-linux-any/linux/hsi/cs-protocol.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/hsi/hsi_char.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/hyperv.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/idxd.h35
-rw-r--r--lib/libc/include/any-linux-any/linux/if_addr.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/if_alg.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/if_arcnet.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/if_bridge.h41
-rw-r--r--lib/libc/include/any-linux-any/linux/if_ether.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/if_link.h121
-rw-r--r--lib/libc/include/any-linux-any/linux/if_macsec.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/if_packet.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/if_pppox.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/if_tun.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/if_tunnel.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/igmp.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/iio/types.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/in.h25
-rw-r--r--lib/libc/include/any-linux-any/linux/inet_diag.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/inotify.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/input-event-codes.h29
-rw-r--r--lib/libc/include/any-linux-any/linux/input.h12
-rw-r--r--lib/libc/include/any-linux-any/linux/io_uring.h302
-rw-r--r--lib/libc/include/any-linux-any/linux/ioam6.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/ioam6_iptunnel.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/iommu.h181
-rw-r--r--lib/libc/include/any-linux-any/linux/iommufd.h347
-rw-r--r--lib/libc/include/any-linux-any/linux/ip.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/ip_vs.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/ipmi_ssif_bmc.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/ipv6.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/iso_fs.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/jffs2.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/kcov.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/kd.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/kexec.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/kfd_ioctl.h149
-rw-r--r--lib/libc/include/any-linux-any/linux/kfd_sysfs.h108
-rw-r--r--lib/libc/include/any-linux-any/linux/kvm.h256
-rw-r--r--lib/libc/include/any-linux-any/linux/l2tp.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/landlock.h57
-rw-r--r--lib/libc/include/any-linux-any/linux/lirc.h21
-rw-r--r--lib/libc/include/any-linux-any/linux/loadpin.h22
-rw-r--r--lib/libc/include/any-linux-any/linux/loop.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/lwtunnel.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/magic.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/mctp.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/mdio.h83
-rw-r--r--lib/libc/include/any-linux-any/linux/media-bus-format.h12
-rw-r--r--lib/libc/include/any-linux-any/linux/media.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/membarrier.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/memfd.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/meye.h65
-rw-r--r--lib/libc/include/any-linux-any/linux/minix_fs.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/mmc/ioctl.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/module.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/mptcp.h23
-rw-r--r--lib/libc/include/any-linux-any/linux/mroute6.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/ndctl.h12
-rw-r--r--lib/libc/include/any-linux-any/linux/neighbour.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/net_dropmon.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/net_tstamp.h20
-rw-r--r--lib/libc/include/any-linux-any/linux/netdev.h61
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/ipset/ip_set.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_common.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_sctp.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/nf_tables.h43
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_cttimeout.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_queue.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/x_tables.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/xt_AUDIT.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/xt_IDLETIMER.h17
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/xt_connmark.h13
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter/xt_osf.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_arp/arp_tables.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_bridge/ebt_among.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_decnet.h68
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_ipv4/ip_tables.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6_tables.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_LOG.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/netlink.h32
-rw-r--r--lib/libc/include/any-linux-any/linux/nfs4.h1
-rw-r--r--lib/libc/include/any-linux-any/linux/nfs_fs.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/nl80211.h333
-rw-r--r--lib/libc/include/any-linux-any/linux/nvme_ioctl.h34
-rw-r--r--lib/libc/include/any-linux-any/linux/omap3isp.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/openvswitch.h36
-rw-r--r--lib/libc/include/any-linux-any/linux/pci_regs.h175
-rw-r--r--lib/libc/include/any-linux-any/linux/perf_event.h76
-rw-r--r--lib/libc/include/any-linux-any/linux/pfkeyv2.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/pfrut.h262
-rw-r--r--lib/libc/include/any-linux-any/linux/pkt_cls.h35
-rw-r--r--lib/libc/include/any-linux-any/linux/pkt_sched.h11
-rw-r--r--lib/libc/include/any-linux-any/linux/pr.h17
-rw-r--r--lib/libc/include/any-linux-any/linux/prctl.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/psci.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/ptrace.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/raid/md_p.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/random.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/reiserfs_xattr.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/rfkill.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/rkisp1-config.h77
-rw-r--r--lib/libc/include/any-linux-any/linux/romfs_fs.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/rpl.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/rpmsg.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/rseq.h42
-rw-r--r--lib/libc/include/any-linux-any/linux/rtc.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/rtnetlink.h20
-rw-r--r--lib/libc/include/any-linux-any/linux/sctp.h10
-rw-r--r--lib/libc/include/any-linux-any/linux/seccomp.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/sed-opal.h22
-rw-r--r--lib/libc/include/any-linux-any/linux/seg6.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/seg6_iptunnel.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/seg6_local.h24
-rw-r--r--lib/libc/include/any-linux-any/linux/serial.h65
-rw-r--r--lib/libc/include/any-linux-any/linux/serial_core.h13
-rw-r--r--lib/libc/include/any-linux-any/linux/serial_reg.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/sev-guest.h80
-rw-r--r--lib/libc/include/any-linux-any/linux/smc.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/snmp.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/socket.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/soundcard.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/spi/spi.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/stat.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/stddef.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/stm.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/swab.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/sysctl.h37
-rw-r--r--lib/libc/include/any-linux-any/linux/target_core_user.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/taskstats.h30
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_bpf.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_ct.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_skbedit.h15
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_skbmod.h7
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_tunnel_key.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/tc_act/tc_vlan.h5
-rw-r--r--lib/libc/include/any-linux-any/linux/tcp.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/tdx-guest.h42
-rw-r--r--lib/libc/include/any-linux-any/linux/tee.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/thermal.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/tipc_config.h26
-rw-r--r--lib/libc/include/any-linux-any/linux/tls.h34
-rw-r--r--lib/libc/include/any-linux-any/linux/tty.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/types.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/ublk_cmd.h278
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/audio.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/cdc.h19
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/ch9.h18
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/g_uvc.h3
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/raw_gadget.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/usb/video.h34
-rw-r--r--lib/libc/include/any-linux-any/linux/usbdevice_fs.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/usbip.h26
-rw-r--r--lib/libc/include/any-linux-any/linux/userfaultfd.h20
-rw-r--r--lib/libc/include/any-linux-any/linux/uuid.h22
-rw-r--r--lib/libc/include/any-linux-any/linux/uvcvideo.h6
-rw-r--r--lib/libc/include/any-linux-any/linux/v4l2-common.h39
-rw-r--r--lib/libc/include/any-linux-any/linux/v4l2-controls.h820
-rw-r--r--lib/libc/include/any-linux-any/linux/v4l2-dv-timings.h9
-rw-r--r--lib/libc/include/any-linux-any/linux/v4l2-mediabus.h4
-rw-r--r--lib/libc/include/any-linux-any/linux/v4l2-subdev.h87
-rw-r--r--lib/libc/include/any-linux-any/linux/vdpa.h16
-rw-r--r--lib/libc/include/any-linux-any/linux/vduse.h47
-rw-r--r--lib/libc/include/any-linux-any/linux/version.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/vfio.h695
-rw-r--r--lib/libc/include/any-linux-any/linux/vfio_zdev.h7
-rw-r--r--lib/libc/include/any-linux-any/linux/vhost.h48
-rw-r--r--lib/libc/include/any-linux-any/linux/vhost_types.h19
-rw-r--r--lib/libc/include/any-linux-any/linux/videodev2.h57
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_9p.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_blk.h124
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_bt.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_config.h13
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_crypto.h82
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_ids.h14
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_iommu.h8
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_net.h38
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_pci.h2
-rw-r--r--lib/libc/include/any-linux-any/linux/virtio_ring.h16
-rw-r--r--lib/libc/include/any-linux-any/linux/xfrm.h25
-rw-r--r--lib/libc/include/any-linux-any/misc/fastrpc.h88
-rw-r--r--lib/libc/include/any-linux-any/misc/uacce/hisi_qm.h17
-rw-r--r--lib/libc/include/any-linux-any/mtd/mtd-abi.h68
-rw-r--r--lib/libc/include/any-linux-any/mtd/ubi-user.h8
-rw-r--r--lib/libc/include/any-linux-any/rdma/efa-abi.h4
-rw-r--r--lib/libc/include/any-linux-any/rdma/erdma-abi.h49
-rw-r--r--lib/libc/include/any-linux-any/rdma/hfi/hfi1_user.h2
-rw-r--r--lib/libc/include/any-linux-any/rdma/hns-abi.h21
-rw-r--r--lib/libc/include/any-linux-any/rdma/ib_user_ioctl_verbs.h4
-rw-r--r--lib/libc/include/any-linux-any/rdma/ib_user_verbs.h135
-rw-r--r--lib/libc/include/any-linux-any/rdma/mana-abi.h66
-rw-r--r--lib/libc/include/any-linux-any/rdma/mlx5-abi.h1
-rw-r--r--lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_cmds.h20
-rw-r--r--lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_verbs.h1
-rw-r--r--lib/libc/include/any-linux-any/rdma/rdma_user_cm.h2
-rw-r--r--lib/libc/include/any-linux-any/rdma/rdma_user_ioctl_cmds.h2
-rw-r--r--lib/libc/include/any-linux-any/rdma/rdma_user_rxe.h12
-rw-r--r--lib/libc/include/any-linux-any/scsi/fc/fc_els.h18
-rw-r--r--lib/libc/include/any-linux-any/scsi/scsi_bsg_fc.h4
-rw-r--r--lib/libc/include/any-linux-any/scsi/scsi_bsg_mpi3mr.h576
-rw-r--r--lib/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h48
-rw-r--r--lib/libc/include/any-linux-any/scsi/scsi_netlink_fc.h7
-rw-r--r--lib/libc/include/any-linux-any/sound/asequencer.h24
-rw-r--r--lib/libc/include/any-linux-any/sound/asoc.h4
-rw-r--r--lib/libc/include/any-linux-any/sound/asound.h29
-rw-r--r--lib/libc/include/any-linux-any/sound/asound_fm.h15
-rw-r--r--lib/libc/include/any-linux-any/sound/compress_offload.h19
-rw-r--r--lib/libc/include/any-linux-any/sound/compress_params.h44
-rw-r--r--lib/libc/include/any-linux-any/sound/emu10k1.h16
-rw-r--r--lib/libc/include/any-linux-any/sound/firewire.h32
-rw-r--r--lib/libc/include/any-linux-any/sound/hdsp.h14
-rw-r--r--lib/libc/include/any-linux-any/sound/hdspm.h15
-rw-r--r--lib/libc/include/any-linux-any/sound/intel/avs/tokens.h130
-rw-r--r--lib/libc/include/any-linux-any/sound/sb16_csp.h15
-rw-r--r--lib/libc/include/any-linux-any/sound/sfnt_info.h15
-rw-r--r--lib/libc/include/any-linux-any/sound/skl-tplg-interface.h5
-rw-r--r--lib/libc/include/any-linux-any/sound/snd_ar_tokens.h27
-rw-r--r--lib/libc/include/any-linux-any/sound/snd_sst_tokens.h10
-rw-r--r--lib/libc/include/any-linux-any/sound/sof/abi.h4
-rw-r--r--lib/libc/include/any-linux-any/sound/sof/header.h32
-rw-r--r--lib/libc/include/any-linux-any/sound/sof/tokens.h63
-rw-r--r--lib/libc/include/any-linux-any/sound/tlv.h11
-rw-r--r--lib/libc/include/any-linux-any/sound/usb_stream.h16
-rw-r--r--lib/libc/include/any-linux-any/xen/gntdev.h8
-rw-r--r--lib/libc/include/any-macos-any/netinet/in_systm.h89
-rw-r--r--lib/libc/include/any-macos-any/netinet/ip.h233
-rw-r--r--lib/libc/include/any-macos-any/netinet/udp.h85
-rw-r--r--lib/libc/include/any-macos-any/sys/paths.h44
-rw-r--r--lib/libc/include/any-macos-any/zconf.h523
-rw-r--r--lib/libc/include/any-macos-any/zlib.h1946
-rw-r--r--lib/libc/include/arc-linux-any/asm/bpf_perf_event.h9
-rw-r--r--lib/libc/include/arm-linux-any/asm/hwcap.h8
-rw-r--r--lib/libc/include/arm-linux-any/asm/signal.h2
-rw-r--r--lib/libc/include/arm-linux-any/asm/unistd-eabi.h1
-rw-r--r--lib/libc/include/arm-linux-any/asm/unistd-oabi.h1
-rw-r--r--lib/libc/include/generic-glibc/resolv.h25
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/auxvec.h17
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/bitsperlong.h9
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/bpf_perf_event.h (renamed from lib/libc/include/powerpc-linux-any/asm/bpf_perf_event.h)2
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/break.h23
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/byteorder.h13
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/hwcap.h20
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/perf_regs.h40
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/ptrace.h60
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/reg.h59
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/sigcontext.h44
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/signal.h13
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/ucontext.h35
-rw-r--r--lib/libc/include/loongarch-linux-any/asm/unistd.h5
-rw-r--r--lib/libc/include/m68k-linux-any/asm/bootinfo-virt.h21
-rw-r--r--lib/libc/include/m68k-linux-any/asm/bootinfo.h12
-rw-r--r--lib/libc/include/m68k-linux-any/asm/ptrace.h5
-rw-r--r--lib/libc/include/m68k-linux-any/asm/signal.h2
-rw-r--r--lib/libc/include/m68k-linux-any/asm/unistd_32.h1
-rw-r--r--lib/libc/include/mips-linux-any/asm/fcntl.h30
-rw-r--r--lib/libc/include/mips-linux-any/asm/mman.h4
-rw-r--r--lib/libc/include/mips-linux-any/asm/shmbuf.h7
-rw-r--r--lib/libc/include/mips-linux-any/asm/signal.h2
-rw-r--r--lib/libc/include/mips-linux-any/asm/socket.h4
-rw-r--r--lib/libc/include/mips-linux-any/asm/stat.h20
-rw-r--r--lib/libc/include/mips-linux-any/asm/termbits.h249
-rw-r--r--lib/libc/include/mips-linux-any/asm/ucontext.h2
-rw-r--r--lib/libc/include/mips-linux-any/asm/unistd_n32.h1
-rw-r--r--lib/libc/include/mips-linux-any/asm/unistd_n64.h1
-rw-r--r--lib/libc/include/mips-linux-any/asm/unistd_o32.h1
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/auxvec.h4
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/elf.h8
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/papr_pdsm.h18
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/shmbuf.h5
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/signal.h7
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/stat.h10
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/termbits.h182
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/unistd_32.h1
-rw-r--r--lib/libc/include/powerpc-linux-any/asm/unistd_64.h1
-rw-r--r--lib/libc/include/riscv-linux-any/asm/auxvec.h4
-rw-r--r--lib/libc/include/riscv-linux-any/asm/kvm.h29
-rw-r--r--lib/libc/include/riscv-linux-any/asm/setup.h8
-rw-r--r--lib/libc/include/riscv-linux-any/asm/ucontext.h12
-rw-r--r--lib/libc/include/riscv-linux-any/asm/unistd.h3
-rw-r--r--lib/libc/include/s390x-linux-any/asm/dasd.h14
-rw-r--r--lib/libc/include/s390x-linux-any/asm/fs3270.h25
-rw-r--r--lib/libc/include/s390x-linux-any/asm/hwctrset.h6
-rw-r--r--lib/libc/include/s390x-linux-any/asm/ipl.h29
-rw-r--r--lib/libc/include/s390x-linux-any/asm/kvm.h1
-rw-r--r--lib/libc/include/s390x-linux-any/asm/pkey.h2
-rw-r--r--lib/libc/include/s390x-linux-any/asm/raw3270.h75
-rw-r--r--lib/libc/include/s390x-linux-any/asm/signal.h2
-rw-r--r--lib/libc/include/s390x-linux-any/asm/termios.h50
-rw-r--r--lib/libc/include/s390x-linux-any/asm/types.h15
-rw-r--r--lib/libc/include/s390x-linux-any/asm/unistd_32.h1
-rw-r--r--lib/libc/include/s390x-linux-any/asm/unistd_64.h1
-rw-r--r--lib/libc/include/s390x-linux-any/asm/uvdevice.h51
-rw-r--r--lib/libc/include/s390x-linux-any/asm/zcrypt.h45
-rw-r--r--lib/libc/include/sparc-linux-any/asm/shmbuf.h5
-rw-r--r--lib/libc/include/sparc-linux-any/asm/signal.h3
-rw-r--r--lib/libc/include/sparc-linux-any/asm/socket.h3
-rw-r--r--lib/libc/include/sparc-linux-any/asm/stat.h12
-rw-r--r--lib/libc/include/sparc-linux-any/asm/termbits.h223
-rw-r--r--lib/libc/include/sparc-linux-any/asm/unistd_32.h1
-rw-r--r--lib/libc/include/sparc-linux-any/asm/unistd_64.h1
-rw-r--r--lib/libc/include/x86-linux-any/asm/amd_hsmp.h307
-rw-r--r--lib/libc/include/x86-linux-any/asm/bootparam.h21
-rw-r--r--lib/libc/include/x86-linux-any/asm/kvm.h95
-rw-r--r--lib/libc/include/x86-linux-any/asm/mman.h14
-rw-r--r--lib/libc/include/x86-linux-any/asm/prctl.h26
-rw-r--r--lib/libc/include/x86-linux-any/asm/processor-flags.h2
-rw-r--r--lib/libc/include/x86-linux-any/asm/sgx.h62
-rw-r--r--lib/libc/include/x86-linux-any/asm/shmbuf.h6
-rw-r--r--lib/libc/include/x86-linux-any/asm/signal.h2
-rw-r--r--lib/libc/include/x86-linux-any/asm/svm.h19
-rw-r--r--lib/libc/include/x86-linux-any/asm/unistd_32.h1
-rw-r--r--lib/libc/include/x86-linux-any/asm/unistd_64.h1
-rw-r--r--lib/libc/include/x86-linux-any/asm/unistd_x32.h1
-rw-r--r--lib/libc/include/x86-linux-any/asm/vmx.h4
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/auxvec.h4
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/byteorder.h13
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/ioctls.h130
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/ipcbuf.h40
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/mman.h124
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/msgbuf.h50
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/param.h29
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/poll.h21
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/posix_types.h40
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/ptrace.h63
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/sembuf.h45
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/setup.h17
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/shmbuf.h54
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/sigcontext.h29
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/signal.h108
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/sockios.h32
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/stat.h60
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/swab.h71
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/types.h30
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/unistd.h26
-rw-r--r--lib/libc/include/xtensa-linux-any/asm/unistd_32.h402
-rw-r--r--lib/libc/wasi/libc-bottom-half/crt/crt1-reactor.c20
-rw-r--r--lib/libc/wasi/libc-bottom-half/sources/__errno_location.c5
-rw-r--r--lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c2
-rw-r--r--lib/libc/wasi/libc-top-half/musl/arch/wasm32/atomic_arch.h1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/include/pthread.h6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/aio/aio.c418
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/aio/aio_suspend.c79
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/aio/lio_listio.c143
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/cimag.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/cimagf.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/cimagl.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/creal.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/crealf.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/complex/creall.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/closedir.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/dirfd.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/fdopendir.c31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/opendir.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/readdir.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/readdir_r.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/rewinddir.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/scandir.c47
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/seekdir.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/dirent/telldir.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/env/__environ.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/env/__init_tls.c237
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/env/__libc_start_main.c97
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/env/__reset_tls.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/env/secure_getenv.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/errno/__errno_location.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/exit/_Exit.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/exit/abort.c30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/exit/abort_lock.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/exit/arm/__aeabi_atexit.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fcntl/fcntl.c48
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fcntl/open.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fcntl/openat.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fadvise.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fallocate.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/__flt_rounds.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/aarch64/fenv.s68
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/arm/fenv.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/i386/fenv.s164
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/m68k/fenv.c85
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/mips/fenv-sf.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/mips64/fenv-sf.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/mipsn32/fenv-sf.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv-sf.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc64/fenv.c69
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/riscv64/fenv-sf.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/s390x/fenv.c56
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c3
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/x32/fenv.s98
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/fenv/x86_64/fenv.s98
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/i386/defsysinfo.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/procfdname.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/sh/__shcall.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/syscall_ret.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/vdso.c93
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/internal/version.c4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/ftok.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/msgctl.c51
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/msgget.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/msgrcv.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/msgsnd.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/semctl.c69
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/semget.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/semop.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/semtimedop.c35
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/shmat.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/shmctl.c51
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/shmdt.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ipc/shmget.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/__dlsym.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/dlsym.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/arm/dlsym.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/arm/find_exidx.c42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dl_iterate_phdr.c47
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dladdr.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dlclose.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dlerror.c87
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dlinfo.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dlopen.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/dlsym.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/i386/dlsym.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/i386/tlsdesc.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/m68k/dlsym.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/microblaze/dlsym.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/mips/dlsym.s17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/mips64/dlsym.s17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/mipsn32/dlsym.s17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/or1k/dlsym.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc/dlsym.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc64/dlsym.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/riscv64/dlsym.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/s390x/dlsym.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/sh/dlsym.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/tlsdesc.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/x32/dlsym.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/dlsym.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/cuserid.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/daemon.c33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/err.c67
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/euidaccess.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/ftw.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/futimes.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/getdtablesize.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/getloadavg.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/getpass.c40
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/getusershell.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/isastream.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/lutimes.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/ulimit.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/utmpx.c52
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/legacy/valloc.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/adjtime.c27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/adjtimex.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/arch_prctl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/brk.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/cache.c50
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/cap.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/chroot.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/clock_adjtime.c151
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/clone.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/copy_file_range.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/epoll.c37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/eventfd.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/fallocate.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/fanotify.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/flock.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/getdents.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/getrandom.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/gettid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/inotify.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/ioperm.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/iopl.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/klogctl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/membarrier.c72
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/memfd_create.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/mlock2.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/module.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/mount.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/name_to_handle_at.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/open_by_handle_at.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/personality.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/pivot_root.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/ppoll.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/prctl.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/prlimit.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/process_vm.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/ptrace.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/quotactl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/readahead.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/reboot.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/remap_file_pages.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/sbrk.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/sendfile.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/setfsgid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/setfsuid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/setgroups.c36
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/sethostname.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/setns.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/settimeofday.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/signalfd.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/splice.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/stime.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/swap.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/sync_file_range.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/syncfs.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/sysinfo.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/tee.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/timerfd.c59
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/unshare.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/utimes.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/vhangup.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/vmsplice.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/wait3.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/wait4.c39
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/x32/sysinfo.c49
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/linux/xattr.c62
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/locale/bind_textdomain_codeset.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/locale/dcngettext.c283
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/locale/textdomain.c42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/calloc.c45
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/free.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/libc_calloc.c4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/lite_malloc.c118
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c60
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/donate.c39
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/free.c151
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc.c387
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc_usable_size.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/realloc.c51
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/memalign.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/aligned_alloc.c53
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc.c556
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_usable_size.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/posix_memalign.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/realloc.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/reallocarray.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/malloc/replaced.c4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__fpclassify.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyf.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyl.c42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__signbit.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__signbitf.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/__signbitl.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceil.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceilf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabs.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabsf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floor.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floorf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fma.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmax.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaxf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmin.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fminf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrint.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrintf.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llround.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llroundf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrint.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrintf.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lround.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lroundf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyint.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyintf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rint.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rintf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/round.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/roundf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrt.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrtf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/trunc.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/aarch64/truncf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/fabs.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/fabsf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/fma.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/fmaf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrt.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrtf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/ceil.c31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/ceilf.c27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/copysign.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/copysignf.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fabs.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fabsf.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/floor.c31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/floorf.c27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fmax.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fmaxf.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fmin.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/fminf.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/__invtrigl.s0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/acos.s18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/acosf.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/acosl.s14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/asin.s21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/asinf.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/asinl.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atan.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2f.s17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atanf.s18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/atanl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ceil.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ceilf.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ceill.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/exp2l.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/exp_ld.s93
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/expl.s101
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/expm1l.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fabs.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/floor.s67
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/floorf.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/floorl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fmod.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodf.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodl.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/hypot.s45
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/hypotf.s42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexp.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpf.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/llrint.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintl.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log10.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log10f.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log10l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log1p.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pf.s26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pl.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log2.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log2f.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/log2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/logf.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/logl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/lrint.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintl.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remainder.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderf.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderl.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remquo.s50
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remquof.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/remquol.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/rint.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/rintf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/rintl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbln.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnf.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbn.s33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnf.s32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnl.s32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrt.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtf.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/trunc.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/truncf.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/i386/truncl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/m68k/sqrtl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/mips/fabs.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/mips/fabsf.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrt.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrtf.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/nearbyint.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/nearbyintf.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabs.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabsf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fma.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fmaf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrt.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrtf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceil.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceilf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabs.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabsf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floor.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floorf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fma.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmax.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaxf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmin.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fminf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrint.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrintf.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lround.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lroundf.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/round.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/roundf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrt.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrtf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/trunc.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/truncf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/rint.c28
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/rintf.c30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysign.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysignf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabs.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabsf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fma.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmax.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaxf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmin.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fminf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrt.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrtf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceil.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceilf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceill.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabs.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/floor.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/fma.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/fmaf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyint.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/rint.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/round.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrt.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/trunc.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncf.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncl.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/sqrt.c158
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/sqrtf.c83
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/trunc.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/truncf.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/__invtrigl.s0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/acosl.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/asinl.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/atan2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/atanl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/ceill.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/exp2l.s83
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/expl.s101
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/expm1l.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fabs.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsf.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsl.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/floorl.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fma.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fmaf.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/fmodl.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/llrint.s5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintf.s5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/log10l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/log1pl.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/log2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/logl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/lrint.s5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintf.s5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/remainderl.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/rintl.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrt.s4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtf.s4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtl.s5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x32/truncl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/__invtrigl.s0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/acosl.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/asinl.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atan2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atanl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/ceill.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/exp2l.s83
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expl.s101
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expm1l.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabs.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsf.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/floorl.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fma.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmaf.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmodl.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrint.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintl.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log10l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log1pl.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log2l.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/logl.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrint.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintf.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintl.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remainderl.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remquol.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/rintl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrt.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtf.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtl.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/math/x86_64/truncl.s1
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/forkpty.c57
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/get_current_dir_name.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getauxval.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getentropy.c33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getpriority.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getresgid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getresuid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getrlimit.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/getrusage.c35
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/initgroups.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/ioctl.c151
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/issetugid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/lockf.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/login_tty.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/mntent.c77
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/openpty.c40
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/ptsname.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/pty.c35
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c156
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/setdomainname.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/setpriority.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/setrlimit.c47
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/syscall.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/syslog.c162
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/misc/wordexp.c187
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/madvise.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mincore.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mlock.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mlockall.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mmap.c41
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mprotect.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/mremap.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/msync.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/munlock.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/munlockall.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/munmap.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/posix_madvise.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mman/shm_open.c43
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_close.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_getattr.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_notify.c73
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_open.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_receive.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_send.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_setattr.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedreceive.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedsend.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/mq/mq_unlink.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/accept.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/accept4.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/bind.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/connect.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/dn_comp.c107
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/dn_expand.c33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/dn_skipname.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/dns_parse.c33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/ent.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/ether.c58
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/freeaddrinfo.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gai_strerror.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getaddrinfo.c135
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr_r.c71
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2_r.c80
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname_r.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getifaddrs.c216
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getnameinfo.c200
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getpeername.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getservbyname.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getservbyname_r.c55
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getservbyport.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getservbyport_r.c60
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getsockname.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/getsockopt.c41
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/h_errno.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/herror.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/hstrerror.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/if_freenameindex.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/if_indextoname.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/if_nameindex.c114
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/if_nametoindex.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/inet_addr.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/inet_legacy.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/inet_ntoa.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/listen.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/lookup_ipliteral.c55
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/lookup_name.c425
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/lookup_serv.c114
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/netlink.c52
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/netname.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/ns_parse.c171
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/proto.c84
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/recv.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/recvfrom.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/recvmmsg.c39
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/recvmsg.c68
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_init.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_mkquery.c44
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_msend.c188
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_query.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_querydomain.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_send.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/res_state.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/resolvconf.c94
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/send.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/sendmmsg.c30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/sendmsg.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/sendto.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/serv.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/setsockopt.c46
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/shutdown.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/sockatmark.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/socket.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/network/socketpair.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/fgetgrent.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/fgetpwent.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/fgetspent.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_a.c169
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_r.c49
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent.c39
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent_a.c68
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getgrouplist.c81
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_a.c142
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_r.c42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent.c37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent_a.c54
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getspent.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam_r.c125
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/lckpwdf.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/nscd_query.c115
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/putgrent.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/putpwent.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/passwd/putspent.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/_Fork.c38
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/arm/vfork.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execl.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execle.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execlp.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execv.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execve.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/execvp.c60
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/fexecve.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/fork.c86
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/i386/vfork.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn.c214
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_destroy.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getflags.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getpgroup.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigdefault.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigmask.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_sched.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setflags.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setpgroup.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigdefault.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigmask.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnp.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/s390x/vfork.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/sh/vfork.s20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/system.c46
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/vfork.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/wait.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/waitid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/waitpid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/x32/vfork.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/process/x86_64/vfork.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/affinity.c33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_cpucount.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_get_priority_max.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_getcpu.c42
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_getparam.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_getscheduler.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_rr_get_interval.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_setparam.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_setscheduler.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/sched/sched_yield.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/select/poll.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/select/pselect.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/select/select.c44
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/longjmp.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/setjmp.s24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/longjmp.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/setjmp.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/longjmp.c0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/longjmp.s14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/setjmp.s18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/longjmp.s29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/setjmp.s32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/longjmp.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/setjmp.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s81
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s89
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/longjmp.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/setjmp.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/setjmp.c0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/longjmp.s18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/setjmp.s22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/longjmp.s18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/setjmp.s22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/restore.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/sigsetjmp.s21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/arm/restore.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/arm/sigsetjmp.s24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/block.c44
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/getitimer.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/i386/restore.s14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/i386/sigsetjmp.s26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/kill.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/killpg.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/m68k/sigsetjmp.s29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/restore.s13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/sigsetjmp.s22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mips/restore.s15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mips/sigsetjmp.s33
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mips64/restore.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mips64/sigsetjmp.s38
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/restore.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/sigsetjmp.s38
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/or1k/sigsetjmp.s24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/restore.s13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/sigsetjmp.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/restore.s13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/sigsetjmp.s37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/psiginfo.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/raise.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/restore.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/restore.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/sigsetjmp.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/s390x/restore.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/s390x/sigsetjmp.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/setitimer.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sh/restore.s24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sh/sigsetjmp.s41
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigaction.c84
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigaddset.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigaltstack.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigandset.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigdelset.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigemptyset.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigfillset.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sighold.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigignore.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/siginterrupt.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigisemptyset.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigismember.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/siglongjmp.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/signal.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigorset.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigpause.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigpending.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigprocmask.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigqueue.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigrelse.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmax.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmin.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigset.c27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp.c0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp_tail.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigsuspend.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigtimedwait.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigwait.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/sigwaitinfo.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x32/getitimer.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x32/restore.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x32/setitimer.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x32/sigsetjmp.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/restore.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/sigsetjmp.s24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/__xstat.c40
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/chmod.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/fchmod.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/fchmodat.c38
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/fstat.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/fstatat.c147
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/futimens.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/lchmod.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/lstat.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mkdir.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mkdirat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mkfifo.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mkfifoat.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mknod.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/mknodat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/stat.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/statvfs.c63
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/umask.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stat/utimensat.c60
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/__lockfile.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/flockfile.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/ftrylockfile.c46
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/funlockfile.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/gets.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/pclose.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/popen.c61
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/remove.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/rename.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/tempnam.c49
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/tmpfile.c31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/stdio/tmpnam.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memcpy.s45
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memset.s31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/i386/memcpy.s32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/i386/memmove.s22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/i386/memset.s76
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memcpy.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memmove.s16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memset.s72
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/__randname.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mkdtemp.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mkostemp.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mkostemps.c29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mkstemp.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mkstemps.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/temp/mktemp.c30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/cfgetospeed.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/cfmakeraw.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/cfsetospeed.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcdrain.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcflow.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcflush.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcgetattr.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcgetsid.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcgetwinsize.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcsendbreak.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcsetattr.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/termios/tcsetwinsize.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__lock.c62
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__set_thread_area.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__syscall_cp.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__timedwait.c84
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__tls_get_addr.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__unmapself.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/__wait.c55
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__unmapself.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/clone.s30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/syscall_cp.s32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/__set_thread_area.c52
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/__unmapself.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/atomics.s106
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/clone.s28
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/arm/syscall_cp.s29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/call_once.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/clone.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_broadcast.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_signal.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_timedwait.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/cnd_wait.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/default_attr.c4
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/i386/__set_thread_area.s47
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/i386/__unmapself.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/i386/clone.s49
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/i386/syscall_cp.s41
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/i386/tls.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/lock_ptc.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/m68k/clone.s25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/m68k/syscall_cp.s26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__unmapself.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/clone.s30
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/syscall_cp.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips/__unmapself.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips/clone.s36
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips/syscall_cp.s53
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips64/__unmapself.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips64/clone.s34
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mips64/syscall_cp.s52
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/__unmapself.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/clone.s34
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s51
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_destroy.c5
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_init.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_lock.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_timedlock.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_trylock.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/mtx_unlock.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__set_thread_area.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__unmapself.s8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/or1k/clone.s31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/or1k/syscall_cp.s29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__unmapself.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/clone.s73
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/syscall_cp.s59
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__unmapself.s9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/clone.s48
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s44
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_atfork.c49
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_get.c102
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_init.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setscope.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstack.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstacksize.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_destroy.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_init.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_wait.c119
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cancel.c101
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cleanup_push.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_broadcast.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_destroy.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_init.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_signal.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_timedwait.c230
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_wait.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setclock.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setpshared.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_create.c585
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_detach.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_equal.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getattr_np.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getconcurrency.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getcpuclockid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getname_np.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getschedparam.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getspecific.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_join.c46
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_key_create.c95
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_kill.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_consistent.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_destroy.c18
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_init.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_lock.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c96
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_trylock.c78
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_unlock.c60
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c32
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_settype.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_once.c50
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_init.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_unlock.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_init.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_self.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setattr_default_np.c37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcancelstate.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcanceltype.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setconcurrency.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setname_np.c26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedparam.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedprio.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setspecific.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_sigmask.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_init.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_lock.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_trylock.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_unlock.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/pthread_testcancel.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__unmapself.s7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/clone.s34
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/syscall_cp.s29
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__set_thread_area.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__unmapself.s6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/s390x/clone.s54
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/s390x/syscall_cp.s34
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_destroy.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_getvalue.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_init.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_open.c182
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_post.c17
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_timedwait.c31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_trywait.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_unlink.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sem_wait.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/__set_thread_area.c37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/atomics.s65
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/clone.s54
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/sh/syscall_cp.s45
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/synccall.c120
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/syscall_cp.c0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/thrd_create.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/thrd_exit.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/thrd_join.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/thrd_yield.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/tls.c0
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/tss_create.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/tss_delete.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/tss_set.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/vmlock.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x32/__set_thread_area.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x32/__unmapself.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x32/clone.s26
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x32/syscall_cp.s31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__unmapself.s10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/clone.s28
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/syscall_cp.s31
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/__map_file.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock.c16
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock_getcpuclockid.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock_getres.c21
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock_gettime.c107
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock_nanosleep.c38
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/clock_settime.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/gettimeofday.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/nanosleep.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/time.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/timer_create.c129
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/timer_delete.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/timer_getoverrun.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/timer_gettime.c28
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/timer_settime.c37
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/times.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/time/utime.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/_exit.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/access.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/acct.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/alarm.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/chdir.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/chown.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/close.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/ctermid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/dup.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/dup2.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/dup3.c24
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/faccessat.c61
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/fchdir.c15
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/fchown.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/fchownat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/fdatasync.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/fsync.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/ftruncate.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getcwd.c25
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getegid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/geteuid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getgid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getgroups.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/gethostname.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin_r.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getpgid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getpgrp.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getpid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getppid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getsid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/getuid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/isatty.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/lchown.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/link.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/linkat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/lseek.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/mips/pipe.s20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/mips64/pipe.s19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/lseek.c20
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/pipe.s19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/nice.c23
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pause.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pipe.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pipe2.c22
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pread.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/preadv.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pwrite.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/pwritev.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/read.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/readlink.c19
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/readlinkat.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/readv.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/renameat.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/rmdir.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setegid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/seteuid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setgid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setpgid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setpgrp.c6
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setregid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setresgid.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setresuid.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setreuid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setsid.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setuid.c8
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/setxid.c34
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/sh/pipe.s27
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/sleep.c10
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/symlink.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/symlinkat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/sync.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/tcgetpgrp.c11
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/tcsetpgrp.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/truncate.c9
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname.c14
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname_r.c28
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/ualarm.c13
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/unlink.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/unlinkat.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/usleep.c12
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/write.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/writev.c7
-rw-r--r--lib/libc/wasi/libc-top-half/musl/src/unistd/x32/lseek.c15
1544 files changed, 19824 insertions, 32305 deletions
diff --git a/lib/libc/glibc/README.md b/lib/libc/glibc/README.md
index 399d3beb2d..e5fe99a532 100644
--- a/lib/libc/glibc/README.md
+++ b/lib/libc/glibc/README.md
@@ -6,3 +6,4 @@ need to be cherry-picked in the future glibc header upgrades:
- 39083c31a550ed80f369f60d35791e98904b8096
- a89813ef282c092a9caf699731c7faaf485acabe
+- 3eaca9bbc6fee4b6be0f22b844f7d3214222f434
diff --git a/lib/libc/include/aarch64-linux-any/asm/hwcap.h b/lib/libc/include/aarch64-linux-any/asm/hwcap.h
index 5004bd804b..5d2f34d3b7 100644
--- a/lib/libc/include/aarch64-linux-any/asm/hwcap.h
+++ b/lib/libc/include/aarch64-linux-any/asm/hwcap.h
@@ -19,6 +19,9 @@
/*
* HWCAP flags - for AT_HWCAP
+ *
+ * Bits 62 and 63 are reserved for use by libc.
+ * Bits 32-61 are unallocated for potential use by libc.
*/
#define HWCAP_FP (1 << 0)
#define HWCAP_ASIMD (1 << 1)
@@ -76,5 +79,28 @@
#define HWCAP2_BTI (1 << 17)
#define HWCAP2_MTE (1 << 18)
#define HWCAP2_ECV (1 << 19)
+#define HWCAP2_AFP (1 << 20)
+#define HWCAP2_RPRES (1 << 21)
+#define HWCAP2_MTE3 (1 << 22)
+#define HWCAP2_SME (1 << 23)
+#define HWCAP2_SME_I16I64 (1 << 24)
+#define HWCAP2_SME_F64F64 (1 << 25)
+#define HWCAP2_SME_I8I32 (1 << 26)
+#define HWCAP2_SME_F16F32 (1 << 27)
+#define HWCAP2_SME_B16F32 (1 << 28)
+#define HWCAP2_SME_F32F32 (1 << 29)
+#define HWCAP2_SME_FA64 (1 << 30)
+#define HWCAP2_WFXT (1UL << 31)
+#define HWCAP2_EBF16 (1UL << 32)
+#define HWCAP2_SVE_EBF16 (1UL << 33)
+#define HWCAP2_CSSC (1UL << 34)
+#define HWCAP2_RPRFM (1UL << 35)
+#define HWCAP2_SVE2P1 (1UL << 36)
+#define HWCAP2_SME2 (1UL << 37)
+#define HWCAP2_SME2P1 (1UL << 38)
+#define HWCAP2_SME_I16I32 (1UL << 39)
+#define HWCAP2_SME_BI32I32 (1UL << 40)
+#define HWCAP2_SME_B16B16 (1UL << 41)
+#define HWCAP2_SME_F16F16 (1UL << 42)
#endif /* __ASM_HWCAP_H */ \ No newline at end of file
diff --git a/lib/libc/include/aarch64-linux-any/asm/kvm.h b/lib/libc/include/aarch64-linux-any/asm/kvm.h
index 2eb5273772..a93fbe0edb 100644
--- a/lib/libc/include/aarch64-linux-any/asm/kvm.h
+++ b/lib/libc/include/aarch64-linux-any/asm/kvm.h
@@ -43,6 +43,7 @@
#define __KVM_HAVE_VCPU_EVENTS
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
+#define KVM_DIRTY_LOG_PAGE_OFFSET 64
#define KVM_REG_SIZE(id) \
(1U << (((id) & KVM_REG_SIZE_MASK) >> KVM_REG_SIZE_SHIFT))
@@ -75,9 +76,11 @@ struct kvm_regs {
/* KVM_ARM_SET_DEVICE_ADDR ioctl id encoding */
#define KVM_ARM_DEVICE_TYPE_SHIFT 0
-#define KVM_ARM_DEVICE_TYPE_MASK (0xffff << KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, \
+ KVM_ARM_DEVICE_TYPE_SHIFT)
#define KVM_ARM_DEVICE_ID_SHIFT 16
-#define KVM_ARM_DEVICE_ID_MASK (0xffff << KVM_ARM_DEVICE_ID_SHIFT)
+#define KVM_ARM_DEVICE_ID_MASK GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, \
+ KVM_ARM_DEVICE_ID_SHIFT)
/* Supported device IDs */
#define KVM_ARM_DEVICE_VGIC_V2 0
@@ -106,6 +109,7 @@ struct kvm_regs {
#define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */
#define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */
#define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */
+#define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */
struct kvm_vcpu_init {
__u32 target;
@@ -139,8 +143,10 @@ struct kvm_guest_debug_arch {
__u64 dbg_wvr[KVM_ARM_MAX_DBG_REGS];
};
+#define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0)
struct kvm_debug_exit_arch {
__u32 hsr;
+ __u32 hsr_high; /* ESR_EL2[61:32] */
__u64 far; /* used for watchpoints */
};
@@ -281,6 +287,11 @@ struct kvm_arm_copy_mte_tags {
#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3
#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4)
+#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 KVM_REG_ARM_FW_REG(3)
+#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL 0
+#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_AVAIL 1
+#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_REQUIRED 2
+
/* SVE registers */
#define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT)
@@ -327,6 +338,31 @@ struct kvm_arm_copy_mte_tags {
#define KVM_ARM64_SVE_VLS_WORDS \
((KVM_ARM64_SVE_VQ_MAX - KVM_ARM64_SVE_VQ_MIN) / 64 + 1)
+/* Bitmap feature firmware registers */
+#define KVM_REG_ARM_FW_FEAT_BMAP (0x0016 << KVM_REG_ARM_COPROC_SHIFT)
+#define KVM_REG_ARM_FW_FEAT_BMAP_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
+ KVM_REG_ARM_FW_FEAT_BMAP | \
+ ((r) & 0xffff))
+
+#define KVM_REG_ARM_STD_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(0)
+
+enum {
+ KVM_REG_ARM_STD_BIT_TRNG_V1_0 = 0,
+};
+
+#define KVM_REG_ARM_STD_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(1)
+
+enum {
+ KVM_REG_ARM_STD_HYP_BIT_PV_TIME = 0,
+};
+
+#define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2)
+
+enum {
+ KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT = 0,
+ KVM_REG_ARM_VENDOR_HYP_BIT_PTP = 1,
+};
+
/* Device Control API: ARM VGIC */
#define KVM_DEV_ARM_VGIC_GRP_ADDR 0
#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
@@ -362,6 +398,7 @@ struct kvm_arm_copy_mte_tags {
#define KVM_ARM_VCPU_PMU_V3_IRQ 0
#define KVM_ARM_VCPU_PMU_V3_INIT 1
#define KVM_ARM_VCPU_PMU_V3_FILTER 2
+#define KVM_ARM_VCPU_PMU_V3_SET_PMU 3
#define KVM_ARM_VCPU_TIMER_CTRL 1
#define KVM_ARM_VCPU_TIMER_IRQ_VTIMER 0
#define KVM_ARM_VCPU_TIMER_IRQ_PTIMER 1
@@ -411,6 +448,16 @@ struct kvm_arm_copy_mte_tags {
#define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS
#define KVM_PSCI_RET_DENIED PSCI_RET_DENIED
+/* arm64-specific kvm_run::system_event flags */
+/*
+ * Reset caused by a PSCI v1.1 SYSTEM_RESET2 call.
+ * Valid only when the system event has a type of KVM_SYSTEM_EVENT_RESET.
+ */
+#define KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 (1ULL << 0)
+
+/* run->fail_entry.hardware_entry_failure_reason codes. */
+#define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED (1ULL << 0)
+
#endif
#endif /* __ARM_KVM_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/aarch64-linux-any/asm/perf_regs.h b/lib/libc/include/aarch64-linux-any/asm/perf_regs.h
index d63b945af5..5a8a1e8776 100644
--- a/lib/libc/include/aarch64-linux-any/asm/perf_regs.h
+++ b/lib/libc/include/aarch64-linux-any/asm/perf_regs.h
@@ -37,5 +37,12 @@ enum perf_event_arm_regs {
PERF_REG_ARM64_SP,
PERF_REG_ARM64_PC,
PERF_REG_ARM64_MAX,
+
+ /* Extended/pseudo registers */
+ PERF_REG_ARM64_VG = 46, /* SVE Vector Granule */
+ PERF_REG_ARM64_EXTENDED_MAX
};
+
+#define PERF_REG_EXTENDED_MASK (1ULL << PERF_REG_ARM64_VG)
+
#endif /* _ASM_ARM64_PERF_REGS_H */ \ No newline at end of file
diff --git a/lib/libc/include/aarch64-linux-any/asm/ptrace.h b/lib/libc/include/aarch64-linux-any/asm/ptrace.h
index 044023b65c..752ebe2c04 100644
--- a/lib/libc/include/aarch64-linux-any/asm/ptrace.h
+++ b/lib/libc/include/aarch64-linux-any/asm/ptrace.h
@@ -109,7 +109,7 @@ struct user_hwdebug_state {
} dbg_regs[16];
};
-/* SVE/FP/SIMD state (NT_ARM_SVE) */
+/* SVE/FP/SIMD state (NT_ARM_SVE & NT_ARM_SSVE) */
struct user_sve_header {
__u32 size; /* total meaningful regset content in bytes */
@@ -220,6 +220,7 @@ struct user_sve_header {
(SVE_PT_SVE_PREG_OFFSET(vq, __SVE_NUM_PREGS) - \
SVE_PT_SVE_PREGS_OFFSET(vq))
+/* For streaming mode SVE (SSVE) FFR must be read and written as zero */
#define SVE_PT_SVE_FFR_OFFSET(vq) \
(SVE_PT_REGS_OFFSET + __SVE_FFR_OFFSET(vq))
@@ -240,10 +241,12 @@ struct user_sve_header {
- SVE_PT_SVE_OFFSET + (__SVE_VQ_BYTES - 1)) \
/ __SVE_VQ_BYTES * __SVE_VQ_BYTES)
-#define SVE_PT_SIZE(vq, flags) \
- (((flags) & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE ? \
- SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, flags) \
- : SVE_PT_FPSIMD_OFFSET + SVE_PT_FPSIMD_SIZE(vq, flags))
+#define SVE_PT_SIZE(vq, flags) \
+ (((flags) & SVE_PT_REGS_MASK) == SVE_PT_REGS_SVE ? \
+ SVE_PT_SVE_OFFSET + SVE_PT_SVE_SIZE(vq, flags) \
+ : ((((flags) & SVE_PT_REGS_MASK) == SVE_PT_REGS_FPSIMD ? \
+ SVE_PT_FPSIMD_OFFSET + SVE_PT_FPSIMD_SIZE(vq, flags) \
+ : SVE_PT_REGS_OFFSET)))
/* pointer authentication masks (NT_ARM_PAC_MASK) */
@@ -265,6 +268,62 @@ struct user_pac_generic_keys {
__uint128_t apgakey;
};
+/* ZA state (NT_ARM_ZA) */
+
+struct user_za_header {
+ __u32 size; /* total meaningful regset content in bytes */
+ __u32 max_size; /* maxmium possible size for this thread */
+ __u16 vl; /* current vector length */
+ __u16 max_vl; /* maximum possible vector length */
+ __u16 flags;
+ __u16 __reserved;
+};
+
+/*
+ * Common ZA_PT_* flags:
+ * These must be kept in sync with prctl interface in <linux/prctl.h>
+ */
+#define ZA_PT_VL_INHERIT ((1 << 17) /* PR_SME_VL_INHERIT */ >> 16)
+#define ZA_PT_VL_ONEXEC ((1 << 18) /* PR_SME_SET_VL_ONEXEC */ >> 16)
+
+
+/*
+ * The remainder of the ZA state follows struct user_za_header. The
+ * total size of the ZA state (including header) depends on the
+ * metadata in the header: ZA_PT_SIZE(vq, flags) gives the total size
+ * of the state in bytes, including the header.
+ *
+ * Refer to <asm/sigcontext.h> for details of how to pass the correct
+ * "vq" argument to these macros.
+ */
+
+/* Offset from the start of struct user_za_header to the register data */
+#define ZA_PT_ZA_OFFSET \
+ ((sizeof(struct user_za_header) + (__SVE_VQ_BYTES - 1)) \
+ / __SVE_VQ_BYTES * __SVE_VQ_BYTES)
+
+/*
+ * The payload starts at offset ZA_PT_ZA_OFFSET, and is of size
+ * ZA_PT_ZA_SIZE(vq, flags).
+ *
+ * The ZA array is stored as a sequence of horizontal vectors ZAV of SVL/8
+ * bytes each, starting from vector 0.
+ *
+ * Additional data might be appended in the future.
+ *
+ * The ZA matrix is represented in memory in an endianness-invariant layout
+ * which differs from the layout used for the FPSIMD V-registers on big-endian
+ * systems: see sigcontext.h for more explanation.
+ */
+
+#define ZA_PT_ZAV_OFFSET(vq, n) \
+ (ZA_PT_ZA_OFFSET + ((vq * __SVE_VQ_BYTES) * n))
+
+#define ZA_PT_ZA_SIZE(vq) ((vq * __SVE_VQ_BYTES) * (vq * __SVE_VQ_BYTES))
+
+#define ZA_PT_SIZE(vq) \
+ (ZA_PT_ZA_OFFSET + ZA_PT_ZA_SIZE(vq))
+
#endif /* __ASSEMBLY__ */
#endif /* __ASM_PTRACE_H */ \ No newline at end of file
diff --git a/lib/libc/include/aarch64-linux-any/asm/sigcontext.h b/lib/libc/include/aarch64-linux-any/asm/sigcontext.h
index c1f9d506ac..6889f0c5f9 100644
--- a/lib/libc/include/aarch64-linux-any/asm/sigcontext.h
+++ b/lib/libc/include/aarch64-linux-any/asm/sigcontext.h
@@ -62,6 +62,10 @@ struct sigcontext {
* context. Such structures must be placed after the rt_sigframe on the stack
* and be 16-byte aligned. The last structure must be a dummy one with the
* magic and size set to 0.
+ *
+ * Note that the values allocated for use as magic should be chosen to
+ * be meaningful in ASCII to aid manual parsing, ZA doesn't follow this
+ * convention due to oversight but it should be observed for future additions.
*/
struct _aarch64_ctx {
__u32 magic;
@@ -134,6 +138,33 @@ struct extra_context {
struct sve_context {
struct _aarch64_ctx head;
__u16 vl;
+ __u16 flags;
+ __u16 __reserved[2];
+};
+
+#define SVE_SIG_FLAG_SM 0x1 /* Context describes streaming mode */
+
+/* TPIDR2_EL0 context */
+#define TPIDR2_MAGIC 0x54504902
+
+struct tpidr2_context {
+ struct _aarch64_ctx head;
+ __u64 tpidr2;
+};
+
+#define ZA_MAGIC 0x54366345
+
+struct za_context {
+ struct _aarch64_ctx head;
+ __u16 vl;
+ __u16 __reserved[3];
+};
+
+#define ZT_MAGIC 0x5a544e01
+
+struct zt_context {
+ struct _aarch64_ctx head;
+ __u16 nregs;
__u16 __reserved[3];
};
@@ -186,9 +217,16 @@ struct sve_context {
* sve_context.vl must equal the thread's current vector length when
* doing a sigreturn.
*
+ * On systems with support for SME the SVE register state may reflect either
+ * streaming or non-streaming mode. In streaming mode the streaming mode
+ * vector length will be used and the flag SVE_SIG_FLAG_SM will be set in
+ * the flags field. It is permitted to enter or leave streaming mode in
+ * a signal return, applications should take care to ensure that any difference
+ * in vector length between the two modes is handled, including any resizing
+ * and movement of context blocks.
*
- * Note: for all these macros, the "vq" argument denotes the SVE
- * vector length in quadwords (i.e., units of 128 bits).
+ * Note: for all these macros, the "vq" argument denotes the vector length
+ * in quadwords (i.e., units of 128 bits).
*
* The correct way to obtain vq is to use sve_vq_from_vl(vl). The
* result is valid if and only if sve_vl_valid(vl) is true. This is
@@ -249,4 +287,48 @@ struct sve_context {
#define SVE_SIG_CONTEXT_SIZE(vq) \
(SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq))
+/*
+ * If the ZA register is enabled for the thread at signal delivery then,
+ * za_context.head.size >= ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(za_context.vl))
+ * and the register data may be accessed using the ZA_SIG_*() macros.
+ *
+ * If za_context.head.size < ZA_SIG_CONTEXT_SIZE(sve_vq_from_vl(za_context.vl))
+ * then ZA was not enabled and no register data was included in which case
+ * ZA register was not enabled for the thread and no register data
+ * the ZA_SIG_*() macros should not be used except for this check.
+ *
+ * The same convention applies when returning from a signal: a caller
+ * will need to remove or resize the za_context block if it wants to
+ * enable the ZA register when it was previously non-live or vice-versa.
+ * This may require the caller to allocate fresh memory and/or move other
+ * context blocks in the signal frame.
+ *
+ * Changing the vector length during signal return is not permitted:
+ * za_context.vl must equal the thread's current SME vector length when
+ * doing a sigreturn.
+ */
+
+#define ZA_SIG_REGS_OFFSET \
+ ((sizeof(struct za_context) + (__SVE_VQ_BYTES - 1)) \
+ / __SVE_VQ_BYTES * __SVE_VQ_BYTES)
+
+#define ZA_SIG_REGS_SIZE(vq) ((vq * __SVE_VQ_BYTES) * (vq * __SVE_VQ_BYTES))
+
+#define ZA_SIG_ZAV_OFFSET(vq, n) (ZA_SIG_REGS_OFFSET + \
+ (SVE_SIG_ZREG_SIZE(vq) * n))
+
+#define ZA_SIG_CONTEXT_SIZE(vq) \
+ (ZA_SIG_REGS_OFFSET + ZA_SIG_REGS_SIZE(vq))
+
+#define ZT_SIG_REG_SIZE 512
+
+#define ZT_SIG_REG_BYTES (ZT_SIG_REG_SIZE / 8)
+
+#define ZT_SIG_REGS_OFFSET sizeof(struct zt_context)
+
+#define ZT_SIG_REGS_SIZE(n) (ZT_SIG_REG_BYTES * n)
+
+#define ZT_SIG_CONTEXT_SIZE(n) \
+ (sizeof(struct zt_context) + ZT_SIG_REGS_SIZE(n))
+
#endif /* __ASM_SIGCONTEXT_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/asm-generic/fcntl.h b/lib/libc/include/any-linux-any/asm-generic/fcntl.h
index f10cd2d88c..646d12680c 100644
--- a/lib/libc/include/any-linux-any/asm-generic/fcntl.h
+++ b/lib/libc/include/any-linux-any/asm-generic/fcntl.h
@@ -91,7 +91,6 @@
/* a horrid kludge trying to make sure that this will fail on old kernels */
#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
-#define O_TMPFILE_MASK (__O_TMPFILE | O_DIRECTORY | O_CREAT)
#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
@@ -116,13 +115,13 @@
#define F_GETSIG 11 /* for sockets. */
#endif
-#ifndef CONFIG_64BIT
+#if __BITS_PER_LONG == 32 || defined(__KERNEL__)
#ifndef F_GETLK64
#define F_GETLK64 12 /* using 'struct flock64' */
#define F_SETLK64 13
#define F_SETLKW64 14
#endif
-#endif
+#endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */
#ifndef F_SETOWN_EX
#define F_SETOWN_EX 15
@@ -193,24 +192,19 @@ struct f_owner_ex {
#define F_LINUX_SPECIFIC_BASE 1024
#ifndef HAVE_ARCH_STRUCT_FLOCK
-#ifndef __ARCH_FLOCK_PAD
-#define __ARCH_FLOCK_PAD
-#endif
-
struct flock {
short l_type;
short l_whence;
__kernel_off_t l_start;
__kernel_off_t l_len;
__kernel_pid_t l_pid;
- __ARCH_FLOCK_PAD
-};
+#ifdef __ARCH_FLOCK_EXTRA_SYSID
+ __ARCH_FLOCK_EXTRA_SYSID
#endif
-
-#ifndef HAVE_ARCH_STRUCT_FLOCK64
-#ifndef __ARCH_FLOCK64_PAD
-#define __ARCH_FLOCK64_PAD
+#ifdef __ARCH_FLOCK_PAD
+ __ARCH_FLOCK_PAD
#endif
+};
struct flock64 {
short l_type;
@@ -218,8 +212,10 @@ struct flock64 {
__kernel_loff_t l_start;
__kernel_loff_t l_len;
__kernel_pid_t l_pid;
+#ifdef __ARCH_FLOCK64_PAD
__ARCH_FLOCK64_PAD
-};
#endif
+};
+#endif /* HAVE_ARCH_STRUCT_FLOCK */
#endif /* _ASM_GENERIC_FCNTL_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/asm-generic/hugetlb_encode.h b/lib/libc/include/any-linux-any/asm-generic/hugetlb_encode.h
index 58de1e4123..dfc94bbf53 100644
--- a/lib/libc/include/any-linux-any/asm-generic/hugetlb_encode.h
+++ b/lib/libc/include/any-linux-any/asm-generic/hugetlb_encode.h
@@ -20,18 +20,18 @@
#define HUGETLB_FLAG_ENCODE_SHIFT 26
#define HUGETLB_FLAG_ENCODE_MASK 0x3f
-#define HUGETLB_FLAG_ENCODE_16KB (14 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_64KB (16 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_512KB (19 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_1MB (20 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_8MB (23 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_16MB (24 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_32MB (25 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_256MB (28 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_512MB (29 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_2GB (31 << HUGETLB_FLAG_ENCODE_SHIFT)
-#define HUGETLB_FLAG_ENCODE_16GB (34 << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16KB (14U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_64KB (16U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512KB (19U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1MB (20U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2MB (21U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_8MB (23U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16MB (24U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_32MB (25U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_256MB (28U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_512MB (29U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_1GB (30U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_2GB (31U << HUGETLB_FLAG_ENCODE_SHIFT)
+#define HUGETLB_FLAG_ENCODE_16GB (34U << HUGETLB_FLAG_ENCODE_SHIFT)
#endif /* _ASM_GENERIC_HUGETLB_ENCODE_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/asm-generic/mman-common.h b/lib/libc/include/any-linux-any/asm-generic/mman-common.h
index 9d958863c1..ffe2ef8e00 100644
--- a/lib/libc/include/any-linux-any/asm-generic/mman-common.h
+++ b/lib/libc/include/any-linux-any/asm-generic/mman-common.h
@@ -75,6 +75,10 @@
#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */
#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */
+#define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
+
+#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
+
/* compatibility flags */
#define MAP_FILE 0
diff --git a/lib/libc/include/any-linux-any/asm-generic/shmbuf.h b/lib/libc/include/any-linux-any/asm-generic/shmbuf.h
index 832e861398..7e0ae82ee5 100644
--- a/lib/libc/include/any-linux-any/asm-generic/shmbuf.h
+++ b/lib/libc/include/any-linux-any/asm-generic/shmbuf.h
@@ -3,6 +3,8 @@
#define __ASM_GENERIC_SHMBUF_H
#include <asm/bitsperlong.h>
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
/*
* The shmid64_ds structure for x86 architecture.
@@ -24,7 +26,7 @@
struct shmid64_ds {
struct ipc64_perm shm_perm; /* operation perms */
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
#if __BITS_PER_LONG == 64
long shm_atime; /* last attach time */
long shm_dtime; /* last detach time */
diff --git a/lib/libc/include/any-linux-any/asm-generic/siginfo.h b/lib/libc/include/any-linux-any/asm-generic/siginfo.h
index 3f28b46755..bf036f92e3 100644
--- a/lib/libc/include/any-linux-any/asm-generic/siginfo.h
+++ b/lib/libc/include/any-linux-any/asm-generic/siginfo.h
@@ -99,6 +99,7 @@ union __sifields {
struct {
unsigned long _data;
__u32 _type;
+ __u32 _flags;
} _perf;
};
} _sigfault;
@@ -164,6 +165,7 @@ typedef struct siginfo {
#define si_pkey _sifields._sigfault._addr_pkey._pkey
#define si_perf_data _sifields._sigfault._perf._data
#define si_perf_type _sifields._sigfault._perf._type
+#define si_perf_flags _sifields._sigfault._perf._flags
#define si_band _sifields._sigpoll._band
#define si_fd _sifields._sigpoll._fd
#define si_call_addr _sifields._sigsys._call_addr
@@ -271,6 +273,11 @@ typedef struct siginfo {
*/
/*
+ * Flags for si_perf_flags if SIGTRAP si_code is TRAP_PERF.
+ */
+#define TRAP_PERF_FLAG_ASYNC (1u << 0)
+
+/*
* SIGCHLD si_codes
*/
#define CLD_EXITED 1 /* child has exited */
diff --git a/lib/libc/include/any-linux-any/asm-generic/signal.h b/lib/libc/include/any-linux-any/asm-generic/signal.h
index 2613729d31..06ca4c77a0 100644
--- a/lib/libc/include/any-linux-any/asm-generic/signal.h
+++ b/lib/libc/include/any-linux-any/asm-generic/signal.h
@@ -83,7 +83,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
#endif /* __ASSEMBLY__ */
diff --git a/lib/libc/include/any-linux-any/asm-generic/socket.h b/lib/libc/include/any-linux-any/asm-generic/socket.h
index 0123e0519c..10edfcc06f 100644
--- a/lib/libc/include/any-linux-any/asm-generic/socket.h
+++ b/lib/libc/include/any-linux-any/asm-generic/socket.h
@@ -128,6 +128,10 @@
#define SO_RESERVE_MEM 73
+#define SO_TXREHASH 74
+
+#define SO_RCVMARK 75
+
#if __BITS_PER_LONG == 64 || (defined(__x86_64__) && defined(__ILP32__))
/* on 64-bit and x32, avoid the ?: operator */
diff --git a/lib/libc/include/any-linux-any/asm-generic/termbits-common.h b/lib/libc/include/any-linux-any/asm-generic/termbits-common.h
new file mode 100644
index 0000000000..2800fc18f0
--- /dev/null
+++ b/lib/libc/include/any-linux-any/asm-generic/termbits-common.h
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_GENERIC_TERMBITS_COMMON_H
+#define __ASM_GENERIC_TERMBITS_COMMON_H
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+
+/* c_iflag bits */
+#define IGNBRK 0x001 /* Ignore break condition */
+#define BRKINT 0x002 /* Signal interrupt on break */
+#define IGNPAR 0x004 /* Ignore characters with parity errors */
+#define PARMRK 0x008 /* Mark parity and framing errors */
+#define INPCK 0x010 /* Enable input parity check */
+#define ISTRIP 0x020 /* Strip 8th bit off characters */
+#define INLCR 0x040 /* Map NL to CR on input */
+#define IGNCR 0x080 /* Ignore CR */
+#define ICRNL 0x100 /* Map CR to NL on input */
+#define IXANY 0x800 /* Any character will restart after stop */
+
+/* c_oflag bits */
+#define OPOST 0x01 /* Perform output processing */
+#define OCRNL 0x08
+#define ONOCR 0x10
+#define ONLRET 0x20
+#define OFILL 0x40
+#define OFDEL 0x80
+
+/* c_cflag bit meaning */
+/* Common CBAUD rates */
+#define B0 0x00000000 /* hang up */
+#define B50 0x00000001
+#define B75 0x00000002
+#define B110 0x00000003
+#define B134 0x00000004
+#define B150 0x00000005
+#define B200 0x00000006
+#define B300 0x00000007
+#define B600 0x00000008
+#define B1200 0x00000009
+#define B1800 0x0000000a
+#define B2400 0x0000000b
+#define B4800 0x0000000c
+#define B9600 0x0000000d
+#define B19200 0x0000000e
+#define B38400 0x0000000f
+#define EXTA B19200
+#define EXTB B38400
+
+#define ADDRB 0x20000000 /* address bit */
+#define CMSPAR 0x40000000 /* mark or space (stick) parity */
+#define CRTSCTS 0x80000000 /* flow control */
+
+#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
+
+/* tcflow() ACTION argument and TCXONC use these */
+#define TCOOFF 0 /* Suspend output */
+#define TCOON 1 /* Restart suspended output */
+#define TCIOFF 2 /* Send a STOP character */
+#define TCION 3 /* Send a START character */
+
+/* tcflush() QUEUE_SELECTOR argument and TCFLSH use these */
+#define TCIFLUSH 0 /* Discard data received but not yet read */
+#define TCOFLUSH 1 /* Discard data written but not yet sent */
+#define TCIOFLUSH 2 /* Discard all pending data */
+
+#endif /* __ASM_GENERIC_TERMBITS_COMMON_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/asm-generic/termbits.h b/lib/libc/include/any-linux-any/asm-generic/termbits.h
index 3343a0950e..e34ca3cd85 100644
--- a/lib/libc/include/any-linux-any/asm-generic/termbits.h
+++ b/lib/libc/include/any-linux-any/asm-generic/termbits.h
@@ -2,10 +2,8 @@
#ifndef __ASM_GENERIC_TERMBITS_H
#define __ASM_GENERIC_TERMBITS_H
-#include <linux/posix_types.h>
+#include <asm-generic/termbits-common.h>
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
#define NCCS 19
@@ -41,156 +39,107 @@ struct ktermios {
};
/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VTIME 5
-#define VMIN 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-#define VSUSP 10
-#define VEOL 11
-#define VREPRINT 12
-#define VDISCARD 13
-#define VWERASE 14
-#define VLNEXT 15
-#define VEOL2 16
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IUCLC 0001000
-#define IXON 0002000
-#define IXANY 0004000
-#define IXOFF 0010000
-#define IMAXBEL 0020000
-#define IUTF8 0040000
+#define IUCLC 0x0200
+#define IXON 0x0400
+#define IXOFF 0x1000
+#define IMAXBEL 0x2000
+#define IUTF8 0x4000
/* c_oflag bits */
-#define OPOST 0000001
-#define OLCUC 0000002
-#define ONLCR 0000004
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
+#define OLCUC 0x00002
+#define ONLCR 0x00004
+#define NLDLY 0x00100
+#define NL0 0x00000
+#define NL1 0x00100
+#define CRDLY 0x00600
+#define CR0 0x00000
+#define CR1 0x00200
+#define CR2 0x00400
+#define CR3 0x00600
+#define TABDLY 0x01800
+#define TAB0 0x00000
+#define TAB1 0x00800
+#define TAB2 0x01000
+#define TAB3 0x01800
+#define XTABS 0x01800
+#define BSDLY 0x02000
+#define BS0 0x00000
+#define BS1 0x02000
+#define VTDLY 0x04000
+#define VT0 0x00000
+#define VT1 0x04000
+#define FFDLY 0x08000
+#define FF0 0x00000
+#define FF1 0x08000
/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060
-#define CS5 0000000
-#define CS6 0000020
-#define CS7 0000040
-#define CS8 0000060
-#define CSTOPB 0000100
-#define CREAD 0000200
-#define PARENB 0000400
-#define PARODD 0001000
-#define HUPCL 0002000
-#define CLOCAL 0004000
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
+#define CBAUD 0x0000100f
+#define CSIZE 0x00000030
+#define CS5 0x00000000
+#define CS6 0x00000010
+#define CS7 0x00000020
+#define CS8 0x00000030
+#define CSTOPB 0x00000040
+#define CREAD 0x00000080
+#define PARENB 0x00000100
+#define PARODD 0x00000200
+#define HUPCL 0x00000400
+#define CLOCAL 0x00000800
+#define CBAUDEX 0x00001000
+#define BOTHER 0x00001000
+#define B57600 0x00001001
+#define B115200 0x00001002
+#define B230400 0x00001003
+#define B460800 0x00001004
+#define B500000 0x00001005
+#define B576000 0x00001006
+#define B921600 0x00001007
+#define B1000000 0x00001008
+#define B1152000 0x00001009
+#define B1500000 0x0000100a
+#define B2000000 0x0000100b
+#define B2500000 0x0000100c
+#define B3000000 0x0000100d
+#define B3500000 0x0000100e
+#define B4000000 0x0000100f
+#define CIBAUD 0x100f0000 /* input baud rate */
/* c_lflag bits */
-#define ISIG 0000001
-#define ICANON 0000002
-#define XCASE 0000004
-#define ECHO 0000010
-#define ECHOE 0000020
-#define ECHOK 0000040
-#define ECHONL 0000100
-#define NOFLSH 0000200
-#define TOSTOP 0000400
-#define ECHOCTL 0001000
-#define ECHOPRT 0002000
-#define ECHOKE 0004000
-#define FLUSHO 0010000
-#define PENDIN 0040000
-#define IEXTEN 0100000
-#define EXTPROC 0200000
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
+#define ISIG 0x00001
+#define ICANON 0x00002
+#define XCASE 0x00004
+#define ECHO 0x00008
+#define ECHOE 0x00010
+#define ECHOK 0x00020
+#define ECHONL 0x00040
+#define NOFLSH 0x00080
+#define TOSTOP 0x00100
+#define ECHOCTL 0x00200
+#define ECHOPRT 0x00400
+#define ECHOKE 0x00800
+#define FLUSHO 0x01000
+#define PENDIN 0x04000
+#define IEXTEN 0x08000
+#define EXTPROC 0x10000
/* tcsetattr uses these */
#define TCSANOW 0
diff --git a/lib/libc/include/any-linux-any/asm-generic/unistd.h b/lib/libc/include/any-linux-any/asm-generic/unistd.h
index 67a82bc104..f338841851 100644
--- a/lib/libc/include/any-linux-any/asm-generic/unistd.h
+++ b/lib/libc/include/any-linux-any/asm-generic/unistd.h
@@ -383,7 +383,7 @@ __SYSCALL(__NR_syslog, sys_syslog)
/* kernel/ptrace.c */
#define __NR_ptrace 117
-__SYSCALL(__NR_ptrace, sys_ptrace)
+__SC_COMP(__NR_ptrace, sys_ptrace, compat_sys_ptrace)
/* kernel/sched/core.c */
#define __NR_sched_setparam 118
@@ -779,7 +779,7 @@ __SYSCALL(__NR_rseq, sys_rseq)
#define __NR_kexec_file_load 294
__SYSCALL(__NR_kexec_file_load, sys_kexec_file_load)
/* 295 through 402 are unassigned to sync up with generic numbers, don't use */
-#if __BITS_PER_LONG == 32
+#if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG == 32
#define __NR_clock_gettime64 403
__SYSCALL(__NR_clock_gettime64, sys_clock_gettime)
#define __NR_clock_settime64 404
@@ -883,8 +883,11 @@ __SYSCALL(__NR_process_mrelease, sys_process_mrelease)
#define __NR_futex_waitv 449
__SYSCALL(__NR_futex_waitv, sys_futex_waitv)
+#define __NR_set_mempolicy_home_node 450
+__SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
+
#undef __NR_syscalls
-#define __NR_syscalls 450
+#define __NR_syscalls 451
/*
* 32 bit systems traditionally used different
diff --git a/lib/libc/include/any-linux-any/drm/amdgpu_drm.h b/lib/libc/include/any-linux-any/drm/amdgpu_drm.h
index 9747001303..f97a2599f6 100644
--- a/lib/libc/include/any-linux-any/drm/amdgpu_drm.h
+++ b/lib/libc/include/any-linux-any/drm/amdgpu_drm.h
@@ -80,7 +80,7 @@ extern "C" {
*
* %AMDGPU_GEM_DOMAIN_GTT GPU accessible system memory, mapped into the
* GPU's virtual address space via gart. Gart memory linearizes non-contiguous
- * pages of system memory, allows GPU access system memory in a linezrized
+ * pages of system memory, allows GPU access system memory in a linearized
* fashion.
*
* %AMDGPU_GEM_DOMAIN_VRAM Local video memory. For APUs, it is memory
@@ -140,6 +140,24 @@ extern "C" {
* not require GTT memory accounting
*/
#define AMDGPU_GEM_CREATE_PREEMPTIBLE (1 << 11)
+/* Flag that BO can be discarded under memory pressure without keeping the
+ * content.
+ */
+#define AMDGPU_GEM_CREATE_DISCARDABLE (1 << 12)
+/* Flag that BO is shared coherently between multiple devices or CPU threads.
+ * May depend on GPU instructions to flush caches explicitly
+ *
+ * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
+ * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
+ */
+#define AMDGPU_GEM_CREATE_COHERENT (1 << 13)
+/* Flag that BO should not be cached by GPU. Coherent without having to flush
+ * GPU caches explicitly
+ *
+ * This influences the choice of MTYPE in the PTEs on GFXv9 and later GPUs and
+ * may override the MTYPE selected in AMDGPU_VA_OP_MAP.
+ */
+#define AMDGPU_GEM_CREATE_UNCACHED (1 << 14)
struct drm_amdgpu_gem_create_in {
/** the requested memory size */
@@ -206,6 +224,8 @@ union drm_amdgpu_bo_list {
#define AMDGPU_CTX_OP_FREE_CTX 2
#define AMDGPU_CTX_OP_QUERY_STATE 3
#define AMDGPU_CTX_OP_QUERY_STATE2 4
+#define AMDGPU_CTX_OP_GET_STABLE_PSTATE 5
+#define AMDGPU_CTX_OP_SET_STABLE_PSTATE 6
/* GPU reset status */
#define AMDGPU_CTX_NO_RESET 0
@@ -238,10 +258,18 @@ union drm_amdgpu_bo_list {
#define AMDGPU_CTX_PRIORITY_HIGH 512
#define AMDGPU_CTX_PRIORITY_VERY_HIGH 1023
+/* select a stable profiling pstate for perfmon tools */
+#define AMDGPU_CTX_STABLE_PSTATE_FLAGS_MASK 0xf
+#define AMDGPU_CTX_STABLE_PSTATE_NONE 0
+#define AMDGPU_CTX_STABLE_PSTATE_STANDARD 1
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_SCLK 2
+#define AMDGPU_CTX_STABLE_PSTATE_MIN_MCLK 3
+#define AMDGPU_CTX_STABLE_PSTATE_PEAK 4
+
struct drm_amdgpu_ctx_in {
/** AMDGPU_CTX_OP_* */
__u32 op;
- /** For future use, no flags defined so far */
+ /** Flags */
__u32 flags;
__u32 ctx_id;
/** AMDGPU_CTX_PRIORITY_* */
@@ -262,6 +290,11 @@ union drm_amdgpu_ctx_out {
/** Reset status since the last call of the ioctl. */
__u32 reset_status;
} state;
+
+ struct {
+ __u32 flags;
+ __u32 _pad;
+ } pstate;
};
union drm_amdgpu_ctx {
@@ -514,6 +547,8 @@ struct drm_amdgpu_gem_op {
#define AMDGPU_VM_MTYPE_UC (4 << 5)
/* Use Read Write MTYPE instead of default MTYPE */
#define AMDGPU_VM_MTYPE_RW (5 << 5)
+/* don't allocate MALL */
+#define AMDGPU_VM_PAGE_NOALLOC (1 << 9)
struct drm_amdgpu_gem_va {
/** GEM object handle */
@@ -538,6 +573,10 @@ struct drm_amdgpu_gem_va {
#define AMDGPU_HW_IP_VCE 4
#define AMDGPU_HW_IP_UVD_ENC 5
#define AMDGPU_HW_IP_VCN_DEC 6
+/*
+ * From VCN4, AMDGPU_HW_IP_VCN_ENC is re-used to support
+ * both encoding and decoding jobs.
+ */
#define AMDGPU_HW_IP_VCN_ENC 7
#define AMDGPU_HW_IP_VCN_JPEG 8
#define AMDGPU_HW_IP_NUM 9
@@ -676,6 +715,7 @@ struct drm_amdgpu_cs_chunk_data {
#define AMDGPU_IDS_FLAGS_FUSION 0x1
#define AMDGPU_IDS_FLAGS_PREEMPTION 0x2
#define AMDGPU_IDS_FLAGS_TMZ 0x4
+#define AMDGPU_IDS_FLAGS_CONFORMANT_TRUNC_COORD 0x8
/* indicate if acceleration can be working */
#define AMDGPU_INFO_ACCEL_WORKING 0x00
@@ -728,6 +768,18 @@ struct drm_amdgpu_cs_chunk_data {
#define AMDGPU_INFO_FW_DMCUB 0x14
/* Subquery id: Query TOC firmware version */
#define AMDGPU_INFO_FW_TOC 0x15
+ /* Subquery id: Query CAP firmware version */
+ #define AMDGPU_INFO_FW_CAP 0x16
+ /* Subquery id: Query GFX RLCP firmware version */
+ #define AMDGPU_INFO_FW_GFX_RLCP 0x17
+ /* Subquery id: Query GFX RLCV firmware version */
+ #define AMDGPU_INFO_FW_GFX_RLCV 0x18
+ /* Subquery id: Query MES_KIQ firmware version */
+ #define AMDGPU_INFO_FW_MES_KIQ 0x19
+ /* Subquery id: Query MES firmware version */
+ #define AMDGPU_INFO_FW_MES 0x1a
+ /* Subquery id: Query IMU firmware version */
+ #define AMDGPU_INFO_FW_IMU 0x1b
/* number of bytes moved for TTM migration */
#define AMDGPU_INFO_NUM_BYTES_MOVED 0x0f
@@ -781,6 +833,10 @@ struct drm_amdgpu_cs_chunk_data {
#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_SCLK 0x8
/* Subquery id: Query GPU stable pstate memory clock */
#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
+ /* Subquery id: Query GPU peak pstate shader clock */
+ #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa
+ /* Subquery id: Query GPU peak pstate memory clock */
+ #define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb
/* Number of VRAM page faults on CPU access. */
#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
@@ -971,6 +1027,8 @@ struct drm_amdgpu_info_vbios {
#define AMDGPU_VRAM_TYPE_DDR4 8
#define AMDGPU_VRAM_TYPE_GDDR6 9
#define AMDGPU_VRAM_TYPE_DDR5 10
+#define AMDGPU_VRAM_TYPE_LPDDR4 11
+#define AMDGPU_VRAM_TYPE_LPDDR5 12
struct drm_amdgpu_info_device {
/** PCI Device ID */
@@ -996,7 +1054,8 @@ struct drm_amdgpu_info_device {
__u32 enabled_rb_pipes_mask;
__u32 num_rb_pipes;
__u32 num_hw_gfx_contexts;
- __u32 _pad;
+ /* PCIe version (the smaller of the GPU and the CPU/motherboard) */
+ __u32 pcie_gen;
__u64 ids_flags;
/** Starting virtual address for UMDs. */
__u64 virtual_address_offset;
@@ -1043,7 +1102,8 @@ struct drm_amdgpu_info_device {
__u32 gs_prim_buffer_depth;
/* max gs wavefront per vgt*/
__u32 max_gs_waves_per_vgt;
- __u32 _pad1;
+ /* PCIe number of lanes (the smaller of the GPU and the CPU/motherboard) */
+ __u32 pcie_num_lanes;
/* always on cu bitmap */
__u32 cu_ao_bitmap[4][4];
/** Starting high virtual address for UMDs. */
@@ -1054,6 +1114,18 @@ struct drm_amdgpu_info_device {
__u32 pa_sc_tile_steering_override;
/* disabled TCCs */
__u64 tcc_disabled_mask;
+ __u64 min_engine_clock;
+ __u64 min_memory_clock;
+ /* The following fields are only set on gfx11+, older chips set 0. */
+ __u32 tcp_cache_size; /* AKA GL0, VMEM cache */
+ __u32 num_sqc_per_wgp;
+ __u32 sqc_data_cache_size; /* AKA SMEM cache */
+ __u32 sqc_inst_cache_size;
+ __u32 gl1c_cache_size;
+ __u32 gl2c_cache_size;
+ __u64 mall_size; /* AKA infinity cache */
+ /* high 32 bits of the rb pipes mask */
+ __u32 enabled_rb_pipes_mask_hi;
};
struct drm_amdgpu_info_hw_ip {
@@ -1068,7 +1140,8 @@ struct drm_amdgpu_info_hw_ip {
__u32 ib_size_alignment;
/** Bitmask of available rings. Bit 0 means ring 0, etc. */
__u32 available_rings;
- __u32 _pad;
+ /** version info: bits 23:16 major, 15:8 minor, 7:0 revision */
+ __u32 ip_discovery_version;
};
struct drm_amdgpu_info_num_handles {
@@ -1133,7 +1206,11 @@ struct drm_amdgpu_info_video_caps {
#define AMDGPU_FAMILY_RV 142 /* Raven */
#define AMDGPU_FAMILY_NV 143 /* Navi10 */
#define AMDGPU_FAMILY_VGH 144 /* Van Gogh */
+#define AMDGPU_FAMILY_GC_11_0_0 145 /* GC 11.0.0 */
#define AMDGPU_FAMILY_YC 146 /* Yellow Carp */
+#define AMDGPU_FAMILY_GC_11_0_1 148 /* GC 11.0.1 */
+#define AMDGPU_FAMILY_GC_10_3_6 149 /* GC 10.3.6 */
+#define AMDGPU_FAMILY_GC_10_3_7 151 /* GC 10.3.7 */
#if defined(__cplusplus)
}
diff --git a/lib/libc/include/any-linux-any/drm/drm.h b/lib/libc/include/any-linux-any/drm/drm.h
index 83756a2044..ce352d1542 100644
--- a/lib/libc/include/any-linux-any/drm/drm.h
+++ b/lib/libc/include/any-linux-any/drm/drm.h
@@ -1090,6 +1090,24 @@ extern "C" {
#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)
#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)
+/**
+ * DRM_IOCTL_MODE_GETFB2 - Get framebuffer metadata.
+ *
+ * This queries metadata about a framebuffer. User-space fills
+ * &drm_mode_fb_cmd2.fb_id as the input, and the kernels fills the rest of the
+ * struct as the output.
+ *
+ * If the client is DRM master or has &CAP_SYS_ADMIN, &drm_mode_fb_cmd2.handles
+ * will be filled with GEM buffer handles. Planes are valid until one has a
+ * zero handle -- this can be used to compute the number of planes.
+ *
+ * Otherwise, &drm_mode_fb_cmd2.handles will be zeroed and planes are valid
+ * until one has a zero &drm_mode_fb_cmd2.pitches.
+ *
+ * If the framebuffer has a format modifier, &DRM_MODE_FB_MODIFIERS will be set
+ * in &drm_mode_fb_cmd2.flags and &drm_mode_fb_cmd2.modifier will contain the
+ * modifier. Otherwise, user-space must ignore &drm_mode_fb_cmd2.modifier.
+ */
#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)
/*
diff --git a/lib/libc/include/any-linux-any/drm/drm_fourcc.h b/lib/libc/include/any-linux-any/drm/drm_fourcc.h
index 766f4d5878..01ef02c4e0 100644
--- a/lib/libc/include/any-linux-any/drm/drm_fourcc.h
+++ b/lib/libc/include/any-linux-any/drm/drm_fourcc.h
@@ -88,6 +88,18 @@ extern "C" {
*
* The authoritative list of format modifier codes is found in
* `include/uapi/drm/drm_fourcc.h`
+ *
+ * Open Source User Waiver
+ * -----------------------
+ *
+ * Because this is the authoritative source for pixel formats and modifiers
+ * referenced by GL, Vulkan extensions and other standards and hence used both
+ * by open source and closed source driver stacks, the usual requirement for an
+ * upstream in-kernel or open source userspace user does not apply.
+ *
+ * To ensure, as much as feasible, compatibility across stacks and avoid
+ * confusion with incompatible enumerations stakeholders for all relevant driver
+ * stacks should approve additions.
*/
#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \
@@ -99,18 +111,42 @@ extern "C" {
#define DRM_FORMAT_INVALID 0
/* color index */
+#define DRM_FORMAT_C1 fourcc_code('C', '1', ' ', ' ') /* [7:0] C0:C1:C2:C3:C4:C5:C6:C7 1:1:1:1:1:1:1:1 eight pixels/byte */
+#define DRM_FORMAT_C2 fourcc_code('C', '2', ' ', ' ') /* [7:0] C0:C1:C2:C3 2:2:2:2 four pixels/byte */
+#define DRM_FORMAT_C4 fourcc_code('C', '4', ' ', ' ') /* [7:0] C0:C1 4:4 two pixels/byte */
#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */
-/* 8 bpp Red */
+/* 1 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D1 fourcc_code('D', '1', ' ', ' ') /* [7:0] D0:D1:D2:D3:D4:D5:D6:D7 1:1:1:1:1:1:1:1 eight pixels/byte */
+
+/* 2 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D2 fourcc_code('D', '2', ' ', ' ') /* [7:0] D0:D1:D2:D3 2:2:2:2 four pixels/byte */
+
+/* 4 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D4 fourcc_code('D', '4', ' ', ' ') /* [7:0] D0:D1 4:4 two pixels/byte */
+
+/* 8 bpp Darkness (inverse relationship between channel value and brightness) */
+#define DRM_FORMAT_D8 fourcc_code('D', '8', ' ', ' ') /* [7:0] D */
+
+/* 1 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R1 fourcc_code('R', '1', ' ', ' ') /* [7:0] R0:R1:R2:R3:R4:R5:R6:R7 1:1:1:1:1:1:1:1 eight pixels/byte */
+
+/* 2 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R2 fourcc_code('R', '2', ' ', ' ') /* [7:0] R0:R1:R2:R3 2:2:2:2 four pixels/byte */
+
+/* 4 bpp Red (direct relationship between channel value and brightness) */
+#define DRM_FORMAT_R4 fourcc_code('R', '4', ' ', ' ') /* [7:0] R0:R1 4:4 two pixels/byte */
+
+/* 8 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */
-/* 10 bpp Red */
+/* 10 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R10 fourcc_code('R', '1', '0', ' ') /* [15:0] x:R 6:10 little endian */
-/* 12 bpp Red */
+/* 12 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R12 fourcc_code('R', '1', '2', ' ') /* [15:0] x:R 4:12 little endian */
-/* 16 bpp Red */
+/* 16 bpp Red (direct relationship between channel value and brightness) */
#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */
/* 16 bpp RG */
@@ -205,7 +241,9 @@ extern "C" {
#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */
#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */
+#define DRM_FORMAT_AVUY8888 fourcc_code('A', 'V', 'U', 'Y') /* [31:0] A:Cr:Cb:Y 8:8:8:8 little endian */
#define DRM_FORMAT_XYUV8888 fourcc_code('X', 'Y', 'U', 'V') /* [31:0] X:Y:Cb:Cr 8:8:8:8 little endian */
+#define DRM_FORMAT_XVUY8888 fourcc_code('X', 'V', 'U', 'Y') /* [31:0] X:Cr:Cb:Y 8:8:8:8 little endian */
#define DRM_FORMAT_VUY888 fourcc_code('V', 'U', '2', '4') /* [23:0] Cr:Cb:Y 8:8:8 little endian */
#define DRM_FORMAT_VUY101010 fourcc_code('V', 'U', '3', '0') /* Y followed by U then V, 10:10:10. Non-linear modifier only */
@@ -314,6 +352,13 @@ extern "C" {
*/
#define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled Cr:Cb plane 16 bits per channel */
+/* 2 plane YCbCr420.
+ * 3 10 bit components and 2 padding bits packed into 4 bytes.
+ * index 0 = Y plane, [31:0] x:Y2:Y1:Y0 2:10:10:10 little endian
+ * index 1 = Cr:Cb plane, [63:0] x:Cr2:Cb2:Cr1:x:Cb1:Cr0:Cb0 [2:10:10:10:2:10:10:10] little endian
+ */
+#define DRM_FORMAT_P030 fourcc_code('P', '0', '3', '0') /* 2x2 subsampled Cr:Cb plane 10 bits per channel packed */
+
/* 3 plane non-subsampled (444) YCbCr
* 16 bits per component, but only 10 bits are used and 6 bits are padded
* index 0: Y plane, [15:0] Y:x [10:6] little endian
@@ -552,7 +597,7 @@ extern "C" {
*
* The main surface is Y-tiled and is at plane index 0 whereas CCS is linear
* and at index 1. The clear color is stored at index 2, and the pitch should
- * be ignored. The clear color structure is 256 bits. The first 128 bits
+ * be 64 bytes aligned. The clear color structure is 256 bits. The first 128 bits
* represents Raw Clear Color Red, Green, Blue and Alpha color each represented
* by 32 bits. The raw clear color is consumed by the 3d engine and generates
* the converted clear color of size 64 bits. The first 32 bits store the Lower
@@ -566,6 +611,53 @@ extern "C" {
#define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8)
/*
+ * Intel Tile 4 layout
+ *
+ * This is a tiled layout using 4KB tiles in a row-major layout. It has the same
+ * shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4). It
+ * only differs from Tile Y at the 256B granularity in between. At this
+ * granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a shape
+ * of 64B x 8 rows.
+ */
+#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9)
+
+/*
+ * Intel color control surfaces (CCS) for DG2 render compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. The CCS data is stored
+ * outside of the GEM object in a reserved memory area dedicated for the
+ * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The
+ * main surface pitch is required to be a multiple of four Tile 4 widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS fourcc_mod_code(INTEL, 10)
+
+/*
+ * Intel color control surfaces (CCS) for DG2 media compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. For semi-planar formats
+ * like NV12, the Y and UV planes are Tile 4 and are located at plane indices
+ * 0 and 1, respectively. The CCS for all planes are stored outside of the
+ * GEM object in a reserved memory area dedicated for the storage of the
+ * CCS data for all RC/RC_CC/MC compressible GEM objects. The main surface
+ * pitch is required to be a multiple of four Tile 4 widths.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_MC_CCS fourcc_mod_code(INTEL, 11)
+
+/*
+ * Intel Color Control Surface with Clear Color (CCS) for DG2 render compression.
+ *
+ * The main surface is Tile 4 and at plane index 0. The CCS data is stored
+ * outside of the GEM object in a reserved memory area dedicated for the
+ * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. The
+ * main surface pitch is required to be a multiple of four Tile 4 widths. The
+ * clear color is stored at plane index 1 and the pitch should be 64 bytes
+ * aligned. The format of the 256 bits of clear color data matches the one used
+ * for the I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC modifier, see its description
+ * for details.
+ */
+#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12)
+
+/*
* Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks
*
* Macroblocks are laid in a Z-shape, and each pixel data is following the
@@ -602,6 +694,28 @@ extern "C" {
*/
#define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1)
+/*
+ * Qualcomm Tiled Format
+ *
+ * Similar to DRM_FORMAT_MOD_QCOM_COMPRESSED but not compressed.
+ * Implementation may be platform and base-format specific.
+ *
+ * Each macrotile consists of m x n (mostly 4 x 4) tiles.
+ * Pixel data pitch/stride is aligned with macrotile width.
+ * Pixel data height is aligned with macrotile height.
+ * Entire pixel data buffer is aligned with 4k(bytes).
+ */
+#define DRM_FORMAT_MOD_QCOM_TILED3 fourcc_mod_code(QCOM, 3)
+
+/*
+ * Qualcomm Alternate Tiled Format
+ *
+ * Alternate tiled format typically only used within GMEM.
+ * Implementation may be platform and base-format specific.
+ */
+#define DRM_FORMAT_MOD_QCOM_TILED2 fourcc_mod_code(QCOM, 2)
+
+
/* Vivante framebuffer modifiers */
/*
@@ -642,6 +756,35 @@ extern "C" {
*/
#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4)
+/*
+ * Vivante TS (tile-status) buffer modifiers. They can be combined with all of
+ * the color buffer tiling modifiers defined above. When TS is present it's a
+ * separate buffer containing the clear/compression status of each tile. The
+ * modifiers are defined as VIVANTE_MOD_TS_c_s, where c is the color buffer
+ * tile size in bytes covered by one entry in the status buffer and s is the
+ * number of status bits per entry.
+ * We reserve the top 8 bits of the Vivante modifier space for tile status
+ * clear/compression modifiers, as future cores might add some more TS layout
+ * variations.
+ */
+#define VIVANTE_MOD_TS_64_4 (1ULL << 48)
+#define VIVANTE_MOD_TS_64_2 (2ULL << 48)
+#define VIVANTE_MOD_TS_128_4 (3ULL << 48)
+#define VIVANTE_MOD_TS_256_4 (4ULL << 48)
+#define VIVANTE_MOD_TS_MASK (0xfULL << 48)
+
+/*
+ * Vivante compression modifiers. Those depend on a TS modifier being present
+ * as the TS bits get reinterpreted as compression tags instead of simple
+ * clear markers when compression is enabled.
+ */
+#define VIVANTE_MOD_COMP_DEC400 (1ULL << 52)
+#define VIVANTE_MOD_COMP_MASK (0xfULL << 52)
+
+/* Masking out the extension bits will yield the base modifier. */
+#define VIVANTE_MOD_EXT_MASK (VIVANTE_MOD_TS_MASK | \
+ VIVANTE_MOD_COMP_MASK)
+
/* NVIDIA frame buffer modifiers */
/*
@@ -854,6 +997,10 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
* and UV. Some SAND-using hardware stores UV in a separate tiled
* image from Y to reduce the column height, which is not supported
* with these modifiers.
+ *
+ * The DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT modifier is also
+ * supported for DRM_FORMAT_P030 where the columns remain as 128 bytes
+ * wide, but as this is a 10 bpp format that translates to 96 pixels.
*/
#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \
@@ -1283,6 +1430,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_TILE_VER_GFX9 1
#define AMD_FMT_MOD_TILE_VER_GFX10 2
#define AMD_FMT_MOD_TILE_VER_GFX10_RBPLUS 3
+#define AMD_FMT_MOD_TILE_VER_GFX11 4
/*
* 64K_S is the same for GFX9/GFX10/GFX10_RBPLUS and hence has GFX9 as canonical
@@ -1298,6 +1446,7 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_TILE_GFX9_64K_S_X 25
#define AMD_FMT_MOD_TILE_GFX9_64K_D_X 26
#define AMD_FMT_MOD_TILE_GFX9_64K_R_X 27
+#define AMD_FMT_MOD_TILE_GFX11_256K_R_X 31
#define AMD_FMT_MOD_DCC_BLOCK_64B 0
#define AMD_FMT_MOD_DCC_BLOCK_128B 1
@@ -1364,11 +1513,11 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
#define AMD_FMT_MOD_PIPE_MASK 0x7
#define AMD_FMT_MOD_SET(field, value) \
- ((uint64_t)(value) << AMD_FMT_MOD_##field##_SHIFT)
+ ((__u64)(value) << AMD_FMT_MOD_##field##_SHIFT)
#define AMD_FMT_MOD_GET(field, value) \
(((value) >> AMD_FMT_MOD_##field##_SHIFT) & AMD_FMT_MOD_##field##_MASK)
#define AMD_FMT_MOD_CLEAR(field) \
- (~((uint64_t)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
+ (~((__u64)AMD_FMT_MOD_##field##_MASK << AMD_FMT_MOD_##field##_SHIFT))
#if defined(__cplusplus)
}
diff --git a/lib/libc/include/any-linux-any/drm/drm_mode.h b/lib/libc/include/any-linux-any/drm/drm_mode.h
index 517853c033..5a51c9fb60 100644
--- a/lib/libc/include/any-linux-any/drm/drm_mode.h
+++ b/lib/libc/include/any-linux-any/drm/drm_mode.h
@@ -663,41 +663,73 @@ struct drm_mode_fb_cmd {
#define DRM_MODE_FB_INTERLACED (1<<0) /* for interlaced framebuffers */
#define DRM_MODE_FB_MODIFIERS (1<<1) /* enables ->modifer[] */
+/**
+ * struct drm_mode_fb_cmd2 - Frame-buffer metadata.
+ *
+ * This struct holds frame-buffer metadata. There are two ways to use it:
+ *
+ * - User-space can fill this struct and perform a &DRM_IOCTL_MODE_ADDFB2
+ * ioctl to register a new frame-buffer. The new frame-buffer object ID will
+ * be set by the kernel in @fb_id.
+ * - User-space can set @fb_id and perform a &DRM_IOCTL_MODE_GETFB2 ioctl to
+ * fetch metadata about an existing frame-buffer.
+ *
+ * In case of planar formats, this struct allows up to 4 buffer objects with
+ * offsets and pitches per plane. The pitch and offset order are dictated by
+ * the format FourCC as defined by ``drm_fourcc.h``, e.g. NV12 is described as:
+ *
+ * YUV 4:2:0 image with a plane of 8-bit Y samples followed by an
+ * interleaved U/V plane containing 8-bit 2x2 subsampled colour difference
+ * samples.
+ *
+ * So it would consist of a Y plane at ``offsets[0]`` and a UV plane at
+ * ``offsets[1]``.
+ *
+ * To accommodate tiled, compressed, etc formats, a modifier can be specified.
+ * For more information see the "Format Modifiers" section. Note that even
+ * though it looks like we have a modifier per-plane, we in fact do not. The
+ * modifier for each plane must be identical. Thus all combinations of
+ * different data layouts for multi-plane formats must be enumerated as
+ * separate modifiers.
+ *
+ * All of the entries in @handles, @pitches, @offsets and @modifier must be
+ * zero when unused. Warning, for @offsets and @modifier zero can't be used to
+ * figure out whether the entry is used or not since it's a valid value (a zero
+ * offset is common, and a zero modifier is &DRM_FORMAT_MOD_LINEAR).
+ */
struct drm_mode_fb_cmd2 {
+ /** @fb_id: Object ID of the frame-buffer. */
__u32 fb_id;
+ /** @width: Width of the frame-buffer. */
__u32 width;
+ /** @height: Height of the frame-buffer. */
__u32 height;
- __u32 pixel_format; /* fourcc code from drm_fourcc.h */
- __u32 flags; /* see above flags */
+ /**
+ * @pixel_format: FourCC format code, see ``DRM_FORMAT_*`` constants in
+ * ``drm_fourcc.h``.
+ */
+ __u32 pixel_format;
+ /**
+ * @flags: Frame-buffer flags (see &DRM_MODE_FB_INTERLACED and
+ * &DRM_MODE_FB_MODIFIERS).
+ */
+ __u32 flags;
- /*
- * In case of planar formats, this ioctl allows up to 4
- * buffer objects with offsets and pitches per plane.
- * The pitch and offset order is dictated by the fourcc,
- * e.g. NV12 (https://fourcc.org/yuv.php#NV12) is described as:
- *
- * YUV 4:2:0 image with a plane of 8 bit Y samples
- * followed by an interleaved U/V plane containing
- * 8 bit 2x2 subsampled colour difference samples.
- *
- * So it would consist of Y as offsets[0] and UV as
- * offsets[1]. Note that offsets[0] will generally
- * be 0 (but this is not required).
- *
- * To accommodate tiled, compressed, etc formats, a
- * modifier can be specified. The default value of zero
- * indicates "native" format as specified by the fourcc.
- * Vendor specific modifier token. Note that even though
- * it looks like we have a modifier per-plane, we in fact
- * do not. The modifier for each plane must be identical.
- * Thus all combinations of different data layouts for
- * multi plane formats must be enumerated as separate
- * modifiers.
+ /**
+ * @handles: GEM buffer handle, one per plane. Set to 0 if the plane is
+ * unused. The same handle can be used for multiple planes.
*/
__u32 handles[4];
- __u32 pitches[4]; /* pitch for each plane */
- __u32 offsets[4]; /* offset of each plane */
- __u64 modifier[4]; /* ie, tiling, compress */
+ /** @pitches: Pitch (aka. stride) in bytes, one per plane. */
+ __u32 pitches[4];
+ /** @offsets: Offset into the buffer in bytes, one per plane. */
+ __u32 offsets[4];
+ /**
+ * @modifier: Format modifier, one per plane. See ``DRM_FORMAT_MOD_*``
+ * constants in ``drm_fourcc.h``. All planes must use the same
+ * modifier. Ignored unless &DRM_MODE_FB_MODIFIERS is set in @flags.
+ */
+ __u64 modifier[4];
};
#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
@@ -903,12 +935,31 @@ struct hdr_output_metadata {
};
};
+/**
+ * DRM_MODE_PAGE_FLIP_EVENT
+ *
+ * Request that the kernel sends back a vblank event (see
+ * struct drm_event_vblank) with the &DRM_EVENT_FLIP_COMPLETE type when the
+ * page-flip is done.
+ */
#define DRM_MODE_PAGE_FLIP_EVENT 0x01
+/**
+ * DRM_MODE_PAGE_FLIP_ASYNC
+ *
+ * Request that the page-flip is performed as soon as possible, ie. with no
+ * delay due to waiting for vblank. This may cause tearing to be visible on
+ * the screen.
+ */
#define DRM_MODE_PAGE_FLIP_ASYNC 0x02
#define DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE 0x4
#define DRM_MODE_PAGE_FLIP_TARGET_RELATIVE 0x8
#define DRM_MODE_PAGE_FLIP_TARGET (DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE | \
DRM_MODE_PAGE_FLIP_TARGET_RELATIVE)
+/**
+ * DRM_MODE_PAGE_FLIP_FLAGS
+ *
+ * Bitmask of flags suitable for &drm_mode_crtc_page_flip_target.flags.
+ */
#define DRM_MODE_PAGE_FLIP_FLAGS (DRM_MODE_PAGE_FLIP_EVENT | \
DRM_MODE_PAGE_FLIP_ASYNC | \
DRM_MODE_PAGE_FLIP_TARGET)
@@ -1002,11 +1053,53 @@ struct drm_mode_destroy_dumb {
__u32 handle;
};
-/* page-flip flags are valid, plus: */
+/**
+ * DRM_MODE_ATOMIC_TEST_ONLY
+ *
+ * Do not apply the atomic commit, instead check whether the hardware supports
+ * this configuration.
+ *
+ * See &drm_mode_config_funcs.atomic_check for more details on test-only
+ * commits.
+ */
#define DRM_MODE_ATOMIC_TEST_ONLY 0x0100
+/**
+ * DRM_MODE_ATOMIC_NONBLOCK
+ *
+ * Do not block while applying the atomic commit. The &DRM_IOCTL_MODE_ATOMIC
+ * IOCTL returns immediately instead of waiting for the changes to be applied
+ * in hardware. Note, the driver will still check that the update can be
+ * applied before retuning.
+ */
#define DRM_MODE_ATOMIC_NONBLOCK 0x0200
+/**
+ * DRM_MODE_ATOMIC_ALLOW_MODESET
+ *
+ * Allow the update to result in temporary or transient visible artifacts while
+ * the update is being applied. Applying the update may also take significantly
+ * more time than a page flip. All visual artifacts will disappear by the time
+ * the update is completed, as signalled through the vblank event's timestamp
+ * (see struct drm_event_vblank).
+ *
+ * This flag must be set when the KMS update might cause visible artifacts.
+ * Without this flag such KMS update will return a EINVAL error. What kind of
+ * update may cause visible artifacts depends on the driver and the hardware.
+ * User-space that needs to know beforehand if an update might cause visible
+ * artifacts can use &DRM_MODE_ATOMIC_TEST_ONLY without
+ * &DRM_MODE_ATOMIC_ALLOW_MODESET to see if it fails.
+ *
+ * To the best of the driver's knowledge, visual artifacts are guaranteed to
+ * not appear when this flag is not set. Some sinks might display visual
+ * artifacts outside of the driver's control.
+ */
#define DRM_MODE_ATOMIC_ALLOW_MODESET 0x0400
+/**
+ * DRM_MODE_ATOMIC_FLAGS
+ *
+ * Bitfield of flags accepted by the &DRM_IOCTL_MODE_ATOMIC IOCTL in
+ * &drm_mode_atomic.flags.
+ */
#define DRM_MODE_ATOMIC_FLAGS (\
DRM_MODE_PAGE_FLIP_EVENT |\
DRM_MODE_PAGE_FLIP_ASYNC |\
diff --git a/lib/libc/include/any-linux-any/misc/habanalabs.h b/lib/libc/include/any-linux-any/drm/habanalabs_accel.h
index 4f2369f0f5..86d00c29f8 100644
--- a/lib/libc/include/any-linux-any/misc/habanalabs.h
+++ b/lib/libc/include/any-linux-any/drm/habanalabs_accel.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
*
- * Copyright 2016-2020 HabanaLabs, Ltd.
+ * Copyright 2016-2022 HabanaLabs, Ltd.
* All Rights Reserved.
*
*/
@@ -30,6 +30,9 @@
*/
#define GAUDI_FIRST_AVAILABLE_W_S_MONITOR 72
+/* Max number of elements in timestamps registration buffers */
+#define TS_MAX_ELEMENTS_NUM (1 << 20) /* 1MB */
+
/*
* Goya queue Numbering
*
@@ -182,6 +185,285 @@ enum gaudi_queue_id {
};
/*
+ * In GAUDI2 we have two modes of operation in regard to queues:
+ * 1. Legacy mode, where each QMAN exposes 4 streams to the user
+ * 2. F/W mode, where we use F/W to schedule the JOBS to the different queues.
+ *
+ * When in legacy mode, the user sends the queue id per JOB according to
+ * enum gaudi2_queue_id below.
+ *
+ * When in F/W mode, the user sends a stream id per Command Submission. The
+ * stream id is a running number from 0 up to (N-1), where N is the number
+ * of streams the F/W exposes and is passed to the user in
+ * struct hl_info_hw_ip_info
+ */
+
+enum gaudi2_queue_id {
+ GAUDI2_QUEUE_ID_PDMA_0_0 = 0,
+ GAUDI2_QUEUE_ID_PDMA_0_1 = 1,
+ GAUDI2_QUEUE_ID_PDMA_0_2 = 2,
+ GAUDI2_QUEUE_ID_PDMA_0_3 = 3,
+ GAUDI2_QUEUE_ID_PDMA_1_0 = 4,
+ GAUDI2_QUEUE_ID_PDMA_1_1 = 5,
+ GAUDI2_QUEUE_ID_PDMA_1_2 = 6,
+ GAUDI2_QUEUE_ID_PDMA_1_3 = 7,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_0_0 = 8,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_0_1 = 9,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_0_2 = 10,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_0_3 = 11,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_1_0 = 12,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_1_1 = 13,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_1_2 = 14,
+ GAUDI2_QUEUE_ID_DCORE0_EDMA_1_3 = 15,
+ GAUDI2_QUEUE_ID_DCORE0_MME_0_0 = 16,
+ GAUDI2_QUEUE_ID_DCORE0_MME_0_1 = 17,
+ GAUDI2_QUEUE_ID_DCORE0_MME_0_2 = 18,
+ GAUDI2_QUEUE_ID_DCORE0_MME_0_3 = 19,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_0_0 = 20,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_0_1 = 21,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_0_2 = 22,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_0_3 = 23,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_1_0 = 24,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_1_1 = 25,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_1_2 = 26,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_1_3 = 27,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_2_0 = 28,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_2_1 = 29,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_2_2 = 30,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_2_3 = 31,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_3_0 = 32,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_3_1 = 33,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_3_2 = 34,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_3_3 = 35,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_4_0 = 36,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_4_1 = 37,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_4_2 = 38,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_4_3 = 39,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_5_0 = 40,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_5_1 = 41,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_5_2 = 42,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_5_3 = 43,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_6_0 = 44,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_6_1 = 45,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_6_2 = 46,
+ GAUDI2_QUEUE_ID_DCORE0_TPC_6_3 = 47,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_0_0 = 48,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_0_1 = 49,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_0_2 = 50,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_0_3 = 51,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_1_0 = 52,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_1_1 = 53,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_1_2 = 54,
+ GAUDI2_QUEUE_ID_DCORE1_EDMA_1_3 = 55,
+ GAUDI2_QUEUE_ID_DCORE1_MME_0_0 = 56,
+ GAUDI2_QUEUE_ID_DCORE1_MME_0_1 = 57,
+ GAUDI2_QUEUE_ID_DCORE1_MME_0_2 = 58,
+ GAUDI2_QUEUE_ID_DCORE1_MME_0_3 = 59,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_0_0 = 60,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_0_1 = 61,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_0_2 = 62,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_0_3 = 63,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_1_0 = 64,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_1_1 = 65,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_1_2 = 66,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_1_3 = 67,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_2_0 = 68,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_2_1 = 69,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_2_2 = 70,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_2_3 = 71,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_3_0 = 72,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_3_1 = 73,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_3_2 = 74,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_3_3 = 75,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_4_0 = 76,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_4_1 = 77,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_4_2 = 78,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_4_3 = 79,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_5_0 = 80,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_5_1 = 81,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_5_2 = 82,
+ GAUDI2_QUEUE_ID_DCORE1_TPC_5_3 = 83,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_0_0 = 84,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_0_1 = 85,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_0_2 = 86,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_0_3 = 87,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_1_0 = 88,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_1_1 = 89,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_1_2 = 90,
+ GAUDI2_QUEUE_ID_DCORE2_EDMA_1_3 = 91,
+ GAUDI2_QUEUE_ID_DCORE2_MME_0_0 = 92,
+ GAUDI2_QUEUE_ID_DCORE2_MME_0_1 = 93,
+ GAUDI2_QUEUE_ID_DCORE2_MME_0_2 = 94,
+ GAUDI2_QUEUE_ID_DCORE2_MME_0_3 = 95,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_0_0 = 96,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_0_1 = 97,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_0_2 = 98,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_0_3 = 99,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_1_0 = 100,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_1_1 = 101,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_1_2 = 102,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_1_3 = 103,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_2_0 = 104,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_2_1 = 105,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_2_2 = 106,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_2_3 = 107,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_3_0 = 108,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_3_1 = 109,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_3_2 = 110,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_3_3 = 111,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_4_0 = 112,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_4_1 = 113,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_4_2 = 114,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_4_3 = 115,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_5_0 = 116,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_5_1 = 117,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_5_2 = 118,
+ GAUDI2_QUEUE_ID_DCORE2_TPC_5_3 = 119,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_0_0 = 120,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_0_1 = 121,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_0_2 = 122,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_0_3 = 123,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_1_0 = 124,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_1_1 = 125,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_1_2 = 126,
+ GAUDI2_QUEUE_ID_DCORE3_EDMA_1_3 = 127,
+ GAUDI2_QUEUE_ID_DCORE3_MME_0_0 = 128,
+ GAUDI2_QUEUE_ID_DCORE3_MME_0_1 = 129,
+ GAUDI2_QUEUE_ID_DCORE3_MME_0_2 = 130,
+ GAUDI2_QUEUE_ID_DCORE3_MME_0_3 = 131,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_0_0 = 132,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_0_1 = 133,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_0_2 = 134,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_0_3 = 135,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_1_0 = 136,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_1_1 = 137,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_1_2 = 138,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_1_3 = 139,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_2_0 = 140,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_2_1 = 141,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_2_2 = 142,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_2_3 = 143,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_3_0 = 144,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_3_1 = 145,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_3_2 = 146,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_3_3 = 147,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_4_0 = 148,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_4_1 = 149,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_4_2 = 150,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_4_3 = 151,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_5_0 = 152,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_5_1 = 153,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_5_2 = 154,
+ GAUDI2_QUEUE_ID_DCORE3_TPC_5_3 = 155,
+ GAUDI2_QUEUE_ID_NIC_0_0 = 156,
+ GAUDI2_QUEUE_ID_NIC_0_1 = 157,
+ GAUDI2_QUEUE_ID_NIC_0_2 = 158,
+ GAUDI2_QUEUE_ID_NIC_0_3 = 159,
+ GAUDI2_QUEUE_ID_NIC_1_0 = 160,
+ GAUDI2_QUEUE_ID_NIC_1_1 = 161,
+ GAUDI2_QUEUE_ID_NIC_1_2 = 162,
+ GAUDI2_QUEUE_ID_NIC_1_3 = 163,
+ GAUDI2_QUEUE_ID_NIC_2_0 = 164,
+ GAUDI2_QUEUE_ID_NIC_2_1 = 165,
+ GAUDI2_QUEUE_ID_NIC_2_2 = 166,
+ GAUDI2_QUEUE_ID_NIC_2_3 = 167,
+ GAUDI2_QUEUE_ID_NIC_3_0 = 168,
+ GAUDI2_QUEUE_ID_NIC_3_1 = 169,
+ GAUDI2_QUEUE_ID_NIC_3_2 = 170,
+ GAUDI2_QUEUE_ID_NIC_3_3 = 171,
+ GAUDI2_QUEUE_ID_NIC_4_0 = 172,
+ GAUDI2_QUEUE_ID_NIC_4_1 = 173,
+ GAUDI2_QUEUE_ID_NIC_4_2 = 174,
+ GAUDI2_QUEUE_ID_NIC_4_3 = 175,
+ GAUDI2_QUEUE_ID_NIC_5_0 = 176,
+ GAUDI2_QUEUE_ID_NIC_5_1 = 177,
+ GAUDI2_QUEUE_ID_NIC_5_2 = 178,
+ GAUDI2_QUEUE_ID_NIC_5_3 = 179,
+ GAUDI2_QUEUE_ID_NIC_6_0 = 180,
+ GAUDI2_QUEUE_ID_NIC_6_1 = 181,
+ GAUDI2_QUEUE_ID_NIC_6_2 = 182,
+ GAUDI2_QUEUE_ID_NIC_6_3 = 183,
+ GAUDI2_QUEUE_ID_NIC_7_0 = 184,
+ GAUDI2_QUEUE_ID_NIC_7_1 = 185,
+ GAUDI2_QUEUE_ID_NIC_7_2 = 186,
+ GAUDI2_QUEUE_ID_NIC_7_3 = 187,
+ GAUDI2_QUEUE_ID_NIC_8_0 = 188,
+ GAUDI2_QUEUE_ID_NIC_8_1 = 189,
+ GAUDI2_QUEUE_ID_NIC_8_2 = 190,
+ GAUDI2_QUEUE_ID_NIC_8_3 = 191,
+ GAUDI2_QUEUE_ID_NIC_9_0 = 192,
+ GAUDI2_QUEUE_ID_NIC_9_1 = 193,
+ GAUDI2_QUEUE_ID_NIC_9_2 = 194,
+ GAUDI2_QUEUE_ID_NIC_9_3 = 195,
+ GAUDI2_QUEUE_ID_NIC_10_0 = 196,
+ GAUDI2_QUEUE_ID_NIC_10_1 = 197,
+ GAUDI2_QUEUE_ID_NIC_10_2 = 198,
+ GAUDI2_QUEUE_ID_NIC_10_3 = 199,
+ GAUDI2_QUEUE_ID_NIC_11_0 = 200,
+ GAUDI2_QUEUE_ID_NIC_11_1 = 201,
+ GAUDI2_QUEUE_ID_NIC_11_2 = 202,
+ GAUDI2_QUEUE_ID_NIC_11_3 = 203,
+ GAUDI2_QUEUE_ID_NIC_12_0 = 204,
+ GAUDI2_QUEUE_ID_NIC_12_1 = 205,
+ GAUDI2_QUEUE_ID_NIC_12_2 = 206,
+ GAUDI2_QUEUE_ID_NIC_12_3 = 207,
+ GAUDI2_QUEUE_ID_NIC_13_0 = 208,
+ GAUDI2_QUEUE_ID_NIC_13_1 = 209,
+ GAUDI2_QUEUE_ID_NIC_13_2 = 210,
+ GAUDI2_QUEUE_ID_NIC_13_3 = 211,
+ GAUDI2_QUEUE_ID_NIC_14_0 = 212,
+ GAUDI2_QUEUE_ID_NIC_14_1 = 213,
+ GAUDI2_QUEUE_ID_NIC_14_2 = 214,
+ GAUDI2_QUEUE_ID_NIC_14_3 = 215,
+ GAUDI2_QUEUE_ID_NIC_15_0 = 216,
+ GAUDI2_QUEUE_ID_NIC_15_1 = 217,
+ GAUDI2_QUEUE_ID_NIC_15_2 = 218,
+ GAUDI2_QUEUE_ID_NIC_15_3 = 219,
+ GAUDI2_QUEUE_ID_NIC_16_0 = 220,
+ GAUDI2_QUEUE_ID_NIC_16_1 = 221,
+ GAUDI2_QUEUE_ID_NIC_16_2 = 222,
+ GAUDI2_QUEUE_ID_NIC_16_3 = 223,
+ GAUDI2_QUEUE_ID_NIC_17_0 = 224,
+ GAUDI2_QUEUE_ID_NIC_17_1 = 225,
+ GAUDI2_QUEUE_ID_NIC_17_2 = 226,
+ GAUDI2_QUEUE_ID_NIC_17_3 = 227,
+ GAUDI2_QUEUE_ID_NIC_18_0 = 228,
+ GAUDI2_QUEUE_ID_NIC_18_1 = 229,
+ GAUDI2_QUEUE_ID_NIC_18_2 = 230,
+ GAUDI2_QUEUE_ID_NIC_18_3 = 231,
+ GAUDI2_QUEUE_ID_NIC_19_0 = 232,
+ GAUDI2_QUEUE_ID_NIC_19_1 = 233,
+ GAUDI2_QUEUE_ID_NIC_19_2 = 234,
+ GAUDI2_QUEUE_ID_NIC_19_3 = 235,
+ GAUDI2_QUEUE_ID_NIC_20_0 = 236,
+ GAUDI2_QUEUE_ID_NIC_20_1 = 237,
+ GAUDI2_QUEUE_ID_NIC_20_2 = 238,
+ GAUDI2_QUEUE_ID_NIC_20_3 = 239,
+ GAUDI2_QUEUE_ID_NIC_21_0 = 240,
+ GAUDI2_QUEUE_ID_NIC_21_1 = 241,
+ GAUDI2_QUEUE_ID_NIC_21_2 = 242,
+ GAUDI2_QUEUE_ID_NIC_21_3 = 243,
+ GAUDI2_QUEUE_ID_NIC_22_0 = 244,
+ GAUDI2_QUEUE_ID_NIC_22_1 = 245,
+ GAUDI2_QUEUE_ID_NIC_22_2 = 246,
+ GAUDI2_QUEUE_ID_NIC_22_3 = 247,
+ GAUDI2_QUEUE_ID_NIC_23_0 = 248,
+ GAUDI2_QUEUE_ID_NIC_23_1 = 249,
+ GAUDI2_QUEUE_ID_NIC_23_2 = 250,
+ GAUDI2_QUEUE_ID_NIC_23_3 = 251,
+ GAUDI2_QUEUE_ID_ROT_0_0 = 252,
+ GAUDI2_QUEUE_ID_ROT_0_1 = 253,
+ GAUDI2_QUEUE_ID_ROT_0_2 = 254,
+ GAUDI2_QUEUE_ID_ROT_0_3 = 255,
+ GAUDI2_QUEUE_ID_ROT_1_0 = 256,
+ GAUDI2_QUEUE_ID_ROT_1_1 = 257,
+ GAUDI2_QUEUE_ID_ROT_1_2 = 258,
+ GAUDI2_QUEUE_ID_ROT_1_3 = 259,
+ GAUDI2_QUEUE_ID_CPU_PQ = 260,
+ GAUDI2_QUEUE_ID_SIZE
+};
+
+/*
* Engine Numbering
*
* Used in the "busy_engines_mask" field in `struct hl_info_hw_idle'
@@ -239,6 +521,89 @@ enum gaudi_engine_id {
GAUDI_ENGINE_ID_SIZE
};
+enum gaudi2_engine_id {
+ GAUDI2_DCORE0_ENGINE_ID_EDMA_0 = 0,
+ GAUDI2_DCORE0_ENGINE_ID_EDMA_1,
+ GAUDI2_DCORE0_ENGINE_ID_MME,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_0,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_1,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_2,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_3,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_4,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_5,
+ GAUDI2_DCORE0_ENGINE_ID_DEC_0,
+ GAUDI2_DCORE0_ENGINE_ID_DEC_1,
+ GAUDI2_DCORE1_ENGINE_ID_EDMA_0,
+ GAUDI2_DCORE1_ENGINE_ID_EDMA_1,
+ GAUDI2_DCORE1_ENGINE_ID_MME,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_0,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_1,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_2,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_3,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_4,
+ GAUDI2_DCORE1_ENGINE_ID_TPC_5,
+ GAUDI2_DCORE1_ENGINE_ID_DEC_0,
+ GAUDI2_DCORE1_ENGINE_ID_DEC_1,
+ GAUDI2_DCORE2_ENGINE_ID_EDMA_0,
+ GAUDI2_DCORE2_ENGINE_ID_EDMA_1,
+ GAUDI2_DCORE2_ENGINE_ID_MME,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_0,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_1,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_2,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_3,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_4,
+ GAUDI2_DCORE2_ENGINE_ID_TPC_5,
+ GAUDI2_DCORE2_ENGINE_ID_DEC_0,
+ GAUDI2_DCORE2_ENGINE_ID_DEC_1,
+ GAUDI2_DCORE3_ENGINE_ID_EDMA_0,
+ GAUDI2_DCORE3_ENGINE_ID_EDMA_1,
+ GAUDI2_DCORE3_ENGINE_ID_MME,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_0,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_1,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_2,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_3,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_4,
+ GAUDI2_DCORE3_ENGINE_ID_TPC_5,
+ GAUDI2_DCORE3_ENGINE_ID_DEC_0,
+ GAUDI2_DCORE3_ENGINE_ID_DEC_1,
+ GAUDI2_DCORE0_ENGINE_ID_TPC_6,
+ GAUDI2_ENGINE_ID_PDMA_0,
+ GAUDI2_ENGINE_ID_PDMA_1,
+ GAUDI2_ENGINE_ID_ROT_0,
+ GAUDI2_ENGINE_ID_ROT_1,
+ GAUDI2_PCIE_ENGINE_ID_DEC_0,
+ GAUDI2_PCIE_ENGINE_ID_DEC_1,
+ GAUDI2_ENGINE_ID_NIC0_0,
+ GAUDI2_ENGINE_ID_NIC0_1,
+ GAUDI2_ENGINE_ID_NIC1_0,
+ GAUDI2_ENGINE_ID_NIC1_1,
+ GAUDI2_ENGINE_ID_NIC2_0,
+ GAUDI2_ENGINE_ID_NIC2_1,
+ GAUDI2_ENGINE_ID_NIC3_0,
+ GAUDI2_ENGINE_ID_NIC3_1,
+ GAUDI2_ENGINE_ID_NIC4_0,
+ GAUDI2_ENGINE_ID_NIC4_1,
+ GAUDI2_ENGINE_ID_NIC5_0,
+ GAUDI2_ENGINE_ID_NIC5_1,
+ GAUDI2_ENGINE_ID_NIC6_0,
+ GAUDI2_ENGINE_ID_NIC6_1,
+ GAUDI2_ENGINE_ID_NIC7_0,
+ GAUDI2_ENGINE_ID_NIC7_1,
+ GAUDI2_ENGINE_ID_NIC8_0,
+ GAUDI2_ENGINE_ID_NIC8_1,
+ GAUDI2_ENGINE_ID_NIC9_0,
+ GAUDI2_ENGINE_ID_NIC9_1,
+ GAUDI2_ENGINE_ID_NIC10_0,
+ GAUDI2_ENGINE_ID_NIC10_1,
+ GAUDI2_ENGINE_ID_NIC11_0,
+ GAUDI2_ENGINE_ID_NIC11_1,
+ GAUDI2_ENGINE_ID_PCIE,
+ GAUDI2_ENGINE_ID_PSOC,
+ GAUDI2_ENGINE_ID_ARC_FARM,
+ GAUDI2_ENGINE_ID_KDMA,
+ GAUDI2_ENGINE_ID_SIZE
+};
+
/*
* ASIC specific PLL index
*
@@ -272,6 +637,49 @@ enum hl_gaudi_pll_index {
HL_GAUDI_PLL_MAX
};
+enum hl_gaudi2_pll_index {
+ HL_GAUDI2_CPU_PLL = 0,
+ HL_GAUDI2_PCI_PLL,
+ HL_GAUDI2_SRAM_PLL,
+ HL_GAUDI2_HBM_PLL,
+ HL_GAUDI2_NIC_PLL,
+ HL_GAUDI2_DMA_PLL,
+ HL_GAUDI2_MESH_PLL,
+ HL_GAUDI2_MME_PLL,
+ HL_GAUDI2_TPC_PLL,
+ HL_GAUDI2_IF_PLL,
+ HL_GAUDI2_VID_PLL,
+ HL_GAUDI2_MSS_PLL,
+ HL_GAUDI2_PLL_MAX
+};
+
+/**
+ * enum hl_goya_dma_direction - Direction of DMA operation inside a LIN_DMA packet that is
+ * submitted to the GOYA's DMA QMAN. This attribute is not relevant
+ * to the H/W but the kernel driver use it to parse the packet's
+ * addresses and patch/validate them.
+ * @HL_DMA_HOST_TO_DRAM: DMA operation from Host memory to GOYA's DDR.
+ * @HL_DMA_HOST_TO_SRAM: DMA operation from Host memory to GOYA's SRAM.
+ * @HL_DMA_DRAM_TO_SRAM: DMA operation from GOYA's DDR to GOYA's SRAM.
+ * @HL_DMA_SRAM_TO_DRAM: DMA operation from GOYA's SRAM to GOYA's DDR.
+ * @HL_DMA_SRAM_TO_HOST: DMA operation from GOYA's SRAM to Host memory.
+ * @HL_DMA_DRAM_TO_HOST: DMA operation from GOYA's DDR to Host memory.
+ * @HL_DMA_DRAM_TO_DRAM: DMA operation from GOYA's DDR to GOYA's DDR.
+ * @HL_DMA_SRAM_TO_SRAM: DMA operation from GOYA's SRAM to GOYA's SRAM.
+ * @HL_DMA_ENUM_MAX: number of values in enum
+ */
+enum hl_goya_dma_direction {
+ HL_DMA_HOST_TO_DRAM,
+ HL_DMA_HOST_TO_SRAM,
+ HL_DMA_DRAM_TO_SRAM,
+ HL_DMA_SRAM_TO_DRAM,
+ HL_DMA_SRAM_TO_HOST,
+ HL_DMA_DRAM_TO_HOST,
+ HL_DMA_DRAM_TO_DRAM,
+ HL_DMA_SRAM_TO_SRAM,
+ HL_DMA_ENUM_MAX
+};
+
/**
* enum hl_device_status - Device status information.
* @HL_DEVICE_STATUS_OPERATIONAL: Device is operational.
@@ -280,6 +688,8 @@ enum hl_gaudi_pll_index {
* @HL_DEVICE_STATUS_NEEDS_RESET: Device needs reset because auto reset was disabled.
* @HL_DEVICE_STATUS_IN_DEVICE_CREATION: Device is operational but its creation is still in
* progress.
+ * @HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE: Device is currently during reset that was
+ * triggered because the user released the device
* @HL_DEVICE_STATUS_LAST: Last status.
*/
enum hl_device_status {
@@ -288,7 +698,8 @@ enum hl_device_status {
HL_DEVICE_STATUS_MALFUNCTION,
HL_DEVICE_STATUS_NEEDS_RESET,
HL_DEVICE_STATUS_IN_DEVICE_CREATION,
- HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_DEVICE_CREATION
+ HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE,
+ HL_DEVICE_STATUS_LAST = HL_DEVICE_STATUS_IN_RESET_AFTER_DEVICE_RELEASE
};
enum hl_server_type {
@@ -296,9 +707,33 @@ enum hl_server_type {
HL_SERVER_GAUDI_HLS1 = 1,
HL_SERVER_GAUDI_HLS1H = 2,
HL_SERVER_GAUDI_TYPE1 = 3,
- HL_SERVER_GAUDI_TYPE2 = 4
+ HL_SERVER_GAUDI_TYPE2 = 4,
+ HL_SERVER_GAUDI2_HLS2 = 5
};
+/*
+ * Notifier event values - for the notification mechanism and the HL_INFO_GET_EVENTS command
+ *
+ * HL_NOTIFIER_EVENT_TPC_ASSERT - Indicates TPC assert event
+ * HL_NOTIFIER_EVENT_UNDEFINED_OPCODE - Indicates undefined operation code
+ * HL_NOTIFIER_EVENT_DEVICE_RESET - Indicates device requires a reset
+ * HL_NOTIFIER_EVENT_CS_TIMEOUT - Indicates CS timeout error
+ * HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE - Indicates device is unavailable
+ * HL_NOTIFIER_EVENT_USER_ENGINE_ERR - Indicates device engine in error state
+ * HL_NOTIFIER_EVENT_GENERAL_HW_ERR - Indicates device HW error
+ * HL_NOTIFIER_EVENT_RAZWI - Indicates razwi happened
+ * HL_NOTIFIER_EVENT_PAGE_FAULT - Indicates page fault happened
+ */
+#define HL_NOTIFIER_EVENT_TPC_ASSERT (1ULL << 0)
+#define HL_NOTIFIER_EVENT_UNDEFINED_OPCODE (1ULL << 1)
+#define HL_NOTIFIER_EVENT_DEVICE_RESET (1ULL << 2)
+#define HL_NOTIFIER_EVENT_CS_TIMEOUT (1ULL << 3)
+#define HL_NOTIFIER_EVENT_DEVICE_UNAVAILABLE (1ULL << 4)
+#define HL_NOTIFIER_EVENT_USER_ENGINE_ERR (1ULL << 5)
+#define HL_NOTIFIER_EVENT_GENERAL_HW_ERR (1ULL << 6)
+#define HL_NOTIFIER_EVENT_RAZWI (1ULL << 7)
+#define HL_NOTIFIER_EVENT_PAGE_FAULT (1ULL << 8)
+
/* Opcode for management ioctl
*
* HW_IP_INFO - Receive information about different IP blocks in the
@@ -333,29 +768,68 @@ enum hl_server_type {
* HL_INFO_SYNC_MANAGER - Retrieve sync manager info per dcore
* HL_INFO_TOTAL_ENERGY - Retrieve total energy consumption
* HL_INFO_PLL_FREQUENCY - Retrieve PLL frequency
+ * HL_INFO_POWER - Retrieve power information
* HL_INFO_OPEN_STATS - Retrieve info regarding recent device open calls
+ * HL_INFO_DRAM_REPLACED_ROWS - Retrieve DRAM replaced rows info
+ * HL_INFO_DRAM_PENDING_ROWS - Retrieve DRAM pending rows num
+ * HL_INFO_LAST_ERR_OPEN_DEV_TIME - Retrieve timestamp of the last time the device was opened
+ * and CS timeout or razwi error occurred.
+ * HL_INFO_CS_TIMEOUT_EVENT - Retrieve CS timeout timestamp and its related CS sequence number.
+ * HL_INFO_RAZWI_EVENT - Retrieve parameters of razwi:
+ * Timestamp of razwi.
+ * The address which accessing it caused the razwi.
+ * Razwi initiator.
+ * Razwi cause, was it a page fault or MMU access error.
+ * HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES - Retrieve valid page sizes for device memory allocation
+ * HL_INFO_SECURED_ATTESTATION - Retrieve attestation report of the boot.
+ * HL_INFO_REGISTER_EVENTFD - Register eventfd for event notifications.
+ * HL_INFO_UNREGISTER_EVENTFD - Unregister eventfd
+ * HL_INFO_GET_EVENTS - Retrieve the last occurred events
+ * HL_INFO_UNDEFINED_OPCODE_EVENT - Retrieve last undefined opcode error information.
+ * HL_INFO_ENGINE_STATUS - Retrieve the status of all the h/w engines in the asic.
+ * HL_INFO_PAGE_FAULT_EVENT - Retrieve parameters of captured page fault.
+ * HL_INFO_USER_MAPPINGS - Retrieve user mappings, captured after page fault event.
+ * HL_INFO_FW_GENERIC_REQ - Send generic request to FW.
*/
-#define HL_INFO_HW_IP_INFO 0
-#define HL_INFO_HW_EVENTS 1
-#define HL_INFO_DRAM_USAGE 2
-#define HL_INFO_HW_IDLE 3
-#define HL_INFO_DEVICE_STATUS 4
-#define HL_INFO_DEVICE_UTILIZATION 6
-#define HL_INFO_HW_EVENTS_AGGREGATE 7
-#define HL_INFO_CLK_RATE 8
-#define HL_INFO_RESET_COUNT 9
-#define HL_INFO_TIME_SYNC 10
-#define HL_INFO_CS_COUNTERS 11
-#define HL_INFO_PCI_COUNTERS 12
-#define HL_INFO_CLK_THROTTLE_REASON 13
-#define HL_INFO_SYNC_MANAGER 14
-#define HL_INFO_TOTAL_ENERGY 15
-#define HL_INFO_PLL_FREQUENCY 16
-#define HL_INFO_POWER 17
-#define HL_INFO_OPEN_STATS 18
-
-#define HL_INFO_VERSION_MAX_LEN 128
-#define HL_INFO_CARD_NAME_MAX_LEN 16
+#define HL_INFO_HW_IP_INFO 0
+#define HL_INFO_HW_EVENTS 1
+#define HL_INFO_DRAM_USAGE 2
+#define HL_INFO_HW_IDLE 3
+#define HL_INFO_DEVICE_STATUS 4
+#define HL_INFO_DEVICE_UTILIZATION 6
+#define HL_INFO_HW_EVENTS_AGGREGATE 7
+#define HL_INFO_CLK_RATE 8
+#define HL_INFO_RESET_COUNT 9
+#define HL_INFO_TIME_SYNC 10
+#define HL_INFO_CS_COUNTERS 11
+#define HL_INFO_PCI_COUNTERS 12
+#define HL_INFO_CLK_THROTTLE_REASON 13
+#define HL_INFO_SYNC_MANAGER 14
+#define HL_INFO_TOTAL_ENERGY 15
+#define HL_INFO_PLL_FREQUENCY 16
+#define HL_INFO_POWER 17
+#define HL_INFO_OPEN_STATS 18
+#define HL_INFO_DRAM_REPLACED_ROWS 21
+#define HL_INFO_DRAM_PENDING_ROWS 22
+#define HL_INFO_LAST_ERR_OPEN_DEV_TIME 23
+#define HL_INFO_CS_TIMEOUT_EVENT 24
+#define HL_INFO_RAZWI_EVENT 25
+#define HL_INFO_DEV_MEM_ALLOC_PAGE_SIZES 26
+#define HL_INFO_SECURED_ATTESTATION 27
+#define HL_INFO_REGISTER_EVENTFD 28
+#define HL_INFO_UNREGISTER_EVENTFD 29
+#define HL_INFO_GET_EVENTS 30
+#define HL_INFO_UNDEFINED_OPCODE_EVENT 31
+#define HL_INFO_ENGINE_STATUS 32
+#define HL_INFO_PAGE_FAULT_EVENT 33
+#define HL_INFO_USER_MAPPINGS 34
+#define HL_INFO_FW_GENERIC_REQ 35
+
+#define HL_INFO_VERSION_MAX_LEN 128
+#define HL_INFO_CARD_NAME_MAX_LEN 16
+
+/* Maximum buffer size for retrieving engines status */
+#define HL_ENGINES_DATA_MAX_SIZE SZ_1M
/**
* struct hl_info_hw_ip_info - hardware information on various IPs in the ASIC
@@ -372,8 +846,10 @@ enum hl_server_type {
* @device_id: PCI device ID of the ASIC.
* @module_id: Module ID of the ASIC for mezzanine cards in servers
* (From OCP spec).
+ * @decoder_enabled_mask: Bit-mask that represents which decoders are enabled.
* @first_available_interrupt_id: The first available interrupt ID for the user
* to be used when it works with user interrupts.
+ * Relevant for Gaudi2 and later.
* @server_type: Server type that the Gaudi ASIC is currently installed in.
* The value is according to enum hl_server_type
* @cpld_version: CPLD version on the board.
@@ -385,9 +861,20 @@ enum hl_server_type {
* @tpc_enabled_mask: Bit-mask that represents which TPCs are enabled. Relevant
* for Goya/Gaudi only.
* @dram_enabled: Whether the DRAM is enabled.
+ * @security_enabled: Whether security is enabled on device.
+ * @mme_master_slave_mode: Indicate whether the MME is working in master/slave
+ * configuration. Relevant for Greco and later.
* @cpucp_version: The CPUCP f/w version.
* @card_name: The card name as passed by the f/w.
+ * @tpc_enabled_mask_ext: Bit-mask that represents which TPCs are enabled.
+ * Relevant for Greco and later.
* @dram_page_size: The DRAM physical page size.
+ * @edma_enabled_mask: Bit-mask that represents which EDMAs are enabled.
+ * Relevant for Gaudi2 and later.
+ * @number_of_user_interrupts: The number of interrupts that are available to the userspace
+ * application to use. Relevant for Gaudi2 and later.
+ * @device_mem_alloc_default_page_size: default page size used in device memory allocation.
+ * @revision_id: PCI revision ID of the ASIC.
*/
struct hl_info_hw_ip_info {
__u64 sram_base_address;
@@ -397,7 +884,7 @@ struct hl_info_hw_ip_info {
__u32 num_of_events;
__u32 device_id;
__u32 module_id;
- __u32 reserved;
+ __u32 decoder_enabled_mask;
__u16 first_available_interrupt_id;
__u16 server_type;
__u32 cpld_version;
@@ -407,11 +894,23 @@ struct hl_info_hw_ip_info {
__u32 psoc_pci_pll_div_factor;
__u8 tpc_enabled_mask;
__u8 dram_enabled;
- __u8 pad[2];
+ __u8 security_enabled;
+ __u8 mme_master_slave_mode;
__u8 cpucp_version[HL_INFO_VERSION_MAX_LEN];
__u8 card_name[HL_INFO_CARD_NAME_MAX_LEN];
- __u64 reserved2;
+ __u64 tpc_enabled_mask_ext;
__u64 dram_page_size;
+ __u32 edma_enabled_mask;
+ __u16 number_of_user_interrupts;
+ __u16 pad2;
+ __u64 reserved4;
+ __u64 device_mem_alloc_default_page_size;
+ __u64 reserved5;
+ __u64 reserved6;
+ __u32 reserved7;
+ __u8 reserved8;
+ __u8 revision_id;
+ __u8 pad[2];
};
struct hl_info_dram_usage {
@@ -419,19 +918,19 @@ struct hl_info_dram_usage {
__u64 ctx_dram_mem;
};
-#define HL_BUSY_ENGINES_MASK_EXT_SIZE 2
+#define HL_BUSY_ENGINES_MASK_EXT_SIZE 4
struct hl_info_hw_idle {
__u32 is_idle;
/*
* Bitmask of busy engines.
- * Bits definition is according to `enum <chip>_enging_id'.
+ * Bits definition is according to `enum <chip>_engine_id'.
*/
__u32 busy_engines_mask;
/*
* Extended Bitmask of busy engines.
- * Bits definition is according to `enum <chip>_enging_id'.
+ * Bits definition is according to `enum <chip>_engine_id'.
*/
__u64 busy_engines_mask_ext[HL_BUSY_ENGINES_MASK_EXT_SIZE];
};
@@ -473,15 +972,27 @@ struct hl_info_pci_counters {
__u64 replay_cnt;
};
-#define HL_CLK_THROTTLE_POWER 0x1
-#define HL_CLK_THROTTLE_THERMAL 0x2
+enum hl_clk_throttling_type {
+ HL_CLK_THROTTLE_TYPE_POWER,
+ HL_CLK_THROTTLE_TYPE_THERMAL,
+ HL_CLK_THROTTLE_TYPE_MAX
+};
+
+/* clk_throttling_reason masks */
+#define HL_CLK_THROTTLE_POWER (1 << HL_CLK_THROTTLE_TYPE_POWER)
+#define HL_CLK_THROTTLE_THERMAL (1 << HL_CLK_THROTTLE_TYPE_THERMAL)
/**
* struct hl_info_clk_throttle - clock throttling reason
* @clk_throttling_reason: each bit represents a clk throttling reason
+ * @clk_throttling_timestamp_us: represents CPU timestamp in microseconds of the start-event
+ * @clk_throttling_duration_ns: the clock throttle time in nanosec
*/
struct hl_info_clk_throttle {
__u32 clk_throttling_reason;
+ __u32 pad;
+ __u64 clk_throttling_timestamp_us[HL_CLK_THROTTLE_TYPE_MAX];
+ __u64 clk_throttling_duration_ns[HL_CLK_THROTTLE_TYPE_MAX];
};
/**
@@ -502,10 +1013,15 @@ struct hl_pll_frequency_info {
* struct hl_open_stats_info - device open statistics information
* @open_counter: ever growing counter, increased on each successful dev open
* @last_open_period_ms: duration (ms) device was open last time
+ * @is_compute_ctx_active: Whether there is an active compute context executing
+ * @compute_ctx_in_release: true if the current compute context is being released
*/
struct hl_open_stats_info {
__u64 open_counter;
__u64 last_open_period_ms;
+ __u8 is_compute_ctx_active;
+ __u8 compute_ctx_in_release;
+ __u8 pad[6];
};
/**
@@ -559,6 +1075,163 @@ struct hl_info_cs_counters {
__u64 ctx_validation_drop_cnt;
};
+/**
+ * struct hl_info_last_err_open_dev_time - last error boot information.
+ * @timestamp: timestamp of last time the device was opened and error occurred.
+ */
+struct hl_info_last_err_open_dev_time {
+ __s64 timestamp;
+};
+
+/**
+ * struct hl_info_cs_timeout_event - last CS timeout information.
+ * @timestamp: timestamp when last CS timeout event occurred.
+ * @seq: sequence number of last CS timeout event.
+ */
+struct hl_info_cs_timeout_event {
+ __s64 timestamp;
+ __u64 seq;
+};
+
+#define HL_RAZWI_NA_ENG_ID U16_MAX
+#define HL_RAZWI_MAX_NUM_OF_ENGINES_PER_RTR 128
+#define HL_RAZWI_READ BIT(0)
+#define HL_RAZWI_WRITE BIT(1)
+#define HL_RAZWI_LBW BIT(2)
+#define HL_RAZWI_HBW BIT(3)
+#define HL_RAZWI_RR BIT(4)
+#define HL_RAZWI_ADDR_DEC BIT(5)
+
+/**
+ * struct hl_info_razwi_event - razwi information.
+ * @timestamp: timestamp of razwi.
+ * @addr: address which accessing it caused razwi.
+ * @engine_id: engine id of the razwi initiator, if it was initiated by engine that does not
+ * have engine id it will be set to HL_RAZWI_NA_ENG_ID. If there are several possible
+ * engines which caused the razwi, it will hold all of them.
+ * @num_of_possible_engines: contains number of possible engine ids. In some asics, razwi indication
+ * might be common for several engines and there is no way to get the
+ * exact engine. In this way, engine_id array will be filled with all
+ * possible engines caused this razwi. Also, there might be possibility
+ * in gaudi, where we don't indication on specific engine, in that case
+ * the value of this parameter will be zero.
+ * @flags: bitmask for additional data: HL_RAZWI_READ - razwi caused by read operation
+ * HL_RAZWI_WRITE - razwi caused by write operation
+ * HL_RAZWI_LBW - razwi caused by lbw fabric transaction
+ * HL_RAZWI_HBW - razwi caused by hbw fabric transaction
+ * HL_RAZWI_RR - razwi caused by range register
+ * HL_RAZWI_ADDR_DEC - razwi caused by address decode error
+ * Note: this data is not supported by all asics, in that case the relevant bits will not
+ * be set.
+ */
+struct hl_info_razwi_event {
+ __s64 timestamp;
+ __u64 addr;
+ __u16 engine_id[HL_RAZWI_MAX_NUM_OF_ENGINES_PER_RTR];
+ __u16 num_of_possible_engines;
+ __u8 flags;
+ __u8 pad[5];
+};
+
+#define MAX_QMAN_STREAMS_INFO 4
+#define OPCODE_INFO_MAX_ADDR_SIZE 8
+/**
+ * struct hl_info_undefined_opcode_event - info about last undefined opcode error
+ * @timestamp: timestamp of the undefined opcode error
+ * @cb_addr_streams: CB addresses (per stream) that are currently exists in the PQ
+ * entries. In case all streams array entries are
+ * filled with values, it means the execution was in Lower-CP.
+ * @cq_addr: the address of the current handled command buffer
+ * @cq_size: the size of the current handled command buffer
+ * @cb_addr_streams_len: num of streams - actual len of cb_addr_streams array.
+ * should be equal to 1 in case of undefined opcode
+ * in Upper-CP (specific stream) and equal to 4 incase
+ * of undefined opcode in Lower-CP.
+ * @engine_id: engine-id that the error occurred on
+ * @stream_id: the stream id the error occurred on. In case the stream equals to
+ * MAX_QMAN_STREAMS_INFO it means the error occurred on a Lower-CP.
+ */
+struct hl_info_undefined_opcode_event {
+ __s64 timestamp;
+ __u64 cb_addr_streams[MAX_QMAN_STREAMS_INFO][OPCODE_INFO_MAX_ADDR_SIZE];
+ __u64 cq_addr;
+ __u32 cq_size;
+ __u32 cb_addr_streams_len;
+ __u32 engine_id;
+ __u32 stream_id;
+};
+
+/**
+ * struct hl_info_dev_memalloc_page_sizes - valid page sizes in device mem alloc information.
+ * @page_order_bitmask: bitmap in which a set bit represents the order of the supported page size
+ * (e.g. 0x2100000 means that 1MB and 32MB pages are supported).
+ */
+struct hl_info_dev_memalloc_page_sizes {
+ __u64 page_order_bitmask;
+};
+
+#define SEC_PCR_DATA_BUF_SZ 256
+#define SEC_PCR_QUOTE_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */
+#define SEC_SIGNATURE_BUF_SZ 255 /* (256 - 1) 1 byte used for size */
+#define SEC_PUB_DATA_BUF_SZ 510 /* (512 - 2) 2 bytes used for size */
+#define SEC_CERTIFICATE_BUF_SZ 2046 /* (2048 - 2) 2 bytes used for size */
+
+/*
+ * struct hl_info_sec_attest - attestation report of the boot
+ * @nonce: number only used once. random number provided by host. this also passed to the quote
+ * command as a qualifying data.
+ * @pcr_quote_len: length of the attestation quote data (bytes)
+ * @pub_data_len: length of the public data (bytes)
+ * @certificate_len: length of the certificate (bytes)
+ * @pcr_num_reg: number of PCR registers in the pcr_data array
+ * @pcr_reg_len: length of each PCR register in the pcr_data array (bytes)
+ * @quote_sig_len: length of the attestation report signature (bytes)
+ * @pcr_data: raw values of the PCR registers
+ * @pcr_quote: attestation report data structure
+ * @quote_sig: signature structure of the attestation report
+ * @public_data: public key for the signed attestation
+ * (outPublic + name + qualifiedName)
+ * @certificate: certificate for the attestation signing key
+ */
+struct hl_info_sec_attest {
+ __u32 nonce;
+ __u16 pcr_quote_len;
+ __u16 pub_data_len;
+ __u16 certificate_len;
+ __u8 pcr_num_reg;
+ __u8 pcr_reg_len;
+ __u8 quote_sig_len;
+ __u8 pcr_data[SEC_PCR_DATA_BUF_SZ];
+ __u8 pcr_quote[SEC_PCR_QUOTE_BUF_SZ];
+ __u8 quote_sig[SEC_SIGNATURE_BUF_SZ];
+ __u8 public_data[SEC_PUB_DATA_BUF_SZ];
+ __u8 certificate[SEC_CERTIFICATE_BUF_SZ];
+ __u8 pad0[2];
+};
+
+/**
+ * struct hl_page_fault_info - page fault information.
+ * @timestamp: timestamp of page fault.
+ * @addr: address which accessing it caused page fault.
+ * @engine_id: engine id which caused the page fault, supported only in gaudi3.
+ */
+struct hl_page_fault_info {
+ __s64 timestamp;
+ __u64 addr;
+ __u16 engine_id;
+ __u8 pad[6];
+};
+
+/**
+ * struct hl_user_mapping - user mapping information.
+ * @dev_va: device virtual address.
+ * @size: virtual address mapping size.
+ */
+struct hl_user_mapping {
+ __u64 dev_va;
+ __u64 size;
+};
+
enum gaudi_dcores {
HL_GAUDI_WS_DCORE,
HL_GAUDI_WN_DCORE,
@@ -579,6 +1252,15 @@ enum gaudi_dcores {
* @period_ms: Period value, in milliseconds, for utilization rate in range 100ms - 1000ms in 100 ms
* resolution. Currently not in use.
* @pll_index: Index as defined in hl_<asic type>_pll_index enumeration.
+ * @eventfd: event file descriptor for event notifications.
+ * @user_buffer_actual_size: Actual data size which was copied to user allocated buffer by the
+ * driver. It is possible for the user to allocate buffer larger than
+ * needed, hence updating this variable so user will know the exact amount
+ * of bytes copied by the kernel to the buffer.
+ * @sec_attest_nonce: Nonce number used for attestation report.
+ * @array_size: Number of array members copied to user buffer.
+ * Relevant for HL_INFO_USER_MAPPINGS info ioctl.
+ * @fw_sub_opcode: generic requests sub opcodes.
* @pad: Padding to 64 bit.
*/
struct hl_info_args {
@@ -591,6 +1273,11 @@ struct hl_info_args {
__u32 ctx_id;
__u32 period_ms;
__u32 pll_index;
+ __u32 eventfd;
+ __u32 user_buffer_actual_size;
+ __u32 sec_attest_nonce;
+ __u32 array_size;
+ __u32 fw_sub_opcode;
};
__u32 pad;
@@ -607,17 +1294,22 @@ struct hl_info_args {
#define HL_MAX_CB_SIZE (0x200000 - 32)
/* Indicates whether the command buffer should be mapped to the device's MMU */
-#define HL_CB_FLAGS_MAP 0x1
+#define HL_CB_FLAGS_MAP 0x1
+
+/* Used with HL_CB_OP_INFO opcode to get the device va address for kernel mapped CB */
+#define HL_CB_FLAGS_GET_DEVICE_VA 0x2
struct hl_cb_in {
/* Handle of CB or 0 if we want to create one */
__u64 cb_handle;
/* HL_CB_OP_* */
__u32 op;
+
/* Size of CB. Maximum size is HL_MAX_CB_SIZE. The minimum size that
* will be allocated, regardless of this parameter's value, is PAGE_SIZE
*/
__u32 cb_size;
+
/* Context ID - Currently not in use */
__u32 ctx_id;
/* HL_CB_FLAGS_* */
@@ -629,11 +1321,16 @@ struct hl_cb_out {
/* Handle of CB */
__u64 cb_handle;
- /* Information about CB */
- struct {
- /* Usage count of CB */
- __u32 usage_cnt;
- __u32 pad;
+ union {
+ /* Information about CB */
+ struct {
+ /* Usage count of CB */
+ __u32 usage_cnt;
+ __u32 pad;
+ };
+
+ /* CB mapped address to device MMU */
+ __u64 device_va;
};
};
};
@@ -646,16 +1343,16 @@ union hl_cb_args {
/* HL_CS_CHUNK_FLAGS_ values
*
* HL_CS_CHUNK_FLAGS_USER_ALLOC_CB:
- * Indicates if the CB was allocated and mapped by userspace.
- * User allocated CB is a command buffer allocated by the user, via malloc
- * (or similar). After allocating the CB, the user invokes “memory ioctl”
- * to map the user memory into a device virtual address. The user provides
- * this address via the cb_handle field. The interface provides the
- * ability to create a large CBs, Which aren’t limited to
- * “HL_MAX_CB_SIZE”. Therefore, it increases the PCI-DMA queues
- * throughput. This CB allocation method also reduces the use of Linux
- * DMA-able memory pool. Which are limited and used by other Linux
- * sub-systems.
+ * Indicates if the CB was allocated and mapped by userspace
+ * (relevant to greco and above). User allocated CB is a command buffer,
+ * allocated by the user, via malloc (or similar). After allocating the
+ * CB, the user invokes - “memory ioctl” to map the user memory into a
+ * device virtual address. The user provides this address via the
+ * cb_handle field. The interface provides the ability to create a
+ * large CBs, Which aren’t limited to “HL_MAX_CB_SIZE”. Therefore, it
+ * increases the PCI-DMA queues throughput. This CB allocation method
+ * also reduces the use of Linux DMA-able memory pool. Which are limited
+ * and used by other Linux sub-systems.
*/
#define HL_CS_CHUNK_FLAGS_USER_ALLOC_CB 0x1
@@ -665,12 +1362,17 @@ union hl_cb_args {
*/
struct hl_cs_chunk {
union {
- /* For external queue, this represents a Handle of CB on the
+ /* Goya/Gaudi:
+ * For external queue, this represents a Handle of CB on the
* Host.
* For internal queue in Goya, this represents an SRAM or
* a DRAM address of the internal CB. In Gaudi, this might also
* represent a mapped host address of the CB.
*
+ * Greco onwards:
+ * For H/W queue, this represents either a Handle of CB on the
+ * Host, or an SRAM, a DRAM, or a mapped host address of the CB.
+ *
* A mapped host address is in the device address space, after
* a host address was mapped by the device MMU.
*/
@@ -735,11 +1437,12 @@ struct hl_cs_chunk {
__u32 pad[10];
};
-/* SIGNAL and WAIT/COLLECTIVE_WAIT flags are mutually exclusive */
+/* SIGNAL/WAIT/COLLECTIVE_WAIT flags are mutually exclusive */
#define HL_CS_FLAGS_FORCE_RESTORE 0x1
#define HL_CS_FLAGS_SIGNAL 0x2
#define HL_CS_FLAGS_WAIT 0x4
#define HL_CS_FLAGS_COLLECTIVE_WAIT 0x8
+
#define HL_CS_FLAGS_TIMESTAMP 0x20
#define HL_CS_FLAGS_STAGED_SUBMISSION 0x40
#define HL_CS_FLAGS_STAGED_SUBMISSION_FIRST 0x80
@@ -769,17 +1472,55 @@ struct hl_cs_chunk {
#define HL_CS_FLAGS_RESERVE_SIGNALS_ONLY 0x1000
#define HL_CS_FLAGS_UNRESERVE_SIGNALS_ONLY 0x2000
+/*
+ * The engine cores CS is merged into the existing CS ioctls.
+ * Use it to control the engine cores mode.
+ */
+#define HL_CS_FLAGS_ENGINE_CORE_COMMAND 0x4000
+
+/*
+ * The flush HBW PCI writes is merged into the existing CS ioctls.
+ * Used to flush all HBW PCI writes.
+ * This is a blocking operation and for this reason the user shall not use
+ * the return sequence number (which will be invalid anyway)
+ */
+#define HL_CS_FLAGS_FLUSH_PCI_HBW_WRITES 0x8000
+
#define HL_CS_STATUS_SUCCESS 0
#define HL_MAX_JOBS_PER_CS 512
+/* HL_ENGINE_CORE_ values
+ *
+ * HL_ENGINE_CORE_HALT: engine core halt
+ * HL_ENGINE_CORE_RUN: engine core run
+ */
+#define HL_ENGINE_CORE_HALT (1 << 0)
+#define HL_ENGINE_CORE_RUN (1 << 1)
+
struct hl_cs_in {
- /* this holds address of array of hl_cs_chunk for restore phase */
- __u64 chunks_restore;
+ union {
+ struct {
+ /* this holds address of array of hl_cs_chunk for restore phase */
+ __u64 chunks_restore;
+
+ /* holds address of array of hl_cs_chunk for execution phase */
+ __u64 chunks_execute;
+ };
- /* holds address of array of hl_cs_chunk for execution phase */
- __u64 chunks_execute;
+ /* Valid only when HL_CS_FLAGS_ENGINE_CORE_COMMAND is set */
+ struct {
+ /* this holds address of array of uint32 for engine_cores */
+ __u64 engine_cores;
+
+ /* number of engine cores in engine_cores array */
+ __u32 num_engine_cores;
+
+ /* the core command to be sent towards engine cores */
+ __u32 core_command;
+ };
+ };
union {
/*
@@ -831,6 +1572,7 @@ struct hl_cs_in {
/* Context ID - Currently not in use */
__u32 ctx_id;
+ __u8 pad[4];
};
struct hl_cs_out {
@@ -843,7 +1585,7 @@ struct hl_cs_out {
/* Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set */
struct {
- /* This is the resereved signal handle id */
+ /* This is the reserved signal handle id */
__u32 handle_id;
/* This is the signals count */
@@ -856,9 +1598,17 @@ struct hl_cs_out {
/*
* SOB base address offset
- * Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY is set
+ * Valid only when HL_CS_FLAGS_RESERVE_SIGNALS_ONLY or HL_CS_FLAGS_SIGNAL is set
*/
__u32 sob_base_addr_offset;
+
+ /*
+ * Count of completed signals in SOB before current signal submission.
+ * Valid only when (HL_CS_FLAGS_ENCAP_SIGNALS & HL_CS_FLAGS_STAGED_SUBMISSION)
+ * or HL_CS_FLAGS_SIGNAL is set
+ */
+ __u16 sob_count_before_submission;
+ __u16 pad[3];
};
union hl_cs_args {
@@ -866,9 +1616,13 @@ union hl_cs_args {
struct hl_cs_out out;
};
-#define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
-#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
-#define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
+#define HL_WAIT_CS_FLAGS_INTERRUPT 0x2
+#define HL_WAIT_CS_FLAGS_INTERRUPT_MASK 0xFFF00000
+#define HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT 0xFFF00000
+#define HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT 0xFFE00000
+#define HL_WAIT_CS_FLAGS_MULTI_CS 0x4
+#define HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ 0x10
+#define HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT 0x20
#define HL_WAIT_MULTI_CS_LIST_MAX_LEN 32
@@ -888,14 +1642,23 @@ struct hl_wait_cs_in {
};
struct {
- /* User address for completion comparison.
- * upon interrupt, driver will compare the value pointed
- * by this address with the supplied target value.
- * in order not to perform any comparison, set address
- * to all 1s.
- * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
- */
- __u64 addr;
+ union {
+ /* User address for completion comparison.
+ * upon interrupt, driver will compare the value pointed
+ * by this address with the supplied target value.
+ * in order not to perform any comparison, set address
+ * to all 1s.
+ * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
+ */
+ __u64 addr;
+
+ /* cq_counters_handle to a kernel mapped cb which contains
+ * cq counters.
+ * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
+ */
+ __u64 cq_counters_handle;
+ };
+
/* Target value for completion comparison */
__u64 target;
};
@@ -906,19 +1669,51 @@ struct hl_wait_cs_in {
/* HL_WAIT_CS_FLAGS_*
* If HL_WAIT_CS_FLAGS_INTERRUPT is set, this field should include
- * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK, in order
- * not to specify an interrupt id ,set mask to all 1s.
+ * interrupt id according to HL_WAIT_CS_FLAGS_INTERRUPT_MASK
+ *
+ * in order to wait for any CQ interrupt, set interrupt value to
+ * HL_WAIT_CS_FLAGS_ANY_CQ_INTERRUPT.
+ *
+ * in order to wait for any decoder interrupt, set interrupt value to
+ * HL_WAIT_CS_FLAGS_ANY_DEC_INTERRUPT.
*/
__u32 flags;
- /* Multi CS API info- valid entries in multi-CS array */
- __u8 seq_arr_len;
- __u8 pad[3];
+ union {
+ struct {
+ /* Multi CS API info- valid entries in multi-CS array */
+ __u8 seq_arr_len;
+ __u8 pad[7];
+ };
- /* Absolute timeout to wait for an interrupt in microseconds.
- * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
+ /* Absolute timeout to wait for an interrupt in microseconds.
+ * Relevant only when HL_WAIT_CS_FLAGS_INTERRUPT is set
+ */
+ __u64 interrupt_timeout_us;
+ };
+
+ /*
+ * cq counter offset inside the counters cb pointed by cq_counters_handle above.
+ * upon interrupt, driver will compare the value pointed
+ * by this address (cq_counters_handle + cq_counters_offset)
+ * with the supplied target value.
+ * relevant only when HL_WAIT_CS_FLAGS_INTERRUPT_KERNEL_CQ is set
+ */
+ __u64 cq_counters_offset;
+
+ /*
+ * Timestamp_handle timestamps buffer handle.
+ * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
+ */
+ __u64 timestamp_handle;
+
+ /*
+ * Timestamp_offset is offset inside the timestamp buffer pointed by timestamp_handle above.
+ * upon interrupt, if the cq reached the target value then driver will write
+ * timestamp to this offset.
+ * relevant only when HL_WAIT_CS_FLAGS_REGISTER_INTERRUPT is set
*/
- __u32 interrupt_timeout_us;
+ __u64 timestamp_offset;
};
#define HL_WAIT_CS_STATUS_COMPLETED 0
@@ -952,113 +1747,147 @@ union hl_wait_cs_args {
/* Opcode to allocate device memory */
#define HL_MEM_OP_ALLOC 0
+
/* Opcode to free previously allocated device memory */
#define HL_MEM_OP_FREE 1
+
/* Opcode to map host and device memory */
#define HL_MEM_OP_MAP 2
+
/* Opcode to unmap previously mapped host and device memory */
#define HL_MEM_OP_UNMAP 3
+
/* Opcode to map a hw block */
#define HL_MEM_OP_MAP_BLOCK 4
+
/* Opcode to create DMA-BUF object for an existing device memory allocation
* and to export an FD of that DMA-BUF back to the caller
*/
#define HL_MEM_OP_EXPORT_DMABUF_FD 5
+/* Opcode to create timestamps pool for user interrupts registration support
+ * The memory will be allocated by the kernel driver, A timestamp buffer which the user
+ * will get handle to it for mmap, and another internal buffer used by the
+ * driver for registration management
+ * The memory will be freed when the user closes the file descriptor(ctx close)
+ */
+#define HL_MEM_OP_TS_ALLOC 6
+
/* Memory flags */
#define HL_MEM_CONTIGUOUS 0x1
#define HL_MEM_SHARED 0x2
#define HL_MEM_USERPTR 0x4
#define HL_MEM_FORCE_HINT 0x8
+#define HL_MEM_PREFETCH 0x40
+/**
+ * structure hl_mem_in - structure that handle input args for memory IOCTL
+ * @union arg: union of structures to be used based on the input operation
+ * @op: specify the requested memory operation (one of the HL_MEM_OP_* definitions).
+ * @flags: flags for the memory operation (one of the HL_MEM_* definitions).
+ * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the DMA-BUF file/FD flags.
+ * @ctx_id: context ID - currently not in use.
+ * @num_of_elements: number of timestamp elements used only with HL_MEM_OP_TS_ALLOC opcode.
+ */
struct hl_mem_in {
union {
- /* HL_MEM_OP_ALLOC- allocate device memory */
+ /**
+ * structure for device memory allocation (used with the HL_MEM_OP_ALLOC op)
+ * @mem_size: memory size to allocate
+ * @page_size: page size to use on allocation. when the value is 0 the default page
+ * size will be taken.
+ */
struct {
- /* Size to alloc */
__u64 mem_size;
+ __u64 page_size;
} alloc;
- /* HL_MEM_OP_FREE - free device memory */
+ /**
+ * structure for free-ing device memory (used with the HL_MEM_OP_FREE op)
+ * @handle: handle returned from HL_MEM_OP_ALLOC
+ */
struct {
- /* Handle returned from HL_MEM_OP_ALLOC */
__u64 handle;
} free;
- /* HL_MEM_OP_MAP - map device memory */
+ /**
+ * structure for mapping device memory (used with the HL_MEM_OP_MAP op)
+ * @hint_addr: requested virtual address of mapped memory.
+ * the driver will try to map the requested region to this hint
+ * address, as long as the address is valid and not already mapped.
+ * the user should check the returned address of the IOCTL to make
+ * sure he got the hint address.
+ * passing 0 here means that the driver will choose the address itself.
+ * @handle: handle returned from HL_MEM_OP_ALLOC.
+ */
struct {
- /*
- * Requested virtual address of mapped memory.
- * The driver will try to map the requested region to
- * this hint address, as long as the address is valid
- * and not already mapped. The user should check the
- * returned address of the IOCTL to make sure he got
- * the hint address. Passing 0 here means that the
- * driver will choose the address itself.
- */
__u64 hint_addr;
- /* Handle returned from HL_MEM_OP_ALLOC */
__u64 handle;
} map_device;
- /* HL_MEM_OP_MAP - map host memory */
+ /**
+ * structure for mapping host memory (used with the HL_MEM_OP_MAP op)
+ * @host_virt_addr: address of allocated host memory.
+ * @hint_addr: requested virtual address of mapped memory.
+ * the driver will try to map the requested region to this hint
+ * address, as long as the address is valid and not already mapped.
+ * the user should check the returned address of the IOCTL to make
+ * sure he got the hint address.
+ * passing 0 here means that the driver will choose the address itself.
+ * @size: size of allocated host memory.
+ */
struct {
- /* Address of allocated host memory */
__u64 host_virt_addr;
- /*
- * Requested virtual address of mapped memory.
- * The driver will try to map the requested region to
- * this hint address, as long as the address is valid
- * and not already mapped. The user should check the
- * returned address of the IOCTL to make sure he got
- * the hint address. Passing 0 here means that the
- * driver will choose the address itself.
- */
__u64 hint_addr;
- /* Size of allocated host memory */
__u64 mem_size;
} map_host;
- /* HL_MEM_OP_MAP_BLOCK - map a hw block */
+ /**
+ * structure for mapping hw block (used with the HL_MEM_OP_MAP_BLOCK op)
+ * @block_addr:HW block address to map, a handle and size will be returned
+ * to the user and will be used to mmap the relevant block.
+ * only addresses from configuration space are allowed.
+ */
struct {
- /*
- * HW block address to map, a handle and size will be
- * returned to the user and will be used to mmap the
- * relevant block. Only addresses from configuration
- * space are allowed.
- */
__u64 block_addr;
} map_block;
- /* HL_MEM_OP_UNMAP - unmap host memory */
+ /**
+ * structure for unmapping host memory (used with the HL_MEM_OP_UNMAP op)
+ * @device_virt_addr: virtual address returned from HL_MEM_OP_MAP
+ */
struct {
- /* Virtual address returned from HL_MEM_OP_MAP */
__u64 device_virt_addr;
} unmap;
- /* HL_MEM_OP_EXPORT_DMABUF_FD */
+ /**
+ * structure for exporting DMABUF object (used with
+ * the HL_MEM_OP_EXPORT_DMABUF_FD op)
+ * @addr: for Gaudi1, the driver expects a physical address
+ * inside the device's DRAM. this is because in Gaudi1
+ * we don't have MMU that covers the device's DRAM.
+ * for all other ASICs, the driver expects a device
+ * virtual address that represents the start address of
+ * a mapped DRAM memory area inside the device.
+ * the address must be the same as was received from the
+ * driver during a previous HL_MEM_OP_MAP operation.
+ * @mem_size: size of memory to export.
+ * @offset: for Gaudi1, this value must be 0. For all other ASICs,
+ * the driver expects an offset inside of the memory area
+ * describe by addr. the offset represents the start
+ * address of that the exported dma-buf object describes.
+ */
struct {
- /* Handle returned from HL_MEM_OP_ALLOC. In Gaudi,
- * where we don't have MMU for the device memory, the
- * driver expects a physical address (instead of
- * a handle) in the device memory space.
- */
- __u64 handle;
- /* Size of memory allocation. Relevant only for GAUDI */
+ __u64 addr;
__u64 mem_size;
+ __u64 offset;
} export_dmabuf_fd;
};
- /* HL_MEM_OP_* */
__u32 op;
- /* HL_MEM_* flags.
- * For the HL_MEM_OP_EXPORT_DMABUF_FD opcode, this field holds the
- * DMA-BUF file/FD flags.
- */
__u32 flags;
- /* Context ID - Currently not in use */
__u32 ctx_id;
- __u32 pad;
+ __u32 num_of_elements;
};
struct hl_mem_out {
@@ -1158,7 +1987,16 @@ struct hl_debug_params_bmon {
/* Trace source ID */
__u32 id;
- __u32 pad;
+
+ /* Control register */
+ __u32 control;
+
+ /* Two more address ranges that the user can request to filter */
+ __u64 start_addr2;
+ __u64 end_addr2;
+
+ __u64 start_addr3;
+ __u64 end_addr3;
};
struct hl_debug_params_spmu {
@@ -1167,7 +2005,11 @@ struct hl_debug_params_spmu {
/* Number of event types selection */
__u32 event_types_num;
- __u32 pad;
+
+ /* TRC configuration register values */
+ __u32 pmtrc_val;
+ __u32 trc_ctrl_host_val;
+ __u32 trc_en_host_val;
};
/* Opcode for ETR component */
@@ -1267,16 +2109,23 @@ struct hl_debug_args {
* (or if its the first CS for this context). The user can also order the
* driver to run the "restore" phase explicitly
*
+ * Goya/Gaudi:
* There are two types of queues - external and internal. External queues
* are DMA queues which transfer data from/to the Host. All other queues are
* internal. The driver will get completion notifications from the device only
* on JOBS which are enqueued in the external queues.
*
+ * Greco onwards:
+ * There is a single type of queue for all types of engines, either DMA engines
+ * for transfers from/to the host or inside the device, or compute engines.
+ * The driver will get completion notifications from the device for all queues.
+ *
* For jobs on external queues, the user needs to create command buffers
* through the CB ioctl and give the CB's handle to the CS ioctl. For jobs on
* internal queues, the user needs to prepare a "command buffer" with packets
* on either the device SRAM/DRAM or the host, and give the device address of
* that buffer to the CS ioctl.
+ * For jobs on H/W queues both options of command buffers are valid.
*
* This IOCTL is asynchronous in regard to the actual execution of the CS. This
* means it returns immediately after ALL the JOBS were enqueued on their
@@ -1285,7 +2134,7 @@ struct hl_debug_args {
*
* Upon successful enqueue, the IOCTL returns a sequence number which the user
* can use with the "Wait for CS" IOCTL to check whether the handle's CS
- * external JOBS have been completed. Note that if the CS has internal JOBS
+ * non-internal JOBS have been completed. Note that if the CS has internal JOBS
* which can execute AFTER the external JOBS have finished, the driver might
* report that the CS has finished executing BEFORE the internal JOBS have
* actually finished executing.
diff --git a/lib/libc/include/any-linux-any/drm/i810_drm.h b/lib/libc/include/any-linux-any/drm/i810_drm.h
deleted file mode 100644
index a4d0486684..0000000000
--- a/lib/libc/include/any-linux-any/drm/i810_drm.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _I810_DRM_H_
-#define _I810_DRM_H_
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* WARNING: These defines must be the same as what the Xserver uses.
- * if you change them, you must change the defines in the Xserver.
- */
-
-#ifndef _I810_DEFINES_
-#define _I810_DEFINES_
-
-#define I810_DMA_BUF_ORDER 12
-#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
-#define I810_DMA_BUF_NR 256
-#define I810_NR_SAREA_CLIPRECTS 8
-
-/* Each region is a minimum of 64k, and there are at most 64 of them.
- */
-#define I810_NR_TEX_REGIONS 64
-#define I810_LOG_MIN_TEX_REGION_SIZE 16
-#endif
-
-#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
-#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
-#define I810_UPLOAD_CTX 0x4
-#define I810_UPLOAD_BUFFERS 0x8
-#define I810_UPLOAD_TEX0 0x10
-#define I810_UPLOAD_TEX1 0x20
-#define I810_UPLOAD_CLIPRECTS 0x40
-
-/* Indices into buf.Setup where various bits of state are mirrored per
- * context and per buffer. These can be fired at the card as a unit,
- * or in a piecewise fashion as required.
- */
-
-/* Destbuffer state
- * - backbuffer linear offset and pitch -- invarient in the current dri
- * - zbuffer linear offset and pitch -- also invarient
- * - drawing origin in back and depth buffers.
- *
- * Keep the depth/back buffer state here to accommodate private buffers
- * in the future.
- */
-#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
-#define I810_DESTREG_DI1 1
-#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
-#define I810_DESTREG_DV1 3
-#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
-#define I810_DESTREG_DR1 5
-#define I810_DESTREG_DR2 6
-#define I810_DESTREG_DR3 7
-#define I810_DESTREG_DR4 8
-#define I810_DEST_SETUP_SIZE 10
-
-/* Context state
- */
-#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
-#define I810_CTXREG_CF1 1
-#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
-#define I810_CTXREG_ST1 3
-#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
-#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
-#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
-#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
-#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
-#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
-#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
-#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
-#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
-#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
-#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
-#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
-#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
-#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
-#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
-#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
-#define I810_CTX_SETUP_SIZE 20
-
-/* Texture state (per tex unit)
- */
-#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
-#define I810_TEXREG_MI1 1
-#define I810_TEXREG_MI2 2
-#define I810_TEXREG_MI3 3
-#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
-#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
-#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
-#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
-#define I810_TEX_SETUP_SIZE 8
-
-/* Flags for clear ioctl
- */
-#define I810_FRONT 0x1
-#define I810_BACK 0x2
-#define I810_DEPTH 0x4
-
-typedef enum _drm_i810_init_func {
- I810_INIT_DMA = 0x01,
- I810_CLEANUP_DMA = 0x02,
- I810_INIT_DMA_1_4 = 0x03
-} drm_i810_init_func_t;
-
-/* This is the init structure after v1.2 */
-typedef struct _drm_i810_init {
- drm_i810_init_func_t func;
- unsigned int mmio_offset;
- unsigned int buffers_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int overlay_offset;
- unsigned int overlay_physical;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
-} drm_i810_init_t;
-
-/* This is the init structure prior to v1.2 */
-typedef struct _drm_i810_pre12_init {
- drm_i810_init_func_t func;
- unsigned int mmio_offset;
- unsigned int buffers_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
-} drm_i810_pre12_init_t;
-
-/* Warning: If you change the SAREA structure you must change the Xserver
- * structure as well */
-
-typedef struct _drm_i810_tex_region {
- unsigned char next, prev; /* indices to form a circular LRU */
- unsigned char in_use; /* owned by a client, or free? */
- int age; /* tracked by clients to update local LRU's */
-} drm_i810_tex_region_t;
-
-typedef struct _drm_i810_sarea {
- unsigned int ContextState[I810_CTX_SETUP_SIZE];
- unsigned int BufferState[I810_DEST_SETUP_SIZE];
- unsigned int TexState[2][I810_TEX_SETUP_SIZE];
- unsigned int dirty;
-
- unsigned int nbox;
- struct drm_clip_rect boxes[I810_NR_SAREA_CLIPRECTS];
-
- /* Maintain an LRU of contiguous regions of texture space. If
- * you think you own a region of texture memory, and it has an
- * age different to the one you set, then you are mistaken and
- * it has been stolen by another client. If global texAge
- * hasn't changed, there is no need to walk the list.
- *
- * These regions can be used as a proxy for the fine-grained
- * texture information of other clients - by maintaining them
- * in the same lru which is used to age their own textures,
- * clients have an approximate lru for the whole of global
- * texture space, and can make informed decisions as to which
- * areas to kick out. There is no need to choose whether to
- * kick out your own texture or someone else's - simply eject
- * them all in LRU order.
- */
-
- drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS + 1];
- /* Last elt is sentinal */
- int texAge; /* last time texture was uploaded */
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int last_quiescent; /* */
- int ctxOwner; /* last context to upload state */
-
- int vertex_prim;
-
- int pf_enabled; /* is pageflipping allowed? */
- int pf_active;
- int pf_current_page; /* which buffer is being displayed? */
-} drm_i810_sarea_t;
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (xf86drmMga.h)
- */
-
-/* i810 specific ioctls
- * The device specific ioctl range is 0x40 to 0x79.
- */
-#define DRM_I810_INIT 0x00
-#define DRM_I810_VERTEX 0x01
-#define DRM_I810_CLEAR 0x02
-#define DRM_I810_FLUSH 0x03
-#define DRM_I810_GETAGE 0x04
-#define DRM_I810_GETBUF 0x05
-#define DRM_I810_SWAP 0x06
-#define DRM_I810_COPY 0x07
-#define DRM_I810_DOCOPY 0x08
-#define DRM_I810_OV0INFO 0x09
-#define DRM_I810_FSTATUS 0x0a
-#define DRM_I810_OV0FLIP 0x0b
-#define DRM_I810_MC 0x0c
-#define DRM_I810_RSTATUS 0x0d
-#define DRM_I810_FLIP 0x0e
-
-#define DRM_IOCTL_I810_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t)
-#define DRM_IOCTL_I810_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t)
-#define DRM_IOCTL_I810_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t)
-#define DRM_IOCTL_I810_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_I810_FLUSH)
-#define DRM_IOCTL_I810_GETAGE DRM_IO( DRM_COMMAND_BASE + DRM_I810_GETAGE)
-#define DRM_IOCTL_I810_GETBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t)
-#define DRM_IOCTL_I810_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_I810_SWAP)
-#define DRM_IOCTL_I810_COPY DRM_IOW( DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t)
-#define DRM_IOCTL_I810_DOCOPY DRM_IO( DRM_COMMAND_BASE + DRM_I810_DOCOPY)
-#define DRM_IOCTL_I810_OV0INFO DRM_IOR( DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t)
-#define DRM_IOCTL_I810_FSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FSTATUS)
-#define DRM_IOCTL_I810_OV0FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_OV0FLIP)
-#define DRM_IOCTL_I810_MC DRM_IOW( DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t)
-#define DRM_IOCTL_I810_RSTATUS DRM_IO ( DRM_COMMAND_BASE + DRM_I810_RSTATUS)
-#define DRM_IOCTL_I810_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FLIP)
-
-typedef struct _drm_i810_clear {
- int clear_color;
- int clear_depth;
- int flags;
-} drm_i810_clear_t;
-
-/* These may be placeholders if we have more cliprects than
- * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
- * false, indicating that the buffer will be dispatched again with a
- * new set of cliprects.
- */
-typedef struct _drm_i810_vertex {
- int idx; /* buffer index */
- int used; /* nr bytes in use */
- int discard; /* client is finished with the buffer? */
-} drm_i810_vertex_t;
-
-typedef struct _drm_i810_copy_t {
- int idx; /* buffer index */
- int used; /* nr bytes in use */
- void *address; /* Address to copy from */
-} drm_i810_copy_t;
-
-#define PR_TRIANGLES (0x0<<18)
-#define PR_TRISTRIP_0 (0x1<<18)
-#define PR_TRISTRIP_1 (0x2<<18)
-#define PR_TRIFAN (0x3<<18)
-#define PR_POLYGON (0x4<<18)
-#define PR_LINES (0x5<<18)
-#define PR_LINESTRIP (0x6<<18)
-#define PR_RECTS (0x7<<18)
-#define PR_MASK (0x7<<18)
-
-typedef struct drm_i810_dma {
- void *virtual;
- int request_idx;
- int request_size;
- int granted;
-} drm_i810_dma_t;
-
-typedef struct _drm_i810_overlay_t {
- unsigned int offset; /* Address of the Overlay Regs */
- unsigned int physical;
-} drm_i810_overlay_t;
-
-typedef struct _drm_i810_mc {
- int idx; /* buffer index */
- int used; /* nr bytes in use */
- int num_blocks; /* number of GFXBlocks */
- int *length; /* List of lengths for GFXBlocks (FUTURE) */
- unsigned int last_render; /* Last Render Request */
-} drm_i810_mc_t;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* _I810_DRM_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/i915_drm.h b/lib/libc/include/any-linux-any/drm/i915_drm.h
index bee505d473..c220b4fcd3 100644
--- a/lib/libc/include/any-linux-any/drm/i915_drm.h
+++ b/lib/libc/include/any-linux-any/drm/i915_drm.h
@@ -154,25 +154,77 @@ enum i915_mocs_table_index {
I915_MOCS_CACHED,
};
-/*
+/**
+ * enum drm_i915_gem_engine_class - uapi engine type enumeration
+ *
* Different engines serve different roles, and there may be more than one
- * engine serving each role. enum drm_i915_gem_engine_class provides a
- * classification of the role of the engine, which may be used when requesting
- * operations to be performed on a certain subset of engines, or for providing
- * information about that group.
+ * engine serving each role. This enum provides a classification of the role
+ * of the engine, which may be used when requesting operations to be performed
+ * on a certain subset of engines, or for providing information about that
+ * group.
*/
enum drm_i915_gem_engine_class {
+ /**
+ * @I915_ENGINE_CLASS_RENDER:
+ *
+ * Render engines support instructions used for 3D, Compute (GPGPU),
+ * and programmable media workloads. These instructions fetch data and
+ * dispatch individual work items to threads that operate in parallel.
+ * The threads run small programs (called "kernels" or "shaders") on
+ * the GPU's execution units (EUs).
+ */
I915_ENGINE_CLASS_RENDER = 0,
+
+ /**
+ * @I915_ENGINE_CLASS_COPY:
+ *
+ * Copy engines (also referred to as "blitters") support instructions
+ * that move blocks of data from one location in memory to another,
+ * or that fill a specified location of memory with fixed data.
+ * Copy engines can perform pre-defined logical or bitwise operations
+ * on the source, destination, or pattern data.
+ */
I915_ENGINE_CLASS_COPY = 1,
+
+ /**
+ * @I915_ENGINE_CLASS_VIDEO:
+ *
+ * Video engines (also referred to as "bit stream decode" (BSD) or
+ * "vdbox") support instructions that perform fixed-function media
+ * decode and encode.
+ */
I915_ENGINE_CLASS_VIDEO = 2,
+
+ /**
+ * @I915_ENGINE_CLASS_VIDEO_ENHANCE:
+ *
+ * Video enhancement engines (also referred to as "vebox") support
+ * instructions related to image enhancement.
+ */
I915_ENGINE_CLASS_VIDEO_ENHANCE = 3,
- /* should be kept compact */
+ /**
+ * @I915_ENGINE_CLASS_COMPUTE:
+ *
+ * Compute engines support a subset of the instructions available
+ * on render engines: compute engines support Compute (GPGPU) and
+ * programmable media workloads, but do not support the 3D pipeline.
+ */
+ I915_ENGINE_CLASS_COMPUTE = 4,
+ /* Values in this enum should be kept compact. */
+
+ /**
+ * @I915_ENGINE_CLASS_INVALID:
+ *
+ * Placeholder value to represent an invalid engine class assignment.
+ */
I915_ENGINE_CLASS_INVALID = -1
};
-/*
+/**
+ * struct i915_engine_class_instance - Engine class/instance identifier
+ *
* There may be more than one engine fulfilling any role within the system.
* Each engine of a class is given a unique instance number and therefore
* any engine can be specified by its class:instance tuplet. APIs that allow
@@ -180,10 +232,21 @@ enum drm_i915_gem_engine_class {
* for this identification.
*/
struct i915_engine_class_instance {
- __u16 engine_class; /* see enum drm_i915_gem_engine_class */
- __u16 engine_instance;
+ /**
+ * @engine_class:
+ *
+ * Engine class from enum drm_i915_gem_engine_class
+ */
+ __u16 engine_class;
#define I915_ENGINE_CLASS_INVALID_NONE -1
#define I915_ENGINE_CLASS_INVALID_VIRTUAL -2
+
+ /**
+ * @engine_instance:
+ *
+ * Engine instance.
+ */
+ __u16 engine_instance;
};
/**
@@ -582,6 +645,22 @@ typedef struct drm_i915_irq_wait {
*/
#define I915_SCHEDULER_CAP_STATIC_PRIORITY_MAP (1ul << 5)
+/*
+ * Query the status of HuC load.
+ *
+ * The query can fail in the following scenarios with the listed error codes:
+ * -ENODEV if HuC is not present on this platform,
+ * -EOPNOTSUPP if HuC firmware usage is disabled,
+ * -ENOPKG if HuC firmware fetch failed,
+ * -ENOEXEC if HuC firmware is invalid or mismatched,
+ * -ENOMEM if i915 failed to prepare the FW objects for transfer to the uC,
+ * -EIO if the FW transfer or the FW authentication failed.
+ *
+ * If the IOCTL is successful, the returned parameter will be set to one of the
+ * following values:
+ * * 0 if HuC firmware load is not complete,
+ * * 1 if HuC firmware is authenticated and running.
+ */
#define I915_PARAM_HUC_STATUS 42
/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
@@ -686,16 +765,35 @@ typedef struct drm_i915_irq_wait {
/* Query if the kernel supports the I915_USERPTR_PROBE flag. */
#define I915_PARAM_HAS_USERPTR_PROBE 56
+/*
+ * Frequency of the timestamps in OA reports. This used to be the same as the CS
+ * timestamp frequency, but differs on some platforms.
+ */
+#define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57
+
/* Must be kept compact -- no holes and well documented */
-typedef struct drm_i915_getparam {
+/**
+ * struct drm_i915_getparam - Driver parameter query structure.
+ */
+struct drm_i915_getparam {
+ /** @param: Driver parameter to query. */
__s32 param;
- /*
+
+ /**
+ * @value: Address of memory where queried value should be put.
+ *
* WARNING: Using pointers instead of fixed-size u64 means we need to write
* compat32 code. Don't repeat this mistake.
*/
int *value;
-} drm_i915_getparam_t;
+};
+
+/**
+ * typedef drm_i915_getparam_t - Driver parameter query structure.
+ * See struct drm_i915_getparam.
+ */
+typedef struct drm_i915_getparam drm_i915_getparam_t;
/* Ioctl to set kernel params:
*/
@@ -1118,10 +1216,16 @@ struct drm_i915_gem_exec_object2 {
/**
* When the EXEC_OBJECT_PINNED flag is specified this is populated by
* the user with the GTT offset at which this object will be pinned.
+ *
* When the I915_EXEC_NO_RELOC flag is specified this must contain the
* presumed_offset of the object.
+ *
* During execbuffer2 the kernel populates it with the value of the
* current GTT offset of the object, for future presumed_offset writes.
+ *
+ * See struct drm_i915_gem_create_ext for the rules when dealing with
+ * alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with
+ * minimum page sizes, like DG2.
*/
__u64 offset;
@@ -1170,76 +1274,119 @@ struct drm_i915_gem_exec_object2 {
__u64 rsvd2;
};
+/**
+ * struct drm_i915_gem_exec_fence - An input or output fence for the execbuf
+ * ioctl.
+ *
+ * The request will wait for input fence to signal before submission.
+ *
+ * The returned output fence will be signaled after the completion of the
+ * request.
+ */
struct drm_i915_gem_exec_fence {
- /**
- * User's handle for a drm_syncobj to wait on or signal.
- */
+ /** @handle: User's handle for a drm_syncobj to wait on or signal. */
__u32 handle;
+ /**
+ * @flags: Supported flags are:
+ *
+ * I915_EXEC_FENCE_WAIT:
+ * Wait for the input fence before request submission.
+ *
+ * I915_EXEC_FENCE_SIGNAL:
+ * Return request completion fence as output
+ */
+ __u32 flags;
#define I915_EXEC_FENCE_WAIT (1<<0)
#define I915_EXEC_FENCE_SIGNAL (1<<1)
#define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1))
- __u32 flags;
};
-/*
- * See drm_i915_gem_execbuffer_ext_timeline_fences.
- */
-#define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0
-
-/*
+/**
+ * struct drm_i915_gem_execbuffer_ext_timeline_fences - Timeline fences
+ * for execbuf ioctl.
+ *
* This structure describes an array of drm_syncobj and associated points for
* timeline variants of drm_syncobj. It is invalid to append this structure to
* the execbuf if I915_EXEC_FENCE_ARRAY is set.
*/
struct drm_i915_gem_execbuffer_ext_timeline_fences {
+#define DRM_I915_GEM_EXECBUFFER_EXT_TIMELINE_FENCES 0
+ /** @base: Extension link. See struct i915_user_extension. */
struct i915_user_extension base;
/**
- * Number of element in the handles_ptr & value_ptr arrays.
+ * @fence_count: Number of elements in the @handles_ptr & @value_ptr
+ * arrays.
*/
__u64 fence_count;
/**
- * Pointer to an array of struct drm_i915_gem_exec_fence of length
- * fence_count.
+ * @handles_ptr: Pointer to an array of struct drm_i915_gem_exec_fence
+ * of length @fence_count.
*/
__u64 handles_ptr;
/**
- * Pointer to an array of u64 values of length fence_count. Values
- * must be 0 for a binary drm_syncobj. A Value of 0 for a timeline
- * drm_syncobj is invalid as it turns a drm_syncobj into a binary one.
+ * @values_ptr: Pointer to an array of u64 values of length
+ * @fence_count.
+ * Values must be 0 for a binary drm_syncobj. A Value of 0 for a
+ * timeline drm_syncobj is invalid as it turns a drm_syncobj into a
+ * binary one.
*/
__u64 values_ptr;
};
+/**
+ * struct drm_i915_gem_execbuffer2 - Structure for DRM_I915_GEM_EXECBUFFER2
+ * ioctl.
+ */
struct drm_i915_gem_execbuffer2 {
- /**
- * List of gem_exec_object2 structs
- */
+ /** @buffers_ptr: Pointer to a list of gem_exec_object2 structs */
__u64 buffers_ptr;
+
+ /** @buffer_count: Number of elements in @buffers_ptr array */
__u32 buffer_count;
- /** Offset in the batchbuffer to start execution from. */
+ /**
+ * @batch_start_offset: Offset in the batchbuffer to start execution
+ * from.
+ */
__u32 batch_start_offset;
- /** Bytes used in batchbuffer from batch_start_offset */
+
+ /**
+ * @batch_len: Length in bytes of the batch buffer, starting from the
+ * @batch_start_offset. If 0, length is assumed to be the batch buffer
+ * object size.
+ */
__u32 batch_len;
+
+ /** @DR1: deprecated */
__u32 DR1;
+
+ /** @DR4: deprecated */
__u32 DR4;
+
+ /** @num_cliprects: See @cliprects_ptr */
__u32 num_cliprects;
+
/**
- * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
- * & I915_EXEC_USE_EXTENSIONS are not set.
+ * @cliprects_ptr: Kernel clipping was a DRI1 misfeature.
+ *
+ * It is invalid to use this field if I915_EXEC_FENCE_ARRAY or
+ * I915_EXEC_USE_EXTENSIONS flags are not set.
*
* If I915_EXEC_FENCE_ARRAY is set, then this is a pointer to an array
- * of struct drm_i915_gem_exec_fence and num_cliprects is the length
- * of the array.
+ * of &drm_i915_gem_exec_fence and @num_cliprects is the length of the
+ * array.
*
* If I915_EXEC_USE_EXTENSIONS is set, then this is a pointer to a
- * single struct i915_user_extension and num_cliprects is 0.
+ * single &i915_user_extension and num_cliprects is 0.
*/
__u64 cliprects_ptr;
+
+ /** @flags: Execbuf flags */
+ __u64 flags;
#define I915_EXEC_RING_MASK (0x3f)
#define I915_EXEC_DEFAULT (0<<0)
#define I915_EXEC_RENDER (1<<0)
@@ -1257,10 +1404,6 @@ struct drm_i915_gem_execbuffer2 {
#define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
#define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
#define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
- __u64 flags;
- __u64 rsvd1; /* now used for context info */
- __u64 rsvd2;
-};
/** Resets the SO write offset registers for transform feedback on gen7. */
#define I915_EXEC_GEN7_SOL_RESET (1<<8)
@@ -1363,9 +1506,23 @@ struct drm_i915_gem_execbuffer2 {
* drm_i915_gem_execbuffer_ext enum.
*/
#define I915_EXEC_USE_EXTENSIONS (1 << 21)
-
#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_USE_EXTENSIONS << 1))
+ /** @rsvd1: Context id */
+ __u64 rsvd1;
+
+ /**
+ * @rsvd2: in and out sync_file file descriptors.
+ *
+ * When I915_EXEC_FENCE_IN or I915_EXEC_FENCE_SUBMIT flag is set, the
+ * lower 32 bits of this field will have the in sync_file fd (input).
+ *
+ * When I915_EXEC_FENCE_OUT flag is set, the upper 32 bits of this
+ * field will have the out sync_file fd (output).
+ */
+ __u64 rsvd2;
+};
+
#define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
#define i915_execbuffer2_set_context_id(eb2, context) \
(eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
@@ -1745,19 +1902,58 @@ struct drm_i915_gem_context_create {
__u32 pad;
};
+/**
+ * struct drm_i915_gem_context_create_ext - Structure for creating contexts.
+ */
struct drm_i915_gem_context_create_ext {
- __u32 ctx_id; /* output: id of new context*/
+ /** @ctx_id: Id of the created context (output) */
+ __u32 ctx_id;
+
+ /**
+ * @flags: Supported flags are:
+ *
+ * I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS:
+ *
+ * Extensions may be appended to this structure and driver must check
+ * for those. See @extensions.
+ *
+ * I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE
+ *
+ * Created context will have single timeline.
+ */
__u32 flags;
#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS (1u << 0)
#define I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE (1u << 1)
#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \
(-(I915_CONTEXT_CREATE_FLAGS_SINGLE_TIMELINE << 1))
+
+ /**
+ * @extensions: Zero-terminated chain of extensions.
+ *
+ * I915_CONTEXT_CREATE_EXT_SETPARAM:
+ * Context parameter to set or query during context creation.
+ * See struct drm_i915_gem_context_create_ext_setparam.
+ *
+ * I915_CONTEXT_CREATE_EXT_CLONE:
+ * This extension has been removed. On the off chance someone somewhere
+ * has attempted to use it, never re-use this extension number.
+ */
__u64 extensions;
+#define I915_CONTEXT_CREATE_EXT_SETPARAM 0
+#define I915_CONTEXT_CREATE_EXT_CLONE 1
};
+/**
+ * struct drm_i915_gem_context_param - Context parameter to set or query.
+ */
struct drm_i915_gem_context_param {
+ /** @ctx_id: Context id */
__u32 ctx_id;
+
+ /** @size: Size of the parameter @value */
__u32 size;
+
+ /** @param: Parameter to set or query */
__u64 param;
#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
/* I915_CONTEXT_PARAM_NO_ZEROMAP has been removed. On the off chance
@@ -1904,6 +2100,7 @@ struct drm_i915_gem_context_param {
#define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd
/* Must be kept compact -- no holes and well documented */
+ /** @value: Context parameter value to be set or queried */
__u64 value;
};
@@ -2054,7 +2251,7 @@ struct i915_context_engines_load_balance {
__u64 mbz64; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_LOAD_BALANCE(name__, N__) struct { \
@@ -2092,7 +2289,7 @@ struct i915_context_engines_bond {
__u64 flags; /* all undefined flags must be zero */
__u64 mbz64[4]; /* reserved for future use; must be zero */
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
#define I915_DEFINE_CONTEXT_ENGINES_BOND(name__, N__) struct { \
@@ -2219,7 +2416,7 @@ struct i915_context_engines_parallel_submit {
* length = width (i) * num_siblings (j)
* index = j + i * num_siblings
*/
- struct i915_engine_class_instance engines[0];
+ struct i915_engine_class_instance engines[];
} __attribute__((packed));
@@ -2302,23 +2499,29 @@ struct i915_context_param_engines {
struct i915_engine_class_instance engines[N__]; \
} __attribute__((packed)) name__
+/**
+ * struct drm_i915_gem_context_create_ext_setparam - Context parameter
+ * to set or query during context creation.
+ */
struct drm_i915_gem_context_create_ext_setparam {
-#define I915_CONTEXT_CREATE_EXT_SETPARAM 0
+ /** @base: Extension link. See struct i915_user_extension. */
struct i915_user_extension base;
+
+ /**
+ * @param: Context parameter to set or query.
+ * See struct drm_i915_gem_context_param.
+ */
struct drm_i915_gem_context_param param;
};
-/* This API has been removed. On the off chance someone somewhere has
- * attempted to use it, never re-use this extension number.
- */
-#define I915_CONTEXT_CREATE_EXT_CLONE 1
-
struct drm_i915_gem_context_destroy {
__u32 ctx_id;
__u32 pad;
};
-/*
+/**
+ * struct drm_i915_gem_vm_control - Structure to create or destroy VM.
+ *
* DRM_I915_GEM_VM_CREATE -
*
* Create a new virtual memory address space (ppGTT) for use within a context
@@ -2328,20 +2531,23 @@ struct drm_i915_gem_context_destroy {
* The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is
* returned in the outparam @id.
*
- * No flags are defined, with all bits reserved and must be zero.
- *
* An extension chain maybe provided, starting with @extensions, and terminated
* by the @next_extension being 0. Currently, no extensions are defined.
*
* DRM_I915_GEM_VM_DESTROY -
*
- * Destroys a previously created VM id, specified in @id.
+ * Destroys a previously created VM id, specified in @vm_id.
*
* No extensions or flags are allowed currently, and so must be zero.
*/
struct drm_i915_gem_vm_control {
+ /** @extensions: Zero-terminated chain of extensions. */
__u64 extensions;
+
+ /** @flags: reserved for future usage, currently MBZ */
__u32 flags;
+
+ /** @vm_id: Id of the VM created or to be destroyed */
__u32 vm_id;
};
@@ -2466,6 +2672,10 @@ enum drm_i915_oa_format {
I915_OA_FORMAT_A12_B8_C8,
I915_OA_FORMAT_A32u40_A4u32_B8_C8,
+ /* DG2 */
+ I915_OAR_FORMAT_A32u40_A4u32_B8_C8,
+ I915_OA_FORMAT_A24u40_A14u32_B8_C8,
+
I915_OA_FORMAT_MAX /* non-ABI */
};
@@ -2651,24 +2861,65 @@ enum drm_i915_perf_record_type {
DRM_I915_PERF_RECORD_MAX /* non-ABI */
};
-/*
+/**
+ * struct drm_i915_perf_oa_config
+ *
* Structure to upload perf dynamic configuration into the kernel.
*/
struct drm_i915_perf_oa_config {
- /** String formatted like "%08x-%04x-%04x-%04x-%012x" */
+ /**
+ * @uuid:
+ *
+ * String formatted like "%\08x-%\04x-%\04x-%\04x-%\012x"
+ */
char uuid[36];
+ /**
+ * @n_mux_regs:
+ *
+ * Number of mux regs in &mux_regs_ptr.
+ */
__u32 n_mux_regs;
+
+ /**
+ * @n_boolean_regs:
+ *
+ * Number of boolean regs in &boolean_regs_ptr.
+ */
__u32 n_boolean_regs;
+
+ /**
+ * @n_flex_regs:
+ *
+ * Number of flex regs in &flex_regs_ptr.
+ */
__u32 n_flex_regs;
- /*
- * These fields are pointers to tuples of u32 values (register address,
- * value). For example the expected length of the buffer pointed by
- * mux_regs_ptr is (2 * sizeof(u32) * n_mux_regs).
+ /**
+ * @mux_regs_ptr:
+ *
+ * Pointer to tuples of u32 values (register address, value) for mux
+ * registers. Expected length of buffer is (2 * sizeof(u32) *
+ * &n_mux_regs).
*/
__u64 mux_regs_ptr;
+
+ /**
+ * @boolean_regs_ptr:
+ *
+ * Pointer to tuples of u32 values (register address, value) for mux
+ * registers. Expected length of buffer is (2 * sizeof(u32) *
+ * &n_boolean_regs).
+ */
__u64 boolean_regs_ptr;
+
+ /**
+ * @flex_regs_ptr:
+ *
+ * Pointer to tuples of u32 values (register address, value) for mux
+ * registers. Expected length of buffer is (2 * sizeof(u32) *
+ * &n_flex_regs).
+ */
__u64 flex_regs_ptr;
};
@@ -2679,12 +2930,24 @@ struct drm_i915_perf_oa_config {
* @data_ptr is also depends on the specific @query_id.
*/
struct drm_i915_query_item {
- /** @query_id: The id for this query */
+ /**
+ * @query_id:
+ *
+ * The id for this query. Currently accepted query IDs are:
+ * - %DRM_I915_QUERY_TOPOLOGY_INFO (see struct drm_i915_query_topology_info)
+ * - %DRM_I915_QUERY_ENGINE_INFO (see struct drm_i915_engine_info)
+ * - %DRM_I915_QUERY_PERF_CONFIG (see struct drm_i915_query_perf_config)
+ * - %DRM_I915_QUERY_MEMORY_REGIONS (see struct drm_i915_query_memory_regions)
+ * - %DRM_I915_QUERY_HWCONFIG_BLOB (see `GuC HWCONFIG blob uAPI`)
+ * - %DRM_I915_QUERY_GEOMETRY_SUBSLICES (see struct drm_i915_query_topology_info)
+ */
__u64 query_id;
-#define DRM_I915_QUERY_TOPOLOGY_INFO 1
-#define DRM_I915_QUERY_ENGINE_INFO 2
-#define DRM_I915_QUERY_PERF_CONFIG 3
-#define DRM_I915_QUERY_MEMORY_REGIONS 4
+#define DRM_I915_QUERY_TOPOLOGY_INFO 1
+#define DRM_I915_QUERY_ENGINE_INFO 2
+#define DRM_I915_QUERY_PERF_CONFIG 3
+#define DRM_I915_QUERY_MEMORY_REGIONS 4
+#define DRM_I915_QUERY_HWCONFIG_BLOB 5
+#define DRM_I915_QUERY_GEOMETRY_SUBSLICES 6
/* Must be kept compact -- no holes and well documented */
/**
@@ -2700,14 +2963,17 @@ struct drm_i915_query_item {
/**
* @flags:
*
- * When query_id == DRM_I915_QUERY_TOPOLOGY_INFO, must be 0.
+ * When &query_id == %DRM_I915_QUERY_TOPOLOGY_INFO, must be 0.
*
- * When query_id == DRM_I915_QUERY_PERF_CONFIG, must be one of the
+ * When &query_id == %DRM_I915_QUERY_PERF_CONFIG, must be one of the
* following:
*
- * - DRM_I915_QUERY_PERF_CONFIG_LIST
- * - DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID
- * - DRM_I915_QUERY_PERF_CONFIG_FOR_UUID
+ * - %DRM_I915_QUERY_PERF_CONFIG_LIST
+ * - %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID
+ * - %DRM_I915_QUERY_PERF_CONFIG_FOR_UUID
+ *
+ * When &query_id == %DRM_I915_QUERY_GEOMETRY_SUBSLICES must contain
+ * a struct i915_engine_class_instance that references a render engine.
*/
__u32 flags;
#define DRM_I915_QUERY_PERF_CONFIG_LIST 1
@@ -2765,66 +3031,112 @@ struct drm_i915_query {
__u64 items_ptr;
};
-/*
- * Data written by the kernel with query DRM_I915_QUERY_TOPOLOGY_INFO :
- *
- * data: contains the 3 pieces of information :
- *
- * - the slice mask with one bit per slice telling whether a slice is
- * available. The availability of slice X can be queried with the following
- * formula :
- *
- * (data[X / 8] >> (X % 8)) & 1
- *
- * - the subslice mask for each slice with one bit per subslice telling
- * whether a subslice is available. Gen12 has dual-subslices, which are
- * similar to two gen11 subslices. For gen12, this array represents dual-
- * subslices. The availability of subslice Y in slice X can be queried
- * with the following formula :
- *
- * (data[subslice_offset +
- * X * subslice_stride +
- * Y / 8] >> (Y % 8)) & 1
- *
- * - the EU mask for each subslice in each slice with one bit per EU telling
- * whether an EU is available. The availability of EU Z in subslice Y in
- * slice X can be queried with the following formula :
+/**
+ * struct drm_i915_query_topology_info
*
- * (data[eu_offset +
- * (X * max_subslices + Y) * eu_stride +
- * Z / 8] >> (Z % 8)) & 1
+ * Describes slice/subslice/EU information queried by
+ * %DRM_I915_QUERY_TOPOLOGY_INFO
*/
struct drm_i915_query_topology_info {
- /*
+ /**
+ * @flags:
+ *
* Unused for now. Must be cleared to zero.
*/
__u16 flags;
+ /**
+ * @max_slices:
+ *
+ * The number of bits used to express the slice mask.
+ */
__u16 max_slices;
+
+ /**
+ * @max_subslices:
+ *
+ * The number of bits used to express the subslice mask.
+ */
__u16 max_subslices;
+
+ /**
+ * @max_eus_per_subslice:
+ *
+ * The number of bits in the EU mask that correspond to a single
+ * subslice's EUs.
+ */
__u16 max_eus_per_subslice;
- /*
+ /**
+ * @subslice_offset:
+ *
* Offset in data[] at which the subslice masks are stored.
*/
__u16 subslice_offset;
- /*
+ /**
+ * @subslice_stride:
+ *
* Stride at which each of the subslice masks for each slice are
* stored.
*/
__u16 subslice_stride;
- /*
+ /**
+ * @eu_offset:
+ *
* Offset in data[] at which the EU masks are stored.
*/
__u16 eu_offset;
- /*
+ /**
+ * @eu_stride:
+ *
* Stride at which each of the EU masks for each subslice are stored.
*/
__u16 eu_stride;
+ /**
+ * @data:
+ *
+ * Contains 3 pieces of information :
+ *
+ * - The slice mask with one bit per slice telling whether a slice is
+ * available. The availability of slice X can be queried with the
+ * following formula :
+ *
+ * .. code:: c
+ *
+ * (data[X / 8] >> (X % 8)) & 1
+ *
+ * Starting with Xe_HP platforms, Intel hardware no longer has
+ * traditional slices so i915 will always report a single slice
+ * (hardcoded slicemask = 0x1) which contains all of the platform's
+ * subslices. I.e., the mask here does not reflect any of the newer
+ * hardware concepts such as "gslices" or "cslices" since userspace
+ * is capable of inferring those from the subslice mask.
+ *
+ * - The subslice mask for each slice with one bit per subslice telling
+ * whether a subslice is available. Starting with Gen12 we use the
+ * term "subslice" to refer to what the hardware documentation
+ * describes as a "dual-subslices." The availability of subslice Y
+ * in slice X can be queried with the following formula :
+ *
+ * .. code:: c
+ *
+ * (data[subslice_offset + X * subslice_stride + Y / 8] >> (Y % 8)) & 1
+ *
+ * - The EU mask for each subslice in each slice, with one bit per EU
+ * telling whether an EU is available. The availability of EU Z in
+ * subslice Y in slice X can be queried with the following formula :
+ *
+ * .. code:: c
+ *
+ * (data[eu_offset +
+ * (X * max_subslices + Y) * eu_stride +
+ * Z / 8
+ * ] >> (Z % 8)) & 1
+ */
__u8 data[];
};
@@ -2945,52 +3257,68 @@ struct drm_i915_query_engine_info {
struct drm_i915_engine_info engines[];
};
-/*
- * Data written by the kernel with query DRM_I915_QUERY_PERF_CONFIG.
+/**
+ * struct drm_i915_query_perf_config
+ *
+ * Data written by the kernel with query %DRM_I915_QUERY_PERF_CONFIG and
+ * %DRM_I915_QUERY_GEOMETRY_SUBSLICES.
*/
struct drm_i915_query_perf_config {
union {
- /*
- * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets
- * this fields to the number of configurations available.
+ /**
+ * @n_configs:
+ *
+ * When &drm_i915_query_item.flags ==
+ * %DRM_I915_QUERY_PERF_CONFIG_LIST, i915 sets this fields to
+ * the number of configurations available.
*/
__u64 n_configs;
- /*
- * When query_id == DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID,
- * i915 will use the value in this field as configuration
- * identifier to decide what data to write into config_ptr.
+ /**
+ * @config:
+ *
+ * When &drm_i915_query_item.flags ==
+ * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_ID, i915 will use the
+ * value in this field as configuration identifier to decide
+ * what data to write into config_ptr.
*/
__u64 config;
- /*
- * When query_id == DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID,
- * i915 will use the value in this field as configuration
- * identifier to decide what data to write into config_ptr.
+ /**
+ * @uuid:
+ *
+ * When &drm_i915_query_item.flags ==
+ * %DRM_I915_QUERY_PERF_CONFIG_DATA_FOR_UUID, i915 will use the
+ * value in this field as configuration identifier to decide
+ * what data to write into config_ptr.
*
* String formatted like "%08x-%04x-%04x-%04x-%012x"
*/
char uuid[36];
};
- /*
+ /**
+ * @flags:
+ *
* Unused for now. Must be cleared to zero.
*/
__u32 flags;
- /*
- * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_LIST, i915 will
- * write an array of __u64 of configuration identifiers.
+ /**
+ * @data:
+ *
+ * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_LIST,
+ * i915 will write an array of __u64 of configuration identifiers.
*
- * When query_item.flags == DRM_I915_QUERY_PERF_CONFIG_DATA, i915 will
- * write a struct drm_i915_perf_oa_config. If the following fields of
- * drm_i915_perf_oa_config are set not set to 0, i915 will write into
- * the associated pointers the values of submitted when the
+ * When &drm_i915_query_item.flags == %DRM_I915_QUERY_PERF_CONFIG_DATA,
+ * i915 will write a struct drm_i915_perf_oa_config. If the following
+ * fields of struct drm_i915_perf_oa_config are not set to 0, i915 will
+ * write into the associated pointers the values of submitted when the
* configuration was created :
*
- * - n_mux_regs
- * - n_boolean_regs
- * - n_flex_regs
+ * - &drm_i915_perf_oa_config.n_mux_regs
+ * - &drm_i915_perf_oa_config.n_boolean_regs
+ * - &drm_i915_perf_oa_config.n_flex_regs
*/
__u8 data[];
};
@@ -3020,36 +3348,6 @@ struct drm_i915_gem_memory_class_instance {
* struct drm_i915_memory_region_info - Describes one region as known to the
* driver.
*
- * Note that we reserve some stuff here for potential future work. As an example
- * we might want expose the capabilities for a given region, which could include
- * things like if the region is CPU mappable/accessible, what are the supported
- * mapping types etc.
- *
- * Note that to extend struct drm_i915_memory_region_info and struct
- * drm_i915_query_memory_regions in the future the plan is to do the following:
- *
- * .. code-block:: C
- *
- * struct drm_i915_memory_region_info {
- * struct drm_i915_gem_memory_class_instance region;
- * union {
- * __u32 rsvd0;
- * __u32 new_thing1;
- * };
- * ...
- * union {
- * __u64 rsvd1[8];
- * struct {
- * __u64 new_thing2;
- * __u64 new_thing3;
- * ...
- * };
- * };
- * };
- *
- * With this things should remain source compatible between versions for
- * userspace, even as we add new fields.
- *
* Note this is using both struct drm_i915_query_item and struct drm_i915_query.
* For this new query we are adding the new query id DRM_I915_QUERY_MEMORY_REGIONS
* at &drm_i915_query_item.query_id.
@@ -3061,14 +3359,81 @@ struct drm_i915_memory_region_info {
/** @rsvd0: MBZ */
__u32 rsvd0;
- /** @probed_size: Memory probed by the driver (-1 = unknown) */
+ /**
+ * @probed_size: Memory probed by the driver
+ *
+ * Note that it should not be possible to ever encounter a zero value
+ * here, also note that no current region type will ever return -1 here.
+ * Although for future region types, this might be a possibility. The
+ * same applies to the other size fields.
+ */
__u64 probed_size;
- /** @unallocated_size: Estimate of memory remaining (-1 = unknown) */
+ /**
+ * @unallocated_size: Estimate of memory remaining
+ *
+ * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable accounting.
+ * Without this (or if this is an older kernel) the value here will
+ * always equal the @probed_size. Note this is only currently tracked
+ * for I915_MEMORY_CLASS_DEVICE regions (for other types the value here
+ * will always equal the @probed_size).
+ */
__u64 unallocated_size;
- /** @rsvd1: MBZ */
- __u64 rsvd1[8];
+ union {
+ /** @rsvd1: MBZ */
+ __u64 rsvd1[8];
+ struct {
+ /**
+ * @probed_cpu_visible_size: Memory probed by the driver
+ * that is CPU accessible.
+ *
+ * This will be always be <= @probed_size, and the
+ * remainder (if there is any) will not be CPU
+ * accessible.
+ *
+ * On systems without small BAR, the @probed_size will
+ * always equal the @probed_cpu_visible_size, since all
+ * of it will be CPU accessible.
+ *
+ * Note this is only tracked for
+ * I915_MEMORY_CLASS_DEVICE regions (for other types the
+ * value here will always equal the @probed_size).
+ *
+ * Note that if the value returned here is zero, then
+ * this must be an old kernel which lacks the relevant
+ * small-bar uAPI support (including
+ * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS), but on
+ * such systems we should never actually end up with a
+ * small BAR configuration, assuming we are able to load
+ * the kernel module. Hence it should be safe to treat
+ * this the same as when @probed_cpu_visible_size ==
+ * @probed_size.
+ */
+ __u64 probed_cpu_visible_size;
+
+ /**
+ * @unallocated_cpu_visible_size: Estimate of CPU
+ * visible memory remaining.
+ *
+ * Note this is only tracked for
+ * I915_MEMORY_CLASS_DEVICE regions (for other types the
+ * value here will always equal the
+ * @probed_cpu_visible_size).
+ *
+ * Requires CAP_PERFMON or CAP_SYS_ADMIN to get reliable
+ * accounting. Without this the value here will always
+ * equal the @probed_cpu_visible_size. Note this is only
+ * currently tracked for I915_MEMORY_CLASS_DEVICE
+ * regions (for other types the value here will also
+ * always equal the @probed_cpu_visible_size).
+ *
+ * If this is an older kernel the value here will be
+ * zero, see also @probed_cpu_visible_size.
+ */
+ __u64 unallocated_cpu_visible_size;
+ };
+ };
};
/**
@@ -3129,14 +3494,24 @@ struct drm_i915_query_memory_regions {
};
/**
+ * DOC: GuC HWCONFIG blob uAPI
+ *
+ * The GuC produces a blob with information about the current device.
+ * i915 reads this blob from GuC and makes it available via this uAPI.
+ *
+ * The format and meaning of the blob content are documented in the
+ * Programmer's Reference Manual.
+ */
+
+/**
* struct drm_i915_gem_create_ext - Existing gem_create behaviour, with added
* extension support using struct i915_user_extension.
*
- * Note that in the future we want to have our buffer flags here, at least for
- * the stuff that is immutable. Previously we would have two ioctls, one to
- * create the object with gem_create, and another to apply various parameters,
- * however this creates some ambiguity for the params which are considered
- * immutable. Also in general we're phasing out the various SET/GET ioctls.
+ * Note that new buffer flags should be added here, at least for the stuff that
+ * is immutable. Previously we would have two ioctls, one to create the object
+ * with gem_create, and another to apply various parameters, however this
+ * creates some ambiguity for the params which are considered immutable. Also in
+ * general we're phasing out the various SET/GET ioctls.
*/
struct drm_i915_gem_create_ext {
/**
@@ -3144,21 +3519,79 @@ struct drm_i915_gem_create_ext {
*
* The (page-aligned) allocated size for the object will be returned.
*
- * Note that for some devices we have might have further minimum
- * page-size restrictions(larger than 4K), like for device local-memory.
- * However in general the final size here should always reflect any
- * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS
- * extension to place the object in device local-memory.
+ * On platforms like DG2/ATS the kernel will always use 64K or larger
+ * pages for I915_MEMORY_CLASS_DEVICE. The kernel also requires a
+ * minimum of 64K GTT alignment for such objects.
+ *
+ * NOTE: Previously the ABI here required a minimum GTT alignment of 2M
+ * on DG2/ATS, due to how the hardware implemented 64K GTT page support,
+ * where we had the following complications:
+ *
+ * 1) The entire PDE (which covers a 2MB virtual address range), must
+ * contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same
+ * PDE is forbidden by the hardware.
+ *
+ * 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM
+ * objects.
+ *
+ * However on actual production HW this was completely changed to now
+ * allow setting a TLB hint at the PTE level (see PS64), which is a lot
+ * more flexible than the above. With this the 2M restriction was
+ * dropped where we now only require 64K.
*/
__u64 size;
+
/**
* @handle: Returned handle for the object.
*
* Object handles are nonzero.
*/
__u32 handle;
- /** @flags: MBZ */
+
+ /**
+ * @flags: Optional flags.
+ *
+ * Supported values:
+ *
+ * I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS - Signal to the kernel that
+ * the object will need to be accessed via the CPU.
+ *
+ * Only valid when placing objects in I915_MEMORY_CLASS_DEVICE, and only
+ * strictly required on configurations where some subset of the device
+ * memory is directly visible/mappable through the CPU (which we also
+ * call small BAR), like on some DG2+ systems. Note that this is quite
+ * undesirable, but due to various factors like the client CPU, BIOS etc
+ * it's something we can expect to see in the wild. See
+ * &drm_i915_memory_region_info.probed_cpu_visible_size for how to
+ * determine if this system applies.
+ *
+ * Note that one of the placements MUST be I915_MEMORY_CLASS_SYSTEM, to
+ * ensure the kernel can always spill the allocation to system memory,
+ * if the object can't be allocated in the mappable part of
+ * I915_MEMORY_CLASS_DEVICE.
+ *
+ * Also note that since the kernel only supports flat-CCS on objects
+ * that can *only* be placed in I915_MEMORY_CLASS_DEVICE, we therefore
+ * don't support I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS together with
+ * flat-CCS.
+ *
+ * Without this hint, the kernel will assume that non-mappable
+ * I915_MEMORY_CLASS_DEVICE is preferred for this object. Note that the
+ * kernel can still migrate the object to the mappable part, as a last
+ * resort, if userspace ever CPU faults this object, but this might be
+ * expensive, and so ideally should be avoided.
+ *
+ * On older kernels which lack the relevant small-bar uAPI support (see
+ * also &drm_i915_memory_region_info.probed_cpu_visible_size),
+ * usage of the flag will result in an error, but it should NEVER be
+ * possible to end up with a small BAR configuration, assuming we can
+ * also successfully load the i915 kernel module. In such cases the
+ * entire I915_MEMORY_CLASS_DEVICE region will be CPU accessible, and as
+ * such there are zero restrictions on where the object can be placed.
+ */
+#define I915_GEM_CREATE_EXT_FLAG_NEEDS_CPU_ACCESS (1 << 0)
__u32 flags;
+
/**
* @extensions: The chain of extensions to apply to this object.
*
@@ -3217,6 +3650,22 @@ struct drm_i915_gem_create_ext {
* At which point we get the object handle in &drm_i915_gem_create_ext.handle,
* along with the final object size in &drm_i915_gem_create_ext.size, which
* should account for any rounding up, if required.
+ *
+ * Note that userspace has no means of knowing the current backing region
+ * for objects where @num_regions is larger than one. The kernel will only
+ * ensure that the priority order of the @regions array is honoured, either
+ * when initially placing the object, or when moving memory around due to
+ * memory pressure
+ *
+ * On Flat-CCS capable HW, compression is supported for the objects residing
+ * in I915_MEMORY_CLASS_DEVICE. When such objects (compressed) have other
+ * memory class in @regions and migrated (by i915, due to memory
+ * constraints) to the non I915_MEMORY_CLASS_DEVICE region, then i915 needs to
+ * decompress the content. But i915 doesn't have the required information to
+ * decompress the userspace compressed objects.
+ *
+ * So i915 supports Flat-CCS, on the objects which can reside only on
+ * I915_MEMORY_CLASS_DEVICE regions.
*/
struct drm_i915_gem_create_ext_memory_regions {
/** @base: Extension link. See struct i915_user_extension. */
diff --git a/lib/libc/include/any-linux-any/drm/ivpu_accel.h b/lib/libc/include/any-linux-any/drm/ivpu_accel.h
new file mode 100644
index 0000000000..31d4091df0
--- /dev/null
+++ b/lib/libc/include/any-linux-any/drm/ivpu_accel.h
@@ -0,0 +1,306 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2020-2023 Intel Corporation
+ */
+
+#ifndef __UAPI_IVPU_DRM_H__
+#define __UAPI_IVPU_DRM_H__
+
+#include "drm.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define DRM_IVPU_DRIVER_MAJOR 1
+#define DRM_IVPU_DRIVER_MINOR 0
+
+#define DRM_IVPU_GET_PARAM 0x00
+#define DRM_IVPU_SET_PARAM 0x01
+#define DRM_IVPU_BO_CREATE 0x02
+#define DRM_IVPU_BO_INFO 0x03
+#define DRM_IVPU_SUBMIT 0x05
+#define DRM_IVPU_BO_WAIT 0x06
+
+#define DRM_IOCTL_IVPU_GET_PARAM \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_GET_PARAM, struct drm_ivpu_param)
+
+#define DRM_IOCTL_IVPU_SET_PARAM \
+ DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SET_PARAM, struct drm_ivpu_param)
+
+#define DRM_IOCTL_IVPU_BO_CREATE \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_CREATE, struct drm_ivpu_bo_create)
+
+#define DRM_IOCTL_IVPU_BO_INFO \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_INFO, struct drm_ivpu_bo_info)
+
+#define DRM_IOCTL_IVPU_SUBMIT \
+ DRM_IOW(DRM_COMMAND_BASE + DRM_IVPU_SUBMIT, struct drm_ivpu_submit)
+
+#define DRM_IOCTL_IVPU_BO_WAIT \
+ DRM_IOWR(DRM_COMMAND_BASE + DRM_IVPU_BO_WAIT, struct drm_ivpu_bo_wait)
+
+/**
+ * DOC: contexts
+ *
+ * VPU contexts have private virtual address space, job queues and priority.
+ * Each context is identified by an unique ID. Context is created on open().
+ */
+
+#define DRM_IVPU_PARAM_DEVICE_ID 0
+#define DRM_IVPU_PARAM_DEVICE_REVISION 1
+#define DRM_IVPU_PARAM_PLATFORM_TYPE 2
+#define DRM_IVPU_PARAM_CORE_CLOCK_RATE 3
+#define DRM_IVPU_PARAM_NUM_CONTEXTS 4
+#define DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS 5
+#define DRM_IVPU_PARAM_CONTEXT_PRIORITY 6
+#define DRM_IVPU_PARAM_CONTEXT_ID 7
+#define DRM_IVPU_PARAM_FW_API_VERSION 8
+#define DRM_IVPU_PARAM_ENGINE_HEARTBEAT 9
+#define DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID 10
+#define DRM_IVPU_PARAM_TILE_CONFIG 11
+#define DRM_IVPU_PARAM_SKU 12
+
+#define DRM_IVPU_PLATFORM_TYPE_SILICON 0
+
+#define DRM_IVPU_CONTEXT_PRIORITY_IDLE 0
+#define DRM_IVPU_CONTEXT_PRIORITY_NORMAL 1
+#define DRM_IVPU_CONTEXT_PRIORITY_FOCUS 2
+#define DRM_IVPU_CONTEXT_PRIORITY_REALTIME 3
+
+/**
+ * struct drm_ivpu_param - Get/Set VPU parameters
+ */
+struct drm_ivpu_param {
+ /**
+ * @param:
+ *
+ * Supported params:
+ *
+ * %DRM_IVPU_PARAM_DEVICE_ID:
+ * PCI Device ID of the VPU device (read-only)
+ *
+ * %DRM_IVPU_PARAM_DEVICE_REVISION:
+ * VPU device revision (read-only)
+ *
+ * %DRM_IVPU_PARAM_PLATFORM_TYPE:
+ * Returns %DRM_IVPU_PLATFORM_TYPE_SILICON on real hardware or device specific
+ * platform type when executing on a simulator or emulator (read-only)
+ *
+ * %DRM_IVPU_PARAM_CORE_CLOCK_RATE:
+ * Current PLL frequency (read-only)
+ *
+ * %DRM_IVPU_PARAM_NUM_CONTEXTS:
+ * Maximum number of simultaneously existing contexts (read-only)
+ *
+ * %DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS:
+ * Lowest VPU virtual address available in the current context (read-only)
+ *
+ * %DRM_IVPU_PARAM_CONTEXT_PRIORITY:
+ * Value of current context scheduling priority (read-write).
+ * See DRM_IVPU_CONTEXT_PRIORITY_* for possible values.
+ *
+ * %DRM_IVPU_PARAM_CONTEXT_ID:
+ * Current context ID, always greater than 0 (read-only)
+ *
+ * %DRM_IVPU_PARAM_FW_API_VERSION:
+ * Firmware API version array (read-only)
+ *
+ * %DRM_IVPU_PARAM_ENGINE_HEARTBEAT:
+ * Heartbeat value from an engine (read-only).
+ * Engine ID (i.e. DRM_IVPU_ENGINE_COMPUTE) is given via index.
+ *
+ * %DRM_IVPU_PARAM_UNIQUE_INFERENCE_ID:
+ * Device-unique inference ID (read-only)
+ *
+ * %DRM_IVPU_PARAM_TILE_CONFIG:
+ * VPU tile configuration (read-only)
+ *
+ * %DRM_IVPU_PARAM_SKU:
+ * VPU SKU ID (read-only)
+ *
+ */
+ __u32 param;
+
+ /** @index: Index for params that have multiple instances */
+ __u32 index;
+
+ /** @value: Param value */
+ __u64 value;
+};
+
+#define DRM_IVPU_BO_HIGH_MEM 0x00000001
+#define DRM_IVPU_BO_MAPPABLE 0x00000002
+
+#define DRM_IVPU_BO_CACHED 0x00000000
+#define DRM_IVPU_BO_UNCACHED 0x00010000
+#define DRM_IVPU_BO_WC 0x00020000
+#define DRM_IVPU_BO_CACHE_MASK 0x00030000
+
+#define DRM_IVPU_BO_FLAGS \
+ (DRM_IVPU_BO_HIGH_MEM | \
+ DRM_IVPU_BO_MAPPABLE | \
+ DRM_IVPU_BO_CACHE_MASK)
+
+/**
+ * struct drm_ivpu_bo_create - Create BO backed by SHMEM
+ *
+ * Create GEM buffer object allocated in SHMEM memory.
+ */
+struct drm_ivpu_bo_create {
+ /** @size: The size in bytes of the allocated memory */
+ __u64 size;
+
+ /**
+ * @flags:
+ *
+ * Supported flags:
+ *
+ * %DRM_IVPU_BO_HIGH_MEM:
+ *
+ * Allocate VPU address from >4GB range.
+ * Buffer object with vpu address >4GB can be always accessed by the
+ * VPU DMA engine, but some HW generation may not be able to access
+ * this memory from then firmware running on the VPU management processor.
+ * Suitable for input, output and some scratch buffers.
+ *
+ * %DRM_IVPU_BO_MAPPABLE:
+ *
+ * Buffer object can be mapped using mmap().
+ *
+ * %DRM_IVPU_BO_CACHED:
+ *
+ * Allocated BO will be cached on host side (WB) and snooped on the VPU side.
+ * This is the default caching mode.
+ *
+ * %DRM_IVPU_BO_UNCACHED:
+ *
+ * Allocated BO will not be cached on host side nor snooped on the VPU side.
+ *
+ * %DRM_IVPU_BO_WC:
+ *
+ * Allocated BO will use write combining buffer for writes but reads will be
+ * uncached.
+ */
+ __u32 flags;
+
+ /** @handle: Returned GEM object handle */
+ __u32 handle;
+
+ /** @vpu_addr: Returned VPU virtual address */
+ __u64 vpu_addr;
+};
+
+/**
+ * struct drm_ivpu_bo_info - Query buffer object info
+ */
+struct drm_ivpu_bo_info {
+ /** @handle: Handle of the queried BO */
+ __u32 handle;
+
+ /** @flags: Returned flags used to create the BO */
+ __u32 flags;
+
+ /** @vpu_addr: Returned VPU virtual address */
+ __u64 vpu_addr;
+
+ /**
+ * @mmap_offset:
+ *
+ * Returned offset to be used in mmap(). 0 in case the BO is not mappable.
+ */
+ __u64 mmap_offset;
+
+ /** @size: Returned GEM object size, aligned to PAGE_SIZE */
+ __u64 size;
+};
+
+/* drm_ivpu_submit engines */
+#define DRM_IVPU_ENGINE_COMPUTE 0
+#define DRM_IVPU_ENGINE_COPY 1
+
+/**
+ * struct drm_ivpu_submit - Submit commands to the VPU
+ *
+ * Execute a single command buffer on a given VPU engine.
+ * Handles to all referenced buffer objects have to be provided in @buffers_ptr.
+ *
+ * User space may wait on job completion using %DRM_IVPU_BO_WAIT ioctl.
+ */
+struct drm_ivpu_submit {
+ /**
+ * @buffers_ptr:
+ *
+ * A pointer to an u32 array of GEM handles of the BOs required for this job.
+ * The number of elements in the array must be equal to the value given by @buffer_count.
+ *
+ * The first BO is the command buffer. The rest of array has to contain all
+ * BOs referenced from the command buffer.
+ */
+ __u64 buffers_ptr;
+
+ /** @buffer_count: Number of elements in the @buffers_ptr */
+ __u32 buffer_count;
+
+ /**
+ * @engine: Select the engine this job should be executed on
+ *
+ * %DRM_IVPU_ENGINE_COMPUTE:
+ *
+ * Performs Deep Learning Neural Compute Inference Operations
+ *
+ * %DRM_IVPU_ENGINE_COPY:
+ *
+ * Performs memory copy operations to/from system memory allocated for VPU
+ */
+ __u32 engine;
+
+ /** @flags: Reserved for future use - must be zero */
+ __u32 flags;
+
+ /**
+ * @commands_offset:
+ *
+ * Offset inside the first buffer in @buffers_ptr containing commands
+ * to be executed. The offset has to be 8-byte aligned.
+ */
+ __u32 commands_offset;
+};
+
+/* drm_ivpu_bo_wait job status codes */
+#define DRM_IVPU_JOB_STATUS_SUCCESS 0
+
+/**
+ * struct drm_ivpu_bo_wait - Wait for BO to become inactive
+ *
+ * Blocks until a given buffer object becomes inactive.
+ * With @timeout_ms set to 0 returns immediately.
+ */
+struct drm_ivpu_bo_wait {
+ /** @handle: Handle to the buffer object to be waited on */
+ __u32 handle;
+
+ /** @flags: Reserved for future use - must be zero */
+ __u32 flags;
+
+ /** @timeout_ns: Absolute timeout in nanoseconds (may be zero) */
+ __s64 timeout_ns;
+
+ /**
+ * @job_status:
+ *
+ * Job status code which is updated after the job is completed.
+ * &DRM_IVPU_JOB_STATUS_SUCCESS or device specific error otherwise.
+ * Valid only if @handle points to a command buffer.
+ */
+ __u32 job_status;
+
+ /** @pad: Padding - must be zero */
+ __u32 pad;
+};
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __UAPI_IVPU_DRM_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/mga_drm.h b/lib/libc/include/any-linux-any/drm/mga_drm.h
deleted file mode 100644
index fcf4a403c2..0000000000
--- a/lib/libc/include/any-linux-any/drm/mga_drm.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
- * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Jeff Hartmann <jhartmann@valinux.com>
- * Keith Whitwell <keith@tungstengraphics.com>
- *
- * Rewritten by:
- * Gareth Hughes <gareth@valinux.com>
- */
-
-#ifndef __MGA_DRM_H__
-#define __MGA_DRM_H__
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (mga_sarea.h)
- */
-
-#ifndef __MGA_SAREA_DEFINES__
-#define __MGA_SAREA_DEFINES__
-
-/* WARP pipe flags
- */
-#define MGA_F 0x1 /* fog */
-#define MGA_A 0x2 /* alpha */
-#define MGA_S 0x4 /* specular */
-#define MGA_T2 0x8 /* multitexture */
-
-#define MGA_WARP_TGZ 0
-#define MGA_WARP_TGZF (MGA_F)
-#define MGA_WARP_TGZA (MGA_A)
-#define MGA_WARP_TGZAF (MGA_F|MGA_A)
-#define MGA_WARP_TGZS (MGA_S)
-#define MGA_WARP_TGZSF (MGA_S|MGA_F)
-#define MGA_WARP_TGZSA (MGA_S|MGA_A)
-#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
-#define MGA_WARP_T2GZ (MGA_T2)
-#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
-#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
-#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
-#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
-#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
-#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
-#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
-
-#define MGA_MAX_G200_PIPES 8 /* no multitex */
-#define MGA_MAX_G400_PIPES 16
-#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
-#define MGA_WARP_UCODE_SIZE 32768 /* in bytes */
-
-#define MGA_CARD_TYPE_G200 1
-#define MGA_CARD_TYPE_G400 2
-#define MGA_CARD_TYPE_G450 3 /* not currently used */
-#define MGA_CARD_TYPE_G550 4
-
-#define MGA_FRONT 0x1
-#define MGA_BACK 0x2
-#define MGA_DEPTH 0x4
-
-/* What needs to be changed for the current vertex dma buffer?
- */
-#define MGA_UPLOAD_CONTEXT 0x1
-#define MGA_UPLOAD_TEX0 0x2
-#define MGA_UPLOAD_TEX1 0x4
-#define MGA_UPLOAD_PIPE 0x8
-#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
-#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
-#define MGA_UPLOAD_2D 0x40
-#define MGA_WAIT_AGE 0x80 /* handled client-side */
-#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
-#if 0
-#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
- quiescent */
-#endif
-
-/* 32 buffers of 64k each, total 2 meg.
- */
-#define MGA_BUFFER_SIZE (1 << 16)
-#define MGA_NUM_BUFFERS 128
-
-/* Keep these small for testing.
- */
-#define MGA_NR_SAREA_CLIPRECTS 8
-
-/* 2 heaps (1 for card, 1 for agp), each divided into up to 128
- * regions, subject to a minimum region size of (1<<16) == 64k.
- *
- * Clients may subdivide regions internally, but when sharing between
- * clients, the region size is the minimum granularity.
- */
-
-#define MGA_CARD_HEAP 0
-#define MGA_AGP_HEAP 1
-#define MGA_NR_TEX_HEAPS 2
-#define MGA_NR_TEX_REGIONS 16
-#define MGA_LOG_MIN_TEX_REGION_SIZE 16
-
-#define DRM_MGA_IDLE_RETRY 2048
-
-#endif /* __MGA_SAREA_DEFINES__ */
-
-/* Setup registers for 3D context
- */
-typedef struct {
- unsigned int dstorg;
- unsigned int maccess;
- unsigned int plnwt;
- unsigned int dwgctl;
- unsigned int alphactrl;
- unsigned int fogcolor;
- unsigned int wflag;
- unsigned int tdualstage0;
- unsigned int tdualstage1;
- unsigned int fcol;
- unsigned int stencil;
- unsigned int stencilctl;
-} drm_mga_context_regs_t;
-
-/* Setup registers for 2D, X server
- */
-typedef struct {
- unsigned int pitch;
-} drm_mga_server_regs_t;
-
-/* Setup registers for each texture unit
- */
-typedef struct {
- unsigned int texctl;
- unsigned int texctl2;
- unsigned int texfilter;
- unsigned int texbordercol;
- unsigned int texorg;
- unsigned int texwidth;
- unsigned int texheight;
- unsigned int texorg1;
- unsigned int texorg2;
- unsigned int texorg3;
- unsigned int texorg4;
-} drm_mga_texture_regs_t;
-
-/* General aging mechanism
- */
-typedef struct {
- unsigned int head; /* Position of head pointer */
- unsigned int wrap; /* Primary DMA wrap count */
-} drm_mga_age_t;
-
-typedef struct _drm_mga_sarea {
- /* The channel for communication of state information to the kernel
- * on firing a vertex dma buffer.
- */
- drm_mga_context_regs_t context_state;
- drm_mga_server_regs_t server_state;
- drm_mga_texture_regs_t tex_state[2];
- unsigned int warp_pipe;
- unsigned int dirty;
- unsigned int vertsize;
-
- /* The current cliprects, or a subset thereof.
- */
- struct drm_clip_rect boxes[MGA_NR_SAREA_CLIPRECTS];
- unsigned int nbox;
-
- /* Information about the most recently used 3d drawable. The
- * client fills in the req_* fields, the server fills in the
- * exported_ fields and puts the cliprects into boxes, above.
- *
- * The client clears the exported_drawable field before
- * clobbering the boxes data.
- */
- unsigned int req_drawable; /* the X drawable id */
- unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
-
- unsigned int exported_drawable;
- unsigned int exported_index;
- unsigned int exported_stamp;
- unsigned int exported_buffers;
- unsigned int exported_nfront;
- unsigned int exported_nback;
- int exported_back_x, exported_front_x, exported_w;
- int exported_back_y, exported_front_y, exported_h;
- struct drm_clip_rect exported_boxes[MGA_NR_SAREA_CLIPRECTS];
-
- /* Counters for aging textures and for client-side throttling.
- */
- unsigned int status[4];
- unsigned int last_wrap;
-
- drm_mga_age_t last_frame;
- unsigned int last_enqueue; /* last time a buffer was enqueued */
- unsigned int last_dispatch; /* age of the most recently dispatched buffer */
- unsigned int last_quiescent; /* */
-
- /* LRU lists for texture memory in agp space and on the card.
- */
- struct drm_tex_region texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS + 1];
- unsigned int texAge[MGA_NR_TEX_HEAPS];
-
- /* Mechanism to validate card state.
- */
- int ctxOwner;
-} drm_mga_sarea_t;
-
-/* MGA specific ioctls
- * The device specific ioctl range is 0x40 to 0x79.
- */
-#define DRM_MGA_INIT 0x00
-#define DRM_MGA_FLUSH 0x01
-#define DRM_MGA_RESET 0x02
-#define DRM_MGA_SWAP 0x03
-#define DRM_MGA_CLEAR 0x04
-#define DRM_MGA_VERTEX 0x05
-#define DRM_MGA_INDICES 0x06
-#define DRM_MGA_ILOAD 0x07
-#define DRM_MGA_BLIT 0x08
-#define DRM_MGA_GETPARAM 0x09
-
-/* 3.2:
- * ioctls for operating on fences.
- */
-#define DRM_MGA_SET_FENCE 0x0a
-#define DRM_MGA_WAIT_FENCE 0x0b
-#define DRM_MGA_DMA_BOOTSTRAP 0x0c
-
-#define DRM_IOCTL_MGA_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_INIT, drm_mga_init_t)
-#define DRM_IOCTL_MGA_FLUSH DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_FLUSH, struct drm_lock)
-#define DRM_IOCTL_MGA_RESET DRM_IO( DRM_COMMAND_BASE + DRM_MGA_RESET)
-#define DRM_IOCTL_MGA_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_MGA_SWAP)
-#define DRM_IOCTL_MGA_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_CLEAR, drm_mga_clear_t)
-#define DRM_IOCTL_MGA_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_VERTEX, drm_mga_vertex_t)
-#define DRM_IOCTL_MGA_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_INDICES, drm_mga_indices_t)
-#define DRM_IOCTL_MGA_ILOAD DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_ILOAD, drm_mga_iload_t)
-#define DRM_IOCTL_MGA_BLIT DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_BLIT, drm_mga_blit_t)
-#define DRM_IOCTL_MGA_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_GETPARAM, drm_mga_getparam_t)
-#define DRM_IOCTL_MGA_SET_FENCE DRM_IOW( DRM_COMMAND_BASE + DRM_MGA_SET_FENCE, __u32)
-#define DRM_IOCTL_MGA_WAIT_FENCE DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_WAIT_FENCE, __u32)
-#define DRM_IOCTL_MGA_DMA_BOOTSTRAP DRM_IOWR(DRM_COMMAND_BASE + DRM_MGA_DMA_BOOTSTRAP, drm_mga_dma_bootstrap_t)
-
-typedef struct _drm_mga_warp_index {
- int installed;
- unsigned long phys_addr;
- int size;
-} drm_mga_warp_index_t;
-
-typedef struct drm_mga_init {
- enum {
- MGA_INIT_DMA = 0x01,
- MGA_CLEANUP_DMA = 0x02
- } func;
-
- unsigned long sarea_priv_offset;
-
- __struct_group(/* no tag */, always32bit, /* no attrs */,
- int chipset;
- int sgram;
-
- unsigned int maccess;
-
- unsigned int fb_cpp;
- unsigned int front_offset, front_pitch;
- unsigned int back_offset, back_pitch;
-
- unsigned int depth_cpp;
- unsigned int depth_offset, depth_pitch;
-
- unsigned int texture_offset[MGA_NR_TEX_HEAPS];
- unsigned int texture_size[MGA_NR_TEX_HEAPS];
- );
-
- unsigned long fb_offset;
- unsigned long mmio_offset;
- unsigned long status_offset;
- unsigned long warp_offset;
- unsigned long primary_offset;
- unsigned long buffers_offset;
-} drm_mga_init_t;
-
-typedef struct drm_mga_dma_bootstrap {
- /**
- * \name AGP texture region
- *
- * On return from the DRM_MGA_DMA_BOOTSTRAP ioctl, these fields will
- * be filled in with the actual AGP texture settings.
- *
- * \warning
- * If these fields are non-zero, but dma_mga_dma_bootstrap::agp_mode
- * is zero, it means that PCI memory (most likely through the use of
- * an IOMMU) is being used for "AGP" textures.
- */
- /*@{ */
- unsigned long texture_handle; /**< Handle used to map AGP textures. */
- __u32 texture_size; /**< Size of the AGP texture region. */
- /*@} */
-
- /**
- * Requested size of the primary DMA region.
- *
- * On return from the DRM_MGA_DMA_BOOTSTRAP ioctl, this field will be
- * filled in with the actual AGP mode. If AGP was not available
- */
- __u32 primary_size;
-
- /**
- * Requested number of secondary DMA buffers.
- *
- * On return from the DRM_MGA_DMA_BOOTSTRAP ioctl, this field will be
- * filled in with the actual number of secondary DMA buffers
- * allocated. Particularly when PCI DMA is used, this may be
- * (subtantially) less than the number requested.
- */
- __u32 secondary_bin_count;
-
- /**
- * Requested size of each secondary DMA buffer.
- *
- * While the kernel \b is free to reduce
- * dma_mga_dma_bootstrap::secondary_bin_count, it is \b not allowed
- * to reduce dma_mga_dma_bootstrap::secondary_bin_size.
- */
- __u32 secondary_bin_size;
-
- /**
- * Bit-wise mask of AGPSTAT2_* values. Currently only \c AGPSTAT2_1X,
- * \c AGPSTAT2_2X, and \c AGPSTAT2_4X are supported. If this value is
- * zero, it means that PCI DMA should be used, even if AGP is
- * possible.
- *
- * On return from the DRM_MGA_DMA_BOOTSTRAP ioctl, this field will be
- * filled in with the actual AGP mode. If AGP was not available
- * (i.e., PCI DMA was used), this value will be zero.
- */
- __u32 agp_mode;
-
- /**
- * Desired AGP GART size, measured in megabytes.
- */
- __u8 agp_size;
-} drm_mga_dma_bootstrap_t;
-
-typedef struct drm_mga_clear {
- unsigned int flags;
- unsigned int clear_color;
- unsigned int clear_depth;
- unsigned int color_mask;
- unsigned int depth_mask;
-} drm_mga_clear_t;
-
-typedef struct drm_mga_vertex {
- int idx; /* buffer to queue */
- int used; /* bytes in use */
- int discard; /* client finished with buffer? */
-} drm_mga_vertex_t;
-
-typedef struct drm_mga_indices {
- int idx; /* buffer to queue */
- unsigned int start;
- unsigned int end;
- int discard; /* client finished with buffer? */
-} drm_mga_indices_t;
-
-typedef struct drm_mga_iload {
- int idx;
- unsigned int dstorg;
- unsigned int length;
-} drm_mga_iload_t;
-
-typedef struct _drm_mga_blit {
- unsigned int planemask;
- unsigned int srcorg;
- unsigned int dstorg;
- int src_pitch, dst_pitch;
- int delta_sx, delta_sy;
- int delta_dx, delta_dy;
- int height, ydir; /* flip image vertically */
- int source_pitch, dest_pitch;
-} drm_mga_blit_t;
-
-/* 3.1: An ioctl to get parameters that aren't available to the 3d
- * client any other way.
- */
-#define MGA_PARAM_IRQ_NR 1
-
-/* 3.2: Query the actual card type. The DDX only distinguishes between
- * G200 chips and non-G200 chips, which it calls G400. It turns out that
- * there are some very sublte differences between the G4x0 chips and the G550
- * chips. Using this parameter query, a client-side driver can detect the
- * difference between a G4x0 and a G550.
- */
-#define MGA_PARAM_CARD_TYPE 2
-
-typedef struct drm_mga_getparam {
- int param;
- void *value;
-} drm_mga_getparam_t;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/msm_drm.h b/lib/libc/include/any-linux-any/drm/msm_drm.h
index c9a02b88cc..e6da14cbf7 100644
--- a/lib/libc/include/any-linux-any/drm/msm_drm.h
+++ b/lib/libc/include/any-linux-any/drm/msm_drm.h
@@ -67,16 +67,25 @@ struct drm_msm_timespec {
__s64 tv_nsec; /* nanoseconds */
};
-#define MSM_PARAM_GPU_ID 0x01
-#define MSM_PARAM_GMEM_SIZE 0x02
-#define MSM_PARAM_CHIP_ID 0x03
-#define MSM_PARAM_MAX_FREQ 0x04
-#define MSM_PARAM_TIMESTAMP 0x05
-#define MSM_PARAM_GMEM_BASE 0x06
-#define MSM_PARAM_PRIORITIES 0x07 /* The # of priority levels */
-#define MSM_PARAM_PP_PGTABLE 0x08 /* => 1 for per-process pagetables, else 0 */
-#define MSM_PARAM_FAULTS 0x09
-#define MSM_PARAM_SUSPENDS 0x0a
+/* Below "RO" indicates a read-only param, "WO" indicates write-only, and
+ * "RW" indicates a param that can be both read (GET_PARAM) and written
+ * (SET_PARAM)
+ */
+#define MSM_PARAM_GPU_ID 0x01 /* RO */
+#define MSM_PARAM_GMEM_SIZE 0x02 /* RO */
+#define MSM_PARAM_CHIP_ID 0x03 /* RO */
+#define MSM_PARAM_MAX_FREQ 0x04 /* RO */
+#define MSM_PARAM_TIMESTAMP 0x05 /* RO */
+#define MSM_PARAM_GMEM_BASE 0x06 /* RO */
+#define MSM_PARAM_PRIORITIES 0x07 /* RO: The # of priority levels */
+#define MSM_PARAM_PP_PGTABLE 0x08 /* RO: Deprecated, always returns zero */
+#define MSM_PARAM_FAULTS 0x09 /* RO */
+#define MSM_PARAM_SUSPENDS 0x0a /* RO */
+#define MSM_PARAM_SYSPROF 0x0b /* WO: 1 preserves perfcntrs, 2 also disables suspend */
+#define MSM_PARAM_COMM 0x0c /* WO: override for task->comm */
+#define MSM_PARAM_CMDLINE 0x0d /* WO: override for task cmdline */
+#define MSM_PARAM_VA_START 0x0e /* RO: start of valid GPU iova range */
+#define MSM_PARAM_VA_SIZE 0x0f /* RO: size of valid GPU iova range (bytes) */
/* For backwards compat. The original support for preemption was based on
* a single ring per priority level so # of priority levels equals the #
@@ -90,6 +99,8 @@ struct drm_msm_param {
__u32 pipe; /* in, MSM_PIPE_x */
__u32 param; /* in, MSM_PARAM_x */
__u64 value; /* out (get_param) or in (set_param) */
+ __u32 len; /* zero for non-pointer params */
+ __u32 pad; /* must be zero */
};
/*
@@ -126,6 +137,8 @@ struct drm_msm_gem_new {
#define MSM_INFO_GET_IOVA 0x01 /* get iova, returned by value */
#define MSM_INFO_SET_NAME 0x02 /* set the debug name (by pointer) */
#define MSM_INFO_GET_NAME 0x03 /* get debug name, returned by pointer */
+#define MSM_INFO_SET_IOVA 0x04 /* set the iova, passed by value */
+#define MSM_INFO_GET_FLAGS 0x05 /* get the MSM_BO_x flags */
struct drm_msm_gem_info {
__u32 handle; /* in */
@@ -209,10 +222,12 @@ struct drm_msm_gem_submit_cmd {
#define MSM_SUBMIT_BO_READ 0x0001
#define MSM_SUBMIT_BO_WRITE 0x0002
#define MSM_SUBMIT_BO_DUMP 0x0004
+#define MSM_SUBMIT_BO_NO_IMPLICIT 0x0008
#define MSM_SUBMIT_BO_FLAGS (MSM_SUBMIT_BO_READ | \
MSM_SUBMIT_BO_WRITE | \
- MSM_SUBMIT_BO_DUMP)
+ MSM_SUBMIT_BO_DUMP | \
+ MSM_SUBMIT_BO_NO_IMPLICIT)
struct drm_msm_gem_submit_bo {
__u32 flags; /* in, mask of MSM_SUBMIT_BO_x */
@@ -227,6 +242,7 @@ struct drm_msm_gem_submit_bo {
#define MSM_SUBMIT_SUDO 0x10000000 /* run submitted cmds from RB */
#define MSM_SUBMIT_SYNCOBJ_IN 0x08000000 /* enable input syncobj */
#define MSM_SUBMIT_SYNCOBJ_OUT 0x04000000 /* enable output syncobj */
+#define MSM_SUBMIT_FENCE_SN_IN 0x02000000 /* userspace passes in seqno fence */
#define MSM_SUBMIT_FLAGS ( \
MSM_SUBMIT_NO_IMPLICIT | \
MSM_SUBMIT_FENCE_FD_IN | \
@@ -234,6 +250,7 @@ struct drm_msm_gem_submit_bo {
MSM_SUBMIT_SUDO | \
MSM_SUBMIT_SYNCOBJ_IN | \
MSM_SUBMIT_SYNCOBJ_OUT | \
+ MSM_SUBMIT_FENCE_SN_IN | \
0)
#define MSM_SUBMIT_SYNCOBJ_RESET 0x00000001 /* Reset syncobj after wait. */
@@ -253,7 +270,7 @@ struct drm_msm_gem_submit_syncobj {
*/
struct drm_msm_gem_submit {
__u32 flags; /* MSM_PIPE_x | MSM_SUBMIT_x */
- __u32 fence; /* out */
+ __u32 fence; /* out (or in with MSM_SUBMIT_FENCE_SN_IN flag) */
__u32 nr_bos; /* in, number of submit_bo's */
__u32 nr_cmds; /* in, number of submit_cmd's */
__u64 bos; /* in, ptr to array of submit_bo's */
@@ -333,9 +350,7 @@ struct drm_msm_submitqueue_query {
};
#define DRM_MSM_GET_PARAM 0x00
-/* placeholder:
#define DRM_MSM_SET_PARAM 0x01
- */
#define DRM_MSM_GEM_NEW 0x02
#define DRM_MSM_GEM_INFO 0x03
#define DRM_MSM_GEM_CPU_PREP 0x04
@@ -351,6 +366,7 @@ struct drm_msm_submitqueue_query {
#define DRM_MSM_SUBMITQUEUE_QUERY 0x0C
#define DRM_IOCTL_MSM_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GET_PARAM, struct drm_msm_param)
+#define DRM_IOCTL_MSM_SET_PARAM DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_SET_PARAM, struct drm_msm_param)
#define DRM_IOCTL_MSM_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_NEW, struct drm_msm_gem_new)
#define DRM_IOCTL_MSM_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_MSM_GEM_INFO, struct drm_msm_gem_info)
#define DRM_IOCTL_MSM_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_MSM_GEM_CPU_PREP, struct drm_msm_gem_cpu_prep)
diff --git a/lib/libc/include/any-linux-any/drm/panfrost_drm.h b/lib/libc/include/any-linux-any/drm/panfrost_drm.h
index 3aeff12294..7e808d8029 100644
--- a/lib/libc/include/any-linux-any/drm/panfrost_drm.h
+++ b/lib/libc/include/any-linux-any/drm/panfrost_drm.h
@@ -84,14 +84,14 @@ struct drm_panfrost_wait_bo {
__s64 timeout_ns; /* absolute */
};
+/* Valid flags to pass to drm_panfrost_create_bo */
#define PANFROST_BO_NOEXEC 1
#define PANFROST_BO_HEAP 2
/**
* struct drm_panfrost_create_bo - ioctl argument for creating Panfrost BOs.
*
- * There are currently no values for the flags argument, but it may be
- * used in a future extension.
+ * The flags argument is a bit mask of PANFROST_BO_* flags.
*/
struct drm_panfrost_create_bo {
__u32 size;
@@ -224,6 +224,57 @@ struct drm_panfrost_madvise {
__u32 retained; /* out, whether backing store still exists */
};
+/* Definitions for coredump decoding in user space */
+#define PANFROSTDUMP_MAJOR 1
+#define PANFROSTDUMP_MINOR 0
+
+#define PANFROSTDUMP_MAGIC 0x464E4150 /* PANF */
+
+#define PANFROSTDUMP_BUF_REG 0
+#define PANFROSTDUMP_BUF_BOMAP (PANFROSTDUMP_BUF_REG + 1)
+#define PANFROSTDUMP_BUF_BO (PANFROSTDUMP_BUF_BOMAP + 1)
+#define PANFROSTDUMP_BUF_TRAILER (PANFROSTDUMP_BUF_BO + 1)
+
+/*
+ * This structure is the native endianness of the dumping machine, tools can
+ * detect the endianness by looking at the value in 'magic'.
+ */
+struct panfrost_dump_object_header {
+ __u32 magic;
+ __u32 type;
+ __u32 file_size;
+ __u32 file_offset;
+
+ union {
+ struct {
+ __u64 jc;
+ __u32 gpu_id;
+ __u32 major;
+ __u32 minor;
+ __u64 nbos;
+ } reghdr;
+
+ struct {
+ __u32 valid;
+ __u64 iova;
+ __u32 data[2];
+ } bomap;
+
+ /*
+ * Force same size in case we want to expand the header
+ * with new fields and also keep it 512-byte aligned
+ */
+
+ __u32 sizer[496];
+ };
+};
+
+/* Registers object, an array of these */
+struct panfrost_dump_registers {
+ __u32 reg;
+ __u32 value;
+};
+
#if defined(__cplusplus)
}
#endif
diff --git a/lib/libc/include/any-linux-any/drm/r128_drm.h b/lib/libc/include/any-linux-any/drm/r128_drm.h
deleted file mode 100644
index 6bd4ed1676..0000000000
--- a/lib/libc/include/any-linux-any/drm/r128_drm.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
- * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
- */
-/*
- * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- */
-
-#ifndef __R128_DRM_H__
-#define __R128_DRM_H__
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the X server file (r128_sarea.h)
- */
-#ifndef __R128_SAREA_DEFINES__
-#define __R128_SAREA_DEFINES__
-
-/* What needs to be changed for the current vertex buffer?
- */
-#define R128_UPLOAD_CONTEXT 0x001
-#define R128_UPLOAD_SETUP 0x002
-#define R128_UPLOAD_TEX0 0x004
-#define R128_UPLOAD_TEX1 0x008
-#define R128_UPLOAD_TEX0IMAGES 0x010
-#define R128_UPLOAD_TEX1IMAGES 0x020
-#define R128_UPLOAD_CORE 0x040
-#define R128_UPLOAD_MASKS 0x080
-#define R128_UPLOAD_WINDOW 0x100
-#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
-#define R128_REQUIRE_QUIESCENCE 0x400
-#define R128_UPLOAD_ALL 0x7ff
-
-#define R128_FRONT 0x1
-#define R128_BACK 0x2
-#define R128_DEPTH 0x4
-
-/* Primitive types
- */
-#define R128_POINTS 0x1
-#define R128_LINES 0x2
-#define R128_LINE_STRIP 0x3
-#define R128_TRIANGLES 0x4
-#define R128_TRIANGLE_FAN 0x5
-#define R128_TRIANGLE_STRIP 0x6
-
-/* Vertex/indirect buffer size
- */
-#define R128_BUFFER_SIZE 16384
-
-/* Byte offsets for indirect buffer data
- */
-#define R128_INDEX_PRIM_OFFSET 20
-#define R128_HOSTDATA_BLIT_OFFSET 32
-
-/* Keep these small for testing.
- */
-#define R128_NR_SAREA_CLIPRECTS 12
-
-/* There are 2 heaps (local/AGP). Each region within a heap is a
- * minimum of 64k, and there are at most 64 of them per heap.
- */
-#define R128_LOCAL_TEX_HEAP 0
-#define R128_AGP_TEX_HEAP 1
-#define R128_NR_TEX_HEAPS 2
-#define R128_NR_TEX_REGIONS 64
-#define R128_LOG_TEX_GRANULARITY 16
-
-#define R128_NR_CONTEXT_REGS 12
-
-#define R128_MAX_TEXTURE_LEVELS 11
-#define R128_MAX_TEXTURE_UNITS 2
-
-#endif /* __R128_SAREA_DEFINES__ */
-
-typedef struct {
- /* Context state - can be written in one large chunk */
- unsigned int dst_pitch_offset_c;
- unsigned int dp_gui_master_cntl_c;
- unsigned int sc_top_left_c;
- unsigned int sc_bottom_right_c;
- unsigned int z_offset_c;
- unsigned int z_pitch_c;
- unsigned int z_sten_cntl_c;
- unsigned int tex_cntl_c;
- unsigned int misc_3d_state_cntl_reg;
- unsigned int texture_clr_cmp_clr_c;
- unsigned int texture_clr_cmp_msk_c;
- unsigned int fog_color_c;
-
- /* Texture state */
- unsigned int tex_size_pitch_c;
- unsigned int constant_color_c;
-
- /* Setup state */
- unsigned int pm4_vc_fpu_setup;
- unsigned int setup_cntl;
-
- /* Mask state */
- unsigned int dp_write_mask;
- unsigned int sten_ref_mask_c;
- unsigned int plane_3d_mask_c;
-
- /* Window state */
- unsigned int window_xy_offset;
-
- /* Core state */
- unsigned int scale_3d_cntl;
-} drm_r128_context_regs_t;
-
-/* Setup registers for each texture unit
- */
-typedef struct {
- unsigned int tex_cntl;
- unsigned int tex_combine_cntl;
- unsigned int tex_size_pitch;
- unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
- unsigned int tex_border_color;
-} drm_r128_texture_regs_t;
-
-typedef struct drm_r128_sarea {
- /* The channel for communication of state information to the kernel
- * on firing a vertex buffer.
- */
- drm_r128_context_regs_t context_state;
- drm_r128_texture_regs_t tex_state[R128_MAX_TEXTURE_UNITS];
- unsigned int dirty;
- unsigned int vertsize;
- unsigned int vc_format;
-
- /* The current cliprects, or a subset thereof.
- */
- struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS];
- unsigned int nbox;
-
- /* Counters for client-side throttling of rendering clients.
- */
- unsigned int last_frame;
- unsigned int last_dispatch;
-
- struct drm_tex_region tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS + 1];
- unsigned int tex_age[R128_NR_TEX_HEAPS];
- int ctx_owner;
- int pfAllowPageFlip; /* number of 3d windows (0,1,2 or more) */
- int pfCurrentPage; /* which buffer is being displayed? */
-} drm_r128_sarea_t;
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the Xserver file (xf86drmR128.h)
- */
-
-/* Rage 128 specific ioctls
- * The device specific ioctl range is 0x40 to 0x79.
- */
-#define DRM_R128_INIT 0x00
-#define DRM_R128_CCE_START 0x01
-#define DRM_R128_CCE_STOP 0x02
-#define DRM_R128_CCE_RESET 0x03
-#define DRM_R128_CCE_IDLE 0x04
-/* 0x05 not used */
-#define DRM_R128_RESET 0x06
-#define DRM_R128_SWAP 0x07
-#define DRM_R128_CLEAR 0x08
-#define DRM_R128_VERTEX 0x09
-#define DRM_R128_INDICES 0x0a
-#define DRM_R128_BLIT 0x0b
-#define DRM_R128_DEPTH 0x0c
-#define DRM_R128_STIPPLE 0x0d
-/* 0x0e not used */
-#define DRM_R128_INDIRECT 0x0f
-#define DRM_R128_FULLSCREEN 0x10
-#define DRM_R128_CLEAR2 0x11
-#define DRM_R128_GETPARAM 0x12
-#define DRM_R128_FLIP 0x13
-
-#define DRM_IOCTL_R128_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INIT, drm_r128_init_t)
-#define DRM_IOCTL_R128_CCE_START DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_START)
-#define DRM_IOCTL_R128_CCE_STOP DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CCE_STOP, drm_r128_cce_stop_t)
-#define DRM_IOCTL_R128_CCE_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_RESET)
-#define DRM_IOCTL_R128_CCE_IDLE DRM_IO( DRM_COMMAND_BASE + DRM_R128_CCE_IDLE)
-/* 0x05 not used */
-#define DRM_IOCTL_R128_RESET DRM_IO( DRM_COMMAND_BASE + DRM_R128_RESET)
-#define DRM_IOCTL_R128_SWAP DRM_IO( DRM_COMMAND_BASE + DRM_R128_SWAP)
-#define DRM_IOCTL_R128_CLEAR DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR, drm_r128_clear_t)
-#define DRM_IOCTL_R128_VERTEX DRM_IOW( DRM_COMMAND_BASE + DRM_R128_VERTEX, drm_r128_vertex_t)
-#define DRM_IOCTL_R128_INDICES DRM_IOW( DRM_COMMAND_BASE + DRM_R128_INDICES, drm_r128_indices_t)
-#define DRM_IOCTL_R128_BLIT DRM_IOW( DRM_COMMAND_BASE + DRM_R128_BLIT, drm_r128_blit_t)
-#define DRM_IOCTL_R128_DEPTH DRM_IOW( DRM_COMMAND_BASE + DRM_R128_DEPTH, drm_r128_depth_t)
-#define DRM_IOCTL_R128_STIPPLE DRM_IOW( DRM_COMMAND_BASE + DRM_R128_STIPPLE, drm_r128_stipple_t)
-/* 0x0e not used */
-#define DRM_IOCTL_R128_INDIRECT DRM_IOWR(DRM_COMMAND_BASE + DRM_R128_INDIRECT, drm_r128_indirect_t)
-#define DRM_IOCTL_R128_FULLSCREEN DRM_IOW( DRM_COMMAND_BASE + DRM_R128_FULLSCREEN, drm_r128_fullscreen_t)
-#define DRM_IOCTL_R128_CLEAR2 DRM_IOW( DRM_COMMAND_BASE + DRM_R128_CLEAR2, drm_r128_clear2_t)
-#define DRM_IOCTL_R128_GETPARAM DRM_IOWR( DRM_COMMAND_BASE + DRM_R128_GETPARAM, drm_r128_getparam_t)
-#define DRM_IOCTL_R128_FLIP DRM_IO( DRM_COMMAND_BASE + DRM_R128_FLIP)
-
-typedef struct drm_r128_init {
- enum {
- R128_INIT_CCE = 0x01,
- R128_CLEANUP_CCE = 0x02
- } func;
- unsigned long sarea_priv_offset;
- int is_pci;
- int cce_mode;
- int cce_secure;
- int ring_size;
- int usec_timeout;
-
- unsigned int fb_bpp;
- unsigned int front_offset, front_pitch;
- unsigned int back_offset, back_pitch;
- unsigned int depth_bpp;
- unsigned int depth_offset, depth_pitch;
- unsigned int span_offset;
-
- unsigned long fb_offset;
- unsigned long mmio_offset;
- unsigned long ring_offset;
- unsigned long ring_rptr_offset;
- unsigned long buffers_offset;
- unsigned long agp_textures_offset;
-} drm_r128_init_t;
-
-typedef struct drm_r128_cce_stop {
- int flush;
- int idle;
-} drm_r128_cce_stop_t;
-
-typedef struct drm_r128_clear {
- unsigned int flags;
- unsigned int clear_color;
- unsigned int clear_depth;
- unsigned int color_mask;
- unsigned int depth_mask;
-} drm_r128_clear_t;
-
-typedef struct drm_r128_vertex {
- int prim;
- int idx; /* Index of vertex buffer */
- int count; /* Number of vertices in buffer */
- int discard; /* Client finished with buffer? */
-} drm_r128_vertex_t;
-
-typedef struct drm_r128_indices {
- int prim;
- int idx;
- int start;
- int end;
- int discard; /* Client finished with buffer? */
-} drm_r128_indices_t;
-
-typedef struct drm_r128_blit {
- int idx;
- int pitch;
- int offset;
- int format;
- unsigned short x, y;
- unsigned short width, height;
-} drm_r128_blit_t;
-
-typedef struct drm_r128_depth {
- enum {
- R128_WRITE_SPAN = 0x01,
- R128_WRITE_PIXELS = 0x02,
- R128_READ_SPAN = 0x03,
- R128_READ_PIXELS = 0x04
- } func;
- int n;
- int *x;
- int *y;
- unsigned int *buffer;
- unsigned char *mask;
-} drm_r128_depth_t;
-
-typedef struct drm_r128_stipple {
- unsigned int *mask;
-} drm_r128_stipple_t;
-
-typedef struct drm_r128_indirect {
- int idx;
- int start;
- int end;
- int discard;
-} drm_r128_indirect_t;
-
-typedef struct drm_r128_fullscreen {
- enum {
- R128_INIT_FULLSCREEN = 0x01,
- R128_CLEANUP_FULLSCREEN = 0x02
- } func;
-} drm_r128_fullscreen_t;
-
-/* 2.3: An ioctl to get parameters that aren't available to the 3d
- * client any other way.
- */
-#define R128_PARAM_IRQ_NR 1
-
-typedef struct drm_r128_getparam {
- int param;
- void *value;
-} drm_r128_getparam_t;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/savage_drm.h b/lib/libc/include/any-linux-any/drm/savage_drm.h
deleted file mode 100644
index 15c3b679d5..0000000000
--- a/lib/libc/include/any-linux-any/drm/savage_drm.h
+++ /dev/null
@@ -1,220 +0,0 @@
-/* savage_drm.h -- Public header for the savage driver
- *
- * Copyright 2004 Felix Kuehling
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL FELIX KUEHLING BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef __SAVAGE_DRM_H__
-#define __SAVAGE_DRM_H__
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-#ifndef __SAVAGE_SAREA_DEFINES__
-#define __SAVAGE_SAREA_DEFINES__
-
-/* 2 heaps (1 for card, 1 for agp), each divided into up to 128
- * regions, subject to a minimum region size of (1<<16) == 64k.
- *
- * Clients may subdivide regions internally, but when sharing between
- * clients, the region size is the minimum granularity.
- */
-
-#define SAVAGE_CARD_HEAP 0
-#define SAVAGE_AGP_HEAP 1
-#define SAVAGE_NR_TEX_HEAPS 2
-#define SAVAGE_NR_TEX_REGIONS 16
-#define SAVAGE_LOG_MIN_TEX_REGION_SIZE 16
-
-#endif /* __SAVAGE_SAREA_DEFINES__ */
-
-typedef struct _drm_savage_sarea {
- /* LRU lists for texture memory in agp space and on the card.
- */
- struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS +
- 1];
- unsigned int texAge[SAVAGE_NR_TEX_HEAPS];
-
- /* Mechanism to validate card state.
- */
- int ctxOwner;
-} drm_savage_sarea_t, *drm_savage_sarea_ptr;
-
-/* Savage-specific ioctls
- */
-#define DRM_SAVAGE_BCI_INIT 0x00
-#define DRM_SAVAGE_BCI_CMDBUF 0x01
-#define DRM_SAVAGE_BCI_EVENT_EMIT 0x02
-#define DRM_SAVAGE_BCI_EVENT_WAIT 0x03
-
-#define DRM_IOCTL_SAVAGE_BCI_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_INIT, drm_savage_init_t)
-#define DRM_IOCTL_SAVAGE_BCI_CMDBUF DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_CMDBUF, drm_savage_cmdbuf_t)
-#define DRM_IOCTL_SAVAGE_BCI_EVENT_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_EMIT, drm_savage_event_emit_t)
-#define DRM_IOCTL_SAVAGE_BCI_EVENT_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_SAVAGE_BCI_EVENT_WAIT, drm_savage_event_wait_t)
-
-#define SAVAGE_DMA_PCI 1
-#define SAVAGE_DMA_AGP 3
-typedef struct drm_savage_init {
- enum {
- SAVAGE_INIT_BCI = 1,
- SAVAGE_CLEANUP_BCI = 2
- } func;
- unsigned int sarea_priv_offset;
-
- /* some parameters */
- unsigned int cob_size;
- unsigned int bci_threshold_lo, bci_threshold_hi;
- unsigned int dma_type;
-
- /* frame buffer layout */
- unsigned int fb_bpp;
- unsigned int front_offset, front_pitch;
- unsigned int back_offset, back_pitch;
- unsigned int depth_bpp;
- unsigned int depth_offset, depth_pitch;
-
- /* local textures */
- unsigned int texture_offset;
- unsigned int texture_size;
-
- /* physical locations of non-permanent maps */
- unsigned long status_offset;
- unsigned long buffers_offset;
- unsigned long agp_textures_offset;
- unsigned long cmd_dma_offset;
-} drm_savage_init_t;
-
-typedef union drm_savage_cmd_header drm_savage_cmd_header_t;
-typedef struct drm_savage_cmdbuf {
- /* command buffer in client's address space */
- drm_savage_cmd_header_t *cmd_addr;
- unsigned int size; /* size of the command buffer in 64bit units */
-
- unsigned int dma_idx; /* DMA buffer index to use */
- int discard; /* discard DMA buffer when done */
- /* vertex buffer in client's address space */
- unsigned int *vb_addr;
- unsigned int vb_size; /* size of client vertex buffer in bytes */
- unsigned int vb_stride; /* stride of vertices in 32bit words */
- /* boxes in client's address space */
- struct drm_clip_rect *box_addr;
- unsigned int nbox; /* number of clipping boxes */
-} drm_savage_cmdbuf_t;
-
-#define SAVAGE_WAIT_2D 0x1 /* wait for 2D idle before updating event tag */
-#define SAVAGE_WAIT_3D 0x2 /* wait for 3D idle before updating event tag */
-#define SAVAGE_WAIT_IRQ 0x4 /* emit or wait for IRQ, not implemented yet */
-typedef struct drm_savage_event {
- unsigned int count;
- unsigned int flags;
-} drm_savage_event_emit_t, drm_savage_event_wait_t;
-
-/* Commands for the cmdbuf ioctl
- */
-#define SAVAGE_CMD_STATE 0 /* a range of state registers */
-#define SAVAGE_CMD_DMA_PRIM 1 /* vertices from DMA buffer */
-#define SAVAGE_CMD_VB_PRIM 2 /* vertices from client vertex buffer */
-#define SAVAGE_CMD_DMA_IDX 3 /* indexed vertices from DMA buffer */
-#define SAVAGE_CMD_VB_IDX 4 /* indexed vertices client vertex buffer */
-#define SAVAGE_CMD_CLEAR 5 /* clear buffers */
-#define SAVAGE_CMD_SWAP 6 /* swap buffers */
-
-/* Primitive types
-*/
-#define SAVAGE_PRIM_TRILIST 0 /* triangle list */
-#define SAVAGE_PRIM_TRISTRIP 1 /* triangle strip */
-#define SAVAGE_PRIM_TRIFAN 2 /* triangle fan */
-#define SAVAGE_PRIM_TRILIST_201 3 /* reorder verts for correct flat
- * shading on s3d */
-
-/* Skip flags (vertex format)
- */
-#define SAVAGE_SKIP_Z 0x01
-#define SAVAGE_SKIP_W 0x02
-#define SAVAGE_SKIP_C0 0x04
-#define SAVAGE_SKIP_C1 0x08
-#define SAVAGE_SKIP_S0 0x10
-#define SAVAGE_SKIP_T0 0x20
-#define SAVAGE_SKIP_ST0 0x30
-#define SAVAGE_SKIP_S1 0x40
-#define SAVAGE_SKIP_T1 0x80
-#define SAVAGE_SKIP_ST1 0xc0
-#define SAVAGE_SKIP_ALL_S3D 0x3f
-#define SAVAGE_SKIP_ALL_S4 0xff
-
-/* Buffer names for clear command
- */
-#define SAVAGE_FRONT 0x1
-#define SAVAGE_BACK 0x2
-#define SAVAGE_DEPTH 0x4
-
-/* 64-bit command header
- */
-union drm_savage_cmd_header {
- struct {
- unsigned char cmd; /* command */
- unsigned char pad0;
- unsigned short pad1;
- unsigned short pad2;
- unsigned short pad3;
- } cmd; /* generic */
- struct {
- unsigned char cmd;
- unsigned char global; /* need idle engine? */
- unsigned short count; /* number of consecutive registers */
- unsigned short start; /* first register */
- unsigned short pad3;
- } state; /* SAVAGE_CMD_STATE */
- struct {
- unsigned char cmd;
- unsigned char prim; /* primitive type */
- unsigned short skip; /* vertex format (skip flags) */
- unsigned short count; /* number of vertices */
- unsigned short start; /* first vertex in DMA/vertex buffer */
- } prim; /* SAVAGE_CMD_DMA_PRIM, SAVAGE_CMD_VB_PRIM */
- struct {
- unsigned char cmd;
- unsigned char prim;
- unsigned short skip;
- unsigned short count; /* number of indices that follow */
- unsigned short pad3;
- } idx; /* SAVAGE_CMD_DMA_IDX, SAVAGE_CMD_VB_IDX */
- struct {
- unsigned char cmd;
- unsigned char pad0;
- unsigned short pad1;
- unsigned int flags;
- } clear0; /* SAVAGE_CMD_CLEAR */
- struct {
- unsigned int mask;
- unsigned int value;
- } clear1; /* SAVAGE_CMD_CLEAR data */
-};
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/sis_drm.h b/lib/libc/include/any-linux-any/drm/sis_drm.h
deleted file mode 100644
index 7c62b0672d..0000000000
--- a/lib/libc/include/any-linux-any/drm/sis_drm.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* sis_drv.h -- Private header for sis driver -*- linux-c -*- */
-/*
- * Copyright 2005 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-#ifndef __SIS_DRM_H__
-#define __SIS_DRM_H__
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* SiS specific ioctls */
-#define NOT_USED_0_3
-#define DRM_SIS_FB_ALLOC 0x04
-#define DRM_SIS_FB_FREE 0x05
-#define NOT_USED_6_12
-#define DRM_SIS_AGP_INIT 0x13
-#define DRM_SIS_AGP_ALLOC 0x14
-#define DRM_SIS_AGP_FREE 0x15
-#define DRM_SIS_FB_INIT 0x16
-
-#define DRM_IOCTL_SIS_FB_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_FB_ALLOC, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_FREE, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_INIT, drm_sis_agp_t)
-#define DRM_IOCTL_SIS_AGP_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_SIS_AGP_ALLOC, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_AGP_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_AGP_FREE, drm_sis_mem_t)
-#define DRM_IOCTL_SIS_FB_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_SIS_FB_INIT, drm_sis_fb_t)
-/*
-#define DRM_IOCTL_SIS_FLIP DRM_IOW( 0x48, drm_sis_flip_t)
-#define DRM_IOCTL_SIS_FLIP_INIT DRM_IO( 0x49)
-#define DRM_IOCTL_SIS_FLIP_FINAL DRM_IO( 0x50)
-*/
-
-typedef struct {
- int context;
- unsigned long offset;
- unsigned long size;
- unsigned long free;
-} drm_sis_mem_t;
-
-typedef struct {
- unsigned long offset, size;
-} drm_sis_agp_t;
-
-typedef struct {
- unsigned long offset, size;
-} drm_sis_fb_t;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* __SIS_DRM_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/via_drm.h b/lib/libc/include/any-linux-any/drm/via_drm.h
deleted file mode 100644
index 8cfda08dd8..0000000000
--- a/lib/libc/include/any-linux-any/drm/via_drm.h
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
- * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-#ifndef _VIA_DRM_H_
-#define _VIA_DRM_H_
-
-#include "drm.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-/* WARNING: These defines must be the same as what the Xserver uses.
- * if you change them, you must change the defines in the Xserver.
- */
-
-#ifndef _VIA_DEFINES_
-#define _VIA_DEFINES_
-
-
-#define VIA_NR_SAREA_CLIPRECTS 8
-#define VIA_NR_XVMC_PORTS 10
-#define VIA_NR_XVMC_LOCKS 5
-#define VIA_MAX_CACHELINE_SIZE 64
-#define XVMCLOCKPTR(saPriv,lockNo) \
- ((__volatile__ struct drm_hw_lock *)(((((unsigned long) (saPriv)->XvMCLockArea) + \
- (VIA_MAX_CACHELINE_SIZE - 1)) & \
- ~(VIA_MAX_CACHELINE_SIZE - 1)) + \
- VIA_MAX_CACHELINE_SIZE*(lockNo)))
-
-/* Each region is a minimum of 64k, and there are at most 64 of them.
- */
-#define VIA_NR_TEX_REGIONS 64
-#define VIA_LOG_MIN_TEX_REGION_SIZE 16
-#endif
-
-#define VIA_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
-#define VIA_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
-#define VIA_UPLOAD_CTX 0x4
-#define VIA_UPLOAD_BUFFERS 0x8
-#define VIA_UPLOAD_TEX0 0x10
-#define VIA_UPLOAD_TEX1 0x20
-#define VIA_UPLOAD_CLIPRECTS 0x40
-#define VIA_UPLOAD_ALL 0xff
-
-/* VIA specific ioctls */
-#define DRM_VIA_ALLOCMEM 0x00
-#define DRM_VIA_FREEMEM 0x01
-#define DRM_VIA_AGP_INIT 0x02
-#define DRM_VIA_FB_INIT 0x03
-#define DRM_VIA_MAP_INIT 0x04
-#define DRM_VIA_DEC_FUTEX 0x05
-#define NOT_USED
-#define DRM_VIA_DMA_INIT 0x07
-#define DRM_VIA_CMDBUFFER 0x08
-#define DRM_VIA_FLUSH 0x09
-#define DRM_VIA_PCICMD 0x0a
-#define DRM_VIA_CMDBUF_SIZE 0x0b
-#define NOT_USED
-#define DRM_VIA_WAIT_IRQ 0x0d
-#define DRM_VIA_DMA_BLIT 0x0e
-#define DRM_VIA_BLIT_SYNC 0x0f
-
-#define DRM_IOCTL_VIA_ALLOCMEM DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_ALLOCMEM, drm_via_mem_t)
-#define DRM_IOCTL_VIA_FREEMEM DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_FREEMEM, drm_via_mem_t)
-#define DRM_IOCTL_VIA_AGP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_AGP_INIT, drm_via_agp_t)
-#define DRM_IOCTL_VIA_FB_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_FB_INIT, drm_via_fb_t)
-#define DRM_IOCTL_VIA_MAP_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_MAP_INIT, drm_via_init_t)
-#define DRM_IOCTL_VIA_DEC_FUTEX DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_DEC_FUTEX, drm_via_futex_t)
-#define DRM_IOCTL_VIA_DMA_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_VIA_DMA_INIT, drm_via_dma_init_t)
-#define DRM_IOCTL_VIA_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_CMDBUFFER, drm_via_cmdbuffer_t)
-#define DRM_IOCTL_VIA_FLUSH DRM_IO( DRM_COMMAND_BASE + DRM_VIA_FLUSH)
-#define DRM_IOCTL_VIA_PCICMD DRM_IOW( DRM_COMMAND_BASE + DRM_VIA_PCICMD, drm_via_cmdbuffer_t)
-#define DRM_IOCTL_VIA_CMDBUF_SIZE DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_CMDBUF_SIZE, \
- drm_via_cmdbuf_size_t)
-#define DRM_IOCTL_VIA_WAIT_IRQ DRM_IOWR( DRM_COMMAND_BASE + DRM_VIA_WAIT_IRQ, drm_via_irqwait_t)
-#define DRM_IOCTL_VIA_DMA_BLIT DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_DMA_BLIT, drm_via_dmablit_t)
-#define DRM_IOCTL_VIA_BLIT_SYNC DRM_IOW(DRM_COMMAND_BASE + DRM_VIA_BLIT_SYNC, drm_via_blitsync_t)
-
-/* Indices into buf.Setup where various bits of state are mirrored per
- * context and per buffer. These can be fired at the card as a unit,
- * or in a piecewise fashion as required.
- */
-
-#define VIA_TEX_SETUP_SIZE 8
-
-/* Flags for clear ioctl
- */
-#define VIA_FRONT 0x1
-#define VIA_BACK 0x2
-#define VIA_DEPTH 0x4
-#define VIA_STENCIL 0x8
-#define VIA_MEM_VIDEO 0 /* matches drm constant */
-#define VIA_MEM_AGP 1 /* matches drm constant */
-#define VIA_MEM_SYSTEM 2
-#define VIA_MEM_MIXED 3
-#define VIA_MEM_UNKNOWN 4
-
-typedef struct {
- __u32 offset;
- __u32 size;
-} drm_via_agp_t;
-
-typedef struct {
- __u32 offset;
- __u32 size;
-} drm_via_fb_t;
-
-typedef struct {
- __u32 context;
- __u32 type;
- __u32 size;
- unsigned long index;
- unsigned long offset;
-} drm_via_mem_t;
-
-typedef struct _drm_via_init {
- enum {
- VIA_INIT_MAP = 0x01,
- VIA_CLEANUP_MAP = 0x02
- } func;
-
- unsigned long sarea_priv_offset;
- unsigned long fb_offset;
- unsigned long mmio_offset;
- unsigned long agpAddr;
-} drm_via_init_t;
-
-typedef struct _drm_via_futex {
- enum {
- VIA_FUTEX_WAIT = 0x00,
- VIA_FUTEX_WAKE = 0X01
- } func;
- __u32 ms;
- __u32 lock;
- __u32 val;
-} drm_via_futex_t;
-
-typedef struct _drm_via_dma_init {
- enum {
- VIA_INIT_DMA = 0x01,
- VIA_CLEANUP_DMA = 0x02,
- VIA_DMA_INITIALIZED = 0x03
- } func;
-
- unsigned long offset;
- unsigned long size;
- unsigned long reg_pause_addr;
-} drm_via_dma_init_t;
-
-typedef struct _drm_via_cmdbuffer {
- char *buf;
- unsigned long size;
-} drm_via_cmdbuffer_t;
-
-/* Warning: If you change the SAREA structure you must change the Xserver
- * structure as well */
-
-typedef struct _drm_via_tex_region {
- unsigned char next, prev; /* indices to form a circular LRU */
- unsigned char inUse; /* owned by a client, or free? */
- int age; /* tracked by clients to update local LRU's */
-} drm_via_tex_region_t;
-
-typedef struct _drm_via_sarea {
- unsigned int dirty;
- unsigned int nbox;
- struct drm_clip_rect boxes[VIA_NR_SAREA_CLIPRECTS];
- drm_via_tex_region_t texList[VIA_NR_TEX_REGIONS + 1];
- int texAge; /* last time texture was uploaded */
- int ctxOwner; /* last context to upload state */
- int vertexPrim;
-
- /*
- * Below is for XvMC.
- * We want the lock integers alone on, and aligned to, a cache line.
- * Therefore this somewhat strange construct.
- */
-
- char XvMCLockArea[VIA_MAX_CACHELINE_SIZE * (VIA_NR_XVMC_LOCKS + 1)];
-
- unsigned int XvMCDisplaying[VIA_NR_XVMC_PORTS];
- unsigned int XvMCSubPicOn[VIA_NR_XVMC_PORTS];
- unsigned int XvMCCtxNoGrabbed; /* Last context to hold decoder */
-
- /* Used by the 3d driver only at this point, for pageflipping:
- */
- unsigned int pfCurrentOffset;
-} drm_via_sarea_t;
-
-typedef struct _drm_via_cmdbuf_size {
- enum {
- VIA_CMDBUF_SPACE = 0x01,
- VIA_CMDBUF_LAG = 0x02
- } func;
- int wait;
- __u32 size;
-} drm_via_cmdbuf_size_t;
-
-typedef enum {
- VIA_IRQ_ABSOLUTE = 0x0,
- VIA_IRQ_RELATIVE = 0x1,
- VIA_IRQ_SIGNAL = 0x10000000,
- VIA_IRQ_FORCE_SEQUENCE = 0x20000000
-} via_irq_seq_type_t;
-
-#define VIA_IRQ_FLAGS_MASK 0xF0000000
-
-enum drm_via_irqs {
- drm_via_irq_hqv0 = 0,
- drm_via_irq_hqv1,
- drm_via_irq_dma0_dd,
- drm_via_irq_dma0_td,
- drm_via_irq_dma1_dd,
- drm_via_irq_dma1_td,
- drm_via_irq_num
-};
-
-struct drm_via_wait_irq_request {
- unsigned irq;
- via_irq_seq_type_t type;
- __u32 sequence;
- __u32 signal;
-};
-
-typedef union drm_via_irqwait {
- struct drm_via_wait_irq_request request;
- struct drm_wait_vblank_reply reply;
-} drm_via_irqwait_t;
-
-typedef struct drm_via_blitsync {
- __u32 sync_handle;
- unsigned engine;
-} drm_via_blitsync_t;
-
-/* - * Below,"flags" is currently unused but will be used for possible future
- * extensions like kernel space bounce buffers for bad alignments and
- * blit engine busy-wait polling for better latency in the absence of
- * interrupts.
- */
-
-typedef struct drm_via_dmablit {
- __u32 num_lines;
- __u32 line_length;
-
- __u32 fb_addr;
- __u32 fb_stride;
-
- unsigned char *mem_addr;
- __u32 mem_stride;
-
- __u32 flags;
- int to_fb;
-
- drm_via_blitsync_t sync;
-} drm_via_dmablit_t;
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif /* _VIA_DRM_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/drm/virtgpu_drm.h b/lib/libc/include/any-linux-any/drm/virtgpu_drm.h
index 3e6c78ce82..087a868478 100644
--- a/lib/libc/include/any-linux-any/drm/virtgpu_drm.h
+++ b/lib/libc/include/any-linux-any/drm/virtgpu_drm.h
@@ -64,6 +64,7 @@ struct drm_virtgpu_map {
__u32 pad;
};
+/* fence_fd is modified on success if VIRTGPU_EXECBUF_FENCE_FD_OUT flag is set. */
struct drm_virtgpu_execbuffer {
__u32 flags;
__u32 size;
diff --git a/lib/libc/include/any-linux-any/drm/vmwgfx_drm.h b/lib/libc/include/any-linux-any/drm/vmwgfx_drm.h
index a711909698..ba23935853 100644
--- a/lib/libc/include/any-linux-any/drm/vmwgfx_drm.h
+++ b/lib/libc/include/any-linux-any/drm/vmwgfx_drm.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA
+ * Copyright © 2009-2022 VMware, Inc., Palo Alto, CA., USA
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -92,6 +92,12 @@ extern "C" {
*
* DRM_VMW_PARAM_SM5
* SM5 support is enabled.
+ *
+ * DRM_VMW_PARAM_GL43
+ * SM5.1+GL4.3 support is enabled.
+ *
+ * DRM_VMW_PARAM_DEVICE_ID
+ * PCI ID of the underlying SVGA device.
*/
#define DRM_VMW_PARAM_NUM_STREAMS 0
@@ -110,6 +116,8 @@ extern "C" {
#define DRM_VMW_PARAM_HW_CAPS2 13
#define DRM_VMW_PARAM_SM4_1 14
#define DRM_VMW_PARAM_SM5 15
+#define DRM_VMW_PARAM_GL43 16
+#define DRM_VMW_PARAM_DEVICE_ID 17
/**
* enum drm_vmw_handle_type - handle type for ref ioctls
diff --git a/lib/libc/include/any-linux-any/linux/acct.h b/lib/libc/include/any-linux-any/linux/acct.h
index 1498eb1f47..a6d68cf68a 100644
--- a/lib/libc/include/any-linux-any/linux/acct.h
+++ b/lib/libc/include/any-linux-any/linux/acct.h
@@ -97,12 +97,13 @@ struct acct_v3
/*
* accounting flags
*/
- /* bit set when the process ... */
+ /* bit set when the process/task ... */
#define AFORK 0x01 /* ... executed fork, but did not exec */
#define ASU 0x02 /* ... used super-user privileges */
#define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
#define ACORE 0x08 /* ... dumped core */
#define AXSIG 0x10 /* ... was killed by a signal */
+#define AGROUP 0x20 /* ... was the last task of the process (task group) */
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
#define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
diff --git a/lib/libc/include/any-linux-any/linux/acrn.h b/lib/libc/include/any-linux-any/linux/acrn.h
index 8ed142084f..02239d21b2 100644
--- a/lib/libc/include/any-linux-any/linux/acrn.h
+++ b/lib/libc/include/any-linux-any/linux/acrn.h
@@ -12,7 +12,6 @@
#define _ACRN_H
#include <linux/types.h>
-#include <linux/uuid.h>
#define ACRN_IO_REQUEST_MAX 16
@@ -186,7 +185,7 @@ struct acrn_ioreq_notify {
* @reserved0: Reserved and must be 0
* @vcpu_num: Number of vCPU in the VM. Return from hypervisor.
* @reserved1: Reserved and must be 0
- * @uuid: UUID of the VM. Pass to hypervisor directly.
+ * @uuid: Empty space never to be used again (used to be UUID of the VM)
* @vm_flag: Flag of the VM creating. Pass to hypervisor directly.
* @ioreq_buf: Service VM GPA of I/O request buffer. Pass to
* hypervisor directly.
@@ -198,7 +197,7 @@ struct acrn_vm_creation {
__u16 reserved0;
__u16 vcpu_num;
__u16 reserved1;
- guid_t uuid;
+ __u8 uuid[16];
__u64 vm_flag;
__u64 ioreq_buf;
__u64 cpu_affinity;
diff --git a/lib/libc/include/any-linux-any/linux/agpgart.h b/lib/libc/include/any-linux-any/linux/agpgart.h
index 077b9e481e..9a885d9762 100644
--- a/lib/libc/include/any-linux-any/linux/agpgart.h
+++ b/lib/libc/include/any-linux-any/linux/agpgart.h
@@ -51,7 +51,6 @@
#endif
#include <linux/types.h>
-#include <stdlib.h>
struct agp_version {
__u16 major;
@@ -63,10 +62,10 @@ typedef struct _agp_info {
__u32 bridge_id; /* bridge vendor/device */
__u32 agp_mode; /* mode info of bridge */
unsigned long aper_base;/* base of aperture */
- size_t aper_size; /* size of aperture */
- size_t pg_total; /* max pages (swap + system) */
- size_t pg_system; /* max pages (system) */
- size_t pg_used; /* current pages used */
+ __kernel_size_t aper_size; /* size of aperture */
+ __kernel_size_t pg_total; /* max pages (swap + system) */
+ __kernel_size_t pg_system; /* max pages (system) */
+ __kernel_size_t pg_used; /* current pages used */
} agp_info;
typedef struct _agp_setup {
diff --git a/lib/libc/include/any-linux-any/linux/android/binder.h b/lib/libc/include/any-linux-any/linux/android/binder.h
index 4324ae07f2..487d17f857 100644
--- a/lib/libc/include/any-linux-any/linux/android/binder.h
+++ b/lib/libc/include/any-linux-any/linux/android/binder.h
@@ -236,6 +236,21 @@ struct binder_frozen_status_info {
__u32 async_recv;
};
+/* struct binder_extened_error - extended error information
+ * @id: identifier for the failed operation
+ * @command: command as defined by binder_driver_return_protocol
+ * @param: parameter holding a negative errno value
+ *
+ * Used with BINDER_GET_EXTENDED_ERROR. This extends the error information
+ * returned by the driver upon a failed operation. Userspace can pull this
+ * data to properly handle specific error scenarios.
+ */
+struct binder_extended_error {
+ __u32 id;
+ __u32 command;
+ __s32 param;
+};
+
#define BINDER_WRITE_READ _IOWR('b', 1, struct binder_write_read)
#define BINDER_SET_IDLE_TIMEOUT _IOW('b', 3, __s64)
#define BINDER_SET_MAX_THREADS _IOW('b', 5, __u32)
@@ -249,6 +264,7 @@ struct binder_frozen_status_info {
#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
+#define BINDER_GET_EXTENDED_ERROR _IOWR('b', 17, struct binder_extended_error)
/*
* NOTE: Two special error codes you should check for when calling
@@ -271,6 +287,7 @@ enum transaction_flags {
TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */
TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */
TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */
+ TF_UPDATE_TXN = 0x40, /* update the outdated pending async txn */
};
struct binder_transaction_data {
@@ -288,8 +305,8 @@ struct binder_transaction_data {
/* General information about the transaction. */
__u32 flags;
- pid_t sender_pid;
- uid_t sender_euid;
+ __kernel_pid_t sender_pid;
+ __kernel_uid32_t sender_euid;
binder_size_t data_size; /* number of bytes of data */
binder_size_t offsets_size; /* number of bytes of offsets */
@@ -433,7 +450,7 @@ enum binder_driver_return_protocol {
BR_FROZEN_REPLY = _IO('r', 18),
/*
- * The target of the last transaction (either a bcTRANSACTION or
+ * The target of the last sync transaction (either a bcTRANSACTION or
* a bcATTEMPT_ACQUIRE) is frozen. No parameters.
*/
@@ -443,6 +460,11 @@ enum binder_driver_return_protocol {
* asynchronous transaction makes the allocated async buffer size exceed
* detection threshold. No parameters.
*/
+
+ BR_TRANSACTION_PENDING_FROZEN = _IO('r', 20),
+ /*
+ * The target of the last async transaction is frozen. No parameters.
+ */
};
enum binder_driver_command_protocol {
diff --git a/lib/libc/include/any-linux-any/linux/aspeed-video.h b/lib/libc/include/any-linux-any/linux/aspeed-video.h
new file mode 100644
index 0000000000..0dbdd4a822
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/aspeed-video.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2021 ASPEED Technology Inc.
+ */
+
+#ifndef _LINUX_ASPEED_VIDEO_H
+#define _LINUX_ASPEED_VIDEO_H
+
+#include <linux/v4l2-controls.h>
+
+#define V4L2_CID_ASPEED_HQ_MODE (V4L2_CID_USER_ASPEED_BASE + 1)
+#define V4L2_CID_ASPEED_HQ_JPEG_QUALITY (V4L2_CID_USER_ASPEED_BASE + 2)
+
+#endif /* _LINUX_ASPEED_VIDEO_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/atmbr2684.h b/lib/libc/include/any-linux-any/linux/atmbr2684.h
index 15e483b0f3..22a95f0f43 100644
--- a/lib/libc/include/any-linux-any/linux/atmbr2684.h
+++ b/lib/libc/include/any-linux-any/linux/atmbr2684.h
@@ -38,7 +38,7 @@
*/
#define BR2684_ENCAPS_VC (0) /* VC-mux */
#define BR2684_ENCAPS_LLC (1)
-#define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
+#define BR2684_ENCAPS_AUTODETECT (2) /* Unsupported */
/*
* Is this VC bridged or routed?
diff --git a/lib/libc/include/any-linux-any/linux/audit.h b/lib/libc/include/any-linux-any/linux/audit.h
index c61a48f8ac..d55a720415 100644
--- a/lib/libc/include/any-linux-any/linux/audit.h
+++ b/lib/libc/include/any-linux-any/linux/audit.h
@@ -187,7 +187,7 @@
#define AUDIT_MAX_KEY_LEN 256
#define AUDIT_BITMASK_SIZE 64
#define AUDIT_WORD(nr) ((__u32)((nr)/32))
-#define AUDIT_BIT(nr) (1 << ((nr) - AUDIT_WORD(nr)*32))
+#define AUDIT_BIT(nr) (1U << ((nr) - AUDIT_WORD(nr)*32))
#define AUDIT_SYSCALL_CLASSES 16
#define AUDIT_CLASS_DIR_WRITE 0
@@ -439,6 +439,8 @@ enum {
#define AUDIT_ARCH_UNICORE (EM_UNICORE|__AUDIT_ARCH_LE)
#define AUDIT_ARCH_X86_64 (EM_X86_64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
#define AUDIT_ARCH_XTENSA (EM_XTENSA)
+#define AUDIT_ARCH_LOONGARCH32 (EM_LOONGARCH|__AUDIT_ARCH_LE)
+#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
#define AUDIT_PERM_EXEC 1
#define AUDIT_PERM_WRITE 2
@@ -514,7 +516,7 @@ struct audit_rule_data {
__u32 values[AUDIT_MAX_FIELDS];
__u32 fieldflags[AUDIT_MAX_FIELDS];
__u32 buflen; /* total length of string fields */
- char buf[0]; /* string fields buffer */
+ char buf[]; /* string fields buffer */
};
#endif /* _LINUX_AUDIT_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/auxvec.h b/lib/libc/include/any-linux-any/linux/auxvec.h
index 6a525a0afd..628a421f48 100644
--- a/lib/libc/include/any-linux-any/linux/auxvec.h
+++ b/lib/libc/include/any-linux-any/linux/auxvec.h
@@ -30,6 +30,8 @@
* differ from AT_PLATFORM. */
#define AT_RANDOM 25 /* address of 16 random bytes */
#define AT_HWCAP2 26 /* extension of AT_HWCAP */
+#define AT_RSEQ_FEATURE_SIZE 27 /* rseq supported feature size */
+#define AT_RSEQ_ALIGN 28 /* rseq allocation alignment */
#define AT_EXECFN 31 /* filename of program */
diff --git a/lib/libc/include/any-linux-any/linux/batadv_packet.h b/lib/libc/include/any-linux-any/linux/batadv_packet.h
index b10abfee1f..790fd16b50 100644
--- a/lib/libc/include/any-linux-any/linux/batadv_packet.h
+++ b/lib/libc/include/any-linux-any/linux/batadv_packet.h
@@ -26,6 +26,7 @@
* @BATADV_CODED: network coded packets
* @BATADV_ELP: echo location packets for B.A.T.M.A.N. V
* @BATADV_OGM2: originator messages for B.A.T.M.A.N. V
+ * @BATADV_MCAST: multicast packet with multiple destination addresses
*
* @BATADV_UNICAST: unicast packets carrying unicast payload traffic
* @BATADV_UNICAST_FRAG: unicast packets carrying a fragment of the original
@@ -42,6 +43,7 @@ enum batadv_packettype {
BATADV_CODED = 0x02,
BATADV_ELP = 0x03,
BATADV_OGM2 = 0x04,
+ BATADV_MCAST = 0x05,
/* 0x40 - 0x7f: unicast */
#define BATADV_UNICAST_MIN 0x40
BATADV_UNICAST = 0x40,
diff --git a/lib/libc/include/any-linux-any/linux/blkzoned.h b/lib/libc/include/any-linux-any/linux/blkzoned.h
index d541c5b23a..fb0ae20d83 100644
--- a/lib/libc/include/any-linux-any/linux/blkzoned.h
+++ b/lib/libc/include/any-linux-any/linux/blkzoned.h
@@ -130,7 +130,7 @@ struct blk_zone_report {
__u64 sector;
__u32 nr_zones;
__u32 flags;
- struct blk_zone zones[0];
+ struct blk_zone zones[];
};
/**
diff --git a/lib/libc/include/any-linux-any/linux/bpf.h b/lib/libc/include/any-linux-any/linux/bpf.h
index d804c123f0..07430d3e3e 100644
--- a/lib/libc/include/any-linux-any/linux/bpf.h
+++ b/lib/libc/include/any-linux-any/linux/bpf.h
@@ -87,10 +87,35 @@ struct bpf_cgroup_storage_key {
__u32 attach_type; /* program attach type (enum bpf_attach_type) */
};
+enum bpf_cgroup_iter_order {
+ BPF_CGROUP_ITER_ORDER_UNSPEC = 0,
+ BPF_CGROUP_ITER_SELF_ONLY, /* process only a single object. */
+ BPF_CGROUP_ITER_DESCENDANTS_PRE, /* walk descendants in pre-order. */
+ BPF_CGROUP_ITER_DESCENDANTS_POST, /* walk descendants in post-order. */
+ BPF_CGROUP_ITER_ANCESTORS_UP, /* walk ancestors upward. */
+};
+
union bpf_iter_link_info {
struct {
__u32 map_fd;
} map;
+ struct {
+ enum bpf_cgroup_iter_order order;
+
+ /* At most one of cgroup_fd and cgroup_id can be non-zero. If
+ * both are zero, the walk starts from the default cgroup v2
+ * root. For walking v1 hierarchy, one should always explicitly
+ * specify cgroup_fd.
+ */
+ __u32 cgroup_fd;
+ __u64 cgroup_id;
+ } cgroup;
+ /* Parameters of task iterators. */
+ struct {
+ __u32 tid;
+ __u32 pid;
+ __u32 pid_fd;
+ } task;
};
/* BPF syscall commands, see bpf(2) man-page for more details. */
@@ -330,6 +355,8 @@ union bpf_iter_link_info {
* *ctx_out*, *data_in* and *data_out* must be NULL.
* *repeat* must be zero.
*
+ * BPF_PROG_RUN is an alias for BPF_PROG_TEST_RUN.
+ *
* Return
* Returns zero on success. On error, -1 is returned and *errno*
* is set appropriately.
@@ -895,7 +922,14 @@ enum bpf_map_type {
BPF_MAP_TYPE_CPUMAP,
BPF_MAP_TYPE_XSKMAP,
BPF_MAP_TYPE_SOCKHASH,
- BPF_MAP_TYPE_CGROUP_STORAGE,
+ BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
+ /* BPF_MAP_TYPE_CGROUP_STORAGE is available to bpf programs attaching
+ * to a cgroup. The newer BPF_MAP_TYPE_CGRP_STORAGE is available to
+ * both cgroup-attached and other progs and supports all functionality
+ * provided by BPF_MAP_TYPE_CGROUP_STORAGE. So mark
+ * BPF_MAP_TYPE_CGROUP_STORAGE deprecated.
+ */
+ BPF_MAP_TYPE_CGROUP_STORAGE = BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED,
BPF_MAP_TYPE_REUSEPORT_SOCKARRAY,
BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE,
BPF_MAP_TYPE_QUEUE,
@@ -907,6 +941,8 @@ enum bpf_map_type {
BPF_MAP_TYPE_INODE_STORAGE,
BPF_MAP_TYPE_TASK_STORAGE,
BPF_MAP_TYPE_BLOOM_FILTER,
+ BPF_MAP_TYPE_USER_RINGBUF,
+ BPF_MAP_TYPE_CGRP_STORAGE,
};
/* Note that tracing related programs such as
@@ -995,6 +1031,8 @@ enum bpf_attach_type {
BPF_SK_REUSEPORT_SELECT,
BPF_SK_REUSEPORT_SELECT_OR_MIGRATE,
BPF_PERF_EVENT,
+ BPF_TRACE_KPROBE_MULTI,
+ BPF_LSM_CGROUP,
__MAX_BPF_ATTACH_TYPE
};
@@ -1009,6 +1047,8 @@ enum bpf_link_type {
BPF_LINK_TYPE_NETNS = 5,
BPF_LINK_TYPE_XDP = 6,
BPF_LINK_TYPE_PERF_EVENT = 7,
+ BPF_LINK_TYPE_KPROBE_MULTI = 8,
+ BPF_LINK_TYPE_STRUCT_OPS = 9,
MAX_BPF_LINK_TYPE,
};
@@ -1111,6 +1151,21 @@ enum bpf_link_type {
*/
#define BPF_F_SLEEPABLE (1U << 4)
+/* If BPF_F_XDP_HAS_FRAGS is used in BPF_PROG_LOAD command, the loaded program
+ * fully support xdp frags.
+ */
+#define BPF_F_XDP_HAS_FRAGS (1U << 5)
+
+/* If BPF_F_XDP_DEV_BOUND_ONLY is used in BPF_PROG_LOAD command, the loaded
+ * program becomes device-bound but can access XDP metadata.
+ */
+#define BPF_F_XDP_DEV_BOUND_ONLY (1U << 6)
+
+/* link_create.kprobe_multi.flags used in LINK_CREATE command for
+ * BPF_TRACE_KPROBE_MULTI attach type to create return probe.
+ */
+#define BPF_F_KPROBE_MULTI_RETURN (1U << 0)
+
/* When BPF ldimm64's insn[0].src_reg != 0 then this can have
* the following extensions:
*
@@ -1217,7 +1272,7 @@ enum {
/* Query effective (directly attached + inherited from ancestor cgroups)
* programs that will be executed for events within a cgroup.
- * attach_flags with this flag are returned only for directly attached programs.
+ * attach_flags with this flag are always returned 0.
*/
#define BPF_F_QUERY_EFFECTIVE (1U << 0)
@@ -1225,6 +1280,8 @@ enum {
/* If set, run the test on the cpu specified by bpf_attr.test.cpu */
#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
+/* If set, XDP frames will be transmitted after processing */
+#define BPF_F_TEST_XDP_LIVE_FRAMES (1U << 1)
/* type for BPF_ENABLE_STATS */
enum bpf_stats_type {
@@ -1342,8 +1399,10 @@ union bpf_attr {
/* or valid module BTF object fd or 0 to attach to vmlinux */
__u32 attach_btf_obj_fd;
};
- __u32 :32; /* pad */
+ __u32 core_relo_cnt; /* number of bpf_core_relo */
__aligned_u64 fd_array; /* array of FDs */
+ __aligned_u64 core_relos;
+ __u32 core_relo_rec_size; /* sizeof(struct bpf_core_relo) */
};
struct { /* anonymous struct used by BPF_OBJ_* commands */
@@ -1384,6 +1443,7 @@ union bpf_attr {
__aligned_u64 ctx_out;
__u32 flags;
__u32 cpu;
+ __u32 batch_size;
} test;
struct { /* anonymous struct used by BPF_*_GET_*_ID */
@@ -1411,6 +1471,10 @@ union bpf_attr {
__u32 attach_flags;
__aligned_u64 prog_ids;
__u32 prog_cnt;
+ /* output: per-program attach_flags.
+ * not allowed to be set during effective query.
+ */
+ __aligned_u64 prog_attach_flags;
} query;
struct { /* anonymous struct used by BPF_RAW_TRACEPOINT_OPEN command */
@@ -1463,6 +1527,22 @@ union bpf_attr {
*/
__u64 bpf_cookie;
} perf_event;
+ struct {
+ __u32 flags;
+ __u32 cnt;
+ __aligned_u64 syms;
+ __aligned_u64 addrs;
+ __aligned_u64 cookies;
+ } kprobe_multi;
+ struct {
+ /* this is overlaid with the target_btf_id above. */
+ __u32 target_btf_id;
+ /* black box user-provided value passed through
+ * to BPF program at the execution time and
+ * accessible through bpf_get_attach_cookie() BPF helper
+ */
+ __u64 cookie;
+ } tracing;
};
} link_create;
@@ -1744,7 +1824,7 @@ union bpf_attr {
* if the maximum number of tail calls has been reached for this
* chain of programs. This limit is defined in the kernel by the
* macro **MAX_TAIL_CALL_CNT** (not accessible to user space),
- * which is currently set to 32.
+ * which is currently set to 33.
* Return
* 0 on success, or a negative error in case of failure.
*
@@ -1773,6 +1853,8 @@ union bpf_attr {
* 0 on success, or a negative error in case of failure.
*
* u64 bpf_get_current_pid_tgid(void)
+ * Description
+ * Get the current pid and tgid.
* Return
* A 64-bit integer containing the current tgid and pid, and
* created as such:
@@ -1780,6 +1862,8 @@ union bpf_attr {
* *current_task*\ **->pid**.
*
* u64 bpf_get_current_uid_gid(void)
+ * Description
+ * Get the current uid and gid.
* Return
* A 64-bit integer containing the current GID and UID, and
* created as such: *current_gid* **<< 32 \|** *current_uid*.
@@ -1922,6 +2006,9 @@ union bpf_attr {
* sending the packet. This flag was added for GRE
* encapsulation, but might be used with other protocols
* as well in the future.
+ * **BPF_F_NO_TUNNEL_KEY**
+ * Add a flag to tunnel metadata indicating that no tunnel
+ * key should be set in the resulting tunnel header.
*
* Here is a typical usage on the transmit path:
*
@@ -2254,6 +2341,8 @@ union bpf_attr {
* The 32-bit hash.
*
* u64 bpf_get_current_task(void)
+ * Description
+ * Get the current task.
* Return
* A pointer to the current task struct.
*
@@ -2284,8 +2373,8 @@ union bpf_attr {
* Return
* The return value depends on the result of the test, and can be:
*
- * * 0, if current task belongs to the cgroup2.
- * * 1, if current task does not belong to the cgroup2.
+ * * 1, if current task belongs to the cgroup2.
+ * * 0, if current task does not belong to the cgroup2.
* * A negative error code, if an error occurred.
*
* long bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags)
@@ -2317,7 +2406,8 @@ union bpf_attr {
* Pull in non-linear data in case the *skb* is non-linear and not
* all of *len* are part of the linear section. Make *len* bytes
* from *skb* readable and writable. If a zero value is passed for
- * *len*, then the whole length of the *skb* is pulled.
+ * *len*, then all bytes in the linear part of *skb* will be made
+ * readable and writable.
*
* This helper is only needed for reading and writing with direct
* packet access.
@@ -2367,6 +2457,8 @@ union bpf_attr {
* indicate that the hash is outdated and to trigger a
* recalculation the next time the kernel tries to access this
* hash or when the **bpf_get_hash_recalc**\ () helper is called.
+ * Return
+ * void.
*
* long bpf_get_numa_node_id(void)
* Description
@@ -2464,6 +2556,8 @@ union bpf_attr {
* A 8-byte long unique number or 0 if *sk* is NULL.
*
* u32 bpf_get_socket_uid(struct sk_buff *skb)
+ * Description
+ * Get the owner UID of the socked associated to *skb*.
* Return
* The owner UID of the socket associated to *skb*. If the socket
* is **NULL**, or if it is not a full socket (i.e. if it is a
@@ -2498,14 +2592,19 @@ union bpf_attr {
* * **SOL_SOCKET**, which supports the following *optname*\ s:
* **SO_RCVBUF**, **SO_SNDBUF**, **SO_MAX_PACING_RATE**,
* **SO_PRIORITY**, **SO_RCVLOWAT**, **SO_MARK**,
- * **SO_BINDTODEVICE**, **SO_KEEPALIVE**.
+ * **SO_BINDTODEVICE**, **SO_KEEPALIVE**, **SO_REUSEADDR**,
+ * **SO_REUSEPORT**, **SO_BINDTOIFINDEX**, **SO_TXREHASH**.
* * **IPPROTO_TCP**, which supports the following *optname*\ s:
* **TCP_CONGESTION**, **TCP_BPF_IW**,
* **TCP_BPF_SNDCWND_CLAMP**, **TCP_SAVE_SYN**,
* **TCP_KEEPIDLE**, **TCP_KEEPINTVL**, **TCP_KEEPCNT**,
- * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**.
+ * **TCP_SYNCNT**, **TCP_USER_TIMEOUT**, **TCP_NOTSENT_LOWAT**,
+ * **TCP_NODELAY**, **TCP_MAXSEG**, **TCP_WINDOW_CLAMP**,
+ * **TCP_THIN_LINEAR_TIMEOUTS**, **TCP_BPF_DELACK_MAX**,
+ * **TCP_BPF_RTO_MIN**.
* * **IPPROTO_IP**, which supports *optname* **IP_TOS**.
- * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**.
+ * * **IPPROTO_IPV6**, which supports the following *optname*\ s:
+ * **IPV6_TCLASS**, **IPV6_AUTOFLOWLABEL**.
* Return
* 0 on success, or a negative error in case of failure.
*
@@ -2524,10 +2623,12 @@ union bpf_attr {
* There are two supported modes at this time:
*
* * **BPF_ADJ_ROOM_MAC**: Adjust room at the mac layer
- * (room space is added or removed below the layer 2 header).
+ * (room space is added or removed between the layer 2 and
+ * layer 3 headers).
*
* * **BPF_ADJ_ROOM_NET**: Adjust room at the network layer
- * (room space is added or removed below the layer 3 header).
+ * (room space is added or removed between the layer 3 and
+ * layer 4 headers).
*
* The following flags are supported at this time:
*
@@ -2551,6 +2652,11 @@ union bpf_attr {
* Use with BPF_F_ADJ_ROOM_ENCAP_L2 flag to further specify the
* L2 type as Ethernet.
*
+ * * **BPF_F_ADJ_ROOM_DECAP_L3_IPV4**,
+ * **BPF_F_ADJ_ROOM_DECAP_L3_IPV6**:
+ * Indicate the new IP header version after decapsulating the outer
+ * IP header. Used when the inner and outer IP versions are different.
+ *
* A call to this helper is susceptible to change the underlying
* packet buffer. Therefore, at load time, all checks on pointers
* previously done by the verifier are invalidated and must be
@@ -2559,7 +2665,7 @@ union bpf_attr {
* Return
* 0 on success, or a negative error in case of failure.
*
- * long bpf_redirect_map(struct bpf_map *map, u32 key, u64 flags)
+ * long bpf_redirect_map(struct bpf_map *map, u64 key, u64 flags)
* Description
* Redirect the packet to the endpoint referenced by *map* at
* index *key*. Depending on its type, this *map* can contain
@@ -2695,7 +2801,7 @@ union bpf_attr {
*
* long bpf_perf_prog_read_value(struct bpf_perf_event_data *ctx, struct bpf_perf_event_value *buf, u32 buf_size)
* Description
- * For en eBPF program attached to a perf event, retrieve the
+ * For an eBPF program attached to a perf event, retrieve the
* value of the event counter associated to *ctx* and store it in
* the structure pointed by *buf* and of size *buf_size*. Enabled
* and running times are also stored in the structure (see
@@ -2720,12 +2826,10 @@ union bpf_attr {
* and **BPF_CGROUP_INET6_CONNECT**.
*
* This helper actually implements a subset of **getsockopt()**.
- * It supports the following *level*\ s:
- *
- * * **IPPROTO_TCP**, which supports *optname*
- * **TCP_CONGESTION**.
- * * **IPPROTO_IP**, which supports *optname* **IP_TOS**.
- * * **IPPROTO_IPV6**, which supports *optname* **IPV6_TCLASS**.
+ * It supports the same set of *optname*\ s that is supported by
+ * the **bpf_setsockopt**\ () helper. The exceptions are
+ * **TCP_BPF_*** is **bpf_setsockopt**\ () only and
+ * **TCP_SAVED_SYN** is **bpf_getsockopt**\ () only.
* Return
* 0 on success, or a negative error in case of failure.
*
@@ -2959,8 +3063,18 @@ union bpf_attr {
* **BPF_F_USER_STACK**
* Collect a user space stack instead of a kernel stack.
* **BPF_F_USER_BUILD_ID**
- * Collect buildid+offset instead of ips for user stack,
- * only valid if **BPF_F_USER_STACK** is also specified.
+ * Collect (build_id, file_offset) instead of ips for user
+ * stack, only valid if **BPF_F_USER_STACK** is also
+ * specified.
+ *
+ * *file_offset* is an offset relative to the beginning
+ * of the executable or shared object file backing the vma
+ * which the *ip* falls in. It is *not* an offset relative
+ * to that object's base address. Accordingly, it must be
+ * adjusted by adding (sh_addr - sh_offset), where
+ * sh_{addr,offset} correspond to the executable section
+ * containing *file_offset* in the object, for comparisons
+ * to symbols' st_value to be valid.
*
* **bpf_get_stack**\ () can collect up to
* **PERF_MAX_STACK_DEPTH** both kernel and user frames, subject
@@ -2973,8 +3087,8 @@ union bpf_attr {
*
* # sysctl kernel.perf_event_max_stack=<new value>
* Return
- * A non-negative value equal to or less than *size* on success,
- * or a negative error in case of failure.
+ * The non-negative copied *buf* length equal to or less than
+ * *size* on success, or a negative error in case of failure.
*
* long bpf_skb_load_bytes_relative(const void *skb, u32 offset, void *to, u32 len, u32 start_header)
* Description
@@ -3020,6 +3134,11 @@ union bpf_attr {
* **BPF_FIB_LOOKUP_OUTPUT**
* Perform lookup from an egress perspective (default is
* ingress).
+ * **BPF_FIB_LOOKUP_SKIP_NEIGH**
+ * Skip the neighbour table lookup. *params*->dmac
+ * and *params*->smac will not be set as output. A common
+ * use case is to call **bpf_redirect_neigh**\ () after
+ * doing **bpf_fib_lookup**\ ().
*
* *ctx* is either **struct xdp_md** for XDP programs or
* **struct sk_buff** tc cls_act programs.
@@ -3238,6 +3357,9 @@ union bpf_attr {
* The id is returned or 0 in case the id could not be retrieved.
*
* u64 bpf_get_current_cgroup_id(void)
+ * Description
+ * Get the current cgroup id based on the cgroup within which
+ * the current task is running.
* Return
* A 64-bit integer containing the current cgroup id based
* on the cgroup within which the current task is running.
@@ -3548,10 +3670,11 @@ union bpf_attr {
*
* *iph* points to the start of the IPv4 or IPv6 header, while
* *iph_len* contains **sizeof**\ (**struct iphdr**) or
- * **sizeof**\ (**struct ip6hdr**).
+ * **sizeof**\ (**struct ipv6hdr**).
*
* *th* points to the start of the TCP header, while *th_len*
- * contains **sizeof**\ (**struct tcphdr**).
+ * contains the length of the TCP header (at least
+ * **sizeof**\ (**struct tcphdr**)).
* Return
* 0 if *iph* and *th* are a valid SYN cookie ACK, or a negative
* error otherwise.
@@ -3734,10 +3857,11 @@ union bpf_attr {
*
* *iph* points to the start of the IPv4 or IPv6 header, while
* *iph_len* contains **sizeof**\ (**struct iphdr**) or
- * **sizeof**\ (**struct ip6hdr**).
+ * **sizeof**\ (**struct ipv6hdr**).
*
* *th* points to the start of the TCP header, while *th_len*
- * contains the length of the TCP header.
+ * contains the length of the TCP header with options (at least
+ * **sizeof**\ (**struct tcphdr**)).
* Return
* On success, lower 32 bits hold the generated SYN cookie in
* followed by 16 bits which hold the MSS value for that cookie,
@@ -4277,8 +4401,8 @@ union bpf_attr {
*
* # sysctl kernel.perf_event_max_stack=<new value>
* Return
- * A non-negative value equal to or less than *size* on success,
- * or a negative error in case of failure.
+ * The non-negative copied *buf* length equal to or less than
+ * *size* on success, or a negative error in case of failure.
*
* long bpf_load_hdr_opt(struct bpf_sock_ops *skops, void *searchby_res, u32 len, u64 flags)
* Description
@@ -4371,7 +4495,7 @@ union bpf_attr {
*
* **-EEXIST** if the option already exists.
*
- * **-EFAULT** on failrue to parse the existing header options.
+ * **-EFAULT** on failure to parse the existing header options.
*
* **-EPERM** if the helper cannot be used under the current
* *skops*\ **->op**.
@@ -4580,7 +4704,7 @@ union bpf_attr {
* a *map* with *task* as the **key**. From this
* perspective, the usage is not much different from
* **bpf_map_lookup_elem**\ (*map*, **&**\ *task*) except this
- * helper enforces the key must be an task_struct and the map must also
+ * helper enforces the key must be a task_struct and the map must also
* be a **BPF_MAP_TYPE_TASK_STORAGE**.
*
* Underneath, the value is stored locally at *task* instead of
@@ -4638,7 +4762,7 @@ union bpf_attr {
*
* long bpf_ima_inode_hash(struct inode *inode, void *dst, u32 size)
* Description
- * Returns the stored IMA hash of the *inode* (if it's avaialable).
+ * Returns the stored IMA hash of the *inode* (if it's available).
* If the hash is larger than *size*, then only *size*
* bytes will be copied to *dst*
* Return
@@ -4662,12 +4786,12 @@ union bpf_attr {
*
* The argument *len_diff* can be used for querying with a planned
* size change. This allows to check MTU prior to changing packet
- * ctx. Providing an *len_diff* adjustment that is larger than the
+ * ctx. Providing a *len_diff* adjustment that is larger than the
* actual packet size (resulting in negative packet size) will in
- * principle not exceed the MTU, why it is not considered a
- * failure. Other BPF-helpers are needed for performing the
- * planned size change, why the responsability for catch a negative
- * packet size belong in those helpers.
+ * principle not exceed the MTU, which is why it is not considered
+ * a failure. Other BPF helpers are needed for performing the
+ * planned size change; therefore the responsibility for catching
+ * a negative packet size belongs in those helpers.
*
* Specifying *ifindex* zero means the MTU check is performed
* against the current net device. This is practical if this isn't
@@ -4865,6 +4989,7 @@ union bpf_attr {
* Get address of the traced function (for tracing and kprobe programs).
* Return
* Address of the traced function.
+ * 0 for kprobes placed within the function (not at the entry).
*
* u64 bpf_get_attach_cookie(void *ctx)
* Description
@@ -4938,196 +5063,673 @@ union bpf_attr {
* **-ENOENT** if symbol is not found.
*
* **-EPERM** if caller does not have permission to obtain kernel address.
+ *
+ * long bpf_find_vma(struct task_struct *task, u64 addr, void *callback_fn, void *callback_ctx, u64 flags)
+ * Description
+ * Find vma of *task* that contains *addr*, call *callback_fn*
+ * function with *task*, *vma*, and *callback_ctx*.
+ * The *callback_fn* should be a static function and
+ * the *callback_ctx* should be a pointer to the stack.
+ * The *flags* is used to control certain aspects of the helper.
+ * Currently, the *flags* must be 0.
+ *
+ * The expected callback signature is
+ *
+ * long (\*callback_fn)(struct task_struct \*task, struct vm_area_struct \*vma, void \*callback_ctx);
+ *
+ * Return
+ * 0 on success.
+ * **-ENOENT** if *task->mm* is NULL, or no vma contains *addr*.
+ * **-EBUSY** if failed to try lock mmap_lock.
+ * **-EINVAL** for invalid **flags**.
+ *
+ * long bpf_loop(u32 nr_loops, void *callback_fn, void *callback_ctx, u64 flags)
+ * Description
+ * For **nr_loops**, call **callback_fn** function
+ * with **callback_ctx** as the context parameter.
+ * The **callback_fn** should be a static function and
+ * the **callback_ctx** should be a pointer to the stack.
+ * The **flags** is used to control certain aspects of the helper.
+ * Currently, the **flags** must be 0. Currently, nr_loops is
+ * limited to 1 << 23 (~8 million) loops.
+ *
+ * long (\*callback_fn)(u32 index, void \*ctx);
+ *
+ * where **index** is the current index in the loop. The index
+ * is zero-indexed.
+ *
+ * If **callback_fn** returns 0, the helper will continue to the next
+ * loop. If return value is 1, the helper will skip the rest of
+ * the loops and return. Other return values are not used now,
+ * and will be rejected by the verifier.
+ *
+ * Return
+ * The number of loops performed, **-EINVAL** for invalid **flags**,
+ * **-E2BIG** if **nr_loops** exceeds the maximum number of loops.
+ *
+ * long bpf_strncmp(const char *s1, u32 s1_sz, const char *s2)
+ * Description
+ * Do strncmp() between **s1** and **s2**. **s1** doesn't need
+ * to be null-terminated and **s1_sz** is the maximum storage
+ * size of **s1**. **s2** must be a read-only string.
+ * Return
+ * An integer less than, equal to, or greater than zero
+ * if the first **s1_sz** bytes of **s1** is found to be
+ * less than, to match, or be greater than **s2**.
+ *
+ * long bpf_get_func_arg(void *ctx, u32 n, u64 *value)
+ * Description
+ * Get **n**-th argument register (zero based) of the traced function (for tracing programs)
+ * returned in **value**.
+ *
+ * Return
+ * 0 on success.
+ * **-EINVAL** if n >= argument register count of traced function.
+ *
+ * long bpf_get_func_ret(void *ctx, u64 *value)
+ * Description
+ * Get return value of the traced function (for tracing programs)
+ * in **value**.
+ *
+ * Return
+ * 0 on success.
+ * **-EOPNOTSUPP** for tracing programs other than BPF_TRACE_FEXIT or BPF_MODIFY_RETURN.
+ *
+ * long bpf_get_func_arg_cnt(void *ctx)
+ * Description
+ * Get number of registers of the traced function (for tracing programs) where
+ * function arguments are stored in these registers.
+ *
+ * Return
+ * The number of argument registers of the traced function.
+ *
+ * int bpf_get_retval(void)
+ * Description
+ * Get the BPF program's return value that will be returned to the upper layers.
+ *
+ * This helper is currently supported by cgroup programs and only by the hooks
+ * where BPF program's return value is returned to the userspace via errno.
+ * Return
+ * The BPF program's return value.
+ *
+ * int bpf_set_retval(int retval)
+ * Description
+ * Set the BPF program's return value that will be returned to the upper layers.
+ *
+ * This helper is currently supported by cgroup programs and only by the hooks
+ * where BPF program's return value is returned to the userspace via errno.
+ *
+ * Note that there is the following corner case where the program exports an error
+ * via bpf_set_retval but signals success via 'return 1':
+ *
+ * bpf_set_retval(-EPERM);
+ * return 1;
+ *
+ * In this case, the BPF program's return value will use helper's -EPERM. This
+ * still holds true for cgroup/bind{4,6} which supports extra 'return 3' success case.
+ *
+ * Return
+ * 0 on success, or a negative error in case of failure.
+ *
+ * u64 bpf_xdp_get_buff_len(struct xdp_buff *xdp_md)
+ * Description
+ * Get the total size of a given xdp buff (linear and paged area)
+ * Return
+ * The total size of a given xdp buffer.
+ *
+ * long bpf_xdp_load_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len)
+ * Description
+ * This helper is provided as an easy way to load data from a
+ * xdp buffer. It can be used to load *len* bytes from *offset* from
+ * the frame associated to *xdp_md*, into the buffer pointed by
+ * *buf*.
+ * Return
+ * 0 on success, or a negative error in case of failure.
+ *
+ * long bpf_xdp_store_bytes(struct xdp_buff *xdp_md, u32 offset, void *buf, u32 len)
+ * Description
+ * Store *len* bytes from buffer *buf* into the frame
+ * associated to *xdp_md*, at *offset*.
+ * Return
+ * 0 on success, or a negative error in case of failure.
+ *
+ * long bpf_copy_from_user_task(void *dst, u32 size, const void *user_ptr, struct task_struct *tsk, u64 flags)
+ * Description
+ * Read *size* bytes from user space address *user_ptr* in *tsk*'s
+ * address space, and stores the data in *dst*. *flags* is not
+ * used yet and is provided for future extensibility. This helper
+ * can only be used by sleepable programs.
+ * Return
+ * 0 on success, or a negative error in case of failure. On error
+ * *dst* buffer is zeroed out.
+ *
+ * long bpf_skb_set_tstamp(struct sk_buff *skb, u64 tstamp, u32 tstamp_type)
+ * Description
+ * Change the __sk_buff->tstamp_type to *tstamp_type*
+ * and set *tstamp* to the __sk_buff->tstamp together.
+ *
+ * If there is no need to change the __sk_buff->tstamp_type,
+ * the tstamp value can be directly written to __sk_buff->tstamp
+ * instead.
+ *
+ * BPF_SKB_TSTAMP_DELIVERY_MONO is the only tstamp that
+ * will be kept during bpf_redirect_*(). A non zero
+ * *tstamp* must be used with the BPF_SKB_TSTAMP_DELIVERY_MONO
+ * *tstamp_type*.
+ *
+ * A BPF_SKB_TSTAMP_UNSPEC *tstamp_type* can only be used
+ * with a zero *tstamp*.
+ *
+ * Only IPv4 and IPv6 skb->protocol are supported.
+ *
+ * This function is most useful when it needs to set a
+ * mono delivery time to __sk_buff->tstamp and then
+ * bpf_redirect_*() to the egress of an iface. For example,
+ * changing the (rcv) timestamp in __sk_buff->tstamp at
+ * ingress to a mono delivery time and then bpf_redirect_*()
+ * to sch_fq@phy-dev.
+ * Return
+ * 0 on success.
+ * **-EINVAL** for invalid input
+ * **-EOPNOTSUPP** for unsupported protocol
+ *
+ * long bpf_ima_file_hash(struct file *file, void *dst, u32 size)
+ * Description
+ * Returns a calculated IMA hash of the *file*.
+ * If the hash is larger than *size*, then only *size*
+ * bytes will be copied to *dst*
+ * Return
+ * The **hash_algo** is returned on success,
+ * **-EOPNOTSUP** if the hash calculation failed or **-EINVAL** if
+ * invalid arguments are passed.
+ *
+ * void *bpf_kptr_xchg(void *map_value, void *ptr)
+ * Description
+ * Exchange kptr at pointer *map_value* with *ptr*, and return the
+ * old value. *ptr* can be NULL, otherwise it must be a referenced
+ * pointer which will be released when this helper is called.
+ * Return
+ * The old value of kptr (which can be NULL). The returned pointer
+ * if not NULL, is a reference which must be released using its
+ * corresponding release function, or moved into a BPF map before
+ * program exit.
+ *
+ * void *bpf_map_lookup_percpu_elem(struct bpf_map *map, const void *key, u32 cpu)
+ * Description
+ * Perform a lookup in *percpu map* for an entry associated to
+ * *key* on *cpu*.
+ * Return
+ * Map value associated to *key* on *cpu*, or **NULL** if no entry
+ * was found or *cpu* is invalid.
+ *
+ * struct mptcp_sock *bpf_skc_to_mptcp_sock(void *sk)
+ * Description
+ * Dynamically cast a *sk* pointer to a *mptcp_sock* pointer.
+ * Return
+ * *sk* if casting is valid, or **NULL** otherwise.
+ *
+ * long bpf_dynptr_from_mem(void *data, u32 size, u64 flags, struct bpf_dynptr *ptr)
+ * Description
+ * Get a dynptr to local memory *data*.
+ *
+ * *data* must be a ptr to a map value.
+ * The maximum *size* supported is DYNPTR_MAX_SIZE.
+ * *flags* is currently unused.
+ * Return
+ * 0 on success, -E2BIG if the size exceeds DYNPTR_MAX_SIZE,
+ * -EINVAL if flags is not 0.
+ *
+ * long bpf_ringbuf_reserve_dynptr(void *ringbuf, u32 size, u64 flags, struct bpf_dynptr *ptr)
+ * Description
+ * Reserve *size* bytes of payload in a ring buffer *ringbuf*
+ * through the dynptr interface. *flags* must be 0.
+ *
+ * Please note that a corresponding bpf_ringbuf_submit_dynptr or
+ * bpf_ringbuf_discard_dynptr must be called on *ptr*, even if the
+ * reservation fails. This is enforced by the verifier.
+ * Return
+ * 0 on success, or a negative error in case of failure.
+ *
+ * void bpf_ringbuf_submit_dynptr(struct bpf_dynptr *ptr, u64 flags)
+ * Description
+ * Submit reserved ring buffer sample, pointed to by *data*,
+ * through the dynptr interface. This is a no-op if the dynptr is
+ * invalid/null.
+ *
+ * For more information on *flags*, please see
+ * 'bpf_ringbuf_submit'.
+ * Return
+ * Nothing. Always succeeds.
+ *
+ * void bpf_ringbuf_discard_dynptr(struct bpf_dynptr *ptr, u64 flags)
+ * Description
+ * Discard reserved ring buffer sample through the dynptr
+ * interface. This is a no-op if the dynptr is invalid/null.
+ *
+ * For more information on *flags*, please see
+ * 'bpf_ringbuf_discard'.
+ * Return
+ * Nothing. Always succeeds.
+ *
+ * long bpf_dynptr_read(void *dst, u32 len, const struct bpf_dynptr *src, u32 offset, u64 flags)
+ * Description
+ * Read *len* bytes from *src* into *dst*, starting from *offset*
+ * into *src*.
+ * *flags* is currently unused.
+ * Return
+ * 0 on success, -E2BIG if *offset* + *len* exceeds the length
+ * of *src*'s data, -EINVAL if *src* is an invalid dynptr or if
+ * *flags* is not 0.
+ *
+ * long bpf_dynptr_write(const struct bpf_dynptr *dst, u32 offset, void *src, u32 len, u64 flags)
+ * Description
+ * Write *len* bytes from *src* into *dst*, starting from *offset*
+ * into *dst*.
+ * *flags* is currently unused.
+ * Return
+ * 0 on success, -E2BIG if *offset* + *len* exceeds the length
+ * of *dst*'s data, -EINVAL if *dst* is an invalid dynptr or if *dst*
+ * is a read-only dynptr or if *flags* is not 0.
+ *
+ * void *bpf_dynptr_data(const struct bpf_dynptr *ptr, u32 offset, u32 len)
+ * Description
+ * Get a pointer to the underlying dynptr data.
+ *
+ * *len* must be a statically known value. The returned data slice
+ * is invalidated whenever the dynptr is invalidated.
+ * Return
+ * Pointer to the underlying dynptr data, NULL if the dynptr is
+ * read-only, if the dynptr is invalid, or if the offset and length
+ * is out of bounds.
+ *
+ * s64 bpf_tcp_raw_gen_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th, u32 th_len)
+ * Description
+ * Try to issue a SYN cookie for the packet with corresponding
+ * IPv4/TCP headers, *iph* and *th*, without depending on a
+ * listening socket.
+ *
+ * *iph* points to the IPv4 header.
+ *
+ * *th* points to the start of the TCP header, while *th_len*
+ * contains the length of the TCP header (at least
+ * **sizeof**\ (**struct tcphdr**)).
+ * Return
+ * On success, lower 32 bits hold the generated SYN cookie in
+ * followed by 16 bits which hold the MSS value for that cookie,
+ * and the top 16 bits are unused.
+ *
+ * On failure, the returned value is one of the following:
+ *
+ * **-EINVAL** if *th_len* is invalid.
+ *
+ * s64 bpf_tcp_raw_gen_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th, u32 th_len)
+ * Description
+ * Try to issue a SYN cookie for the packet with corresponding
+ * IPv6/TCP headers, *iph* and *th*, without depending on a
+ * listening socket.
+ *
+ * *iph* points to the IPv6 header.
+ *
+ * *th* points to the start of the TCP header, while *th_len*
+ * contains the length of the TCP header (at least
+ * **sizeof**\ (**struct tcphdr**)).
+ * Return
+ * On success, lower 32 bits hold the generated SYN cookie in
+ * followed by 16 bits which hold the MSS value for that cookie,
+ * and the top 16 bits are unused.
+ *
+ * On failure, the returned value is one of the following:
+ *
+ * **-EINVAL** if *th_len* is invalid.
+ *
+ * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin.
+ *
+ * long bpf_tcp_raw_check_syncookie_ipv4(struct iphdr *iph, struct tcphdr *th)
+ * Description
+ * Check whether *iph* and *th* contain a valid SYN cookie ACK
+ * without depending on a listening socket.
+ *
+ * *iph* points to the IPv4 header.
+ *
+ * *th* points to the TCP header.
+ * Return
+ * 0 if *iph* and *th* are a valid SYN cookie ACK.
+ *
+ * On failure, the returned value is one of the following:
+ *
+ * **-EACCES** if the SYN cookie is not valid.
+ *
+ * long bpf_tcp_raw_check_syncookie_ipv6(struct ipv6hdr *iph, struct tcphdr *th)
+ * Description
+ * Check whether *iph* and *th* contain a valid SYN cookie ACK
+ * without depending on a listening socket.
+ *
+ * *iph* points to the IPv6 header.
+ *
+ * *th* points to the TCP header.
+ * Return
+ * 0 if *iph* and *th* are a valid SYN cookie ACK.
+ *
+ * On failure, the returned value is one of the following:
+ *
+ * **-EACCES** if the SYN cookie is not valid.
+ *
+ * **-EPROTONOSUPPORT** if CONFIG_IPV6 is not builtin.
+ *
+ * u64 bpf_ktime_get_tai_ns(void)
+ * Description
+ * A nonsettable system-wide clock derived from wall-clock time but
+ * ignoring leap seconds. This clock does not experience
+ * discontinuities and backwards jumps caused by NTP inserting leap
+ * seconds as CLOCK_REALTIME does.
+ *
+ * See: **clock_gettime**\ (**CLOCK_TAI**)
+ * Return
+ * Current *ktime*.
+ *
+ * long bpf_user_ringbuf_drain(struct bpf_map *map, void *callback_fn, void *ctx, u64 flags)
+ * Description
+ * Drain samples from the specified user ring buffer, and invoke
+ * the provided callback for each such sample:
+ *
+ * long (\*callback_fn)(const struct bpf_dynptr \*dynptr, void \*ctx);
+ *
+ * If **callback_fn** returns 0, the helper will continue to try
+ * and drain the next sample, up to a maximum of
+ * BPF_MAX_USER_RINGBUF_SAMPLES samples. If the return value is 1,
+ * the helper will skip the rest of the samples and return. Other
+ * return values are not used now, and will be rejected by the
+ * verifier.
+ * Return
+ * The number of drained samples if no error was encountered while
+ * draining samples, or 0 if no samples were present in the ring
+ * buffer. If a user-space producer was epoll-waiting on this map,
+ * and at least one sample was drained, they will receive an event
+ * notification notifying them of available space in the ring
+ * buffer. If the BPF_RB_NO_WAKEUP flag is passed to this
+ * function, no wakeup notification will be sent. If the
+ * BPF_RB_FORCE_WAKEUP flag is passed, a wakeup notification will
+ * be sent even if no sample was drained.
+ *
+ * On failure, the returned value is one of the following:
+ *
+ * **-EBUSY** if the ring buffer is contended, and another calling
+ * context was concurrently draining the ring buffer.
+ *
+ * **-EINVAL** if user-space is not properly tracking the ring
+ * buffer due to the producer position not being aligned to 8
+ * bytes, a sample not being aligned to 8 bytes, or the producer
+ * position not matching the advertised length of a sample.
+ *
+ * **-E2BIG** if user-space has tried to publish a sample which is
+ * larger than the size of the ring buffer, or which cannot fit
+ * within a struct bpf_dynptr.
+ *
+ * void *bpf_cgrp_storage_get(struct bpf_map *map, struct cgroup *cgroup, void *value, u64 flags)
+ * Description
+ * Get a bpf_local_storage from the *cgroup*.
+ *
+ * Logically, it could be thought of as getting the value from
+ * a *map* with *cgroup* as the **key**. From this
+ * perspective, the usage is not much different from
+ * **bpf_map_lookup_elem**\ (*map*, **&**\ *cgroup*) except this
+ * helper enforces the key must be a cgroup struct and the map must also
+ * be a **BPF_MAP_TYPE_CGRP_STORAGE**.
+ *
+ * In reality, the local-storage value is embedded directly inside of the
+ * *cgroup* object itself, rather than being located in the
+ * **BPF_MAP_TYPE_CGRP_STORAGE** map. When the local-storage value is
+ * queried for some *map* on a *cgroup* object, the kernel will perform an
+ * O(n) iteration over all of the live local-storage values for that
+ * *cgroup* object until the local-storage value for the *map* is found.
+ *
+ * An optional *flags* (**BPF_LOCAL_STORAGE_GET_F_CREATE**) can be
+ * used such that a new bpf_local_storage will be
+ * created if one does not exist. *value* can be used
+ * together with **BPF_LOCAL_STORAGE_GET_F_CREATE** to specify
+ * the initial value of a bpf_local_storage. If *value* is
+ * **NULL**, the new bpf_local_storage will be zero initialized.
+ * Return
+ * A bpf_local_storage pointer is returned on success.
+ *
+ * **NULL** if not found or there was an error in adding
+ * a new bpf_local_storage.
+ *
+ * long bpf_cgrp_storage_delete(struct bpf_map *map, struct cgroup *cgroup)
+ * Description
+ * Delete a bpf_local_storage from a *cgroup*.
+ * Return
+ * 0 on success.
+ *
+ * **-ENOENT** if the bpf_local_storage cannot be found.
*/
-#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), \
- FN(timer_init), \
- FN(timer_set_callback), \
- FN(timer_start), \
- FN(timer_cancel), \
- FN(get_func_ip), \
- FN(get_attach_cookie), \
- FN(task_pt_regs), \
- FN(get_branch_snapshot), \
- FN(trace_vprintk), \
- FN(skc_to_unix_sock), \
- FN(kallsyms_lookup_name), \
+#define ___BPF_FUNC_MAPPER(FN, ctx...) \
+ FN(unspec, 0, ##ctx) \
+ FN(map_lookup_elem, 1, ##ctx) \
+ FN(map_update_elem, 2, ##ctx) \
+ FN(map_delete_elem, 3, ##ctx) \
+ FN(probe_read, 4, ##ctx) \
+ FN(ktime_get_ns, 5, ##ctx) \
+ FN(trace_printk, 6, ##ctx) \
+ FN(get_prandom_u32, 7, ##ctx) \
+ FN(get_smp_processor_id, 8, ##ctx) \
+ FN(skb_store_bytes, 9, ##ctx) \
+ FN(l3_csum_replace, 10, ##ctx) \
+ FN(l4_csum_replace, 11, ##ctx) \
+ FN(tail_call, 12, ##ctx) \
+ FN(clone_redirect, 13, ##ctx) \
+ FN(get_current_pid_tgid, 14, ##ctx) \
+ FN(get_current_uid_gid, 15, ##ctx) \
+ FN(get_current_comm, 16, ##ctx) \
+ FN(get_cgroup_classid, 17, ##ctx) \
+ FN(skb_vlan_push, 18, ##ctx) \
+ FN(skb_vlan_pop, 19, ##ctx) \
+ FN(skb_get_tunnel_key, 20, ##ctx) \
+ FN(skb_set_tunnel_key, 21, ##ctx) \
+ FN(perf_event_read, 22, ##ctx) \
+ FN(redirect, 23, ##ctx) \
+ FN(get_route_realm, 24, ##ctx) \
+ FN(perf_event_output, 25, ##ctx) \
+ FN(skb_load_bytes, 26, ##ctx) \
+ FN(get_stackid, 27, ##ctx) \
+ FN(csum_diff, 28, ##ctx) \
+ FN(skb_get_tunnel_opt, 29, ##ctx) \
+ FN(skb_set_tunnel_opt, 30, ##ctx) \
+ FN(skb_change_proto, 31, ##ctx) \
+ FN(skb_change_type, 32, ##ctx) \
+ FN(skb_under_cgroup, 33, ##ctx) \
+ FN(get_hash_recalc, 34, ##ctx) \
+ FN(get_current_task, 35, ##ctx) \
+ FN(probe_write_user, 36, ##ctx) \
+ FN(current_task_under_cgroup, 37, ##ctx) \
+ FN(skb_change_tail, 38, ##ctx) \
+ FN(skb_pull_data, 39, ##ctx) \
+ FN(csum_update, 40, ##ctx) \
+ FN(set_hash_invalid, 41, ##ctx) \
+ FN(get_numa_node_id, 42, ##ctx) \
+ FN(skb_change_head, 43, ##ctx) \
+ FN(xdp_adjust_head, 44, ##ctx) \
+ FN(probe_read_str, 45, ##ctx) \
+ FN(get_socket_cookie, 46, ##ctx) \
+ FN(get_socket_uid, 47, ##ctx) \
+ FN(set_hash, 48, ##ctx) \
+ FN(setsockopt, 49, ##ctx) \
+ FN(skb_adjust_room, 50, ##ctx) \
+ FN(redirect_map, 51, ##ctx) \
+ FN(sk_redirect_map, 52, ##ctx) \
+ FN(sock_map_update, 53, ##ctx) \
+ FN(xdp_adjust_meta, 54, ##ctx) \
+ FN(perf_event_read_value, 55, ##ctx) \
+ FN(perf_prog_read_value, 56, ##ctx) \
+ FN(getsockopt, 57, ##ctx) \
+ FN(override_return, 58, ##ctx) \
+ FN(sock_ops_cb_flags_set, 59, ##ctx) \
+ FN(msg_redirect_map, 60, ##ctx) \
+ FN(msg_apply_bytes, 61, ##ctx) \
+ FN(msg_cork_bytes, 62, ##ctx) \
+ FN(msg_pull_data, 63, ##ctx) \
+ FN(bind, 64, ##ctx) \
+ FN(xdp_adjust_tail, 65, ##ctx) \
+ FN(skb_get_xfrm_state, 66, ##ctx) \
+ FN(get_stack, 67, ##ctx) \
+ FN(skb_load_bytes_relative, 68, ##ctx) \
+ FN(fib_lookup, 69, ##ctx) \
+ FN(sock_hash_update, 70, ##ctx) \
+ FN(msg_redirect_hash, 71, ##ctx) \
+ FN(sk_redirect_hash, 72, ##ctx) \
+ FN(lwt_push_encap, 73, ##ctx) \
+ FN(lwt_seg6_store_bytes, 74, ##ctx) \
+ FN(lwt_seg6_adjust_srh, 75, ##ctx) \
+ FN(lwt_seg6_action, 76, ##ctx) \
+ FN(rc_repeat, 77, ##ctx) \
+ FN(rc_keydown, 78, ##ctx) \
+ FN(skb_cgroup_id, 79, ##ctx) \
+ FN(get_current_cgroup_id, 80, ##ctx) \
+ FN(get_local_storage, 81, ##ctx) \
+ FN(sk_select_reuseport, 82, ##ctx) \
+ FN(skb_ancestor_cgroup_id, 83, ##ctx) \
+ FN(sk_lookup_tcp, 84, ##ctx) \
+ FN(sk_lookup_udp, 85, ##ctx) \
+ FN(sk_release, 86, ##ctx) \
+ FN(map_push_elem, 87, ##ctx) \
+ FN(map_pop_elem, 88, ##ctx) \
+ FN(map_peek_elem, 89, ##ctx) \
+ FN(msg_push_data, 90, ##ctx) \
+ FN(msg_pop_data, 91, ##ctx) \
+ FN(rc_pointer_rel, 92, ##ctx) \
+ FN(spin_lock, 93, ##ctx) \
+ FN(spin_unlock, 94, ##ctx) \
+ FN(sk_fullsock, 95, ##ctx) \
+ FN(tcp_sock, 96, ##ctx) \
+ FN(skb_ecn_set_ce, 97, ##ctx) \
+ FN(get_listener_sock, 98, ##ctx) \
+ FN(skc_lookup_tcp, 99, ##ctx) \
+ FN(tcp_check_syncookie, 100, ##ctx) \
+ FN(sysctl_get_name, 101, ##ctx) \
+ FN(sysctl_get_current_value, 102, ##ctx) \
+ FN(sysctl_get_new_value, 103, ##ctx) \
+ FN(sysctl_set_new_value, 104, ##ctx) \
+ FN(strtol, 105, ##ctx) \
+ FN(strtoul, 106, ##ctx) \
+ FN(sk_storage_get, 107, ##ctx) \
+ FN(sk_storage_delete, 108, ##ctx) \
+ FN(send_signal, 109, ##ctx) \
+ FN(tcp_gen_syncookie, 110, ##ctx) \
+ FN(skb_output, 111, ##ctx) \
+ FN(probe_read_user, 112, ##ctx) \
+ FN(probe_read_kernel, 113, ##ctx) \
+ FN(probe_read_user_str, 114, ##ctx) \
+ FN(probe_read_kernel_str, 115, ##ctx) \
+ FN(tcp_send_ack, 116, ##ctx) \
+ FN(send_signal_thread, 117, ##ctx) \
+ FN(jiffies64, 118, ##ctx) \
+ FN(read_branch_records, 119, ##ctx) \
+ FN(get_ns_current_pid_tgid, 120, ##ctx) \
+ FN(xdp_output, 121, ##ctx) \
+ FN(get_netns_cookie, 122, ##ctx) \
+ FN(get_current_ancestor_cgroup_id, 123, ##ctx) \
+ FN(sk_assign, 124, ##ctx) \
+ FN(ktime_get_boot_ns, 125, ##ctx) \
+ FN(seq_printf, 126, ##ctx) \
+ FN(seq_write, 127, ##ctx) \
+ FN(sk_cgroup_id, 128, ##ctx) \
+ FN(sk_ancestor_cgroup_id, 129, ##ctx) \
+ FN(ringbuf_output, 130, ##ctx) \
+ FN(ringbuf_reserve, 131, ##ctx) \
+ FN(ringbuf_submit, 132, ##ctx) \
+ FN(ringbuf_discard, 133, ##ctx) \
+ FN(ringbuf_query, 134, ##ctx) \
+ FN(csum_level, 135, ##ctx) \
+ FN(skc_to_tcp6_sock, 136, ##ctx) \
+ FN(skc_to_tcp_sock, 137, ##ctx) \
+ FN(skc_to_tcp_timewait_sock, 138, ##ctx) \
+ FN(skc_to_tcp_request_sock, 139, ##ctx) \
+ FN(skc_to_udp6_sock, 140, ##ctx) \
+ FN(get_task_stack, 141, ##ctx) \
+ FN(load_hdr_opt, 142, ##ctx) \
+ FN(store_hdr_opt, 143, ##ctx) \
+ FN(reserve_hdr_opt, 144, ##ctx) \
+ FN(inode_storage_get, 145, ##ctx) \
+ FN(inode_storage_delete, 146, ##ctx) \
+ FN(d_path, 147, ##ctx) \
+ FN(copy_from_user, 148, ##ctx) \
+ FN(snprintf_btf, 149, ##ctx) \
+ FN(seq_printf_btf, 150, ##ctx) \
+ FN(skb_cgroup_classid, 151, ##ctx) \
+ FN(redirect_neigh, 152, ##ctx) \
+ FN(per_cpu_ptr, 153, ##ctx) \
+ FN(this_cpu_ptr, 154, ##ctx) \
+ FN(redirect_peer, 155, ##ctx) \
+ FN(task_storage_get, 156, ##ctx) \
+ FN(task_storage_delete, 157, ##ctx) \
+ FN(get_current_task_btf, 158, ##ctx) \
+ FN(bprm_opts_set, 159, ##ctx) \
+ FN(ktime_get_coarse_ns, 160, ##ctx) \
+ FN(ima_inode_hash, 161, ##ctx) \
+ FN(sock_from_file, 162, ##ctx) \
+ FN(check_mtu, 163, ##ctx) \
+ FN(for_each_map_elem, 164, ##ctx) \
+ FN(snprintf, 165, ##ctx) \
+ FN(sys_bpf, 166, ##ctx) \
+ FN(btf_find_by_name_kind, 167, ##ctx) \
+ FN(sys_close, 168, ##ctx) \
+ FN(timer_init, 169, ##ctx) \
+ FN(timer_set_callback, 170, ##ctx) \
+ FN(timer_start, 171, ##ctx) \
+ FN(timer_cancel, 172, ##ctx) \
+ FN(get_func_ip, 173, ##ctx) \
+ FN(get_attach_cookie, 174, ##ctx) \
+ FN(task_pt_regs, 175, ##ctx) \
+ FN(get_branch_snapshot, 176, ##ctx) \
+ FN(trace_vprintk, 177, ##ctx) \
+ FN(skc_to_unix_sock, 178, ##ctx) \
+ FN(kallsyms_lookup_name, 179, ##ctx) \
+ FN(find_vma, 180, ##ctx) \
+ FN(loop, 181, ##ctx) \
+ FN(strncmp, 182, ##ctx) \
+ FN(get_func_arg, 183, ##ctx) \
+ FN(get_func_ret, 184, ##ctx) \
+ FN(get_func_arg_cnt, 185, ##ctx) \
+ FN(get_retval, 186, ##ctx) \
+ FN(set_retval, 187, ##ctx) \
+ FN(xdp_get_buff_len, 188, ##ctx) \
+ FN(xdp_load_bytes, 189, ##ctx) \
+ FN(xdp_store_bytes, 190, ##ctx) \
+ FN(copy_from_user_task, 191, ##ctx) \
+ FN(skb_set_tstamp, 192, ##ctx) \
+ FN(ima_file_hash, 193, ##ctx) \
+ FN(kptr_xchg, 194, ##ctx) \
+ FN(map_lookup_percpu_elem, 195, ##ctx) \
+ FN(skc_to_mptcp_sock, 196, ##ctx) \
+ FN(dynptr_from_mem, 197, ##ctx) \
+ FN(ringbuf_reserve_dynptr, 198, ##ctx) \
+ FN(ringbuf_submit_dynptr, 199, ##ctx) \
+ FN(ringbuf_discard_dynptr, 200, ##ctx) \
+ FN(dynptr_read, 201, ##ctx) \
+ FN(dynptr_write, 202, ##ctx) \
+ FN(dynptr_data, 203, ##ctx) \
+ FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx) \
+ FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx) \
+ FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx) \
+ FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx) \
+ FN(ktime_get_tai_ns, 208, ##ctx) \
+ FN(user_ringbuf_drain, 209, ##ctx) \
+ FN(cgrp_storage_get, 210, ##ctx) \
+ FN(cgrp_storage_delete, 211, ##ctx) \
/* */
+/* backwards-compatibility macros for users of __BPF_FUNC_MAPPER that don't
+ * know or care about integer value that is now passed as second argument
+ */
+#define __BPF_FUNC_MAPPER_APPLY(name, value, FN) FN(name),
+#define __BPF_FUNC_MAPPER(FN) ___BPF_FUNC_MAPPER(__BPF_FUNC_MAPPER_APPLY, FN)
+
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
*/
-#define __BPF_ENUM_FN(x) BPF_FUNC_ ## x
+#define __BPF_ENUM_FN(x, y) BPF_FUNC_ ## x = y,
enum bpf_func_id {
- __BPF_FUNC_MAPPER(__BPF_ENUM_FN)
+ ___BPF_FUNC_MAPPER(__BPF_ENUM_FN)
__BPF_FUNC_MAX_ID,
};
#undef __BPF_ENUM_FN
@@ -5180,6 +5782,12 @@ enum {
BPF_F_ZERO_CSUM_TX = (1ULL << 1),
BPF_F_DONT_FRAGMENT = (1ULL << 2),
BPF_F_SEQ_NUMBER = (1ULL << 3),
+ BPF_F_NO_TUNNEL_KEY = (1ULL << 4),
+};
+
+/* BPF_FUNC_skb_get_tunnel_key flags. */
+enum {
+ BPF_F_TUNINFO_FLAGS = (1ULL << 4),
};
/* BPF_FUNC_perf_event_output, BPF_FUNC_perf_event_read and
@@ -5214,6 +5822,8 @@ enum {
BPF_F_ADJ_ROOM_ENCAP_L4_UDP = (1ULL << 4),
BPF_F_ADJ_ROOM_NO_CSUM_RESET = (1ULL << 5),
BPF_F_ADJ_ROOM_ENCAP_L2_ETH = (1ULL << 6),
+ BPF_F_ADJ_ROOM_DECAP_L3_IPV4 = (1ULL << 7),
+ BPF_F_ADJ_ROOM_DECAP_L3_IPV6 = (1ULL << 8),
};
enum {
@@ -5309,6 +5919,15 @@ union { \
__u64 :64; \
} __attribute__((aligned(8)))
+enum {
+ BPF_SKB_TSTAMP_UNSPEC,
+ BPF_SKB_TSTAMP_DELIVERY_MONO, /* tstamp has mono delivery time */
+ /* For any BPF_SKB_TSTAMP_* that the bpf prog cannot handle,
+ * the bpf prog should handle it like BPF_SKB_TSTAMP_UNSPEC
+ * and try to deduce it by ingress, egress or skb->sk->sk_clockid.
+ */
+};
+
/* user accessible mirror of in-kernel sk_buff.
* new fields can only be added to the end of this structure
*/
@@ -5349,7 +5968,8 @@ struct __sk_buff {
__u32 gso_segs;
__bpf_md_ptr(struct bpf_sock *, sk);
__u32 gso_size;
- __u32 :32; /* Padding, future use. */
+ __u8 tstamp_type;
+ __u32 :24; /* Padding, future use. */
__u64 hwtstamp;
};
@@ -5361,8 +5981,15 @@ struct bpf_tunnel_key {
};
__u8 tunnel_tos;
__u8 tunnel_ttl;
- __u16 tunnel_ext; /* Padding, future use. */
+ union {
+ __u16 tunnel_ext; /* compat */
+ __be16 tunnel_flags;
+ };
__u32 tunnel_label;
+ union {
+ __u32 local_ipv4;
+ __u32 local_ipv6[4];
+ };
};
/* user accessible mirror of in-kernel xfrm_state.
@@ -5401,6 +6028,11 @@ enum bpf_ret_code {
* represented by BPF_REDIRECT above).
*/
BPF_LWT_REROUTE = 128,
+ /* BPF_FLOW_DISSECTOR_CONTINUE: used by BPF_PROG_TYPE_FLOW_DISSECTOR
+ * to indicate that no custom dissection was performed, and
+ * fallback to standard dissector is requested.
+ */
+ BPF_FLOW_DISSECTOR_CONTINUE = 129,
};
struct bpf_sock {
@@ -5414,7 +6046,8 @@ struct bpf_sock {
__u32 src_ip4;
__u32 src_ip6[4];
__u32 src_port; /* host byte order */
- __u32 dst_port; /* network byte order */
+ __be16 dst_port; /* network byte order */
+ __u16 :16; /* zero padding */
__u32 dst_ip4;
__u32 dst_ip6[4];
__u32 state;
@@ -5645,6 +6278,8 @@ struct bpf_prog_info {
__u64 run_cnt;
__u64 recursion_misses;
__u32 verified_insns;
+ __u32 attach_btf_obj_id;
+ __u32 attach_btf_id;
} __attribute__((aligned(8)));
struct bpf_map_info {
@@ -5696,11 +6331,26 @@ struct bpf_link_info {
struct {
__aligned_u64 target_name; /* in/out: target_name buffer ptr */
__u32 target_name_len; /* in/out: target_name buffer len */
+
+ /* If the iter specific field is 32 bits, it can be put
+ * in the first or second union. Otherwise it should be
+ * put in the second union.
+ */
union {
struct {
__u32 map_id;
} map;
};
+ union {
+ struct {
+ __u64 cgroup_id;
+ __u32 order;
+ } cgroup;
+ struct {
+ __u32 tid;
+ __u32 pid;
+ } task;
+ };
} iter;
struct {
__u32 netns_ino;
@@ -5819,6 +6469,7 @@ struct bpf_sock_ops {
* the outgoing header has not
* been written yet.
*/
+ __u64 skb_hwtstamp;
};
/* Definitions for bpf_sock_ops_cb_flags */
@@ -6104,6 +6755,7 @@ struct bpf_raw_tracepoint_args {
enum {
BPF_FIB_LOOKUP_DIRECT = (1U << 0),
BPF_FIB_LOOKUP_OUTPUT = (1U << 1),
+ BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2),
};
enum {
@@ -6256,6 +6908,32 @@ struct bpf_timer {
__u64 :64;
} __attribute__((aligned(8)));
+struct bpf_dynptr {
+ __u64 :64;
+ __u64 :64;
+} __attribute__((aligned(8)));
+
+struct bpf_list_head {
+ __u64 :64;
+ __u64 :64;
+} __attribute__((aligned(8)));
+
+struct bpf_list_node {
+ __u64 :64;
+ __u64 :64;
+} __attribute__((aligned(8)));
+
+struct bpf_rb_root {
+ __u64 :64;
+ __u64 :64;
+} __attribute__((aligned(8)));
+
+struct bpf_rb_node {
+ __u64 :64;
+ __u64 :64;
+ __u64 :64;
+} __attribute__((aligned(8)));
+
struct bpf_sysctl {
__u32 write; /* Sysctl is being read (= 0) or written (= 1).
* Allows 1,2,4-byte read, but no write.
@@ -6292,10 +6970,12 @@ struct bpf_sk_lookup {
__u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */
__u32 remote_ip4; /* Network byte order */
__u32 remote_ip6[4]; /* Network byte order */
- __u32 remote_port; /* Network byte order */
+ __be16 remote_port; /* Network byte order */
+ __u16 :16; /* Zero padding */
__u32 local_ip4; /* Network byte order */
__u32 local_ip6[4]; /* Network byte order */
__u32 local_port; /* Host byte order */
+ __u32 ingress_ifindex; /* The arriving interface. Determined by inet_iif. */
};
/*
@@ -6328,4 +7008,79 @@ enum {
BTF_F_ZERO = (1ULL << 3),
};
+/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value
+ * has to be adjusted by relocations. It is emitted by llvm and passed to
+ * libbpf and later to the kernel.
+ */
+enum bpf_core_relo_kind {
+ BPF_CORE_FIELD_BYTE_OFFSET = 0, /* field byte offset */
+ BPF_CORE_FIELD_BYTE_SIZE = 1, /* field size in bytes */
+ BPF_CORE_FIELD_EXISTS = 2, /* field existence in target kernel */
+ BPF_CORE_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
+ BPF_CORE_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
+ BPF_CORE_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
+ BPF_CORE_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
+ BPF_CORE_TYPE_ID_TARGET = 7, /* type ID in target kernel */
+ BPF_CORE_TYPE_EXISTS = 8, /* type existence in target kernel */
+ BPF_CORE_TYPE_SIZE = 9, /* type size in bytes */
+ BPF_CORE_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */
+ BPF_CORE_ENUMVAL_VALUE = 11, /* enum value integer value */
+ BPF_CORE_TYPE_MATCHES = 12, /* type match in target kernel */
+};
+
+/*
+ * "struct bpf_core_relo" is used to pass relocation data form LLVM to libbpf
+ * and from libbpf to the kernel.
+ *
+ * CO-RE relocation captures the following data:
+ * - insn_off - instruction offset (in bytes) within a BPF program that needs
+ * its insn->imm field to be relocated with actual field info;
+ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable
+ * type or field;
+ * - access_str_off - offset into corresponding .BTF string section. String
+ * interpretation depends on specific relocation kind:
+ * - for field-based relocations, string encodes an accessed field using
+ * a sequence of field and array indices, separated by colon (:). It's
+ * conceptually very close to LLVM's getelementptr ([0]) instruction's
+ * arguments for identifying offset to a field.
+ * - for type-based relocations, strings is expected to be just "0";
+ * - for enum value-based relocations, string contains an index of enum
+ * value within its enum type;
+ * - kind - one of enum bpf_core_relo_kind;
+ *
+ * Example:
+ * struct sample {
+ * int a;
+ * struct {
+ * int b[10];
+ * };
+ * };
+ *
+ * struct sample *s = ...;
+ * int *x = &s->a; // encoded as "0:0" (a is field #0)
+ * int *y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1,
+ * // b is field #0 inside anon struct, accessing elem #5)
+ * int *z = &s[10]->b; // encoded as "10:1" (ptr is used as an array)
+ *
+ * type_id for all relocs in this example will capture BTF type id of
+ * `struct sample`.
+ *
+ * Such relocation is emitted when using __builtin_preserve_access_index()
+ * Clang built-in, passing expression that captures field address, e.g.:
+ *
+ * bpf_probe_read(&dst, sizeof(dst),
+ * __builtin_preserve_access_index(&src->a.b.c));
+ *
+ * In this case Clang will emit field relocation recording necessary data to
+ * be able to find offset of embedded `a.b.c` field within `src` struct.
+ *
+ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction
+ */
+struct bpf_core_relo {
+ __u32 insn_off;
+ __u32 type_id;
+ __u32 access_str_off;
+ enum bpf_core_relo_kind kind;
+};
+
#endif /* __LINUX_BPF_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/btf.h b/lib/libc/include/any-linux-any/linux/btf.h
index 5576514901..60311ac5b9 100644
--- a/lib/libc/include/any-linux-any/linux/btf.h
+++ b/lib/libc/include/any-linux-any/linux/btf.h
@@ -33,17 +33,17 @@ struct btf_type {
/* "info" bits arrangement
* bits 0-15: vlen (e.g. # of struct's members)
* bits 16-23: unused
- * bits 24-27: kind (e.g. int, ptr, array...etc)
- * bits 28-30: unused
+ * bits 24-28: kind (e.g. int, ptr, array...etc)
+ * bits 29-30: unused
* bit 31: kind_flag, currently used by
- * struct, union and fwd
+ * struct, union, enum, fwd and enum64
*/
__u32 info;
- /* "size" is used by INT, ENUM, STRUCT, UNION and DATASEC.
+ /* "size" is used by INT, ENUM, STRUCT, UNION, DATASEC and ENUM64.
* "size" tells the size of the type it is describing.
*
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
- * FUNC, FUNC_PROTO, VAR and DECL_TAG.
+ * FUNC, FUNC_PROTO, VAR, DECL_TAG and TYPE_TAG.
* "type" is a type_id referring to another type.
*/
union {
@@ -63,7 +63,7 @@ enum {
BTF_KIND_ARRAY = 3, /* Array */
BTF_KIND_STRUCT = 4, /* Struct */
BTF_KIND_UNION = 5, /* Union */
- BTF_KIND_ENUM = 6, /* Enumeration */
+ BTF_KIND_ENUM = 6, /* Enumeration up to 32-bit values */
BTF_KIND_FWD = 7, /* Forward */
BTF_KIND_TYPEDEF = 8, /* Typedef */
BTF_KIND_VOLATILE = 9, /* Volatile */
@@ -75,6 +75,8 @@ enum {
BTF_KIND_DATASEC = 15, /* Section */
BTF_KIND_FLOAT = 16, /* Floating point */
BTF_KIND_DECL_TAG = 17, /* Decl Tag */
+ BTF_KIND_TYPE_TAG = 18, /* Type Tag */
+ BTF_KIND_ENUM64 = 19, /* Enumeration up to 64-bit values */
NR_BTF_KINDS,
BTF_KIND_MAX = NR_BTF_KINDS - 1,
@@ -185,4 +187,14 @@ struct btf_decl_tag {
__s32 component_idx;
};
+/* BTF_KIND_ENUM64 is followed by multiple "struct btf_enum64".
+ * The exact number of btf_enum64 is stored in the vlen (of the
+ * info in "struct btf_type").
+ */
+struct btf_enum64 {
+ __u32 name_off;
+ __u32 val_lo32;
+ __u32 val_hi32;
+};
+
#endif /* __LINUX_BTF_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/btrfs.h b/lib/libc/include/any-linux-any/linux/btrfs.h
index 0076ad0fc9..ced3180ef9 100644
--- a/lib/libc/include/any-linux-any/linux/btrfs.h
+++ b/lib/libc/include/any-linux-any/linux/btrfs.h
@@ -19,8 +19,14 @@
#ifndef _LINUX_BTRFS_H
#define _LINUX_BTRFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/fs.h>
#define BTRFS_IOCTL_MAGIC 0x94
#define BTRFS_VOL_NAME_MAX 255
@@ -91,7 +97,7 @@ struct btrfs_qgroup_inherit {
__u64 num_ref_copies;
__u64 num_excl_copies;
struct btrfs_qgroup_limit lim;
- __u64 qgroups[0];
+ __u64 qgroups[];
};
struct btrfs_ioctl_qgroup_limit_args {
@@ -179,6 +185,7 @@ struct btrfs_scrub_progress {
};
#define BTRFS_SCRUB_READONLY 1
+#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)
struct btrfs_ioctl_scrub_args {
__u64 devid; /* in */
__u64 start; /* in */
@@ -237,7 +244,17 @@ struct btrfs_ioctl_dev_info_args {
__u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
__u64 bytes_used; /* out */
__u64 total_bytes; /* out */
- __u64 unused[379]; /* pad to 4k */
+ /*
+ * Optional, out.
+ *
+ * Showing the fsid of the device, allowing user space to check if this
+ * device is a seeding one.
+ *
+ * Introduced in v6.3, thus user space still needs to check if kernel
+ * changed this value. Older kernel will not touch the values here.
+ */
+ __u8 fsid[BTRFS_UUID_SIZE];
+ __u64 unused[377]; /* pad to 4k */
__u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
};
@@ -288,6 +305,12 @@ struct btrfs_ioctl_fs_info_args {
#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
#define BTRFS_FEATURE_COMPAT_RO_VERITY (1ULL << 2)
+/*
+ * Put all block group items into a dedicated block group tree, greatly
+ * reducing mount time for large filesystem due to better locality.
+ */
+#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE (1ULL << 3)
+
#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
@@ -307,6 +330,7 @@ struct btrfs_ioctl_fs_info_args {
#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10)
#define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11)
#define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12)
+#define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13)
struct btrfs_ioctl_feature_flags {
__u64 compat_flags;
@@ -324,6 +348,12 @@ struct btrfs_ioctl_feature_flags {
*/
struct btrfs_balance_args {
__u64 profiles;
+
+ /*
+ * usage filter
+ * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
+ * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
+ */
union {
__u64 usage;
struct {
@@ -540,7 +570,7 @@ struct btrfs_ioctl_search_header {
__u64 offset;
__u32 type;
__u32 len;
-};
+} __attribute__ ((__may_alias__));
#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
/*
@@ -553,18 +583,23 @@ struct btrfs_ioctl_search_args {
char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
};
+/*
+ * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes.
+ * The allocated size of the buffer is set in buf_size.
+ */
struct btrfs_ioctl_search_args_v2 {
struct btrfs_ioctl_search_key key; /* in/out - search parameters */
__u64 buf_size; /* in - size of buffer
* out - on EOVERFLOW: needed size
* to store item */
- __u64 buf[0]; /* out - found items */
+ __u64 buf[]; /* out - found items */
};
+/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
struct btrfs_ioctl_clone_range_args {
- __s64 src_fd;
- __u64 src_offset, src_length;
- __u64 dest_offset;
+ __s64 src_fd;
+ __u64 src_offset, src_length;
+ __u64 dest_offset;
};
/*
@@ -629,7 +664,7 @@ struct btrfs_ioctl_same_args {
__u16 dest_count; /* in - total elements in info array */
__u16 reserved1;
__u32 reserved2;
- struct btrfs_ioctl_same_extent_info info[0];
+ struct btrfs_ioctl_same_extent_info info[];
};
struct btrfs_ioctl_space_info {
@@ -641,7 +676,7 @@ struct btrfs_ioctl_space_info {
struct btrfs_ioctl_space_args {
__u64 space_slots;
__u64 total_spaces;
- struct btrfs_ioctl_space_info spaces[0];
+ struct btrfs_ioctl_space_info spaces[];
};
struct btrfs_data_container {
@@ -649,7 +684,7 @@ struct btrfs_data_container {
__u32 bytes_missing; /* out -- additional bytes needed for result */
__u32 elem_cnt; /* out */
__u32 elem_missed; /* out */
- __u64 val[0]; /* out */
+ __u64 val[]; /* out */
};
struct btrfs_ioctl_ino_path_args {
@@ -668,8 +703,11 @@ struct btrfs_ioctl_logical_ino_args {
/* struct btrfs_data_container *inodes; out */
__u64 inodes;
};
-/* Return every ref to the extent, not just those containing logical block.
- * Requires logical == extent bytenr. */
+
+/*
+ * Return every ref to the extent, not just those containing logical block.
+ * Requires logical == extent bytenr.
+ */
#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
enum btrfs_dev_stat_values {
@@ -774,11 +812,19 @@ struct btrfs_ioctl_received_subvol_args {
*/
#define BTRFS_SEND_FLAG_VERSION 0x8
+/*
+ * Send compressed data using the ENCODED_WRITE command instead of decompressing
+ * the data and sending it with the WRITE command. This requires protocol
+ * version >= 2.
+ */
+#define BTRFS_SEND_FLAG_COMPRESSED 0x10
+
#define BTRFS_SEND_FLAG_MASK \
(BTRFS_SEND_FLAG_NO_FILE_DATA | \
BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
BTRFS_SEND_FLAG_OMIT_END_CMD | \
- BTRFS_SEND_FLAG_VERSION)
+ BTRFS_SEND_FLAG_VERSION | \
+ BTRFS_SEND_FLAG_COMPRESSED)
struct btrfs_ioctl_send_args {
__s64 send_fd; /* in */
@@ -866,6 +912,134 @@ struct btrfs_ioctl_get_subvol_rootref_args {
__u8 align[7];
};
+/*
+ * Data and metadata for an encoded read or write.
+ *
+ * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g.,
+ * compression). This can be used to read the compressed contents of a file or
+ * write pre-compressed data directly to a file.
+ *
+ * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially
+ * preadv/pwritev with additional metadata about how the data is encoded and the
+ * size of the unencoded data.
+ *
+ * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills
+ * the metadata fields, and returns the size of the encoded data. It reads one
+ * extent per call. It can also read data which is not encoded.
+ *
+ * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data
+ * from the iovecs, and returns the size of the encoded data. Note that the
+ * encoded data is not validated when it is written; if it is not valid (e.g.,
+ * it cannot be decompressed), then a subsequent read may return an error.
+ *
+ * Since the filesystem page cache contains decoded data, encoded I/O bypasses
+ * the page cache. Encoded I/O requires CAP_SYS_ADMIN.
+ */
+struct btrfs_ioctl_encoded_io_args {
+ /* Input parameters for both reads and writes. */
+
+ /*
+ * iovecs containing encoded data.
+ *
+ * For reads, if the size of the encoded data is larger than the sum of
+ * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with
+ * ENOBUFS.
+ *
+ * For writes, the size of the encoded data is the sum of iov[n].iov_len
+ * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may
+ * increase in the future). This must also be less than or equal to
+ * unencoded_len.
+ */
+ const struct iovec *iov;
+ /* Number of iovecs. */
+ unsigned long iovcnt;
+ /*
+ * Offset in file.
+ *
+ * For writes, must be aligned to the sector size of the filesystem.
+ */
+ __s64 offset;
+ /* Currently must be zero. */
+ __u64 flags;
+
+ /*
+ * For reads, the following members are output parameters that will
+ * contain the returned metadata for the encoded data.
+ * For writes, the following members must be set to the metadata for the
+ * encoded data.
+ */
+
+ /*
+ * Length of the data in the file.
+ *
+ * Must be less than or equal to unencoded_len - unencoded_offset. For
+ * writes, must be aligned to the sector size of the filesystem unless
+ * the data ends at or beyond the current end of the file.
+ */
+ __u64 len;
+ /*
+ * Length of the unencoded (i.e., decrypted and decompressed) data.
+ *
+ * For writes, must be no more than 128 KiB (this limit may increase in
+ * the future). If the unencoded data is actually longer than
+ * unencoded_len, then it is truncated; if it is shorter, then it is
+ * extended with zeroes.
+ */
+ __u64 unencoded_len;
+ /*
+ * Offset from the first byte of the unencoded data to the first byte of
+ * logical data in the file.
+ *
+ * Must be less than unencoded_len.
+ */
+ __u64 unencoded_offset;
+ /*
+ * BTRFS_ENCODED_IO_COMPRESSION_* type.
+ *
+ * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE.
+ */
+ __u32 compression;
+ /* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */
+ __u32 encryption;
+ /*
+ * Reserved for future expansion.
+ *
+ * For reads, always returned as zero. Users should check for non-zero
+ * bytes. If there are any, then the kernel has a newer version of this
+ * structure with additional information that the user definition is
+ * missing.
+ *
+ * For writes, must be zeroed.
+ */
+ __u8 reserved[64];
+};
+
+/* Data is not compressed. */
+#define BTRFS_ENCODED_IO_COMPRESSION_NONE 0
+/* Data is compressed as a single zlib stream. */
+#define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1
+/*
+ * Data is compressed as a single zstd frame with the windowLog compression
+ * parameter set to no more than 17.
+ */
+#define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2
+/*
+ * Data is compressed sector by sector (using the sector size indicated by the
+ * name of the constant) with LZO1X and wrapped in the format documented in
+ * fs/btrfs/lzo.c. For writes, the compression sector size must match the
+ * filesystem sector size.
+ */
+#define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3
+#define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4
+#define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5
+#define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6
+#define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7
+#define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8
+
+/* Data is not encrypted. */
+#define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0
+#define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1
+
/* Error codes as returned by the kernel */
enum btrfs_err_code {
BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
@@ -994,5 +1168,13 @@ enum btrfs_err_code {
struct btrfs_ioctl_ino_lookup_user_args)
#define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
struct btrfs_ioctl_vol_args_v2)
+#define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \
+ struct btrfs_ioctl_encoded_io_args)
+#define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \
+ struct btrfs_ioctl_encoded_io_args)
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _LINUX_BTRFS_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/btrfs_tree.h b/lib/libc/include/any-linux-any/linux/btrfs_tree.h
index 71374a6f79..6ae8adb128 100644
--- a/lib/libc/include/any-linux-any/linux/btrfs_tree.h
+++ b/lib/libc/include/any-linux-any/linux/btrfs_tree.h
@@ -6,6 +6,23 @@
#include <linux/types.h>
#include <stddef.h>
+/* ASCII for _BHRfS_M, no terminating nul */
+#define BTRFS_MAGIC 0x4D5F53665248425FULL
+
+#define BTRFS_MAX_LEVEL 8
+
+/*
+ * We can actually store much bigger names, but lets not confuse the rest of
+ * linux.
+ */
+#define BTRFS_NAME_LEN 255
+
+/*
+ * Theoretical limit is larger, but we keep this down to a sane value. That
+ * should limit greatly the possibility of collisions on inode ref items.
+ */
+#define BTRFS_LINK_MAX 65535U
+
/*
* This header contains the structure definitions and constants used
* by file system objects that can be retrieved using
@@ -49,6 +66,9 @@
/* tracks free space in block groups. */
#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
+/* Holds the block group items for extent tree v2. */
+#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
+
/* device stats in the device tree */
#define BTRFS_DEV_STATS_OBJECTID 0ULL
@@ -142,7 +162,9 @@
/*
* dir items are the name -> inode pointers in a directory. There is one
- * for every name in a directory.
+ * for every name in a directory. BTRFS_DIR_LOG_ITEM_KEY is no longer used
+ * but it's still defined here for documentation purposes and to help avoid
+ * having its numerical value reused in the future.
*/
#define BTRFS_DIR_LOG_ITEM_KEY 60
#define BTRFS_DIR_LOG_INDEX_KEY 72
@@ -350,6 +372,50 @@ enum btrfs_csum_type {
#define BTRFS_FT_SYMLINK 7
#define BTRFS_FT_XATTR 8
#define BTRFS_FT_MAX 9
+/* Directory contains encrypted data */
+#define BTRFS_FT_ENCRYPTED 0x80
+
+static __inline__ __u8 btrfs_dir_flags_to_ftype(__u8 flags)
+{
+ return flags & ~BTRFS_FT_ENCRYPTED;
+}
+
+/*
+ * Inode flags
+ */
+#define BTRFS_INODE_NODATASUM (1U << 0)
+#define BTRFS_INODE_NODATACOW (1U << 1)
+#define BTRFS_INODE_READONLY (1U << 2)
+#define BTRFS_INODE_NOCOMPRESS (1U << 3)
+#define BTRFS_INODE_PREALLOC (1U << 4)
+#define BTRFS_INODE_SYNC (1U << 5)
+#define BTRFS_INODE_IMMUTABLE (1U << 6)
+#define BTRFS_INODE_APPEND (1U << 7)
+#define BTRFS_INODE_NODUMP (1U << 8)
+#define BTRFS_INODE_NOATIME (1U << 9)
+#define BTRFS_INODE_DIRSYNC (1U << 10)
+#define BTRFS_INODE_COMPRESS (1U << 11)
+
+#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31)
+
+#define BTRFS_INODE_FLAG_MASK \
+ (BTRFS_INODE_NODATASUM | \
+ BTRFS_INODE_NODATACOW | \
+ BTRFS_INODE_READONLY | \
+ BTRFS_INODE_NOCOMPRESS | \
+ BTRFS_INODE_PREALLOC | \
+ BTRFS_INODE_SYNC | \
+ BTRFS_INODE_IMMUTABLE | \
+ BTRFS_INODE_APPEND | \
+ BTRFS_INODE_NODUMP | \
+ BTRFS_INODE_NOATIME | \
+ BTRFS_INODE_DIRSYNC | \
+ BTRFS_INODE_COMPRESS | \
+ BTRFS_INODE_ROOT_ITEM_INIT)
+
+#define BTRFS_INODE_RO_VERITY (1U << 0)
+
+#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY)
/*
* The key defines the order in the tree, and so it also defines (optimal)
@@ -380,6 +446,109 @@ struct btrfs_key {
__u64 offset;
} __attribute__ ((__packed__));
+/*
+ * Every tree block (leaf or node) starts with this header.
+ */
+struct btrfs_header {
+ /* These first four must match the super block */
+ __u8 csum[BTRFS_CSUM_SIZE];
+ /* FS specific uuid */
+ __u8 fsid[BTRFS_FSID_SIZE];
+ /* Which block this node is supposed to live in */
+ __le64 bytenr;
+ __le64 flags;
+
+ /* Allowed to be different from the super from here on down */
+ __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
+ __le64 generation;
+ __le64 owner;
+ __le32 nritems;
+ __u8 level;
+} __attribute__ ((__packed__));
+
+/*
+ * This is a very generous portion of the super block, giving us room to
+ * translate 14 chunks with 3 stripes each.
+ */
+#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
+
+/*
+ * Just in case we somehow lose the roots and are not able to mount, we store
+ * an array of the roots from previous transactions in the super.
+ */
+#define BTRFS_NUM_BACKUP_ROOTS 4
+struct btrfs_root_backup {
+ __le64 tree_root;
+ __le64 tree_root_gen;
+
+ __le64 chunk_root;
+ __le64 chunk_root_gen;
+
+ __le64 extent_root;
+ __le64 extent_root_gen;
+
+ __le64 fs_root;
+ __le64 fs_root_gen;
+
+ __le64 dev_root;
+ __le64 dev_root_gen;
+
+ __le64 csum_root;
+ __le64 csum_root_gen;
+
+ __le64 total_bytes;
+ __le64 bytes_used;
+ __le64 num_devices;
+ /* future */
+ __le64 unused_64[4];
+
+ __u8 tree_root_level;
+ __u8 chunk_root_level;
+ __u8 extent_root_level;
+ __u8 fs_root_level;
+ __u8 dev_root_level;
+ __u8 csum_root_level;
+ /* future and to align */
+ __u8 unused_8[10];
+} __attribute__ ((__packed__));
+
+/*
+ * A leaf is full of items. offset and size tell us where to find the item in
+ * the leaf (relative to the start of the data area)
+ */
+struct btrfs_item {
+ struct btrfs_disk_key key;
+ __le32 offset;
+ __le32 size;
+} __attribute__ ((__packed__));
+
+/*
+ * Leaves have an item area and a data area:
+ * [item0, item1....itemN] [free space] [dataN...data1, data0]
+ *
+ * The data is separate from the items to get the keys closer together during
+ * searches.
+ */
+struct btrfs_leaf {
+ struct btrfs_header header;
+ struct btrfs_item items[];
+} __attribute__ ((__packed__));
+
+/*
+ * All non-leaf blocks are nodes, they hold only keys and pointers to other
+ * blocks.
+ */
+struct btrfs_key_ptr {
+ struct btrfs_disk_key key;
+ __le64 blockptr;
+ __le64 generation;
+} __attribute__ ((__packed__));
+
+struct btrfs_node {
+ struct btrfs_header header;
+ struct btrfs_key_ptr ptrs[];
+} __attribute__ ((__packed__));
+
struct btrfs_dev_item {
/* the internal btrfs device id */
__le64 devid;
@@ -463,6 +632,69 @@ struct btrfs_chunk {
/* additional stripes go here */
} __attribute__ ((__packed__));
+/*
+ * The super block basically lists the main trees of the FS.
+ */
+struct btrfs_super_block {
+ /* The first 4 fields must match struct btrfs_header */
+ __u8 csum[BTRFS_CSUM_SIZE];
+ /* FS specific UUID, visible to user */
+ __u8 fsid[BTRFS_FSID_SIZE];
+ /* This block number */
+ __le64 bytenr;
+ __le64 flags;
+
+ /* Allowed to be different from the btrfs_header from here own down */
+ __le64 magic;
+ __le64 generation;
+ __le64 root;
+ __le64 chunk_root;
+ __le64 log_root;
+
+ /*
+ * This member has never been utilized since the very beginning, thus
+ * it's always 0 regardless of kernel version. We always use
+ * generation + 1 to read log tree root. So here we mark it deprecated.
+ */
+ __le64 __unused_log_root_transid;
+ __le64 total_bytes;
+ __le64 bytes_used;
+ __le64 root_dir_objectid;
+ __le64 num_devices;
+ __le32 sectorsize;
+ __le32 nodesize;
+ __le32 __unused_leafsize;
+ __le32 stripesize;
+ __le32 sys_chunk_array_size;
+ __le64 chunk_root_generation;
+ __le64 compat_flags;
+ __le64 compat_ro_flags;
+ __le64 incompat_flags;
+ __le16 csum_type;
+ __u8 root_level;
+ __u8 chunk_root_level;
+ __u8 log_root_level;
+ struct btrfs_dev_item dev_item;
+
+ char label[BTRFS_LABEL_SIZE];
+
+ __le64 cache_generation;
+ __le64 uuid_tree_generation;
+
+ /* The UUID written into btree blocks */
+ __u8 metadata_uuid[BTRFS_FSID_SIZE];
+
+ __u64 nr_global_roots;
+
+ /* Future expansion */
+ __le64 reserved[27];
+ __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
+ struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
+
+ /* Padded to 4096 bytes */
+ __u8 padding[565];
+} __attribute__ ((__packed__));
+
#define BTRFS_FREE_SPACE_EXTENT 1
#define BTRFS_FREE_SPACE_BITMAP 2
@@ -517,6 +749,14 @@ struct btrfs_extent_item_v0 {
/* use full backrefs for extent pointers in the block */
#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
+#define BTRFS_BACKREF_REV_MAX 256
+#define BTRFS_BACKREF_REV_SHIFT 56
+#define BTRFS_BACKREF_REV_MASK (((u64)BTRFS_BACKREF_REV_MAX - 1) << \
+ BTRFS_BACKREF_REV_SHIFT)
+
+#define BTRFS_OLD_BACKREF_REV 0
+#define BTRFS_MIXED_BACKREF_REV 1
+
/*
* this flag is only used internally by scrub and may be changed at any time
* it is only declared here to avoid collisions
@@ -566,7 +806,7 @@ struct btrfs_inode_extref {
__le64 parent_objectid;
__le64 index;
__le16 name_len;
- __u8 name[0];
+ __u8 name[];
/* name goes here */
} __attribute__ ((__packed__));
@@ -871,19 +1111,6 @@ struct btrfs_dev_replace_item {
#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
BTRFS_SPACE_INFO_GLOBAL_RSV)
-enum btrfs_raid_types {
- BTRFS_RAID_RAID10,
- BTRFS_RAID_RAID1,
- BTRFS_RAID_DUP,
- BTRFS_RAID_RAID0,
- BTRFS_RAID_SINGLE,
- BTRFS_RAID_RAID5,
- BTRFS_RAID_RAID6,
- BTRFS_RAID_RAID1C3,
- BTRFS_RAID_RAID1C4,
- BTRFS_NR_RAID_TYPES
-};
-
#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
BTRFS_BLOCK_GROUP_SYSTEM | \
BTRFS_BLOCK_GROUP_METADATA)
@@ -969,6 +1196,10 @@ static __inline__ __u16 btrfs_qgroup_level(__u64 qgroupid)
*/
#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
+#define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | \
+ BTRFS_QGROUP_STATUS_FLAG_RESCAN | \
+ BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
+
#define BTRFS_QGROUP_STATUS_VERSION 1
struct btrfs_qgroup_status_item {
diff --git a/lib/libc/include/any-linux-any/linux/cachefiles.h b/lib/libc/include/any-linux-any/linux/cachefiles.h
new file mode 100644
index 0000000000..fb2265a74a
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/cachefiles.h
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_CACHEFILES_H
+#define _LINUX_CACHEFILES_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+/*
+ * Fscache ensures that the maximum length of cookie key is 255. The volume key
+ * is controlled by netfs, and generally no bigger than 255.
+ */
+#define CACHEFILES_MSG_MAX_SIZE 1024
+
+enum cachefiles_opcode {
+ CACHEFILES_OP_OPEN,
+ CACHEFILES_OP_CLOSE,
+ CACHEFILES_OP_READ,
+};
+
+/*
+ * Message Header
+ *
+ * @msg_id a unique ID identifying this message
+ * @opcode message type, CACHEFILE_OP_*
+ * @len message length, including message header and following data
+ * @object_id a unique ID identifying a cache file
+ * @data message type specific payload
+ */
+struct cachefiles_msg {
+ __u32 msg_id;
+ __u32 opcode;
+ __u32 len;
+ __u32 object_id;
+ __u8 data[];
+};
+
+/*
+ * @data contains the volume_key followed directly by the cookie_key. volume_key
+ * is a NUL-terminated string; @volume_key_size indicates the size of the volume
+ * key in bytes. cookie_key is binary data, which is netfs specific;
+ * @cookie_key_size indicates the size of the cookie key in bytes.
+ *
+ * @fd identifies an anon_fd referring to the cache file.
+ */
+struct cachefiles_open {
+ __u32 volume_key_size;
+ __u32 cookie_key_size;
+ __u32 fd;
+ __u32 flags;
+ __u8 data[];
+};
+
+/*
+ * @off indicates the starting offset of the requested file range
+ * @len indicates the length of the requested file range
+ */
+struct cachefiles_read {
+ __u64 off;
+ __u64 len;
+};
+
+/*
+ * Reply for READ request
+ * @arg for this ioctl is the @id field of READ request.
+ */
+#define CACHEFILES_IOC_READ_COMPLETE _IOW(0x98, 1, int)
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/can.h b/lib/libc/include/any-linux-any/linux/can.h
index 5ee86620f8..a78b7dbc9d 100644
--- a/lib/libc/include/any-linux-any/linux/can.h
+++ b/lib/libc/include/any-linux-any/linux/can.h
@@ -48,6 +48,7 @@
#include <linux/types.h>
#include <linux/socket.h>
+#include <linux/stddef.h> /* for offsetof */
/* controller area network (CAN) kernel definitions */
@@ -60,6 +61,7 @@
#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
+#define CANXL_PRIO_MASK CAN_SFF_MASK /* 11 bit priority mask */
/*
* Controller Area Network Identifier structure
@@ -73,6 +75,7 @@ typedef __u32 canid_t;
#define CAN_SFF_ID_BITS 11
#define CAN_EFF_ID_BITS 29
+#define CANXL_PRIO_BITS CAN_SFF_ID_BITS
/*
* Controller Area Network Error Message Frame Mask structure
@@ -91,6 +94,16 @@ typedef __u32 can_err_mask_t;
#define CANFD_MAX_DLC 15
#define CANFD_MAX_DLEN 64
+/*
+ * CAN XL payload length and DLC definitions according to ISO 11898-1
+ * CAN XL DLC ranges from 0 .. 2047 => data length from 1 .. 2048 byte
+ */
+#define CANXL_MIN_DLC 0
+#define CANXL_MAX_DLC 2047
+#define CANXL_MAX_DLC_MASK 0x07FF
+#define CANXL_MIN_DLEN 1
+#define CANXL_MAX_DLEN 2048
+
/**
* struct can_frame - Classical CAN frame structure (aka CAN 2.0B)
* @can_id: CAN ID of the frame and CAN_*_FLAG flags, see canid_t definition
@@ -141,8 +154,8 @@ struct can_frame {
* When this is done the former differentiation via CAN_MTU / CANFD_MTU gets
* lost. CANFD_FDF allows programmers to mark CAN FD frames in the case of
* using struct canfd_frame for mixed CAN / CAN FD content (dual use).
- * N.B. the Kernel APIs do NOT provide mixed CAN / CAN FD content inside of
- * struct canfd_frame therefore the CANFD_FDF flag is disregarded by Linux.
+ * Since the introduction of CAN XL the CANFD_FDF flag is set in all CAN FD
+ * frame structures provided by the CAN subsystem of the Linux kernel.
*/
#define CANFD_BRS 0x01 /* bit rate switch (second bitrate for payload data) */
#define CANFD_ESI 0x02 /* error state indicator of the transmitting node */
@@ -166,8 +179,46 @@ struct canfd_frame {
__u8 data[CANFD_MAX_DLEN] __attribute__((aligned(8)));
};
+/*
+ * defined bits for canxl_frame.flags
+ *
+ * The canxl_frame.flags element contains two bits CANXL_XLF and CANXL_SEC
+ * and shares the relative position of the struct can[fd]_frame.len element.
+ * The CANXL_XLF bit ALWAYS needs to be set to indicate a valid CAN XL frame.
+ * As a side effect setting this bit intentionally breaks the length checks
+ * for Classical CAN and CAN FD frames.
+ *
+ * Undefined bits in canxl_frame.flags are reserved and shall be set to zero.
+ */
+#define CANXL_XLF 0x80 /* mandatory CAN XL frame flag (must always be set!) */
+#define CANXL_SEC 0x01 /* Simple Extended Content (security/segmentation) */
+
+/**
+ * struct canxl_frame - CAN with e'X'tended frame 'L'ength frame structure
+ * @prio: 11 bit arbitration priority with zero'ed CAN_*_FLAG flags
+ * @flags: additional flags for CAN XL
+ * @sdt: SDU (service data unit) type
+ * @len: frame payload length in byte (CANXL_MIN_DLEN .. CANXL_MAX_DLEN)
+ * @af: acceptance field
+ * @data: CAN XL frame payload (CANXL_MIN_DLEN .. CANXL_MAX_DLEN byte)
+ *
+ * @prio shares the same position as @can_id from struct can[fd]_frame.
+ */
+struct canxl_frame {
+ canid_t prio; /* 11 bit priority for arbitration (canid_t) */
+ __u8 flags; /* additional flags for CAN XL */
+ __u8 sdt; /* SDU (service data unit) type */
+ __u16 len; /* frame payload length in byte */
+ __u32 af; /* acceptance field */
+ __u8 data[CANXL_MAX_DLEN];
+};
+
#define CAN_MTU (sizeof(struct can_frame))
#define CANFD_MTU (sizeof(struct canfd_frame))
+#define CANXL_MTU (sizeof(struct canxl_frame))
+#define CANXL_HDR_SIZE (offsetof(struct canxl_frame, data))
+#define CANXL_MIN_MTU (CANXL_HDR_SIZE + 64)
+#define CANXL_MAX_MTU CANXL_MTU
/* particular protocols of the protocol family PF_CAN */
#define CAN_RAW 1 /* RAW sockets */
diff --git a/lib/libc/include/any-linux-any/linux/can/bcm.h b/lib/libc/include/any-linux-any/linux/can/bcm.h
index 7b818faea6..87a3947711 100644
--- a/lib/libc/include/any-linux-any/linux/can/bcm.h
+++ b/lib/libc/include/any-linux-any/linux/can/bcm.h
@@ -71,7 +71,7 @@ struct bcm_msg_head {
struct bcm_timeval ival1, ival2;
canid_t can_id;
__u32 nframes;
- struct can_frame frames[0];
+ struct can_frame frames[];
};
enum {
diff --git a/lib/libc/include/any-linux-any/linux/can/error.h b/lib/libc/include/any-linux-any/linux/can/error.h
index 0e392e7c3f..5f72a2da01 100644
--- a/lib/libc/include/any-linux-any/linux/can/error.h
+++ b/lib/libc/include/any-linux-any/linux/can/error.h
@@ -57,6 +57,8 @@
#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
+#define CAN_ERR_CNT 0x00000200U /* TX error counter / data[6] */
+ /* RX error counter / data[7] */
/* arbitration lost in bit ... / data[0] */
#define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
@@ -120,6 +122,22 @@
#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
-/* controller specific additional information / data[5..7] */
+/* data[5] is reserved (do not use) */
+
+/* TX error counter / data[6] */
+/* RX error counter / data[7] */
+
+/* CAN state thresholds
+ *
+ * Error counter Error state
+ * -----------------------------------
+ * 0 - 95 Error-active
+ * 96 - 127 Error-warning
+ * 128 - 255 Error-passive
+ * 256 and greater Bus-off
+ */
+#define CAN_ERROR_WARNING_THRESHOLD 96
+#define CAN_ERROR_PASSIVE_THRESHOLD 128
+#define CAN_BUS_OFF_THRESHOLD 256
#endif /* _CAN_ERROR_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/can/isotp.h b/lib/libc/include/any-linux-any/linux/can/isotp.h
index dd3178500d..963924325c 100644
--- a/lib/libc/include/any-linux-any/linux/can/isotp.h
+++ b/lib/libc/include/any-linux-any/linux/can/isotp.h
@@ -124,33 +124,30 @@ struct can_isotp_ll_options {
/* flags for isotp behaviour */
-#define CAN_ISOTP_LISTEN_MODE 0x001 /* listen only (do not send FC) */
-#define CAN_ISOTP_EXTEND_ADDR 0x002 /* enable extended addressing */
-#define CAN_ISOTP_TX_PADDING 0x004 /* enable CAN frame padding tx path */
-#define CAN_ISOTP_RX_PADDING 0x008 /* enable CAN frame padding rx path */
-#define CAN_ISOTP_CHK_PAD_LEN 0x010 /* check received CAN frame padding */
-#define CAN_ISOTP_CHK_PAD_DATA 0x020 /* check received CAN frame padding */
-#define CAN_ISOTP_HALF_DUPLEX 0x040 /* half duplex error state handling */
-#define CAN_ISOTP_FORCE_TXSTMIN 0x080 /* ignore stmin from received FC */
-#define CAN_ISOTP_FORCE_RXSTMIN 0x100 /* ignore CFs depending on rx stmin */
-#define CAN_ISOTP_RX_EXT_ADDR 0x200 /* different rx extended addressing */
-#define CAN_ISOTP_WAIT_TX_DONE 0x400 /* wait for tx completion */
-#define CAN_ISOTP_SF_BROADCAST 0x800 /* 1-to-N functional addressing */
-
-/* default values */
+#define CAN_ISOTP_LISTEN_MODE 0x0001 /* listen only (do not send FC) */
+#define CAN_ISOTP_EXTEND_ADDR 0x0002 /* enable extended addressing */
+#define CAN_ISOTP_TX_PADDING 0x0004 /* enable CAN frame padding tx path */
+#define CAN_ISOTP_RX_PADDING 0x0008 /* enable CAN frame padding rx path */
+#define CAN_ISOTP_CHK_PAD_LEN 0x0010 /* check received CAN frame padding */
+#define CAN_ISOTP_CHK_PAD_DATA 0x0020 /* check received CAN frame padding */
+#define CAN_ISOTP_HALF_DUPLEX 0x0040 /* half duplex error state handling */
+#define CAN_ISOTP_FORCE_TXSTMIN 0x0080 /* ignore stmin from received FC */
+#define CAN_ISOTP_FORCE_RXSTMIN 0x0100 /* ignore CFs depending on rx stmin */
+#define CAN_ISOTP_RX_EXT_ADDR 0x0200 /* different rx extended addressing */
+#define CAN_ISOTP_WAIT_TX_DONE 0x0400 /* wait for tx completion */
+#define CAN_ISOTP_SF_BROADCAST 0x0800 /* 1-to-N functional addressing */
+#define CAN_ISOTP_CF_BROADCAST 0x1000 /* 1-to-N transmission w/o FC */
+
+/* protocol machine default values */
#define CAN_ISOTP_DEFAULT_FLAGS 0
#define CAN_ISOTP_DEFAULT_EXT_ADDRESS 0x00
#define CAN_ISOTP_DEFAULT_PAD_CONTENT 0xCC /* prevent bit-stuffing */
-#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 0
+#define CAN_ISOTP_DEFAULT_FRAME_TXTIME 50000 /* 50 micro seconds */
#define CAN_ISOTP_DEFAULT_RECV_BS 0
#define CAN_ISOTP_DEFAULT_RECV_STMIN 0x00
#define CAN_ISOTP_DEFAULT_RECV_WFTMAX 0
-#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU
-#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN
-#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0
-
/*
* Remark on CAN_ISOTP_DEFAULT_RECV_* values:
*
@@ -162,4 +159,24 @@ struct can_isotp_ll_options {
* consistency and copied directly into the flow control (FC) frame.
*/
+/* link layer default values => make use of Classical CAN frames */
+
+#define CAN_ISOTP_DEFAULT_LL_MTU CAN_MTU
+#define CAN_ISOTP_DEFAULT_LL_TX_DL CAN_MAX_DLEN
+#define CAN_ISOTP_DEFAULT_LL_TX_FLAGS 0
+
+/*
+ * The CAN_ISOTP_DEFAULT_FRAME_TXTIME has become a non-zero value as
+ * it only makes sense for isotp implementation tests to run without
+ * a N_As value. As user space applications usually do not set the
+ * frame_txtime element of struct can_isotp_options the new in-kernel
+ * default is very likely overwritten with zero when the sockopt()
+ * CAN_ISOTP_OPTS is invoked.
+ * To make sure that a N_As value of zero is only set intentional the
+ * value '0' is now interpreted as 'do not change the current value'.
+ * When a frame_txtime of zero is required for testing purposes this
+ * CAN_ISOTP_FRAME_TXTIME_ZERO u32 value has to be set in frame_txtime.
+ */
+#define CAN_ISOTP_FRAME_TXTIME_ZERO 0xFFFFFFFF
+
#endif /* !_UAPI_CAN_ISOTP_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/can/netlink.h b/lib/libc/include/any-linux-any/linux/can/netlink.h
index 1268a0aa18..2890f7e444 100644
--- a/lib/libc/include/any-linux-any/linux/can/netlink.h
+++ b/lib/libc/include/any-linux-any/linux/can/netlink.h
@@ -137,6 +137,7 @@ enum {
IFLA_CAN_DATA_BITRATE_CONST,
IFLA_CAN_BITRATE_MAX,
IFLA_CAN_TDC,
+ IFLA_CAN_CTRLMODE_EXT,
/* add new constants above here */
__IFLA_CAN_MAX,
@@ -166,6 +167,18 @@ enum {
IFLA_CAN_TDC_MAX = __IFLA_CAN_TDC - 1
};
+/*
+ * IFLA_CAN_CTRLMODE_EXT nest: controller mode extended parameters
+ */
+enum {
+ IFLA_CAN_CTRLMODE_UNSPEC,
+ IFLA_CAN_CTRLMODE_SUPPORTED, /* u32 */
+
+ /* add new constants above here */
+ __IFLA_CAN_CTRLMODE,
+ IFLA_CAN_CTRLMODE_MAX = __IFLA_CAN_CTRLMODE - 1
+};
+
/* u16 termination range: 1..65535 Ohms */
#define CAN_TERMINATION_DISABLED 0
diff --git a/lib/libc/include/any-linux-any/linux/can/raw.h b/lib/libc/include/any-linux-any/linux/can/raw.h
index 6098abc52a..f5b29a697f 100644
--- a/lib/libc/include/any-linux-any/linux/can/raw.h
+++ b/lib/libc/include/any-linux-any/linux/can/raw.h
@@ -62,6 +62,7 @@ enum {
CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
CAN_RAW_JOIN_FILTERS, /* all filters must match to trigger */
+ CAN_RAW_XL_FRAMES, /* allow CAN XL frames (default:off) */
};
#endif /* !_UAPI_CAN_RAW_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/capability.h b/lib/libc/include/any-linux-any/linux/capability.h
index 5d8ee52b2f..f3d8dd16b8 100644
--- a/lib/libc/include/any-linux-any/linux/capability.h
+++ b/lib/libc/include/any-linux-any/linux/capability.h
@@ -424,7 +424,7 @@ struct vfs_ns_cap_data {
*/
#define CAP_TO_INDEX(x) ((x) >> 5) /* 1 << 5 == bits in __u32 */
-#define CAP_TO_MASK(x) (1 << ((x) & 31)) /* mask for indexed __u32 */
+#define CAP_TO_MASK(x) (1U << ((x) & 31)) /* mask for indexed __u32 */
#endif /* _LINUX_CAPABILITY_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/cdrom.h b/lib/libc/include/any-linux-any/linux/cdrom.h
index 59a3f79d4b..8739b21cc0 100644
--- a/lib/libc/include/any-linux-any/linux/cdrom.h
+++ b/lib/libc/include/any-linux-any/linux/cdrom.h
@@ -103,7 +103,7 @@
#define CDROMREADALL 0x5318 /* read all 2646 bytes */
/*
- * These ioctls are (now) only in ide-cd.c for controlling
+ * These ioctls were only in (now removed) ide-cd.c for controlling
* drive spindown time. They should be implemented in the
* Uniform driver, via generic packet commands, GPCMD_MODE_SELECT_10,
* GPCMD_MODE_SENSE_10 and the GPMODE_POWER_PAGE...
diff --git a/lib/libc/include/any-linux-any/linux/cec-funcs.h b/lib/libc/include/any-linux-any/linux/cec-funcs.h
index 90d5c41e2d..a0ae699e09 100644
--- a/lib/libc/include/any-linux-any/linux/cec-funcs.h
+++ b/lib/libc/include/any-linux-any/linux/cec-funcs.h
@@ -1568,6 +1568,20 @@ static __inline__ void cec_ops_request_short_audio_descriptor(const struct cec_m
}
}
+static __inline__ void cec_msg_set_audio_volume_level(struct cec_msg *msg,
+ __u8 audio_volume_level)
+{
+ msg->len = 3;
+ msg->msg[1] = CEC_MSG_SET_AUDIO_VOLUME_LEVEL;
+ msg->msg[2] = audio_volume_level;
+}
+
+static __inline__ void cec_ops_set_audio_volume_level(const struct cec_msg *msg,
+ __u8 *audio_volume_level)
+{
+ *audio_volume_level = msg->msg[2];
+}
+
/* Audio Rate Control Feature */
static __inline__ void cec_msg_set_audio_rate(struct cec_msg *msg,
diff --git a/lib/libc/include/any-linux-any/linux/cec.h b/lib/libc/include/any-linux-any/linux/cec.h
index 8a98f42492..24d0b3b075 100644
--- a/lib/libc/include/any-linux-any/linux/cec.h
+++ b/lib/libc/include/any-linux-any/linux/cec.h
@@ -142,6 +142,26 @@ static __inline__ void cec_msg_set_reply_to(struct cec_msg *msg,
msg->reply = msg->timeout = 0;
}
+/**
+ * cec_msg_recv_is_tx_result - return true if this message contains the
+ * result of an earlier non-blocking transmit
+ * @msg: the message structure from CEC_RECEIVE
+ */
+static __inline__ int cec_msg_recv_is_tx_result(const struct cec_msg *msg)
+{
+ return msg->sequence && msg->tx_status && !msg->rx_status;
+}
+
+/**
+ * cec_msg_recv_is_rx_result - return true if this message contains the
+ * reply of an earlier non-blocking transmit
+ * @msg: the message structure from CEC_RECEIVE
+ */
+static __inline__ int cec_msg_recv_is_rx_result(const struct cec_msg *msg)
+{
+ return msg->sequence && !msg->tx_status && msg->rx_status;
+}
+
/* cec_msg flags field */
#define CEC_MSG_FL_REPLY_TO_FOLLOWERS (1 << 0)
#define CEC_MSG_FL_RAW (1 << 1)
@@ -748,6 +768,7 @@ struct cec_event {
#define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE 0x08
#define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX 0x04
#define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX 0x02
+#define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_VOLUME_LEVEL 0x01
#define CEC_MSG_GIVE_FEATURES 0xa5 /* HDMI 2.0 */
@@ -1039,6 +1060,7 @@ struct cec_event {
#define CEC_OP_AUD_FMT_ID_CEA861 0
#define CEC_OP_AUD_FMT_ID_CEA861_CXT 1
+#define CEC_MSG_SET_AUDIO_VOLUME_LEVEL 0x73
/* Audio Rate Control Feature */
#define CEC_MSG_SET_AUDIO_RATE 0x9a
diff --git a/lib/libc/include/any-linux-any/linux/comedi.h b/lib/libc/include/any-linux-any/linux/comedi.h
new file mode 100644
index 0000000000..0ef8eadde4
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/comedi.h
@@ -0,0 +1,1528 @@
+/* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
+/*
+ * comedi.h
+ * header file for COMEDI user API
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998-2001 David A. Schleef <ds@schleef.org>
+ */
+
+#ifndef _COMEDI_H
+#define _COMEDI_H
+
+#define COMEDI_MAJORVERSION 0
+#define COMEDI_MINORVERSION 7
+#define COMEDI_MICROVERSION 76
+#define VERSION "0.7.76"
+
+/* comedi's major device number */
+#define COMEDI_MAJOR 98
+
+/*
+ * maximum number of minor devices. This can be increased, although
+ * kernel structures are currently statically allocated, thus you
+ * don't want this to be much more than you actually use.
+ */
+#define COMEDI_NDEVICES 16
+
+/* number of config options in the config structure */
+#define COMEDI_NDEVCONFOPTS 32
+
+/*
+ * NOTE: 'comedi_config --init-data' is deprecated
+ *
+ * The following indexes in the config options were used by
+ * comedi_config to pass firmware blobs from user space to the
+ * comedi drivers. The request_firmware() hotplug interface is
+ * now used by all comedi drivers instead.
+ */
+
+/* length of nth chunk of firmware data -*/
+#define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25
+#define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26
+#define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27
+#define COMEDI_DEVCONF_AUX_DATA0_LENGTH 28
+/* most significant 32 bits of pointer address (if needed) */
+#define COMEDI_DEVCONF_AUX_DATA_HI 29
+/* least significant 32 bits of pointer address */
+#define COMEDI_DEVCONF_AUX_DATA_LO 30
+#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31 /* total data length */
+
+/* max length of device and driver names */
+#define COMEDI_NAMELEN 20
+
+/* packs and unpacks a channel/range number */
+
+#define CR_PACK(chan, rng, aref) \
+ ((((aref) & 0x3) << 24) | (((rng) & 0xff) << 16) | (chan))
+#define CR_PACK_FLAGS(chan, range, aref, flags) \
+ (CR_PACK(chan, range, aref) | ((flags) & CR_FLAGS_MASK))
+
+#define CR_CHAN(a) ((a) & 0xffff)
+#define CR_RANGE(a) (((a) >> 16) & 0xff)
+#define CR_AREF(a) (((a) >> 24) & 0x03)
+
+#define CR_FLAGS_MASK 0xfc000000
+#define CR_ALT_FILTER 0x04000000
+#define CR_DITHER CR_ALT_FILTER
+#define CR_DEGLITCH CR_ALT_FILTER
+#define CR_ALT_SOURCE 0x08000000
+#define CR_EDGE 0x40000000
+#define CR_INVERT 0x80000000
+
+#define AREF_GROUND 0x00 /* analog ref = analog ground */
+#define AREF_COMMON 0x01 /* analog ref = analog common */
+#define AREF_DIFF 0x02 /* analog ref = differential */
+#define AREF_OTHER 0x03 /* analog ref = other (undefined) */
+
+/* counters -- these are arbitrary values */
+#define GPCT_RESET 0x0001
+#define GPCT_SET_SOURCE 0x0002
+#define GPCT_SET_GATE 0x0004
+#define GPCT_SET_DIRECTION 0x0008
+#define GPCT_SET_OPERATION 0x0010
+#define GPCT_ARM 0x0020
+#define GPCT_DISARM 0x0040
+#define GPCT_GET_INT_CLK_FRQ 0x0080
+
+#define GPCT_INT_CLOCK 0x0001
+#define GPCT_EXT_PIN 0x0002
+#define GPCT_NO_GATE 0x0004
+#define GPCT_UP 0x0008
+#define GPCT_DOWN 0x0010
+#define GPCT_HWUD 0x0020
+#define GPCT_SIMPLE_EVENT 0x0040
+#define GPCT_SINGLE_PERIOD 0x0080
+#define GPCT_SINGLE_PW 0x0100
+#define GPCT_CONT_PULSE_OUT 0x0200
+#define GPCT_SINGLE_PULSE_OUT 0x0400
+
+/* instructions */
+
+#define INSN_MASK_WRITE 0x8000000
+#define INSN_MASK_READ 0x4000000
+#define INSN_MASK_SPECIAL 0x2000000
+
+#define INSN_READ (0 | INSN_MASK_READ)
+#define INSN_WRITE (1 | INSN_MASK_WRITE)
+#define INSN_BITS (2 | INSN_MASK_READ | INSN_MASK_WRITE)
+#define INSN_CONFIG (3 | INSN_MASK_READ | INSN_MASK_WRITE)
+#define INSN_DEVICE_CONFIG (INSN_CONFIG | INSN_MASK_SPECIAL)
+#define INSN_GTOD (4 | INSN_MASK_READ | INSN_MASK_SPECIAL)
+#define INSN_WAIT (5 | INSN_MASK_WRITE | INSN_MASK_SPECIAL)
+#define INSN_INTTRIG (6 | INSN_MASK_WRITE | INSN_MASK_SPECIAL)
+
+/* command flags */
+/* These flags are used in comedi_cmd structures */
+
+#define CMDF_BOGUS 0x00000001 /* do the motions */
+
+/* try to use a real-time interrupt while performing command */
+#define CMDF_PRIORITY 0x00000008
+
+/* wake up on end-of-scan events */
+#define CMDF_WAKE_EOS 0x00000020
+
+#define CMDF_WRITE 0x00000040
+
+#define CMDF_RAWDATA 0x00000080
+
+/* timer rounding definitions */
+#define CMDF_ROUND_MASK 0x00030000
+#define CMDF_ROUND_NEAREST 0x00000000
+#define CMDF_ROUND_DOWN 0x00010000
+#define CMDF_ROUND_UP 0x00020000
+#define CMDF_ROUND_UP_NEXT 0x00030000
+
+#define COMEDI_EV_START 0x00040000
+#define COMEDI_EV_SCAN_BEGIN 0x00080000
+#define COMEDI_EV_CONVERT 0x00100000
+#define COMEDI_EV_SCAN_END 0x00200000
+#define COMEDI_EV_STOP 0x00400000
+
+/* compatibility definitions */
+#define TRIG_BOGUS CMDF_BOGUS
+#define TRIG_RT CMDF_PRIORITY
+#define TRIG_WAKE_EOS CMDF_WAKE_EOS
+#define TRIG_WRITE CMDF_WRITE
+#define TRIG_ROUND_MASK CMDF_ROUND_MASK
+#define TRIG_ROUND_NEAREST CMDF_ROUND_NEAREST
+#define TRIG_ROUND_DOWN CMDF_ROUND_DOWN
+#define TRIG_ROUND_UP CMDF_ROUND_UP
+#define TRIG_ROUND_UP_NEXT CMDF_ROUND_UP_NEXT
+
+/* trigger sources */
+
+#define TRIG_ANY 0xffffffff
+#define TRIG_INVALID 0x00000000
+
+#define TRIG_NONE 0x00000001 /* never trigger */
+#define TRIG_NOW 0x00000002 /* trigger now + N ns */
+#define TRIG_FOLLOW 0x00000004 /* trigger on next lower level trig */
+#define TRIG_TIME 0x00000008 /* trigger at time N ns */
+#define TRIG_TIMER 0x00000010 /* trigger at rate N ns */
+#define TRIG_COUNT 0x00000020 /* trigger when count reaches N */
+#define TRIG_EXT 0x00000040 /* trigger on external signal N */
+#define TRIG_INT 0x00000080 /* trigger on comedi-internal signal N */
+#define TRIG_OTHER 0x00000100 /* driver defined */
+
+/* subdevice flags */
+
+#define SDF_BUSY 0x0001 /* device is busy */
+#define SDF_BUSY_OWNER 0x0002 /* device is busy with your job */
+#define SDF_LOCKED 0x0004 /* subdevice is locked */
+#define SDF_LOCK_OWNER 0x0008 /* you own lock */
+#define SDF_MAXDATA 0x0010 /* maxdata depends on channel */
+#define SDF_FLAGS 0x0020 /* flags depend on channel */
+#define SDF_RANGETYPE 0x0040 /* range type depends on channel */
+#define SDF_PWM_COUNTER 0x0080 /* PWM can automatically switch off */
+#define SDF_PWM_HBRIDGE 0x0100 /* PWM is signed (H-bridge) */
+#define SDF_CMD 0x1000 /* can do commands (deprecated) */
+#define SDF_SOFT_CALIBRATED 0x2000 /* subdevice uses software calibration */
+#define SDF_CMD_WRITE 0x4000 /* can do output commands */
+#define SDF_CMD_READ 0x8000 /* can do input commands */
+
+/* subdevice can be read (e.g. analog input) */
+#define SDF_READABLE 0x00010000
+/* subdevice can be written (e.g. analog output) */
+#define SDF_WRITABLE 0x00020000
+#define SDF_WRITEABLE SDF_WRITABLE /* spelling error in API */
+/* subdevice does not have externally visible lines */
+#define SDF_INTERNAL 0x00040000
+#define SDF_GROUND 0x00100000 /* can do aref=ground */
+#define SDF_COMMON 0x00200000 /* can do aref=common */
+#define SDF_DIFF 0x00400000 /* can do aref=diff */
+#define SDF_OTHER 0x00800000 /* can do aref=other */
+#define SDF_DITHER 0x01000000 /* can do dithering */
+#define SDF_DEGLITCH 0x02000000 /* can do deglitching */
+#define SDF_MMAP 0x04000000 /* can do mmap() */
+#define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */
+#define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */
+#define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */
+
+/* subdevice types */
+
+/**
+ * enum comedi_subdevice_type - COMEDI subdevice types
+ * @COMEDI_SUBD_UNUSED: Unused subdevice.
+ * @COMEDI_SUBD_AI: Analog input.
+ * @COMEDI_SUBD_AO: Analog output.
+ * @COMEDI_SUBD_DI: Digital input.
+ * @COMEDI_SUBD_DO: Digital output.
+ * @COMEDI_SUBD_DIO: Digital input/output.
+ * @COMEDI_SUBD_COUNTER: Counter.
+ * @COMEDI_SUBD_TIMER: Timer.
+ * @COMEDI_SUBD_MEMORY: Memory, EEPROM, DPRAM.
+ * @COMEDI_SUBD_CALIB: Calibration DACs.
+ * @COMEDI_SUBD_PROC: Processor, DSP.
+ * @COMEDI_SUBD_SERIAL: Serial I/O.
+ * @COMEDI_SUBD_PWM: Pulse-Width Modulation output.
+ */
+enum comedi_subdevice_type {
+ COMEDI_SUBD_UNUSED,
+ COMEDI_SUBD_AI,
+ COMEDI_SUBD_AO,
+ COMEDI_SUBD_DI,
+ COMEDI_SUBD_DO,
+ COMEDI_SUBD_DIO,
+ COMEDI_SUBD_COUNTER,
+ COMEDI_SUBD_TIMER,
+ COMEDI_SUBD_MEMORY,
+ COMEDI_SUBD_CALIB,
+ COMEDI_SUBD_PROC,
+ COMEDI_SUBD_SERIAL,
+ COMEDI_SUBD_PWM
+};
+
+/* configuration instructions */
+
+/**
+ * enum comedi_io_direction - COMEDI I/O directions
+ * @COMEDI_INPUT: Input.
+ * @COMEDI_OUTPUT: Output.
+ * @COMEDI_OPENDRAIN: Open-drain (or open-collector) output.
+ *
+ * These are used by the %INSN_CONFIG_DIO_QUERY configuration instruction to
+ * report a direction. They may also be used in other places where a direction
+ * needs to be specified.
+ */
+enum comedi_io_direction {
+ COMEDI_INPUT = 0,
+ COMEDI_OUTPUT = 1,
+ COMEDI_OPENDRAIN = 2
+};
+
+/**
+ * enum configuration_ids - COMEDI configuration instruction codes
+ * @INSN_CONFIG_DIO_INPUT: Configure digital I/O as input.
+ * @INSN_CONFIG_DIO_OUTPUT: Configure digital I/O as output.
+ * @INSN_CONFIG_DIO_OPENDRAIN: Configure digital I/O as open-drain (or open
+ * collector) output.
+ * @INSN_CONFIG_ANALOG_TRIG: Configure analog trigger.
+ * @INSN_CONFIG_ALT_SOURCE: Configure alternate input source.
+ * @INSN_CONFIG_DIGITAL_TRIG: Configure digital trigger.
+ * @INSN_CONFIG_BLOCK_SIZE: Configure block size for DMA transfers.
+ * @INSN_CONFIG_TIMER_1: Configure divisor for external clock.
+ * @INSN_CONFIG_FILTER: Configure a filter.
+ * @INSN_CONFIG_CHANGE_NOTIFY: Configure change notification for digital
+ * inputs. (New drivers should use
+ * %INSN_CONFIG_DIGITAL_TRIG instead.)
+ * @INSN_CONFIG_SERIAL_CLOCK: Configure clock for serial I/O.
+ * @INSN_CONFIG_BIDIRECTIONAL_DATA: Send and receive byte over serial I/O.
+ * @INSN_CONFIG_DIO_QUERY: Query direction of digital I/O channel.
+ * @INSN_CONFIG_PWM_OUTPUT: Configure pulse-width modulator output.
+ * @INSN_CONFIG_GET_PWM_OUTPUT: Get pulse-width modulator output configuration.
+ * @INSN_CONFIG_ARM: Arm a subdevice or channel.
+ * @INSN_CONFIG_DISARM: Disarm a subdevice or channel.
+ * @INSN_CONFIG_GET_COUNTER_STATUS: Get counter status.
+ * @INSN_CONFIG_RESET: Reset a subdevice or channel.
+ * @INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR: Configure counter/timer as
+ * single pulse generator.
+ * @INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR: Configure counter/timer as
+ * pulse train generator.
+ * @INSN_CONFIG_GPCT_QUADRATURE_ENCODER: Configure counter as a quadrature
+ * encoder.
+ * @INSN_CONFIG_SET_GATE_SRC: Set counter/timer gate source.
+ * @INSN_CONFIG_GET_GATE_SRC: Get counter/timer gate source.
+ * @INSN_CONFIG_SET_CLOCK_SRC: Set counter/timer master clock source.
+ * @INSN_CONFIG_GET_CLOCK_SRC: Get counter/timer master clock source.
+ * @INSN_CONFIG_SET_OTHER_SRC: Set counter/timer "other" source.
+ * @INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE: Get size (in bytes) of subdevice's
+ * on-board FIFOs used during streaming
+ * input/output.
+ * @INSN_CONFIG_SET_COUNTER_MODE: Set counter/timer mode.
+ * @INSN_CONFIG_8254_SET_MODE: (Deprecated) Same as
+ * %INSN_CONFIG_SET_COUNTER_MODE.
+ * @INSN_CONFIG_8254_READ_STATUS: Read status of 8254 counter channel.
+ * @INSN_CONFIG_SET_ROUTING: Set routing for a channel.
+ * @INSN_CONFIG_GET_ROUTING: Get routing for a channel.
+ * @INSN_CONFIG_PWM_SET_PERIOD: Set PWM period in nanoseconds.
+ * @INSN_CONFIG_PWM_GET_PERIOD: Get PWM period in nanoseconds.
+ * @INSN_CONFIG_GET_PWM_STATUS: Get PWM status.
+ * @INSN_CONFIG_PWM_SET_H_BRIDGE: Set PWM H bridge duty cycle and polarity for
+ * a relay simultaneously.
+ * @INSN_CONFIG_PWM_GET_H_BRIDGE: Get PWM H bridge duty cycle and polarity.
+ * @INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS: Get the hardware timing restraints,
+ * regardless of trigger sources.
+ */
+enum configuration_ids {
+ INSN_CONFIG_DIO_INPUT = COMEDI_INPUT,
+ INSN_CONFIG_DIO_OUTPUT = COMEDI_OUTPUT,
+ INSN_CONFIG_DIO_OPENDRAIN = COMEDI_OPENDRAIN,
+ INSN_CONFIG_ANALOG_TRIG = 16,
+/* INSN_CONFIG_WAVEFORM = 17, */
+/* INSN_CONFIG_TRIG = 18, */
+/* INSN_CONFIG_COUNTER = 19, */
+ INSN_CONFIG_ALT_SOURCE = 20,
+ INSN_CONFIG_DIGITAL_TRIG = 21,
+ INSN_CONFIG_BLOCK_SIZE = 22,
+ INSN_CONFIG_TIMER_1 = 23,
+ INSN_CONFIG_FILTER = 24,
+ INSN_CONFIG_CHANGE_NOTIFY = 25,
+
+ INSN_CONFIG_SERIAL_CLOCK = 26, /*ALPHA*/
+ INSN_CONFIG_BIDIRECTIONAL_DATA = 27,
+ INSN_CONFIG_DIO_QUERY = 28,
+ INSN_CONFIG_PWM_OUTPUT = 29,
+ INSN_CONFIG_GET_PWM_OUTPUT = 30,
+ INSN_CONFIG_ARM = 31,
+ INSN_CONFIG_DISARM = 32,
+ INSN_CONFIG_GET_COUNTER_STATUS = 33,
+ INSN_CONFIG_RESET = 34,
+ INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR = 1001,
+ INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR = 1002,
+ INSN_CONFIG_GPCT_QUADRATURE_ENCODER = 1003,
+ INSN_CONFIG_SET_GATE_SRC = 2001,
+ INSN_CONFIG_GET_GATE_SRC = 2002,
+ INSN_CONFIG_SET_CLOCK_SRC = 2003,
+ INSN_CONFIG_GET_CLOCK_SRC = 2004,
+ INSN_CONFIG_SET_OTHER_SRC = 2005,
+ INSN_CONFIG_GET_HARDWARE_BUFFER_SIZE = 2006,
+ INSN_CONFIG_SET_COUNTER_MODE = 4097,
+ INSN_CONFIG_8254_SET_MODE = INSN_CONFIG_SET_COUNTER_MODE,
+ INSN_CONFIG_8254_READ_STATUS = 4098,
+ INSN_CONFIG_SET_ROUTING = 4099,
+ INSN_CONFIG_GET_ROUTING = 4109,
+ INSN_CONFIG_PWM_SET_PERIOD = 5000,
+ INSN_CONFIG_PWM_GET_PERIOD = 5001,
+ INSN_CONFIG_GET_PWM_STATUS = 5002,
+ INSN_CONFIG_PWM_SET_H_BRIDGE = 5003,
+ INSN_CONFIG_PWM_GET_H_BRIDGE = 5004,
+ INSN_CONFIG_GET_CMD_TIMING_CONSTRAINTS = 5005,
+};
+
+/**
+ * enum device_configuration_ids - COMEDI configuration instruction codes global
+ * to an entire device.
+ * @INSN_DEVICE_CONFIG_TEST_ROUTE: Validate the possibility of a
+ * globally-named route
+ * @INSN_DEVICE_CONFIG_CONNECT_ROUTE: Connect a globally-named route
+ * @INSN_DEVICE_CONFIG_DISCONNECT_ROUTE:Disconnect a globally-named route
+ * @INSN_DEVICE_CONFIG_GET_ROUTES: Get a list of all globally-named routes
+ * that are valid for a particular device.
+ */
+enum device_config_route_ids {
+ INSN_DEVICE_CONFIG_TEST_ROUTE = 0,
+ INSN_DEVICE_CONFIG_CONNECT_ROUTE = 1,
+ INSN_DEVICE_CONFIG_DISCONNECT_ROUTE = 2,
+ INSN_DEVICE_CONFIG_GET_ROUTES = 3,
+};
+
+/**
+ * enum comedi_digital_trig_op - operations for configuring a digital trigger
+ * @COMEDI_DIGITAL_TRIG_DISABLE: Return digital trigger to its default,
+ * inactive, unconfigured state.
+ * @COMEDI_DIGITAL_TRIG_ENABLE_EDGES: Set rising and/or falling edge inputs
+ * that each can fire the trigger.
+ * @COMEDI_DIGITAL_TRIG_ENABLE_LEVELS: Set a combination of high and/or low
+ * level inputs that can fire the trigger.
+ *
+ * These are used with the %INSN_CONFIG_DIGITAL_TRIG configuration instruction.
+ * The data for the configuration instruction is as follows...
+ *
+ * data[%0] = %INSN_CONFIG_DIGITAL_TRIG
+ *
+ * data[%1] = trigger ID
+ *
+ * data[%2] = configuration operation
+ *
+ * data[%3] = configuration parameter 1
+ *
+ * data[%4] = configuration parameter 2
+ *
+ * data[%5] = configuration parameter 3
+ *
+ * The trigger ID (data[%1]) is used to differentiate multiple digital triggers
+ * belonging to the same subdevice. The configuration operation (data[%2]) is
+ * one of the enum comedi_digital_trig_op values. The configuration
+ * parameters (data[%3], data[%4], and data[%5]) depend on the operation; they
+ * are not used with %COMEDI_DIGITAL_TRIG_DISABLE.
+ *
+ * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES and %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS,
+ * configuration parameter 1 (data[%3]) contains a "left-shift" value that
+ * specifies the input corresponding to bit 0 of configuration parameters 2
+ * and 3. This is useful if the trigger has more than 32 inputs.
+ *
+ * For %COMEDI_DIGITAL_TRIG_ENABLE_EDGES, configuration parameter 2 (data[%4])
+ * specifies which of up to 32 inputs have rising-edge sensitivity, and
+ * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs
+ * have falling-edge sensitivity that can fire the trigger.
+ *
+ * For %COMEDI_DIGITAL_TRIG_ENABLE_LEVELS, configuration parameter 2 (data[%4])
+ * specifies which of up to 32 inputs must be at a high level, and
+ * configuration parameter 3 (data[%5]) specifies which of up to 32 inputs
+ * must be at a low level for the trigger to fire.
+ *
+ * Some sequences of %INSN_CONFIG_DIGITAL_TRIG instructions may have a (partly)
+ * accumulative effect, depending on the low-level driver. This is useful
+ * when setting up a trigger that has more than 32 inputs, or has a combination
+ * of edge- and level-triggered inputs.
+ */
+enum comedi_digital_trig_op {
+ COMEDI_DIGITAL_TRIG_DISABLE = 0,
+ COMEDI_DIGITAL_TRIG_ENABLE_EDGES = 1,
+ COMEDI_DIGITAL_TRIG_ENABLE_LEVELS = 2
+};
+
+/**
+ * enum comedi_support_level - support level for a COMEDI feature
+ * @COMEDI_UNKNOWN_SUPPORT: Unspecified support for feature.
+ * @COMEDI_SUPPORTED: Feature is supported.
+ * @COMEDI_UNSUPPORTED: Feature is unsupported.
+ */
+enum comedi_support_level {
+ COMEDI_UNKNOWN_SUPPORT = 0,
+ COMEDI_SUPPORTED,
+ COMEDI_UNSUPPORTED
+};
+
+/**
+ * enum comedi_counter_status_flags - counter status bits
+ * @COMEDI_COUNTER_ARMED: Counter is armed.
+ * @COMEDI_COUNTER_COUNTING: Counter is counting.
+ * @COMEDI_COUNTER_TERMINAL_COUNT: Counter reached terminal count.
+ *
+ * These bitwise values are used by the %INSN_CONFIG_GET_COUNTER_STATUS
+ * configuration instruction to report the status of a counter.
+ */
+enum comedi_counter_status_flags {
+ COMEDI_COUNTER_ARMED = 0x1,
+ COMEDI_COUNTER_COUNTING = 0x2,
+ COMEDI_COUNTER_TERMINAL_COUNT = 0x4,
+};
+
+/* ioctls */
+
+#define CIO 'd'
+#define COMEDI_DEVCONFIG _IOW(CIO, 0, struct comedi_devconfig)
+#define COMEDI_DEVINFO _IOR(CIO, 1, struct comedi_devinfo)
+#define COMEDI_SUBDINFO _IOR(CIO, 2, struct comedi_subdinfo)
+#define COMEDI_CHANINFO _IOR(CIO, 3, struct comedi_chaninfo)
+/* _IOWR(CIO, 4, ...) is reserved */
+#define COMEDI_LOCK _IO(CIO, 5)
+#define COMEDI_UNLOCK _IO(CIO, 6)
+#define COMEDI_CANCEL _IO(CIO, 7)
+#define COMEDI_RANGEINFO _IOR(CIO, 8, struct comedi_rangeinfo)
+#define COMEDI_CMD _IOR(CIO, 9, struct comedi_cmd)
+#define COMEDI_CMDTEST _IOR(CIO, 10, struct comedi_cmd)
+#define COMEDI_INSNLIST _IOR(CIO, 11, struct comedi_insnlist)
+#define COMEDI_INSN _IOR(CIO, 12, struct comedi_insn)
+#define COMEDI_BUFCONFIG _IOR(CIO, 13, struct comedi_bufconfig)
+#define COMEDI_BUFINFO _IOWR(CIO, 14, struct comedi_bufinfo)
+#define COMEDI_POLL _IO(CIO, 15)
+#define COMEDI_SETRSUBD _IO(CIO, 16)
+#define COMEDI_SETWSUBD _IO(CIO, 17)
+
+/* structures */
+
+/**
+ * struct comedi_insn - COMEDI instruction
+ * @insn: COMEDI instruction type (%INSN_xxx).
+ * @n: Length of @data[].
+ * @data: Pointer to data array operated on by the instruction.
+ * @subdev: Subdevice index.
+ * @chanspec: A packed "chanspec" value consisting of channel number,
+ * analog range index, analog reference type, and flags.
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_INSN ioctl, and indirectly with the
+ * %COMEDI_INSNLIST ioctl.
+ */
+struct comedi_insn {
+ unsigned int insn;
+ unsigned int n;
+ unsigned int *data;
+ unsigned int subdev;
+ unsigned int chanspec;
+ unsigned int unused[3];
+};
+
+/**
+ * struct comedi_insnlist - list of COMEDI instructions
+ * @n_insns: Number of COMEDI instructions.
+ * @insns: Pointer to array COMEDI instructions.
+ *
+ * This is used with the %COMEDI_INSNLIST ioctl.
+ */
+struct comedi_insnlist {
+ unsigned int n_insns;
+ struct comedi_insn *insns;
+};
+
+/**
+ * struct comedi_cmd - COMEDI asynchronous acquisition command details
+ * @subdev: Subdevice index.
+ * @flags: Command flags (%CMDF_xxx).
+ * @start_src: "Start acquisition" trigger source (%TRIG_xxx).
+ * @start_arg: "Start acquisition" trigger argument.
+ * @scan_begin_src: "Scan begin" trigger source.
+ * @scan_begin_arg: "Scan begin" trigger argument.
+ * @convert_src: "Convert" trigger source.
+ * @convert_arg: "Convert" trigger argument.
+ * @scan_end_src: "Scan end" trigger source.
+ * @scan_end_arg: "Scan end" trigger argument.
+ * @stop_src: "Stop acquisition" trigger source.
+ * @stop_arg: "Stop acquisition" trigger argument.
+ * @chanlist: Pointer to array of "chanspec" values, containing a
+ * sequence of channel numbers packed with analog range
+ * index, etc.
+ * @chanlist_len: Number of channels in sequence.
+ * @data: Pointer to miscellaneous set-up data (not used).
+ * @data_len: Length of miscellaneous set-up data.
+ *
+ * This is used with the %COMEDI_CMD or %COMEDI_CMDTEST ioctl to set-up
+ * or validate an asynchronous acquisition command. The ioctl may modify
+ * the &struct comedi_cmd and copy it back to the caller.
+ *
+ * Optional command @flags values that can be ORed together...
+ *
+ * %CMDF_BOGUS - makes %COMEDI_CMD ioctl return error %EAGAIN instead of
+ * starting the command.
+ *
+ * %CMDF_PRIORITY - requests "hard real-time" processing (which is not
+ * supported in this version of COMEDI).
+ *
+ * %CMDF_WAKE_EOS - requests the command makes data available for reading
+ * after every "scan" period.
+ *
+ * %CMDF_WRITE - marks the command as being in the "write" (to device)
+ * direction. This does not need to be specified by the caller unless the
+ * subdevice supports commands in either direction.
+ *
+ * %CMDF_RAWDATA - prevents the command from "munging" the data between the
+ * COMEDI sample format and the raw hardware sample format.
+ *
+ * %CMDF_ROUND_NEAREST - requests timing periods to be rounded to nearest
+ * supported values.
+ *
+ * %CMDF_ROUND_DOWN - requests timing periods to be rounded down to supported
+ * values (frequencies rounded up).
+ *
+ * %CMDF_ROUND_UP - requests timing periods to be rounded up to supported
+ * values (frequencies rounded down).
+ *
+ * Trigger source values for @start_src, @scan_begin_src, @convert_src,
+ * @scan_end_src, and @stop_src...
+ *
+ * %TRIG_ANY - "all ones" value used to test which trigger sources are
+ * supported.
+ *
+ * %TRIG_INVALID - "all zeroes" value used to indicate that all requested
+ * trigger sources are invalid.
+ *
+ * %TRIG_NONE - never trigger (often used as a @stop_src value).
+ *
+ * %TRIG_NOW - trigger after '_arg' nanoseconds.
+ *
+ * %TRIG_FOLLOW - trigger follows another event.
+ *
+ * %TRIG_TIMER - trigger every '_arg' nanoseconds.
+ *
+ * %TRIG_COUNT - trigger when count '_arg' is reached.
+ *
+ * %TRIG_EXT - trigger on external signal specified by '_arg'.
+ *
+ * %TRIG_INT - trigger on internal, software trigger specified by '_arg'.
+ *
+ * %TRIG_OTHER - trigger on other, driver-defined signal specified by '_arg'.
+ */
+struct comedi_cmd {
+ unsigned int subdev;
+ unsigned int flags;
+
+ unsigned int start_src;
+ unsigned int start_arg;
+
+ unsigned int scan_begin_src;
+ unsigned int scan_begin_arg;
+
+ unsigned int convert_src;
+ unsigned int convert_arg;
+
+ unsigned int scan_end_src;
+ unsigned int scan_end_arg;
+
+ unsigned int stop_src;
+ unsigned int stop_arg;
+
+ unsigned int *chanlist;
+ unsigned int chanlist_len;
+
+ short *data;
+ unsigned int data_len;
+};
+
+/**
+ * struct comedi_chaninfo - used to retrieve per-channel information
+ * @subdev: Subdevice index.
+ * @maxdata_list: Optional pointer to per-channel maximum data values.
+ * @flaglist: Optional pointer to per-channel flags.
+ * @rangelist: Optional pointer to per-channel range types.
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_CHANINFO ioctl to get per-channel information
+ * for the subdevice. Use of this requires knowledge of the number of channels
+ * and subdevice flags obtained using the %COMEDI_SUBDINFO ioctl.
+ *
+ * The @maxdata_list member must be %NULL unless the %SDF_MAXDATA subdevice
+ * flag is set. The @flaglist member must be %NULL unless the %SDF_FLAGS
+ * subdevice flag is set. The @rangelist member must be %NULL unless the
+ * %SDF_RANGETYPE subdevice flag is set. Otherwise, the arrays they point to
+ * must be at least as long as the number of channels.
+ */
+struct comedi_chaninfo {
+ unsigned int subdev;
+ unsigned int *maxdata_list;
+ unsigned int *flaglist;
+ unsigned int *rangelist;
+ unsigned int unused[4];
+};
+
+/**
+ * struct comedi_rangeinfo - used to retrieve the range table for a channel
+ * @range_type: Encodes subdevice index (bits 27:24), channel index
+ * (bits 23:16) and range table length (bits 15:0).
+ * @range_ptr: Pointer to array of @struct comedi_krange to be filled
+ * in with the range table for the channel or subdevice.
+ *
+ * This is used with the %COMEDI_RANGEINFO ioctl to retrieve the range table
+ * for a specific channel (if the subdevice has the %SDF_RANGETYPE flag set to
+ * indicate that the range table depends on the channel), or for the subdevice
+ * as a whole (if the %SDF_RANGETYPE flag is clear, indicating the range table
+ * is shared by all channels).
+ *
+ * The @range_type value is an input to the ioctl and comes from a previous
+ * use of the %COMEDI_SUBDINFO ioctl (if the %SDF_RANGETYPE flag is clear),
+ * or the %COMEDI_CHANINFO ioctl (if the %SDF_RANGETYPE flag is set).
+ */
+struct comedi_rangeinfo {
+ unsigned int range_type;
+ void *range_ptr;
+};
+
+/**
+ * struct comedi_krange - describes a range in a range table
+ * @min: Minimum value in millionths (1e-6) of a unit.
+ * @max: Maximum value in millionths (1e-6) of a unit.
+ * @flags: Indicates the units (in bits 7:0) OR'ed with optional flags.
+ *
+ * A range table is associated with a single channel, or with all channels in a
+ * subdevice, and a list of one or more ranges. A %struct comedi_krange
+ * describes the physical range of units for one of those ranges. Sample
+ * values in COMEDI are unsigned from %0 up to some 'maxdata' value. The
+ * mapping from sample values to physical units is assumed to be nomimally
+ * linear (for the purpose of describing the range), with sample value %0
+ * mapping to @min, and the 'maxdata' sample value mapping to @max.
+ *
+ * The currently defined units are %UNIT_volt (%0), %UNIT_mA (%1), and
+ * %UNIT_none (%2). The @min and @max values are the physical range multiplied
+ * by 1e6, so a @max value of %1000000 (with %UNIT_volt) represents a maximal
+ * value of 1 volt.
+ *
+ * The only defined flag value is %RF_EXTERNAL (%0x100), indicating that the
+ * range needs to be multiplied by an external reference.
+ */
+struct comedi_krange {
+ int min;
+ int max;
+ unsigned int flags;
+};
+
+/**
+ * struct comedi_subdinfo - used to retrieve information about a subdevice
+ * @type: Type of subdevice from &enum comedi_subdevice_type.
+ * @n_chan: Number of channels the subdevice supports.
+ * @subd_flags: A mixture of static and dynamic flags describing
+ * aspects of the subdevice and its current state.
+ * @timer_type: Timer type. Always set to %5 ("nanosecond timer").
+ * @len_chanlist: Maximum length of a channel list if the subdevice
+ * supports asynchronous acquisition commands.
+ * @maxdata: Maximum sample value for all channels if the
+ * %SDF_MAXDATA subdevice flag is clear.
+ * @flags: Channel flags for all channels if the %SDF_FLAGS
+ * subdevice flag is clear.
+ * @range_type: The range type for all channels if the %SDF_RANGETYPE
+ * subdevice flag is clear. Encodes the subdevice index
+ * (bits 27:24), a dummy channel index %0 (bits 23:16),
+ * and the range table length (bits 15:0).
+ * @settling_time_0: Not used.
+ * @insn_bits_support: Set to %COMEDI_SUPPORTED if the subdevice supports the
+ * %INSN_BITS instruction, or to %COMEDI_UNSUPPORTED if it
+ * does not.
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_SUBDINFO ioctl which copies an array of
+ * &struct comedi_subdinfo back to user space, with one element per subdevice.
+ * Use of this requires knowledge of the number of subdevices obtained from
+ * the %COMEDI_DEVINFO ioctl.
+ *
+ * These are the @subd_flags values that may be ORed together...
+ *
+ * %SDF_BUSY - the subdevice is busy processing an asynchronous command or a
+ * synchronous instruction.
+ *
+ * %SDF_BUSY_OWNER - the subdevice is busy processing an asynchronous
+ * acquisition command started on the current file object (the file object
+ * issuing the %COMEDI_SUBDINFO ioctl).
+ *
+ * %SDF_LOCKED - the subdevice is locked by a %COMEDI_LOCK ioctl.
+ *
+ * %SDF_LOCK_OWNER - the subdevice is locked by a %COMEDI_LOCK ioctl from the
+ * current file object.
+ *
+ * %SDF_MAXDATA - maximum sample values are channel-specific.
+ *
+ * %SDF_FLAGS - channel flags are channel-specific.
+ *
+ * %SDF_RANGETYPE - range types are channel-specific.
+ *
+ * %SDF_PWM_COUNTER - PWM can switch off automatically.
+ *
+ * %SDF_PWM_HBRIDGE - or PWM is signed (H-bridge).
+ *
+ * %SDF_CMD - the subdevice supports asynchronous commands.
+ *
+ * %SDF_SOFT_CALIBRATED - the subdevice uses software calibration.
+ *
+ * %SDF_CMD_WRITE - the subdevice supports asynchronous commands in the output
+ * ("write") direction.
+ *
+ * %SDF_CMD_READ - the subdevice supports asynchronous commands in the input
+ * ("read") direction.
+ *
+ * %SDF_READABLE - the subdevice is readable (e.g. analog input).
+ *
+ * %SDF_WRITABLE (aliased as %SDF_WRITEABLE) - the subdevice is writable (e.g.
+ * analog output).
+ *
+ * %SDF_INTERNAL - the subdevice has no externally visible lines.
+ *
+ * %SDF_GROUND - the subdevice can use ground as an analog reference.
+ *
+ * %SDF_COMMON - the subdevice can use a common analog reference.
+ *
+ * %SDF_DIFF - the subdevice can use differential inputs (or outputs).
+ *
+ * %SDF_OTHER - the subdevice can use some other analog reference.
+ *
+ * %SDF_DITHER - the subdevice can do dithering.
+ *
+ * %SDF_DEGLITCH - the subdevice can do deglitching.
+ *
+ * %SDF_MMAP - this is never set.
+ *
+ * %SDF_RUNNING - an asynchronous command is still running.
+ *
+ * %SDF_LSAMPL - the subdevice uses "long" (32-bit) samples (for asynchronous
+ * command data).
+ *
+ * %SDF_PACKED - the subdevice packs several DIO samples into a single sample
+ * (for asynchronous command data).
+ *
+ * No "channel flags" (@flags) values are currently defined.
+ */
+struct comedi_subdinfo {
+ unsigned int type;
+ unsigned int n_chan;
+ unsigned int subd_flags;
+ unsigned int timer_type;
+ unsigned int len_chanlist;
+ unsigned int maxdata;
+ unsigned int flags;
+ unsigned int range_type;
+ unsigned int settling_time_0;
+ unsigned int insn_bits_support;
+ unsigned int unused[8];
+};
+
+/**
+ * struct comedi_devinfo - used to retrieve information about a COMEDI device
+ * @version_code: COMEDI version code.
+ * @n_subdevs: Number of subdevices the device has.
+ * @driver_name: Null-terminated COMEDI driver name.
+ * @board_name: Null-terminated COMEDI board name.
+ * @read_subdevice: Index of the current "read" subdevice (%-1 if none).
+ * @write_subdevice: Index of the current "write" subdevice (%-1 if none).
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_DEVINFO ioctl to get basic information about
+ * the device.
+ */
+struct comedi_devinfo {
+ unsigned int version_code;
+ unsigned int n_subdevs;
+ char driver_name[COMEDI_NAMELEN];
+ char board_name[COMEDI_NAMELEN];
+ int read_subdevice;
+ int write_subdevice;
+ int unused[30];
+};
+
+/**
+ * struct comedi_devconfig - used to configure a legacy COMEDI device
+ * @board_name: Null-terminated string specifying the type of board
+ * to configure.
+ * @options: An array of integer configuration options.
+ *
+ * This is used with the %COMEDI_DEVCONFIG ioctl to configure a "legacy" COMEDI
+ * device, such as an ISA card. Not all COMEDI drivers support this. Those
+ * that do either expect the specified board name to match one of a list of
+ * names registered with the COMEDI core, or expect the specified board name
+ * to match the COMEDI driver name itself. The configuration options are
+ * handled in a driver-specific manner.
+ */
+struct comedi_devconfig {
+ char board_name[COMEDI_NAMELEN];
+ int options[COMEDI_NDEVCONFOPTS];
+};
+
+/**
+ * struct comedi_bufconfig - used to set or get buffer size for a subdevice
+ * @subdevice: Subdevice index.
+ * @flags: Not used.
+ * @maximum_size: Maximum allowed buffer size.
+ * @size: Buffer size.
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_BUFCONFIG ioctl to get or configure the
+ * maximum buffer size and current buffer size for a COMEDI subdevice that
+ * supports asynchronous commands. If the subdevice does not support
+ * asynchronous commands, @maximum_size and @size are ignored and set to 0.
+ *
+ * On ioctl input, non-zero values of @maximum_size and @size specify a
+ * new maximum size and new current size (in bytes), respectively. These
+ * will by rounded up to a multiple of %PAGE_SIZE. Specifying a new maximum
+ * size requires admin capabilities.
+ *
+ * On ioctl output, @maximum_size and @size and set to the current maximum
+ * buffer size and current buffer size, respectively.
+ */
+struct comedi_bufconfig {
+ unsigned int subdevice;
+ unsigned int flags;
+
+ unsigned int maximum_size;
+ unsigned int size;
+
+ unsigned int unused[4];
+};
+
+/**
+ * struct comedi_bufinfo - used to manipulate buffer position for a subdevice
+ * @subdevice: Subdevice index.
+ * @bytes_read: Specify amount to advance read position for an
+ * asynchronous command in the input ("read") direction.
+ * @buf_write_ptr: Current write position (index) within the buffer.
+ * @buf_read_ptr: Current read position (index) within the buffer.
+ * @buf_write_count: Total amount written, modulo 2^32.
+ * @buf_read_count: Total amount read, modulo 2^32.
+ * @bytes_written: Specify amount to advance write position for an
+ * asynchronous command in the output ("write") direction.
+ * @unused: Reserved for future use.
+ *
+ * This is used with the %COMEDI_BUFINFO ioctl to optionally advance the
+ * current read or write position in an asynchronous acquisition data buffer,
+ * and to get the current read and write positions in the buffer.
+ */
+struct comedi_bufinfo {
+ unsigned int subdevice;
+ unsigned int bytes_read;
+
+ unsigned int buf_write_ptr;
+ unsigned int buf_read_ptr;
+ unsigned int buf_write_count;
+ unsigned int buf_read_count;
+
+ unsigned int bytes_written;
+
+ unsigned int unused[4];
+};
+
+/* range stuff */
+
+#define __RANGE(a, b) ((((a) & 0xffff) << 16) | ((b) & 0xffff))
+
+#define RANGE_OFFSET(a) (((a) >> 16) & 0xffff)
+#define RANGE_LENGTH(b) ((b) & 0xffff)
+
+#define RF_UNIT(flags) ((flags) & 0xff)
+#define RF_EXTERNAL 0x100
+
+#define UNIT_volt 0
+#define UNIT_mA 1
+#define UNIT_none 2
+
+#define COMEDI_MIN_SPEED 0xffffffffu
+
+/**********************************************************/
+/* everything after this line is ALPHA */
+/**********************************************************/
+
+/*
+ * 8254 specific configuration.
+ *
+ * It supports two config commands:
+ *
+ * 0 ID: INSN_CONFIG_SET_COUNTER_MODE
+ * 1 8254 Mode
+ * I8254_MODE0, I8254_MODE1, ..., I8254_MODE5
+ * OR'ed with:
+ * I8254_BCD, I8254_BINARY
+ *
+ * 0 ID: INSN_CONFIG_8254_READ_STATUS
+ * 1 <-- Status byte returned here.
+ * B7 = Output
+ * B6 = NULL Count
+ * B5 - B0 Current mode.
+ */
+
+enum i8254_mode {
+ I8254_MODE0 = (0 << 1), /* Interrupt on terminal count */
+ I8254_MODE1 = (1 << 1), /* Hardware retriggerable one-shot */
+ I8254_MODE2 = (2 << 1), /* Rate generator */
+ I8254_MODE3 = (3 << 1), /* Square wave mode */
+ I8254_MODE4 = (4 << 1), /* Software triggered strobe */
+ /* Hardware triggered strobe (retriggerable) */
+ I8254_MODE5 = (5 << 1),
+ /* Use binary-coded decimal instead of binary (pretty useless) */
+ I8254_BCD = 1,
+ I8254_BINARY = 0
+};
+
+/* *** BEGIN GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */
+
+/*
+ * Common National Instruments Terminal/Signal names.
+ * Some of these have no NI_ prefix as they are useful for non-NI hardware, such
+ * as those that utilize the PXI/RTSI trigger lines.
+ *
+ * NOTE ABOUT THE CHOICE OF NAMES HERE AND THE CAMELSCRIPT:
+ * The choice to use CamelScript and the exact names below is for
+ * maintainability, clarity, similarity to manufacturer's documentation,
+ * _and_ a mitigation for confusion that has plagued the use of these drivers
+ * for years!
+ *
+ * More detail:
+ * There have been significant confusions over the past many years for users
+ * when trying to understand how to connect to/from signals and terminals on
+ * NI hardware using comedi. The major reason for this is that the actual
+ * register values were exposed and required to be used by users. Several
+ * major reasons exist why this caused major confusion for users:
+ * 1) The register values are _NOT_ in user documentation, but rather in
+ * arcane locations, such as a few register programming manuals that are
+ * increasingly hard to find and the NI MHDDK (comments in example code).
+ * There is no one place to find the various valid values of the registers.
+ * 2) The register values are _NOT_ completely consistent. There is no way to
+ * gain any sense of intuition of which values, or even enums one should use
+ * for various registers. There was some attempt in prior use of comedi to
+ * name enums such that a user might know which enums should be used for
+ * varying purposes, but the end-user had to gain a knowledge of register
+ * values to correctly wield this approach.
+ * 3) The names for signals and registers found in the various register level
+ * programming manuals and vendor-provided documentation are _not_ even
+ * close to the same names that are in the end-user documentation.
+ *
+ * Similar, albeit less, confusion plagued NI's previous version of their own
+ * drivers. Earlier than 2003, NI greatly simplified the situation for users
+ * by releasing a new API that abstracted the names of signals/terminals to a
+ * common and intuitive set of names.
+ *
+ * The names below mirror the names chosen and well documented by NI. These
+ * names are exposed to the user via the comedilib user library. By keeping
+ * the names below, in spite of the use of CamelScript, maintenance will be
+ * greatly eased and confusion for users _and_ comedi developers will be
+ * greatly reduced.
+ */
+
+/*
+ * Base of abstracted NI names.
+ * The first 16 bits of *_arg are reserved for channel selection.
+ * Since we only actually need the first 4 or 5 bits for all register values on
+ * NI select registers anyways, we'll identify all values >= (1<<15) as being an
+ * abstracted NI signal/terminal name.
+ * These values are also used/returned by INSN_DEVICE_CONFIG_TEST_ROUTE,
+ * INSN_DEVICE_CONFIG_CONNECT_ROUTE, INSN_DEVICE_CONFIG_DISCONNECT_ROUTE,
+ * and INSN_DEVICE_CONFIG_GET_ROUTES.
+ */
+#define NI_NAMES_BASE 0x8000u
+
+#define _TERM_N(base, n, x) ((base) + ((x) & ((n) - 1)))
+
+/*
+ * not necessarily all allowed 64 PFIs are valid--certainly not for all devices
+ */
+#define NI_PFI(x) _TERM_N(NI_NAMES_BASE, 64, x)
+/* 8 trigger lines by standard, Some devices cannot talk to all eight. */
+#define TRIGGER_LINE(x) _TERM_N(NI_PFI(-1) + 1, 8, x)
+/* 4 RTSI shared MUXes to route signals to/from TRIGGER_LINES on NI hardware */
+#define NI_RTSI_BRD(x) _TERM_N(TRIGGER_LINE(-1) + 1, 4, x)
+
+/* *** Counter/timer names : 8 counters max *** */
+#define NI_MAX_COUNTERS 8
+#define NI_COUNTER_NAMES_BASE (NI_RTSI_BRD(-1) + 1)
+#define NI_CtrSource(x) _TERM_N(NI_COUNTER_NAMES_BASE, NI_MAX_COUNTERS, x)
+/* Gate, Aux, A,B,Z are all treated, at times as gates */
+#define NI_GATES_NAMES_BASE (NI_CtrSource(-1) + 1)
+#define NI_CtrGate(x) _TERM_N(NI_GATES_NAMES_BASE, NI_MAX_COUNTERS, x)
+#define NI_CtrAux(x) _TERM_N(NI_CtrGate(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_CtrA(x) _TERM_N(NI_CtrAux(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_CtrB(x) _TERM_N(NI_CtrA(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_CtrZ(x) _TERM_N(NI_CtrB(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_GATES_NAMES_MAX NI_CtrZ(-1)
+#define NI_CtrArmStartTrigger(x) _TERM_N(NI_CtrZ(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_CtrInternalOutput(x) \
+ _TERM_N(NI_CtrArmStartTrigger(-1) + 1, NI_MAX_COUNTERS, x)
+/** external pin(s) labeled conveniently as Ctr<i>Out. */
+#define NI_CtrOut(x) _TERM_N(NI_CtrInternalOutput(-1) + 1, NI_MAX_COUNTERS, x)
+/** For Buffered sampling of ctr -- x series capability. */
+#define NI_CtrSampleClock(x) _TERM_N(NI_CtrOut(-1) + 1, NI_MAX_COUNTERS, x)
+#define NI_COUNTER_NAMES_MAX NI_CtrSampleClock(-1)
+
+enum ni_common_signal_names {
+ /* PXI_Star: this is a non-NI-specific signal */
+ PXI_Star = NI_COUNTER_NAMES_MAX + 1,
+ PXI_Clk10,
+ PXIe_Clk100,
+ NI_AI_SampleClock,
+ NI_AI_SampleClockTimebase,
+ NI_AI_StartTrigger,
+ NI_AI_ReferenceTrigger,
+ NI_AI_ConvertClock,
+ NI_AI_ConvertClockTimebase,
+ NI_AI_PauseTrigger,
+ NI_AI_HoldCompleteEvent,
+ NI_AI_HoldComplete,
+ NI_AI_ExternalMUXClock,
+ NI_AI_STOP, /* pulse signal that occurs when a update is finished(?) */
+ NI_AO_SampleClock,
+ NI_AO_SampleClockTimebase,
+ NI_AO_StartTrigger,
+ NI_AO_PauseTrigger,
+ NI_DI_SampleClock,
+ NI_DI_SampleClockTimebase,
+ NI_DI_StartTrigger,
+ NI_DI_ReferenceTrigger,
+ NI_DI_PauseTrigger,
+ NI_DI_InputBufferFull,
+ NI_DI_ReadyForStartEvent,
+ NI_DI_ReadyForTransferEventBurst,
+ NI_DI_ReadyForTransferEventPipelined,
+ NI_DO_SampleClock,
+ NI_DO_SampleClockTimebase,
+ NI_DO_StartTrigger,
+ NI_DO_PauseTrigger,
+ NI_DO_OutputBufferFull,
+ NI_DO_DataActiveEvent,
+ NI_DO_ReadyForStartEvent,
+ NI_DO_ReadyForTransferEvent,
+ NI_MasterTimebase,
+ NI_20MHzTimebase,
+ NI_80MHzTimebase,
+ NI_100MHzTimebase,
+ NI_200MHzTimebase,
+ NI_100kHzTimebase,
+ NI_10MHzRefClock,
+ NI_FrequencyOutput,
+ NI_ChangeDetectionEvent,
+ NI_AnalogComparisonEvent,
+ NI_WatchdogExpiredEvent,
+ NI_WatchdogExpirationTrigger,
+ NI_SCXI_Trig1,
+ NI_LogicLow,
+ NI_LogicHigh,
+ NI_ExternalStrobe,
+ NI_PFI_DO,
+ NI_CaseGround,
+ /* special internal signal used as variable source for RTSI bus: */
+ NI_RGOUT0,
+
+ /* just a name to make the next more convenient, regardless of above */
+ _NI_NAMES_MAX_PLUS_1,
+ NI_NUM_NAMES = _NI_NAMES_MAX_PLUS_1 - NI_NAMES_BASE,
+};
+
+/* *** END GLOBALLY-NAMED NI TERMINALS/SIGNALS *** */
+
+#define NI_USUAL_PFI_SELECT(x) (((x) < 10) ? (0x1 + (x)) : (0xb + (x)))
+#define NI_USUAL_RTSI_SELECT(x) (((x) < 7) ? (0xb + (x)) : 0x1b)
+
+/*
+ * mode bits for NI general-purpose counters, set with
+ * INSN_CONFIG_SET_COUNTER_MODE
+ */
+#define NI_GPCT_COUNTING_MODE_SHIFT 16
+#define NI_GPCT_INDEX_PHASE_BITSHIFT 20
+#define NI_GPCT_COUNTING_DIRECTION_SHIFT 24
+enum ni_gpct_mode_bits {
+ NI_GPCT_GATE_ON_BOTH_EDGES_BIT = 0x4,
+ NI_GPCT_EDGE_GATE_MODE_MASK = 0x18,
+ NI_GPCT_EDGE_GATE_STARTS_STOPS_BITS = 0x0,
+ NI_GPCT_EDGE_GATE_STOPS_STARTS_BITS = 0x8,
+ NI_GPCT_EDGE_GATE_STARTS_BITS = 0x10,
+ NI_GPCT_EDGE_GATE_NO_STARTS_NO_STOPS_BITS = 0x18,
+ NI_GPCT_STOP_MODE_MASK = 0x60,
+ NI_GPCT_STOP_ON_GATE_BITS = 0x00,
+ NI_GPCT_STOP_ON_GATE_OR_TC_BITS = 0x20,
+ NI_GPCT_STOP_ON_GATE_OR_SECOND_TC_BITS = 0x40,
+ NI_GPCT_LOAD_B_SELECT_BIT = 0x80,
+ NI_GPCT_OUTPUT_MODE_MASK = 0x300,
+ NI_GPCT_OUTPUT_TC_PULSE_BITS = 0x100,
+ NI_GPCT_OUTPUT_TC_TOGGLE_BITS = 0x200,
+ NI_GPCT_OUTPUT_TC_OR_GATE_TOGGLE_BITS = 0x300,
+ NI_GPCT_HARDWARE_DISARM_MASK = 0xc00,
+ NI_GPCT_NO_HARDWARE_DISARM_BITS = 0x000,
+ NI_GPCT_DISARM_AT_TC_BITS = 0x400,
+ NI_GPCT_DISARM_AT_GATE_BITS = 0x800,
+ NI_GPCT_DISARM_AT_TC_OR_GATE_BITS = 0xc00,
+ NI_GPCT_LOADING_ON_TC_BIT = 0x1000,
+ NI_GPCT_LOADING_ON_GATE_BIT = 0x4000,
+ NI_GPCT_COUNTING_MODE_MASK = 0x7 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_NORMAL_BITS =
+ 0x0 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X1_BITS =
+ 0x1 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X2_BITS =
+ 0x2 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS =
+ 0x3 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_TWO_PULSE_BITS =
+ 0x4 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_COUNTING_MODE_SYNC_SOURCE_BITS =
+ 0x6 << NI_GPCT_COUNTING_MODE_SHIFT,
+ NI_GPCT_INDEX_PHASE_MASK = 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_LOW_A_LOW_B_BITS =
+ 0x0 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_LOW_A_HIGH_B_BITS =
+ 0x1 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_HIGH_A_LOW_B_BITS =
+ 0x2 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_PHASE_HIGH_A_HIGH_B_BITS =
+ 0x3 << NI_GPCT_INDEX_PHASE_BITSHIFT,
+ NI_GPCT_INDEX_ENABLE_BIT = 0x400000,
+ NI_GPCT_COUNTING_DIRECTION_MASK =
+ 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_DOWN_BITS =
+ 0x00 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_UP_BITS =
+ 0x1 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS =
+ 0x2 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_COUNTING_DIRECTION_HW_GATE_BITS =
+ 0x3 << NI_GPCT_COUNTING_DIRECTION_SHIFT,
+ NI_GPCT_RELOAD_SOURCE_MASK = 0xc000000,
+ NI_GPCT_RELOAD_SOURCE_FIXED_BITS = 0x0,
+ NI_GPCT_RELOAD_SOURCE_SWITCHING_BITS = 0x4000000,
+ NI_GPCT_RELOAD_SOURCE_GATE_SELECT_BITS = 0x8000000,
+ NI_GPCT_OR_GATE_BIT = 0x10000000,
+ NI_GPCT_INVERT_OUTPUT_BIT = 0x20000000
+};
+
+/*
+ * Bits for setting a clock source with
+ * INSN_CONFIG_SET_CLOCK_SRC when using NI general-purpose counters.
+ */
+enum ni_gpct_clock_source_bits {
+ NI_GPCT_CLOCK_SRC_SELECT_MASK = 0x3f,
+ NI_GPCT_TIMEBASE_1_CLOCK_SRC_BITS = 0x0,
+ NI_GPCT_TIMEBASE_2_CLOCK_SRC_BITS = 0x1,
+ NI_GPCT_TIMEBASE_3_CLOCK_SRC_BITS = 0x2,
+ NI_GPCT_LOGIC_LOW_CLOCK_SRC_BITS = 0x3,
+ NI_GPCT_NEXT_GATE_CLOCK_SRC_BITS = 0x4,
+ NI_GPCT_NEXT_TC_CLOCK_SRC_BITS = 0x5,
+ /* NI 660x-specific */
+ NI_GPCT_SOURCE_PIN_i_CLOCK_SRC_BITS = 0x6,
+ NI_GPCT_PXI10_CLOCK_SRC_BITS = 0x7,
+ NI_GPCT_PXI_STAR_TRIGGER_CLOCK_SRC_BITS = 0x8,
+ NI_GPCT_ANALOG_TRIGGER_OUT_CLOCK_SRC_BITS = 0x9,
+ NI_GPCT_PRESCALE_MODE_CLOCK_SRC_MASK = 0x30000000,
+ NI_GPCT_NO_PRESCALE_CLOCK_SRC_BITS = 0x0,
+ /* divide source by 2 */
+ NI_GPCT_PRESCALE_X2_CLOCK_SRC_BITS = 0x10000000,
+ /* divide source by 8 */
+ NI_GPCT_PRESCALE_X8_CLOCK_SRC_BITS = 0x20000000,
+ NI_GPCT_INVERT_CLOCK_SRC_BIT = 0x80000000
+};
+
+/* NI 660x-specific */
+#define NI_GPCT_SOURCE_PIN_CLOCK_SRC_BITS(x) (0x10 + (x))
+
+#define NI_GPCT_RTSI_CLOCK_SRC_BITS(x) (0x18 + (x))
+
+/* no pfi on NI 660x */
+#define NI_GPCT_PFI_CLOCK_SRC_BITS(x) (0x20 + (x))
+
+/*
+ * Possibilities for setting a gate source with
+ * INSN_CONFIG_SET_GATE_SRC when using NI general-purpose counters.
+ * May be bitwise-or'd with CR_EDGE or CR_INVERT.
+ */
+enum ni_gpct_gate_select {
+ /* m-series gates */
+ NI_GPCT_TIMESTAMP_MUX_GATE_SELECT = 0x0,
+ NI_GPCT_AI_START2_GATE_SELECT = 0x12,
+ NI_GPCT_PXI_STAR_TRIGGER_GATE_SELECT = 0x13,
+ NI_GPCT_NEXT_OUT_GATE_SELECT = 0x14,
+ NI_GPCT_AI_START1_GATE_SELECT = 0x1c,
+ NI_GPCT_NEXT_SOURCE_GATE_SELECT = 0x1d,
+ NI_GPCT_ANALOG_TRIGGER_OUT_GATE_SELECT = 0x1e,
+ NI_GPCT_LOGIC_LOW_GATE_SELECT = 0x1f,
+ /* more gates for 660x */
+ NI_GPCT_SOURCE_PIN_i_GATE_SELECT = 0x100,
+ NI_GPCT_GATE_PIN_i_GATE_SELECT = 0x101,
+ /* more gates for 660x "second gate" */
+ NI_GPCT_UP_DOWN_PIN_i_GATE_SELECT = 0x201,
+ NI_GPCT_SELECTED_GATE_GATE_SELECT = 0x21e,
+ /*
+ * m-series "second gate" sources are unknown,
+ * we should add them here with an offset of 0x300 when
+ * known.
+ */
+ NI_GPCT_DISABLED_GATE_SELECT = 0x8000,
+};
+
+#define NI_GPCT_GATE_PIN_GATE_SELECT(x) (0x102 + (x))
+#define NI_GPCT_RTSI_GATE_SELECT(x) NI_USUAL_RTSI_SELECT(x)
+#define NI_GPCT_PFI_GATE_SELECT(x) NI_USUAL_PFI_SELECT(x)
+#define NI_GPCT_UP_DOWN_PIN_GATE_SELECT(x) (0x202 + (x))
+
+/*
+ * Possibilities for setting a source with
+ * INSN_CONFIG_SET_OTHER_SRC when using NI general-purpose counters.
+ */
+enum ni_gpct_other_index {
+ NI_GPCT_SOURCE_ENCODER_A,
+ NI_GPCT_SOURCE_ENCODER_B,
+ NI_GPCT_SOURCE_ENCODER_Z
+};
+
+enum ni_gpct_other_select {
+ /* m-series gates */
+ /* Still unknown, probably only need NI_GPCT_PFI_OTHER_SELECT */
+ NI_GPCT_DISABLED_OTHER_SELECT = 0x8000,
+};
+
+#define NI_GPCT_PFI_OTHER_SELECT(x) NI_USUAL_PFI_SELECT(x)
+
+/*
+ * start sources for ni general-purpose counters for use with
+ * INSN_CONFIG_ARM
+ */
+enum ni_gpct_arm_source {
+ NI_GPCT_ARM_IMMEDIATE = 0x0,
+ /*
+ * Start both the counter and the adjacent paired counter simultaneously
+ */
+ NI_GPCT_ARM_PAIRED_IMMEDIATE = 0x1,
+ /*
+ * If the NI_GPCT_HW_ARM bit is set, we will pass the least significant
+ * bits (3 bits for 660x or 5 bits for m-series) through to the
+ * hardware. To select a hardware trigger, pass the appropriate select
+ * bit, e.g.,
+ * NI_GPCT_HW_ARM | NI_GPCT_AI_START1_GATE_SELECT or
+ * NI_GPCT_HW_ARM | NI_GPCT_PFI_GATE_SELECT(pfi_number)
+ */
+ NI_GPCT_HW_ARM = 0x1000,
+ NI_GPCT_ARM_UNKNOWN = NI_GPCT_HW_ARM, /* for backward compatibility */
+};
+
+/* digital filtering options for ni 660x for use with INSN_CONFIG_FILTER. */
+enum ni_gpct_filter_select {
+ NI_GPCT_FILTER_OFF = 0x0,
+ NI_GPCT_FILTER_TIMEBASE_3_SYNC = 0x1,
+ NI_GPCT_FILTER_100x_TIMEBASE_1 = 0x2,
+ NI_GPCT_FILTER_20x_TIMEBASE_1 = 0x3,
+ NI_GPCT_FILTER_10x_TIMEBASE_1 = 0x4,
+ NI_GPCT_FILTER_2x_TIMEBASE_1 = 0x5,
+ NI_GPCT_FILTER_2x_TIMEBASE_3 = 0x6
+};
+
+/*
+ * PFI digital filtering options for ni m-series for use with
+ * INSN_CONFIG_FILTER.
+ */
+enum ni_pfi_filter_select {
+ NI_PFI_FILTER_OFF = 0x0,
+ NI_PFI_FILTER_125ns = 0x1,
+ NI_PFI_FILTER_6425ns = 0x2,
+ NI_PFI_FILTER_2550us = 0x3
+};
+
+/* master clock sources for ni mio boards and INSN_CONFIG_SET_CLOCK_SRC */
+enum ni_mio_clock_source {
+ NI_MIO_INTERNAL_CLOCK = 0,
+ /*
+ * Doesn't work for m-series, use NI_MIO_PLL_RTSI_CLOCK()
+ * the NI_MIO_PLL_* sources are m-series only
+ */
+ NI_MIO_RTSI_CLOCK = 1,
+ NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK = 2,
+ NI_MIO_PLL_PXI10_CLOCK = 3,
+ NI_MIO_PLL_RTSI0_CLOCK = 4
+};
+
+#define NI_MIO_PLL_RTSI_CLOCK(x) (NI_MIO_PLL_RTSI0_CLOCK + (x))
+
+/*
+ * Signals which can be routed to an NI RTSI pin with INSN_CONFIG_SET_ROUTING.
+ * The numbers assigned are not arbitrary, they correspond to the bits required
+ * to program the board.
+ */
+enum ni_rtsi_routing {
+ NI_RTSI_OUTPUT_ADR_START1 = 0,
+ NI_RTSI_OUTPUT_ADR_START2 = 1,
+ NI_RTSI_OUTPUT_SCLKG = 2,
+ NI_RTSI_OUTPUT_DACUPDN = 3,
+ NI_RTSI_OUTPUT_DA_START1 = 4,
+ NI_RTSI_OUTPUT_G_SRC0 = 5,
+ NI_RTSI_OUTPUT_G_GATE0 = 6,
+ NI_RTSI_OUTPUT_RGOUT0 = 7,
+ NI_RTSI_OUTPUT_RTSI_BRD_0 = 8,
+ /* Pre-m-series always have RTSI clock on line 7 */
+ NI_RTSI_OUTPUT_RTSI_OSC = 12
+};
+
+#define NI_RTSI_OUTPUT_RTSI_BRD(x) (NI_RTSI_OUTPUT_RTSI_BRD_0 + (x))
+
+/*
+ * Signals which can be routed to an NI PFI pin on an m-series board with
+ * INSN_CONFIG_SET_ROUTING. These numbers are also returned by
+ * INSN_CONFIG_GET_ROUTING on pre-m-series boards, even though their routing
+ * cannot be changed. The numbers assigned are not arbitrary, they correspond
+ * to the bits required to program the board.
+ */
+enum ni_pfi_routing {
+ NI_PFI_OUTPUT_PFI_DEFAULT = 0,
+ NI_PFI_OUTPUT_AI_START1 = 1,
+ NI_PFI_OUTPUT_AI_START2 = 2,
+ NI_PFI_OUTPUT_AI_CONVERT = 3,
+ NI_PFI_OUTPUT_G_SRC1 = 4,
+ NI_PFI_OUTPUT_G_GATE1 = 5,
+ NI_PFI_OUTPUT_AO_UPDATE_N = 6,
+ NI_PFI_OUTPUT_AO_START1 = 7,
+ NI_PFI_OUTPUT_AI_START_PULSE = 8,
+ NI_PFI_OUTPUT_G_SRC0 = 9,
+ NI_PFI_OUTPUT_G_GATE0 = 10,
+ NI_PFI_OUTPUT_EXT_STROBE = 11,
+ NI_PFI_OUTPUT_AI_EXT_MUX_CLK = 12,
+ NI_PFI_OUTPUT_GOUT0 = 13,
+ NI_PFI_OUTPUT_GOUT1 = 14,
+ NI_PFI_OUTPUT_FREQ_OUT = 15,
+ NI_PFI_OUTPUT_PFI_DO = 16,
+ NI_PFI_OUTPUT_I_ATRIG = 17,
+ NI_PFI_OUTPUT_RTSI0 = 18,
+ NI_PFI_OUTPUT_PXI_STAR_TRIGGER_IN = 26,
+ NI_PFI_OUTPUT_SCXI_TRIG1 = 27,
+ NI_PFI_OUTPUT_DIO_CHANGE_DETECT_RTSI = 28,
+ NI_PFI_OUTPUT_CDI_SAMPLE = 29,
+ NI_PFI_OUTPUT_CDO_UPDATE = 30
+};
+
+#define NI_PFI_OUTPUT_RTSI(x) (NI_PFI_OUTPUT_RTSI0 + (x))
+
+/*
+ * Signals which can be routed to output on a NI PFI pin on a 660x board
+ * with INSN_CONFIG_SET_ROUTING. The numbers assigned are
+ * not arbitrary, they correspond to the bits required
+ * to program the board. Lines 0 to 7 can only be set to
+ * NI_660X_PFI_OUTPUT_DIO. Lines 32 to 39 can only be set to
+ * NI_660X_PFI_OUTPUT_COUNTER.
+ */
+enum ni_660x_pfi_routing {
+ NI_660X_PFI_OUTPUT_COUNTER = 1, /* counter */
+ NI_660X_PFI_OUTPUT_DIO = 2, /* static digital output */
+};
+
+/*
+ * NI External Trigger lines. These values are not arbitrary, but are related
+ * to the bits required to program the board (offset by 1 for historical
+ * reasons).
+ */
+#define NI_EXT_PFI(x) (NI_USUAL_PFI_SELECT(x) - 1)
+#define NI_EXT_RTSI(x) (NI_USUAL_RTSI_SELECT(x) - 1)
+
+/*
+ * Clock sources for CDIO subdevice on NI m-series boards. Used as the
+ * scan_begin_arg for a comedi_command. These sources may also be bitwise-or'd
+ * with CR_INVERT to change polarity.
+ */
+enum ni_m_series_cdio_scan_begin_src {
+ NI_CDIO_SCAN_BEGIN_SRC_GROUND = 0,
+ NI_CDIO_SCAN_BEGIN_SRC_AI_START = 18,
+ NI_CDIO_SCAN_BEGIN_SRC_AI_CONVERT = 19,
+ NI_CDIO_SCAN_BEGIN_SRC_PXI_STAR_TRIGGER = 20,
+ NI_CDIO_SCAN_BEGIN_SRC_G0_OUT = 28,
+ NI_CDIO_SCAN_BEGIN_SRC_G1_OUT = 29,
+ NI_CDIO_SCAN_BEGIN_SRC_ANALOG_TRIGGER = 30,
+ NI_CDIO_SCAN_BEGIN_SRC_AO_UPDATE = 31,
+ NI_CDIO_SCAN_BEGIN_SRC_FREQ_OUT = 32,
+ NI_CDIO_SCAN_BEGIN_SRC_DIO_CHANGE_DETECT_IRQ = 33
+};
+
+#define NI_CDIO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
+#define NI_CDIO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
+
+/*
+ * scan_begin_src for scan_begin_arg==TRIG_EXT with analog output command on NI
+ * boards. These scan begin sources can also be bitwise-or'd with CR_INVERT to
+ * change polarity.
+ */
+#define NI_AO_SCAN_BEGIN_SRC_PFI(x) NI_USUAL_PFI_SELECT(x)
+#define NI_AO_SCAN_BEGIN_SRC_RTSI(x) NI_USUAL_RTSI_SELECT(x)
+
+/*
+ * Bits for setting a clock source with
+ * INSN_CONFIG_SET_CLOCK_SRC when using NI frequency output subdevice.
+ */
+enum ni_freq_out_clock_source_bits {
+ NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC, /* 10 MHz */
+ NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC /* 100 KHz */
+};
+
+/*
+ * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
+ * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver).
+ */
+enum amplc_dio_clock_source {
+ /*
+ * Per channel external clock
+ * input/output pin (pin is only an
+ * input when clock source set to this value,
+ * otherwise it is an output)
+ */
+ AMPLC_DIO_CLK_CLKN,
+ AMPLC_DIO_CLK_10MHZ, /* 10 MHz internal clock */
+ AMPLC_DIO_CLK_1MHZ, /* 1 MHz internal clock */
+ AMPLC_DIO_CLK_100KHZ, /* 100 kHz internal clock */
+ AMPLC_DIO_CLK_10KHZ, /* 10 kHz internal clock */
+ AMPLC_DIO_CLK_1KHZ, /* 1 kHz internal clock */
+ /*
+ * Output of preceding counter channel
+ * (for channel 0, preceding counter
+ * channel is channel 2 on preceding
+ * counter subdevice, for first counter
+ * subdevice, preceding counter
+ * subdevice is the last counter
+ * subdevice)
+ */
+ AMPLC_DIO_CLK_OUTNM1,
+ AMPLC_DIO_CLK_EXT, /* per chip external input pin */
+ /* the following are "enhanced" clock sources for PCIe models */
+ AMPLC_DIO_CLK_VCC, /* clock input HIGH */
+ AMPLC_DIO_CLK_GND, /* clock input LOW */
+ AMPLC_DIO_CLK_PAT_PRESENT, /* "pattern present" signal */
+ AMPLC_DIO_CLK_20MHZ /* 20 MHz internal clock */
+};
+
+/*
+ * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
+ * timer subdevice on some Amplicon DIO PCIe boards (amplc_dio200 driver).
+ */
+enum amplc_dio_ts_clock_src {
+ AMPLC_DIO_TS_CLK_1GHZ, /* 1 ns period with 20 ns granularity */
+ AMPLC_DIO_TS_CLK_1MHZ, /* 1 us period */
+ AMPLC_DIO_TS_CLK_1KHZ /* 1 ms period */
+};
+
+/*
+ * Values for setting a gate source with INSN_CONFIG_SET_GATE_SRC for
+ * 8254 counter subdevices on Amplicon DIO boards (amplc_dio200 driver).
+ */
+enum amplc_dio_gate_source {
+ AMPLC_DIO_GAT_VCC, /* internal high logic level */
+ AMPLC_DIO_GAT_GND, /* internal low logic level */
+ AMPLC_DIO_GAT_GATN, /* per channel external gate input */
+ /*
+ * negated output of counter channel minus 2
+ * (for channels 0 or 1, channel minus 2 is channel 1 or 2 on
+ * the preceding counter subdevice, for the first counter subdevice
+ * the preceding counter subdevice is the last counter subdevice)
+ */
+ AMPLC_DIO_GAT_NOUTNM2,
+ AMPLC_DIO_GAT_RESERVED4,
+ AMPLC_DIO_GAT_RESERVED5,
+ AMPLC_DIO_GAT_RESERVED6,
+ AMPLC_DIO_GAT_RESERVED7,
+ /* the following are "enhanced" gate sources for PCIe models */
+ AMPLC_DIO_GAT_NGATN = 6, /* negated per channel gate input */
+ /* non-negated output of counter channel minus 2 */
+ AMPLC_DIO_GAT_OUTNM2,
+ AMPLC_DIO_GAT_PAT_PRESENT, /* "pattern present" signal */
+ AMPLC_DIO_GAT_PAT_OCCURRED, /* "pattern occurred" latched */
+ AMPLC_DIO_GAT_PAT_GONE, /* "pattern gone away" latched */
+ AMPLC_DIO_GAT_NPAT_PRESENT, /* negated "pattern present" */
+ AMPLC_DIO_GAT_NPAT_OCCURRED, /* negated "pattern occurred" */
+ AMPLC_DIO_GAT_NPAT_GONE /* negated "pattern gone away" */
+};
+
+/*
+ * Values for setting a clock source with INSN_CONFIG_SET_CLOCK_SRC for
+ * the counter subdevice on the Kolter Electronic PCI-Counter board
+ * (ke_counter driver).
+ */
+enum ke_counter_clock_source {
+ KE_CLK_20MHZ, /* internal 20MHz (default) */
+ KE_CLK_4MHZ, /* internal 4MHz (option) */
+ KE_CLK_EXT /* external clock on pin 21 of D-Sub */
+};
+
+#endif /* _COMEDI_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/connector.h b/lib/libc/include/any-linux-any/linux/connector.h
index dfe50a5c5a..72a42a2607 100644
--- a/lib/libc/include/any-linux-any/linux/connector.h
+++ b/lib/libc/include/any-linux-any/linux/connector.h
@@ -75,7 +75,7 @@ struct cn_msg {
__u16 len; /* Length of the following data */
__u16 flags;
- __u8 data[0];
+ __u8 data[];
};
#endif /* __CONNECTOR_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/const.h b/lib/libc/include/any-linux-any/linux/const.h
index 3555ca8afb..1d3cec533c 100644
--- a/lib/libc/include/any-linux-any/linux/const.h
+++ b/lib/libc/include/any-linux-any/linux/const.h
@@ -28,7 +28,7 @@
#define _BITUL(x) (_UL(1) << (x))
#define _BITULL(x) (_ULL(1) << (x))
-#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
#define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
diff --git a/lib/libc/include/any-linux-any/linux/counter.h b/lib/libc/include/any-linux-any/linux/counter.h
index 3e7af37e75..e613c8ccab 100644
--- a/lib/libc/include/any-linux-any/linux/counter.h
+++ b/lib/libc/include/any-linux-any/linux/counter.h
@@ -61,6 +61,10 @@ enum counter_event_type {
COUNTER_EVENT_THRESHOLD,
/* Index signal detected */
COUNTER_EVENT_INDEX,
+ /* State of counter is changed */
+ COUNTER_EVENT_CHANGE_OF_STATE,
+ /* Count value captured */
+ COUNTER_EVENT_CAPTURE,
};
/**
@@ -151,4 +155,10 @@ enum counter_synapse_action {
COUNTER_SYNAPSE_ACTION_BOTH_EDGES,
};
+/* Signal polarity values */
+enum counter_signal_polarity {
+ COUNTER_SIGNAL_POLARITY_POSITIVE,
+ COUNTER_SIGNAL_POLARITY_NEGATIVE,
+};
+
#endif /* _COUNTER_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/cxl_mem.h b/lib/libc/include/any-linux-any/linux/cxl_mem.h
index aa3b50a8d9..5be6864972 100644
--- a/lib/libc/include/any-linux-any/linux/cxl_mem.h
+++ b/lib/libc/include/any-linux-any/linux/cxl_mem.h
@@ -11,14 +11,19 @@
/**
* DOC: UAPI
*
- * Not all of all commands that the driver supports are always available for use
- * by userspace. Userspace must check the results from the QUERY command in
- * order to determine the live set of commands.
+ * Not all of the commands that the driver supports are available for use by
+ * userspace at all times. Userspace can check the result of the QUERY command
+ * to determine the live set of commands. Alternatively, it can issue the
+ * command and check for failure.
*/
#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command)
+/*
+ * NOTE: New defines must be added to the end of the list to preserve
+ * compatibility because this enum is exported to user space.
+ */
#define CXL_CMDS \
___C(INVALID, "Invalid Command"), \
___C(IDENTIFY, "Identify Command"), \
@@ -68,8 +73,21 @@ static const struct {
* struct cxl_command_info - Command information returned from a query.
* @id: ID number for the command.
* @flags: Flags that specify command behavior.
- * @size_in: Expected input size, or -1 if variable length.
- * @size_out: Expected output size, or -1 if variable length.
+ *
+ * CXL_MEM_COMMAND_FLAG_USER_ENABLED
+ *
+ * The given command id is supported by the driver and is supported by
+ * a related opcode on the device.
+ *
+ * CXL_MEM_COMMAND_FLAG_EXCLUSIVE
+ *
+ * Requests with the given command id will terminate with EBUSY as the
+ * kernel actively owns management of the given resource. For example,
+ * the label-storage-area can not be written while the kernel is
+ * actively managing that space.
+ *
+ * @size_in: Expected input size, or ~0 if variable length.
+ * @size_out: Expected output size, or ~0 if variable length.
*
* Represents a single command that is supported by both the driver and the
* hardware. This is returned as part of an array from the query ioctl. The
@@ -77,8 +95,8 @@ static const struct {
* bytes of output.
*
* - @id = 10
- * - @flags = 0
- * - @size_in = -1
+ * - @flags = CXL_MEM_COMMAND_FLAG_ENABLED
+ * - @size_in = ~0
* - @size_out = 0
*
* See struct cxl_mem_query_commands.
@@ -87,10 +105,12 @@ struct cxl_command_info {
__u32 id;
__u32 flags;
-#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(0, 0)
+#define CXL_MEM_COMMAND_FLAG_MASK GENMASK(1, 0)
+#define CXL_MEM_COMMAND_FLAG_ENABLED BIT(0)
+#define CXL_MEM_COMMAND_FLAG_EXCLUSIVE BIT(1)
- __s32 size_in;
- __s32 size_out;
+ __u32 size_in;
+ __u32 size_out;
};
/**
@@ -169,13 +189,13 @@ struct cxl_send_command {
__u32 retval;
struct {
- __s32 size;
+ __u32 size;
__u32 rsvd;
__u64 payload;
} in;
struct {
- __s32 size;
+ __u32 size;
__u32 rsvd;
__u64 payload;
} out;
diff --git a/lib/libc/include/any-linux-any/linux/cyclades.h b/lib/libc/include/any-linux-any/linux/cyclades.h
new file mode 100644
index 0000000000..5e6ebb40a1
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/cyclades.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef _LINUX_CYCLADES_H
+#define _LINUX_CYCLADES_H
+
+#warning "Support for features provided by this header has been removed"
+#warning "Please consider updating your code"
+
+struct cyclades_monitor {
+ unsigned long int_count;
+ unsigned long char_count;
+ unsigned long char_max;
+ unsigned long char_last;
+};
+
+#define CYGETMON 0x435901
+#define CYGETTHRESH 0x435902
+#define CYSETTHRESH 0x435903
+#define CYGETDEFTHRESH 0x435904
+#define CYSETDEFTHRESH 0x435905
+#define CYGETTIMEOUT 0x435906
+#define CYSETTIMEOUT 0x435907
+#define CYGETDEFTIMEOUT 0x435908
+#define CYSETDEFTIMEOUT 0x435909
+#define CYSETRFLOW 0x43590a
+#define CYGETRFLOW 0x43590b
+#define CYSETRTSDTR_INV 0x43590c
+#define CYGETRTSDTR_INV 0x43590d
+#define CYZSETPOLLCYCLE 0x43590e
+#define CYZGETPOLLCYCLE 0x43590f
+#define CYGETCD1400VER 0x435910
+#define CYSETWAIT 0x435912
+#define CYGETWAIT 0x435913
+
+#endif /* _LINUX_CYCLADES_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/cycx_cfm.h b/lib/libc/include/any-linux-any/linux/cycx_cfm.h
index ff9b0ffeda..6e3c5684a6 100644
--- a/lib/libc/include/any-linux-any/linux/cycx_cfm.h
+++ b/lib/libc/include/any-linux-any/linux/cycx_cfm.h
@@ -91,7 +91,7 @@ struct cycx_firmware {
unsigned short reserved[6];
char descr[CFM_DESCR_LEN];
struct cycx_fw_info info;
- unsigned char image[0];
+ unsigned char image[];
};
struct cycx_fw_header {
diff --git a/lib/libc/include/any-linux-any/linux/dcbnl.h b/lib/libc/include/any-linux-any/linux/dcbnl.h
index 4397db0201..bea4b64da1 100644
--- a/lib/libc/include/any-linux-any/linux/dcbnl.h
+++ b/lib/libc/include/any-linux-any/linux/dcbnl.h
@@ -218,6 +218,9 @@ struct cee_pfc {
#define IEEE_8021QAZ_APP_SEL_ANY 4
#define IEEE_8021QAZ_APP_SEL_DSCP 5
+/* Non-std selector values */
+#define DCB_APP_SEL_PCP 255
+
/* This structure contains the IEEE 802.1Qaz APP managed object. This
* object is also used for the CEE std as well.
*
@@ -247,6 +250,8 @@ struct dcb_app {
__u16 protocol;
};
+#define IEEE_8021QAZ_APP_SEL_MAX 255
+
/**
* struct dcb_peer_app_info - APP feature information sent by the peer
*
@@ -405,6 +410,8 @@ enum dcbnl_attrs {
* @DCB_ATTR_IEEE_PEER_ETS: peer ETS configuration - get only
* @DCB_ATTR_IEEE_PEER_PFC: peer PFC configuration - get only
* @DCB_ATTR_IEEE_PEER_APP: peer APP tlv - get only
+ * @DCB_ATTR_DCB_APP_TRUST_TABLE: selector trust table
+ * @DCB_ATTR_DCB_REWR_TABLE: rewrite configuration
*/
enum ieee_attrs {
DCB_ATTR_IEEE_UNSPEC,
@@ -418,6 +425,8 @@ enum ieee_attrs {
DCB_ATTR_IEEE_QCN,
DCB_ATTR_IEEE_QCN_STATS,
DCB_ATTR_DCB_BUFFER,
+ DCB_ATTR_DCB_APP_TRUST_TABLE,
+ DCB_ATTR_DCB_REWR_TABLE,
__DCB_ATTR_IEEE_MAX
};
#define DCB_ATTR_IEEE_MAX (__DCB_ATTR_IEEE_MAX - 1)
@@ -425,6 +434,7 @@ enum ieee_attrs {
enum ieee_attrs_app {
DCB_ATTR_IEEE_APP_UNSPEC,
DCB_ATTR_IEEE_APP,
+ DCB_ATTR_DCB_APP,
__DCB_ATTR_IEEE_APP_MAX
};
#define DCB_ATTR_IEEE_APP_MAX (__DCB_ATTR_IEEE_APP_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/devlink.h b/lib/libc/include/any-linux-any/linux/devlink.h
index aa9d5a0695..bb9bf86545 100644
--- a/lib/libc/include/any-linux-any/linux/devlink.h
+++ b/lib/libc/include/any-linux-any/linux/devlink.h
@@ -131,6 +131,14 @@ enum devlink_command {
DEVLINK_CMD_RATE_NEW,
DEVLINK_CMD_RATE_DEL,
+ DEVLINK_CMD_LINECARD_GET, /* can dump */
+ DEVLINK_CMD_LINECARD_SET,
+ DEVLINK_CMD_LINECARD_NEW,
+ DEVLINK_CMD_LINECARD_DEL,
+
+ DEVLINK_CMD_SELFTESTS_GET, /* can dump */
+ DEVLINK_CMD_SELFTESTS_RUN,
+
/* add new commands above here */
__DEVLINK_CMD_MAX,
DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1
@@ -271,6 +279,30 @@ enum {
#define DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS \
(_BITUL(__DEVLINK_FLASH_OVERWRITE_MAX_BIT) - 1)
+enum devlink_attr_selftest_id {
+ DEVLINK_ATTR_SELFTEST_ID_UNSPEC,
+ DEVLINK_ATTR_SELFTEST_ID_FLASH, /* flag */
+
+ __DEVLINK_ATTR_SELFTEST_ID_MAX,
+ DEVLINK_ATTR_SELFTEST_ID_MAX = __DEVLINK_ATTR_SELFTEST_ID_MAX - 1
+};
+
+enum devlink_selftest_status {
+ DEVLINK_SELFTEST_STATUS_SKIP,
+ DEVLINK_SELFTEST_STATUS_PASS,
+ DEVLINK_SELFTEST_STATUS_FAIL
+};
+
+enum devlink_attr_selftest_result {
+ DEVLINK_ATTR_SELFTEST_RESULT_UNSPEC,
+ DEVLINK_ATTR_SELFTEST_RESULT, /* nested */
+ DEVLINK_ATTR_SELFTEST_RESULT_ID, /* u32, enum devlink_attr_selftest_id */
+ DEVLINK_ATTR_SELFTEST_RESULT_STATUS, /* u8, enum devlink_selftest_status */
+
+ __DEVLINK_ATTR_SELFTEST_RESULT_MAX,
+ DEVLINK_ATTR_SELFTEST_RESULT_MAX = __DEVLINK_ATTR_SELFTEST_RESULT_MAX - 1
+};
+
/**
* enum devlink_trap_action - Packet trap action.
* @DEVLINK_TRAP_ACTION_DROP: Packet is dropped by the device and a copy is not
@@ -338,6 +370,19 @@ enum devlink_reload_limit {
#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
+enum devlink_linecard_state {
+ DEVLINK_LINECARD_STATE_UNSPEC,
+ DEVLINK_LINECARD_STATE_UNPROVISIONED,
+ DEVLINK_LINECARD_STATE_UNPROVISIONING,
+ DEVLINK_LINECARD_STATE_PROVISIONING,
+ DEVLINK_LINECARD_STATE_PROVISIONING_FAILED,
+ DEVLINK_LINECARD_STATE_PROVISIONED,
+ DEVLINK_LINECARD_STATE_ACTIVE,
+
+ __DEVLINK_LINECARD_STATE_MAX,
+ DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1
+};
+
enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
@@ -553,6 +598,20 @@ enum devlink_attr {
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */
+ DEVLINK_ATTR_LINECARD_INDEX, /* u32 */
+ DEVLINK_ATTR_LINECARD_STATE, /* u8 */
+ DEVLINK_ATTR_LINECARD_TYPE, /* string */
+ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */
+
+ DEVLINK_ATTR_NESTED_DEVLINK, /* nested */
+
+ DEVLINK_ATTR_SELFTESTS, /* nested */
+
+ DEVLINK_ATTR_RATE_TX_PRIORITY, /* u32 */
+ DEVLINK_ATTR_RATE_TX_WEIGHT, /* u32 */
+
+ DEVLINK_ATTR_REGION_DIRECT, /* flag */
+
/* add new attributes above here, update the policy in devlink.c */
__DEVLINK_ATTR_MAX,
@@ -599,11 +658,24 @@ enum devlink_resource_unit {
DEVLINK_RESOURCE_UNIT_ENTRY,
};
+enum devlink_port_fn_attr_cap {
+ DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT,
+ DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT,
+
+ /* Add new caps above */
+ __DEVLINK_PORT_FN_ATTR_CAPS_MAX,
+};
+
+#define DEVLINK_PORT_FN_CAP_ROCE _BITUL(DEVLINK_PORT_FN_ATTR_CAP_ROCE_BIT)
+#define DEVLINK_PORT_FN_CAP_MIGRATABLE \
+ _BITUL(DEVLINK_PORT_FN_ATTR_CAP_MIGRATABLE_BIT)
+
enum devlink_port_function_attr {
DEVLINK_PORT_FUNCTION_ATTR_UNSPEC,
DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR, /* binary */
DEVLINK_PORT_FN_ATTR_STATE, /* u8 */
DEVLINK_PORT_FN_ATTR_OPSTATE, /* u8 */
+ DEVLINK_PORT_FN_ATTR_CAPS, /* bitfield32 */
__DEVLINK_PORT_FUNCTION_ATTR_MAX,
DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
diff --git a/lib/libc/include/any-linux-any/linux/dlm.h b/lib/libc/include/any-linux-any/linux/dlm.h
index a61171f640..3e5565e1ed 100644
--- a/lib/libc/include/any-linux-any/linux/dlm.h
+++ b/lib/libc/include/any-linux-any/linux/dlm.h
@@ -69,7 +69,6 @@ struct dlm_lksb {
/* dlm_new_lockspace() flags */
#define DLM_LSFL_TIMEWARN 0x00000002
-#define DLM_LSFL_FS 0x00000004
#define DLM_LSFL_NEWEXCL 0x00000008
diff --git a/lib/libc/include/any-linux-any/linux/dm-ioctl.h b/lib/libc/include/any-linux-any/linux/dm-ioctl.h
index 4fbee36541..50aead3ea8 100644
--- a/lib/libc/include/any-linux-any/linux/dm-ioctl.h
+++ b/lib/libc/include/any-linux-any/linux/dm-ioctl.h
@@ -182,7 +182,7 @@ struct dm_target_spec {
struct dm_target_deps {
__u32 count; /* Array size */
__u32 padding; /* unused */
- __u64 dev[0]; /* out */
+ __u64 dev[]; /* out */
};
/*
@@ -192,7 +192,7 @@ struct dm_name_list {
__u64 dev;
__u32 next; /* offset to the next record from
the _start_ of this */
- char name[0];
+ char name[];
/*
* The following members can be accessed by taking a pointer that
@@ -216,7 +216,7 @@ struct dm_target_versions {
__u32 next;
__u32 version[3];
- char name[0];
+ char name[];
};
/*
@@ -225,7 +225,7 @@ struct dm_target_versions {
struct dm_target_msg {
__u64 sector; /* Device sector */
- char message[0];
+ char message[];
};
/*
@@ -286,9 +286,9 @@ enum {
#define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
#define DM_VERSION_MAJOR 4
-#define DM_VERSION_MINOR 45
+#define DM_VERSION_MINOR 47
#define DM_VERSION_PATCHLEVEL 0
-#define DM_VERSION_EXTRA "-ioctl (2021-03-22)"
+#define DM_VERSION_EXTRA "-ioctl (2022-07-28)"
/* Status bits */
#define DM_READONLY_FLAG (1 << 0) /* In/Out */
diff --git a/lib/libc/include/any-linux-any/linux/dm-log-userspace.h b/lib/libc/include/any-linux-any/linux/dm-log-userspace.h
index e51c67675c..d48e121f79 100644
--- a/lib/libc/include/any-linux-any/linux/dm-log-userspace.h
+++ b/lib/libc/include/any-linux-any/linux/dm-log-userspace.h
@@ -426,7 +426,7 @@ struct dm_ulog_request {
__u32 request_type; /* DM_ULOG_* defined above */
__u32 data_size; /* How much data (not including this struct) */
- char data[0];
+ char data[];
};
#endif /* __DM_LOG_USERSPACE_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/dma-buf.h b/lib/libc/include/any-linux-any/linux/dma-buf.h
index ce24f38b77..4bb9315f82 100644
--- a/lib/libc/include/any-linux-any/linux/dma-buf.h
+++ b/lib/libc/include/any-linux-any/linux/dma-buf.h
@@ -85,6 +85,88 @@ struct dma_buf_sync {
#define DMA_BUF_NAME_LEN 32
+/**
+ * struct dma_buf_export_sync_file - Get a sync_file from a dma-buf
+ *
+ * Userspace can perform a DMA_BUF_IOCTL_EXPORT_SYNC_FILE to retrieve the
+ * current set of fences on a dma-buf file descriptor as a sync_file. CPU
+ * waits via poll() or other driver-specific mechanisms typically wait on
+ * whatever fences are on the dma-buf at the time the wait begins. This
+ * is similar except that it takes a snapshot of the current fences on the
+ * dma-buf for waiting later instead of waiting immediately. This is
+ * useful for modern graphics APIs such as Vulkan which assume an explicit
+ * synchronization model but still need to inter-operate with dma-buf.
+ *
+ * The intended usage pattern is the following:
+ *
+ * 1. Export a sync_file with flags corresponding to the expected GPU usage
+ * via DMA_BUF_IOCTL_EXPORT_SYNC_FILE.
+ *
+ * 2. Submit rendering work which uses the dma-buf. The work should wait on
+ * the exported sync file before rendering and produce another sync_file
+ * when complete.
+ *
+ * 3. Import the rendering-complete sync_file into the dma-buf with flags
+ * corresponding to the GPU usage via DMA_BUF_IOCTL_IMPORT_SYNC_FILE.
+ *
+ * Unlike doing implicit synchronization via a GPU kernel driver's exec ioctl,
+ * the above is not a single atomic operation. If userspace wants to ensure
+ * ordering via these fences, it is the respnosibility of userspace to use
+ * locks or other mechanisms to ensure that no other context adds fences or
+ * submits work between steps 1 and 3 above.
+ */
+struct dma_buf_export_sync_file {
+ /**
+ * @flags: Read/write flags
+ *
+ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
+ *
+ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
+ * the returned sync file waits on any writers of the dma-buf to
+ * complete. Waiting on the returned sync file is equivalent to
+ * poll() with POLLIN.
+ *
+ * If DMA_BUF_SYNC_WRITE is set, the returned sync file waits on
+ * any users of the dma-buf (read or write) to complete. Waiting
+ * on the returned sync file is equivalent to poll() with POLLOUT.
+ * If both DMA_BUF_SYNC_WRITE and DMA_BUF_SYNC_READ are set, this
+ * is equivalent to just DMA_BUF_SYNC_WRITE.
+ */
+ __u32 flags;
+ /** @fd: Returned sync file descriptor */
+ __s32 fd;
+};
+
+/**
+ * struct dma_buf_import_sync_file - Insert a sync_file into a dma-buf
+ *
+ * Userspace can perform a DMA_BUF_IOCTL_IMPORT_SYNC_FILE to insert a
+ * sync_file into a dma-buf for the purposes of implicit synchronization
+ * with other dma-buf consumers. This allows clients using explicitly
+ * synchronized APIs such as Vulkan to inter-op with dma-buf consumers
+ * which expect implicit synchronization such as OpenGL or most media
+ * drivers/video.
+ */
+struct dma_buf_import_sync_file {
+ /**
+ * @flags: Read/write flags
+ *
+ * Must be DMA_BUF_SYNC_READ, DMA_BUF_SYNC_WRITE, or both.
+ *
+ * If DMA_BUF_SYNC_READ is set and DMA_BUF_SYNC_WRITE is not set,
+ * this inserts the sync_file as a read-only fence. Any subsequent
+ * implicitly synchronized writes to this dma-buf will wait on this
+ * fence but reads will not.
+ *
+ * If DMA_BUF_SYNC_WRITE is set, this inserts the sync_file as a
+ * write fence. All subsequent implicitly synchronized access to
+ * this dma-buf will wait on this fence.
+ */
+ __u32 flags;
+ /** @fd: Sync file descriptor */
+ __s32 fd;
+};
+
#define DMA_BUF_BASE 'b'
#define DMA_BUF_IOCTL_SYNC _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
@@ -92,7 +174,9 @@ struct dma_buf_sync {
* between them in actual uapi, they're just different numbers.
*/
#define DMA_BUF_SET_NAME _IOW(DMA_BUF_BASE, 1, const char *)
-#define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, u32)
-#define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, u64)
+#define DMA_BUF_SET_NAME_A _IOW(DMA_BUF_BASE, 1, __u32)
+#define DMA_BUF_SET_NAME_B _IOW(DMA_BUF_BASE, 1, __u64)
+#define DMA_BUF_IOCTL_EXPORT_SYNC_FILE _IOWR(DMA_BUF_BASE, 2, struct dma_buf_export_sync_file)
+#define DMA_BUF_IOCTL_IMPORT_SYNC_FILE _IOW(DMA_BUF_BASE, 3, struct dma_buf_import_sync_file)
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/dn.h b/lib/libc/include/any-linux-any/linux/dn.h
deleted file mode 100644
index 23bcffd79d..0000000000
--- a/lib/libc/include/any-linux-any/linux/dn.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef _LINUX_DN_H
-#define _LINUX_DN_H
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-#include <linux/if_ether.h>
-
-/*
-
- DECnet Data Structures and Constants
-
-*/
-
-/*
- * DNPROTO_NSP can't be the same as SOL_SOCKET,
- * so increment each by one (compared to ULTRIX)
- */
-#define DNPROTO_NSP 2 /* NSP protocol number */
-#define DNPROTO_ROU 3 /* Routing protocol number */
-#define DNPROTO_NML 4 /* Net mgt protocol number */
-#define DNPROTO_EVL 5 /* Evl protocol number (usr) */
-#define DNPROTO_EVR 6 /* Evl protocol number (evl) */
-#define DNPROTO_NSPT 7 /* NSP trace protocol number */
-
-
-#define DN_ADDL 2
-#define DN_MAXADDL 2 /* ULTRIX headers have 20 here, but pathworks has 2 */
-#define DN_MAXOPTL 16
-#define DN_MAXOBJL 16
-#define DN_MAXACCL 40
-#define DN_MAXALIASL 128
-#define DN_MAXNODEL 256
-#define DNBUFSIZE 65023
-
-/*
- * SET/GET Socket options - must match the DSO_ numbers below
- */
-#define SO_CONDATA 1
-#define SO_CONACCESS 2
-#define SO_PROXYUSR 3
-#define SO_LINKINFO 7
-
-#define DSO_CONDATA 1 /* Set/Get connect data */
-#define DSO_DISDATA 10 /* Set/Get disconnect data */
-#define DSO_CONACCESS 2 /* Set/Get connect access data */
-#define DSO_ACCEPTMODE 4 /* Set/Get accept mode */
-#define DSO_CONACCEPT 5 /* Accept deferred connection */
-#define DSO_CONREJECT 6 /* Reject deferred connection */
-#define DSO_LINKINFO 7 /* Set/Get link information */
-#define DSO_STREAM 8 /* Set socket type to stream */
-#define DSO_SEQPACKET 9 /* Set socket type to sequenced packet */
-#define DSO_MAXWINDOW 11 /* Maximum window size allowed */
-#define DSO_NODELAY 12 /* Turn off nagle */
-#define DSO_CORK 13 /* Wait for more data! */
-#define DSO_SERVICES 14 /* NSP Services field */
-#define DSO_INFO 15 /* NSP Info field */
-#define DSO_MAX 15 /* Maximum option number */
-
-
-/* LINK States */
-#define LL_INACTIVE 0
-#define LL_CONNECTING 1
-#define LL_RUNNING 2
-#define LL_DISCONNECTING 3
-
-#define ACC_IMMED 0
-#define ACC_DEFER 1
-
-#define SDF_WILD 1 /* Wild card object */
-#define SDF_PROXY 2 /* Addr eligible for proxy */
-#define SDF_UICPROXY 4 /* Use uic-based proxy */
-
-/* Structures */
-
-
-struct dn_naddr {
- __le16 a_len;
- __u8 a_addr[DN_MAXADDL]; /* Two bytes little endian */
-};
-
-struct sockaddr_dn {
- __u16 sdn_family;
- __u8 sdn_flags;
- __u8 sdn_objnum;
- __le16 sdn_objnamel;
- __u8 sdn_objname[DN_MAXOBJL];
- struct dn_naddr sdn_add;
-};
-#define sdn_nodeaddrl sdn_add.a_len /* Node address length */
-#define sdn_nodeaddr sdn_add.a_addr /* Node address */
-
-
-
-/*
- * DECnet set/get DSO_CONDATA, DSO_DISDATA (optional data) structure
- */
-struct optdata_dn {
- __le16 opt_status; /* Extended status return */
-#define opt_sts opt_status
- __le16 opt_optl; /* Length of user data */
- __u8 opt_data[16]; /* User data */
-};
-
-struct accessdata_dn {
- __u8 acc_accl;
- __u8 acc_acc[DN_MAXACCL];
- __u8 acc_passl;
- __u8 acc_pass[DN_MAXACCL];
- __u8 acc_userl;
- __u8 acc_user[DN_MAXACCL];
-};
-
-/*
- * DECnet logical link information structure
- */
-struct linkinfo_dn {
- __u16 idn_segsize; /* Segment size for link */
- __u8 idn_linkstate; /* Logical link state */
-};
-
-/*
- * Ethernet address format (for DECnet)
- */
-union etheraddress {
- __u8 dne_addr[ETH_ALEN]; /* Full ethernet address */
- struct {
- __u8 dne_hiord[4]; /* DECnet HIORD prefix */
- __u8 dne_nodeaddr[2]; /* DECnet node address */
- } dne_remote;
-};
-
-
-/*
- * DECnet physical socket address format
- */
-struct dn_addr {
- __le16 dna_family; /* AF_DECnet */
- union etheraddress dna_netaddr; /* DECnet ethernet address */
-};
-
-#define DECNET_IOCTL_BASE 0x89 /* PROTOPRIVATE range */
-
-#define SIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, struct dn_naddr)
-#define SIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, struct dn_naddr)
-#define OSIOCSNETADDR _IOW(DECNET_IOCTL_BASE, 0xe0, int)
-#define OSIOCGNETADDR _IOR(DECNET_IOCTL_BASE, 0xe1, int)
-
-#endif /* _LINUX_DN_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/dvb/audio.h b/lib/libc/include/any-linux-any/linux/dvb/audio.h
index 568286fc6a..258b1ccae0 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/audio.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/audio.h
@@ -7,21 +7,6 @@
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Lesser Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBAUDIO_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/ca.h b/lib/libc/include/any-linux-any/linux/dvb/ca.h
index c439b66fa0..9361e58df9 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/ca.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/ca.h
@@ -5,21 +5,6 @@
* Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Lesser Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBCA_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/dmx.h b/lib/libc/include/any-linux-any/linux/dvb/dmx.h
index 0c0e38b883..ed7e0b1ba7 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/dmx.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/dmx.h
@@ -5,21 +5,6 @@
* Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
* & Ralph Metzler <ralph@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBDMX_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/frontend.h b/lib/libc/include/any-linux-any/linux/dvb/frontend.h
index 6783419145..b84ce13564 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/frontend.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/frontend.h
@@ -7,21 +7,6 @@
* Holger Waechtler <holger@convergence.de>
* Andre Draszik <ad@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBFRONTEND_H_
@@ -282,7 +267,6 @@ enum fe_spectral_inversion {
/**
* enum fe_code_rate - Type of Forward Error Correction (FEC)
*
- *
* @FEC_NONE: No Forward Error Correction Code
* @FEC_1_2: Forward Error Correction Code 1/2
* @FEC_2_3: Forward Error Correction Code 2/3
@@ -296,6 +280,22 @@ enum fe_spectral_inversion {
* @FEC_3_5: Forward Error Correction Code 3/5
* @FEC_9_10: Forward Error Correction Code 9/10
* @FEC_2_5: Forward Error Correction Code 2/5
+ * @FEC_1_3: Forward Error Correction Code 1/3
+ * @FEC_1_4: Forward Error Correction Code 1/4
+ * @FEC_5_9: Forward Error Correction Code 5/9
+ * @FEC_7_9: Forward Error Correction Code 7/9
+ * @FEC_8_15: Forward Error Correction Code 8/15
+ * @FEC_11_15: Forward Error Correction Code 11/15
+ * @FEC_13_18: Forward Error Correction Code 13/18
+ * @FEC_9_20: Forward Error Correction Code 9/20
+ * @FEC_11_20: Forward Error Correction Code 11/20
+ * @FEC_23_36: Forward Error Correction Code 23/36
+ * @FEC_25_36: Forward Error Correction Code 25/36
+ * @FEC_13_45: Forward Error Correction Code 13/45
+ * @FEC_26_45: Forward Error Correction Code 26/45
+ * @FEC_28_45: Forward Error Correction Code 28/45
+ * @FEC_32_45: Forward Error Correction Code 32/45
+ * @FEC_77_90: Forward Error Correction Code 77/90
*
* Please note that not all FEC types are supported by a given standard.
*/
@@ -313,6 +313,22 @@ enum fe_code_rate {
FEC_3_5,
FEC_9_10,
FEC_2_5,
+ FEC_1_3,
+ FEC_1_4,
+ FEC_5_9,
+ FEC_7_9,
+ FEC_8_15,
+ FEC_11_15,
+ FEC_13_18,
+ FEC_9_20,
+ FEC_11_20,
+ FEC_23_36,
+ FEC_25_36,
+ FEC_13_45,
+ FEC_26_45,
+ FEC_28_45,
+ FEC_32_45,
+ FEC_77_90,
};
/**
@@ -331,6 +347,13 @@ enum fe_code_rate {
* @APSK_32: 32-APSK modulation
* @DQPSK: DQPSK modulation
* @QAM_4_NR: 4-QAM-NR modulation
+ * @QAM_1024: 1024-QAM modulation
+ * @QAM_4096: 4096-QAM modulation
+ * @APSK_8_L: 8APSK-L modulation
+ * @APSK_16_L: 16APSK-L modulation
+ * @APSK_32_L: 32APSK-L modulation
+ * @APSK_64: 64APSK modulation
+ * @APSK_64_L: 64APSK-L modulation
*
* Please note that not all modulations are supported by a given standard.
*
@@ -350,6 +373,13 @@ enum fe_modulation {
APSK_32,
DQPSK,
QAM_4_NR,
+ QAM_1024,
+ QAM_4096,
+ APSK_8_L,
+ APSK_16_L,
+ APSK_32_L,
+ APSK_64,
+ APSK_64_L,
};
/**
@@ -404,6 +434,7 @@ enum fe_transmit_mode {
* @GUARD_INTERVAL_PN420: PN length 420 (1/4)
* @GUARD_INTERVAL_PN595: PN length 595 (1/6)
* @GUARD_INTERVAL_PN945: PN length 945 (1/9)
+ * @GUARD_INTERVAL_1_64: Guard interval 1/64
*
* Please note that not all guard intervals are supported by a given standard.
*/
@@ -419,6 +450,7 @@ enum fe_guard_interval {
GUARD_INTERVAL_PN420,
GUARD_INTERVAL_PN595,
GUARD_INTERVAL_PN945,
+ GUARD_INTERVAL_1_64,
};
/**
@@ -571,6 +603,9 @@ enum fe_pilot {
* @ROLLOFF_20: Roloff factor: α=20%
* @ROLLOFF_25: Roloff factor: α=25%
* @ROLLOFF_AUTO: Auto-detect the roloff factor.
+ * @ROLLOFF_15: Rolloff factor: α=15%
+ * @ROLLOFF_10: Rolloff factor: α=10%
+ * @ROLLOFF_5: Rolloff factor: α=5%
*
* .. note:
*
@@ -581,6 +616,9 @@ enum fe_rolloff {
ROLLOFF_20,
ROLLOFF_25,
ROLLOFF_AUTO,
+ ROLLOFF_15,
+ ROLLOFF_10,
+ ROLLOFF_5,
};
/**
@@ -594,6 +632,8 @@ enum fe_rolloff {
* Cable TV: DVB-C following ITU-T J.83 Annex B spec (ClearQAM)
* @SYS_DVBC_ANNEX_C:
* Cable TV: DVB-C following ITU-T J.83 Annex C spec
+ * @SYS_DVBC2:
+ * Cable TV: DVB-C2
* @SYS_ISDBC:
* Cable TV: ISDB-C (no drivers yet)
* @SYS_DVBT:
@@ -611,7 +651,7 @@ enum fe_rolloff {
* @SYS_DVBS:
* Satellite TV: DVB-S
* @SYS_DVBS2:
- * Satellite TV: DVB-S2
+ * Satellite TV: DVB-S2 and DVB-S2X
* @SYS_TURBO:
* Satellite TV: DVB-S Turbo
* @SYS_ISDBS:
@@ -645,6 +685,7 @@ enum fe_delivery_system {
SYS_DVBT2,
SYS_TURBO,
SYS_DVBC_ANNEX_C,
+ SYS_DVBC2,
};
/* backward compatibility definitions for delivery systems */
@@ -720,7 +761,7 @@ enum atscmh_rs_frame_mode {
};
/**
- * enum atscmh_rs_code_mode
+ * enum atscmh_rs_code_mode - ATSC-M/H Reed Solomon modes
* @ATSCMH_RSCODE_211_187: Reed Solomon code (211,187).
* @ATSCMH_RSCODE_223_187: Reed Solomon code (223,187).
* @ATSCMH_RSCODE_235_187: Reed Solomon code (235,187).
diff --git a/lib/libc/include/any-linux-any/linux/dvb/net.h b/lib/libc/include/any-linux-any/linux/dvb/net.h
index f9457659fd..564fe08306 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/net.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/net.h
@@ -5,21 +5,6 @@
* Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
* & Ralph Metzler <ralph@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBNET_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/osd.h b/lib/libc/include/any-linux-any/linux/dvb/osd.h
index 7233614558..45b00cc547 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/osd.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/osd.h
@@ -7,21 +7,6 @@
* Copyright (C) 2001 Ralph Metzler <ralph@convergence.de>
* & Marcus Metzler <marcus@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Lesser Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBOSD_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/version.h b/lib/libc/include/any-linux-any/linux/dvb/version.h
index af23e5cff2..2aa5225534 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/version.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/version.h
@@ -4,21 +4,6 @@
*
* Copyright (C) 2000 Holger Waechtler <holger@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBVERSION_H_
diff --git a/lib/libc/include/any-linux-any/linux/dvb/video.h b/lib/libc/include/any-linux-any/linux/dvb/video.h
index f8d223b977..8fac9e7826 100644
--- a/lib/libc/include/any-linux-any/linux/dvb/video.h
+++ b/lib/libc/include/any-linux-any/linux/dvb/video.h
@@ -7,21 +7,6 @@
* Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
* & Ralph Metzler <ralph@convergence.de>
* for convergence integrated media GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
*/
#ifndef _DVBVIDEO_H_
diff --git a/lib/libc/include/any-linux-any/linux/dw100.h b/lib/libc/include/any-linux-any/linux/dw100.h
new file mode 100644
index 0000000000..b1a5fb0802
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/dw100.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/* Copyright 2022 NXP */
+
+#ifndef __UAPI_DW100_H__
+#define __UAPI_DW100_H__
+
+#include <linux/v4l2-controls.h>
+
+/*
+ * Check Documentation/userspace-api/media/drivers/dw100.rst for control details.
+ */
+#define V4L2_CID_DW100_DEWARPING_16x16_VERTEX_MAP (V4L2_CID_USER_DW100_BASE + 1)
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/elf-em.h b/lib/libc/include/any-linux-any/linux/elf-em.h
index d98712302b..8f5c3b375a 100644
--- a/lib/libc/include/any-linux-any/linux/elf-em.h
+++ b/lib/libc/include/any-linux-any/linux/elf-em.h
@@ -51,6 +51,7 @@
#define EM_RISCV 243 /* RISC-V */
#define EM_BPF 247 /* Linux BPF - in-kernel virtual machine */
#define EM_CSKY 252 /* C-SKY */
+#define EM_LOONGARCH 258 /* LoongArch */
#define EM_FRV 0x5441 /* Fujitsu FR-V */
/*
diff --git a/lib/libc/include/any-linux-any/linux/elf.h b/lib/libc/include/any-linux-any/linux/elf.h
index 06490b74e5..c9025e10d9 100644
--- a/lib/libc/include/any-linux-any/linux/elf.h
+++ b/lib/libc/include/any-linux-any/linux/elf.h
@@ -35,10 +35,14 @@ typedef __s64 Elf64_Sxword;
#define PT_HIOS 0x6fffffff /* OS-specific */
#define PT_LOPROC 0x70000000
#define PT_HIPROC 0x7fffffff
-#define PT_GNU_EH_FRAME 0x6474e550
-#define PT_GNU_PROPERTY 0x6474e553
-
+#define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550)
#define PT_GNU_STACK (PT_LOOS + 0x474e551)
+#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
+#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553)
+
+
+/* ARM MTE memory tag segment type */
+#define PT_AARCH64_MEMTAG_MTE (PT_LOPROC + 0x2)
/*
* Extended Numbering
@@ -87,7 +91,7 @@ typedef __s64 Elf64_Sxword;
#define DT_INIT 12
#define DT_FINI 13
#define DT_SONAME 14
-#define DT_RPATH 15
+#define DT_RPATH 15
#define DT_SYMBOLIC 16
#define DT_REL 17
#define DT_RELSZ 18
@@ -130,15 +134,15 @@ typedef __s64 Elf64_Sxword;
#define STT_TLS 6
#define ELF_ST_BIND(x) ((x) >> 4)
-#define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
+#define ELF_ST_TYPE(x) ((x) & 0xf)
#define ELF32_ST_BIND(x) ELF_ST_BIND(x)
#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
#define ELF64_ST_BIND(x) ELF_ST_BIND(x)
#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
-typedef struct dynamic{
+typedef struct dynamic {
Elf32_Sword d_tag;
- union{
+ union {
Elf32_Sword d_val;
Elf32_Addr d_ptr;
} d_un;
@@ -169,7 +173,7 @@ typedef struct elf64_rel {
Elf64_Xword r_info; /* index and type of relocation */
} Elf64_Rel;
-typedef struct elf32_rela{
+typedef struct elf32_rela {
Elf32_Addr r_offset;
Elf32_Word r_info;
Elf32_Sword r_addend;
@@ -181,7 +185,7 @@ typedef struct elf64_rela {
Elf64_Sxword r_addend; /* Constant addend used to compute value */
} Elf64_Rela;
-typedef struct elf32_sym{
+typedef struct elf32_sym {
Elf32_Word st_name;
Elf32_Addr st_value;
Elf32_Word st_size;
@@ -202,7 +206,7 @@ typedef struct elf64_sym {
#define EI_NIDENT 16
-typedef struct elf32_hdr{
+typedef struct elf32_hdr {
unsigned char e_ident[EI_NIDENT];
Elf32_Half e_type;
Elf32_Half e_machine;
@@ -242,7 +246,7 @@ typedef struct elf64_hdr {
#define PF_W 0x2
#define PF_X 0x1
-typedef struct elf32_phdr{
+typedef struct elf32_phdr {
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
@@ -416,6 +420,7 @@ typedef struct elf64_shdr {
#define NT_S390_GS_CB 0x30b /* s390 guarded storage registers */
#define NT_S390_GS_BC 0x30c /* s390 guarded storage broadcast control block */
#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation */
+#define NT_S390_PV_CPU_DATA 0x30e /* s390 protvirt cpu dump data */
#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
#define NT_ARM_TLS 0x401 /* ARM TLS register */
#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
@@ -427,11 +432,21 @@ typedef struct elf64_shdr {
#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication generic key */
#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* arm64 tagged address control (prctl()) */
#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* arm64 ptr auth enabled keys (prctl()) */
+#define NT_ARM_SSVE 0x40b /* ARM Streaming SVE registers */
+#define NT_ARM_ZA 0x40c /* ARM SME ZA registers */
+#define NT_ARM_ZT 0x40d /* ARM SME ZT registers */
#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */
#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note */
#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers */
#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode */
#define NT_MIPS_MSA 0x802 /* MIPS SIMD registers */
+#define NT_LOONGARCH_CPUCFG 0xa00 /* LoongArch CPU config registers */
+#define NT_LOONGARCH_CSR 0xa01 /* LoongArch control and status registers */
+#define NT_LOONGARCH_LSX 0xa02 /* LoongArch Loongson SIMD Extension registers */
+#define NT_LOONGARCH_LASX 0xa03 /* LoongArch Loongson Advanced SIMD Extension registers */
+#define NT_LOONGARCH_LBT 0xa04 /* LoongArch Loongson Binary Translation registers */
+#define NT_LOONGARCH_HW_BREAK 0xa05 /* LoongArch hardware breakpoint registers */
+#define NT_LOONGARCH_HW_WATCH 0xa06 /* LoongArch hardware watchpoint registers */
/* Note types with note name "GNU" */
#define NT_GNU_PROPERTY_TYPE_0 5
diff --git a/lib/libc/include/any-linux-any/linux/ethtool.h b/lib/libc/include/any-linux-any/linux/ethtool.h
index 16ec0d7a25..019eea67fa 100644
--- a/lib/libc/include/any-linux-any/linux/ethtool.h
+++ b/lib/libc/include/any-linux-any/linux/ethtool.h
@@ -157,8 +157,10 @@ static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
* in its bus driver structure (e.g. pci_driver::name). Must
* not be an empty string.
* @version: Driver version string; may be an empty string
- * @fw_version: Firmware version string; may be an empty string
- * @erom_version: Expansion ROM version string; may be an empty string
+ * @fw_version: Firmware version string; driver defined; may be an
+ * empty string
+ * @erom_version: Expansion ROM version string; driver defined; may be
+ * an empty string
* @bus_info: Device bus address. This should match the dev_name()
* string for the underlying bus device, if there is one. May be
* an empty string.
@@ -177,10 +179,6 @@ static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
*
* Users can use the %ETHTOOL_GSSET_INFO command to get the number of
* strings in any string set (from Linux 2.6.34).
- *
- * Drivers should set at most @driver, @version, @fw_version and
- * @bus_info in their get_drvinfo() implementation. The ethtool
- * core fills in the other fields using other driver operations.
*/
struct ethtool_drvinfo {
__u32 cmd;
@@ -229,6 +227,7 @@ enum tunable_id {
ETHTOOL_RX_COPYBREAK,
ETHTOOL_TX_COPYBREAK,
ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
+ ETHTOOL_TX_COPYBREAK_BUF_SIZE,
/*
* Add your fresh new tunable attribute above and remember to update
* tunable_strings[] in net/ethtool/common.c
@@ -254,7 +253,7 @@ struct ethtool_tunable {
__u32 id;
__u32 type_id;
__u32 len;
- void *data[0];
+ void *data[];
};
#define DOWNSHIFT_DEV_DEFAULT_COUNT 0xff
@@ -319,7 +318,7 @@ struct ethtool_regs {
__u32 cmd;
__u32 version;
__u32 len;
- __u8 data[0];
+ __u8 data[];
};
/**
@@ -345,7 +344,7 @@ struct ethtool_eeprom {
__u32 magic;
__u32 offset;
__u32 len;
- __u8 data[0];
+ __u8 data[];
};
/**
@@ -711,6 +710,24 @@ enum ethtool_stringset {
};
/**
+ * enum ethtool_mac_stats_src - source of ethtool MAC statistics
+ * @ETHTOOL_MAC_STATS_SRC_AGGREGATE:
+ * if device supports a MAC merge layer, this retrieves the aggregate
+ * statistics of the eMAC and pMAC. Otherwise, it retrieves just the
+ * statistics of the single (express) MAC.
+ * @ETHTOOL_MAC_STATS_SRC_EMAC:
+ * if device supports a MM layer, this retrieves the eMAC statistics.
+ * Otherwise, it retrieves the statistics of the single (express) MAC.
+ * @ETHTOOL_MAC_STATS_SRC_PMAC:
+ * if device supports a MM layer, this retrieves the pMAC statistics.
+ */
+enum ethtool_mac_stats_src {
+ ETHTOOL_MAC_STATS_SRC_AGGREGATE,
+ ETHTOOL_MAC_STATS_SRC_EMAC,
+ ETHTOOL_MAC_STATS_SRC_PMAC,
+};
+
+/**
* enum ethtool_module_power_mode_policy - plug-in module power mode policy
* @ETHTOOL_MODULE_POWER_MODE_POLICY_HIGH: Module is always in high power mode.
* @ETHTOOL_MODULE_POWER_MODE_POLICY_AUTO: Module is transitioned by the host
@@ -734,6 +751,76 @@ enum ethtool_module_power_mode {
};
/**
+ * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE
+ * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState
+ * @ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN: state of PoDL PSE functions are
+ * unknown
+ * @ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED: PoDL PSE functions are disabled
+ * @ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED: PoDL PSE functions are enabled
+ */
+enum ethtool_podl_pse_admin_state {
+ ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN = 1,
+ ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED,
+ ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED,
+};
+
+/**
+ * enum ethtool_podl_pse_pw_d_status - power detection status of the PoDL PSE.
+ * IEEE 802.3-2018 30.15.1.1.3 aPoDLPSEPowerDetectionStatus:
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN: PoDL PSE
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED: "The enumeration “disabled” is
+ * asserted true when the PoDL PSE state diagram variable mr_pse_enable is
+ * false"
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING: "The enumeration “searching” is
+ * asserted true when either of the PSE state diagram variables
+ * pi_detecting or pi_classifying is true."
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING: "The enumeration “deliveringPower”
+ * is asserted true when the PoDL PSE state diagram variable pi_powered is
+ * true."
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP: "The enumeration “sleep” is asserted
+ * true when the PoDL PSE state diagram variable pi_sleeping is true."
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE: "The enumeration “idle” is asserted true
+ * when the logical combination of the PoDL PSE state diagram variables
+ * pi_prebiased*!pi_sleeping is true."
+ * @ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR: "The enumeration “error” is asserted
+ * true when the PoDL PSE state diagram variable overload_held is true."
+ */
+enum ethtool_podl_pse_pw_d_status {
+ ETHTOOL_PODL_PSE_PW_D_STATUS_UNKNOWN = 1,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_DISABLED,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_SEARCHING,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_DELIVERING,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_SLEEP,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_IDLE,
+ ETHTOOL_PODL_PSE_PW_D_STATUS_ERROR,
+};
+
+/**
+ * enum ethtool_mm_verify_status - status of MAC Merge Verify function
+ * @ETHTOOL_MM_VERIFY_STATUS_UNKNOWN:
+ * verification status is unknown
+ * @ETHTOOL_MM_VERIFY_STATUS_INITIAL:
+ * the 802.3 Verify State diagram is in the state INIT_VERIFICATION
+ * @ETHTOOL_MM_VERIFY_STATUS_VERIFYING:
+ * the Verify State diagram is in the state VERIFICATION_IDLE,
+ * SEND_VERIFY or WAIT_FOR_RESPONSE
+ * @ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED:
+ * indicates that the Verify State diagram is in the state VERIFIED
+ * @ETHTOOL_MM_VERIFY_STATUS_FAILED:
+ * the Verify State diagram is in the state VERIFY_FAIL
+ * @ETHTOOL_MM_VERIFY_STATUS_DISABLED:
+ * verification of preemption operation is disabled
+ */
+enum ethtool_mm_verify_status {
+ ETHTOOL_MM_VERIFY_STATUS_UNKNOWN,
+ ETHTOOL_MM_VERIFY_STATUS_INITIAL,
+ ETHTOOL_MM_VERIFY_STATUS_VERIFYING,
+ ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED,
+ ETHTOOL_MM_VERIFY_STATUS_FAILED,
+ ETHTOOL_MM_VERIFY_STATUS_DISABLED,
+};
+
+/**
* struct ethtool_gstrings - string set for data tagging
* @cmd: Command number = %ETHTOOL_GSTRINGS
* @string_set: String set ID; one of &enum ethtool_stringset
@@ -749,7 +836,7 @@ struct ethtool_gstrings {
__u32 cmd;
__u32 string_set;
__u32 len;
- __u8 data[0];
+ __u8 data[];
};
/**
@@ -774,7 +861,7 @@ struct ethtool_sset_info {
__u32 cmd;
__u32 reserved;
__u64 sset_mask;
- __u32 data[0];
+ __u32 data[];
};
/**
@@ -814,7 +901,7 @@ struct ethtool_test {
__u32 flags;
__u32 reserved;
__u32 len;
- __u64 data[0];
+ __u64 data[];
};
/**
@@ -831,7 +918,7 @@ struct ethtool_test {
struct ethtool_stats {
__u32 cmd;
__u32 n_stats;
- __u64 data[0];
+ __u64 data[];
};
/**
@@ -848,7 +935,7 @@ struct ethtool_stats {
struct ethtool_perm_addr {
__u32 cmd;
__u32 size;
- __u8 data[0];
+ __u8 data[];
};
/* boolean flags controlling per-interface behavior characteristics.
@@ -1137,7 +1224,7 @@ struct ethtool_rxnfc {
__u32 rule_cnt;
__u32 rss_context;
};
- __u32 rule_locs[0];
+ __u32 rule_locs[];
};
@@ -1157,7 +1244,7 @@ struct ethtool_rxnfc {
struct ethtool_rxfh_indir {
__u32 cmd;
__u32 size;
- __u32 ring_index[0];
+ __u32 ring_index[];
};
/**
@@ -1198,7 +1285,7 @@ struct ethtool_rxfh {
__u8 hfunc;
__u8 rsvd8[3];
__u32 rsvd32;
- __u32 rss_config[0];
+ __u32 rss_config[];
};
#define ETH_RXFH_CONTEXT_ALLOC 0xffffffff
#define ETH_RXFH_INDIR_NO_CHANGE 0xffffffff
@@ -1283,7 +1370,7 @@ struct ethtool_dump {
__u32 version;
__u32 flag;
__u32 len;
- __u8 data[0];
+ __u8 data[];
};
#define ETH_FW_DUMP_DISABLE 0
@@ -1315,7 +1402,7 @@ struct ethtool_get_features_block {
struct ethtool_gfeatures {
__u32 cmd;
__u32 size;
- struct ethtool_get_features_block features[0];
+ struct ethtool_get_features_block features[];
};
/**
@@ -1337,7 +1424,7 @@ struct ethtool_set_features_block {
struct ethtool_sfeatures {
__u32 cmd;
__u32 size;
- struct ethtool_set_features_block features[0];
+ struct ethtool_set_features_block features[];
};
/**
@@ -1688,6 +1775,17 @@ enum ethtool_link_mode_bit_indices {
ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT = 89,
ETHTOOL_LINK_MODE_100baseFX_Half_BIT = 90,
ETHTOOL_LINK_MODE_100baseFX_Full_BIT = 91,
+ ETHTOOL_LINK_MODE_10baseT1L_Full_BIT = 92,
+ ETHTOOL_LINK_MODE_800000baseCR8_Full_BIT = 93,
+ ETHTOOL_LINK_MODE_800000baseKR8_Full_BIT = 94,
+ ETHTOOL_LINK_MODE_800000baseDR8_Full_BIT = 95,
+ ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT = 96,
+ ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT = 97,
+ ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT = 98,
+ ETHTOOL_LINK_MODE_10baseT1S_Full_BIT = 99,
+ ETHTOOL_LINK_MODE_10baseT1S_Half_BIT = 100,
+ ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT = 101,
+
/* must be last entry */
__ETHTOOL_LINK_MODE_MASK_NBITS
};
@@ -1799,6 +1897,7 @@ enum ethtool_link_mode_bit_indices {
#define SPEED_100000 100000
#define SPEED_200000 200000
#define SPEED_400000 400000
+#define SPEED_800000 800000
#define SPEED_UNKNOWN -1
@@ -1836,6 +1935,20 @@ static __inline__ int ethtool_validate_duplex(__u8 duplex)
#define MASTER_SLAVE_STATE_SLAVE 3
#define MASTER_SLAVE_STATE_ERR 4
+/* These are used to throttle the rate of data on the phy interface when the
+ * native speed of the interface is higher than the link speed. These should
+ * not be used for phy interfaces which natively support multiple speeds (e.g.
+ * MII or SGMII).
+ */
+/* No rate matching performed. */
+#define RATE_MATCH_NONE 0
+/* The phy sends pause frames to throttle the MAC. */
+#define RATE_MATCH_PAUSE 1
+/* The phy asserts CRS to prevent the MAC from transmitting. */
+#define RATE_MATCH_CRS 2
+/* The MAC is programmed with a sufficiently-large IPG. */
+#define RATE_MATCH_OPEN_LOOP 3
+
/* Which connector port. */
#define PORT_TP 0x00
#define PORT_AUI 0x01
@@ -2029,8 +2142,8 @@ enum ethtool_reset_flags {
* reported consistently by PHYLIB. Read-only.
* @master_slave_cfg: Master/slave port mode.
* @master_slave_state: Master/slave port state.
+ * @rate_matching: Rate adaptation performed by the PHY
* @reserved: Reserved for future use; see the note on reserved space.
- * @reserved1: Reserved for future use; see the note on reserved space.
* @link_mode_masks: Variable length bitmaps.
*
* If autonegotiation is disabled, the speed and @duplex represent the
@@ -2081,9 +2194,9 @@ struct ethtool_link_settings {
__u8 transceiver;
__u8 master_slave_cfg;
__u8 master_slave_state;
- __u8 reserved1[1];
+ __u8 rate_matching;
__u32 reserved[7];
- __u32 link_mode_masks[0];
+ __u32 link_mode_masks[];
/* layout of link_mode_masks fields:
* __u32 map_supported[link_mode_masks_nwords];
* __u32 map_advertising[link_mode_masks_nwords];
diff --git a/lib/libc/include/any-linux-any/linux/ethtool_netlink.h b/lib/libc/include/any-linux-any/linux/ethtool_netlink.h
index bc128ee502..daf193cf30 100644
--- a/lib/libc/include/any-linux-any/linux/ethtool_netlink.h
+++ b/lib/libc/include/any-linux-any/linux/ethtool_netlink.h
@@ -49,6 +49,14 @@ enum {
ETHTOOL_MSG_PHC_VCLOCKS_GET,
ETHTOOL_MSG_MODULE_GET,
ETHTOOL_MSG_MODULE_SET,
+ ETHTOOL_MSG_PSE_GET,
+ ETHTOOL_MSG_PSE_SET,
+ ETHTOOL_MSG_RSS_GET,
+ ETHTOOL_MSG_PLCA_GET_CFG,
+ ETHTOOL_MSG_PLCA_SET_CFG,
+ ETHTOOL_MSG_PLCA_GET_STATUS,
+ ETHTOOL_MSG_MM_GET,
+ ETHTOOL_MSG_MM_SET,
/* add new constants above here */
__ETHTOOL_MSG_USER_CNT,
@@ -94,6 +102,13 @@ enum {
ETHTOOL_MSG_PHC_VCLOCKS_GET_REPLY,
ETHTOOL_MSG_MODULE_GET_REPLY,
ETHTOOL_MSG_MODULE_NTF,
+ ETHTOOL_MSG_PSE_GET_REPLY,
+ ETHTOOL_MSG_RSS_GET_REPLY,
+ ETHTOOL_MSG_PLCA_GET_CFG_REPLY,
+ ETHTOOL_MSG_PLCA_GET_STATUS_REPLY,
+ ETHTOOL_MSG_PLCA_NTF,
+ ETHTOOL_MSG_MM_GET_REPLY,
+ ETHTOOL_MSG_MM_NTF,
/* add new constants above here */
__ETHTOOL_MSG_KERNEL_CNT,
@@ -242,6 +257,7 @@ enum {
ETHTOOL_A_LINKMODES_MASTER_SLAVE_CFG, /* u8 */
ETHTOOL_A_LINKMODES_MASTER_SLAVE_STATE, /* u8 */
ETHTOOL_A_LINKMODES_LANES, /* u32 */
+ ETHTOOL_A_LINKMODES_RATE_MATCHING, /* u8 */
/* add new constants above here */
__ETHTOOL_A_LINKMODES_CNT,
@@ -258,6 +274,7 @@ enum {
ETHTOOL_A_LINKSTATE_SQI_MAX, /* u32 */
ETHTOOL_A_LINKSTATE_EXT_STATE, /* u8 */
ETHTOOL_A_LINKSTATE_EXT_SUBSTATE, /* u8 */
+ ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT, /* u32 */
/* add new constants above here */
__ETHTOOL_A_LINKSTATE_CNT,
@@ -319,6 +336,12 @@ enum {
/* RINGS */
enum {
+ ETHTOOL_TCP_DATA_SPLIT_UNKNOWN = 0,
+ ETHTOOL_TCP_DATA_SPLIT_DISABLED,
+ ETHTOOL_TCP_DATA_SPLIT_ENABLED,
+};
+
+enum {
ETHTOOL_A_RINGS_UNSPEC,
ETHTOOL_A_RINGS_HEADER, /* nest - _A_HEADER_* */
ETHTOOL_A_RINGS_RX_MAX, /* u32 */
@@ -329,6 +352,11 @@ enum {
ETHTOOL_A_RINGS_RX_MINI, /* u32 */
ETHTOOL_A_RINGS_RX_JUMBO, /* u32 */
ETHTOOL_A_RINGS_TX, /* u32 */
+ ETHTOOL_A_RINGS_RX_BUF_LEN, /* u32 */
+ ETHTOOL_A_RINGS_TCP_DATA_SPLIT, /* u8 */
+ ETHTOOL_A_RINGS_CQE_SIZE, /* u32 */
+ ETHTOOL_A_RINGS_TX_PUSH, /* u8 */
+ ETHTOOL_A_RINGS_RX_PUSH, /* u8 */
/* add new constants above here */
__ETHTOOL_A_RINGS_CNT,
@@ -383,6 +411,9 @@ enum {
ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL, /* u32 */
ETHTOOL_A_COALESCE_USE_CQE_MODE_TX, /* u8 */
ETHTOOL_A_COALESCE_USE_CQE_MODE_RX, /* u8 */
+ ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES, /* u32 */
+ ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES, /* u32 */
+ ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS, /* u32 */
/* add new constants above here */
__ETHTOOL_A_COALESCE_CNT,
@@ -398,6 +429,7 @@ enum {
ETHTOOL_A_PAUSE_RX, /* u8 */
ETHTOOL_A_PAUSE_TX, /* u8 */
ETHTOOL_A_PAUSE_STATS, /* nest - _PAUSE_STAT_* */
+ ETHTOOL_A_PAUSE_STATS_SRC, /* u32 */
/* add new constants above here */
__ETHTOOL_A_PAUSE_CNT,
@@ -714,6 +746,8 @@ enum {
ETHTOOL_A_STATS_GRP, /* nest - _A_STATS_GRP_* */
+ ETHTOOL_A_STATS_SRC, /* u32 */
+
/* add new constants above here */
__ETHTOOL_A_STATS_CNT,
ETHTOOL_A_STATS_MAX = (__ETHTOOL_A_STATS_CNT - 1)
@@ -852,6 +886,93 @@ enum {
ETHTOOL_A_MODULE_MAX = (__ETHTOOL_A_MODULE_CNT - 1)
};
+/* Power Sourcing Equipment */
+enum {
+ ETHTOOL_A_PSE_UNSPEC,
+ ETHTOOL_A_PSE_HEADER, /* nest - _A_HEADER_* */
+ ETHTOOL_A_PODL_PSE_ADMIN_STATE, /* u32 */
+ ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, /* u32 */
+ ETHTOOL_A_PODL_PSE_PW_D_STATUS, /* u32 */
+
+ /* add new constants above here */
+ __ETHTOOL_A_PSE_CNT,
+ ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
+};
+
+enum {
+ ETHTOOL_A_RSS_UNSPEC,
+ ETHTOOL_A_RSS_HEADER,
+ ETHTOOL_A_RSS_CONTEXT, /* u32 */
+ ETHTOOL_A_RSS_HFUNC, /* u32 */
+ ETHTOOL_A_RSS_INDIR, /* binary */
+ ETHTOOL_A_RSS_HKEY, /* binary */
+
+ __ETHTOOL_A_RSS_CNT,
+ ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1),
+};
+
+/* PLCA */
+
+enum {
+ ETHTOOL_A_PLCA_UNSPEC,
+ ETHTOOL_A_PLCA_HEADER, /* nest - _A_HEADER_* */
+ ETHTOOL_A_PLCA_VERSION, /* u16 */
+ ETHTOOL_A_PLCA_ENABLED, /* u8 */
+ ETHTOOL_A_PLCA_STATUS, /* u8 */
+ ETHTOOL_A_PLCA_NODE_CNT, /* u32 */
+ ETHTOOL_A_PLCA_NODE_ID, /* u32 */
+ ETHTOOL_A_PLCA_TO_TMR, /* u32 */
+ ETHTOOL_A_PLCA_BURST_CNT, /* u32 */
+ ETHTOOL_A_PLCA_BURST_TMR, /* u32 */
+
+ /* add new constants above here */
+ __ETHTOOL_A_PLCA_CNT,
+ ETHTOOL_A_PLCA_MAX = (__ETHTOOL_A_PLCA_CNT - 1)
+};
+
+/* MAC Merge (802.3) */
+
+enum {
+ ETHTOOL_A_MM_STAT_UNSPEC,
+ ETHTOOL_A_MM_STAT_PAD,
+
+ /* aMACMergeFrameAssErrorCount */
+ ETHTOOL_A_MM_STAT_REASSEMBLY_ERRORS, /* u64 */
+ /* aMACMergeFrameSmdErrorCount */
+ ETHTOOL_A_MM_STAT_SMD_ERRORS, /* u64 */
+ /* aMACMergeFrameAssOkCount */
+ ETHTOOL_A_MM_STAT_REASSEMBLY_OK, /* u64 */
+ /* aMACMergeFragCountRx */
+ ETHTOOL_A_MM_STAT_RX_FRAG_COUNT, /* u64 */
+ /* aMACMergeFragCountTx */
+ ETHTOOL_A_MM_STAT_TX_FRAG_COUNT, /* u64 */
+ /* aMACMergeHoldCount */
+ ETHTOOL_A_MM_STAT_HOLD_COUNT, /* u64 */
+
+ /* add new constants above here */
+ __ETHTOOL_A_MM_STAT_CNT,
+ ETHTOOL_A_MM_STAT_MAX = (__ETHTOOL_A_MM_STAT_CNT - 1)
+};
+
+enum {
+ ETHTOOL_A_MM_UNSPEC,
+ ETHTOOL_A_MM_HEADER, /* nest - _A_HEADER_* */
+ ETHTOOL_A_MM_PMAC_ENABLED, /* u8 */
+ ETHTOOL_A_MM_TX_ENABLED, /* u8 */
+ ETHTOOL_A_MM_TX_ACTIVE, /* u8 */
+ ETHTOOL_A_MM_TX_MIN_FRAG_SIZE, /* u32 */
+ ETHTOOL_A_MM_RX_MIN_FRAG_SIZE, /* u32 */
+ ETHTOOL_A_MM_VERIFY_ENABLED, /* u8 */
+ ETHTOOL_A_MM_VERIFY_STATUS, /* u8 */
+ ETHTOOL_A_MM_VERIFY_TIME, /* u32 */
+ ETHTOOL_A_MM_MAX_VERIFY_TIME, /* u32 */
+ ETHTOOL_A_MM_STATS, /* nest - _A_MM_STAT_* */
+
+ /* add new constants above here */
+ __ETHTOOL_A_MM_CNT,
+ ETHTOOL_A_MM_MAX = (__ETHTOOL_A_MM_CNT - 1)
+};
+
/* generic netlink info */
#define ETHTOOL_GENL_NAME "ethtool"
#define ETHTOOL_GENL_VERSION 1
diff --git a/lib/libc/include/any-linux-any/linux/eventpoll.h b/lib/libc/include/any-linux-any/linux/eventpoll.h
index f42ad8389b..ad2b5245fb 100644
--- a/lib/libc/include/any-linux-any/linux/eventpoll.h
+++ b/lib/libc/include/any-linux-any/linux/eventpoll.h
@@ -41,6 +41,12 @@
#define EPOLLMSG (__poll_t)0x00000400
#define EPOLLRDHUP (__poll_t)0x00002000
+/*
+ * Internal flag - wakeup generated by io_uring, used to detect recursion back
+ * into the io_uring poll handler.
+ */
+#define EPOLL_URING_WAKE ((__poll_t)(1U << 27))
+
/* Set exclusive wakeup mode for the target file descriptor */
#define EPOLLEXCLUSIVE ((__poll_t)(1U << 28))
diff --git a/lib/libc/include/any-linux-any/linux/f2fs.h b/lib/libc/include/any-linux-any/linux/f2fs.h
index eedb49d0f2..73ef44290f 100644
--- a/lib/libc/include/any-linux-any/linux/f2fs.h
+++ b/lib/libc/include/any-linux-any/linux/f2fs.h
@@ -13,7 +13,7 @@
#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2)
#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3)
#define F2FS_IOC_RELEASE_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 4)
-#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
+#define F2FS_IOC_ABORT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 5)
#define F2FS_IOC_GARBAGE_COLLECT _IOW(F2FS_IOCTL_MAGIC, 6, __u32)
#define F2FS_IOC_WRITE_CHECKPOINT _IO(F2FS_IOCTL_MAGIC, 7)
#define F2FS_IOC_DEFRAGMENT _IOWR(F2FS_IOCTL_MAGIC, 8, \
@@ -42,6 +42,7 @@
struct f2fs_comp_option)
#define F2FS_IOC_DECOMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 23)
#define F2FS_IOC_COMPRESS_FILE _IO(F2FS_IOCTL_MAGIC, 24)
+#define F2FS_IOC_START_ATOMIC_REPLACE _IO(F2FS_IOCTL_MAGIC, 25)
/*
* should be same as XFS_IOC_GOINGDOWN.
diff --git a/lib/libc/include/any-linux-any/linux/fanotify.h b/lib/libc/include/any-linux-any/linux/fanotify.h
index bafe7071e3..b7809e3b50 100644
--- a/lib/libc/include/any-linux-any/linux/fanotify.h
+++ b/lib/libc/include/any-linux-any/linux/fanotify.h
@@ -28,6 +28,8 @@
#define FAN_EVENT_ON_CHILD 0x08000000 /* Interested in child events */
+#define FAN_RENAME 0x10000000 /* File was renamed */
+
#define FAN_ONDIR 0x40000000 /* Event occurred against dir */
/* helper events */
@@ -57,9 +59,13 @@
#define FAN_REPORT_FID 0x00000200 /* Report unique file id */
#define FAN_REPORT_DIR_FID 0x00000400 /* Report unique directory id */
#define FAN_REPORT_NAME 0x00000800 /* Report events with name */
+#define FAN_REPORT_TARGET_FID 0x00001000 /* Report dirent target id */
/* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */
#define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME)
+/* Convenience macro - FAN_REPORT_TARGET_FID requires all other FID flags */
+#define FAN_REPORT_DFID_NAME_TARGET (FAN_REPORT_DFID_NAME | \
+ FAN_REPORT_FID | FAN_REPORT_TARGET_FID)
/* Deprecated - do not use this in programs and do not add new flags here! */
#define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \
@@ -76,12 +82,21 @@
#define FAN_MARK_IGNORED_SURV_MODIFY 0x00000040
#define FAN_MARK_FLUSH 0x00000080
/* FAN_MARK_FILESYSTEM is 0x00000100 */
+#define FAN_MARK_EVICTABLE 0x00000200
+/* This bit is mutually exclusive with FAN_MARK_IGNORED_MASK bit */
+#define FAN_MARK_IGNORE 0x00000400
/* These are NOT bitwise flags. Both bits can be used togther. */
#define FAN_MARK_INODE 0x00000000
#define FAN_MARK_MOUNT 0x00000010
#define FAN_MARK_FILESYSTEM 0x00000100
+/*
+ * Convenience macro - FAN_MARK_IGNORE requires FAN_MARK_IGNORED_SURV_MODIFY
+ * for non-inode mark types.
+ */
+#define FAN_MARK_IGNORE_SURV (FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY)
+
/* Deprecated - do not use this in programs and do not add new flags here! */
#define FAN_ALL_MARK_FLAGS (FAN_MARK_ADD |\
FAN_MARK_REMOVE |\
@@ -128,6 +143,12 @@ struct fanotify_event_metadata {
#define FAN_EVENT_INFO_TYPE_PIDFD 4
#define FAN_EVENT_INFO_TYPE_ERROR 5
+/* Special info types for FAN_RENAME */
+#define FAN_EVENT_INFO_TYPE_OLD_DFID_NAME 10
+/* Reserved for FAN_EVENT_INFO_TYPE_OLD_DFID 11 */
+#define FAN_EVENT_INFO_TYPE_NEW_DFID_NAME 12
+/* Reserved for FAN_EVENT_INFO_TYPE_NEW_DFID 13 */
+
/* Variable length info record following event metadata */
struct fanotify_event_info_header {
__u8 info_type;
@@ -149,7 +170,7 @@ struct fanotify_event_info_fid {
* Following is an opaque struct file_handle that can be passed as
* an argument to open_by_handle_at(2).
*/
- unsigned char handle[0];
+ unsigned char handle[];
};
/*
@@ -167,15 +188,43 @@ struct fanotify_event_info_error {
__u32 error_count;
};
+/*
+ * User space may need to record additional information about its decision.
+ * The extra information type records what kind of information is included.
+ * The default is none. We also define an extra information buffer whose
+ * size is determined by the extra information type.
+ *
+ * If the information type is Audit Rule, then the information following
+ * is the rule number that triggered the user space decision that
+ * requires auditing.
+ */
+
+#define FAN_RESPONSE_INFO_NONE 0
+#define FAN_RESPONSE_INFO_AUDIT_RULE 1
+
struct fanotify_response {
__s32 fd;
__u32 response;
};
+struct fanotify_response_info_header {
+ __u8 type;
+ __u8 pad;
+ __u16 len;
+};
+
+struct fanotify_response_info_audit_rule {
+ struct fanotify_response_info_header hdr;
+ __u32 rule_number;
+ __u32 subj_trust;
+ __u32 obj_trust;
+};
+
/* Legit userspace responses to a _PERM event */
#define FAN_ALLOW 0x01
#define FAN_DENY 0x02
-#define FAN_AUDIT 0x10 /* Bit mask to create audit record for result */
+#define FAN_AUDIT 0x10 /* Bitmask to create audit record for result */
+#define FAN_INFO 0x20 /* Bitmask to indicate additional information */
/* No fd set in event */
#define FAN_NOFD -1
diff --git a/lib/libc/include/any-linux-any/linux/fb.h b/lib/libc/include/any-linux-any/linux/fb.h
index 1d37b7f09a..066a3990d1 100644
--- a/lib/libc/include/any-linux-any/linux/fb.h
+++ b/lib/libc/include/any-linux-any/linux/fb.h
@@ -180,7 +180,7 @@ struct fb_fix_screeninfo {
*
* For pseudocolor: offset and length should be the same for all color
* components. Offset specifies the position of the least significant bit
- * of the pallette index in a pixel value. Length indicates the number
+ * of the palette index in a pixel value. Length indicates the number
* of available palette entries (i.e. # of entries = 1 << length).
*/
struct fb_bitfield {
diff --git a/lib/libc/include/any-linux-any/linux/fcntl.h b/lib/libc/include/any-linux-any/linux/fcntl.h
index 8861ac53a2..e26e01609d 100644
--- a/lib/libc/include/any-linux-any/linux/fcntl.h
+++ b/lib/libc/include/any-linux-any/linux/fcntl.h
@@ -43,6 +43,7 @@
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
#define F_SEAL_WRITE 0x0008 /* prevent writes */
#define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */
+#define F_SEAL_EXEC 0x0020 /* prevent chmod modifying exec bits */
/* (1U << 31) is reserved for signed error codes */
/*
diff --git a/lib/libc/include/any-linux-any/linux/fiemap.h b/lib/libc/include/any-linux-any/linux/fiemap.h
index f14dc7089a..fe6ff75596 100644
--- a/lib/libc/include/any-linux-any/linux/fiemap.h
+++ b/lib/libc/include/any-linux-any/linux/fiemap.h
@@ -34,7 +34,7 @@ struct fiemap {
__u32 fm_mapped_extents;/* number of extents that were mapped (out) */
__u32 fm_extent_count; /* size of fm_extents array (in) */
__u32 fm_reserved;
- struct fiemap_extent fm_extents[0]; /* array of mapped extents (out) */
+ struct fiemap_extent fm_extents[]; /* array of mapped extents (out) */
};
#define FIEMAP_MAX_OFFSET (~0ULL)
diff --git a/lib/libc/include/any-linux-any/linux/firewire-cdev.h b/lib/libc/include/any-linux-any/linux/firewire-cdev.h
index 387bf66f7c..d18813a0c8 100644
--- a/lib/libc/include/any-linux-any/linux/firewire-cdev.h
+++ b/lib/libc/include/any-linux-any/linux/firewire-cdev.h
@@ -118,7 +118,7 @@ struct fw_cdev_event_response {
__u32 type;
__u32 rcode;
__u32 length;
- __u32 data[0];
+ __u32 data[];
};
/**
@@ -142,7 +142,7 @@ struct fw_cdev_event_request {
__u64 offset;
__u32 handle;
__u32 length;
- __u32 data[0];
+ __u32 data[];
};
/**
@@ -205,7 +205,7 @@ struct fw_cdev_event_request2 {
__u32 generation;
__u32 handle;
__u32 length;
- __u32 data[0];
+ __u32 data[];
};
/**
@@ -265,7 +265,7 @@ struct fw_cdev_event_iso_interrupt {
__u32 type;
__u32 cycle;
__u32 header_length;
- __u32 header[0];
+ __u32 header[];
};
/**
@@ -355,7 +355,7 @@ struct fw_cdev_event_phy_packet {
__u32 type;
__u32 rcode;
__u32 length;
- __u32 data[0];
+ __u32 data[];
};
/**
@@ -803,7 +803,7 @@ struct fw_cdev_set_iso_channels {
*/
struct fw_cdev_iso_packet {
__u32 control;
- __u32 header[0];
+ __u32 header[];
};
/**
diff --git a/lib/libc/include/any-linux-any/linux/fou.h b/lib/libc/include/any-linux-any/linux/fou.h
index 58b8a7e247..fb70cbe09f 100644
--- a/lib/libc/include/any-linux-any/linux/fou.h
+++ b/lib/libc/include/any-linux-any/linux/fou.h
@@ -1,32 +1,37 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/* fou.h - FOU Interface */
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* Do not edit directly, auto-generated from: */
+/* Documentation/netlink/specs/fou.yaml */
+/* YNL-GEN uapi header */
#ifndef _LINUX_FOU_H
#define _LINUX_FOU_H
-/* NETLINK_GENERIC related info
- */
#define FOU_GENL_NAME "fou"
-#define FOU_GENL_VERSION 0x1
+#define FOU_GENL_VERSION 1
enum {
- FOU_ATTR_UNSPEC,
- FOU_ATTR_PORT, /* u16 */
- FOU_ATTR_AF, /* u8 */
- FOU_ATTR_IPPROTO, /* u8 */
- FOU_ATTR_TYPE, /* u8 */
- FOU_ATTR_REMCSUM_NOPARTIAL, /* flag */
- FOU_ATTR_LOCAL_V4, /* u32 */
- FOU_ATTR_LOCAL_V6, /* in6_addr */
- FOU_ATTR_PEER_V4, /* u32 */
- FOU_ATTR_PEER_V6, /* in6_addr */
- FOU_ATTR_PEER_PORT, /* u16 */
- FOU_ATTR_IFINDEX, /* s32 */
-
- __FOU_ATTR_MAX,
+ FOU_ENCAP_UNSPEC,
+ FOU_ENCAP_DIRECT,
+ FOU_ENCAP_GUE,
};
-#define FOU_ATTR_MAX (__FOU_ATTR_MAX - 1)
+enum {
+ FOU_ATTR_UNSPEC,
+ FOU_ATTR_PORT,
+ FOU_ATTR_AF,
+ FOU_ATTR_IPPROTO,
+ FOU_ATTR_TYPE,
+ FOU_ATTR_REMCSUM_NOPARTIAL,
+ FOU_ATTR_LOCAL_V4,
+ FOU_ATTR_LOCAL_V6,
+ FOU_ATTR_PEER_V4,
+ FOU_ATTR_PEER_V6,
+ FOU_ATTR_PEER_PORT,
+ FOU_ATTR_IFINDEX,
+
+ __FOU_ATTR_MAX
+};
+#define FOU_ATTR_MAX (__FOU_ATTR_MAX - 1)
enum {
FOU_CMD_UNSPEC,
@@ -34,15 +39,8 @@ enum {
FOU_CMD_DEL,
FOU_CMD_GET,
- __FOU_CMD_MAX,
+ __FOU_CMD_MAX
};
-
-enum {
- FOU_ENCAP_UNSPEC,
- FOU_ENCAP_DIRECT,
- FOU_ENCAP_GUE,
-};
-
-#define FOU_CMD_MAX (__FOU_CMD_MAX - 1)
+#define FOU_CMD_MAX (__FOU_CMD_MAX - 1)
#endif /* _LINUX_FOU_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/fs.h b/lib/libc/include/any-linux-any/linux/fs.h
index 836f45e384..3b04dffabf 100644
--- a/lib/libc/include/any-linux-any/linux/fs.h
+++ b/lib/libc/include/any-linux-any/linux/fs.h
@@ -86,7 +86,7 @@ struct file_dedupe_range {
__u16 dest_count; /* in - total elements in info array */
__u16 reserved1; /* must be zero */
__u32 reserved2; /* must be zero */
- struct file_dedupe_range_info info[0];
+ struct file_dedupe_range_info info[];
};
/* And dynamically-tunable limits and defaults: */
diff --git a/lib/libc/include/any-linux-any/linux/fscrypt.h b/lib/libc/include/any-linux-any/linux/fscrypt.h
index 5c3e81776a..b6b9a739dc 100644
--- a/lib/libc/include/any-linux-any/linux/fscrypt.h
+++ b/lib/libc/include/any-linux-any/linux/fscrypt.h
@@ -26,8 +26,11 @@
#define FSCRYPT_MODE_AES_256_CTS 4
#define FSCRYPT_MODE_AES_128_CBC 5
#define FSCRYPT_MODE_AES_128_CTS 6
+#define FSCRYPT_MODE_SM4_XTS 7
+#define FSCRYPT_MODE_SM4_CTS 8
#define FSCRYPT_MODE_ADIANTUM 9
-/* If adding a mode number > 9, update FSCRYPT_MODE_MAX in fscrypt_private.h */
+#define FSCRYPT_MODE_AES_256_HCTR2 10
+/* If adding a mode number > 10, update FSCRYPT_MODE_MAX in fscrypt_private.h */
/*
* Legacy policy version; ad-hoc KDF and no key verification.
@@ -183,8 +186,6 @@ struct fscrypt_get_key_status_arg {
#define FS_ENCRYPTION_MODE_AES_256_CTS FSCRYPT_MODE_AES_256_CTS
#define FS_ENCRYPTION_MODE_AES_128_CBC FSCRYPT_MODE_AES_128_CBC
#define FS_ENCRYPTION_MODE_AES_128_CTS FSCRYPT_MODE_AES_128_CTS
-#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* removed */
-#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* removed */
#define FS_ENCRYPTION_MODE_ADIANTUM FSCRYPT_MODE_ADIANTUM
#define FS_KEY_DESC_PREFIX FSCRYPT_KEY_DESC_PREFIX
#define FS_KEY_DESC_PREFIX_SIZE FSCRYPT_KEY_DESC_PREFIX_SIZE
diff --git a/lib/libc/include/any-linux-any/linux/fsi.h b/lib/libc/include/any-linux-any/linux/fsi.h
index 091e2613ff..859cf9afcc 100644
--- a/lib/libc/include/any-linux-any/linux/fsi.h
+++ b/lib/libc/include/any-linux-any/linux/fsi.h
@@ -55,4 +55,18 @@ struct scom_access {
#define FSI_SCOM_WRITE _IOWR('s', 0x02, struct scom_access)
#define FSI_SCOM_RESET _IOW('s', 0x03, __u32)
+/*
+ * /dev/sbefifo* ioctl interface
+ */
+
+/**
+ * FSI_SBEFIFO_READ_TIMEOUT sets the read timeout for response from SBE.
+ *
+ * The read timeout is specified in seconds. The minimum value of read
+ * timeout is 10 seconds (default) and the maximum value of read timeout is
+ * 120 seconds. A read timeout of 0 will reset the value to the default of
+ * (10 seconds).
+ */
+#define FSI_SBEFIFO_READ_TIMEOUT_SECONDS _IOW('s', 0x00, __u32)
+
#endif /* _LINUX_FSI_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/fsmap.h b/lib/libc/include/any-linux-any/linux/fsmap.h
index 4158430ee8..15cb713e24 100644
--- a/lib/libc/include/any-linux-any/linux/fsmap.h
+++ b/lib/libc/include/any-linux-any/linux/fsmap.h
@@ -69,7 +69,7 @@ struct fsmap_head {
};
/* Size of an fsmap_head with room for nr records. */
-static __inline__ size_t
+static __inline__ __kernel_size_t
fsmap_sizeof(
unsigned int nr)
{
diff --git a/lib/libc/include/any-linux-any/linux/fuse.h b/lib/libc/include/any-linux-any/linux/fuse.h
index 7a20684e26..713fe11440 100644
--- a/lib/libc/include/any-linux-any/linux/fuse.h
+++ b/lib/libc/include/any-linux-any/linux/fuse.h
@@ -187,6 +187,25 @@
*
* 7.35
* - add FOPEN_NOFLUSH
+ *
+ * 7.36
+ * - extend fuse_init_in with reserved fields, add FUSE_INIT_EXT init flag
+ * - add flags2 to fuse_init_in and fuse_init_out
+ * - add FUSE_SECURITY_CTX init flag
+ * - add security context to create, mkdir, symlink, and mknod requests
+ * - add FUSE_HAS_INODE_DAX, FUSE_ATTR_DAX
+ *
+ * 7.37
+ * - add FUSE_TMPFILE
+ *
+ * 7.38
+ * - add FUSE_EXPIRE_ONLY flag to fuse_notify_inval_entry
+ * - add FOPEN_PARALLEL_DIRECT_WRITES
+ * - add total_extlen to fuse_in_header
+ * - add FUSE_MAX_NR_SECCTX
+ * - add extension header
+ * - add FUSE_EXT_GROUPS
+ * - add FUSE_CREATE_SUPP_GROUP
*/
#ifndef _LINUX_FUSE_H
@@ -218,7 +237,7 @@
#define FUSE_KERNEL_VERSION 7
/** Minor version number of this interface */
-#define FUSE_KERNEL_MINOR_VERSION 35
+#define FUSE_KERNEL_MINOR_VERSION 38
/** The node ID of the root inode */
#define FUSE_ROOT_ID 1
@@ -290,6 +309,7 @@ struct fuse_file_lock {
* FOPEN_CACHE_DIR: allow caching this directory
* FOPEN_STREAM: the file is stream-like (no file position at all)
* FOPEN_NOFLUSH: don't flush data cache on close (unless FUSE_WRITEBACK_CACHE)
+ * FOPEN_PARALLEL_DIRECT_WRITES: Allow concurrent direct writes on the same inode
*/
#define FOPEN_DIRECT_IO (1 << 0)
#define FOPEN_KEEP_CACHE (1 << 1)
@@ -297,6 +317,7 @@ struct fuse_file_lock {
#define FOPEN_CACHE_DIR (1 << 3)
#define FOPEN_STREAM (1 << 4)
#define FOPEN_NOFLUSH (1 << 5)
+#define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6)
/**
* INIT request/reply flags
@@ -337,6 +358,13 @@ struct fuse_file_lock {
* write/truncate sgid is killed only if file has group
* execute permission. (Same as Linux VFS behavior).
* FUSE_SETXATTR_EXT: Server supports extended struct fuse_setxattr_in
+ * FUSE_INIT_EXT: extended fuse_init_in request
+ * FUSE_INIT_RESERVED: reserved, do not use
+ * FUSE_SECURITY_CTX: add security context to create, mkdir, symlink, and
+ * mknod
+ * FUSE_HAS_INODE_DAX: use per inode DAX
+ * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir,
+ * symlink and mknod (single group that matches parent)
*/
#define FUSE_ASYNC_READ (1 << 0)
#define FUSE_POSIX_LOCKS (1 << 1)
@@ -368,6 +396,12 @@ struct fuse_file_lock {
#define FUSE_SUBMOUNTS (1 << 27)
#define FUSE_HANDLE_KILLPRIV_V2 (1 << 28)
#define FUSE_SETXATTR_EXT (1 << 29)
+#define FUSE_INIT_EXT (1 << 30)
+#define FUSE_INIT_RESERVED (1 << 31)
+/* bits 32..63 get shifted down 32 bits into the flags2 field */
+#define FUSE_SECURITY_CTX (1ULL << 32)
+#define FUSE_HAS_INODE_DAX (1ULL << 33)
+#define FUSE_CREATE_SUPP_GROUP (1ULL << 34)
/**
* CUSE INIT request/reply flags
@@ -450,8 +484,10 @@ struct fuse_file_lock {
* fuse_attr flags
*
* FUSE_ATTR_SUBMOUNT: Object is a submount root
+ * FUSE_ATTR_DAX: Enable DAX for this file in per inode DAX mode
*/
#define FUSE_ATTR_SUBMOUNT (1 << 0)
+#define FUSE_ATTR_DAX (1 << 1)
/**
* Open flags
@@ -465,6 +501,23 @@ struct fuse_file_lock {
*/
#define FUSE_SETXATTR_ACL_KILL_SGID (1 << 0)
+/**
+ * notify_inval_entry flags
+ * FUSE_EXPIRE_ONLY
+ */
+#define FUSE_EXPIRE_ONLY (1 << 0)
+
+/**
+ * extension type
+ * FUSE_MAX_NR_SECCTX: maximum value of &fuse_secctx_header.nr_secctx
+ * FUSE_EXT_GROUPS: &fuse_supp_groups extension
+ */
+enum fuse_ext_type {
+ /* Types 0..31 are reserved for fuse_secctx_header */
+ FUSE_MAX_NR_SECCTX = 31,
+ FUSE_EXT_GROUPS = 32,
+};
+
enum fuse_opcode {
FUSE_LOOKUP = 1,
FUSE_FORGET = 2, /* no reply */
@@ -514,6 +567,7 @@ enum fuse_opcode {
FUSE_SETUPMAPPING = 48,
FUSE_REMOVEMAPPING = 49,
FUSE_SYNCFS = 50,
+ FUSE_TMPFILE = 51,
/* CUSE specific operations */
CUSE_INIT = 4096,
@@ -737,6 +791,8 @@ struct fuse_init_in {
uint32_t minor;
uint32_t max_readahead;
uint32_t flags;
+ uint32_t flags2;
+ uint32_t unused[11];
};
#define FUSE_COMPAT_INIT_OUT_SIZE 8
@@ -753,7 +809,8 @@ struct fuse_init_out {
uint32_t time_gran;
uint16_t max_pages;
uint16_t map_alignment;
- uint32_t unused[8];
+ uint32_t flags2;
+ uint32_t unused[7];
};
#define CUSE_INIT_INFO_MAX 4096
@@ -844,7 +901,8 @@ struct fuse_in_header {
uint32_t uid;
uint32_t gid;
uint32_t pid;
- uint32_t padding;
+ uint16_t total_extlen; /* length of extensions in 8byte units */
+ uint16_t padding;
};
struct fuse_out_header {
@@ -861,9 +919,12 @@ struct fuse_dirent {
char name[];
};
-#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
-#define FUSE_DIRENT_ALIGN(x) \
+/* Align variable length records to 64bit boundary */
+#define FUSE_REC_ALIGN(x) \
(((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
+
+#define FUSE_NAME_OFFSET offsetof(struct fuse_dirent, name)
+#define FUSE_DIRENT_ALIGN(x) FUSE_REC_ALIGN(x)
#define FUSE_DIRENT_SIZE(d) \
FUSE_DIRENT_ALIGN(FUSE_NAME_OFFSET + (d)->namelen)
@@ -886,7 +947,7 @@ struct fuse_notify_inval_inode_out {
struct fuse_notify_inval_entry_out {
uint64_t parent;
uint32_t namelen;
- uint32_t padding;
+ uint32_t flags;
};
struct fuse_notify_delete_out {
@@ -980,4 +1041,49 @@ struct fuse_syncfs_in {
uint64_t padding;
};
+/*
+ * For each security context, send fuse_secctx with size of security context
+ * fuse_secctx will be followed by security context name and this in turn
+ * will be followed by actual context label.
+ * fuse_secctx, name, context
+ */
+struct fuse_secctx {
+ uint32_t size;
+ uint32_t padding;
+};
+
+/*
+ * Contains the information about how many fuse_secctx structures are being
+ * sent and what's the total size of all security contexts (including
+ * size of fuse_secctx_header).
+ *
+ */
+struct fuse_secctx_header {
+ uint32_t size;
+ uint32_t nr_secctx;
+};
+
+/**
+ * struct fuse_ext_header - extension header
+ * @size: total size of this extension including this header
+ * @type: type of extension
+ *
+ * This is made compatible with fuse_secctx_header by using type values >
+ * FUSE_MAX_NR_SECCTX
+ */
+struct fuse_ext_header {
+ uint32_t size;
+ uint32_t type;
+};
+
+/**
+ * struct fuse_supp_groups - Supplementary group extension
+ * @nr_groups: number of supplementary groups
+ * @groups: flexible array of group IDs
+ */
+struct fuse_supp_groups {
+ uint32_t nr_groups;
+ uint32_t groups[];
+};
+
#endif /* _LINUX_FUSE_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/genetlink.h b/lib/libc/include/any-linux-any/linux/genetlink.h
index 7a59668bba..b98771eb29 100644
--- a/lib/libc/include/any-linux-any/linux/genetlink.h
+++ b/lib/libc/include/any-linux-any/linux/genetlink.h
@@ -87,6 +87,8 @@ enum {
__CTRL_ATTR_MCAST_GRP_MAX,
};
+#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
+
enum {
CTRL_ATTR_POLICY_UNSPEC,
CTRL_ATTR_POLICY_DO,
@@ -96,7 +98,6 @@ enum {
CTRL_ATTR_POLICY_DUMP_MAX = __CTRL_ATTR_POLICY_DUMP_MAX - 1
};
-#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
-
+#define CTRL_ATTR_POLICY_MAX (__CTRL_ATTR_POLICY_DUMP_MAX - 1)
#endif /* __LINUX_GENERIC_NETLINK_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/gpio.h b/lib/libc/include/any-linux-any/linux/gpio.h
index e482ee8bf0..dbde386399 100644
--- a/lib/libc/include/any-linux-any/linux/gpio.h
+++ b/lib/libc/include/any-linux-any/linux/gpio.h
@@ -66,6 +66,8 @@ struct gpiochip_info {
* @GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN: line has pull-down bias enabled
* @GPIO_V2_LINE_FLAG_BIAS_DISABLED: line has bias disabled
* @GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME: line events contain REALTIME timestamps
+ * @GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE: line events contain timestamps from
+ * hardware timestamp engine
*/
enum gpio_v2_line_flag {
GPIO_V2_LINE_FLAG_USED = _BITULL(0),
@@ -80,6 +82,7 @@ enum gpio_v2_line_flag {
GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN = _BITULL(9),
GPIO_V2_LINE_FLAG_BIAS_DISABLED = _BITULL(10),
GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME = _BITULL(11),
+ GPIO_V2_LINE_FLAG_EVENT_CLOCK_HTE = _BITULL(12),
};
/**
diff --git a/lib/libc/include/any-linux-any/linux/gsmmux.h b/lib/libc/include/any-linux-any/linux/gsmmux.h
index f814f4ff1f..6bc35cfb56 100644
--- a/lib/libc/include/any-linux-any/linux/gsmmux.h
+++ b/lib/libc/include/any-linux-any/linux/gsmmux.h
@@ -19,8 +19,7 @@ struct gsm_config
unsigned int mtu;
unsigned int k;
unsigned int i;
- unsigned int unused[8]; /* Padding for expansion without
- breaking stuff */
+ unsigned int unused[8]; /* Can not be used */
};
#define GSMIOC_GETCONF _IOR('G', 0, struct gsm_config)
@@ -29,9 +28,9 @@ struct gsm_config
struct gsm_netconfig {
unsigned int adaption; /* Adaption to use in network mode */
unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */
- unsigned short unused2;
+ unsigned short unused2; /* Can not be used */
char if_name[IFNAMSIZ]; /* interface name format string */
- __u8 unused[28]; /* For future use */
+ __u8 unused[28]; /* Can not be used */
};
#define GSMIOC_ENABLE_NET _IOW('G', 2, struct gsm_netconfig)
@@ -40,4 +39,14 @@ struct gsm_netconfig {
/* get the base tty number for a configured gsmmux tty */
#define GSMIOC_GETFIRST _IOR('G', 4, __u32)
+struct gsm_config_ext {
+ __u32 keep_alive; /* Control channel keep-alive in 1/100th of a
+ * second (0 to disable)
+ */
+ __u32 reserved[7]; /* For future use, must be initialized to zero */
+};
+
+#define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext)
+#define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext)
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/gtp.h b/lib/libc/include/any-linux-any/linux/gtp.h
index c5d22e8fce..ae9623ff69 100644
--- a/lib/libc/include/any-linux-any/linux/gtp.h
+++ b/lib/libc/include/any-linux-any/linux/gtp.h
@@ -8,6 +8,7 @@ enum gtp_genl_cmds {
GTP_CMD_NEWPDP,
GTP_CMD_DELPDP,
GTP_CMD_GETPDP,
+ GTP_CMD_ECHOREQ,
GTP_CMD_MAX,
};
diff --git a/lib/libc/include/any-linux-any/linux/hid.h b/lib/libc/include/any-linux-any/linux/hid.h
index 9123ad1184..b582347636 100644
--- a/lib/libc/include/any-linux-any/linux/hid.h
+++ b/lib/libc/include/any-linux-any/linux/hid.h
@@ -43,15 +43,29 @@
#define USB_INTERFACE_PROTOCOL_MOUSE 2
/*
+ * HID report types --- Ouch! HID spec says 1 2 3!
+ */
+
+enum hid_report_type {
+ HID_INPUT_REPORT = 0,
+ HID_OUTPUT_REPORT = 1,
+ HID_FEATURE_REPORT = 2,
+
+ HID_REPORT_TYPES,
+};
+
+/*
* HID class requests
*/
-#define HID_REQ_GET_REPORT 0x01
-#define HID_REQ_GET_IDLE 0x02
-#define HID_REQ_GET_PROTOCOL 0x03
-#define HID_REQ_SET_REPORT 0x09
-#define HID_REQ_SET_IDLE 0x0A
-#define HID_REQ_SET_PROTOCOL 0x0B
+enum hid_class_request {
+ HID_REQ_GET_REPORT = 0x01,
+ HID_REQ_GET_IDLE = 0x02,
+ HID_REQ_GET_PROTOCOL = 0x03,
+ HID_REQ_SET_REPORT = 0x09,
+ HID_REQ_SET_IDLE = 0x0A,
+ HID_REQ_SET_PROTOCOL = 0x0B,
+};
/*
* HID class descriptor types
diff --git a/lib/libc/include/any-linux-any/linux/hsi/cs-protocol.h b/lib/libc/include/any-linux-any/linux/hsi/cs-protocol.h
index d98a4a6b3b..d3d215bdee 100644
--- a/lib/libc/include/any-linux-any/linux/hsi/cs-protocol.h
+++ b/lib/libc/include/any-linux-any/linux/hsi/cs-protocol.h
@@ -6,20 +6,6 @@
*
* Contact: Kai Vehmanen <kai.vehmanen@nokia.com>
* Original author: Peter Ujfalusi <peter.ujfalusi@nokia.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
*/
#ifndef _CS_PROTOCOL_H
diff --git a/lib/libc/include/any-linux-any/linux/hsi/hsi_char.h b/lib/libc/include/any-linux-any/linux/hsi/hsi_char.h
index cd6ce7c474..d3c41d4ea1 100644
--- a/lib/libc/include/any-linux-any/linux/hsi/hsi_char.h
+++ b/lib/libc/include/any-linux-any/linux/hsi/hsi_char.h
@@ -5,20 +5,6 @@
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
*
* Contact: Andras Domokos <andras.domokos at nokia.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
*/
#ifndef __HSI_CHAR_H
diff --git a/lib/libc/include/any-linux-any/linux/hyperv.h b/lib/libc/include/any-linux-any/linux/hyperv.h
index f210fa4329..8aa0c8b62f 100644
--- a/lib/libc/include/any-linux-any/linux/hyperv.h
+++ b/lib/libc/include/any-linux-any/linux/hyperv.h
@@ -90,6 +90,17 @@ struct hv_vss_check_dm_info {
__u32 flags;
} __attribute__((packed));
+/*
+ * struct hv_vss_msg encodes the fields that the Linux VSS
+ * driver accesses. However, FREEZE messages from Hyper-V contain
+ * additional LUN information that Linux doesn't use and are not
+ * represented in struct hv_vss_msg. A received FREEZE message may
+ * be as large as 6,260 bytes, so the driver must allocate at least
+ * that much space, not sizeof(struct hv_vss_msg). Other messages
+ * such as AUTO_RECOVER may be as large as 12,500 bytes. However,
+ * because the Linux VSS driver responds that it doesn't support
+ * auto-recovery, it should not receive such messages.
+ */
struct hv_vss_msg {
union {
struct hv_vss_hdr vss_hdr;
diff --git a/lib/libc/include/any-linux-any/linux/idxd.h b/lib/libc/include/any-linux-any/linux/idxd.h
index 5d86b1dbd5..b452aecdc1 100644
--- a/lib/libc/include/any-linux-any/linux/idxd.h
+++ b/lib/libc/include/any-linux-any/linux/idxd.h
@@ -24,6 +24,8 @@ enum idxd_scmd_stat {
IDXD_SCMD_WQ_NONE_CONFIGURED = 0x800d0000,
IDXD_SCMD_WQ_NO_SIZE = 0x800e0000,
IDXD_SCMD_WQ_NO_PRIV = 0x800f0000,
+ IDXD_SCMD_WQ_IRQ_ERR = 0x80100000,
+ IDXD_SCMD_WQ_USER_NO_IOMMU = 0x80110000,
};
#define IDXD_SCMD_SOFTERR_MASK 0x80000000
@@ -48,6 +50,11 @@ enum idxd_scmd_stat {
/* IAX */
#define IDXD_OP_FLAG_RD_SRC2_AECS 0x010000
+#define IDXD_OP_FLAG_RD_SRC2_2ND 0x020000
+#define IDXD_OP_FLAG_WR_SRC2_AECS_COMP 0x040000
+#define IDXD_OP_FLAG_WR_SRC2_AECS_OVFL 0x080000
+#define IDXD_OP_FLAG_SRC2_STS 0x100000
+#define IDXD_OP_FLAG_CRC_RFC3720 0x200000
/* Opcode */
enum dsa_opcode {
@@ -76,6 +83,18 @@ enum iax_opcode {
IAX_OPCODE_MEMMOVE,
IAX_OPCODE_DECOMPRESS = 0x42,
IAX_OPCODE_COMPRESS,
+ IAX_OPCODE_CRC64,
+ IAX_OPCODE_ZERO_DECOMP_32 = 0x48,
+ IAX_OPCODE_ZERO_DECOMP_16,
+ IAX_OPCODE_ZERO_COMP_32 = 0x4c,
+ IAX_OPCODE_ZERO_COMP_16,
+ IAX_OPCODE_SCAN = 0x50,
+ IAX_OPCODE_SET_MEMBER,
+ IAX_OPCODE_EXTRACT,
+ IAX_OPCODE_SELECT,
+ IAX_OPCODE_RLE_BURST,
+ IAX_OPCODE_FIND_UNIQUE,
+ IAX_OPCODE_EXPAND,
};
/* Completion record status */
@@ -115,6 +134,7 @@ enum iax_completion_status {
IAX_COMP_NONE = 0,
IAX_COMP_SUCCESS,
IAX_COMP_PAGE_FAULT_IR = 0x04,
+ IAX_COMP_ANALYTICS_ERROR = 0x0a,
IAX_COMP_OUTBUF_OVERFLOW,
IAX_COMP_BAD_OPCODE = 0x10,
IAX_COMP_INVALID_FLAGS,
@@ -135,7 +155,10 @@ enum iax_completion_status {
IAX_COMP_WATCHDOG,
IAX_COMP_INVALID_COMP_FLAG = 0x30,
IAX_COMP_INVALID_FILTER_FLAG,
- IAX_COMP_INVALID_NUM_ELEMS = 0x33,
+ IAX_COMP_INVALID_INPUT_SIZE,
+ IAX_COMP_INVALID_NUM_ELEMS,
+ IAX_COMP_INVALID_SRC1_WIDTH,
+ IAX_COMP_INVALID_INVERT_OUT,
};
#define DSA_COMP_STATUS_MASK 0x7f
@@ -268,7 +291,7 @@ struct dsa_completion_record {
};
uint32_t delta_rec_size;
- uint32_t crc_val;
+ uint64_t crc_val;
/* DIF check & strip */
struct {
@@ -314,8 +337,12 @@ struct iax_completion_record {
uint32_t output_size;
uint8_t output_bits;
uint8_t rsvd3;
- uint16_t rsvd4;
- uint64_t rsvd5[4];
+ uint16_t xor_csum;
+ uint32_t crc;
+ uint32_t min;
+ uint32_t max;
+ uint32_t sum;
+ uint64_t rsvd4[2];
} __attribute__((packed));
struct iax_raw_completion_record {
diff --git a/lib/libc/include/any-linux-any/linux/if_addr.h b/lib/libc/include/any-linux-any/linux/if_addr.h
index 1f5512bf3c..f951fd30c2 100644
--- a/lib/libc/include/any-linux-any/linux/if_addr.h
+++ b/lib/libc/include/any-linux-any/linux/if_addr.h
@@ -33,8 +33,9 @@ enum {
IFA_CACHEINFO,
IFA_MULTICAST,
IFA_FLAGS,
- IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
+ IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
IFA_TARGET_NETNSID,
+ IFA_PROTO, /* u8, address protocol */
__IFA_MAX,
};
@@ -67,4 +68,10 @@ struct ifa_cacheinfo {
#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
+/* ifa_proto */
+#define IFAPROT_UNSPEC 0
+#define IFAPROT_KERNEL_LO 1 /* loopback */
+#define IFAPROT_KERNEL_RA 2 /* set by kernel from router announcement */
+#define IFAPROT_KERNEL_LL 3 /* link-local set by kernel */
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/if_alg.h b/lib/libc/include/any-linux-any/linux/if_alg.h
index 55652e56aa..afda35eeaa 100644
--- a/lib/libc/include/any-linux-any/linux/if_alg.h
+++ b/lib/libc/include/any-linux-any/linux/if_alg.h
@@ -42,7 +42,7 @@ struct sockaddr_alg_new {
struct af_alg_iv {
__u32 ivlen;
- __u8 iv[0];
+ __u8 iv[];
};
/* Socket options */
@@ -52,6 +52,7 @@ struct af_alg_iv {
#define ALG_SET_AEAD_ASSOCLEN 4
#define ALG_SET_AEAD_AUTHSIZE 5
#define ALG_SET_DRBG_ENTROPY 6
+#define ALG_SET_KEY_BY_KEY_SERIAL 7
/* Operations */
#define ALG_OP_DECRYPT 0
diff --git a/lib/libc/include/any-linux-any/linux/if_arcnet.h b/lib/libc/include/any-linux-any/linux/if_arcnet.h
index a8ca6f308f..a3bed942d6 100644
--- a/lib/libc/include/any-linux-any/linux/if_arcnet.h
+++ b/lib/libc/include/any-linux-any/linux/if_arcnet.h
@@ -60,7 +60,7 @@ struct arc_rfc1201 {
__u8 proto; /* protocol ID field - varies */
__u8 split_flag; /* for use with split packets */
__be16 sequence; /* sequence number */
- __u8 payload[0]; /* space remaining in packet (504 bytes)*/
+ __u8 payload[]; /* space remaining in packet (504 bytes)*/
};
#define RFC1201_HDR_SIZE 4
@@ -69,7 +69,7 @@ struct arc_rfc1201 {
*/
struct arc_rfc1051 {
__u8 proto; /* ARC_P_RFC1051_ARP/RFC1051_IP */
- __u8 payload[0]; /* 507 bytes */
+ __u8 payload[]; /* 507 bytes */
};
#define RFC1051_HDR_SIZE 1
@@ -80,7 +80,7 @@ struct arc_rfc1051 {
struct arc_eth_encap {
__u8 proto; /* Always ARC_P_ETHER */
struct ethhdr eth; /* standard ethernet header (yuck!) */
- __u8 payload[0]; /* 493 bytes */
+ __u8 payload[]; /* 493 bytes */
};
#define ETH_ENCAP_HDR_SIZE 14
diff --git a/lib/libc/include/any-linux-any/linux/if_bridge.h b/lib/libc/include/any-linux-any/linux/if_bridge.h
index 0d5e48b519..a3ec77adc3 100644
--- a/lib/libc/include/any-linux-any/linux/if_bridge.h
+++ b/lib/libc/include/any-linux-any/linux/if_bridge.h
@@ -122,6 +122,7 @@ enum {
IFLA_BRIDGE_VLAN_TUNNEL_INFO,
IFLA_BRIDGE_MRP,
IFLA_BRIDGE_CFM,
+ IFLA_BRIDGE_MST,
__IFLA_BRIDGE_MAX,
};
#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
@@ -453,6 +454,21 @@ enum {
#define IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX (__IFLA_BRIDGE_CFM_CC_PEER_STATUS_MAX - 1)
+enum {
+ IFLA_BRIDGE_MST_UNSPEC,
+ IFLA_BRIDGE_MST_ENTRY,
+ __IFLA_BRIDGE_MST_MAX,
+};
+#define IFLA_BRIDGE_MST_MAX (__IFLA_BRIDGE_MST_MAX - 1)
+
+enum {
+ IFLA_BRIDGE_MST_ENTRY_UNSPEC,
+ IFLA_BRIDGE_MST_ENTRY_MSTI,
+ IFLA_BRIDGE_MST_ENTRY_STATE,
+ __IFLA_BRIDGE_MST_ENTRY_MAX,
+};
+#define IFLA_BRIDGE_MST_ENTRY_MAX (__IFLA_BRIDGE_MST_ENTRY_MAX - 1)
+
struct bridge_stp_xstats {
__u64 transition_blk;
__u64 transition_fwd;
@@ -507,6 +523,8 @@ enum {
BRIDGE_VLANDB_ENTRY_TUNNEL_INFO,
BRIDGE_VLANDB_ENTRY_STATS,
BRIDGE_VLANDB_ENTRY_MCAST_ROUTER,
+ BRIDGE_VLANDB_ENTRY_MCAST_N_GROUPS,
+ BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS,
__BRIDGE_VLANDB_ENTRY_MAX,
};
#define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1)
@@ -564,6 +582,7 @@ enum {
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER,
BRIDGE_VLANDB_GOPTS_MCAST_ROUTER_PORTS,
BRIDGE_VLANDB_GOPTS_MCAST_QUERIER_STATE,
+ BRIDGE_VLANDB_GOPTS_MSTI,
__BRIDGE_VLANDB_GOPTS_MAX
};
#define BRIDGE_VLANDB_GOPTS_MAX (__BRIDGE_VLANDB_GOPTS_MAX - 1)
@@ -706,10 +725,31 @@ enum {
enum {
MDBE_ATTR_UNSPEC,
MDBE_ATTR_SOURCE,
+ MDBE_ATTR_SRC_LIST,
+ MDBE_ATTR_GROUP_MODE,
+ MDBE_ATTR_RTPROT,
__MDBE_ATTR_MAX,
};
#define MDBE_ATTR_MAX (__MDBE_ATTR_MAX - 1)
+/* per mdb entry source */
+enum {
+ MDBE_SRC_LIST_UNSPEC,
+ MDBE_SRC_LIST_ENTRY,
+ __MDBE_SRC_LIST_MAX,
+};
+#define MDBE_SRC_LIST_MAX (__MDBE_SRC_LIST_MAX - 1)
+
+/* per mdb entry per source attributes
+ * these are embedded in MDBE_SRC_LIST_ENTRY
+ */
+enum {
+ MDBE_SRCATTR_UNSPEC,
+ MDBE_SRCATTR_ADDRESS,
+ __MDBE_SRCATTR_MAX,
+};
+#define MDBE_SRCATTR_MAX (__MDBE_SRCATTR_MAX - 1)
+
/* Embedded inside LINK_XSTATS_TYPE_BRIDGE */
enum {
BRIDGE_XSTATS_UNSPEC,
@@ -759,6 +799,7 @@ struct br_mcast_stats {
enum br_boolopt_id {
BR_BOOLOPT_NO_LL_LEARN,
BR_BOOLOPT_MCAST_VLAN_SNOOPING,
+ BR_BOOLOPT_MST_ENABLE,
BR_BOOLOPT_MAX
};
diff --git a/lib/libc/include/any-linux-any/linux/if_ether.h b/lib/libc/include/any-linux-any/linux/if_ether.h
index 53b8462712..7af9ced28b 100644
--- a/lib/libc/include/any-linux-any/linux/if_ether.h
+++ b/lib/libc/include/any-linux-any/linux/if_ether.h
@@ -86,8 +86,10 @@
* over Ethernet
*/
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#define ETH_P_PROFINET 0x8892 /* PROFINET */
#define ETH_P_REALTEK 0x8899 /* Multiple proprietary protocols */
#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
+#define ETH_P_ETHERCAT 0x88A4 /* EtherCAT */
#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
#define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */
#define ETH_P_PREAUTH 0x88C7 /* 802.11 Preauthentication */
@@ -114,6 +116,7 @@
#define ETH_P_QINQ3 0x9300 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_DSA_8021Q 0xDADB /* Fake VLAN Header for DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
+#define ETH_P_DSA_A5PSW 0xE001 /* A5PSW Tag Value [ NOT AN OFFICIALLY REGISTERED ID ] */
#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */
#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */
@@ -135,6 +138,7 @@
#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
#define ETH_P_CAN 0x000C /* CAN: Controller Area Network */
#define ETH_P_CANFD 0x000D /* CANFD: CAN flexible data rate*/
+#define ETH_P_CANXL 0x000E /* CANXL: eXtended frame Length */
#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
diff --git a/lib/libc/include/any-linux-any/linux/if_link.h b/lib/libc/include/any-linux-any/linux/if_link.h
index 0a7e0973be..aec361cf35 100644
--- a/lib/libc/include/any-linux-any/linux/if_link.h
+++ b/lib/libc/include/any-linux-any/linux/if_link.h
@@ -211,6 +211,9 @@ struct rtnl_link_stats {
* @rx_nohandler: Number of packets received on the interface
* but dropped by the networking stack because the device is
* not designated to receive packets (e.g. backup link in a bond).
+ *
+ * @rx_otherhost_dropped: Number of packets dropped due to mismatch
+ * in destination MAC address.
*/
struct rtnl_link_stats64 {
__u64 rx_packets;
@@ -243,6 +246,23 @@ struct rtnl_link_stats64 {
__u64 rx_compressed;
__u64 tx_compressed;
__u64 rx_nohandler;
+
+ __u64 rx_otherhost_dropped;
+};
+
+/* Subset of link stats useful for in-HW collection. Meaning of the fields is as
+ * for struct rtnl_link_stats64.
+ */
+struct rtnl_hw_stats64 {
+ __u64 rx_packets;
+ __u64 tx_packets;
+ __u64 rx_bytes;
+ __u64 tx_bytes;
+ __u64 rx_errors;
+ __u64 tx_errors;
+ __u64 rx_dropped;
+ __u64 tx_dropped;
+ __u64 multicast;
};
/* The struct should be in sync with struct ifmap */
@@ -347,6 +367,15 @@ enum {
*/
IFLA_PARENT_DEV_NAME,
IFLA_PARENT_DEV_BUS_NAME,
+ IFLA_GRO_MAX_SIZE,
+ IFLA_TSO_MAX_SIZE,
+ IFLA_TSO_MAX_SEGS,
+ IFLA_ALLMULTI, /* Allmulti count: > 0 means acts ALLMULTI */
+
+ IFLA_DEVLINK_PORT,
+
+ IFLA_GSO_IPV4_MAX_SIZE,
+ IFLA_GRO_IPV4_MAX_SIZE,
__IFLA_MAX
};
@@ -534,6 +563,10 @@ enum {
IFLA_BRPORT_MRP_IN_OPEN,
IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
+ IFLA_BRPORT_LOCKED,
+ IFLA_BRPORT_MAB,
+ IFLA_BRPORT_MCAST_N_GROUPS,
+ IFLA_BRPORT_MCAST_MAX_GROUPS,
__IFLA_BRPORT_MAX
};
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
@@ -668,6 +701,7 @@ enum {
IFLA_XFRM_UNSPEC,
IFLA_XFRM_LINK,
IFLA_XFRM_IF_ID,
+ IFLA_XFRM_COLLECT_METADATA,
__IFLA_XFRM_MAX
};
@@ -709,7 +743,55 @@ enum ipvlan_mode {
#define IPVLAN_F_PRIVATE 0x01
#define IPVLAN_F_VEPA 0x02
+/* Tunnel RTM header */
+struct tunnel_msg {
+ __u8 family;
+ __u8 flags;
+ __u16 reserved2;
+ __u32 ifindex;
+};
+
/* VXLAN section */
+
+/* include statistics in the dump */
+#define TUNNEL_MSG_FLAG_STATS 0x01
+
+#define TUNNEL_MSG_VALID_USER_FLAGS TUNNEL_MSG_FLAG_STATS
+
+/* Embedded inside VXLAN_VNIFILTER_ENTRY_STATS */
+enum {
+ VNIFILTER_ENTRY_STATS_UNSPEC,
+ VNIFILTER_ENTRY_STATS_RX_BYTES,
+ VNIFILTER_ENTRY_STATS_RX_PKTS,
+ VNIFILTER_ENTRY_STATS_RX_DROPS,
+ VNIFILTER_ENTRY_STATS_RX_ERRORS,
+ VNIFILTER_ENTRY_STATS_TX_BYTES,
+ VNIFILTER_ENTRY_STATS_TX_PKTS,
+ VNIFILTER_ENTRY_STATS_TX_DROPS,
+ VNIFILTER_ENTRY_STATS_TX_ERRORS,
+ VNIFILTER_ENTRY_STATS_PAD,
+ __VNIFILTER_ENTRY_STATS_MAX
+};
+#define VNIFILTER_ENTRY_STATS_MAX (__VNIFILTER_ENTRY_STATS_MAX - 1)
+
+enum {
+ VXLAN_VNIFILTER_ENTRY_UNSPEC,
+ VXLAN_VNIFILTER_ENTRY_START,
+ VXLAN_VNIFILTER_ENTRY_END,
+ VXLAN_VNIFILTER_ENTRY_GROUP,
+ VXLAN_VNIFILTER_ENTRY_GROUP6,
+ VXLAN_VNIFILTER_ENTRY_STATS,
+ __VXLAN_VNIFILTER_ENTRY_MAX
+};
+#define VXLAN_VNIFILTER_ENTRY_MAX (__VXLAN_VNIFILTER_ENTRY_MAX - 1)
+
+enum {
+ VXLAN_VNIFILTER_UNSPEC,
+ VXLAN_VNIFILTER_ENTRY,
+ __VXLAN_VNIFILTER_MAX
+};
+#define VXLAN_VNIFILTER_MAX (__VXLAN_VNIFILTER_MAX - 1)
+
enum {
IFLA_VXLAN_UNSPEC,
IFLA_VXLAN_ID,
@@ -741,6 +823,7 @@ enum {
IFLA_VXLAN_GPE,
IFLA_VXLAN_TTL_INHERIT,
IFLA_VXLAN_DF,
+ IFLA_VXLAN_VNIFILTER, /* only applicable with COLLECT_METADATA mode */
__IFLA_VXLAN_MAX
};
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
@@ -774,6 +857,7 @@ enum {
IFLA_GENEVE_LABEL,
IFLA_GENEVE_TTL_INHERIT,
IFLA_GENEVE_DF,
+ IFLA_GENEVE_INNER_PROTO_INHERIT,
__IFLA_GENEVE_MAX
};
#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
@@ -819,6 +903,8 @@ enum {
IFLA_GTP_FD1,
IFLA_GTP_PDP_HASHSIZE,
IFLA_GTP_ROLE,
+ IFLA_GTP_CREATE_SOCKETS,
+ IFLA_GTP_RESTART_COUNT,
__IFLA_GTP_MAX,
};
#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
@@ -856,6 +942,8 @@ enum {
IFLA_BOND_TLB_DYNAMIC_LB,
IFLA_BOND_PEER_NOTIF_DELAY,
IFLA_BOND_AD_LACP_ACTIVE,
+ IFLA_BOND_MISSED_MAX,
+ IFLA_BOND_NS_IP6_TARGET,
__IFLA_BOND_MAX,
};
@@ -883,6 +971,7 @@ enum {
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID,
IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE,
IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE,
+ IFLA_BOND_SLAVE_PRIO,
__IFLA_BOND_SLAVE_MAX,
};
@@ -1152,6 +1241,17 @@ enum {
#define IFLA_STATS_FILTER_BIT(ATTR) (1 << (ATTR - 1))
+enum {
+ IFLA_STATS_GETSET_UNSPEC,
+ IFLA_STATS_GET_FILTERS, /* Nest of IFLA_STATS_LINK_xxx, each a u32 with
+ * a filter mask for the corresponding group.
+ */
+ IFLA_STATS_SET_OFFLOAD_XSTATS_L3_STATS, /* 0 or 1 as u8 */
+ __IFLA_STATS_GETSET_MAX,
+};
+
+#define IFLA_STATS_GETSET_MAX (__IFLA_STATS_GETSET_MAX - 1)
+
/* These are embedded into IFLA_STATS_LINK_XSTATS:
* [IFLA_STATS_LINK_XSTATS]
* -> [LINK_XSTATS_TYPE_xxx]
@@ -1169,10 +1269,21 @@ enum {
enum {
IFLA_OFFLOAD_XSTATS_UNSPEC,
IFLA_OFFLOAD_XSTATS_CPU_HIT, /* struct rtnl_link_stats64 */
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO, /* HW stats info. A nest */
+ IFLA_OFFLOAD_XSTATS_L3_STATS, /* struct rtnl_hw_stats64 */
__IFLA_OFFLOAD_XSTATS_MAX
};
#define IFLA_OFFLOAD_XSTATS_MAX (__IFLA_OFFLOAD_XSTATS_MAX - 1)
+enum {
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_UNSPEC,
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_REQUEST, /* u8 */
+ IFLA_OFFLOAD_XSTATS_HW_S_INFO_USED, /* u8 */
+ __IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX,
+};
+#define IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX \
+ (__IFLA_OFFLOAD_XSTATS_HW_S_INFO_MAX - 1)
+
/* XDP section */
#define XDP_FLAGS_UPDATE_IF_NOEXIST (1U << 0)
@@ -1271,4 +1382,14 @@ enum {
#define IFLA_MCTP_MAX (__IFLA_MCTP_MAX - 1)
+/* DSA section */
+
+enum {
+ IFLA_DSA_UNSPEC,
+ IFLA_DSA_MASTER,
+ __IFLA_DSA_MAX,
+};
+
+#define IFLA_DSA_MAX (__IFLA_DSA_MAX - 1)
+
#endif /* _LINUX_IF_LINK_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/if_macsec.h b/lib/libc/include/any-linux-any/linux/if_macsec.h
index 64093fd8ca..bb74210d23 100644
--- a/lib/libc/include/any-linux-any/linux/if_macsec.h
+++ b/lib/libc/include/any-linux-any/linux/if_macsec.h
@@ -22,6 +22,8 @@
#define MACSEC_KEYID_LEN 16
+#define MACSEC_SALT_LEN 12
+
/* cipher IDs as per IEEE802.1AE-2018 (Table 14-1) */
#define MACSEC_CIPHER_ID_GCM_AES_128 0x0080C20001000001ULL
#define MACSEC_CIPHER_ID_GCM_AES_256 0x0080C20001000002ULL
diff --git a/lib/libc/include/any-linux-any/linux/if_packet.h b/lib/libc/include/any-linux-any/linux/if_packet.h
index 0a6bd1871d..cbfcee9d24 100644
--- a/lib/libc/include/any-linux-any/linux/if_packet.h
+++ b/lib/libc/include/any-linux-any/linux/if_packet.h
@@ -70,6 +70,7 @@ struct sockaddr_ll {
#define PACKET_FANOUT_EBPF 7
#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000
#define PACKET_FANOUT_FLAG_UNIQUEID 0x2000
+#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000
#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
struct tpacket_stats {
@@ -114,6 +115,7 @@ struct tpacket_auxdata {
#define TP_STATUS_BLK_TMO (1 << 5)
#define TP_STATUS_VLAN_TPID_VALID (1 << 6) /* auxdata has valid tp_vlan_tpid */
#define TP_STATUS_CSUM_VALID (1 << 7)
+#define TP_STATUS_GSO_TCP (1 << 8)
/* Tx ring - header status */
#define TP_STATUS_AVAILABLE 0
diff --git a/lib/libc/include/any-linux-any/linux/if_pppox.h b/lib/libc/include/any-linux-any/linux/if_pppox.h
index af246f830c..a3988ac76c 100644
--- a/lib/libc/include/any-linux-any/linux/if_pppox.h
+++ b/lib/libc/include/any-linux-any/linux/if_pppox.h
@@ -122,7 +122,7 @@ struct sockaddr_pppol2tpv3in6 {
struct pppoe_tag {
__be16 tag_type;
__be16 tag_len;
- char tag_data[0];
+ char tag_data[];
} __attribute__ ((packed));
/* Tag identifiers */
@@ -150,7 +150,7 @@ struct pppoe_hdr {
__u8 code;
__be16 sid;
__be16 length;
- struct pppoe_tag tag[0];
+ struct pppoe_tag tag[];
} __attribute__((packed));
/* Length of entire PPPoE + PPP header */
diff --git a/lib/libc/include/any-linux-any/linux/if_tun.h b/lib/libc/include/any-linux-any/linux/if_tun.h
index 0c65205b10..be032f5f09 100644
--- a/lib/libc/include/any-linux-any/linux/if_tun.h
+++ b/lib/libc/include/any-linux-any/linux/if_tun.h
@@ -67,6 +67,8 @@
#define IFF_TAP 0x0002
#define IFF_NAPI 0x0010
#define IFF_NAPI_FRAGS 0x0020
+/* Used in TUNSETIFF to bring up tun/tap without carrier */
+#define IFF_NO_CARRIER 0x0040
#define IFF_NO_PI 0x1000
/* This flag has no real effect */
#define IFF_ONE_QUEUE 0x2000
@@ -88,6 +90,8 @@
#define TUN_F_TSO6 0x04 /* I can handle TSO for IPv6 packets */
#define TUN_F_TSO_ECN 0x08 /* I can handle TSO with ECN bits. */
#define TUN_F_UFO 0x10 /* I can handle UFO packets */
+#define TUN_F_USO4 0x20 /* I can handle USO for IPv4 packets */
+#define TUN_F_USO6 0x40 /* I can handle USO for IPv6 packets */
/* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
#define TUN_PKT_STRIP 0x0001
@@ -108,7 +112,7 @@ struct tun_pi {
struct tun_filter {
__u16 flags; /* TUN_FLT_ flags see above */
__u16 count; /* Number of addresses */
- __u8 addr[0][ETH_ALEN];
+ __u8 addr[][ETH_ALEN];
};
#endif /* __IF_TUN_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/if_tunnel.h b/lib/libc/include/any-linux-any/linux/if_tunnel.h
index 0bc34f3d18..d3542643dd 100644
--- a/lib/libc/include/any-linux-any/linux/if_tunnel.h
+++ b/lib/libc/include/any-linux-any/linux/if_tunnel.h
@@ -176,8 +176,10 @@ enum {
#define TUNNEL_VXLAN_OPT __cpu_to_be16(0x1000)
#define TUNNEL_NOCACHE __cpu_to_be16(0x2000)
#define TUNNEL_ERSPAN_OPT __cpu_to_be16(0x4000)
+#define TUNNEL_GTP_OPT __cpu_to_be16(0x8000)
#define TUNNEL_OPTIONS_PRESENT \
- (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT)
+ (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | \
+ TUNNEL_GTP_OPT)
#endif /* _IF_TUNNEL_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/igmp.h b/lib/libc/include/any-linux-any/linux/igmp.h
index 5173bced4b..07892b8422 100644
--- a/lib/libc/include/any-linux-any/linux/igmp.h
+++ b/lib/libc/include/any-linux-any/linux/igmp.h
@@ -48,7 +48,7 @@ struct igmpv3_grec {
__u8 grec_auxwords;
__be16 grec_nsrcs;
__be32 grec_mca;
- __be32 grec_src[0];
+ __be32 grec_src[];
};
struct igmpv3_report {
@@ -57,7 +57,7 @@ struct igmpv3_report {
__sum16 csum;
__be16 resv2;
__be16 ngrec;
- struct igmpv3_grec grec[0];
+ struct igmpv3_grec grec[];
};
struct igmpv3_query {
@@ -78,7 +78,7 @@ struct igmpv3_query {
#endif
__u8 qqic;
__be16 nsrcs;
- __be32 srcs[0];
+ __be32 srcs[];
};
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
diff --git a/lib/libc/include/any-linux-any/linux/iio/types.h b/lib/libc/include/any-linux-any/linux/iio/types.h
index a2ec5ce6ba..3d56f798a5 100644
--- a/lib/libc/include/any-linux-any/linux/iio/types.h
+++ b/lib/libc/include/any-linux-any/linux/iio/types.h
@@ -95,6 +95,12 @@ enum iio_modifier {
IIO_MOD_ETHANOL,
IIO_MOD_H2,
IIO_MOD_O2,
+ IIO_MOD_LINEAR_X,
+ IIO_MOD_LINEAR_Y,
+ IIO_MOD_LINEAR_Z,
+ IIO_MOD_PITCH,
+ IIO_MOD_YAW,
+ IIO_MOD_ROLL,
};
enum iio_event_type {
@@ -104,6 +110,8 @@ enum iio_event_type {
IIO_EV_TYPE_THRESH_ADAPTIVE,
IIO_EV_TYPE_MAG_ADAPTIVE,
IIO_EV_TYPE_CHANGE,
+ IIO_EV_TYPE_MAG_REFERENCED,
+ IIO_EV_TYPE_GESTURE,
};
enum iio_event_direction {
@@ -111,6 +119,8 @@ enum iio_event_direction {
IIO_EV_DIR_RISING,
IIO_EV_DIR_FALLING,
IIO_EV_DIR_NONE,
+ IIO_EV_DIR_SINGLETAP,
+ IIO_EV_DIR_DOUBLETAP,
};
#endif /* _IIO_TYPES_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/in.h b/lib/libc/include/any-linux-any/linux/in.h
index 9c696802f9..5f36500afb 100644
--- a/lib/libc/include/any-linux-any/linux/in.h
+++ b/lib/libc/include/any-linux-any/linux/in.h
@@ -20,6 +20,7 @@
#define _LINUX_IN_H
#include <linux/types.h>
+#include <linux/stddef.h>
#include <linux/libc-compat.h>
#include <linux/socket.h>
@@ -68,6 +69,8 @@ enum {
#define IPPROTO_PIM IPPROTO_PIM
IPPROTO_COMP = 108, /* Compression Header Protocol */
#define IPPROTO_COMP IPPROTO_COMP
+ IPPROTO_L2TP = 115, /* Layer 2 Tunnelling Protocol */
+#define IPPROTO_L2TP IPPROTO_L2TP
IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */
#define IPPROTO_SCTP IPPROTO_SCTP
IPPROTO_UDPLITE = 136, /* UDP-Lite (RFC 3828) */
@@ -159,6 +162,8 @@ struct in_addr {
#define MCAST_MSFILTER 48
#define IP_MULTICAST_ALL 49
#define IP_UNICAST_IF 50
+#define IP_LOCAL_PORT_RANGE 51
+#define IP_PROTOCOL 52
#define MCAST_EXCLUDE 0
#define MCAST_INCLUDE 1
@@ -188,21 +193,13 @@ struct ip_mreq_source {
};
struct ip_msfilter {
+ __be32 imsf_multiaddr;
+ __be32 imsf_interface;
+ __u32 imsf_fmode;
+ __u32 imsf_numsrc;
union {
- struct {
- __be32 imsf_multiaddr_aux;
- __be32 imsf_interface_aux;
- __u32 imsf_fmode_aux;
- __u32 imsf_numsrc_aux;
- __be32 imsf_slist[1];
- };
- struct {
- __be32 imsf_multiaddr;
- __be32 imsf_interface;
- __u32 imsf_fmode;
- __u32 imsf_numsrc;
- __be32 imsf_slist_flex[];
- };
+ __be32 imsf_slist[1];
+ __DECLARE_FLEX_ARRAY(__be32, imsf_slist_flex);
};
};
diff --git a/lib/libc/include/any-linux-any/linux/inet_diag.h b/lib/libc/include/any-linux-any/linux/inet_diag.h
index 48582a0699..86fc5f453c 100644
--- a/lib/libc/include/any-linux-any/linux/inet_diag.h
+++ b/lib/libc/include/any-linux-any/linux/inet_diag.h
@@ -104,7 +104,7 @@ struct inet_diag_hostcond {
__u8 family;
__u8 prefix_len;
int port;
- __be32 addr[0];
+ __be32 addr[];
};
struct inet_diag_markcond {
diff --git a/lib/libc/include/any-linux-any/linux/inotify.h b/lib/libc/include/any-linux-any/linux/inotify.h
index 2520657a27..e54aac2783 100644
--- a/lib/libc/include/any-linux-any/linux/inotify.h
+++ b/lib/libc/include/any-linux-any/linux/inotify.h
@@ -23,7 +23,7 @@ struct inotify_event {
__u32 mask; /* watch mask */
__u32 cookie; /* cookie to synchronize two events */
__u32 len; /* length (including nulls) of name */
- char name[0]; /* stub for possible name */
+ char name[]; /* stub for possible name */
};
/* the following are legal, implemented events that user-space can watch for */
diff --git a/lib/libc/include/any-linux-any/linux/input-event-codes.h b/lib/libc/include/any-linux-any/linux/input-event-codes.h
index 88ff65470d..ecf14c91d0 100644
--- a/lib/libc/include/any-linux-any/linux/input-event-codes.h
+++ b/lib/libc/include/any-linux-any/linux/input-event-codes.h
@@ -278,7 +278,8 @@
#define KEY_PAUSECD 201
#define KEY_PROG3 202
#define KEY_PROG4 203
-#define KEY_DASHBOARD 204 /* AL Dashboard */
+#define KEY_ALL_APPLICATIONS 204 /* AC Desktop Show All Applications */
+#define KEY_DASHBOARD KEY_ALL_APPLICATIONS
#define KEY_SUSPEND 205
#define KEY_CLOSE 206 /* AC Close */
#define KEY_PLAY 207
@@ -612,6 +613,10 @@
#define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */
#define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */
#define KEY_EMOJI_PICKER 0x249 /* Show/hide emoji picker (HUTRR101) */
+#define KEY_DICTATE 0x24a /* Start or Stop Voice Dictation Session (HUTRR99) */
+#define KEY_CAMERA_ACCESS_ENABLE 0x24b /* Enables programmatic access to camera devices. (HUTRR72) */
+#define KEY_CAMERA_ACCESS_DISABLE 0x24c /* Disables programmatic access to camera devices. (HUTRR72) */
+#define KEY_CAMERA_ACCESS_TOGGLE 0x24d /* Toggles the current state of the camera access control. (HUTRR72) */
#define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */
#define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */
@@ -660,6 +665,27 @@
/* Select an area of screen to be copied */
#define KEY_SELECTIVE_SCREENSHOT 0x27a
+/* Move the focus to the next or previous user controllable element within a UI container */
+#define KEY_NEXT_ELEMENT 0x27b
+#define KEY_PREVIOUS_ELEMENT 0x27c
+
+/* Toggle Autopilot engagement */
+#define KEY_AUTOPILOT_ENGAGE_TOGGLE 0x27d
+
+/* Shortcut Keys */
+#define KEY_MARK_WAYPOINT 0x27e
+#define KEY_SOS 0x27f
+#define KEY_NAV_CHART 0x280
+#define KEY_FISHING_CHART 0x281
+#define KEY_SINGLE_RANGE_RADAR 0x282
+#define KEY_DUAL_RANGE_RADAR 0x283
+#define KEY_RADAR_OVERLAY 0x284
+#define KEY_TRADITIONAL_SONAR 0x285
+#define KEY_CLEARVU_SONAR 0x286
+#define KEY_SIDEVU_SONAR 0x287
+#define KEY_NAV_INFO 0x288
+#define KEY_BRIGHTNESS_MENU 0x289
+
/*
* Some keyboards have keys which do not have a defined meaning, these keys
* are intended to be programmed / bound to macros by the user. For most
@@ -839,6 +865,7 @@
#define ABS_TOOL_WIDTH 0x1c
#define ABS_VOLUME 0x20
+#define ABS_PROFILE 0x21
#define ABS_MISC 0x28
diff --git a/lib/libc/include/any-linux-any/linux/input.h b/lib/libc/include/any-linux-any/linux/input.h
index 101554d9a1..017fad3e0c 100644
--- a/lib/libc/include/any-linux-any/linux/input.h
+++ b/lib/libc/include/any-linux-any/linux/input.h
@@ -76,10 +76,13 @@ struct input_id {
* Note that input core does not clamp reported values to the
* [minimum, maximum] limits, such task is left to userspace.
*
- * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z)
- * is reported in units per millimeter (units/mm), resolution
- * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported
- * in units per radian.
+ * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z,
+ * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units
+ * per millimeter (units/mm), resolution for rotational axes
+ * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian.
+ * The resolution for the size axes (ABS_MT_TOUCH_MAJOR,
+ * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR)
+ * is reported in units per millimeter (units/mm).
* When INPUT_PROP_ACCELEROMETER is set the resolution changes.
* The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in
* units per g (units/g) and in units per degree per second
@@ -269,6 +272,7 @@ struct input_mask {
#define BUS_RMI 0x1D
#define BUS_CEC 0x1E
#define BUS_INTEL_ISHTP 0x1F
+#define BUS_AMD_SFH 0x20
/*
* MT_TOOL types
diff --git a/lib/libc/include/any-linux-any/linux/io_uring.h b/lib/libc/include/any-linux-any/linux/io_uring.h
index bce18b531a..7753a0be4f 100644
--- a/lib/libc/include/any-linux-any/linux/io_uring.h
+++ b/lib/libc/include/any-linux-any/linux/io_uring.h
@@ -10,6 +10,19 @@
#include <linux/fs.h>
#include <linux/types.h>
+/*
+ * this file is shared with liburing and that has to autodetect
+ * if linux/time_types.h is available or not, it can
+ * define UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
+ * if linux/time_types.h is not available
+ */
+#ifndef UAPI_LINUX_IO_URING_H_SKIP_LINUX_TIME_TYPES_H
+#include <linux/time_types.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/*
* IO submission data structure (Submission Queue Entry)
@@ -22,6 +35,10 @@ struct io_uring_sqe {
union {
__u64 off; /* offset into file */
__u64 addr2;
+ struct {
+ __u32 cmd_op;
+ __u32 __pad1;
+ };
};
union {
__u64 addr; /* pointer to buffer or iovecs */
@@ -45,6 +62,9 @@ struct io_uring_sqe {
__u32 rename_flags;
__u32 unlink_flags;
__u32 hardlink_flags;
+ __u32 xattr_flags;
+ __u32 msg_ring_flags;
+ __u32 uring_cmd_flags;
};
__u64 user_data; /* data to be passed back at completion time */
/* pack this to avoid bogus arm OABI complaints */
@@ -59,10 +79,33 @@ struct io_uring_sqe {
union {
__s32 splice_fd_in;
__u32 file_index;
+ struct {
+ __u16 addr_len;
+ __u16 __pad3[1];
+ };
+ };
+ union {
+ struct {
+ __u64 addr3;
+ __u64 __pad2[1];
+ };
+ /*
+ * If the ring is initialized with IORING_SETUP_SQE128, then
+ * this field is used for 80 bytes of arbitrary command data
+ */
+ __u8 cmd[0];
};
- __u64 __pad2[2];
};
+/*
+ * If sqe->file_index is set to this for opcodes that instantiate a new
+ * direct descriptor (like openat/openat2/accept), then io_uring will allocate
+ * an available direct descriptor instead of having the application pass one
+ * in. The picked direct descriptor will be returned in cqe->res, or -ENFILE
+ * if the space is full.
+ */
+#define IORING_FILE_INDEX_ALLOC (~0U)
+
enum {
IOSQE_FIXED_FILE_BIT,
IOSQE_IO_DRAIN_BIT,
@@ -70,6 +113,7 @@ enum {
IOSQE_IO_HARDLINK_BIT,
IOSQE_ASYNC_BIT,
IOSQE_BUFFER_SELECT_BIT,
+ IOSQE_CQE_SKIP_SUCCESS_BIT,
};
/*
@@ -87,6 +131,8 @@ enum {
#define IOSQE_ASYNC (1U << IOSQE_ASYNC_BIT)
/* select buffer from sqe->buf_group */
#define IOSQE_BUFFER_SELECT (1U << IOSQE_BUFFER_SELECT_BIT)
+/* don't post CQE if request succeeded */
+#define IOSQE_CQE_SKIP_SUCCESS (1U << IOSQE_CQE_SKIP_SUCCESS_BIT)
/*
* io_uring_setup() flags
@@ -98,8 +144,36 @@ enum {
#define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */
#define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */
#define IORING_SETUP_R_DISABLED (1U << 6) /* start with ring disabled */
+#define IORING_SETUP_SUBMIT_ALL (1U << 7) /* continue submit on error */
+/*
+ * Cooperative task running. When requests complete, they often require
+ * forcing the submitter to transition to the kernel to complete. If this
+ * flag is set, work will be done when the task transitions anyway, rather
+ * than force an inter-processor interrupt reschedule. This avoids interrupting
+ * a task running in userspace, and saves an IPI.
+ */
+#define IORING_SETUP_COOP_TASKRUN (1U << 8)
+/*
+ * If COOP_TASKRUN is set, get notified if task work is available for
+ * running and a kernel transition would be needed to run it. This sets
+ * IORING_SQ_TASKRUN in the sq ring flags. Not valid with COOP_TASKRUN.
+ */
+#define IORING_SETUP_TASKRUN_FLAG (1U << 9)
+#define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */
+#define IORING_SETUP_CQE32 (1U << 11) /* CQEs are 32 byte */
+/*
+ * Only one task is allowed to submit requests
+ */
+#define IORING_SETUP_SINGLE_ISSUER (1U << 12)
-enum {
+/*
+ * Defer running task work to get events.
+ * Rather than running bits of task work whenever the task transitions
+ * try to do it just before it is needed.
+ */
+#define IORING_SETUP_DEFER_TASKRUN (1U << 13)
+
+enum io_uring_op {
IORING_OP_NOP,
IORING_OP_READV,
IORING_OP_WRITEV,
@@ -140,12 +214,29 @@ enum {
IORING_OP_MKDIRAT,
IORING_OP_SYMLINKAT,
IORING_OP_LINKAT,
+ IORING_OP_MSG_RING,
+ IORING_OP_FSETXATTR,
+ IORING_OP_SETXATTR,
+ IORING_OP_FGETXATTR,
+ IORING_OP_GETXATTR,
+ IORING_OP_SOCKET,
+ IORING_OP_URING_CMD,
+ IORING_OP_SEND_ZC,
+ IORING_OP_SENDMSG_ZC,
/* this goes last, obviously */
IORING_OP_LAST,
};
/*
+ * sqe->uring_cmd_flags
+ * IORING_URING_CMD_FIXED use registered buffer; pass this flag
+ * along with setting sqe->buf_index.
+ */
+#define IORING_URING_CMD_FIXED (1U << 0)
+
+
+/*
* sqe->fsync_flags
*/
#define IORING_FSYNC_DATASYNC (1U << 0)
@@ -177,10 +268,87 @@ enum {
*
* IORING_POLL_UPDATE Update existing poll request, matching
* sqe->addr as the old user_data field.
+ *
+ * IORING_POLL_LEVEL Level triggered poll.
*/
#define IORING_POLL_ADD_MULTI (1U << 0)
#define IORING_POLL_UPDATE_EVENTS (1U << 1)
#define IORING_POLL_UPDATE_USER_DATA (1U << 2)
+#define IORING_POLL_ADD_LEVEL (1U << 3)
+
+/*
+ * ASYNC_CANCEL flags.
+ *
+ * IORING_ASYNC_CANCEL_ALL Cancel all requests that match the given key
+ * IORING_ASYNC_CANCEL_FD Key off 'fd' for cancelation rather than the
+ * request 'user_data'
+ * IORING_ASYNC_CANCEL_ANY Match any request
+ * IORING_ASYNC_CANCEL_FD_FIXED 'fd' passed in is a fixed descriptor
+ */
+#define IORING_ASYNC_CANCEL_ALL (1U << 0)
+#define IORING_ASYNC_CANCEL_FD (1U << 1)
+#define IORING_ASYNC_CANCEL_ANY (1U << 2)
+#define IORING_ASYNC_CANCEL_FD_FIXED (1U << 3)
+
+/*
+ * send/sendmsg and recv/recvmsg flags (sqe->ioprio)
+ *
+ * IORING_RECVSEND_POLL_FIRST If set, instead of first attempting to send
+ * or receive and arm poll if that yields an
+ * -EAGAIN result, arm poll upfront and skip
+ * the initial transfer attempt.
+ *
+ * IORING_RECV_MULTISHOT Multishot recv. Sets IORING_CQE_F_MORE if
+ * the handler will continue to report
+ * CQEs on behalf of the same SQE.
+ *
+ * IORING_RECVSEND_FIXED_BUF Use registered buffers, the index is stored in
+ * the buf_index field.
+ *
+ * IORING_SEND_ZC_REPORT_USAGE
+ * If set, SEND[MSG]_ZC should report
+ * the zerocopy usage in cqe.res
+ * for the IORING_CQE_F_NOTIF cqe.
+ * 0 is reported if zerocopy was actually possible.
+ * IORING_NOTIF_USAGE_ZC_COPIED if data was copied
+ * (at least partially).
+ */
+#define IORING_RECVSEND_POLL_FIRST (1U << 0)
+#define IORING_RECV_MULTISHOT (1U << 1)
+#define IORING_RECVSEND_FIXED_BUF (1U << 2)
+#define IORING_SEND_ZC_REPORT_USAGE (1U << 3)
+
+/*
+ * cqe.res for IORING_CQE_F_NOTIF if
+ * IORING_SEND_ZC_REPORT_USAGE was requested
+ *
+ * It should be treated as a flag, all other
+ * bits of cqe.res should be treated as reserved!
+ */
+#define IORING_NOTIF_USAGE_ZC_COPIED (1U << 31)
+
+/*
+ * accept flags stored in sqe->ioprio
+ */
+#define IORING_ACCEPT_MULTISHOT (1U << 0)
+
+/*
+ * IORING_OP_MSG_RING command types, stored in sqe->addr
+ */
+enum {
+ IORING_MSG_DATA, /* pass sqe->len as 'res' and off as user_data */
+ IORING_MSG_SEND_FD, /* send a registered fd to another ring */
+};
+
+/*
+ * IORING_OP_MSG_RING flags (sqe->msg_ring_flags)
+ *
+ * IORING_MSG_RING_CQE_SKIP Don't post a CQE to the target ring. Not
+ * applicable for IORING_MSG_DATA, obviously.
+ */
+#define IORING_MSG_RING_CQE_SKIP (1U << 0)
+/* Pass through the flags from sqe->file_index to cqe->flags */
+#define IORING_MSG_RING_FLAGS_PASS (1U << 1)
/*
* IO completion data structure (Completion Queue Entry)
@@ -189,6 +357,12 @@ struct io_uring_cqe {
__u64 user_data; /* sqe->data submission passed back */
__s32 res; /* result code for this event */
__u32 flags;
+
+ /*
+ * If the ring is initialized with IORING_SETUP_CQE32, then this field
+ * contains 16-bytes of padding, doubling the size of the CQE.
+ */
+ __u64 big_cqe[];
};
/*
@@ -196,9 +370,14 @@ struct io_uring_cqe {
*
* IORING_CQE_F_BUFFER If set, the upper 16 bits are the buffer ID
* IORING_CQE_F_MORE If set, parent SQE will generate more CQE entries
+ * IORING_CQE_F_SOCK_NONEMPTY If set, more data to read after socket recv
+ * IORING_CQE_F_NOTIF Set for notification CQEs. Can be used to distinct
+ * them from sends.
*/
#define IORING_CQE_F_BUFFER (1U << 0)
#define IORING_CQE_F_MORE (1U << 1)
+#define IORING_CQE_F_SOCK_NONEMPTY (1U << 2)
+#define IORING_CQE_F_NOTIF (1U << 3)
enum {
IORING_CQE_BUFFER_SHIFT = 16,
@@ -231,6 +410,7 @@ struct io_sqring_offsets {
*/
#define IORING_SQ_NEED_WAKEUP (1U << 0) /* needs io_uring_enter wakeup */
#define IORING_SQ_CQ_OVERFLOW (1U << 1) /* CQ ring is overflown */
+#define IORING_SQ_TASKRUN (1U << 2) /* task should enter the kernel */
struct io_cqring_offsets {
__u32 head;
@@ -254,10 +434,11 @@ struct io_cqring_offsets {
/*
* io_uring_enter(2) flags
*/
-#define IORING_ENTER_GETEVENTS (1U << 0)
-#define IORING_ENTER_SQ_WAKEUP (1U << 1)
-#define IORING_ENTER_SQ_WAIT (1U << 2)
-#define IORING_ENTER_EXT_ARG (1U << 3)
+#define IORING_ENTER_GETEVENTS (1U << 0)
+#define IORING_ENTER_SQ_WAKEUP (1U << 1)
+#define IORING_ENTER_SQ_WAIT (1U << 2)
+#define IORING_ENTER_EXT_ARG (1U << 3)
+#define IORING_ENTER_REGISTERED_RING (1U << 4)
/*
* Passed in for io_uring_setup(2). Copied back with updated info on success
@@ -289,6 +470,9 @@ struct io_uring_params {
#define IORING_FEAT_EXT_ARG (1U << 8)
#define IORING_FEAT_NATIVE_WORKERS (1U << 9)
#define IORING_FEAT_RSRC_TAGS (1U << 10)
+#define IORING_FEAT_CQE_SKIP (1U << 11)
+#define IORING_FEAT_LINKED_FILE (1U << 12)
+#define IORING_FEAT_REG_REG_RING (1U << 13)
/*
* io_uring_register(2) opcodes and arguments
@@ -321,8 +505,25 @@ enum {
/* set/get max number of io-wq workers */
IORING_REGISTER_IOWQ_MAX_WORKERS = 19,
+ /* register/unregister io_uring fd with the ring */
+ IORING_REGISTER_RING_FDS = 20,
+ IORING_UNREGISTER_RING_FDS = 21,
+
+ /* register ring based provide buffer group */
+ IORING_REGISTER_PBUF_RING = 22,
+ IORING_UNREGISTER_PBUF_RING = 23,
+
+ /* sync cancelation API */
+ IORING_REGISTER_SYNC_CANCEL = 24,
+
+ /* register a range of fixed file slots for automatic slot allocation */
+ IORING_REGISTER_FILE_ALLOC_RANGE = 25,
+
/* this goes last */
- IORING_REGISTER_LAST
+ IORING_REGISTER_LAST,
+
+ /* flag added to the opcode to use a registered ring fd */
+ IORING_REGISTER_USE_REGISTERED_RING = 1U << 31
};
/* io-wq worker categories */
@@ -338,9 +539,15 @@ struct io_uring_files_update {
__aligned_u64 /* __s32 * */ fds;
};
+/*
+ * Register a fully sparse file space, rather than pass in an array of all
+ * -1 file descriptors.
+ */
+#define IORING_RSRC_REGISTER_SPARSE (1U << 0)
+
struct io_uring_rsrc_register {
__u32 nr;
- __u32 resv;
+ __u32 flags;
__u64 resv2;
__aligned_u64 data;
__aligned_u64 tags;
@@ -361,6 +568,19 @@ struct io_uring_rsrc_update2 {
__u32 resv2;
};
+struct io_uring_notification_slot {
+ __u64 tag;
+ __u64 resv[3];
+};
+
+struct io_uring_notification_register {
+ __u32 nr_slots;
+ __u32 resv;
+ __u64 resv2;
+ __u64 data;
+ __u64 resv3;
+};
+
/* Skip updating fd indexes set to this value in the fd table */
#define IORING_REGISTER_FILES_SKIP (-2)
@@ -378,7 +598,7 @@ struct io_uring_probe {
__u8 ops_len; /* length of ops[] array below */
__u16 resv;
__u32 resv2[3];
- struct io_uring_probe_op ops[0];
+ struct io_uring_probe_op ops[];
};
struct io_uring_restriction {
@@ -392,6 +612,38 @@ struct io_uring_restriction {
__u32 resv2[3];
};
+struct io_uring_buf {
+ __u64 addr;
+ __u32 len;
+ __u16 bid;
+ __u16 resv;
+};
+
+struct io_uring_buf_ring {
+ union {
+ /*
+ * To avoid spilling into more pages than we need to, the
+ * ring tail is overlaid with the io_uring_buf->resv field.
+ */
+ struct {
+ __u64 resv1;
+ __u32 resv2;
+ __u16 resv3;
+ __u16 tail;
+ };
+ __DECLARE_FLEX_ARRAY(struct io_uring_buf, bufs);
+ };
+};
+
+/* argument for IORING_(UN)REGISTER_PBUF_RING */
+struct io_uring_buf_reg {
+ __u64 ring_addr;
+ __u32 ring_entries;
+ __u16 bgid;
+ __u16 pad;
+ __u64 resv[3];
+};
+
/*
* io_uring_restriction->opcode values
*/
@@ -418,4 +670,36 @@ struct io_uring_getevents_arg {
__u64 ts;
};
+/*
+ * Argument for IORING_REGISTER_SYNC_CANCEL
+ */
+struct io_uring_sync_cancel_reg {
+ __u64 addr;
+ __s32 fd;
+ __u32 flags;
+ struct __kernel_timespec timeout;
+ __u64 pad[4];
+};
+
+/*
+ * Argument for IORING_REGISTER_FILE_ALLOC_RANGE
+ * The range is specified as [off, off + len)
+ */
+struct io_uring_file_index_range {
+ __u32 off;
+ __u32 len;
+ __u64 resv;
+};
+
+struct io_uring_recvmsg_out {
+ __u32 namelen;
+ __u32 controllen;
+ __u32 payloadlen;
+ __u32 flags;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/ioam6.h b/lib/libc/include/any-linux-any/linux/ioam6.h
index 2bdb69bedd..5691a612e0 100644
--- a/lib/libc/include/any-linux-any/linux/ioam6.h
+++ b/lib/libc/include/any-linux-any/linux/ioam6.h
@@ -127,7 +127,7 @@ struct ioam6_trace_hdr {
#endif
#define IOAM6_TRACE_DATA_SIZE_MAX 244
- __u8 data[0];
+ __u8 data[];
} __attribute__((packed));
#endif /* _LINUX_IOAM6_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/ioam6_iptunnel.h b/lib/libc/include/any-linux-any/linux/ioam6_iptunnel.h
index c9d4df0aaa..09fefe04ac 100644
--- a/lib/libc/include/any-linux-any/linux/ioam6_iptunnel.h
+++ b/lib/libc/include/any-linux-any/linux/ioam6_iptunnel.h
@@ -41,6 +41,15 @@ enum {
/* IOAM Trace Header */
IOAM6_IPTUNNEL_TRACE, /* struct ioam6_trace_hdr */
+ /* Insertion frequency:
+ * "k over n" packets (0 < k <= n)
+ * [0.0001% ... 100%]
+ */
+#define IOAM6_IPTUNNEL_FREQ_MIN 1
+#define IOAM6_IPTUNNEL_FREQ_MAX 1000000
+ IOAM6_IPTUNNEL_FREQ_K, /* u32 */
+ IOAM6_IPTUNNEL_FREQ_N, /* u32 */
+
__IOAM6_IPTUNNEL_MAX,
};
diff --git a/lib/libc/include/any-linux-any/linux/iommu.h b/lib/libc/include/any-linux-any/linux/iommu.h
index dc56a66130..5046f80e5c 100644
--- a/lib/libc/include/any-linux-any/linux/iommu.h
+++ b/lib/libc/include/any-linux-any/linux/iommu.h
@@ -158,185 +158,4 @@ struct iommu_page_response {
__u32 code;
};
-/* defines the granularity of the invalidation */
-enum iommu_inv_granularity {
- IOMMU_INV_GRANU_DOMAIN, /* domain-selective invalidation */
- IOMMU_INV_GRANU_PASID, /* PASID-selective invalidation */
- IOMMU_INV_GRANU_ADDR, /* page-selective invalidation */
- IOMMU_INV_GRANU_NR, /* number of invalidation granularities */
-};
-
-/**
- * struct iommu_inv_addr_info - Address Selective Invalidation Structure
- *
- * @flags: indicates the granularity of the address-selective invalidation
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
- * relates to cache entries tagged with this PASID and matching the address
- * range.
- * - If ARCHID bit is set, @archid is populated and the invalidation relates
- * to cache entries tagged with this architecture specific ID and matching
- * the address range.
- * - Both PASID and ARCHID can be set as they may tag different caches.
- * - If neither PASID or ARCHID is set, global addr invalidation applies.
- * - The LEAF flag indicates whether only the leaf PTE caching needs to be
- * invalidated and other paging structure caches can be preserved.
- * @pasid: process address space ID
- * @archid: architecture-specific ID
- * @addr: first stage/level input address
- * @granule_size: page/block size of the mapping in bytes
- * @nb_granules: number of contiguous granules to be invalidated
- */
-struct iommu_inv_addr_info {
-#define IOMMU_INV_ADDR_FLAGS_PASID (1 << 0)
-#define IOMMU_INV_ADDR_FLAGS_ARCHID (1 << 1)
-#define IOMMU_INV_ADDR_FLAGS_LEAF (1 << 2)
- __u32 flags;
- __u32 archid;
- __u64 pasid;
- __u64 addr;
- __u64 granule_size;
- __u64 nb_granules;
-};
-
-/**
- * struct iommu_inv_pasid_info - PASID Selective Invalidation Structure
- *
- * @flags: indicates the granularity of the PASID-selective invalidation
- * - If the PASID bit is set, the @pasid field is populated and the invalidation
- * relates to cache entries tagged with this PASID and matching the address
- * range.
- * - If the ARCHID bit is set, the @archid is populated and the invalidation
- * relates to cache entries tagged with this architecture specific ID and
- * matching the address range.
- * - Both PASID and ARCHID can be set as they may tag different caches.
- * - At least one of PASID or ARCHID must be set.
- * @pasid: process address space ID
- * @archid: architecture-specific ID
- */
-struct iommu_inv_pasid_info {
-#define IOMMU_INV_PASID_FLAGS_PASID (1 << 0)
-#define IOMMU_INV_PASID_FLAGS_ARCHID (1 << 1)
- __u32 flags;
- __u32 archid;
- __u64 pasid;
-};
-
-/**
- * struct iommu_cache_invalidate_info - First level/stage invalidation
- * information
- * @argsz: User filled size of this data
- * @version: API version of this structure
- * @cache: bitfield that allows to select which caches to invalidate
- * @granularity: defines the lowest granularity used for the invalidation:
- * domain > PASID > addr
- * @padding: reserved for future use (should be zero)
- * @pasid_info: invalidation data when @granularity is %IOMMU_INV_GRANU_PASID
- * @addr_info: invalidation data when @granularity is %IOMMU_INV_GRANU_ADDR
- *
- * Not all the combinations of cache/granularity are valid:
- *
- * +--------------+---------------+---------------+---------------+
- * | type / | DEV_IOTLB | IOTLB | PASID |
- * | granularity | | | cache |
- * +==============+===============+===============+===============+
- * | DOMAIN | N/A | Y | Y |
- * +--------------+---------------+---------------+---------------+
- * | PASID | Y | Y | Y |
- * +--------------+---------------+---------------+---------------+
- * | ADDR | Y | Y | N/A |
- * +--------------+---------------+---------------+---------------+
- *
- * Invalidations by %IOMMU_INV_GRANU_DOMAIN don't take any argument other than
- * @version and @cache.
- *
- * If multiple cache types are invalidated simultaneously, they all
- * must support the used granularity.
- */
-struct iommu_cache_invalidate_info {
- __u32 argsz;
-#define IOMMU_CACHE_INVALIDATE_INFO_VERSION_1 1
- __u32 version;
-/* IOMMU paging structure cache */
-#define IOMMU_CACHE_INV_TYPE_IOTLB (1 << 0) /* IOMMU IOTLB */
-#define IOMMU_CACHE_INV_TYPE_DEV_IOTLB (1 << 1) /* Device IOTLB */
-#define IOMMU_CACHE_INV_TYPE_PASID (1 << 2) /* PASID cache */
-#define IOMMU_CACHE_INV_TYPE_NR (3)
- __u8 cache;
- __u8 granularity;
- __u8 padding[6];
- union {
- struct iommu_inv_pasid_info pasid_info;
- struct iommu_inv_addr_info addr_info;
- } granu;
-};
-
-/**
- * struct iommu_gpasid_bind_data_vtd - Intel VT-d specific data on device and guest
- * SVA binding.
- *
- * @flags: VT-d PASID table entry attributes
- * @pat: Page attribute table data to compute effective memory type
- * @emt: Extended memory type
- *
- * Only guest vIOMMU selectable and effective options are passed down to
- * the host IOMMU.
- */
-struct iommu_gpasid_bind_data_vtd {
-#define IOMMU_SVA_VTD_GPASID_SRE (1 << 0) /* supervisor request */
-#define IOMMU_SVA_VTD_GPASID_EAFE (1 << 1) /* extended access enable */
-#define IOMMU_SVA_VTD_GPASID_PCD (1 << 2) /* page-level cache disable */
-#define IOMMU_SVA_VTD_GPASID_PWT (1 << 3) /* page-level write through */
-#define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */
-#define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */
-#define IOMMU_SVA_VTD_GPASID_WPE (1 << 6) /* Write protect enable */
-#define IOMMU_SVA_VTD_GPASID_LAST (1 << 7)
- __u64 flags;
- __u32 pat;
- __u32 emt;
-};
-
-#define IOMMU_SVA_VTD_GPASID_MTS_MASK (IOMMU_SVA_VTD_GPASID_CD | \
- IOMMU_SVA_VTD_GPASID_EMTE | \
- IOMMU_SVA_VTD_GPASID_PCD | \
- IOMMU_SVA_VTD_GPASID_PWT)
-
-/**
- * struct iommu_gpasid_bind_data - Information about device and guest PASID binding
- * @argsz: User filled size of this data
- * @version: Version of this data structure
- * @format: PASID table entry format
- * @flags: Additional information on guest bind request
- * @gpgd: Guest page directory base of the guest mm to bind
- * @hpasid: Process address space ID used for the guest mm in host IOMMU
- * @gpasid: Process address space ID used for the guest mm in guest IOMMU
- * @addr_width: Guest virtual address width
- * @padding: Reserved for future use (should be zero)
- * @vtd: Intel VT-d specific data
- *
- * Guest to host PASID mapping can be an identity or non-identity, where guest
- * has its own PASID space. For non-identify mapping, guest to host PASID lookup
- * is needed when VM programs guest PASID into an assigned device. VMM may
- * trap such PASID programming then request host IOMMU driver to convert guest
- * PASID to host PASID based on this bind data.
- */
-struct iommu_gpasid_bind_data {
- __u32 argsz;
-#define IOMMU_GPASID_BIND_VERSION_1 1
- __u32 version;
-#define IOMMU_PASID_FORMAT_INTEL_VTD 1
-#define IOMMU_PASID_FORMAT_LAST 2
- __u32 format;
- __u32 addr_width;
-#define IOMMU_SVA_GPASID_VAL (1 << 0) /* guest PASID valid */
- __u64 flags;
- __u64 gpgd;
- __u64 hpasid;
- __u64 gpasid;
- __u8 padding[8];
- /* Vendor specific data */
- union {
- struct iommu_gpasid_bind_data_vtd vtd;
- } vendor;
-};
-
#endif /* _IOMMU_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/iommufd.h b/lib/libc/include/any-linux-any/linux/iommufd.h
new file mode 100644
index 0000000000..70fbdee5aa
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/iommufd.h
@@ -0,0 +1,347 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES.
+ */
+#ifndef _IOMMUFD_H
+#define _IOMMUFD_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define IOMMUFD_TYPE (';')
+
+/**
+ * DOC: General ioctl format
+ *
+ * The ioctl interface follows a general format to allow for extensibility. Each
+ * ioctl is passed in a structure pointer as the argument providing the size of
+ * the structure in the first u32. The kernel checks that any structure space
+ * beyond what it understands is 0. This allows userspace to use the backward
+ * compatible portion while consistently using the newer, larger, structures.
+ *
+ * ioctls use a standard meaning for common errnos:
+ *
+ * - ENOTTY: The IOCTL number itself is not supported at all
+ * - E2BIG: The IOCTL number is supported, but the provided structure has
+ * non-zero in a part the kernel does not understand.
+ * - EOPNOTSUPP: The IOCTL number is supported, and the structure is
+ * understood, however a known field has a value the kernel does not
+ * understand or support.
+ * - EINVAL: Everything about the IOCTL was understood, but a field is not
+ * correct.
+ * - ENOENT: An ID or IOVA provided does not exist.
+ * - ENOMEM: Out of memory.
+ * - EOVERFLOW: Mathematics overflowed.
+ *
+ * As well as additional errnos, within specific ioctls.
+ */
+enum {
+ IOMMUFD_CMD_BASE = 0x80,
+ IOMMUFD_CMD_DESTROY = IOMMUFD_CMD_BASE,
+ IOMMUFD_CMD_IOAS_ALLOC,
+ IOMMUFD_CMD_IOAS_ALLOW_IOVAS,
+ IOMMUFD_CMD_IOAS_COPY,
+ IOMMUFD_CMD_IOAS_IOVA_RANGES,
+ IOMMUFD_CMD_IOAS_MAP,
+ IOMMUFD_CMD_IOAS_UNMAP,
+ IOMMUFD_CMD_OPTION,
+ IOMMUFD_CMD_VFIO_IOAS,
+};
+
+/**
+ * struct iommu_destroy - ioctl(IOMMU_DESTROY)
+ * @size: sizeof(struct iommu_destroy)
+ * @id: iommufd object ID to destroy. Can be any destroyable object type.
+ *
+ * Destroy any object held within iommufd.
+ */
+struct iommu_destroy {
+ __u32 size;
+ __u32 id;
+};
+#define IOMMU_DESTROY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_DESTROY)
+
+/**
+ * struct iommu_ioas_alloc - ioctl(IOMMU_IOAS_ALLOC)
+ * @size: sizeof(struct iommu_ioas_alloc)
+ * @flags: Must be 0
+ * @out_ioas_id: Output IOAS ID for the allocated object
+ *
+ * Allocate an IO Address Space (IOAS) which holds an IO Virtual Address (IOVA)
+ * to memory mapping.
+ */
+struct iommu_ioas_alloc {
+ __u32 size;
+ __u32 flags;
+ __u32 out_ioas_id;
+};
+#define IOMMU_IOAS_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOC)
+
+/**
+ * struct iommu_iova_range - ioctl(IOMMU_IOVA_RANGE)
+ * @start: First IOVA
+ * @last: Inclusive last IOVA
+ *
+ * An interval in IOVA space.
+ */
+struct iommu_iova_range {
+ __aligned_u64 start;
+ __aligned_u64 last;
+};
+
+/**
+ * struct iommu_ioas_iova_ranges - ioctl(IOMMU_IOAS_IOVA_RANGES)
+ * @size: sizeof(struct iommu_ioas_iova_ranges)
+ * @ioas_id: IOAS ID to read ranges from
+ * @num_iovas: Input/Output total number of ranges in the IOAS
+ * @__reserved: Must be 0
+ * @allowed_iovas: Pointer to the output array of struct iommu_iova_range
+ * @out_iova_alignment: Minimum alignment required for mapping IOVA
+ *
+ * Query an IOAS for ranges of allowed IOVAs. Mapping IOVA outside these ranges
+ * is not allowed. num_iovas will be set to the total number of iovas and
+ * the allowed_iovas[] will be filled in as space permits.
+ *
+ * The allowed ranges are dependent on the HW path the DMA operation takes, and
+ * can change during the lifetime of the IOAS. A fresh empty IOAS will have a
+ * full range, and each attached device will narrow the ranges based on that
+ * device's HW restrictions. Detaching a device can widen the ranges. Userspace
+ * should query ranges after every attach/detach to know what IOVAs are valid
+ * for mapping.
+ *
+ * On input num_iovas is the length of the allowed_iovas array. On output it is
+ * the total number of iovas filled in. The ioctl will return -EMSGSIZE and set
+ * num_iovas to the required value if num_iovas is too small. In this case the
+ * caller should allocate a larger output array and re-issue the ioctl.
+ *
+ * out_iova_alignment returns the minimum IOVA alignment that can be given
+ * to IOMMU_IOAS_MAP/COPY. IOVA's must satisfy::
+ *
+ * starting_iova % out_iova_alignment == 0
+ * (starting_iova + length) % out_iova_alignment == 0
+ *
+ * out_iova_alignment can be 1 indicating any IOVA is allowed. It cannot
+ * be higher than the system PAGE_SIZE.
+ */
+struct iommu_ioas_iova_ranges {
+ __u32 size;
+ __u32 ioas_id;
+ __u32 num_iovas;
+ __u32 __reserved;
+ __aligned_u64 allowed_iovas;
+ __aligned_u64 out_iova_alignment;
+};
+#define IOMMU_IOAS_IOVA_RANGES _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_IOVA_RANGES)
+
+/**
+ * struct iommu_ioas_allow_iovas - ioctl(IOMMU_IOAS_ALLOW_IOVAS)
+ * @size: sizeof(struct iommu_ioas_allow_iovas)
+ * @ioas_id: IOAS ID to allow IOVAs from
+ * @num_iovas: Input/Output total number of ranges in the IOAS
+ * @__reserved: Must be 0
+ * @allowed_iovas: Pointer to array of struct iommu_iova_range
+ *
+ * Ensure a range of IOVAs are always available for allocation. If this call
+ * succeeds then IOMMU_IOAS_IOVA_RANGES will never return a list of IOVA ranges
+ * that are narrower than the ranges provided here. This call will fail if
+ * IOMMU_IOAS_IOVA_RANGES is currently narrower than the given ranges.
+ *
+ * When an IOAS is first created the IOVA_RANGES will be maximally sized, and as
+ * devices are attached the IOVA will narrow based on the device restrictions.
+ * When an allowed range is specified any narrowing will be refused, ie device
+ * attachment can fail if the device requires limiting within the allowed range.
+ *
+ * Automatic IOVA allocation is also impacted by this call. MAP will only
+ * allocate within the allowed IOVAs if they are present.
+ *
+ * This call replaces the entire allowed list with the given list.
+ */
+struct iommu_ioas_allow_iovas {
+ __u32 size;
+ __u32 ioas_id;
+ __u32 num_iovas;
+ __u32 __reserved;
+ __aligned_u64 allowed_iovas;
+};
+#define IOMMU_IOAS_ALLOW_IOVAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_ALLOW_IOVAS)
+
+/**
+ * enum iommufd_ioas_map_flags - Flags for map and copy
+ * @IOMMU_IOAS_MAP_FIXED_IOVA: If clear the kernel will compute an appropriate
+ * IOVA to place the mapping at
+ * @IOMMU_IOAS_MAP_WRITEABLE: DMA is allowed to write to this mapping
+ * @IOMMU_IOAS_MAP_READABLE: DMA is allowed to read from this mapping
+ */
+enum iommufd_ioas_map_flags {
+ IOMMU_IOAS_MAP_FIXED_IOVA = 1 << 0,
+ IOMMU_IOAS_MAP_WRITEABLE = 1 << 1,
+ IOMMU_IOAS_MAP_READABLE = 1 << 2,
+};
+
+/**
+ * struct iommu_ioas_map - ioctl(IOMMU_IOAS_MAP)
+ * @size: sizeof(struct iommu_ioas_map)
+ * @flags: Combination of enum iommufd_ioas_map_flags
+ * @ioas_id: IOAS ID to change the mapping of
+ * @__reserved: Must be 0
+ * @user_va: Userspace pointer to start mapping from
+ * @length: Number of bytes to map
+ * @iova: IOVA the mapping was placed at. If IOMMU_IOAS_MAP_FIXED_IOVA is set
+ * then this must be provided as input.
+ *
+ * Set an IOVA mapping from a user pointer. If FIXED_IOVA is specified then the
+ * mapping will be established at iova, otherwise a suitable location based on
+ * the reserved and allowed lists will be automatically selected and returned in
+ * iova.
+ *
+ * If IOMMU_IOAS_MAP_FIXED_IOVA is specified then the iova range must currently
+ * be unused, existing IOVA cannot be replaced.
+ */
+struct iommu_ioas_map {
+ __u32 size;
+ __u32 flags;
+ __u32 ioas_id;
+ __u32 __reserved;
+ __aligned_u64 user_va;
+ __aligned_u64 length;
+ __aligned_u64 iova;
+};
+#define IOMMU_IOAS_MAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_MAP)
+
+/**
+ * struct iommu_ioas_copy - ioctl(IOMMU_IOAS_COPY)
+ * @size: sizeof(struct iommu_ioas_copy)
+ * @flags: Combination of enum iommufd_ioas_map_flags
+ * @dst_ioas_id: IOAS ID to change the mapping of
+ * @src_ioas_id: IOAS ID to copy from
+ * @length: Number of bytes to copy and map
+ * @dst_iova: IOVA the mapping was placed at. If IOMMU_IOAS_MAP_FIXED_IOVA is
+ * set then this must be provided as input.
+ * @src_iova: IOVA to start the copy
+ *
+ * Copy an already existing mapping from src_ioas_id and establish it in
+ * dst_ioas_id. The src iova/length must exactly match a range used with
+ * IOMMU_IOAS_MAP.
+ *
+ * This may be used to efficiently clone a subset of an IOAS to another, or as a
+ * kind of 'cache' to speed up mapping. Copy has an efficiency advantage over
+ * establishing equivalent new mappings, as internal resources are shared, and
+ * the kernel will pin the user memory only once.
+ */
+struct iommu_ioas_copy {
+ __u32 size;
+ __u32 flags;
+ __u32 dst_ioas_id;
+ __u32 src_ioas_id;
+ __aligned_u64 length;
+ __aligned_u64 dst_iova;
+ __aligned_u64 src_iova;
+};
+#define IOMMU_IOAS_COPY _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_COPY)
+
+/**
+ * struct iommu_ioas_unmap - ioctl(IOMMU_IOAS_UNMAP)
+ * @size: sizeof(struct iommu_ioas_unmap)
+ * @ioas_id: IOAS ID to change the mapping of
+ * @iova: IOVA to start the unmapping at
+ * @length: Number of bytes to unmap, and return back the bytes unmapped
+ *
+ * Unmap an IOVA range. The iova/length must be a superset of a previously
+ * mapped range used with IOMMU_IOAS_MAP or IOMMU_IOAS_COPY. Splitting or
+ * truncating ranges is not allowed. The values 0 to U64_MAX will unmap
+ * everything.
+ */
+struct iommu_ioas_unmap {
+ __u32 size;
+ __u32 ioas_id;
+ __aligned_u64 iova;
+ __aligned_u64 length;
+};
+#define IOMMU_IOAS_UNMAP _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_UNMAP)
+
+/**
+ * enum iommufd_option - ioctl(IOMMU_OPTION_RLIMIT_MODE) and
+ * ioctl(IOMMU_OPTION_HUGE_PAGES)
+ * @IOMMU_OPTION_RLIMIT_MODE:
+ * Change how RLIMIT_MEMLOCK accounting works. The caller must have privilege
+ * to invoke this. Value 0 (default) is user based accouting, 1 uses process
+ * based accounting. Global option, object_id must be 0
+ * @IOMMU_OPTION_HUGE_PAGES:
+ * Value 1 (default) allows contiguous pages to be combined when generating
+ * iommu mappings. Value 0 disables combining, everything is mapped to
+ * PAGE_SIZE. This can be useful for benchmarking. This is a per-IOAS
+ * option, the object_id must be the IOAS ID.
+ */
+enum iommufd_option {
+ IOMMU_OPTION_RLIMIT_MODE = 0,
+ IOMMU_OPTION_HUGE_PAGES = 1,
+};
+
+/**
+ * enum iommufd_option_ops - ioctl(IOMMU_OPTION_OP_SET) and
+ * ioctl(IOMMU_OPTION_OP_GET)
+ * @IOMMU_OPTION_OP_SET: Set the option's value
+ * @IOMMU_OPTION_OP_GET: Get the option's value
+ */
+enum iommufd_option_ops {
+ IOMMU_OPTION_OP_SET = 0,
+ IOMMU_OPTION_OP_GET = 1,
+};
+
+/**
+ * struct iommu_option - iommu option multiplexer
+ * @size: sizeof(struct iommu_option)
+ * @option_id: One of enum iommufd_option
+ * @op: One of enum iommufd_option_ops
+ * @__reserved: Must be 0
+ * @object_id: ID of the object if required
+ * @val64: Option value to set or value returned on get
+ *
+ * Change a simple option value. This multiplexor allows controlling options
+ * on objects. IOMMU_OPTION_OP_SET will load an option and IOMMU_OPTION_OP_GET
+ * will return the current value.
+ */
+struct iommu_option {
+ __u32 size;
+ __u32 option_id;
+ __u16 op;
+ __u16 __reserved;
+ __u32 object_id;
+ __aligned_u64 val64;
+};
+#define IOMMU_OPTION _IO(IOMMUFD_TYPE, IOMMUFD_CMD_OPTION)
+
+/**
+ * enum iommufd_vfio_ioas_op - IOMMU_VFIO_IOAS_* ioctls
+ * @IOMMU_VFIO_IOAS_GET: Get the current compatibility IOAS
+ * @IOMMU_VFIO_IOAS_SET: Change the current compatibility IOAS
+ * @IOMMU_VFIO_IOAS_CLEAR: Disable VFIO compatibility
+ */
+enum iommufd_vfio_ioas_op {
+ IOMMU_VFIO_IOAS_GET = 0,
+ IOMMU_VFIO_IOAS_SET = 1,
+ IOMMU_VFIO_IOAS_CLEAR = 2,
+};
+
+/**
+ * struct iommu_vfio_ioas - ioctl(IOMMU_VFIO_IOAS)
+ * @size: sizeof(struct iommu_vfio_ioas)
+ * @ioas_id: For IOMMU_VFIO_IOAS_SET the input IOAS ID to set
+ * For IOMMU_VFIO_IOAS_GET will output the IOAS ID
+ * @op: One of enum iommufd_vfio_ioas_op
+ * @__reserved: Must be 0
+ *
+ * The VFIO compatibility support uses a single ioas because VFIO APIs do not
+ * support the ID field. Set or Get the IOAS that VFIO compatibility will use.
+ * When VFIO_GROUP_SET_CONTAINER is used on an iommufd it will get the
+ * compatibility ioas, either by taking what is already set, or auto creating
+ * one. From then on VFIO will continue to use that ioas and is not effected by
+ * this ioctl. SET or CLEAR does not destroy any auto-created IOAS.
+ */
+struct iommu_vfio_ioas {
+ __u32 size;
+ __u32 ioas_id;
+ __u16 op;
+ __u16 __reserved;
+};
+#define IOMMU_VFIO_IOAS _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VFIO_IOAS)
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/ip.h b/lib/libc/include/any-linux-any/linux/ip.h
index fb2fe5581f..837c253c31 100644
--- a/lib/libc/include/any-linux-any/linux/ip.h
+++ b/lib/libc/include/any-linux-any/linux/ip.h
@@ -18,6 +18,7 @@
#ifndef _LINUX_IP_H
#define _LINUX_IP_H
#include <linux/types.h>
+#include <linux/stddef.h>
#include <asm/byteorder.h>
#define IPTOS_TOS_MASK 0x1E
@@ -100,8 +101,10 @@ struct iphdr {
__u8 ttl;
__u8 protocol;
__sum16 check;
- __be32 saddr;
- __be32 daddr;
+ __struct_group(/* no tag */, addrs, /* no attrs */,
+ __be32 saddr;
+ __be32 daddr;
+ );
/*The options start here. */
};
@@ -112,13 +115,13 @@ struct ip_auth_hdr {
__be16 reserved;
__be32 spi;
__be32 seq_no; /* Sequence number */
- __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */
+ __u8 auth_data[]; /* Variable len but >=4. Mind the 64 bit alignment! */
};
struct ip_esp_hdr {
__be32 spi;
__be32 seq_no; /* Sequence number */
- __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */
+ __u8 enc_data[]; /* Variable len but >=8. Mind the 64 bit alignment! */
};
struct ip_comp_hdr {
diff --git a/lib/libc/include/any-linux-any/linux/ip_vs.h b/lib/libc/include/any-linux-any/linux/ip_vs.h
index 2067296f02..88da670601 100644
--- a/lib/libc/include/any-linux-any/linux/ip_vs.h
+++ b/lib/libc/include/any-linux-any/linux/ip_vs.h
@@ -254,7 +254,7 @@ struct ip_vs_get_dests {
unsigned int num_dests;
/* the real servers */
- struct ip_vs_dest_entry entrytable[0];
+ struct ip_vs_dest_entry entrytable[];
};
@@ -264,7 +264,7 @@ struct ip_vs_get_services {
unsigned int num_services;
/* service table */
- struct ip_vs_service_entry entrytable[0];
+ struct ip_vs_service_entry entrytable[];
};
diff --git a/lib/libc/include/any-linux-any/linux/ipmi_ssif_bmc.h b/lib/libc/include/any-linux-any/linux/ipmi_ssif_bmc.h
new file mode 100644
index 0000000000..8d83d3beb3
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/ipmi_ssif_bmc.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note*/
+/*
+ * Copyright (c) 2022, Ampere Computing LLC.
+ */
+
+#ifndef _LINUX_IPMI_SSIF_BMC_H
+#define _LINUX_IPMI_SSIF_BMC_H
+
+#include <linux/types.h>
+
+/* Max length of ipmi ssif message included netfn and cmd field */
+#define IPMI_SSIF_PAYLOAD_MAX 254
+struct ipmi_ssif_msg {
+ unsigned int len;
+ __u8 payload[IPMI_SSIF_PAYLOAD_MAX];
+};
+
+#endif /* _LINUX_IPMI_SSIF_BMC_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/ipv6.h b/lib/libc/include/any-linux-any/linux/ipv6.h
index e09e8f2cd8..66c9a81948 100644
--- a/lib/libc/include/any-linux-any/linux/ipv6.h
+++ b/lib/libc/include/any-linux-any/linux/ipv6.h
@@ -4,6 +4,7 @@
#include <linux/libc-compat.h>
#include <linux/types.h>
+#include <linux/stddef.h>
#include <linux/in6.h>
#include <asm/byteorder.h>
@@ -130,8 +131,10 @@ struct ipv6hdr {
__u8 nexthdr;
__u8 hop_limit;
- struct in6_addr saddr;
- struct in6_addr daddr;
+ __struct_group(/* no tag */, addrs, /* no attrs */,
+ struct in6_addr saddr;
+ struct in6_addr daddr;
+ );
};
@@ -194,6 +197,7 @@ enum {
DEVCONF_IOAM6_ID,
DEVCONF_IOAM6_ID_WIDE,
DEVCONF_NDISC_EVICT_NOCARRIER,
+ DEVCONF_ACCEPT_UNTRACKED_NA,
DEVCONF_MAX
};
diff --git a/lib/libc/include/any-linux-any/linux/iso_fs.h b/lib/libc/include/any-linux-any/linux/iso_fs.h
index 88cbfc8a93..f94d0d24f6 100644
--- a/lib/libc/include/any-linux-any/linux/iso_fs.h
+++ b/lib/libc/include/any-linux-any/linux/iso_fs.h
@@ -137,7 +137,7 @@ struct iso_path_table{
__u8 name_len[2]; /* 721 */
__u8 extent[4]; /* 731 */
__u8 parent[2]; /* 721 */
- char name[0];
+ char name[];
} __attribute__((packed));
/* high sierra is identical to iso, except that the date is only 6 bytes, and
@@ -154,7 +154,7 @@ struct iso_directory_record {
__u8 interleave [ISODCL (28, 28)]; /* 711 */
__u8 volume_sequence_number [ISODCL (29, 32)]; /* 723 */
__u8 name_len [ISODCL (33, 33)]; /* 711 */
- char name [0];
+ char name [];
} __attribute__((packed));
#define ISOFS_BLOCK_BITS 11
diff --git a/lib/libc/include/any-linux-any/linux/jffs2.h b/lib/libc/include/any-linux-any/linux/jffs2.h
index ded2d866ae..ef0d84520a 100644
--- a/lib/libc/include/any-linux-any/linux/jffs2.h
+++ b/lib/libc/include/any-linux-any/linux/jffs2.h
@@ -123,7 +123,7 @@ struct jffs2_raw_dirent
__u8 unused[2];
jint32_t node_crc;
jint32_t name_crc;
- __u8 name[0];
+ __u8 name[];
};
/* The JFFS2 raw inode structure: Used for storage on physical media. */
@@ -155,7 +155,7 @@ struct jffs2_raw_inode
jint16_t flags; /* See JFFS2_INO_FLAG_* */
jint32_t data_crc; /* CRC for the (compressed) data. */
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
- __u8 data[0];
+ __u8 data[];
};
struct jffs2_raw_xattr {
@@ -170,7 +170,7 @@ struct jffs2_raw_xattr {
jint16_t value_len;
jint32_t data_crc;
jint32_t node_crc;
- __u8 data[0];
+ __u8 data[];
} __attribute__((packed));
struct jffs2_raw_xref
@@ -196,7 +196,7 @@ struct jffs2_raw_summary
jint32_t padded; /* sum of the size of padding nodes */
jint32_t sum_crc; /* summary information crc */
jint32_t node_crc; /* node crc */
- jint32_t sum[0]; /* inode summary info */
+ jint32_t sum[]; /* inode summary info */
};
union jffs2_node_union
diff --git a/lib/libc/include/any-linux-any/linux/kcov.h b/lib/libc/include/any-linux-any/linux/kcov.h
index 7c375c2052..6b3a32e000 100644
--- a/lib/libc/include/any-linux-any/linux/kcov.h
+++ b/lib/libc/include/any-linux-any/linux/kcov.h
@@ -13,7 +13,7 @@ struct kcov_remote_arg {
__u32 area_size; /* Length of coverage buffer in words */
__u32 num_handles; /* Size of handles array */
__aligned_u64 common_handle;
- __aligned_u64 handles[0];
+ __aligned_u64 handles[];
};
#define KCOV_REMOTE_MAX_HANDLES 0x100
diff --git a/lib/libc/include/any-linux-any/linux/kd.h b/lib/libc/include/any-linux-any/linux/kd.h
index 73a11d454e..0263aee027 100644
--- a/lib/libc/include/any-linux-any/linux/kd.h
+++ b/lib/libc/include/any-linux-any/linux/kd.h
@@ -161,19 +161,25 @@ struct console_font_op {
unsigned int flags; /* KD_FONT_FLAG_* */
unsigned int width, height; /* font size */
unsigned int charcount;
- unsigned char *data; /* font data with height fixed to 32 */
+ unsigned char *data; /* font data with vpitch fixed to 32 for
+ * KD_FONT_OP_SET/GET
+ */
};
struct console_font {
unsigned int width, height; /* font size */
unsigned int charcount;
- unsigned char *data; /* font data with height fixed to 32 */
+ unsigned char *data; /* font data with vpitch fixed to 32 for
+ * KD_FONT_OP_SET/GET
+ */
};
#define KD_FONT_OP_SET 0 /* Set font */
#define KD_FONT_OP_GET 1 /* Get font */
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */
#define KD_FONT_OP_COPY 3 /* Obsolete, do not use */
+#define KD_FONT_OP_SET_TALL 4 /* Set font with vpitch = height */
+#define KD_FONT_OP_GET_TALL 5 /* Get font with vpitch = height */
#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */
diff --git a/lib/libc/include/any-linux-any/linux/kexec.h b/lib/libc/include/any-linux-any/linux/kexec.h
index 3bafe3ccc6..3d78e69493 100644
--- a/lib/libc/include/any-linux-any/linux/kexec.h
+++ b/lib/libc/include/any-linux-any/linux/kexec.h
@@ -43,6 +43,7 @@
#define KEXEC_ARCH_MIPS ( 8 << 16)
#define KEXEC_ARCH_AARCH64 (183 << 16)
#define KEXEC_ARCH_RISCV (243 << 16)
+#define KEXEC_ARCH_LOONGARCH (258 << 16)
/* The artificial cap on the number of segments passed to kexec_load. */
#define KEXEC_SEGMENT_MAX 16
@@ -53,9 +54,9 @@
*/
struct kexec_segment {
const void *buf;
- size_t bufsz;
+ __kernel_size_t bufsz;
const void *mem;
- size_t memsz;
+ __kernel_size_t memsz;
};
diff --git a/lib/libc/include/any-linux-any/linux/kfd_ioctl.h b/lib/libc/include/any-linux-any/linux/kfd_ioctl.h
index 93e2d6fad3..4358bcd75b 100644
--- a/lib/libc/include/any-linux-any/linux/kfd_ioctl.h
+++ b/lib/libc/include/any-linux-any/linux/kfd_ioctl.h
@@ -32,9 +32,14 @@
* - 1.4 - Indicate new SRAM EDC bit in device properties
* - 1.5 - Add SVM API
* - 1.6 - Query clear flags in SVM get_attr API
+ * - 1.7 - Checkpoint Restore (CRIU) API
+ * - 1.8 - CRIU - Support for SDMA transfers with GTT BOs
+ * - 1.9 - Add available memory ioctl
+ * - 1.10 - Add SMI profiler event log
+ * - 1.11 - Add unified memory for ctx save/restore area
*/
#define KFD_IOCTL_MAJOR_VERSION 1
-#define KFD_IOCTL_MINOR_VERSION 6
+#define KFD_IOCTL_MINOR_VERSION 11
struct kfd_ioctl_get_version_args {
__u32 major_version; /* from KFD */
@@ -98,6 +103,12 @@ struct kfd_ioctl_get_queue_wave_state_args {
__u32 pad;
};
+struct kfd_ioctl_get_available_memory_args {
+ __u64 available; /* from KFD */
+ __u32 gpu_id; /* to KFD */
+ __u32 pad;
+};
+
/* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */
#define KFD_IOC_CACHE_POLICY_COHERENT 0
#define KFD_IOC_CACHE_POLICY_NONCOHERENT 1
@@ -194,6 +205,8 @@ struct kfd_ioctl_dbg_wave_control_args {
__u32 buf_size_in_bytes; /*including gpu_id and buf_size */
};
+#define KFD_INVALID_FD 0xffffffff
+
/* Matching HSA_EVENTTYPE */
#define KFD_IOC_EVENT_SIGNAL 0
#define KFD_IOC_EVENT_NODECHANGE 1
@@ -459,15 +472,129 @@ enum kfd_smi_event {
KFD_SMI_EVENT_THERMAL_THROTTLE = 2,
KFD_SMI_EVENT_GPU_PRE_RESET = 3,
KFD_SMI_EVENT_GPU_POST_RESET = 4,
+ KFD_SMI_EVENT_MIGRATE_START = 5,
+ KFD_SMI_EVENT_MIGRATE_END = 6,
+ KFD_SMI_EVENT_PAGE_FAULT_START = 7,
+ KFD_SMI_EVENT_PAGE_FAULT_END = 8,
+ KFD_SMI_EVENT_QUEUE_EVICTION = 9,
+ KFD_SMI_EVENT_QUEUE_RESTORE = 10,
+ KFD_SMI_EVENT_UNMAP_FROM_GPU = 11,
+
+ /*
+ * max event number, as a flag bit to get events from all processes,
+ * this requires super user permission, otherwise will not be able to
+ * receive event from any process. Without this flag to receive events
+ * from same process.
+ */
+ KFD_SMI_EVENT_ALL_PROCESS = 64
+};
+
+enum KFD_MIGRATE_TRIGGERS {
+ KFD_MIGRATE_TRIGGER_PREFETCH,
+ KFD_MIGRATE_TRIGGER_PAGEFAULT_GPU,
+ KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU,
+ KFD_MIGRATE_TRIGGER_TTM_EVICTION
+};
+
+enum KFD_QUEUE_EVICTION_TRIGGERS {
+ KFD_QUEUE_EVICTION_TRIGGER_SVM,
+ KFD_QUEUE_EVICTION_TRIGGER_USERPTR,
+ KFD_QUEUE_EVICTION_TRIGGER_TTM,
+ KFD_QUEUE_EVICTION_TRIGGER_SUSPEND,
+ KFD_QUEUE_EVICTION_CRIU_CHECKPOINT,
+ KFD_QUEUE_EVICTION_CRIU_RESTORE
+};
+
+enum KFD_SVM_UNMAP_TRIGGERS {
+ KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY,
+ KFD_SVM_UNMAP_TRIGGER_MMU_NOTIFY_MIGRATE,
+ KFD_SVM_UNMAP_TRIGGER_UNMAP_FROM_CPU
};
#define KFD_SMI_EVENT_MASK_FROM_INDEX(i) (1ULL << ((i) - 1))
+#define KFD_SMI_EVENT_MSG_SIZE 96
struct kfd_ioctl_smi_events_args {
__u32 gpuid; /* to KFD */
__u32 anon_fd; /* from KFD */
};
+/**************************************************************************************************
+ * CRIU IOCTLs (Checkpoint Restore In Userspace)
+ *
+ * When checkpointing a process, the userspace application will perform:
+ * 1. PROCESS_INFO op to determine current process information. This pauses execution and evicts
+ * all the queues.
+ * 2. CHECKPOINT op to checkpoint process contents (BOs, queues, events, svm-ranges)
+ * 3. UNPAUSE op to un-evict all the queues
+ *
+ * When restoring a process, the CRIU userspace application will perform:
+ *
+ * 1. RESTORE op to restore process contents
+ * 2. RESUME op to start the process
+ *
+ * Note: Queues are forced into an evicted state after a successful PROCESS_INFO. User
+ * application needs to perform an UNPAUSE operation after calling PROCESS_INFO.
+ */
+
+enum kfd_criu_op {
+ KFD_CRIU_OP_PROCESS_INFO,
+ KFD_CRIU_OP_CHECKPOINT,
+ KFD_CRIU_OP_UNPAUSE,
+ KFD_CRIU_OP_RESTORE,
+ KFD_CRIU_OP_RESUME,
+};
+
+/**
+ * kfd_ioctl_criu_args - Arguments perform CRIU operation
+ * @devices: [in/out] User pointer to memory location for devices information.
+ * This is an array of type kfd_criu_device_bucket.
+ * @bos: [in/out] User pointer to memory location for BOs information
+ * This is an array of type kfd_criu_bo_bucket.
+ * @priv_data: [in/out] User pointer to memory location for private data
+ * @priv_data_size: [in/out] Size of priv_data in bytes
+ * @num_devices: [in/out] Number of GPUs used by process. Size of @devices array.
+ * @num_bos [in/out] Number of BOs used by process. Size of @bos array.
+ * @num_objects: [in/out] Number of objects used by process. Objects are opaque to
+ * user application.
+ * @pid: [in/out] PID of the process being checkpointed
+ * @op [in] Type of operation (kfd_criu_op)
+ *
+ * Return: 0 on success, -errno on failure
+ */
+struct kfd_ioctl_criu_args {
+ __u64 devices; /* Used during ops: CHECKPOINT, RESTORE */
+ __u64 bos; /* Used during ops: CHECKPOINT, RESTORE */
+ __u64 priv_data; /* Used during ops: CHECKPOINT, RESTORE */
+ __u64 priv_data_size; /* Used during ops: PROCESS_INFO, RESTORE */
+ __u32 num_devices; /* Used during ops: PROCESS_INFO, RESTORE */
+ __u32 num_bos; /* Used during ops: PROCESS_INFO, RESTORE */
+ __u32 num_objects; /* Used during ops: PROCESS_INFO, RESTORE */
+ __u32 pid; /* Used during ops: PROCESS_INFO, RESUME */
+ __u32 op;
+};
+
+struct kfd_criu_device_bucket {
+ __u32 user_gpu_id;
+ __u32 actual_gpu_id;
+ __u32 drm_fd;
+ __u32 pad;
+};
+
+struct kfd_criu_bo_bucket {
+ __u64 addr;
+ __u64 size;
+ __u64 offset;
+ __u64 restored_offset; /* During restore, updated offset for BO */
+ __u32 gpu_id; /* This is the user_gpu_id */
+ __u32 alloc_flags;
+ __u32 dmabuf_fd;
+ __u32 pad;
+};
+
+/* CRIU IOCTLs - END */
+/**************************************************************************************************/
+
/* Register offset inside the remapped mmio page
*/
enum kfd_mmio_remap {
@@ -487,6 +614,8 @@ enum kfd_mmio_remap {
#define KFD_IOCTL_SVM_FLAG_GPU_EXEC 0x00000010
/* GPUs mostly read, may allow similar optimizations as RO, but writes fault */
#define KFD_IOCTL_SVM_FLAG_GPU_READ_MOSTLY 0x00000020
+/* Keep GPU memory mapping always valid as if XNACK is disable */
+#define KFD_IOCTL_SVM_FLAG_GPU_ALWAYS_MAPPED 0x00000040
/**
* kfd_ioctl_svm_op - SVM ioctl operations
@@ -596,7 +725,7 @@ struct kfd_ioctl_svm_args {
__u32 op;
__u32 nattr;
/* Variable length array of attributes */
- struct kfd_ioctl_svm_attribute attrs[0];
+ struct kfd_ioctl_svm_attribute attrs[];
};
/**
@@ -679,16 +808,16 @@ struct kfd_ioctl_set_xnack_mode_args {
#define AMDKFD_IOC_WAIT_EVENTS \
AMDKFD_IOWR(0x0C, struct kfd_ioctl_wait_events_args)
-#define AMDKFD_IOC_DBG_REGISTER \
+#define AMDKFD_IOC_DBG_REGISTER_DEPRECATED \
AMDKFD_IOW(0x0D, struct kfd_ioctl_dbg_register_args)
-#define AMDKFD_IOC_DBG_UNREGISTER \
+#define AMDKFD_IOC_DBG_UNREGISTER_DEPRECATED \
AMDKFD_IOW(0x0E, struct kfd_ioctl_dbg_unregister_args)
-#define AMDKFD_IOC_DBG_ADDRESS_WATCH \
+#define AMDKFD_IOC_DBG_ADDRESS_WATCH_DEPRECATED \
AMDKFD_IOW(0x0F, struct kfd_ioctl_dbg_address_watch_args)
-#define AMDKFD_IOC_DBG_WAVE_CONTROL \
+#define AMDKFD_IOC_DBG_WAVE_CONTROL_DEPRECATED \
AMDKFD_IOW(0x10, struct kfd_ioctl_dbg_wave_control_args)
#define AMDKFD_IOC_SET_SCRATCH_BACKING_VA \
@@ -742,7 +871,13 @@ struct kfd_ioctl_set_xnack_mode_args {
#define AMDKFD_IOC_SET_XNACK_MODE \
AMDKFD_IOWR(0x21, struct kfd_ioctl_set_xnack_mode_args)
+#define AMDKFD_IOC_CRIU_OP \
+ AMDKFD_IOWR(0x22, struct kfd_ioctl_criu_args)
+
+#define AMDKFD_IOC_AVAILABLE_MEMORY \
+ AMDKFD_IOWR(0x23, struct kfd_ioctl_get_available_memory_args)
+
#define AMDKFD_COMMAND_START 0x01
-#define AMDKFD_COMMAND_END 0x22
+#define AMDKFD_COMMAND_END 0x24
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/kfd_sysfs.h b/lib/libc/include/any-linux-any/linux/kfd_sysfs.h
new file mode 100644
index 0000000000..81f035692c
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/kfd_sysfs.h
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */
+/*
+ * Copyright 2021 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef KFD_SYSFS_H_INCLUDED
+#define KFD_SYSFS_H_INCLUDED
+
+/* Capability bits in node properties */
+#define HSA_CAP_HOT_PLUGGABLE 0x00000001
+#define HSA_CAP_ATS_PRESENT 0x00000002
+#define HSA_CAP_SHARED_WITH_GRAPHICS 0x00000004
+#define HSA_CAP_QUEUE_SIZE_POW2 0x00000008
+#define HSA_CAP_QUEUE_SIZE_32BIT 0x00000010
+#define HSA_CAP_QUEUE_IDLE_EVENT 0x00000020
+#define HSA_CAP_VA_LIMIT 0x00000040
+#define HSA_CAP_WATCH_POINTS_SUPPORTED 0x00000080
+#define HSA_CAP_WATCH_POINTS_TOTALBITS_MASK 0x00000f00
+#define HSA_CAP_WATCH_POINTS_TOTALBITS_SHIFT 8
+#define HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK 0x00003000
+#define HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT 12
+
+#define HSA_CAP_DOORBELL_TYPE_PRE_1_0 0x0
+#define HSA_CAP_DOORBELL_TYPE_1_0 0x1
+#define HSA_CAP_DOORBELL_TYPE_2_0 0x2
+#define HSA_CAP_AQL_QUEUE_DOUBLE_MAP 0x00004000
+
+/* Old buggy user mode depends on this being 0 */
+#define HSA_CAP_RESERVED_WAS_SRAM_EDCSUPPORTED 0x00080000
+
+#define HSA_CAP_MEM_EDCSUPPORTED 0x00100000
+#define HSA_CAP_RASEVENTNOTIFY 0x00200000
+#define HSA_CAP_ASIC_REVISION_MASK 0x03c00000
+#define HSA_CAP_ASIC_REVISION_SHIFT 22
+#define HSA_CAP_SRAM_EDCSUPPORTED 0x04000000
+#define HSA_CAP_SVMAPI_SUPPORTED 0x08000000
+#define HSA_CAP_FLAGS_COHERENTHOSTACCESS 0x10000000
+#define HSA_CAP_RESERVED 0xe00f8000
+
+/* Heap types in memory properties */
+#define HSA_MEM_HEAP_TYPE_SYSTEM 0
+#define HSA_MEM_HEAP_TYPE_FB_PUBLIC 1
+#define HSA_MEM_HEAP_TYPE_FB_PRIVATE 2
+#define HSA_MEM_HEAP_TYPE_GPU_GDS 3
+#define HSA_MEM_HEAP_TYPE_GPU_LDS 4
+#define HSA_MEM_HEAP_TYPE_GPU_SCRATCH 5
+
+/* Flag bits in memory properties */
+#define HSA_MEM_FLAGS_HOT_PLUGGABLE 0x00000001
+#define HSA_MEM_FLAGS_NON_VOLATILE 0x00000002
+#define HSA_MEM_FLAGS_RESERVED 0xfffffffc
+
+/* Cache types in cache properties */
+#define HSA_CACHE_TYPE_DATA 0x00000001
+#define HSA_CACHE_TYPE_INSTRUCTION 0x00000002
+#define HSA_CACHE_TYPE_CPU 0x00000004
+#define HSA_CACHE_TYPE_HSACU 0x00000008
+#define HSA_CACHE_TYPE_RESERVED 0xfffffff0
+
+/* Link types in IO link properties (matches CRAT link types) */
+#define HSA_IOLINK_TYPE_UNDEFINED 0
+#define HSA_IOLINK_TYPE_HYPERTRANSPORT 1
+#define HSA_IOLINK_TYPE_PCIEXPRESS 2
+#define HSA_IOLINK_TYPE_AMBA 3
+#define HSA_IOLINK_TYPE_MIPI 4
+#define HSA_IOLINK_TYPE_QPI_1_1 5
+#define HSA_IOLINK_TYPE_RESERVED1 6
+#define HSA_IOLINK_TYPE_RESERVED2 7
+#define HSA_IOLINK_TYPE_RAPID_IO 8
+#define HSA_IOLINK_TYPE_INFINIBAND 9
+#define HSA_IOLINK_TYPE_RESERVED3 10
+#define HSA_IOLINK_TYPE_XGMI 11
+#define HSA_IOLINK_TYPE_XGOP 12
+#define HSA_IOLINK_TYPE_GZ 13
+#define HSA_IOLINK_TYPE_ETHERNET_RDMA 14
+#define HSA_IOLINK_TYPE_RDMA_OTHER 15
+#define HSA_IOLINK_TYPE_OTHER 16
+
+/* Flag bits in IO link properties (matches CRAT flags, excluding the
+ * bi-directional flag, which is not offially part of the CRAT spec, and
+ * only used internally in KFD)
+ */
+#define HSA_IOLINK_FLAGS_ENABLED (1 << 0)
+#define HSA_IOLINK_FLAGS_NON_COHERENT (1 << 1)
+#define HSA_IOLINK_FLAGS_NO_ATOMICS_32_BIT (1 << 2)
+#define HSA_IOLINK_FLAGS_NO_ATOMICS_64_BIT (1 << 3)
+#define HSA_IOLINK_FLAGS_NO_PEER_TO_PEER_DMA (1 << 4)
+#define HSA_IOLINK_FLAGS_RESERVED 0xffffffe0
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/kvm.h b/lib/libc/include/any-linux-any/linux/kvm.h
index a2e5c29258..442231416d 100644
--- a/lib/libc/include/any-linux-any/linux/kvm.h
+++ b/lib/libc/include/any-linux-any/linux/kvm.h
@@ -86,14 +86,6 @@ struct kvm_debug_guest {
/* *** End of deprecated interfaces *** */
-/* for KVM_CREATE_MEMORY_REGION */
-struct kvm_memory_region {
- __u32 slot;
- __u32 flags;
- __u64 guest_phys_addr;
- __u64 memory_size; /* bytes */
-};
-
/* for KVM_SET_USER_MEMORY_REGION */
struct kvm_userspace_memory_region {
__u32 slot;
@@ -104,9 +96,9 @@ struct kvm_userspace_memory_region {
};
/*
- * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace,
- * other bits are reserved for kvm internal use which are defined in
- * include/linux/kvm_host.h.
+ * The bit 0 ~ bit 15 of kvm_userspace_memory_region::flags are visible for
+ * userspace, other bits are reserved for kvm internal use which are defined
+ * in include/linux/kvm_host.h.
*/
#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0)
#define KVM_MEM_READONLY (1UL << 1)
@@ -270,6 +262,8 @@ struct kvm_xen_exit {
#define KVM_EXIT_X86_BUS_LOCK 33
#define KVM_EXIT_XEN 34
#define KVM_EXIT_RISCV_SBI 35
+#define KVM_EXIT_RISCV_CSR 36
+#define KVM_EXIT_NOTIFY 37
/* For KVM_EXIT_INTERNAL_ERROR */
/* Emulate instruction failed. */
@@ -444,8 +438,15 @@ struct kvm_run {
#define KVM_SYSTEM_EVENT_SHUTDOWN 1
#define KVM_SYSTEM_EVENT_RESET 2
#define KVM_SYSTEM_EVENT_CRASH 3
+#define KVM_SYSTEM_EVENT_WAKEUP 4
+#define KVM_SYSTEM_EVENT_SUSPEND 5
+#define KVM_SYSTEM_EVENT_SEV_TERM 6
__u32 type;
- __u64 flags;
+ __u32 ndata;
+ union {
+ __u64 flags;
+ __u64 data[16];
+ };
} system_event;
/* KVM_EXIT_S390_STSI */
struct {
@@ -474,6 +475,9 @@ struct kvm_run {
#define KVM_MSR_EXIT_REASON_INVAL (1 << 0)
#define KVM_MSR_EXIT_REASON_UNKNOWN (1 << 1)
#define KVM_MSR_EXIT_REASON_FILTER (1 << 2)
+#define KVM_MSR_EXIT_REASON_VALID_MASK (KVM_MSR_EXIT_REASON_INVAL | \
+ KVM_MSR_EXIT_REASON_UNKNOWN | \
+ KVM_MSR_EXIT_REASON_FILTER)
__u32 reason; /* kernel -> user */
__u32 index; /* kernel -> user */
__u64 data; /* kernel <-> user */
@@ -487,6 +491,18 @@ struct kvm_run {
unsigned long args[6];
unsigned long ret[2];
} riscv_sbi;
+ /* KVM_EXIT_RISCV_CSR */
+ struct {
+ unsigned long csr_num;
+ unsigned long new_value;
+ unsigned long write_mask;
+ unsigned long ret_value;
+ } riscv_csr;
+ /* KVM_EXIT_NOTIFY */
+ struct {
+#define KVM_NOTIFY_CONTEXT_INVALID (1 << 0)
+ __u32 flags;
+ } notify;
/* Fix the size of the union. */
char padding[256];
};
@@ -533,7 +549,7 @@ struct kvm_coalesced_mmio {
struct kvm_coalesced_mmio_ring {
__u32 first, last;
- struct kvm_coalesced_mmio coalesced_mmio[0];
+ struct kvm_coalesced_mmio coalesced_mmio[];
};
#define KVM_COALESCED_MMIO_MAX \
@@ -562,9 +578,14 @@ struct kvm_s390_mem_op {
__u32 op; /* type of operation */
__u64 buf; /* buffer in userspace */
union {
- __u8 ar; /* the access register number */
+ struct {
+ __u8 ar; /* the access register number */
+ __u8 key; /* access key, ignored if flag unset */
+ __u8 pad1[6]; /* ignored */
+ __u64 old_addr; /* ignored if cmpxchg flag unset */
+ };
__u32 sida_offset; /* offset into the sida */
- __u8 reserved[32]; /* should be set to 0 */
+ __u8 reserved[32]; /* ignored */
};
};
/* types for kvm_s390_mem_op->op */
@@ -572,9 +593,18 @@ struct kvm_s390_mem_op {
#define KVM_S390_MEMOP_LOGICAL_WRITE 1
#define KVM_S390_MEMOP_SIDA_READ 2
#define KVM_S390_MEMOP_SIDA_WRITE 3
+#define KVM_S390_MEMOP_ABSOLUTE_READ 4
+#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5
+#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6
+
/* flags for kvm_s390_mem_op->flags */
#define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
+#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2)
+
+/* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */
+#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0)
+#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1)
/* for KVM_INTERRUPT */
struct kvm_interrupt {
@@ -606,7 +636,7 @@ struct kvm_clear_dirty_log {
/* for KVM_SET_SIGNAL_MASK */
struct kvm_signal_mask {
__u32 len;
- __u8 sigset[0];
+ __u8 sigset[];
};
/* for KVM_TPR_ACCESS_REPORTING */
@@ -634,6 +664,7 @@ struct kvm_vapic_addr {
#define KVM_MP_STATE_OPERATING 7
#define KVM_MP_STATE_LOAD 8
#define KVM_MP_STATE_AP_RESET_HOLD 9
+#define KVM_MP_STATE_SUSPENDED 10
struct kvm_mp_state {
__u32 mp_state;
@@ -1131,6 +1162,26 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204
#define KVM_CAP_ARM_MTE 205
#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206
+#define KVM_CAP_VM_GPA_BITS 207
+#define KVM_CAP_XSAVE2 208
+#define KVM_CAP_SYS_ATTRIBUTES 209
+#define KVM_CAP_PPC_AIL_MODE_3 210
+#define KVM_CAP_S390_MEM_OP_EXTENSION 211
+#define KVM_CAP_PMU_CAPABILITY 212
+#define KVM_CAP_DISABLE_QUIRKS2 213
+#define KVM_CAP_VM_TSC_CONTROL 214
+#define KVM_CAP_SYSTEM_EVENT_DATA 215
+#define KVM_CAP_ARM_SYSTEM_SUSPEND 216
+#define KVM_CAP_S390_PROTECTED_DUMP 217
+#define KVM_CAP_X86_TRIPLE_FAULT_EVENT 218
+#define KVM_CAP_X86_NOTIFY_VMEXIT 219
+#define KVM_CAP_VM_DISABLE_NX_HUGE_PAGES 220
+#define KVM_CAP_S390_ZPCI_OP 221
+#define KVM_CAP_S390_CPU_TOPOLOGY 222
+#define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223
+#define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224
+#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
+#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
#ifdef KVM_CAP_IRQ_ROUTING
@@ -1162,11 +1213,20 @@ struct kvm_irq_routing_hv_sint {
__u32 sint;
};
+struct kvm_irq_routing_xen_evtchn {
+ __u32 port;
+ __u32 vcpu;
+ __u32 priority;
+};
+
+#define KVM_IRQ_ROUTING_XEN_EVTCHN_PRIO_2LEVEL ((__u32)(-1))
+
/* gsi routing entry types */
#define KVM_IRQ_ROUTING_IRQCHIP 1
#define KVM_IRQ_ROUTING_MSI 2
#define KVM_IRQ_ROUTING_S390_ADAPTER 3
#define KVM_IRQ_ROUTING_HV_SINT 4
+#define KVM_IRQ_ROUTING_XEN_EVTCHN 5
struct kvm_irq_routing_entry {
__u32 gsi;
@@ -1178,6 +1238,7 @@ struct kvm_irq_routing_entry {
struct kvm_irq_routing_msi msi;
struct kvm_irq_routing_s390_adapter adapter;
struct kvm_irq_routing_hv_sint hv_sint;
+ struct kvm_irq_routing_xen_evtchn xen_evtchn;
__u32 pad[8];
} u;
};
@@ -1185,7 +1246,7 @@ struct kvm_irq_routing_entry {
struct kvm_irq_routing {
__u32 nr;
__u32 flags;
- struct kvm_irq_routing_entry entries[0];
+ struct kvm_irq_routing_entry entries[];
};
#endif
@@ -1208,6 +1269,9 @@ struct kvm_x86_mce {
#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
#define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
#define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
+#define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
+#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
+#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
struct kvm_xen_hvm_config {
__u32 flags;
@@ -1303,7 +1367,7 @@ struct kvm_dirty_tlb {
struct kvm_reg_list {
__u64 n; /* number of regs */
- __u64 reg[0];
+ __u64 reg[];
};
struct kvm_one_reg {
@@ -1379,17 +1443,11 @@ struct kvm_vfio_spapr_tce {
};
/*
- * ioctls for VM fds
- */
-#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
-/*
* KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
* a vcpu fd.
*/
#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
-/* KVM_SET_MEMORY_ALIAS is obsolete: */
-#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46, \
@@ -1446,7 +1504,8 @@ struct kvm_s390_ucas_mapping {
#define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2)
/* Available with KVM_CAP_PPC_GET_PVINFO */
#define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo)
-/* Available with KVM_CAP_TSC_CONTROL */
+/* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with
+* KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */
#define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2)
#define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3)
/* Available with KVM_CAP_PCI_2_3 */
@@ -1621,6 +1680,55 @@ struct kvm_s390_pv_unp {
__u64 tweak;
};
+enum pv_cmd_dmp_id {
+ KVM_PV_DUMP_INIT,
+ KVM_PV_DUMP_CONFIG_STOR_STATE,
+ KVM_PV_DUMP_COMPLETE,
+ KVM_PV_DUMP_CPU,
+};
+
+struct kvm_s390_pv_dmp {
+ __u64 subcmd;
+ __u64 buff_addr;
+ __u64 buff_len;
+ __u64 gaddr; /* For dump storage state */
+ __u64 reserved[4];
+};
+
+enum pv_cmd_info_id {
+ KVM_PV_INFO_VM,
+ KVM_PV_INFO_DUMP,
+};
+
+struct kvm_s390_pv_info_dump {
+ __u64 dump_cpu_buffer_len;
+ __u64 dump_config_mem_buffer_per_1m;
+ __u64 dump_config_finalize_len;
+};
+
+struct kvm_s390_pv_info_vm {
+ __u64 inst_calls_list[4];
+ __u64 max_cpus;
+ __u64 max_guests;
+ __u64 max_guest_addr;
+ __u64 feature_indication;
+};
+
+struct kvm_s390_pv_info_header {
+ __u32 id;
+ __u32 len_max;
+ __u32 len_written;
+ __u32 reserved;
+};
+
+struct kvm_s390_pv_info {
+ struct kvm_s390_pv_info_header header;
+ union {
+ struct kvm_s390_pv_info_dump dump;
+ struct kvm_s390_pv_info_vm vm;
+ };
+};
+
enum pv_cmd_id {
KVM_PV_ENABLE,
KVM_PV_DISABLE,
@@ -1629,6 +1737,10 @@ enum pv_cmd_id {
KVM_PV_VERIFY,
KVM_PV_PREP_RESET,
KVM_PV_UNSHARE_ALL,
+ KVM_PV_INFO,
+ KVM_PV_DUMP,
+ KVM_PV_ASYNC_CLEANUP_PREPARE,
+ KVM_PV_ASYNC_CLEANUP_PERFORM,
};
struct kvm_pv_cmd {
@@ -1659,22 +1771,59 @@ struct kvm_xen_hvm_attr {
union {
__u8 long_mode;
__u8 vector;
+ __u8 runstate_update_flag;
struct {
__u64 gfn;
+#define KVM_XEN_INVALID_GFN ((__u64)-1)
} shared_info;
+ struct {
+ __u32 send_port;
+ __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */
+ __u32 flags;
+#define KVM_XEN_EVTCHN_DEASSIGN (1 << 0)
+#define KVM_XEN_EVTCHN_UPDATE (1 << 1)
+#define KVM_XEN_EVTCHN_RESET (1 << 2)
+ /*
+ * Events sent by the guest are either looped back to
+ * the guest itself (potentially on a different port#)
+ * or signalled via an eventfd.
+ */
+ union {
+ struct {
+ __u32 port;
+ __u32 vcpu;
+ __u32 priority;
+ } port;
+ struct {
+ __u32 port; /* Zero for eventfd */
+ __s32 fd;
+ } eventfd;
+ __u32 padding[4];
+ } deliver;
+ } evtchn;
+ __u32 xen_version;
__u64 pad[8];
} u;
};
+
/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
+#define KVM_XEN_ATTR_TYPE_EVTCHN 0x3
+#define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG */
+#define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5
/* Per-vCPU Xen attributes */
#define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
#define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
+#define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_xen_evtchn)
+
#define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2)
#define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2)
@@ -1683,6 +1832,7 @@ struct kvm_xen_vcpu_attr {
__u16 pad[3];
union {
__u64 gpa;
+#define KVM_XEN_INVALID_GPA ((__u64)-1)
__u64 pad[8];
struct {
__u64 state;
@@ -1692,6 +1842,13 @@ struct kvm_xen_vcpu_attr {
__u64 time_blocked;
__u64 time_offline;
} runstate;
+ __u32 vcpu_id;
+ struct {
+ __u32 port;
+ __u32 priority;
+ __u64 expires_ns;
+ } timer;
+ __u8 vector;
} u;
};
@@ -1702,6 +1859,10 @@ struct kvm_xen_vcpu_attr {
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4
#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5
+/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6
+#define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7
+#define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8
/* Secure Encrypted Virtualization command */
enum sev_cmd_id {
@@ -1956,6 +2117,8 @@ struct kvm_dirty_gfn {
#define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
#define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
+#define KVM_PMU_CAP_DISABLE (1 << 0)
+
/**
* struct kvm_stats_header - Header of per vm/vcpu binary statistics data.
* @flags: Some extra information for header, always 0 for now.
@@ -1999,7 +2162,8 @@ struct kvm_stats_header {
#define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
-#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
+#define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT)
+#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN
#define KVM_STATS_BASE_SHIFT 8
#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)
@@ -2031,4 +2195,44 @@ struct kvm_stats_desc {
#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)
+/* Available with KVM_CAP_XSAVE2 */
+#define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave)
+
+/* Available with KVM_CAP_S390_PROTECTED_DUMP */
+#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd)
+
+/* Available with KVM_CAP_X86_NOTIFY_VMEXIT */
+#define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0)
+#define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1)
+
+/* Available with KVM_CAP_S390_ZPCI_OP */
+#define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op)
+
+struct kvm_s390_zpci_op {
+ /* in */
+ __u32 fh; /* target device */
+ __u8 op; /* operation to perform */
+ __u8 pad[3];
+ union {
+ /* for KVM_S390_ZPCIOP_REG_AEN */
+ struct {
+ __u64 ibv; /* Guest addr of interrupt bit vector */
+ __u64 sb; /* Guest addr of summary bit */
+ __u32 flags;
+ __u32 noi; /* Number of interrupts */
+ __u8 isc; /* Guest interrupt subclass */
+ __u8 sbo; /* Offset of guest summary bit vector */
+ __u16 pad;
+ } reg_aen;
+ __u64 reserved[8];
+ } u;
+};
+
+/* types for kvm_s390_zpci_op->op */
+#define KVM_S390_ZPCIOP_REG_AEN 0
+#define KVM_S390_ZPCIOP_DEREG_AEN 1
+
+/* flags for kvm_s390_zpci_op->u.reg_aen.flags */
+#define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0)
+
#endif /* __LINUX_KVM_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/l2tp.h b/lib/libc/include/any-linux-any/linux/l2tp.h
index 7900c2af88..e746051d28 100644
--- a/lib/libc/include/any-linux-any/linux/l2tp.h
+++ b/lib/libc/include/any-linux-any/linux/l2tp.h
@@ -13,8 +13,6 @@
#include <linux/in.h>
#include <linux/in6.h>
-#define IPPROTO_L2TP 115
-
/**
* struct sockaddr_l2tpip - the sockaddr structure for L2TP-over-IP sockets
* @l2tp_family: address family number AF_L2TPIP.
diff --git a/lib/libc/include/any-linux-any/linux/landlock.h b/lib/libc/include/any-linux-any/linux/landlock.h
index 802ee38bf7..51680fda0b 100644
--- a/lib/libc/include/any-linux-any/linux/landlock.h
+++ b/lib/libc/include/any-linux-any/linux/landlock.h
@@ -21,8 +21,14 @@ struct landlock_ruleset_attr {
/**
* @handled_access_fs: Bitmask of actions (cf. `Filesystem flags`_)
* that is handled by this ruleset and should then be forbidden if no
- * rule explicitly allow them. This is needed for backward
- * compatibility reasons.
+ * rule explicitly allow them: it is a deny-by-default list that should
+ * contain as much Landlock access rights as possible. Indeed, all
+ * Landlock filesystem access rights that are not part of
+ * handled_access_fs are allowed. This is needed for backward
+ * compatibility reasons. One exception is the
+ * %LANDLOCK_ACCESS_FS_REFER access right, which is always implicitly
+ * handled, but must still be explicitly handled to add new rules with
+ * this access right.
*/
__u64 handled_access_fs;
};
@@ -33,7 +39,9 @@ struct landlock_ruleset_attr {
* - %LANDLOCK_CREATE_RULESET_VERSION: Get the highest supported Landlock ABI
* version.
*/
+/* clang-format off */
#define LANDLOCK_CREATE_RULESET_VERSION (1U << 0)
+/* clang-format on */
/**
* enum landlock_rule_type - Landlock rule type
@@ -60,8 +68,9 @@ struct landlock_path_beneath_attr {
*/
__u64 allowed_access;
/**
- * @parent_fd: File descriptor, open with ``O_PATH``, which identifies
- * the parent directory of a file hierarchy, or just a file.
+ * @parent_fd: File descriptor, preferably opened with ``O_PATH``,
+ * which identifies the parent directory of a file hierarchy, or just a
+ * file.
*/
__s32 parent_fd;
/*
@@ -86,8 +95,19 @@ struct landlock_path_beneath_attr {
* A file can only receive these access rights:
*
* - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file.
- * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access.
+ * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. Note that
+ * you might additionally need the %LANDLOCK_ACCESS_FS_TRUNCATE right in order
+ * to overwrite files with :manpage:`open(2)` using ``O_TRUNC`` or
+ * :manpage:`creat(2)`.
* - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access.
+ * - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a file with :manpage:`truncate(2)`,
+ * :manpage:`ftruncate(2)`, :manpage:`creat(2)`, or :manpage:`open(2)` with
+ * ``O_TRUNC``. Whether an opened file can be truncated with
+ * :manpage:`ftruncate(2)` is determined during :manpage:`open(2)`, in the
+ * same way as read and write permissions are checked during
+ * :manpage:`open(2)` using %LANDLOCK_ACCESS_FS_READ_FILE and
+ * %LANDLOCK_ACCESS_FS_WRITE_FILE. This access right is available since the
+ * third version of the Landlock ABI.
*
* A directory can receive access rights related to files or directories. The
* following access right is applied to the directory itself, and the
@@ -109,17 +129,33 @@ struct landlock_path_beneath_attr {
* - %LANDLOCK_ACCESS_FS_MAKE_FIFO: Create (or rename or link) a named pipe.
* - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device.
* - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link.
+ * - %LANDLOCK_ACCESS_FS_REFER: Link or rename a file from or to a different
+ * directory (i.e. reparent a file hierarchy). This access right is
+ * available since the second version of the Landlock ABI. This is also the
+ * only access right which is always considered handled by any ruleset in
+ * such a way that reparenting a file hierarchy is always denied by default.
+ * To avoid privilege escalation, it is not enough to add a rule with this
+ * access right. When linking or renaming a file, the destination directory
+ * hierarchy must also always have the same or a superset of restrictions of
+ * the source hierarchy. If it is not the case, or if the domain doesn't
+ * handle this access right, such actions are denied by default with errno
+ * set to ``EXDEV``. Linking also requires a ``LANDLOCK_ACCESS_FS_MAKE_*``
+ * access right on the destination directory, and renaming also requires a
+ * ``LANDLOCK_ACCESS_FS_REMOVE_*`` access right on the source's (file or
+ * directory) parent. Otherwise, such actions are denied with errno set to
+ * ``EACCES``. The ``EACCES`` errno prevails over ``EXDEV`` to let user space
+ * efficiently deal with an unrecoverable error.
*
* .. warning::
*
* It is currently not possible to restrict some file-related actions
* accessible through these syscall families: :manpage:`chdir(2)`,
- * :manpage:`truncate(2)`, :manpage:`stat(2)`, :manpage:`flock(2)`,
- * :manpage:`chmod(2)`, :manpage:`chown(2)`, :manpage:`setxattr(2)`,
- * :manpage:`utime(2)`, :manpage:`ioctl(2)`, :manpage:`fcntl(2)`,
- * :manpage:`access(2)`.
+ * :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`,
+ * :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`,
+ * :manpage:`ioctl(2)`, :manpage:`fcntl(2)`, :manpage:`access(2)`.
* Future Landlock evolutions will enable to restrict them.
*/
+/* clang-format off */
#define LANDLOCK_ACCESS_FS_EXECUTE (1ULL << 0)
#define LANDLOCK_ACCESS_FS_WRITE_FILE (1ULL << 1)
#define LANDLOCK_ACCESS_FS_READ_FILE (1ULL << 2)
@@ -133,5 +169,8 @@ struct landlock_path_beneath_attr {
#define LANDLOCK_ACCESS_FS_MAKE_FIFO (1ULL << 10)
#define LANDLOCK_ACCESS_FS_MAKE_BLOCK (1ULL << 11)
#define LANDLOCK_ACCESS_FS_MAKE_SYM (1ULL << 12)
+#define LANDLOCK_ACCESS_FS_REFER (1ULL << 13)
+#define LANDLOCK_ACCESS_FS_TRUNCATE (1ULL << 14)
+/* clang-format on */
#endif /* _LINUX_LANDLOCK_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/lirc.h b/lib/libc/include/any-linux-any/linux/lirc.h
index eb11ed5d43..917560d9ef 100644
--- a/lib/libc/include/any-linux-any/linux/lirc.h
+++ b/lib/libc/include/any-linux-any/linux/lirc.h
@@ -16,14 +16,16 @@
#define LIRC_MODE2_PULSE 0x01000000
#define LIRC_MODE2_FREQUENCY 0x02000000
#define LIRC_MODE2_TIMEOUT 0x03000000
+#define LIRC_MODE2_OVERFLOW 0x04000000
#define LIRC_VALUE_MASK 0x00FFFFFF
#define LIRC_MODE2_MASK 0xFF000000
-#define LIRC_SPACE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
-#define LIRC_PULSE(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
-#define LIRC_FREQUENCY(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
-#define LIRC_TIMEOUT(val) (((val)&LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
+#define LIRC_SPACE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_SPACE)
+#define LIRC_PULSE(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_PULSE)
+#define LIRC_FREQUENCY(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_FREQUENCY)
+#define LIRC_TIMEOUT(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_TIMEOUT)
+#define LIRC_OVERFLOW(val) (((val) & LIRC_VALUE_MASK) | LIRC_MODE2_OVERFLOW)
#define LIRC_VALUE(val) ((val)&LIRC_VALUE_MASK)
#define LIRC_MODE2(val) ((val)&LIRC_MODE2_MASK)
@@ -32,6 +34,7 @@
#define LIRC_IS_PULSE(val) (LIRC_MODE2(val) == LIRC_MODE2_PULSE)
#define LIRC_IS_FREQUENCY(val) (LIRC_MODE2(val) == LIRC_MODE2_FREQUENCY)
#define LIRC_IS_TIMEOUT(val) (LIRC_MODE2(val) == LIRC_MODE2_TIMEOUT)
+#define LIRC_IS_OVERFLOW(val) (LIRC_MODE2(val) == LIRC_MODE2_OVERFLOW)
/* used heavily by lirc userspace */
#define lirc_t int
@@ -70,13 +73,10 @@
#define LIRC_CAN_REC_MASK LIRC_MODE2REC(LIRC_CAN_SEND_MASK)
#define LIRC_CAN_SET_REC_CARRIER (LIRC_CAN_SET_SEND_CARRIER << 16)
-#define LIRC_CAN_SET_REC_DUTY_CYCLE (LIRC_CAN_SET_SEND_DUTY_CYCLE << 16)
-#define LIRC_CAN_SET_REC_DUTY_CYCLE_RANGE 0x40000000
#define LIRC_CAN_SET_REC_CARRIER_RANGE 0x80000000
#define LIRC_CAN_GET_REC_RESOLUTION 0x20000000
#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000
-#define LIRC_CAN_SET_REC_FILTER 0x08000000
#define LIRC_CAN_MEASURE_CARRIER 0x02000000
#define LIRC_CAN_USE_WIDEBAND_RECEIVER 0x04000000
@@ -84,7 +84,12 @@
#define LIRC_CAN_SEND(x) ((x)&LIRC_CAN_SEND_MASK)
#define LIRC_CAN_REC(x) ((x)&LIRC_CAN_REC_MASK)
-#define LIRC_CAN_NOTIFY_DECODE 0x01000000
+/*
+ * Unused features. These features were never implemented, in tree or
+ * out of tree. These definitions are here so not to break the lircd build.
+ */
+#define LIRC_CAN_SET_REC_FILTER 0
+#define LIRC_CAN_NOTIFY_DECODE 0
/*** IOCTL commands for lirc driver ***/
diff --git a/lib/libc/include/any-linux-any/linux/loadpin.h b/lib/libc/include/any-linux-any/linux/loadpin.h
new file mode 100644
index 0000000000..8f446543ba
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/loadpin.h
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (c) 2022, Google LLC
+ */
+
+#ifndef _LINUX_LOOP_LOADPIN_H
+#define _LINUX_LOOP_LOADPIN_H
+
+#define LOADPIN_IOC_MAGIC 'L'
+
+/**
+ * LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS - Set up the root digests of verity devices
+ * that loadpin should trust.
+ *
+ * Takes a file descriptor from which to read the root digests of trusted verity devices. The file
+ * is expected to contain a list of digests in ASCII format, with one line per digest. The ioctl
+ * must be issued on the securityfs attribute 'loadpin/dm-verity' (which can be typically found
+ * under /sys/kernel/security/loadpin/dm-verity).
+ */
+#define LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS _IOW(LOADPIN_IOC_MAGIC, 0x00, unsigned int)
+
+#endif /* _LINUX_LOOP_LOADPIN_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/loop.h b/lib/libc/include/any-linux-any/linux/loop.h
index f0b2841811..481a87450b 100644
--- a/lib/libc/include/any-linux-any/linux/loop.h
+++ b/lib/libc/include/any-linux-any/linux/loop.h
@@ -1,11 +1,6 @@
/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
/*
- * include/linux/loop.h
- *
- * Written by Theodore Ts'o, 3/29/93.
- *
- * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
- * permitted under the GNU General Public License.
+ * Copyright 1993 by Theodore Ts'o.
*/
#ifndef _LINUX_LOOP_H
#define _LINUX_LOOP_H
@@ -45,7 +40,7 @@ struct loop_info {
unsigned long lo_inode; /* ioctl r/o */
__kernel_old_dev_t lo_rdevice; /* ioctl r/o */
int lo_offset;
- int lo_encrypt_type;
+ int lo_encrypt_type; /* obsolete, ignored */
int lo_encrypt_key_size; /* ioctl w/o */
int lo_flags;
char lo_name[LO_NAME_SIZE];
@@ -61,7 +56,7 @@ struct loop_info64 {
__u64 lo_offset;
__u64 lo_sizelimit;/* bytes, 0 == max available */
__u32 lo_number; /* ioctl r/o */
- __u32 lo_encrypt_type;
+ __u32 lo_encrypt_type; /* obsolete, ignored */
__u32 lo_encrypt_key_size; /* ioctl w/o */
__u32 lo_flags;
__u8 lo_file_name[LO_NAME_SIZE];
diff --git a/lib/libc/include/any-linux-any/linux/lwtunnel.h b/lib/libc/include/any-linux-any/linux/lwtunnel.h
index d026ebb75d..cfd8bca2c2 100644
--- a/lib/libc/include/any-linux-any/linux/lwtunnel.h
+++ b/lib/libc/include/any-linux-any/linux/lwtunnel.h
@@ -15,6 +15,7 @@ enum lwtunnel_encap_types {
LWTUNNEL_ENCAP_SEG6_LOCAL,
LWTUNNEL_ENCAP_RPL,
LWTUNNEL_ENCAP_IOAM6,
+ LWTUNNEL_ENCAP_XFRM,
__LWTUNNEL_ENCAP_MAX,
};
@@ -111,4 +112,13 @@ enum {
#define LWT_BPF_MAX_HEADROOM 256
+enum {
+ LWT_XFRM_UNSPEC,
+ LWT_XFRM_IF_ID,
+ LWT_XFRM_LINK,
+ __LWT_XFRM_MAX,
+};
+
+#define LWT_XFRM_MAX (__LWT_XFRM_MAX - 1)
+
#endif /* _LWTUNNEL_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/magic.h b/lib/libc/include/any-linux-any/linux/magic.h
index 9d973c038a..804b34fc66 100644
--- a/lib/libc/include/any-linux-any/linux/magic.h
+++ b/lib/libc/include/any-linux-any/linux/magic.h
@@ -6,6 +6,7 @@
#define AFFS_SUPER_MAGIC 0xadff
#define AFS_SUPER_MAGIC 0x5346414F
#define AUTOFS_SUPER_MAGIC 0x0187
+#define CEPH_SUPER_MAGIC 0x00c36400
#define CODA_SUPER_MAGIC 0x73757245
#define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
#define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */
@@ -35,6 +36,7 @@
#define EFIVARFS_MAGIC 0xde5e81e4
#define HOSTFS_SUPER_MAGIC 0x00c0ffee
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
+#define FUSE_SUPER_MAGIC 0x65735546
#define MINIX_SUPER_MAGIC 0x137F /* minix v1 fs, 14 char names */
#define MINIX_SUPER_MAGIC2 0x138F /* minix v1 fs, 30 char names */
@@ -43,6 +45,7 @@
#define MINIX3_SUPER_MAGIC 0x4d5a /* minix v3 fs, 60 char names */
#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
+#define EXFAT_SUPER_MAGIC 0x2011BAB0
#define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */
#define NFS_SUPER_MAGIC 0x6969
#define OCFS2_SUPER_MAGIC 0x7461636f
@@ -51,6 +54,7 @@
#define QNX6_SUPER_MAGIC 0x68191122 /* qnx6 fs detection */
#define AFS_FS_MAGIC 0x6B414653
+
#define REISERFS_SUPER_MAGIC 0x52654973 /* used by gcc */
/* used by file system utilities that
look at the superblock, etc. */
@@ -59,6 +63,9 @@
#define REISER2FS_JR_SUPER_MAGIC_STRING "ReIsEr3Fs"
#define SMB_SUPER_MAGIC 0x517B
+#define CIFS_SUPER_MAGIC 0xFF534D42 /* the first four bytes of SMB PDUs */
+#define SMB2_SUPER_MAGIC 0xFE534D42
+
#define CGROUP_SUPER_MAGIC 0x27e0eb
#define CGROUP2_SUPER_MAGIC 0x63677270
@@ -91,12 +98,8 @@
/* Since UDF 2.01 is ISO 13346 based... */
#define UDF_SUPER_MAGIC 0x15013346
-#define BALLOON_KVM_MAGIC 0x13661366
-#define ZSMALLOC_MAGIC 0x58295829
#define DMA_BUF_MAGIC 0x444d4142 /* "DMAB" */
#define DEVMEM_MAGIC 0x454d444d /* "DMEM" */
-#define Z3FOLD_MAGIC 0x33
-#define PPC_CMM_MAGIC 0xc7571590
#define SECRETMEM_MAGIC 0x5345434d /* "SECM" */
#endif /* __LINUX_MAGIC_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/mctp.h b/lib/libc/include/any-linux-any/linux/mctp.h
index c2ae24d37a..ef71453366 100644
--- a/lib/libc/include/any-linux-any/linux/mctp.h
+++ b/lib/libc/include/any-linux-any/linux/mctp.h
@@ -44,7 +44,25 @@ struct sockaddr_mctp_ext {
#define MCTP_TAG_MASK 0x07
#define MCTP_TAG_OWNER 0x08
+#define MCTP_TAG_PREALLOC 0x10
#define MCTP_OPT_ADDR_EXT 1
+#define SIOCMCTPALLOCTAG (SIOCPROTOPRIVATE + 0)
+#define SIOCMCTPDROPTAG (SIOCPROTOPRIVATE + 1)
+
+struct mctp_ioc_tag_ctl {
+ mctp_eid_t peer_addr;
+
+ /* For SIOCMCTPALLOCTAG: must be passed as zero, kernel will
+ * populate with the allocated tag value. Returned tag value will
+ * always have TO and PREALLOC set.
+ *
+ * For SIOCMCTPDROPTAG: userspace provides tag value to drop, from
+ * a prior SIOCMCTPALLOCTAG call (and so must have TO and PREALLOC set).
+ */
+ __u8 tag;
+ __u16 flags;
+};
+
#endif /* __UAPI_MCTP_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/mdio.h b/lib/libc/include/any-linux-any/linux/mdio.h
index b7498c1d1d..95d89fd038 100644
--- a/lib/libc/include/any-linux-any/linux/mdio.h
+++ b/lib/libc/include/any-linux-any/linux/mdio.h
@@ -67,6 +67,21 @@
#define MDIO_PCS_10GBRT_STAT2 33 /* 10GBASE-R/-T PCS status 2 */
#define MDIO_AN_10GBT_CTRL 32 /* 10GBASE-T auto-negotiation control */
#define MDIO_AN_10GBT_STAT 33 /* 10GBASE-T auto-negotiation status */
+#define MDIO_B10L_PMA_CTRL 2294 /* 10BASE-T1L PMA control */
+#define MDIO_PMA_10T1L_STAT 2295 /* 10BASE-T1L PMA status */
+#define MDIO_PCS_10T1L_CTRL 2278 /* 10BASE-T1L PCS control */
+#define MDIO_PMA_PMD_BT1 18 /* BASE-T1 PMA/PMD extended ability */
+#define MDIO_AN_T1_CTRL 512 /* BASE-T1 AN control */
+#define MDIO_AN_T1_STAT 513 /* BASE-T1 AN status */
+#define MDIO_AN_T1_ADV_L 514 /* BASE-T1 AN advertisement register [15:0] */
+#define MDIO_AN_T1_ADV_M 515 /* BASE-T1 AN advertisement register [31:16] */
+#define MDIO_AN_T1_ADV_H 516 /* BASE-T1 AN advertisement register [47:32] */
+#define MDIO_AN_T1_LP_L 517 /* BASE-T1 AN LP Base Page ability register [15:0] */
+#define MDIO_AN_T1_LP_M 518 /* BASE-T1 AN LP Base Page ability register [31:16] */
+#define MDIO_AN_T1_LP_H 519 /* BASE-T1 AN LP Base Page ability register [47:32] */
+#define MDIO_AN_10BT1_AN_CTRL 526 /* 10BASE-T1 AN control register */
+#define MDIO_AN_10BT1_AN_STAT 527 /* 10BASE-T1 AN status register */
+#define MDIO_PMA_PMD_BT1_CTRL 2100 /* BASE-T1 PMA/PMD control register */
/* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */
#define MDIO_PMA_LASI_RXCTRL 0x9000 /* RX_ALARM control */
@@ -159,6 +174,7 @@
#define MDIO_PMA_CTRL2_10BT 0x000f /* 10BASE-T type */
#define MDIO_PMA_CTRL2_2_5GBT 0x0030 /* 2.5GBaseT type */
#define MDIO_PMA_CTRL2_5GBT 0x0031 /* 5GBaseT type */
+#define MDIO_PMA_CTRL2_BASET1 0x003D /* BASE-T1 type */
#define MDIO_PCS_CTRL2_TYPE 0x0003 /* PCS type selection */
#define MDIO_PCS_CTRL2_10GBR 0x0000 /* 10GBASE-R type */
#define MDIO_PCS_CTRL2_10GBX 0x0001 /* 10GBASE-X type */
@@ -212,6 +228,7 @@
#define MDIO_PMA_EXTABLE_1000BKX 0x0040 /* 1000BASE-KX ability */
#define MDIO_PMA_EXTABLE_100BTX 0x0080 /* 100BASE-TX ability */
#define MDIO_PMA_EXTABLE_10BT 0x0100 /* 10BASE-T ability */
+#define MDIO_PMA_EXTABLE_BT1 0x0800 /* BASE-T1 ability */
#define MDIO_PMA_EXTABLE_NBT 0x4000 /* 2.5/5GBASE-T ability */
/* PHY XGXS lane state register. */
@@ -268,6 +285,72 @@
#define MDIO_AN_10GBT_STAT_MS 0x4000 /* Master/slave config */
#define MDIO_AN_10GBT_STAT_MSFLT 0x8000 /* Master/slave config fault */
+/* 10BASE-T1L PMA control */
+#define MDIO_PMA_10T1L_CTRL_LB_EN 0x0001 /* Enable loopback mode */
+#define MDIO_PMA_10T1L_CTRL_EEE_EN 0x0400 /* Enable EEE mode */
+#define MDIO_PMA_10T1L_CTRL_LOW_POWER 0x0800 /* Low-power mode */
+#define MDIO_PMA_10T1L_CTRL_2V4_EN 0x1000 /* Enable 2.4 Vpp operating mode */
+#define MDIO_PMA_10T1L_CTRL_TX_DIS 0x4000 /* Transmit disable */
+#define MDIO_PMA_10T1L_CTRL_PMA_RST 0x8000 /* MA reset */
+
+/* 10BASE-T1L PMA status register. */
+#define MDIO_PMA_10T1L_STAT_LINK 0x0001 /* PMA receive link up */
+#define MDIO_PMA_10T1L_STAT_FAULT 0x0002 /* Fault condition detected */
+#define MDIO_PMA_10T1L_STAT_POLARITY 0x0004 /* Receive polarity is reversed */
+#define MDIO_PMA_10T1L_STAT_RECV_FAULT 0x0200 /* Able to detect fault on receive path */
+#define MDIO_PMA_10T1L_STAT_EEE 0x0400 /* PHY has EEE ability */
+#define MDIO_PMA_10T1L_STAT_LOW_POWER 0x0800 /* PMA has low-power ability */
+#define MDIO_PMA_10T1L_STAT_2V4_ABLE 0x1000 /* PHY has 2.4 Vpp operating mode ability */
+#define MDIO_PMA_10T1L_STAT_LB_ABLE 0x2000 /* PHY has loopback ability */
+
+/* 10BASE-T1L PCS control register. */
+#define MDIO_PCS_10T1L_CTRL_LB 0x4000 /* Enable PCS level loopback mode */
+#define MDIO_PCS_10T1L_CTRL_RESET 0x8000 /* PCS reset */
+
+/* BASE-T1 PMA/PMD extended ability register. */
+#define MDIO_PMA_PMD_BT1_B10L_ABLE 0x0004 /* 10BASE-T1L Ability */
+
+/* BASE-T1 auto-negotiation advertisement register [15:0] */
+#define MDIO_AN_T1_ADV_L_PAUSE_CAP ADVERTISE_PAUSE_CAP
+#define MDIO_AN_T1_ADV_L_PAUSE_ASYM ADVERTISE_PAUSE_ASYM
+#define MDIO_AN_T1_ADV_L_FORCE_MS 0x1000 /* Force Master/slave Configuration */
+#define MDIO_AN_T1_ADV_L_REMOTE_FAULT ADVERTISE_RFAULT
+#define MDIO_AN_T1_ADV_L_ACK ADVERTISE_LPACK
+#define MDIO_AN_T1_ADV_L_NEXT_PAGE_REQ ADVERTISE_NPAGE
+
+/* BASE-T1 auto-negotiation advertisement register [31:16] */
+#define MDIO_AN_T1_ADV_M_B10L 0x4000 /* device is compatible with 10BASE-T1L */
+#define MDIO_AN_T1_ADV_M_MST 0x0010 /* advertise master preference */
+
+/* BASE-T1 auto-negotiation advertisement register [47:32] */
+#define MDIO_AN_T1_ADV_H_10L_TX_HI_REQ 0x1000 /* 10BASE-T1L High Level Transmit Request */
+#define MDIO_AN_T1_ADV_H_10L_TX_HI 0x2000 /* 10BASE-T1L High Level Transmit Ability */
+
+/* BASE-T1 AN LP Base Page ability register [15:0] */
+#define MDIO_AN_T1_LP_L_PAUSE_CAP LPA_PAUSE_CAP
+#define MDIO_AN_T1_LP_L_PAUSE_ASYM LPA_PAUSE_ASYM
+#define MDIO_AN_T1_LP_L_FORCE_MS 0x1000 /* LP Force Master/slave Configuration */
+#define MDIO_AN_T1_LP_L_REMOTE_FAULT LPA_RFAULT
+#define MDIO_AN_T1_LP_L_ACK LPA_LPACK
+#define MDIO_AN_T1_LP_L_NEXT_PAGE_REQ LPA_NPAGE
+
+/* BASE-T1 AN LP Base Page ability register [31:16] */
+#define MDIO_AN_T1_LP_M_MST 0x0010 /* LP master preference */
+#define MDIO_AN_T1_LP_M_B10L 0x4000 /* LP is compatible with 10BASE-T1L */
+
+/* BASE-T1 AN LP Base Page ability register [47:32] */
+#define MDIO_AN_T1_LP_H_10L_TX_HI_REQ 0x1000 /* 10BASE-T1L High Level LP Transmit Request */
+#define MDIO_AN_T1_LP_H_10L_TX_HI 0x2000 /* 10BASE-T1L High Level LP Transmit Ability */
+
+/* 10BASE-T1 AN control register */
+#define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L 0x4000 /* 10BASE-T1L EEE ability advertisement */
+
+/* 10BASE-T1 AN status register */
+#define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L 0x4000 /* 10BASE-T1L LP EEE ability advertisement */
+
+/* BASE-T1 PMA/PMD control register */
+#define MDIO_PMA_PMD_BT1_CTRL_CFG_MST 0x4000 /* MASTER-SLAVE config value */
+
/* EEE Supported/Advertisement/LP Advertisement registers.
*
* EEE capability Register (3.20), Advertisement (7.60) and
diff --git a/lib/libc/include/any-linux-any/linux/media-bus-format.h b/lib/libc/include/any-linux-any/linux/media-bus-format.h
index 896e894207..1a8227c028 100644
--- a/lib/libc/include/any-linux-any/linux/media-bus-format.h
+++ b/lib/libc/include/any-linux-any/linux/media-bus-format.h
@@ -34,7 +34,7 @@
#define MEDIA_BUS_FMT_FIXED 0x0001
-/* RGB - next is 0x101e */
+/* RGB - next is 0x1025 */
#define MEDIA_BUS_FMT_RGB444_1X12 0x1016
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE 0x1001
#define MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE 0x1002
@@ -46,8 +46,11 @@
#define MEDIA_BUS_FMT_RGB565_2X8_BE 0x1007
#define MEDIA_BUS_FMT_RGB565_2X8_LE 0x1008
#define MEDIA_BUS_FMT_RGB666_1X18 0x1009
+#define MEDIA_BUS_FMT_BGR666_1X18 0x1023
#define MEDIA_BUS_FMT_RBG888_1X24 0x100e
#define MEDIA_BUS_FMT_RGB666_1X24_CPADHI 0x1015
+#define MEDIA_BUS_FMT_BGR666_1X24_CPADHI 0x1024
+#define MEDIA_BUS_FMT_RGB565_1X24_CPADHI 0x1022
#define MEDIA_BUS_FMT_RGB666_1X7X3_SPWG 0x1010
#define MEDIA_BUS_FMT_BGR888_1X24 0x1013
#define MEDIA_BUS_FMT_BGR888_3X8 0x101b
@@ -59,13 +62,17 @@
#define MEDIA_BUS_FMT_RGB888_3X8_DELTA 0x101d
#define MEDIA_BUS_FMT_RGB888_1X7X4_SPWG 0x1011
#define MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA 0x1012
+#define MEDIA_BUS_FMT_RGB666_1X30_CPADLO 0x101e
+#define MEDIA_BUS_FMT_RGB888_1X30_CPADLO 0x101f
#define MEDIA_BUS_FMT_ARGB8888_1X32 0x100d
#define MEDIA_BUS_FMT_RGB888_1X32_PADHI 0x100f
#define MEDIA_BUS_FMT_RGB101010_1X30 0x1018
+#define MEDIA_BUS_FMT_RGB666_1X36_CPADLO 0x1020
+#define MEDIA_BUS_FMT_RGB888_1X36_CPADLO 0x1021
#define MEDIA_BUS_FMT_RGB121212_1X36 0x1019
#define MEDIA_BUS_FMT_RGB161616_1X48 0x101a
-/* YUV (including grey) - next is 0x202e */
+/* YUV (including grey) - next is 0x202f */
#define MEDIA_BUS_FMT_Y8_1X8 0x2001
#define MEDIA_BUS_FMT_UV8_1X8 0x2015
#define MEDIA_BUS_FMT_UYVY8_1_5X8 0x2002
@@ -88,6 +95,7 @@
#define MEDIA_BUS_FMT_YUYV12_2X12 0x201e
#define MEDIA_BUS_FMT_YVYU12_2X12 0x201f
#define MEDIA_BUS_FMT_Y14_1X14 0x202d
+#define MEDIA_BUS_FMT_Y16_1X16 0x202e
#define MEDIA_BUS_FMT_UYVY8_1X16 0x200f
#define MEDIA_BUS_FMT_VYUY8_1X16 0x2010
#define MEDIA_BUS_FMT_YUYV8_1X16 0x2011
diff --git a/lib/libc/include/any-linux-any/linux/media.h b/lib/libc/include/any-linux-any/linux/media.h
index c7c418e81f..69c87900f0 100644
--- a/lib/libc/include/any-linux-any/linux/media.h
+++ b/lib/libc/include/any-linux-any/linux/media.h
@@ -20,7 +20,6 @@
#ifndef __LINUX_MEDIA_H
#define __LINUX_MEDIA_H
-#include <stdint.h>
#include <linux/ioctl.h>
#include <linux/types.h>
@@ -222,6 +221,7 @@ struct media_pad_desc {
#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
+# define MEDIA_LNK_FL_ANCILLARY_LINK (2 << 28)
struct media_link_desc {
struct media_pad_desc source;
diff --git a/lib/libc/include/any-linux-any/linux/membarrier.h b/lib/libc/include/any-linux-any/linux/membarrier.h
index 9ce4c4a52e..fee2744a7e 100644
--- a/lib/libc/include/any-linux-any/linux/membarrier.h
+++ b/lib/libc/include/any-linux-any/linux/membarrier.h
@@ -137,6 +137,9 @@
* @MEMBARRIER_CMD_SHARED:
* Alias to MEMBARRIER_CMD_GLOBAL. Provided for
* header backward compatibility.
+ * @MEMBARRIER_CMD_GET_REGISTRATIONS:
+ * Returns a bitmask of previously issued
+ * registration commands.
*
* Command to be passed to the membarrier system call. The commands need to
* be a single bit each, except for MEMBARRIER_CMD_QUERY which is assigned to
@@ -153,6 +156,7 @@ enum membarrier_cmd {
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = (1 << 6),
MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = (1 << 7),
MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = (1 << 8),
+ MEMBARRIER_CMD_GET_REGISTRATIONS = (1 << 9),
/* Alias for header backward compatibility. */
MEMBARRIER_CMD_SHARED = MEMBARRIER_CMD_GLOBAL,
diff --git a/lib/libc/include/any-linux-any/linux/memfd.h b/lib/libc/include/any-linux-any/linux/memfd.h
index b82cd26b2e..32876a0931 100644
--- a/lib/libc/include/any-linux-any/linux/memfd.h
+++ b/lib/libc/include/any-linux-any/linux/memfd.h
@@ -8,6 +8,10 @@
#define MFD_CLOEXEC 0x0001U
#define MFD_ALLOW_SEALING 0x0002U
#define MFD_HUGETLB 0x0004U
+/* not executable and sealed to prevent changing to executable. */
+#define MFD_NOEXEC_SEAL 0x0008U
+/* executable */
+#define MFD_EXEC 0x0010U
/*
* Huge page size encoding when MFD_HUGETLB is specified, and a huge page
diff --git a/lib/libc/include/any-linux-any/linux/meye.h b/lib/libc/include/any-linux-any/linux/meye.h
deleted file mode 100644
index de7498bbd4..0000000000
--- a/lib/libc/include/any-linux-any/linux/meye.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * Motion Eye video4linux driver for Sony Vaio PictureBook
- *
- * Copyright (C) 2001-2003 Stelian Pop <stelian@popies.net>
- *
- * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
- *
- * Copyright (C) 2000 Andrew Tridgell <tridge@valinux.com>
- *
- * Earlier work by Werner Almesberger, Paul `Rusty' Russell and Paul Mackerras.
- *
- * Some parts borrowed from various video4linux drivers, especially
- * bttv-driver.c and zoran.c, see original files for credits.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#ifndef _MEYE_H_
-#define _MEYE_H_
-
-/****************************************************************************/
-/* Private API for handling mjpeg capture / playback. */
-/****************************************************************************/
-
-struct meye_params {
- unsigned char subsample;
- unsigned char quality;
- unsigned char sharpness;
- unsigned char agc;
- unsigned char picture;
- unsigned char framerate;
-};
-
-/* query the extended parameters */
-#define MEYEIOC_G_PARAMS _IOR ('v', BASE_VIDIOC_PRIVATE+0, struct meye_params)
-/* set the extended parameters */
-#define MEYEIOC_S_PARAMS _IOW ('v', BASE_VIDIOC_PRIVATE+1, struct meye_params)
-/* queue a buffer for mjpeg capture */
-#define MEYEIOC_QBUF_CAPT _IOW ('v', BASE_VIDIOC_PRIVATE+2, int)
-/* sync a previously queued mjpeg buffer */
-#define MEYEIOC_SYNC _IOWR('v', BASE_VIDIOC_PRIVATE+3, int)
-/* get a still uncompressed snapshot */
-#define MEYEIOC_STILLCAPT _IO ('v', BASE_VIDIOC_PRIVATE+4)
-/* get a jpeg compressed snapshot */
-#define MEYEIOC_STILLJCAPT _IOR ('v', BASE_VIDIOC_PRIVATE+5, int)
-
-/* V4L2 private controls */
-#define V4L2_CID_MEYE_AGC (V4L2_CID_USER_MEYE_BASE + 0)
-#define V4L2_CID_MEYE_PICTURE (V4L2_CID_USER_MEYE_BASE + 1)
-#define V4L2_CID_MEYE_FRAMERATE (V4L2_CID_USER_MEYE_BASE + 2)
-
-#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/minix_fs.h b/lib/libc/include/any-linux-any/linux/minix_fs.h
index a4833d2ede..e18a846b95 100644
--- a/lib/libc/include/any-linux-any/linux/minix_fs.h
+++ b/lib/libc/include/any-linux-any/linux/minix_fs.h
@@ -97,11 +97,11 @@ struct minix3_super_block {
struct minix_dir_entry {
__u16 inode;
- char name[0];
+ char name[];
};
struct minix3_dir_entry {
__u32 inode;
- char name[0];
+ char name[];
};
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/mmc/ioctl.h b/lib/libc/include/any-linux-any/linux/mmc/ioctl.h
index e0154cb0d0..7aa70f4bb5 100644
--- a/lib/libc/include/any-linux-any/linux/mmc/ioctl.h
+++ b/lib/libc/include/any-linux-any/linux/mmc/ioctl.h
@@ -58,7 +58,7 @@ struct mmc_ioc_cmd {
*/
struct mmc_ioc_multi_cmd {
__u64 num_of_cmds;
- struct mmc_ioc_cmd cmds[0];
+ struct mmc_ioc_cmd cmds[];
};
#define MMC_IOC_CMD _IOWR(MMC_BLOCK_MAJOR, 0, struct mmc_ioc_cmd)
diff --git a/lib/libc/include/any-linux-any/linux/module.h b/lib/libc/include/any-linux-any/linux/module.h
index 791bf1d2fe..e3e7b3c91f 100644
--- a/lib/libc/include/any-linux-any/linux/module.h
+++ b/lib/libc/include/any-linux-any/linux/module.h
@@ -5,5 +5,6 @@
/* Flags for sys_finit_module: */
#define MODULE_INIT_IGNORE_MODVERSIONS 1
#define MODULE_INIT_IGNORE_VERMAGIC 2
+#define MODULE_INIT_COMPRESSED_FILE 4
#endif /* _LINUX_MODULE_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/mptcp.h b/lib/libc/include/any-linux-any/linux/mptcp.h
index d146c9a3e9..aaa03664e5 100644
--- a/lib/libc/include/any-linux-any/linux/mptcp.h
+++ b/lib/libc/include/any-linux-any/linux/mptcp.h
@@ -2,14 +2,15 @@
#ifndef _MPTCP_H
#define _MPTCP_H
+#include <netinet/in.h> /* for sockaddr_in and sockaddr_in6 */
+#include <sys/socket.h> /* for struct sockaddr */
+
#include <linux/const.h>
#include <linux/types.h>
#include <linux/in.h> /* for sockaddr_in */
#include <linux/in6.h> /* for sockaddr_in6 */
#include <linux/socket.h> /* for sockaddr_storage and sa_family */
-#include <sys/socket.h> /* for struct sockaddr */
-
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
#define MPTCP_SUBFLOW_FLAG_JOIN_REM _BITUL(2)
@@ -53,6 +54,9 @@ enum {
MPTCP_PM_ATTR_ADDR, /* nested address */
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
+ MPTCP_PM_ATTR_TOKEN, /* u32 */
+ MPTCP_PM_ATTR_LOC_ID, /* u8 */
+ MPTCP_PM_ATTR_ADDR_REMOTE, /* nested address */
__MPTCP_PM_ATTR_MAX
};
@@ -79,6 +83,7 @@ enum {
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
+#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)
enum {
MPTCP_PM_CMD_UNSPEC,
@@ -90,6 +95,10 @@ enum {
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
MPTCP_PM_CMD_SET_FLAGS,
+ MPTCP_PM_CMD_ANNOUNCE,
+ MPTCP_PM_CMD_REMOVE,
+ MPTCP_PM_CMD_SUBFLOW_CREATE,
+ MPTCP_PM_CMD_SUBFLOW_DESTROY,
__MPTCP_PM_CMD_AFTER_LAST
};
@@ -149,6 +158,12 @@ struct mptcp_info {
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* The priority of a subflow has changed. 'error' should not be set.
+ *
+ * MPTCP_EVENT_LISTENER_CREATED: family, sport, saddr4 | saddr6
+ * A new PM listener is created.
+ *
+ * MPTCP_EVENT_LISTENER_CLOSED: family, sport, saddr4 | saddr6
+ * A PM listener is closed.
*/
enum mptcp_event_type {
MPTCP_EVENT_UNSPEC = 0,
@@ -163,6 +178,9 @@ enum mptcp_event_type {
MPTCP_EVENT_SUB_CLOSED = 11,
MPTCP_EVENT_SUB_PRIORITY = 13,
+
+ MPTCP_EVENT_LISTENER_CREATED = 15,
+ MPTCP_EVENT_LISTENER_CLOSED = 16,
};
enum mptcp_event_attr {
@@ -185,6 +203,7 @@ enum mptcp_event_attr {
MPTCP_ATTR_IF_IDX, /* s32 */
MPTCP_ATTR_RESET_REASON,/* u32 */
MPTCP_ATTR_RESET_FLAGS, /* u32 */
+ MPTCP_ATTR_SERVER_SIDE, /* u8 */
__MPTCP_ATTR_AFTER_LAST
};
diff --git a/lib/libc/include/any-linux-any/linux/mroute6.h b/lib/libc/include/any-linux-any/linux/mroute6.h
index 783fc9cf2b..5ea3b8a1ec 100644
--- a/lib/libc/include/any-linux-any/linux/mroute6.h
+++ b/lib/libc/include/any-linux-any/linux/mroute6.h
@@ -134,6 +134,7 @@ struct mrt6msg {
#define MRT6MSG_NOCACHE 1
#define MRT6MSG_WRONGMIF 2
#define MRT6MSG_WHOLEPKT 3 /* used for use level encap */
+#define MRT6MSG_WRMIFWHOLE 4 /* For PIM Register and assert processing */
__u8 im6_mbz; /* must be zero */
__u8 im6_msgtype; /* what type of message */
__u16 im6_mif; /* mif rec'd on */
diff --git a/lib/libc/include/any-linux-any/linux/ndctl.h b/lib/libc/include/any-linux-any/linux/ndctl.h
index 7a7970f759..9af49fbe89 100644
--- a/lib/libc/include/any-linux-any/linux/ndctl.h
+++ b/lib/libc/include/any-linux-any/linux/ndctl.h
@@ -30,25 +30,25 @@ struct nd_cmd_get_config_data_hdr {
__u32 in_offset;
__u32 in_length;
__u32 status;
- __u8 out_buf[0];
+ __u8 out_buf[];
} __attribute__((packed));
struct nd_cmd_set_config_hdr {
__u32 in_offset;
__u32 in_length;
- __u8 in_buf[0];
+ __u8 in_buf[];
} __attribute__((packed));
struct nd_cmd_vendor_hdr {
__u32 opcode;
__u32 in_length;
- __u8 in_buf[0];
+ __u8 in_buf[];
} __attribute__((packed));
struct nd_cmd_vendor_tail {
__u32 status;
__u32 out_length;
- __u8 out_buf[0];
+ __u8 out_buf[];
} __attribute__((packed));
struct nd_cmd_ars_cap {
@@ -86,7 +86,7 @@ struct nd_cmd_ars_status {
__u32 reserved;
__u64 err_address;
__u64 length;
- } __attribute__((packed)) records[0];
+ } __attribute__((packed)) records[];
} __attribute__((packed));
struct nd_cmd_clear_error {
@@ -189,7 +189,6 @@ static __inline__ const char *nvdimm_cmd_name(unsigned cmd)
#define ND_DEVICE_REGION_BLK 3 /* nd_region: (parent of BLK namespaces) */
#define ND_DEVICE_NAMESPACE_IO 4 /* legacy persistent memory */
#define ND_DEVICE_NAMESPACE_PMEM 5 /* PMEM namespace (may alias with BLK) */
-#define ND_DEVICE_NAMESPACE_BLK 6 /* BLK namespace (may alias with PMEM) */
#define ND_DEVICE_DAX_PMEM 7 /* Device DAX interface to pmem */
enum nd_driver_flags {
@@ -198,7 +197,6 @@ enum nd_driver_flags {
ND_DRIVER_REGION_BLK = 1 << ND_DEVICE_REGION_BLK,
ND_DRIVER_NAMESPACE_IO = 1 << ND_DEVICE_NAMESPACE_IO,
ND_DRIVER_NAMESPACE_PMEM = 1 << ND_DEVICE_NAMESPACE_PMEM,
- ND_DRIVER_NAMESPACE_BLK = 1 << ND_DEVICE_NAMESPACE_BLK,
ND_DRIVER_DAX_PMEM = 1 << ND_DEVICE_DAX_PMEM,
};
diff --git a/lib/libc/include/any-linux-any/linux/neighbour.h b/lib/libc/include/any-linux-any/linux/neighbour.h
index 1dc2494d77..ea947fef2e 100644
--- a/lib/libc/include/any-linux-any/linux/neighbour.h
+++ b/lib/libc/include/any-linux-any/linux/neighbour.h
@@ -32,6 +32,8 @@ enum {
NDA_NH_ID,
NDA_FDB_EXT_ATTRS,
NDA_FLAGS_EXT,
+ NDA_NDM_STATE_MASK,
+ NDA_NDM_FLAGS_MASK,
__NDA_MAX
};
@@ -50,7 +52,8 @@ enum {
#define NTF_STICKY (1 << 6)
#define NTF_ROUTER (1 << 7)
/* Extended flags under NDA_FLAGS_EXT: */
-#define NTF_EXT_MANAGED (1 << 0)
+#define NTF_EXT_MANAGED (1 << 0)
+#define NTF_EXT_LOCKED (1 << 1)
/*
* Neighbor Cache Entry States.
@@ -84,6 +87,11 @@ enum {
* NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
* of a user space control plane, and automatically refreshed so that (if
* possible) they remain in NUD_REACHABLE state.
+ *
+ * NTF_EXT_LOCKED flagged bridge FDB entries are entries generated by the
+ * bridge in response to a host trying to communicate via a locked bridge port
+ * with MAB enabled. Their purpose is to notify user space that a host requires
+ * authentication.
*/
struct nda_cacheinfo {
@@ -152,6 +160,7 @@ enum {
NDTPA_QUEUE_LENBYTES, /* u32 */
NDTPA_MCAST_REPROBES, /* u32 */
NDTPA_PAD,
+ NDTPA_INTERVAL_PROBE_TIME_MS, /* u64, msecs */
__NDTPA_MAX
};
#define NDTPA_MAX (__NDTPA_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/net_dropmon.h b/lib/libc/include/any-linux-any/linux/net_dropmon.h
index 2e03c6d5d7..9d2438f896 100644
--- a/lib/libc/include/any-linux-any/linux/net_dropmon.h
+++ b/lib/libc/include/any-linux-any/linux/net_dropmon.h
@@ -29,12 +29,12 @@ struct net_dm_config_entry {
struct net_dm_config_msg {
__u32 entries;
- struct net_dm_config_entry options[0];
+ struct net_dm_config_entry options[];
};
struct net_dm_alert_msg {
__u32 entries;
- struct net_dm_drop_point points[0];
+ struct net_dm_drop_point points[];
};
struct net_dm_user_msg {
@@ -93,6 +93,7 @@ enum net_dm_attr {
NET_DM_ATTR_SW_DROPS, /* flag */
NET_DM_ATTR_HW_DROPS, /* flag */
NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */
+ NET_DM_ATTR_REASON, /* string */
__NET_DM_ATTR_MAX,
NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
diff --git a/lib/libc/include/any-linux-any/linux/net_tstamp.h b/lib/libc/include/any-linux-any/linux/net_tstamp.h
index fc70faaf1d..34e82a2372 100644
--- a/lib/libc/include/any-linux-any/linux/net_tstamp.h
+++ b/lib/libc/include/any-linux-any/linux/net_tstamp.h
@@ -31,8 +31,9 @@ enum {
SOF_TIMESTAMPING_OPT_PKTINFO = (1<<13),
SOF_TIMESTAMPING_OPT_TX_SWHW = (1<<14),
SOF_TIMESTAMPING_BIND_PHC = (1 << 15),
+ SOF_TIMESTAMPING_OPT_ID_TCP = (1 << 16),
- SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_BIND_PHC,
+ SOF_TIMESTAMPING_LAST = SOF_TIMESTAMPING_OPT_ID_TCP,
SOF_TIMESTAMPING_MASK = (SOF_TIMESTAMPING_LAST - 1) |
SOF_TIMESTAMPING_LAST
};
@@ -62,7 +63,7 @@ struct so_timestamping {
/**
* struct hwtstamp_config - %SIOCGHWTSTAMP and %SIOCSHWTSTAMP parameter
*
- * @flags: no flags defined right now, must be zero for %SIOCSHWTSTAMP
+ * @flags: one of HWTSTAMP_FLAG_*
* @tx_type: one of HWTSTAMP_TX_*
* @rx_filter: one of HWTSTAMP_FILTER_*
*
@@ -78,6 +79,21 @@ struct hwtstamp_config {
int rx_filter;
};
+/* possible values for hwtstamp_config->flags */
+enum hwtstamp_flags {
+ /*
+ * With this flag, the user could get bond active interface's
+ * PHC index. Note this PHC index is not stable as when there
+ * is a failover, the bond active interface will be changed, so
+ * will be the PHC index.
+ */
+ HWTSTAMP_FLAG_BONDED_PHC_INDEX = (1<<0),
+#define HWTSTAMP_FLAG_BONDED_PHC_INDEX HWTSTAMP_FLAG_BONDED_PHC_INDEX
+
+ HWTSTAMP_FLAG_LAST = HWTSTAMP_FLAG_BONDED_PHC_INDEX,
+ HWTSTAMP_FLAG_MASK = (HWTSTAMP_FLAG_LAST - 1) | HWTSTAMP_FLAG_LAST
+};
+
/* possible values for hwtstamp_config->tx_type */
enum hwtstamp_tx_types {
/*
diff --git a/lib/libc/include/any-linux-any/linux/netdev.h b/lib/libc/include/any-linux-any/linux/netdev.h
new file mode 100644
index 0000000000..c4594d91cb
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/netdev.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/* Do not edit directly, auto-generated from: */
+/* Documentation/netlink/specs/netdev.yaml */
+/* YNL-GEN uapi header */
+
+#ifndef _LINUX_NETDEV_H
+#define _LINUX_NETDEV_H
+
+#define NETDEV_FAMILY_NAME "netdev"
+#define NETDEV_FAMILY_VERSION 1
+
+/**
+ * enum netdev_xdp_act
+ * @NETDEV_XDP_ACT_BASIC: XDP feautues set supported by all drivers
+ * (XDP_ABORTED, XDP_DROP, XDP_PASS, XDP_TX)
+ * @NETDEV_XDP_ACT_REDIRECT: The netdev supports XDP_REDIRECT
+ * @NETDEV_XDP_ACT_NDO_XMIT: This feature informs if netdev implements
+ * ndo_xdp_xmit callback.
+ * @NETDEV_XDP_ACT_XSK_ZEROCOPY: This feature informs if netdev supports AF_XDP
+ * in zero copy mode.
+ * @NETDEV_XDP_ACT_HW_OFFLOAD: This feature informs if netdev supports XDP hw
+ * offloading.
+ * @NETDEV_XDP_ACT_RX_SG: This feature informs if netdev implements non-linear
+ * XDP buffer support in the driver napi callback.
+ * @NETDEV_XDP_ACT_NDO_XMIT_SG: This feature informs if netdev implements
+ * non-linear XDP buffer support in ndo_xdp_xmit callback.
+ */
+enum netdev_xdp_act {
+ NETDEV_XDP_ACT_BASIC = 1,
+ NETDEV_XDP_ACT_REDIRECT = 2,
+ NETDEV_XDP_ACT_NDO_XMIT = 4,
+ NETDEV_XDP_ACT_XSK_ZEROCOPY = 8,
+ NETDEV_XDP_ACT_HW_OFFLOAD = 16,
+ NETDEV_XDP_ACT_RX_SG = 32,
+ NETDEV_XDP_ACT_NDO_XMIT_SG = 64,
+
+ NETDEV_XDP_ACT_MASK = 127,
+};
+
+enum {
+ NETDEV_A_DEV_IFINDEX = 1,
+ NETDEV_A_DEV_PAD,
+ NETDEV_A_DEV_XDP_FEATURES,
+
+ __NETDEV_A_DEV_MAX,
+ NETDEV_A_DEV_MAX = (__NETDEV_A_DEV_MAX - 1)
+};
+
+enum {
+ NETDEV_CMD_DEV_GET = 1,
+ NETDEV_CMD_DEV_ADD_NTF,
+ NETDEV_CMD_DEV_DEL_NTF,
+ NETDEV_CMD_DEV_CHANGE_NTF,
+
+ __NETDEV_CMD_MAX,
+ NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1)
+};
+
+#define NETDEV_MCGRP_MGMT "mgmt"
+
+#endif /* _LINUX_NETDEV_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/ipset/ip_set.h b/lib/libc/include/any-linux-any/linux/netfilter/ipset/ip_set.h
index 17fc8d019f..6c5255a482 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/ipset/ip_set.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/ipset/ip_set.h
@@ -3,10 +3,6 @@
* Patrick Schaaf <bof@bof.de>
* Martin Josefsson <gandalf@wlug.westbo.se>
* Copyright (C) 2003-2011 Jozsef Kadlecsik <kadlec@netfilter.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef _IP_SET_H
#define _IP_SET_H
@@ -89,6 +85,7 @@ enum {
IPSET_ATTR_CADT_LINENO = IPSET_ATTR_LINENO, /* 9 */
IPSET_ATTR_MARK, /* 10 */
IPSET_ATTR_MARKMASK, /* 11 */
+ IPSET_ATTR_BITMASK, /* 12 */
/* Reserve empty slots */
IPSET_ATTR_CADT_MAX = 16,
/* Create-only specific attributes */
@@ -157,6 +154,7 @@ enum ipset_errno {
IPSET_ERR_COMMENT,
IPSET_ERR_INVALID_MARKMASK,
IPSET_ERR_SKBINFO,
+ IPSET_ERR_BITMASK_NETMASK_EXCL,
/* Type specific error codes */
IPSET_ERR_TYPE_SPECIFIC = 4352,
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_common.h b/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_common.h
index cd3fe74d31..233ddfca8f 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_common.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_common.h
@@ -94,7 +94,7 @@ enum ip_conntrack_status {
IPS_UNTRACKED = (1 << IPS_UNTRACKED_BIT),
- /* Conntrack got a helper explicitly attached via CT target. */
+ /* Conntrack got a helper explicitly attached (ruleset, ctnetlink). */
IPS_HELPER_BIT = 13,
IPS_HELPER = (1 << IPS_HELPER_BIT),
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_sctp.h b/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_sctp.h
index c5cbc4687e..73a5c43f9f 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_sctp.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/nf_conntrack_sctp.h
@@ -15,7 +15,7 @@ enum sctp_conntrack {
SCTP_CONNTRACK_SHUTDOWN_RECD,
SCTP_CONNTRACK_SHUTDOWN_ACK_SENT,
SCTP_CONNTRACK_HEARTBEAT_SENT,
- SCTP_CONNTRACK_HEARTBEAT_ACKED,
+ SCTP_CONNTRACK_HEARTBEAT_ACKED, /* no longer used */
SCTP_CONNTRACK_MAX
};
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/nf_tables.h b/lib/libc/include/any-linux-any/linux/netfilter/nf_tables.h
index 9ee6a72e8b..b7afed512a 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/nf_tables.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/nf_tables.h
@@ -97,6 +97,14 @@ enum nft_verdicts {
* @NFT_MSG_NEWFLOWTABLE: add new flow table (enum nft_flowtable_attributes)
* @NFT_MSG_GETFLOWTABLE: get flow table (enum nft_flowtable_attributes)
* @NFT_MSG_DELFLOWTABLE: delete flow table (enum nft_flowtable_attributes)
+ * @NFT_MSG_GETRULE_RESET: get rules and reset stateful expressions (enum nft_obj_attributes)
+ * @NFT_MSG_DESTROYTABLE: destroy a table (enum nft_table_attributes)
+ * @NFT_MSG_DESTROYCHAIN: destroy a chain (enum nft_chain_attributes)
+ * @NFT_MSG_DESTROYRULE: destroy a rule (enum nft_rule_attributes)
+ * @NFT_MSG_DESTROYSET: destroy a set (enum nft_set_attributes)
+ * @NFT_MSG_DESTROYSETELEM: destroy a set element (enum nft_set_elem_attributes)
+ * @NFT_MSG_DESTROYOBJ: destroy a stateful object (enum nft_object_attributes)
+ * @NFT_MSG_DESTROYFLOWTABLE: destroy flow table (enum nft_flowtable_attributes)
*/
enum nf_tables_msg_types {
NFT_MSG_NEWTABLE,
@@ -124,6 +132,14 @@ enum nf_tables_msg_types {
NFT_MSG_NEWFLOWTABLE,
NFT_MSG_GETFLOWTABLE,
NFT_MSG_DELFLOWTABLE,
+ NFT_MSG_GETRULE_RESET,
+ NFT_MSG_DESTROYTABLE,
+ NFT_MSG_DESTROYCHAIN,
+ NFT_MSG_DESTROYRULE,
+ NFT_MSG_DESTROYSET,
+ NFT_MSG_DESTROYSETELEM,
+ NFT_MSG_DESTROYOBJ,
+ NFT_MSG_DESTROYFLOWTABLE,
NFT_MSG_MAX,
};
@@ -760,6 +776,7 @@ enum nft_payload_bases {
NFT_PAYLOAD_NETWORK_HEADER,
NFT_PAYLOAD_TRANSPORT_HEADER,
NFT_PAYLOAD_INNER_HEADER,
+ NFT_PAYLOAD_TUN_HEADER,
};
/**
@@ -779,6 +796,32 @@ enum nft_payload_csum_flags {
NFT_PAYLOAD_L4CSUM_PSEUDOHDR = (1 << 0),
};
+enum nft_inner_type {
+ NFT_INNER_UNSPEC = 0,
+ NFT_INNER_VXLAN,
+ NFT_INNER_GENEVE,
+};
+
+enum nft_inner_flags {
+ NFT_INNER_HDRSIZE = (1 << 0),
+ NFT_INNER_LL = (1 << 1),
+ NFT_INNER_NH = (1 << 2),
+ NFT_INNER_TH = (1 << 3),
+};
+#define NFT_INNER_MASK (NFT_INNER_HDRSIZE | NFT_INNER_LL | \
+ NFT_INNER_NH | NFT_INNER_TH)
+
+enum nft_inner_attributes {
+ NFTA_INNER_UNSPEC,
+ NFTA_INNER_NUM,
+ NFTA_INNER_TYPE,
+ NFTA_INNER_FLAGS,
+ NFTA_INNER_HDRSIZE,
+ NFTA_INNER_EXPR,
+ __NFTA_INNER_MAX
+};
+#define NFTA_INNER_MAX (__NFTA_INNER_MAX - 1)
+
/**
* enum nft_payload_attributes - nf_tables payload expression netlink attributes
*
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_cttimeout.h b/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_cttimeout.h
index ff05774ddd..7ac9ba13e7 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_cttimeout.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_cttimeout.h
@@ -94,7 +94,7 @@ enum ctattr_timeout_sctp {
CTA_TIMEOUT_SCTP_SHUTDOWN_RECD,
CTA_TIMEOUT_SCTP_SHUTDOWN_ACK_SENT,
CTA_TIMEOUT_SCTP_HEARTBEAT_SENT,
- CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED,
+ CTA_TIMEOUT_SCTP_HEARTBEAT_ACKED, /* no longer used */
__CTA_TIMEOUT_SCTP_MAX
};
#define CTA_TIMEOUT_SCTP_MAX (__CTA_TIMEOUT_SCTP_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_queue.h b/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_queue.h
index b29e5373d0..bf9b62b995 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_queue.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/nfnetlink_queue.h
@@ -61,6 +61,7 @@ enum nfqnl_attr_type {
NFQA_SECCTX, /* security context string */
NFQA_VLAN, /* nested attribute: packet vlan info */
NFQA_L2HDR, /* full L2 header */
+ NFQA_PRIORITY, /* skb->priority */
__NFQA_MAX
};
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/x_tables.h b/lib/libc/include/any-linux-any/linux/netfilter/x_tables.h
index c574ce49c5..cc97d31be2 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/x_tables.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/x_tables.h
@@ -28,7 +28,7 @@ struct xt_entry_match {
__u16 match_size;
} u;
- unsigned char data[0];
+ unsigned char data[];
};
struct xt_entry_target {
@@ -119,7 +119,7 @@ struct xt_counters_info {
unsigned int num_counters;
/* The counters (actually `number' of these). */
- struct xt_counters counters[0];
+ struct xt_counters counters[];
};
#define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/xt_AUDIT.h b/lib/libc/include/any-linux-any/linux/netfilter/xt_AUDIT.h
index 01902639ac..c3cb8e34e2 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/xt_AUDIT.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/xt_AUDIT.h
@@ -4,10 +4,6 @@
*
* (C) 2010-2011 Thomas Graf <tgraf@redhat.com>
* (C) 2010-2011 Red Hat, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef _XT_AUDIT_TARGET_H
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/xt_IDLETIMER.h b/lib/libc/include/any-linux-any/linux/netfilter/xt_IDLETIMER.h
index 26672c9f23..568c4a356d 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/xt_IDLETIMER.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/xt_IDLETIMER.h
@@ -1,6 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
/*
- * linux/include/linux/netfilter/xt_IDLETIMER.h
- *
* Header file for Xtables timer target module.
*
* Copyright (C) 2004, 2010 Nokia Corporation
@@ -10,20 +9,6 @@
* by Luciano Coelho <luciano.coelho@nokia.com>
*
* Contact: Luciano Coelho <luciano.coelho@nokia.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
*/
#ifndef _XT_IDLETIMER_H
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/xt_connmark.h b/lib/libc/include/any-linux-any/linux/netfilter/xt_connmark.h
index 4431d3ef79..7ae9a1fcc1 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/xt_connmark.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/xt_connmark.h
@@ -1,18 +1,13 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com>
+ * by Henrik Nordstrom <hno@marasystems.com>
+ */
+
#ifndef _XT_CONNMARK_H
#define _XT_CONNMARK_H
#include <linux/types.h>
-/* Copyright (C) 2002,2004 MARA Systems AB <https://www.marasystems.com>
- * by Henrik Nordstrom <hno@marasystems.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
enum {
XT_CONNMARK_SET = 0,
XT_CONNMARK_SAVE,
diff --git a/lib/libc/include/any-linux-any/linux/netfilter/xt_osf.h b/lib/libc/include/any-linux-any/linux/netfilter/xt_osf.h
index af84c4fe1e..941f555b92 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter/xt_osf.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter/xt_osf.h
@@ -1,20 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Copyright (c) 2003+ Evgeniy Polyakov <johnpol@2ka.mxt.ru>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _XT_OSF_H
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_arp/arp_tables.h b/lib/libc/include/any-linux-any/linux/netfilter_arp/arp_tables.h
index fdb3fdc6bd..eec6d82672 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter_arp/arp_tables.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter_arp/arp_tables.h
@@ -107,7 +107,7 @@ struct arpt_entry
struct xt_counters counters;
/* The matches (if any), then the target. */
- unsigned char elems[0];
+ unsigned char elems[];
};
/*
@@ -179,7 +179,7 @@ struct arpt_replace {
struct xt_counters *counters;
/* The entries (hang off end: not really an array). */
- struct arpt_entry entries[0];
+ struct arpt_entry entries[];
};
/* The argument to ARPT_SO_GET_ENTRIES. */
@@ -191,7 +191,7 @@ struct arpt_get_entries {
unsigned int size;
/* The entries. */
- struct arpt_entry entrytable[0];
+ struct arpt_entry entrytable[];
};
/* Helper functions */
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_bridge/ebt_among.h b/lib/libc/include/any-linux-any/linux/netfilter_bridge/ebt_among.h
index 6b772e9e74..a730ce1dc2 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter_bridge/ebt_among.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter_bridge/ebt_among.h
@@ -40,7 +40,7 @@ struct ebt_mac_wormhash_tuple {
struct ebt_mac_wormhash {
int table[257];
int poolsize;
- struct ebt_mac_wormhash_tuple pool[0];
+ struct ebt_mac_wormhash_tuple pool[];
};
#define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_decnet.h b/lib/libc/include/any-linux-any/linux/netfilter_decnet.h
deleted file mode 100644
index 4aecd4d55a..0000000000
--- a/lib/libc/include/any-linux-any/linux/netfilter_decnet.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-#ifndef __LINUX_DECNET_NETFILTER_H
-#define __LINUX_DECNET_NETFILTER_H
-
-/* DECnet-specific defines for netfilter.
- * This file (C) Steve Whitehouse 1999 derived from the
- * ipv4 netfilter header file which is
- * (C)1998 Rusty Russell -- This code is GPL.
- */
-
-#include <linux/netfilter.h>
-
-/* only for userspace compatibility */
-
-#include <limits.h> /* for INT_MIN, INT_MAX */
-
-/* kernel define is in netfilter_defs.h */
-#define NF_DN_NUMHOOKS 7
-
-/* DECnet Hooks */
-/* After promisc drops, checksum checks. */
-#define NF_DN_PRE_ROUTING 0
-/* If the packet is destined for this box. */
-#define NF_DN_LOCAL_IN 1
-/* If the packet is destined for another interface. */
-#define NF_DN_FORWARD 2
-/* Packets coming from a local process. */
-#define NF_DN_LOCAL_OUT 3
-/* Packets about to hit the wire. */
-#define NF_DN_POST_ROUTING 4
-/* Input Hello Packets */
-#define NF_DN_HELLO 5
-/* Input Routing Packets */
-#define NF_DN_ROUTE 6
-
-enum nf_dn_hook_priorities {
- NF_DN_PRI_FIRST = INT_MIN,
- NF_DN_PRI_CONNTRACK = -200,
- NF_DN_PRI_MANGLE = -150,
- NF_DN_PRI_NAT_DST = -100,
- NF_DN_PRI_FILTER = 0,
- NF_DN_PRI_NAT_SRC = 100,
- NF_DN_PRI_DNRTMSG = 200,
- NF_DN_PRI_LAST = INT_MAX,
-};
-
-struct nf_dn_rtmsg {
- int nfdn_ifindex;
-};
-
-#define NFDN_RTMSG(r) ((unsigned char *)(r) + NLMSG_ALIGN(sizeof(struct nf_dn_rtmsg)))
-
-/* backwards compatibility for userspace */
-#define DNRMG_L1_GROUP 0x01
-#define DNRMG_L2_GROUP 0x02
-
-enum {
- DNRNG_NLGRP_NONE,
-#define DNRNG_NLGRP_NONE DNRNG_NLGRP_NONE
- DNRNG_NLGRP_L1,
-#define DNRNG_NLGRP_L1 DNRNG_NLGRP_L1
- DNRNG_NLGRP_L2,
-#define DNRNG_NLGRP_L2 DNRNG_NLGRP_L2
- __DNRNG_NLGRP_MAX
-};
-#define DNRNG_NLGRP_MAX (__DNRNG_NLGRP_MAX - 1)
-
-#endif /*__LINUX_DECNET_NETFILTER_H*/ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_ipv4/ip_tables.h b/lib/libc/include/any-linux-any/linux/netfilter_ipv4/ip_tables.h
index 1ed5b8f3eb..c37732f717 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter_ipv4/ip_tables.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter_ipv4/ip_tables.h
@@ -119,7 +119,7 @@ struct ipt_entry {
struct xt_counters counters;
/* The matches (if any), then the target. */
- unsigned char elems[0];
+ unsigned char elems[];
};
/*
@@ -201,7 +201,7 @@ struct ipt_replace {
struct xt_counters *counters;
/* The entries (hang off end: not really an array). */
- struct ipt_entry entries[0];
+ struct ipt_entry entries[];
};
/* The argument to IPT_SO_GET_ENTRIES. */
@@ -213,7 +213,7 @@ struct ipt_get_entries {
unsigned int size;
/* The entries. */
- struct ipt_entry entrytable[0];
+ struct ipt_entry entrytable[];
};
/* Helper functions */
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6_tables.h b/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6_tables.h
index 1df0535fdf..9afcc51efd 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6_tables.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6_tables.h
@@ -241,7 +241,7 @@ struct ip6t_replace {
struct xt_counters *counters;
/* The entries (hang off end: not really an array). */
- struct ip6t_entry entries[0];
+ struct ip6t_entry entries[];
};
/* The argument to IP6T_SO_GET_ENTRIES. */
@@ -253,7 +253,7 @@ struct ip6t_get_entries {
unsigned int size;
/* The entries. */
- struct ip6t_entry entrytable[0];
+ struct ip6t_entry entrytable[];
};
/* Helper functions */
diff --git a/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_LOG.h b/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_LOG.h
index 3bcf277977..310b744de7 100644
--- a/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_LOG.h
+++ b/lib/libc/include/any-linux-any/linux/netfilter_ipv6/ip6t_LOG.h
@@ -17,4 +17,4 @@ struct ip6t_log_info {
char prefix[30];
};
-#endif /*_IPT_LOG_H*/ \ No newline at end of file
+#endif /* _IP6T_LOG_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/netlink.h b/lib/libc/include/any-linux-any/linux/netlink.h
index 8a7362cd7d..0fffd74f01 100644
--- a/lib/libc/include/any-linux-any/linux/netlink.h
+++ b/lib/libc/include/any-linux-any/linux/netlink.h
@@ -20,7 +20,7 @@
#define NETLINK_CONNECTOR 11
#define NETLINK_NETFILTER 12 /* netfilter subsystem */
#define NETLINK_IP6_FW 13
-#define NETLINK_DNRTMSG 14 /* DECnet routing messages */
+#define NETLINK_DNRTMSG 14 /* DECnet routing messages (obsolete) */
#define NETLINK_KOBJECT_UEVENT 15 /* Kernel messages to userspace */
#define NETLINK_GENERIC 16
/* leave room for NETLINK_DM (DM Events) */
@@ -41,12 +41,20 @@ struct sockaddr_nl {
__u32 nl_groups; /* multicast groups mask */
};
+/**
+ * struct nlmsghdr - fixed format metadata header of Netlink messages
+ * @nlmsg_len: Length of message including header
+ * @nlmsg_type: Message content type
+ * @nlmsg_flags: Additional flags
+ * @nlmsg_seq: Sequence number
+ * @nlmsg_pid: Sending process port ID
+ */
struct nlmsghdr {
- __u32 nlmsg_len; /* Length of message including header */
- __u16 nlmsg_type; /* Message content */
- __u16 nlmsg_flags; /* Additional flags */
- __u32 nlmsg_seq; /* Sequence number */
- __u32 nlmsg_pid; /* Sending process port ID */
+ __u32 nlmsg_len;
+ __u16 nlmsg_type;
+ __u16 nlmsg_flags;
+ __u32 nlmsg_seq;
+ __u32 nlmsg_pid;
};
/* Flags values */
@@ -54,7 +62,7 @@ struct nlmsghdr {
#define NLM_F_REQUEST 0x01 /* It is request message. */
#define NLM_F_MULTI 0x02 /* Multipart message, terminated by NLMSG_DONE */
#define NLM_F_ACK 0x04 /* Reply with ack, with zero or error code */
-#define NLM_F_ECHO 0x08 /* Echo this request */
+#define NLM_F_ECHO 0x08 /* Receive resulting notifications */
#define NLM_F_DUMP_INTR 0x10 /* Dump was inconsistent due to sequence change */
#define NLM_F_DUMP_FILTERED 0x20 /* Dump was filtered as requested */
@@ -72,6 +80,7 @@ struct nlmsghdr {
/* Modifiers to DELETE request */
#define NLM_F_NONREC 0x100 /* Do not delete recursively */
+#define NLM_F_BULK 0x200 /* Delete multiple objects */
/* Flags for ACK message */
#define NLM_F_CAPPED 0x100 /* request was capped */
@@ -131,6 +140,10 @@ struct nlmsgerr {
* be used - in the success case - to identify a created
* object or operation or similar (binary)
* @NLMSGERR_ATTR_POLICY: policy for a rejected attribute
+ * @NLMSGERR_ATTR_MISS_TYPE: type of a missing required attribute,
+ * %NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was
+ * missing at the message level
+ * @NLMSGERR_ATTR_MISS_NEST: offset of the nest where attribute was missing
* @__NLMSGERR_ATTR_MAX: number of attributes
* @NLMSGERR_ATTR_MAX: highest attribute number
*/
@@ -140,6 +153,8 @@ enum nlmsgerr_attrs {
NLMSGERR_ATTR_OFFS,
NLMSGERR_ATTR_COOKIE,
NLMSGERR_ATTR_POLICY,
+ NLMSGERR_ATTR_MISS_TYPE,
+ NLMSGERR_ATTR_MISS_NEST,
__NLMSGERR_ATTR_MAX,
NLMSGERR_ATTR_MAX = __NLMSGERR_ATTR_MAX - 1
@@ -332,6 +347,9 @@ enum netlink_attribute_type {
* bitfield32 type (U32)
* @NL_POLICY_TYPE_ATTR_MASK: mask of valid bits for unsigned integers (U64)
* @NL_POLICY_TYPE_ATTR_PAD: pad attribute for 64-bit alignment
+ *
+ * @__NL_POLICY_TYPE_ATTR_MAX: number of attributes
+ * @NL_POLICY_TYPE_ATTR_MAX: highest attribute number
*/
enum netlink_policy_type_attr {
NL_POLICY_TYPE_ATTR_UNSPEC,
diff --git a/lib/libc/include/any-linux-any/linux/nfs4.h b/lib/libc/include/any-linux-any/linux/nfs4.h
index 06bbe3bd6e..4a74d8c6ac 100644
--- a/lib/libc/include/any-linux-any/linux/nfs4.h
+++ b/lib/libc/include/any-linux-any/linux/nfs4.h
@@ -45,6 +45,7 @@
#define NFS4_OPEN_RESULT_CONFIRM 0x0002
#define NFS4_OPEN_RESULT_LOCKTYPE_POSIX 0x0004
+#define NFS4_OPEN_RESULT_PRESERVE_UNLINKED 0x0008
#define NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK 0x0020
#define NFS4_SHARE_ACCESS_MASK 0x000F
diff --git a/lib/libc/include/any-linux-any/linux/nfs_fs.h b/lib/libc/include/any-linux-any/linux/nfs_fs.h
index 763cf9cedc..fd2b6fa719 100644
--- a/lib/libc/include/any-linux-any/linux/nfs_fs.h
+++ b/lib/libc/include/any-linux-any/linux/nfs_fs.h
@@ -52,7 +52,7 @@
#define NFSDBG_CALLBACK 0x0100
#define NFSDBG_CLIENT 0x0200
#define NFSDBG_MOUNT 0x0400
-#define NFSDBG_FSCACHE 0x0800
+#define NFSDBG_FSCACHE 0x0800 /* unused */
#define NFSDBG_PNFS 0x1000
#define NFSDBG_PNFS_LD 0x2000
#define NFSDBG_STATE 0x4000
diff --git a/lib/libc/include/any-linux-any/linux/nl80211.h b/lib/libc/include/any-linux-any/linux/nl80211.h
index fe5482291c..3e927dd2c8 100644
--- a/lib/libc/include/any-linux-any/linux/nl80211.h
+++ b/lib/libc/include/any-linux-any/linux/nl80211.h
@@ -11,7 +11,7 @@
* Copyright 2008 Jouni Malinen <jouni.malinen@atheros.com>
* Copyright 2008 Colin McCabe <colin@cozybit.com>
* Copyright 2015-2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2021 Intel Corporation
+ * Copyright (C) 2018-2022 Intel Corporation
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -324,6 +324,17 @@
*/
/**
+ * DOC: Multi-Link Operation
+ *
+ * In Multi-Link Operation, a connection between to MLDs utilizes multiple
+ * links. To use this in nl80211, various commands and responses now need
+ * to or will include the new %NL80211_ATTR_MLO_LINKS attribute.
+ * Additionally, various commands that need to operate on a specific link
+ * now need to be given the %NL80211_ATTR_MLO_LINK_ID attribute, e.g. to
+ * use %NL80211_CMD_START_AP or similar functions.
+ */
+
+/**
* enum nl80211_commands - supported nl80211 commands
*
* @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -366,14 +377,22 @@
* the non-transmitting interfaces are deleted as well.
*
* @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
- * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
+ * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC
+ * represents peer's MLD address for MLO pairwise key. For MLO group key,
+ * the link is identified by %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT,
* %NL80211_ATTR_KEY_DEFAULT_MGMT, or %NL80211_ATTR_KEY_THRESHOLD.
+ * For MLO connection, the link to set default key is identified by
+ * %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
* %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
- * and %NL80211_ATTR_KEY_SEQ attributes.
+ * and %NL80211_ATTR_KEY_SEQ attributes. %NL80211_ATTR_MAC represents
+ * peer's MLD address for MLO pairwise key. The link to add MLO
+ * group key is identified by %NL80211_ATTR_MLO_LINK_ID.
* @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
- * or %NL80211_ATTR_MAC.
+ * or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC represents peer's MLD address
+ * for MLO pairwise key. The link to delete group key is identified by
+ * %NL80211_ATTR_MLO_LINK_ID.
*
* @NL80211_CMD_GET_BEACON: (not used)
* @NL80211_CMD_SET_BEACON: change the beacon on an access point interface
@@ -405,7 +424,8 @@
* interface identified by %NL80211_ATTR_IFINDEX.
* @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
* or, if no MAC address given, all stations, on the interface identified
- * by %NL80211_ATTR_IFINDEX. %NL80211_ATTR_MGMT_SUBTYPE and
+ * by %NL80211_ATTR_IFINDEX. For MLD station, MLD address is used in
+ * %NL80211_ATTR_MAC. %NL80211_ATTR_MGMT_SUBTYPE and
* %NL80211_ATTR_REASON_CODE can optionally be used to specify which type
* of disconnection indication should be sent to the station
* (Deauthentication or Disassociation frame and reason code for that
@@ -753,6 +773,13 @@
* %NL80211_ATTR_CSA_C_OFFSETS_TX is an array of offsets to CSA
* counters which will be updated to the current value. This attribute
* is used during CSA period.
+ * For TX on an MLD, the frequency can be omitted and the link ID be
+ * specified, or if transmitting to a known peer MLD (with MLD addresses
+ * in the frame) both can be omitted and the link will be selected by
+ * lower layers.
+ * For RX notification, %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
+ * indicate the frame RX timestamp and %NL80211_ATTR_TX_HW_TIMESTAMP may
+ * be included to indicate the ack TX timestamp.
* @NL80211_CMD_FRAME_WAIT_CANCEL: When an off-channel TX was requested, this
* command may be used with the corresponding cookie to cancel the wait
* time if it is known that it is no longer necessary. This command is
@@ -763,7 +790,9 @@
* transmitted with %NL80211_CMD_FRAME. %NL80211_ATTR_COOKIE identifies
* the TX command and %NL80211_ATTR_FRAME includes the contents of the
* frame. %NL80211_ATTR_ACK flag is included if the recipient acknowledged
- * the frame.
+ * the frame. %NL80211_ATTR_TX_HW_TIMESTAMP may be included to indicate the
+ * tx timestamp and %NL80211_ATTR_RX_HW_TIMESTAMP may be included to
+ * indicate the ack RX timestamp.
* @NL80211_CMD_ACTION_TX_STATUS: Alias for @NL80211_CMD_FRAME_TX_STATUS for
* backward compatibility.
*
@@ -1108,6 +1137,12 @@
* has been received. %NL80211_ATTR_FRAME is used to specify the
* frame contents. The frame is the raw EAPoL data, without ethernet or
* 802.11 headers.
+ * For an MLD transmitter, the %NL80211_ATTR_MLO_LINK_ID may be given and
+ * its effect will depend on the destination: If the destination is known
+ * to be an MLD, this will be used as a hint to select the link to transmit
+ * the frame on. If the destination is not an MLD, this will select both
+ * the link to transmit on and the source address will be set to the link
+ * address of that link.
* When used as an event indication %NL80211_ATTR_CONTROL_PORT_ETHERTYPE,
* %NL80211_ATTR_CONTROL_PORT_NO_ENCRYPT and %NL80211_ATTR_MAC are added
* indicating the protocol type of the received frame; whether the frame
@@ -1132,6 +1167,23 @@
* %NL80211_ATTR_STATUS_CODE attribute in %NL80211_CMD_EXTERNAL_AUTH
* command interface.
*
+ * Host driver sends MLD address of the AP with %NL80211_ATTR_MLD_ADDR in
+ * %NL80211_CMD_EXTERNAL_AUTH event to indicate user space to enable MLO
+ * during the authentication offload in STA mode while connecting to MLD
+ * APs. Host driver should check %NL80211_ATTR_MLO_SUPPORT flag capability
+ * in %NL80211_CMD_CONNECT to know whether the user space supports enabling
+ * MLO during the authentication offload or not.
+ * User space should enable MLO during the authentication only when it
+ * receives the AP MLD address in authentication offload request. User
+ * space shouldn't enable MLO when the authentication offload request
+ * doesn't indicate the AP MLD address even if the AP is MLO capable.
+ * User space should use %NL80211_ATTR_MLD_ADDR as peer's MLD address and
+ * interface address identified by %NL80211_ATTR_IFINDEX as self MLD
+ * address. User space and host driver to use MLD addresses in RA, TA and
+ * BSSID fields of the frames between them, and host driver translates the
+ * MLD addresses to/from link addresses based on the link chosen for the
+ * authentication.
+ *
* Host driver reports this status on an authentication failure to the
* user space through the connect result as the user space would have
* initiated the connection through the connect request.
@@ -1232,6 +1284,21 @@
* &NL80211_ATTR_FILS_NONCES - for FILS Nonces
* (STA Nonce 16 bytes followed by AP Nonce 16 bytes)
*
+ * @NL80211_CMD_ASSOC_COMEBACK: notification about an association
+ * temporal rejection with comeback. The event includes %NL80211_ATTR_MAC
+ * to describe the BSSID address of the AP and %NL80211_ATTR_TIMEOUT to
+ * specify the timeout value.
+ *
+ * @NL80211_CMD_ADD_LINK: Add a new link to an interface. The
+ * %NL80211_ATTR_MLO_LINK_ID attribute is used for the new link.
+ * @NL80211_CMD_REMOVE_LINK: Remove a link from an interface. This may come
+ * without %NL80211_ATTR_MLO_LINK_ID as an easy way to remove all links
+ * in preparation for e.g. roaming to a regular (non-MLO) AP.
+ *
+ * @NL80211_CMD_ADD_LINK_STA: Add a link to an MLD station
+ * @NL80211_CMD_MODIFY_LINK_STA: Modify a link of an MLD station
+ * @NL80211_CMD_REMOVE_LINK_STA: Remove a link of an MLD station
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -1474,6 +1541,15 @@ enum nl80211_commands {
NL80211_CMD_SET_FILS_AAD,
+ NL80211_CMD_ASSOC_COMEBACK,
+
+ NL80211_CMD_ADD_LINK,
+ NL80211_CMD_REMOVE_LINK,
+
+ NL80211_CMD_ADD_LINK_STA,
+ NL80211_CMD_MODIFY_LINK_STA,
+ NL80211_CMD_REMOVE_LINK_STA,
+
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
@@ -2333,8 +2409,10 @@ enum nl80211_commands {
*
* @NL80211_ATTR_IFTYPE_EXT_CAPA: Nested attribute of the following attributes:
* %NL80211_ATTR_IFTYPE, %NL80211_ATTR_EXT_CAPA,
- * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities per
- * interface type.
+ * %NL80211_ATTR_EXT_CAPA_MASK, to specify the extended capabilities and
+ * other interface-type specific capabilities per interface type. For MLO,
+ * %NL80211_ATTR_EML_CAPABILITY and %NL80211_ATTR_MLD_CAPA_AND_OPS are
+ * present.
*
* @NL80211_ATTR_MU_MIMO_GROUP_DATA: array of 24 bytes that defines a MU-MIMO
* groupID for monitor mode.
@@ -2470,7 +2548,9 @@ enum nl80211_commands {
* space supports external authentication. This attribute shall be used
* with %NL80211_CMD_CONNECT and %NL80211_CMD_START_AP request. The driver
* may offload authentication processing to user space if this capability
- * is indicated in the respective requests from the user space.
+ * is indicated in the respective requests from the user space. (This flag
+ * attribute deprecated for %NL80211_CMD_START_AP, use
+ * %NL80211_ATTR_AP_SETTINGS_FLAGS)
*
* @NL80211_ATTR_NSS: Station's New/updated RX_NSS value notified using this
* u8 attribute. This is used with %NL80211_CMD_STA_OPMODE_CHANGED.
@@ -2639,6 +2719,62 @@ enum nl80211_commands {
* Mandatory parameter for the transmitting interface to enable MBSSID.
* Optional for the non-transmitting interfaces.
*
+ * @NL80211_ATTR_RADAR_BACKGROUND: Configure dedicated offchannel chain
+ * available for radar/CAC detection on some hw. This chain can't be used
+ * to transmit or receive frames and it is bounded to a running wdev.
+ * Background radar/CAC detection allows to avoid the CAC downtime
+ * switching on a different channel during CAC detection on the selected
+ * radar channel.
+ *
+ * @NL80211_ATTR_AP_SETTINGS_FLAGS: u32 attribute contains ap settings flags,
+ * enumerated in &enum nl80211_ap_settings_flags. This attribute shall be
+ * used with %NL80211_CMD_START_AP request.
+ *
+ * @NL80211_ATTR_EHT_CAPABILITY: EHT Capability information element (from
+ * association request when used with NL80211_CMD_NEW_STATION). Can be set
+ * only if %NL80211_STA_FLAG_WME is set.
+ *
+ * @NL80211_ATTR_MLO_LINK_ID: A (u8) link ID for use with MLO, to be used with
+ * various commands that need a link ID to operate.
+ * @NL80211_ATTR_MLO_LINKS: A nested array of links, each containing some
+ * per-link information and a link ID.
+ * @NL80211_ATTR_MLD_ADDR: An MLD address, used with various commands such as
+ * authenticate/associate.
+ *
+ * @NL80211_ATTR_MLO_SUPPORT: Flag attribute to indicate user space supports MLO
+ * connection. Used with %NL80211_CMD_CONNECT. If this attribute is not
+ * included in NL80211_CMD_CONNECT drivers must not perform MLO connection.
+ *
+ * @NL80211_ATTR_MAX_NUM_AKM_SUITES: U16 attribute. Indicates maximum number of
+ * AKM suites allowed for %NL80211_CMD_CONNECT, %NL80211_CMD_ASSOCIATE and
+ * %NL80211_CMD_START_AP in %NL80211_CMD_GET_WIPHY response. If this
+ * attribute is not present userspace shall consider maximum number of AKM
+ * suites allowed as %NL80211_MAX_NR_AKM_SUITES which is the legacy maximum
+ * number prior to the introduction of this attribute.
+ *
+ * @NL80211_ATTR_EML_CAPABILITY: EML Capability information (u16)
+ * @NL80211_ATTR_MLD_CAPA_AND_OPS: MLD Capabilities and Operations (u16)
+ *
+ * @NL80211_ATTR_TX_HW_TIMESTAMP: Hardware timestamp for TX operation in
+ * nanoseconds (u64). This is the device clock timestamp so it will
+ * probably reset when the device is stopped or the firmware is reset.
+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the frame TX
+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
+ * the ack TX timestamp.
+ * @NL80211_ATTR_RX_HW_TIMESTAMP: Hardware timestamp for RX operation in
+ * nanoseconds (u64). This is the device clock timestamp so it will
+ * probably reset when the device is stopped or the firmware is reset.
+ * When used with %NL80211_CMD_FRAME_TX_STATUS, indicates the ack RX
+ * timestamp. When used with %NL80211_CMD_FRAME RX notification, indicates
+ * the incoming frame RX timestamp.
+ * @NL80211_ATTR_TD_BITMAP: Transition Disable bitmap, for subsequent
+ * (re)associations.
+ *
+ * @NL80211_ATTR_PUNCT_BITMAP: (u32) Preamble puncturing bitmap, lowest
+ * bit corresponds to the lowest 20 MHz channel. Each bit set to 1
+ * indicates that the sub-channel is punctured. Higher 16 bits are
+ * reserved.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3145,6 +3281,31 @@ enum nl80211_attrs {
NL80211_ATTR_MBSSID_CONFIG,
NL80211_ATTR_MBSSID_ELEMS,
+ NL80211_ATTR_RADAR_BACKGROUND,
+
+ NL80211_ATTR_AP_SETTINGS_FLAGS,
+
+ NL80211_ATTR_EHT_CAPABILITY,
+
+ NL80211_ATTR_DISABLE_EHT,
+
+ NL80211_ATTR_MLO_LINKS,
+ NL80211_ATTR_MLO_LINK_ID,
+ NL80211_ATTR_MLD_ADDR,
+
+ NL80211_ATTR_MLO_SUPPORT,
+
+ NL80211_ATTR_MAX_NUM_AKM_SUITES,
+
+ NL80211_ATTR_EML_CAPABILITY,
+ NL80211_ATTR_MLD_CAPA_AND_OPS,
+
+ NL80211_ATTR_TX_HW_TIMESTAMP,
+ NL80211_ATTR_RX_HW_TIMESTAMP,
+ NL80211_ATTR_TD_BITMAP,
+
+ NL80211_ATTR_PUNCT_BITMAP,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -3199,7 +3360,14 @@ enum nl80211_attrs {
#define NL80211_HE_MIN_CAPABILITY_LEN 16
#define NL80211_HE_MAX_CAPABILITY_LEN 54
#define NL80211_MAX_NR_CIPHER_SUITES 5
+
+/*
+ * NL80211_MAX_NR_AKM_SUITES is obsolete when %NL80211_ATTR_MAX_NUM_AKM_SUITES
+ * present in %NL80211_CMD_GET_WIPHY response.
+ */
#define NL80211_MAX_NR_AKM_SUITES 2
+#define NL80211_EHT_MIN_CAPABILITY_LEN 13
+#define NL80211_EHT_MAX_CAPABILITY_LEN 51
#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
@@ -3227,7 +3395,7 @@ enum nl80211_attrs {
* and therefore can't be created in the normal ways, use the
* %NL80211_CMD_START_P2P_DEVICE and %NL80211_CMD_STOP_P2P_DEVICE
* commands to create and destroy one
- * @NL80211_IF_TYPE_OCB: Outside Context of a BSS
+ * @NL80211_IFTYPE_OCB: Outside Context of a BSS
* This mode corresponds to the MIB variable dot11OCBActivated=true
* @NL80211_IFTYPE_NAN: NAN device interface type (not a netdev)
* @NL80211_IFTYPE_MAX: highest interface type number currently defined
@@ -3369,6 +3537,56 @@ enum nl80211_he_ru_alloc {
};
/**
+ * enum nl80211_eht_gi - EHT guard interval
+ * @NL80211_RATE_INFO_EHT_GI_0_8: 0.8 usec
+ * @NL80211_RATE_INFO_EHT_GI_1_6: 1.6 usec
+ * @NL80211_RATE_INFO_EHT_GI_3_2: 3.2 usec
+ */
+enum nl80211_eht_gi {
+ NL80211_RATE_INFO_EHT_GI_0_8,
+ NL80211_RATE_INFO_EHT_GI_1_6,
+ NL80211_RATE_INFO_EHT_GI_3_2,
+};
+
+/**
+ * enum nl80211_eht_ru_alloc - EHT RU allocation values
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_26: 26-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_52: 52-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_52P26: 52+26-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_106: 106-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_106P26: 106+26 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_242: 242-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_484: 484-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_484P242: 484+242 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_996: 996-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_996P484: 996+484 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242: 996+484+242 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_2x996: 2x996-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484: 2x996+484 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_3x996: 3x996-tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484: 3x996+484 tone RU allocation
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC_4x996: 4x996-tone RU allocation
+ */
+enum nl80211_eht_ru_alloc {
+ NL80211_RATE_INFO_EHT_RU_ALLOC_26,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_52,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_52P26,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_106,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_106P26,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_242,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_484,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_484P242,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_996,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_996P484,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_996P484P242,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_2x996,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_2x996P484,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_3x996,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_3x996P484,
+ NL80211_RATE_INFO_EHT_RU_ALLOC_4x996,
+};
+
+/**
* enum nl80211_rate_info - bitrate information
*
* These attribute types are used with %NL80211_STA_INFO_TXRATE
@@ -3407,6 +3625,13 @@ enum nl80211_he_ru_alloc {
* @NL80211_RATE_INFO_HE_DCM: HE DCM value (u8, 0/1)
* @NL80211_RATE_INFO_RU_ALLOC: HE RU allocation, if not present then
* non-OFDMA was used (u8, see &enum nl80211_he_ru_alloc)
+ * @NL80211_RATE_INFO_320_MHZ_WIDTH: 320 MHz bitrate
+ * @NL80211_RATE_INFO_EHT_MCS: EHT MCS index (u8, 0-15)
+ * @NL80211_RATE_INFO_EHT_NSS: EHT NSS value (u8, 1-8)
+ * @NL80211_RATE_INFO_EHT_GI: EHT guard interval identifier
+ * (u8, see &enum nl80211_eht_gi)
+ * @NL80211_RATE_INFO_EHT_RU_ALLOC: EHT RU allocation, if not present then
+ * non-OFDMA was used (u8, see &enum nl80211_eht_ru_alloc)
* @__NL80211_RATE_INFO_AFTER_LAST: internal use
*/
enum nl80211_rate_info {
@@ -3428,6 +3653,11 @@ enum nl80211_rate_info {
NL80211_RATE_INFO_HE_GI,
NL80211_RATE_INFO_HE_DCM,
NL80211_RATE_INFO_HE_RU_ALLOC,
+ NL80211_RATE_INFO_320_MHZ_WIDTH,
+ NL80211_RATE_INFO_EHT_MCS,
+ NL80211_RATE_INFO_EHT_NSS,
+ NL80211_RATE_INFO_EHT_GI,
+ NL80211_RATE_INFO_EHT_RU_ALLOC,
/* keep last */
__NL80211_RATE_INFO_AFTER_LAST,
@@ -3738,13 +3968,20 @@ enum nl80211_mpath_info {
* capabilities IE
* @NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE: HE PPE thresholds information as
* defined in HE capabilities IE
- * @NL80211_BAND_IFTYPE_ATTR_MAX: highest band HE capability attribute currently
- * defined
* @NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA: HE 6GHz band capabilities (__le16),
* given for all 6 GHz band channels
* @NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS: vendor element capabilities that are
* advertised on this band/for this iftype (binary)
+ * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MAC: EHT MAC capabilities as in EHT
+ * capabilities element
+ * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PHY: EHT PHY capabilities as in EHT
+ * capabilities element
+ * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MCS_SET: EHT supported NSS/MCS as in EHT
+ * capabilities element
+ * @NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE: EHT PPE thresholds information as
+ * defined in EHT capabilities element
* @__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST: internal use
+ * @NL80211_BAND_IFTYPE_ATTR_MAX: highest band attribute currently defined
*/
enum nl80211_band_iftype_attr {
__NL80211_BAND_IFTYPE_ATTR_INVALID,
@@ -3756,6 +3993,10 @@ enum nl80211_band_iftype_attr {
NL80211_BAND_IFTYPE_ATTR_HE_CAP_PPE,
NL80211_BAND_IFTYPE_ATTR_HE_6GHZ_CAPA,
NL80211_BAND_IFTYPE_ATTR_VENDOR_ELEMS,
+ NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MAC,
+ NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PHY,
+ NL80211_BAND_IFTYPE_ATTR_EHT_CAP_MCS_SET,
+ NL80211_BAND_IFTYPE_ATTR_EHT_CAP_PPE,
/* keep last */
__NL80211_BAND_IFTYPE_ATTR_AFTER_LAST,
@@ -3900,6 +4141,10 @@ enum nl80211_wmm_rule {
* on this channel in current regulatory domain.
* @NL80211_FREQUENCY_ATTR_16MHZ: 16 MHz operation is allowed
* on this channel in current regulatory domain.
+ * @NL80211_FREQUENCY_ATTR_NO_320MHZ: any 320 MHz channel using this channel
+ * as the primary or any of the secondary channels isn't possible
+ * @NL80211_FREQUENCY_ATTR_NO_EHT: EHT operation is not allowed on this channel
+ * in current regulatory domain.
* @NL80211_FREQUENCY_ATTR_MAX: highest frequency attribute number
* currently defined
* @__NL80211_FREQUENCY_ATTR_AFTER_LAST: internal use
@@ -3936,6 +4181,8 @@ enum nl80211_frequency_attr {
NL80211_FREQUENCY_ATTR_4MHZ,
NL80211_FREQUENCY_ATTR_8MHZ,
NL80211_FREQUENCY_ATTR_16MHZ,
+ NL80211_FREQUENCY_ATTR_NO_320MHZ,
+ NL80211_FREQUENCY_ATTR_NO_EHT,
/* keep last */
__NL80211_FREQUENCY_ATTR_AFTER_LAST,
@@ -4134,6 +4381,7 @@ enum nl80211_sched_scan_match_attr {
* @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed
* @NL80211_RRF_NO_160MHZ: 160MHz operation not allowed
* @NL80211_RRF_NO_HE: HE operation not allowed
+ * @NL80211_RRF_NO_320MHZ: 320MHz operation not allowed
*/
enum nl80211_reg_rule_flags {
NL80211_RRF_NO_OFDM = 1<<0,
@@ -4152,6 +4400,7 @@ enum nl80211_reg_rule_flags {
NL80211_RRF_NO_80MHZ = 1<<15,
NL80211_RRF_NO_160MHZ = 1<<16,
NL80211_RRF_NO_HE = 1<<17,
+ NL80211_RRF_NO_320MHZ = 1<<18,
};
#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
@@ -4649,6 +4898,8 @@ enum nl80211_key_mode {
* @NL80211_CHAN_WIDTH_4: 4 MHz OFDM channel
* @NL80211_CHAN_WIDTH_8: 8 MHz OFDM channel
* @NL80211_CHAN_WIDTH_16: 16 MHz OFDM channel
+ * @NL80211_CHAN_WIDTH_320: 320 MHz channel, the %NL80211_ATTR_CENTER_FREQ1
+ * attribute must be provided as well
*/
enum nl80211_chan_width {
NL80211_CHAN_WIDTH_20_NOHT,
@@ -4664,6 +4915,7 @@ enum nl80211_chan_width {
NL80211_CHAN_WIDTH_4,
NL80211_CHAN_WIDTH_8,
NL80211_CHAN_WIDTH_16,
+ NL80211_CHAN_WIDTH_320,
};
/**
@@ -4735,6 +4987,8 @@ enum nl80211_bss_scan_width {
* Contains a nested array of signal strength attributes (u8, dBm),
* using the nesting index as the antenna number.
* @NL80211_BSS_FREQUENCY_OFFSET: frequency offset in KHz
+ * @NL80211_BSS_MLO_LINK_ID: MLO link ID of the BSS (u8).
+ * @NL80211_BSS_MLD_ADDR: MLD address of this BSS if connected to it.
* @__NL80211_BSS_AFTER_LAST: internal
* @NL80211_BSS_MAX: highest BSS attribute
*/
@@ -4760,6 +5014,8 @@ enum nl80211_bss {
NL80211_BSS_PARENT_BSSID,
NL80211_BSS_CHAIN_SIGNAL,
NL80211_BSS_FREQUENCY_OFFSET,
+ NL80211_BSS_MLO_LINK_ID,
+ NL80211_BSS_MLD_ADDR,
/* keep last */
__NL80211_BSS_AFTER_LAST,
@@ -5555,7 +5811,7 @@ enum nl80211_iface_limit_attrs {
* => allows 8 of AP/GO that can have BI gcd >= min gcd
*
* numbers = [ #{STA} <= 2 ], channels = 2, max = 2
- * => allows two STAs on different channels
+ * => allows two STAs on the same or on different channels
*
* numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
* => allows a STA plus three P2P interfaces
@@ -5600,7 +5856,7 @@ enum nl80211_if_combination_attrs {
* @NL80211_PLINK_ESTAB: mesh peer link is established
* @NL80211_PLINK_HOLDING: mesh peer link is being closed or cancelled
* @NL80211_PLINK_BLOCKED: all frames transmitted from this mesh
- * plink are discarded
+ * plink are discarded, except for authentication frames
* @NUM_NL80211_PLINK_STATES: number of peer link states
* @MAX_NL80211_PLINK_STATES: highest numerical value of plink states
*/
@@ -5639,6 +5895,7 @@ enum plink_actions {
#define NL80211_KEK_LEN 16
#define NL80211_KCK_EXT_LEN 24
#define NL80211_KEK_EXT_LEN 32
+#define NL80211_KCK_EXT_LEN_32 32
#define NL80211_REPLAY_CTR_LEN 8
/**
@@ -5737,13 +5994,15 @@ enum nl80211_tdls_operation {
NL80211_TDLS_DISABLE_LINK,
};
-/*
+/**
* enum nl80211_ap_sme_features - device-integrated AP features
- * Reserved for future use, no bits are defined in
- * NL80211_ATTR_DEVICE_AP_SME yet.
+ * @NL80211_AP_SME_SA_QUERY_OFFLOAD: SA Query procedures offloaded to driver
+ * when user space indicates support for SA Query procedures offload during
+ * "start ap" with %NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT.
+ */
enum nl80211_ap_sme_features {
+ NL80211_AP_SME_SA_QUERY_OFFLOAD = 1 << 0,
};
- */
/**
* enum nl80211_feature_flags - device/driver features
@@ -5754,7 +6013,7 @@ enum nl80211_ap_sme_features {
* @NL80211_FEATURE_INACTIVITY_TIMER: This driver takes care of freeing up
* the connected inactive stations in AP mode.
* @NL80211_FEATURE_CELL_BASE_REG_HINTS: This driver has been tested
- * to work properly to suppport receiving regulatory hints from
+ * to work properly to support receiving regulatory hints from
* cellular base stations.
* @NL80211_FEATURE_P2P_DEVICE_NEEDS_CHANNEL: (no longer available, only
* here to reserve the value for API/ABI compatibility)
@@ -6051,6 +6310,22 @@ enum nl80211_feature_flags {
* frames. Userspace has to share FILS AAD details to the driver by using
* @NL80211_CMD_SET_FILS_AAD.
*
+ * @NL80211_EXT_FEATURE_RADAR_BACKGROUND: Device supports background radar/CAC
+ * detection.
+ *
+ * @NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE: Device can perform a MAC address
+ * change without having to bring the underlying network device down
+ * first. For example, in station mode this can be used to vary the
+ * origin MAC address prior to a connection to a new AP for privacy
+ * or other reasons. Note that certain driver specific restrictions
+ * might apply, e.g. no scans in progress, no offchannel operations
+ * in progress, and no active connections.
+ *
+ * @NL80211_EXT_FEATURE_PUNCT: Driver supports preamble puncturing in AP mode.
+ *
+ * @NL80211_EXT_FEATURE_SECURE_NAN: Device supports NAN Pairing which enables
+ * authentication, data encryption and message integrity.
+ *
* @NUM_NL80211_EXT_FEATURES: number of extended features.
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
*/
@@ -6117,6 +6392,10 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE,
NL80211_EXT_FEATURE_BSS_COLOR,
NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
+ NL80211_EXT_FEATURE_RADAR_BACKGROUND,
+ NL80211_EXT_FEATURE_POWERED_ADDR_CHANGE,
+ NL80211_EXT_FEATURE_PUNCT,
+ NL80211_EXT_FEATURE_SECURE_NAN,
/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
@@ -7462,4 +7741,20 @@ enum nl80211_mbssid_config_attributes {
NL80211_MBSSID_CONFIG_ATTR_MAX = __NL80211_MBSSID_CONFIG_ATTR_LAST - 1,
};
+/**
+ * enum nl80211_ap_settings_flags - AP settings flags
+ *
+ * @NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT: AP supports external
+ * authentication.
+ * @NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT: Userspace supports SA Query
+ * procedures offload to driver. If driver advertises
+ * %NL80211_AP_SME_SA_QUERY_OFFLOAD in AP SME features, userspace shall
+ * ignore SA Query procedures and validations when this flag is set by
+ * userspace.
+ */
+enum nl80211_ap_settings_flags {
+ NL80211_AP_SETTINGS_EXTERNAL_AUTH_SUPPORT = 1 << 0,
+ NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1,
+};
+
#endif /* __LINUX_NL80211_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/nvme_ioctl.h b/lib/libc/include/any-linux-any/linux/nvme_ioctl.h
index f143faf3a2..7dc6d52736 100644
--- a/lib/libc/include/any-linux-any/linux/nvme_ioctl.h
+++ b/lib/libc/include/any-linux-any/linux/nvme_ioctl.h
@@ -55,7 +55,10 @@ struct nvme_passthru_cmd64 {
__u64 metadata;
__u64 addr;
__u32 metadata_len;
- __u32 data_len;
+ union {
+ __u32 data_len; /* for non-vectored io */
+ __u32 vec_cnt; /* for vectored io */
+ };
__u32 cdw10;
__u32 cdw11;
__u32 cdw12;
@@ -67,6 +70,28 @@ struct nvme_passthru_cmd64 {
__u64 result;
};
+/* same as struct nvme_passthru_cmd64, minus the 8b result field */
+struct nvme_uring_cmd {
+ __u8 opcode;
+ __u8 flags;
+ __u16 rsvd1;
+ __u32 nsid;
+ __u32 cdw2;
+ __u32 cdw3;
+ __u64 metadata;
+ __u64 addr;
+ __u32 metadata_len;
+ __u32 data_len;
+ __u32 cdw10;
+ __u32 cdw11;
+ __u32 cdw12;
+ __u32 cdw13;
+ __u32 cdw14;
+ __u32 cdw15;
+ __u32 timeout_ms;
+ __u32 rsvd2;
+};
+
#define nvme_admin_cmd nvme_passthru_cmd
#define NVME_IOCTL_ID _IO('N', 0x40)
@@ -78,5 +103,12 @@ struct nvme_passthru_cmd64 {
#define NVME_IOCTL_RESCAN _IO('N', 0x46)
#define NVME_IOCTL_ADMIN64_CMD _IOWR('N', 0x47, struct nvme_passthru_cmd64)
#define NVME_IOCTL_IO64_CMD _IOWR('N', 0x48, struct nvme_passthru_cmd64)
+#define NVME_IOCTL_IO64_CMD_VEC _IOWR('N', 0x49, struct nvme_passthru_cmd64)
+
+/* io_uring async commands: */
+#define NVME_URING_CMD_IO _IOWR('N', 0x80, struct nvme_uring_cmd)
+#define NVME_URING_CMD_IO_VEC _IOWR('N', 0x81, struct nvme_uring_cmd)
+#define NVME_URING_CMD_ADMIN _IOWR('N', 0x82, struct nvme_uring_cmd)
+#define NVME_URING_CMD_ADMIN_VEC _IOWR('N', 0x83, struct nvme_uring_cmd)
#endif /* _LINUX_NVME_IOCTL_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/omap3isp.h b/lib/libc/include/any-linux-any/linux/omap3isp.h
index cbf8b41efc..29f3e644d6 100644
--- a/lib/libc/include/any-linux-any/linux/omap3isp.h
+++ b/lib/libc/include/any-linux-any/linux/omap3isp.h
@@ -162,6 +162,7 @@ struct omap3isp_h3a_aewb_config {
* struct omap3isp_stat_data - Statistic data sent to or received from user
* @ts: Timestamp of returned framestats.
* @buf: Pointer to pass to user.
+ * @buf_size: Size of buffer.
* @frame_number: Frame number of requested stats.
* @cur_frame: Current frame number being processed.
* @config_counter: Number of the configuration associated with the data.
@@ -169,10 +170,12 @@ struct omap3isp_h3a_aewb_config {
struct omap3isp_stat_data {
struct timeval ts;
void *buf;
- __u32 buf_size;
- __u16 frame_number;
- __u16 cur_frame;
- __u16 config_counter;
+ __struct_group(/* no tag */, frame, /* no attrs */,
+ __u32 buf_size;
+ __u16 frame_number;
+ __u16 cur_frame;
+ __u16 config_counter;
+ );
};
diff --git a/lib/libc/include/any-linux-any/linux/openvswitch.h b/lib/libc/include/any-linux-any/linux/openvswitch.h
index 22a37ff009..b41c7626ac 100644
--- a/lib/libc/include/any-linux-any/linux/openvswitch.h
+++ b/lib/libc/include/any-linux-any/linux/openvswitch.h
@@ -76,6 +76,8 @@ enum ovs_datapath_cmd {
* datapath. Always present in notifications.
* @OVS_DP_ATTR_MEGAFLOW_STATS: Statistics about mega flow masks usage for the
* datapath. Always present in notifications.
+ * @OVS_DP_ATTR_IFINDEX: Interface index for a new datapath netdev. Only
+ * valid for %OVS_DP_CMD_NEW requests.
*
* These attributes follow the &struct ovs_header within the Generic Netlink
* payload for %OVS_DP_* commands.
@@ -92,6 +94,7 @@ enum ovs_datapath_attr {
OVS_DP_ATTR_PER_CPU_PIDS, /* Netlink PIDS to receive upcalls in
* per-cpu dispatch mode
*/
+ OVS_DP_ATTR_IFINDEX,
__OVS_DP_ATTR_MAX
};
@@ -274,11 +277,25 @@ enum ovs_vport_attr {
OVS_VPORT_ATTR_PAD,
OVS_VPORT_ATTR_IFINDEX,
OVS_VPORT_ATTR_NETNSID,
+ OVS_VPORT_ATTR_UPCALL_STATS,
__OVS_VPORT_ATTR_MAX
};
#define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1)
+/**
+ * enum ovs_vport_upcall_attr - attributes for %OVS_VPORT_UPCALL* commands
+ * @OVS_VPORT_UPCALL_SUCCESS: 64-bit upcall success packets.
+ * @OVS_VPORT_UPCALL_FAIL: 64-bit upcall fail packets.
+ */
+enum ovs_vport_upcall_attr {
+ OVS_VPORT_UPCALL_ATTR_SUCCESS,
+ OVS_VPORT_UPCALL_ATTR_FAIL,
+ __OVS_VPORT_UPCALL_ATTR_MAX
+};
+
+#define OVS_VPORT_UPCALL_ATTR_MAX (__OVS_VPORT_UPCALL_ATTR_MAX - 1)
+
enum {
OVS_VXLAN_EXT_UNSPEC,
OVS_VXLAN_EXT_GBP, /* Flag or __u32 */
@@ -352,6 +369,20 @@ enum ovs_key_attr {
OVS_KEY_ATTR_CT_ORIG_TUPLE_IPV6, /* struct ovs_key_ct_tuple_ipv6 */
OVS_KEY_ATTR_NSH, /* Nested set of ovs_nsh_key_* */
+ /* User space decided to squat on types 29 and 30. They are defined
+ * below, but should not be sent to the kernel.
+ *
+ * WARNING: No new types should be added unless they are defined
+ * for both kernel and user space (no 'ifdef's). It's hard
+ * to keep compatibility otherwise.
+ */
+ OVS_KEY_ATTR_PACKET_TYPE, /* be32 packet type */
+ OVS_KEY_ATTR_ND_EXTENSIONS, /* IPv6 Neighbor Discovery extensions */
+
+ OVS_KEY_ATTR_TUNNEL_INFO, /* struct ip_tunnel_info.
+ * For in-kernel use only.
+ */
+ OVS_KEY_ATTR_IPV6_EXTHDRS, /* struct ovs_key_ipv6_exthdr */
__OVS_KEY_ATTR_MAX
};
@@ -427,6 +458,11 @@ struct ovs_key_ipv6 {
__u8 ipv6_frag; /* One of OVS_FRAG_TYPE_*. */
};
+/* separate structure to support backward compatibility with older user space */
+struct ovs_key_ipv6_exthdrs {
+ __u16 hdrs;
+};
+
struct ovs_key_tcp {
__be16 tcp_src;
__be16 tcp_dst;
diff --git a/lib/libc/include/any-linux-any/linux/pci_regs.h b/lib/libc/include/any-linux-any/linux/pci_regs.h
index 50d858110d..8e1c8452b0 100644
--- a/lib/libc/include/any-linux-any/linux/pci_regs.h
+++ b/lib/libc/include/any-linux-any/linux/pci_regs.h
@@ -301,23 +301,23 @@
#define PCI_SID_ESR_FIC 0x20 /* First In Chassis Flag */
#define PCI_SID_CHASSIS_NR 3 /* Chassis Number */
-/* Message Signalled Interrupt registers */
+/* Message Signaled Interrupt registers */
-#define PCI_MSI_FLAGS 2 /* Message Control */
+#define PCI_MSI_FLAGS 0x02 /* Message Control */
#define PCI_MSI_FLAGS_ENABLE 0x0001 /* MSI feature enabled */
#define PCI_MSI_FLAGS_QMASK 0x000e /* Maximum queue size available */
#define PCI_MSI_FLAGS_QSIZE 0x0070 /* Message queue size configured */
#define PCI_MSI_FLAGS_64BIT 0x0080 /* 64-bit addresses allowed */
#define PCI_MSI_FLAGS_MASKBIT 0x0100 /* Per-vector masking capable */
#define PCI_MSI_RFU 3 /* Rest of capability flags */
-#define PCI_MSI_ADDRESS_LO 4 /* Lower 32 bits */
-#define PCI_MSI_ADDRESS_HI 8 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
-#define PCI_MSI_DATA_32 8 /* 16 bits of data for 32-bit devices */
-#define PCI_MSI_MASK_32 12 /* Mask bits register for 32-bit devices */
-#define PCI_MSI_PENDING_32 16 /* Pending intrs for 32-bit devices */
-#define PCI_MSI_DATA_64 12 /* 16 bits of data for 64-bit devices */
-#define PCI_MSI_MASK_64 16 /* Mask bits register for 64-bit devices */
-#define PCI_MSI_PENDING_64 20 /* Pending intrs for 64-bit devices */
+#define PCI_MSI_ADDRESS_LO 0x04 /* Lower 32 bits */
+#define PCI_MSI_ADDRESS_HI 0x08 /* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */
+#define PCI_MSI_DATA_32 0x08 /* 16 bits of data for 32-bit devices */
+#define PCI_MSI_MASK_32 0x0c /* Mask bits register for 32-bit devices */
+#define PCI_MSI_PENDING_32 0x10 /* Pending intrs for 32-bit devices */
+#define PCI_MSI_DATA_64 0x0c /* 16 bits of data for 64-bit devices */
+#define PCI_MSI_MASK_64 0x10 /* Mask bits register for 64-bit devices */
+#define PCI_MSI_PENDING_64 0x14 /* Pending intrs for 64-bit devices */
/* MSI-X registers (in MSI-X capability) */
#define PCI_MSIX_FLAGS 2 /* Message Control */
@@ -335,10 +335,10 @@
/* MSI-X Table entry format (in memory mapped by a BAR) */
#define PCI_MSIX_ENTRY_SIZE 16
-#define PCI_MSIX_ENTRY_LOWER_ADDR 0 /* Message Address */
-#define PCI_MSIX_ENTRY_UPPER_ADDR 4 /* Message Upper Address */
-#define PCI_MSIX_ENTRY_DATA 8 /* Message Data */
-#define PCI_MSIX_ENTRY_VECTOR_CTRL 12 /* Vector Control */
+#define PCI_MSIX_ENTRY_LOWER_ADDR 0x0 /* Message Address */
+#define PCI_MSIX_ENTRY_UPPER_ADDR 0x4 /* Message Upper Address */
+#define PCI_MSIX_ENTRY_DATA 0x8 /* Message Data */
+#define PCI_MSIX_ENTRY_VECTOR_CTRL 0xc /* Vector Control */
#define PCI_MSIX_ENTRY_CTRL_MASKBIT 0x00000001
/* CompactPCI Hotswap Register */
@@ -470,7 +470,7 @@
/* PCI Express capability registers */
-#define PCI_EXP_FLAGS 2 /* Capabilities register */
+#define PCI_EXP_FLAGS 0x02 /* Capabilities register */
#define PCI_EXP_FLAGS_VERS 0x000f /* Capability version */
#define PCI_EXP_FLAGS_TYPE 0x00f0 /* Device/Port type */
#define PCI_EXP_TYPE_ENDPOINT 0x0 /* Express Endpoint */
@@ -484,7 +484,7 @@
#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */
#define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */
#define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */
-#define PCI_EXP_DEVCAP 4 /* Device capabilities */
+#define PCI_EXP_DEVCAP 0x04 /* Device capabilities */
#define PCI_EXP_DEVCAP_PAYLOAD 0x00000007 /* Max_Payload_Size */
#define PCI_EXP_DEVCAP_PHANTOM 0x00000018 /* Phantom functions */
#define PCI_EXP_DEVCAP_EXT_TAG 0x00000020 /* Extended tags */
@@ -497,7 +497,7 @@
#define PCI_EXP_DEVCAP_PWR_VAL 0x03fc0000 /* Slot Power Limit Value */
#define PCI_EXP_DEVCAP_PWR_SCL 0x0c000000 /* Slot Power Limit Scale */
#define PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
-#define PCI_EXP_DEVCTL 8 /* Device Control */
+#define PCI_EXP_DEVCTL 0x08 /* Device Control */
#define PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
#define PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
#define PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
@@ -522,7 +522,7 @@
#define PCI_EXP_DEVCTL_READRQ_2048B 0x4000 /* 2048 Bytes */
#define PCI_EXP_DEVCTL_READRQ_4096B 0x5000 /* 4096 Bytes */
#define PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
-#define PCI_EXP_DEVSTA 10 /* Device Status */
+#define PCI_EXP_DEVSTA 0x0a /* Device Status */
#define PCI_EXP_DEVSTA_CED 0x0001 /* Correctable Error Detected */
#define PCI_EXP_DEVSTA_NFED 0x0002 /* Non-Fatal Error Detected */
#define PCI_EXP_DEVSTA_FED 0x0004 /* Fatal Error Detected */
@@ -530,7 +530,7 @@
#define PCI_EXP_DEVSTA_AUXPD 0x0010 /* AUX Power Detected */
#define PCI_EXP_DEVSTA_TRPND 0x0020 /* Transactions Pending */
#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V1 12 /* v1 endpoints without link end here */
-#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
+#define PCI_EXP_LNKCAP 0x0c /* Link Capabilities */
#define PCI_EXP_LNKCAP_SLS 0x0000000f /* Supported Link Speeds */
#define PCI_EXP_LNKCAP_SLS_2_5GB 0x00000001 /* LNKCAP2 SLS Vector bit 0 */
#define PCI_EXP_LNKCAP_SLS_5_0GB 0x00000002 /* LNKCAP2 SLS Vector bit 1 */
@@ -549,7 +549,7 @@
#define PCI_EXP_LNKCAP_DLLLARC 0x00100000 /* Data Link Layer Link Active Reporting Capable */
#define PCI_EXP_LNKCAP_LBNC 0x00200000 /* Link Bandwidth Notification Capability */
#define PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
-#define PCI_EXP_LNKCTL 16 /* Link Control */
+#define PCI_EXP_LNKCTL 0x10 /* Link Control */
#define PCI_EXP_LNKCTL_ASPMC 0x0003 /* ASPM Control */
#define PCI_EXP_LNKCTL_ASPM_L0S 0x0001 /* L0s Enable */
#define PCI_EXP_LNKCTL_ASPM_L1 0x0002 /* L1 Enable */
@@ -562,7 +562,7 @@
#define PCI_EXP_LNKCTL_HAWD 0x0200 /* Hardware Autonomous Width Disable */
#define PCI_EXP_LNKCTL_LBMIE 0x0400 /* Link Bandwidth Management Interrupt Enable */
#define PCI_EXP_LNKCTL_LABIE 0x0800 /* Link Autonomous Bandwidth Interrupt Enable */
-#define PCI_EXP_LNKSTA 18 /* Link Status */
+#define PCI_EXP_LNKSTA 0x12 /* Link Status */
#define PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */
#define PCI_EXP_LNKSTA_CLS_2_5GB 0x0001 /* Current Link Speed 2.5GT/s */
#define PCI_EXP_LNKSTA_CLS_5_0GB 0x0002 /* Current Link Speed 5.0GT/s */
@@ -582,7 +582,7 @@
#define PCI_EXP_LNKSTA_LBMS 0x4000 /* Link Bandwidth Management Status */
#define PCI_EXP_LNKSTA_LABS 0x8000 /* Link Autonomous Bandwidth Status */
#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V1 20 /* v1 endpoints with link end here */
-#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
+#define PCI_EXP_SLTCAP 0x14 /* Slot Capabilities */
#define PCI_EXP_SLTCAP_ABP 0x00000001 /* Attention Button Present */
#define PCI_EXP_SLTCAP_PCP 0x00000002 /* Power Controller Present */
#define PCI_EXP_SLTCAP_MRLSP 0x00000004 /* MRL Sensor Present */
@@ -595,7 +595,7 @@
#define PCI_EXP_SLTCAP_EIP 0x00020000 /* Electromechanical Interlock Present */
#define PCI_EXP_SLTCAP_NCCS 0x00040000 /* No Command Completed Support */
#define PCI_EXP_SLTCAP_PSN 0xfff80000 /* Physical Slot Number */
-#define PCI_EXP_SLTCTL 24 /* Slot Control */
+#define PCI_EXP_SLTCTL 0x18 /* Slot Control */
#define PCI_EXP_SLTCTL_ABPE 0x0001 /* Attention Button Pressed Enable */
#define PCI_EXP_SLTCTL_PFDE 0x0002 /* Power Fault Detected Enable */
#define PCI_EXP_SLTCTL_MRLSCE 0x0004 /* MRL Sensor Changed Enable */
@@ -616,8 +616,9 @@
#define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */
#define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control */
#define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Enable */
+#define PCI_EXP_SLTCTL_ASPL_DISABLE 0x2000 /* Auto Slot Power Limit Disable */
#define PCI_EXP_SLTCTL_IBPD_DISABLE 0x4000 /* In-band PD disable */
-#define PCI_EXP_SLTSTA 26 /* Slot Status */
+#define PCI_EXP_SLTSTA 0x1a /* Slot Status */
#define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */
#define PCI_EXP_SLTSTA_PFD 0x0002 /* Power Fault Detected */
#define PCI_EXP_SLTSTA_MRLSC 0x0004 /* MRL Sensor Changed */
@@ -627,15 +628,15 @@
#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */
#define PCI_EXP_SLTSTA_EIS 0x0080 /* Electromechanical Interlock Status */
#define PCI_EXP_SLTSTA_DLLSC 0x0100 /* Data Link Layer State Changed */
-#define PCI_EXP_RTCTL 28 /* Root Control */
+#define PCI_EXP_RTCTL 0x1c /* Root Control */
#define PCI_EXP_RTCTL_SECEE 0x0001 /* System Error on Correctable Error */
#define PCI_EXP_RTCTL_SENFEE 0x0002 /* System Error on Non-Fatal Error */
#define PCI_EXP_RTCTL_SEFEE 0x0004 /* System Error on Fatal Error */
#define PCI_EXP_RTCTL_PMEIE 0x0008 /* PME Interrupt Enable */
#define PCI_EXP_RTCTL_CRSSVE 0x0010 /* CRS Software Visibility Enable */
-#define PCI_EXP_RTCAP 30 /* Root Capabilities */
+#define PCI_EXP_RTCAP 0x1e /* Root Capabilities */
#define PCI_EXP_RTCAP_CRSVIS 0x0001 /* CRS Software Visibility capability */
-#define PCI_EXP_RTSTA 32 /* Root Status */
+#define PCI_EXP_RTSTA 0x20 /* Root Status */
#define PCI_EXP_RTSTA_PME 0x00010000 /* PME status */
#define PCI_EXP_RTSTA_PENDING 0x00020000 /* PME pending */
/*
@@ -646,7 +647,7 @@
* Use pcie_capability_read_word() and similar interfaces to use them
* safely.
*/
-#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
+#define PCI_EXP_DEVCAP2 0x24 /* Device Capabilities 2 */
#define PCI_EXP_DEVCAP2_COMP_TMOUT_DIS 0x00000010 /* Completion Timeout Disable supported */
#define PCI_EXP_DEVCAP2_ARI 0x00000020 /* Alternative Routing-ID */
#define PCI_EXP_DEVCAP2_ATOMIC_ROUTE 0x00000040 /* Atomic Op routing */
@@ -658,7 +659,7 @@
#define PCI_EXP_DEVCAP2_OBFF_MSG 0x00040000 /* New message signaling */
#define PCI_EXP_DEVCAP2_OBFF_WAKE 0x00080000 /* Re-use WAKE# for OBFF */
#define PCI_EXP_DEVCAP2_EE_PREFIX 0x00200000 /* End-End TLP Prefix */
-#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
+#define PCI_EXP_DEVCTL2 0x28 /* Device Control 2 */
#define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */
#define PCI_EXP_DEVCTL2_COMP_TMOUT_DIS 0x0010 /* Completion Timeout Disable */
#define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */
@@ -670,9 +671,9 @@
#define PCI_EXP_DEVCTL2_OBFF_MSGA_EN 0x2000 /* Enable OBFF Message type A */
#define PCI_EXP_DEVCTL2_OBFF_MSGB_EN 0x4000 /* Enable OBFF Message type B */
#define PCI_EXP_DEVCTL2_OBFF_WAKE_EN 0x6000 /* OBFF using WAKE# signaling */
-#define PCI_EXP_DEVSTA2 42 /* Device Status 2 */
-#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2 44 /* v2 endpoints without link end here */
-#define PCI_EXP_LNKCAP2 44 /* Link Capabilities 2 */
+#define PCI_EXP_DEVSTA2 0x2a /* Device Status 2 */
+#define PCI_CAP_EXP_RC_ENDPOINT_SIZEOF_V2 0x2c /* end of v2 EPs w/o link */
+#define PCI_EXP_LNKCAP2 0x2c /* Link Capabilities 2 */
#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x00000002 /* Supported Speed 2.5GT/s */
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x00000004 /* Supported Speed 5GT/s */
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x00000008 /* Supported Speed 8GT/s */
@@ -680,7 +681,7 @@
#define PCI_EXP_LNKCAP2_SLS_32_0GB 0x00000020 /* Supported Speed 32GT/s */
#define PCI_EXP_LNKCAP2_SLS_64_0GB 0x00000040 /* Supported Speed 64GT/s */
#define PCI_EXP_LNKCAP2_CROSSLINK 0x00000100 /* Crosslink supported */
-#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
+#define PCI_EXP_LNKCTL2 0x30 /* Link Control 2 */
#define PCI_EXP_LNKCTL2_TLS 0x000f
#define PCI_EXP_LNKCTL2_TLS_2_5GT 0x0001 /* Supported Speed 2.5GT/s */
#define PCI_EXP_LNKCTL2_TLS_5_0GT 0x0002 /* Supported Speed 5GT/s */
@@ -691,12 +692,13 @@
#define PCI_EXP_LNKCTL2_ENTER_COMP 0x0010 /* Enter Compliance */
#define PCI_EXP_LNKCTL2_TX_MARGIN 0x0380 /* Transmit Margin */
#define PCI_EXP_LNKCTL2_HASD 0x0020 /* HW Autonomous Speed Disable */
-#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */
-#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 52 /* v2 endpoints with link end here */
-#define PCI_EXP_SLTCAP2 52 /* Slot Capabilities 2 */
+#define PCI_EXP_LNKSTA2 0x32 /* Link Status 2 */
+#define PCI_EXP_LNKSTA2_FLIT 0x0400 /* Flit Mode Status */
+#define PCI_CAP_EXP_ENDPOINT_SIZEOF_V2 0x32 /* end of v2 EPs w/ link */
+#define PCI_EXP_SLTCAP2 0x34 /* Slot Capabilities 2 */
#define PCI_EXP_SLTCAP2_IBPD 0x00000001 /* In-band PD Disable Supported */
-#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
-#define PCI_EXP_SLTSTA2 58 /* Slot Status 2 */
+#define PCI_EXP_SLTCTL2 0x38 /* Slot Control 2 */
+#define PCI_EXP_SLTSTA2 0x3a /* Slot Status 2 */
/* Extended Capabilities (PCI-X 2.0 and Express) */
#define PCI_EXT_CAP_ID(header) (header & 0x0000ffff)
@@ -736,13 +738,14 @@
#define PCI_EXT_CAP_ID_DVSEC 0x23 /* Designated Vendor-Specific */
#define PCI_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */
#define PCI_EXT_CAP_ID_PL_16GT 0x26 /* Physical Layer 16.0 GT/s */
-#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_16GT
+#define PCI_EXT_CAP_ID_DOE 0x2E /* Data Object Exchange */
+#define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_DOE
#define PCI_EXT_CAP_DSN_SIZEOF 12
#define PCI_EXT_CAP_MCAST_ENDPOINT_SIZEOF 40
/* Advanced Error Reporting */
-#define PCI_ERR_UNCOR_STATUS 4 /* Uncorrectable Error Status */
+#define PCI_ERR_UNCOR_STATUS 0x04 /* Uncorrectable Error Status */
#define PCI_ERR_UNC_UND 0x00000001 /* Undefined */
#define PCI_ERR_UNC_DLP 0x00000010 /* Data Link Protocol */
#define PCI_ERR_UNC_SURPDN 0x00000020 /* Surprise Down */
@@ -760,11 +763,11 @@
#define PCI_ERR_UNC_MCBTLP 0x00800000 /* MC blocked TLP */
#define PCI_ERR_UNC_ATOMEG 0x01000000 /* Atomic egress blocked */
#define PCI_ERR_UNC_TLPPRE 0x02000000 /* TLP prefix blocked */
-#define PCI_ERR_UNCOR_MASK 8 /* Uncorrectable Error Mask */
+#define PCI_ERR_UNCOR_MASK 0x08 /* Uncorrectable Error Mask */
/* Same bits as above */
-#define PCI_ERR_UNCOR_SEVER 12 /* Uncorrectable Error Severity */
+#define PCI_ERR_UNCOR_SEVER 0x0c /* Uncorrectable Error Severity */
/* Same bits as above */
-#define PCI_ERR_COR_STATUS 16 /* Correctable Error Status */
+#define PCI_ERR_COR_STATUS 0x10 /* Correctable Error Status */
#define PCI_ERR_COR_RCVR 0x00000001 /* Receiver Error Status */
#define PCI_ERR_COR_BAD_TLP 0x00000040 /* Bad TLP Status */
#define PCI_ERR_COR_BAD_DLLP 0x00000080 /* Bad DLLP Status */
@@ -773,20 +776,20 @@
#define PCI_ERR_COR_ADV_NFAT 0x00002000 /* Advisory Non-Fatal */
#define PCI_ERR_COR_INTERNAL 0x00004000 /* Corrected Internal */
#define PCI_ERR_COR_LOG_OVER 0x00008000 /* Header Log Overflow */
-#define PCI_ERR_COR_MASK 20 /* Correctable Error Mask */
+#define PCI_ERR_COR_MASK 0x14 /* Correctable Error Mask */
/* Same bits as above */
-#define PCI_ERR_CAP 24 /* Advanced Error Capabilities */
-#define PCI_ERR_CAP_FEP(x) ((x) & 31) /* First Error Pointer */
+#define PCI_ERR_CAP 0x18 /* Advanced Error Capabilities & Ctrl*/
+#define PCI_ERR_CAP_FEP(x) ((x) & 0x1f) /* First Error Pointer */
#define PCI_ERR_CAP_ECRC_GENC 0x00000020 /* ECRC Generation Capable */
#define PCI_ERR_CAP_ECRC_GENE 0x00000040 /* ECRC Generation Enable */
#define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */
#define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */
-#define PCI_ERR_HEADER_LOG 28 /* Header Log Register (16 bytes) */
-#define PCI_ERR_ROOT_COMMAND 44 /* Root Error Command */
+#define PCI_ERR_HEADER_LOG 0x1c /* Header Log Register (16 bytes) */
+#define PCI_ERR_ROOT_COMMAND 0x2c /* Root Error Command */
#define PCI_ERR_ROOT_CMD_COR_EN 0x00000001 /* Correctable Err Reporting Enable */
#define PCI_ERR_ROOT_CMD_NONFATAL_EN 0x00000002 /* Non-Fatal Err Reporting Enable */
#define PCI_ERR_ROOT_CMD_FATAL_EN 0x00000004 /* Fatal Err Reporting Enable */
-#define PCI_ERR_ROOT_STATUS 48
+#define PCI_ERR_ROOT_STATUS 0x30
#define PCI_ERR_ROOT_COR_RCV 0x00000001 /* ERR_COR Received */
#define PCI_ERR_ROOT_MULTI_COR_RCV 0x00000002 /* Multiple ERR_COR */
#define PCI_ERR_ROOT_UNCOR_RCV 0x00000004 /* ERR_FATAL/NONFATAL */
@@ -795,52 +798,52 @@
#define PCI_ERR_ROOT_NONFATAL_RCV 0x00000020 /* Non-Fatal Received */
#define PCI_ERR_ROOT_FATAL_RCV 0x00000040 /* Fatal Received */
#define PCI_ERR_ROOT_AER_IRQ 0xf8000000 /* Advanced Error Interrupt Message Number */
-#define PCI_ERR_ROOT_ERR_SRC 52 /* Error Source Identification */
+#define PCI_ERR_ROOT_ERR_SRC 0x34 /* Error Source Identification */
/* Virtual Channel */
-#define PCI_VC_PORT_CAP1 4
+#define PCI_VC_PORT_CAP1 0x04
#define PCI_VC_CAP1_EVCC 0x00000007 /* extended VC count */
#define PCI_VC_CAP1_LPEVCC 0x00000070 /* low prio extended VC count */
#define PCI_VC_CAP1_ARB_SIZE 0x00000c00
-#define PCI_VC_PORT_CAP2 8
+#define PCI_VC_PORT_CAP2 0x08
#define PCI_VC_CAP2_32_PHASE 0x00000002
#define PCI_VC_CAP2_64_PHASE 0x00000004
#define PCI_VC_CAP2_128_PHASE 0x00000008
#define PCI_VC_CAP2_ARB_OFF 0xff000000
-#define PCI_VC_PORT_CTRL 12
+#define PCI_VC_PORT_CTRL 0x0c
#define PCI_VC_PORT_CTRL_LOAD_TABLE 0x00000001
-#define PCI_VC_PORT_STATUS 14
+#define PCI_VC_PORT_STATUS 0x0e
#define PCI_VC_PORT_STATUS_TABLE 0x00000001
-#define PCI_VC_RES_CAP 16
+#define PCI_VC_RES_CAP 0x10
#define PCI_VC_RES_CAP_32_PHASE 0x00000002
#define PCI_VC_RES_CAP_64_PHASE 0x00000004
#define PCI_VC_RES_CAP_128_PHASE 0x00000008
#define PCI_VC_RES_CAP_128_PHASE_TB 0x00000010
#define PCI_VC_RES_CAP_256_PHASE 0x00000020
#define PCI_VC_RES_CAP_ARB_OFF 0xff000000
-#define PCI_VC_RES_CTRL 20
+#define PCI_VC_RES_CTRL 0x14
#define PCI_VC_RES_CTRL_LOAD_TABLE 0x00010000
#define PCI_VC_RES_CTRL_ARB_SELECT 0x000e0000
#define PCI_VC_RES_CTRL_ID 0x07000000
#define PCI_VC_RES_CTRL_ENABLE 0x80000000
-#define PCI_VC_RES_STATUS 26
+#define PCI_VC_RES_STATUS 0x1a
#define PCI_VC_RES_STATUS_TABLE 0x00000001
#define PCI_VC_RES_STATUS_NEGO 0x00000002
#define PCI_CAP_VC_BASE_SIZEOF 0x10
-#define PCI_CAP_VC_PER_VC_SIZEOF 0x0C
+#define PCI_CAP_VC_PER_VC_SIZEOF 0x0c
/* Power Budgeting */
-#define PCI_PWR_DSR 4 /* Data Select Register */
-#define PCI_PWR_DATA 8 /* Data Register */
+#define PCI_PWR_DSR 0x04 /* Data Select Register */
+#define PCI_PWR_DATA 0x08 /* Data Register */
#define PCI_PWR_DATA_BASE(x) ((x) & 0xff) /* Base Power */
#define PCI_PWR_DATA_SCALE(x) (((x) >> 8) & 3) /* Data Scale */
#define PCI_PWR_DATA_PM_SUB(x) (((x) >> 10) & 7) /* PM Sub State */
#define PCI_PWR_DATA_PM_STATE(x) (((x) >> 13) & 3) /* PM State */
#define PCI_PWR_DATA_TYPE(x) (((x) >> 15) & 7) /* Type */
#define PCI_PWR_DATA_RAIL(x) (((x) >> 18) & 7) /* Power Rail */
-#define PCI_PWR_CAP 12 /* Capability */
+#define PCI_PWR_CAP 0x0c /* Capability */
#define PCI_PWR_CAP_BUDGET(x) ((x) & 1) /* Included in system budget */
-#define PCI_EXT_CAP_PWR_SIZEOF 16
+#define PCI_EXT_CAP_PWR_SIZEOF 0x10
/* Root Complex Event Collector Endpoint Association */
#define PCI_RCEC_RCIEP_BITMAP 4 /* Associated Bitmap for RCiEPs */
@@ -964,7 +967,7 @@
#define PCI_SRIOV_VFM_MI 0x1 /* Dormant.MigrateIn */
#define PCI_SRIOV_VFM_MO 0x2 /* Active.MigrateOut */
#define PCI_SRIOV_VFM_AV 0x3 /* Active.Available */
-#define PCI_EXT_CAP_SRIOV_SIZEOF 64
+#define PCI_EXT_CAP_SRIOV_SIZEOF 0x40
#define PCI_LTR_MAX_SNOOP_LAT 0x4
#define PCI_LTR_MAX_NOSNOOP_LAT 0x6
@@ -1017,12 +1020,12 @@
#define PCI_TPH_LOC_NONE 0x000 /* no location */
#define PCI_TPH_LOC_CAP 0x200 /* in capability */
#define PCI_TPH_LOC_MSIX 0x400 /* in MSI-X */
-#define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* st table mask */
-#define PCI_TPH_CAP_ST_SHIFT 16 /* st table shift */
-#define PCI_TPH_BASE_SIZEOF 12 /* size with no st table */
+#define PCI_TPH_CAP_ST_MASK 0x07FF0000 /* ST table mask */
+#define PCI_TPH_CAP_ST_SHIFT 16 /* ST table shift */
+#define PCI_TPH_BASE_SIZEOF 0xc /* size with no ST table */
/* Downstream Port Containment */
-#define PCI_EXP_DPC_CAP 4 /* DPC Capability */
+#define PCI_EXP_DPC_CAP 0x04 /* DPC Capability */
#define PCI_EXP_DPC_IRQ 0x001F /* Interrupt Message Number */
#define PCI_EXP_DPC_CAP_RP_EXT 0x0020 /* Root Port Extensions */
#define PCI_EXP_DPC_CAP_POISONED_TLP 0x0040 /* Poisoned TLP Egress Blocking Supported */
@@ -1030,19 +1033,19 @@
#define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0x0F00 /* RP PIO Log Size */
#define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000 /* ERR_COR signal on DL_Active supported */
-#define PCI_EXP_DPC_CTL 6 /* DPC control */
+#define PCI_EXP_DPC_CTL 0x06 /* DPC control */
#define PCI_EXP_DPC_CTL_EN_FATAL 0x0001 /* Enable trigger on ERR_FATAL message */
#define PCI_EXP_DPC_CTL_EN_NONFATAL 0x0002 /* Enable trigger on ERR_NONFATAL message */
#define PCI_EXP_DPC_CTL_INT_EN 0x0008 /* DPC Interrupt Enable */
-#define PCI_EXP_DPC_STATUS 8 /* DPC Status */
+#define PCI_EXP_DPC_STATUS 0x08 /* DPC Status */
#define PCI_EXP_DPC_STATUS_TRIGGER 0x0001 /* Trigger Status */
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN 0x0006 /* Trigger Reason */
#define PCI_EXP_DPC_STATUS_INTERRUPT 0x0008 /* Interrupt Status */
#define PCI_EXP_DPC_RP_BUSY 0x0010 /* Root Port Busy */
#define PCI_EXP_DPC_STATUS_TRIGGER_RSN_EXT 0x0060 /* Trig Reason Extension */
-#define PCI_EXP_DPC_SOURCE_ID 10 /* DPC Source Identifier */
+#define PCI_EXP_DPC_SOURCE_ID 0x0A /* DPC Source Identifier */
#define PCI_EXP_DPC_RP_PIO_STATUS 0x0C /* RP PIO Status */
#define PCI_EXP_DPC_RP_PIO_MASK 0x10 /* RP PIO Mask */
@@ -1056,6 +1059,7 @@
/* Precision Time Measurement */
#define PCI_PTM_CAP 0x04 /* PTM Capability */
#define PCI_PTM_CAP_REQ 0x00000001 /* Requester capable */
+#define PCI_PTM_CAP_RES 0x00000002 /* Responder capable */
#define PCI_PTM_CAP_ROOT 0x00000004 /* Root capable */
#define PCI_PTM_GRANULARITY_MASK 0x0000FF00 /* Clock granularity */
#define PCI_PTM_CTRL 0x08 /* PTM Control */
@@ -1086,7 +1090,11 @@
/* Designated Vendor-Specific (DVSEC, PCI_EXT_CAP_ID_DVSEC) */
#define PCI_DVSEC_HEADER1 0x4 /* Designated Vendor-Specific Header1 */
+#define PCI_DVSEC_HEADER1_VID(x) ((x) & 0xffff)
+#define PCI_DVSEC_HEADER1_REV(x) (((x) >> 16) & 0xf)
+#define PCI_DVSEC_HEADER1_LEN(x) (((x) >> 20) & 0xfff)
#define PCI_DVSEC_HEADER2 0x8 /* Designated Vendor-Specific Header2 */
+#define PCI_DVSEC_HEADER2_ID(x) ((x) & 0xffff)
/* Data Link Feature */
#define PCI_DLF_CAP 0x04 /* Capabilities Register */
@@ -1098,4 +1106,31 @@
#define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_MASK 0x000000F0
#define PCI_PL_16GT_LE_CTRL_USP_TX_PRESET_SHIFT 4
+/* Data Object Exchange */
+#define PCI_DOE_CAP 0x04 /* DOE Capabilities Register */
+#define PCI_DOE_CAP_INT_SUP 0x00000001 /* Interrupt Support */
+#define PCI_DOE_CAP_INT_MSG_NUM 0x00000ffe /* Interrupt Message Number */
+#define PCI_DOE_CTRL 0x08 /* DOE Control Register */
+#define PCI_DOE_CTRL_ABORT 0x00000001 /* DOE Abort */
+#define PCI_DOE_CTRL_INT_EN 0x00000002 /* DOE Interrupt Enable */
+#define PCI_DOE_CTRL_GO 0x80000000 /* DOE Go */
+#define PCI_DOE_STATUS 0x0c /* DOE Status Register */
+#define PCI_DOE_STATUS_BUSY 0x00000001 /* DOE Busy */
+#define PCI_DOE_STATUS_INT_STATUS 0x00000002 /* DOE Interrupt Status */
+#define PCI_DOE_STATUS_ERROR 0x00000004 /* DOE Error */
+#define PCI_DOE_STATUS_DATA_OBJECT_READY 0x80000000 /* Data Object Ready */
+#define PCI_DOE_WRITE 0x10 /* DOE Write Data Mailbox Register */
+#define PCI_DOE_READ 0x14 /* DOE Read Data Mailbox Register */
+#define PCI_DOE_CAP_SIZEOF 0x18 /* Size of DOE register block */
+
+/* DOE Data Object - note not actually registers */
+#define PCI_DOE_DATA_OBJECT_HEADER_1_VID 0x0000ffff
+#define PCI_DOE_DATA_OBJECT_HEADER_1_TYPE 0x00ff0000
+#define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff
+
+#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff
+#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff
+#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000
+#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000
+
#endif /* LINUX_PCI_REGS_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/perf_event.h b/lib/libc/include/any-linux-any/linux/perf_event.h
index 5243134458..7a5a0f1cd5 100644
--- a/lib/libc/include/any-linux-any/linux/perf_event.h
+++ b/lib/libc/include/any-linux-any/linux/perf_event.h
@@ -164,8 +164,6 @@ enum perf_event_sample_format {
PERF_SAMPLE_WEIGHT_STRUCT = 1U << 24,
PERF_SAMPLE_MAX = 1U << 25, /* non-ABI */
-
- __PERF_SAMPLE_CALLCHAIN_EARLY = 1ULL << 63, /* non-ABI; internal use */
};
#define PERF_SAMPLE_WEIGHT_TYPE (PERF_SAMPLE_WEIGHT | PERF_SAMPLE_WEIGHT_STRUCT)
@@ -204,6 +202,8 @@ enum perf_branch_sample_type_shift {
PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 17, /* save low level index of raw branch records */
+ PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT = 18, /* save privilege mode */
+
PERF_SAMPLE_BRANCH_MAX_SHIFT /* non-ABI */
};
@@ -233,6 +233,8 @@ enum perf_branch_sample_type {
PERF_SAMPLE_BRANCH_HW_INDEX = 1U << PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT,
+ PERF_SAMPLE_BRANCH_PRIV_SAVE = 1U << PERF_SAMPLE_BRANCH_PRIV_SAVE_SHIFT,
+
PERF_SAMPLE_BRANCH_MAX = 1U << PERF_SAMPLE_BRANCH_MAX_SHIFT,
};
@@ -251,9 +253,50 @@ enum {
PERF_BR_SYSRET = 8, /* syscall return */
PERF_BR_COND_CALL = 9, /* conditional function call */
PERF_BR_COND_RET = 10, /* conditional function return */
+ PERF_BR_ERET = 11, /* exception return */
+ PERF_BR_IRQ = 12, /* irq */
+ PERF_BR_SERROR = 13, /* system error */
+ PERF_BR_NO_TX = 14, /* not in transaction */
+ PERF_BR_EXTEND_ABI = 15, /* extend ABI */
PERF_BR_MAX,
};
+/*
+ * Common branch speculation outcome classification
+ */
+enum {
+ PERF_BR_SPEC_NA = 0, /* Not available */
+ PERF_BR_SPEC_WRONG_PATH = 1, /* Speculative but on wrong path */
+ PERF_BR_NON_SPEC_CORRECT_PATH = 2, /* Non-speculative but on correct path */
+ PERF_BR_SPEC_CORRECT_PATH = 3, /* Speculative and on correct path */
+ PERF_BR_SPEC_MAX,
+};
+
+enum {
+ PERF_BR_NEW_FAULT_ALGN = 0, /* Alignment fault */
+ PERF_BR_NEW_FAULT_DATA = 1, /* Data fault */
+ PERF_BR_NEW_FAULT_INST = 2, /* Inst fault */
+ PERF_BR_NEW_ARCH_1 = 3, /* Architecture specific */
+ PERF_BR_NEW_ARCH_2 = 4, /* Architecture specific */
+ PERF_BR_NEW_ARCH_3 = 5, /* Architecture specific */
+ PERF_BR_NEW_ARCH_4 = 6, /* Architecture specific */
+ PERF_BR_NEW_ARCH_5 = 7, /* Architecture specific */
+ PERF_BR_NEW_MAX,
+};
+
+enum {
+ PERF_BR_PRIV_UNKNOWN = 0,
+ PERF_BR_PRIV_USER = 1,
+ PERF_BR_PRIV_KERNEL = 2,
+ PERF_BR_PRIV_HV = 3,
+};
+
+#define PERF_BR_ARM64_FIQ PERF_BR_NEW_ARCH_1
+#define PERF_BR_ARM64_DEBUG_HALT PERF_BR_NEW_ARCH_2
+#define PERF_BR_ARM64_DEBUG_EXIT PERF_BR_NEW_ARCH_3
+#define PERF_BR_ARM64_DEBUG_INST PERF_BR_NEW_ARCH_4
+#define PERF_BR_ARM64_DEBUG_DATA PERF_BR_NEW_ARCH_5
+
#define PERF_SAMPLE_BRANCH_PLM_ALL \
(PERF_SAMPLE_BRANCH_USER|\
PERF_SAMPLE_BRANCH_KERNEL|\
@@ -299,6 +342,7 @@ enum {
* { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED
* { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
* { u64 id; } && PERF_FORMAT_ID
+ * { u64 lost; } && PERF_FORMAT_LOST
* } && !PERF_FORMAT_GROUP
*
* { u64 nr;
@@ -306,6 +350,7 @@ enum {
* { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING
* { u64 value;
* { u64 id; } && PERF_FORMAT_ID
+ * { u64 lost; } && PERF_FORMAT_LOST
* } cntr[nr];
* } && PERF_FORMAT_GROUP
* };
@@ -315,8 +360,9 @@ enum perf_event_read_format {
PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
PERF_FORMAT_ID = 1U << 2,
PERF_FORMAT_GROUP = 1U << 3,
+ PERF_FORMAT_LOST = 1U << 4,
- PERF_FORMAT_MAX = 1U << 4, /* non-ABI */
+ PERF_FORMAT_MAX = 1U << 5, /* non-ABI */
};
#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
@@ -328,6 +374,7 @@ enum perf_event_read_format {
#define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
#define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */
+#define PERF_ATTR_SIZE_VER8 136 /* add: config3 */
/*
* Hardware event_id to monitor via a performance monitoring event:
@@ -465,8 +512,12 @@ struct perf_event_attr {
/*
* User provided data if sigtrap=1, passed back to user via
* siginfo_t::si_perf_data, e.g. to permit user to identify the event.
+ * Note, siginfo_t::si_perf_data is long-sized, and sig_data will be
+ * truncated accordingly on 32 bit architectures.
*/
__u64 sig_data;
+
+ __u64 config3; /* extension of config2 */
};
/*
@@ -487,7 +538,7 @@ struct perf_event_query_bpf {
/*
* User provided buffer to store program ids
*/
- __u32 ids[0];
+ __u32 ids[];
};
/*
@@ -1288,7 +1339,9 @@ union perf_mem_data_src {
#define PERF_MEM_LVLNUM_L2 0x02 /* L2 */
#define PERF_MEM_LVLNUM_L3 0x03 /* L3 */
#define PERF_MEM_LVLNUM_L4 0x04 /* L4 */
-/* 5-0xa available */
+/* 5-0x8 available */
+#define PERF_MEM_LVLNUM_CXL 0x09 /* CXL */
+#define PERF_MEM_LVLNUM_IO 0x0a /* I/O */
#define PERF_MEM_LVLNUM_ANY_CACHE 0x0b /* Any cache */
#define PERF_MEM_LVLNUM_LFB 0x0c /* LFB */
#define PERF_MEM_LVLNUM_RAM 0x0d /* RAM */
@@ -1306,7 +1359,7 @@ union perf_mem_data_src {
#define PERF_MEM_SNOOP_SHIFT 19
#define PERF_MEM_SNOOPX_FWD 0x01 /* forward */
-/* 1 free */
+#define PERF_MEM_SNOOPX_PEER 0x02 /* xfer from peer */
#define PERF_MEM_SNOOPX_SHIFT 38
/* locked instruction */
@@ -1332,7 +1385,10 @@ union perf_mem_data_src {
/* hop level */
#define PERF_MEM_HOPS_0 0x01 /* remote core, same node */
-/* 2-7 available */
+#define PERF_MEM_HOPS_1 0x02 /* remote node, same socket */
+#define PERF_MEM_HOPS_2 0x03 /* remote socket, same board */
+#define PERF_MEM_HOPS_3 0x04 /* remote board */
+/* 5-7 available */
#define PERF_MEM_HOPS_SHIFT 43
#define PERF_MEM_S(a, s) \
@@ -1353,6 +1409,7 @@ union perf_mem_data_src {
* abort: aborting a hardware transaction
* cycles: cycles from last branch (or 0 if not supported)
* type: branch type
+ * spec: branch speculation info (or 0 if not supported)
*/
struct perf_branch_entry {
__u64 from;
@@ -1363,7 +1420,10 @@ struct perf_branch_entry {
abort:1, /* transaction abort */
cycles:16, /* cycle count to last branch */
type:4, /* branch type */
- reserved:40;
+ spec:2, /* branch speculation info */
+ new_type:4, /* additional branch type */
+ priv:3, /* privilege level */
+ reserved:31;
};
union perf_sample_weight {
diff --git a/lib/libc/include/any-linux-any/linux/pfkeyv2.h b/lib/libc/include/any-linux-any/linux/pfkeyv2.h
index 102b2e1ccc..b55dd6a513 100644
--- a/lib/libc/include/any-linux-any/linux/pfkeyv2.h
+++ b/lib/libc/include/any-linux-any/linux/pfkeyv2.h
@@ -309,6 +309,7 @@ struct sadb_x_filter {
#define SADB_X_AALG_SHA2_512HMAC 7
#define SADB_X_AALG_RIPEMD160HMAC 8
#define SADB_X_AALG_AES_XCBC_MAC 9
+#define SADB_X_AALG_SM3_256HMAC 10
#define SADB_X_AALG_NULL 251 /* kame */
#define SADB_AALG_MAX 251
@@ -329,6 +330,7 @@ struct sadb_x_filter {
#define SADB_X_EALG_AES_GCM_ICV16 20
#define SADB_X_EALG_CAMELLIACBC 22
#define SADB_X_EALG_NULL_AES_GMAC 23
+#define SADB_X_EALG_SM4CBC 24
#define SADB_EALG_MAX 253 /* last EALG */
/* private allocations should use 249-255 (RFC2407) */
#define SADB_X_EALG_SERPENTCBC 252 /* draft-ietf-ipsec-ciph-aes-cbc-00 */
diff --git a/lib/libc/include/any-linux-any/linux/pfrut.h b/lib/libc/include/any-linux-any/linux/pfrut.h
new file mode 100644
index 0000000000..8c97b1c063
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/pfrut.h
@@ -0,0 +1,262 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Platform Firmware Runtime Update header
+ *
+ * Copyright(c) 2021 Intel Corporation. All rights reserved.
+ */
+#ifndef __PFRUT_H__
+#define __PFRUT_H__
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+#define PFRUT_IOCTL_MAGIC 0xEE
+
+/**
+ * PFRU_IOC_SET_REV - _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
+ *
+ * Return:
+ * * 0 - success
+ * * -EFAULT - fail to read the revision id
+ * * -EINVAL - user provides an invalid revision id
+ *
+ * Set the Revision ID for Platform Firmware Runtime Update.
+ */
+#define PFRU_IOC_SET_REV _IOW(PFRUT_IOCTL_MAGIC, 0x01, unsigned int)
+
+/**
+ * PFRU_IOC_STAGE - _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - stage phase returns invalid result
+ *
+ * Stage a capsule image from communication buffer and perform authentication.
+ */
+#define PFRU_IOC_STAGE _IOW(PFRUT_IOCTL_MAGIC, 0x02, unsigned int)
+
+/**
+ * PFRU_IOC_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - activate phase returns invalid result
+ *
+ * Activate a previously staged capsule image.
+ */
+#define PFRU_IOC_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x03, unsigned int)
+
+/**
+ * PFRU_IOC_STAGE_ACTIVATE - _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - stage/activate phase returns invalid result.
+ *
+ * Perform both stage and activation action.
+ */
+#define PFRU_IOC_STAGE_ACTIVATE _IOW(PFRUT_IOCTL_MAGIC, 0x04, unsigned int)
+
+/**
+ * PFRU_IOC_QUERY_CAP - _IOR(PFRUT_IOCTL_MAGIC, 0x05,
+ * struct pfru_update_cap_info)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - query phase returns invalid result
+ * * -EFAULT - the result fails to be copied to userspace
+ *
+ * Retrieve information on the Platform Firmware Runtime Update capability.
+ * The information is a struct pfru_update_cap_info.
+ */
+#define PFRU_IOC_QUERY_CAP _IOR(PFRUT_IOCTL_MAGIC, 0x05, struct pfru_update_cap_info)
+
+/**
+ * struct pfru_payload_hdr - Capsule file payload header.
+ *
+ * @sig: Signature of this capsule file.
+ * @hdr_version: Revision of this header structure.
+ * @hdr_size: Size of this header, including the OemHeader bytes.
+ * @hw_ver: The supported firmware version.
+ * @rt_ver: Version of the code injection image.
+ * @platform_id: A platform specific GUID to specify the platform what
+ * this capsule image support.
+ */
+struct pfru_payload_hdr {
+ __u32 sig;
+ __u32 hdr_version;
+ __u32 hdr_size;
+ __u32 hw_ver;
+ __u32 rt_ver;
+ __u8 platform_id[16];
+};
+
+enum pfru_dsm_status {
+ DSM_SUCCEED = 0,
+ DSM_FUNC_NOT_SUPPORT = 1,
+ DSM_INVAL_INPUT = 2,
+ DSM_HARDWARE_ERR = 3,
+ DSM_RETRY_SUGGESTED = 4,
+ DSM_UNKNOWN = 5,
+ DSM_FUNC_SPEC_ERR = 6,
+};
+
+/**
+ * struct pfru_update_cap_info - Runtime update capability information.
+ *
+ * @status: Indicator of whether this query succeed.
+ * @update_cap: Bitmap to indicate whether the feature is supported.
+ * @code_type: A buffer containing an image type GUID.
+ * @fw_version: Platform firmware version.
+ * @code_rt_version: Code injection runtime version for anti-rollback.
+ * @drv_type: A buffer containing an image type GUID.
+ * @drv_rt_version: The version of the driver update runtime code.
+ * @drv_svn: The secure version number(SVN) of the driver update runtime code.
+ * @platform_id: A buffer containing a platform ID GUID.
+ * @oem_id: A buffer containing an OEM ID GUID.
+ * @oem_info_len: Length of the buffer containing the vendor specific information.
+ */
+struct pfru_update_cap_info {
+ __u32 status;
+ __u32 update_cap;
+
+ __u8 code_type[16];
+ __u32 fw_version;
+ __u32 code_rt_version;
+
+ __u8 drv_type[16];
+ __u32 drv_rt_version;
+ __u32 drv_svn;
+
+ __u8 platform_id[16];
+ __u8 oem_id[16];
+
+ __u32 oem_info_len;
+};
+
+/**
+ * struct pfru_com_buf_info - Communication buffer information.
+ *
+ * @status: Indicator of whether this query succeed.
+ * @ext_status: Implementation specific query result.
+ * @addr_lo: Low 32bit physical address of the communication buffer to hold
+ * a runtime update package.
+ * @addr_hi: High 32bit physical address of the communication buffer to hold
+ * a runtime update package.
+ * @buf_size: Maximum size in bytes of the communication buffer.
+ */
+struct pfru_com_buf_info {
+ __u32 status;
+ __u32 ext_status;
+ __u64 addr_lo;
+ __u64 addr_hi;
+ __u32 buf_size;
+};
+
+/**
+ * struct pfru_updated_result - Platform firmware runtime update result information.
+ * @status: Indicator of whether this update succeed.
+ * @ext_status: Implementation specific update result.
+ * @low_auth_time: Low 32bit value of image authentication time in nanosecond.
+ * @high_auth_time: High 32bit value of image authentication time in nanosecond.
+ * @low_exec_time: Low 32bit value of image execution time in nanosecond.
+ * @high_exec_time: High 32bit value of image execution time in nanosecond.
+ */
+struct pfru_updated_result {
+ __u32 status;
+ __u32 ext_status;
+ __u64 low_auth_time;
+ __u64 high_auth_time;
+ __u64 low_exec_time;
+ __u64 high_exec_time;
+};
+
+/**
+ * struct pfrt_log_data_info - Log Data from telemetry service.
+ * @status: Indicator of whether this update succeed.
+ * @ext_status: Implementation specific update result.
+ * @chunk1_addr_lo: Low 32bit physical address of the telemetry data chunk1
+ * starting address.
+ * @chunk1_addr_hi: High 32bit physical address of the telemetry data chunk1
+ * starting address.
+ * @chunk2_addr_lo: Low 32bit physical address of the telemetry data chunk2
+ * starting address.
+ * @chunk2_addr_hi: High 32bit physical address of the telemetry data chunk2
+ * starting address.
+ * @max_data_size: Maximum supported size of data of all data chunks combined.
+ * @chunk1_size: Data size in bytes of the telemetry data chunk1 buffer.
+ * @chunk2_size: Data size in bytes of the telemetry data chunk2 buffer.
+ * @rollover_cnt: Number of times telemetry data buffer is overwritten
+ * since telemetry buffer reset.
+ * @reset_cnt: Number of times telemetry services resets that results in
+ * rollover count and data chunk buffers are reset.
+ */
+struct pfrt_log_data_info {
+ __u32 status;
+ __u32 ext_status;
+ __u64 chunk1_addr_lo;
+ __u64 chunk1_addr_hi;
+ __u64 chunk2_addr_lo;
+ __u64 chunk2_addr_hi;
+ __u32 max_data_size;
+ __u32 chunk1_size;
+ __u32 chunk2_size;
+ __u32 rollover_cnt;
+ __u32 reset_cnt;
+};
+
+/**
+ * struct pfrt_log_info - Telemetry log information.
+ * @log_level: The telemetry log level.
+ * @log_type: The telemetry log type(history and execution).
+ * @log_revid: The telemetry log revision id.
+ */
+struct pfrt_log_info {
+ __u32 log_level;
+ __u32 log_type;
+ __u32 log_revid;
+};
+
+/**
+ * PFRT_LOG_IOC_SET_INFO - _IOW(PFRUT_IOCTL_MAGIC, 0x06,
+ * struct pfrt_log_info)
+ *
+ * Return:
+ * * 0 - success
+ * * -EFAULT - fail to get the setting parameter
+ * * -EINVAL - fail to set the log level
+ *
+ * Set the PFRT log level and log type. The input information is
+ * a struct pfrt_log_info.
+ */
+#define PFRT_LOG_IOC_SET_INFO _IOW(PFRUT_IOCTL_MAGIC, 0x06, struct pfrt_log_info)
+
+/**
+ * PFRT_LOG_IOC_GET_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x07,
+ * struct pfrt_log_info)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - fail to get the log level
+ * * -EFAULT - fail to copy the result back to userspace
+ *
+ * Retrieve log level and log type of the telemetry. The information is
+ * a struct pfrt_log_info.
+ */
+#define PFRT_LOG_IOC_GET_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x07, struct pfrt_log_info)
+
+/**
+ * PFRT_LOG_IOC_GET_DATA_INFO - _IOR(PFRUT_IOCTL_MAGIC, 0x08,
+ * struct pfrt_log_data_info)
+ *
+ * Return:
+ * * 0 - success
+ * * -EINVAL - fail to get the log buffer information
+ * * -EFAULT - fail to copy the log buffer information to userspace
+ *
+ * Retrieve data information about the telemetry. The information
+ * is a struct pfrt_log_data_info.
+ */
+#define PFRT_LOG_IOC_GET_DATA_INFO _IOR(PFRUT_IOCTL_MAGIC, 0x08, struct pfrt_log_data_info)
+
+#endif /* __PFRUT_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/pkt_cls.h b/lib/libc/include/any-linux-any/linux/pkt_cls.h
index 39c27f157b..7a785167d1 100644
--- a/lib/libc/include/any-linux-any/linux/pkt_cls.h
+++ b/lib/libc/include/any-linux-any/linux/pkt_cls.h
@@ -19,13 +19,16 @@ enum {
TCA_ACT_FLAGS,
TCA_ACT_HW_STATS,
TCA_ACT_USED_HW_STATS,
+ TCA_ACT_IN_HW_COUNT,
__TCA_ACT_MAX
};
/* See other TCA_ACT_FLAGS_ * flags in include/net/act_api.h. */
-#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for
- * actions stats.
- */
+#define TCA_ACT_FLAGS_NO_PERCPU_STATS (1 << 0) /* Don't use percpu allocator for
+ * actions stats.
+ */
+#define TCA_ACT_FLAGS_SKIP_HW (1 << 1) /* don't offload action to HW */
+#define TCA_ACT_FLAGS_SKIP_SW (1 << 2) /* don't use action in SW */
/* tca HW stats type
* When user does not pass the attribute, he does not care.
@@ -253,7 +256,7 @@ struct tc_u32_sel {
short hoff;
__be32 hmask;
- struct tc_u32_key keys[0];
+ struct tc_u32_key keys[];
};
struct tc_u32_mark {
@@ -265,7 +268,7 @@ struct tc_u32_mark {
struct tc_u32_pcnt {
__u64 rcnt;
__u64 rhit;
- __u64 kcnts[0];
+ __u64 kcnts[];
};
/* Flags */
@@ -584,6 +587,13 @@ enum {
TCA_FLOWER_KEY_HASH, /* u32 */
TCA_FLOWER_KEY_HASH_MASK, /* u32 */
+ TCA_FLOWER_KEY_NUM_OF_VLANS, /* u8 */
+
+ TCA_FLOWER_KEY_PPPOE_SID, /* be16 */
+ TCA_FLOWER_KEY_PPP_PROTO, /* be16 */
+
+ TCA_FLOWER_KEY_L2TPV3_SID, /* be32 */
+
__TCA_FLOWER_MAX,
};
@@ -613,6 +623,10 @@ enum {
* TCA_FLOWER_KEY_ENC_OPT_ERSPAN_
* attributes
*/
+ TCA_FLOWER_KEY_ENC_OPTS_GTP, /* Nested
+ * TCA_FLOWER_KEY_ENC_OPT_GTP_
+ * attributes
+ */
__TCA_FLOWER_KEY_ENC_OPTS_MAX,
};
@@ -652,6 +666,17 @@ enum {
(__TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX - 1)
enum {
+ TCA_FLOWER_KEY_ENC_OPT_GTP_UNSPEC,
+ TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE, /* u8 */
+ TCA_FLOWER_KEY_ENC_OPT_GTP_QFI, /* u8 */
+
+ __TCA_FLOWER_KEY_ENC_OPT_GTP_MAX,
+};
+
+#define TCA_FLOWER_KEY_ENC_OPT_GTP_MAX \
+ (__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX - 1)
+
+enum {
TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
TCA_FLOWER_KEY_MPLS_OPTS_LSE,
__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
diff --git a/lib/libc/include/any-linux-any/linux/pkt_sched.h b/lib/libc/include/any-linux-any/linux/pkt_sched.h
index 239ed65905..3e679d9743 100644
--- a/lib/libc/include/any-linux-any/linux/pkt_sched.h
+++ b/lib/libc/include/any-linux-any/linux/pkt_sched.h
@@ -1233,6 +1233,16 @@ enum {
#define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD _BITUL(1)
enum {
+ TCA_TAPRIO_TC_ENTRY_UNSPEC,
+ TCA_TAPRIO_TC_ENTRY_INDEX, /* u32 */
+ TCA_TAPRIO_TC_ENTRY_MAX_SDU, /* u32 */
+
+ /* add new constants above here */
+ __TCA_TAPRIO_TC_ENTRY_CNT,
+ TCA_TAPRIO_TC_ENTRY_MAX = (__TCA_TAPRIO_TC_ENTRY_CNT - 1)
+};
+
+enum {
TCA_TAPRIO_ATTR_UNSPEC,
TCA_TAPRIO_ATTR_PRIOMAP, /* struct tc_mqprio_qopt */
TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, /* nested of entry */
@@ -1245,6 +1255,7 @@ enum {
TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION, /* s64 */
TCA_TAPRIO_ATTR_FLAGS, /* u32 */
TCA_TAPRIO_ATTR_TXTIME_DELAY, /* u32 */
+ TCA_TAPRIO_ATTR_TC_ENTRY, /* nest */
__TCA_TAPRIO_ATTR_MAX,
};
diff --git a/lib/libc/include/any-linux-any/linux/pr.h b/lib/libc/include/any-linux-any/linux/pr.h
index db88b1f25a..c52481a33e 100644
--- a/lib/libc/include/any-linux-any/linux/pr.h
+++ b/lib/libc/include/any-linux-any/linux/pr.h
@@ -4,6 +4,23 @@
#include <linux/types.h>
+enum pr_status {
+ PR_STS_SUCCESS = 0x0,
+ /*
+ * The following error codes are based on SCSI, because the interface
+ * was originally created for it and has existing users.
+ */
+ /* Generic device failure. */
+ PR_STS_IOERR = 0x2,
+ PR_STS_RESERVATION_CONFLICT = 0x18,
+ /* Temporary path failure that can be retried. */
+ PR_STS_RETRY_PATH_FAILURE = 0xe0000,
+ /* The request was failed due to a fast failure timer. */
+ PR_STS_PATH_FAST_FAILED = 0xf0000,
+ /* The path cannot be reached and has been marked as failed. */
+ PR_STS_PATH_FAILED = 0x10000,
+};
+
enum pr_type {
PR_WRITE_EXCLUSIVE = 1,
PR_EXCLUSIVE_ACCESS = 2,
diff --git a/lib/libc/include/any-linux-any/linux/prctl.h b/lib/libc/include/any-linux-any/linux/prctl.h
index 77b045ef6c..636ee2ca4c 100644
--- a/lib/libc/include/any-linux-any/linux/prctl.h
+++ b/lib/libc/include/any-linux-any/linux/prctl.h
@@ -272,4 +272,22 @@ struct prctl_mm_map {
# define PR_SCHED_CORE_SCOPE_THREAD_GROUP 1
# define PR_SCHED_CORE_SCOPE_PROCESS_GROUP 2
+/* arm64 Scalable Matrix Extension controls */
+/* Flag values must be in sync with SVE versions */
+#define PR_SME_SET_VL 63 /* set task vector length */
+# define PR_SME_SET_VL_ONEXEC (1 << 18) /* defer effect until exec */
+#define PR_SME_GET_VL 64 /* get task vector length */
+/* Bits common to PR_SME_SET_VL and PR_SME_GET_VL */
+# define PR_SME_VL_LEN_MASK 0xffff
+# define PR_SME_VL_INHERIT (1 << 17) /* inherit across exec */
+
+/* Memory deny write / execute */
+#define PR_SET_MDWE 65
+# define PR_MDWE_REFUSE_EXEC_GAIN 1
+
+#define PR_GET_MDWE 66
+
+#define PR_SET_VMA 0x53564d41
+# define PR_SET_VMA_ANON_NAME 0
+
#endif /* _LINUX_PRCTL_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/psci.h b/lib/libc/include/any-linux-any/linux/psci.h
index e4933102cf..6c0040f7dd 100644
--- a/lib/libc/include/any-linux-any/linux/psci.h
+++ b/lib/libc/include/any-linux-any/linux/psci.h
@@ -48,12 +48,26 @@
#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU PSCI_0_2_FN64(7)
#define PSCI_1_0_FN_PSCI_FEATURES PSCI_0_2_FN(10)
+#define PSCI_1_0_FN_CPU_FREEZE PSCI_0_2_FN(11)
+#define PSCI_1_0_FN_CPU_DEFAULT_SUSPEND PSCI_0_2_FN(12)
+#define PSCI_1_0_FN_NODE_HW_STATE PSCI_0_2_FN(13)
#define PSCI_1_0_FN_SYSTEM_SUSPEND PSCI_0_2_FN(14)
#define PSCI_1_0_FN_SET_SUSPEND_MODE PSCI_0_2_FN(15)
+#define PSCI_1_0_FN_STAT_RESIDENCY PSCI_0_2_FN(16)
+#define PSCI_1_0_FN_STAT_COUNT PSCI_0_2_FN(17)
+
#define PSCI_1_1_FN_SYSTEM_RESET2 PSCI_0_2_FN(18)
+#define PSCI_1_1_FN_MEM_PROTECT PSCI_0_2_FN(19)
+#define PSCI_1_1_FN_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN(20)
+#define PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND PSCI_0_2_FN64(12)
+#define PSCI_1_0_FN64_NODE_HW_STATE PSCI_0_2_FN64(13)
#define PSCI_1_0_FN64_SYSTEM_SUSPEND PSCI_0_2_FN64(14)
+#define PSCI_1_0_FN64_STAT_RESIDENCY PSCI_0_2_FN64(16)
+#define PSCI_1_0_FN64_STAT_COUNT PSCI_0_2_FN64(17)
+
#define PSCI_1_1_FN64_SYSTEM_RESET2 PSCI_0_2_FN64(18)
+#define PSCI_1_1_FN64_MEM_PROTECT_CHECK_RANGE PSCI_0_2_FN64(20)
/* PSCI v0.2 power state encoding for CPU_SUSPEND function */
#define PSCI_0_2_POWER_STATE_ID_MASK 0xffff
@@ -82,6 +96,10 @@
#define PSCI_0_2_TOS_UP_NO_MIGRATE 1
#define PSCI_0_2_TOS_MP 2
+/* PSCI v1.1 reset type encoding for SYSTEM_RESET2 */
+#define PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET 0
+#define PSCI_1_1_RESET_TYPE_VENDOR_START 0x80000000U
+
/* PSCI version decoding (independent of PSCI version) */
#define PSCI_VERSION_MAJOR_SHIFT 16
#define PSCI_VERSION_MINOR_MASK \
diff --git a/lib/libc/include/any-linux-any/linux/ptrace.h b/lib/libc/include/any-linux-any/linux/ptrace.h
index aa9f369102..f3cb836d71 100644
--- a/lib/libc/include/any-linux-any/linux/ptrace.h
+++ b/lib/libc/include/any-linux-any/linux/ptrace.h
@@ -114,7 +114,7 @@ struct ptrace_rseq_configuration {
/*
* These values are stored in task->ptrace_message
- * by tracehook_report_syscall_* to describe the current syscall-stop.
+ * by ptrace_stop to describe the current syscall-stop.
*/
#define PTRACE_EVENTMSG_SYSCALL_ENTRY 1
#define PTRACE_EVENTMSG_SYSCALL_EXIT 2
diff --git a/lib/libc/include/any-linux-any/linux/raid/md_p.h b/lib/libc/include/any-linux-any/linux/raid/md_p.h
index 775f37f43a..53df9c9656 100644
--- a/lib/libc/include/any-linux-any/linux/raid/md_p.h
+++ b/lib/libc/include/any-linux-any/linux/raid/md_p.h
@@ -303,7 +303,7 @@ struct mdp_superblock_1 {
* into the 'roles' value. If a device is spare or faulty, then it doesn't
* have a meaningful role.
*/
- __le16 dev_roles[0]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
+ __le16 dev_roles[]; /* role in array, or 0xffff for a spare, or 0xfffe for faulty */
};
/* feature_map bits */
diff --git a/lib/libc/include/any-linux-any/linux/random.h b/lib/libc/include/any-linux-any/linux/random.h
index b0af6454e2..eaf8deac0b 100644
--- a/lib/libc/include/any-linux-any/linux/random.h
+++ b/lib/libc/include/any-linux-any/linux/random.h
@@ -41,7 +41,7 @@
struct rand_pool_info {
int entropy_count;
int buf_size;
- __u32 buf[0];
+ __u32 buf[];
};
/*
diff --git a/lib/libc/include/any-linux-any/linux/reiserfs_xattr.h b/lib/libc/include/any-linux-any/linux/reiserfs_xattr.h
index d1aeefe37c..a0c7aa714a 100644
--- a/lib/libc/include/any-linux-any/linux/reiserfs_xattr.h
+++ b/lib/libc/include/any-linux-any/linux/reiserfs_xattr.h
@@ -19,7 +19,7 @@ struct reiserfs_xattr_header {
struct reiserfs_security_handle {
const char *name;
void *value;
- size_t length;
+ __kernel_size_t length;
};
#endif /* _LINUX_REISERFS_XATTR_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/rfkill.h b/lib/libc/include/any-linux-any/linux/rfkill.h
index 0a5a1bc405..7ea68a4c18 100644
--- a/lib/libc/include/any-linux-any/linux/rfkill.h
+++ b/lib/libc/include/any-linux-any/linux/rfkill.h
@@ -159,8 +159,16 @@ struct rfkill_event_ext {
* old behaviour for all userspace, unless it explicitly opts in to the
* rules outlined here by using the new &struct rfkill_event_ext.
*
- * Userspace using &struct rfkill_event_ext must adhere to the following
- * rules
+ * Additionally, some other userspace (bluez, g-s-d) was reading with a
+ * large size but as streaming reads rather than message-based, or with
+ * too strict checks for the returned size. So eventually, we completely
+ * reverted this, and extended messages need to be opted in to by using
+ * an ioctl:
+ *
+ * ioctl(fd, RFKILL_IOCTL_MAX_SIZE, sizeof(struct rfkill_event_ext));
+ *
+ * Userspace using &struct rfkill_event_ext and the ioctl must adhere to
+ * the following rules:
*
* 1. accept short writes, optionally using them to detect that it's
* running on an older kernel;
@@ -175,6 +183,8 @@ struct rfkill_event_ext {
#define RFKILL_IOC_MAGIC 'R'
#define RFKILL_IOC_NOINPUT 1
#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT)
+#define RFKILL_IOC_MAX_SIZE 2
+#define RFKILL_IOCTL_MAX_SIZE _IOW(RFKILL_IOC_MAGIC, RFKILL_IOC_MAX_SIZE, __u32)
/* and that's all userspace gets */
diff --git a/lib/libc/include/any-linux-any/linux/rkisp1-config.h b/lib/libc/include/any-linux-any/linux/rkisp1-config.h
index 6f9239f59e..2e38008690 100644
--- a/lib/libc/include/any-linux-any/linux/rkisp1-config.h
+++ b/lib/libc/include/any-linux-any/linux/rkisp1-config.h
@@ -117,7 +117,46 @@
/*
* Defect Pixel Cluster Correction
*/
-#define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
+#define RKISP1_CIF_ISP_DPCC_METHODS_MAX 3
+
+#define RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE (1U << 2)
+
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_RB_CENTER (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_G_3X3 (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_RB_3X3 (1U << 3)
+
+/* 0-2 for sets 1-3 */
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_SET(n) ((n) << 0)
+#define RKISP1_CIF_ISP_DPCC_SET_USE_STAGE1_USE_FIX_SET (1U << 3)
+
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_GREEN_ENABLE (1U << 0)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_GREEN_ENABLE (1U << 1)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_GREEN_ENABLE (1U << 2)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_GREEN_ENABLE (1U << 3)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_GREEN_ENABLE (1U << 4)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_PG_RED_BLUE_ENABLE (1U << 8)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_LC_RED_BLUE_ENABLE (1U << 9)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RO_RED_BLUE_ENABLE (1U << 10)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RND_RED_BLUE_ENABLE (1U << 11)
+#define RKISP1_CIF_ISP_DPCC_METHODS_SET_RG_RED_BLUE_ENABLE (1U << 12)
+
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_PG_FAC_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RND_THRESH_RB(v) ((v) << 8)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_G(v) ((v) << 0)
+#define RKISP1_CIF_ISP_DPCC_RG_FAC_RB(v) ((v) << 8)
+
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_G(n, v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RO_LIMITS_n_RB(n, v) ((v) << ((n) * 4 + 2))
+
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_G(n, v) ((v) << ((n) * 4))
+#define RKISP1_CIF_ISP_DPCC_RND_OFFS_n_RB(n, v) ((v) << ((n) * 4 + 2))
/*
* Denoising pre filter
@@ -249,16 +288,20 @@ struct rkisp1_cif_isp_bls_config {
};
/**
- * struct rkisp1_cif_isp_dpcc_methods_config - Methods Configuration used by DPCC
+ * struct rkisp1_cif_isp_dpcc_methods_config - DPCC methods set configuration
*
- * Methods Configuration used by Defect Pixel Cluster Correction
+ * This structure stores the configuration of one set of methods for the DPCC
+ * algorithm. Multiple methods can be selected in each set (independently for
+ * the Green and Red/Blue components) through the @method field, the result is
+ * the logical AND of all enabled methods. The remaining fields set thresholds
+ * and factors for each method.
*
- * @method: Method enable bits
- * @line_thresh: Line threshold
- * @line_mad_fac: Line MAD factor
- * @pg_fac: Peak gradient factor
- * @rnd_thresh: Rank Neighbor Difference threshold
- * @rg_fac: Rank gradient factor
+ * @method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)
+ * @line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)
+ * @line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)
+ * @pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)
+ * @rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)
+ * @rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
*/
struct rkisp1_cif_isp_dpcc_methods_config {
__u32 method;
@@ -272,14 +315,16 @@ struct rkisp1_cif_isp_dpcc_methods_config {
/**
* struct rkisp1_cif_isp_dpcc_config - Configuration used by DPCC
*
- * Configuration used by Defect Pixel Cluster Correction
+ * Configuration used by Defect Pixel Cluster Correction. Three sets of methods
+ * can be configured and selected through the @set_use field. The result is the
+ * logical OR of all enabled sets.
*
- * @mode: dpcc output mode
- * @output_mode: whether use hard coded methods
- * @set_use: stage1 methods set
- * @methods: methods config
- * @ro_limits: rank order limits
- * @rnd_offs: differential rank offsets for rank neighbor difference
+ * @mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)
+ * @output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)
+ * @set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)
+ * @methods: Methods sets configuration
+ * @ro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)
+ * @rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
*/
struct rkisp1_cif_isp_dpcc_config {
__u32 mode;
diff --git a/lib/libc/include/any-linux-any/linux/romfs_fs.h b/lib/libc/include/any-linux-any/linux/romfs_fs.h
index 1a86775a87..e7dba52f41 100644
--- a/lib/libc/include/any-linux-any/linux/romfs_fs.h
+++ b/lib/libc/include/any-linux-any/linux/romfs_fs.h
@@ -27,7 +27,7 @@ struct romfs_super_block {
__be32 word1;
__be32 size;
__be32 checksum;
- char name[0]; /* volume name */
+ char name[]; /* volume name */
};
/* On disk inode */
@@ -37,7 +37,7 @@ struct romfs_inode {
__be32 spec;
__be32 size;
__be32 checksum;
- char name[0];
+ char name[];
};
#define ROMFH_TYPE 7
diff --git a/lib/libc/include/any-linux-any/linux/rpl.h b/lib/libc/include/any-linux-any/linux/rpl.h
index 667338da68..5237b4e8ab 100644
--- a/lib/libc/include/any-linux-any/linux/rpl.h
+++ b/lib/libc/include/any-linux-any/linux/rpl.h
@@ -37,8 +37,8 @@ struct ipv6_rpl_sr_hdr {
#endif
union {
- struct in6_addr addr[0];
- __u8 data[0];
+ __DECLARE_FLEX_ARRAY(struct in6_addr, addr);
+ __DECLARE_FLEX_ARRAY(__u8, data);
} segments;
} __attribute__((packed));
diff --git a/lib/libc/include/any-linux-any/linux/rpmsg.h b/lib/libc/include/any-linux-any/linux/rpmsg.h
index a12ce6e909..360eb05dd2 100644
--- a/lib/libc/include/any-linux-any/linux/rpmsg.h
+++ b/lib/libc/include/any-linux-any/linux/rpmsg.h
@@ -33,4 +33,14 @@ struct rpmsg_endpoint_info {
*/
#define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2)
+/**
+ * Instantiate a new local rpmsg service device.
+ */
+#define RPMSG_CREATE_DEV_IOCTL _IOW(0xb5, 0x3, struct rpmsg_endpoint_info)
+
+/**
+ * Release a local rpmsg device.
+ */
+#define RPMSG_RELEASE_DEV_IOCTL _IOW(0xb5, 0x4, struct rpmsg_endpoint_info)
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/rseq.h b/lib/libc/include/any-linux-any/linux/rseq.h
index 504d8f76d7..753d9fb689 100644
--- a/lib/libc/include/any-linux-any/linux/rseq.h
+++ b/lib/libc/include/any-linux-any/linux/rseq.h
@@ -105,23 +105,11 @@ struct rseq {
* Read and set by the kernel. Set by user-space with single-copy
* atomicity semantics. This field should only be updated by the
* thread which registered this data structure. Aligned on 64-bit.
+ *
+ * 32-bit architectures should update the low order bits of the
+ * rseq_cs field, leaving the high order bits initialized to 0.
*/
- union {
- __u64 ptr64;
-#ifdef __LP64__
- __u64 ptr;
-#else
- struct {
-#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(__BIG_ENDIAN)
- __u32 padding; /* Initialized to zero. */
- __u32 ptr32;
-#else /* LITTLE */
- __u32 ptr32;
- __u32 padding; /* Initialized to zero. */
-#endif /* ENDIAN */
- } ptr;
-#endif
- } rseq_cs;
+ __u64 rseq_cs;
/*
* Restartable sequences flags field.
@@ -142,6 +130,28 @@ struct rseq {
* this thread.
*/
__u32 flags;
+
+ /*
+ * Restartable sequences node_id field. Updated by the kernel. Read by
+ * user-space with single-copy atomicity semantics. This field should
+ * only be read by the thread which registered this data structure.
+ * Aligned on 32-bit. Contains the current NUMA node ID.
+ */
+ __u32 node_id;
+
+ /*
+ * Restartable sequences mm_cid field. Updated by the kernel. Read by
+ * user-space with single-copy atomicity semantics. This field should
+ * only be read by the thread which registered this data structure.
+ * Aligned on 32-bit. Contains the current thread's concurrency ID
+ * (allocated uniquely within a memory map).
+ */
+ __u32 mm_cid;
+
+ /*
+ * Flexible array member at end of structure, after last feature field.
+ */
+ char end[];
} __attribute__((aligned(4 * sizeof(__u64))));
#endif /* _LINUX_RSEQ_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/rtc.h b/lib/libc/include/any-linux-any/linux/rtc.h
index 3a6d0b949b..ace9b906fc 100644
--- a/lib/libc/include/any-linux-any/linux/rtc.h
+++ b/lib/libc/include/any-linux-any/linux/rtc.h
@@ -133,7 +133,8 @@ struct rtc_param {
#define RTC_FEATURE_UPDATE_INTERRUPT 4
#define RTC_FEATURE_CORRECTION 5
#define RTC_FEATURE_BACKUP_SWITCH_MODE 6
-#define RTC_FEATURE_CNT 7
+#define RTC_FEATURE_ALARM_WAKEUP_ONLY 7
+#define RTC_FEATURE_CNT 8
/* parameter list */
#define RTC_PARAM_FEATURES 0
diff --git a/lib/libc/include/any-linux-any/linux/rtnetlink.h b/lib/libc/include/any-linux-any/linux/rtnetlink.h
index 39fbda33fc..3c41d05a42 100644
--- a/lib/libc/include/any-linux-any/linux/rtnetlink.h
+++ b/lib/libc/include/any-linux-any/linux/rtnetlink.h
@@ -146,6 +146,8 @@ enum {
#define RTM_NEWSTATS RTM_NEWSTATS
RTM_GETSTATS = 94,
#define RTM_GETSTATS RTM_GETSTATS
+ RTM_SETSTATS,
+#define RTM_SETSTATS RTM_SETSTATS
RTM_NEWCACHEREPORT = 96,
#define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT
@@ -185,6 +187,13 @@ enum {
RTM_GETNEXTHOPBUCKET,
#define RTM_GETNEXTHOPBUCKET RTM_GETNEXTHOPBUCKET
+ RTM_NEWTUNNEL = 120,
+#define RTM_NEWTUNNEL RTM_NEWTUNNEL
+ RTM_DELTUNNEL,
+#define RTM_DELTUNNEL RTM_DELTUNNEL
+ RTM_GETTUNNEL,
+#define RTM_GETTUNNEL RTM_GETTUNNEL
+
__RTM_MAX,
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
};
@@ -431,7 +440,7 @@ struct rtnexthop {
/* RTA_VIA */
struct rtvia {
__kernel_sa_family_t rtvia_family;
- __u8 rtvia_addr[0];
+ __u8 rtvia_addr[];
};
/* RTM_CACHEINFO */
@@ -626,6 +635,7 @@ enum {
TCA_INGRESS_BLOCK,
TCA_EGRESS_BLOCK,
TCA_DUMP_FLAGS,
+ TCA_EXT_WARN_MSG,
__TCA_MAX
};
@@ -752,6 +762,12 @@ enum rtnetlink_groups {
#define RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP
RTNLGRP_BRVLAN,
#define RTNLGRP_BRVLAN RTNLGRP_BRVLAN
+ RTNLGRP_MCTP_IFADDR,
+#define RTNLGRP_MCTP_IFADDR RTNLGRP_MCTP_IFADDR
+ RTNLGRP_TUNNEL,
+#define RTNLGRP_TUNNEL RTNLGRP_TUNNEL
+ RTNLGRP_STATS,
+#define RTNLGRP_STATS RTNLGRP_STATS
__RTNLGRP_MAX
};
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
@@ -771,6 +787,7 @@ enum {
TCA_ROOT_FLAGS,
TCA_ROOT_COUNT,
TCA_ROOT_TIME_DELTA, /* in msecs */
+ TCA_ROOT_EXT_WARN_MSG,
__TCA_ROOT_MAX,
#define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)
};
@@ -800,6 +817,7 @@ enum {
#define RTEXT_FILTER_MRP (1 << 4)
#define RTEXT_FILTER_CFM_CONFIG (1 << 5)
#define RTEXT_FILTER_CFM_STATUS (1 << 6)
+#define RTEXT_FILTER_MST (1 << 7)
/* End of information exported to user level */
diff --git a/lib/libc/include/any-linux-any/linux/sctp.h b/lib/libc/include/any-linux-any/linux/sctp.h
index ea5b987a8d..9d3d1557a4 100644
--- a/lib/libc/include/any-linux-any/linux/sctp.h
+++ b/lib/libc/include/any-linux-any/linux/sctp.h
@@ -365,7 +365,7 @@ struct sctp_assoc_change {
__u16 sac_outbound_streams;
__u16 sac_inbound_streams;
sctp_assoc_t sac_assoc_id;
- __u8 sac_info[0];
+ __u8 sac_info[];
};
/*
@@ -436,7 +436,7 @@ struct sctp_remote_error {
__u32 sre_length;
__be16 sre_error;
sctp_assoc_t sre_assoc_id;
- __u8 sre_data[0];
+ __u8 sre_data[];
};
@@ -453,7 +453,7 @@ struct sctp_send_failed {
__u32 ssf_error;
struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id;
- __u8 ssf_data[0];
+ __u8 ssf_data[];
};
struct sctp_send_failed_event {
@@ -463,7 +463,7 @@ struct sctp_send_failed_event {
__u32 ssf_error;
struct sctp_sndinfo ssfe_info;
sctp_assoc_t ssf_assoc_id;
- __u8 ssf_data[0];
+ __u8 ssf_data[];
};
/*
@@ -1023,7 +1023,7 @@ struct sctp_getaddrs_old {
struct sctp_getaddrs {
sctp_assoc_t assoc_id; /*input*/
__u32 addr_num; /*output*/
- __u8 addrs[0]; /*output, variable size*/
+ __u8 addrs[]; /*output, variable size*/
};
/* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves
diff --git a/lib/libc/include/any-linux-any/linux/seccomp.h b/lib/libc/include/any-linux-any/linux/seccomp.h
index 31b12f1772..a54efaa211 100644
--- a/lib/libc/include/any-linux-any/linux/seccomp.h
+++ b/lib/libc/include/any-linux-any/linux/seccomp.h
@@ -23,6 +23,8 @@
#define SECCOMP_FILTER_FLAG_SPEC_ALLOW (1UL << 2)
#define SECCOMP_FILTER_FLAG_NEW_LISTENER (1UL << 3)
#define SECCOMP_FILTER_FLAG_TSYNC_ESRCH (1UL << 4)
+/* Received notifications wait in killable state (only respond to fatal signals) */
+#define SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV (1UL << 5)
/*
* All BPF programs must return a 32-bit value.
diff --git a/lib/libc/include/any-linux-any/linux/sed-opal.h b/lib/libc/include/any-linux-any/linux/sed-opal.h
index d9fe76a6ae..8e4836a101 100644
--- a/lib/libc/include/any-linux-any/linux/sed-opal.h
+++ b/lib/libc/include/any-linux-any/linux/sed-opal.h
@@ -44,6 +44,11 @@ enum opal_lock_state {
OPAL_LK = 0x04, /* 0100 */
};
+enum opal_lock_flags {
+ /* IOC_OPAL_SAVE will also store the provided key for locking */
+ OPAL_SAVE_FOR_LOCK = 0x01,
+};
+
struct opal_key {
__u8 lr;
__u8 key_len;
@@ -76,7 +81,8 @@ struct opal_user_lr_setup {
struct opal_lock_unlock {
struct opal_session_info session;
__u32 l_state;
- __u8 __align[4];
+ __u16 flags;
+ __u8 __align[2];
};
struct opal_new_pw {
@@ -132,6 +138,19 @@ struct opal_read_write_table {
__u64 priv;
};
+#define OPAL_FL_SUPPORTED 0x00000001
+#define OPAL_FL_LOCKING_SUPPORTED 0x00000002
+#define OPAL_FL_LOCKING_ENABLED 0x00000004
+#define OPAL_FL_LOCKED 0x00000008
+#define OPAL_FL_MBR_ENABLED 0x00000010
+#define OPAL_FL_MBR_DONE 0x00000020
+#define OPAL_FL_SUM_SUPPORTED 0x00000040
+
+struct opal_status {
+ __u32 flags;
+ __u32 reserved;
+};
+
#define IOC_OPAL_SAVE _IOW('p', 220, struct opal_lock_unlock)
#define IOC_OPAL_LOCK_UNLOCK _IOW('p', 221, struct opal_lock_unlock)
#define IOC_OPAL_TAKE_OWNERSHIP _IOW('p', 222, struct opal_key)
@@ -148,5 +167,6 @@ struct opal_read_write_table {
#define IOC_OPAL_MBR_DONE _IOW('p', 233, struct opal_mbr_done)
#define IOC_OPAL_WRITE_SHADOW_MBR _IOW('p', 234, struct opal_shadow_mbr)
#define IOC_OPAL_GENERIC_TABLE_RW _IOW('p', 235, struct opal_read_write_table)
+#define IOC_OPAL_GET_STATUS _IOR('p', 236, struct opal_status)
#endif /* _SED_OPAL_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/seg6.h b/lib/libc/include/any-linux-any/linux/seg6.h
index 6aca08e8e7..e3f14246b6 100644
--- a/lib/libc/include/any-linux-any/linux/seg6.h
+++ b/lib/libc/include/any-linux-any/linux/seg6.h
@@ -30,7 +30,7 @@ struct ipv6_sr_hdr {
__u8 flags;
__u16 tag;
- struct in6_addr segments[0];
+ struct in6_addr segments[];
};
#define SR6_FLAG1_PROTECTED (1 << 6)
diff --git a/lib/libc/include/any-linux-any/linux/seg6_iptunnel.h b/lib/libc/include/any-linux-any/linux/seg6_iptunnel.h
index 710e980071..4361e5c5a1 100644
--- a/lib/libc/include/any-linux-any/linux/seg6_iptunnel.h
+++ b/lib/libc/include/any-linux-any/linux/seg6_iptunnel.h
@@ -26,7 +26,7 @@ enum {
struct seg6_iptunnel_encap {
int mode;
- struct ipv6_sr_hdr srh[0];
+ struct ipv6_sr_hdr srh[];
};
#define SEG6_IPTUN_ENCAP_SIZE(x) ((sizeof(*x)) + (((x)->srh->hdrlen + 1) << 3))
@@ -35,6 +35,8 @@ enum {
SEG6_IPTUN_MODE_INLINE,
SEG6_IPTUN_MODE_ENCAP,
SEG6_IPTUN_MODE_L2ENCAP,
+ SEG6_IPTUN_MODE_ENCAP_RED,
+ SEG6_IPTUN_MODE_L2ENCAP_RED,
};
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/seg6_local.h b/lib/libc/include/any-linux-any/linux/seg6_local.h
index 826348703f..cbe3e5e5de 100644
--- a/lib/libc/include/any-linux-any/linux/seg6_local.h
+++ b/lib/libc/include/any-linux-any/linux/seg6_local.h
@@ -28,6 +28,7 @@ enum {
SEG6_LOCAL_BPF,
SEG6_LOCAL_VRFTABLE,
SEG6_LOCAL_COUNTERS,
+ SEG6_LOCAL_FLAVORS,
__SEG6_LOCAL_MAX,
};
#define SEG6_LOCAL_MAX (__SEG6_LOCAL_MAX - 1)
@@ -110,4 +111,27 @@ enum {
#define SEG6_LOCAL_CNT_MAX (__SEG6_LOCAL_CNT_MAX - 1)
+/* SRv6 End* Flavor attributes */
+enum {
+ SEG6_LOCAL_FLV_UNSPEC,
+ SEG6_LOCAL_FLV_OPERATION,
+ SEG6_LOCAL_FLV_LCBLOCK_BITS,
+ SEG6_LOCAL_FLV_LCNODE_FN_BITS,
+ __SEG6_LOCAL_FLV_MAX,
+};
+
+#define SEG6_LOCAL_FLV_MAX (__SEG6_LOCAL_FLV_MAX - 1)
+
+/* Designed flavor operations for SRv6 End* Behavior */
+enum {
+ SEG6_LOCAL_FLV_OP_UNSPEC,
+ SEG6_LOCAL_FLV_OP_PSP,
+ SEG6_LOCAL_FLV_OP_USP,
+ SEG6_LOCAL_FLV_OP_USD,
+ SEG6_LOCAL_FLV_OP_NEXT_CSID,
+ __SEG6_LOCAL_FLV_OP_MAX
+};
+
+#define SEG6_LOCAL_FLV_OP_MAX (__SEG6_LOCAL_FLV_OP_MAX - 1)
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/serial.h b/lib/libc/include/any-linux-any/linux/serial.h
index 1e50da14cb..983a7095f6 100644
--- a/lib/libc/include/any-linux-any/linux/serial.h
+++ b/lib/libc/include/any-linux-any/linux/serial.h
@@ -107,29 +107,62 @@ struct serial_icounter_struct {
int reserved[9];
};
-/*
+/**
+ * struct serial_rs485 - serial interface for controlling RS485 settings.
+ * @flags: RS485 feature flags.
+ * @delay_rts_before_send: Delay before send (milliseconds).
+ * @delay_rts_after_send: Delay after send (milliseconds).
+ * @addr_recv: Receive filter for RS485 addressing mode
+ * (used only when %SER_RS485_ADDR_RECV is set).
+ * @addr_dest: Destination address for RS485 addressing mode
+ * (used only when %SER_RS485_ADDR_DEST is set).
+ * @padding0: Padding (set to zero).
+ * @padding1: Padding (set to zero).
+ * @padding: Deprecated, use @padding0 and @padding1 instead.
+ * Do not use with @addr_recv and @addr_dest (due to
+ * overlap).
+ *
* Serial interface for controlling RS485 settings on chips with suitable
* support. Set with TIOCSRS485 and get with TIOCGRS485 if supported by your
* platform. The set function returns the new state, with any unsupported bits
* reverted appropriately.
+ *
+ * The flag bits are:
+ *
+ * * %SER_RS485_ENABLED - RS485 enabled.
+ * * %SER_RS485_RTS_ON_SEND - Logical level for RTS pin when sending.
+ * * %SER_RS485_RTS_AFTER_SEND - Logical level for RTS pin after sent.
+ * * %SER_RS485_RX_DURING_TX - Full-duplex RS485 line.
+ * * %SER_RS485_TERMINATE_BUS - Enable bus termination (if supported).
+ * * %SER_RS485_ADDRB - Enable RS485 addressing mode.
+ * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB.
+ * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB.
*/
-
struct serial_rs485 {
- __u32 flags; /* RS485 feature flags */
-#define SER_RS485_ENABLED (1 << 0) /* If enabled */
-#define SER_RS485_RTS_ON_SEND (1 << 1) /* Logical level for
- RTS pin when
- sending */
-#define SER_RS485_RTS_AFTER_SEND (1 << 2) /* Logical level for
- RTS pin after sent*/
+ __u32 flags;
+#define SER_RS485_ENABLED (1 << 0)
+#define SER_RS485_RTS_ON_SEND (1 << 1)
+#define SER_RS485_RTS_AFTER_SEND (1 << 2)
#define SER_RS485_RX_DURING_TX (1 << 4)
-#define SER_RS485_TERMINATE_BUS (1 << 5) /* Enable bus
- termination
- (if supported) */
- __u32 delay_rts_before_send; /* Delay before send (milliseconds) */
- __u32 delay_rts_after_send; /* Delay after send (milliseconds) */
- __u32 padding[5]; /* Memory is cheap, new structs
- are a royal PITA .. */
+#define SER_RS485_TERMINATE_BUS (1 << 5)
+#define SER_RS485_ADDRB (1 << 6)
+#define SER_RS485_ADDR_RECV (1 << 7)
+#define SER_RS485_ADDR_DEST (1 << 8)
+
+ __u32 delay_rts_before_send;
+ __u32 delay_rts_after_send;
+
+ /* The fields below are defined by flags */
+ union {
+ __u32 padding[5]; /* Memory is cheap, new structs are a pain */
+
+ struct {
+ __u8 addr_recv;
+ __u8 addr_dest;
+ __u8 padding0[2];
+ __u32 padding1[4];
+ };
+ };
};
/*
diff --git a/lib/libc/include/any-linux-any/linux/serial_core.h b/lib/libc/include/any-linux-any/linux/serial_core.h
index ed079f5ea8..d8bfabce0b 100644
--- a/lib/libc/include/any-linux-any/linux/serial_core.h
+++ b/lib/libc/include/any-linux-any/linux/serial_core.h
@@ -68,6 +68,9 @@
/* NVIDIA Tegra Combined UART */
#define PORT_TEGRA_TCU 41
+/* ASPEED AST2x00 virtual UART */
+#define PORT_ASPEED_VUART 42
+
/* Intel EG20 */
#define PORT_PCH_8LINE 44
#define PORT_PCH_2LINE 45
@@ -121,10 +124,6 @@
/* TXX9 type number */
#define PORT_TXX9 64
-/* NEC VR4100 series SIU/DSIU */
-#define PORT_VR41XX_SIU 65
-#define PORT_VR41XX_DSIU 66
-
/* Samsung S3C2400 SoC */
#define PORT_S3C2400 67
@@ -208,6 +207,9 @@
/* Atheros AR933X SoC */
#define PORT_AR933X 99
+/* MCHP 16550A UART with 256 byte FIFOs */
+#define PORT_MCHP16550A 100
+
/* ARC (Synopsys) on-chip UART */
#define PORT_ARC 101
@@ -274,4 +276,7 @@
/* Freescale LINFlexD UART */
#define PORT_LINFLEXUART 122
+/* Sunplus UART */
+#define PORT_SUNPLUS 123
+
#endif /* LINUX_SERIAL_CORE_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/serial_reg.h b/lib/libc/include/any-linux-any/linux/serial_reg.h
index 30ff4e346a..6f17570d85 100644
--- a/lib/libc/include/any-linux-any/linux/serial_reg.h
+++ b/lib/libc/include/any-linux-any/linux/serial_reg.h
@@ -44,6 +44,11 @@
#define UART_IIR_RX_TIMEOUT 0x0c /* OMAP RX Timeout interrupt */
#define UART_IIR_XOFF 0x10 /* OMAP XOFF/Special Character */
#define UART_IIR_CTS_RTS_DSR 0x20 /* OMAP CTS/RTS/DSR Change */
+#define UART_IIR_64BYTE_FIFO 0x20 /* 16750 64 bytes FIFO */
+#define UART_IIR_FIFO_ENABLED 0xc0 /* FIFOs enabled / port type identification */
+#define UART_IIR_FIFO_ENABLED_8250 0x00 /* 8250: no FIFO */
+#define UART_IIR_FIFO_ENABLED_16550 0x80 /* 16550: (broken/unusable) FIFO */
+#define UART_IIR_FIFO_ENABLED_16550A 0xc0 /* 16550A: FIFO enabled */
#define UART_FCR 2 /* Out: FIFO Control Register */
#define UART_FCR_ENABLE_FIFO 0x01 /* Enable the FIFO */
@@ -139,7 +144,7 @@
#define UART_LSR_PE 0x04 /* Parity error indicator */
#define UART_LSR_OE 0x02 /* Overrun error indicator */
#define UART_LSR_DR 0x01 /* Receiver data ready */
-#define UART_LSR_BRK_ERROR_BITS 0x1E /* BI, FE, PE, OE bits */
+#define UART_LSR_BRK_ERROR_BITS (UART_LSR_BI|UART_LSR_FE|UART_LSR_PE|UART_LSR_OE)
#define UART_MSR 6 /* In: Modem Status Register */
#define UART_MSR_DCD 0x80 /* Data Carrier Detect */
@@ -150,7 +155,7 @@
#define UART_MSR_TERI 0x04 /* Trailing edge ring indicator */
#define UART_MSR_DDSR 0x02 /* Delta DSR */
#define UART_MSR_DCTS 0x01 /* Delta CTS */
-#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
+#define UART_MSR_ANY_DELTA (UART_MSR_DDCD|UART_MSR_TERI|UART_MSR_DDSR|UART_MSR_DCTS)
#define UART_SCR 7 /* I/O: Scratch Register */
diff --git a/lib/libc/include/any-linux-any/linux/sev-guest.h b/lib/libc/include/any-linux-any/linux/sev-guest.h
new file mode 100644
index 0000000000..57799449dd
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/sev-guest.h
@@ -0,0 +1,80 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/*
+ * Userspace interface for AMD SEV and SNP guest driver.
+ *
+ * Copyright (C) 2021 Advanced Micro Devices, Inc.
+ *
+ * Author: Brijesh Singh <brijesh.singh@amd.com>
+ *
+ * SEV API specification is available at: https://developer.amd.com/sev/
+ */
+
+#ifndef __UAPI_LINUX_SEV_GUEST_H_
+#define __UAPI_LINUX_SEV_GUEST_H_
+
+#include <linux/types.h>
+
+struct snp_report_req {
+ /* user data that should be included in the report */
+ __u8 user_data[64];
+
+ /* The vmpl level to be included in the report */
+ __u32 vmpl;
+
+ /* Must be zero filled */
+ __u8 rsvd[28];
+};
+
+struct snp_report_resp {
+ /* response data, see SEV-SNP spec for the format */
+ __u8 data[4000];
+};
+
+struct snp_derived_key_req {
+ __u32 root_key_select;
+ __u32 rsvd;
+ __u64 guest_field_select;
+ __u32 vmpl;
+ __u32 guest_svn;
+ __u64 tcb_version;
+};
+
+struct snp_derived_key_resp {
+ /* response data, see SEV-SNP spec for the format */
+ __u8 data[64];
+};
+
+struct snp_guest_request_ioctl {
+ /* message version number (must be non-zero) */
+ __u8 msg_version;
+
+ /* Request and response structure address */
+ __u64 req_data;
+ __u64 resp_data;
+
+ /* firmware error code on failure (see psp-sev.h) */
+ __u64 fw_err;
+};
+
+struct snp_ext_report_req {
+ struct snp_report_req data;
+
+ /* where to copy the certificate blob */
+ __u64 certs_address;
+
+ /* length of the certificate blob */
+ __u32 certs_len;
+};
+
+#define SNP_GUEST_REQ_IOC_TYPE 'S'
+
+/* Get SNP attestation report */
+#define SNP_GET_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x0, struct snp_guest_request_ioctl)
+
+/* Get a derived key from the root */
+#define SNP_GET_DERIVED_KEY _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x1, struct snp_guest_request_ioctl)
+
+/* Get SNP extended report as defined in the GHCB specification version 2. */
+#define SNP_GET_EXT_REPORT _IOWR(SNP_GUEST_REQ_IOC_TYPE, 0x2, struct snp_guest_request_ioctl)
+
+#endif /* __UAPI_LINUX_SEV_GUEST_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/smc.h b/lib/libc/include/any-linux-any/linux/smc.h
index e24c597bdb..813d63a45f 100644
--- a/lib/libc/include/any-linux-any/linux/smc.h
+++ b/lib/libc/include/any-linux-any/linux/smc.h
@@ -59,6 +59,9 @@ enum {
SMC_NETLINK_DUMP_SEID,
SMC_NETLINK_ENABLE_SEID,
SMC_NETLINK_DISABLE_SEID,
+ SMC_NETLINK_DUMP_HS_LIMITATION,
+ SMC_NETLINK_ENABLE_HS_LIMITATION,
+ SMC_NETLINK_DISABLE_HS_LIMITATION,
};
/* SMC_GENL_FAMILY top level attributes */
@@ -119,6 +122,9 @@ enum {
SMC_NLA_LGR_R_CONNS_NUM, /* u32 */
SMC_NLA_LGR_R_V2_COMMON, /* nest */
SMC_NLA_LGR_R_V2, /* nest */
+ SMC_NLA_LGR_R_NET_COOKIE, /* u64 */
+ SMC_NLA_LGR_R_PAD, /* flag */
+ SMC_NLA_LGR_R_BUF_TYPE, /* u8 */
__SMC_NLA_LGR_R_MAX,
SMC_NLA_LGR_R_MAX = __SMC_NLA_LGR_R_MAX - 1
};
@@ -282,4 +288,16 @@ enum {
__SMC_NLA_SEID_TABLE_MAX,
SMC_NLA_SEID_TABLE_MAX = __SMC_NLA_SEID_TABLE_MAX - 1
};
+
+/* SMC_NETLINK_HS_LIMITATION attributes */
+enum {
+ SMC_NLA_HS_LIMITATION_UNSPEC,
+ SMC_NLA_HS_LIMITATION_ENABLED, /* u8 */
+ __SMC_NLA_HS_LIMITATION_MAX,
+ SMC_NLA_HS_LIMITATION_MAX = __SMC_NLA_HS_LIMITATION_MAX - 1
+};
+
+/* SMC socket options */
+#define SMC_LIMIT_HS 1 /* constraint on smc handshake */
+
#endif /* _LINUX_SMC_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/snmp.h b/lib/libc/include/any-linux-any/linux/snmp.h
index 212242caf3..ed532774c7 100644
--- a/lib/libc/include/any-linux-any/linux/snmp.h
+++ b/lib/libc/include/any-linux-any/linux/snmp.h
@@ -95,6 +95,8 @@ enum
ICMP_MIB_OUTADDRMASKS, /* OutAddrMasks */
ICMP_MIB_OUTADDRMASKREPS, /* OutAddrMaskReps */
ICMP_MIB_CSUMERRORS, /* InCsumErrors */
+ ICMP_MIB_RATELIMITGLOBAL, /* OutRateLimitGlobal */
+ ICMP_MIB_RATELIMITHOST, /* OutRateLimitHost */
__ICMP_MIB_MAX
};
@@ -112,6 +114,7 @@ enum
ICMP6_MIB_OUTMSGS, /* OutMsgs */
ICMP6_MIB_OUTERRORS, /* OutErrors */
ICMP6_MIB_CSUMERRORS, /* InCsumErrors */
+ ICMP6_MIB_RATELIMITHOST, /* OutRateLimitHost */
__ICMP6_MIB_MAX
};
@@ -292,6 +295,7 @@ enum
LINUX_MIB_TCPDSACKIGNOREDDUBIOUS, /* TCPDSACKIgnoredDubious */
LINUX_MIB_TCPMIGRATEREQSUCCESS, /* TCPMigrateReqSuccess */
LINUX_MIB_TCPMIGRATEREQFAILURE, /* TCPMigrateReqFailure */
+ LINUX_MIB_TCPPLBREHASH, /* TCPPLBRehash */
__LINUX_MIB_MAX
};
@@ -344,6 +348,8 @@ enum
LINUX_MIB_TLSRXDEVICE, /* TlsRxDevice */
LINUX_MIB_TLSDECRYPTERROR, /* TlsDecryptError */
LINUX_MIB_TLSRXDEVICERESYNC, /* TlsRxDeviceResync */
+ LINUX_MIB_TLSDECRYPTRETRY, /* TlsDecryptRetry */
+ LINUX_MIB_TLSRXNOPADVIOL, /* TlsRxNoPadViolation */
__LINUX_MIB_TLSMAX
};
diff --git a/lib/libc/include/any-linux-any/linux/socket.h b/lib/libc/include/any-linux-any/linux/socket.h
index 34df26c11d..6766d42388 100644
--- a/lib/libc/include/any-linux-any/linux/socket.h
+++ b/lib/libc/include/any-linux-any/linux/socket.h
@@ -31,4 +31,8 @@ struct __kernel_sockaddr_storage {
#define SOCK_BUF_LOCK_MASK (SOCK_SNDBUF_LOCK | SOCK_RCVBUF_LOCK)
+#define SOCK_TXREHASH_DEFAULT 255
+#define SOCK_TXREHASH_DISABLED 0
+#define SOCK_TXREHASH_ENABLED 1
+
#endif /* _LINUX_SOCKET_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/soundcard.h b/lib/libc/include/any-linux-any/linux/soundcard.h
index 18f32e8004..7f3c06495a 100644
--- a/lib/libc/include/any-linux-any/linux/soundcard.h
+++ b/lib/libc/include/any-linux-any/linux/soundcard.h
@@ -1046,7 +1046,7 @@ typedef struct mixer_vol_table {
* the GPL version of OSS-4.x and build against that version
* of the header.
*
- * We redefine the extern keyword so that make headers_check
+ * We redefine the extern keyword so that usr/include/headers_check.pl
* does not complain about SEQ_USE_EXTBUF.
*/
#define SEQ_DECLAREBUF() SEQ_USE_EXTBUF()
diff --git a/lib/libc/include/any-linux-any/linux/spi/spi.h b/lib/libc/include/any-linux-any/linux/spi/spi.h
index 8c10e0542d..736fa9b933 100644
--- a/lib/libc/include/any-linux-any/linux/spi/spi.h
+++ b/lib/libc/include/any-linux-any/linux/spi/spi.h
@@ -27,6 +27,7 @@
#define SPI_TX_OCTAL _BITUL(13) /* transmit with 8 wires */
#define SPI_RX_OCTAL _BITUL(14) /* receive with 8 wires */
#define SPI_3WIRE_HIZ _BITUL(15) /* high impedance turnaround */
+#define SPI_RX_CPHA_FLIP _BITUL(16) /* flip CPHA on Rx only xfer */
/*
* All the bits defined above should be covered by SPI_MODE_USER_MASK.
@@ -36,6 +37,6 @@
* These bits must not overlap. A static assert check should make sure of that.
* If adding extra bits, make sure to increase the bit index below as well.
*/
-#define SPI_MODE_USER_MASK (_BITUL(16) - 1)
+#define SPI_MODE_USER_MASK (_BITUL(17) - 1)
#endif /* _SPI_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/stat.h b/lib/libc/include/any-linux-any/linux/stat.h
index 6b4ecf89f4..23dc6489f3 100644
--- a/lib/libc/include/any-linux-any/linux/stat.h
+++ b/lib/libc/include/any-linux-any/linux/stat.h
@@ -124,7 +124,8 @@ struct statx {
__u32 stx_dev_minor;
/* 0x90 */
__u64 stx_mnt_id;
- __u64 __spare2;
+ __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */
+ __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */
/* 0xa0 */
__u64 __spare3[12]; /* Spare space for future expansion */
/* 0x100 */
@@ -152,6 +153,7 @@ struct statx {
#define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */
#define STATX_BTIME 0x00000800U /* Want/got stx_btime */
#define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */
+#define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */
#define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */
diff --git a/lib/libc/include/any-linux-any/linux/stddef.h b/lib/libc/include/any-linux-any/linux/stddef.h
index 47a672946e..63c407010f 100644
--- a/lib/libc/include/any-linux-any/linux/stddef.h
+++ b/lib/libc/include/any-linux-any/linux/stddef.h
@@ -1,4 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _LINUX_STDDEF_H
+#define _LINUX_STDDEF_H
+
#ifndef __always_inline
@@ -40,4 +43,5 @@
struct { \
struct { } __empty_ ## NAME; \
TYPE NAME[]; \
- } \ No newline at end of file
+ }
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/stm.h b/lib/libc/include/any-linux-any/linux/stm.h
index c82694670a..c105f511e4 100644
--- a/lib/libc/include/any-linux-any/linux/stm.h
+++ b/lib/libc/include/any-linux-any/linux/stm.h
@@ -36,7 +36,7 @@ struct stp_policy_id {
/* padding */
__u16 __reserved_0;
__u32 __reserved_1;
- char id[0];
+ char id[];
};
#define STP_POLICY_ID_SET _IOWR('%', 0, struct stp_policy_id)
diff --git a/lib/libc/include/any-linux-any/linux/swab.h b/lib/libc/include/any-linux-any/linux/swab.h
index fe73313955..d47867a6be 100644
--- a/lib/libc/include/any-linux-any/linux/swab.h
+++ b/lib/libc/include/any-linux-any/linux/swab.h
@@ -3,7 +3,7 @@
#define _LINUX_SWAB_H
#include <linux/types.h>
-
+#include <linux/stddef.h>
#include <asm/bitsperlong.h>
#include <asm/swab.h>
@@ -102,7 +102,7 @@ static __inline__ __u32 __fswahb32(__u32 val)
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
#else
#define __swab16(x) \
- (__builtin_constant_p((__u16)(x)) ? \
+ (__u16)(__builtin_constant_p(x) ? \
___constant_swab16(x) : \
__fswab16(x))
#endif
@@ -115,7 +115,7 @@ static __inline__ __u32 __fswahb32(__u32 val)
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
#else
#define __swab32(x) \
- (__builtin_constant_p((__u32)(x)) ? \
+ (__u32)(__builtin_constant_p(x) ? \
___constant_swab32(x) : \
__fswab32(x))
#endif
@@ -128,7 +128,7 @@ static __inline__ __u32 __fswahb32(__u32 val)
#define __swab64(x) (__u64)__builtin_bswap64((__u64)(x))
#else
#define __swab64(x) \
- (__builtin_constant_p((__u64)(x)) ? \
+ (__u64)(__builtin_constant_p(x) ? \
___constant_swab64(x) : \
__fswab64(x))
#endif
diff --git a/lib/libc/include/any-linux-any/linux/sysctl.h b/lib/libc/include/any-linux-any/linux/sysctl.h
index 90792c94fb..435b96354d 100644
--- a/lib/libc/include/any-linux-any/linux/sysctl.h
+++ b/lib/libc/include/any-linux-any/linux/sysctl.h
@@ -584,24 +584,25 @@ enum {
/* /proc/sys/net/<protocol>/neigh/<dev> */
enum {
- NET_NEIGH_MCAST_SOLICIT=1,
- NET_NEIGH_UCAST_SOLICIT=2,
- NET_NEIGH_APP_SOLICIT=3,
- NET_NEIGH_RETRANS_TIME=4,
- NET_NEIGH_REACHABLE_TIME=5,
- NET_NEIGH_DELAY_PROBE_TIME=6,
- NET_NEIGH_GC_STALE_TIME=7,
- NET_NEIGH_UNRES_QLEN=8,
- NET_NEIGH_PROXY_QLEN=9,
- NET_NEIGH_ANYCAST_DELAY=10,
- NET_NEIGH_PROXY_DELAY=11,
- NET_NEIGH_LOCKTIME=12,
- NET_NEIGH_GC_INTERVAL=13,
- NET_NEIGH_GC_THRESH1=14,
- NET_NEIGH_GC_THRESH2=15,
- NET_NEIGH_GC_THRESH3=16,
- NET_NEIGH_RETRANS_TIME_MS=17,
- NET_NEIGH_REACHABLE_TIME_MS=18,
+ NET_NEIGH_MCAST_SOLICIT = 1,
+ NET_NEIGH_UCAST_SOLICIT = 2,
+ NET_NEIGH_APP_SOLICIT = 3,
+ NET_NEIGH_RETRANS_TIME = 4,
+ NET_NEIGH_REACHABLE_TIME = 5,
+ NET_NEIGH_DELAY_PROBE_TIME = 6,
+ NET_NEIGH_GC_STALE_TIME = 7,
+ NET_NEIGH_UNRES_QLEN = 8,
+ NET_NEIGH_PROXY_QLEN = 9,
+ NET_NEIGH_ANYCAST_DELAY = 10,
+ NET_NEIGH_PROXY_DELAY = 11,
+ NET_NEIGH_LOCKTIME = 12,
+ NET_NEIGH_GC_INTERVAL = 13,
+ NET_NEIGH_GC_THRESH1 = 14,
+ NET_NEIGH_GC_THRESH2 = 15,
+ NET_NEIGH_GC_THRESH3 = 16,
+ NET_NEIGH_RETRANS_TIME_MS = 17,
+ NET_NEIGH_REACHABLE_TIME_MS = 18,
+ NET_NEIGH_INTERVAL_PROBE_TIME_MS = 19,
};
/* /proc/sys/net/dccp */
diff --git a/lib/libc/include/any-linux-any/linux/target_core_user.h b/lib/libc/include/any-linux-any/linux/target_core_user.h
index f4fde38b60..b4d909dd91 100644
--- a/lib/libc/include/any-linux-any/linux/target_core_user.h
+++ b/lib/libc/include/any-linux-any/linux/target_core_user.h
@@ -152,7 +152,7 @@ struct tcmu_tmr_entry {
__u32 cmd_cnt;
__u64 __pad3;
__u64 __pad4;
- __u16 cmd_ids[0];
+ __u16 cmd_ids[];
} __attribute__((packed));
#define TCMU_OP_ALIGN_SIZE sizeof(__u64)
diff --git a/lib/libc/include/any-linux-any/linux/taskstats.h b/lib/libc/include/any-linux-any/linux/taskstats.h
index 66b35d0321..36d19221b1 100644
--- a/lib/libc/include/any-linux-any/linux/taskstats.h
+++ b/lib/libc/include/any-linux-any/linux/taskstats.h
@@ -34,7 +34,7 @@
*/
-#define TASKSTATS_VERSION 10
+#define TASKSTATS_VERSION 13
#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
* in linux/sched.h */
@@ -48,7 +48,8 @@ struct taskstats {
__u32 ac_exitcode; /* Exit status */
/* The accounting flags of a task as defined in <linux/acct.h>
- * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG.
+ * Defined values are AFORK, ASU, ACOMPAT, ACORE, AXSIG, and AGROUP.
+ * (AGROUP since version 12).
*/
__u8 ac_flag; /* Record flags */
__u8 ac_nice; /* task_nice */
@@ -172,6 +173,31 @@ struct taskstats {
/* v10: 64-bit btime to avoid overflow */
__u64 ac_btime64; /* 64-bit begin time */
+
+ /* v11: Delay waiting for memory compact */
+ __u64 compact_count;
+ __u64 compact_delay_total;
+
+ /* v12 begin */
+ __u32 ac_tgid; /* thread group ID */
+ /* Thread group walltime up to now. This is total process walltime if
+ * AGROUP flag is set.
+ */
+ __u64 ac_tgetime __attribute__((aligned(8)));
+ /* Lightweight information to identify process binary files.
+ * This leaves userspace to match this to a file system path, using
+ * MAJOR() and MINOR() macros to identify a device and mount point,
+ * the inode to identify the executable file. This is /proc/self/exe
+ * at the end, so matching the most recent exec(). Values are zero
+ * for kernel threads.
+ */
+ __u64 ac_exe_dev; /* program binary device ID */
+ __u64 ac_exe_inode; /* program binary inode number */
+ /* v12 end */
+
+ /* v13: Delay waiting for write-protect copy */
+ __u64 wpcopy_count;
+ __u64 wpcopy_delay_total;
};
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_bpf.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_bpf.h
index 186fee5eee..650c37b224 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_bpf.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_bpf.h
@@ -1,11 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
*/
#ifndef __LINUX_TC_BPF_H
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_ct.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_ct.h
index 9836e96863..f19e961f03 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_ct.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_ct.h
@@ -22,6 +22,9 @@ enum {
TCA_CT_NAT_PORT_MIN, /* be16 */
TCA_CT_NAT_PORT_MAX, /* be16 */
TCA_CT_PAD,
+ TCA_CT_HELPER_NAME, /* string */
+ TCA_CT_HELPER_FAMILY, /* u8 */
+ TCA_CT_HELPER_PROTO, /* u8 */
__TCA_CT_MAX
};
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_skbedit.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_skbedit.h
index ca058d8fbf..521ebd3bd1 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_skbedit.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_skbedit.h
@@ -2,19 +2,6 @@
/*
* Copyright (c) 2008, Intel Corporation.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- *
* Author: Alexander Duyck <alexander.h.duyck@intel.com>
*/
@@ -29,6 +16,7 @@
#define SKBEDIT_F_PTYPE 0x8
#define SKBEDIT_F_MASK 0x10
#define SKBEDIT_F_INHERITDSFIELD 0x20
+#define SKBEDIT_F_TXQ_SKBHASH 0x40
struct tc_skbedit {
tc_gen;
@@ -45,6 +33,7 @@ enum {
TCA_SKBEDIT_PTYPE,
TCA_SKBEDIT_MASK,
TCA_SKBEDIT_FLAGS,
+ TCA_SKBEDIT_QUEUE_MAPPING_MAX,
__TCA_SKBEDIT_MAX
};
#define TCA_SKBEDIT_MAX (__TCA_SKBEDIT_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_skbmod.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_skbmod.h
index 8d64b4728f..db7788f094 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_skbmod.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_skbmod.h
@@ -1,12 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Copyright (c) 2016, Jamal Hadi Salim
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-*/
+ */
#ifndef __LINUX_TC_SKBMOD_H
#define __LINUX_TC_SKBMOD_H
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_tunnel_key.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_tunnel_key.h
index f8ddd04b7b..3f1d68f9cf 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_tunnel_key.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_tunnel_key.h
@@ -2,11 +2,6 @@
/*
* Copyright (c) 2016, Amir Vadai <amir@vadai.me>
* Copyright (c) 2016, Mellanox Technologies. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
*/
#ifndef __LINUX_TC_TUNNEL_KEY_H
diff --git a/lib/libc/include/any-linux-any/linux/tc_act/tc_vlan.h b/lib/libc/include/any-linux-any/linux/tc_act/tc_vlan.h
index ec12a54aa8..3322e82347 100644
--- a/lib/libc/include/any-linux-any/linux/tc_act/tc_vlan.h
+++ b/lib/libc/include/any-linux-any/linux/tc_act/tc_vlan.h
@@ -1,11 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
*/
#ifndef __LINUX_TC_VLAN_H
diff --git a/lib/libc/include/any-linux-any/linux/tcp.h b/lib/libc/include/any-linux-any/linux/tcp.h
index c669f7a648..a29b18c8a2 100644
--- a/lib/libc/include/any-linux-any/linux/tcp.h
+++ b/lib/libc/include/any-linux-any/linux/tcp.h
@@ -284,6 +284,11 @@ struct tcp_info {
__u32 tcpi_snd_wnd; /* peer's advertised receive window after
* scaling (bytes)
*/
+ __u32 tcpi_rcv_wnd; /* local advertised receive window after
+ * scaling (bytes)
+ */
+
+ __u32 tcpi_rehash; /* PLB or timeout triggered rehash attempts */
};
/* netlink attributes types for SCM_TIMESTAMPING_OPT_STATS */
@@ -315,6 +320,7 @@ enum {
TCP_NLA_BYTES_NOTSENT, /* Bytes in write queue not yet sent */
TCP_NLA_EDT, /* Earliest departure time (CLOCK_MONOTONIC) */
TCP_NLA_TTL, /* TTL or hop limit of a packet received */
+ TCP_NLA_REHASH, /* PLB and timeout triggered rehash attempts */
};
/* for TCP_MD5SIG socket option */
diff --git a/lib/libc/include/any-linux-any/linux/tdx-guest.h b/lib/libc/include/any-linux-any/linux/tdx-guest.h
new file mode 100644
index 0000000000..726bbe86fc
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/tdx-guest.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Userspace interface for TDX guest driver
+ *
+ * Copyright (C) 2022 Intel Corporation
+ */
+
+#ifndef _LINUX_TDX_GUEST_H_
+#define _LINUX_TDX_GUEST_H_
+
+#include <linux/ioctl.h>
+#include <linux/types.h>
+
+/* Length of the REPORTDATA used in TDG.MR.REPORT TDCALL */
+#define TDX_REPORTDATA_LEN 64
+
+/* Length of TDREPORT used in TDG.MR.REPORT TDCALL */
+#define TDX_REPORT_LEN 1024
+
+/**
+ * struct tdx_report_req - Request struct for TDX_CMD_GET_REPORT0 IOCTL.
+ *
+ * @reportdata: User buffer with REPORTDATA to be included into TDREPORT.
+ * Typically it can be some nonce provided by attestation
+ * service, so the generated TDREPORT can be uniquely verified.
+ * @tdreport: User buffer to store TDREPORT output from TDCALL[TDG.MR.REPORT].
+ */
+struct tdx_report_req {
+ __u8 reportdata[TDX_REPORTDATA_LEN];
+ __u8 tdreport[TDX_REPORT_LEN];
+};
+
+/*
+ * TDX_CMD_GET_REPORT0 - Get TDREPORT0 (a.k.a. TDREPORT subtype 0) using
+ * TDCALL[TDG.MR.REPORT]
+ *
+ * Return 0 on success, -EIO on TDCALL execution failure, and
+ * standard errno on other general error cases.
+ */
+#define TDX_CMD_GET_REPORT0 _IOWR('T', 1, struct tdx_report_req)
+
+#endif /* _LINUX_TDX_GUEST_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/tee.h b/lib/libc/include/any-linux-any/linux/tee.h
index e825d83cdf..230b177d0f 100644
--- a/lib/libc/include/any-linux-any/linux/tee.h
+++ b/lib/libc/include/any-linux-any/linux/tee.h
@@ -42,10 +42,6 @@
#define TEE_IOC_MAGIC 0xa4
#define TEE_IOC_BASE 0
-/* Flags relating to shared memory */
-#define TEE_IOCTL_SHM_MAPPED 0x1 /* memory mapped in normal world */
-#define TEE_IOCTL_SHM_DMA_BUF 0x2 /* dma-buf handle on shared memory */
-
#define TEE_MAX_ARG_SIZE 1024
#define TEE_GEN_CAP_GP (1 << 0)/* GlobalPlatform compliant TEE */
diff --git a/lib/libc/include/any-linux-any/linux/thermal.h b/lib/libc/include/any-linux-any/linux/thermal.h
index 35162dfc22..68eeaf16b7 100644
--- a/lib/libc/include/any-linux-any/linux/thermal.h
+++ b/lib/libc/include/any-linux-any/linux/thermal.h
@@ -44,7 +44,10 @@ enum thermal_genl_attr {
THERMAL_GENL_ATTR_CDEV_MAX_STATE,
THERMAL_GENL_ATTR_CDEV_NAME,
THERMAL_GENL_ATTR_GOV_NAME,
-
+ THERMAL_GENL_ATTR_CPU_CAPABILITY,
+ THERMAL_GENL_ATTR_CPU_CAPABILITY_ID,
+ THERMAL_GENL_ATTR_CPU_CAPABILITY_PERFORMANCE,
+ THERMAL_GENL_ATTR_CPU_CAPABILITY_EFFICIENCY,
__THERMAL_GENL_ATTR_MAX,
};
#define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1)
@@ -71,6 +74,7 @@ enum thermal_genl_event {
THERMAL_GENL_EVENT_CDEV_DELETE, /* Cdev unbound */
THERMAL_GENL_EVENT_CDEV_STATE_UPDATE, /* Cdev state updated */
THERMAL_GENL_EVENT_TZ_GOV_CHANGE, /* Governor policy changed */
+ THERMAL_GENL_EVENT_CPU_CAPABILITY_CHANGE, /* CPU capability changed */
__THERMAL_GENL_EVENT_MAX,
};
#define THERMAL_GENL_EVENT_MAX (__THERMAL_GENL_EVENT_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/tipc_config.h b/lib/libc/include/any-linux-any/linux/tipc_config.h
index 527fbea35a..bfd44757c5 100644
--- a/lib/libc/include/any-linux-any/linux/tipc_config.h
+++ b/lib/libc/include/any-linux-any/linux/tipc_config.h
@@ -43,8 +43,6 @@
#include <linux/tipc.h>
#include <asm/byteorder.h>
-#include <arpa/inet.h> /* for ntohs etc. */
-
/*
* Configuration
*
@@ -267,33 +265,33 @@ static __inline__ int TLV_OK(const void *tlv, __u16 space)
*/
return (space >= TLV_SPACE(0)) &&
- (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space);
+ (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_len) <= space);
}
static __inline__ int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type)
{
return TLV_OK(tlv, space) &&
- (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
+ (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_type) == exp_type);
}
static __inline__ int TLV_GET_LEN(struct tlv_desc *tlv)
{
- return ntohs(tlv->tlv_len);
+ return __be16_to_cpu(tlv->tlv_len);
}
static __inline__ void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len)
{
- tlv->tlv_len = htons(len);
+ tlv->tlv_len = __cpu_to_be16(len);
}
static __inline__ int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type)
{
- return (ntohs(tlv->tlv_type) == type);
+ return (__be16_to_cpu(tlv->tlv_type) == type);
}
static __inline__ void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type)
{
- tlv->tlv_type = htons(type);
+ tlv->tlv_type = __cpu_to_be16(type);
}
static __inline__ int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
@@ -303,8 +301,8 @@ static __inline__ int TLV_SET(void *tlv, __u16 type, void *data, __u16 len)
tlv_len = TLV_LENGTH(len);
tlv_ptr = (struct tlv_desc *)tlv;
- tlv_ptr->tlv_type = htons(type);
- tlv_ptr->tlv_len = htons(tlv_len);
+ tlv_ptr->tlv_type = __cpu_to_be16(type);
+ tlv_ptr->tlv_len = __cpu_to_be16(tlv_len);
if (len && data) {
memcpy(TLV_DATA(tlv_ptr), data, len);
memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len);
@@ -346,7 +344,7 @@ static __inline__ void *TLV_LIST_DATA(struct tlv_list_desc *list)
static __inline__ void TLV_LIST_STEP(struct tlv_list_desc *list)
{
- __u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len));
+ __u16 tlv_space = TLV_ALIGN(__be16_to_cpu(list->tlv_ptr->tlv_len));
list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space);
list->tlv_space -= tlv_space;
@@ -402,9 +400,9 @@ static __inline__ int TCM_SET(void *msg, __u16 cmd, __u16 flags,
msg_len = TCM_LENGTH(data_len);
tcm_hdr = (struct tipc_cfg_msg_hdr *)msg;
- tcm_hdr->tcm_len = htonl(msg_len);
- tcm_hdr->tcm_type = htons(cmd);
- tcm_hdr->tcm_flags = htons(flags);
+ tcm_hdr->tcm_len = __cpu_to_be32(msg_len);
+ tcm_hdr->tcm_type = __cpu_to_be16(cmd);
+ tcm_hdr->tcm_flags = __cpu_to_be16(flags);
if (data_len && data) {
memcpy(TCM_DATA(msg), data, data_len);
memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len);
diff --git a/lib/libc/include/any-linux-any/linux/tls.h b/lib/libc/include/any-linux-any/linux/tls.h
index 8f5ee6c7d6..34431c8acd 100644
--- a/lib/libc/include/any-linux-any/linux/tls.h
+++ b/lib/libc/include/any-linux-any/linux/tls.h
@@ -39,6 +39,8 @@
/* TLS socket options */
#define TLS_TX 1 /* Set transmit parameters */
#define TLS_RX 2 /* Set receive parameters */
+#define TLS_TX_ZEROCOPY_RO 3 /* TX zerocopy (only sendfile now) */
+#define TLS_RX_EXPECT_NO_PAD 4 /* Attempt opportunistic zero-copy */
/* Supported versions */
#define TLS_VERSION_MINOR(ver) ((ver) & 0xFF)
@@ -98,6 +100,20 @@
#define TLS_CIPHER_SM4_CCM_TAG_SIZE 16
#define TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_128 57
+#define TLS_CIPHER_ARIA_GCM_128_IV_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_128_KEY_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_128_SALT_SIZE 4
+#define TLS_CIPHER_ARIA_GCM_128_TAG_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE 8
+
+#define TLS_CIPHER_ARIA_GCM_256 58
+#define TLS_CIPHER_ARIA_GCM_256_IV_SIZE 8
+#define TLS_CIPHER_ARIA_GCM_256_KEY_SIZE 32
+#define TLS_CIPHER_ARIA_GCM_256_SALT_SIZE 4
+#define TLS_CIPHER_ARIA_GCM_256_TAG_SIZE 16
+#define TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE 8
+
#define TLS_SET_RECORD_TYPE 1
#define TLS_GET_RECORD_TYPE 2
@@ -154,12 +170,30 @@ struct tls12_crypto_info_sm4_ccm {
unsigned char rec_seq[TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE];
};
+struct tls12_crypto_info_aria_gcm_128 {
+ struct tls_crypto_info info;
+ unsigned char iv[TLS_CIPHER_ARIA_GCM_128_IV_SIZE];
+ unsigned char key[TLS_CIPHER_ARIA_GCM_128_KEY_SIZE];
+ unsigned char salt[TLS_CIPHER_ARIA_GCM_128_SALT_SIZE];
+ unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE];
+};
+
+struct tls12_crypto_info_aria_gcm_256 {
+ struct tls_crypto_info info;
+ unsigned char iv[TLS_CIPHER_ARIA_GCM_256_IV_SIZE];
+ unsigned char key[TLS_CIPHER_ARIA_GCM_256_KEY_SIZE];
+ unsigned char salt[TLS_CIPHER_ARIA_GCM_256_SALT_SIZE];
+ unsigned char rec_seq[TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE];
+};
+
enum {
TLS_INFO_UNSPEC,
TLS_INFO_VERSION,
TLS_INFO_CIPHER,
TLS_INFO_TXCONF,
TLS_INFO_RXCONF,
+ TLS_INFO_ZC_RO_TX,
+ TLS_INFO_RX_NO_PAD,
__TLS_INFO_MAX,
};
#define TLS_INFO_MAX (__TLS_INFO_MAX - 1)
diff --git a/lib/libc/include/any-linux-any/linux/tty.h b/lib/libc/include/any-linux-any/linux/tty.h
index ab1f3ad563..799fb4bad7 100644
--- a/lib/libc/include/any-linux-any/linux/tty.h
+++ b/lib/libc/include/any-linux-any/linux/tty.h
@@ -6,8 +6,6 @@
* 'tty.h' defines some structures used by tty_io.c and some defines.
*/
-#define NR_LDISCS 30
-
/* line disciplines */
#define N_TTY 0
#define N_SLIP 1
@@ -38,5 +36,11 @@
#define N_NCI 25 /* NFC NCI UART */
#define N_SPEAKUP 26 /* Speakup communication with synths */
#define N_NULL 27 /* Null ldisc used for error handling */
+#define N_MCTP 28 /* MCTP-over-serial */
+#define N_DEVELOPMENT 29 /* Manual out-of-tree testing */
+#define N_CAN327 30 /* ELM327 based OBD-II interfaces */
+
+/* Always the newest line discipline + 1 */
+#define NR_LDISCS 31
#endif /* _LINUX_TTY_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/types.h b/lib/libc/include/any-linux-any/linux/types.h
index c1fa1c9d61..6b6130a6d7 100644
--- a/lib/libc/include/any-linux-any/linux/types.h
+++ b/lib/libc/include/any-linux-any/linux/types.h
@@ -14,12 +14,15 @@
* any application/library that wants linux/types.h.
*/
+/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
#ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise __attribute__((bitwise))
#else
-#define __bitwise__
+#define __bitwise
#endif
-#define __bitwise __bitwise__
+
+/* The kernel doesn't use this legacy form, but user space does */
+#define __bitwise__ __bitwise
typedef __u16 __bitwise __le16;
typedef __u16 __bitwise __be16;
diff --git a/lib/libc/include/any-linux-any/linux/ublk_cmd.h b/lib/libc/include/any-linux-any/linux/ublk_cmd.h
new file mode 100644
index 0000000000..4903fb9455
--- /dev/null
+++ b/lib/libc/include/any-linux-any/linux/ublk_cmd.h
@@ -0,0 +1,278 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef USER_BLK_DRV_CMD_INC_H
+#define USER_BLK_DRV_CMD_INC_H
+
+#include <linux/types.h>
+
+/* ublk server command definition */
+
+/*
+ * Admin commands, issued by ublk server, and handled by ublk driver.
+ */
+#define UBLK_CMD_GET_QUEUE_AFFINITY 0x01
+#define UBLK_CMD_GET_DEV_INFO 0x02
+#define UBLK_CMD_ADD_DEV 0x04
+#define UBLK_CMD_DEL_DEV 0x05
+#define UBLK_CMD_START_DEV 0x06
+#define UBLK_CMD_STOP_DEV 0x07
+#define UBLK_CMD_SET_PARAMS 0x08
+#define UBLK_CMD_GET_PARAMS 0x09
+#define UBLK_CMD_START_USER_RECOVERY 0x10
+#define UBLK_CMD_END_USER_RECOVERY 0x11
+#define UBLK_CMD_GET_DEV_INFO2 0x12
+
+/*
+ * IO commands, issued by ublk server, and handled by ublk driver.
+ *
+ * FETCH_REQ: issued via sqe(URING_CMD) beforehand for fetching IO request
+ * from ublk driver, should be issued only when starting device. After
+ * the associated cqe is returned, request's tag can be retrieved via
+ * cqe->userdata.
+ *
+ * COMMIT_AND_FETCH_REQ: issued via sqe(URING_CMD) after ublkserver handled
+ * this IO request, request's handling result is committed to ublk
+ * driver, meantime FETCH_REQ is piggyback, and FETCH_REQ has to be
+ * handled before completing io request.
+ *
+ * NEED_GET_DATA: only used for write requests to set io addr and copy data
+ * When NEED_GET_DATA is set, ublksrv has to issue UBLK_IO_NEED_GET_DATA
+ * command after ublk driver returns UBLK_IO_RES_NEED_GET_DATA.
+ *
+ * It is only used if ublksrv set UBLK_F_NEED_GET_DATA flag
+ * while starting a ublk device.
+ */
+#define UBLK_IO_FETCH_REQ 0x20
+#define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
+#define UBLK_IO_NEED_GET_DATA 0x22
+
+/* only ABORT means that no re-fetch */
+#define UBLK_IO_RES_OK 0
+#define UBLK_IO_RES_NEED_GET_DATA 1
+#define UBLK_IO_RES_ABORT (-ENODEV)
+
+#define UBLKSRV_CMD_BUF_OFFSET 0
+#define UBLKSRV_IO_BUF_OFFSET 0x80000000
+
+/* tag bit is 12bit, so at most 4096 IOs for each queue */
+#define UBLK_MAX_QUEUE_DEPTH 4096
+
+/*
+ * zero copy requires 4k block size, and can remap ublk driver's io
+ * request into ublksrv's vm space
+ */
+#define UBLK_F_SUPPORT_ZERO_COPY (1ULL << 0)
+
+/*
+ * Force to complete io cmd via io_uring_cmd_complete_in_task so that
+ * performance comparison is done easily with using task_work_add
+ */
+#define UBLK_F_URING_CMD_COMP_IN_TASK (1ULL << 1)
+
+/*
+ * User should issue io cmd again for write requests to
+ * set io buffer address and copy data from bio vectors
+ * to the userspace io buffer.
+ *
+ * In this mode, task_work is not used.
+ */
+#define UBLK_F_NEED_GET_DATA (1UL << 2)
+
+#define UBLK_F_USER_RECOVERY (1UL << 3)
+
+#define UBLK_F_USER_RECOVERY_REISSUE (1UL << 4)
+
+/*
+ * Unprivileged user can create /dev/ublkcN and /dev/ublkbN.
+ *
+ * /dev/ublk-control needs to be available for unprivileged user, and it
+ * can be done via udev rule to make all control commands available to
+ * unprivileged user. Except for the command of UBLK_CMD_ADD_DEV, all
+ * other commands are only allowed for the owner of the specified device.
+ *
+ * When userspace sends UBLK_CMD_ADD_DEV, the device pair's owner_uid and
+ * owner_gid are stored to ublksrv_ctrl_dev_info by kernel, so far only
+ * the current user's uid/gid is stored, that said owner of the created
+ * device is always the current user.
+ *
+ * We still need udev rule to apply OWNER/GROUP with the stored owner_uid
+ * and owner_gid.
+ *
+ * Then ublk server can be run as unprivileged user, and /dev/ublkbN can
+ * be accessed and managed by its owner represented by owner_uid/owner_gid.
+ */
+#define UBLK_F_UNPRIVILEGED_DEV (1UL << 5)
+
+/* device state */
+#define UBLK_S_DEV_DEAD 0
+#define UBLK_S_DEV_LIVE 1
+#define UBLK_S_DEV_QUIESCED 2
+
+/* shipped via sqe->cmd of io_uring command */
+struct ublksrv_ctrl_cmd {
+ /* sent to which device, must be valid */
+ __u32 dev_id;
+
+ /* sent to which queue, must be -1 if the cmd isn't for queue */
+ __u16 queue_id;
+ /*
+ * cmd specific buffer, can be IN or OUT.
+ */
+ __u16 len;
+ __u64 addr;
+
+ /* __inline__ data */
+ __u64 data[1];
+
+ /*
+ * Used for UBLK_F_UNPRIVILEGED_DEV and UBLK_CMD_GET_DEV_INFO2
+ * only, include null char
+ */
+ __u16 dev_path_len;
+ __u16 pad;
+ __u32 reserved;
+};
+
+struct ublksrv_ctrl_dev_info {
+ __u16 nr_hw_queues;
+ __u16 queue_depth;
+ __u16 state;
+ __u16 pad0;
+
+ __u32 max_io_buf_bytes;
+ __u32 dev_id;
+
+ __s32 ublksrv_pid;
+ __u32 pad1;
+
+ __u64 flags;
+
+ /* For ublksrv internal use, invisible to ublk driver */
+ __u64 ublksrv_flags;
+
+ __u32 owner_uid; /* store by kernel */
+ __u32 owner_gid; /* store by kernel */
+ __u64 reserved1;
+ __u64 reserved2;
+};
+
+#define UBLK_IO_OP_READ 0
+#define UBLK_IO_OP_WRITE 1
+#define UBLK_IO_OP_FLUSH 2
+#define UBLK_IO_OP_DISCARD 3
+#define UBLK_IO_OP_WRITE_SAME 4
+#define UBLK_IO_OP_WRITE_ZEROES 5
+
+#define UBLK_IO_F_FAILFAST_DEV (1U << 8)
+#define UBLK_IO_F_FAILFAST_TRANSPORT (1U << 9)
+#define UBLK_IO_F_FAILFAST_DRIVER (1U << 10)
+#define UBLK_IO_F_META (1U << 11)
+#define UBLK_IO_F_FUA (1U << 13)
+#define UBLK_IO_F_NOUNMAP (1U << 15)
+#define UBLK_IO_F_SWAP (1U << 16)
+
+/*
+ * io cmd is described by this structure, and stored in share memory, indexed
+ * by request tag.
+ *
+ * The data is stored by ublk driver, and read by ublksrv after one fetch command
+ * returns.
+ */
+struct ublksrv_io_desc {
+ /* op: bit 0-7, flags: bit 8-31 */
+ __u32 op_flags;
+
+ __u32 nr_sectors;
+
+ /* start sector for this io */
+ __u64 start_sector;
+
+ /* buffer address in ublksrv daemon vm space, from ublk driver */
+ __u64 addr;
+};
+
+static __inline__ __u8 ublksrv_get_op(const struct ublksrv_io_desc *iod)
+{
+ return iod->op_flags & 0xff;
+}
+
+static __inline__ __u32 ublksrv_get_flags(const struct ublksrv_io_desc *iod)
+{
+ return iod->op_flags >> 8;
+}
+
+/* issued to ublk driver via /dev/ublkcN */
+struct ublksrv_io_cmd {
+ __u16 q_id;
+
+ /* for fetch/commit which result */
+ __u16 tag;
+
+ /* io result, it is valid for COMMIT* command only */
+ __s32 result;
+
+ /*
+ * userspace buffer address in ublksrv daemon process, valid for
+ * FETCH* command only
+ */
+ __u64 addr;
+};
+
+struct ublk_param_basic {
+#define UBLK_ATTR_READ_ONLY (1 << 0)
+#define UBLK_ATTR_ROTATIONAL (1 << 1)
+#define UBLK_ATTR_VOLATILE_CACHE (1 << 2)
+#define UBLK_ATTR_FUA (1 << 3)
+ __u32 attrs;
+ __u8 logical_bs_shift;
+ __u8 physical_bs_shift;
+ __u8 io_opt_shift;
+ __u8 io_min_shift;
+
+ __u32 max_sectors;
+ __u32 chunk_sectors;
+
+ __u64 dev_sectors;
+ __u64 virt_boundary_mask;
+};
+
+struct ublk_param_discard {
+ __u32 discard_alignment;
+
+ __u32 discard_granularity;
+ __u32 max_discard_sectors;
+
+ __u32 max_write_zeroes_sectors;
+ __u16 max_discard_segments;
+ __u16 reserved0;
+};
+
+/*
+ * read-only, can't set via UBLK_CMD_SET_PARAMS, disk_devt is available
+ * after device is started
+ */
+struct ublk_param_devt {
+ __u32 char_major;
+ __u32 char_minor;
+ __u32 disk_major;
+ __u32 disk_minor;
+};
+
+struct ublk_params {
+ /*
+ * Total length of parameters, userspace has to set 'len' for both
+ * SET_PARAMS and GET_PARAMS command, and driver may update len
+ * if two sides use different version of 'ublk_params', same with
+ * 'types' fields.
+ */
+ __u32 len;
+#define UBLK_PARAM_TYPE_BASIC (1 << 0)
+#define UBLK_PARAM_TYPE_DISCARD (1 << 1)
+#define UBLK_PARAM_TYPE_DEVT (1 << 2)
+ __u32 types; /* types of parameter included */
+
+ struct ublk_param_basic basic;
+ struct ublk_param_discard discard;
+ struct ublk_param_devt devt;
+};
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/usb/audio.h b/lib/libc/include/any-linux-any/linux/usb/audio.h
index ab0573ae6c..229aeaad67 100644
--- a/lib/libc/include/any-linux-any/linux/usb/audio.h
+++ b/lib/libc/include/any-linux-any/linux/usb/audio.h
@@ -341,7 +341,7 @@ struct uac_feature_unit_descriptor {
__u8 bUnitID;
__u8 bSourceID;
__u8 bControlSize;
- __u8 bmaControls[0]; /* variable length */
+ __u8 bmaControls[]; /* variable length */
} __attribute__((packed));
static __inline__ __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
diff --git a/lib/libc/include/any-linux-any/linux/usb/cdc.h b/lib/libc/include/any-linux-any/linux/usb/cdc.h
index 10b4c0a4e8..9d896d4fd5 100644
--- a/lib/libc/include/any-linux-any/linux/usb/cdc.h
+++ b/lib/libc/include/any-linux-any/linux/usb/cdc.h
@@ -171,7 +171,7 @@ struct usb_cdc_mdlm_detail_desc {
/* type is associated with mdlm_desc.bGUID */
__u8 bGuidDescriptorType;
- __u8 bDetailData[0];
+ __u8 bDetailData[];
} __attribute__ ((packed));
/* "OBEX Control Model Functional Descriptor" */
@@ -271,6 +271,10 @@ struct usb_cdc_line_coding {
__u8 bDataBits;
} __attribute__ ((packed));
+/* Control Signal Bitmap Values from 6.2.14 SetControlLineState */
+#define USB_CDC_CTRL_DTR (1 << 0)
+#define USB_CDC_CTRL_RTS (1 << 1)
+
/* table 62; bits in multicast filter */
#define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
#define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
@@ -302,6 +306,15 @@ struct usb_cdc_notification {
__le16 wLength;
} __attribute__ ((packed));
+/* UART State Bitmap Values from 6.3.5 SerialState */
+#define USB_CDC_SERIAL_STATE_DCD (1 << 0)
+#define USB_CDC_SERIAL_STATE_DSR (1 << 1)
+#define USB_CDC_SERIAL_STATE_BREAK (1 << 2)
+#define USB_CDC_SERIAL_STATE_RING_SIGNAL (1 << 3)
+#define USB_CDC_SERIAL_STATE_FRAMING (1 << 4)
+#define USB_CDC_SERIAL_STATE_PARITY (1 << 5)
+#define USB_CDC_SERIAL_STATE_OVERRUN (1 << 6)
+
struct usb_cdc_speed_change {
__le32 DLBitRRate; /* contains the downlink bit rate (IN pipe) */
__le32 ULBitRate; /* contains the uplink bit rate (OUT pipe) */
@@ -379,7 +392,7 @@ struct usb_cdc_ncm_ndp16 {
__le32 dwSignature;
__le16 wLength;
__le16 wNextNdpIndex;
- struct usb_cdc_ncm_dpe16 dpe16[0];
+ struct usb_cdc_ncm_dpe16 dpe16[];
} __attribute__ ((packed));
/* 32-bit NCM Datagram Pointer Entry */
@@ -395,7 +408,7 @@ struct usb_cdc_ncm_ndp32 {
__le16 wReserved6;
__le32 dwNextNdpIndex;
__le32 dwReserved12;
- struct usb_cdc_ncm_dpe32 dpe32[0];
+ struct usb_cdc_ncm_dpe32 dpe32[];
} __attribute__ ((packed));
/* CDC NCM subclass 3.2.1 and 3.2.2 */
diff --git a/lib/libc/include/any-linux-any/linux/usb/ch9.h b/lib/libc/include/any-linux-any/linux/usb/ch9.h
index 06d506abcd..3eb25178a0 100644
--- a/lib/libc/include/any-linux-any/linux/usb/ch9.h
+++ b/lib/libc/include/any-linux-any/linux/usb/ch9.h
@@ -818,7 +818,7 @@ struct usb_key_descriptor {
__u8 tTKID[3];
__u8 bReserved;
- __u8 bKeyData[0];
+ __u8 bKeyData[];
} __attribute__((packed));
/*-------------------------------------------------------------------------*/
@@ -948,6 +948,22 @@ struct usb_ss_container_id_descriptor {
#define USB_DT_USB_SS_CONTN_ID_SIZE 20
/*
+ * Platform Device Capability descriptor: Defines platform specific device
+ * capabilities
+ */
+#define USB_PLAT_DEV_CAP_TYPE 5
+struct usb_plat_dev_cap_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+ __u8 bDevCapabilityType;
+ __u8 bReserved;
+ __u8 UUID[16];
+ __u8 CapabilityData[];
+} __attribute__((packed));
+
+#define USB_DT_USB_PLAT_DEV_CAP_SIZE(capability_data_size) (20 + capability_data_size)
+
+/*
* SuperSpeed Plus USB Capability descriptor: Defines the set of
* SuperSpeed Plus USB specific device level capabilities
*/
diff --git a/lib/libc/include/any-linux-any/linux/usb/g_uvc.h b/lib/libc/include/any-linux-any/linux/usb/g_uvc.h
index 8bd4b7392f..611274ee04 100644
--- a/lib/libc/include/any-linux-any/linux/usb/g_uvc.h
+++ b/lib/libc/include/any-linux-any/linux/usb/g_uvc.h
@@ -21,6 +21,9 @@
#define UVC_EVENT_DATA (V4L2_EVENT_PRIVATE_START + 5)
#define UVC_EVENT_LAST (V4L2_EVENT_PRIVATE_START + 5)
+#define UVC_STRING_CONTROL_IDX 0
+#define UVC_STRING_STREAMING_IDX 1
+
struct uvc_request_data {
__s32 length;
__u8 data[60];
diff --git a/lib/libc/include/any-linux-any/linux/usb/raw_gadget.h b/lib/libc/include/any-linux-any/linux/usb/raw_gadget.h
index 7cfda4e617..506533fdd4 100644
--- a/lib/libc/include/any-linux-any/linux/usb/raw_gadget.h
+++ b/lib/libc/include/any-linux-any/linux/usb/raw_gadget.h
@@ -60,7 +60,7 @@ enum usb_raw_event_type {
struct usb_raw_event {
__u32 type;
__u32 length;
- __u8 data[0];
+ __u8 data[];
};
#define USB_RAW_IO_FLAGS_ZERO 0x0001
@@ -90,7 +90,7 @@ struct usb_raw_ep_io {
__u16 ep;
__u16 flags;
__u32 length;
- __u8 data[0];
+ __u8 data[];
};
/* Maximum number of non-control endpoints in struct usb_raw_eps_info. */
diff --git a/lib/libc/include/any-linux-any/linux/usb/video.h b/lib/libc/include/any-linux-any/linux/usb/video.h
index a364d95343..e7f923d8c1 100644
--- a/lib/libc/include/any-linux-any/linux/usb/video.h
+++ b/lib/libc/include/any-linux-any/linux/usb/video.h
@@ -179,6 +179,36 @@
#define UVC_CONTROL_CAP_AUTOUPDATE (1 << 3)
#define UVC_CONTROL_CAP_ASYNCHRONOUS (1 << 4)
+/* 3.9.2.6 Color Matching Descriptor Values */
+enum uvc_color_primaries_values {
+ UVC_COLOR_PRIMARIES_UNSPECIFIED,
+ UVC_COLOR_PRIMARIES_BT_709_SRGB,
+ UVC_COLOR_PRIMARIES_BT_470_2_M,
+ UVC_COLOR_PRIMARIES_BT_470_2_B_G,
+ UVC_COLOR_PRIMARIES_SMPTE_170M,
+ UVC_COLOR_PRIMARIES_SMPTE_240M,
+};
+
+enum uvc_transfer_characteristics_values {
+ UVC_TRANSFER_CHARACTERISTICS_UNSPECIFIED,
+ UVC_TRANSFER_CHARACTERISTICS_BT_709,
+ UVC_TRANSFER_CHARACTERISTICS_BT_470_2_M,
+ UVC_TRANSFER_CHARACTERISTICS_BT_470_2_B_G,
+ UVC_TRANSFER_CHARACTERISTICS_SMPTE_170M,
+ UVC_TRANSFER_CHARACTERISTICS_SMPTE_240M,
+ UVC_TRANSFER_CHARACTERISTICS_LINEAR,
+ UVC_TRANSFER_CHARACTERISTICS_SRGB,
+};
+
+enum uvc_matrix_coefficients {
+ UVC_MATRIX_COEFFICIENTS_UNSPECIFIED,
+ UVC_MATRIX_COEFFICIENTS_BT_709,
+ UVC_MATRIX_COEFFICIENTS_FCC,
+ UVC_MATRIX_COEFFICIENTS_BT_470_2_B_G,
+ UVC_MATRIX_COEFFICIENTS_SMPTE_170M,
+ UVC_MATRIX_COEFFICIENTS_SMPTE_240M,
+};
+
/* ------------------------------------------------------------------------
* UVC structures
*/
@@ -466,7 +496,7 @@ struct uvc_format_uncompressed {
__u8 bDefaultFrameIndex;
__u8 bAspectRatioX;
__u8 bAspectRatioY;
- __u8 bmInterfaceFlags;
+ __u8 bmInterlaceFlags;
__u8 bCopyProtect;
} __attribute__((__packed__));
@@ -522,7 +552,7 @@ struct uvc_format_mjpeg {
__u8 bDefaultFrameIndex;
__u8 bAspectRatioX;
__u8 bAspectRatioY;
- __u8 bmInterfaceFlags;
+ __u8 bmInterlaceFlags;
__u8 bCopyProtect;
} __attribute__((__packed__));
diff --git a/lib/libc/include/any-linux-any/linux/usbdevice_fs.h b/lib/libc/include/any-linux-any/linux/usbdevice_fs.h
index d7761f894a..d979a17a6a 100644
--- a/lib/libc/include/any-linux-any/linux/usbdevice_fs.h
+++ b/lib/libc/include/any-linux-any/linux/usbdevice_fs.h
@@ -131,7 +131,7 @@ struct usbdevfs_urb {
unsigned int signr; /* signal to be sent on completion,
or 0 if none should be sent. */
void *usercontext;
- struct usbdevfs_iso_packet_desc iso_frame_desc[0];
+ struct usbdevfs_iso_packet_desc iso_frame_desc[];
};
/* ioctls for talking directly to drivers */
@@ -176,7 +176,7 @@ struct usbdevfs_disconnect_claim {
struct usbdevfs_streams {
unsigned int num_streams; /* Not used by USBDEVFS_FREE_STREAMS */
unsigned int num_eps;
- unsigned char eps[0];
+ unsigned char eps[];
};
/*
diff --git a/lib/libc/include/any-linux-any/linux/usbip.h b/lib/libc/include/any-linux-any/linux/usbip.h
index 65227541af..d7cd6ec955 100644
--- a/lib/libc/include/any-linux-any/linux/usbip.h
+++ b/lib/libc/include/any-linux-any/linux/usbip.h
@@ -24,4 +24,30 @@ enum usbip_device_status {
VDEV_ST_USED,
VDEV_ST_ERROR
};
+
+/* USB URB Transfer flags:
+ *
+ * USBIP server and client (vchi) pack URBs in TCP packets. The following
+ * are the transfer type defines used in USBIP protocol.
+ */
+
+#define USBIP_URB_SHORT_NOT_OK 0x0001
+#define USBIP_URB_ISO_ASAP 0x0002
+#define USBIP_URB_NO_TRANSFER_DMA_MAP 0x0004
+#define USBIP_URB_ZERO_PACKET 0x0040
+#define USBIP_URB_NO_INTERRUPT 0x0080
+#define USBIP_URB_FREE_BUFFER 0x0100
+#define USBIP_URB_DIR_IN 0x0200
+#define USBIP_URB_DIR_OUT 0
+#define USBIP_URB_DIR_MASK USBIP_URB_DIR_IN
+
+#define USBIP_URB_DMA_MAP_SINGLE 0x00010000
+#define USBIP_URB_DMA_MAP_PAGE 0x00020000
+#define USBIP_URB_DMA_MAP_SG 0x00040000
+#define USBIP_URB_MAP_LOCAL 0x00080000
+#define USBIP_URB_SETUP_MAP_SINGLE 0x00100000
+#define USBIP_URB_SETUP_MAP_LOCAL 0x00200000
+#define USBIP_URB_DMA_SG_COMBINED 0x00400000
+#define USBIP_URB_ALIGNED_TEMP_BUFFER 0x00800000
+
#endif /* _LINUX_USBIP_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/userfaultfd.h b/lib/libc/include/any-linux-any/linux/userfaultfd.h
index 3ad4dcbfda..185393f31a 100644
--- a/lib/libc/include/any-linux-any/linux/userfaultfd.h
+++ b/lib/libc/include/any-linux-any/linux/userfaultfd.h
@@ -12,6 +12,10 @@
#include <linux/types.h>
+/* ioctls for /dev/userfaultfd */
+#define USERFAULTFD_IOC 0xAA
+#define USERFAULTFD_IOC_NEW _IO(USERFAULTFD_IOC, 0x00)
+
/*
* If the UFFDIO_API is upgraded someday, the UFFDIO_UNREGISTER and
* UFFDIO_WAKE ioctls should be defined as _IOW and not as _IOR. In
@@ -32,7 +36,9 @@
UFFD_FEATURE_SIGBUS | \
UFFD_FEATURE_THREAD_ID | \
UFFD_FEATURE_MINOR_HUGETLBFS | \
- UFFD_FEATURE_MINOR_SHMEM)
+ UFFD_FEATURE_MINOR_SHMEM | \
+ UFFD_FEATURE_EXACT_ADDRESS | \
+ UFFD_FEATURE_WP_HUGETLBFS_SHMEM)
#define UFFD_API_IOCTLS \
((__u64)1 << _UFFDIO_REGISTER | \
(__u64)1 << _UFFDIO_UNREGISTER | \
@@ -46,7 +52,8 @@
#define UFFD_API_RANGE_IOCTLS_BASIC \
((__u64)1 << _UFFDIO_WAKE | \
(__u64)1 << _UFFDIO_COPY | \
- (__u64)1 << _UFFDIO_CONTINUE)
+ (__u64)1 << _UFFDIO_CONTINUE | \
+ (__u64)1 << _UFFDIO_WRITEPROTECT)
/*
* Valid ioctl command number range with this API is from 0x00 to
@@ -189,6 +196,13 @@ struct uffdio_api {
*
* UFFD_FEATURE_MINOR_SHMEM indicates the same support as
* UFFD_FEATURE_MINOR_HUGETLBFS, but for shmem-backed pages instead.
+ *
+ * UFFD_FEATURE_EXACT_ADDRESS indicates that the exact address of page
+ * faults would be provided and the offset within the page would not be
+ * masked.
+ *
+ * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd
+ * write-protection mode is supported on both shmem and hugetlbfs.
*/
#define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0)
#define UFFD_FEATURE_EVENT_FORK (1<<1)
@@ -201,6 +215,8 @@ struct uffdio_api {
#define UFFD_FEATURE_THREAD_ID (1<<8)
#define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9)
#define UFFD_FEATURE_MINOR_SHMEM (1<<10)
+#define UFFD_FEATURE_EXACT_ADDRESS (1<<11)
+#define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1<<12)
__u64 features;
__u64 ioctls;
diff --git a/lib/libc/include/any-linux-any/linux/uuid.h b/lib/libc/include/any-linux-any/linux/uuid.h
index aa5a553af3..02640d2bea 100644
--- a/lib/libc/include/any-linux-any/linux/uuid.h
+++ b/lib/libc/include/any-linux-any/linux/uuid.h
@@ -1,18 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/* DO NOT USE in new code! This is solely for MEI due to legacy reasons */
/*
- * UUID/GUID definition
+ * MEI UUID definition
*
* Copyright (C) 2010, Intel Corp.
* Huang Ying <ying.huang@intel.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License version
- * 2 as published by the Free Software Foundation;
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*/
#ifndef _LINUX_UUID_H_
@@ -22,19 +14,15 @@
typedef struct {
__u8 b[16];
-} guid_t;
+} uuid_le;
-#define GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
-((guid_t) \
+#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
+((uuid_le) \
{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
(b) & 0xff, ((b) >> 8) & 0xff, \
(c) & 0xff, ((c) >> 8) & 0xff, \
(d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
-/* backwards compatibility, don't use in new code */
-typedef guid_t uuid_le;
-#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
- GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
#define NULL_UUID_LE \
UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \
0x00, 0x00, 0x00, 0x00)
diff --git a/lib/libc/include/any-linux-any/linux/uvcvideo.h b/lib/libc/include/any-linux-any/linux/uvcvideo.h
index 353e6e71a2..6e40070909 100644
--- a/lib/libc/include/any-linux-any/linux/uvcvideo.h
+++ b/lib/libc/include/any-linux-any/linux/uvcvideo.h
@@ -36,9 +36,11 @@
UVC_CTRL_FLAG_GET_MAX | UVC_CTRL_FLAG_GET_RES | \
UVC_CTRL_FLAG_GET_DEF)
+#define UVC_MENU_NAME_LEN 32
+
struct uvc_menu_info {
__u32 value;
- __u8 name[32];
+ __u8 name[UVC_MENU_NAME_LEN];
};
struct uvc_xu_control_mapping {
@@ -86,7 +88,7 @@ struct uvc_xu_control_query {
* struct. The first two fields are added by the driver, they can be used for
* clock synchronisation. The rest is an exact copy of a UVC payload header.
* Only complete objects with complete buffers are included. Therefore it's
- * always sizeof(meta->ts) + sizeof(meta->sof) + meta->length bytes large.
+ * always sizeof(meta->ns) + sizeof(meta->sof) + meta->length bytes large.
*/
struct uvc_meta_buf {
__u64 ns;
diff --git a/lib/libc/include/any-linux-any/linux/v4l2-common.h b/lib/libc/include/any-linux-any/linux/v4l2-common.h
index 03fa37fc29..c13d5ebaab 100644
--- a/lib/libc/include/any-linux-any/linux/v4l2-common.h
+++ b/lib/libc/include/any-linux-any/linux/v4l2-common.h
@@ -10,45 +10,6 @@
*
* Copyright (C) 2012 Nokia Corporation
* Contact: Sakari Ailus <sakari.ailus@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Alternatively you can redistribute this file under the terms of the
- * BSD license as stated below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
*/
#ifndef __V4L2_COMMON__
diff --git a/lib/libc/include/any-linux-any/linux/v4l2-controls.h b/lib/libc/include/any-linux-any/linux/v4l2-controls.h
index 38e81d0656..077bcd79eb 100644
--- a/lib/libc/include/any-linux-any/linux/v4l2-controls.h
+++ b/lib/libc/include/any-linux-any/linux/v4l2-controls.h
@@ -4,44 +4,6 @@
*
* Copyright (C) 1999-2012 the contributors
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * Alternatively you can redistribute this file under the terms of the
- * BSD license as stated below:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. The names of its contributors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
* The contents of this header was split off from videodev2.h. All control
* definitions should be added to this header, which is included by
* videodev2.h.
@@ -128,6 +90,7 @@ enum v4l2_colorfx {
V4L2_COLORFX_SOLARIZATION = 13,
V4L2_COLORFX_ANTIQUE = 14,
V4L2_COLORFX_SET_CBCR = 15,
+ V4L2_COLORFX_SET_RGB = 16,
};
#define V4L2_CID_AUTOBRIGHTNESS (V4L2_CID_BASE+32)
#define V4L2_CID_BAND_STOP_FILTER (V4L2_CID_BASE+33)
@@ -145,14 +108,17 @@ enum v4l2_colorfx {
#define V4L2_CID_ALPHA_COMPONENT (V4L2_CID_BASE+41)
#define V4L2_CID_COLORFX_CBCR (V4L2_CID_BASE+42)
+#define V4L2_CID_COLORFX_RGB (V4L2_CID_BASE+43)
/* last CID + 1 */
-#define V4L2_CID_LASTP1 (V4L2_CID_BASE+43)
+#define V4L2_CID_LASTP1 (V4L2_CID_BASE+44)
/* USER-class private control IDs */
-/* The base for the meye driver controls. See linux/meye.h for the list
- * of controls. We reserve 16 controls for this driver. */
+/*
+ * The base for the meye driver controls. This driver was removed, but
+ * we keep this define in case any software still uses it.
+ */
#define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000)
/* The base for the bttv driver controls.
@@ -217,6 +183,24 @@ enum v4l2_colorfx {
*/
#define V4L2_CID_USER_ALLEGRO_BASE (V4L2_CID_USER_BASE + 0x1170)
+/*
+ * The base for the isl7998x driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ISL7998X_BASE (V4L2_CID_USER_BASE + 0x1180)
+
+/*
+ * The base for DW100 driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_DW100_BASE (V4L2_CID_USER_BASE + 0x1190)
+
+/*
+ * The base for Aspeed driver controls.
+ * We reserve 16 controls for this driver.
+ */
+#define V4L2_CID_USER_ASPEED_BASE (V4L2_CID_USER_BASE + 0x11a0)
+
/* MPEG-class control IDs */
/* The MPEG controls are applicable to all codec controls
* and the 'MPEG' part of the define is historical */
@@ -439,6 +423,11 @@ enum v4l2_mpeg_video_multi_slice_mode {
#define V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (V4L2_CID_CODEC_BASE+234)
#define V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR (V4L2_CID_CODEC_BASE+235)
#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (V4L2_CID_CODEC_BASE+236)
+#define V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE (V4L2_CID_CODEC_BASE+237)
+enum v4l2_mpeg_video_intra_refresh_period_type {
+ V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_RANDOM = 0,
+ V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE_CYCLIC = 1,
+};
/* CIDs for the MPEG-2 Part 2 (H.262) codec */
#define V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL (V4L2_CID_CODEC_BASE+270)
@@ -998,6 +987,8 @@ enum v4l2_auto_focus_range {
#define V4L2_CID_CAMERA_SENSOR_ROTATION (V4L2_CID_CAMERA_CLASS_BASE+35)
+#define V4L2_CID_HDR_SENSOR_MODE (V4L2_CID_CAMERA_CLASS_BASE+36)
+
/* FM Modulator class control IDs */
#define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)
@@ -1559,6 +1550,8 @@ struct v4l2_h264_dpb_entry {
#define V4L2_H264_DECODE_PARAM_FLAG_IDR_PIC 0x01
#define V4L2_H264_DECODE_PARAM_FLAG_FIELD_PIC 0x02
#define V4L2_H264_DECODE_PARAM_FLAG_BOTTOM_FIELD 0x04
+#define V4L2_H264_DECODE_PARAM_FLAG_PFRAME 0x08
+#define V4L2_H264_DECODE_PARAM_FLAG_BFRAME 0x10
#define V4L2_CID_STATELESS_H264_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 7)
/**
@@ -1713,7 +1706,7 @@ struct v4l2_vp8_segment {
* @sharpness_level: matches sharpness_level syntax element.
* @level: matches loop_filter_level syntax element.
* @padding: padding field. Should be zeroed by applications.
- * @flags: see V4L2_VP8_LF_FLAG_{}.
+ * @flags: see V4L2_VP8_LF_{}.
*
* This structure contains loop filter related parameters.
* See the 'mb_lf_adjustments()' part of the frame header syntax,
@@ -1980,6 +1973,465 @@ struct v4l2_ctrl_mpeg2_quantisation {
__u8 chroma_non_intra_quantiser_matrix[64];
};
+#define V4L2_CID_STATELESS_HEVC_SPS (V4L2_CID_CODEC_STATELESS_BASE + 400)
+#define V4L2_CID_STATELESS_HEVC_PPS (V4L2_CID_CODEC_STATELESS_BASE + 401)
+#define V4L2_CID_STATELESS_HEVC_SLICE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 402)
+#define V4L2_CID_STATELESS_HEVC_SCALING_MATRIX (V4L2_CID_CODEC_STATELESS_BASE + 403)
+#define V4L2_CID_STATELESS_HEVC_DECODE_PARAMS (V4L2_CID_CODEC_STATELESS_BASE + 404)
+#define V4L2_CID_STATELESS_HEVC_DECODE_MODE (V4L2_CID_CODEC_STATELESS_BASE + 405)
+#define V4L2_CID_STATELESS_HEVC_START_CODE (V4L2_CID_CODEC_STATELESS_BASE + 406)
+#define V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (V4L2_CID_CODEC_STATELESS_BASE + 407)
+
+enum v4l2_stateless_hevc_decode_mode {
+ V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED,
+ V4L2_STATELESS_HEVC_DECODE_MODE_FRAME_BASED,
+};
+
+enum v4l2_stateless_hevc_start_code {
+ V4L2_STATELESS_HEVC_START_CODE_NONE,
+ V4L2_STATELESS_HEVC_START_CODE_ANNEX_B,
+};
+
+#define V4L2_HEVC_SLICE_TYPE_B 0
+#define V4L2_HEVC_SLICE_TYPE_P 1
+#define V4L2_HEVC_SLICE_TYPE_I 2
+
+#define V4L2_HEVC_SPS_FLAG_SEPARATE_COLOUR_PLANE (1ULL << 0)
+#define V4L2_HEVC_SPS_FLAG_SCALING_LIST_ENABLED (1ULL << 1)
+#define V4L2_HEVC_SPS_FLAG_AMP_ENABLED (1ULL << 2)
+#define V4L2_HEVC_SPS_FLAG_SAMPLE_ADAPTIVE_OFFSET (1ULL << 3)
+#define V4L2_HEVC_SPS_FLAG_PCM_ENABLED (1ULL << 4)
+#define V4L2_HEVC_SPS_FLAG_PCM_LOOP_FILTER_DISABLED (1ULL << 5)
+#define V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT (1ULL << 6)
+#define V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED (1ULL << 7)
+#define V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED (1ULL << 8)
+
+/**
+ * struct v4l2_ctrl_hevc_sps - ITU-T Rec. H.265: Sequence parameter set
+ *
+ * @video_parameter_set_id: specifies the value of the
+ * vps_video_parameter_set_id of the active VPS
+ * @seq_parameter_set_id: provides an identifier for the SPS for
+ * reference by other syntax elements
+ * @pic_width_in_luma_samples: specifies the width of each decoded picture
+ * in units of luma samples
+ * @pic_height_in_luma_samples: specifies the height of each decoded picture
+ * in units of luma samples
+ * @bit_depth_luma_minus8: this value plus 8specifies the bit depth of the
+ * samples of the luma array
+ * @bit_depth_chroma_minus8: this value plus 8 specifies the bit depth of the
+ * samples of the chroma arrays
+ * @log2_max_pic_order_cnt_lsb_minus4: this value plus 4 specifies the value of
+ * the variable MaxPicOrderCntLsb
+ * @sps_max_dec_pic_buffering_minus1: this value plus 1 specifies the maximum
+ * required size of the decoded picture
+ * buffer for the codec video sequence
+ * @sps_max_num_reorder_pics: indicates the maximum allowed number of pictures
+ * @sps_max_latency_increase_plus1: not equal to 0 is used to compute the
+ * value of SpsMaxLatencyPictures array
+ * @log2_min_luma_coding_block_size_minus3: plus 3 specifies the minimum
+ * luma coding block size
+ * @log2_diff_max_min_luma_coding_block_size: specifies the difference between
+ * the maximum and minimum luma
+ * coding block size
+ * @log2_min_luma_transform_block_size_minus2: plus 2 specifies the minimum luma
+ * transform block size
+ * @log2_diff_max_min_luma_transform_block_size: specifies the difference between
+ * the maximum and minimum luma
+ * transform block size
+ * @max_transform_hierarchy_depth_inter: specifies the maximum hierarchy
+ * depth for transform units of
+ * coding units coded in inter
+ * prediction mode
+ * @max_transform_hierarchy_depth_intra: specifies the maximum hierarchy
+ * depth for transform units of
+ * coding units coded in intra
+ * prediction mode
+ * @pcm_sample_bit_depth_luma_minus1: this value plus 1 specifies the number of
+ * bits used to represent each of PCM sample
+ * values of the luma component
+ * @pcm_sample_bit_depth_chroma_minus1: this value plus 1 specifies the number
+ * of bits used to represent each of PCM
+ * sample values of the chroma components
+ * @log2_min_pcm_luma_coding_block_size_minus3: this value plus 3 specifies the
+ * minimum size of coding blocks
+ * @log2_diff_max_min_pcm_luma_coding_block_size: specifies the difference between
+ * the maximum and minimum size of
+ * coding blocks
+ * @num_short_term_ref_pic_sets: specifies the number of st_ref_pic_set()
+ * syntax structures included in the SPS
+ * @num_long_term_ref_pics_sps: specifies the number of candidate long-term
+ * reference pictures that are specified in the SPS
+ * @chroma_format_idc: specifies the chroma sampling
+ * @sps_max_sub_layers_minus1: this value plus 1 specifies the maximum number
+ * of temporal sub-layers
+ * @reserved: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_SPS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_sps {
+ __u8 video_parameter_set_id;
+ __u8 seq_parameter_set_id;
+ __u16 pic_width_in_luma_samples;
+ __u16 pic_height_in_luma_samples;
+ __u8 bit_depth_luma_minus8;
+ __u8 bit_depth_chroma_minus8;
+ __u8 log2_max_pic_order_cnt_lsb_minus4;
+ __u8 sps_max_dec_pic_buffering_minus1;
+ __u8 sps_max_num_reorder_pics;
+ __u8 sps_max_latency_increase_plus1;
+ __u8 log2_min_luma_coding_block_size_minus3;
+ __u8 log2_diff_max_min_luma_coding_block_size;
+ __u8 log2_min_luma_transform_block_size_minus2;
+ __u8 log2_diff_max_min_luma_transform_block_size;
+ __u8 max_transform_hierarchy_depth_inter;
+ __u8 max_transform_hierarchy_depth_intra;
+ __u8 pcm_sample_bit_depth_luma_minus1;
+ __u8 pcm_sample_bit_depth_chroma_minus1;
+ __u8 log2_min_pcm_luma_coding_block_size_minus3;
+ __u8 log2_diff_max_min_pcm_luma_coding_block_size;
+ __u8 num_short_term_ref_pic_sets;
+ __u8 num_long_term_ref_pics_sps;
+ __u8 chroma_format_idc;
+ __u8 sps_max_sub_layers_minus1;
+
+ __u8 reserved[6];
+ __u64 flags;
+};
+
+#define V4L2_HEVC_PPS_FLAG_DEPENDENT_SLICE_SEGMENT_ENABLED (1ULL << 0)
+#define V4L2_HEVC_PPS_FLAG_OUTPUT_FLAG_PRESENT (1ULL << 1)
+#define V4L2_HEVC_PPS_FLAG_SIGN_DATA_HIDING_ENABLED (1ULL << 2)
+#define V4L2_HEVC_PPS_FLAG_CABAC_INIT_PRESENT (1ULL << 3)
+#define V4L2_HEVC_PPS_FLAG_CONSTRAINED_INTRA_PRED (1ULL << 4)
+#define V4L2_HEVC_PPS_FLAG_TRANSFORM_SKIP_ENABLED (1ULL << 5)
+#define V4L2_HEVC_PPS_FLAG_CU_QP_DELTA_ENABLED (1ULL << 6)
+#define V4L2_HEVC_PPS_FLAG_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT (1ULL << 7)
+#define V4L2_HEVC_PPS_FLAG_WEIGHTED_PRED (1ULL << 8)
+#define V4L2_HEVC_PPS_FLAG_WEIGHTED_BIPRED (1ULL << 9)
+#define V4L2_HEVC_PPS_FLAG_TRANSQUANT_BYPASS_ENABLED (1ULL << 10)
+#define V4L2_HEVC_PPS_FLAG_TILES_ENABLED (1ULL << 11)
+#define V4L2_HEVC_PPS_FLAG_ENTROPY_CODING_SYNC_ENABLED (1ULL << 12)
+#define V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED (1ULL << 13)
+#define V4L2_HEVC_PPS_FLAG_PPS_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 14)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_OVERRIDE_ENABLED (1ULL << 15)
+#define V4L2_HEVC_PPS_FLAG_PPS_DISABLE_DEBLOCKING_FILTER (1ULL << 16)
+#define V4L2_HEVC_PPS_FLAG_LISTS_MODIFICATION_PRESENT (1ULL << 17)
+#define V4L2_HEVC_PPS_FLAG_SLICE_SEGMENT_HEADER_EXTENSION_PRESENT (1ULL << 18)
+#define V4L2_HEVC_PPS_FLAG_DEBLOCKING_FILTER_CONTROL_PRESENT (1ULL << 19)
+#define V4L2_HEVC_PPS_FLAG_UNIFORM_SPACING (1ULL << 20)
+
+/**
+ * struct v4l2_ctrl_hevc_pps - ITU-T Rec. H.265: Picture parameter set
+ *
+ * @pic_parameter_set_id: identifies the PPS for reference by other
+ * syntax elements
+ * @num_extra_slice_header_bits: specifies the number of extra slice header
+ * bits that are present in the slice header RBSP
+ * for coded pictures referring to the PPS.
+ * @num_ref_idx_l0_default_active_minus1: this value plus 1 specifies the
+ * inferred value of num_ref_idx_l0_active_minus1
+ * @num_ref_idx_l1_default_active_minus1: this value plus 1 specifies the
+ * inferred value of num_ref_idx_l1_active_minus1
+ * @init_qp_minus26: this value plus 26 specifies the initial value of SliceQp Y for
+ * each slice referring to the PPS
+ * @diff_cu_qp_delta_depth: specifies the difference between the luma coding
+ * tree block size and the minimum luma coding block
+ * size of coding units that convey cu_qp_delta_abs
+ * and cu_qp_delta_sign_flag
+ * @pps_cb_qp_offset: specify the offsets to the luma quantization parameter Cb
+ * @pps_cr_qp_offset: specify the offsets to the luma quantization parameter Cr
+ * @num_tile_columns_minus1: this value plus 1 specifies the number of tile columns
+ * partitioning the picture
+ * @num_tile_rows_minus1: this value plus 1 specifies the number of tile rows partitioning
+ * the picture
+ * @column_width_minus1: this value plus 1 specifies the width of the each tile column in
+ * units of coding tree blocks
+ * @row_height_minus1: this value plus 1 specifies the height of the each tile row in
+ * units of coding tree blocks
+ * @pps_beta_offset_div2: specify the default deblocking parameter offsets for
+ * beta divided by 2
+ * @pps_tc_offset_div2: specify the default deblocking parameter offsets for tC
+ * divided by 2
+ * @log2_parallel_merge_level_minus2: this value plus 2 specifies the value of
+ * the variable Log2ParMrgLevel
+ * @reserved: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_PPS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_pps {
+ __u8 pic_parameter_set_id;
+ __u8 num_extra_slice_header_bits;
+ __u8 num_ref_idx_l0_default_active_minus1;
+ __u8 num_ref_idx_l1_default_active_minus1;
+ __s8 init_qp_minus26;
+ __u8 diff_cu_qp_delta_depth;
+ __s8 pps_cb_qp_offset;
+ __s8 pps_cr_qp_offset;
+ __u8 num_tile_columns_minus1;
+ __u8 num_tile_rows_minus1;
+ __u8 column_width_minus1[20];
+ __u8 row_height_minus1[22];
+ __s8 pps_beta_offset_div2;
+ __s8 pps_tc_offset_div2;
+ __u8 log2_parallel_merge_level_minus2;
+ __u8 reserved;
+ __u64 flags;
+};
+
+#define V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE 0x01
+
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME 0
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_FIELD 1
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_FIELD 2
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM 3
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP 4
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_BOTTOM_TOP 5
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM 6
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING 7
+#define V4L2_HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING 8
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_PREVIOUS_BOTTOM 9
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_PREVIOUS_TOP 10
+#define V4L2_HEVC_SEI_PIC_STRUCT_TOP_PAIRED_NEXT_BOTTOM 11
+#define V4L2_HEVC_SEI_PIC_STRUCT_BOTTOM_PAIRED_NEXT_TOP 12
+
+#define V4L2_HEVC_DPB_ENTRIES_NUM_MAX 16
+
+/**
+ * struct v4l2_hevc_dpb_entry - HEVC decoded picture buffer entry
+ *
+ * @timestamp: timestamp of the V4L2 capture buffer to use as reference.
+ * @flags: long term flag for the reference frame
+ * @field_pic: whether the reference is a field picture or a frame.
+ * @reserved: padding field. Should be zeroed by applications.
+ * @pic_order_cnt_val: the picture order count of the current picture.
+ */
+struct v4l2_hevc_dpb_entry {
+ __u64 timestamp;
+ __u8 flags;
+ __u8 field_pic;
+ __u16 reserved;
+ __s32 pic_order_cnt_val;
+};
+
+/**
+ * struct v4l2_hevc_pred_weight_table - HEVC weighted prediction parameters
+ *
+ * @delta_luma_weight_l0: the difference of the weighting factor applied
+ * to the luma prediction value for list 0
+ * @luma_offset_l0: the additive offset applied to the luma prediction value
+ * for list 0
+ * @delta_chroma_weight_l0: the difference of the weighting factor applied
+ * to the chroma prediction values for list 0
+ * @chroma_offset_l0: the difference of the additive offset applied to
+ * the chroma prediction values for list 0
+ * @delta_luma_weight_l1: the difference of the weighting factor applied
+ * to the luma prediction value for list 1
+ * @luma_offset_l1: the additive offset applied to the luma prediction value
+ * for list 1
+ * @delta_chroma_weight_l1: the difference of the weighting factor applied
+ * to the chroma prediction values for list 1
+ * @chroma_offset_l1: the difference of the additive offset applied to
+ * the chroma prediction values for list 1
+ * @luma_log2_weight_denom: the base 2 logarithm of the denominator for
+ * all luma weighting factors
+ * @delta_chroma_log2_weight_denom: the difference of the base 2 logarithm
+ * of the denominator for all chroma
+ * weighting factors
+ */
+struct v4l2_hevc_pred_weight_table {
+ __s8 delta_luma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 luma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 delta_chroma_weight_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+ __s8 chroma_offset_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+
+ __s8 delta_luma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 luma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __s8 delta_chroma_weight_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+ __s8 chroma_offset_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX][2];
+
+ __u8 luma_log2_weight_denom;
+ __s8 delta_chroma_log2_weight_denom;
+};
+
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_LUMA (1ULL << 0)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_SAO_CHROMA (1ULL << 1)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_TEMPORAL_MVP_ENABLED (1ULL << 2)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_MVD_L1_ZERO (1ULL << 3)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_CABAC_INIT (1ULL << 4)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_COLLOCATED_FROM_L0 (1ULL << 5)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_USE_INTEGER_MV (1ULL << 6)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_DEBLOCKING_FILTER_DISABLED (1ULL << 7)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_SLICE_LOOP_FILTER_ACROSS_SLICES_ENABLED (1ULL << 8)
+#define V4L2_HEVC_SLICE_PARAMS_FLAG_DEPENDENT_SLICE_SEGMENT (1ULL << 9)
+
+/**
+ * struct v4l2_ctrl_hevc_slice_params - HEVC slice parameters
+ *
+ * This control is a dynamically sized 1-dimensional array,
+ * V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.
+ *
+ * @bit_size: size (in bits) of the current slice data
+ * @data_byte_offset: offset (in bytes) to the video data in the current slice data
+ * @num_entry_point_offsets: specifies the number of entry point offset syntax
+ * elements in the slice header.
+ * @nal_unit_type: specifies the coding type of the slice (B, P or I)
+ * @nuh_temporal_id_plus1: minus 1 specifies a temporal identifier for the NAL unit
+ * @slice_type: see V4L2_HEVC_SLICE_TYPE_{}
+ * @colour_plane_id: specifies the colour plane associated with the current slice
+ * @slice_pic_order_cnt: specifies the picture order count
+ * @num_ref_idx_l0_active_minus1: this value plus 1 specifies the maximum
+ * reference index for reference picture list 0
+ * that may be used to decode the slice
+ * @num_ref_idx_l1_active_minus1: this value plus 1 specifies the maximum
+ * reference index for reference picture list 1
+ * that may be used to decode the slice
+ * @collocated_ref_idx: specifies the reference index of the collocated picture used
+ * for temporal motion vector prediction
+ * @five_minus_max_num_merge_cand: specifies the maximum number of merging
+ * motion vector prediction candidates supported in
+ * the slice subtracted from 5
+ * @slice_qp_delta: specifies the initial value of QpY to be used for the coding
+ * blocks in the slice
+ * @slice_cb_qp_offset: specifies a difference to be added to the value of pps_cb_qp_offset
+ * @slice_cr_qp_offset: specifies a difference to be added to the value of pps_cr_qp_offset
+ * @slice_act_y_qp_offset: screen content extension parameters
+ * @slice_act_cb_qp_offset: screen content extension parameters
+ * @slice_act_cr_qp_offset: screen content extension parameters
+ * @slice_beta_offset_div2: specify the deblocking parameter offsets for beta divided by 2
+ * @slice_tc_offset_div2: specify the deblocking parameter offsets for tC divided by 2
+ * @pic_struct: indicates whether a picture should be displayed as a frame or as one or
+ * more fields
+ * @reserved0: padding field. Should be zeroed by applications.
+ * @slice_segment_addr: specifies the address of the first coding tree block in
+ * the slice segment
+ * @ref_idx_l0: the list of L0 reference elements as indices in the DPB
+ * @ref_idx_l1: the list of L1 reference elements as indices in the DPB
+ * @short_term_ref_pic_set_size: specifies the size of short-term reference
+ * pictures set included in the SPS
+ * @long_term_ref_pic_set_size: specifies the size of long-term reference
+ * pictures set include in the SPS
+ * @pred_weight_table: the prediction weight coefficients for inter-picture
+ * prediction
+ * @reserved1: padding field. Should be zeroed by applications.
+ * @flags: see V4L2_HEVC_SLICE_PARAMS_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_slice_params {
+ __u32 bit_size;
+ __u32 data_byte_offset;
+ __u32 num_entry_point_offsets;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: NAL unit header */
+ __u8 nal_unit_type;
+ __u8 nuh_temporal_id_plus1;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+ __u8 slice_type;
+ __u8 colour_plane_id;
+ __s32 slice_pic_order_cnt;
+ __u8 num_ref_idx_l0_active_minus1;
+ __u8 num_ref_idx_l1_active_minus1;
+ __u8 collocated_ref_idx;
+ __u8 five_minus_max_num_merge_cand;
+ __s8 slice_qp_delta;
+ __s8 slice_cb_qp_offset;
+ __s8 slice_cr_qp_offset;
+ __s8 slice_act_y_qp_offset;
+ __s8 slice_act_cb_qp_offset;
+ __s8 slice_act_cr_qp_offset;
+ __s8 slice_beta_offset_div2;
+ __s8 slice_tc_offset_div2;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Picture timing SEI message */
+ __u8 pic_struct;
+
+ __u8 reserved0[3];
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: General slice segment header */
+ __u32 slice_segment_addr;
+ __u8 ref_idx_l0[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 ref_idx_l1[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u16 short_term_ref_pic_set_size;
+ __u16 long_term_ref_pic_set_size;
+
+ /* ISO/IEC 23008-2, ITU-T Rec. H.265: Weighted prediction parameter */
+ struct v4l2_hevc_pred_weight_table pred_weight_table;
+
+ __u8 reserved1[2];
+ __u64 flags;
+};
+
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IRAP_PIC 0x1
+#define V4L2_HEVC_DECODE_PARAM_FLAG_IDR_PIC 0x2
+#define V4L2_HEVC_DECODE_PARAM_FLAG_NO_OUTPUT_OF_PRIOR 0x4
+
+/**
+ * struct v4l2_ctrl_hevc_decode_params - HEVC decode parameters
+ *
+ * @pic_order_cnt_val: picture order count
+ * @short_term_ref_pic_set_size: specifies the size of short-term reference
+ * pictures set included in the SPS of the first slice
+ * @long_term_ref_pic_set_size: specifies the size of long-term reference
+ * pictures set include in the SPS of the first slice
+ * @num_active_dpb_entries: the number of entries in dpb
+ * @num_poc_st_curr_before: the number of reference pictures in the short-term
+ * set that come before the current frame
+ * @num_poc_st_curr_after: the number of reference pictures in the short-term
+ * set that come after the current frame
+ * @num_poc_lt_curr: the number of reference pictures in the long-term set
+ * @poc_st_curr_before: provides the index of the short term before references
+ * in DPB array
+ * @poc_st_curr_after: provides the index of the short term after references
+ * in DPB array
+ * @poc_lt_curr: provides the index of the long term references in DPB array
+ * @reserved: padding field. Should be zeroed by applications.
+ * @dpb: the decoded picture buffer, for meta-data about reference frames
+ * @flags: see V4L2_HEVC_DECODE_PARAM_FLAG_{}
+ */
+struct v4l2_ctrl_hevc_decode_params {
+ __s32 pic_order_cnt_val;
+ __u16 short_term_ref_pic_set_size;
+ __u16 long_term_ref_pic_set_size;
+ __u8 num_active_dpb_entries;
+ __u8 num_poc_st_curr_before;
+ __u8 num_poc_st_curr_after;
+ __u8 num_poc_lt_curr;
+ __u8 poc_st_curr_before[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 poc_st_curr_after[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 poc_lt_curr[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u8 reserved[4];
+ struct v4l2_hevc_dpb_entry dpb[V4L2_HEVC_DPB_ENTRIES_NUM_MAX];
+ __u64 flags;
+};
+
+/**
+ * struct v4l2_ctrl_hevc_scaling_matrix - HEVC scaling lists parameters
+ *
+ * @scaling_list_4x4: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_8x8: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_16x16: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_32x32: scaling list is used for the scaling process for
+ * transform coefficients. The values on each scaling
+ * list are expected in raster scan order
+ * @scaling_list_dc_coef_16x16: scaling list is used for the scaling process
+ * for transform coefficients. The values on each
+ * scaling list are expected in raster scan order.
+ * @scaling_list_dc_coef_32x32: scaling list is used for the scaling process
+ * for transform coefficients. The values on each
+ * scaling list are expected in raster scan order.
+ */
+struct v4l2_ctrl_hevc_scaling_matrix {
+ __u8 scaling_list_4x4[6][16];
+ __u8 scaling_list_8x8[6][64];
+ __u8 scaling_list_16x16[6][64];
+ __u8 scaling_list_32x32[2][64];
+ __u8 scaling_list_dc_coef_16x16[6];
+ __u8 scaling_list_dc_coef_32x32[2];
+};
+
#define V4L2_CID_COLORIMETRY_CLASS_BASE (V4L2_CTRL_CLASS_COLORIMETRY | 0x900)
#define V4L2_CID_COLORIMETRY_CLASS (V4L2_CTRL_CLASS_COLORIMETRY | 1)
@@ -2014,6 +2466,290 @@ struct v4l2_ctrl_hdr10_mastering_display {
__u32 min_display_mastering_luminance;
};
+/* Stateless VP9 controls */
+
+#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_ENABLED 0x1
+#define V4L2_VP9_LOOP_FILTER_FLAG_DELTA_UPDATE 0x2
+
+/**
+ * struct v4l2_vp9_loop_filter - VP9 loop filter parameters
+ *
+ * @ref_deltas: contains the adjustment needed for the filter level based on the
+ * chosen reference frame. If this syntax element is not present in the bitstream,
+ * users should pass its last value.
+ * @mode_deltas: contains the adjustment needed for the filter level based on the
+ * chosen mode. If this syntax element is not present in the bitstream, users should
+ * pass its last value.
+ * @level: indicates the loop filter strength.
+ * @sharpness: indicates the sharpness level.
+ * @flags: combination of V4L2_VP9_LOOP_FILTER_FLAG_{} flags.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * This structure contains all loop filter related parameters. See sections
+ * '7.2.8 Loop filter semantics' of the VP9 specification for more details.
+ */
+struct v4l2_vp9_loop_filter {
+ __s8 ref_deltas[4];
+ __s8 mode_deltas[2];
+ __u8 level;
+ __u8 sharpness;
+ __u8 flags;
+ __u8 reserved[7];
+};
+
+/**
+ * struct v4l2_vp9_quantization - VP9 quantization parameters
+ *
+ * @base_q_idx: indicates the base frame qindex.
+ * @delta_q_y_dc: indicates the Y DC quantizer relative to base_q_idx.
+ * @delta_q_uv_dc: indicates the UV DC quantizer relative to base_q_idx.
+ * @delta_q_uv_ac: indicates the UV AC quantizer relative to base_q_idx.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * Encodes the quantization parameters. See section '7.2.9 Quantization params
+ * syntax' of the VP9 specification for more details.
+ */
+struct v4l2_vp9_quantization {
+ __u8 base_q_idx;
+ __s8 delta_q_y_dc;
+ __s8 delta_q_uv_dc;
+ __s8 delta_q_uv_ac;
+ __u8 reserved[4];
+};
+
+#define V4L2_VP9_SEGMENTATION_FLAG_ENABLED 0x01
+#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_MAP 0x02
+#define V4L2_VP9_SEGMENTATION_FLAG_TEMPORAL_UPDATE 0x04
+#define V4L2_VP9_SEGMENTATION_FLAG_UPDATE_DATA 0x08
+#define V4L2_VP9_SEGMENTATION_FLAG_ABS_OR_DELTA_UPDATE 0x10
+
+#define V4L2_VP9_SEG_LVL_ALT_Q 0
+#define V4L2_VP9_SEG_LVL_ALT_L 1
+#define V4L2_VP9_SEG_LVL_REF_FRAME 2
+#define V4L2_VP9_SEG_LVL_SKIP 3
+#define V4L2_VP9_SEG_LVL_MAX 4
+
+#define V4L2_VP9_SEGMENT_FEATURE_ENABLED(id) (1 << (id))
+#define V4L2_VP9_SEGMENT_FEATURE_ENABLED_MASK 0xf
+
+/**
+ * struct v4l2_vp9_segmentation - VP9 segmentation parameters
+ *
+ * @feature_data: data attached to each feature. Data entry is only valid if
+ * the feature is enabled. The array shall be indexed with segment number as
+ * the first dimension (0..7) and one of V4L2_VP9_SEG_{} as the second dimension.
+ * @feature_enabled: bitmask defining which features are enabled in each segment.
+ * The value for each segment is a combination of V4L2_VP9_SEGMENT_FEATURE_ENABLED(id)
+ * values where id is one of V4L2_VP9_SEG_LVL_{}.
+ * @tree_probs: specifies the probability values to be used when decoding a
+ * Segment-ID. See '5.15. Segmentation map' section of the VP9 specification
+ * for more details.
+ * @pred_probs: specifies the probability values to be used when decoding a
+ * Predicted-Segment-ID. See '6.4.14. Get segment id syntax' section of :ref:`vp9`
+ * for more details.
+ * @flags: combination of V4L2_VP9_SEGMENTATION_FLAG_{} flags.
+ * @reserved: padding field. Should be zeroed by applications.
+ *
+ * Encodes the quantization parameters. See section '7.2.10 Segmentation params syntax' of
+ * the VP9 specification for more details.
+ */
+struct v4l2_vp9_segmentation {
+ __s16 feature_data[8][4];
+ __u8 feature_enabled[8];
+ __u8 tree_probs[7];
+ __u8 pred_probs[3];
+ __u8 flags;
+ __u8 reserved[5];
+};
+
+#define V4L2_VP9_FRAME_FLAG_KEY_FRAME 0x001
+#define V4L2_VP9_FRAME_FLAG_SHOW_FRAME 0x002
+#define V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT 0x004
+#define V4L2_VP9_FRAME_FLAG_INTRA_ONLY 0x008
+#define V4L2_VP9_FRAME_FLAG_ALLOW_HIGH_PREC_MV 0x010
+#define V4L2_VP9_FRAME_FLAG_REFRESH_FRAME_CTX 0x020
+#define V4L2_VP9_FRAME_FLAG_PARALLEL_DEC_MODE 0x040
+#define V4L2_VP9_FRAME_FLAG_X_SUBSAMPLING 0x080
+#define V4L2_VP9_FRAME_FLAG_Y_SUBSAMPLING 0x100
+#define V4L2_VP9_FRAME_FLAG_COLOR_RANGE_FULL_SWING 0x200
+
+#define V4L2_VP9_SIGN_BIAS_LAST 0x1
+#define V4L2_VP9_SIGN_BIAS_GOLDEN 0x2
+#define V4L2_VP9_SIGN_BIAS_ALT 0x4
+
+#define V4L2_VP9_RESET_FRAME_CTX_NONE 0
+#define V4L2_VP9_RESET_FRAME_CTX_SPEC 1
+#define V4L2_VP9_RESET_FRAME_CTX_ALL 2
+
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP 0
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SMOOTH 1
+#define V4L2_VP9_INTERP_FILTER_EIGHTTAP_SHARP 2
+#define V4L2_VP9_INTERP_FILTER_BILINEAR 3
+#define V4L2_VP9_INTERP_FILTER_SWITCHABLE 4
+
+#define V4L2_VP9_REFERENCE_MODE_SINGLE_REFERENCE 0
+#define V4L2_VP9_REFERENCE_MODE_COMPOUND_REFERENCE 1
+#define V4L2_VP9_REFERENCE_MODE_SELECT 2
+
+#define V4L2_VP9_PROFILE_MAX 3
+
+#define V4L2_CID_STATELESS_VP9_FRAME (V4L2_CID_CODEC_STATELESS_BASE + 300)
+/**
+ * struct v4l2_ctrl_vp9_frame - VP9 frame decoding control
+ *
+ * @lf: loop filter parameters. See &v4l2_vp9_loop_filter for more details.
+ * @quant: quantization parameters. See &v4l2_vp9_quantization for more details.
+ * @seg: segmentation parameters. See &v4l2_vp9_segmentation for more details.
+ * @flags: combination of V4L2_VP9_FRAME_FLAG_{} flags.
+ * @compressed_header_size: compressed header size in bytes.
+ * @uncompressed_header_size: uncompressed header size in bytes.
+ * @frame_width_minus_1: add 1 to it and you'll get the frame width expressed in pixels.
+ * @frame_height_minus_1: add 1 to it and you'll get the frame height expressed in pixels.
+ * @render_width_minus_1: add 1 to it and you'll get the expected render width expressed in
+ * pixels. This is not used during the decoding process but might be used by HW scalers
+ * to prepare a frame that's ready for scanout.
+ * @render_height_minus_1: add 1 to it and you'll get the expected render height expressed in
+ * pixels. This is not used during the decoding process but might be used by HW scalers
+ * to prepare a frame that's ready for scanout.
+ * @last_frame_ts: "last" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @golden_frame_ts: "golden" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @alt_frame_ts: "alt" reference buffer timestamp.
+ * The timestamp refers to the timestamp field in struct v4l2_buffer.
+ * Use v4l2_timeval_to_ns() to convert the struct timeval to a __u64.
+ * @ref_frame_sign_bias: a bitfield specifying whether the sign bias is set for a given
+ * reference frame. Either of V4L2_VP9_SIGN_BIAS_{}.
+ * @reset_frame_context: specifies whether the frame context should be reset to default values.
+ * Either of V4L2_VP9_RESET_FRAME_CTX_{}.
+ * @frame_context_idx: frame context that should be used/updated.
+ * @profile: VP9 profile. Can be 0, 1, 2 or 3.
+ * @bit_depth: bits per components. Can be 8, 10 or 12. Note that not all profiles support
+ * 10 and/or 12 bits depths.
+ * @interpolation_filter: specifies the filter selection used for performing inter prediction.
+ * Set to one of V4L2_VP9_INTERP_FILTER_{}.
+ * @tile_cols_log2: specifies the base 2 logarithm of the width of each tile (where the width
+ * is measured in units of 8x8 blocks). Shall be less than or equal to 6.
+ * @tile_rows_log2: specifies the base 2 logarithm of the height of each tile (where the height
+ * is measured in units of 8x8 blocks).
+ * @reference_mode: specifies the type of inter prediction to be used.
+ * Set to one of V4L2_VP9_REFERENCE_MODE_{}.
+ * @reserved: padding field. Should be zeroed by applications.
+ */
+struct v4l2_ctrl_vp9_frame {
+ struct v4l2_vp9_loop_filter lf;
+ struct v4l2_vp9_quantization quant;
+ struct v4l2_vp9_segmentation seg;
+ __u32 flags;
+ __u16 compressed_header_size;
+ __u16 uncompressed_header_size;
+ __u16 frame_width_minus_1;
+ __u16 frame_height_minus_1;
+ __u16 render_width_minus_1;
+ __u16 render_height_minus_1;
+ __u64 last_frame_ts;
+ __u64 golden_frame_ts;
+ __u64 alt_frame_ts;
+ __u8 ref_frame_sign_bias;
+ __u8 reset_frame_context;
+ __u8 frame_context_idx;
+ __u8 profile;
+ __u8 bit_depth;
+ __u8 interpolation_filter;
+ __u8 tile_cols_log2;
+ __u8 tile_rows_log2;
+ __u8 reference_mode;
+ __u8 reserved[7];
+};
+
+#define V4L2_VP9_NUM_FRAME_CTX 4
+
+/**
+ * struct v4l2_vp9_mv_probs - VP9 Motion vector probability updates
+ * @joint: motion vector joint probability updates.
+ * @sign: motion vector sign probability updates.
+ * @classes: motion vector class probability updates.
+ * @class0_bit: motion vector class0 bit probability updates.
+ * @bits: motion vector bits probability updates.
+ * @class0_fr: motion vector class0 fractional bit probability updates.
+ * @fr: motion vector fractional bit probability updates.
+ * @class0_hp: motion vector class0 high precision fractional bit probability updates.
+ * @hp: motion vector high precision fractional bit probability updates.
+ *
+ * This structure contains new values of motion vector probabilities.
+ * A value of zero in an array element means there is no update of the relevant probability.
+ * See `struct v4l2_vp9_prob_updates` for details.
+ */
+struct v4l2_vp9_mv_probs {
+ __u8 joint[3];
+ __u8 sign[2];
+ __u8 classes[2][10];
+ __u8 class0_bit[2];
+ __u8 bits[2][10];
+ __u8 class0_fr[2][2][3];
+ __u8 fr[2][3];
+ __u8 class0_hp[2];
+ __u8 hp[2];
+};
+
+#define V4L2_CID_STATELESS_VP9_COMPRESSED_HDR (V4L2_CID_CODEC_STATELESS_BASE + 301)
+
+#define V4L2_VP9_TX_MODE_ONLY_4X4 0
+#define V4L2_VP9_TX_MODE_ALLOW_8X8 1
+#define V4L2_VP9_TX_MODE_ALLOW_16X16 2
+#define V4L2_VP9_TX_MODE_ALLOW_32X32 3
+#define V4L2_VP9_TX_MODE_SELECT 4
+
+/**
+ * struct v4l2_ctrl_vp9_compressed_hdr - VP9 probability updates control
+ * @tx_mode: specifies the TX mode. Set to one of V4L2_VP9_TX_MODE_{}.
+ * @tx8: TX 8x8 probability updates.
+ * @tx16: TX 16x16 probability updates.
+ * @tx32: TX 32x32 probability updates.
+ * @coef: coefficient probability updates.
+ * @skip: skip probability updates.
+ * @inter_mode: inter mode probability updates.
+ * @interp_filter: interpolation filter probability updates.
+ * @is_inter: is inter-block probability updates.
+ * @comp_mode: compound prediction mode probability updates.
+ * @single_ref: single ref probability updates.
+ * @comp_ref: compound ref probability updates.
+ * @y_mode: Y prediction mode probability updates.
+ * @uv_mode: UV prediction mode probability updates.
+ * @partition: partition probability updates.
+ * @mv: motion vector probability updates.
+ *
+ * This structure holds the probabilities update as parsed in the compressed
+ * header (Spec 6.3). These values represent the value of probability update after
+ * being translated with inv_map_table[] (see 6.3.5). A value of zero in an array element
+ * means that there is no update of the relevant probability.
+ *
+ * This control is optional and needs to be used when dealing with the hardware which is
+ * not capable of parsing the compressed header itself. Only drivers which need it will
+ * implement it.
+ */
+struct v4l2_ctrl_vp9_compressed_hdr {
+ __u8 tx_mode;
+ __u8 tx8[2][1];
+ __u8 tx16[2][2];
+ __u8 tx32[2][3];
+ __u8 coef[4][2][2][6][6][3];
+ __u8 skip[3];
+ __u8 inter_mode[7][3];
+ __u8 interp_filter[4][2];
+ __u8 is_inter[4];
+ __u8 comp_mode[5];
+ __u8 single_ref[5][2];
+ __u8 comp_ref[5];
+ __u8 y_mode[4][9];
+ __u8 uv_mode[10][9];
+ __u8 partition[16][3];
+
+ struct v4l2_vp9_mv_probs mv;
+};
+
/* MPEG-compression definitions kept for backwards compatibility */
#define V4L2_CTRL_CLASS_MPEG V4L2_CTRL_CLASS_CODEC
#define V4L2_CID_MPEG_CLASS V4L2_CID_CODEC_CLASS
diff --git a/lib/libc/include/any-linux-any/linux/v4l2-dv-timings.h b/lib/libc/include/any-linux-any/linux/v4l2-dv-timings.h
index ff5aebcd36..6add6af34c 100644
--- a/lib/libc/include/any-linux-any/linux/v4l2-dv-timings.h
+++ b/lib/libc/include/any-linux-any/linux/v4l2-dv-timings.h
@@ -3,15 +3,6 @@
* V4L2 DV timings header.
*
* Copyright (C) 2012-2016 Hans Verkuil <hans.verkuil@cisco.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
*/
#ifndef _V4L2_DV_TIMINGS_H
diff --git a/lib/libc/include/any-linux-any/linux/v4l2-mediabus.h b/lib/libc/include/any-linux-any/linux/v4l2-mediabus.h
index c19c487de2..e199e15da9 100644
--- a/lib/libc/include/any-linux-any/linux/v4l2-mediabus.h
+++ b/lib/libc/include/any-linux-any/linux/v4l2-mediabus.h
@@ -3,10 +3,6 @@
* Media Bus API header
*
* Copyright (C) 2009, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
*/
#ifndef __LINUX_V4L2_MEDIABUS_H
diff --git a/lib/libc/include/any-linux-any/linux/v4l2-subdev.h b/lib/libc/include/any-linux-any/linux/v4l2-subdev.h
index 36d7b3fd7c..93aed23151 100644
--- a/lib/libc/include/any-linux-any/linux/v4l2-subdev.h
+++ b/lib/libc/include/any-linux-any/linux/v4l2-subdev.h
@@ -6,24 +6,12 @@
*
* Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
* Sakari Ailus <sakari.ailus@iki.fi>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __LINUX_V4L2_SUBDEV_H
#define __LINUX_V4L2_SUBDEV_H
+#include <linux/const.h>
#include <linux/ioctl.h>
#include <linux/types.h>
#include <linux/v4l2-common.h>
@@ -44,13 +32,15 @@ enum v4l2_subdev_format_whence {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @format: media bus format (format code and frame size)
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_format {
__u32 which;
__u32 pad;
struct v4l2_mbus_framefmt format;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -58,13 +48,15 @@ struct v4l2_subdev_format {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @rect: pad crop rectangle boundaries
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_crop {
__u32 which;
__u32 pad;
struct v4l2_rect rect;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
#define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE 0x00000001
@@ -80,6 +72,7 @@ struct v4l2_subdev_crop {
* @code: format code (MEDIA_BUS_FMT_ definitions)
* @which: format type (from enum v4l2_subdev_format_whence)
* @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_mbus_code_enum {
@@ -88,7 +81,8 @@ struct v4l2_subdev_mbus_code_enum {
__u32 code;
__u32 which;
__u32 flags;
- __u32 reserved[7];
+ __u32 stream;
+ __u32 reserved[6];
};
/**
@@ -101,6 +95,7 @@ struct v4l2_subdev_mbus_code_enum {
* @min_height: minimum frame height, in pixels
* @max_height: maximum frame height, in pixels
* @which: format type (from enum v4l2_subdev_format_whence)
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_size_enum {
@@ -112,19 +107,22 @@ struct v4l2_subdev_frame_size_enum {
__u32 min_height;
__u32 max_height;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
* struct v4l2_subdev_frame_interval - Pad-level frame rate
* @pad: pad number, as reported by the media API
* @interval: frame interval in seconds
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_interval {
__u32 pad;
struct v4l2_fract interval;
- __u32 reserved[9];
+ __u32 stream;
+ __u32 reserved[8];
};
/**
@@ -136,6 +134,7 @@ struct v4l2_subdev_frame_interval {
* @height: frame height in pixels
* @interval: frame interval in seconds
* @which: format type (from enum v4l2_subdev_format_whence)
+ * @stream: stream number, defined in subdev routing
* @reserved: drivers and applications must zero this array
*/
struct v4l2_subdev_frame_interval_enum {
@@ -146,7 +145,8 @@ struct v4l2_subdev_frame_interval_enum {
__u32 height;
struct v4l2_fract interval;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -158,6 +158,7 @@ struct v4l2_subdev_frame_interval_enum {
* defined in v4l2-common.h; V4L2_SEL_TGT_* .
* @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
* @r: coordinates of the selection window
+ * @stream: stream number, defined in subdev routing
* @reserved: for future use, set to zero for now
*
* Hardware may use multiple helper windows to process a video stream.
@@ -170,7 +171,8 @@ struct v4l2_subdev_selection {
__u32 target;
__u32 flags;
struct v4l2_rect r;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -188,6 +190,49 @@ struct v4l2_subdev_capability {
/* The v4l2 sub-device video device node is registered in read-only mode. */
#define V4L2_SUBDEV_CAP_RO_SUBDEV 0x00000001
+/* The v4l2 sub-device supports routing and multiplexed streams. */
+#define V4L2_SUBDEV_CAP_STREAMS 0x00000002
+
+/*
+ * Is the route active? An active route will start when streaming is enabled
+ * on a video node.
+ */
+#define V4L2_SUBDEV_ROUTE_FL_ACTIVE (1U << 0)
+
+/**
+ * struct v4l2_subdev_route - A route inside a subdev
+ *
+ * @sink_pad: the sink pad index
+ * @sink_stream: the sink stream identifier
+ * @source_pad: the source pad index
+ * @source_stream: the source stream identifier
+ * @flags: route flags V4L2_SUBDEV_ROUTE_FL_*
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_route {
+ __u32 sink_pad;
+ __u32 sink_stream;
+ __u32 source_pad;
+ __u32 source_stream;
+ __u32 flags;
+ __u32 reserved[5];
+};
+
+/**
+ * struct v4l2_subdev_routing - Subdev routing information
+ *
+ * @which: configuration type (from enum v4l2_subdev_format_whence)
+ * @num_routes: the total number of routes in the routes array
+ * @routes: pointer to the routes array
+ * @reserved: drivers and applications must zero this array
+ */
+struct v4l2_subdev_routing {
+ __u32 which;
+ __u32 num_routes;
+ __u64 routes;
+ __u32 reserved[6];
+};
+
/* Backwards compatibility define --- to be removed */
#define v4l2_subdev_edid v4l2_edid
@@ -203,6 +248,8 @@ struct v4l2_subdev_capability {
#define VIDIOC_SUBDEV_S_CROP _IOWR('V', 60, struct v4l2_subdev_crop)
#define VIDIOC_SUBDEV_G_SELECTION _IOWR('V', 61, struct v4l2_subdev_selection)
#define VIDIOC_SUBDEV_S_SELECTION _IOWR('V', 62, struct v4l2_subdev_selection)
+#define VIDIOC_SUBDEV_G_ROUTING _IOWR('V', 38, struct v4l2_subdev_routing)
+#define VIDIOC_SUBDEV_S_ROUTING _IOWR('V', 39, struct v4l2_subdev_routing)
/* The following ioctls are identical to the ioctls in videodev2.h */
#define VIDIOC_SUBDEV_G_STD _IOR('V', 23, v4l2_std_id)
#define VIDIOC_SUBDEV_S_STD _IOW('V', 24, v4l2_std_id)
diff --git a/lib/libc/include/any-linux-any/linux/vdpa.h b/lib/libc/include/any-linux-any/linux/vdpa.h
index 8ef96a7abe..bb7e518ea3 100644
--- a/lib/libc/include/any-linux-any/linux/vdpa.h
+++ b/lib/libc/include/any-linux-any/linux/vdpa.h
@@ -18,11 +18,15 @@ enum vdpa_command {
VDPA_CMD_DEV_DEL,
VDPA_CMD_DEV_GET, /* can dump */
VDPA_CMD_DEV_CONFIG_GET, /* can dump */
+ VDPA_CMD_DEV_VSTATS_GET,
};
enum vdpa_attr {
VDPA_ATTR_UNSPEC,
+ /* Pad attribute for 64b alignment */
+ VDPA_ATTR_PAD = VDPA_ATTR_UNSPEC,
+
/* bus name (optional) + dev name together make the parent device handle */
VDPA_ATTR_MGMTDEV_BUS_NAME, /* string */
VDPA_ATTR_MGMTDEV_DEV_NAME, /* string */
@@ -40,6 +44,18 @@ enum vdpa_attr {
VDPA_ATTR_DEV_NET_CFG_MAX_VQP, /* u16 */
VDPA_ATTR_DEV_NET_CFG_MTU, /* u16 */
+ VDPA_ATTR_DEV_NEGOTIATED_FEATURES, /* u64 */
+ VDPA_ATTR_DEV_MGMTDEV_MAX_VQS, /* u32 */
+ /* virtio features that are supported by the vDPA management device */
+ VDPA_ATTR_DEV_SUPPORTED_FEATURES, /* u64 */
+
+ VDPA_ATTR_DEV_QUEUE_INDEX, /* u32 */
+ VDPA_ATTR_DEV_VENDOR_ATTR_NAME, /* string */
+ VDPA_ATTR_DEV_VENDOR_ATTR_VALUE, /* u64 */
+
+ /* virtio features that are provisioned to the vDPA device */
+ VDPA_ATTR_DEV_FEATURES, /* u64 */
+
/* new attributes must be added above here */
VDPA_ATTR_MAX,
};
diff --git a/lib/libc/include/any-linux-any/linux/vduse.h b/lib/libc/include/any-linux-any/linux/vduse.h
index c7b7d0122e..ba61460de2 100644
--- a/lib/libc/include/any-linux-any/linux/vduse.h
+++ b/lib/libc/include/any-linux-any/linux/vduse.h
@@ -210,6 +210,53 @@ struct vduse_vq_eventfd {
*/
#define VDUSE_VQ_INJECT_IRQ _IOW(VDUSE_BASE, 0x17, __u32)
+/**
+ * struct vduse_iova_umem - userspace memory configuration for one IOVA region
+ * @uaddr: start address of userspace memory, it must be aligned to page size
+ * @iova: start of the IOVA region
+ * @size: size of the IOVA region
+ * @reserved: for future use, needs to be initialized to zero
+ *
+ * Structure used by VDUSE_IOTLB_REG_UMEM and VDUSE_IOTLB_DEREG_UMEM
+ * ioctls to register/de-register userspace memory for IOVA regions
+ */
+struct vduse_iova_umem {
+ __u64 uaddr;
+ __u64 iova;
+ __u64 size;
+ __u64 reserved[3];
+};
+
+/* Register userspace memory for IOVA regions */
+#define VDUSE_IOTLB_REG_UMEM _IOW(VDUSE_BASE, 0x18, struct vduse_iova_umem)
+
+/* De-register the userspace memory. Caller should set iova and size field. */
+#define VDUSE_IOTLB_DEREG_UMEM _IOW(VDUSE_BASE, 0x19, struct vduse_iova_umem)
+
+/**
+ * struct vduse_iova_info - information of one IOVA region
+ * @start: start of the IOVA region
+ * @last: last of the IOVA region
+ * @capability: capability of the IOVA regsion
+ * @reserved: for future use, needs to be initialized to zero
+ *
+ * Structure used by VDUSE_IOTLB_GET_INFO ioctl to get information of
+ * one IOVA region.
+ */
+struct vduse_iova_info {
+ __u64 start;
+ __u64 last;
+#define VDUSE_IOVA_CAP_UMEM (1 << 0)
+ __u64 capability;
+ __u64 reserved[3];
+};
+
+/*
+ * Find the first IOVA region that overlaps with the range [start, last]
+ * and return some information on it. Caller should set start and last fields.
+ */
+#define VDUSE_IOTLB_GET_INFO _IOWR(VDUSE_BASE, 0x1a, struct vduse_iova_info)
+
/* The control messages definition for read(2)/write(2) on /dev/vduse/$NAME */
/**
diff --git a/lib/libc/include/any-linux-any/linux/version.h b/lib/libc/include/any-linux-any/linux/version.h
index 118d1d84fc..ed526dca4c 100644
--- a/lib/libc/include/any-linux-any/linux/version.h
+++ b/lib/libc/include/any-linux-any/linux/version.h
@@ -1,5 +1,5 @@
-#define LINUX_VERSION_CODE 331778
+#define LINUX_VERSION_CODE 393992
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
-#define LINUX_VERSION_MAJOR 5
-#define LINUX_VERSION_PATCHLEVEL 16
-#define LINUX_VERSION_SUBLEVEL 2 \ No newline at end of file
+#define LINUX_VERSION_MAJOR 6
+#define LINUX_VERSION_PATCHLEVEL 3
+#define LINUX_VERSION_SUBLEVEL 8 \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/vfio.h b/lib/libc/include/any-linux-any/linux/vfio.h
index 773c9013a9..58a0477627 100644
--- a/lib/libc/include/any-linux-any/linux/vfio.h
+++ b/lib/libc/include/any-linux-any/linux/vfio.h
@@ -49,7 +49,11 @@
/* Supports VFIO_DMA_UNMAP_FLAG_ALL */
#define VFIO_UNMAP_ALL 9
-/* Supports the vaddr flag for DMA map and unmap */
+/*
+ * Supports the vaddr flag for DMA map and unmap. Not supported for mediated
+ * devices, so this capability is subject to change as groups are added or
+ * removed.
+ */
#define VFIO_UPDATE_VADDR 10
/*
@@ -323,7 +327,7 @@ struct vfio_region_info_cap_type {
#define VFIO_REGION_TYPE_PCI_VENDOR_MASK (0xffff)
#define VFIO_REGION_TYPE_GFX (1)
#define VFIO_REGION_TYPE_CCW (2)
-#define VFIO_REGION_TYPE_MIGRATION (3)
+#define VFIO_REGION_TYPE_MIGRATION_DEPRECATED (3)
/* sub-types for VFIO_REGION_TYPE_PCI_* */
@@ -405,225 +409,29 @@ struct vfio_region_gfx_edid {
#define VFIO_REGION_SUBTYPE_CCW_CRW (3)
/* sub-types for VFIO_REGION_TYPE_MIGRATION */
-#define VFIO_REGION_SUBTYPE_MIGRATION (1)
-
-/*
- * The structure vfio_device_migration_info is placed at the 0th offset of
- * the VFIO_REGION_SUBTYPE_MIGRATION region to get and set VFIO device related
- * migration information. Field accesses from this structure are only supported
- * at their native width and alignment. Otherwise, the result is undefined and
- * vendor drivers should return an error.
- *
- * device_state: (read/write)
- * - The user application writes to this field to inform the vendor driver
- * about the device state to be transitioned to.
- * - The vendor driver should take the necessary actions to change the
- * device state. After successful transition to a given state, the
- * vendor driver should return success on write(device_state, state)
- * system call. If the device state transition fails, the vendor driver
- * should return an appropriate -errno for the fault condition.
- * - On the user application side, if the device state transition fails,
- * that is, if write(device_state, state) returns an error, read
- * device_state again to determine the current state of the device from
- * the vendor driver.
- * - The vendor driver should return previous state of the device unless
- * the vendor driver has encountered an internal error, in which case
- * the vendor driver may report the device_state VFIO_DEVICE_STATE_ERROR.
- * - The user application must use the device reset ioctl to recover the
- * device from VFIO_DEVICE_STATE_ERROR state. If the device is
- * indicated to be in a valid device state by reading device_state, the
- * user application may attempt to transition the device to any valid
- * state reachable from the current state or terminate itself.
- *
- * device_state consists of 3 bits:
- * - If bit 0 is set, it indicates the _RUNNING state. If bit 0 is clear,
- * it indicates the _STOP state. When the device state is changed to
- * _STOP, driver should stop the device before write() returns.
- * - If bit 1 is set, it indicates the _SAVING state, which means that the
- * driver should start gathering device state information that will be
- * provided to the VFIO user application to save the device's state.
- * - If bit 2 is set, it indicates the _RESUMING state, which means that
- * the driver should prepare to resume the device. Data provided through
- * the migration region should be used to resume the device.
- * Bits 3 - 31 are reserved for future use. To preserve them, the user
- * application should perform a read-modify-write operation on this
- * field when modifying the specified bits.
- *
- * +------- _RESUMING
- * |+------ _SAVING
- * ||+----- _RUNNING
- * |||
- * 000b => Device Stopped, not saving or resuming
- * 001b => Device running, which is the default state
- * 010b => Stop the device & save the device state, stop-and-copy state
- * 011b => Device running and save the device state, pre-copy state
- * 100b => Device stopped and the device state is resuming
- * 101b => Invalid state
- * 110b => Error state
- * 111b => Invalid state
- *
- * State transitions:
- *
- * _RESUMING _RUNNING Pre-copy Stop-and-copy _STOP
- * (100b) (001b) (011b) (010b) (000b)
- * 0. Running or default state
- * |
- *
- * 1. Normal Shutdown (optional)
- * |------------------------------------->|
- *
- * 2. Save the state or suspend
- * |------------------------->|---------->|
- *
- * 3. Save the state during live migration
- * |----------->|------------>|---------->|
- *
- * 4. Resuming
- * |<---------|
- *
- * 5. Resumed
- * |--------->|
- *
- * 0. Default state of VFIO device is _RUNNING when the user application starts.
- * 1. During normal shutdown of the user application, the user application may
- * optionally change the VFIO device state from _RUNNING to _STOP. This
- * transition is optional. The vendor driver must support this transition but
- * must not require it.
- * 2. When the user application saves state or suspends the application, the
- * device state transitions from _RUNNING to stop-and-copy and then to _STOP.
- * On state transition from _RUNNING to stop-and-copy, driver must stop the
- * device, save the device state and send it to the application through the
- * migration region. The sequence to be followed for such transition is given
- * below.
- * 3. In live migration of user application, the state transitions from _RUNNING
- * to pre-copy, to stop-and-copy, and to _STOP.
- * On state transition from _RUNNING to pre-copy, the driver should start
- * gathering the device state while the application is still running and send
- * the device state data to application through the migration region.
- * On state transition from pre-copy to stop-and-copy, the driver must stop
- * the device, save the device state and send it to the user application
- * through the migration region.
- * Vendor drivers must support the pre-copy state even for implementations
- * where no data is provided to the user before the stop-and-copy state. The
- * user must not be required to consume all migration data before the device
- * transitions to a new state, including the stop-and-copy state.
- * The sequence to be followed for above two transitions is given below.
- * 4. To start the resuming phase, the device state should be transitioned from
- * the _RUNNING to the _RESUMING state.
- * In the _RESUMING state, the driver should use the device state data
- * received through the migration region to resume the device.
- * 5. After providing saved device data to the driver, the application should
- * change the state from _RESUMING to _RUNNING.
- *
- * reserved:
- * Reads on this field return zero and writes are ignored.
- *
- * pending_bytes: (read only)
- * The number of pending bytes still to be migrated from the vendor driver.
- *
- * data_offset: (read only)
- * The user application should read data_offset field from the migration
- * region. The user application should read the device data from this
- * offset within the migration region during the _SAVING state or write
- * the device data during the _RESUMING state. See below for details of
- * sequence to be followed.
- *
- * data_size: (read/write)
- * The user application should read data_size to get the size in bytes of
- * the data copied in the migration region during the _SAVING state and
- * write the size in bytes of the data copied in the migration region
- * during the _RESUMING state.
- *
- * The format of the migration region is as follows:
- * ------------------------------------------------------------------
- * |vfio_device_migration_info| data section |
- * | | /////////////////////////////// |
- * ------------------------------------------------------------------
- * ^ ^
- * offset 0-trapped part data_offset
- *
- * The structure vfio_device_migration_info is always followed by the data
- * section in the region, so data_offset will always be nonzero. The offset
- * from where the data is copied is decided by the kernel driver. The data
- * section can be trapped, mmapped, or partitioned, depending on how the kernel
- * driver defines the data section. The data section partition can be defined
- * as mapped by the sparse mmap capability. If mmapped, data_offset must be
- * page aligned, whereas initial section which contains the
- * vfio_device_migration_info structure, might not end at the offset, which is
- * page aligned. The user is not required to access through mmap regardless
- * of the capabilities of the region mmap.
- * The vendor driver should determine whether and how to partition the data
- * section. The vendor driver should return data_offset accordingly.
- *
- * The sequence to be followed while in pre-copy state and stop-and-copy state
- * is as follows:
- * a. Read pending_bytes, indicating the start of a new iteration to get device
- * data. Repeated read on pending_bytes at this stage should have no side
- * effects.
- * If pending_bytes == 0, the user application should not iterate to get data
- * for that device.
- * If pending_bytes > 0, perform the following steps.
- * b. Read data_offset, indicating that the vendor driver should make data
- * available through the data section. The vendor driver should return this
- * read operation only after data is available from (region + data_offset)
- * to (region + data_offset + data_size).
- * c. Read data_size, which is the amount of data in bytes available through
- * the migration region.
- * Read on data_offset and data_size should return the offset and size of
- * the current buffer if the user application reads data_offset and
- * data_size more than once here.
- * d. Read data_size bytes of data from (region + data_offset) from the
- * migration region.
- * e. Process the data.
- * f. Read pending_bytes, which indicates that the data from the previous
- * iteration has been read. If pending_bytes > 0, go to step b.
- *
- * The user application can transition from the _SAVING|_RUNNING
- * (pre-copy state) to the _SAVING (stop-and-copy) state regardless of the
- * number of pending bytes. The user application should iterate in _SAVING
- * (stop-and-copy) until pending_bytes is 0.
- *
- * The sequence to be followed while _RESUMING device state is as follows:
- * While data for this device is available, repeat the following steps:
- * a. Read data_offset from where the user application should write data.
- * b. Write migration data starting at the migration region + data_offset for
- * the length determined by data_size from the migration source.
- * c. Write data_size, which indicates to the vendor driver that data is
- * written in the migration region. Vendor driver must return this write
- * operations on consuming data. Vendor driver should apply the
- * user-provided migration region data to the device resume state.
- *
- * If an error occurs during the above sequences, the vendor driver can return
- * an error code for next read() or write() operation, which will terminate the
- * loop. The user application should then take the next necessary action, for
- * example, failing migration or terminating the user application.
- *
- * For the user application, data is opaque. The user application should write
- * data in the same order as the data is received and the data should be of
- * same transaction size at the source.
- */
+#define VFIO_REGION_SUBTYPE_MIGRATION_DEPRECATED (1)
struct vfio_device_migration_info {
__u32 device_state; /* VFIO device state */
-#define VFIO_DEVICE_STATE_STOP (0)
-#define VFIO_DEVICE_STATE_RUNNING (1 << 0)
-#define VFIO_DEVICE_STATE_SAVING (1 << 1)
-#define VFIO_DEVICE_STATE_RESUMING (1 << 2)
-#define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_RUNNING | \
- VFIO_DEVICE_STATE_SAVING | \
- VFIO_DEVICE_STATE_RESUMING)
+#define VFIO_DEVICE_STATE_V1_STOP (0)
+#define VFIO_DEVICE_STATE_V1_RUNNING (1 << 0)
+#define VFIO_DEVICE_STATE_V1_SAVING (1 << 1)
+#define VFIO_DEVICE_STATE_V1_RESUMING (1 << 2)
+#define VFIO_DEVICE_STATE_MASK (VFIO_DEVICE_STATE_V1_RUNNING | \
+ VFIO_DEVICE_STATE_V1_SAVING | \
+ VFIO_DEVICE_STATE_V1_RESUMING)
#define VFIO_DEVICE_STATE_VALID(state) \
- (state & VFIO_DEVICE_STATE_RESUMING ? \
- (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_RESUMING : 1)
+ (state & VFIO_DEVICE_STATE_V1_RESUMING ? \
+ (state & VFIO_DEVICE_STATE_MASK) == VFIO_DEVICE_STATE_V1_RESUMING : 1)
#define VFIO_DEVICE_STATE_IS_ERROR(state) \
- ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_SAVING | \
- VFIO_DEVICE_STATE_RESUMING))
+ ((state & VFIO_DEVICE_STATE_MASK) == (VFIO_DEVICE_STATE_V1_SAVING | \
+ VFIO_DEVICE_STATE_V1_RESUMING))
#define VFIO_DEVICE_STATE_SET_ERROR(state) \
- ((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_SATE_SAVING | \
- VFIO_DEVICE_STATE_RESUMING)
+ ((state & ~VFIO_DEVICE_STATE_MASK) | VFIO_DEVICE_STATE_V1_SAVING | \
+ VFIO_DEVICE_STATE_V1_RESUMING)
__u32 reserved;
__u64 pending_bytes;
@@ -839,7 +647,7 @@ enum {
};
/**
- * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12,
+ * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12,
* struct vfio_pci_hot_reset_info)
*
* Return: 0 on success, -errno on failure:
@@ -966,7 +774,7 @@ struct vfio_device_ioeventfd {
#define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16)
/**
- * VFIO_DEVICE_FEATURE - _IORW(VFIO_TYPE, VFIO_BASE + 17,
+ * VFIO_DEVICE_FEATURE - _IOWR(VFIO_TYPE, VFIO_BASE + 17,
* struct vfio_device_feature)
*
* Get, set, or probe feature data of the device. The feature is selected
@@ -1002,6 +810,456 @@ struct vfio_device_feature {
*/
#define VFIO_DEVICE_FEATURE_PCI_VF_TOKEN (0)
+/*
+ * Indicates the device can support the migration API through
+ * VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE. If this GET succeeds, the RUNNING and
+ * ERROR states are always supported. Support for additional states is
+ * indicated via the flags field; at least VFIO_MIGRATION_STOP_COPY must be
+ * set.
+ *
+ * VFIO_MIGRATION_STOP_COPY means that STOP, STOP_COPY and
+ * RESUMING are supported.
+ *
+ * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P means that RUNNING_P2P
+ * is supported in addition to the STOP_COPY states.
+ *
+ * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_PRE_COPY means that
+ * PRE_COPY is supported in addition to the STOP_COPY states.
+ *
+ * VFIO_MIGRATION_STOP_COPY | VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY
+ * means that RUNNING_P2P, PRE_COPY and PRE_COPY_P2P are supported
+ * in addition to the STOP_COPY states.
+ *
+ * Other combinations of flags have behavior to be defined in the future.
+ */
+struct vfio_device_feature_migration {
+ __aligned_u64 flags;
+#define VFIO_MIGRATION_STOP_COPY (1 << 0)
+#define VFIO_MIGRATION_P2P (1 << 1)
+#define VFIO_MIGRATION_PRE_COPY (1 << 2)
+};
+#define VFIO_DEVICE_FEATURE_MIGRATION 1
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_SET, execute a migration state change on the VFIO
+ * device. The new state is supplied in device_state, see enum
+ * vfio_device_mig_state for details
+ *
+ * The kernel migration driver must fully transition the device to the new state
+ * value before the operation returns to the user.
+ *
+ * The kernel migration driver must not generate asynchronous device state
+ * transitions outside of manipulation by the user or the VFIO_DEVICE_RESET
+ * ioctl as described above.
+ *
+ * If this function fails then current device_state may be the original
+ * operating state or some other state along the combination transition path.
+ * The user can then decide if it should execute a VFIO_DEVICE_RESET, attempt
+ * to return to the original state, or attempt to return to some other state
+ * such as RUNNING or STOP.
+ *
+ * If the new_state starts a new data transfer session then the FD associated
+ * with that session is returned in data_fd. The user is responsible to close
+ * this FD when it is finished. The user must consider the migration data stream
+ * carried over the FD to be opaque and must preserve the byte order of the
+ * stream. The user is not required to preserve buffer segmentation when writing
+ * the data stream during the RESUMING operation.
+ *
+ * Upon VFIO_DEVICE_FEATURE_GET, get the current migration state of the VFIO
+ * device, data_fd will be -1.
+ */
+struct vfio_device_feature_mig_state {
+ __u32 device_state; /* From enum vfio_device_mig_state */
+ __s32 data_fd;
+};
+#define VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE 2
+
+/*
+ * The device migration Finite State Machine is described by the enum
+ * vfio_device_mig_state. Some of the FSM arcs will create a migration data
+ * transfer session by returning a FD, in this case the migration data will
+ * flow over the FD using read() and write() as discussed below.
+ *
+ * There are 5 states to support VFIO_MIGRATION_STOP_COPY:
+ * RUNNING - The device is running normally
+ * STOP - The device does not change the internal or external state
+ * STOP_COPY - The device internal state can be read out
+ * RESUMING - The device is stopped and is loading a new internal state
+ * ERROR - The device has failed and must be reset
+ *
+ * And optional states to support VFIO_MIGRATION_P2P:
+ * RUNNING_P2P - RUNNING, except the device cannot do peer to peer DMA
+ * And VFIO_MIGRATION_PRE_COPY:
+ * PRE_COPY - The device is running normally but tracking internal state
+ * changes
+ * And VFIO_MIGRATION_P2P | VFIO_MIGRATION_PRE_COPY:
+ * PRE_COPY_P2P - PRE_COPY, except the device cannot do peer to peer DMA
+ *
+ * The FSM takes actions on the arcs between FSM states. The driver implements
+ * the following behavior for the FSM arcs:
+ *
+ * RUNNING_P2P -> STOP
+ * STOP_COPY -> STOP
+ * While in STOP the device must stop the operation of the device. The device
+ * must not generate interrupts, DMA, or any other change to external state.
+ * It must not change its internal state. When stopped the device and kernel
+ * migration driver must accept and respond to interaction to support external
+ * subsystems in the STOP state, for example PCI MSI-X and PCI config space.
+ * Failure by the user to restrict device access while in STOP must not result
+ * in error conditions outside the user context (ex. host system faults).
+ *
+ * The STOP_COPY arc will terminate a data transfer session.
+ *
+ * RESUMING -> STOP
+ * Leaving RESUMING terminates a data transfer session and indicates the
+ * device should complete processing of the data delivered by write(). The
+ * kernel migration driver should complete the incorporation of data written
+ * to the data transfer FD into the device internal state and perform
+ * final validity and consistency checking of the new device state. If the
+ * user provided data is found to be incomplete, inconsistent, or otherwise
+ * invalid, the migration driver must fail the SET_STATE ioctl and
+ * optionally go to the ERROR state as described below.
+ *
+ * While in STOP the device has the same behavior as other STOP states
+ * described above.
+ *
+ * To abort a RESUMING session the device must be reset.
+ *
+ * PRE_COPY -> RUNNING
+ * RUNNING_P2P -> RUNNING
+ * While in RUNNING the device is fully operational, the device may generate
+ * interrupts, DMA, respond to MMIO, all vfio device regions are functional,
+ * and the device may advance its internal state.
+ *
+ * The PRE_COPY arc will terminate a data transfer session.
+ *
+ * PRE_COPY_P2P -> RUNNING_P2P
+ * RUNNING -> RUNNING_P2P
+ * STOP -> RUNNING_P2P
+ * While in RUNNING_P2P the device is partially running in the P2P quiescent
+ * state defined below.
+ *
+ * The PRE_COPY_P2P arc will terminate a data transfer session.
+ *
+ * RUNNING -> PRE_COPY
+ * RUNNING_P2P -> PRE_COPY_P2P
+ * STOP -> STOP_COPY
+ * PRE_COPY, PRE_COPY_P2P and STOP_COPY form the "saving group" of states
+ * which share a data transfer session. Moving between these states alters
+ * what is streamed in session, but does not terminate or otherwise affect
+ * the associated fd.
+ *
+ * These arcs begin the process of saving the device state and will return a
+ * new data_fd. The migration driver may perform actions such as enabling
+ * dirty logging of device state when entering PRE_COPY or PER_COPY_P2P.
+ *
+ * Each arc does not change the device operation, the device remains
+ * RUNNING, P2P quiesced or in STOP. The STOP_COPY state is described below
+ * in PRE_COPY_P2P -> STOP_COPY.
+ *
+ * PRE_COPY -> PRE_COPY_P2P
+ * Entering PRE_COPY_P2P continues all the behaviors of PRE_COPY above.
+ * However, while in the PRE_COPY_P2P state, the device is partially running
+ * in the P2P quiescent state defined below, like RUNNING_P2P.
+ *
+ * PRE_COPY_P2P -> PRE_COPY
+ * This arc allows returning the device to a full RUNNING behavior while
+ * continuing all the behaviors of PRE_COPY.
+ *
+ * PRE_COPY_P2P -> STOP_COPY
+ * While in the STOP_COPY state the device has the same behavior as STOP
+ * with the addition that the data transfers session continues to stream the
+ * migration state. End of stream on the FD indicates the entire device
+ * state has been transferred.
+ *
+ * The user should take steps to restrict access to vfio device regions while
+ * the device is in STOP_COPY or risk corruption of the device migration data
+ * stream.
+ *
+ * STOP -> RESUMING
+ * Entering the RESUMING state starts a process of restoring the device state
+ * and will return a new data_fd. The data stream fed into the data_fd should
+ * be taken from the data transfer output of a single FD during saving from
+ * a compatible device. The migration driver may alter/reset the internal
+ * device state for this arc if required to prepare the device to receive the
+ * migration data.
+ *
+ * STOP_COPY -> PRE_COPY
+ * STOP_COPY -> PRE_COPY_P2P
+ * These arcs are not permitted and return error if requested. Future
+ * revisions of this API may define behaviors for these arcs, in this case
+ * support will be discoverable by a new flag in
+ * VFIO_DEVICE_FEATURE_MIGRATION.
+ *
+ * any -> ERROR
+ * ERROR cannot be specified as a device state, however any transition request
+ * can be failed with an errno return and may then move the device_state into
+ * ERROR. In this case the device was unable to execute the requested arc and
+ * was also unable to restore the device to any valid device_state.
+ * To recover from ERROR VFIO_DEVICE_RESET must be used to return the
+ * device_state back to RUNNING.
+ *
+ * The optional peer to peer (P2P) quiescent state is intended to be a quiescent
+ * state for the device for the purposes of managing multiple devices within a
+ * user context where peer-to-peer DMA between devices may be active. The
+ * RUNNING_P2P and PRE_COPY_P2P states must prevent the device from initiating
+ * any new P2P DMA transactions. If the device can identify P2P transactions
+ * then it can stop only P2P DMA, otherwise it must stop all DMA. The migration
+ * driver must complete any such outstanding operations prior to completing the
+ * FSM arc into a P2P state. For the purpose of specification the states
+ * behave as though the device was fully running if not supported. Like while in
+ * STOP or STOP_COPY the user must not touch the device, otherwise the state
+ * can be exited.
+ *
+ * The remaining possible transitions are interpreted as combinations of the
+ * above FSM arcs. As there are multiple paths through the FSM arcs the path
+ * should be selected based on the following rules:
+ * - Select the shortest path.
+ * - The path cannot have saving group states as interior arcs, only
+ * starting/end states.
+ * Refer to vfio_mig_get_next_state() for the result of the algorithm.
+ *
+ * The automatic transit through the FSM arcs that make up the combination
+ * transition is invisible to the user. When working with combination arcs the
+ * user may see any step along the path in the device_state if SET_STATE
+ * fails. When handling these types of errors users should anticipate future
+ * revisions of this protocol using new states and those states becoming
+ * visible in this case.
+ *
+ * The optional states cannot be used with SET_STATE if the device does not
+ * support them. The user can discover if these states are supported by using
+ * VFIO_DEVICE_FEATURE_MIGRATION. By using combination transitions the user can
+ * avoid knowing about these optional states if the kernel driver supports them.
+ *
+ * Arcs touching PRE_COPY and PRE_COPY_P2P are removed if support for PRE_COPY
+ * is not present.
+ */
+enum vfio_device_mig_state {
+ VFIO_DEVICE_STATE_ERROR = 0,
+ VFIO_DEVICE_STATE_STOP = 1,
+ VFIO_DEVICE_STATE_RUNNING = 2,
+ VFIO_DEVICE_STATE_STOP_COPY = 3,
+ VFIO_DEVICE_STATE_RESUMING = 4,
+ VFIO_DEVICE_STATE_RUNNING_P2P = 5,
+ VFIO_DEVICE_STATE_PRE_COPY = 6,
+ VFIO_DEVICE_STATE_PRE_COPY_P2P = 7,
+};
+
+/**
+ * VFIO_MIG_GET_PRECOPY_INFO - _IO(VFIO_TYPE, VFIO_BASE + 21)
+ *
+ * This ioctl is used on the migration data FD in the precopy phase of the
+ * migration data transfer. It returns an estimate of the current data sizes
+ * remaining to be transferred. It allows the user to judge when it is
+ * appropriate to leave PRE_COPY for STOP_COPY.
+ *
+ * This ioctl is valid only in PRE_COPY states and kernel driver should
+ * return -EINVAL from any other migration state.
+ *
+ * The vfio_precopy_info data structure returned by this ioctl provides
+ * estimates of data available from the device during the PRE_COPY states.
+ * This estimate is split into two categories, initial_bytes and
+ * dirty_bytes.
+ *
+ * The initial_bytes field indicates the amount of initial precopy
+ * data available from the device. This field should have a non-zero initial
+ * value and decrease as migration data is read from the device.
+ * It is recommended to leave PRE_COPY for STOP_COPY only after this field
+ * reaches zero. Leaving PRE_COPY earlier might make things slower.
+ *
+ * The dirty_bytes field tracks device state changes relative to data
+ * previously retrieved. This field starts at zero and may increase as
+ * the internal device state is modified or decrease as that modified
+ * state is read from the device.
+ *
+ * Userspace may use the combination of these fields to estimate the
+ * potential data size available during the PRE_COPY phases, as well as
+ * trends relative to the rate the device is dirtying its internal
+ * state, but these fields are not required to have any bearing relative
+ * to the data size available during the STOP_COPY phase.
+ *
+ * Drivers have a lot of flexibility in when and what they transfer during the
+ * PRE_COPY phase, and how they report this from VFIO_MIG_GET_PRECOPY_INFO.
+ *
+ * During pre-copy the migration data FD has a temporary "end of stream" that is
+ * reached when both initial_bytes and dirty_byte are zero. For instance, this
+ * may indicate that the device is idle and not currently dirtying any internal
+ * state. When read() is done on this temporary end of stream the kernel driver
+ * should return ENOMSG from read(). Userspace can wait for more data (which may
+ * never come) by using poll.
+ *
+ * Once in STOP_COPY the migration data FD has a permanent end of stream
+ * signaled in the usual way by read() always returning 0 and poll always
+ * returning readable. ENOMSG may not be returned in STOP_COPY.
+ * Support for this ioctl is mandatory if a driver claims to support
+ * VFIO_MIGRATION_PRE_COPY.
+ *
+ * Return: 0 on success, -1 and errno set on failure.
+ */
+struct vfio_precopy_info {
+ __u32 argsz;
+ __u32 flags;
+ __aligned_u64 initial_bytes;
+ __aligned_u64 dirty_bytes;
+};
+
+#define VFIO_MIG_GET_PRECOPY_INFO _IO(VFIO_TYPE, VFIO_BASE + 21)
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_SET, allow the device to be moved into a low power
+ * state with the platform-based power management. Device use of lower power
+ * states depends on factors managed by the runtime power management core,
+ * including system level support and coordinating support among dependent
+ * devices. Enabling device low power entry does not guarantee lower power
+ * usage by the device, nor is a mechanism provided through this feature to
+ * know the current power state of the device. If any device access happens
+ * (either from the host or through the vfio uAPI) when the device is in the
+ * low power state, then the host will move the device out of the low power
+ * state as necessary prior to the access. Once the access is completed, the
+ * device may re-enter the low power state. For single shot low power support
+ * with wake-up notification, see
+ * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP below. Access to mmap'd
+ * device regions is disabled on LOW_POWER_ENTRY and may only be resumed after
+ * calling LOW_POWER_EXIT.
+ */
+#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY 3
+
+/*
+ * This device feature has the same behavior as
+ * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY with the exception that the user
+ * provides an eventfd for wake-up notification. When the device moves out of
+ * the low power state for the wake-up, the host will not allow the device to
+ * re-enter a low power state without a subsequent user call to one of the low
+ * power entry device feature IOCTLs. Access to mmap'd device regions is
+ * disabled on LOW_POWER_ENTRY_WITH_WAKEUP and may only be resumed after the
+ * low power exit. The low power exit can happen either through LOW_POWER_EXIT
+ * or through any other access (where the wake-up notification has been
+ * generated). The access to mmap'd device regions will not trigger low power
+ * exit.
+ *
+ * The notification through the provided eventfd will be generated only when
+ * the device has entered and is resumed from a low power state after
+ * calling this device feature IOCTL. A device that has not entered low power
+ * state, as managed through the runtime power management core, will not
+ * generate a notification through the provided eventfd on access. Calling the
+ * LOW_POWER_EXIT feature is optional in the case where notification has been
+ * signaled on the provided eventfd that a resume from low power has occurred.
+ */
+struct vfio_device_low_power_entry_with_wakeup {
+ __s32 wakeup_eventfd;
+ __u32 reserved;
+};
+
+#define VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP 4
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_SET, disallow use of device low power states as
+ * previously enabled via VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY or
+ * VFIO_DEVICE_FEATURE_LOW_POWER_ENTRY_WITH_WAKEUP device features.
+ * This device feature IOCTL may itself generate a wakeup eventfd notification
+ * in the latter case if the device had previously entered a low power state.
+ */
+#define VFIO_DEVICE_FEATURE_LOW_POWER_EXIT 5
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_SET start/stop device DMA logging.
+ * VFIO_DEVICE_FEATURE_PROBE can be used to detect if the device supports
+ * DMA logging.
+ *
+ * DMA logging allows a device to internally record what DMAs the device is
+ * initiating and report them back to userspace. It is part of the VFIO
+ * migration infrastructure that allows implementing dirty page tracking
+ * during the pre copy phase of live migration. Only DMA WRITEs are logged,
+ * and this API is not connected to VFIO_DEVICE_FEATURE_MIG_DEVICE_STATE.
+ *
+ * When DMA logging is started a range of IOVAs to monitor is provided and the
+ * device can optimize its logging to cover only the IOVA range given. Each
+ * DMA that the device initiates inside the range will be logged by the device
+ * for later retrieval.
+ *
+ * page_size is an input that hints what tracking granularity the device
+ * should try to achieve. If the device cannot do the hinted page size then
+ * it's the driver choice which page size to pick based on its support.
+ * On output the device will return the page size it selected.
+ *
+ * ranges is a pointer to an array of
+ * struct vfio_device_feature_dma_logging_range.
+ *
+ * The core kernel code guarantees to support by minimum num_ranges that fit
+ * into a single kernel page. User space can try higher values but should give
+ * up if the above can't be achieved as of some driver limitations.
+ *
+ * A single call to start device DMA logging can be issued and a matching stop
+ * should follow at the end. Another start is not allowed in the meantime.
+ */
+struct vfio_device_feature_dma_logging_control {
+ __aligned_u64 page_size;
+ __u32 num_ranges;
+ __u32 __reserved;
+ __aligned_u64 ranges;
+};
+
+struct vfio_device_feature_dma_logging_range {
+ __aligned_u64 iova;
+ __aligned_u64 length;
+};
+
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_START 6
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_SET stop device DMA logging that was started
+ * by VFIO_DEVICE_FEATURE_DMA_LOGGING_START
+ */
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_STOP 7
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_GET read back and clear the device DMA log
+ *
+ * Query the device's DMA log for written pages within the given IOVA range.
+ * During querying the log is cleared for the IOVA range.
+ *
+ * bitmap is a pointer to an array of u64s that will hold the output bitmap
+ * with 1 bit reporting a page_size unit of IOVA. The mapping of IOVA to bits
+ * is given by:
+ * bitmap[(addr - iova)/page_size] & (1ULL << (addr % 64))
+ *
+ * The input page_size can be any power of two value and does not have to
+ * match the value given to VFIO_DEVICE_FEATURE_DMA_LOGGING_START. The driver
+ * will format its internal logging to match the reporting page size, possibly
+ * by replicating bits if the internal page size is lower than requested.
+ *
+ * The LOGGING_REPORT will only set bits in the bitmap and never clear or
+ * perform any initialization of the user provided bitmap.
+ *
+ * If any error is returned userspace should assume that the dirty log is
+ * corrupted. Error recovery is to consider all memory dirty and try to
+ * restart the dirty tracking, or to abort/restart the whole migration.
+ *
+ * If DMA logging is not enabled, an error will be returned.
+ *
+ */
+struct vfio_device_feature_dma_logging_report {
+ __aligned_u64 iova;
+ __aligned_u64 length;
+ __aligned_u64 page_size;
+ __aligned_u64 bitmap;
+};
+
+#define VFIO_DEVICE_FEATURE_DMA_LOGGING_REPORT 8
+
+/*
+ * Upon VFIO_DEVICE_FEATURE_GET read back the estimated data length that will
+ * be required to complete stop copy.
+ *
+ * Note: Can be called on each device state.
+ */
+
+struct vfio_device_feature_mig_data_size {
+ __aligned_u64 stop_copy_length;
+};
+
+#define VFIO_DEVICE_FEATURE_MIG_DATA_SIZE 9
+
/* -------- API for Type1 VFIO IOMMU -------- */
/**
@@ -1089,8 +1347,7 @@ struct vfio_iommu_type1_info_dma_avail {
* Map process virtual addresses to IO virtual addresses using the
* provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required.
*
- * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova, and
- * unblock translation of host virtual addresses in the iova range. The vaddr
+ * If flags & VFIO_DMA_MAP_FLAG_VADDR, update the base vaddr for iova. The vaddr
* must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To
* maintain memory consistency within the user application, the updated vaddr
* must address the same memory object as originally mapped. Failure to do so
@@ -1141,9 +1398,9 @@ struct vfio_bitmap {
* must be 0. This cannot be combined with the get-dirty-bitmap flag.
*
* If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host
- * virtual addresses in the iova range. Tasks that attempt to translate an
- * iova's vaddr will block. DMA to already-mapped pages continues. This
- * cannot be combined with the get-dirty-bitmap flag.
+ * virtual addresses in the iova range. DMA to already-mapped pages continues.
+ * Groups may not be added to the container while any addresses are invalid.
+ * This cannot be combined with the get-dirty-bitmap flag.
*/
struct vfio_iommu_type1_dma_unmap {
__u32 argsz;
diff --git a/lib/libc/include/any-linux-any/linux/vfio_zdev.h b/lib/libc/include/any-linux-any/linux/vfio_zdev.h
index 2d87f16eb4..1ef924930f 100644
--- a/lib/libc/include/any-linux-any/linux/vfio_zdev.h
+++ b/lib/libc/include/any-linux-any/linux/vfio_zdev.h
@@ -29,6 +29,9 @@ struct vfio_device_info_cap_zpci_base {
__u16 fmb_length; /* Measurement Block Length (in bytes) */
__u8 pft; /* PCI Function Type */
__u8 gid; /* PCI function group ID */
+ /* End of version 1 */
+ __u32 fh; /* PCI function handle */
+ /* End of version 2 */
};
/**
@@ -47,6 +50,10 @@ struct vfio_device_info_cap_zpci_group {
__u16 noi; /* Maximum number of MSIs */
__u16 maxstbl; /* Maximum Store Block Length */
__u8 version; /* Supported PCI Version */
+ /* End of version 1 */
+ __u8 reserved;
+ __u16 imaxstbl; /* Maximum Interpreted Store Block Length */
+ /* End of version 2 */
};
/**
diff --git a/lib/libc/include/any-linux-any/linux/vhost.h b/lib/libc/include/any-linux-any/linux/vhost.h
index ae9a62845a..c2872e98e3 100644
--- a/lib/libc/include/any-linux-any/linux/vhost.h
+++ b/lib/libc/include/any-linux-any/linux/vhost.h
@@ -89,11 +89,6 @@
/* Set or get vhost backend capability */
-/* Use message type V2 */
-#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
-/* IOTLB can accept batching hints */
-#define VHOST_BACKEND_F_IOTLB_BATCH 0x2
-
#define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
@@ -150,4 +145,47 @@
/* Get the valid iova range */
#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \
struct vhost_vdpa_iova_range)
+/* Get the config size */
+#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32)
+
+/* Get the count of all virtqueues */
+#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
+
+/* Get the number of virtqueue groups. */
+#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32)
+
+/* Get the number of address spaces. */
+#define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int)
+
+/* Get the group for a virtqueue: read index, write group in num,
+ * The virtqueue index is stored in the index field of
+ * vhost_vring_state. The group for this specific virtqueue is
+ * returned via num field of vhost_vring_state.
+ */
+#define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, \
+ struct vhost_vring_state)
+/* Set the ASID for a virtqueue group. The group index is stored in
+ * the index field of vhost_vring_state, the ASID associated with this
+ * group is stored at num field of vhost_vring_state.
+ */
+#define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \
+ struct vhost_vring_state)
+
+/* Suspend a device so it does not process virtqueue requests anymore
+ *
+ * After the return of ioctl the device must preserve all the necessary state
+ * (the virtqueue vring base plus the possible device specific states) that is
+ * required for restoring in the future. The device must not change its
+ * configuration after that point.
+ */
+#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D)
+
+/* Resume a device so it can resume processing virtqueue requests
+ *
+ * After the return of this ioctl the device will have restored all the
+ * necessary states and it is fully operational to continue processing the
+ * virtqueue descriptors.
+ */
+#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E)
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/vhost_types.h b/lib/libc/include/any-linux-any/linux/vhost_types.h
index a611a3397e..ec842259e6 100644
--- a/lib/libc/include/any-linux-any/linux/vhost_types.h
+++ b/lib/libc/include/any-linux-any/linux/vhost_types.h
@@ -87,7 +87,7 @@ struct vhost_msg {
struct vhost_msg_v2 {
__u32 type;
- __u32 reserved;
+ __u32 asid;
union {
struct vhost_iotlb_msg iotlb;
__u8 padding[64];
@@ -107,7 +107,7 @@ struct vhost_memory_region {
struct vhost_memory {
__u32 nregions;
__u32 padding;
- struct vhost_memory_region regions[0];
+ struct vhost_memory_region regions[];
};
/* VHOST_SCSI specific definitions */
@@ -135,7 +135,7 @@ struct vhost_scsi_target {
struct vhost_vdpa_config {
__u32 off;
__u32 len;
- __u8 buf[0];
+ __u8 buf[];
};
/* vhost vdpa IOVA range
@@ -153,4 +153,17 @@ struct vhost_vdpa_iova_range {
/* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */
#define VHOST_NET_F_VIRTIO_NET_HDR 27
+/* Use message type V2 */
+#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
+/* IOTLB can accept batching hints */
+#define VHOST_BACKEND_F_IOTLB_BATCH 0x2
+/* IOTLB can accept address space identifier through V2 type of IOTLB
+ * message
+ */
+#define VHOST_BACKEND_F_IOTLB_ASID 0x3
+/* Device can be suspended */
+#define VHOST_BACKEND_F_SUSPEND 0x4
+/* Device can be resumed */
+#define VHOST_BACKEND_F_RESUME 0x5
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/videodev2.h b/lib/libc/include/any-linux-any/linux/videodev2.h
index ba715dc368..13202eb3aa 100644
--- a/lib/libc/include/any-linux-any/linux/videodev2.h
+++ b/lib/libc/include/any-linux-any/linux/videodev2.h
@@ -243,6 +243,7 @@ enum v4l2_colorspace {
/* DCI-P3 colorspace, used by cinema projectors */
V4L2_COLORSPACE_DCI_P3 = 12,
+
};
/*
@@ -474,7 +475,6 @@ struct v4l2_capability {
#define V4L2_CAP_META_CAPTURE 0x00800000 /* Is a metadata capture device */
#define V4L2_CAP_READWRITE 0x01000000 /* read/write systemcalls */
-#define V4L2_CAP_ASYNCIO 0x02000000 /* async I/O */
#define V4L2_CAP_STREAMING 0x04000000 /* streaming I/O ioctls */
#define V4L2_CAP_META_OUTPUT 0x08000000 /* Is a metadata output device */
@@ -549,6 +549,9 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_RGBX32 v4l2_fourcc('X', 'B', '2', '4') /* 32 RGBX-8-8-8-8 */
#define V4L2_PIX_FMT_ARGB32 v4l2_fourcc('B', 'A', '2', '4') /* 32 ARGB-8-8-8-8 */
#define V4L2_PIX_FMT_XRGB32 v4l2_fourcc('B', 'X', '2', '4') /* 32 XRGB-8-8-8-8 */
+#define V4L2_PIX_FMT_RGBX1010102 v4l2_fourcc('R', 'X', '3', '0') /* 32 RGBX-10-10-10-2 */
+#define V4L2_PIX_FMT_RGBA1010102 v4l2_fourcc('R', 'A', '3', '0') /* 32 RGBA-10-10-10-2 */
+#define V4L2_PIX_FMT_ARGB2101010 v4l2_fourcc('A', 'R', '3', '0') /* 32 ARGB-2-10-10-10 */
/* Grey formats */
#define V4L2_PIX_FMT_GREY v4l2_fourcc('G', 'R', 'E', 'Y') /* 8 Greyscale */
@@ -563,6 +566,7 @@ struct v4l2_pix_format {
/* Grey bit-packed formats */
#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B') /* 10 Greyscale bit-packed */
#define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P') /* 10 Greyscale, MIPI RAW10 packed */
+#define V4L2_PIX_FMT_IPU3_Y10 v4l2_fourcc('i', 'p', '3', 'y') /* IPU3 packed 10-bit greyscale */
/* Palette formats */
#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8') /* 8 8-bit palette */
@@ -586,8 +590,18 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_XYUV32 v4l2_fourcc('X', 'Y', 'U', 'V') /* 32 XYUV-8-8-8-8 */
#define V4L2_PIX_FMT_VUYA32 v4l2_fourcc('V', 'U', 'Y', 'A') /* 32 VUYA-8-8-8-8 */
#define V4L2_PIX_FMT_VUYX32 v4l2_fourcc('V', 'U', 'Y', 'X') /* 32 VUYX-8-8-8-8 */
+#define V4L2_PIX_FMT_YUVA32 v4l2_fourcc('Y', 'U', 'V', 'A') /* 32 YUVA-8-8-8-8 */
+#define V4L2_PIX_FMT_YUVX32 v4l2_fourcc('Y', 'U', 'V', 'X') /* 32 YUVX-8-8-8-8 */
#define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */
+/*
+ * YCbCr packed format. For each Y2xx format, xx bits of valid data occupy the MSBs
+ * of the 16 bit components, and 16-xx bits of zero padding occupy the LSBs.
+ */
+#define V4L2_PIX_FMT_Y210 v4l2_fourcc('Y', '2', '1', '0') /* 32 YUYV 4:2:2 */
+#define V4L2_PIX_FMT_Y212 v4l2_fourcc('Y', '2', '1', '2') /* 32 YUYV 4:2:2 */
+#define V4L2_PIX_FMT_Y216 v4l2_fourcc('Y', '2', '1', '6') /* 32 YUYV 4:2:2 */
+
/* two planes -- one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12 v4l2_fourcc('N', 'V', '1', '2') /* 12 Y/CbCr 4:2:0 */
#define V4L2_PIX_FMT_NV21 v4l2_fourcc('N', 'V', '2', '1') /* 12 Y/CrCb 4:2:0 */
@@ -595,6 +609,7 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_NV61 v4l2_fourcc('N', 'V', '6', '1') /* 16 Y/CrCb 4:2:2 */
#define V4L2_PIX_FMT_NV24 v4l2_fourcc('N', 'V', '2', '4') /* 24 Y/CbCr 4:4:4 */
#define V4L2_PIX_FMT_NV42 v4l2_fourcc('N', 'V', '4', '2') /* 24 Y/CrCb 4:4:4 */
+#define V4L2_PIX_FMT_P010 v4l2_fourcc('P', '0', '1', '0') /* 24 Y/CbCr 4:2:0 10-bit per component */
/* two non contiguous planes - one Y, one Cr + Cb interleaved */
#define V4L2_PIX_FMT_NV12M v4l2_fourcc('N', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 */
@@ -622,10 +637,15 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_NV12_4L4 v4l2_fourcc('V', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 4x4 tiles */
#define V4L2_PIX_FMT_NV12_16L16 v4l2_fourcc('H', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 tiles */
#define V4L2_PIX_FMT_NV12_32L32 v4l2_fourcc('S', 'T', '1', '2') /* 12 Y/CbCr 4:2:0 32x32 tiles */
+#define V4L2_PIX_FMT_P010_4L4 v4l2_fourcc('T', '0', '1', '0') /* 12 Y/CbCr 4:2:0 10-bit 4x4 macroblocks */
+#define V4L2_PIX_FMT_NV12_8L128 v4l2_fourcc('A', 'T', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */
+#define V4L2_PIX_FMT_NV12_10BE_8L128 v4l2_fourcc_be('A', 'X', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */
/* Tiled YUV formats, non contiguous planes */
#define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 tiles */
#define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 tiles */
+#define V4L2_PIX_FMT_NV12M_8L128 v4l2_fourcc('N', 'A', '1', '2') /* Y/CbCr 4:2:0 8x128 tiles */
+#define V4L2_PIX_FMT_NV12M_10BE_8L128 v4l2_fourcc_be('N', 'T', '1', '2') /* Y/CbCr 4:2:0 10-bit 8x128 tiles */
/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
#define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B', 'A', '8', '1') /* 8 BGBG.. GRGR.. */
@@ -697,10 +717,12 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_VP8 v4l2_fourcc('V', 'P', '8', '0') /* VP8 */
#define V4L2_PIX_FMT_VP8_FRAME v4l2_fourcc('V', 'P', '8', 'F') /* VP8 parsed frame */
#define V4L2_PIX_FMT_VP9 v4l2_fourcc('V', 'P', '9', '0') /* VP9 */
+#define V4L2_PIX_FMT_VP9_FRAME v4l2_fourcc('V', 'P', '9', 'F') /* VP9 parsed frame */
#define V4L2_PIX_FMT_HEVC v4l2_fourcc('H', 'E', 'V', 'C') /* HEVC aka H.265 */
#define V4L2_PIX_FMT_FWHT v4l2_fourcc('F', 'W', 'H', 'T') /* Fast Walsh Hadamard Transform (vicodec) */
#define V4L2_PIX_FMT_FWHT_STATELESS v4l2_fourcc('S', 'F', 'W', 'H') /* Stateless FWHT (vicodec) */
#define V4L2_PIX_FMT_H264_SLICE v4l2_fourcc('S', '2', '6', '4') /* H264 parsed slices */
+#define V4L2_PIX_FMT_HEVC_SLICE v4l2_fourcc('S', '2', '6', '5') /* HEVC parsed slices */
/* Vendor-specific formats */
#define V4L2_PIX_FMT_CPIA1 v4l2_fourcc('C', 'P', 'I', 'A') /* cpia1 YUV */
@@ -737,8 +759,11 @@ struct v4l2_pix_format {
#define V4L2_PIX_FMT_INZI v4l2_fourcc('I', 'N', 'Z', 'I') /* Intel Planar Greyscale 10-bit and Depth 16-bit */
#define V4L2_PIX_FMT_CNF4 v4l2_fourcc('C', 'N', 'F', '4') /* Intel 4-bit packed depth confidence information */
#define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* BTTV 8-bit dithered RGB */
+#define V4L2_PIX_FMT_QC08C v4l2_fourcc('Q', '0', '8', 'C') /* Qualcomm 8-bit compressed */
+#define V4L2_PIX_FMT_QC10C v4l2_fourcc('Q', '1', '0', 'C') /* Qualcomm 10-bit compressed */
+#define V4L2_PIX_FMT_AJPG v4l2_fourcc('A', 'J', 'P', 'G') /* Aspeed JPEG */
-/* 10bit raw bayer packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
+/* 10bit raw packed, 32 bytes for every 25 pixels, last LSB 6 bits unused */
#define V4L2_PIX_FMT_IPU3_SBGGR10 v4l2_fourcc('i', 'p', '3', 'b') /* IPU3 packed 10-bit BGGR bayer */
#define V4L2_PIX_FMT_IPU3_SGBRG10 v4l2_fourcc('i', 'p', '3', 'g') /* IPU3 packed 10-bit GBRG bayer */
#define V4L2_PIX_FMT_IPU3_SGRBG10 v4l2_fourcc('i', 'p', '3', 'G') /* IPU3 packed 10-bit GRBG bayer */
@@ -1540,7 +1565,8 @@ struct v4l2_bt_timings {
((bt)->width + V4L2_DV_BT_BLANKING_WIDTH(bt))
#define V4L2_DV_BT_BLANKING_HEIGHT(bt) \
((bt)->vfrontporch + (bt)->vsync + (bt)->vbackporch + \
- (bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch)
+ ((bt)->interlaced ? \
+ ((bt)->il_vfrontporch + (bt)->il_vsync + (bt)->il_vbackporch) : 0))
#define V4L2_DV_BT_FRAME_HEIGHT(bt) \
((bt)->height + V4L2_DV_BT_BLANKING_HEIGHT(bt))
@@ -1718,6 +1744,8 @@ struct v4l2_ext_control {
__u8 *p_u8;
__u16 *p_u16;
__u32 *p_u32;
+ __u32 *p_s32;
+ __u32 *p_s64;
struct v4l2_area *p_area;
struct v4l2_ctrl_h264_sps *p_h264_sps;
struct v4l2_ctrl_h264_pps *p_h264_pps;
@@ -1730,6 +1758,13 @@ struct v4l2_ext_control {
struct v4l2_ctrl_mpeg2_sequence *p_mpeg2_sequence;
struct v4l2_ctrl_mpeg2_picture *p_mpeg2_picture;
struct v4l2_ctrl_mpeg2_quantisation *p_mpeg2_quantisation;
+ struct v4l2_ctrl_vp9_compressed_hdr *p_vp9_compressed_hdr_probs;
+ struct v4l2_ctrl_vp9_frame *p_vp9_frame;
+ struct v4l2_ctrl_hevc_sps *p_hevc_sps;
+ struct v4l2_ctrl_hevc_pps *p_hevc_pps;
+ struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
+ struct v4l2_ctrl_hevc_scaling_matrix *p_hevc_scaling_matrix;
+ struct v4l2_ctrl_hevc_decode_params *p_hevc_decode_params;
void *ptr;
};
} __attribute__ ((packed));
@@ -1790,6 +1825,15 @@ enum v4l2_ctrl_type {
V4L2_CTRL_TYPE_MPEG2_QUANTISATION = 0x0250,
V4L2_CTRL_TYPE_MPEG2_SEQUENCE = 0x0251,
V4L2_CTRL_TYPE_MPEG2_PICTURE = 0x0252,
+
+ V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR = 0x0260,
+ V4L2_CTRL_TYPE_VP9_FRAME = 0x0261,
+
+ V4L2_CTRL_TYPE_HEVC_SPS = 0x0270,
+ V4L2_CTRL_TYPE_HEVC_PPS = 0x0271,
+ V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS = 0x0272,
+ V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX = 0x0273,
+ V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS = 0x0274,
};
/* Used in the VIDIOC_QUERYCTRL ioctl for querying controls */
@@ -1845,6 +1889,7 @@ struct v4l2_querymenu {
#define V4L2_CTRL_FLAG_HAS_PAYLOAD 0x0100
#define V4L2_CTRL_FLAG_EXECUTE_ON_WRITE 0x0200
#define V4L2_CTRL_FLAG_MODIFY_LAYOUT 0x0400
+#define V4L2_CTRL_FLAG_DYNAMIC_ARRAY 0x0800
/* Query flags, to be ORed with the control ID */
#define V4L2_CTRL_FLAG_NEXT_CTRL 0x80000000
@@ -2352,6 +2397,7 @@ struct v4l2_event_vsync {
#define V4L2_EVENT_CTRL_CH_VALUE (1 << 0)
#define V4L2_EVENT_CTRL_CH_FLAGS (1 << 1)
#define V4L2_EVENT_CTRL_CH_RANGE (1 << 2)
+#define V4L2_EVENT_CTRL_CH_DIMENSIONS (1 << 3)
struct v4l2_event_ctrl {
__u32 changes;
@@ -2594,5 +2640,10 @@ struct v4l2_create_buffers {
/* Deprecated definitions kept for backwards compatibility */
#define V4L2_PIX_FMT_HM12 V4L2_PIX_FMT_NV12_16L16
#define V4L2_PIX_FMT_SUNXI_TILED_NV12 V4L2_PIX_FMT_NV12_32L32
+/*
+ * This capability was never implemented, anyone using this cap should drop it
+ * from their code.
+ */
+#define V4L2_CAP_ASYNCIO 0x02000000
#endif /* __LINUX_VIDEODEV2_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_9p.h b/lib/libc/include/any-linux-any/linux/virtio_9p.h
index b56dfa0b3a..3efcd83041 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_9p.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_9p.h
@@ -38,7 +38,7 @@ struct virtio_9p_config {
/* length of the tag name */
__virtio16 tag_len;
/* non-NULL terminated tag name */
- __u8 tag[0];
+ __u8 tag[];
} __attribute__((packed));
#endif /* _LINUX_VIRTIO_9P_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_blk.h b/lib/libc/include/any-linux-any/linux/virtio_blk.h
index a5a91e4346..ec674c4604 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_blk.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_blk.h
@@ -40,6 +40,8 @@
#define VIRTIO_BLK_F_MQ 12 /* support more than one vq */
#define VIRTIO_BLK_F_DISCARD 13 /* DISCARD is supported */
#define VIRTIO_BLK_F_WRITE_ZEROES 14 /* WRITE ZEROES is supported */
+#define VIRTIO_BLK_F_SECURE_ERASE 16 /* Secure Erase is supported */
+#define VIRTIO_BLK_F_ZONED 17 /* Zoned block device */
/* Legacy feature bits */
#ifndef VIRTIO_BLK_NO_LEGACY
@@ -119,6 +121,31 @@ struct virtio_blk_config {
__u8 write_zeroes_may_unmap;
__u8 unused1[3];
+
+ /* the next 3 entries are guarded by VIRTIO_BLK_F_SECURE_ERASE */
+ /*
+ * The maximum secure erase sectors (in 512-byte sectors) for
+ * one segment.
+ */
+ __virtio32 max_secure_erase_sectors;
+ /*
+ * The maximum number of secure erase segments in a
+ * secure erase command.
+ */
+ __virtio32 max_secure_erase_seg;
+ /* Secure erase commands must be aligned to this number of sectors. */
+ __virtio32 secure_erase_sector_alignment;
+
+ /* Zoned block device characteristics (if VIRTIO_BLK_F_ZONED) */
+ struct virtio_blk_zoned_characteristics {
+ __virtio32 zone_sectors;
+ __virtio32 max_open_zones;
+ __virtio32 max_active_zones;
+ __virtio32 max_append_sectors;
+ __virtio32 write_granularity;
+ __u8 model;
+ __u8 unused2[3];
+ } zoned;
} __attribute__((packed));
/*
@@ -153,6 +180,30 @@ struct virtio_blk_config {
/* Write zeroes command */
#define VIRTIO_BLK_T_WRITE_ZEROES 13
+/* Secure erase command */
+#define VIRTIO_BLK_T_SECURE_ERASE 14
+
+/* Zone append command */
+#define VIRTIO_BLK_T_ZONE_APPEND 15
+
+/* Report zones command */
+#define VIRTIO_BLK_T_ZONE_REPORT 16
+
+/* Open zone command */
+#define VIRTIO_BLK_T_ZONE_OPEN 18
+
+/* Close zone command */
+#define VIRTIO_BLK_T_ZONE_CLOSE 20
+
+/* Finish zone command */
+#define VIRTIO_BLK_T_ZONE_FINISH 22
+
+/* Reset zone command */
+#define VIRTIO_BLK_T_ZONE_RESET 24
+
+/* Reset All zones command */
+#define VIRTIO_BLK_T_ZONE_RESET_ALL 26
+
#ifndef VIRTIO_BLK_NO_LEGACY
/* Barrier before this op. */
#define VIRTIO_BLK_T_BARRIER 0x80000000
@@ -172,6 +223,72 @@ struct virtio_blk_outhdr {
__virtio64 sector;
};
+/*
+ * Supported zoned device models.
+ */
+
+/* Regular block device */
+#define VIRTIO_BLK_Z_NONE 0
+/* Host-managed zoned device */
+#define VIRTIO_BLK_Z_HM 1
+/* Host-aware zoned device */
+#define VIRTIO_BLK_Z_HA 2
+
+/*
+ * Zone descriptor. A part of VIRTIO_BLK_T_ZONE_REPORT command reply.
+ */
+struct virtio_blk_zone_descriptor {
+ /* Zone capacity */
+ __virtio64 z_cap;
+ /* The starting sector of the zone */
+ __virtio64 z_start;
+ /* Zone write pointer position in sectors */
+ __virtio64 z_wp;
+ /* Zone type */
+ __u8 z_type;
+ /* Zone state */
+ __u8 z_state;
+ __u8 reserved[38];
+};
+
+struct virtio_blk_zone_report {
+ __virtio64 nr_zones;
+ __u8 reserved[56];
+ struct virtio_blk_zone_descriptor zones[];
+};
+
+/*
+ * Supported zone types.
+ */
+
+/* Conventional zone */
+#define VIRTIO_BLK_ZT_CONV 1
+/* Sequential Write Required zone */
+#define VIRTIO_BLK_ZT_SWR 2
+/* Sequential Write Preferred zone */
+#define VIRTIO_BLK_ZT_SWP 3
+
+/*
+ * Zone states that are available for zones of all types.
+ */
+
+/* Not a write pointer (conventional zones only) */
+#define VIRTIO_BLK_ZS_NOT_WP 0
+/* Empty */
+#define VIRTIO_BLK_ZS_EMPTY 1
+/* Implicitly Open */
+#define VIRTIO_BLK_ZS_IOPEN 2
+/* Explicitly Open */
+#define VIRTIO_BLK_ZS_EOPEN 3
+/* Closed */
+#define VIRTIO_BLK_ZS_CLOSED 4
+/* Read-Only */
+#define VIRTIO_BLK_ZS_RDONLY 13
+/* Full */
+#define VIRTIO_BLK_ZS_FULL 14
+/* Offline */
+#define VIRTIO_BLK_ZS_OFFLINE 15
+
/* Unmap this range (only valid for write zeroes command) */
#define VIRTIO_BLK_WRITE_ZEROES_FLAG_UNMAP 0x00000001
@@ -198,4 +315,11 @@ struct virtio_scsi_inhdr {
#define VIRTIO_BLK_S_OK 0
#define VIRTIO_BLK_S_IOERR 1
#define VIRTIO_BLK_S_UNSUPP 2
+
+/* Error codes that are specific to zoned block devices */
+#define VIRTIO_BLK_S_ZONE_INVALID_CMD 3
+#define VIRTIO_BLK_S_ZONE_UNALIGNED_WP 4
+#define VIRTIO_BLK_S_ZONE_OPEN_RESOURCE 5
+#define VIRTIO_BLK_S_ZONE_ACTIVE_RESOURCE 6
+
#endif /* _LINUX_VIRTIO_BLK_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_bt.h b/lib/libc/include/any-linux-any/linux/virtio_bt.h
index 7c9a927018..87ff6f95d1 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_bt.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_bt.h
@@ -9,6 +9,7 @@
#define VIRTIO_BT_F_VND_HCI 0 /* Indicates vendor command support */
#define VIRTIO_BT_F_MSFT_EXT 1 /* Indicates MSFT vendor support */
#define VIRTIO_BT_F_AOSP_EXT 2 /* Indicates AOSP vendor support */
+#define VIRTIO_BT_F_CONFIG_V2 3 /* Use second version configuration */
enum virtio_bt_config_type {
VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0,
@@ -28,4 +29,11 @@ struct virtio_bt_config {
__u16 msft_opcode;
} __attribute__((packed));
+struct virtio_bt_config_v2 {
+ __u8 type;
+ __u8 alignment;
+ __u16 vendor;
+ __u16 msft_opcode;
+};
+
#endif /* _LINUX_VIRTIO_BT_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_config.h b/lib/libc/include/any-linux-any/linux/virtio_config.h
index 9295eadbc3..19deb7f89f 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_config.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_config.h
@@ -52,7 +52,7 @@
* rest are per-device feature bits.
*/
#define VIRTIO_TRANSPORT_F_START 28
-#define VIRTIO_TRANSPORT_F_END 38
+#define VIRTIO_TRANSPORT_F_END 41
#ifndef VIRTIO_CONFIG_NO_LEGACY
/* Do we get callbacks when the ring is completely used, even if we've
@@ -81,6 +81,12 @@
#define VIRTIO_F_RING_PACKED 34
/*
+ * Inorder feature indicates that all buffers are used by the device
+ * in the same order in which they have been made available.
+ */
+#define VIRTIO_F_IN_ORDER 35
+
+/*
* This feature indicates that memory accesses by the driver and the
* device are ordered in a way described by the platform.
*/
@@ -90,4 +96,9 @@
* Does the device support Single Root I/O Virtualization?
*/
#define VIRTIO_F_SR_IOV 37
+
+/*
+ * This feature indicates that the driver can reset a queue individually.
+ */
+#define VIRTIO_F_RING_RESET 40
#endif /* _LINUX_VIRTIO_CONFIG_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_crypto.h b/lib/libc/include/any-linux-any/linux/virtio_crypto.h
index 1fae6b1c43..c85c387531 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_crypto.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_crypto.h
@@ -37,6 +37,7 @@
#define VIRTIO_CRYPTO_SERVICE_HASH 1
#define VIRTIO_CRYPTO_SERVICE_MAC 2
#define VIRTIO_CRYPTO_SERVICE_AEAD 3
+#define VIRTIO_CRYPTO_SERVICE_AKCIPHER 4
#define VIRTIO_CRYPTO_OPCODE(service, op) (((service) << 8) | (op))
@@ -57,6 +58,10 @@ struct virtio_crypto_ctrl_header {
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x02)
#define VIRTIO_CRYPTO_AEAD_DESTROY_SESSION \
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x03)
+#define VIRTIO_CRYPTO_AKCIPHER_CREATE_SESSION \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x04)
+#define VIRTIO_CRYPTO_AKCIPHER_DESTROY_SESSION \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x05)
__le32 opcode;
__le32 algo;
__le32 flag;
@@ -180,6 +185,58 @@ struct virtio_crypto_aead_create_session_req {
__u8 padding[32];
};
+struct virtio_crypto_rsa_session_para {
+#define VIRTIO_CRYPTO_RSA_RAW_PADDING 0
+#define VIRTIO_CRYPTO_RSA_PKCS1_PADDING 1
+ __le32 padding_algo;
+
+#define VIRTIO_CRYPTO_RSA_NO_HASH 0
+#define VIRTIO_CRYPTO_RSA_MD2 1
+#define VIRTIO_CRYPTO_RSA_MD3 2
+#define VIRTIO_CRYPTO_RSA_MD4 3
+#define VIRTIO_CRYPTO_RSA_MD5 4
+#define VIRTIO_CRYPTO_RSA_SHA1 5
+#define VIRTIO_CRYPTO_RSA_SHA256 6
+#define VIRTIO_CRYPTO_RSA_SHA384 7
+#define VIRTIO_CRYPTO_RSA_SHA512 8
+#define VIRTIO_CRYPTO_RSA_SHA224 9
+ __le32 hash_algo;
+};
+
+struct virtio_crypto_ecdsa_session_para {
+#define VIRTIO_CRYPTO_CURVE_UNKNOWN 0
+#define VIRTIO_CRYPTO_CURVE_NIST_P192 1
+#define VIRTIO_CRYPTO_CURVE_NIST_P224 2
+#define VIRTIO_CRYPTO_CURVE_NIST_P256 3
+#define VIRTIO_CRYPTO_CURVE_NIST_P384 4
+#define VIRTIO_CRYPTO_CURVE_NIST_P521 5
+ __le32 curve_id;
+ __le32 padding;
+};
+
+struct virtio_crypto_akcipher_session_para {
+#define VIRTIO_CRYPTO_NO_AKCIPHER 0
+#define VIRTIO_CRYPTO_AKCIPHER_RSA 1
+#define VIRTIO_CRYPTO_AKCIPHER_DSA 2
+#define VIRTIO_CRYPTO_AKCIPHER_ECDSA 3
+ __le32 algo;
+
+#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PUBLIC 1
+#define VIRTIO_CRYPTO_AKCIPHER_KEY_TYPE_PRIVATE 2
+ __le32 keytype;
+ __le32 keylen;
+
+ union {
+ struct virtio_crypto_rsa_session_para rsa;
+ struct virtio_crypto_ecdsa_session_para ecdsa;
+ } u;
+};
+
+struct virtio_crypto_akcipher_create_session_req {
+ struct virtio_crypto_akcipher_session_para para;
+ __u8 padding[36];
+};
+
struct virtio_crypto_alg_chain_session_para {
#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_HASH_THEN_CIPHER 1
#define VIRTIO_CRYPTO_SYM_ALG_CHAIN_ORDER_CIPHER_THEN_HASH 2
@@ -247,6 +304,8 @@ struct virtio_crypto_op_ctrl_req {
mac_create_session;
struct virtio_crypto_aead_create_session_req
aead_create_session;
+ struct virtio_crypto_akcipher_create_session_req
+ akcipher_create_session;
struct virtio_crypto_destroy_session_req
destroy_session;
__u8 padding[56];
@@ -266,6 +325,14 @@ struct virtio_crypto_op_header {
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x00)
#define VIRTIO_CRYPTO_AEAD_DECRYPT \
VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AEAD, 0x01)
+#define VIRTIO_CRYPTO_AKCIPHER_ENCRYPT \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x00)
+#define VIRTIO_CRYPTO_AKCIPHER_DECRYPT \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x01)
+#define VIRTIO_CRYPTO_AKCIPHER_SIGN \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x02)
+#define VIRTIO_CRYPTO_AKCIPHER_VERIFY \
+ VIRTIO_CRYPTO_OPCODE(VIRTIO_CRYPTO_SERVICE_AKCIPHER, 0x03)
__le32 opcode;
/* algo should be service-specific algorithms */
__le32 algo;
@@ -390,6 +457,16 @@ struct virtio_crypto_aead_data_req {
__u8 padding[32];
};
+struct virtio_crypto_akcipher_para {
+ __le32 src_data_len;
+ __le32 dst_data_len;
+};
+
+struct virtio_crypto_akcipher_data_req {
+ struct virtio_crypto_akcipher_para para;
+ __u8 padding[40];
+};
+
/* The request of the data virtqueue's packet */
struct virtio_crypto_op_data_req {
struct virtio_crypto_op_header header;
@@ -399,6 +476,7 @@ struct virtio_crypto_op_data_req {
struct virtio_crypto_hash_data_req hash_req;
struct virtio_crypto_mac_data_req mac_req;
struct virtio_crypto_aead_data_req aead_req;
+ struct virtio_crypto_akcipher_data_req akcipher_req;
__u8 padding[48];
} u;
};
@@ -408,6 +486,8 @@ struct virtio_crypto_op_data_req {
#define VIRTIO_CRYPTO_BADMSG 2
#define VIRTIO_CRYPTO_NOTSUPP 3
#define VIRTIO_CRYPTO_INVSESS 4 /* Invalid session id */
+#define VIRTIO_CRYPTO_NOSPC 5 /* no free session ID */
+#define VIRTIO_CRYPTO_KEY_REJECTED 6 /* Signature verification failed */
/* The accelerator hardware is ready */
#define VIRTIO_CRYPTO_S_HW_READY (1 << 0)
@@ -438,7 +518,7 @@ struct virtio_crypto_config {
__le32 max_cipher_key_len;
/* Maximum length of authenticated key */
__le32 max_auth_key_len;
- __le32 reserve;
+ __le32 akcipher_algo;
/* Maximum size of each crypto request's content */
__le64 max_size;
};
diff --git a/lib/libc/include/any-linux-any/linux/virtio_ids.h b/lib/libc/include/any-linux-any/linux/virtio_ids.h
index 30776ce1fc..c3e777be20 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_ids.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_ids.h
@@ -73,12 +73,12 @@
* Virtio Transitional IDs
*/
-#define VIRTIO_TRANS_ID_NET 1000 /* transitional virtio net */
-#define VIRTIO_TRANS_ID_BLOCK 1001 /* transitional virtio block */
-#define VIRTIO_TRANS_ID_BALLOON 1002 /* transitional virtio balloon */
-#define VIRTIO_TRANS_ID_CONSOLE 1003 /* transitional virtio console */
-#define VIRTIO_TRANS_ID_SCSI 1004 /* transitional virtio SCSI */
-#define VIRTIO_TRANS_ID_RNG 1005 /* transitional virtio rng */
-#define VIRTIO_TRANS_ID_9P 1009 /* transitional virtio 9p console */
+#define VIRTIO_TRANS_ID_NET 0x1000 /* transitional virtio net */
+#define VIRTIO_TRANS_ID_BLOCK 0x1001 /* transitional virtio block */
+#define VIRTIO_TRANS_ID_BALLOON 0x1002 /* transitional virtio balloon */
+#define VIRTIO_TRANS_ID_CONSOLE 0x1003 /* transitional virtio console */
+#define VIRTIO_TRANS_ID_SCSI 0x1004 /* transitional virtio SCSI */
+#define VIRTIO_TRANS_ID_RNG 0x1005 /* transitional virtio rng */
+#define VIRTIO_TRANS_ID_9P 0x1009 /* transitional virtio 9p console */
#endif /* _LINUX_VIRTIO_IDS_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_iommu.h b/lib/libc/include/any-linux-any/linux/virtio_iommu.h
index 217f1e1fb3..37b85a601b 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_iommu.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_iommu.h
@@ -16,6 +16,7 @@
#define VIRTIO_IOMMU_F_BYPASS 3
#define VIRTIO_IOMMU_F_PROBE 4
#define VIRTIO_IOMMU_F_MMIO 5
+#define VIRTIO_IOMMU_F_BYPASS_CONFIG 6
struct virtio_iommu_range_64 {
__le64 start;
@@ -36,6 +37,8 @@ struct virtio_iommu_config {
struct virtio_iommu_range_32 domain_range;
/* Probe buffer size */
__le32 probe_size;
+ __u8 bypass;
+ __u8 reserved[3];
};
/* Request types */
@@ -66,11 +69,14 @@ struct virtio_iommu_req_tail {
__u8 reserved[3];
};
+#define VIRTIO_IOMMU_ATTACH_F_BYPASS (1 << 0)
+
struct virtio_iommu_req_attach {
struct virtio_iommu_req_head head;
__le32 domain;
__le32 endpoint;
- __u8 reserved[8];
+ __le32 flags;
+ __u8 reserved[4];
struct virtio_iommu_req_tail tail;
};
diff --git a/lib/libc/include/any-linux-any/linux/virtio_net.h b/lib/libc/include/any-linux-any/linux/virtio_net.h
index c7d95c3f3f..128745b370 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_net.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_net.h
@@ -56,7 +56,10 @@
#define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow
* Steering */
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */
-
+#define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */
+#define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6 55 /* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO 56 /* Host can handle USO in. */
#define VIRTIO_NET_F_HASH_REPORT 57 /* Supports hash report */
#define VIRTIO_NET_F_RSS 60 /* Supports RSS RX steering */
#define VIRTIO_NET_F_RSC_EXT 61 /* extended coalescing info */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
#define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */
#define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */
#define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */
#define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */
__u8 gso_type;
__virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */
@@ -355,4 +359,36 @@ struct virtio_net_hash_config {
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS 5
#define VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET 0
+/*
+ * Control notifications coalescing.
+ *
+ * Request the device to change the notifications coalescing parameters.
+ *
+ * Available with the VIRTIO_NET_F_NOTF_COAL feature bit.
+ */
+#define VIRTIO_NET_CTRL_NOTF_COAL 6
+/*
+ * Set the tx-usecs/tx-max-packets parameters.
+ */
+struct virtio_net_ctrl_coal_tx {
+ /* Maximum number of packets to send before a TX notification */
+ __le32 tx_max_packets;
+ /* Maximum number of usecs to delay a TX notification */
+ __le32 tx_usecs;
+};
+
+#define VIRTIO_NET_CTRL_NOTF_COAL_TX_SET 0
+
+/*
+ * Set the rx-usecs/rx-max-packets parameters.
+ */
+struct virtio_net_ctrl_coal_rx {
+ /* Maximum number of packets to receive before a RX notification */
+ __le32 rx_max_packets;
+ /* Maximum number of usecs to delay a RX notification */
+ __le32 rx_usecs;
+};
+
+#define VIRTIO_NET_CTRL_NOTF_COAL_RX_SET 1
+
#endif /* _LINUX_VIRTIO_NET_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/linux/virtio_pci.h b/lib/libc/include/any-linux-any/linux/virtio_pci.h
index d20b7d0f33..e858f38291 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_pci.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_pci.h
@@ -202,6 +202,8 @@ struct virtio_pci_cfg_cap {
#define VIRTIO_PCI_COMMON_Q_AVAILHI 44
#define VIRTIO_PCI_COMMON_Q_USEDLO 48
#define VIRTIO_PCI_COMMON_Q_USEDHI 52
+#define VIRTIO_PCI_COMMON_Q_NDATA 56
+#define VIRTIO_PCI_COMMON_Q_RESET 58
#endif /* VIRTIO_PCI_NO_MODERN */
diff --git a/lib/libc/include/any-linux-any/linux/virtio_ring.h b/lib/libc/include/any-linux-any/linux/virtio_ring.h
index 8085013380..1e2c99697a 100644
--- a/lib/libc/include/any-linux-any/linux/virtio_ring.h
+++ b/lib/libc/include/any-linux-any/linux/virtio_ring.h
@@ -91,15 +91,21 @@
#define VRING_USED_ALIGN_SIZE 4
#define VRING_DESC_ALIGN_SIZE 16
-/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
+/**
+ * struct vring_desc - Virtio ring descriptors,
+ * 16 bytes long. These can chain together via @next.
+ *
+ * @addr: buffer address (guest-physical)
+ * @len: buffer length
+ * @flags: descriptor flags
+ * @next: index of the next descriptor in the chain,
+ * if the VRING_DESC_F_NEXT flag is set. We chain unused
+ * descriptors via this, too.
+ */
struct vring_desc {
- /* Address (guest-physical). */
__virtio64 addr;
- /* Length. */
__virtio32 len;
- /* The flags as indicated above. */
__virtio16 flags;
- /* We chain unused descriptors via this, too */
__virtio16 next;
};
diff --git a/lib/libc/include/any-linux-any/linux/xfrm.h b/lib/libc/include/any-linux-any/linux/xfrm.h
index 31dde4d91b..77aae3df6f 100644
--- a/lib/libc/include/any-linux-any/linux/xfrm.h
+++ b/lib/libc/include/any-linux-any/linux/xfrm.h
@@ -33,7 +33,7 @@ struct xfrm_sec_ctx {
__u8 ctx_alg;
__u16 ctx_len;
__u32 ctx_sid;
- char ctx_str[0];
+ char ctx_str[];
};
/* Security Context Domains of Interpretation */
@@ -96,27 +96,27 @@ struct xfrm_replay_state_esn {
__u32 oseq_hi;
__u32 seq_hi;
__u32 replay_window;
- __u32 bmp[0];
+ __u32 bmp[];
};
struct xfrm_algo {
char alg_name[64];
unsigned int alg_key_len; /* in bits */
- char alg_key[0];
+ char alg_key[];
};
struct xfrm_algo_auth {
char alg_name[64];
unsigned int alg_key_len; /* in bits */
unsigned int alg_trunc_len; /* in bits */
- char alg_key[0];
+ char alg_key[];
};
struct xfrm_algo_aead {
char alg_name[64];
unsigned int alg_key_len; /* in bits */
unsigned int alg_icv_len; /* in bits */
- char alg_key[0];
+ char alg_key[];
};
struct xfrm_stats {
@@ -296,7 +296,7 @@ enum xfrm_attr_type_t {
XFRMA_ETIMER_THRESH,
XFRMA_SRCADDR, /* xfrm_address_t */
XFRMA_COADDR, /* xfrm_address_t */
- XFRMA_LASTUSED, /* unsigned long */
+ XFRMA_LASTUSED, /* __u64 */
XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
XFRMA_MIGRATE,
XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
@@ -313,6 +313,7 @@ enum xfrm_attr_type_t {
XFRMA_SET_MARK, /* __u32 */
XFRMA_SET_MARK_MASK, /* __u32 */
XFRMA_IF_ID, /* __u32 */
+ XFRMA_MTIMER_THRESH, /* __u32 in seconds for input SA */
__XFRMA_MAX
#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK /* Compatibility */
@@ -510,8 +511,20 @@ struct xfrm_user_offload {
int ifindex;
__u8 flags;
};
+/* This flag was exposed without any kernel code that supports it.
+ * Unfortunately, strongswan has the code that sets this flag,
+ * which makes it impossible to reuse this bit.
+ *
+ * So leave it here to make sure that it won't be reused by mistake.
+ */
#define XFRM_OFFLOAD_IPV6 1
#define XFRM_OFFLOAD_INBOUND 2
+/* Two bits above are relevant for state path only, while
+ * offload is used for both policy and state flows.
+ *
+ * In policy offload mode, they are free and can be safely reused.
+ */
+#define XFRM_OFFLOAD_PACKET 4
struct xfrm_userpolicy_default {
#define XFRM_USERPOLICY_UNSPEC 0
diff --git a/lib/libc/include/any-linux-any/misc/fastrpc.h b/lib/libc/include/any-linux-any/misc/fastrpc.h
index 296aba0d27..f2a35db7cc 100644
--- a/lib/libc/include/any-linux-any/misc/fastrpc.h
+++ b/lib/libc/include/any-linux-any/misc/fastrpc.h
@@ -13,12 +13,65 @@
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
+#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
+#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
+#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)
+#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
+
+/**
+ * enum fastrpc_map_flags - control flags for mapping memory on DSP user process
+ * @FASTRPC_MAP_STATIC: Map memory pages with RW- permission and CACHE WRITEBACK.
+ * The driver is responsible for cache maintenance when passed
+ * the buffer to FastRPC calls. Same virtual address will be
+ * assigned for subsequent FastRPC calls.
+ * @FASTRPC_MAP_RESERVED: Reserved
+ * @FASTRPC_MAP_FD: Map memory pages with RW- permission and CACHE WRITEBACK.
+ * Mapping tagged with a file descriptor. User is responsible for
+ * CPU and DSP cache maintenance for the buffer. Get virtual address
+ * of buffer on DSP using HAP_mmap_get() and HAP_mmap_put() APIs.
+ * @FASTRPC_MAP_FD_DELAYED: Mapping delayed until user call HAP_mmap() and HAP_munmap()
+ * functions on DSP. It is useful to map a buffer with cache modes
+ * other than default modes. User is responsible for CPU and DSP
+ * cache maintenance for the buffer.
+ * @FASTRPC_MAP_FD_NOMAP: This flag is used to skip CPU mapping,
+ * otherwise behaves similar to FASTRPC_MAP_FD_DELAYED flag.
+ * @FASTRPC_MAP_MAX: max count for flags
+ *
+ */
+enum fastrpc_map_flags {
+ FASTRPC_MAP_STATIC = 0,
+ FASTRPC_MAP_RESERVED,
+ FASTRPC_MAP_FD = 2,
+ FASTRPC_MAP_FD_DELAYED,
+ FASTRPC_MAP_FD_NOMAP = 16,
+ FASTRPC_MAP_MAX,
+};
+
+enum fastrpc_proc_attr {
+ /* Macro for Debug attr */
+ FASTRPC_MODE_DEBUG = (1 << 0),
+ /* Macro for Ptrace */
+ FASTRPC_MODE_PTRACE = (1 << 1),
+ /* Macro for CRC Check */
+ FASTRPC_MODE_CRC = (1 << 2),
+ /* Macro for Unsigned PD */
+ FASTRPC_MODE_UNSIGNED_MODULE = (1 << 3),
+ /* Macro for Adaptive QoS */
+ FASTRPC_MODE_ADAPTIVE_QOS = (1 << 4),
+ /* Macro for System Process */
+ FASTRPC_MODE_SYSTEM_PROCESS = (1 << 5),
+ /* Macro for Prvileged Process */
+ FASTRPC_MODE_PRIVILEGED = (1 << 6),
+};
+
+/* Fastrpc attribute for memory protection of buffers */
+#define FASTRPC_ATTR_SECUREMAP (1)
struct fastrpc_invoke_args {
__u64 ptr;
__u64 length;
__s32 fd;
- __u32 reserved;
+ __u32 attr;
};
struct fastrpc_invoke {
@@ -35,6 +88,12 @@ struct fastrpc_init_create {
__u64 file; /* pointer to elf file */
};
+struct fastrpc_init_create_static {
+ __u32 namelen; /* length of pd process name */
+ __u32 memlen;
+ __u64 name; /* pd process name */
+};
+
struct fastrpc_alloc_dma_buf {
__s32 fd; /* fd */
__u32 flags; /* flags to map with */
@@ -49,9 +108,36 @@ struct fastrpc_req_mmap {
__u64 vaddrout; /* dsp virtual address */
};
+struct fastrpc_mem_map {
+ __s32 version;
+ __s32 fd; /* fd */
+ __s32 offset; /* buffer offset */
+ __u32 flags; /* flags defined in enum fastrpc_map_flags */
+ __u64 vaddrin; /* buffer virtual address */
+ __u64 length; /* buffer length */
+ __u64 vaddrout; /* [out] remote virtual address */
+ __s32 attrs; /* buffer attributes used for SMMU mapping */
+ __s32 reserved[4];
+};
+
struct fastrpc_req_munmap {
__u64 vaddrout; /* address to unmap */
__u64 size; /* size */
};
+struct fastrpc_mem_unmap {
+ __s32 vesion;
+ __s32 fd; /* fd */
+ __u64 vaddr; /* remote process (dsp) virtual address */
+ __u64 length; /* buffer size */
+ __s32 reserved[5];
+};
+
+struct fastrpc_ioctl_capability {
+ __u32 domain;
+ __u32 attribute_id;
+ __u32 capability; /* dsp capability */
+ __u32 reserved[4];
+};
+
#endif /* __QCOM_FASTRPC_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/misc/uacce/hisi_qm.h b/lib/libc/include/any-linux-any/misc/uacce/hisi_qm.h
index 588b203d45..3f89cd1528 100644
--- a/lib/libc/include/any-linux-any/misc/uacce/hisi_qm.h
+++ b/lib/libc/include/any-linux-any/misc/uacce/hisi_qm.h
@@ -14,11 +14,26 @@ struct hisi_qp_ctx {
__u16 qc_type;
};
+/**
+ * struct hisi_qp_info - User data for hisi qp.
+ * @sqe_size: Submission queue element size
+ * @sq_depth: The number of sqe
+ * @cq_depth: The number of cqe
+ * @reserved: Reserved data
+ */
+struct hisi_qp_info {
+ __u32 sqe_size;
+ __u16 sq_depth;
+ __u16 cq_depth;
+ __u64 reserved;
+};
+
#define HISI_QM_API_VER_BASE "hisi_qm_v1"
#define HISI_QM_API_VER2_BASE "hisi_qm_v2"
#define HISI_QM_API_VER3_BASE "hisi_qm_v3"
/* UACCE_CMD_QM_SET_QP_CTX: Set qp algorithm type */
#define UACCE_CMD_QM_SET_QP_CTX _IOWR('H', 10, struct hisi_qp_ctx)
-
+/* UACCE_CMD_QM_SET_QP_INFO: Set qp depth and BD size */
+#define UACCE_CMD_QM_SET_QP_INFO _IOWR('H', 11, struct hisi_qp_info)
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/mtd/mtd-abi.h b/lib/libc/include/any-linux-any/mtd/mtd-abi.h
index a1938ede6e..30f2262e0f 100644
--- a/lib/libc/include/any-linux-any/mtd/mtd-abi.h
+++ b/lib/libc/include/any-linux-any/mtd/mtd-abi.h
@@ -55,9 +55,9 @@ struct mtd_oob_buf64 {
* @MTD_OPS_RAW: data are transferred as-is, with no error correction;
* this mode implies %MTD_OPS_PLACE_OOB
*
- * These modes can be passed to ioctl(MEMWRITE) and are also used internally.
- * See notes on "MTD file modes" for discussion on %MTD_OPS_RAW vs.
- * %MTD_FILE_MODE_RAW.
+ * These modes can be passed to ioctl(MEMWRITE) and ioctl(MEMREAD); they are
+ * also used internally. See notes on "MTD file modes" for discussion on
+ * %MTD_OPS_RAW vs. %MTD_FILE_MODE_RAW.
*/
enum {
MTD_OPS_PLACE_OOB = 0,
@@ -69,8 +69,8 @@ enum {
* struct mtd_write_req - data structure for requesting a write operation
*
* @start: start address
- * @len: length of data buffer
- * @ooblen: length of OOB buffer
+ * @len: length of data buffer (only lower 32 bits are used)
+ * @ooblen: length of OOB buffer (only lower 32 bits are used)
* @usr_data: user-provided data buffer
* @usr_oob: user-provided OOB buffer
* @mode: MTD mode (see "MTD operation modes")
@@ -91,6 +91,53 @@ struct mtd_write_req {
__u8 padding[7];
};
+/**
+ * struct mtd_read_req_ecc_stats - ECC statistics for a read operation
+ *
+ * @uncorrectable_errors: the number of uncorrectable errors that happened
+ * during the read operation
+ * @corrected_bitflips: the number of bitflips corrected during the read
+ * operation
+ * @max_bitflips: the maximum number of bitflips detected in any single ECC
+ * step for the data read during the operation; this information
+ * can be used to decide whether the data stored in a specific
+ * region of the MTD device should be moved somewhere else to
+ * avoid data loss.
+ */
+struct mtd_read_req_ecc_stats {
+ __u32 uncorrectable_errors;
+ __u32 corrected_bitflips;
+ __u32 max_bitflips;
+};
+
+/**
+ * struct mtd_read_req - data structure for requesting a read operation
+ *
+ * @start: start address
+ * @len: length of data buffer (only lower 32 bits are used)
+ * @ooblen: length of OOB buffer (only lower 32 bits are used)
+ * @usr_data: user-provided data buffer
+ * @usr_oob: user-provided OOB buffer
+ * @mode: MTD mode (see "MTD operation modes")
+ * @padding: reserved, must be set to 0
+ * @ecc_stats: ECC statistics for the read operation
+ *
+ * This structure supports ioctl(MEMREAD) operations, allowing data and/or OOB
+ * reads in various modes. To read from OOB-only, set @usr_data == NULL, and to
+ * read data-only, set @usr_oob == NULL. However, setting both @usr_data and
+ * @usr_oob to NULL is not allowed.
+ */
+struct mtd_read_req {
+ __u64 start;
+ __u64 len;
+ __u64 ooblen;
+ __u64 usr_data;
+ __u64 usr_oob;
+ __u8 mode;
+ __u8 padding[7];
+ struct mtd_read_req_ecc_stats ecc_stats;
+};
+
#define MTD_ABSENT 0
#define MTD_RAM 1
#define MTD_ROM 2
@@ -207,6 +254,12 @@ struct otp_info {
#define MEMWRITE _IOWR('M', 24, struct mtd_write_req)
/* Erase a given range of user data (must be in mode %MTD_FILE_MODE_OTP_USER) */
#define OTPERASE _IOW('M', 25, struct otp_info)
+/*
+ * Most generic read interface; can read in-band and/or out-of-band in various
+ * modes (see "struct mtd_read_req"). This ioctl is not supported for flashes
+ * without OOB, e.g., NOR flash.
+ */
+#define MEMREAD _IOWR('M', 26, struct mtd_read_req)
/*
* Obsolete legacy interface. Keep it in order not to break userspace
@@ -270,8 +323,9 @@ struct mtd_ecc_stats {
* Note: %MTD_FILE_MODE_RAW provides the same functionality as %MTD_OPS_RAW -
* raw access to the flash, without error correction or autoplacement schemes.
* Wherever possible, the MTD_OPS_* mode will override the MTD_FILE_MODE_* mode
- * (e.g., when using ioctl(MEMWRITE)), but in some cases, the MTD_FILE_MODE is
- * used out of necessity (e.g., `write()', ioctl(MEMWRITEOOB64)).
+ * (e.g., when using ioctl(MEMWRITE) or ioctl(MEMREAD)), but in some cases, the
+ * MTD_FILE_MODE is used out of necessity (e.g., `write()',
+ * ioctl(MEMWRITEOOB64)).
*/
enum mtd_file_modes {
MTD_FILE_MODE_NORMAL = MTD_OTP_OFF,
diff --git a/lib/libc/include/any-linux-any/mtd/ubi-user.h b/lib/libc/include/any-linux-any/mtd/ubi-user.h
index 898ec5bde5..e8b12cd0a3 100644
--- a/lib/libc/include/any-linux-any/mtd/ubi-user.h
+++ b/lib/libc/include/any-linux-any/mtd/ubi-user.h
@@ -247,6 +247,7 @@ enum {
* @vid_hdr_offset: VID header offset (use defaults if %0)
* @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs
* @padding: reserved for future, not used, has to be zeroed
+ * @disable_fm: whether disable fastmap
*
* This data structure is used to specify MTD device UBI has to attach and the
* parameters it has to use. The number which should be assigned to the new UBI
@@ -281,13 +282,18 @@ enum {
* eraseblocks for new bad eraseblocks, but attempts to use available
* eraseblocks (if any). The accepted range is 0-768. If 0 is given, the
* default kernel value of %CONFIG_MTD_UBI_BEB_LIMIT will be used.
+ *
+ * If @disable_fm is not zero, ubi doesn't create new fastmap even the module
+ * param 'fm_autoconvert' is set, and existed old fastmap will be destroyed
+ * after doing full scanning.
*/
struct ubi_attach_req {
__s32 ubi_num;
__s32 mtd_num;
__s32 vid_hdr_offset;
__s16 max_beb_per1024;
- __s8 padding[10];
+ __s8 disable_fm;
+ __s8 padding[9];
};
/*
diff --git a/lib/libc/include/any-linux-any/rdma/efa-abi.h b/lib/libc/include/any-linux-any/rdma/efa-abi.h
index c065c08eb9..dfa8b270bd 100644
--- a/lib/libc/include/any-linux-any/rdma/efa-abi.h
+++ b/lib/libc/include/any-linux-any/rdma/efa-abi.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
/*
- * Copyright 2018-2021 Amazon.com, Inc. or its affiliates. All rights reserved.
+ * Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All rights reserved.
*/
#ifndef EFA_ABI_USER_H
@@ -54,6 +54,7 @@ struct efa_ibv_alloc_pd_resp {
enum {
EFA_CREATE_CQ_WITH_COMPLETION_CHANNEL = 1 << 0,
+ EFA_CREATE_CQ_WITH_SGID = 1 << 1,
};
struct efa_ibv_create_cq {
@@ -118,6 +119,7 @@ enum {
EFA_QUERY_DEVICE_CAPS_RDMA_READ = 1 << 0,
EFA_QUERY_DEVICE_CAPS_RNR_RETRY = 1 << 1,
EFA_QUERY_DEVICE_CAPS_CQ_NOTIFICATIONS = 1 << 2,
+ EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID = 1 << 3,
};
struct efa_ibv_ex_query_device_resp {
diff --git a/lib/libc/include/any-linux-any/rdma/erdma-abi.h b/lib/libc/include/any-linux-any/rdma/erdma-abi.h
new file mode 100644
index 0000000000..d0e510d8dd
--- /dev/null
+++ b/lib/libc/include/any-linux-any/rdma/erdma-abi.h
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/*
+ * Copyright (c) 2020-2022, Alibaba Group.
+ */
+
+#ifndef __ERDMA_USER_H__
+#define __ERDMA_USER_H__
+
+#include <linux/types.h>
+
+#define ERDMA_ABI_VERSION 1
+
+struct erdma_ureq_create_cq {
+ __aligned_u64 db_record_va;
+ __aligned_u64 qbuf_va;
+ __u32 qbuf_len;
+ __u32 rsvd0;
+};
+
+struct erdma_uresp_create_cq {
+ __u32 cq_id;
+ __u32 num_cqe;
+};
+
+struct erdma_ureq_create_qp {
+ __aligned_u64 db_record_va;
+ __aligned_u64 qbuf_va;
+ __u32 qbuf_len;
+ __u32 rsvd0;
+};
+
+struct erdma_uresp_create_qp {
+ __u32 qp_id;
+ __u32 num_sqe;
+ __u32 num_rqe;
+ __u32 rq_offset;
+};
+
+struct erdma_uresp_alloc_ctx {
+ __u32 dev_id;
+ __u32 pad;
+ __u32 sdb_type;
+ __u32 sdb_offset;
+ __aligned_u64 sdb;
+ __aligned_u64 rdb;
+ __aligned_u64 cdb;
+};
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/rdma/hfi/hfi1_user.h b/lib/libc/include/any-linux-any/rdma/hfi/hfi1_user.h
index b152e66059..f7af8905d9 100644
--- a/lib/libc/include/any-linux-any/rdma/hfi/hfi1_user.h
+++ b/lib/libc/include/any-linux-any/rdma/hfi/hfi1_user.h
@@ -180,7 +180,7 @@ struct hfi1_sdma_comp_entry {
struct hfi1_status {
__aligned_u64 dev; /* device/hw status bits */
__aligned_u64 port; /* port state and status bits */
- char freezemsg[0];
+ char freezemsg[];
};
enum sdma_req_opcode {
diff --git a/lib/libc/include/any-linux-any/rdma/hns-abi.h b/lib/libc/include/any-linux-any/rdma/hns-abi.h
index ac17a23e3d..dab7b2776c 100644
--- a/lib/libc/include/any-linux-any/rdma/hns-abi.h
+++ b/lib/libc/include/any-linux-any/rdma/hns-abi.h
@@ -77,10 +77,24 @@ enum hns_roce_qp_cap_flags {
HNS_ROCE_QP_CAP_RQ_RECORD_DB = 1 << 0,
HNS_ROCE_QP_CAP_SQ_RECORD_DB = 1 << 1,
HNS_ROCE_QP_CAP_OWNER_DB = 1 << 2,
+ HNS_ROCE_QP_CAP_DIRECT_WQE = 1 << 5,
};
struct hns_roce_ib_create_qp_resp {
__aligned_u64 cap_flags;
+ __aligned_u64 dwqe_mmap_key;
+};
+
+enum {
+ HNS_ROCE_EXSGE_FLAGS = 1 << 0,
+ HNS_ROCE_RQ_INLINE_FLAGS = 1 << 1,
+ HNS_ROCE_CQE_INLINE_FLAGS = 1 << 2,
+};
+
+enum {
+ HNS_ROCE_RSP_EXSGE_FLAGS = 1 << 0,
+ HNS_ROCE_RSP_RQ_INLINE_FLAGS = 1 << 1,
+ HNS_ROCE_RSP_CQE_INLINE_FLAGS = 1 << 2,
};
struct hns_roce_ib_alloc_ucontext_resp {
@@ -88,6 +102,13 @@ struct hns_roce_ib_alloc_ucontext_resp {
__u32 cqe_size;
__u32 srq_tab_size;
__u32 reserved;
+ __u32 config;
+ __u32 max_inline_data;
+};
+
+struct hns_roce_ib_alloc_ucontext {
+ __u32 config;
+ __u32 reserved;
};
struct hns_roce_ib_alloc_pd_resp {
diff --git a/lib/libc/include/any-linux-any/rdma/ib_user_ioctl_verbs.h b/lib/libc/include/any-linux-any/rdma/ib_user_ioctl_verbs.h
index 1505aeddb2..3f7fe5a248 100644
--- a/lib/libc/include/any-linux-any/rdma/ib_user_ioctl_verbs.h
+++ b/lib/libc/include/any-linux-any/rdma/ib_user_ioctl_verbs.h
@@ -57,6 +57,8 @@ enum ib_uverbs_access_flags {
IB_UVERBS_ACCESS_ZERO_BASED = 1 << 5,
IB_UVERBS_ACCESS_ON_DEMAND = 1 << 6,
IB_UVERBS_ACCESS_HUGETLB = 1 << 7,
+ IB_UVERBS_ACCESS_FLUSH_GLOBAL = 1 << 8,
+ IB_UVERBS_ACCESS_FLUSH_PERSISTENT = 1 << 9,
IB_UVERBS_ACCESS_RELAXED_ORDERING = IB_UVERBS_ACCESS_OPTIONAL_FIRST,
IB_UVERBS_ACCESS_OPTIONAL_RANGE =
@@ -250,6 +252,8 @@ enum rdma_driver_id {
RDMA_DRIVER_QIB,
RDMA_DRIVER_EFA,
RDMA_DRIVER_SIW,
+ RDMA_DRIVER_ERDMA,
+ RDMA_DRIVER_MANA,
};
enum ib_uverbs_gid_type {
diff --git a/lib/libc/include/any-linux-any/rdma/ib_user_verbs.h b/lib/libc/include/any-linux-any/rdma/ib_user_verbs.h
index a50216e61e..0d982c2219 100644
--- a/lib/libc/include/any-linux-any/rdma/ib_user_verbs.h
+++ b/lib/libc/include/any-linux-any/rdma/ib_user_verbs.h
@@ -105,6 +105,18 @@ enum {
IB_USER_VERBS_EX_CMD_MODIFY_CQ
};
+/* see IBA A19.4.1.1 Placement Types */
+enum ib_placement_type {
+ IB_FLUSH_GLOBAL = 1U << 0,
+ IB_FLUSH_PERSISTENT = 1U << 1,
+};
+
+/* see IBA A19.4.1.2 Selectivity Level */
+enum ib_selectivity_level {
+ IB_FLUSH_RANGE = 0,
+ IB_FLUSH_MR,
+};
+
/*
* Make sure that all structs defined in this file remain laid out so
* that they pack the same way on 32-bit and 64-bit architectures (to
@@ -158,18 +170,18 @@ struct ib_uverbs_ex_cmd_hdr {
struct ib_uverbs_get_context {
__aligned_u64 response;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_get_context_resp {
__u32 async_fd;
__u32 num_comp_vectors;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_device {
__aligned_u64 response;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_device_resp {
@@ -278,7 +290,7 @@ struct ib_uverbs_query_port {
__aligned_u64 response;
__u8 port_num;
__u8 reserved[7];
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_port_resp {
@@ -308,12 +320,12 @@ struct ib_uverbs_query_port_resp {
struct ib_uverbs_alloc_pd {
__aligned_u64 response;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_alloc_pd_resp {
__u32 pd_handle;
- __u32 driver_data[0];
+ __u32 driver_data[];
};
struct ib_uverbs_dealloc_pd {
@@ -324,12 +336,12 @@ struct ib_uverbs_open_xrcd {
__aligned_u64 response;
__u32 fd;
__u32 oflags;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_open_xrcd_resp {
__u32 xrcd_handle;
- __u32 driver_data[0];
+ __u32 driver_data[];
};
struct ib_uverbs_close_xrcd {
@@ -343,14 +355,14 @@ struct ib_uverbs_reg_mr {
__aligned_u64 hca_va;
__u32 pd_handle;
__u32 access_flags;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_reg_mr_resp {
__u32 mr_handle;
__u32 lkey;
__u32 rkey;
- __u32 driver_data[0];
+ __u32 driver_data[];
};
struct ib_uverbs_rereg_mr {
@@ -362,13 +374,13 @@ struct ib_uverbs_rereg_mr {
__aligned_u64 hca_va;
__u32 pd_handle;
__u32 access_flags;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_rereg_mr_resp {
__u32 lkey;
__u32 rkey;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_dereg_mr {
@@ -380,13 +392,13 @@ struct ib_uverbs_alloc_mw {
__u32 pd_handle;
__u8 mw_type;
__u8 reserved[3];
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_alloc_mw_resp {
__u32 mw_handle;
__u32 rkey;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_dealloc_mw {
@@ -408,7 +420,7 @@ struct ib_uverbs_create_cq {
__u32 comp_vector;
__s32 comp_channel;
__u32 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
enum ib_uverbs_ex_create_cq_flags {
@@ -442,13 +454,13 @@ struct ib_uverbs_resize_cq {
__aligned_u64 response;
__u32 cq_handle;
__u32 cqe;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_resize_cq_resp {
__u32 cqe;
__u32 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_poll_cq {
@@ -466,6 +478,8 @@ enum ib_uverbs_wc_opcode {
IB_UVERBS_WC_BIND_MW = 5,
IB_UVERBS_WC_LOCAL_INV = 6,
IB_UVERBS_WC_TSO = 7,
+ IB_UVERBS_WC_FLUSH = 8,
+ IB_UVERBS_WC_ATOMIC_WRITE = 9,
};
struct ib_uverbs_wc {
@@ -492,7 +506,7 @@ struct ib_uverbs_wc {
struct ib_uverbs_poll_cq_resp {
__u32 count;
__u32 reserved;
- struct ib_uverbs_wc wc[0];
+ struct ib_uverbs_wc wc[];
};
struct ib_uverbs_req_notify_cq {
@@ -585,7 +599,7 @@ struct ib_uverbs_create_qp {
__u8 qp_type;
__u8 is_srq;
__u8 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
enum ib_uverbs_create_qp_mask {
@@ -624,7 +638,7 @@ struct ib_uverbs_open_qp {
__u32 qpn;
__u8 qp_type;
__u8 reserved[7];
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
/* also used for open response */
@@ -669,7 +683,7 @@ struct ib_uverbs_query_qp {
__aligned_u64 response;
__u32 qp_handle;
__u32 attr_mask;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_qp_resp {
@@ -703,7 +717,7 @@ struct ib_uverbs_query_qp_resp {
__u8 alt_timeout;
__u8 sq_sig_all;
__u8 reserved[5];
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_modify_qp {
@@ -784,6 +798,8 @@ enum ib_uverbs_wr_opcode {
IB_UVERBS_WR_RDMA_READ_WITH_INV = 11,
IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP = 12,
IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD = 13,
+ IB_UVERBS_WR_FLUSH = 14,
+ IB_UVERBS_WR_ATOMIC_WRITE = 15,
/* Review enum ib_wr_opcode before modifying this */
};
@@ -824,7 +840,7 @@ struct ib_uverbs_post_send {
__u32 wr_count;
__u32 sge_count;
__u32 wqe_size;
- struct ib_uverbs_send_wr send_wr[0];
+ struct ib_uverbs_send_wr send_wr[];
};
struct ib_uverbs_post_send_resp {
@@ -843,7 +859,7 @@ struct ib_uverbs_post_recv {
__u32 wr_count;
__u32 sge_count;
__u32 wqe_size;
- struct ib_uverbs_recv_wr recv_wr[0];
+ struct ib_uverbs_recv_wr recv_wr[];
};
struct ib_uverbs_post_recv_resp {
@@ -856,7 +872,7 @@ struct ib_uverbs_post_srq_recv {
__u32 wr_count;
__u32 sge_count;
__u32 wqe_size;
- struct ib_uverbs_recv_wr recv[0];
+ struct ib_uverbs_recv_wr recv[];
};
struct ib_uverbs_post_srq_recv_resp {
@@ -869,12 +885,12 @@ struct ib_uverbs_create_ah {
__u32 pd_handle;
__u32 reserved;
struct ib_uverbs_ah_attr attr;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_create_ah_resp {
__u32 ah_handle;
- __u32 driver_data[0];
+ __u32 driver_data[];
};
struct ib_uverbs_destroy_ah {
@@ -886,7 +902,7 @@ struct ib_uverbs_attach_mcast {
__u32 qp_handle;
__u16 mlid;
__u16 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_detach_mcast {
@@ -894,7 +910,7 @@ struct ib_uverbs_detach_mcast {
__u32 qp_handle;
__u16 mlid;
__u16 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_flow_spec_hdr {
@@ -1135,7 +1151,7 @@ struct ib_uverbs_flow_attr {
* struct ib_flow_spec_xxx
* struct ib_flow_spec_yyy
*/
- struct ib_uverbs_flow_spec_hdr flow_specs[0];
+ struct ib_uverbs_flow_spec_hdr flow_specs[];
};
struct ib_uverbs_create_flow {
@@ -1161,7 +1177,7 @@ struct ib_uverbs_create_srq {
__u32 max_wr;
__u32 max_sge;
__u32 srq_limit;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_create_xsrq {
@@ -1175,7 +1191,7 @@ struct ib_uverbs_create_xsrq {
__u32 max_num_tags;
__u32 xrcd_handle;
__u32 cq_handle;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_create_srq_resp {
@@ -1183,7 +1199,7 @@ struct ib_uverbs_create_srq_resp {
__u32 max_wr;
__u32 max_sge;
__u32 srqn;
- __u32 driver_data[0];
+ __u32 driver_data[];
};
struct ib_uverbs_modify_srq {
@@ -1191,14 +1207,14 @@ struct ib_uverbs_modify_srq {
__u32 attr_mask;
__u32 max_wr;
__u32 srq_limit;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_srq {
__aligned_u64 response;
__u32 srq_handle;
__u32 reserved;
- __aligned_u64 driver_data[0];
+ __aligned_u64 driver_data[];
};
struct ib_uverbs_query_srq_resp {
@@ -1269,7 +1285,7 @@ struct ib_uverbs_ex_create_rwq_ind_table {
* wq_handle1
* wq_handle2
*/
- __u32 wq_handles[0];
+ __u32 wq_handles[];
};
struct ib_uverbs_ex_create_rwq_ind_table_resp {
@@ -1298,4 +1314,51 @@ struct ib_uverbs_ex_modify_cq {
#define IB_DEVICE_NAME_MAX 64
+/*
+ * bits 9, 15, 16, 19, 22, 27, 30, 31, 32, 33, 35 and 37 may be set by old
+ * kernels and should not be used.
+ */
+enum ib_uverbs_device_cap_flags {
+ IB_UVERBS_DEVICE_RESIZE_MAX_WR = 1 << 0,
+ IB_UVERBS_DEVICE_BAD_PKEY_CNTR = 1 << 1,
+ IB_UVERBS_DEVICE_BAD_QKEY_CNTR = 1 << 2,
+ IB_UVERBS_DEVICE_RAW_MULTI = 1 << 3,
+ IB_UVERBS_DEVICE_AUTO_PATH_MIG = 1 << 4,
+ IB_UVERBS_DEVICE_CHANGE_PHY_PORT = 1 << 5,
+ IB_UVERBS_DEVICE_UD_AV_PORT_ENFORCE = 1 << 6,
+ IB_UVERBS_DEVICE_CURR_QP_STATE_MOD = 1 << 7,
+ IB_UVERBS_DEVICE_SHUTDOWN_PORT = 1 << 8,
+ /* IB_UVERBS_DEVICE_INIT_TYPE = 1 << 9, (not in use) */
+ IB_UVERBS_DEVICE_PORT_ACTIVE_EVENT = 1 << 10,
+ IB_UVERBS_DEVICE_SYS_IMAGE_GUID = 1 << 11,
+ IB_UVERBS_DEVICE_RC_RNR_NAK_GEN = 1 << 12,
+ IB_UVERBS_DEVICE_SRQ_RESIZE = 1 << 13,
+ IB_UVERBS_DEVICE_N_NOTIFY_CQ = 1 << 14,
+ IB_UVERBS_DEVICE_MEM_WINDOW = 1 << 17,
+ IB_UVERBS_DEVICE_UD_IP_CSUM = 1 << 18,
+ IB_UVERBS_DEVICE_XRC = 1 << 20,
+ IB_UVERBS_DEVICE_MEM_MGT_EXTENSIONS = 1 << 21,
+ IB_UVERBS_DEVICE_MEM_WINDOW_TYPE_2A = 1 << 23,
+ IB_UVERBS_DEVICE_MEM_WINDOW_TYPE_2B = 1 << 24,
+ IB_UVERBS_DEVICE_RC_IP_CSUM = 1 << 25,
+ /* Deprecated. Please use IB_UVERBS_RAW_PACKET_CAP_IP_CSUM. */
+ IB_UVERBS_DEVICE_RAW_IP_CSUM = 1 << 26,
+ IB_UVERBS_DEVICE_MANAGED_FLOW_STEERING = 1 << 29,
+ /* Deprecated. Please use IB_UVERBS_RAW_PACKET_CAP_SCATTER_FCS. */
+ IB_UVERBS_DEVICE_RAW_SCATTER_FCS = 1ULL << 34,
+ IB_UVERBS_DEVICE_PCI_WRITE_END_PADDING = 1ULL << 36,
+ /* Flush placement types */
+ IB_UVERBS_DEVICE_FLUSH_GLOBAL = 1ULL << 38,
+ IB_UVERBS_DEVICE_FLUSH_PERSISTENT = 1ULL << 39,
+ /* Atomic write attributes */
+ IB_UVERBS_DEVICE_ATOMIC_WRITE = 1ULL << 40,
+};
+
+enum ib_uverbs_raw_packet_caps {
+ IB_UVERBS_RAW_PACKET_CAP_CVLAN_STRIPPING = 1 << 0,
+ IB_UVERBS_RAW_PACKET_CAP_SCATTER_FCS = 1 << 1,
+ IB_UVERBS_RAW_PACKET_CAP_IP_CSUM = 1 << 2,
+ IB_UVERBS_RAW_PACKET_CAP_DELAY_DROP = 1 << 3,
+};
+
#endif /* IB_USER_VERBS_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/rdma/mana-abi.h b/lib/libc/include/any-linux-any/rdma/mana-abi.h
new file mode 100644
index 0000000000..4d656b42e3
--- /dev/null
+++ b/lib/libc/include/any-linux-any/rdma/mana-abi.h
@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
+/*
+ * Copyright (c) 2022, Microsoft Corporation. All rights reserved.
+ */
+
+#ifndef MANA_ABI_USER_H
+#define MANA_ABI_USER_H
+
+#include <linux/types.h>
+#include <rdma/ib_user_ioctl_verbs.h>
+
+/*
+ * Increment this value if any changes that break userspace ABI
+ * compatibility are made.
+ */
+
+#define MANA_IB_UVERBS_ABI_VERSION 1
+
+struct mana_ib_create_cq {
+ __aligned_u64 buf_addr;
+};
+
+struct mana_ib_create_qp {
+ __aligned_u64 sq_buf_addr;
+ __u32 sq_buf_size;
+ __u32 port;
+};
+
+struct mana_ib_create_qp_resp {
+ __u32 sqid;
+ __u32 cqid;
+ __u32 tx_vp_offset;
+ __u32 reserved;
+};
+
+struct mana_ib_create_wq {
+ __aligned_u64 wq_buf_addr;
+ __u32 wq_buf_size;
+ __u32 reserved;
+};
+
+/* RX Hash function flags */
+enum mana_ib_rx_hash_function_flags {
+ MANA_IB_RX_HASH_FUNC_TOEPLITZ = 1 << 0,
+};
+
+struct mana_ib_create_qp_rss {
+ __aligned_u64 rx_hash_fields_mask;
+ __u8 rx_hash_function;
+ __u8 reserved[7];
+ __u32 rx_hash_key_len;
+ __u8 rx_hash_key[40];
+ __u32 port;
+};
+
+struct rss_resp_entry {
+ __u32 cqid;
+ __u32 wqid;
+};
+
+struct mana_ib_create_qp_rss_resp {
+ __aligned_u64 num_entries;
+ struct rss_resp_entry entries[64];
+};
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/rdma/mlx5-abi.h b/lib/libc/include/any-linux-any/rdma/mlx5-abi.h
index 346cea8fec..090d350a3d 100644
--- a/lib/libc/include/any-linux-any/rdma/mlx5-abi.h
+++ b/lib/libc/include/any-linux-any/rdma/mlx5-abi.h
@@ -104,6 +104,7 @@ enum mlx5_ib_alloc_ucontext_resp_mask {
MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_ECE = 1UL << 2,
MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_SQD2RTS = 1UL << 3,
MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_REAL_TIME_TS = 1UL << 4,
+ MLX5_IB_ALLOC_UCONTEXT_RESP_MASK_MKEY_UPDATE_TAG = 1UL << 5,
};
enum mlx5_user_cmds_supp_uhw {
diff --git a/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_cmds.h b/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_cmds.h
index b01ce64118..e7029051f4 100644
--- a/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_cmds.h
+++ b/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_cmds.h
@@ -174,6 +174,7 @@ enum mlx5_ib_devx_umem_reg_attrs {
MLX5_IB_ATTR_DEVX_UMEM_REG_ACCESS,
MLX5_IB_ATTR_DEVX_UMEM_REG_OUT_ID,
MLX5_IB_ATTR_DEVX_UMEM_REG_PGSZ_BITMAP,
+ MLX5_IB_ATTR_DEVX_UMEM_REG_DMABUF_FD,
};
enum mlx5_ib_devx_umem_dereg_attrs {
@@ -228,6 +229,7 @@ enum mlx5_ib_objects {
MLX5_IB_OBJECT_VAR,
MLX5_IB_OBJECT_PP,
MLX5_IB_OBJECT_UAR,
+ MLX5_IB_OBJECT_STEERING_ANCHOR,
};
enum mlx5_ib_flow_matcher_create_attrs {
@@ -248,11 +250,27 @@ enum mlx5_ib_flow_matcher_methods {
MLX5_IB_METHOD_FLOW_MATCHER_DESTROY,
};
+enum mlx5_ib_flow_steering_anchor_create_attrs {
+ MLX5_IB_ATTR_STEERING_ANCHOR_CREATE_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
+ MLX5_IB_ATTR_STEERING_ANCHOR_FT_TYPE,
+ MLX5_IB_ATTR_STEERING_ANCHOR_PRIORITY,
+ MLX5_IB_ATTR_STEERING_ANCHOR_FT_ID,
+};
+
+enum mlx5_ib_flow_steering_anchor_destroy_attrs {
+ MLX5_IB_ATTR_STEERING_ANCHOR_DESTROY_HANDLE = (1U << UVERBS_ID_NS_SHIFT),
+};
+
+enum mlx5_ib_steering_anchor_methods {
+ MLX5_IB_METHOD_STEERING_ANCHOR_CREATE = (1U << UVERBS_ID_NS_SHIFT),
+ MLX5_IB_METHOD_STEERING_ANCHOR_DESTROY,
+};
+
enum mlx5_ib_device_query_context_attrs {
MLX5_IB_ATTR_QUERY_CONTEXT_RESP_UCTX = (1U << UVERBS_ID_NS_SHIFT),
};
-#define MLX5_IB_DW_MATCH_PARAM 0x90
+#define MLX5_IB_DW_MATCH_PARAM 0xA0
struct mlx5_ib_match_params {
__u32 match_params[MLX5_IB_DW_MATCH_PARAM];
diff --git a/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_verbs.h b/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_verbs.h
index 4fef7c9283..df8e463439 100644
--- a/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_verbs.h
+++ b/lib/libc/include/any-linux-any/rdma/mlx5_user_ioctl_verbs.h
@@ -63,6 +63,7 @@ enum mlx5_ib_uapi_dm_type {
MLX5_IB_UAPI_DM_TYPE_MEMIC,
MLX5_IB_UAPI_DM_TYPE_STEERING_SW_ICM,
MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_SW_ICM,
+ MLX5_IB_UAPI_DM_TYPE_HEADER_MODIFY_PATTERN_SW_ICM,
};
enum mlx5_ib_uapi_devx_create_event_channel_flags {
diff --git a/lib/libc/include/any-linux-any/rdma/rdma_user_cm.h b/lib/libc/include/any-linux-any/rdma/rdma_user_cm.h
index 5aec793a9a..3fbf696a34 100644
--- a/lib/libc/include/any-linux-any/rdma/rdma_user_cm.h
+++ b/lib/libc/include/any-linux-any/rdma/rdma_user_cm.h
@@ -184,7 +184,7 @@ struct rdma_ucm_query_addr_resp {
struct rdma_ucm_query_path_resp {
__u32 num_paths;
__u32 reserved;
- struct ib_path_rec_data path_data[0];
+ struct ib_path_rec_data path_data[];
};
struct rdma_ucm_conn_param {
diff --git a/lib/libc/include/any-linux-any/rdma/rdma_user_ioctl_cmds.h b/lib/libc/include/any-linux-any/rdma/rdma_user_ioctl_cmds.h
index 22996ef248..55fa29b61f 100644
--- a/lib/libc/include/any-linux-any/rdma/rdma_user_ioctl_cmds.h
+++ b/lib/libc/include/any-linux-any/rdma/rdma_user_ioctl_cmds.h
@@ -81,7 +81,7 @@ struct ib_uverbs_ioctl_hdr {
__aligned_u64 reserved1;
__u32 driver_id;
__u32 reserved2;
- struct ib_uverbs_attr attrs[0];
+ struct ib_uverbs_attr attrs[];
};
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/rdma/rdma_user_rxe.h b/lib/libc/include/any-linux-any/rdma/rdma_user_rxe.h
index 6c5f373817..7e5322e24a 100644
--- a/lib/libc/include/any-linux-any/rdma/rdma_user_rxe.h
+++ b/lib/libc/include/any-linux-any/rdma/rdma_user_rxe.h
@@ -74,7 +74,7 @@ struct rxe_av {
struct rxe_send_wr {
__aligned_u64 wr_id;
- __u32 num_sge;
+ __u32 reserved;
__u32 opcode;
__u32 send_flags;
union {
@@ -84,6 +84,13 @@ struct rxe_send_wr {
union {
struct {
__aligned_u64 remote_addr;
+ __u32 length;
+ __u32 rkey;
+ __u8 type;
+ __u8 level;
+ } flush;
+ struct {
+ __aligned_u64 remote_addr;
__u32 rkey;
__u32 reserved;
} rdma;
@@ -136,6 +143,7 @@ struct rxe_dma_info {
__u32 reserved;
union {
__DECLARE_FLEX_ARRAY(__u8, inline_data);
+ __DECLARE_FLEX_ARRAY(__u8, atomic_wr);
__DECLARE_FLEX_ARRAY(struct rxe_sge, sge);
};
};
@@ -156,7 +164,7 @@ struct rxe_send_wqe {
struct rxe_recv_wqe {
__aligned_u64 wr_id;
- __u32 num_sge;
+ __u32 reserved;
__u32 padding;
struct rxe_dma_info dma;
};
diff --git a/lib/libc/include/any-linux-any/scsi/fc/fc_els.h b/lib/libc/include/any-linux-any/scsi/fc/fc_els.h
index 27377b6125..e84bc63e7f 100644
--- a/lib/libc/include/any-linux-any/scsi/fc/fc_els.h
+++ b/lib/libc/include/any-linux-any/scsi/fc/fc_els.h
@@ -264,7 +264,7 @@ struct fc_tlv_desc {
* Size of descriptor excluding
* desc_tag and desc_len fields.
*/
- __u8 desc_value[0]; /* Descriptor Value */
+ __u8 desc_value[]; /* Descriptor Value */
};
/* Descriptor tag and len fields are considered the mandatory header
@@ -1027,7 +1027,7 @@ struct fc_fn_li_desc {
* threshold to caause the LI event
*/
__be32 pname_count; /* number of portname_list elements */
- __be64 pname_list[0]; /* list of N_Port_Names accessible
+ __be64 pname_list[]; /* list of N_Port_Names accessible
* through the attached port
*/
};
@@ -1069,7 +1069,7 @@ struct fc_fn_peer_congn_desc {
* congestion event
*/
__be32 pname_count; /* number of portname_list elements */
- __be64 pname_list[0]; /* list of N_Port_Names accessible
+ __be64 pname_list[]; /* list of N_Port_Names accessible
* through the attached port
*/
};
@@ -1104,7 +1104,7 @@ struct fc_els_fpin {
* Size of ELS excluding fpin_cmd,
* fpin_zero and desc_len fields.
*/
- struct fc_tlv_desc fpin_desc[0]; /* Descriptor list */
+ struct fc_tlv_desc fpin_desc[]; /* Descriptor list */
};
/* Diagnostic Function Descriptor - FPIN Registration */
@@ -1115,7 +1115,7 @@ struct fc_df_desc_fpin_reg {
* desc_tag and desc_len fields.
*/
__be32 count; /* Number of desc_tags elements */
- __be32 desc_tags[0]; /* Array of Descriptor Tags.
+ __be32 desc_tags[]; /* Array of Descriptor Tags.
* Each tag indicates a function
* supported by the N_Port (request)
* or by the N_Port and Fabric
@@ -1135,7 +1135,7 @@ struct fc_els_rdf {
* Size of ELS excluding fpin_cmd,
* fpin_zero and desc_len fields.
*/
- struct fc_tlv_desc desc[0]; /* Descriptor list */
+ struct fc_tlv_desc desc[]; /* Descriptor list */
};
/*
@@ -1148,7 +1148,7 @@ struct fc_els_rdf_resp {
* and desc_list_len fields.
*/
struct fc_els_lsri_desc lsri;
- struct fc_tlv_desc desc[0]; /* Supported Descriptor list */
+ struct fc_tlv_desc desc[]; /* Supported Descriptor list */
};
@@ -1231,7 +1231,7 @@ struct fc_els_edc {
* Size of ELS excluding edc_cmd,
* edc_zero and desc_len fields.
*/
- struct fc_tlv_desc desc[0];
+ struct fc_tlv_desc desc[];
/* Diagnostic Descriptor list */
};
@@ -1245,7 +1245,7 @@ struct fc_els_edc_resp {
* and desc_list_len fields.
*/
struct fc_els_lsri_desc lsri;
- struct fc_tlv_desc desc[0];
+ struct fc_tlv_desc desc[];
/* Supported Diagnostic Descriptor list */
};
diff --git a/lib/libc/include/any-linux-any/scsi/scsi_bsg_fc.h b/lib/libc/include/any-linux-any/scsi/scsi_bsg_fc.h
index 6582ee107b..cf5255efb9 100644
--- a/lib/libc/include/any-linux-any/scsi/scsi_bsg_fc.h
+++ b/lib/libc/include/any-linux-any/scsi/scsi_bsg_fc.h
@@ -209,14 +209,14 @@ struct fc_bsg_host_vendor {
__u64 vendor_id;
/* start of vendor command area */
- __u32 vendor_cmd[0];
+ __u32 vendor_cmd[];
};
/* Response:
*/
struct fc_bsg_host_vendor_reply {
/* start of vendor response area */
- __u32 vendor_rsp[0];
+ __DECLARE_FLEX_ARRAY(__u32, vendor_rsp);
};
diff --git a/lib/libc/include/any-linux-any/scsi/scsi_bsg_mpi3mr.h b/lib/libc/include/any-linux-any/scsi/scsi_bsg_mpi3mr.h
new file mode 100644
index 0000000000..29a3b5d649
--- /dev/null
+++ b/lib/libc/include/any-linux-any/scsi/scsi_bsg_mpi3mr.h
@@ -0,0 +1,576 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
+/*
+ * Driver for Broadcom MPI3 Storage Controllers
+ *
+ * Copyright (C) 2017-2022 Broadcom Inc.
+ * (mailto: mpi3mr-linuxdrv.pdl@broadcom.com)
+ *
+ */
+
+#ifndef SCSI_BSG_MPI3MR_H_INCLUDED
+#define SCSI_BSG_MPI3MR_H_INCLUDED
+
+#include <linux/types.h>
+
+/* Definitions for BSG commands */
+#define MPI3MR_IOCTL_VERSION 0x06
+
+#define MPI3MR_APP_DEFAULT_TIMEOUT (60) /*seconds*/
+
+#define MPI3MR_BSG_ADPTYPE_UNKNOWN 0
+#define MPI3MR_BSG_ADPTYPE_AVGFAMILY 1
+
+#define MPI3MR_BSG_ADPSTATE_UNKNOWN 0
+#define MPI3MR_BSG_ADPSTATE_OPERATIONAL 1
+#define MPI3MR_BSG_ADPSTATE_FAULT 2
+#define MPI3MR_BSG_ADPSTATE_IN_RESET 3
+#define MPI3MR_BSG_ADPSTATE_UNRECOVERABLE 4
+
+#define MPI3MR_BSG_ADPRESET_UNKNOWN 0
+#define MPI3MR_BSG_ADPRESET_SOFT 1
+#define MPI3MR_BSG_ADPRESET_DIAG_FAULT 2
+
+#define MPI3MR_BSG_LOGDATA_MAX_ENTRIES 400
+#define MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ 4
+
+#define MPI3MR_DRVBSG_OPCODE_UNKNOWN 0
+#define MPI3MR_DRVBSG_OPCODE_ADPINFO 1
+#define MPI3MR_DRVBSG_OPCODE_ADPRESET 2
+#define MPI3MR_DRVBSG_OPCODE_ALLTGTDEVINFO 4
+#define MPI3MR_DRVBSG_OPCODE_GETCHGCNT 5
+#define MPI3MR_DRVBSG_OPCODE_LOGDATAENABLE 6
+#define MPI3MR_DRVBSG_OPCODE_PELENABLE 7
+#define MPI3MR_DRVBSG_OPCODE_GETLOGDATA 8
+#define MPI3MR_DRVBSG_OPCODE_QUERY_HDB 9
+#define MPI3MR_DRVBSG_OPCODE_REPOST_HDB 10
+#define MPI3MR_DRVBSG_OPCODE_UPLOAD_HDB 11
+#define MPI3MR_DRVBSG_OPCODE_REFRESH_HDB_TRIGGERS 12
+
+
+#define MPI3MR_BSG_BUFTYPE_UNKNOWN 0
+#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_CMD 1
+#define MPI3MR_BSG_BUFTYPE_RAIDMGMT_RESP 2
+#define MPI3MR_BSG_BUFTYPE_DATA_IN 3
+#define MPI3MR_BSG_BUFTYPE_DATA_OUT 4
+#define MPI3MR_BSG_BUFTYPE_MPI_REPLY 5
+#define MPI3MR_BSG_BUFTYPE_ERR_RESPONSE 6
+#define MPI3MR_BSG_BUFTYPE_MPI_REQUEST 0xFE
+
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_UNKNOWN 0
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_STATUS 1
+#define MPI3MR_BSG_MPI_REPLY_BUFTYPE_ADDRESS 2
+
+#define MPI3MR_HDB_BUFTYPE_UNKNOWN 0
+#define MPI3MR_HDB_BUFTYPE_TRACE 1
+#define MPI3MR_HDB_BUFTYPE_FIRMWARE 2
+#define MPI3MR_HDB_BUFTYPE_RESERVED 3
+
+#define MPI3MR_HDB_BUFSTATUS_UNKNOWN 0
+#define MPI3MR_HDB_BUFSTATUS_NOT_ALLOCATED 1
+#define MPI3MR_HDB_BUFSTATUS_POSTED_UNPAUSED 2
+#define MPI3MR_HDB_BUFSTATUS_POSTED_PAUSED 3
+#define MPI3MR_HDB_BUFSTATUS_RELEASED 4
+
+#define MPI3MR_HDB_TRIGGER_TYPE_UNKNOWN 0
+#define MPI3MR_HDB_TRIGGER_TYPE_DIAGFAULT 1
+#define MPI3MR_HDB_TRIGGER_TYPE_ELEMENT 2
+#define MPI3MR_HDB_TRIGGER_TYPE_MASTER 3
+
+
+/* Supported BSG commands */
+enum command {
+ MPI3MR_DRV_CMD = 1,
+ MPI3MR_MPT_CMD = 2,
+};
+
+/**
+ * struct mpi3_driver_info_layout - Information about driver
+ *
+ * @information_length: Length of this structure in bytes
+ * @driver_signature: Driver Vendor name
+ * @os_name: Operating System Name
+ * @driver_name: Driver name
+ * @driver_version: Driver version
+ * @driver_release_date: Driver release date
+ * @driver_capabilities: Driver capabilities
+ */
+struct mpi3_driver_info_layout {
+ __le32 information_length;
+ __u8 driver_signature[12];
+ __u8 os_name[16];
+ __u8 os_version[12];
+ __u8 driver_name[20];
+ __u8 driver_version[32];
+ __u8 driver_release_date[20];
+ __le32 driver_capabilities;
+};
+
+/**
+ * struct mpi3mr_bsg_in_adpinfo - Adapter information request
+ * data returned by the driver.
+ *
+ * @adp_type: Adapter type
+ * @rsvd1: Reserved
+ * @pci_dev_id: PCI device ID of the adapter
+ * @pci_dev_hw_rev: PCI revision of the adapter
+ * @pci_subsys_dev_id: PCI subsystem device ID of the adapter
+ * @pci_subsys_ven_id: PCI subsystem vendor ID of the adapter
+ * @pci_dev: PCI device
+ * @pci_func: PCI function
+ * @pci_bus: PCI bus
+ * @rsvd2: Reserved
+ * @pci_seg_id: PCI segment ID
+ * @app_intfc_ver: version of the application interface definition
+ * @rsvd3: Reserved
+ * @rsvd4: Reserved
+ * @rsvd5: Reserved
+ * @driver_info: Driver Information (Version/Name)
+ */
+struct mpi3mr_bsg_in_adpinfo {
+ __u32 adp_type;
+ __u32 rsvd1;
+ __u32 pci_dev_id;
+ __u32 pci_dev_hw_rev;
+ __u32 pci_subsys_dev_id;
+ __u32 pci_subsys_ven_id;
+ __u32 pci_dev:5;
+ __u32 pci_func:3;
+ __u32 pci_bus:8;
+ __u16 rsvd2;
+ __u32 pci_seg_id;
+ __u32 app_intfc_ver;
+ __u8 adp_state;
+ __u8 rsvd3;
+ __u16 rsvd4;
+ __u32 rsvd5[2];
+ struct mpi3_driver_info_layout driver_info;
+};
+
+/**
+ * struct mpi3mr_bsg_adp_reset - Adapter reset request
+ * payload data to the driver.
+ *
+ * @reset_type: Reset type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_adp_reset {
+ __u8 reset_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+};
+
+/**
+ * struct mpi3mr_change_count - Topology change count
+ * returned by the driver.
+ *
+ * @change_count: Topology change count
+ * @rsvd: Reserved
+ */
+struct mpi3mr_change_count {
+ __u16 change_count;
+ __u16 rsvd;
+};
+
+/**
+ * struct mpi3mr_device_map_info - Target device mapping
+ * information
+ *
+ * @handle: Firmware device handle
+ * @perst_id: Persistent ID assigned by the firmware
+ * @target_id: Target ID assigned by the driver
+ * @bus_id: Bus ID assigned by the driver
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_device_map_info {
+ __u16 handle;
+ __u16 perst_id;
+ __u32 target_id;
+ __u8 bus_id;
+ __u8 rsvd1;
+ __u16 rsvd2;
+};
+
+/**
+ * struct mpi3mr_all_tgt_info - Target device mapping
+ * information returned by the driver
+ *
+ * @num_devices: The number of devices in driver's inventory
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @dmi: Variable length array of mapping information of targets
+ */
+struct mpi3mr_all_tgt_info {
+ __u16 num_devices;
+ __u16 rsvd1;
+ __u32 rsvd2;
+ struct mpi3mr_device_map_info dmi[1];
+};
+
+/**
+ * struct mpi3mr_logdata_enable - Number of log data
+ * entries saved by the driver returned as payload data for
+ * enable logdata BSG request by the driver.
+ *
+ * @max_entries: Number of log data entries cached by the driver
+ * @rsvd: Reserved
+ */
+struct mpi3mr_logdata_enable {
+ __u16 max_entries;
+ __u16 rsvd;
+};
+
+/**
+ * struct mpi3mr_bsg_out_pel_enable - PEL enable request payload
+ * data to the driver.
+ *
+ * @pel_locale: PEL locale to the firmware
+ * @pel_class: PEL class to the firmware
+ * @rsvd: Reserved
+ */
+struct mpi3mr_bsg_out_pel_enable {
+ __u16 pel_locale;
+ __u8 pel_class;
+ __u8 rsvd;
+};
+
+/**
+ * struct mpi3mr_logdata_entry - Log data entry cached by the
+ * driver.
+ *
+ * @valid_entry: Is the entry valid
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @data: Variable length Log entry data
+ */
+struct mpi3mr_logdata_entry {
+ __u8 valid_entry;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u8 data[1]; /* Variable length Array */
+};
+
+/**
+ * struct mpi3mr_bsg_in_log_data - Log data entries saved by
+ * the driver returned as payload data for Get logdata request
+ * by the driver.
+ *
+ * @entry: Variable length Log data entry array
+ */
+struct mpi3mr_bsg_in_log_data {
+ struct mpi3mr_logdata_entry entry[1];
+};
+
+/**
+ * struct mpi3mr_hdb_entry - host diag buffer entry.
+ *
+ * @buf_type: Buffer type
+ * @status: Buffer status
+ * @trigger_type: Trigger type
+ * @rsvd1: Reserved
+ * @size: Buffer size
+ * @rsvd2: Reserved
+ * @trigger_data: Trigger specific data
+ * @rsvd3: Reserved
+ * @rsvd4: Reserved
+ */
+struct mpi3mr_hdb_entry {
+ __u8 buf_type;
+ __u8 status;
+ __u8 trigger_type;
+ __u8 rsvd1;
+ __u16 size;
+ __u16 rsvd2;
+ __u64 trigger_data;
+ __u32 rsvd3;
+ __u32 rsvd4;
+};
+
+
+/**
+ * struct mpi3mr_bsg_in_hdb_status - This structure contains
+ * return data for the BSG request to retrieve the number of host
+ * diagnostic buffers supported by the driver and their current
+ * status and additional status specific data if any in forms of
+ * multiple hdb entries.
+ *
+ * @num_hdb_types: Number of host diag buffer types supported
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @rsvd3: Reserved
+ * @entry: Variable length Diag buffer status entry array
+ */
+struct mpi3mr_bsg_in_hdb_status {
+ __u8 num_hdb_types;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u32 rsvd3;
+ struct mpi3mr_hdb_entry entry[1];
+};
+
+/**
+ * struct mpi3mr_bsg_out_repost_hdb - Repost host diagnostic
+ * buffer request payload data to the driver.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_out_repost_hdb {
+ __u8 buf_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+};
+
+/**
+ * struct mpi3mr_bsg_out_upload_hdb - Upload host diagnostic
+ * buffer request payload data to the driver.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @start_offset: Start offset of the buffer from where to copy
+ * @length: Length of the buffer to copy
+ */
+struct mpi3mr_bsg_out_upload_hdb {
+ __u8 buf_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u32 start_offset;
+ __u32 length;
+};
+
+/**
+ * struct mpi3mr_bsg_out_refresh_hdb_triggers - Refresh host
+ * diagnostic buffer triggers request payload data to the driver.
+ *
+ * @page_type: Page type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_out_refresh_hdb_triggers {
+ __u8 page_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+};
+/**
+ * struct mpi3mr_bsg_drv_cmd - Generic bsg data
+ * structure for all driver specific requests.
+ *
+ * @mrioc_id: Controller ID
+ * @opcode: Driver specific opcode
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ */
+struct mpi3mr_bsg_drv_cmd {
+ __u8 mrioc_id;
+ __u8 opcode;
+ __u16 rsvd1;
+ __u32 rsvd2[4];
+};
+/**
+ * struct mpi3mr_bsg_in_reply_buf - MPI reply buffer returned
+ * for MPI Passthrough request .
+ *
+ * @mpi_reply_type: Type of MPI reply
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @reply_buf: Variable Length buffer based on mpirep type
+ */
+struct mpi3mr_bsg_in_reply_buf {
+ __u8 mpi_reply_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u8 reply_buf[1];
+};
+
+/**
+ * struct mpi3mr_buf_entry - User buffer descriptor for MPI
+ * Passthrough requests.
+ *
+ * @buf_type: Buffer type
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @buf_len: Buffer length
+ */
+struct mpi3mr_buf_entry {
+ __u8 buf_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u32 buf_len;
+};
+/**
+ * struct mpi3mr_bsg_buf_entry_list - list of user buffer
+ * descriptor for MPI Passthrough requests.
+ *
+ * @num_of_entries: Number of buffer descriptors
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @rsvd3: Reserved
+ * @buf_entry: Variable length array of buffer descriptors
+ */
+struct mpi3mr_buf_entry_list {
+ __u8 num_of_entries;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u32 rsvd3;
+ struct mpi3mr_buf_entry buf_entry[1];
+};
+/**
+ * struct mpi3mr_bsg_mptcmd - Generic bsg data
+ * structure for all MPI Passthrough requests .
+ *
+ * @mrioc_id: Controller ID
+ * @rsvd1: Reserved
+ * @timeout: MPI request timeout
+ * @buf_entry_list: Buffer descriptor list
+ */
+struct mpi3mr_bsg_mptcmd {
+ __u8 mrioc_id;
+ __u8 rsvd1;
+ __u16 timeout;
+ __u32 rsvd2;
+ struct mpi3mr_buf_entry_list buf_entry_list;
+};
+
+/**
+ * struct mpi3mr_bsg_packet - Generic bsg data
+ * structure for all supported requests .
+ *
+ * @cmd_type: represents drvrcmd or mptcmd
+ * @rsvd1: Reserved
+ * @rsvd2: Reserved
+ * @drvrcmd: driver request structure
+ * @mptcmd: mpt request structure
+ */
+struct mpi3mr_bsg_packet {
+ __u8 cmd_type;
+ __u8 rsvd1;
+ __u16 rsvd2;
+ __u32 rsvd3;
+ union {
+ struct mpi3mr_bsg_drv_cmd drvrcmd;
+ struct mpi3mr_bsg_mptcmd mptcmd;
+ } cmd;
+};
+
+struct mpi3_nvme_encapsulated_request {
+ __le16 host_tag;
+ __u8 ioc_use_only02;
+ __u8 function;
+ __le16 ioc_use_only04;
+ __u8 ioc_use_only06;
+ __u8 msg_flags;
+ __le16 change_count;
+ __le16 dev_handle;
+ __le16 encapsulated_command_length;
+ __le16 flags;
+ __le32 data_length;
+ __le32 reserved14[3];
+ __le32 command[];
+};
+
+struct mpi3_nvme_encapsulated_error_reply {
+ __le16 host_tag;
+ __u8 ioc_use_only02;
+ __u8 function;
+ __le16 ioc_use_only04;
+ __u8 ioc_use_only06;
+ __u8 msg_flags;
+ __le16 ioc_use_only08;
+ __le16 ioc_status;
+ __le32 ioc_log_info;
+ __le32 nvme_completion_entry[4];
+};
+
+#define MPI3MR_NVME_PRP_SIZE 8 /* PRP size */
+#define MPI3MR_NVME_CMD_PRP1_OFFSET 24 /* PRP1 offset in NVMe cmd */
+#define MPI3MR_NVME_CMD_PRP2_OFFSET 32 /* PRP2 offset in NVMe cmd */
+#define MPI3MR_NVME_CMD_SGL_OFFSET 24 /* SGL offset in NVMe cmd */
+#define MPI3MR_NVME_DATA_FORMAT_PRP 0
+#define MPI3MR_NVME_DATA_FORMAT_SGL1 1
+#define MPI3MR_NVME_DATA_FORMAT_SGL2 2
+
+/* MPI3: task management related definitions */
+struct mpi3_scsi_task_mgmt_request {
+ __le16 host_tag;
+ __u8 ioc_use_only02;
+ __u8 function;
+ __le16 ioc_use_only04;
+ __u8 ioc_use_only06;
+ __u8 msg_flags;
+ __le16 change_count;
+ __le16 dev_handle;
+ __le16 task_host_tag;
+ __u8 task_type;
+ __u8 reserved0f;
+ __le16 task_request_queue_id;
+ __le16 reserved12;
+ __le32 reserved14;
+ __u8 lun[8];
+};
+
+#define MPI3_SCSITASKMGMT_MSGFLAGS_DO_NOT_SEND_TASK_IU (0x08)
+#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK (0x01)
+#define MPI3_SCSITASKMGMT_TASKTYPE_ABORT_TASK_SET (0x02)
+#define MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET (0x03)
+#define MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET (0x05)
+#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_TASK_SET (0x06)
+#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK (0x07)
+#define MPI3_SCSITASKMGMT_TASKTYPE_CLEAR_ACA (0x08)
+#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_TASK_SET (0x09)
+#define MPI3_SCSITASKMGMT_TASKTYPE_QUERY_ASYNC_EVENT (0x0a)
+#define MPI3_SCSITASKMGMT_TASKTYPE_I_T_NEXUS_RESET (0x0b)
+struct mpi3_scsi_task_mgmt_reply {
+ __le16 host_tag;
+ __u8 ioc_use_only02;
+ __u8 function;
+ __le16 ioc_use_only04;
+ __u8 ioc_use_only06;
+ __u8 msg_flags;
+ __le16 ioc_use_only08;
+ __le16 ioc_status;
+ __le32 ioc_log_info;
+ __le32 termination_count;
+ __le32 response_data;
+ __le32 reserved18;
+};
+
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_COMPLETE (0x00)
+#define MPI3_SCSITASKMGMT_RSPCODE_INVALID_FRAME (0x02)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_FUNCTION_NOT_SUPPORTED (0x04)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_FAILED (0x05)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_SUCCEEDED (0x08)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_INVALID_LUN (0x09)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_OVERLAPPED_TAG (0x0a)
+#define MPI3_SCSITASKMGMT_RSPCODE_IO_QUEUED_ON_IOC (0x80)
+#define MPI3_SCSITASKMGMT_RSPCODE_TM_NVME_DENIED (0x81)
+
+/* MPI3: PEL related definitions */
+#define MPI3_PEL_LOCALE_FLAGS_NON_BLOCKING_BOOT_EVENT (0x0200)
+#define MPI3_PEL_LOCALE_FLAGS_BLOCKING_BOOT_EVENT (0x0100)
+#define MPI3_PEL_LOCALE_FLAGS_PCIE (0x0080)
+#define MPI3_PEL_LOCALE_FLAGS_CONFIGURATION (0x0040)
+#define MPI3_PEL_LOCALE_FLAGS_CONTROLER (0x0020)
+#define MPI3_PEL_LOCALE_FLAGS_SAS (0x0010)
+#define MPI3_PEL_LOCALE_FLAGS_EPACK (0x0008)
+#define MPI3_PEL_LOCALE_FLAGS_ENCLOSURE (0x0004)
+#define MPI3_PEL_LOCALE_FLAGS_PD (0x0002)
+#define MPI3_PEL_LOCALE_FLAGS_VD (0x0001)
+#define MPI3_PEL_CLASS_DEBUG (0x00)
+#define MPI3_PEL_CLASS_PROGRESS (0x01)
+#define MPI3_PEL_CLASS_INFORMATIONAL (0x02)
+#define MPI3_PEL_CLASS_WARNING (0x03)
+#define MPI3_PEL_CLASS_CRITICAL (0x04)
+#define MPI3_PEL_CLASS_FATAL (0x05)
+#define MPI3_PEL_CLASS_FAULT (0x06)
+
+/* MPI3: Function definitions */
+#define MPI3_BSG_FUNCTION_MGMT_PASSTHROUGH (0x0a)
+#define MPI3_BSG_FUNCTION_SCSI_IO (0x20)
+#define MPI3_BSG_FUNCTION_SCSI_TASK_MGMT (0x21)
+#define MPI3_BSG_FUNCTION_SMP_PASSTHROUGH (0x22)
+#define MPI3_BSG_FUNCTION_NVME_ENCAPSULATED (0x24)
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h b/lib/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h
index 647c3179f4..7a87e9bb81 100644
--- a/lib/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h
+++ b/lib/libc/include/any-linux-any/scsi/scsi_bsg_ufs.h
@@ -14,10 +14,27 @@
*/
#define UFS_CDB_SIZE 16
-#define UPIU_TRANSACTION_UIC_CMD 0x1F
/* uic commands are 4DW long, per UFSHCI V2.1 paragraph 5.6.1 */
#define UIC_CMD_SIZE (sizeof(__u32) * 4)
+enum ufs_bsg_msg_code {
+ UPIU_TRANSACTION_UIC_CMD = 0x1F,
+ UPIU_TRANSACTION_ARPMB_CMD,
+};
+
+/* UFS RPMB Request Message Types */
+enum ufs_rpmb_op_type {
+ UFS_RPMB_WRITE_KEY = 0x01,
+ UFS_RPMB_READ_CNT = 0x02,
+ UFS_RPMB_WRITE = 0x03,
+ UFS_RPMB_READ = 0x04,
+ UFS_RPMB_READ_RESP = 0x05,
+ UFS_RPMB_SEC_CONF_WRITE = 0x06,
+ UFS_RPMB_SEC_CONF_READ = 0x07,
+ UFS_RPMB_PURGE_ENABLE = 0x08,
+ UFS_RPMB_PURGE_STATUS_READ = 0x09,
+};
+
/**
* struct utp_upiu_header - UPIU header structure
* @dword_0: UPIU header DW-0
@@ -79,6 +96,23 @@ struct utp_upiu_req {
};
};
+struct ufs_arpmb_meta {
+ __be16 req_resp_type;
+ __u8 nonce[16];
+ __be32 write_counter;
+ __be16 addr_lun;
+ __be16 block_count;
+ __be16 result;
+} __attribute__((__packed__));
+
+struct ufs_ehs {
+ __u8 length;
+ __u8 ehs_type;
+ __be16 ehssub_type;
+ struct ufs_arpmb_meta meta;
+ __u8 mac_key[32];
+} __attribute__((__packed__));
+
/* request (CDB) structure of the sg_io_v4 */
struct ufs_bsg_request {
__u32 msgcode;
@@ -95,11 +129,21 @@ struct ufs_bsg_reply {
* msg and status fields. The per-msgcode reply structure
* will contain valid data.
*/
- __u32 result;
+ int result;
/* If there was reply_payload, how much was received? */
__u32 reply_payload_rcv_len;
struct utp_upiu_req upiu_rsp;
};
+
+struct ufs_rpmb_request {
+ struct ufs_bsg_request bsg_request;
+ struct ufs_ehs ehs_req;
+};
+
+struct ufs_rpmb_reply {
+ struct ufs_bsg_reply bsg_reply;
+ struct ufs_ehs ehs_rsp;
+};
#endif /* UFS_BSG_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/scsi/scsi_netlink_fc.h b/lib/libc/include/any-linux-any/scsi/scsi_netlink_fc.h
index dc19180000..613ab2162b 100644
--- a/lib/libc/include/any-linux-any/scsi/scsi_netlink_fc.h
+++ b/lib/libc/include/any-linux-any/scsi/scsi_netlink_fc.h
@@ -35,7 +35,7 @@
* FC Transport Broadcast Event Message :
* FC_NL_ASYNC_EVENT
*
- * Note: if Vendor Unique message, &event_data will be start of
+ * Note: if Vendor Unique message, event_data_flex will be start of
* vendor unique payload, and the length of the payload is
* per event_datalen
*
@@ -50,7 +50,10 @@ struct fc_nl_event {
__u16 event_datalen;
__u32 event_num;
__u32 event_code;
- __u32 event_data;
+ union {
+ __u32 event_data;
+ __DECLARE_FLEX_ARRAY(__u8, event_data_flex);
+ };
} __attribute__((aligned(sizeof(__u64))));
diff --git a/lib/libc/include/any-linux-any/sound/asequencer.h b/lib/libc/include/any-linux-any/sound/asequencer.h
index 3c5554f5c6..157c1352a3 100644
--- a/lib/libc/include/any-linux-any/sound/asequencer.h
+++ b/lib/libc/include/any-linux-any/sound/asequencer.h
@@ -3,22 +3,6 @@
* Main header file for the ALSA sequencer
* Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
* (c) 1998-1999 by Jaroslav Kysela <perex@perex.cz>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#ifndef __SOUND_ASEQUENCER_H
#define __SOUND_ASEQUENCER_H
@@ -344,10 +328,10 @@ typedef int __bitwise snd_seq_client_type_t;
#define KERNEL_CLIENT ((snd_seq_client_type_t) 2)
/* event filter flags */
-#define SNDRV_SEQ_FILTER_BROADCAST (1<<0) /* accept broadcast messages */
-#define SNDRV_SEQ_FILTER_MULTICAST (1<<1) /* accept multicast messages */
-#define SNDRV_SEQ_FILTER_BOUNCE (1<<2) /* accept bounce event in error */
-#define SNDRV_SEQ_FILTER_USE_EVENT (1<<31) /* use event filter */
+#define SNDRV_SEQ_FILTER_BROADCAST (1U<<0) /* accept broadcast messages */
+#define SNDRV_SEQ_FILTER_MULTICAST (1U<<1) /* accept multicast messages */
+#define SNDRV_SEQ_FILTER_BOUNCE (1U<<2) /* accept bounce event in error */
+#define SNDRV_SEQ_FILTER_USE_EVENT (1U<<31) /* use event filter */
struct snd_seq_client_info {
int client; /* client number to inquire */
diff --git a/lib/libc/include/any-linux-any/sound/asoc.h b/lib/libc/include/any-linux-any/sound/asoc.h
index 6308b31834..428acdb4ab 100644
--- a/lib/libc/include/any-linux-any/sound/asoc.h
+++ b/lib/libc/include/any-linux-any/sound/asoc.h
@@ -5,10 +5,6 @@
* Copyright (C) 2012 Texas Instruments Inc.
* Copyright (C) 2015 Intel Corporation.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
* Simple file API to load FW that includes mixers, coefficients, DAPM graphs,
* algorithms, equalisers, DAIs, widgets etc.
*/
diff --git a/lib/libc/include/any-linux-any/sound/asound.h b/lib/libc/include/any-linux-any/sound/asound.h
index ffa45edb7b..308384b7b3 100644
--- a/lib/libc/include/any-linux-any/sound/asound.h
+++ b/lib/libc/include/any-linux-any/sound/asound.h
@@ -3,22 +3,6 @@
* Advanced Linux Sound Architecture - ALSA - Driver
* Copyright (c) 1994-2003 by Jaroslav Kysela <perex@perex.cz>,
* Abramo Bagnara <abramo@alsa-project.org>
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#ifndef __SOUND_ASOUND_H
@@ -54,8 +38,10 @@
* *
****************************************************************************/
+#define AES_IEC958_STATUS_SIZE 24
+
struct snd_aes_iec958 {
- unsigned char status[24]; /* AES/IEC958 channel status bits */
+ unsigned char status[AES_IEC958_STATUS_SIZE]; /* AES/IEC958 channel status bits */
unsigned char subcode[147]; /* AES/IEC958 subcode bits */
unsigned char pad; /* nothing */
unsigned char dig_subframe[4]; /* AES/IEC958 subframe bits */
@@ -200,6 +186,11 @@ typedef int __bitwise snd_pcm_format_t;
#define SNDRV_PCM_FORMAT_S24_BE ((snd_pcm_format_t) 7) /* low three bytes */
#define SNDRV_PCM_FORMAT_U24_LE ((snd_pcm_format_t) 8) /* low three bytes */
#define SNDRV_PCM_FORMAT_U24_BE ((snd_pcm_format_t) 9) /* low three bytes */
+/*
+ * For S32/U32 formats, 'msbits' hardware parameter is often used to deliver information about the
+ * available bit count in most significant bit. It's for the case of so-called 'left-justified' or
+ * `right-padding` sample which has less width than 32 bit.
+ */
#define SNDRV_PCM_FORMAT_S32_LE ((snd_pcm_format_t) 10)
#define SNDRV_PCM_FORMAT_S32_BE ((snd_pcm_format_t) 11)
#define SNDRV_PCM_FORMAT_U32_LE ((snd_pcm_format_t) 12)
@@ -298,7 +289,7 @@ typedef int __bitwise snd_pcm_subformat_t;
#define SNDRV_PCM_INFO_HAS_LINK_ESTIMATED_ATIME 0x04000000 /* report estimated link audio time */
#define SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME 0x08000000 /* report synchronized audio/system time */
#define SNDRV_PCM_INFO_EXPLICIT_SYNC 0x10000000 /* needs explicit sync of pointers and data */
-
+#define SNDRV_PCM_INFO_NO_REWINDS 0x20000000 /* hardware can only support monotonic changes of appl_ptr */
#define SNDRV_PCM_INFO_DRAIN_TRIGGER 0x40000000 /* internal kernel flag - trigger in drain */
#define SNDRV_PCM_INFO_FIFO_IN_FRAMES 0x80000000 /* internal kernel flag - FIFO size is in frames */
@@ -1085,7 +1076,7 @@ struct snd_ctl_elem_value {
struct snd_ctl_tlv {
unsigned int numid; /* control element numeric identification */
unsigned int length; /* in bytes aligned to 4 */
- unsigned int tlv[0]; /* first TLV */
+ unsigned int tlv[]; /* first TLV */
};
#define SNDRV_CTL_IOCTL_PVERSION _IOR('U', 0x00, int)
diff --git a/lib/libc/include/any-linux-any/sound/asound_fm.h b/lib/libc/include/any-linux-any/sound/asound_fm.h
index ae674964f4..deaee63bae 100644
--- a/lib/libc/include/any-linux-any/sound/asound_fm.h
+++ b/lib/libc/include/any-linux-any/sound/asound_fm.h
@@ -10,21 +10,6 @@
* 4Front Technologies
*
* Direct FM control
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#define SNDRV_DM_FM_MODE_OPL2 0x00
diff --git a/lib/libc/include/any-linux-any/sound/compress_offload.h b/lib/libc/include/any-linux-any/sound/compress_offload.h
index 1c69d60193..ad894bcb59 100644
--- a/lib/libc/include/any-linux-any/sound/compress_offload.h
+++ b/lib/libc/include/any-linux-any/sound/compress_offload.h
@@ -5,23 +5,6 @@
* Copyright (C) 2011 Intel Corporation
* Authors: Vinod Koul <vinod.koul@linux.intel.com>
* Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
*/
#ifndef __COMPRESS_OFFLOAD_H
#define __COMPRESS_OFFLOAD_H
@@ -123,7 +106,7 @@ struct snd_compr_codec_caps {
} __attribute__((packed, aligned(4)));
/**
- * enum sndrv_compress_encoder
+ * enum sndrv_compress_encoder - encoder metadata key
* @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the
* end of the track
* @SNDRV_COMPRESS_ENCODER_DELAY: no of samples inserted by the encoder at the
diff --git a/lib/libc/include/any-linux-any/sound/compress_params.h b/lib/libc/include/any-linux-any/sound/compress_params.h
index 9bae35384d..d509a4e559 100644
--- a/lib/libc/include/any-linux-any/sound/compress_params.h
+++ b/lib/libc/include/any-linux-any/sound/compress_params.h
@@ -7,47 +7,13 @@
* Authors: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
* Vinod Koul <vinod.koul@linux.intel.com>
*
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* The definitions in this file are derived from the OpenMAX AL version 1.1
- * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below.
+ * and OpenMAX IL v 1.1.2 header files which contain the copyright notice below
+ * and are licensed under the MIT license.
*
* Copyright (c) 2007-2010 The Khronos Group Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and/or associated documentation files (the
- * "Materials "), to deal in the Materials without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Materials, and to
- * permit persons to whom the Materials are furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Materials.
- *
- * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
- *
*/
#ifndef __SND_COMPRESS_PARAMS_H
#define __SND_COMPRESS_PARAMS_H
@@ -250,7 +216,7 @@ struct snd_enc_wma {
/**
- * struct snd_enc_vorbis
+ * struct snd_enc_vorbis - Vorbis encoder parameters
* @quality: Sets encoding quality to n, between -1 (low) and 10 (high).
* In the default mode of operation, the quality level is 3.
* Normal quality range is 0 - 10.
@@ -279,7 +245,7 @@ struct snd_enc_vorbis {
/**
- * struct snd_enc_real
+ * struct snd_enc_real - RealAudio encoder parameters
* @quant_bits: number of coupling quantization bits in the stream
* @start_region: coupling start region in the stream
* @num_regions: number of regions value
@@ -294,7 +260,7 @@ struct snd_enc_real {
} __attribute__((packed, aligned(4)));
/**
- * struct snd_enc_flac
+ * struct snd_enc_flac - FLAC encoder parameters
* @num: serial number, valid only for OGG formats
* needs to be set by application
* @gain: Add replay gain tags
diff --git a/lib/libc/include/any-linux-any/sound/emu10k1.h b/lib/libc/include/any-linux-any/sound/emu10k1.h
index e0cf2842d1..e501003fab 100644
--- a/lib/libc/include/any-linux-any/sound/emu10k1.h
+++ b/lib/libc/include/any-linux-any/sound/emu10k1.h
@@ -3,22 +3,6 @@
* Copyright (c) by Jaroslav Kysela <perex@perex.cz>,
* Creative Labs, Inc.
* Definitions for EMU10K1 (SB Live!) chips
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#ifndef __SOUND_EMU10K1_H
#define __SOUND_EMU10K1_H
diff --git a/lib/libc/include/any-linux-any/sound/firewire.h b/lib/libc/include/any-linux-any/sound/firewire.h
index 2324fc9af8..e6ca43848f 100644
--- a/lib/libc/include/any-linux-any/sound/firewire.h
+++ b/lib/libc/include/any-linux-any/sound/firewire.h
@@ -14,6 +14,7 @@
#define SNDRV_FIREWIRE_EVENT_MOTU_NOTIFICATION 0x64776479
#define SNDRV_FIREWIRE_EVENT_TASCAM_CONTROL 0x7473636d
#define SNDRV_FIREWIRE_EVENT_MOTU_REGISTER_DSP_CHANGE 0x4d545244
+#define SNDRV_FIREWIRE_EVENT_FF400_MESSAGE 0x4f6c6761
struct snd_firewire_event_common {
unsigned int type; /* SNDRV_FIREWIRE_EVENT_xxx */
@@ -38,11 +39,11 @@ struct snd_efw_transaction {
__be32 category;
__be32 command;
__be32 status;
- __be32 params[0];
+ __be32 params[];
};
struct snd_firewire_event_efw_response {
unsigned int type;
- __be32 response[0]; /* some responses */
+ __be32 response[]; /* some responses */
};
struct snd_firewire_event_digi00x_message {
@@ -63,7 +64,7 @@ struct snd_firewire_tascam_change {
struct snd_firewire_event_tascam_control {
unsigned int type;
- struct snd_firewire_tascam_change changes[0];
+ struct snd_firewire_tascam_change changes[];
};
struct snd_firewire_event_motu_register_dsp_change {
@@ -72,6 +73,30 @@ struct snd_firewire_event_motu_register_dsp_change {
__u32 changes[]; /* Encoded event for change of register DSP. */
};
+/**
+ * struct snd_firewire_event_ff400_message - the container for message from Fireface 400 when
+ * operating hardware knob.
+ *
+ * @type: Fixed to SNDRV_FIREWIRE_EVENT_FF400_MESSAGE.
+ * @message_count: The number of messages.
+ * @messages.message: The messages expressing hardware knob operation.
+ * @messages.tstamp: The isochronous cycle at which the request subaction of asynchronous
+ * transaction was sent to deliver the message. It has 16 bit unsigned integer
+ * value. The higher 3 bits of value expresses the lower three bits of second
+ * field in the format of CYCLE_TIME, up to 7. The rest 13 bits expresses cycle
+ * field up to 7999.
+ *
+ * The structure expresses message transmitted by Fireface 400 when operating hardware knob.
+ */
+struct snd_firewire_event_ff400_message {
+ unsigned int type;
+ unsigned int message_count;
+ struct {
+ __u32 message;
+ __u32 tstamp;
+ } messages[];
+};
+
union snd_firewire_event {
struct snd_firewire_event_common common;
struct snd_firewire_event_lock_status lock_status;
@@ -81,6 +106,7 @@ union snd_firewire_event {
struct snd_firewire_event_tascam_control tascam_control;
struct snd_firewire_event_motu_notification motu_notification;
struct snd_firewire_event_motu_register_dsp_change motu_register_dsp_change;
+ struct snd_firewire_event_ff400_message ff400_message;
};
diff --git a/lib/libc/include/any-linux-any/sound/hdsp.h b/lib/libc/include/any-linux-any/sound/hdsp.h
index d232a81263..7e71d5a9ae 100644
--- a/lib/libc/include/any-linux-any/sound/hdsp.h
+++ b/lib/libc/include/any-linux-any/sound/hdsp.h
@@ -4,20 +4,6 @@
/*
* Copyright (C) 2003 Thomas Charbonnel (thomas@undata.org)
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef __linux__
diff --git a/lib/libc/include/any-linux-any/sound/hdspm.h b/lib/libc/include/any-linux-any/sound/hdspm.h
index c976129dda..f58928cc51 100644
--- a/lib/libc/include/any-linux-any/sound/hdspm.h
+++ b/lib/libc/include/any-linux-any/sound/hdspm.h
@@ -4,21 +4,6 @@
/*
* Copyright (C) 2003 Winfried Ritsch (IEM)
* based on hdsp.h from Thomas Charbonnel (thomas@undata.org)
- *
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef __linux__
diff --git a/lib/libc/include/any-linux-any/sound/intel/avs/tokens.h b/lib/libc/include/any-linux-any/sound/intel/avs/tokens.h
new file mode 100644
index 0000000000..c6a2481491
--- /dev/null
+++ b/lib/libc/include/any-linux-any/sound/intel/avs/tokens.h
@@ -0,0 +1,130 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright(c) 2021 Intel Corporation. All rights reserved.
+ *
+ * Authors: Cezary Rojewski <cezary.rojewski@intel.com>
+ * Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
+ */
+
+#ifndef __UAPI_SOUND_INTEL_AVS_TOKENS_H
+#define __UAPI_SOUND_INTEL_AVS_TOKENS_H
+
+enum avs_tplg_token {
+ /* struct avs_tplg */
+ AVS_TKN_MANIFEST_NAME_STRING = 1,
+ AVS_TKN_MANIFEST_VERSION_U32 = 2,
+ AVS_TKN_MANIFEST_NUM_LIBRARIES_U32 = 3,
+ AVS_TKN_MANIFEST_NUM_AFMTS_U32 = 4,
+ AVS_TKN_MANIFEST_NUM_MODCFGS_BASE_U32 = 5,
+ AVS_TKN_MANIFEST_NUM_MODCFGS_EXT_U32 = 6,
+ AVS_TKN_MANIFEST_NUM_PPLCFGS_U32 = 7,
+ AVS_TKN_MANIFEST_NUM_BINDINGS_U32 = 8,
+
+ /* struct avs_tplg_library */
+ AVS_TKN_LIBRARY_ID_U32 = 101,
+ AVS_TKN_LIBRARY_NAME_STRING = 102,
+
+ /* struct avs_audio_format */
+ AVS_TKN_AFMT_ID_U32 = 201,
+ AVS_TKN_AFMT_SAMPLE_RATE_U32 = 202,
+ AVS_TKN_AFMT_BIT_DEPTH_U32 = 203,
+ AVS_TKN_AFMT_CHANNEL_MAP_U32 = 204,
+ AVS_TKN_AFMT_CHANNEL_CFG_U32 = 205,
+ AVS_TKN_AFMT_INTERLEAVING_U32 = 206,
+ AVS_TKN_AFMT_NUM_CHANNELS_U32 = 207,
+ AVS_TKN_AFMT_VALID_BIT_DEPTH_U32 = 208,
+ AVS_TKN_AFMT_SAMPLE_TYPE_U32 = 209,
+
+ /* struct avs_tplg_modcfg_base */
+ AVS_TKN_MODCFG_BASE_ID_U32 = 301,
+ AVS_TKN_MODCFG_BASE_CPC_U32 = 302,
+ AVS_TKN_MODCFG_BASE_IBS_U32 = 303,
+ AVS_TKN_MODCFG_BASE_OBS_U32 = 304,
+ AVS_TKN_MODCFG_BASE_PAGES_U32 = 305,
+
+ /* struct avs_tplg_modcfg_ext */
+ AVS_TKN_MODCFG_EXT_ID_U32 = 401,
+ AVS_TKN_MODCFG_EXT_TYPE_UUID = 402,
+ AVS_TKN_MODCFG_CPR_OUT_AFMT_ID_U32 = 403,
+ AVS_TKN_MODCFG_CPR_FEATURE_MASK_U32 = 404,
+ AVS_TKN_MODCFG_CPR_DMA_TYPE_U32 = 405,
+ AVS_TKN_MODCFG_CPR_DMABUFF_SIZE_U32 = 406,
+ AVS_TKN_MODCFG_CPR_VINDEX_U8 = 407,
+ AVS_TKN_MODCFG_CPR_BLOB_FMT_ID_U32 = 408,
+ AVS_TKN_MODCFG_MICSEL_OUT_AFMT_ID_U32 = 409,
+ AVS_TKN_MODCFG_INTELWOV_CPC_LP_MODE_U32 = 410,
+ AVS_TKN_MODCFG_SRC_OUT_FREQ_U32 = 411,
+ AVS_TKN_MODCFG_MUX_REF_AFMT_ID_U32 = 412,
+ AVS_TKN_MODCFG_MUX_OUT_AFMT_ID_U32 = 413,
+ AVS_TKN_MODCFG_AEC_REF_AFMT_ID_U32 = 414,
+ AVS_TKN_MODCFG_AEC_OUT_AFMT_ID_U32 = 415,
+ AVS_TKN_MODCFG_AEC_CPC_LP_MODE_U32 = 416,
+ AVS_TKN_MODCFG_ASRC_OUT_FREQ_U32 = 417,
+ AVS_TKN_MODCFG_ASRC_MODE_U8 = 418,
+ AVS_TKN_MODCFG_ASRC_DISABLE_JITTER_U8 = 419,
+ AVS_TKN_MODCFG_UPDOWN_MIX_OUT_CHAN_CFG_U32 = 420,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_SELECT_U32 = 421,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_0_S32 = 422,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_1_S32 = 423,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_2_S32 = 424,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_3_S32 = 425,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_4_S32 = 426,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_5_S32 = 427,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_6_S32 = 428,
+ AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_7_S32 = 429,
+ AVS_TKN_MODCFG_UPDOWN_MIX_CHAN_MAP_U32 = 430,
+ AVS_TKN_MODCFG_EXT_NUM_INPUT_PINS_U16 = 431,
+ AVS_TKN_MODCFG_EXT_NUM_OUTPUT_PINS_U16 = 432,
+
+ /* struct avs_tplg_pplcfg */
+ AVS_TKN_PPLCFG_ID_U32 = 1401,
+ AVS_TKN_PPLCFG_REQ_SIZE_U16 = 1402,
+ AVS_TKN_PPLCFG_PRIORITY_U8 = 1403,
+ AVS_TKN_PPLCFG_LOW_POWER_BOOL = 1404,
+ AVS_TKN_PPLCFG_ATTRIBUTES_U16 = 1405,
+ AVS_TKN_PPLCFG_TRIGGER_U32 = 1406,
+
+ /* struct avs_tplg_binding */
+ AVS_TKN_BINDING_ID_U32 = 1501,
+ AVS_TKN_BINDING_TARGET_TPLG_NAME_STRING = 1502,
+ AVS_TKN_BINDING_TARGET_PATH_TMPL_ID_U32 = 1503,
+ AVS_TKN_BINDING_TARGET_PPL_ID_U32 = 1504,
+ AVS_TKN_BINDING_TARGET_MOD_ID_U32 = 1505,
+ AVS_TKN_BINDING_TARGET_MOD_PIN_U8 = 1506,
+ AVS_TKN_BINDING_MOD_ID_U32 = 1507,
+ AVS_TKN_BINDING_MOD_PIN_U8 = 1508,
+ AVS_TKN_BINDING_IS_SINK_U8 = 1509,
+
+ /* struct avs_tplg_pipeline */
+ AVS_TKN_PPL_ID_U32 = 1601,
+ AVS_TKN_PPL_PPLCFG_ID_U32 = 1602,
+ AVS_TKN_PPL_NUM_BINDING_IDS_U32 = 1603,
+ AVS_TKN_PPL_BINDING_ID_U32 = 1604,
+
+ /* struct avs_tplg_module */
+ AVS_TKN_MOD_ID_U32 = 1701,
+ AVS_TKN_MOD_MODCFG_BASE_ID_U32 = 1702,
+ AVS_TKN_MOD_IN_AFMT_ID_U32 = 1703,
+ AVS_TKN_MOD_CORE_ID_U8 = 1704,
+ AVS_TKN_MOD_PROC_DOMAIN_U8 = 1705,
+ AVS_TKN_MOD_MODCFG_EXT_ID_U32 = 1706,
+ AVS_TKN_MOD_KCONTROL_ID_U32 = 1707,
+
+ /* struct avs_tplg_path_template */
+ AVS_TKN_PATH_TMPL_ID_U32 = 1801,
+
+ /* struct avs_tplg_path */
+ AVS_TKN_PATH_ID_U32 = 1901,
+ AVS_TKN_PATH_FE_FMT_ID_U32 = 1902,
+ AVS_TKN_PATH_BE_FMT_ID_U32 = 1903,
+
+ /* struct avs_tplg_pin_format */
+ AVS_TKN_PIN_FMT_INDEX_U32 = 2201,
+ AVS_TKN_PIN_FMT_IOBS_U32 = 2202,
+ AVS_TKN_PIN_FMT_AFMT_ID_U32 = 2203,
+
+ /* struct avs_tplg_kcontrol */
+ AVS_TKN_KCONTROL_ID_U32 = 2301,
+};
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/sound/sb16_csp.h b/lib/libc/include/any-linux-any/sound/sb16_csp.h
index decb60dc30..1d2d154ead 100644
--- a/lib/libc/include/any-linux-any/sound/sb16_csp.h
+++ b/lib/libc/include/any-linux-any/sound/sb16_csp.h
@@ -4,21 +4,6 @@
* Takashi Iwai <tiwai@suse.de>
*
* SB16ASP/AWE32 CSP control
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#ifndef __SOUND_SB16_CSP_H
#define __SOUND_SB16_CSP_H
diff --git a/lib/libc/include/any-linux-any/sound/sfnt_info.h b/lib/libc/include/any-linux-any/sound/sfnt_info.h
index f2b26ceb83..62979a92c6 100644
--- a/lib/libc/include/any-linux-any/sound/sfnt_info.h
+++ b/lib/libc/include/any-linux-any/sound/sfnt_info.h
@@ -6,21 +6,6 @@
* Patch record compatible with AWE driver on OSS
*
* Copyright (C) 1999-2000 Takashi Iwai
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
*/
#include <sound/asound.h>
diff --git a/lib/libc/include/any-linux-any/sound/skl-tplg-interface.h b/lib/libc/include/any-linux-any/sound/skl-tplg-interface.h
index d728bc110d..fe3afac2d0 100644
--- a/lib/libc/include/any-linux-any/sound/skl-tplg-interface.h
+++ b/lib/libc/include/any-linux-any/sound/skl-tplg-interface.h
@@ -66,7 +66,8 @@ enum skl_ch_cfg {
SKL_CH_CFG_DUAL_MONO = 9,
SKL_CH_CFG_I2S_DUAL_STEREO_0 = 10,
SKL_CH_CFG_I2S_DUAL_STEREO_1 = 11,
- SKL_CH_CFG_4_CHANNEL = 12,
+ SKL_CH_CFG_7_1 = 12,
+ SKL_CH_CFG_4_CHANNEL = SKL_CH_CFG_7_1,
SKL_CH_CFG_INVALID
};
@@ -151,7 +152,7 @@ struct skl_dfw_algo_data {
__u32 rsvd:30;
__u32 param_id;
__u32 max;
- char params[0];
+ char params[];
} __attribute__((packed));
enum skl_tkn_dir {
diff --git a/lib/libc/include/any-linux-any/sound/snd_ar_tokens.h b/lib/libc/include/any-linux-any/sound/snd_ar_tokens.h
index 5fa88e5ce1..8075cd1342 100644
--- a/lib/libc/include/any-linux-any/sound/snd_ar_tokens.h
+++ b/lib/libc/include/any-linux-any/sound/snd_ar_tokens.h
@@ -191,6 +191,33 @@ enum ar_event_types {
#define AR_TKN_U32_MODULE_SRC_INSTANCE_ID 208
#define AR_TKN_U32_MODULE_DST_INSTANCE_ID 209
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID1 210
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID1 211
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID1 212
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID2 213
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID2 214
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID2 215
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID3 216
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID3 217
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID3 218
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID4 219
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID4 220
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID4 221
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID5 222
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID5 223
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID5 224
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID6 225
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID6 226
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID6 227
+
+#define AR_TKN_U32_MODULE_SRC_OP_PORT_ID7 228
+#define AR_TKN_U32_MODULE_DST_IN_PORT_ID7 229
+#define AR_TKN_U32_MODULE_DST_INSTANCE_ID7 230
#define AR_TKN_U32_MODULE_HW_IF_IDX 250
#define AR_TKN_U32_MODULE_HW_IF_TYPE 251
diff --git a/lib/libc/include/any-linux-any/sound/snd_sst_tokens.h b/lib/libc/include/any-linux-any/sound/snd_sst_tokens.h
index 72ef4d6876..146ab14fe4 100644
--- a/lib/libc/include/any-linux-any/sound/snd_sst_tokens.h
+++ b/lib/libc/include/any-linux-any/sound/snd_sst_tokens.h
@@ -4,16 +4,6 @@
*
* Copyright (C) 2016 Intel Corp
* Author: Shreyas NC <shreyas.nc@intel.com>
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as version 2, as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
*/
#ifndef __SND_SST_TOKENS_H__
#define __SND_SST_TOKENS_H__
diff --git a/lib/libc/include/any-linux-any/sound/sof/abi.h b/lib/libc/include/any-linux-any/sound/sof/abi.h
index da376016e7..5d241e9135 100644
--- a/lib/libc/include/any-linux-any/sound/sof/abi.h
+++ b/lib/libc/include/any-linux-any/sound/sof/abi.h
@@ -24,9 +24,11 @@
#ifndef __INCLUDE_UAPI_SOUND_SOF_ABI_H__
#define __INCLUDE_UAPI_SOUND_SOF_ABI_H__
+#include <linux/types.h>
+
/* SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
-#define SOF_ABI_MINOR 18
+#define SOF_ABI_MINOR 23
#define SOF_ABI_PATCH 0
/* SOF ABI version number. Format within 32bit word is MMmmmppp */
diff --git a/lib/libc/include/any-linux-any/sound/sof/header.h b/lib/libc/include/any-linux-any/sound/sof/header.h
index 0542915962..9c54ccd30a 100644
--- a/lib/libc/include/any-linux-any/sound/sof/header.h
+++ b/lib/libc/include/any-linux-any/sound/sof/header.h
@@ -23,7 +23,37 @@ struct sof_abi_hdr {
__u32 size; /**< size in bytes of data excl. this struct */
__u32 abi; /**< SOF ABI version */
__u32 reserved[4]; /**< reserved for future use */
- __u32 data[0]; /**< Component data - opaque to core */
+ __u32 data[]; /**< Component data - opaque to core */
} __attribute__((packed));
+#define SOF_MANIFEST_DATA_TYPE_NHLT 1
+
+/**
+ * struct sof_manifest_tlv - SOF manifest TLV data
+ * @type: type of data
+ * @size: data size (not including the size of this struct)
+ * @data: payload data
+ */
+struct sof_manifest_tlv {
+ __le32 type;
+ __le32 size;
+ __u8 data[];
+};
+
+/**
+ * struct sof_manifest - SOF topology manifest
+ * @abi_major: Major ABI version
+ * @abi_minor: Minor ABI version
+ * @abi_patch: ABI patch
+ * @count: count of tlv items
+ * @items: consecutive variable size tlv items
+ */
+struct sof_manifest {
+ __le16 abi_major;
+ __le16 abi_minor;
+ __le16 abi_patch;
+ __le16 count;
+ struct sof_manifest_tlv items[];
+};
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/sound/sof/tokens.h b/lib/libc/include/any-linux-any/sound/sof/tokens.h
index 3945633a0a..220da87550 100644
--- a/lib/libc/include/any-linux-any/sound/sof/tokens.h
+++ b/lib/libc/include/any-linux-any/sound/sof/tokens.h
@@ -52,11 +52,17 @@
#define SOF_TKN_SCHED_FRAMES 204
#define SOF_TKN_SCHED_TIME_DOMAIN 205
#define SOF_TKN_SCHED_DYNAMIC_PIPELINE 206
+#define SOF_TKN_SCHED_LP_MODE 207
+#define SOF_TKN_SCHED_MEM_USAGE 208
/* volume */
#define SOF_TKN_VOLUME_RAMP_STEP_TYPE 250
#define SOF_TKN_VOLUME_RAMP_STEP_MS 251
+#define SOF_TKN_GAIN_RAMP_TYPE 260
+#define SOF_TKN_GAIN_RAMP_DURATION 261
+#define SOF_TKN_GAIN_VAL 262
+
/* SRC */
#define SOF_TKN_SRC_RATE_IN 300
#define SOF_TKN_SRC_RATE_OUT 301
@@ -79,6 +85,18 @@
*/
#define SOF_TKN_COMP_CORE_ID 404
#define SOF_TKN_COMP_UUID 405
+#define SOF_TKN_COMP_CPC 406
+#define SOF_TKN_COMP_IS_PAGES 409
+#define SOF_TKN_COMP_NUM_AUDIO_FORMATS 410
+#define SOF_TKN_COMP_NUM_SINK_PINS 411
+#define SOF_TKN_COMP_NUM_SOURCE_PINS 412
+/*
+ * The token for sink/source pin binding, it specifies the widget
+ * name that the sink/source pin is connected from/to.
+ */
+#define SOF_TKN_COMP_SINK_PIN_BINDING_WNAME 413
+#define SOF_TKN_COMP_SRC_PIN_BINDING_WNAME 414
+
/* SSP */
#define SOF_TKN_INTEL_SSP_CLKS_CONTROL 500
@@ -140,4 +158,49 @@
#define SOF_TKN_INTEL_HDA_RATE 1500
#define SOF_TKN_INTEL_HDA_CH 1501
+/* AFE */
+#define SOF_TKN_MEDIATEK_AFE_RATE 1600
+#define SOF_TKN_MEDIATEK_AFE_CH 1601
+#define SOF_TKN_MEDIATEK_AFE_FORMAT 1602
+
+/* MIXER */
+#define SOF_TKN_MIXER_TYPE 1700
+
+/* ACPDMIC */
+#define SOF_TKN_AMD_ACPDMIC_RATE 1800
+#define SOF_TKN_AMD_ACPDMIC_CH 1801
+
+/* CAVS AUDIO FORMAT */
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_RATE 1900
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_BIT_DEPTH 1901
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_VALID_BIT 1902
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_CHANNELS 1903
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_CH_MAP 1904
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_CH_CFG 1905
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_INTERLEAVING_STYLE 1906
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_FMT_CFG 1907
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IN_SAMPLE_TYPE 1908
+/* intentional token numbering discontinuity, reserved for future use */
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_RATE 1930
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_BIT_DEPTH 1931
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_VALID_BIT 1932
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_CHANNELS 1933
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_CH_MAP 1934
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_CH_CFG 1935
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_INTERLEAVING_STYLE 1936
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_FMT_CFG 1937
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OUT_SAMPLE_TYPE 1938
+/* intentional token numbering discontinuity, reserved for future use */
+#define SOF_TKN_CAVS_AUDIO_FORMAT_IBS 1970
+#define SOF_TKN_CAVS_AUDIO_FORMAT_OBS 1971
+#define SOF_TKN_CAVS_AUDIO_FORMAT_DMA_BUFFER_SIZE 1972
+
+/* COPIER */
+#define SOF_TKN_INTEL_COPIER_NODE_TYPE 1980
+
+/* ACP I2S */
+#define SOF_TKN_AMD_ACPI2S_RATE 1700
+#define SOF_TKN_AMD_ACPI2S_CH 1701
+#define SOF_TKN_AMD_ACPI2S_TDM_MODE 1702
+
#endif \ No newline at end of file
diff --git a/lib/libc/include/any-linux-any/sound/tlv.h b/lib/libc/include/any-linux-any/sound/tlv.h
index af766e90d7..249c256830 100644
--- a/lib/libc/include/any-linux-any/sound/tlv.h
+++ b/lib/libc/include/any-linux-any/sound/tlv.h
@@ -1,15 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
#ifndef __UAPI_SOUND_TLV_H
#define __UAPI_SOUND_TLV_H
diff --git a/lib/libc/include/any-linux-any/sound/usb_stream.h b/lib/libc/include/any-linux-any/sound/usb_stream.h
index f5907a6e02..36743eb44e 100644
--- a/lib/libc/include/any-linux-any/sound/usb_stream.h
+++ b/lib/libc/include/any-linux-any/sound/usb_stream.h
@@ -1,20 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
/*
* Copyright (C) 2007, 2008 Karsten Wiese <fzu@wemgehoertderstaat.de>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SOUND_USB_STREAM_H
@@ -61,7 +47,7 @@ struct usb_stream {
unsigned inpacket_split_at;
unsigned next_inpacket_split;
unsigned next_inpacket_split_at;
- struct usb_stream_packet inpacket[0];
+ struct usb_stream_packet inpacket[];
};
enum usb_stream_state {
diff --git a/lib/libc/include/any-linux-any/xen/gntdev.h b/lib/libc/include/any-linux-any/xen/gntdev.h
index e1473b6ab3..553287bb64 100644
--- a/lib/libc/include/any-linux-any/xen/gntdev.h
+++ b/lib/libc/include/any-linux-any/xen/gntdev.h
@@ -47,7 +47,13 @@ struct ioctl_gntdev_grant_ref {
/*
* Inserts the grant references into the mapping table of an instance
* of gntdev. N.B. This does not perform the mapping, which is deferred
- * until mmap() is called with @index as the offset.
+ * until mmap() is called with @index as the offset. @index should be
+ * considered opaque to userspace, with one exception: if no grant
+ * references have ever been inserted into the mapping table of this
+ * instance, @index will be set to 0. This is necessary to use gntdev
+ * with userspace APIs that expect a file descriptor that can be
+ * mmap()'d at offset 0, such as Wayland. If @count is set to 0, this
+ * ioctl will fail.
*/
#define IOCTL_GNTDEV_MAP_GRANT_REF \
_IOC(_IOC_NONE, 'G', 0, sizeof(struct ioctl_gntdev_map_grant_ref))
diff --git a/lib/libc/include/any-macos-any/netinet/in_systm.h b/lib/libc/include/any-macos-any/netinet/in_systm.h
new file mode 100644
index 0000000000..49e8e45e0c
--- /dev/null
+++ b/lib/libc/include/any-macos-any/netinet/in_systm.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2000-2018 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)in_systm.h 8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/in_systm.h,v 1.9 1999/12/29 04:41:00 peter Exp $
+ */
+
+#ifndef _NETINET_IN_SYSTM_H_
+#define _NETINET_IN_SYSTM_H_
+
+#include <sys/appleapiopts.h>
+
+#include <sys/_types.h>
+
+/*
+ * Miscellaneous internetwork
+ * definitions for kernel.
+ */
+
+/*
+ * Network types.
+ *
+ * Internally the system keeps counters in the headers with the bytes
+ * swapped so that VAX instructions will work on them. It reverses
+ * the bytes before transmission at each protocol level. The n_ types
+ * represent the types with the bytes in ``high-ender'' order.
+ */
+typedef __uint16_t n_short; /* short as received from the net */
+typedef __uint32_t n_long; /* long as received from the net */
+
+typedef __uint32_t n_time; /* ms since 00:00 GMT, byte rev */
+
+#endif /* _NETINET_IN_SYSTM_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-macos-any/netinet/ip.h b/lib/libc/include/any-macos-any/netinet/ip.h
new file mode 100644
index 0000000000..b4dfff5258
--- /dev/null
+++ b/lib/libc/include/any-macos-any/netinet/ip.h
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2000-2016 Apple Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.2 (Berkeley) 6/1/94
+ * $FreeBSD: src/sys/netinet/ip.h,v 1.17 1999/12/22 19:13:20 shin Exp $
+ */
+
+#ifndef _NETINET_IP_H_
+#define _NETINET_IP_H_
+#include <sys/appleapiopts.h>
+#include <sys/types.h> /* XXX temporary hack to get u_ types */
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+#define IPVERSION 4
+
+/*
+ * Structure of an internet header, naked of options.
+ */
+struct ip {
+#ifdef _IP_VHL
+ u_char ip_vhl; /* version << 4 | header length >> 2 */
+#else
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ip_hl:4, /* header length */
+ ip_v:4; /* version */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ip_v:4, /* version */
+ ip_hl:4; /* header length */
+#endif
+#endif /* not _IP_VHL */
+ u_char ip_tos; /* type of service */
+ u_short ip_len; /* total length */
+ u_short ip_id; /* identification */
+ u_short ip_off; /* fragment offset field */
+#define IP_RF 0x8000 /* reserved fragment flag */
+#define IP_DF 0x4000 /* dont fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
+ u_char ip_ttl; /* time to live */
+ u_char ip_p; /* protocol */
+ u_short ip_sum; /* checksum */
+ struct in_addr ip_src, ip_dst; /* source and dest address */
+};
+
+#ifdef _IP_VHL
+#define IP_MAKE_VHL(v, hl) ((uint8_t)((v) << 4 | (hl)))
+#define IP_VHL_HL(vhl) ((vhl) & 0x0f)
+#define IP_VHL_V(vhl) ((vhl) >> 4)
+#define IP_VHL_BORING 0x45
+#endif
+
+#define IP_MAXPACKET 65535 /* maximum packet size */
+
+/*
+ * Definitions for IP type of service (ip_tos)
+ */
+#define IPTOS_LOWDELAY 0x10
+#define IPTOS_THROUGHPUT 0x08
+#define IPTOS_RELIABILITY 0x04
+#define IPTOS_MINCOST 0x02
+#if 1
+/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */
+#define IPTOS_CE 0x01
+#define IPTOS_ECT 0x02
+#endif
+
+#define IPTOS_DSCP_SHIFT 2
+
+/*
+ * ECN (Explicit Congestion Notification) codepoints in RFC3168
+ * mapped to the lower 2 bits of the TOS field.
+ */
+#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */
+#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */
+#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */
+#define IPTOS_ECN_CE 0x03 /* congestion experienced */
+#define IPTOS_ECN_MASK 0x03 /* ECN field mask */
+
+/*
+ * Definitions for IP precedence (also in ip_tos) (hopefully unused)
+ */
+#define IPTOS_PREC_NETCONTROL 0xe0
+#define IPTOS_PREC_INTERNETCONTROL 0xc0
+#define IPTOS_PREC_CRITIC_ECP 0xa0
+#define IPTOS_PREC_FLASHOVERRIDE 0x80
+#define IPTOS_PREC_FLASH 0x60
+#define IPTOS_PREC_IMMEDIATE 0x40
+#define IPTOS_PREC_PRIORITY 0x20
+#define IPTOS_PREC_ROUTINE 0x00
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPIED(o) ((o)&0x80)
+#define IPOPT_CLASS(o) ((o)&0x60)
+#define IPOPT_NUMBER(o) ((o)&0x1f)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_NOP 1 /* no operation */
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SSRR 137 /* strict source route */
+#define IPOPT_RA 148 /* router alert */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp {
+ u_char ipt_code; /* IPOPT_TS */
+ u_char ipt_len; /* size of structure (variable) */
+ u_char ipt_ptr; /* index of current entry */
+#if BYTE_ORDER == LITTLE_ENDIAN
+ u_int ipt_flg:4, /* flags, see below */
+ ipt_oflw:4; /* overflow counter */
+#endif
+#if BYTE_ORDER == BIG_ENDIAN
+ u_int ipt_oflw:4, /* overflow counter */
+ ipt_flg:4; /* flags, see below */
+#endif
+ union ipt_timestamp {
+ n_long ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ n_long ipt_time;
+ } ipt_ta[1];
+ } ipt_timestamp;
+};
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 3 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
+#define IPFRAGTTL 30 /* time to live for frags (seconds) */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/any-macos-any/netinet/udp.h b/lib/libc/include/any-macos-any/netinet/udp.h
new file mode 100644
index 0000000000..177bff51f9
--- /dev/null
+++ b/lib/libc/include/any-macos-any/netinet/udp.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)udp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_UDP_H_
+#define _NETINET_UDP_H_
+
+#include <sys/appleapiopts.h>
+#include <sys/types.h> /* u_short */
+
+/*
+ * Udp protocol header.
+ * Per RFC 768, September, 1981.
+ */
+struct udphdr {
+ u_short uh_sport; /* source port */
+ u_short uh_dport; /* destination port */
+ u_short uh_ulen; /* udp length */
+ u_short uh_sum; /* udp checksum */
+};
+
+/*
+ * User-settable options (used with setsockopt).
+ */
+#define UDP_NOCKSUM 0x01 /* don't checksum outbound payloads */
+
+#endif /* _NETINET_UDP_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-macos-any/sys/paths.h b/lib/libc/include/any-macos-any/sys/paths.h
new file mode 100644
index 0000000000..9ba98b6aa8
--- /dev/null
+++ b/lib/libc/include/any-macos-any/sys/paths.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+/* @(#)paths.h 1.0 11/13/00 */
+
+#ifndef _SYS_PATHS_H_
+#define _SYS_PATHS_H_
+
+#include <sys/appleapiopts.h>
+
+#ifdef __APPLE_API_PRIVATE
+
+/* Provides support for system wide forks */
+#define _PATH_FORKSPECIFIER "/..namedfork/"
+#define _PATH_DATANAME "data"
+#define _PATH_RSRCNAME "rsrc"
+#define _PATH_RSRCFORKSPEC "/..namedfork/rsrc"
+
+#endif /* __APPLE_API_PRIVATE */
+#endif /* !_SYS_PATHS_H_ */ \ No newline at end of file
diff --git a/lib/libc/include/any-macos-any/zconf.h b/lib/libc/include/any-macos-any/zconf.h
new file mode 100644
index 0000000000..57a7090f9c
--- /dev/null
+++ b/lib/libc/include/any-macos-any/zconf.h
@@ -0,0 +1,523 @@
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZCONF_H
+#define ZCONF_H
+
+/*
+ * If you *really* need a unique prefix for all types and library functions,
+ * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
+ */
+#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
+# define Z_PREFIX_SET
+
+/* all linked symbols and init macros */
+# define _dist_code z__dist_code
+# define _length_code z__length_code
+# define _tr_align z__tr_align
+# define _tr_flush_bits z__tr_flush_bits
+# define _tr_flush_block z__tr_flush_block
+# define _tr_init z__tr_init
+# define _tr_stored_block z__tr_stored_block
+# define _tr_tally z__tr_tally
+# define adler32 z_adler32
+# define adler32_combine z_adler32_combine
+# define adler32_combine64 z_adler32_combine64
+# define adler32_z z_adler32_z
+# ifndef Z_SOLO
+# define compress z_compress
+# define compress2 z_compress2
+# define compressBound z_compressBound
+# endif
+# define crc32 z_crc32
+# define crc32_combine z_crc32_combine
+# define crc32_combine64 z_crc32_combine64
+# define crc32_z z_crc32_z
+# define deflate z_deflate
+# define deflateBound z_deflateBound
+# define deflateCopy z_deflateCopy
+# define deflateEnd z_deflateEnd
+# define deflateGetDictionary z_deflateGetDictionary
+# define deflateInit z_deflateInit
+# define deflateInit2 z_deflateInit2
+# define deflateInit2_ z_deflateInit2_
+# define deflateInit_ z_deflateInit_
+# define deflateParams z_deflateParams
+# define deflatePending z_deflatePending
+# define deflatePrime z_deflatePrime
+# define deflateReset z_deflateReset
+# define deflateResetKeep z_deflateResetKeep
+# define deflateSetDictionary z_deflateSetDictionary
+# define deflateSetHeader z_deflateSetHeader
+# define deflateTune z_deflateTune
+# define deflate_copyright z_deflate_copyright
+# define get_crc_table z_get_crc_table
+# ifndef Z_SOLO
+# define gz_error z_gz_error
+# define gz_intmax z_gz_intmax
+# define gz_strwinerror z_gz_strwinerror
+# define gzbuffer z_gzbuffer
+# define gzclearerr z_gzclearerr
+# define gzclose z_gzclose
+# define gzclose_r z_gzclose_r
+# define gzclose_w z_gzclose_w
+# define gzdirect z_gzdirect
+# define gzdopen z_gzdopen
+# define gzeof z_gzeof
+# define gzerror z_gzerror
+# define gzflush z_gzflush
+# define gzfread z_gzfread
+# define gzfwrite z_gzfwrite
+# define gzgetc z_gzgetc
+# define gzgetc_ z_gzgetc_
+# define gzgets z_gzgets
+# define gzoffset z_gzoffset
+# define gzoffset64 z_gzoffset64
+# define gzopen z_gzopen
+# define gzopen64 z_gzopen64
+# ifdef _WIN32
+# define gzopen_w z_gzopen_w
+# endif
+# define gzprintf z_gzprintf
+# define gzputc z_gzputc
+# define gzputs z_gzputs
+# define gzread z_gzread
+# define gzrewind z_gzrewind
+# define gzseek z_gzseek
+# define gzseek64 z_gzseek64
+# define gzsetparams z_gzsetparams
+# define gztell z_gztell
+# define gztell64 z_gztell64
+# define gzungetc z_gzungetc
+# define gzvprintf z_gzvprintf
+# define gzwrite z_gzwrite
+# endif
+# define inflate z_inflate
+# define inflateBack z_inflateBack
+# define inflateBackEnd z_inflateBackEnd
+# define inflateBackInit z_inflateBackInit
+# define inflateBackInit_ z_inflateBackInit_
+# define inflateCodesUsed z_inflateCodesUsed
+# define inflateCopy z_inflateCopy
+# define inflateEnd z_inflateEnd
+# define inflateGetDictionary z_inflateGetDictionary
+# define inflateGetHeader z_inflateGetHeader
+# define inflateInit z_inflateInit
+# define inflateInit2 z_inflateInit2
+# define inflateInit2_ z_inflateInit2_
+# define inflateInit_ z_inflateInit_
+# define inflateMark z_inflateMark
+# define inflatePrime z_inflatePrime
+# define inflateReset z_inflateReset
+# define inflateReset2 z_inflateReset2
+# define inflateResetKeep z_inflateResetKeep
+# define inflateSetDictionary z_inflateSetDictionary
+# define inflateSync z_inflateSync
+# define inflateSyncPoint z_inflateSyncPoint
+# define inflateUndermine z_inflateUndermine
+# define inflateValidate z_inflateValidate
+# define inflate_copyright z_inflate_copyright
+# define inflate_fast z_inflate_fast
+# define inflate_table z_inflate_table
+# ifndef Z_SOLO
+# define uncompress z_uncompress
+# define uncompress2 z_uncompress2
+# endif
+# define zError z_zError
+# ifndef Z_SOLO
+# define zcalloc z_zcalloc
+# define zcfree z_zcfree
+# endif
+# define zlibCompileFlags z_zlibCompileFlags
+# define zlibVersion z_zlibVersion
+
+/* all zlib typedefs in zlib.h and zconf.h */
+# define Byte z_Byte
+# define Bytef z_Bytef
+# define alloc_func z_alloc_func
+# define charf z_charf
+# define free_func z_free_func
+# ifndef Z_SOLO
+# define gzFile z_gzFile
+# endif
+# define gz_header z_gz_header
+# define gz_headerp z_gz_headerp
+# define in_func z_in_func
+# define intf z_intf
+# define out_func z_out_func
+# define uInt z_uInt
+# define uIntf z_uIntf
+# define uLong z_uLong
+# define uLongf z_uLongf
+# define voidp z_voidp
+# define voidpc z_voidpc
+# define voidpf z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+# define gz_header_s z_gz_header_s
+# define internal_state z_internal_state
+
+#endif
+
+#if defined(__MSDOS__) && !defined(MSDOS)
+# define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+# define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+# define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+# ifndef SYS16BIT
+# define SYS16BIT
+# endif
+# endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+# define MAXSEG_64K
+#endif
+#ifdef MSDOS
+# define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+# ifndef STDC
+# define STDC
+# endif
+# if __STDC_VERSION__ >= 199901L
+# ifndef STDC99
+# define STDC99
+# endif
+# endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+# define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
+# define STDC
+#endif
+
+#ifndef STDC
+# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+# define const /* note: need a more gentle solution here */
+# endif
+#endif
+
+#if defined(ZLIB_CONST) && !defined(z_const)
+# define z_const const
+#else
+# define z_const
+#endif
+
+#ifdef Z_SOLO
+ typedef unsigned long z_size_t;
+#else
+# define z_longlong long long
+# if defined(NO_SIZE_T)
+ typedef unsigned NO_SIZE_T z_size_t;
+# elif defined(STDC)
+# include <stddef.h>
+ typedef size_t z_size_t;
+# else
+ typedef unsigned long z_size_t;
+# endif
+# undef z_longlong
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+# ifdef MAXSEG_64K
+# define MAX_MEM_LEVEL 8
+# else
+# define MAX_MEM_LEVEL 9
+# endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+# define MAX_WBITS 15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+ (1 << (windowBits+2)) + (1 << (memLevel+9))
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
+ for small objects.
+*/
+
+ /* Type declarations */
+
+#ifndef OF /* function prototypes */
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
+#ifndef Z_ARG /* function prototypes for stdarg */
+# if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# define Z_ARG(args) args
+# else
+# define Z_ARG(args) ()
+# endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+# if defined(M_I86SM) || defined(M_I86MM)
+ /* MSC small or medium model */
+# define SMALL_MEDIUM
+# ifdef _MSC_VER
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+# if (defined(__SMALL__) || defined(__MEDIUM__))
+ /* Turbo C small or medium model */
+# define SMALL_MEDIUM
+# ifdef __BORLANDC__
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+ /* If building or using zlib as a DLL, define ZLIB_DLL.
+ * This is not mandatory, but it offers a little performance increase.
+ */
+# ifdef ZLIB_DLL
+# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+# ifdef ZLIB_INTERNAL
+# define ZEXTERN extern __declspec(dllexport)
+# else
+# define ZEXTERN extern __declspec(dllimport)
+# endif
+# endif
+# endif /* ZLIB_DLL */
+ /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+ * define ZLIB_WINAPI.
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+ */
+# ifdef ZLIB_WINAPI
+# ifdef FAR
+# undef FAR
+# endif
+# include <windows.h>
+ /* No need for _export, use ZLIB.DEF instead. */
+ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+# define ZEXPORT WINAPI
+# ifdef WIN32
+# define ZEXPORTVA WINAPIV
+# else
+# define ZEXPORTVA FAR CDECL
+# endif
+# endif
+#endif
+
+#if defined (__BEOS__)
+# ifdef ZLIB_DLL
+# ifdef ZLIB_INTERNAL
+# define ZEXPORT __declspec(dllexport)
+# define ZEXPORTVA __declspec(dllexport)
+# else
+# define ZEXPORT __declspec(dllimport)
+# define ZEXPORTVA __declspec(dllimport)
+# endif
+# endif
+#endif
+
+#ifndef ZEXTERN
+# define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+# define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+# define ZEXPORTVA
+#endif
+
+#ifndef FAR
+# define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+typedef unsigned char Byte; /* 8 bits */
+#endif
+typedef unsigned int uInt; /* 16 bits or more */
+typedef unsigned long uLong; /* 32 bits or more */
+
+#ifdef SMALL_MEDIUM
+ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
+# define Bytef Byte FAR
+#else
+ typedef Byte FAR Bytef;
+#endif
+typedef char FAR charf;
+typedef int FAR intf;
+typedef uInt FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+ typedef void const *voidpc;
+ typedef void FAR *voidpf;
+ typedef void *voidp;
+#else
+ typedef Byte const *voidpc;
+ typedef Byte FAR *voidpf;
+ typedef Byte *voidp;
+#endif
+
+typedef unsigned long z_crc_t;
+
+#if defined(__APPLE__) /* avoid unistd.h on Win32 */
+#if 1 /* was set to #if 1 by ./configure */
+# define Z_HAVE_UNISTD_H
+#endif
+#endif /* defined(__APPLE__) */
+
+#if 1 /* was set to #if 1 by ./configure */
+# define Z_HAVE_STDARG_H
+#endif
+
+#ifdef STDC
+# ifndef Z_SOLO
+# include <sys/types.h> /* for off_t */
+# endif
+#endif
+
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+# include <stdarg.h> /* for va_list */
+# endif
+#endif
+
+#ifdef _WIN32
+# ifndef Z_SOLO
+# include <stddef.h> /* for wchar_t */
+# endif
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
+# undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
+# define Z_HAVE_UNISTD_H
+#endif
+#ifndef Z_SOLO
+# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
+# ifdef VMS
+# include <unixio.h> /* for off_t */
+# endif
+# if !defined(z_off_t) && !defined(__APPLE__)
+# define z_off_t off_t
+# endif
+# endif
+#endif
+
+#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
+# define Z_LFS64
+#endif
+
+#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
+# define Z_LARGE64
+#endif
+
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
+# define Z_WANT64
+#endif
+
+#if !defined(SEEK_SET) && !defined(Z_SOLO)
+# define SEEK_SET 0 /* Seek from beginning of file. */
+# define SEEK_CUR 1 /* Seek from current position. */
+# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
+#endif
+
+#ifndef z_off_t
+# define z_off_t long
+#endif
+
+#if !defined(_WIN32) && defined(Z_LARGE64)
+# define z_off64_t off64_t
+#elif defined(__APPLE__)
+# define z_off64_t off_t
+#else
+# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
+# define z_off64_t __int64
+# else
+# define z_off64_t z_off_t
+# endif
+#endif
+
+/* MVS linker does not support external names larger than 8 bytes */
+#if defined(__MVS__)
+ #pragma map(deflateInit_,"DEIN")
+ #pragma map(deflateInit2_,"DEIN2")
+ #pragma map(deflateEnd,"DEEND")
+ #pragma map(deflateBound,"DEBND")
+ #pragma map(inflateInit_,"ININ")
+ #pragma map(inflateInit2_,"ININ2")
+ #pragma map(inflateEnd,"INEND")
+ #pragma map(inflateSync,"INSY")
+ #pragma map(inflateSetDictionary,"INSEDI")
+ #pragma map(compressBound,"CMBND")
+ #pragma map(inflate_table,"INTABL")
+ #pragma map(inflate_fast,"INFA")
+ #pragma map(inflate_copyright,"INCOPY")
+#endif
+
+#endif /* ZCONF_H */ \ No newline at end of file
diff --git a/lib/libc/include/any-macos-any/zlib.h b/lib/libc/include/any-macos-any/zlib.h
new file mode 100644
index 0000000000..ce1fbd6a68
--- /dev/null
+++ b/lib/libc/include/any-macos-any/zlib.h
@@ -0,0 +1,1946 @@
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+ version 1.2.11, January 15th, 2017
+
+ Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+
+ The data format used by the zlib library is described by RFCs (Request for
+ Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+ (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
+*/
+
+#ifndef ZLIB_H
+#define ZLIB_H
+
+#include "zconf.h"
+#ifdef __APPLE__
+#include <Availability.h>
+#else /* !__APPLE__ */
+#define __API_AVAILABLE(...) /* nothing */
+#endif /* !__APPLE__ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZLIB_VERSION "1.2.11"
+#define ZLIB_VERNUM 0x12b0
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 11
+#define ZLIB_VER_SUBREVISION 0
+
+/*
+ The 'zlib' compression library provides in-memory compression and
+ decompression functions, including integrity checks of the uncompressed data.
+ This version of the library supports only one compression method (deflation)
+ but other algorithms will be added later and will have the same stream
+ interface.
+
+ Compression can be done in a single step if the buffers are large enough,
+ or can be done by repeated calls of the compression function. In the latter
+ case, the application must provide more input and/or consume the output
+ (providing more output space) before each call.
+
+ The compressed data format used by default by the in-memory functions is
+ the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+ around a deflate stream, which is itself documented in RFC 1951.
+
+ The library also supports reading and writing files in gzip (.gz) format
+ with an interface similar to that of stdio using the functions that start
+ with "gz". The gzip format is different from the zlib format. gzip is a
+ gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
+ This library can optionally read and write gzip and raw deflate streams in
+ memory as well.
+
+ The zlib format was designed to be compact and fast for use in memory
+ and on communications channels. The gzip format was designed for single-
+ file compression on file systems, has a larger header than zlib to maintain
+ directory information, and uses a different, slower check method than zlib.
+
+ The library does not install any signal handler. The decoder checks
+ the consistency of the compressed data, so the library should never crash
+ even in the case of corrupted input.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void (*free_func) OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+ z_const Bytef *next_in; /* next input byte */
+ uInt avail_in; /* number of bytes available at next_in */
+ uLong total_in; /* total number of input bytes read so far */
+
+ Bytef *next_out; /* next output byte will go here */
+ uInt avail_out; /* remaining free space at next_out */
+ uLong total_out; /* total number of bytes output so far */
+
+ z_const char *msg; /* last error message, NULL if no error */
+ struct internal_state FAR *state; /* not visible by applications */
+
+ alloc_func zalloc; /* used to allocate the internal state */
+ free_func zfree; /* used to free the internal state */
+ voidpf opaque; /* private data object passed to zalloc and zfree */
+
+ int data_type; /* best guess about the data type: binary or text
+ for deflate, or the decoding state for inflate */
+ uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */
+ uLong reserved; /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+/*
+ gzip header information passed to and from zlib routines. See RFC 1952
+ for more details on the meanings of these fields.
+*/
+typedef struct gz_header_s {
+ int text; /* true if compressed data believed to be text */
+ uLong time; /* modification time */
+ int xflags; /* extra flags (not used when writing a gzip file) */
+ int os; /* operating system */
+ Bytef *extra; /* pointer to extra field or Z_NULL if none */
+ uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
+ uInt extra_max; /* space at extra (only when reading header) */
+ Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
+ uInt name_max; /* space at name (only when reading header) */
+ Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
+ uInt comm_max; /* space at comment (only when reading header) */
+ int hcrc; /* true if there was or will be a header crc */
+ int done; /* true when done reading gzip header (not used
+ when writing a gzip file) */
+} gz_header;
+
+typedef gz_header FAR *gz_headerp;
+
+/*
+ The application must update next_in and avail_in when avail_in has dropped
+ to zero. It must update next_out and avail_out when avail_out has dropped
+ to zero. The application must initialize zalloc, zfree and opaque before
+ calling the init function. All other fields are set by the compression
+ library and must not be updated by the application.
+
+ The opaque value provided by the application will be passed as the first
+ parameter for calls of zalloc and zfree. This can be useful for custom
+ memory management. The compression library attaches no meaning to the
+ opaque value.
+
+ zalloc must return Z_NULL if there is not enough memory for the object.
+ If zlib is used in a multi-threaded application, zalloc and zfree must be
+ thread safe. In that case, zlib is thread-safe. When zalloc and zfree are
+ Z_NULL on entry to the initialization function, they are set to internal
+ routines that use the standard library functions malloc() and free().
+
+ On 16-bit systems, the functions zalloc and zfree must be able to allocate
+ exactly 65536 bytes, but will not be required to allocate more than this if
+ the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers
+ returned by zalloc for objects of exactly 65536 bytes *must* have their
+ offset normalized to zero. The default allocation function provided by this
+ library ensures this (see zutil.c). To reduce memory requirements and avoid
+ any allocation of 64K objects, at the expense of compression ratio, compile
+ the library with -DMAX_WBITS=14 (see zconf.h).
+
+ The fields total_in and total_out can be used for statistics or progress
+ reports. After compression, total_in holds the total size of the
+ uncompressed data and may be saved for use by the decompressor (particularly
+ if the decompressor wants to decompress everything in a single step).
+*/
+
+ /* constants */
+
+#define Z_NO_FLUSH 0
+#define Z_PARTIAL_FLUSH 1
+#define Z_SYNC_FLUSH 2
+#define Z_FULL_FLUSH 3
+#define Z_FINISH 4
+#define Z_BLOCK 5
+#define Z_TREES 6
+/* Allowed flush values; see deflate() and inflate() below for details */
+
+#define Z_OK 0
+#define Z_STREAM_END 1
+#define Z_NEED_DICT 2
+#define Z_ERRNO (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR (-3)
+#define Z_MEM_ERROR (-4)
+#define Z_BUF_ERROR (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION 0
+#define Z_BEST_SPEED 1
+#define Z_BEST_COMPRESSION 9
+#define Z_DEFAULT_COMPRESSION (-1)
+/* compression levels */
+
+#define Z_FILTERED 1
+#define Z_HUFFMAN_ONLY 2
+#define Z_RLE 3
+#define Z_FIXED 4
+#define Z_DEFAULT_STRATEGY 0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY 0
+#define Z_TEXT 1
+#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
+#define Z_UNKNOWN 2
+/* Possible values of the data_type field for deflate() */
+
+#define Z_DEFLATED 8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
+
+#define zlib_version zlibVersion()
+/* for compatibility with versions < 1.0.2 */
+
+
+ /* basic functions */
+
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
+ If the first character differs, the library code actually used is not
+ compatible with the zlib.h header file used by the application. This check
+ is automatically made by deflateInit and inflateInit.
+ */
+
+/*
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
+ Initializes the internal stream state for compression. The fields
+ zalloc, zfree and opaque must be initialized before by the caller. If
+ zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+ allocation functions.
+
+ The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+ 1 gives best speed, 9 gives best compression, 0 gives no compression at all
+ (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION
+ requests a default compromise between speed and compression (currently
+ equivalent to level 6).
+
+ deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if level is not a valid compression level, or
+ Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+ with the version assumed by the caller (ZLIB_VERSION). msg is set to null
+ if there is no error message. deflateInit does not perform any compression:
+ this will be done by deflate().
+*/
+
+
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+/*
+ deflate compresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. deflate performs one or both of the
+ following actions:
+
+ - Compress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), next_in and avail_in are updated and
+ processing will resume at this point for the next call of deflate().
+
+ - Generate more output starting at next_out and update next_out and avail_out
+ accordingly. This action is forced if the parameter flush is non zero.
+ Forcing flush frequently degrades the compression ratio, so this parameter
+ should be set only when necessary. Some output may be provided even if
+ flush is zero.
+
+ Before the call of deflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating avail_in or avail_out accordingly; avail_out should
+ never be zero before the call. The application can consume the compressed
+ output when it wants, for example when the output buffer is full (avail_out
+ == 0), or after each call of deflate(). If deflate returns Z_OK and with
+ zero avail_out, it must be called again after making room in the output
+ buffer because there might be more output pending. See deflatePending(),
+ which can be used if desired to determine whether or not there is more ouput
+ in that case.
+
+ Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
+ decide how much data to accumulate before producing output, in order to
+ maximize compression.
+
+ If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
+ flushed to the output buffer and the output is aligned on a byte boundary, so
+ that the decompressor can get all input data available so far. (In
+ particular avail_in is zero after the call if enough output space has been
+ provided before the call.) Flushing may degrade compression for some
+ compression algorithms and so it should be used only when necessary. This
+ completes the current deflate block and follows it with an empty stored block
+ that is three bits plus filler bits to the next byte, followed by four bytes
+ (00 00 ff ff).
+
+ If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+ output buffer, but the output is not aligned to a byte boundary. All of the
+ input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+ This completes the current deflate block and follows it with an empty fixed
+ codes block that is 10 bits long. This assures that enough bytes are output
+ in order for the decompressor to finish the block before the empty fixed
+ codes block.
+
+ If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+ for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+ seven bits of the current block are held to be written as the next byte after
+ the next deflate block is completed. In this case, the decompressor may not
+ be provided enough bits at this point in order to complete decompression of
+ the data provided so far to the compressor. It may need to wait for the next
+ block to be emitted. This is for advanced applications that need to control
+ the emission of deflate blocks.
+
+ If flush is set to Z_FULL_FLUSH, all output is flushed as with
+ Z_SYNC_FLUSH, and the compression state is reset so that decompression can
+ restart from this point if previous compressed data has been damaged or if
+ random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
+ compression.
+
+ If deflate returns with avail_out == 0, this function must be called again
+ with the same value of the flush parameter and more output space (updated
+ avail_out), until the flush is complete (deflate returns with non-zero
+ avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+ avail_out is greater than six to avoid repeated flush markers due to
+ avail_out == 0 on return.
+
+ If the parameter flush is set to Z_FINISH, pending input is processed,
+ pending output is flushed and deflate returns with Z_STREAM_END if there was
+ enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this
+ function must be called again with Z_FINISH and more output space (updated
+ avail_out) but no more input data, until it returns with Z_STREAM_END or an
+ error. After deflate has returned Z_STREAM_END, the only possible operations
+ on the stream are deflateReset or deflateEnd.
+
+ Z_FINISH can be used in the first deflate call after deflateInit if all the
+ compression is to be done in a single step. In order to complete in one
+ call, avail_out must be at least the value returned by deflateBound (see
+ below). Then deflate is guaranteed to return Z_STREAM_END. If not enough
+ output space is provided, deflate will not return Z_STREAM_END, and it must
+ be called again as described above.
+
+ deflate() sets strm->adler to the Adler-32 checksum of all input read
+ so far (that is, total_in bytes). If a gzip stream is being generated, then
+ strm->adler will be the CRC-32 checksum of the input read so far. (See
+ deflateInit2 below.)
+
+ deflate() may update strm->data_type if it can make a good guess about
+ the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is
+ considered binary. This field is only for information purposes and does not
+ affect the compression algorithm in any manner.
+
+ deflate() returns Z_OK if some progress has been made (more input
+ processed or more output produced), Z_STREAM_END if all input has been
+ consumed and all output has been produced (only when flush is set to
+ Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+ if next_in or next_out was Z_NULL or the state was inadvertently written over
+ by the application), or Z_BUF_ERROR if no progress is possible (for example
+ avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and
+ deflate() can be called again with more input and more output space to
+ continue compressing.
+*/
+
+
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+ stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+ prematurely (some input or output was discarded). In the error case, msg
+ may be set but then points to a static string (which must not be
+ deallocated).
+*/
+
+
+/*
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
+ Initializes the internal stream state for decompression. The fields
+ next_in, avail_in, zalloc, zfree and opaque must be initialized before by
+ the caller. In the current version of inflate, the provided input is not
+ read or consumed. The allocation of a sliding window will be deferred to
+ the first call of inflate (if the decompression does not complete on the
+ first call). If zalloc and zfree are set to Z_NULL, inflateInit updates
+ them to use default allocation functions.
+
+ inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit does not perform any decompression.
+ Actual decompression will be done by inflate(). So next_in, and avail_in,
+ next_out, and avail_out are unused and unchanged. The current
+ implementation of inflateInit() does not process any header information --
+ that is deferred until inflate() is called.
+*/
+
+
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+/*
+ inflate decompresses as much data as possible, and stops when the input
+ buffer becomes empty or the output buffer becomes full. It may introduce
+ some output latency (reading input without producing any output) except when
+ forced to flush.
+
+ The detailed semantics are as follows. inflate performs one or both of the
+ following actions:
+
+ - Decompress more input starting at next_in and update next_in and avail_in
+ accordingly. If not all input can be processed (because there is not
+ enough room in the output buffer), then next_in and avail_in are updated
+ accordingly, and processing will resume at this point for the next call of
+ inflate().
+
+ - Generate more output starting at next_out and update next_out and avail_out
+ accordingly. inflate() provides as much output as possible, until there is
+ no more input data or no more space in the output buffer (see below about
+ the flush parameter).
+
+ Before the call of inflate(), the application should ensure that at least
+ one of the actions is possible, by providing more input and/or consuming more
+ output, and updating the next_* and avail_* values accordingly. If the
+ caller of inflate() does not provide both available input and available
+ output space, it is possible that there will be no progress made. The
+ application can consume the uncompressed output when it wants, for example
+ when the output buffer is full (avail_out == 0), or after each call of
+ inflate(). If inflate returns Z_OK and with zero avail_out, it must be
+ called again after making room in the output buffer because there might be
+ more output pending.
+
+ The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+ Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much
+ output as possible to the output buffer. Z_BLOCK requests that inflate()
+ stop if and when it gets to the next deflate block boundary. When decoding
+ the zlib or gzip format, this will cause inflate() to return immediately
+ after the header and before the first block. When doing a raw inflate,
+ inflate() will go ahead and process the first block, and will return when it
+ gets to the end of that block, or when it runs out of data.
+
+ The Z_BLOCK option assists in appending to or combining deflate streams.
+ To assist in this, on return inflate() always sets strm->data_type to the
+ number of unused bits in the last byte taken from strm->next_in, plus 64 if
+ inflate() is currently decoding the last block in the deflate stream, plus
+ 128 if inflate() returned immediately after decoding an end-of-block code or
+ decoding the complete header up to just before the first byte of the deflate
+ stream. The end-of-block will not be indicated until all of the uncompressed
+ data from that block has been written to strm->next_out. The number of
+ unused bits may in general be greater than seven, except when bit 7 of
+ data_type is set, in which case the number of unused bits will be less than
+ eight. data_type is set as noted here every time inflate() returns for all
+ flush options, and so can be used to determine the amount of currently
+ consumed input in bits.
+
+ The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+ end of each deflate block header is reached, before any actual data in that
+ block is decoded. This allows the caller to determine the length of the
+ deflate block header for later use in random access within a deflate block.
+ 256 is added to the value of strm->data_type when inflate() returns
+ immediately after reaching the end of the deflate block header.
+
+ inflate() should normally be called until it returns Z_STREAM_END or an
+ error. However if all decompression is to be performed in a single step (a
+ single call of inflate), the parameter flush should be set to Z_FINISH. In
+ this case all pending input is processed and all pending output is flushed;
+ avail_out must be large enough to hold all of the uncompressed data for the
+ operation to complete. (The size of the uncompressed data may have been
+ saved by the compressor for this purpose.) The use of Z_FINISH is not
+ required to perform an inflation in one step. However it may be used to
+ inform inflate that a faster approach can be used for the single inflate()
+ call. Z_FINISH also informs inflate to not maintain a sliding window if the
+ stream completes, which reduces inflate's memory footprint. If the stream
+ does not complete, either because not all of the stream is provided or not
+ enough output space is provided, then a sliding window will be allocated and
+ inflate() can be called again to continue the operation as if Z_NO_FLUSH had
+ been used.
+
+ In this implementation, inflate() always flushes as much output as
+ possible to the output buffer, and always uses the faster approach on the
+ first call. So the effects of the flush parameter in this implementation are
+ on the return value of inflate() as noted below, when inflate() returns early
+ when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
+ memory for a sliding window when Z_FINISH is used.
+
+ If a preset dictionary is needed after this call (see inflateSetDictionary
+ below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
+ chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
+ strm->adler to the Adler-32 checksum of all output produced so far (that is,
+ total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
+ below. At the end of the stream, inflate() checks that its computed Adler-32
+ checksum is equal to that saved by the compressor and returns Z_STREAM_END
+ only if the checksum is correct.
+
+ inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+ deflate data. The header type is detected automatically, if requested when
+ initializing with inflateInit2(). Any information contained in the gzip
+ header is not retained unless inflateGetHeader() is used. When processing
+ gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
+ produced so far. The CRC-32 is checked against the gzip trailer, as is the
+ uncompressed length, modulo 2^32.
+
+ inflate() returns Z_OK if some progress has been made (more input processed
+ or more output produced), Z_STREAM_END if the end of the compressed data has
+ been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+ preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+ corrupted (input stream not conforming to the zlib format or incorrect check
+ value, in which case strm->msg points to a string with a more specific
+ error), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+ next_in or next_out was Z_NULL, or the state was inadvertently written over
+ by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR
+ if no progress was possible or if there was not enough room in the output
+ buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
+ inflate() can be called again with more input and more output space to
+ continue decompressing. If Z_DATA_ERROR is returned, the application may
+ then call inflateSync() to look for a good compression block if a partial
+ recovery of the data is to be attempted.
+*/
+
+
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+/*
+ All dynamically allocated data structures for this stream are freed.
+ This function discards any unprocessed input and does not flush any pending
+ output.
+
+ inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state
+ was inconsistent.
+*/
+
+
+ /* Advanced functions */
+
+/*
+ The following functions are needed only in some special applications.
+*/
+
+/*
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+ int level,
+ int method,
+ int windowBits,
+ int memLevel,
+ int strategy));
+
+ This is another version of deflateInit with more compression options. The
+ fields next_in, zalloc, zfree and opaque must be initialized before by the
+ caller.
+
+ The method parameter is the compression method. It must be Z_DEFLATED in
+ this version of the library.
+
+ The windowBits parameter is the base two logarithm of the window size
+ (the size of the history buffer). It should be in the range 8..15 for this
+ version of the library. Larger values of this parameter result in better
+ compression at the expense of memory usage. The default value is 15 if
+ deflateInit is used instead.
+
+ For the current implementation of deflate(), a windowBits value of 8 (a
+ window size of 256 bytes) is not supported. As a result, a request for 8
+ will result in 9 (a 512-byte window). In that case, providing 8 to
+ inflateInit2() will result in an error when the zlib header with 9 is
+ checked against the initialization of inflate(). The remedy is to not use 8
+ with deflateInit2() with this initialization, or at least in that case use 9
+ with inflateInit2().
+
+ windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
+ determines the window size. deflate() will then generate raw deflate data
+ with no zlib header or trailer, and will not compute a check value.
+
+ windowBits can also be greater than 15 for optional gzip encoding. Add
+ 16 to windowBits to write a simple gzip header and trailer around the
+ compressed data instead of a zlib wrapper. The gzip header will have no
+ file name, no extra data, no comment, no modification time (set to zero), no
+ header crc, and the operating system will be set to the appropriate value,
+ if the operating system was determined at compile time. If a gzip stream is
+ being written, strm->adler is a CRC-32 instead of an Adler-32.
+
+ For raw deflate or gzip encoding, a request for a 256-byte window is
+ rejected as invalid, since only the zlib header provides a means of
+ transmitting the window size to the decompressor.
+
+ The memLevel parameter specifies how much memory should be allocated
+ for the internal compression state. memLevel=1 uses minimum memory but is
+ slow and reduces compression ratio; memLevel=9 uses maximum memory for
+ optimal speed. The default value is 8. See zconf.h for total memory usage
+ as a function of windowBits and memLevel.
+
+ The strategy parameter is used to tune the compression algorithm. Use the
+ value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+ filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
+ string match), or Z_RLE to limit match distances to one (run-length
+ encoding). Filtered data consists mostly of small values with a somewhat
+ random distribution. In this case, the compression algorithm is tuned to
+ compress them better. The effect of Z_FILTERED is to force more Huffman
+ coding and less string matching; it is somewhat intermediate between
+ Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as
+ fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The
+ strategy parameter only affects the compression ratio but not the
+ correctness of the compressed output even if it is not set appropriately.
+ Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+ decoder for special applications.
+
+ deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+ method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+ incompatible with the version assumed by the caller (ZLIB_VERSION). msg is
+ set to null if there is no error message. deflateInit2 does not perform any
+ compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the compression dictionary from the given byte sequence
+ without producing any compressed output. When using the zlib format, this
+ function must be called immediately after deflateInit, deflateInit2 or
+ deflateReset, and before any call of deflate. When doing raw deflate, this
+ function must be called either before any call of deflate, or immediately
+ after the completion of a deflate block, i.e. after all input has been
+ consumed and all output has been delivered when using any of the flush
+ options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
+ compressor and decompressor must use exactly the same dictionary (see
+ inflateSetDictionary).
+
+ The dictionary should consist of strings (byte sequences) that are likely
+ to be encountered later in the data to be compressed, with the most commonly
+ used strings preferably put towards the end of the dictionary. Using a
+ dictionary is most useful when the data to be compressed is short and can be
+ predicted with good accuracy; the data can then be compressed better than
+ with the default empty dictionary.
+
+ Depending on the size of the compression data structures selected by
+ deflateInit or deflateInit2, a part of the dictionary may in effect be
+ discarded, for example if the dictionary is larger than the window size
+ provided in deflateInit or deflateInit2. Thus the strings most likely to be
+ useful should be put at the end of the dictionary, not at the front. In
+ addition, the current implementation of deflate will use at most the window
+ size minus 262 bytes of the provided dictionary.
+
+ Upon return of this function, strm->adler is set to the Adler-32 value
+ of the dictionary; the decompressor may later use this value to determine
+ which dictionary has been used by the compressor. (The Adler-32 value
+ applies to the whole dictionary even if only a subset of the dictionary is
+ actually used by the compressor.) If a raw deflate was requested, then the
+ Adler-32 value is not computed and strm->adler is not set.
+
+ deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent (for example if deflate has already been called for this stream
+ or if not at a block boundary for raw deflate). deflateSetDictionary does
+ not perform any compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ Returns the sliding dictionary being maintained by deflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If deflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ deflateGetDictionary() may return a length less than the window size, even
+ when more than the window size in input has been provided. It may return up
+ to 258 bytes less in that case, due to how zlib's implementation of deflate
+ manages the sliding window and lookahead for matches, where matches can be
+ up to 258 bytes long. If the application needs the last window-size bytes of
+ input, then that would need to be saved by the application outside of zlib.
+
+ deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when several compression strategies will be
+ tried, for example when there are several ways of pre-processing the input
+ data with a filter. The streams that will be discarded should then be freed
+ by calling deflateEnd. Note that deflateCopy duplicates the internal
+ compression state which can be quite large, so this strategy is slow and can
+ consume lots of memory.
+
+ deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to deflateEnd followed by deflateInit, but
+ does not free and reallocate the internal compression state. The stream
+ will leave the compression level and any other attributes that may have been
+ set unchanged.
+
+ deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
+ int level,
+ int strategy));
+/*
+ Dynamically update the compression level and compression strategy. The
+ interpretation of level and strategy is as in deflateInit2(). This can be
+ used to switch between compression and straight copy of the input data, or
+ to switch to a different kind of input data requiring a different strategy.
+ If the compression approach (which is a function of the level) or the
+ strategy is changed, and if any input has been consumed in a previous
+ deflate() call, then the input available so far is compressed with the old
+ level and strategy using deflate(strm, Z_BLOCK). There are three approaches
+ for the compression levels 0, 1..3, and 4..9 respectively. The new level
+ and strategy will take effect at the next call of deflate().
+
+ If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does
+ not have enough output space to complete, then the parameter change will not
+ take effect. In this case, deflateParams() can be called again with the
+ same parameters and more output space to try again.
+
+ In order to assure a change in the parameters on the first try, the
+ deflate stream should be flushed using deflate() with Z_BLOCK or other flush
+ request until strm.avail_out is not zero, before calling deflateParams().
+ Then no more input data should be provided before the deflateParams() call.
+ If this is done, the old level and strategy will be applied to the data
+ compressed before deflateParams(), and the new level and strategy will be
+ applied to the the data compressed after deflateParams().
+
+ deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream
+ state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if
+ there was not enough output space to complete the compression of the
+ available input data before a change in the strategy or approach. Note that
+ in the case of a Z_BUF_ERROR, the parameters are not changed. A return
+ value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be
+ retried with more output space.
+*/
+
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
+ int good_length,
+ int max_lazy,
+ int nice_length,
+ int max_chain));
+/*
+ Fine tune deflate's internal compression parameters. This should only be
+ used by someone who understands the algorithm used by zlib's deflate for
+ searching for the best matching string, and even then only by the most
+ fanatic optimizer trying to squeeze out the last compressed bit for their
+ specific input data. Read the deflate.c source code for the meaning of the
+ max_lazy, good_length, nice_length, and max_chain parameters.
+
+ deflateTune() can be called after deflateInit() or deflateInit2(), and
+ returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
+ */
+
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
+ uLong sourceLen));
+/*
+ deflateBound() returns an upper bound on the compressed size after
+ deflation of sourceLen bytes. It must be called after deflateInit() or
+ deflateInit2(), and after deflateSetHeader(), if used. This would be used
+ to allocate an output buffer for deflation in a single pass, and so would be
+ called before deflate(). If that first deflate() call is provided the
+ sourceLen input bytes, an output buffer allocated to the size returned by
+ deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
+ to return Z_STREAM_END. Note that it is possible for the compressed size to
+ be larger than the value returned by deflateBound() if flush options other
+ than Z_FINISH or Z_NO_FLUSH are used.
+*/
+
+ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
+ unsigned *pending,
+ int *bits))
+ __API_AVAILABLE(macos(10.10),ios(8.0));
+/*
+ deflatePending() returns the number of bytes and bits of output that have
+ been generated, but not yet provided in the available output. The bytes not
+ provided would be due to the available output space having being consumed.
+ The number of bits of output not provided are between 0 and 7, where they
+ await more bits to join them in order to fill out a full byte. If pending
+ or bits are Z_NULL, then those values are not set.
+
+ deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+ */
+
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ deflatePrime() inserts bits in the deflate output stream. The intent
+ is that this function is used to start off the deflate output with the bits
+ leftover from a previous deflate stream when appending to it. As such, this
+ function can only be used for raw deflate, and must be used before the first
+ deflate() call after a deflateInit2() or deflateReset(). bits must be less
+ than or equal to 16, and that many of the least significant bits of value
+ will be inserted in the output.
+
+ deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
+ room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
+ source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ deflateSetHeader() provides gzip header information for when a gzip
+ stream is requested by deflateInit2(). deflateSetHeader() may be called
+ after deflateInit2() or deflateReset() and before the first call of
+ deflate(). The text, time, os, extra field, name, and comment information
+ in the provided gz_header structure are written to the gzip header (xflag is
+ ignored -- the extra flags are set according to the compression level). The
+ caller must assure that, if not Z_NULL, name and comment are terminated with
+ a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+ available there. If hcrc is true, a gzip header crc is included. Note that
+ the current versions of the command-line version of gzip (up through version
+ 1.3.x) do not support header crc's, and will report that it is a "multi-part
+ gzip file" and give up.
+
+ If deflateSetHeader is not used, the default gzip header has text false,
+ the time set to zero, and os set to 255, with no extra, name, or comment
+ fields. The gzip header is returned to the default state by deflateReset().
+
+ deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+ int windowBits));
+
+ This is another version of inflateInit with an extra parameter. The
+ fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+ before by the caller.
+
+ The windowBits parameter is the base two logarithm of the maximum window
+ size (the size of the history buffer). It should be in the range 8..15 for
+ this version of the library. The default value is 15 if inflateInit is used
+ instead. windowBits must be greater than or equal to the windowBits value
+ provided to deflateInit2() while compressing, or it must be equal to 15 if
+ deflateInit2() was not used. If a compressed stream with a larger window
+ size is given as input, inflate() will return with the error code
+ Z_DATA_ERROR instead of trying to allocate a larger window.
+
+ windowBits can also be zero to request that inflate use the window size in
+ the zlib header of the compressed stream.
+
+ windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
+ determines the window size. inflate() will then process raw deflate data,
+ not looking for a zlib or gzip header, not generating a check value, and not
+ looking for any check values for comparison at the end of the stream. This
+ is for use with other formats that use the deflate compressed data format
+ such as zip. Those formats provide their own check values. If a custom
+ format is developed using the raw deflate format for compressed data, it is
+ recommended that a check value such as an Adler-32 or a CRC-32 be applied to
+ the uncompressed data as is done in the zlib, gzip, and zip formats. For
+ most applications, the zlib format should be used as is. Note that comments
+ above on the use in deflateInit2() applies to the magnitude of windowBits.
+
+ windowBits can also be greater than 15 for optional gzip decoding. Add
+ 32 to windowBits to enable zlib and gzip decoding with automatic header
+ detection, or add 16 to decode only the gzip format (the zlib format will
+ return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a
+ CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see
+ below), inflate() will not automatically decode concatenated gzip streams.
+ inflate() will return Z_STREAM_END at the end of the gzip stream. The state
+ would need to be reset to continue decoding a subsequent gzip stream.
+
+ inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+ version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+ invalid, such as a null pointer to the structure. msg is set to null if
+ there is no error message. inflateInit2 does not perform any decompression
+ apart from possibly reading the zlib header if present: actual decompression
+ will be done by inflate(). (So next_in and avail_in may be modified, but
+ next_out and avail_out are unused and unchanged.) The current implementation
+ of inflateInit2() does not process any header information -- that is
+ deferred until inflate() is called.
+*/
+
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+ const Bytef *dictionary,
+ uInt dictLength));
+/*
+ Initializes the decompression dictionary from the given uncompressed byte
+ sequence. This function must be called immediately after a call of inflate,
+ if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
+ can be determined from the Adler-32 value returned by that call of inflate.
+ The compressor and decompressor must use exactly the same dictionary (see
+ deflateSetDictionary). For raw inflate, this function can be called at any
+ time to set the dictionary. If the provided dictionary is smaller than the
+ window and there is already data in the window, then the provided dictionary
+ will amend what's there. The application must insure that the dictionary
+ that was used for compression is provided.
+
+ inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+ parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
+ inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+ expected one (incorrect Adler-32 value). inflateSetDictionary does not
+ perform any decompression: this will be done by subsequent calls of
+ inflate().
+*/
+
+ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
+ Bytef *dictionary,
+ uInt *dictLength))
+ __API_AVAILABLE(macos(10.10),ios(8.0));
+/*
+ Returns the sliding dictionary being maintained by inflate. dictLength is
+ set to the number of bytes in the dictionary, and that many bytes are copied
+ to dictionary. dictionary must have enough space, where 32768 bytes is
+ always enough. If inflateGetDictionary() is called with dictionary equal to
+ Z_NULL, then only the dictionary length is returned, and nothing is copied.
+ Similary, if dictLength is Z_NULL, then it is not set.
+
+ inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
+ stream state is inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+/*
+ Skips invalid compressed data until a possible full flush point (see above
+ for the description of deflate with Z_FULL_FLUSH) can be found, or until all
+ available input is skipped. No output is provided.
+
+ inflateSync searches for a 00 00 FF FF pattern in the compressed data.
+ All full flush points have this pattern, but not all occurrences of this
+ pattern are full flush points.
+
+ inflateSync returns Z_OK if a possible full flush point has been found,
+ Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
+ has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
+ In the success case, the application may save the current current value of
+ total_in which indicates where valid compressed data was found. In the
+ error case, the application may repeatedly call inflateSync, providing more
+ input each time, until success or end of the input data.
+*/
+
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+ z_streamp source));
+/*
+ Sets the destination stream as a complete copy of the source stream.
+
+ This function can be useful when randomly accessing a large stream. The
+ first pass through the stream can periodically record the inflate state,
+ allowing restarting inflate at those points when randomly accessing the
+ stream.
+
+ inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+ (such as zalloc being Z_NULL). msg is left unchanged in both source and
+ destination.
+*/
+
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+/*
+ This function is equivalent to inflateEnd followed by inflateInit,
+ but does not free and reallocate the internal decompression state. The
+ stream will keep attributes that may have been set by inflateInit2.
+
+ inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+ int windowBits))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+/*
+ This function is the same as inflateReset, but it also permits changing
+ the wrap and window size requests. The windowBits parameter is interpreted
+ the same as it is for inflateInit2. If the window size is changed, then the
+ memory allocated for the window is freed, and the window will be reallocated
+ by inflate() if needed.
+
+ inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+ the windowBits parameter is invalid.
+*/
+
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+ int bits,
+ int value));
+/*
+ This function inserts bits in the inflate input stream. The intent is
+ that this function is used to start inflating at a bit position in the
+ middle of a byte. The provided bits will be used before any bytes are used
+ from next_in. This function should only be used with raw inflate, and
+ should be used before the first inflate() call after inflateInit2() or
+ inflateReset(). bits must be less than or equal to 16, and that many of the
+ least significant bits of value will be inserted in the input.
+
+ If bits is negative, then the input stream bit buffer is emptied. Then
+ inflatePrime() can be called again to put bits in the buffer. This is used
+ to clear out bits leftover after feeding inflate a block description prior
+ to feeding inflate codes.
+
+ inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+/*
+ This function returns two values, one in the lower 16 bits of the return
+ value, and the other in the remaining upper bits, obtained by shifting the
+ return value down 16 bits. If the upper value is -1 and the lower value is
+ zero, then inflate() is currently decoding information outside of a block.
+ If the upper value is -1 and the lower value is non-zero, then inflate is in
+ the middle of a stored block, with the lower value equaling the number of
+ bytes from the input remaining to copy. If the upper value is not -1, then
+ it is the number of bits back from the current bit position in the input of
+ the code (literal or length/distance pair) currently being processed. In
+ that case the lower value is the number of bytes already emitted for that
+ code.
+
+ A code is being processed if inflate is waiting for more input to complete
+ decoding of the code, or if it has completed decoding but is waiting for
+ more output space to write the literal or match data.
+
+ inflateMark() is used to mark locations in the input data for random
+ access, which may be at bit positions, and to note those cases where the
+ output of a code may span boundaries of random access blocks. The current
+ location in the input stream can be determined from avail_in and data_type
+ as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+ inflateMark returns the value noted above, or -65536 if the provided
+ source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+ gz_headerp head));
+/*
+ inflateGetHeader() requests that gzip header information be stored in the
+ provided gz_header structure. inflateGetHeader() may be called after
+ inflateInit2() or inflateReset(), and before the first call of inflate().
+ As inflate() processes the gzip stream, head->done is zero until the header
+ is completed, at which time head->done is set to one. If a zlib stream is
+ being decoded, then head->done is set to -1 to indicate that there will be
+ no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be
+ used to force inflate() to return immediately after header processing is
+ complete and before any actual data is decompressed.
+
+ The text, time, xflags, and os fields are filled in with the gzip header
+ contents. hcrc is set to true if there is a header CRC. (The header CRC
+ was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+ contains the maximum number of bytes to write to extra. Once done is true,
+ extra_len contains the actual extra field length, and extra contains the
+ extra field, or that field truncated if extra_max is less than extra_len.
+ If name is not Z_NULL, then up to name_max characters are written there,
+ terminated with a zero unless the length is greater than name_max. If
+ comment is not Z_NULL, then up to comm_max characters are written there,
+ terminated with a zero unless the length is greater than comm_max. When any
+ of extra, name, or comment are not Z_NULL and the respective field is not
+ present in the header, then that field is set to Z_NULL to signal its
+ absence. This allows the use of deflateSetHeader() with the returned
+ structure to duplicate the header. However if those fields are set to
+ allocated memory, then the application will need to save those pointers
+ elsewhere so that they can be eventually freed.
+
+ If inflateGetHeader is not used, then the header information is simply
+ discarded. The header is always checked for validity, including the header
+ CRC if present. inflateReset() will reset the process to discard the header
+ information. The application would need to call inflateGetHeader() again to
+ retrieve the header from the next gzip stream.
+
+ inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+ stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window));
+
+ Initialize the internal stream state for decompression using inflateBack()
+ calls. The fields zalloc, zfree and opaque in strm must be initialized
+ before the call. If zalloc and zfree are Z_NULL, then the default library-
+ derived memory allocation routines are used. windowBits is the base two
+ logarithm of the window size, in the range 8..15. window is a caller
+ supplied buffer of that size. Except for special applications where it is
+ assured that deflate was used with small window sizes, windowBits must be 15
+ and a 32K byte window must be supplied to be able to decompress general
+ deflate streams.
+
+ See inflateBack() for the usage of these routines.
+
+ inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
+ the parameters are invalid, Z_MEM_ERROR if the internal state could not be
+ allocated, or Z_VERSION_ERROR if the version of the library does not match
+ the version of the header file.
+*/
+
+typedef unsigned (*in_func) OF((void FAR *,
+ z_const unsigned char FAR * FAR *));
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+ in_func in, void FAR *in_desc,
+ out_func out, void FAR *out_desc));
+/*
+ inflateBack() does a raw inflate with a single call using a call-back
+ interface for input and output. This is potentially more efficient than
+ inflate() for file i/o applications, in that it avoids copying between the
+ output and the sliding window by simply making the window itself the output
+ buffer. inflate() can be faster on modern CPUs when used with large
+ buffers. inflateBack() trusts the application to not change the output
+ buffer passed by the output function, at least until inflateBack() returns.
+
+ inflateBackInit() must be called first to allocate the internal state
+ and to initialize the state with the user-provided window buffer.
+ inflateBack() may then be used multiple times to inflate a complete, raw
+ deflate stream with each call. inflateBackEnd() is then called to free the
+ allocated state.
+
+ A raw deflate stream is one with no zlib or gzip header or trailer.
+ This routine would normally be used in a utility that reads zip or gzip
+ files and writes out uncompressed files. The utility would decode the
+ header and process the trailer on its own, hence this routine expects only
+ the raw deflate stream to decompress. This is different from the default
+ behavior of inflate(), which expects a zlib header and trailer around the
+ deflate stream.
+
+ inflateBack() uses two subroutines supplied by the caller that are then
+ called by inflateBack() for input and output. inflateBack() calls those
+ routines until it reads a complete deflate stream and writes out all of the
+ uncompressed data, or until it encounters an error. The function's
+ parameters and return types are defined above in the in_func and out_func
+ typedefs. inflateBack() will call in(in_desc, &buf) which should return the
+ number of bytes of provided input, and a pointer to that input in buf. If
+ there is no input available, in() must return zero -- buf is ignored in that
+ case -- and inflateBack() will return a buffer error. inflateBack() will
+ call out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].
+ out() should return zero on success, or non-zero on failure. If out()
+ returns non-zero, inflateBack() will return with an error. Neither in() nor
+ out() are permitted to change the contents of the window provided to
+ inflateBackInit(), which is also the buffer that out() uses to write from.
+ The length written by out() will be at most the window size. Any non-zero
+ amount of input may be provided by in().
+
+ For convenience, inflateBack() can be provided input on the first call by
+ setting strm->next_in and strm->avail_in. If that input is exhausted, then
+ in() will be called. Therefore strm->next_in must be initialized before
+ calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
+ immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
+ must also be initialized, and then if strm->avail_in is not zero, input will
+ initially be taken from strm->next_in[0 .. strm->avail_in - 1].
+
+ The in_desc and out_desc parameters of inflateBack() is passed as the
+ first parameter of in() and out() respectively when they are called. These
+ descriptors can be optionally used to pass any information that the caller-
+ supplied in() and out() functions need to do their job.
+
+ On return, inflateBack() will set strm->next_in and strm->avail_in to
+ pass back any unused input that was provided by the last in() call. The
+ return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
+ if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+ in the deflate stream (in which case strm->msg is set to indicate the nature
+ of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+ In the case of Z_BUF_ERROR, an input or output error can be distinguished
+ using strm->next_in which will be Z_NULL only if in() returned an error. If
+ strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+ non-zero. (in() will always be called before out(), so strm->next_in is
+ assured to be defined if out() returns non-zero.) Note that inflateBack()
+ cannot return Z_OK.
+*/
+
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
+/*
+ All memory allocated by inflateBackInit() is freed.
+
+ inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
+ state was inconsistent.
+*/
+
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+/* Return flags indicating compile-time options.
+
+ Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
+ 1.0: size of uInt
+ 3.2: size of uLong
+ 5.4: size of voidpf (pointer)
+ 7.6: size of z_off_t
+
+ Compiler, assembler, and debug options:
+ 8: ZLIB_DEBUG
+ 9: ASMV or ASMINF -- use ASM code
+ 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
+ 11: 0 (reserved)
+
+ One-time table building (smaller code, but not thread-safe if true):
+ 12: BUILDFIXED -- build static block decoding tables when needed
+ 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
+ 14,15: 0 (reserved)
+
+ Library content (indicates missing functionality):
+ 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
+ deflate code when not needed)
+ 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
+ and decode gzip streams (to avoid linking crc code)
+ 18-19: 0 (reserved)
+
+ Operation variations (changes in library functionality):
+ 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
+ 21: FASTEST -- deflate algorithm with only one, lowest compression level
+ 22,23: 0 (reserved)
+
+ The sprintf variant used by gzprintf (zero is best):
+ 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
+ 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+ 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
+ Remainder:
+ 27-31: 0 (reserved)
+ */
+
+#ifndef Z_SOLO
+
+ /* utility functions */
+
+/*
+ The following utility functions are implemented on top of the basic
+ stream-oriented functions. To simplify the interface, some default options
+ are assumed (compression level and memory usage, standard memory allocation
+ functions). The source code of these utility functions can be modified if
+ you need special options.
+*/
+
+ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Compresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed data. compress() is equivalent to compress2() with a level
+ parameter of Z_DEFAULT_COMPRESSION.
+
+ compress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer.
+*/
+
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen,
+ int level));
+/*
+ Compresses the source buffer into the destination buffer. The level
+ parameter has the same meaning as in deflateInit. sourceLen is the byte
+ length of the source buffer. Upon entry, destLen is the total size of the
+ destination buffer, which must be at least the value returned by
+ compressBound(sourceLen). Upon exit, destLen is the actual size of the
+ compressed data.
+
+ compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+ memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+ Z_STREAM_ERROR if the level parameter is invalid.
+*/
+
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
+/*
+ compressBound() returns an upper bound on the compressed size after
+ compress() or compress2() on sourceLen bytes. It would be used before a
+ compress() or compress2() call to allocate the destination buffer.
+*/
+
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed data.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
+ the case where there is not enough room, uncompress() will fill the output
+ buffer with the uncompressed data up to that point.
+*/
+
+ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ Same as uncompress, except that sourceLen is a pointer, where the
+ length of the source is *sourceLen. On return, *sourceLen is the number of
+ source bytes consumed.
+*/
+
+ /* gzip file access functions */
+
+/*
+ This library supports reading and writing files in gzip (.gz) format with
+ an interface similar to that of stdio, using the functions that start with
+ "gz". The gzip format is different from the zlib format. gzip is a gzip
+ wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+ Opens a gzip (.gz) file for reading or writing. The mode parameter is as
+ in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+ a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+ compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+ for fixed code compression as in "wb9F". (See the description of
+ deflateInit2 for more information about the strategy parameter.) 'T' will
+ request transparent writing or appending with no compression and not using
+ the gzip format.
+
+ "a" can be used instead of "w" to request that the gzip stream that will
+ be written be appended to the file. "+" will result in an error, since
+ reading and writing to the same gzip file is not supported. The addition of
+ "x" when writing will create the file exclusively, which fails if the file
+ already exists. On systems that support it, the addition of "e" when
+ reading or writing will set the flag to close the file on an execve() call.
+
+ These functions, as well as gzip, will read and decode a sequence of gzip
+ streams in a file. The append function of gzopen() can be used to create
+ such a file. (Also see gzflush() for another way to do this.) When
+ appending, gzopen does not test whether the file begins with a gzip stream,
+ nor does it look for the end of the gzip streams to begin appending. gzopen
+ will simply append a gzip stream to the existing file.
+
+ gzopen can be used to read a file which is not in gzip format; in this
+ case gzread will directly read from the file without decompression. When
+ reading, this will be detected automatically by looking for the magic two-
+ byte gzip header.
+
+ gzopen returns NULL if the file could not be opened, if there was
+ insufficient memory to allocate the gzFile state, or if an invalid mode was
+ specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+ errno can be checked to determine if the reason gzopen failed was that the
+ file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+ gzdopen associates a gzFile with the file descriptor fd. File descriptors
+ are obtained from calls like open, dup, creat, pipe or fileno (if the file
+ has been previously opened with fopen). The mode parameter is as in gzopen.
+
+ The next call of gzclose on the returned gzFile will also close the file
+ descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+ fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+ mode);. The duplicated descriptor should be saved to avoid a leak, since
+ gzdopen does not close fd if it fails. If you are using fileno() to get the
+ file descriptor from a FILE *, then you will have to use dup() to avoid
+ double-close()ing the file descriptor. Both gzclose() and fclose() will
+ close the associated file descriptor, so they need to have different file
+ descriptors.
+
+ gzdopen returns NULL if there was insufficient memory to allocate the
+ gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+ provided, or '+' was provided), or if fd is -1. The file descriptor is not
+ used until the next gz* read, write, seek, or close operation, so gzdopen
+ will not detect if fd is invalid (unless fd is -1).
+*/
+
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+/*
+ Set the internal buffer size used by this library's functions. The
+ default buffer size is 8192 bytes. This function must be called after
+ gzopen() or gzdopen(), and before any other calls that read or write the
+ file. The buffer memory allocation is always deferred to the first read or
+ write. Three times that size in buffer space is allocated. A larger buffer
+ size of, for example, 64K or 128K bytes will noticeably increase the speed
+ of decompression (reading).
+
+ The new buffer size also affects the maximum length for gzprintf().
+
+ gzbuffer() returns 0 on success, or -1 on failure, such as being called
+ too late.
+*/
+
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+/*
+ Dynamically update the compression level or strategy. See the description
+ of deflateInit2 for the meaning of these parameters. Previously provided
+ data is flushed before the parameter change.
+
+ gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not
+ opened for writing, Z_ERRNO if there is an error writing the flushed data,
+ or Z_MEM_ERROR if there is a memory allocation error.
+*/
+
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+/*
+ Reads the given number of uncompressed bytes from the compressed file. If
+ the input file is not in gzip format, gzread copies the given number of
+ bytes into the buffer directly from the file.
+
+ After reaching the end of a gzip stream in the input, gzread will continue
+ to read, looking for another gzip stream. Any number of gzip streams may be
+ concatenated in the input file, and will all be decompressed by gzread().
+ If something other than a gzip stream is encountered after a gzip stream,
+ that remaining trailing garbage is ignored (and no error is returned).
+
+ gzread can be used to read a gzip file that is being concurrently written.
+ Upon reaching the end of the input, gzread will return with the available
+ data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
+ gzclearerr can be used to clear the end of file indicator in order to permit
+ gzread to be tried again. Z_OK indicates that a gzip stream was completed
+ on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
+ middle of a gzip stream. Note that gzread does not return -1 in the event
+ of an incomplete gzip stream. This error is deferred until gzclose(), which
+ will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
+ stream. Alternatively, gzerror can be used before gzclose to detect this
+ case.
+
+ gzread returns the number of uncompressed bytes actually read, less than
+ len for end of file, or -1 for error. If len is too large to fit in an int,
+ then nothing is read, -1 is returned, and the error state is set to
+ Z_STREAM_ERROR.
+*/
+
+ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
+ gzFile file))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ Read up to nitems items of size size from file to buf, otherwise operating
+ as gzread() does. This duplicates the interface of stdio's fread(), with
+ size_t request and return types. If the library defines size_t, then
+ z_size_t is identical to size_t. If not, then z_size_t is an unsigned
+ integer type that can contain a pointer.
+
+ gzfread() returns the number of full items read of size size, or zero if
+ the end of the file was reached and a full item could not be read, or if
+ there was an error. gzerror() must be consulted if zero is returned in
+ order to determine if there was an error. If the multiplication of size and
+ nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
+ is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
+
+ In the event that the end of file is reached and only a partial item is
+ available at the end, i.e. the remaining uncompressed data length is not a
+ multiple of size, then the final partial item is nevetheless read into buf
+ and the end-of-file flag is set. The length of the partial item read is not
+ provided, but could be inferred from the result of gztell(). This behavior
+ is the same as the behavior of fread() implementations in common libraries,
+ but it prevents the direct use of gzfread() to read a concurrently written
+ file, reseting and retrying on end-of-file, when size is not 1.
+*/
+
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+ voidpc buf, unsigned len));
+/*
+ Writes the given number of uncompressed bytes into the compressed file.
+ gzwrite returns the number of uncompressed bytes written or 0 in case of
+ error.
+*/
+
+ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
+ z_size_t nitems, gzFile file))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ gzfwrite() writes nitems items of size size from buf to file, duplicating
+ the interface of stdio's fwrite(), with size_t request and return types. If
+ the library defines size_t, then z_size_t is identical to size_t. If not,
+ then z_size_t is an unsigned integer type that can contain a pointer.
+
+ gzfwrite() returns the number of full items written of size size, or zero
+ if there was an error. If the multiplication of size and nitems overflows,
+ i.e. the product does not fit in a z_size_t, then nothing is written, zero
+ is returned, and the error state is set to Z_STREAM_ERROR.
+*/
+
+ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
+/*
+ Converts, formats, and writes the arguments to the compressed file under
+ control of the format string, as in fprintf. gzprintf returns the number of
+ uncompressed bytes actually written, or a negative zlib error code in case
+ of error. The number of uncompressed bytes written is limited to 8191, or
+ one less than the buffer size given to gzbuffer(). The caller should assure
+ that this limit is not exceeded. If it is exceeded, then gzprintf() will
+ return an error (0) with nothing written. In this case, there may also be a
+ buffer overflow with unpredictable consequences, which is possible only if
+ zlib was compiled with the insecure functions sprintf() or vsprintf()
+ because the secure snprintf() or vsnprintf() functions were not available.
+ This can be determined using zlibCompileFlags().
+*/
+
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+/*
+ Writes the given null-terminated string to the compressed file, excluding
+ the terminating null character.
+
+ gzputs returns the number of characters written, or -1 in case of error.
+*/
+
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+/*
+ Reads bytes from the compressed file until len-1 characters are read, or a
+ newline character is read and transferred to buf, or an end-of-file
+ condition is encountered. If any characters are read or if len == 1, the
+ string is terminated with a null character. If no characters are read due
+ to an end-of-file or len < 1, then the buffer is left untouched.
+
+ gzgets returns buf which is a null-terminated string, or it returns NULL
+ for end-of-file or in case of error. If there was an error, the contents at
+ buf are indeterminate.
+*/
+
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+/*
+ Writes c, converted to an unsigned char, into the compressed file. gzputc
+ returns the value that was written, or -1 in case of error.
+*/
+
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+/*
+ Reads one byte from the compressed file. gzgetc returns this byte or -1
+ in case of end of file or error. This is implemented as a macro for speed.
+ As such, it does not do all of the checking the other functions do. I.e.
+ it does not check to see if file is NULL, nor whether the structure file
+ points to has been clobbered or not.
+*/
+
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+/*
+ Push one character back onto the stream to be read as the first character
+ on the next read. At least one character of push-back is allowed.
+ gzungetc() returns the character pushed, or -1 on failure. gzungetc() will
+ fail if c is -1, and may fail if a character has been pushed but not read
+ yet. If gzungetc is used immediately after gzopen or gzdopen, at least the
+ output buffer size of pushed characters is allowed. (See gzbuffer above.)
+ The pushed character will be discarded if the stream is repositioned with
+ gzseek() or gzrewind().
+*/
+
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+/*
+ Flushes all pending output into the compressed file. The parameter flush
+ is as in the deflate() function. The return value is the zlib error number
+ (see function gzerror below). gzflush is only permitted when writing.
+
+ If the flush parameter is Z_FINISH, the remaining data is written and the
+ gzip stream is completed in the output. If gzwrite() is called again, a new
+ gzip stream will be started in the output. gzread() is able to read such
+ concatenated gzip streams.
+
+ gzflush should be called only when strictly necessary because it will
+ degrade compression if called too often.
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+ z_off_t offset, int whence));
+
+ Sets the starting position for the next gzread or gzwrite on the given
+ compressed file. The offset represents a number of bytes in the
+ uncompressed data stream. The whence parameter is defined as in lseek(2);
+ the value SEEK_END is not supported.
+
+ If the file is opened for reading, this function is emulated but can be
+ extremely slow. If the file is opened for writing, only forward seeks are
+ supported; gzseek then compresses a sequence of zeroes up to the new
+ starting position.
+
+ gzseek returns the resulting offset location as measured in bytes from
+ the beginning of the uncompressed stream, or -1 in case of error, in
+ particular if the file is opened for writing and the new starting position
+ would be before the current position.
+*/
+
+ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
+/*
+ Rewinds the given file. This function is supported only for reading.
+
+ gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
+
+ Returns the starting position for the next gzread or gzwrite on the given
+ compressed file. This position represents a number of bytes in the
+ uncompressed data stream, and is zero when starting, even if appending or
+ reading a gzip stream from the middle of a file using gzdopen().
+
+ gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
+
+ Returns the current offset in the file being read or written. This offset
+ includes the count of bytes that precede the gzip stream, for example when
+ appending or when using gzdopen() for reading. When reading, the offset
+ does not include as yet unused buffered input. This information can be used
+ for a progress indicator. On error, gzoffset() returns -1.
+*/
+
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+/*
+ Returns true (1) if the end-of-file indicator has been set while reading,
+ false (0) otherwise. Note that the end-of-file indicator is set only if the
+ read tried to go past the end of the input, but came up short. Therefore,
+ just like feof(), gzeof() may return false even if there is no more data to
+ read, in the event that the last read request was for the exact number of
+ bytes remaining in the input file. This will happen if the input file size
+ is an exact multiple of the buffer size.
+
+ If gzeof() returns true, then the read functions will return no more data,
+ unless the end-of-file indicator is reset by gzclearerr() and the input file
+ has grown since the previous end of file was detected.
+*/
+
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
+/*
+ Returns true (1) if file is being copied directly while reading, or false
+ (0) if file is a gzip stream being decompressed.
+
+ If the input file is empty, gzdirect() will return true, since the input
+ does not contain a gzip stream.
+
+ If gzdirect() is used immediately after gzopen() or gzdopen() it will
+ cause buffers to be allocated to allow reading the file to determine if it
+ is a gzip file. Therefore if gzbuffer() is used, it should be called before
+ gzdirect().
+
+ When writing, gzdirect() returns true (1) if transparent writing was
+ requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
+ gzdirect() is not needed when writing. Transparent writing must be
+ explicitly requested, so the application already knows the answer. When
+ linking statically, using gzdirect() will include all of the zlib code for
+ gzip file reading and decompression, which may not be desired.)
+*/
+
+ZEXTERN int ZEXPORT gzclose OF((gzFile file));
+/*
+ Flushes all pending output if necessary, closes the compressed file and
+ deallocates the (de)compression state. Note that once file is closed, you
+ cannot call gzerror with file, since its structures have been deallocated.
+ gzclose must not be called more than once on the same file, just as free
+ must not be called more than once on the same allocation.
+
+ gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+ file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
+ last read ended in the middle of a gzip stream, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+/*
+ Same as gzclose(), but gzclose_r() is only for use when reading, and
+ gzclose_w() is only for use when writing or appending. The advantage to
+ using these instead of gzclose() is that they avoid linking in zlib
+ compression or decompression code that is not used when only reading or only
+ writing respectively. If gzclose() is used, then both compression and
+ decompression code will be included the application when linking to a static
+ zlib library.
+
+ Because Mac OS X doesn't use a static zlib library, these routine are of
+ no value for Mac OS X-only applications, and gzclose() is recommended
+ instead.
+*/
+
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+/*
+ Returns the error message for the last error which occurred on the given
+ compressed file. errnum is set to zlib error number. If an error occurred
+ in the file system and not in the compression library, errnum is set to
+ Z_ERRNO and the application may consult errno to get the exact error code.
+
+ The application must not modify the returned string. Future calls to
+ this function may invalidate the previously returned string. If file is
+ closed, then the string previously returned by gzerror will no longer be
+ available.
+
+ gzerror() should be used to distinguish errors from end-of-file for those
+ functions above that do not distinguish those cases in their return values.
+*/
+
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
+/*
+ Clears the error and end-of-file flags for file. This is analogous to the
+ clearerr() function in stdio. This is useful for continuing to read a gzip
+ file that is being written concurrently.
+*/
+
+#endif /* !Z_SOLO */
+
+ /* checksum functions */
+
+/*
+ These functions are not related to compression but are exported
+ anyway because they might be useful in applications using the compression
+ library.
+*/
+
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+/*
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+ return the updated checksum. If buf is Z_NULL, this function returns the
+ required initial value for the checksum.
+
+ An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed
+ much faster.
+
+ Usage example:
+
+ uLong adler = adler32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ adler = adler32(adler, buffer, length);
+ }
+ if (adler != original_adler) error();
+*/
+
+ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ Same as adler32(), but with a size_t length.
+*/
+
+/*
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
+ z_off_t len2));
+
+ Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
+ and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
+ each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
+ seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
+ that the z_off_t type (like off_t) is a signed integer. If len2 is
+ negative, the result has no meaning or utility.
+*/
+
+ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
+/*
+ Update a running CRC-32 with the bytes buf[0..len-1] and return the
+ updated CRC-32. If buf is Z_NULL, this function returns the required
+ initial value for the crc. Pre- and post-conditioning (one's complement) is
+ performed within this function so it shouldn't be done by the application.
+
+ Usage example:
+
+ uLong crc = crc32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ crc = crc32(crc, buffer, length);
+ }
+ if (crc != original_crc) error();
+*/
+
+ZEXTERN uLong ZEXPORT crc32_z OF((uLong adler, const Bytef *buf,
+ z_size_t len))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+/*
+ Same as crc32(), but with a size_t length.
+*/
+
+/*
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
+ Combine two CRC-32 check values into one. For two sequences of bytes,
+ seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
+ calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
+ check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
+ len2.
+*/
+
+
+ /* various hacks, don't look :) */
+
+/* deflateInit and inflateInit are macros to allow checking the zlib version
+ * and the compiler's view of z_stream:
+ */
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
+ int windowBits, int memLevel,
+ int strategy, const char *version,
+ int stream_size));
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
+ const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+ unsigned char FAR *window,
+ const char *version,
+ int stream_size));
+#ifdef Z_PREFIX_SET
+# define z_deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define z_inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define z_inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#else
+# define deflateInit(strm, level) \
+ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit(strm) \
+ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
+# define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+ (strategy), ZLIB_VERSION, (int)sizeof(z_stream))
+# define inflateInit2(strm, windowBits) \
+ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
+ (int)sizeof(z_stream))
+# define inflateBackInit(strm, windowBits, window) \
+ inflateBackInit_((strm), (windowBits), (window), \
+ ZLIB_VERSION, (int)sizeof(z_stream))
+#endif
+
+#ifndef Z_SOLO
+
+/* gzgetc() macro and its supporting function and exposed data structure. Note
+ * that the real internal state is much larger than the exposed structure.
+ * This abbreviated structure exposes just enough for the gzgetc() macro. The
+ * user should not mess with these exposed elements, since their names or
+ * behavior could change in the future, perhaps even capriciously. They can
+ * only be used by the gzgetc() macro. You have been warned.
+ */
+struct gzFile_s {
+ unsigned have;
+ unsigned char *next;
+ z_off64_t pos;
+};
+ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file))
+ __API_AVAILABLE(macos(10.10),ios(8.0)); /* backward compatibility */
+#ifdef Z_PREFIX_SET
+# undef z_gzgetc
+# define z_gzgetc(g) \
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
+#else
+# define gzgetc(g) \
+ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g))
+#endif
+
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#ifdef Z_LARGE64
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+ ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+
+#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
+# ifdef Z_PREFIX_SET
+# define z_gzopen z_gzopen64
+# define z_gzseek z_gzseek64
+# define z_gztell z_gztell64
+# define z_gzoffset z_gzoffset64
+# define z_adler32_combine z_adler32_combine64
+# define z_crc32_combine z_crc32_combine64
+# else
+# define gzopen gzopen64
+# define gzseek gzseek64
+# define gztell gztell64
+# define gzoffset gzoffset64
+# define adler32_combine adler32_combine64
+# define crc32_combine crc32_combine64
+# endif
+# ifndef Z_LARGE64
+ ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
+ ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+# endif
+#else
+ ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+ ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+#else /* Z_SOLO */
+
+ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+
+#endif /* !Z_SOLO */
+
+/* undocumented functions */
+ZEXTERN const char * ZEXPORT zError OF((int));
+ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
+ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
+ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int))
+ __API_AVAILABLE(macos(10.7),ios(5.0));
+ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF ((z_streamp))
+ __API_AVAILABLE(macos(10.13),ios(11.0));
+ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp))
+ __API_AVAILABLE(macos(10.10),ios(8.0));
+ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp))
+ __API_AVAILABLE(macos(10.10),ios(8.0));
+#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(Z_SOLO)
+ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
+ const char *mode));
+#endif
+#if defined(STDC) || defined(Z_HAVE_STDARG_H)
+# ifndef Z_SOLO
+ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
+ const char *format,
+ va_list va))
+ __API_AVAILABLE(macos(10.10),ios(8.0));
+# endif
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifndef __APPLE__
+#undef __API_AVAILABLE
+#endif /* !__APPLE__ */
+
+#endif /* ZLIB_H */ \ No newline at end of file
diff --git a/lib/libc/include/arc-linux-any/asm/bpf_perf_event.h b/lib/libc/include/arc-linux-any/asm/bpf_perf_event.h
new file mode 100644
index 0000000000..0ca4230753
--- /dev/null
+++ b/lib/libc/include/arc-linux-any/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_BPF_PERF_EVENT_H__
+#define __ASM_BPF_PERF_EVENT_H__
+
+#include <asm/ptrace.h>
+
+typedef struct user_regs_struct bpf_user_pt_regs_t;
+
+#endif /* __ASM_BPF_PERF_EVENT_H__ */ \ No newline at end of file
diff --git a/lib/libc/include/arm-linux-any/asm/hwcap.h b/lib/libc/include/arm-linux-any/asm/hwcap.h
index a66337ae9a..a48502a8ff 100644
--- a/lib/libc/include/arm-linux-any/asm/hwcap.h
+++ b/lib/libc/include/arm-linux-any/asm/hwcap.h
@@ -28,6 +28,12 @@
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
#define HWCAP_LPAE (1 << 20)
#define HWCAP_EVTSTRM (1 << 21)
+#define HWCAP_FPHP (1 << 22)
+#define HWCAP_ASIMDHP (1 << 23)
+#define HWCAP_ASIMDDP (1 << 24)
+#define HWCAP_ASIMDFHM (1 << 25)
+#define HWCAP_ASIMDBF16 (1 << 26)
+#define HWCAP_I8MM (1 << 27)
/*
* HWCAP2 flags - for elf_hwcap2 (in kernel) and AT_HWCAP2
@@ -37,5 +43,7 @@
#define HWCAP2_SHA1 (1 << 2)
#define HWCAP2_SHA2 (1 << 3)
#define HWCAP2_CRC32 (1 << 4)
+#define HWCAP2_SB (1 << 5)
+#define HWCAP2_SSBS (1 << 6)
#endif /* __ASMARM_HWCAP_H */ \ No newline at end of file
diff --git a/lib/libc/include/arm-linux-any/asm/signal.h b/lib/libc/include/arm-linux-any/asm/signal.h
index 57be70449e..48154f1641 100644
--- a/lib/libc/include/arm-linux-any/asm/signal.h
+++ b/lib/libc/include/arm-linux-any/asm/signal.h
@@ -89,7 +89,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
diff --git a/lib/libc/include/arm-linux-any/asm/unistd-eabi.h b/lib/libc/include/arm-linux-any/asm/unistd-eabi.h
index 1a055cb9f4..d62996f063 100644
--- a/lib/libc/include/arm-linux-any/asm/unistd-eabi.h
+++ b/lib/libc/include/arm-linux-any/asm/unistd-eabi.h
@@ -403,5 +403,6 @@
#define __NR_landlock_restrict_self (__NR_SYSCALL_BASE + 446)
#define __NR_process_mrelease (__NR_SYSCALL_BASE + 448)
#define __NR_futex_waitv (__NR_SYSCALL_BASE + 449)
+#define __NR_set_mempolicy_home_node (__NR_SYSCALL_BASE + 450)
#endif /* _ASM_UNISTD_EABI_H */ \ No newline at end of file
diff --git a/lib/libc/include/arm-linux-any/asm/unistd-oabi.h b/lib/libc/include/arm-linux-any/asm/unistd-oabi.h
index 3016fc582d..2f547d0211 100644
--- a/lib/libc/include/arm-linux-any/asm/unistd-oabi.h
+++ b/lib/libc/include/arm-linux-any/asm/unistd-oabi.h
@@ -415,5 +415,6 @@
#define __NR_landlock_restrict_self (__NR_SYSCALL_BASE + 446)
#define __NR_process_mrelease (__NR_SYSCALL_BASE + 448)
#define __NR_futex_waitv (__NR_SYSCALL_BASE + 449)
+#define __NR_set_mempolicy_home_node (__NR_SYSCALL_BASE + 450)
#endif /* _ASM_UNISTD_OABI_H */ \ No newline at end of file
diff --git a/lib/libc/include/generic-glibc/resolv.h b/lib/libc/include/generic-glibc/resolv.h
index 406727e8fb..d0f9955f94 100644
--- a/lib/libc/include/generic-glibc/resolv.h
+++ b/lib/libc/include/generic-glibc/resolv.h
@@ -170,16 +170,20 @@ __END_DECLS
#define res_isourserver __res_isourserver
/* In glibc 2.33 and earlier res_search, res_nsearch, res_query, res_nquery,
- * res_querydomain, res_nquerydomain were #define'd to __res_search,
- * __res_nsearch, etc. glibc 2.34 onwards removes the macros and exposes the
- * symbols directly. New glibc exposes compat symbols with underscores for
- * backwards compatibility. Applications linked to glibc 2.34+ are expected
- * to use the non-underscored symbols.
+ * res_querydomain, res_nquerydomain, dn_skipname, dn_comp, dn_expand were
+ * #define'd to __res_search, __res_nsearch, etc. glibc 2.34 onwards removes
+ * the macros and exposes the symbols directly. New glibc exposes compat
+ * symbols with underscores for backwards compatibility. Applications linked to
+ * glibc 2.34+ are expected to use the non-underscored symbols.
*
- * It will be enough to bring the macros back when compiling against the older
- * glibc versions.
+ * It is enough to bring the macros back when compiling against the older glibc
+ * versions.
*
- * See glibc commit ea9878ec271c791880fcbbe519d70c42f8113750.
+ * See glibc commits:
+ * - ea9878ec271c791880fcbbe519d70c42f8113750 res_*
+ * - 391e02236b931132c0e8b5ba4c3b087c2aaa1044 dn_skipname
+ * - fd8a87c0c1932de591e7ad108ff6288a4b6b18c9 dn_comp
+ * - 640bbdf71c6f10ac26252ac67a22902e26657bd8 dn_expand
*/
#if (__GLIBC__ == 2 && __GLIBC_MINOR__ < 34)
#define res_search __res_search
@@ -188,6 +192,9 @@ __END_DECLS
#define res_nquery __res_nquery
#define res_querydomain __res_querydomain
#define res_nquerydomain __res_nquerydomain
+#define dn_skipname __dn_skipname
+#define dn_comp __dn_comp
+#define dn_expand __dn_expand
#endif
/* end glibc compat hacks */
@@ -327,4 +334,4 @@ void res_nclose (res_state) __THROW;
__END_DECLS
-#endif /* !_RESOLV_H_ */ \ No newline at end of file
+#endif /* !_RESOLV_H_ */
diff --git a/lib/libc/include/loongarch-linux-any/asm/auxvec.h b/lib/libc/include/loongarch-linux-any/asm/auxvec.h
new file mode 100644
index 0000000000..3e4d958b60
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/auxvec.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Author: Hanlu Li <lihanlu@loongson.cn>
+ * Huacai Chen <chenhuacai@loongson.cn>
+ *
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#ifndef __ASM_AUXVEC_H
+#define __ASM_AUXVEC_H
+
+/* Location of VDSO image. */
+#define AT_SYSINFO_EHDR 33
+
+#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */
+
+#endif /* __ASM_AUXVEC_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/bitsperlong.h b/lib/libc/include/loongarch-linux-any/asm/bitsperlong.h
new file mode 100644
index 0000000000..cb01576f45
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/bitsperlong.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_LOONGARCH_BITSPERLONG_H
+#define __ASM_LOONGARCH_BITSPERLONG_H
+
+#define __BITS_PER_LONG (__SIZEOF_LONG__ * 8)
+
+#include <asm-generic/bitsperlong.h>
+
+#endif /* __ASM_LOONGARCH_BITSPERLONG_H */ \ No newline at end of file
diff --git a/lib/libc/include/powerpc-linux-any/asm/bpf_perf_event.h b/lib/libc/include/loongarch-linux-any/asm/bpf_perf_event.h
index 2e8dc3b979..13351cb469 100644
--- a/lib/libc/include/powerpc-linux-any/asm/bpf_perf_event.h
+++ b/lib/libc/include/loongarch-linux-any/asm/bpf_perf_event.h
@@ -2,7 +2,7 @@
#ifndef __ASM_BPF_PERF_EVENT_H__
#define __ASM_BPF_PERF_EVENT_H__
-#include <asm/ptrace.h>
+#include <linux/ptrace.h>
typedef struct user_pt_regs bpf_user_pt_regs_t;
diff --git a/lib/libc/include/loongarch-linux-any/asm/break.h b/lib/libc/include/loongarch-linux-any/asm/break.h
new file mode 100644
index 0000000000..79769a1217
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/break.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+#ifndef __UAPI_ASM_BREAK_H
+#define __UAPI_ASM_BREAK_H
+
+#define BRK_DEFAULT 0 /* Used as default */
+#define BRK_BUG 1 /* Used by BUG() */
+#define BRK_KDB 2 /* Used in KDB_ENTER() */
+#define BRK_MATHEMU 3 /* Used by FPU emulator */
+#define BRK_USERBP 4 /* User bp (used by debuggers) */
+#define BRK_SSTEPBP 5 /* User bp (used by debuggers) */
+#define BRK_OVERFLOW 6 /* Overflow check */
+#define BRK_DIVZERO 7 /* Divide by zero check */
+#define BRK_RANGE 8 /* Range error check */
+#define BRK_MULOVFL 9 /* Multiply overflow */
+#define BRK_KPROBE_BP 10 /* Kprobe break */
+#define BRK_KPROBE_SSTEPBP 11 /* Kprobe single step break */
+#define BRK_UPROBE_BP 12 /* See <asm/uprobes.h> */
+#define BRK_UPROBE_XOLBP 13 /* See <asm/uprobes.h> */
+
+#endif /* __UAPI_ASM_BREAK_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/byteorder.h b/lib/libc/include/loongarch-linux-any/asm/byteorder.h
new file mode 100644
index 0000000000..59a90c2a30
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/byteorder.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Author: Hanlu Li <lihanlu@loongson.cn>
+ * Huacai Chen <chenhuacai@loongson.cn>
+ *
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_BYTEORDER_H
+#define _ASM_BYTEORDER_H
+
+#include <linux/byteorder/little_endian.h>
+
+#endif /* _ASM_BYTEORDER_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/hwcap.h b/lib/libc/include/loongarch-linux-any/asm/hwcap.h
new file mode 100644
index 0000000000..97702ea737
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/hwcap.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_HWCAP_H
+#define _ASM_HWCAP_H
+
+/* HWCAP flags */
+#define HWCAP_LOONGARCH_CPUCFG (1 << 0)
+#define HWCAP_LOONGARCH_LAM (1 << 1)
+#define HWCAP_LOONGARCH_UAL (1 << 2)
+#define HWCAP_LOONGARCH_FPU (1 << 3)
+#define HWCAP_LOONGARCH_LSX (1 << 4)
+#define HWCAP_LOONGARCH_LASX (1 << 5)
+#define HWCAP_LOONGARCH_CRC32 (1 << 6)
+#define HWCAP_LOONGARCH_COMPLEX (1 << 7)
+#define HWCAP_LOONGARCH_CRYPTO (1 << 8)
+#define HWCAP_LOONGARCH_LVZ (1 << 9)
+#define HWCAP_LOONGARCH_LBT_X86 (1 << 10)
+#define HWCAP_LOONGARCH_LBT_ARM (1 << 11)
+#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12)
+
+#endif /* _ASM_HWCAP_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/perf_regs.h b/lib/libc/include/loongarch-linux-any/asm/perf_regs.h
new file mode 100644
index 0000000000..661aa1f698
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/perf_regs.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_LOONGARCH_PERF_REGS_H
+#define _ASM_LOONGARCH_PERF_REGS_H
+
+enum perf_event_loongarch_regs {
+ PERF_REG_LOONGARCH_PC,
+ PERF_REG_LOONGARCH_R1,
+ PERF_REG_LOONGARCH_R2,
+ PERF_REG_LOONGARCH_R3,
+ PERF_REG_LOONGARCH_R4,
+ PERF_REG_LOONGARCH_R5,
+ PERF_REG_LOONGARCH_R6,
+ PERF_REG_LOONGARCH_R7,
+ PERF_REG_LOONGARCH_R8,
+ PERF_REG_LOONGARCH_R9,
+ PERF_REG_LOONGARCH_R10,
+ PERF_REG_LOONGARCH_R11,
+ PERF_REG_LOONGARCH_R12,
+ PERF_REG_LOONGARCH_R13,
+ PERF_REG_LOONGARCH_R14,
+ PERF_REG_LOONGARCH_R15,
+ PERF_REG_LOONGARCH_R16,
+ PERF_REG_LOONGARCH_R17,
+ PERF_REG_LOONGARCH_R18,
+ PERF_REG_LOONGARCH_R19,
+ PERF_REG_LOONGARCH_R20,
+ PERF_REG_LOONGARCH_R21,
+ PERF_REG_LOONGARCH_R22,
+ PERF_REG_LOONGARCH_R23,
+ PERF_REG_LOONGARCH_R24,
+ PERF_REG_LOONGARCH_R25,
+ PERF_REG_LOONGARCH_R26,
+ PERF_REG_LOONGARCH_R27,
+ PERF_REG_LOONGARCH_R28,
+ PERF_REG_LOONGARCH_R29,
+ PERF_REG_LOONGARCH_R30,
+ PERF_REG_LOONGARCH_R31,
+ PERF_REG_LOONGARCH_MAX,
+};
+#endif /* _ASM_LOONGARCH_PERF_REGS_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/ptrace.h b/lib/libc/include/loongarch-linux-any/asm/ptrace.h
new file mode 100644
index 0000000000..726a985ff1
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/ptrace.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Author: Hanlu Li <lihanlu@loongson.cn>
+ * Huacai Chen <chenhuacai@loongson.cn>
+ *
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_PTRACE_H
+#define _ASM_PTRACE_H
+
+#include <linux/types.h>
+
+#include <stdint.h>
+
+/*
+ * For PTRACE_{POKE,PEEK}USR. 0 - 31 are GPRs,
+ * 32 is syscall's original ARG0, 33 is PC, 34 is BADVADDR.
+ */
+#define GPR_BASE 0
+#define GPR_NUM 32
+#define GPR_END (GPR_BASE + GPR_NUM - 1)
+#define ARG0 (GPR_END + 1)
+#define PC (GPR_END + 2)
+#define BADVADDR (GPR_END + 3)
+
+#define NUM_FPU_REGS 32
+
+struct user_pt_regs {
+ /* Main processor registers. */
+ unsigned long regs[32];
+
+ /* Original syscall arg0. */
+ unsigned long orig_a0;
+
+ /* Special CSR registers. */
+ unsigned long csr_era;
+ unsigned long csr_badv;
+ unsigned long reserved[10];
+} __attribute__((aligned(8)));
+
+struct user_fp_state {
+ uint64_t fpr[32];
+ uint64_t fcc;
+ uint32_t fcsr;
+};
+
+struct user_watch_state {
+ uint64_t dbg_info;
+ struct {
+ uint64_t addr;
+ uint64_t mask;
+ uint32_t ctrl;
+ uint32_t pad;
+ } dbg_regs[8];
+};
+
+#define PTRACE_SYSEMU 0x1f
+#define PTRACE_SYSEMU_SINGLESTEP 0x20
+
+#endif /* _ASM_PTRACE_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/reg.h b/lib/libc/include/loongarch-linux-any/asm/reg.h
new file mode 100644
index 0000000000..6560b7559e
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/reg.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Various register offset definitions for debuggers, core file
+ * examiners and whatnot.
+ *
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+
+#ifndef __UAPI_ASM_LOONGARCH_REG_H
+#define __UAPI_ASM_LOONGARCH_REG_H
+
+#define LOONGARCH_EF_R0 0
+#define LOONGARCH_EF_R1 1
+#define LOONGARCH_EF_R2 2
+#define LOONGARCH_EF_R3 3
+#define LOONGARCH_EF_R4 4
+#define LOONGARCH_EF_R5 5
+#define LOONGARCH_EF_R6 6
+#define LOONGARCH_EF_R7 7
+#define LOONGARCH_EF_R8 8
+#define LOONGARCH_EF_R9 9
+#define LOONGARCH_EF_R10 10
+#define LOONGARCH_EF_R11 11
+#define LOONGARCH_EF_R12 12
+#define LOONGARCH_EF_R13 13
+#define LOONGARCH_EF_R14 14
+#define LOONGARCH_EF_R15 15
+#define LOONGARCH_EF_R16 16
+#define LOONGARCH_EF_R17 17
+#define LOONGARCH_EF_R18 18
+#define LOONGARCH_EF_R19 19
+#define LOONGARCH_EF_R20 20
+#define LOONGARCH_EF_R21 21
+#define LOONGARCH_EF_R22 22
+#define LOONGARCH_EF_R23 23
+#define LOONGARCH_EF_R24 24
+#define LOONGARCH_EF_R25 25
+#define LOONGARCH_EF_R26 26
+#define LOONGARCH_EF_R27 27
+#define LOONGARCH_EF_R28 28
+#define LOONGARCH_EF_R29 29
+#define LOONGARCH_EF_R30 30
+#define LOONGARCH_EF_R31 31
+
+/*
+ * Saved special registers
+ */
+#define LOONGARCH_EF_ORIG_A0 32
+#define LOONGARCH_EF_CSR_ERA 33
+#define LOONGARCH_EF_CSR_BADV 34
+#define LOONGARCH_EF_CSR_CRMD 35
+#define LOONGARCH_EF_CSR_PRMD 36
+#define LOONGARCH_EF_CSR_EUEN 37
+#define LOONGARCH_EF_CSR_ECFG 38
+#define LOONGARCH_EF_CSR_ESTAT 39
+
+#define LOONGARCH_EF_SIZE 320 /* size in bytes */
+
+#endif /* __UAPI_ASM_LOONGARCH_REG_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/sigcontext.h b/lib/libc/include/loongarch-linux-any/asm/sigcontext.h
new file mode 100644
index 0000000000..c5134e41ca
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/sigcontext.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Author: Hanlu Li <lihanlu@loongson.cn>
+ * Huacai Chen <chenhuacai@loongson.cn>
+ *
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_SIGCONTEXT_H
+#define _ASM_SIGCONTEXT_H
+
+#include <linux/types.h>
+#include <linux/posix_types.h>
+
+/* FP context was used */
+#define SC_USED_FP (1 << 0)
+/* Address error was due to memory load */
+#define SC_ADDRERR_RD (1 << 30)
+/* Address error was due to memory store */
+#define SC_ADDRERR_WR (1 << 31)
+
+struct sigcontext {
+ __u64 sc_pc;
+ __u64 sc_regs[32];
+ __u32 sc_flags;
+ __u64 sc_extcontext[0] __attribute__((__aligned__(16)));
+};
+
+#define CONTEXT_INFO_ALIGN 16
+struct sctx_info {
+ __u32 magic;
+ __u32 size;
+ __u64 padding; /* padding to 16 bytes */
+};
+
+/* FPU context */
+#define FPU_CTX_MAGIC 0x46505501
+#define FPU_CTX_ALIGN 8
+struct fpu_context {
+ __u64 regs[32];
+ __u64 fcc;
+ __u32 fcsr;
+};
+
+#endif /* _ASM_SIGCONTEXT_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/signal.h b/lib/libc/include/loongarch-linux-any/asm/signal.h
new file mode 100644
index 0000000000..844fe675ab
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/signal.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
+ */
+#ifndef _ASM_SIGNAL_H
+#define _ASM_SIGNAL_H
+
+#define MINSIGSTKSZ 4096
+#define SIGSTKSZ 16384
+
+#include <asm-generic/signal.h>
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/ucontext.h b/lib/libc/include/loongarch-linux-any/asm/ucontext.h
new file mode 100644
index 0000000000..4ef1fbe22b
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/ucontext.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __LOONGARCH_UAPI_ASM_UCONTEXT_H
+#define __LOONGARCH_UAPI_ASM_UCONTEXT_H
+
+/**
+ * struct ucontext - user context structure
+ * @uc_flags:
+ * @uc_link:
+ * @uc_stack:
+ * @uc_mcontext: holds basic processor state
+ * @uc_sigmask:
+ * @uc_extcontext: holds extended processor state
+ */
+struct ucontext {
+ unsigned long uc_flags;
+ struct ucontext *uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ /* There's some padding here to allow sigset_t to be expanded in the
+ * future. Though this is unlikely, other architectures put uc_sigmask
+ * at the end of this structure and explicitly state it can be
+ * expanded, so we didn't want to box ourselves in here. */
+ __u8 __unused[1024 / 8 - sizeof(sigset_t)];
+ /* We can't put uc_sigmask at the end of this structure because we need
+ * to be able to expand sigcontext in the future. For example, the
+ * vector ISA extension will almost certainly add ISA state. We want
+ * to ensure all user-visible ISA state can be saved and restored via a
+ * ucontext, so we're putting this at the end in order to allow for
+ * infinite extensibility. Since we know this will be extended and we
+ * assume sigset_t won't be extended an extreme amount, we're
+ * prioritizing this. */
+ struct sigcontext uc_mcontext;
+};
+
+#endif /* __LOONGARCH_UAPI_ASM_UCONTEXT_H */ \ No newline at end of file
diff --git a/lib/libc/include/loongarch-linux-any/asm/unistd.h b/lib/libc/include/loongarch-linux-any/asm/unistd.h
new file mode 100644
index 0000000000..2e8b5dc83c
--- /dev/null
+++ b/lib/libc/include/loongarch-linux-any/asm/unistd.h
@@ -0,0 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_CLONE3
+
+#include <asm-generic/unistd.h> \ No newline at end of file
diff --git a/lib/libc/include/m68k-linux-any/asm/bootinfo-virt.h b/lib/libc/include/m68k-linux-any/asm/bootinfo-virt.h
new file mode 100644
index 0000000000..ddaf450244
--- /dev/null
+++ b/lib/libc/include/m68k-linux-any/asm/bootinfo-virt.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * asm/bootinfo-virt.h -- Virtual-m68k-specific boot information definitions
+ */
+
+#ifndef _ASM_M68K_BOOTINFO_VIRT_H
+#define _ASM_M68K_BOOTINFO_VIRT_H
+
+#define BI_VIRT_QEMU_VERSION 0x8000
+#define BI_VIRT_GF_PIC_BASE 0x8001
+#define BI_VIRT_GF_RTC_BASE 0x8002
+#define BI_VIRT_GF_TTY_BASE 0x8003
+#define BI_VIRT_VIRTIO_BASE 0x8004
+#define BI_VIRT_CTRL_BASE 0x8005
+
+/* No longer used -- replaced with BI_RNG_SEED -- but don't reuse this index:
+ * #define BI_VIRT_RNG_SEED 0x8006 */
+
+#define VIRT_BOOTI_VERSION MK_BI_VERSION(2, 0)
+
+#endif /* _ASM_M68K_BOOTINFO_MAC_H */ \ No newline at end of file
diff --git a/lib/libc/include/m68k-linux-any/asm/bootinfo.h b/lib/libc/include/m68k-linux-any/asm/bootinfo.h
index 126e1c51e2..ae68806f9e 100644
--- a/lib/libc/include/m68k-linux-any/asm/bootinfo.h
+++ b/lib/libc/include/m68k-linux-any/asm/bootinfo.h
@@ -34,7 +34,7 @@
struct bi_record {
__be16 tag; /* tag ID */
__be16 size; /* size of record (in bytes) */
- __be32 data[0]; /* data */
+ __be32 data[]; /* data */
};
@@ -64,6 +64,13 @@ struct mem_info {
/* (struct mem_info) */
#define BI_COMMAND_LINE 0x0007 /* kernel command line parameters */
/* (string) */
+/*
+ * A random seed used to initialize the RNG. Record format:
+ *
+ * - length [ 2 bytes, 16-bit big endian ]
+ * - seed data [ `length` bytes, padded to preserve 4-byte struct alignment ]
+ */
+#define BI_RNG_SEED 0x0008
/*
@@ -83,6 +90,7 @@ struct mem_info {
#define MACH_SUN3X 11
#define MACH_M54XX 12
#define MACH_M5441X 13
+#define MACH_VIRT 14
/*
@@ -167,7 +175,7 @@ struct bootversion {
struct {
__be32 machtype;
__be32 version;
- } machversions[0];
+ } machversions[];
} __attribute__((packed));
#endif /* __ASSEMBLY__ */
diff --git a/lib/libc/include/m68k-linux-any/asm/ptrace.h b/lib/libc/include/m68k-linux-any/asm/ptrace.h
index e27cb6575d..6fda18bc1b 100644
--- a/lib/libc/include/m68k-linux-any/asm/ptrace.h
+++ b/lib/libc/include/m68k-linux-any/asm/ptrace.h
@@ -74,7 +74,12 @@ struct switch_stack {
#define PTRACE_GET_THREAD_AREA 25
+#define PTRACE_GETFDPIC 31
+
#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */
+#define PTRACE_GETFDPIC_EXEC 0
+#define PTRACE_GETFDPIC_INTERP 1
+
#endif /* __ASSEMBLY__ */
#endif /* _M68K_PTRACE_H */ \ No newline at end of file
diff --git a/lib/libc/include/m68k-linux-any/asm/signal.h b/lib/libc/include/m68k-linux-any/asm/signal.h
index 52413acb4f..f55ac3189e 100644
--- a/lib/libc/include/m68k-linux-any/asm/signal.h
+++ b/lib/libc/include/m68k-linux-any/asm/signal.h
@@ -79,7 +79,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
#endif /* _M68K_SIGNAL_H */ \ No newline at end of file
diff --git a/lib/libc/include/m68k-linux-any/asm/unistd_32.h b/lib/libc/include/m68k-linux-any/asm/unistd_32.h
index 21404d7be1..fbf935125b 100644
--- a/lib/libc/include/m68k-linux-any/asm/unistd_32.h
+++ b/lib/libc/include/m68k-linux-any/asm/unistd_32.h
@@ -422,6 +422,7 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/include/mips-linux-any/asm/fcntl.h b/lib/libc/include/mips-linux-any/asm/fcntl.h
index 39195b19b9..e20d6a1081 100644
--- a/lib/libc/include/mips-linux-any/asm/fcntl.h
+++ b/lib/libc/include/mips-linux-any/asm/fcntl.h
@@ -44,36 +44,16 @@
#define F_SETOWN 24 /* for sockets. */
#define F_GETOWN 23 /* for sockets. */
-#ifndef __mips64
+#if __BITS_PER_LONG == 32 || defined(__KERNEL__)
#define F_GETLK64 33 /* using 'struct flock64' */
#define F_SETLK64 34
#define F_SETLKW64 35
-#endif
-
-/*
- * The flavours of struct flock. "struct flock" is the ABI compliant
- * variant. Finally struct flock64 is the LFS variant of struct flock. As
- * a historic accident and inconsistence with the ABI definition it doesn't
- * contain all the same fields as struct flock.
- */
+#endif /* __BITS_PER_LONG == 32 || defined(__KERNEL__) */
#if _MIPS_SIM != _MIPS_SIM_ABI64
-
-#include <linux/types.h>
-
-struct flock {
- short l_type;
- short l_whence;
- __kernel_off_t l_start;
- __kernel_off_t l_len;
- long l_sysid;
- __kernel_pid_t l_pid;
- long pad[4];
-};
-
-#define HAVE_ARCH_STRUCT_FLOCK
-
-#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
+#define __ARCH_FLOCK_EXTRA_SYSID long l_sysid;
+#define __ARCH_FLOCK_PAD long pad[4];
+#endif
#include <asm-generic/fcntl.h>
diff --git a/lib/libc/include/mips-linux-any/asm/mman.h b/lib/libc/include/mips-linux-any/asm/mman.h
index aad31b1531..63bd928320 100644
--- a/lib/libc/include/mips-linux-any/asm/mman.h
+++ b/lib/libc/include/mips-linux-any/asm/mman.h
@@ -101,6 +101,10 @@
#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */
#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */
+#define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
+
+#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
+
/* compatibility flags */
#define MAP_FILE 0
diff --git a/lib/libc/include/mips-linux-any/asm/shmbuf.h b/lib/libc/include/mips-linux-any/asm/shmbuf.h
index 2759840c68..4078d51c7d 100644
--- a/lib/libc/include/mips-linux-any/asm/shmbuf.h
+++ b/lib/libc/include/mips-linux-any/asm/shmbuf.h
@@ -2,6 +2,9 @@
#ifndef _ASM_SHMBUF_H
#define _ASM_SHMBUF_H
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
+
/*
* The shmid64_ds structure for the MIPS architecture.
* Note extra padding because this structure is passed back and forth
@@ -16,7 +19,7 @@
#ifdef __mips64
struct shmid64_ds {
struct ipc64_perm shm_perm; /* operation perms */
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
long shm_atime; /* last attach time */
long shm_dtime; /* last detach time */
long shm_ctime; /* last change time */
@@ -29,7 +32,7 @@ struct shmid64_ds {
#else
struct shmid64_ds {
struct ipc64_perm shm_perm; /* operation perms */
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
unsigned long shm_atime; /* last attach time */
unsigned long shm_dtime; /* last detach time */
unsigned long shm_ctime; /* last change time */
diff --git a/lib/libc/include/mips-linux-any/asm/signal.h b/lib/libc/include/mips-linux-any/asm/signal.h
index fc106e5a7d..bb11adb3e9 100644
--- a/lib/libc/include/mips-linux-any/asm/signal.h
+++ b/lib/libc/include/mips-linux-any/asm/signal.h
@@ -98,7 +98,7 @@ struct sigaction {
/* IRIX compatible stack_t */
typedef struct sigaltstack {
void *ss_sp;
- size_t ss_size;
+ __kernel_size_t ss_size;
int ss_flags;
} stack_t;
diff --git a/lib/libc/include/mips-linux-any/asm/socket.h b/lib/libc/include/mips-linux-any/asm/socket.h
index 777774ffca..e5cf024aa5 100644
--- a/lib/libc/include/mips-linux-any/asm/socket.h
+++ b/lib/libc/include/mips-linux-any/asm/socket.h
@@ -144,6 +144,10 @@
#define SO_RESERVE_MEM 73
+#define SO_TXREHASH 74
+
+#define SO_RCVMARK 75
+
#if __BITS_PER_LONG == 64
#define SO_TIMESTAMP SO_TIMESTAMP_OLD
diff --git a/lib/libc/include/mips-linux-any/asm/stat.h b/lib/libc/include/mips-linux-any/asm/stat.h
index 27edfc5e74..544a542e87 100644
--- a/lib/libc/include/mips-linux-any/asm/stat.h
+++ b/lib/libc/include/mips-linux-any/asm/stat.h
@@ -19,11 +19,11 @@
struct stat {
unsigned st_dev;
long st_pad1[3]; /* Reserved for network id */
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid32_t st_uid;
+ __kernel_gid32_t st_gid;
unsigned st_rdev;
long st_pad2[2];
long st_size;
@@ -55,11 +55,11 @@ struct stat64 {
unsigned long long st_ino;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid32_t st_uid;
+ __kernel_gid32_t st_gid;
unsigned long st_rdev;
unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
@@ -96,11 +96,11 @@ struct stat {
unsigned long st_ino;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
__u32 st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid32_t st_uid;
+ __kernel_gid32_t st_gid;
unsigned int st_rdev;
unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
diff --git a/lib/libc/include/mips-linux-any/asm/termbits.h b/lib/libc/include/mips-linux-any/asm/termbits.h
index 088cb4959f..177ac4b899 100644
--- a/lib/libc/include/mips-linux-any/asm/termbits.h
+++ b/lib/libc/include/mips-linux-any/asm/termbits.h
@@ -11,11 +11,9 @@
#ifndef _ASM_TERMBITS_H
#define _ASM_TERMBITS_H
-#include <linux/posix_types.h>
+#include <asm-generic/termbits-common.h>
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
-typedef unsigned int tcflag_t;
+typedef unsigned int tcflag_t;
/*
* The ABI says nothing about NCC but seems to use NCCS as
@@ -54,175 +52,126 @@ struct ktermios {
};
/* c_cc characters */
-#define VINTR 0 /* Interrupt character [ISIG]. */
-#define VQUIT 1 /* Quit character [ISIG]. */
-#define VERASE 2 /* Erase character [ICANON]. */
-#define VKILL 3 /* Kill-line character [ICANON]. */
-#define VMIN 4 /* Minimum number of bytes read at once [!ICANON]. */
-#define VTIME 5 /* Time-out value (tenths of a second) [!ICANON]. */
-#define VEOL2 6 /* Second EOL character [ICANON]. */
+#define VINTR 0 /* Interrupt character [ISIG] */
+#define VQUIT 1 /* Quit character [ISIG] */
+#define VERASE 2 /* Erase character [ICANON] */
+#define VKILL 3 /* Kill-line character [ICANON] */
+#define VMIN 4 /* Minimum number of bytes read at once [!ICANON] */
+#define VTIME 5 /* Time-out value (tenths of a second) [!ICANON] */
+#define VEOL2 6 /* Second EOL character [ICANON] */
#define VSWTC 7 /* ??? */
#define VSWTCH VSWTC
-#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF]. */
-#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF]. */
-#define VSUSP 10 /* Suspend character [ISIG]. */
+#define VSTART 8 /* Start (X-ON) character [IXON, IXOFF] */
+#define VSTOP 9 /* Stop (X-OFF) character [IXON, IXOFF] */
+#define VSUSP 10 /* Suspend character [ISIG] */
#if 0
/*
* VDSUSP is not supported
*/
-#define VDSUSP 11 /* Delayed suspend character [ISIG]. */
+#define VDSUSP 11 /* Delayed suspend character [ISIG] */
#endif
-#define VREPRINT 12 /* Reprint-line character [ICANON]. */
-#define VDISCARD 13 /* Discard character [IEXTEN]. */
-#define VWERASE 14 /* Word-erase character [ICANON]. */
-#define VLNEXT 15 /* Literal-next character [IEXTEN]. */
-#define VEOF 16 /* End-of-file character [ICANON]. */
-#define VEOL 17 /* End-of-line character [ICANON]. */
+#define VREPRINT 12 /* Reprint-line character [ICANON] */
+#define VDISCARD 13 /* Discard character [IEXTEN] */
+#define VWERASE 14 /* Word-erase character [ICANON] */
+#define VLNEXT 15 /* Literal-next character [IEXTEN] */
+#define VEOF 16 /* End-of-file character [ICANON] */
+#define VEOL 17 /* End-of-line character [ICANON] */
/* c_iflag bits */
-#define IGNBRK 0000001 /* Ignore break condition. */
-#define BRKINT 0000002 /* Signal interrupt on break. */
-#define IGNPAR 0000004 /* Ignore characters with parity errors. */
-#define PARMRK 0000010 /* Mark parity and framing errors. */
-#define INPCK 0000020 /* Enable input parity check. */
-#define ISTRIP 0000040 /* Strip 8th bit off characters. */
-#define INLCR 0000100 /* Map NL to CR on input. */
-#define IGNCR 0000200 /* Ignore CR. */
-#define ICRNL 0000400 /* Map CR to NL on input. */
-#define IUCLC 0001000 /* Map upper case to lower case on input. */
-#define IXON 0002000 /* Enable start/stop output control. */
-#define IXANY 0004000 /* Any character will restart after stop. */
-#define IXOFF 0010000 /* Enable start/stop input control. */
-#define IMAXBEL 0020000 /* Ring bell when input queue is full. */
-#define IUTF8 0040000 /* Input is UTF-8 */
+#define IUCLC 0x0200 /* Map upper case to lower case on input */
+#define IXON 0x0400 /* Enable start/stop output control */
+#define IXOFF 0x1000 /* Enable start/stop input control */
+#define IMAXBEL 0x2000 /* Ring bell when input queue is full */
+#define IUTF8 0x4000 /* Input is UTF-8 */
/* c_oflag bits */
-#define OPOST 0000001 /* Perform output processing. */
-#define OLCUC 0000002 /* Map lower case to upper case on output. */
-#define ONLCR 0000004 /* Map NL to CR-NL on output. */
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-#define OFILL 0000100
-#define OFDEL 0000200
-#define NLDLY 0000400
-#define NL0 0000000
-#define NL1 0000400
-#define CRDLY 0003000
-#define CR0 0000000
-#define CR1 0001000
-#define CR2 0002000
-#define CR3 0003000
-#define TABDLY 0014000
-#define TAB0 0000000
-#define TAB1 0004000
-#define TAB2 0010000
-#define TAB3 0014000
-#define XTABS 0014000
-#define BSDLY 0020000
-#define BS0 0000000
-#define BS1 0020000
-#define VTDLY 0040000
-#define VT0 0000000
-#define VT1 0040000
-#define FFDLY 0100000
-#define FF0 0000000
-#define FF1 0100000
+#define OLCUC 0x00002 /* Map lower case to upper case on output */
+#define ONLCR 0x00004 /* Map NL to CR-NL on output */
+#define NLDLY 0x00100
+#define NL0 0x00000
+#define NL1 0x00100
+#define CRDLY 0x00600
+#define CR0 0x00000
+#define CR1 0x00200
+#define CR2 0x00400
+#define CR3 0x00600
+#define TABDLY 0x01800
+#define TAB0 0x00000
+#define TAB1 0x00800
+#define TAB2 0x01000
+#define TAB3 0x01800
+#define XTABS 0x01800
+#define BSDLY 0x02000
+#define BS0 0x00000
+#define BS1 0x02000
+#define VTDLY 0x04000
+#define VT0 0x00000
+#define VT1 0x04000
+#define FFDLY 0x08000
+#define FF0 0x00000
+#define FF1 0x08000
/*
#define PAGEOUT ???
#define WRAP ???
*/
/* c_cflag bit meaning */
-#define CBAUD 0010017
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0000060 /* Number of bits per byte (mask). */
-#define CS5 0000000 /* 5 bits per byte. */
-#define CS6 0000020 /* 6 bits per byte. */
-#define CS7 0000040 /* 7 bits per byte. */
-#define CS8 0000060 /* 8 bits per byte. */
-#define CSTOPB 0000100 /* Two stop bits instead of one. */
-#define CREAD 0000200 /* Enable receiver. */
-#define PARENB 0000400 /* Parity enable. */
-#define PARODD 0001000 /* Odd parity instead of even. */
-#define HUPCL 0002000 /* Hang up on last close. */
-#define CLOCAL 0004000 /* Ignore modem status lines. */
-#define CBAUDEX 0010000
-#define BOTHER 0010000
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-#define CIBAUD 002003600000 /* input baud rate */
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
+#define CBAUD 0x0000100f
+#define CSIZE 0x00000030 /* Number of bits per byte (mask) */
+#define CS5 0x00000000 /* 5 bits per byte */
+#define CS6 0x00000010 /* 6 bits per byte */
+#define CS7 0x00000020 /* 7 bits per byte */
+#define CS8 0x00000030 /* 8 bits per byte */
+#define CSTOPB 0x00000040 /* Two stop bits instead of one */
+#define CREAD 0x00000080 /* Enable receiver */
+#define PARENB 0x00000100 /* Parity enable */
+#define PARODD 0x00000200 /* Odd parity instead of even */
+#define HUPCL 0x00000400 /* Hang up on last close */
+#define CLOCAL 0x00000800 /* Ignore modem status lines */
+#define CBAUDEX 0x00001000
+#define BOTHER 0x00001000
+#define B57600 0x00001001
+#define B115200 0x00001002
+#define B230400 0x00001003
+#define B460800 0x00001004
+#define B500000 0x00001005
+#define B576000 0x00001006
+#define B921600 0x00001007
+#define B1000000 0x00001008
+#define B1152000 0x00001009
+#define B1500000 0x0000100a
+#define B2000000 0x0000100b
+#define B2500000 0x0000100c
+#define B3000000 0x0000100d
+#define B3500000 0x0000100e
+#define B4000000 0x0000100f
+#define CIBAUD 0x100f0000 /* input baud rate */
/* c_lflag bits */
-#define ISIG 0000001 /* Enable signals. */
-#define ICANON 0000002 /* Do erase and kill processing. */
-#define XCASE 0000004
-#define ECHO 0000010 /* Enable echo. */
-#define ECHOE 0000020 /* Visual erase for ERASE. */
-#define ECHOK 0000040 /* Echo NL after KILL. */
-#define ECHONL 0000100 /* Echo NL even if ECHO is off. */
-#define NOFLSH 0000200 /* Disable flush after interrupt. */
-#define IEXTEN 0000400 /* Enable DISCARD and LNEXT. */
-#define ECHOCTL 0001000 /* Echo control characters as ^X. */
-#define ECHOPRT 0002000 /* Hardcopy visual erase. */
-#define ECHOKE 0004000 /* Visual erase for KILL. */
-#define FLUSHO 0020000
-#define PENDIN 0040000 /* Retype pending input (state). */
-#define TOSTOP 0100000 /* Send SIGTTOU for background output. */
-#define ITOSTOP TOSTOP
-#define EXTPROC 0200000 /* External processing on pty */
+#define ISIG 0x00001 /* Enable signals */
+#define ICANON 0x00002 /* Do erase and kill processing */
+#define XCASE 0x00004
+#define ECHO 0x00008 /* Enable echo */
+#define ECHOE 0x00010 /* Visual erase for ERASE */
+#define ECHOK 0x00020 /* Echo NL after KILL */
+#define ECHONL 0x00040 /* Echo NL even if ECHO is off */
+#define NOFLSH 0x00080 /* Disable flush after interrupt */
+#define IEXTEN 0x00100 /* Enable DISCARD and LNEXT */
+#define ECHOCTL 0x00200 /* Echo control characters as ^X */
+#define ECHOPRT 0x00400 /* Hardcopy visual erase */
+#define ECHOKE 0x00800 /* Visual erase for KILL */
+#define FLUSHO 0x02000
+#define PENDIN 0x04000 /* Retype pending input (state) */
+#define TOSTOP 0x08000 /* Send SIGTTOU for background output */
+#define ITOSTOP TOSTOP
+#define EXTPROC 0x10000 /* External processing on pty */
/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0 /* Suspend output. */
-#define TCOON 1 /* Restart suspended output. */
-#define TCIOFF 2 /* Send a STOP character. */
-#define TCION 3 /* Send a START character. */
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0 /* Discard data received but not yet read. */
-#define TCOFLUSH 1 /* Discard data written but not yet sent. */
-#define TCIOFLUSH 2 /* Discard all pending data. */
-
/* tcsetattr uses these */
-#define TCSANOW TCSETS /* Change immediately. */
-#define TCSADRAIN TCSETSW /* Change when pending output is written. */
-#define TCSAFLUSH TCSETSF /* Flush pending input before changing. */
+#define TCSANOW TCSETS /* Change immediately */
+#define TCSADRAIN TCSETSW /* Change when pending output is written */
+#define TCSAFLUSH TCSETSF /* Flush pending input before changing */
#endif /* _ASM_TERMBITS_H */ \ No newline at end of file
diff --git a/lib/libc/include/mips-linux-any/asm/ucontext.h b/lib/libc/include/mips-linux-any/asm/ucontext.h
index 1cee85f0c7..b48ae92977 100644
--- a/lib/libc/include/mips-linux-any/asm/ucontext.h
+++ b/lib/libc/include/mips-linux-any/asm/ucontext.h
@@ -60,7 +60,7 @@ struct ucontext {
sigset_t uc_sigmask;
/* Extended context structures may follow ucontext */
- unsigned long long uc_extcontext[0];
+ unsigned long long uc_extcontext[];
};
#endif /* __MIPS_UAPI_ASM_UCONTEXT_H */ \ No newline at end of file
diff --git a/lib/libc/include/mips-linux-any/asm/unistd_n32.h b/lib/libc/include/mips-linux-any/asm/unistd_n32.h
index cab1f6ed69..24ede5a185 100644
--- a/lib/libc/include/mips-linux-any/asm/unistd_n32.h
+++ b/lib/libc/include/mips-linux-any/asm/unistd_n32.h
@@ -378,5 +378,6 @@
#define __NR_landlock_restrict_self (__NR_Linux + 446)
#define __NR_process_mrelease (__NR_Linux + 448)
#define __NR_futex_waitv (__NR_Linux + 449)
+#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
#endif /* _ASM_UNISTD_N32_H */ \ No newline at end of file
diff --git a/lib/libc/include/mips-linux-any/asm/unistd_n64.h b/lib/libc/include/mips-linux-any/asm/unistd_n64.h
index 5c6d2bbf01..35eaf9ca6c 100644
--- a/lib/libc/include/mips-linux-any/asm/unistd_n64.h
+++ b/lib/libc/include/mips-linux-any/asm/unistd_n64.h
@@ -354,5 +354,6 @@
#define __NR_landlock_restrict_self (__NR_Linux + 446)
#define __NR_process_mrelease (__NR_Linux + 448)
#define __NR_futex_waitv (__NR_Linux + 449)
+#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
#endif /* _ASM_UNISTD_N64_H */ \ No newline at end of file
diff --git a/lib/libc/include/mips-linux-any/asm/unistd_o32.h b/lib/libc/include/mips-linux-any/asm/unistd_o32.h
index 790c9f2c3d..8a4aa5b544 100644
--- a/lib/libc/include/mips-linux-any/asm/unistd_o32.h
+++ b/lib/libc/include/mips-linux-any/asm/unistd_o32.h
@@ -424,5 +424,6 @@
#define __NR_landlock_restrict_self (__NR_Linux + 446)
#define __NR_process_mrelease (__NR_Linux + 448)
#define __NR_futex_waitv (__NR_Linux + 449)
+#define __NR_set_mempolicy_home_node (__NR_Linux + 450)
#endif /* _ASM_UNISTD_O32_H */ \ No newline at end of file
diff --git a/lib/libc/include/powerpc-linux-any/asm/auxvec.h b/lib/libc/include/powerpc-linux-any/asm/auxvec.h
index 692cfa2ddf..668dcedf89 100644
--- a/lib/libc/include/powerpc-linux-any/asm/auxvec.h
+++ b/lib/libc/include/powerpc-linux-any/asm/auxvec.h
@@ -48,6 +48,8 @@
#define AT_L3_CACHESIZE 46
#define AT_L3_CACHEGEOMETRY 47
-#define AT_VECTOR_SIZE_ARCH 14 /* entries in ARCH_DLINFO */
+#define AT_MINSIGSTKSZ 51 /* stack needed for signal delivery */
+
+#define AT_VECTOR_SIZE_ARCH 15 /* entries in ARCH_DLINFO */
#endif \ No newline at end of file
diff --git a/lib/libc/include/powerpc-linux-any/asm/elf.h b/lib/libc/include/powerpc-linux-any/asm/elf.h
index fd09043d5c..82b3f0b6cf 100644
--- a/lib/libc/include/powerpc-linux-any/asm/elf.h
+++ b/lib/libc/include/powerpc-linux-any/asm/elf.h
@@ -289,12 +289,4 @@ typedef elf_fpreg_t elf_vsrreghalf_t32[ELF_NVSRHALFREG];
/* Keep this the last entry. */
#define R_PPC64_NUM 253
-/* There's actually a third entry here, but it's unused */
-struct ppc64_opd_entry
-{
- unsigned long funcaddr;
- unsigned long r2;
-};
-
-
#endif /* _ASM_POWERPC_ELF_H */ \ No newline at end of file
diff --git a/lib/libc/include/powerpc-linux-any/asm/papr_pdsm.h b/lib/libc/include/powerpc-linux-any/asm/papr_pdsm.h
index ffaa110fe1..76afe27d5d 100644
--- a/lib/libc/include/powerpc-linux-any/asm/papr_pdsm.h
+++ b/lib/libc/include/powerpc-linux-any/asm/papr_pdsm.h
@@ -116,6 +116,22 @@ struct nd_papr_pdsm_health {
};
};
+/* Flags for injecting specific smart errors */
+#define PDSM_SMART_INJECT_HEALTH_FATAL (1 << 0)
+#define PDSM_SMART_INJECT_BAD_SHUTDOWN (1 << 1)
+
+struct nd_papr_pdsm_smart_inject {
+ union {
+ struct {
+ /* One or more of PDSM_SMART_INJECT_ */
+ __u32 flags;
+ __u8 fatal_enable;
+ __u8 unsafe_shutdown_enable;
+ };
+ __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
+ };
+};
+
/*
* Methods to be embedded in ND_CMD_CALL request. These are sent to the kernel
* via 'nd_cmd_pkg.nd_command' member of the ioctl struct
@@ -123,12 +139,14 @@ struct nd_papr_pdsm_health {
enum papr_pdsm {
PAPR_PDSM_MIN = 0x0,
PAPR_PDSM_HEALTH,
+ PAPR_PDSM_SMART_INJECT,
PAPR_PDSM_MAX,
};
/* Maximal union that can hold all possible payload types */
union nd_pdsm_payload {
struct nd_papr_pdsm_health health;
+ struct nd_papr_pdsm_smart_inject smart_inject;
__u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
} __attribute__((packed));
diff --git a/lib/libc/include/powerpc-linux-any/asm/shmbuf.h b/lib/libc/include/powerpc-linux-any/asm/shmbuf.h
index fa7cd9fb63..0c290c3281 100644
--- a/lib/libc/include/powerpc-linux-any/asm/shmbuf.h
+++ b/lib/libc/include/powerpc-linux-any/asm/shmbuf.h
@@ -2,6 +2,9 @@
#ifndef _ASM_POWERPC_SHMBUF_H
#define _ASM_POWERPC_SHMBUF_H
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
+
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -34,7 +37,7 @@ struct shmid64_ds {
unsigned long shm_ctime; /* last change time */
unsigned long __unused4;
#endif
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
__kernel_pid_t shm_cpid; /* pid of creator */
__kernel_pid_t shm_lpid; /* pid of last operator */
unsigned long shm_nattch; /* no. of current attaches */
diff --git a/lib/libc/include/powerpc-linux-any/asm/signal.h b/lib/libc/include/powerpc-linux-any/asm/signal.h
index 63f252dd8d..f0b0a8e5d5 100644
--- a/lib/libc/include/powerpc-linux-any/asm/signal.h
+++ b/lib/libc/include/powerpc-linux-any/asm/signal.h
@@ -62,8 +62,13 @@ typedef struct {
#define SA_RESTORER 0x04000000U
+#ifdef __powerpc64__
+#define MINSIGSTKSZ 8192
+#define SIGSTKSZ 32768
+#else
#define MINSIGSTKSZ 2048
#define SIGSTKSZ 8192
+#endif
#include <asm-generic/signal-defs.h>
@@ -84,7 +89,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
diff --git a/lib/libc/include/powerpc-linux-any/asm/stat.h b/lib/libc/include/powerpc-linux-any/asm/stat.h
index 56f5bb4aaa..142f4df929 100644
--- a/lib/libc/include/powerpc-linux-any/asm/stat.h
+++ b/lib/libc/include/powerpc-linux-any/asm/stat.h
@@ -29,16 +29,16 @@ struct __old_kernel_stat {
struct stat {
unsigned long st_dev;
- ino_t st_ino;
+ __kernel_ino_t st_ino;
#ifdef __powerpc64__
unsigned long st_nlink;
- mode_t st_mode;
+ __kernel_mode_t st_mode;
#else
- mode_t st_mode;
+ __kernel_mode_t st_mode;
unsigned short st_nlink;
#endif
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid32_t st_uid;
+ __kernel_gid32_t st_gid;
unsigned long st_rdev;
long st_size;
unsigned long st_blksize;
diff --git a/lib/libc/include/powerpc-linux-any/asm/termbits.h b/lib/libc/include/powerpc-linux-any/asm/termbits.h
index 1ccc258b06..0e36b0648a 100644
--- a/lib/libc/include/powerpc-linux-any/asm/termbits.h
+++ b/lib/libc/include/powerpc-linux-any/asm/termbits.h
@@ -9,8 +9,8 @@
* 2 of the License, or (at your option) any later version.
*/
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
+#include <asm-generic/termbits-common.h>
+
typedef unsigned int tcflag_t;
/*
@@ -64,115 +64,72 @@ struct ktermios {
#define VDISCARD 16
/* c_iflag bits */
-#define IGNBRK 0000001
-#define BRKINT 0000002
-#define IGNPAR 0000004
-#define PARMRK 0000010
-#define INPCK 0000020
-#define ISTRIP 0000040
-#define INLCR 0000100
-#define IGNCR 0000200
-#define ICRNL 0000400
-#define IXON 0001000
-#define IXOFF 0002000
-#define IXANY 0004000
-#define IUCLC 0010000
-#define IMAXBEL 0020000
-#define IUTF8 0040000
+#define IXON 0x0200
+#define IXOFF 0x0400
+#define IUCLC 0x1000
+#define IMAXBEL 0x2000
+#define IUTF8 0x4000
/* c_oflag bits */
-#define OPOST 0000001
-#define ONLCR 0000002
-#define OLCUC 0000004
-
-#define OCRNL 0000010
-#define ONOCR 0000020
-#define ONLRET 0000040
-
-#define OFILL 00000100
-#define OFDEL 00000200
-#define NLDLY 00001400
-#define NL0 00000000
-#define NL1 00000400
-#define NL2 00001000
-#define NL3 00001400
-#define TABDLY 00006000
-#define TAB0 00000000
-#define TAB1 00002000
-#define TAB2 00004000
-#define TAB3 00006000
-#define XTABS 00006000 /* required by POSIX to == TAB3 */
-#define CRDLY 00030000
-#define CR0 00000000
-#define CR1 00010000
-#define CR2 00020000
-#define CR3 00030000
-#define FFDLY 00040000
-#define FF0 00000000
-#define FF1 00040000
-#define BSDLY 00100000
-#define BS0 00000000
-#define BS1 00100000
-#define VTDLY 00200000
-#define VT0 00000000
-#define VT1 00200000
+#define ONLCR 0x00002
+#define OLCUC 0x00004
+#define NLDLY 0x00300
+#define NL0 0x00000
+#define NL1 0x00100
+#define NL2 0x00200
+#define NL3 0x00300
+#define TABDLY 0x00c00
+#define TAB0 0x00000
+#define TAB1 0x00400
+#define TAB2 0x00800
+#define TAB3 0x00c00
+#define XTABS 0x00c00 /* required by POSIX to == TAB3 */
+#define CRDLY 0x03000
+#define CR0 0x00000
+#define CR1 0x01000
+#define CR2 0x02000
+#define CR3 0x03000
+#define FFDLY 0x04000
+#define FF0 0x00000
+#define FF1 0x04000
+#define BSDLY 0x08000
+#define BS0 0x00000
+#define BS1 0x08000
+#define VTDLY 0x10000
+#define VT0 0x00000
+#define VT1 0x10000
/* c_cflag bit meaning */
-#define CBAUD 0000377
-#define B0 0000000 /* hang up */
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define EXTA B19200
-#define EXTB B38400
-#define CBAUDEX 0000000
-#define B57600 00020
-#define B115200 00021
-#define B230400 00022
-#define B460800 00023
-#define B500000 00024
-#define B576000 00025
-#define B921600 00026
-#define B1000000 00027
-#define B1152000 00030
-#define B1500000 00031
-#define B2000000 00032
-#define B2500000 00033
-#define B3000000 00034
-#define B3500000 00035
-#define B4000000 00036
-#define BOTHER 00037
-
-#define CIBAUD 077600000
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
-
-#define CSIZE 00001400
-#define CS5 00000000
-#define CS6 00000400
-#define CS7 00001000
-#define CS8 00001400
-
-#define CSTOPB 00002000
-#define CREAD 00004000
-#define PARENB 00010000
-#define PARODD 00020000
-#define HUPCL 00040000
-
-#define CLOCAL 00100000
-#define CMSPAR 010000000000 /* mark or space (stick) parity */
-#define CRTSCTS 020000000000 /* flow control */
+#define CBAUD 0x000000ff
+#define CBAUDEX 0x00000000
+#define BOTHER 0x0000001f
+#define B57600 0x00000010
+#define B115200 0x00000011
+#define B230400 0x00000012
+#define B460800 0x00000013
+#define B500000 0x00000014
+#define B576000 0x00000015
+#define B921600 0x00000016
+#define B1000000 0x00000017
+#define B1152000 0x00000018
+#define B1500000 0x00000019
+#define B2000000 0x0000001a
+#define B2500000 0x0000001b
+#define B3000000 0x0000001c
+#define B3500000 0x0000001d
+#define B4000000 0x0000001e
+#define CSIZE 0x00000300
+#define CS5 0x00000000
+#define CS6 0x00000100
+#define CS7 0x00000200
+#define CS8 0x00000300
+#define CSTOPB 0x00000400
+#define CREAD 0x00000800
+#define PARENB 0x00001000
+#define PARODD 0x00002000
+#define HUPCL 0x00004000
+#define CLOCAL 0x00008000
+#define CIBAUD 0x00ff0000
/* c_lflag bits */
#define ISIG 0x00000080
@@ -192,17 +149,6 @@ struct ktermios {
#define IEXTEN 0x00000400
#define EXTPROC 0x10000000
-/* Values for the ACTION argument to `tcflow'. */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* Values for the QUEUE_SELECTOR argument to `tcflush'. */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
/* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */
#define TCSANOW 0
#define TCSADRAIN 1
diff --git a/lib/libc/include/powerpc-linux-any/asm/unistd_32.h b/lib/libc/include/powerpc-linux-any/asm/unistd_32.h
index a0ae4bc895..479813d693 100644
--- a/lib/libc/include/powerpc-linux-any/asm/unistd_32.h
+++ b/lib/libc/include/powerpc-linux-any/asm/unistd_32.h
@@ -431,6 +431,7 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/include/powerpc-linux-any/asm/unistd_64.h b/lib/libc/include/powerpc-linux-any/asm/unistd_64.h
index c7581bde20..17dd3bfc9c 100644
--- a/lib/libc/include/powerpc-linux-any/asm/unistd_64.h
+++ b/lib/libc/include/powerpc-linux-any/asm/unistd_64.h
@@ -403,6 +403,7 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_64_H */ \ No newline at end of file
diff --git a/lib/libc/include/riscv-linux-any/asm/auxvec.h b/lib/libc/include/riscv-linux-any/asm/auxvec.h
index 056e62732a..76a1a4dc0d 100644
--- a/lib/libc/include/riscv-linux-any/asm/auxvec.h
+++ b/lib/libc/include/riscv-linux-any/asm/auxvec.h
@@ -30,8 +30,10 @@
#define AT_L1D_CACHEGEOMETRY 43
#define AT_L2_CACHESIZE 44
#define AT_L2_CACHEGEOMETRY 45
+#define AT_L3_CACHESIZE 46
+#define AT_L3_CACHEGEOMETRY 47
/* entries in ARCH_DLINFO */
-#define AT_VECTOR_SIZE_ARCH 7
+#define AT_VECTOR_SIZE_ARCH 9
#endif /* _ASM_RISCV_AUXVEC_H */ \ No newline at end of file
diff --git a/lib/libc/include/riscv-linux-any/asm/kvm.h b/lib/libc/include/riscv-linux-any/asm/kvm.h
index 9f4617c120..6b8d68c67b 100644
--- a/lib/libc/include/riscv-linux-any/asm/kvm.h
+++ b/lib/libc/include/riscv-linux-any/asm/kvm.h
@@ -48,6 +48,10 @@ struct kvm_sregs {
/* CONFIG registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
struct kvm_riscv_config {
unsigned long isa;
+ unsigned long zicbom_block_size;
+ unsigned long mvendorid;
+ unsigned long marchid;
+ unsigned long mimpid;
};
/* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */
@@ -82,6 +86,28 @@ struct kvm_riscv_timer {
__u64 state;
};
+/*
+ * ISA extension IDs specific to KVM. This is not the same as the host ISA
+ * extension IDs as that is internal to the host and should not be exposed
+ * to the guest. This should always be contiguous to keep the mapping simple
+ * in KVM implementation.
+ */
+enum KVM_RISCV_ISA_EXT_ID {
+ KVM_RISCV_ISA_EXT_A = 0,
+ KVM_RISCV_ISA_EXT_C,
+ KVM_RISCV_ISA_EXT_D,
+ KVM_RISCV_ISA_EXT_F,
+ KVM_RISCV_ISA_EXT_H,
+ KVM_RISCV_ISA_EXT_I,
+ KVM_RISCV_ISA_EXT_M,
+ KVM_RISCV_ISA_EXT_SVPBMT,
+ KVM_RISCV_ISA_EXT_SSTC,
+ KVM_RISCV_ISA_EXT_SVINVAL,
+ KVM_RISCV_ISA_EXT_ZIHINTPAUSE,
+ KVM_RISCV_ISA_EXT_ZICBOM,
+ KVM_RISCV_ISA_EXT_MAX,
+};
+
/* Possible states for kvm_riscv_timer */
#define KVM_RISCV_TIMER_STATE_OFF 0
#define KVM_RISCV_TIMER_STATE_ON 1
@@ -123,6 +149,9 @@ struct kvm_riscv_timer {
#define KVM_REG_RISCV_FP_D_REG(name) \
(offsetof(struct __riscv_d_ext_state, name) / sizeof(__u64))
+/* ISA Extension registers are mapped as type 7 */
+#define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT)
+
#endif
#endif /* __LINUX_KVM_RISCV_H */ \ No newline at end of file
diff --git a/lib/libc/include/riscv-linux-any/asm/setup.h b/lib/libc/include/riscv-linux-any/asm/setup.h
new file mode 100644
index 0000000000..1094751b59
--- /dev/null
+++ b/lib/libc/include/riscv-linux-any/asm/setup.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+
+#ifndef _ASM_RISCV_SETUP_H
+#define _ASM_RISCV_SETUP_H
+
+#define COMMAND_LINE_SIZE 1024
+
+#endif /* _ASM_RISCV_SETUP_H */ \ No newline at end of file
diff --git a/lib/libc/include/riscv-linux-any/asm/ucontext.h b/lib/libc/include/riscv-linux-any/asm/ucontext.h
index ecd19d211e..6a5f12d99c 100644
--- a/lib/libc/include/riscv-linux-any/asm/ucontext.h
+++ b/lib/libc/include/riscv-linux-any/asm/ucontext.h
@@ -15,19 +15,23 @@ struct ucontext {
struct ucontext *uc_link;
stack_t uc_stack;
sigset_t uc_sigmask;
- /* There's some padding here to allow sigset_t to be expanded in the
+ /*
+ * There's some padding here to allow sigset_t to be expanded in the
* future. Though this is unlikely, other architectures put uc_sigmask
* at the end of this structure and explicitly state it can be
- * expanded, so we didn't want to box ourselves in here. */
+ * expanded, so we didn't want to box ourselves in here.
+ */
__u8 __unused[1024 / 8 - sizeof(sigset_t)];
- /* We can't put uc_sigmask at the end of this structure because we need
+ /*
+ * We can't put uc_sigmask at the end of this structure because we need
* to be able to expand sigcontext in the future. For example, the
* vector ISA extension will almost certainly add ISA state. We want
* to ensure all user-visible ISA state can be saved and restored via a
* ucontext, so we're putting this at the end in order to allow for
* infinite extensibility. Since we know this will be extended and we
* assume sigset_t won't be extended an extreme amount, we're
- * prioritizing this. */
+ * prioritizing this.
+ */
struct sigcontext uc_mcontext;
};
diff --git a/lib/libc/include/riscv-linux-any/asm/unistd.h b/lib/libc/include/riscv-linux-any/asm/unistd.h
index c11dceb9c8..822a7e45cc 100644
--- a/lib/libc/include/riscv-linux-any/asm/unistd.h
+++ b/lib/libc/include/riscv-linux-any/asm/unistd.h
@@ -15,12 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifdef __LP64__
+#if defined(__LP64__) && !defined(__SYSCALL_COMPAT)
#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SET_GET_RLIMIT
#endif /* __LP64__ */
#define __ARCH_WANT_SYS_CLONE3
+#define __ARCH_WANT_MEMFD_SECRET
#include <asm-generic/unistd.h>
diff --git a/lib/libc/include/s390x-linux-any/asm/dasd.h b/lib/libc/include/s390x-linux-any/asm/dasd.h
index 3eb068b101..a8580984c7 100644
--- a/lib/libc/include/s390x-linux-any/asm/dasd.h
+++ b/lib/libc/include/s390x-linux-any/asm/dasd.h
@@ -183,6 +183,18 @@ typedef struct format_data_t {
} format_data_t;
/*
+ * struct dasd_copypair_swap_data_t
+ * represents all data necessary to issue a swap of the copy pair relation
+ */
+struct dasd_copypair_swap_data_t {
+ char primary[20]; /* BUSID of primary */
+ char secondary[20]; /* BUSID of secondary */
+
+ /* Reserved for future updates. */
+ __u8 reserved[64];
+};
+
+/*
* values to be used for format_data_t.intensity
* 0/8: normal format
* 1/9: also write record zero
@@ -326,6 +338,8 @@ struct dasd_snid_ioctl_data {
#define BIODASDSATTR _IOW(DASD_IOCTL_LETTER,2,attrib_data_t)
/* Release Allocated Space */
#define BIODASDRAS _IOW(DASD_IOCTL_LETTER, 3, format_data_t)
+/* Swap copy pair relation */
+#define BIODASDCOPYPAIRSWAP _IOW(DASD_IOCTL_LETTER, 4, struct dasd_copypair_swap_data_t)
/* Get Sense Path Group ID (SNID) data */
#define BIODASDSNID _IOWR(DASD_IOCTL_LETTER, 1, struct dasd_snid_ioctl_data)
diff --git a/lib/libc/include/s390x-linux-any/asm/fs3270.h b/lib/libc/include/s390x-linux-any/asm/fs3270.h
new file mode 100644
index 0000000000..4d231ec190
--- /dev/null
+++ b/lib/libc/include/s390x-linux-any/asm/fs3270.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_S390_UAPI_FS3270_H
+#define __ASM_S390_UAPI_FS3270_H
+
+#include <linux/types.h>
+#include <asm/ioctl.h>
+
+/* ioctls for fullscreen 3270 */
+#define TUBICMD _IO('3', 3) /* set ccw command for fs reads. */
+#define TUBOCMD _IO('3', 4) /* set ccw command for fs writes. */
+#define TUBGETI _IO('3', 7) /* get ccw command for fs reads. */
+#define TUBGETO _IO('3', 8) /* get ccw command for fs writes. */
+#define TUBGETMOD _IO('3', 13) /* get characteristics like model, cols, rows */
+
+/* For TUBGETMOD */
+struct raw3270_iocb {
+ __u16 model;
+ __u16 line_cnt;
+ __u16 col_cnt;
+ __u16 pf_cnt;
+ __u16 re_cnt;
+ __u16 map;
+};
+
+#endif /* __ASM_S390_UAPI_FS3270_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/hwctrset.h b/lib/libc/include/s390x-linux-any/asm/hwctrset.h
index 2d32da555e..f9d1fcd222 100644
--- a/lib/libc/include/s390x-linux-any/asm/hwctrset.h
+++ b/lib/libc/include/s390x-linux-any/asm/hwctrset.h
@@ -30,18 +30,18 @@ struct s390_ctrset_start { /* Set CPUs to operate on */
struct s390_ctrset_setdata { /* Counter set data */
__u32 set; /* Counter set number */
__u32 no_cnts; /* # of counters stored in cv[] */
- __u64 cv[0]; /* Counter values (variable length) */
+ __u64 cv[]; /* Counter values (variable length) */
};
struct s390_ctrset_cpudata { /* Counter set data per CPU */
__u32 cpu_nr; /* CPU number */
__u32 no_sets; /* # of counters sets in data[] */
- struct s390_ctrset_setdata data[0];
+ struct s390_ctrset_setdata data[];
};
struct s390_ctrset_read { /* Structure to get all ctr sets */
__u64 no_cpus; /* Total # of CPUs data taken from */
- struct s390_ctrset_cpudata data[0];
+ struct s390_ctrset_cpudata data[];
};
#define S390_HWCTR_MAGIC 'C' /* Random magic # for ioctls */
diff --git a/lib/libc/include/s390x-linux-any/asm/ipl.h b/lib/libc/include/s390x-linux-any/asm/ipl.h
index f8648e395c..9d9197ba24 100644
--- a/lib/libc/include/s390x-linux-any/asm/ipl.h
+++ b/lib/libc/include/s390x-linux-any/asm/ipl.h
@@ -27,6 +27,7 @@ enum ipl_pbt {
IPL_PBT_FCP = 0,
IPL_PBT_SCP_DATA = 1,
IPL_PBT_CCW = 2,
+ IPL_PBT_ECKD = 3,
IPL_PBT_NVME = 4,
};
@@ -111,6 +112,34 @@ struct ipl_pb0_ccw {
__u8 reserved5[8];
} __attribute__((packed));
+/* IPL Parameter Block 0 for ECKD */
+struct ipl_pb0_eckd {
+ __u32 len;
+ __u8 pbt;
+ __u8 reserved1[3];
+ __u32 reserved2[78];
+ __u8 opt;
+ __u8 reserved4[4];
+ __u8 reserved5:5;
+ __u8 ssid:3;
+ __u16 devno;
+ __u32 reserved6[5];
+ __u32 bootprog;
+ __u8 reserved7[12];
+ struct {
+ __u16 cyl;
+ __u8 head;
+ __u8 record;
+ __u32 reserved;
+ } br_chr __attribute__((packed));
+ __u32 scp_data_len;
+ __u8 reserved8[260];
+ __u8 scp_data[];
+} __attribute__((packed));
+
+#define IPL_PB0_ECKD_OPT_IPL 0x10
+#define IPL_PB0_ECKD_OPT_DUMP 0x20
+
#define IPL_PB0_CCW_VM_FLAG_NSS 0x80
#define IPL_PB0_CCW_VM_FLAG_VP 0x40
diff --git a/lib/libc/include/s390x-linux-any/asm/kvm.h b/lib/libc/include/s390x-linux-any/asm/kvm.h
index 5e528866a8..a298b4b7cc 100644
--- a/lib/libc/include/s390x-linux-any/asm/kvm.h
+++ b/lib/libc/include/s390x-linux-any/asm/kvm.h
@@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req {
#define KVM_S390_VM_CRYPTO 2
#define KVM_S390_VM_CPU_MODEL 3
#define KVM_S390_VM_MIGRATION 4
+#define KVM_S390_VM_CPU_TOPOLOGY 5
/* kvm attributes for mem_ctrl */
#define KVM_S390_VM_MEM_ENABLE_CMMA 0
diff --git a/lib/libc/include/s390x-linux-any/asm/pkey.h b/lib/libc/include/s390x-linux-any/asm/pkey.h
index 128dacb476..c54ff3e61b 100644
--- a/lib/libc/include/s390x-linux-any/asm/pkey.h
+++ b/lib/libc/include/s390x-linux-any/asm/pkey.h
@@ -171,7 +171,7 @@ struct pkey_skey2pkey {
#define PKEY_SKEY2PKEY _IOWR(PKEY_IOCTL_MAGIC, 0x06, struct pkey_skey2pkey)
/*
- * Verify the given CCA AES secure key for being able to be useable with
+ * Verify the given CCA AES secure key for being able to be usable with
* the pkey module. Check for correct key type and check for having at
* least one crypto card being able to handle this key (master key
* or old master key verification pattern matches).
diff --git a/lib/libc/include/s390x-linux-any/asm/raw3270.h b/lib/libc/include/s390x-linux-any/asm/raw3270.h
new file mode 100644
index 0000000000..733cd50845
--- /dev/null
+++ b/lib/libc/include/s390x-linux-any/asm/raw3270.h
@@ -0,0 +1,75 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __ASM_S390_UAPI_RAW3270_H
+#define __ASM_S390_UAPI_RAW3270_H
+
+/* Local Channel Commands */
+#define TC_WRITE 0x01 /* Write */
+#define TC_RDBUF 0x02 /* Read Buffer */
+#define TC_EWRITE 0x05 /* Erase write */
+#define TC_READMOD 0x06 /* Read modified */
+#define TC_EWRITEA 0x0d /* Erase write alternate */
+#define TC_WRITESF 0x11 /* Write structured field */
+
+/* Buffer Control Orders */
+#define TO_GE 0x08 /* Graphics Escape */
+#define TO_SF 0x1d /* Start field */
+#define TO_SBA 0x11 /* Set buffer address */
+#define TO_IC 0x13 /* Insert cursor */
+#define TO_PT 0x05 /* Program tab */
+#define TO_RA 0x3c /* Repeat to address */
+#define TO_SFE 0x29 /* Start field extended */
+#define TO_EUA 0x12 /* Erase unprotected to address */
+#define TO_MF 0x2c /* Modify field */
+#define TO_SA 0x28 /* Set attribute */
+
+/* Field Attribute Bytes */
+#define TF_INPUT 0x40 /* Visible input */
+#define TF_INPUTN 0x4c /* Invisible input */
+#define TF_INMDT 0xc1 /* Visible, Set-MDT */
+#define TF_LOG 0x60
+
+/* Character Attribute Bytes */
+#define TAT_RESET 0x00
+#define TAT_FIELD 0xc0
+#define TAT_EXTHI 0x41
+#define TAT_FGCOLOR 0x42
+#define TAT_CHARS 0x43
+#define TAT_BGCOLOR 0x45
+#define TAT_TRANS 0x46
+
+/* Extended-Highlighting Bytes */
+#define TAX_RESET 0x00
+#define TAX_BLINK 0xf1
+#define TAX_REVER 0xf2
+#define TAX_UNDER 0xf4
+
+/* Reset value */
+#define TAR_RESET 0x00
+
+/* Color values */
+#define TAC_RESET 0x00
+#define TAC_BLUE 0xf1
+#define TAC_RED 0xf2
+#define TAC_PINK 0xf3
+#define TAC_GREEN 0xf4
+#define TAC_TURQ 0xf5
+#define TAC_YELLOW 0xf6
+#define TAC_WHITE 0xf7
+#define TAC_DEFAULT 0x00
+
+/* Write Control Characters */
+#define TW_NONE 0x40 /* No particular action */
+#define TW_KR 0xc2 /* Keyboard restore */
+#define TW_PLUSALARM 0x04 /* Add this bit for alarm */
+
+#define RAW3270_FIRSTMINOR 1 /* First minor number */
+#define RAW3270_MAXDEVS 255 /* Max number of 3270 devices */
+
+#define AID_CLEAR 0x6d
+#define AID_ENTER 0x7d
+#define AID_PF3 0xf3
+#define AID_PF7 0xf7
+#define AID_PF8 0xf8
+#define AID_READ_PARTITION 0x88
+
+#endif /* __ASM_S390_UAPI_RAW3270_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/signal.h b/lib/libc/include/s390x-linux-any/asm/signal.h
index 0111391473..082459a1a6 100644
--- a/lib/libc/include/s390x-linux-any/asm/signal.h
+++ b/lib/libc/include/s390x-linux-any/asm/signal.h
@@ -104,7 +104,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
diff --git a/lib/libc/include/s390x-linux-any/asm/termios.h b/lib/libc/include/s390x-linux-any/asm/termios.h
deleted file mode 100644
index e1725075d8..0000000000
--- a/lib/libc/include/s390x-linux-any/asm/termios.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- * S390 version
- *
- * Derived from "include/asm-i386/termios.h"
- */
-
-#ifndef _S390_TERMIOS_H
-#define _S390_TERMIOS_H
-
-#include <asm/termbits.h>
-#include <asm/ioctls.h>
-
-struct winsize {
- unsigned short ws_row;
- unsigned short ws_col;
- unsigned short ws_xpixel;
- unsigned short ws_ypixel;
-};
-
-#define NCC 8
-struct termio {
- unsigned short c_iflag; /* input mode flags */
- unsigned short c_oflag; /* output mode flags */
- unsigned short c_cflag; /* control mode flags */
- unsigned short c_lflag; /* local mode flags */
- unsigned char c_line; /* line discipline */
- unsigned char c_cc[NCC]; /* control characters */
-};
-
-/* modem lines */
-#define TIOCM_LE 0x001
-#define TIOCM_DTR 0x002
-#define TIOCM_RTS 0x004
-#define TIOCM_ST 0x008
-#define TIOCM_SR 0x010
-#define TIOCM_CTS 0x020
-#define TIOCM_CAR 0x040
-#define TIOCM_RNG 0x080
-#define TIOCM_DSR 0x100
-#define TIOCM_CD TIOCM_CAR
-#define TIOCM_RI TIOCM_RNG
-#define TIOCM_OUT1 0x2000
-#define TIOCM_OUT2 0x4000
-#define TIOCM_LOOP 0x8000
-
-/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
-
-
-#endif /* _S390_TERMIOS_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/types.h b/lib/libc/include/s390x-linux-any/asm/types.h
index 4490762705..9c31c50035 100644
--- a/lib/libc/include/s390x-linux-any/asm/types.h
+++ b/lib/libc/include/s390x-linux-any/asm/types.h
@@ -12,15 +12,18 @@
#ifndef __ASSEMBLY__
-/* A address type so that arithmetic can be done on it & it can be upgraded to
- 64 bit when necessary
-*/
-typedef unsigned long addr_t;
+typedef unsigned long addr_t;
typedef __signed__ long saddr_t;
typedef struct {
- __u32 u[4];
-} __vector128;
+ union {
+ struct {
+ __u64 high;
+ __u64 low;
+ };
+ __u32 u[4];
+ };
+} __attribute__((packed, aligned(4))) __vector128;
#endif /* __ASSEMBLY__ */
diff --git a/lib/libc/include/s390x-linux-any/asm/unistd_32.h b/lib/libc/include/s390x-linux-any/asm/unistd_32.h
index 935fa660a7..420d534daa 100644
--- a/lib/libc/include/s390x-linux-any/asm/unistd_32.h
+++ b/lib/libc/include/s390x-linux-any/asm/unistd_32.h
@@ -421,5 +421,6 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_S390_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/unistd_64.h b/lib/libc/include/s390x-linux-any/asm/unistd_64.h
index 3e69aefa60..ec8d73d183 100644
--- a/lib/libc/include/s390x-linux-any/asm/unistd_64.h
+++ b/lib/libc/include/s390x-linux-any/asm/unistd_64.h
@@ -369,5 +369,6 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_S390_UNISTD_64_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/uvdevice.h b/lib/libc/include/s390x-linux-any/asm/uvdevice.h
new file mode 100644
index 0000000000..1e88524778
--- /dev/null
+++ b/lib/libc/include/s390x-linux-any/asm/uvdevice.h
@@ -0,0 +1,51 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright IBM Corp. 2022
+ * Author(s): Steffen Eiden <seiden@linux.ibm.com>
+ */
+#ifndef __S390_ASM_UVDEVICE_H
+#define __S390_ASM_UVDEVICE_H
+
+#include <linux/types.h>
+
+struct uvio_ioctl_cb {
+ __u32 flags;
+ __u16 uv_rc; /* UV header rc value */
+ __u16 uv_rrc; /* UV header rrc value */
+ __u64 argument_addr; /* Userspace address of uvio argument */
+ __u32 argument_len;
+ __u8 reserved14[0x40 - 0x14]; /* must be zero */
+};
+
+#define UVIO_ATT_USER_DATA_LEN 0x100
+#define UVIO_ATT_UID_LEN 0x10
+struct uvio_attest {
+ __u64 arcb_addr; /* 0x0000 */
+ __u64 meas_addr; /* 0x0008 */
+ __u64 add_data_addr; /* 0x0010 */
+ __u8 user_data[UVIO_ATT_USER_DATA_LEN]; /* 0x0018 */
+ __u8 config_uid[UVIO_ATT_UID_LEN]; /* 0x0118 */
+ __u32 arcb_len; /* 0x0128 */
+ __u32 meas_len; /* 0x012c */
+ __u32 add_data_len; /* 0x0130 */
+ __u16 user_data_len; /* 0x0134 */
+ __u16 reserved136; /* 0x0136 */
+};
+
+/*
+ * The following max values define an upper length for the IOCTL in/out buffers.
+ * However, they do not represent the maximum the Ultravisor allows which is
+ * often way smaller. By allowing larger buffer sizes we hopefully do not need
+ * to update the code with every machine update. It is therefore possible for
+ * userspace to request more memory than actually used by kernel/UV.
+ */
+#define UVIO_ATT_ARCB_MAX_LEN 0x100000
+#define UVIO_ATT_MEASUREMENT_MAX_LEN 0x8000
+#define UVIO_ATT_ADDITIONAL_MAX_LEN 0x8000
+
+#define UVIO_DEVICE_NAME "uv"
+#define UVIO_TYPE_UVC 'u'
+
+#define UVIO_IOCTL_ATT _IOWR(UVIO_TYPE_UVC, 0x01, struct uvio_ioctl_cb)
+
+#endif /* __S390_ASM_UVDEVICE_H */ \ No newline at end of file
diff --git a/lib/libc/include/s390x-linux-any/asm/zcrypt.h b/lib/libc/include/s390x-linux-any/asm/zcrypt.h
index 66776dc253..63f9293dbe 100644
--- a/lib/libc/include/s390x-linux-any/asm/zcrypt.h
+++ b/lib/libc/include/s390x-linux-any/asm/zcrypt.h
@@ -4,7 +4,7 @@
*
* zcrypt 2.2.1 (user-visible header)
*
- * Copyright IBM Corp. 2001, 2019
+ * Copyright IBM Corp. 2001, 2022
* Author(s): Robert Burroughs
* Eric Rossman (edrossma@us.ibm.com)
*
@@ -85,7 +85,8 @@ struct ica_rsa_modexpo_crt {
struct CPRBX {
__u16 cprb_len; /* CPRB length 220 */
__u8 cprb_ver_id; /* CPRB version id. 0x02 */
- __u8 pad_000[3]; /* Alignment pad bytes */
+ __u8 ctfm; /* Command Type Filtering Mask */
+ __u8 pad_000[2]; /* Alignment pad bytes */
__u8 func_id[2]; /* function id 0x5432 */
__u8 cprb_flags[4]; /* Flags */
__u32 req_parml; /* request parameter buffer len */
@@ -95,19 +96,19 @@ struct CPRBX {
__u32 rpl_datal; /* reply data block len */
__u32 rpld_datal; /* replied data block len */
__u32 req_extbl; /* request extension block len */
- __u8 pad_001[4]; /* reserved */
+ __u8 _pad_001[4]; /* reserved */
__u32 rpld_extbl; /* replied extension block len */
- __u8 padx000[16 - sizeof(__u8 *)];
+ __u8 _pad_002[16 - sizeof(__u8 *)];
__u8 *req_parmb; /* request parm block 'address' */
- __u8 padx001[16 - sizeof(__u8 *)];
+ __u8 _pad_003[16 - sizeof(__u8 *)];
__u8 *req_datab; /* request data block 'address' */
- __u8 padx002[16 - sizeof(__u8 *)];
+ __u8 _pad_004[16 - sizeof(__u8 *)];
__u8 *rpl_parmb; /* reply parm block 'address' */
- __u8 padx003[16 - sizeof(__u8 *)];
+ __u8 _pad_005[16 - sizeof(__u8 *)];
__u8 *rpl_datab; /* reply data block 'address' */
- __u8 padx004[16 - sizeof(__u8 *)];
+ __u8 _pad_006[16 - sizeof(__u8 *)];
__u8 *req_extb; /* request extension block 'addr'*/
- __u8 padx005[16 - sizeof(__u8 *)];
+ __u8 _pad_007[16 - sizeof(__u8 *)];
__u8 *rpl_extb; /* reply extension block 'address'*/
__u16 ccp_rtcode; /* server return code */
__u16 ccp_rscode; /* server reason code */
@@ -115,12 +116,10 @@ struct CPRBX {
__u8 logon_id[8]; /* Logon Identifier */
__u8 mac_value[8]; /* Mac Value */
__u8 mac_content_flgs; /* Mac content flag byte */
- __u8 pad_002; /* Alignment */
+ __u8 _pad_008; /* Alignment */
__u16 domain; /* Domain */
- __u8 usage_domain[4]; /* Usage domain */
- __u8 cntrl_domain[4]; /* Control domain */
- __u8 S390enf_mask[4]; /* S/390 enforcement mask */
- __u8 pad_004[36]; /* reserved */
+ __u8 _pad_009[12]; /* reserved, checked for zeros */
+ __u8 _pad_010[36]; /* reserved */
} __attribute__((packed));
/**
@@ -238,8 +237,8 @@ struct zcrypt_device_matrix_ext {
};
#define AUTOSELECT 0xFFFFFFFF
-#define AUTOSEL_AP ((__u16) 0xFFFF)
-#define AUTOSEL_DOM ((__u16) 0xFFFF)
+#define AUTOSEL_AP ((__u16)0xFFFF)
+#define AUTOSEL_DOM ((__u16)0xFFFF)
#define ZCRYPT_IOCTL_MAGIC 'z'
@@ -288,7 +287,7 @@ struct zcrypt_device_matrix_ext {
* 0x08: CEX3A
* 0x0a: CEX4
* 0x0b: CEX5
- * 0x0c: CEX6 and CEX7
+ * 0x0c: CEX6, CEX7 or CEX8
* 0x0d: device is disabled
*
* ZCRYPT_QDEPTH_MASK
@@ -305,12 +304,12 @@ struct zcrypt_device_matrix_ext {
/**
* Supported ioctl calls
*/
-#define ICARSAMODEXPO _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
-#define ICARSACRT _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
-#define ZSECSENDCPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
-#define ZSENDEP11CPRB _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
+#define ICARSAMODEXPO _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x05, 0)
+#define ICARSACRT _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x06, 0)
+#define ZSECSENDCPRB _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x81, 0)
+#define ZSENDEP11CPRB _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x04, 0)
-#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
+#define ZCRYPT_DEVICE_STATUS _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x5f, 0)
#define ZCRYPT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x58, char[MAX_ZDEV_CARDIDS_EXT])
#define ZCRYPT_QDEPTH_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x59, char[MAX_ZDEV_CARDIDS_EXT])
#define ZCRYPT_PERDEV_REQCNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x5a, int[MAX_ZDEV_CARDIDS_EXT])
@@ -352,7 +351,7 @@ struct zcrypt_device_matrix {
};
/* Deprecated: use ZCRYPT_DEVICE_STATUS */
-#define ZDEVICESTATUS _IOC(_IOC_READ|_IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
+#define ZDEVICESTATUS _IOC(_IOC_READ | _IOC_WRITE, ZCRYPT_IOCTL_MAGIC, 0x4f, 0)
/* Deprecated: use ZCRYPT_STATUS_MASK */
#define Z90STAT_STATUS_MASK _IOR(ZCRYPT_IOCTL_MAGIC, 0x48, char[64])
/* Deprecated: use ZCRYPT_QDEPTH_MASK */
diff --git a/lib/libc/include/sparc-linux-any/asm/shmbuf.h b/lib/libc/include/sparc-linux-any/asm/shmbuf.h
index 7874de669a..bc79627a4f 100644
--- a/lib/libc/include/sparc-linux-any/asm/shmbuf.h
+++ b/lib/libc/include/sparc-linux-any/asm/shmbuf.h
@@ -2,6 +2,9 @@
#ifndef _SPARC_SHMBUF_H
#define _SPARC_SHMBUF_H
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
+
/*
* The shmid64_ds structure for sparc architecture.
* Note extra padding because this structure is passed back and forth
@@ -25,7 +28,7 @@ struct shmid64_ds {
unsigned long shm_ctime_high;
unsigned long shm_ctime; /* last change time */
#endif
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
__kernel_pid_t shm_cpid; /* pid of creator */
__kernel_pid_t shm_lpid; /* pid of last operator */
unsigned long shm_nattch; /* no. of current attaches */
diff --git a/lib/libc/include/sparc-linux-any/asm/signal.h b/lib/libc/include/sparc-linux-any/asm/signal.h
index a6a91744d6..cf7a24e531 100644
--- a/lib/libc/include/sparc-linux-any/asm/signal.h
+++ b/lib/libc/include/sparc-linux-any/asm/signal.h
@@ -151,6 +151,7 @@ struct sigstack {
#include <asm-generic/signal-defs.h>
+#include <asm/posix_types.h>
struct __new_sigaction {
__sighandler_t sa_handler;
@@ -169,7 +170,7 @@ struct __old_sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
diff --git a/lib/libc/include/sparc-linux-any/asm/socket.h b/lib/libc/include/sparc-linux-any/asm/socket.h
index c64883b008..f8b9a44ba1 100644
--- a/lib/libc/include/sparc-linux-any/asm/socket.h
+++ b/lib/libc/include/sparc-linux-any/asm/socket.h
@@ -126,6 +126,9 @@
#define SO_RESERVE_MEM 0x0052
+#define SO_TXREHASH 0x0053
+
+#define SO_RCVMARK 0x0054
diff --git a/lib/libc/include/sparc-linux-any/asm/stat.h b/lib/libc/include/sparc-linux-any/asm/stat.h
index a8aaaa6d22..e088eba873 100644
--- a/lib/libc/include/sparc-linux-any/asm/stat.h
+++ b/lib/libc/include/sparc-linux-any/asm/stat.h
@@ -8,11 +8,11 @@
/* 64 bit sparc */
struct stat {
unsigned int st_dev;
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
short st_nlink;
- uid_t st_uid;
- gid_t st_gid;
+ __kernel_uid32_t st_uid;
+ __kernel_gid32_t st_gid;
unsigned int st_rdev;
long st_size;
long st_atime;
@@ -51,8 +51,8 @@ struct stat64 {
/* 32 bit sparc */
struct stat {
unsigned short st_dev;
- ino_t st_ino;
- mode_t st_mode;
+ __kernel_ino_t st_ino;
+ __kernel_mode_t st_mode;
short st_nlink;
unsigned short st_uid;
unsigned short st_gid;
diff --git a/lib/libc/include/sparc-linux-any/asm/termbits.h b/lib/libc/include/sparc-linux-any/asm/termbits.h
index 8ee7aaf1d4..fe2c21bebb 100644
--- a/lib/libc/include/sparc-linux-any/asm/termbits.h
+++ b/lib/libc/include/sparc-linux-any/asm/termbits.h
@@ -2,15 +2,12 @@
#ifndef _SPARC_TERMBITS_H
#define _SPARC_TERMBITS_H
-#include <linux/posix_types.h>
-
-typedef unsigned char cc_t;
-typedef unsigned int speed_t;
+#include <asm-generic/termbits-common.h>
#if defined(__sparc__) && defined(__arch64__)
-typedef unsigned int tcflag_t;
+typedef unsigned int tcflag_t;
#else
-typedef unsigned long tcflag_t;
+typedef unsigned long tcflag_t;
#endif
#define NCC 8
@@ -56,21 +53,19 @@ struct ktermios {
};
/* c_cc characters */
-#define VINTR 0
-#define VQUIT 1
-#define VERASE 2
-#define VKILL 3
-#define VEOF 4
-#define VEOL 5
-#define VEOL2 6
-#define VSWTC 7
-#define VSTART 8
-#define VSTOP 9
-
-
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VEOL 5
+#define VEOL2 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
#define VSUSP 10
-#define VDSUSP 11 /* SunOS POSIX nicety I do believe... */
+#define VDSUSP 11 /* SunOS POSIX nicety I do believe... */
#define VREPRINT 12
#define VDISCARD 13
#define VWERASE 14
@@ -83,121 +78,83 @@ struct ktermios {
#define VTIME VEOL
/* c_iflag bits */
-#define IGNBRK 0x00000001
-#define BRKINT 0x00000002
-#define IGNPAR 0x00000004
-#define PARMRK 0x00000008
-#define INPCK 0x00000010
-#define ISTRIP 0x00000020
-#define INLCR 0x00000040
-#define IGNCR 0x00000080
-#define ICRNL 0x00000100
-#define IUCLC 0x00000200
-#define IXON 0x00000400
-#define IXANY 0x00000800
-#define IXOFF 0x00001000
-#define IMAXBEL 0x00002000
-#define IUTF8 0x00004000
+#define IUCLC 0x0200
+#define IXON 0x0400
+#define IXOFF 0x1000
+#define IMAXBEL 0x2000
+#define IUTF8 0x4000
/* c_oflag bits */
-#define OPOST 0x00000001
-#define OLCUC 0x00000002
-#define ONLCR 0x00000004
-#define OCRNL 0x00000008
-#define ONOCR 0x00000010
-#define ONLRET 0x00000020
-#define OFILL 0x00000040
-#define OFDEL 0x00000080
-#define NLDLY 0x00000100
-#define NL0 0x00000000
-#define NL1 0x00000100
-#define CRDLY 0x00000600
-#define CR0 0x00000000
-#define CR1 0x00000200
-#define CR2 0x00000400
-#define CR3 0x00000600
-#define TABDLY 0x00001800
-#define TAB0 0x00000000
-#define TAB1 0x00000800
-#define TAB2 0x00001000
-#define TAB3 0x00001800
-#define XTABS 0x00001800
-#define BSDLY 0x00002000
-#define BS0 0x00000000
-#define BS1 0x00002000
-#define VTDLY 0x00004000
-#define VT0 0x00000000
-#define VT1 0x00004000
-#define FFDLY 0x00008000
-#define FF0 0x00000000
-#define FF1 0x00008000
-#define PAGEOUT 0x00010000 /* SUNOS specific */
-#define WRAP 0x00020000 /* SUNOS specific */
+#define OLCUC 0x00002
+#define ONLCR 0x00004
+#define NLDLY 0x00100
+#define NL0 0x00000
+#define NL1 0x00100
+#define CRDLY 0x00600
+#define CR0 0x00000
+#define CR1 0x00200
+#define CR2 0x00400
+#define CR3 0x00600
+#define TABDLY 0x01800
+#define TAB0 0x00000
+#define TAB1 0x00800
+#define TAB2 0x01000
+#define TAB3 0x01800
+#define XTABS 0x01800
+#define BSDLY 0x02000
+#define BS0 0x00000
+#define BS1 0x02000
+#define VTDLY 0x04000
+#define VT0 0x00000
+#define VT1 0x04000
+#define FFDLY 0x08000
+#define FF0 0x00000
+#define FF1 0x08000
+#define PAGEOUT 0x10000 /* SUNOS specific */
+#define WRAP 0x20000 /* SUNOS specific */
/* c_cflag bit meaning */
-#define CBAUD 0x0000100f
-#define B0 0x00000000 /* hang up */
-#define B50 0x00000001
-#define B75 0x00000002
-#define B110 0x00000003
-#define B134 0x00000004
-#define B150 0x00000005
-#define B200 0x00000006
-#define B300 0x00000007
-#define B600 0x00000008
-#define B1200 0x00000009
-#define B1800 0x0000000a
-#define B2400 0x0000000b
-#define B4800 0x0000000c
-#define B9600 0x0000000d
-#define B19200 0x0000000e
-#define B38400 0x0000000f
-#define EXTA B19200
-#define EXTB B38400
-#define CSIZE 0x00000030
-#define CS5 0x00000000
-#define CS6 0x00000010
-#define CS7 0x00000020
-#define CS8 0x00000030
-#define CSTOPB 0x00000040
-#define CREAD 0x00000080
-#define PARENB 0x00000100
-#define PARODD 0x00000200
-#define HUPCL 0x00000400
-#define CLOCAL 0x00000800
-#define CBAUDEX 0x00001000
+#define CBAUD 0x0000100f
+#define CSIZE 0x00000030
+#define CS5 0x00000000
+#define CS6 0x00000010
+#define CS7 0x00000020
+#define CS8 0x00000030
+#define CSTOPB 0x00000040
+#define CREAD 0x00000080
+#define PARENB 0x00000100
+#define PARODD 0x00000200
+#define HUPCL 0x00000400
+#define CLOCAL 0x00000800
+#define CBAUDEX 0x00001000
/* We'll never see these speeds with the Zilogs, but for completeness... */
-#define BOTHER 0x00001000
-#define B57600 0x00001001
-#define B115200 0x00001002
-#define B230400 0x00001003
-#define B460800 0x00001004
+#define BOTHER 0x00001000
+#define B57600 0x00001001
+#define B115200 0x00001002
+#define B230400 0x00001003
+#define B460800 0x00001004
/* This is what we can do with the Zilogs. */
-#define B76800 0x00001005
+#define B76800 0x00001005
/* This is what we can do with the SAB82532. */
-#define B153600 0x00001006
-#define B307200 0x00001007
-#define B614400 0x00001008
-#define B921600 0x00001009
+#define B153600 0x00001006
+#define B307200 0x00001007
+#define B614400 0x00001008
+#define B921600 0x00001009
/* And these are the rest... */
-#define B500000 0x0000100a
-#define B576000 0x0000100b
-#define B1000000 0x0000100c
-#define B1152000 0x0000100d
-#define B1500000 0x0000100e
-#define B2000000 0x0000100f
+#define B500000 0x0000100a
+#define B576000 0x0000100b
+#define B1000000 0x0000100c
+#define B1152000 0x0000100d
+#define B1500000 0x0000100e
+#define B2000000 0x0000100f
/* These have totally bogus values and nobody uses them
so far. Later on we'd have to use say 0x10000x and
adjust CBAUD constant and drivers accordingly.
-#define B2500000 0x00001010
-#define B3000000 0x00001011
-#define B3500000 0x00001012
-#define B4000000 0x00001013 */
-#define CIBAUD 0x100f0000 /* input baud rate (not used) */
-#define CMSPAR 0x40000000 /* mark or space (stick) parity */
-#define CRTSCTS 0x80000000 /* flow control */
-
-#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
+#define B2500000 0x00001010
+#define B3000000 0x00001011
+#define B3500000 0x00001012
+#define B4000000 0x00001013 */
+#define CIBAUD 0x100f0000 /* input baud rate (not used) */
/* c_lflag bits */
#define ISIG 0x00000001
@@ -212,7 +169,7 @@ struct ktermios {
#define ECHOCTL 0x00000200
#define ECHOPRT 0x00000400
#define ECHOKE 0x00000800
-#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */
+#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */
#define FLUSHO 0x00002000
#define PENDIN 0x00004000
#define IEXTEN 0x00008000
@@ -237,21 +194,9 @@ struct ktermios {
/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
-
-/* tcflow() and TCXONC use these */
-#define TCOOFF 0
-#define TCOON 1
-#define TCIOFF 2
-#define TCION 3
-
-/* tcflush() and TCFLSH use these */
-#define TCIFLUSH 0
-#define TCOFLUSH 1
-#define TCIOFLUSH 2
-
/* tcsetattr uses these */
-#define TCSANOW 0
-#define TCSADRAIN 1
-#define TCSAFLUSH 2
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
#endif /* _SPARC_TERMBITS_H */ \ No newline at end of file
diff --git a/lib/libc/include/sparc-linux-any/asm/unistd_32.h b/lib/libc/include/sparc-linux-any/asm/unistd_32.h
index e4d9a5fdcf..d2d745c0b7 100644
--- a/lib/libc/include/sparc-linux-any/asm/unistd_32.h
+++ b/lib/libc/include/sparc-linux-any/asm/unistd_32.h
@@ -419,6 +419,7 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/include/sparc-linux-any/asm/unistd_64.h b/lib/libc/include/sparc-linux-any/asm/unistd_64.h
index bf10b1cbfb..468efc36ed 100644
--- a/lib/libc/include/sparc-linux-any/asm/unistd_64.h
+++ b/lib/libc/include/sparc-linux-any/asm/unistd_64.h
@@ -382,6 +382,7 @@
#define __NR_landlock_restrict_self 446
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_64_H */ \ No newline at end of file
diff --git a/lib/libc/include/x86-linux-any/asm/amd_hsmp.h b/lib/libc/include/x86-linux-any/asm/amd_hsmp.h
new file mode 100644
index 0000000000..8eee35e83e
--- /dev/null
+++ b/lib/libc/include/x86-linux-any/asm/amd_hsmp.h
@@ -0,0 +1,307 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+#ifndef _ASM_X86_AMD_HSMP_H_
+#define _ASM_X86_AMD_HSMP_H_
+
+#include <linux/types.h>
+
+#pragma pack(4)
+
+#define HSMP_MAX_MSG_LEN 8
+
+/*
+ * HSMP Messages supported
+ */
+enum hsmp_message_ids {
+ HSMP_TEST = 1, /* 01h Increments input value by 1 */
+ HSMP_GET_SMU_VER, /* 02h SMU FW version */
+ HSMP_GET_PROTO_VER, /* 03h HSMP interface version */
+ HSMP_GET_SOCKET_POWER, /* 04h average package power consumption */
+ HSMP_SET_SOCKET_POWER_LIMIT, /* 05h Set the socket power limit */
+ HSMP_GET_SOCKET_POWER_LIMIT, /* 06h Get current socket power limit */
+ HSMP_GET_SOCKET_POWER_LIMIT_MAX,/* 07h Get maximum socket power value */
+ HSMP_SET_BOOST_LIMIT, /* 08h Set a core maximum frequency limit */
+ HSMP_SET_BOOST_LIMIT_SOCKET, /* 09h Set socket maximum frequency level */
+ HSMP_GET_BOOST_LIMIT, /* 0Ah Get current frequency limit */
+ HSMP_GET_PROC_HOT, /* 0Bh Get PROCHOT status */
+ HSMP_SET_XGMI_LINK_WIDTH, /* 0Ch Set max and min width of xGMI Link */
+ HSMP_SET_DF_PSTATE, /* 0Dh Alter APEnable/Disable messages behavior */
+ HSMP_SET_AUTO_DF_PSTATE, /* 0Eh Enable DF P-State Performance Boost algorithm */
+ HSMP_GET_FCLK_MCLK, /* 0Fh Get FCLK and MEMCLK for current socket */
+ HSMP_GET_CCLK_THROTTLE_LIMIT, /* 10h Get CCLK frequency limit in socket */
+ HSMP_GET_C0_PERCENT, /* 11h Get average C0 residency in socket */
+ HSMP_SET_NBIO_DPM_LEVEL, /* 12h Set max/min LCLK DPM Level for a given NBIO */
+ HSMP_GET_NBIO_DPM_LEVEL, /* 13h Get LCLK DPM level min and max for a given NBIO */
+ HSMP_GET_DDR_BANDWIDTH, /* 14h Get theoretical maximum and current DDR Bandwidth */
+ HSMP_GET_TEMP_MONITOR, /* 15h Get socket temperature */
+ HSMP_GET_DIMM_TEMP_RANGE, /* 16h Get per-DIMM temperature range and refresh rate */
+ HSMP_GET_DIMM_POWER, /* 17h Get per-DIMM power consumption */
+ HSMP_GET_DIMM_THERMAL, /* 18h Get per-DIMM thermal sensors */
+ HSMP_GET_SOCKET_FREQ_LIMIT, /* 19h Get current active frequency per socket */
+ HSMP_GET_CCLK_CORE_LIMIT, /* 1Ah Get CCLK frequency limit per core */
+ HSMP_GET_RAILS_SVI, /* 1Bh Get SVI-based Telemetry for all rails */
+ HSMP_GET_SOCKET_FMAX_FMIN, /* 1Ch Get Fmax and Fmin per socket */
+ HSMP_GET_IOLINK_BANDWITH, /* 1Dh Get current bandwidth on IO Link */
+ HSMP_GET_XGMI_BANDWITH, /* 1Eh Get current bandwidth on xGMI Link */
+ HSMP_SET_GMI3_WIDTH, /* 1Fh Set max and min GMI3 Link width */
+ HSMP_SET_PCI_RATE, /* 20h Control link rate on PCIe devices */
+ HSMP_SET_POWER_MODE, /* 21h Select power efficiency profile policy */
+ HSMP_SET_PSTATE_MAX_MIN, /* 22h Set the max and min DF P-State */
+ HSMP_MSG_ID_MAX,
+};
+
+struct hsmp_message {
+ __u32 msg_id; /* Message ID */
+ __u16 num_args; /* Number of input argument words in message */
+ __u16 response_sz; /* Number of expected output/response words */
+ __u32 args[HSMP_MAX_MSG_LEN]; /* argument/response buffer */
+ __u16 sock_ind; /* socket number */
+};
+
+enum hsmp_msg_type {
+ HSMP_RSVD = -1,
+ HSMP_SET = 0,
+ HSMP_GET = 1,
+};
+
+struct hsmp_msg_desc {
+ int num_args;
+ int response_sz;
+ enum hsmp_msg_type type;
+};
+
+/*
+ * User may use these comments as reference, please find the
+ * supported list of messages and message definition in the
+ * HSMP chapter of respective family/model PPR.
+ *
+ * Not supported messages would return -ENOMSG.
+ */
+static const struct hsmp_msg_desc hsmp_msg_desc_table[] = {
+ /* RESERVED */
+ {0, 0, HSMP_RSVD},
+
+ /*
+ * HSMP_TEST, num_args = 1, response_sz = 1
+ * input: args[0] = xx
+ * output: args[0] = xx + 1
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SMU_VER, num_args = 0, response_sz = 1
+ * output: args[0] = smu fw ver
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_PROTO_VER, num_args = 0, response_sz = 1
+ * output: args[0] = proto version
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER, num_args = 0, response_sz = 1
+ * output: args[0] = socket power in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_SOCKET_POWER_LIMIT, num_args = 1, response_sz = 0
+ * input: args[0] = power limit value in mWatts
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = socket power limit value in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_POWER_LIMIT_MAX, num_args = 0, response_sz = 1
+ * output: args[0] = maximuam socket power limit in mWatts
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_BOOST_LIMIT, num_args = 1, response_sz = 0
+ * input: args[0] = apic id[31:16] + boost limit value in MHz[15:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_BOOST_LIMIT_SOCKET, num_args = 1, response_sz = 0
+ * input: args[0] = boost limit value in MHz
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_BOOST_LIMIT, num_args = 1, response_sz = 1
+ * input: args[0] = apic id
+ * output: args[0] = boost limit value in MHz
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_PROC_HOT, num_args = 0, response_sz = 1
+ * output: args[0] = proc hot status
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_XGMI_LINK_WIDTH, num_args = 1, response_sz = 0
+ * input: args[0] = min link width[15:8] + max link width[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_DF_PSTATE, num_args = 1, response_sz = 0
+ * input: args[0] = df pstate[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /* HSMP_SET_AUTO_DF_PSTATE, num_args = 0, response_sz = 0 */
+ {0, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_FCLK_MCLK, num_args = 0, response_sz = 2
+ * output: args[0] = fclk in MHz, args[1] = mclk in MHz
+ */
+ {0, 2, HSMP_GET},
+
+ /*
+ * HSMP_GET_CCLK_THROTTLE_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = core clock in MHz
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_C0_PERCENT, num_args = 0, response_sz = 1
+ * output: args[0] = average c0 residency
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 0
+ * input: args[0] = nbioid[23:16] + max dpm level[15:8] + min dpm level[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_GET_NBIO_DPM_LEVEL, num_args = 1, response_sz = 1
+ * input: args[0] = nbioid[23:16]
+ * output: args[0] = max dpm level[15:8] + min dpm level[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DDR_BANDWIDTH, num_args = 0, response_sz = 1
+ * output: args[0] = max bw in Gbps[31:20] + utilised bw in Gbps[19:8] +
+ * bw in percentage[7:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_TEMP_MONITOR, num_args = 0, response_sz = 1
+ * output: args[0] = temperature in degree celsius. [15:8] integer part +
+ * [7:5] fractional part
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_TEMP_RANGE, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = refresh rate[3] + temperature range[2:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_POWER, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = DIMM power in mW[31:17] + update rate in ms[16:8] +
+ * DIMM address[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_DIMM_THERMAL, num_args = 1, response_sz = 1
+ * input: args[0] = DIMM address[7:0]
+ * output: args[0] = temperature in degree celcius[31:21] + update rate in ms[16:8] +
+ * DIMM address[7:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_FREQ_LIMIT, num_args = 0, response_sz = 1
+ * output: args[0] = frequency in MHz[31:16] + frequency source[15:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_CCLK_CORE_LIMIT, num_args = 1, response_sz = 1
+ * input: args[0] = apic id [31:0]
+ * output: args[0] = frequency in MHz[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_RAILS_SVI, num_args = 0, response_sz = 1
+ * output: args[0] = power in mW[31:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_SOCKET_FMAX_FMIN, num_args = 0, response_sz = 1
+ * output: args[0] = fmax in MHz[31:16] + fmin in MHz[15:0]
+ */
+ {0, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_IOLINK_BANDWITH, num_args = 1, response_sz = 1
+ * input: args[0] = link id[15:8] + bw type[2:0]
+ * output: args[0] = io bandwidth in Mbps[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_GET_XGMI_BANDWITH, num_args = 1, response_sz = 1
+ * input: args[0] = link id[15:8] + bw type[2:0]
+ * output: args[0] = xgmi bandwidth in Mbps[31:0]
+ */
+ {1, 1, HSMP_GET},
+
+ /*
+ * HSMP_SET_GMI3_WIDTH, num_args = 1, response_sz = 0
+ * input: args[0] = min link width[15:8] + max link width[7:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_PCI_RATE, num_args = 1, response_sz = 1
+ * input: args[0] = link rate control value
+ * output: args[0] = previous link rate control value
+ */
+ {1, 1, HSMP_SET},
+
+ /*
+ * HSMP_SET_POWER_MODE, num_args = 1, response_sz = 0
+ * input: args[0] = power efficiency mode[2:0]
+ */
+ {1, 0, HSMP_SET},
+
+ /*
+ * HSMP_SET_PSTATE_MAX_MIN, num_args = 1, response_sz = 0
+ * input: args[0] = min df pstate[15:8] + max df pstate[7:0]
+ */
+ {1, 0, HSMP_SET},
+};
+
+/* Reset to default packing */
+#pragma pack()
+
+/* Define unique ioctl command for hsmp msgs using generic _IOWR */
+#define HSMP_BASE_IOCTL_NR 0xF8
+#define HSMP_IOCTL_CMD _IOWR(HSMP_BASE_IOCTL_NR, 0, struct hsmp_message)
+
+#endif /*_ASM_X86_AMD_HSMP_H_*/ \ No newline at end of file
diff --git a/lib/libc/include/x86-linux-any/asm/bootparam.h b/lib/libc/include/x86-linux-any/asm/bootparam.h
index d592c70bd8..1c940a3c61 100644
--- a/lib/libc/include/x86-linux-any/asm/bootparam.h
+++ b/lib/libc/include/x86-linux-any/asm/bootparam.h
@@ -10,11 +10,13 @@
#define SETUP_EFI 4
#define SETUP_APPLE_PROPERTIES 5
#define SETUP_JAILHOUSE 6
+#define SETUP_CC_BLOB 7
+#define SETUP_IMA 8
+#define SETUP_RNG_SEED 9
+#define SETUP_ENUM_MAX SETUP_RNG_SEED
#define SETUP_INDIRECT (1<<31)
-
-/* SETUP_INDIRECT | max(SETUP_*) */
-#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_JAILHOUSE)
+#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT)
/* ram_size flags */
#define RAMDISK_IMAGE_START_MASK 0x07FF
@@ -51,7 +53,7 @@ struct setup_data {
__u64 next;
__u32 type;
__u32 len;
- __u8 data[0];
+ __u8 data[];
};
/* extensible setup indirect data node */
@@ -171,6 +173,14 @@ struct jailhouse_setup_data {
} __attribute__((packed)) v2;
} __attribute__((packed));
+/*
+ * IMA buffer setup data information from the previous kernel during kexec
+ */
+struct ima_setup_data {
+ __u64 addr;
+ __u64 size;
+} __attribute__((packed));
+
/* The so-called "zeropage" */
struct boot_params {
struct screen_info screen_info; /* 0x000 */
@@ -187,7 +197,8 @@ struct boot_params {
__u32 ext_ramdisk_image; /* 0x0c0 */
__u32 ext_ramdisk_size; /* 0x0c4 */
__u32 ext_cmd_line_ptr; /* 0x0c8 */
- __u8 _pad4[116]; /* 0x0cc */
+ __u8 _pad4[112]; /* 0x0cc */
+ __u32 cc_blob_address; /* 0x13c */
struct edid_info edid_info; /* 0x140 */
struct efi_info efi_info; /* 0x1c0 */
__u32 alt_mem_k; /* 0x1e0 */
diff --git a/lib/libc/include/x86-linux-any/asm/kvm.h b/lib/libc/include/x86-linux-any/asm/kvm.h
index 172838ee1e..e1e89d1b37 100644
--- a/lib/libc/include/x86-linux-any/asm/kvm.h
+++ b/lib/libc/include/x86-linux-any/asm/kvm.h
@@ -9,6 +9,7 @@
#include <linux/types.h>
#include <linux/ioctl.h>
+#include <linux/stddef.h>
#define KVM_PIO_PAGE_OFFSET 1
#define KVM_COALESCED_MMIO_PAGE_OFFSET 2
@@ -53,14 +54,6 @@
/* Architectural interrupt line count. */
#define KVM_NR_INTERRUPTS 256
-struct kvm_memory_alias {
- __u32 slot; /* this has a different namespace than memory slots */
- __u32 flags;
- __u64 guest_phys_addr;
- __u64 memory_size;
- __u64 target_phys_addr;
-};
-
/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
struct kvm_pic_state {
__u8 last_irr; /* edge detection */
@@ -198,13 +191,13 @@ struct kvm_msrs {
__u32 nmsrs; /* number of msrs in entries */
__u32 pad;
- struct kvm_msr_entry entries[0];
+ struct kvm_msr_entry entries[];
};
/* for KVM_GET_MSR_INDEX_LIST */
struct kvm_msr_list {
__u32 nmsrs; /* number of msrs in entries */
- __u32 indices[0];
+ __u32 indices[];
};
/* Maximum size of any access bitmap in bytes */
@@ -214,6 +207,8 @@ struct kvm_msr_list {
struct kvm_msr_filter_range {
#define KVM_MSR_FILTER_READ (1 << 0)
#define KVM_MSR_FILTER_WRITE (1 << 1)
+#define KVM_MSR_FILTER_RANGE_VALID_MASK (KVM_MSR_FILTER_READ | \
+ KVM_MSR_FILTER_WRITE)
__u32 flags;
__u32 nmsrs; /* number of msrs in bitmap */
__u32 base; /* MSR index the bitmap starts at */
@@ -224,6 +219,7 @@ struct kvm_msr_filter_range {
struct kvm_msr_filter {
#define KVM_MSR_FILTER_DEFAULT_ALLOW (0 << 0)
#define KVM_MSR_FILTER_DEFAULT_DENY (1 << 0)
+#define KVM_MSR_FILTER_VALID_MASK (KVM_MSR_FILTER_DEFAULT_DENY)
__u32 flags;
struct kvm_msr_filter_range ranges[KVM_MSR_FILTER_MAX_RANGES];
};
@@ -241,7 +237,7 @@ struct kvm_cpuid_entry {
struct kvm_cpuid {
__u32 nent;
__u32 padding;
- struct kvm_cpuid_entry entries[0];
+ struct kvm_cpuid_entry entries[];
};
struct kvm_cpuid_entry2 {
@@ -263,7 +259,7 @@ struct kvm_cpuid_entry2 {
struct kvm_cpuid2 {
__u32 nent;
__u32 padding;
- struct kvm_cpuid_entry2 entries[0];
+ struct kvm_cpuid_entry2 entries[];
};
/* for KVM_GET_PIT and KVM_SET_PIT */
@@ -306,7 +302,8 @@ struct kvm_pit_state {
struct kvm_pit_channel_state channels[3];
};
-#define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
+#define KVM_PIT_FLAGS_HPET_LEGACY 0x00000001
+#define KVM_PIT_FLAGS_SPEAKER_DATA_ON 0x00000002
struct kvm_pit_state2 {
struct kvm_pit_channel_state channels[3];
@@ -325,6 +322,7 @@ struct kvm_reinject_control {
#define KVM_VCPUEVENT_VALID_SHADOW 0x00000004
#define KVM_VCPUEVENT_VALID_SMM 0x00000008
#define KVM_VCPUEVENT_VALID_PAYLOAD 0x00000010
+#define KVM_VCPUEVENT_VALID_TRIPLE_FAULT 0x00000020
/* Interrupt shadow states */
#define KVM_X86_SHADOW_INT_MOV_SS 0x01
@@ -359,7 +357,10 @@ struct kvm_vcpu_events {
__u8 smm_inside_nmi;
__u8 latched_init;
} smi;
- __u8 reserved[27];
+ struct {
+ __u8 pending;
+ } triple_fault;
+ __u8 reserved[26];
__u8 exception_has_payload;
__u64 exception_payload;
};
@@ -373,9 +374,23 @@ struct kvm_debugregs {
__u64 reserved[9];
};
-/* for KVM_CAP_XSAVE */
+/* for KVM_CAP_XSAVE and KVM_CAP_XSAVE2 */
struct kvm_xsave {
+ /*
+ * KVM_GET_XSAVE2 and KVM_SET_XSAVE write and read as many bytes
+ * as are returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
+ * respectively, when invoked on the vm file descriptor.
+ *
+ * The size value returned by KVM_CHECK_EXTENSION(KVM_CAP_XSAVE2)
+ * will always be at least 4096. Currently, it is only greater
+ * than 4096 if a dynamic feature has been enabled with
+ * ``arch_prctl()``, but this may change in the future.
+ *
+ * The offsets of the state save areas in struct kvm_xsave follow
+ * the contents of CPUID leaf 0xD on the host.
+ */
__u32 region[1024];
+ __u32 extra[];
};
#define KVM_MAX_XCRS 16
@@ -414,11 +429,13 @@ struct kvm_sync_regs {
struct kvm_vcpu_events events;
};
-#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)
-#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1)
-#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)
-#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
-#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4)
+#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)
+#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1)
+#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2)
+#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3)
+#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4)
+#define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5)
+#define KVM_X86_QUIRK_MWAIT_NEVER_UD_FAULTS (1 << 6)
#define KVM_STATE_NESTED_FORMAT_VMX 0
#define KVM_STATE_NESTED_FORMAT_SVM 1
@@ -438,6 +455,9 @@ struct kvm_sync_regs {
#define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
+/* attributes for system fd (group 0) */
+#define KVM_X86_XCOMP_GUEST_SUPP 0
+
struct kvm_vmx_nested_state_data {
__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
__u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
@@ -486,8 +506,8 @@ struct kvm_nested_state {
* KVM_{GET,PUT}_NESTED_STATE ioctl values.
*/
union {
- struct kvm_vmx_nested_state_data vmx[0];
- struct kvm_svm_nested_state_data svm[0];
+ __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx);
+ __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm);
} data;
};
@@ -498,12 +518,41 @@ struct kvm_pmu_event_filter {
__u32 fixed_counter_bitmap;
__u32 flags;
__u32 pad[4];
- __u64 events[0];
+ __u64 events[];
};
#define KVM_PMU_EVENT_ALLOW 0
#define KVM_PMU_EVENT_DENY 1
+#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
+#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS)
+
+/*
+ * Masked event layout.
+ * Bits Description
+ * ---- -----------
+ * 7:0 event select (low bits)
+ * 15:8 umask match
+ * 31:16 unused
+ * 35:32 event select (high bits)
+ * 36:54 unused
+ * 55 exclude bit
+ * 63:56 umask mask
+ */
+
+#define KVM_PMU_ENCODE_MASKED_ENTRY(event_select, mask, match, exclude) \
+ (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \
+ (((mask) & 0xFFULL) << 56) | \
+ (((match) & 0xFFULL) << 8) | \
+ ((__u64)(!!(exclude)) << 55))
+
+#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \
+ (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8))
+#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56)
+
/* for KVM_{GET,SET,HAS}_DEVICE_ATTR */
#define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
#define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
diff --git a/lib/libc/include/x86-linux-any/asm/mman.h b/lib/libc/include/x86-linux-any/asm/mman.h
index 6541e3128b..cceb7d975e 100644
--- a/lib/libc/include/x86-linux-any/asm/mman.h
+++ b/lib/libc/include/x86-linux-any/asm/mman.h
@@ -5,20 +5,6 @@
#define MAP_32BIT 0x40 /* only give out 32bit addresses */
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
-/*
- * Take the 4 protection key bits out of the vma->vm_flags
- * value and turn them in to the bits that we can put in
- * to a pte.
- *
- * Only override these if Protection Keys are available
- * (which is only on 64-bit).
- */
-#define arch_vm_get_page_prot(vm_flags) __pgprot( \
- ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \
- ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \
- ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \
- ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0))
-
#define arch_calc_vm_prot_bits(prot, key) ( \
((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \
((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \
diff --git a/lib/libc/include/x86-linux-any/asm/prctl.h b/lib/libc/include/x86-linux-any/asm/prctl.h
index 9c544ba44d..cff429de57 100644
--- a/lib/libc/include/x86-linux-any/asm/prctl.h
+++ b/lib/libc/include/x86-linux-any/asm/prctl.h
@@ -2,20 +2,22 @@
#ifndef _ASM_X86_PRCTL_H
#define _ASM_X86_PRCTL_H
-#define ARCH_SET_GS 0x1001
-#define ARCH_SET_FS 0x1002
-#define ARCH_GET_FS 0x1003
-#define ARCH_GET_GS 0x1004
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
-#define ARCH_GET_CPUID 0x1011
-#define ARCH_SET_CPUID 0x1012
+#define ARCH_GET_CPUID 0x1011
+#define ARCH_SET_CPUID 0x1012
-#define ARCH_GET_XCOMP_SUPP 0x1021
-#define ARCH_GET_XCOMP_PERM 0x1022
-#define ARCH_REQ_XCOMP_PERM 0x1023
+#define ARCH_GET_XCOMP_SUPP 0x1021
+#define ARCH_GET_XCOMP_PERM 0x1022
+#define ARCH_REQ_XCOMP_PERM 0x1023
+#define ARCH_GET_XCOMP_GUEST_PERM 0x1024
+#define ARCH_REQ_XCOMP_GUEST_PERM 0x1025
-#define ARCH_MAP_VDSO_X32 0x2001
-#define ARCH_MAP_VDSO_32 0x2002
-#define ARCH_MAP_VDSO_64 0x2003
+#define ARCH_MAP_VDSO_X32 0x2001
+#define ARCH_MAP_VDSO_32 0x2002
+#define ARCH_MAP_VDSO_64 0x2003
#endif /* _ASM_X86_PRCTL_H */ \ No newline at end of file
diff --git a/lib/libc/include/x86-linux-any/asm/processor-flags.h b/lib/libc/include/x86-linux-any/asm/processor-flags.h
index e6526dcaba..ef8897d8f5 100644
--- a/lib/libc/include/x86-linux-any/asm/processor-flags.h
+++ b/lib/libc/include/x86-linux-any/asm/processor-flags.h
@@ -130,6 +130,8 @@
#define X86_CR4_SMAP _BITUL(X86_CR4_SMAP_BIT)
#define X86_CR4_PKE_BIT 22 /* enable Protection Keys support */
#define X86_CR4_PKE _BITUL(X86_CR4_PKE_BIT)
+#define X86_CR4_CET_BIT 23 /* enable Control-flow Enforcement Technology */
+#define X86_CR4_CET _BITUL(X86_CR4_CET_BIT)
/*
* x86-64 Task Priority Register, CR8
diff --git a/lib/libc/include/x86-linux-any/asm/sgx.h b/lib/libc/include/x86-linux-any/asm/sgx.h
index e4052b06f3..e5339772ed 100644
--- a/lib/libc/include/x86-linux-any/asm/sgx.h
+++ b/lib/libc/include/x86-linux-any/asm/sgx.h
@@ -29,6 +29,12 @@ enum sgx_page_flags {
_IOW(SGX_MAGIC, 0x03, struct sgx_enclave_provision)
#define SGX_IOC_VEPC_REMOVE_ALL \
_IO(SGX_MAGIC, 0x04)
+#define SGX_IOC_ENCLAVE_RESTRICT_PERMISSIONS \
+ _IOWR(SGX_MAGIC, 0x05, struct sgx_enclave_restrict_permissions)
+#define SGX_IOC_ENCLAVE_MODIFY_TYPES \
+ _IOWR(SGX_MAGIC, 0x06, struct sgx_enclave_modify_types)
+#define SGX_IOC_ENCLAVE_REMOVE_PAGES \
+ _IOWR(SGX_MAGIC, 0x07, struct sgx_enclave_remove_pages)
/**
* struct sgx_enclave_create - parameter structure for the
@@ -76,6 +82,62 @@ struct sgx_enclave_provision {
__u64 fd;
};
+/**
+ * struct sgx_enclave_restrict_permissions - parameters for ioctl
+ * %SGX_IOC_ENCLAVE_RESTRICT_PERMISSIONS
+ * @offset: starting page offset (page aligned relative to enclave base
+ * address defined in SECS)
+ * @length: length of memory (multiple of the page size)
+ * @permissions:new permission bits for pages in range described by @offset
+ * and @length
+ * @result: (output) SGX result code of ENCLS[EMODPR] function
+ * @count: (output) bytes successfully changed (multiple of page size)
+ */
+struct sgx_enclave_restrict_permissions {
+ __u64 offset;
+ __u64 length;
+ __u64 permissions;
+ __u64 result;
+ __u64 count;
+};
+
+/**
+ * struct sgx_enclave_modify_types - parameters for ioctl
+ * %SGX_IOC_ENCLAVE_MODIFY_TYPES
+ * @offset: starting page offset (page aligned relative to enclave base
+ * address defined in SECS)
+ * @length: length of memory (multiple of the page size)
+ * @page_type: new type for pages in range described by @offset and @length
+ * @result: (output) SGX result code of ENCLS[EMODT] function
+ * @count: (output) bytes successfully changed (multiple of page size)
+ */
+struct sgx_enclave_modify_types {
+ __u64 offset;
+ __u64 length;
+ __u64 page_type;
+ __u64 result;
+ __u64 count;
+};
+
+/**
+ * struct sgx_enclave_remove_pages - %SGX_IOC_ENCLAVE_REMOVE_PAGES parameters
+ * @offset: starting page offset (page aligned relative to enclave base
+ * address defined in SECS)
+ * @length: length of memory (multiple of the page size)
+ * @count: (output) bytes successfully changed (multiple of page size)
+ *
+ * Regular (PT_REG) or TCS (PT_TCS) can be removed from an initialized
+ * enclave if the system supports SGX2. First, the %SGX_IOC_ENCLAVE_MODIFY_TYPES
+ * ioctl() should be used to change the page type to PT_TRIM. After that
+ * succeeds ENCLU[EACCEPT] should be run from within the enclave and then
+ * %SGX_IOC_ENCLAVE_REMOVE_PAGES can be used to complete the page removal.
+ */
+struct sgx_enclave_remove_pages {
+ __u64 offset;
+ __u64 length;
+ __u64 count;
+};
+
struct sgx_enclave_run;
/**
diff --git a/lib/libc/include/x86-linux-any/asm/shmbuf.h b/lib/libc/include/x86-linux-any/asm/shmbuf.h
index f7ccc998c3..4e172a0408 100644
--- a/lib/libc/include/x86-linux-any/asm/shmbuf.h
+++ b/lib/libc/include/x86-linux-any/asm/shmbuf.h
@@ -5,6 +5,10 @@
#if !defined(__x86_64__) || !defined(__ILP32__)
#include <asm-generic/shmbuf.h>
#else
+
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
+
/*
* The shmid64_ds structure for x86 architecture with x32 ABI.
*
@@ -15,7 +19,7 @@
struct shmid64_ds {
struct ipc64_perm shm_perm; /* operation perms */
- size_t shm_segsz; /* size of segment (bytes) */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
__kernel_long_t shm_atime; /* last attach time */
__kernel_long_t shm_dtime; /* last detach time */
__kernel_long_t shm_ctime; /* last change time */
diff --git a/lib/libc/include/x86-linux-any/asm/signal.h b/lib/libc/include/x86-linux-any/asm/signal.h
index 2fced4fa1e..7e8e6a1d84 100644
--- a/lib/libc/include/x86-linux-any/asm/signal.h
+++ b/lib/libc/include/x86-linux-any/asm/signal.h
@@ -100,7 +100,7 @@ struct sigaction {
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
- size_t ss_size;
+ __kernel_size_t ss_size;
} stack_t;
#endif /* __ASSEMBLY__ */
diff --git a/lib/libc/include/x86-linux-any/asm/svm.h b/lib/libc/include/x86-linux-any/asm/svm.h
index d7a4474176..cb5ce1ffe3 100644
--- a/lib/libc/include/x86-linux-any/asm/svm.h
+++ b/lib/libc/include/x86-linux-any/asm/svm.h
@@ -108,6 +108,20 @@
#define SVM_VMGEXIT_AP_JUMP_TABLE 0x80000005
#define SVM_VMGEXIT_SET_AP_JUMP_TABLE 0
#define SVM_VMGEXIT_GET_AP_JUMP_TABLE 1
+#define SVM_VMGEXIT_PSC 0x80000010
+#define SVM_VMGEXIT_GUEST_REQUEST 0x80000011
+#define SVM_VMGEXIT_EXT_GUEST_REQUEST 0x80000012
+#define SVM_VMGEXIT_AP_CREATION 0x80000013
+#define SVM_VMGEXIT_AP_CREATE_ON_INIT 0
+#define SVM_VMGEXIT_AP_CREATE 1
+#define SVM_VMGEXIT_AP_DESTROY 2
+#define SVM_VMGEXIT_HV_FEATURES 0x8000fffd
+#define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe
+#define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \
+ /* SW_EXITINFO1[3:0] */ \
+ (((((u64)reason_set) & 0xf)) | \
+ /* SW_EXITINFO1[11:4] */ \
+ ((((u64)reason_code) & 0xff) << 4))
#define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff
/* Exit code reserved for hypervisor/software use */
@@ -218,6 +232,11 @@
{ SVM_VMGEXIT_NMI_COMPLETE, "vmgexit_nmi_complete" }, \
{ SVM_VMGEXIT_AP_HLT_LOOP, "vmgexit_ap_hlt_loop" }, \
{ SVM_VMGEXIT_AP_JUMP_TABLE, "vmgexit_ap_jump_table" }, \
+ { SVM_VMGEXIT_PSC, "vmgexit_page_state_change" }, \
+ { SVM_VMGEXIT_GUEST_REQUEST, "vmgexit_guest_request" }, \
+ { SVM_VMGEXIT_EXT_GUEST_REQUEST, "vmgexit_ext_guest_request" }, \
+ { SVM_VMGEXIT_AP_CREATION, "vmgexit_ap_creation" }, \
+ { SVM_VMGEXIT_HV_FEATURES, "vmgexit_hypervisor_feature" }, \
{ SVM_EXIT_ERR, "invalid_guest_state" }
diff --git a/lib/libc/include/x86-linux-any/asm/unistd_32.h b/lib/libc/include/x86-linux-any/asm/unistd_32.h
index 6eec656c7a..5678e32992 100644
--- a/lib/libc/include/x86-linux-any/asm/unistd_32.h
+++ b/lib/libc/include/x86-linux-any/asm/unistd_32.h
@@ -440,6 +440,7 @@
#define __NR_memfd_secret 447
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/include/x86-linux-any/asm/unistd_64.h b/lib/libc/include/x86-linux-any/asm/unistd_64.h
index f3c26d4301..97ba4d821b 100644
--- a/lib/libc/include/x86-linux-any/asm/unistd_64.h
+++ b/lib/libc/include/x86-linux-any/asm/unistd_64.h
@@ -362,6 +362,7 @@
#define __NR_memfd_secret 447
#define __NR_process_mrelease 448
#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
#endif /* _ASM_UNISTD_64_H */ \ No newline at end of file
diff --git a/lib/libc/include/x86-linux-any/asm/unistd_x32.h b/lib/libc/include/x86-linux-any/asm/unistd_x32.h
index 27ca1570c1..daf58a7d41 100644
--- a/lib/libc/include/x86-linux-any/asm/unistd_x32.h
+++ b/lib/libc/include/x86-linux-any/asm/unistd_x32.h
@@ -315,6 +315,7 @@
#define __NR_memfd_secret (__X32_SYSCALL_BIT + 447)
#define __NR_process_mrelease (__X32_SYSCALL_BIT + 448)
#define __NR_futex_waitv (__X32_SYSCALL_BIT + 449)
+#define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450)
#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
diff --git a/lib/libc/include/x86-linux-any/asm/vmx.h b/lib/libc/include/x86-linux-any/asm/vmx.h
index b2af1411e3..14cafc84bf 100644
--- a/lib/libc/include/x86-linux-any/asm/vmx.h
+++ b/lib/libc/include/x86-linux-any/asm/vmx.h
@@ -91,6 +91,7 @@
#define EXIT_REASON_UMWAIT 67
#define EXIT_REASON_TPAUSE 68
#define EXIT_REASON_BUS_LOCK 74
+#define EXIT_REASON_NOTIFY 75
#define VMX_EXIT_REASONS \
{ EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
@@ -153,7 +154,8 @@
{ EXIT_REASON_XRSTORS, "XRSTORS" }, \
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
{ EXIT_REASON_TPAUSE, "TPAUSE" }, \
- { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }
+ { EXIT_REASON_BUS_LOCK, "BUS_LOCK" }, \
+ { EXIT_REASON_NOTIFY, "NOTIFY" }
#define VMX_EXIT_REASON_FLAGS \
{ VMX_EXIT_REASONS_FAILED_VMENTRY, "FAILED_VMENTRY" }
diff --git a/lib/libc/include/xtensa-linux-any/asm/auxvec.h b/lib/libc/include/xtensa-linux-any/asm/auxvec.h
new file mode 100644
index 0000000000..976a6d1cb8
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/auxvec.h
@@ -0,0 +1,4 @@
+#ifndef __XTENSA_AUXVEC_H
+#define __XTENSA_AUXVEC_H
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/byteorder.h b/lib/libc/include/xtensa-linux-any/asm/byteorder.h
new file mode 100644
index 0000000000..1a184af190
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/byteorder.h
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _XTENSA_BYTEORDER_H
+#define _XTENSA_BYTEORDER_H
+
+#ifdef __XTENSA_EL__
+#include <linux/byteorder/little_endian.h>
+#elif defined(__XTENSA_EB__)
+#include <linux/byteorder/big_endian.h>
+#else
+# error processor byte order undefined!
+#endif
+
+#endif /* _XTENSA_BYTEORDER_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/ioctls.h b/lib/libc/include/xtensa-linux-any/asm/ioctls.h
new file mode 100644
index 0000000000..b3cc86e03b
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/ioctls.h
@@ -0,0 +1,130 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/ioctls.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 - 2005 Tensilica Inc.
+ *
+ * Derived from "include/asm-i386/ioctls.h"
+ */
+
+#ifndef _XTENSA_IOCTLS_H
+#define _XTENSA_IOCTLS_H
+
+#include <asm/ioctl.h>
+
+#define FIOCLEX _IO('f', 1)
+#define FIONCLEX _IO('f', 2)
+#define FIOASYNC _IOW('f', 125, int)
+#define FIONBIO _IOW('f', 126, int)
+#define FIONREAD _IOR('f', 127, int)
+#define TIOCINQ FIONREAD
+#define FIOQSIZE _IOR('f', 128, loff_t)
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+
+#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */
+#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */
+#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */
+#define TCSETAF 0x4012741C /* _IOW('t', 28, struct termio) */
+
+#define TCSBRK _IO('t', 29)
+#define TCXONC _IO('t', 30)
+#define TCFLSH _IO('t', 31)
+
+#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */
+#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */
+#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
+#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
+#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
+
+#define TIOCSPGRP _IOW('t', 118, int)
+#define TIOCGPGRP _IOR('t', 119, int)
+
+#define TIOCEXCL _IO('T', 12)
+#define TIOCNXCL _IO('T', 13)
+#define TIOCSCTTY _IO('T', 14)
+
+#define TIOCSTI _IOW('T', 18, char)
+#define TIOCMGET _IOR('T', 21, unsigned int)
+#define TIOCMBIS _IOW('T', 22, unsigned int)
+#define TIOCMBIC _IOW('T', 23, unsigned int)
+#define TIOCMSET _IOW('T', 24, unsigned int)
+# define TIOCM_LE 0x001
+# define TIOCM_DTR 0x002
+# define TIOCM_RTS 0x004
+# define TIOCM_ST 0x008
+# define TIOCM_SR 0x010
+# define TIOCM_CTS 0x020
+# define TIOCM_CAR 0x040
+# define TIOCM_RNG 0x080
+# define TIOCM_DSR 0x100
+# define TIOCM_CD TIOCM_CAR
+# define TIOCM_RI TIOCM_RNG
+
+#define TIOCGSOFTCAR _IOR('T', 25, unsigned int)
+#define TIOCSSOFTCAR _IOW('T', 26, unsigned int)
+#define TIOCLINUX _IOW('T', 28, char)
+#define TIOCCONS _IO('T', 29)
+#define TIOCGSERIAL 0x803C541E /*_IOR('T', 30, struct serial_struct)*/
+#define TIOCSSERIAL 0x403C541F /*_IOW('T', 31, struct serial_struct)*/
+#define TIOCPKT _IOW('T', 32, int)
+# define TIOCPKT_DATA 0
+# define TIOCPKT_FLUSHREAD 1
+# define TIOCPKT_FLUSHWRITE 2
+# define TIOCPKT_STOP 4
+# define TIOCPKT_START 8
+# define TIOCPKT_NOSTOP 16
+# define TIOCPKT_DOSTOP 32
+# define TIOCPKT_IOCTL 64
+
+
+#define TIOCNOTTY _IO('T', 34)
+#define TIOCSETD _IOW('T', 35, int)
+#define TIOCGETD _IOR('T', 36, int)
+#define TCSBRKP _IOW('T', 37, int) /* Needed for POSIX tcsendbreak()*/
+#define TIOCSBRK _IO('T', 39) /* BSD compatibility */
+#define TIOCCBRK _IO('T', 40) /* BSD compatibility */
+#define TIOCGSID _IOR('T', 41, pid_t) /* Return the session ID of FD*/
+#define TCGETS2 _IOR('T', 42, struct termios2)
+#define TCSETS2 _IOW('T', 43, struct termios2)
+#define TCSETSW2 _IOW('T', 44, struct termios2)
+#define TCSETSF2 _IOW('T', 45, struct termios2)
+#define TIOCGRS485 _IOR('T', 46, struct serial_rs485)
+#define TIOCSRS485 _IOWR('T', 47, struct serial_rs485)
+#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
+#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
+#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
+#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
+#define TIOCVHANGUP _IO('T', 0x37)
+#define TIOCGPKT _IOR('T', 0x38, int) /* Get packet mode state */
+#define TIOCGPTLCK _IOR('T', 0x39, int) /* Get Pty lock state */
+#define TIOCGEXCL _IOR('T', 0x40, int) /* Get exclusive mode state */
+#define TIOCGPTPEER _IO('T', 0x41) /* Safely open the slave */
+#define TIOCGISO7816 _IOR('T', 0x42, struct serial_iso7816)
+#define TIOCSISO7816 _IOWR('T', 0x43, struct serial_iso7816)
+
+#define TIOCSERCONFIG _IO('T', 83)
+#define TIOCSERGWILD _IOR('T', 84, int)
+#define TIOCSERSWILD _IOW('T', 85, int)
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
+#define TIOCSERGETLSR _IOR('T', 89, unsigned int) /* Get line status reg. */
+ /* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
+# define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
+#define TIOCSERGETMULTI 0x80a8545a /* Get multiport config */
+ /* _IOR('T', 90, struct serial_multiport_struct) */
+#define TIOCSERSETMULTI 0x40a8545b /* Set multiport config */
+ /* _IOW('T', 91, struct serial_multiport_struct) */
+
+#define TIOCMIWAIT _IO('T', 92) /* wait for a change on serial input line(s) */
+#define TIOCGICOUNT 0x545D /* read serial port __inline__ interrupt counts */
+
+#endif /* _XTENSA_IOCTLS_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/ipcbuf.h b/lib/libc/include/xtensa-linux-any/asm/ipcbuf.h
new file mode 100644
index 0000000000..48da6ab2ce
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/ipcbuf.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/ipcbuf.h
+ *
+ * The ipc64_perm structure for the Xtensa architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_IPCBUF_H
+#define _XTENSA_IPCBUF_H
+
+#include <linux/posix_types.h>
+
+/*
+ * Pad space is left for:
+ * - 32-bit mode_t and seq
+ * - 2 miscellaneous 32-bit values
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of
+ * this archive for more details.
+ */
+
+struct ipc64_perm
+{
+ __kernel_key_t key;
+ __kernel_uid32_t uid;
+ __kernel_gid32_t gid;
+ __kernel_uid32_t cuid;
+ __kernel_gid32_t cgid;
+ __kernel_mode_t mode;
+ unsigned long seq;
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif /* _XTENSA_IPCBUF_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/mman.h b/lib/libc/include/xtensa-linux-any/asm/mman.h
new file mode 100644
index 0000000000..fa37824323
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/mman.h
@@ -0,0 +1,124 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/mman.h
+ *
+ * Xtensa Processor memory-manager definitions
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995 by Ralf Baechle
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_MMAN_H
+#define _XTENSA_MMAN_H
+
+/*
+ * Protections are chosen from these bits, OR'd together. The
+ * implementation does not necessarily support PROT_EXEC or PROT_WRITE
+ * without PROT_READ. The only guarantees are that no writing will be
+ * allowed without PROT_WRITE and no access will be allowed for PROT_NONE.
+ */
+
+#define PROT_NONE 0x0 /* page can not be accessed */
+#define PROT_READ 0x1 /* page can be read */
+#define PROT_WRITE 0x2 /* page can be written */
+#define PROT_EXEC 0x4 /* page can be executed */
+
+#define PROT_SEM 0x10 /* page may be used for atomic ops */
+#define PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
+#define PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end fo growsup vma */
+
+/*
+ * Flags for mmap
+ */
+/* 0x01 - 0x03 are defined in linux/mman.h */
+#define MAP_TYPE 0x00f /* Mask for type of mapping */
+#define MAP_FIXED 0x010 /* Interpret addr exactly */
+
+/* not used by linux, but here to make sure we don't clash with ABI defines */
+#define MAP_RENAME 0x020 /* Assign page to file */
+#define MAP_AUTOGROW 0x040 /* File may grow by writing */
+#define MAP_LOCAL 0x080 /* Copy on fork/sproc */
+#define MAP_AUTORSRV 0x100 /* Logical swap reserved on demand */
+
+/* These are linux-specific */
+#define MAP_NORESERVE 0x0400 /* don't check for reservations */
+#define MAP_ANONYMOUS 0x0800 /* don't use a file */
+#define MAP_GROWSDOWN 0x1000 /* stack-like segment */
+#define MAP_DENYWRITE 0x2000 /* ETXTBSY */
+#define MAP_EXECUTABLE 0x4000 /* mark it as an executable */
+#define MAP_LOCKED 0x8000 /* pages are locked */
+#define MAP_POPULATE 0x10000 /* populate (prefault) pagetables */
+#define MAP_NONBLOCK 0x20000 /* do not block on IO */
+#define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */
+#define MAP_HUGETLB 0x80000 /* create a huge page mapping */
+#define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */
+#define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be
+ * uninitialized */
+
+/*
+ * Flags for msync
+ */
+#define MS_ASYNC 0x0001 /* sync memory asynchronously */
+#define MS_INVALIDATE 0x0002 /* invalidate mappings & caches */
+#define MS_SYNC 0x0004 /* synchronous memory sync */
+
+/*
+ * Flags for mlockall
+ */
+#define MCL_CURRENT 1 /* lock all current mappings */
+#define MCL_FUTURE 2 /* lock all future mappings */
+#define MCL_ONFAULT 4 /* lock all pages that are faulted in */
+
+/*
+ * Flags for mlock
+ */
+#define MLOCK_ONFAULT 0x01 /* Lock pages in range after they are faulted in, do not prefault */
+
+#define MADV_NORMAL 0 /* no further special treatment */
+#define MADV_RANDOM 1 /* expect random page references */
+#define MADV_SEQUENTIAL 2 /* expect sequential page references */
+#define MADV_WILLNEED 3 /* will need these pages */
+#define MADV_DONTNEED 4 /* don't need these pages */
+
+/* common parameters: try to keep these consistent across architectures */
+#define MADV_FREE 8 /* free pages only if memory pressure */
+#define MADV_REMOVE 9 /* remove these pages & resources */
+#define MADV_DONTFORK 10 /* don't inherit across fork */
+#define MADV_DOFORK 11 /* do inherit across fork */
+
+#define MADV_MERGEABLE 12 /* KSM may merge identical pages */
+#define MADV_UNMERGEABLE 13 /* KSM may not merge identical pages */
+
+#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
+#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
+
+#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
+ overrides the coredump filter bits */
+#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */
+
+#define MADV_WIPEONFORK 18 /* Zero memory on fork, child only */
+#define MADV_KEEPONFORK 19 /* Undo MADV_WIPEONFORK */
+
+#define MADV_COLD 20 /* deactivate these pages */
+#define MADV_PAGEOUT 21 /* reclaim these pages */
+
+#define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */
+#define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */
+
+#define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */
+
+#define MADV_COLLAPSE 25 /* Synchronous hugepage collapse */
+
+/* compatibility flags */
+#define MAP_FILE 0
+
+#define PKEY_DISABLE_ACCESS 0x1
+#define PKEY_DISABLE_WRITE 0x2
+#define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\
+ PKEY_DISABLE_WRITE)
+
+#endif /* _XTENSA_MMAN_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/msgbuf.h b/lib/libc/include/xtensa-linux-any/asm/msgbuf.h
new file mode 100644
index 0000000000..3f9e7278f3
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/msgbuf.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/msgbuf.h
+ *
+ * The msqid64_ds structure for the Xtensa architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 32-bit values
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of
+ * this archive for more details.
+ */
+
+#ifndef _XTENSA_MSGBUF_H
+#define _XTENSA_MSGBUF_H
+
+#include <asm/ipcbuf.h>
+
+struct msqid64_ds {
+ struct ipc64_perm msg_perm;
+#ifdef __XTENSA_EB__
+ unsigned long msg_stime_high;
+ unsigned long msg_stime; /* last msgsnd time */
+ unsigned long msg_rtime_high;
+ unsigned long msg_rtime; /* last msgrcv time */
+ unsigned long msg_ctime_high;
+ unsigned long msg_ctime; /* last change time */
+#elif defined(__XTENSA_EL__)
+ unsigned long msg_stime; /* last msgsnd time */
+ unsigned long msg_stime_high;
+ unsigned long msg_rtime; /* last msgrcv time */
+ unsigned long msg_rtime_high;
+ unsigned long msg_ctime; /* last change time */
+ unsigned long msg_ctime_high;
+#else
+# error processor byte order undefined!
+#endif
+ unsigned long msg_cbytes; /* current number of bytes on queue */
+ unsigned long msg_qnum; /* number of messages in queue */
+ unsigned long msg_qbytes; /* max number of bytes on queue */
+ __kernel_pid_t msg_lspid; /* pid of last msgsnd */
+ __kernel_pid_t msg_lrpid; /* last receive pid */
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#endif /* _XTENSA_MSGBUF_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/param.h b/lib/libc/include/xtensa-linux-any/asm/param.h
new file mode 100644
index 0000000000..4fd3bc4e76
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/param.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/param.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_PARAM_H
+#define _XTENSA_PARAM_H
+
+# define HZ 100
+
+#define EXEC_PAGESIZE 4096
+
+#ifndef NGROUPS
+#define NGROUPS 32
+#endif
+
+#ifndef NOGROUP
+#define NOGROUP (-1)
+#endif
+
+#define MAXHOSTNAMELEN 64 /* max length of hostname */
+
+#endif /* _XTENSA_PARAM_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/poll.h b/lib/libc/include/xtensa-linux-any/asm/poll.h
new file mode 100644
index 0000000000..d31acdeb68
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/poll.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/poll.h
+ *
+ * This file is subject to the terms and conditions of the GNU General
+ * Public License. See the file "COPYING" in the main directory of
+ * this archive for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_POLL_H
+#define _XTENSA_POLL_H
+
+#define POLLWRNORM POLLOUT
+#define POLLWRBAND 0x0100
+#define POLLREMOVE 0x0800
+
+#include <asm-generic/poll.h>
+
+#endif /* _XTENSA_POLL_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/posix_types.h b/lib/libc/include/xtensa-linux-any/asm/posix_types.h
new file mode 100644
index 0000000000..7a7b2a8f51
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/posix_types.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/posix_types.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Largely copied from include/asm-ppc/posix_types.h
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_POSIX_TYPES_H
+#define _XTENSA_POSIX_TYPES_H
+
+/*
+ * This file is generally used by user-level software, so you need to
+ * be a little careful about namespace pollution etc. Also, we cannot
+ * assume GCC is being used.
+ */
+
+typedef unsigned short __kernel_ipc_pid_t;
+#define __kernel_ipc_pid_t __kernel_ipc_pid_t
+
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef long __kernel_ptrdiff_t;
+#define __kernel_size_t __kernel_size_t
+
+typedef unsigned short __kernel_old_uid_t;
+typedef unsigned short __kernel_old_gid_t;
+#define __kernel_old_uid_t __kernel_old_uid_t
+
+typedef unsigned short __kernel_old_dev_t;
+#define __kernel_old_dev_t __kernel_old_dev_t
+
+#include <asm-generic/posix_types.h>
+
+#endif /* _XTENSA_POSIX_TYPES_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/ptrace.h b/lib/libc/include/xtensa-linux-any/asm/ptrace.h
new file mode 100644
index 0000000000..a53da07490
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/ptrace.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/ptrace.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_PTRACE_H
+#define _XTENSA_PTRACE_H
+
+#include <linux/types.h>
+
+/* Registers used by strace */
+
+#define REG_A_BASE 0x0000
+#define REG_AR_BASE 0x0100
+#define REG_PC 0x0020
+#define REG_PS 0x02e6
+#define REG_WB 0x0248
+#define REG_WS 0x0249
+#define REG_LBEG 0x0200
+#define REG_LEND 0x0201
+#define REG_LCOUNT 0x0202
+#define REG_SAR 0x0203
+
+#define SYSCALL_NR 0x00ff
+
+/* Other PTRACE_ values defined in <linux/ptrace.h> using values 0-9,16,17,24 */
+
+#define PTRACE_GETREGS 12
+#define PTRACE_SETREGS 13
+#define PTRACE_GETXTREGS 18
+#define PTRACE_SETXTREGS 19
+#define PTRACE_GETHBPREGS 20
+#define PTRACE_SETHBPREGS 21
+#define PTRACE_GETFDPIC 22
+
+#define PTRACE_GETFDPIC_EXEC 0
+#define PTRACE_GETFDPIC_INTERP 1
+
+#ifndef __ASSEMBLY__
+
+struct user_pt_regs {
+ __u32 pc;
+ __u32 ps;
+ __u32 lbeg;
+ __u32 lend;
+ __u32 lcount;
+ __u32 sar;
+ __u32 windowstart;
+ __u32 windowbase;
+ __u32 threadptr;
+ __u32 syscall;
+ __u32 reserved[6 + 48];
+ __u32 a[64];
+};
+
+#endif
+#endif /* _XTENSA_PTRACE_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/sembuf.h b/lib/libc/include/xtensa-linux-any/asm/sembuf.h
new file mode 100644
index 0000000000..6c85cd336f
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/sembuf.h
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/sembuf.h
+ *
+ * The semid64_ds structure for Xtensa architecture.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ *
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 32-bit values
+ *
+ */
+
+#ifndef _XTENSA_SEMBUF_H
+#define _XTENSA_SEMBUF_H
+
+#include <asm/byteorder.h>
+#include <asm/ipcbuf.h>
+
+struct semid64_ds {
+ struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
+#ifdef __XTENSA_EL__
+ unsigned long sem_otime; /* last semop time */
+ unsigned long sem_otime_high;
+ unsigned long sem_ctime; /* last change time */
+ unsigned long sem_ctime_high;
+#else
+ unsigned long sem_otime_high;
+ unsigned long sem_otime; /* last semop time */
+ unsigned long sem_ctime_high;
+ unsigned long sem_ctime; /* last change time */
+#endif
+ unsigned long sem_nsems; /* no. of semaphores in array */
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif /* __ASM_XTENSA_SEMBUF_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/setup.h b/lib/libc/include/xtensa-linux-any/asm/setup.h
new file mode 100644
index 0000000000..996b11db2e
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/setup.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/setup.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SETUP_H
+#define _XTENSA_SETUP_H
+
+#define COMMAND_LINE_SIZE 256
+
+#endif \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/shmbuf.h b/lib/libc/include/xtensa-linux-any/asm/shmbuf.h
new file mode 100644
index 0000000000..256548b0b3
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/shmbuf.h
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/shmbuf.h
+ *
+ * The shmid64_ds structure for Xtensa architecture.
+ * Note extra padding because this structure is passed back and forth
+ * between kernel and user space, but the padding is on the wrong
+ * side for big-endian xtensa, for historic reasons.
+ *
+ * Pad space is left for:
+ * - 2 miscellaneous 32-bit values
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SHMBUF_H
+#define _XTENSA_SHMBUF_H
+
+#include <asm/ipcbuf.h>
+#include <asm/posix_types.h>
+
+struct shmid64_ds {
+ struct ipc64_perm shm_perm; /* operation perms */
+ __kernel_size_t shm_segsz; /* size of segment (bytes) */
+ unsigned long shm_atime; /* last attach time */
+ unsigned long shm_atime_high;
+ unsigned long shm_dtime; /* last detach time */
+ unsigned long shm_dtime_high;
+ unsigned long shm_ctime; /* last change time */
+ unsigned long shm_ctime_high;
+ __kernel_pid_t shm_cpid; /* pid of creator */
+ __kernel_pid_t shm_lpid; /* pid of last operator */
+ unsigned long shm_nattch; /* no. of current attaches */
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+struct shminfo64 {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif /* _XTENSA_SHMBUF_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/sigcontext.h b/lib/libc/include/xtensa-linux-any/asm/sigcontext.h
new file mode 100644
index 0000000000..638fa76a00
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/sigcontext.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/sigcontext.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2007 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SIGCONTEXT_H
+#define _XTENSA_SIGCONTEXT_H
+
+
+struct sigcontext {
+ unsigned long sc_pc;
+ unsigned long sc_ps;
+ unsigned long sc_lbeg;
+ unsigned long sc_lend;
+ unsigned long sc_lcount;
+ unsigned long sc_sar;
+ unsigned long sc_acclo;
+ unsigned long sc_acchi;
+ unsigned long sc_a[16];
+ void *sc_xtregs;
+};
+
+#endif /* _XTENSA_SIGCONTEXT_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/signal.h b/lib/libc/include/xtensa-linux-any/asm/signal.h
new file mode 100644
index 0000000000..b98c324701
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/signal.h
@@ -0,0 +1,108 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/signal.h
+ *
+ * Swiped from SH.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SIGNAL_H
+#define _XTENSA_SIGNAL_H
+
+
+#define _NSIG 64
+#define _NSIG_BPW 32
+#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+/* Avoid too many header ordering problems. */
+struct siginfo;
+typedef unsigned long old_sigset_t; /* at least 32 bits */
+typedef struct {
+ unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+#endif
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+/* #define SIGLOST 29 */
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGUNUSED 31
+
+/* These should not be considered constants from userland. */
+#define SIGRTMIN 32
+#define SIGRTMAX (_NSIG-1)
+
+#define SA_RESTORER 0x04000000
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+
+#ifndef __ASSEMBLY__
+
+#include <asm-generic/signal-defs.h>
+
+
+/* Here we must cater to libcs that poke about in kernel headers. */
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+
+typedef struct sigaltstack {
+ void *ss_sp;
+ int ss_flags;
+ __kernel_size_t ss_size;
+} stack_t;
+
+#endif /* __ASSEMBLY__ */
+#endif /* _XTENSA_SIGNAL_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/sockios.h b/lib/libc/include/xtensa-linux-any/asm/sockios.h
new file mode 100644
index 0000000000..6e9b4210f9
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/sockios.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/sockios.h
+ *
+ * Socket-level I/O control calls. Copied from MIPS.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995 by Ralf Baechle
+ * Copyright (C) 2001 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SOCKIOS_H
+#define _XTENSA_SOCKIOS_H
+
+#include <asm/ioctl.h>
+
+/* Socket-level I/O control calls. */
+
+#define FIOGETOWN _IOR('f', 123, int)
+#define FIOSETOWN _IOW('f', 124, int)
+
+#define SIOCATMARK _IOR('s', 7, int)
+#define SIOCSPGRP _IOW('s', 8, pid_t)
+#define SIOCGPGRP _IOR('s', 9, pid_t)
+
+#define SIOCGSTAMP_OLD 0x8906 /* Get stamp (timeval) */
+#define SIOCGSTAMPNS_OLD 0x8907 /* Get stamp (timespec) */
+
+#endif /* _XTENSA_SOCKIOS_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/stat.h b/lib/libc/include/xtensa-linux-any/asm/stat.h
new file mode 100644
index 0000000000..744624bfaf
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/stat.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/stat.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2007 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_STAT_H
+#define _XTENSA_STAT_H
+
+#define STAT_HAVE_NSEC 1
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long st_atime_nsec;
+ unsigned long st_mtime;
+ unsigned long st_mtime_nsec;
+ unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+struct stat64 {
+ unsigned long long st_dev; /* Device */
+ unsigned long long st_ino; /* File serial number */
+ unsigned int st_mode; /* File mode. */
+ unsigned int st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group. */
+ unsigned long long st_rdev; /* Device number, if device. */
+ long long st_size; /* Size of file, in bytes. */
+ unsigned long st_blksize; /* Optimal block size for I/O. */
+ unsigned long __unused2;
+ unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long st_atime; /* Time of last access. */
+ unsigned long st_atime_nsec;
+ unsigned long st_mtime; /* Time of last modification. */
+ unsigned long st_mtime_nsec;
+ unsigned long st_ctime; /* Time of last status change. */
+ unsigned long st_ctime_nsec;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#endif /* _XTENSA_STAT_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/swab.h b/lib/libc/include/xtensa-linux-any/asm/swab.h
new file mode 100644
index 0000000000..81cd8c3f0c
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/swab.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/swab.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_SWAB_H
+#define _XTENSA_SWAB_H
+
+#include <linux/types.h>
+
+
+#define __SWAB_64_THRU_32__
+
+static __inline__ __u32 __arch_swab32(__u32 x)
+{
+ __u32 res;
+ /* instruction sequence from Xtensa ISA release 2/2000 */
+ __asm__("ssai 8 \n\t"
+ "srli %0, %1, 16 \n\t"
+ "src %0, %0, %1 \n\t"
+ "src %0, %0, %0 \n\t"
+ "src %0, %1, %0 \n"
+ : "=&a" (res)
+ : "a" (x)
+ );
+ return res;
+}
+#define __arch_swab32 __arch_swab32
+
+static __inline__ __u16 __arch_swab16(__u16 x)
+{
+ /* Given that 'short' values are signed (i.e., can be negative),
+ * we cannot assume that the upper 16-bits of the register are
+ * zero. We are careful to mask values after shifting.
+ */
+
+ /* There exists an anomaly between xt-gcc and xt-xcc. xt-gcc
+ * inserts an extui instruction after putting this function __inline__
+ * to ensure that it uses only the least-significant 16 bits of
+ * the result. xt-xcc doesn't use an extui, but assumes the
+ * __asm__ macro follows convention that the upper 16 bits of an
+ * 'unsigned short' result are still zero. This macro doesn't
+ * follow convention; indeed, it leaves garbage in the upport 16
+ * bits of the register.
+
+ * Declaring the temporary variables 'res' and 'tmp' to be 32-bit
+ * types while the return type of the function is a 16-bit type
+ * forces both compilers to insert exactly one extui instruction
+ * (or equivalent) to mask off the upper 16 bits. */
+
+ __u32 res;
+ __u32 tmp;
+
+ __asm__("extui %1, %2, 8, 8\n\t"
+ "slli %0, %2, 8 \n\t"
+ "or %0, %0, %1 \n"
+ : "=&a" (res), "=&a" (tmp)
+ : "a" (x)
+ );
+
+ return res;
+}
+#define __arch_swab16 __arch_swab16
+
+#endif /* _XTENSA_SWAB_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/types.h b/lib/libc/include/xtensa-linux-any/asm/types.h
new file mode 100644
index 0000000000..48fbfd3f22
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/types.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * include/asm-xtensa/types.h
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2001 - 2005 Tensilica Inc.
+ */
+
+#ifndef _XTENSA_TYPES_H
+#define _XTENSA_TYPES_H
+
+#include <asm-generic/int-ll64.h>
+
+#ifdef __ASSEMBLY__
+# define __XTENSA_UL(x) (x)
+# define __XTENSA_UL_CONST(x) x
+#else
+# define __XTENSA_UL(x) ((unsigned long)(x))
+# define ___XTENSA_UL_CONST(x) x##UL
+# define __XTENSA_UL_CONST(x) ___XTENSA_UL_CONST(x)
+#endif
+
+#ifndef __ASSEMBLY__
+
+#endif
+
+#endif /* _XTENSA_TYPES_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/unistd.h b/lib/libc/include/xtensa-linux-any/asm/unistd.h
new file mode 100644
index 0000000000..8e17c4b8f7
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/unistd.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _XTENSA_UNISTD_H
+#define _XTENSA_UNISTD_H
+
+#include <asm/unistd_32.h>
+
+#define __ARCH_WANT_SYS_OLDUMOUNT
+
+/*
+ * sysxtensa syscall handler
+ *
+ * int sysxtensa (SYS_XTENSA_ATOMIC_SET, ptr, val, unused);
+ * int sysxtensa (SYS_XTENSA_ATOMIC_ADD, ptr, val, unused);
+ * int sysxtensa (SYS_XTENSA_ATOMIC_EXG_ADD, ptr, val, unused);
+ * int sysxtensa (SYS_XTENSA_ATOMIC_CMP_SWP, ptr, oldval, newval);
+ * a2 a6 a3 a4 a5
+ */
+
+#define SYS_XTENSA_RESERVED 0 /* don't use this */
+#define SYS_XTENSA_ATOMIC_SET 1 /* set variable */
+#define SYS_XTENSA_ATOMIC_EXG_ADD 2 /* exchange memory and add */
+#define SYS_XTENSA_ATOMIC_ADD 3 /* add to memory */
+#define SYS_XTENSA_ATOMIC_CMP_SWP 4 /* compare and swap */
+#define SYS_XTENSA_COUNT 5 /* count */
+
+#endif /* _XTENSA_UNISTD_H */ \ No newline at end of file
diff --git a/lib/libc/include/xtensa-linux-any/asm/unistd_32.h b/lib/libc/include/xtensa-linux-any/asm/unistd_32.h
new file mode 100644
index 0000000000..6173c2a74e
--- /dev/null
+++ b/lib/libc/include/xtensa-linux-any/asm/unistd_32.h
@@ -0,0 +1,402 @@
+#ifndef _ASM_UNISTD_32_H
+#define _ASM_UNISTD_32_H
+
+#define __NR_spill 0
+#define __NR_xtensa 1
+#define __NR_available4 2
+#define __NR_available5 3
+#define __NR_available6 4
+#define __NR_available7 5
+#define __NR_available8 6
+#define __NR_available9 7
+#define __NR_open 8
+#define __NR_close 9
+#define __NR_dup 10
+#define __NR_dup2 11
+#define __NR_read 12
+#define __NR_write 13
+#define __NR_select 14
+#define __NR_lseek 15
+#define __NR_poll 16
+#define __NR__llseek 17
+#define __NR_epoll_wait 18
+#define __NR_epoll_ctl 19
+#define __NR_epoll_create 20
+#define __NR_creat 21
+#define __NR_truncate 22
+#define __NR_ftruncate 23
+#define __NR_readv 24
+#define __NR_writev 25
+#define __NR_fsync 26
+#define __NR_fdatasync 27
+#define __NR_truncate64 28
+#define __NR_ftruncate64 29
+#define __NR_pread64 30
+#define __NR_pwrite64 31
+#define __NR_link 32
+#define __NR_rename 33
+#define __NR_symlink 34
+#define __NR_readlink 35
+#define __NR_mknod 36
+#define __NR_pipe 37
+#define __NR_unlink 38
+#define __NR_rmdir 39
+#define __NR_mkdir 40
+#define __NR_chdir 41
+#define __NR_fchdir 42
+#define __NR_getcwd 43
+#define __NR_chmod 44
+#define __NR_chown 45
+#define __NR_stat 46
+#define __NR_stat64 47
+#define __NR_lchown 48
+#define __NR_lstat 49
+#define __NR_lstat64 50
+#define __NR_available51 51
+#define __NR_fchmod 52
+#define __NR_fchown 53
+#define __NR_fstat 54
+#define __NR_fstat64 55
+#define __NR_flock 56
+#define __NR_access 57
+#define __NR_umask 58
+#define __NR_getdents 59
+#define __NR_getdents64 60
+#define __NR_fcntl64 61
+#define __NR_fallocate 62
+#define __NR_fadvise64_64 63
+#define __NR_utime 64
+#define __NR_utimes 65
+#define __NR_ioctl 66
+#define __NR_fcntl 67
+#define __NR_setxattr 68
+#define __NR_getxattr 69
+#define __NR_listxattr 70
+#define __NR_removexattr 71
+#define __NR_lsetxattr 72
+#define __NR_lgetxattr 73
+#define __NR_llistxattr 74
+#define __NR_lremovexattr 75
+#define __NR_fsetxattr 76
+#define __NR_fgetxattr 77
+#define __NR_flistxattr 78
+#define __NR_fremovexattr 79
+#define __NR_mmap2 80
+#define __NR_munmap 81
+#define __NR_mprotect 82
+#define __NR_brk 83
+#define __NR_mlock 84
+#define __NR_munlock 85
+#define __NR_mlockall 86
+#define __NR_munlockall 87
+#define __NR_mremap 88
+#define __NR_msync 89
+#define __NR_mincore 90
+#define __NR_madvise 91
+#define __NR_shmget 92
+#define __NR_shmat 93
+#define __NR_shmctl 94
+#define __NR_shmdt 95
+#define __NR_socket 96
+#define __NR_setsockopt 97
+#define __NR_getsockopt 98
+#define __NR_shutdown 99
+#define __NR_bind 100
+#define __NR_connect 101
+#define __NR_listen 102
+#define __NR_accept 103
+#define __NR_getsockname 104
+#define __NR_getpeername 105
+#define __NR_sendmsg 106
+#define __NR_recvmsg 107
+#define __NR_send 108
+#define __NR_recv 109
+#define __NR_sendto 110
+#define __NR_recvfrom 111
+#define __NR_socketpair 112
+#define __NR_sendfile 113
+#define __NR_sendfile64 114
+#define __NR_sendmmsg 115
+#define __NR_clone 116
+#define __NR_execve 117
+#define __NR_exit 118
+#define __NR_exit_group 119
+#define __NR_getpid 120
+#define __NR_wait4 121
+#define __NR_waitid 122
+#define __NR_kill 123
+#define __NR_tkill 124
+#define __NR_tgkill 125
+#define __NR_set_tid_address 126
+#define __NR_gettid 127
+#define __NR_setsid 128
+#define __NR_getsid 129
+#define __NR_prctl 130
+#define __NR_personality 131
+#define __NR_getpriority 132
+#define __NR_setpriority 133
+#define __NR_setitimer 134
+#define __NR_getitimer 135
+#define __NR_setuid 136
+#define __NR_getuid 137
+#define __NR_setgid 138
+#define __NR_getgid 139
+#define __NR_geteuid 140
+#define __NR_getegid 141
+#define __NR_setreuid 142
+#define __NR_setregid 143
+#define __NR_setresuid 144
+#define __NR_getresuid 145
+#define __NR_setresgid 146
+#define __NR_getresgid 147
+#define __NR_setpgid 148
+#define __NR_getpgid 149
+#define __NR_getppid 150
+#define __NR_getpgrp 151
+#define __NR_reserved152 152
+#define __NR_reserved153 153
+#define __NR_times 154
+#define __NR_acct 155
+#define __NR_sched_setaffinity 156
+#define __NR_sched_getaffinity 157
+#define __NR_capget 158
+#define __NR_capset 159
+#define __NR_ptrace 160
+#define __NR_semtimedop 161
+#define __NR_semget 162
+#define __NR_semop 163
+#define __NR_semctl 164
+#define __NR_available165 165
+#define __NR_msgget 166
+#define __NR_msgsnd 167
+#define __NR_msgrcv 168
+#define __NR_msgctl 169
+#define __NR_available170 170
+#define __NR_umount2 171
+#define __NR_mount 172
+#define __NR_swapon 173
+#define __NR_chroot 174
+#define __NR_pivot_root 175
+#define __NR_umount 176
+#define __NR_swapoff 177
+#define __NR_sync 178
+#define __NR_syncfs 179
+#define __NR_setfsuid 180
+#define __NR_setfsgid 181
+#define __NR_sysfs 182
+#define __NR_ustat 183
+#define __NR_statfs 184
+#define __NR_fstatfs 185
+#define __NR_statfs64 186
+#define __NR_fstatfs64 187
+#define __NR_setrlimit 188
+#define __NR_getrlimit 189
+#define __NR_getrusage 190
+#define __NR_futex 191
+#define __NR_gettimeofday 192
+#define __NR_settimeofday 193
+#define __NR_adjtimex 194
+#define __NR_nanosleep 195
+#define __NR_getgroups 196
+#define __NR_setgroups 197
+#define __NR_sethostname 198
+#define __NR_setdomainname 199
+#define __NR_syslog 200
+#define __NR_vhangup 201
+#define __NR_uselib 202
+#define __NR_reboot 203
+#define __NR_quotactl 204
+#define __NR_nfsservctl 205
+#define __NR__sysctl 206
+#define __NR_bdflush 207
+#define __NR_uname 208
+#define __NR_sysinfo 209
+#define __NR_init_module 210
+#define __NR_delete_module 211
+#define __NR_sched_setparam 212
+#define __NR_sched_getparam 213
+#define __NR_sched_setscheduler 214
+#define __NR_sched_getscheduler 215
+#define __NR_sched_get_priority_max 216
+#define __NR_sched_get_priority_min 217
+#define __NR_sched_rr_get_interval 218
+#define __NR_sched_yield 219
+#define __NR_available222 222
+#define __NR_restart_syscall 223
+#define __NR_sigaltstack 224
+#define __NR_rt_sigreturn 225
+#define __NR_rt_sigaction 226
+#define __NR_rt_sigprocmask 227
+#define __NR_rt_sigpending 228
+#define __NR_rt_sigtimedwait 229
+#define __NR_rt_sigqueueinfo 230
+#define __NR_rt_sigsuspend 231
+#define __NR_mq_open 232
+#define __NR_mq_unlink 233
+#define __NR_mq_timedsend 234
+#define __NR_mq_timedreceive 235
+#define __NR_mq_notify 236
+#define __NR_mq_getsetattr 237
+#define __NR_available238 238
+#define __NR_io_setup 239
+#define __NR_io_destroy 240
+#define __NR_io_submit 241
+#define __NR_io_getevents 242
+#define __NR_io_cancel 243
+#define __NR_clock_settime 244
+#define __NR_clock_gettime 245
+#define __NR_clock_getres 246
+#define __NR_clock_nanosleep 247
+#define __NR_timer_create 248
+#define __NR_timer_delete 249
+#define __NR_timer_settime 250
+#define __NR_timer_gettime 251
+#define __NR_timer_getoverrun 252
+#define __NR_reserved253 253
+#define __NR_lookup_dcookie 254
+#define __NR_available255 255
+#define __NR_add_key 256
+#define __NR_request_key 257
+#define __NR_keyctl 258
+#define __NR_available259 259
+#define __NR_readahead 260
+#define __NR_remap_file_pages 261
+#define __NR_migrate_pages 262
+#define __NR_mbind 263
+#define __NR_get_mempolicy 264
+#define __NR_set_mempolicy 265
+#define __NR_unshare 266
+#define __NR_move_pages 267
+#define __NR_splice 268
+#define __NR_tee 269
+#define __NR_vmsplice 270
+#define __NR_available271 271
+#define __NR_pselect6 272
+#define __NR_ppoll 273
+#define __NR_epoll_pwait 274
+#define __NR_epoll_create1 275
+#define __NR_inotify_init 276
+#define __NR_inotify_add_watch 277
+#define __NR_inotify_rm_watch 278
+#define __NR_inotify_init1 279
+#define __NR_getcpu 280
+#define __NR_kexec_load 281
+#define __NR_ioprio_set 282
+#define __NR_ioprio_get 283
+#define __NR_set_robust_list 284
+#define __NR_get_robust_list 285
+#define __NR_available286 286
+#define __NR_available287 287
+#define __NR_openat 288
+#define __NR_mkdirat 289
+#define __NR_mknodat 290
+#define __NR_unlinkat 291
+#define __NR_renameat 292
+#define __NR_linkat 293
+#define __NR_symlinkat 294
+#define __NR_readlinkat 295
+#define __NR_utimensat 296
+#define __NR_fchownat 297
+#define __NR_futimesat 298
+#define __NR_fstatat64 299
+#define __NR_fchmodat 300
+#define __NR_faccessat 301
+#define __NR_available302 302
+#define __NR_available303 303
+#define __NR_signalfd 304
+#define __NR_eventfd 306
+#define __NR_recvmmsg 307
+#define __NR_setns 308
+#define __NR_signalfd4 309
+#define __NR_dup3 310
+#define __NR_pipe2 311
+#define __NR_timerfd_create 312
+#define __NR_timerfd_settime 313
+#define __NR_timerfd_gettime 314
+#define __NR_available315 315
+#define __NR_eventfd2 316
+#define __NR_preadv 317
+#define __NR_pwritev 318
+#define __NR_available319 319
+#define __NR_fanotify_init 320
+#define __NR_fanotify_mark 321
+#define __NR_process_vm_readv 322
+#define __NR_process_vm_writev 323
+#define __NR_name_to_handle_at 324
+#define __NR_open_by_handle_at 325
+#define __NR_sync_file_range2 326
+#define __NR_perf_event_open 327
+#define __NR_rt_tgsigqueueinfo 328
+#define __NR_clock_adjtime 329
+#define __NR_prlimit64 330
+#define __NR_kcmp 331
+#define __NR_finit_module 332
+#define __NR_accept4 333
+#define __NR_sched_setattr 334
+#define __NR_sched_getattr 335
+#define __NR_renameat2 336
+#define __NR_seccomp 337
+#define __NR_getrandom 338
+#define __NR_memfd_create 339
+#define __NR_bpf 340
+#define __NR_execveat 341
+#define __NR_userfaultfd 342
+#define __NR_membarrier 343
+#define __NR_mlock2 344
+#define __NR_copy_file_range 345
+#define __NR_preadv2 346
+#define __NR_pwritev2 347
+#define __NR_pkey_mprotect 348
+#define __NR_pkey_alloc 349
+#define __NR_pkey_free 350
+#define __NR_statx 351
+#define __NR_rseq 352
+#define __NR_clock_gettime64 403
+#define __NR_clock_settime64 404
+#define __NR_clock_adjtime64 405
+#define __NR_clock_getres_time64 406
+#define __NR_clock_nanosleep_time64 407
+#define __NR_timer_gettime64 408
+#define __NR_timer_settime64 409
+#define __NR_timerfd_gettime64 410
+#define __NR_timerfd_settime64 411
+#define __NR_utimensat_time64 412
+#define __NR_pselect6_time64 413
+#define __NR_ppoll_time64 414
+#define __NR_io_pgetevents_time64 416
+#define __NR_recvmmsg_time64 417
+#define __NR_mq_timedsend_time64 418
+#define __NR_mq_timedreceive_time64 419
+#define __NR_semtimedop_time64 420
+#define __NR_rt_sigtimedwait_time64 421
+#define __NR_futex_time64 422
+#define __NR_sched_rr_get_interval_time64 423
+#define __NR_pidfd_send_signal 424
+#define __NR_io_uring_setup 425
+#define __NR_io_uring_enter 426
+#define __NR_io_uring_register 427
+#define __NR_open_tree 428
+#define __NR_move_mount 429
+#define __NR_fsopen 430
+#define __NR_fsconfig 431
+#define __NR_fsmount 432
+#define __NR_fspick 433
+#define __NR_pidfd_open 434
+#define __NR_clone3 435
+#define __NR_close_range 436
+#define __NR_openat2 437
+#define __NR_pidfd_getfd 438
+#define __NR_faccessat2 439
+#define __NR_process_madvise 440
+#define __NR_epoll_pwait2 441
+#define __NR_mount_setattr 442
+#define __NR_quotactl_fd 443
+#define __NR_landlock_create_ruleset 444
+#define __NR_landlock_add_rule 445
+#define __NR_landlock_restrict_self 446
+#define __NR_process_mrelease 448
+#define __NR_futex_waitv 449
+#define __NR_set_mempolicy_home_node 450
+
+
+#endif /* _ASM_UNISTD_32_H */ \ No newline at end of file
diff --git a/lib/libc/wasi/libc-bottom-half/crt/crt1-reactor.c b/lib/libc/wasi/libc-bottom-half/crt/crt1-reactor.c
index f507c9efa3..ea4a84f8de 100644
--- a/lib/libc/wasi/libc-bottom-half/crt/crt1-reactor.c
+++ b/lib/libc/wasi/libc-bottom-half/crt/crt1-reactor.c
@@ -1,7 +1,27 @@
+#if defined(_REENTRANT)
+#include <stdatomic.h>
+extern void __wasi_init_tp(void);
+#endif
extern void __wasm_call_ctors(void);
__attribute__((export_name("_initialize")))
void _initialize(void) {
+#if defined(_REENTRANT)
+ static volatile atomic_int initialized = 0;
+ int expected = 0;
+ if (!atomic_compare_exchange_strong(&initialized, &expected, 1)) {
+ __builtin_trap();
+ }
+
+ __wasi_init_tp();
+#else
+ static volatile int initialized = 0;
+ if (initialized != 0) {
+ __builtin_trap();
+ }
+ initialized = 1;
+#endif
+
// The linker synthesizes this to call constructors.
__wasm_call_ctors();
}
diff --git a/lib/libc/wasi/libc-bottom-half/sources/__errno_location.c b/lib/libc/wasi/libc-bottom-half/sources/__errno_location.c
new file mode 100644
index 0000000000..5e6ef5e6bf
--- /dev/null
+++ b/lib/libc/wasi/libc-bottom-half/sources/__errno_location.c
@@ -0,0 +1,5 @@
+#include <errno.h>
+
+int *__errno_location(void) {
+ return &errno;
+}
diff --git a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c
index d2e6b71c64..186de01831 100644
--- a/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c
+++ b/lib/libc/wasi/libc-bottom-half/sources/__wasilibc_real.c
@@ -662,7 +662,7 @@ __wasi_errno_t __wasi_sock_shutdown(
#ifdef _REENTRANT
int32_t __imported_wasi_thread_spawn(int32_t arg0) __attribute__((
__import_module__("wasi"),
- __import_name__("thread_spawn")
+ __import_name__("thread-spawn")
));
int32_t __wasi_thread_spawn(void* start_arg) {
diff --git a/lib/libc/wasi/libc-top-half/musl/arch/wasm32/atomic_arch.h b/lib/libc/wasi/libc-top-half/musl/arch/wasm32/atomic_arch.h
index dd9428c942..c24ce2d7b1 100644
--- a/lib/libc/wasi/libc-top-half/musl/arch/wasm32/atomic_arch.h
+++ b/lib/libc/wasi/libc-top-half/musl/arch/wasm32/atomic_arch.h
@@ -1,4 +1,3 @@
-#define a_barrier() (__sync_synchronize())
#define a_cas(p, t, s) (__sync_val_compare_and_swap((p), (t), (s)))
#define a_crash() (__builtin_trap())
#define a_clz_32 __builtin_clz
diff --git a/lib/libc/wasi/libc-top-half/musl/include/pthread.h b/lib/libc/wasi/libc-top-half/musl/include/pthread.h
index b14fe826d7..05101e8eb2 100644
--- a/lib/libc/wasi/libc-top-half/musl/include/pthread.h
+++ b/lib/libc/wasi/libc-top-half/musl/include/pthread.h
@@ -55,15 +55,9 @@ extern "C" {
#define PTHREAD_PROCESS_SHARED 1
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
#define PTHREAD_MUTEX_INITIALIZER {{{0}}}
#define PTHREAD_RWLOCK_INITIALIZER {{{0}}}
#define PTHREAD_COND_INITIALIZER {{{0}}}
-#else
-#define PTHREAD_MUTEX_INITIALIZER 0
-#define PTHREAD_RWLOCK_INITIALIZER 0
-#define PTHREAD_COND_INITIALIZER 0
-#endif
#define PTHREAD_ONCE_INIT 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/aio/aio.c b/lib/libc/wasi/libc-top-half/musl/src/aio/aio.c
deleted file mode 100644
index a1a3e7914b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/aio/aio.c
+++ /dev/null
@@ -1,418 +0,0 @@
-#include <aio.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <limits.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/auxv.h>
-#include "syscall.h"
-#include "atomic.h"
-#include "pthread_impl.h"
-#include "aio_impl.h"
-
-#define malloc __libc_malloc
-#define calloc __libc_calloc
-#define realloc __libc_realloc
-#define free __libc_free
-
-/* The following is a threads-based implementation of AIO with minimal
- * dependence on implementation details. Most synchronization is
- * performed with pthread primitives, but atomics and futex operations
- * are used for notification in a couple places where the pthread
- * primitives would be inefficient or impractical.
- *
- * For each fd with outstanding aio operations, an aio_queue structure
- * is maintained. These are reference-counted and destroyed by the last
- * aio worker thread to exit. Accessing any member of the aio_queue
- * structure requires a lock on the aio_queue. Adding and removing aio
- * queues themselves requires a write lock on the global map object,
- * a 4-level table mapping file descriptor numbers to aio queues. A
- * read lock on the map is used to obtain locks on existing queues by
- * excluding destruction of the queue by a different thread while it is
- * being locked.
- *
- * Each aio queue has a list of active threads/operations. Presently there
- * is a one to one relationship between threads and operations. The only
- * members of the aio_thread structure which are accessed by other threads
- * are the linked list pointers, op (which is immutable), running (which
- * is updated atomically), and err (which is synchronized via running),
- * so no locking is necessary. Most of the other other members are used
- * for sharing data between the main flow of execution and cancellation
- * cleanup handler.
- *
- * Taking any aio locks requires having all signals blocked. This is
- * necessary because aio_cancel is needed by close, and close is required
- * to be async-signal safe. All aio worker threads run with all signals
- * blocked permanently.
- */
-
-struct aio_thread {
- pthread_t td;
- struct aiocb *cb;
- struct aio_thread *next, *prev;
- struct aio_queue *q;
- volatile int running;
- int err, op;
- ssize_t ret;
-};
-
-struct aio_queue {
- int fd, seekable, append, ref, init;
- pthread_mutex_t lock;
- pthread_cond_t cond;
- struct aio_thread *head;
-};
-
-struct aio_args {
- struct aiocb *cb;
- struct aio_queue *q;
- int op;
- sem_t sem;
-};
-
-static pthread_rwlock_t maplock = PTHREAD_RWLOCK_INITIALIZER;
-static struct aio_queue *****map;
-static volatile int aio_fd_cnt;
-volatile int __aio_fut;
-
-static size_t io_thread_stack_size;
-
-#define MAX(a,b) ((a)>(b) ? (a) : (b))
-
-static struct aio_queue *__aio_get_queue(int fd, int need)
-{
- if (fd < 0) {
- errno = EBADF;
- return 0;
- }
- int a=fd>>24;
- unsigned char b=fd>>16, c=fd>>8, d=fd;
- struct aio_queue *q = 0;
- pthread_rwlock_rdlock(&maplock);
- if ((!map || !map[a] || !map[a][b] || !map[a][b][c] || !(q=map[a][b][c][d])) && need) {
- pthread_rwlock_unlock(&maplock);
- if (fcntl(fd, F_GETFD) < 0) return 0;
- pthread_rwlock_wrlock(&maplock);
- if (!io_thread_stack_size) {
- unsigned long val = __getauxval(AT_MINSIGSTKSZ);
- io_thread_stack_size = MAX(MINSIGSTKSZ+2048, val+512);
- }
- if (!map) map = calloc(sizeof *map, (-1U/2+1)>>24);
- if (!map) goto out;
- if (!map[a]) map[a] = calloc(sizeof **map, 256);
- if (!map[a]) goto out;
- if (!map[a][b]) map[a][b] = calloc(sizeof ***map, 256);
- if (!map[a][b]) goto out;
- if (!map[a][b][c]) map[a][b][c] = calloc(sizeof ****map, 256);
- if (!map[a][b][c]) goto out;
- if (!(q = map[a][b][c][d])) {
- map[a][b][c][d] = q = calloc(sizeof *****map, 1);
- if (q) {
- q->fd = fd;
- pthread_mutex_init(&q->lock, 0);
- pthread_cond_init(&q->cond, 0);
- a_inc(&aio_fd_cnt);
- }
- }
- }
- if (q) pthread_mutex_lock(&q->lock);
-out:
- pthread_rwlock_unlock(&maplock);
- return q;
-}
-
-static void __aio_unref_queue(struct aio_queue *q)
-{
- if (q->ref > 1) {
- q->ref--;
- pthread_mutex_unlock(&q->lock);
- return;
- }
-
- /* This is potentially the last reference, but a new reference
- * may arrive since we cannot free the queue object without first
- * taking the maplock, which requires releasing the queue lock. */
- pthread_mutex_unlock(&q->lock);
- pthread_rwlock_wrlock(&maplock);
- pthread_mutex_lock(&q->lock);
- if (q->ref == 1) {
- int fd=q->fd;
- int a=fd>>24;
- unsigned char b=fd>>16, c=fd>>8, d=fd;
- map[a][b][c][d] = 0;
- a_dec(&aio_fd_cnt);
- pthread_rwlock_unlock(&maplock);
- pthread_mutex_unlock(&q->lock);
- free(q);
- } else {
- q->ref--;
- pthread_rwlock_unlock(&maplock);
- pthread_mutex_unlock(&q->lock);
- }
-}
-
-static void cleanup(void *ctx)
-{
- struct aio_thread *at = ctx;
- struct aio_queue *q = at->q;
- struct aiocb *cb = at->cb;
- struct sigevent sev = cb->aio_sigevent;
-
- /* There are four potential types of waiters we could need to wake:
- * 1. Callers of aio_cancel/close.
- * 2. Callers of aio_suspend with a single aiocb.
- * 3. Callers of aio_suspend with a list.
- * 4. AIO worker threads waiting for sequenced operations.
- * Types 1-3 are notified via atomics/futexes, mainly for AS-safety
- * considerations. Type 4 is notified later via a cond var. */
-
- cb->__ret = at->ret;
- if (a_swap(&at->running, 0) < 0)
- __wake(&at->running, -1, 1);
- if (a_swap(&cb->__err, at->err) != EINPROGRESS)
- __wake(&cb->__err, -1, 1);
- if (a_swap(&__aio_fut, 0))
- __wake(&__aio_fut, -1, 1);
-
- pthread_mutex_lock(&q->lock);
-
- if (at->next) at->next->prev = at->prev;
- if (at->prev) at->prev->next = at->next;
- else q->head = at->next;
-
- /* Signal aio worker threads waiting for sequenced operations. */
- pthread_cond_broadcast(&q->cond);
-
- __aio_unref_queue(q);
-
- if (sev.sigev_notify == SIGEV_SIGNAL) {
- siginfo_t si = {
- .si_signo = sev.sigev_signo,
- .si_value = sev.sigev_value,
- .si_code = SI_ASYNCIO,
- .si_pid = getpid(),
- .si_uid = getuid()
- };
- __syscall(SYS_rt_sigqueueinfo, si.si_pid, si.si_signo, &si);
- }
- if (sev.sigev_notify == SIGEV_THREAD) {
- a_store(&__pthread_self()->cancel, 0);
- sev.sigev_notify_function(sev.sigev_value);
- }
-}
-
-static void *io_thread_func(void *ctx)
-{
- struct aio_thread at, *p;
-
- struct aio_args *args = ctx;
- struct aiocb *cb = args->cb;
- int fd = cb->aio_fildes;
- int op = args->op;
- void *buf = (void *)cb->aio_buf;
- size_t len = cb->aio_nbytes;
- off_t off = cb->aio_offset;
-
- struct aio_queue *q = args->q;
- ssize_t ret;
-
- pthread_mutex_lock(&q->lock);
- sem_post(&args->sem);
-
- at.op = op;
- at.running = 1;
- at.ret = -1;
- at.err = ECANCELED;
- at.q = q;
- at.td = __pthread_self();
- at.cb = cb;
- at.prev = 0;
- if ((at.next = q->head)) at.next->prev = &at;
- q->head = &at;
-
- if (!q->init) {
- int seekable = lseek(fd, 0, SEEK_CUR) >= 0;
- q->seekable = seekable;
- q->append = !seekable || (fcntl(fd, F_GETFL) & O_APPEND);
- q->init = 1;
- }
-
- pthread_cleanup_push(cleanup, &at);
-
- /* Wait for sequenced operations. */
- if (op!=LIO_READ && (op!=LIO_WRITE || q->append)) {
- for (;;) {
- for (p=at.next; p && p->op!=LIO_WRITE; p=p->next);
- if (!p) break;
- pthread_cond_wait(&q->cond, &q->lock);
- }
- }
-
- pthread_mutex_unlock(&q->lock);
-
- switch (op) {
- case LIO_WRITE:
- ret = q->append ? write(fd, buf, len) : pwrite(fd, buf, len, off);
- break;
- case LIO_READ:
- ret = !q->seekable ? read(fd, buf, len) : pread(fd, buf, len, off);
- break;
- case O_SYNC:
- ret = fsync(fd);
- break;
- case O_DSYNC:
- ret = fdatasync(fd);
- break;
- }
- at.ret = ret;
- at.err = ret<0 ? errno : 0;
-
- pthread_cleanup_pop(1);
-
- return 0;
-}
-
-static int submit(struct aiocb *cb, int op)
-{
- int ret = 0;
- pthread_attr_t a;
- sigset_t allmask, origmask;
- pthread_t td;
- struct aio_queue *q = __aio_get_queue(cb->aio_fildes, 1);
- struct aio_args args = { .cb = cb, .op = op, .q = q };
- sem_init(&args.sem, 0, 0);
-
- if (!q) {
- if (errno != EBADF) errno = EAGAIN;
- cb->__ret = -1;
- cb->__err = errno;
- return -1;
- }
- q->ref++;
- pthread_mutex_unlock(&q->lock);
-
- if (cb->aio_sigevent.sigev_notify == SIGEV_THREAD) {
- if (cb->aio_sigevent.sigev_notify_attributes)
- a = *cb->aio_sigevent.sigev_notify_attributes;
- else
- pthread_attr_init(&a);
- } else {
- pthread_attr_init(&a);
- pthread_attr_setstacksize(&a, io_thread_stack_size);
- pthread_attr_setguardsize(&a, 0);
- }
- pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
- sigfillset(&allmask);
- pthread_sigmask(SIG_BLOCK, &allmask, &origmask);
- cb->__err = EINPROGRESS;
- if (pthread_create(&td, &a, io_thread_func, &args)) {
- pthread_mutex_lock(&q->lock);
- __aio_unref_queue(q);
- cb->__err = errno = EAGAIN;
- cb->__ret = ret = -1;
- }
- pthread_sigmask(SIG_SETMASK, &origmask, 0);
-
- if (!ret) {
- while (sem_wait(&args.sem));
- }
-
- return ret;
-}
-
-int aio_read(struct aiocb *cb)
-{
- return submit(cb, LIO_READ);
-}
-
-int aio_write(struct aiocb *cb)
-{
- return submit(cb, LIO_WRITE);
-}
-
-int aio_fsync(int op, struct aiocb *cb)
-{
- if (op != O_SYNC && op != O_DSYNC) {
- errno = EINVAL;
- return -1;
- }
- return submit(cb, op);
-}
-
-ssize_t aio_return(struct aiocb *cb)
-{
- return cb->__ret;
-}
-
-int aio_error(const struct aiocb *cb)
-{
- a_barrier();
- return cb->__err & 0x7fffffff;
-}
-
-int aio_cancel(int fd, struct aiocb *cb)
-{
- sigset_t allmask, origmask;
- int ret = AIO_ALLDONE;
- struct aio_thread *p;
- struct aio_queue *q;
-
- /* Unspecified behavior case. Report an error. */
- if (cb && fd != cb->aio_fildes) {
- errno = EINVAL;
- return -1;
- }
-
- sigfillset(&allmask);
- pthread_sigmask(SIG_BLOCK, &allmask, &origmask);
-
- errno = ENOENT;
- if (!(q = __aio_get_queue(fd, 0))) {
- if (errno == EBADF) ret = -1;
- goto done;
- }
-
- for (p = q->head; p; p = p->next) {
- if (cb && cb != p->cb) continue;
- /* Transition target from running to running-with-waiters */
- if (a_cas(&p->running, 1, -1)) {
- pthread_cancel(p->td);
- __wait(&p->running, 0, -1, 1);
- if (p->err == ECANCELED) ret = AIO_CANCELED;
- }
- }
-
- pthread_mutex_unlock(&q->lock);
-done:
- pthread_sigmask(SIG_SETMASK, &origmask, 0);
- return ret;
-}
-
-int __aio_close(int fd)
-{
- a_barrier();
- if (aio_fd_cnt) aio_cancel(fd, 0);
- return fd;
-}
-
-void __aio_atfork(int who)
-{
- if (who<0) {
- pthread_rwlock_rdlock(&maplock);
- return;
- }
- if (who>0 && map) for (int a=0; a<(-1U/2+1)>>24; a++)
- if (map[a]) for (int b=0; b<256; b++)
- if (map[a][b]) for (int c=0; c<256; c++)
- if (map[a][b][c]) for (int d=0; d<256; d++)
- map[a][b][c][d] = 0;
- pthread_rwlock_unlock(&maplock);
-}
-
-weak_alias(aio_cancel, aio_cancel64);
-weak_alias(aio_error, aio_error64);
-weak_alias(aio_fsync, aio_fsync64);
-weak_alias(aio_read, aio_read64);
-weak_alias(aio_write, aio_write64);
-weak_alias(aio_return, aio_return64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/aio/aio_suspend.c b/lib/libc/wasi/libc-top-half/musl/src/aio/aio_suspend.c
deleted file mode 100644
index 1c1060e340..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/aio/aio_suspend.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include <aio.h>
-#include <errno.h>
-#include <time.h>
-#include "atomic.h"
-#include "pthread_impl.h"
-#include "aio_impl.h"
-
-int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec *ts)
-{
- int i, tid = 0, ret, expect = 0;
- struct timespec at;
- volatile int dummy_fut, *pfut;
- int nzcnt = 0;
- const struct aiocb *cb = 0;
-
- pthread_testcancel();
-
- if (cnt<0) {
- errno = EINVAL;
- return -1;
- }
-
- for (i=0; i<cnt; i++) if (cbs[i]) {
- if (aio_error(cbs[i]) != EINPROGRESS) return 0;
- nzcnt++;
- cb = cbs[i];
- }
-
- if (ts) {
- clock_gettime(CLOCK_MONOTONIC, &at);
- at.tv_sec += ts->tv_sec;
- if ((at.tv_nsec += ts->tv_nsec) >= 1000000000) {
- at.tv_nsec -= 1000000000;
- at.tv_sec++;
- }
- }
-
- for (;;) {
- for (i=0; i<cnt; i++)
- if (cbs[i] && aio_error(cbs[i]) != EINPROGRESS)
- return 0;
-
- switch (nzcnt) {
- case 0:
- pfut = &dummy_fut;
- break;
- case 1:
- pfut = (void *)&cb->__err;
- expect = EINPROGRESS | 0x80000000;
- a_cas(pfut, EINPROGRESS, expect);
- break;
- default:
- pfut = &__aio_fut;
- if (!tid) tid = __pthread_self()->tid;
- expect = a_cas(pfut, 0, tid);
- if (!expect) expect = tid;
- /* Need to recheck the predicate before waiting. */
- for (i=0; i<cnt; i++)
- if (cbs[i] && aio_error(cbs[i]) != EINPROGRESS)
- return 0;
- break;
- }
-
- ret = __timedwait_cp(pfut, expect, CLOCK_MONOTONIC, ts?&at:0, 1);
-
- switch (ret) {
- case ETIMEDOUT:
- ret = EAGAIN;
- case ECANCELED:
- case EINTR:
- errno = ret;
- return -1;
- }
- }
-}
-
-#if !_REDIR_TIME64
-weak_alias(aio_suspend, aio_suspend64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/aio/lio_listio.c b/lib/libc/wasi/libc-top-half/musl/src/aio/lio_listio.c
deleted file mode 100644
index 0799c15d8b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/aio/lio_listio.c
+++ /dev/null
@@ -1,143 +0,0 @@
-#include <aio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-#include "pthread_impl.h"
-
-struct lio_state {
- struct sigevent *sev;
- int cnt;
- struct aiocb *cbs[];
-};
-
-static int lio_wait(struct lio_state *st)
-{
- int i, err, got_err = 0;
- int cnt = st->cnt;
- struct aiocb **cbs = st->cbs;
-
- for (;;) {
- for (i=0; i<cnt; i++) {
- if (!cbs[i]) continue;
- err = aio_error(cbs[i]);
- if (err==EINPROGRESS)
- break;
- if (err) got_err=1;
- cbs[i] = 0;
- }
- if (i==cnt) {
- if (got_err) {
- errno = EIO;
- return -1;
- }
- return 0;
- }
- if (aio_suspend((void *)cbs, cnt, 0))
- return -1;
- }
-}
-
-static void notify_signal(struct sigevent *sev)
-{
- siginfo_t si = {
- .si_signo = sev->sigev_signo,
- .si_value = sev->sigev_value,
- .si_code = SI_ASYNCIO,
- .si_pid = getpid(),
- .si_uid = getuid()
- };
- __syscall(SYS_rt_sigqueueinfo, si.si_pid, si.si_signo, &si);
-}
-
-static void *wait_thread(void *p)
-{
- struct lio_state *st = p;
- struct sigevent *sev = st->sev;
- lio_wait(st);
- free(st);
- switch (sev->sigev_notify) {
- case SIGEV_SIGNAL:
- notify_signal(sev);
- break;
- case SIGEV_THREAD:
- sev->sigev_notify_function(sev->sigev_value);
- break;
- }
- return 0;
-}
-
-int lio_listio(int mode, struct aiocb *restrict const *restrict cbs, int cnt, struct sigevent *restrict sev)
-{
- int i, ret;
- struct lio_state *st=0;
-
- if (cnt < 0) {
- errno = EINVAL;
- return -1;
- }
-
- if (mode == LIO_WAIT || (sev && sev->sigev_notify != SIGEV_NONE)) {
- if (!(st = malloc(sizeof *st + cnt*sizeof *cbs))) {
- errno = EAGAIN;
- return -1;
- }
- st->cnt = cnt;
- st->sev = sev;
- memcpy(st->cbs, (void*) cbs, cnt*sizeof *cbs);
- }
-
- for (i=0; i<cnt; i++) {
- if (!cbs[i]) continue;
- switch (cbs[i]->aio_lio_opcode) {
- case LIO_READ:
- ret = aio_read(cbs[i]);
- break;
- case LIO_WRITE:
- ret = aio_write(cbs[i]);
- break;
- default:
- continue;
- }
- if (ret) {
- free(st);
- errno = EAGAIN;
- return -1;
- }
- }
-
- if (mode == LIO_WAIT) {
- ret = lio_wait(st);
- free(st);
- return ret;
- }
-
- if (st) {
- pthread_attr_t a;
- sigset_t set, set_old;
- pthread_t td;
-
- if (sev->sigev_notify == SIGEV_THREAD) {
- if (sev->sigev_notify_attributes)
- a = *sev->sigev_notify_attributes;
- else
- pthread_attr_init(&a);
- } else {
- pthread_attr_init(&a);
- pthread_attr_setstacksize(&a, PAGE_SIZE);
- pthread_attr_setguardsize(&a, 0);
- }
- pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);
- sigfillset(&set);
- pthread_sigmask(SIG_BLOCK, &set, &set_old);
- if (pthread_create(&td, &a, wait_thread, st)) {
- free(st);
- errno = EAGAIN;
- return -1;
- }
- pthread_sigmask(SIG_SETMASK, &set_old, 0);
- }
-
- return 0;
-}
-
-weak_alias(lio_listio, lio_listio64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/cimag.c b/lib/libc/wasi/libc-top-half/musl/src/complex/cimag.c
deleted file mode 100644
index d6b0e6838c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/cimag.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "complex_impl.h"
-
-double (cimag)(double complex z)
-{
- return cimag(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/cimagf.c b/lib/libc/wasi/libc-top-half/musl/src/complex/cimagf.c
deleted file mode 100644
index b7166dcfa9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/cimagf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "complex_impl.h"
-
-float (cimagf)(float complex z)
-{
- return cimagf(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/cimagl.c b/lib/libc/wasi/libc-top-half/musl/src/complex/cimagl.c
deleted file mode 100644
index 4db77f201e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/cimagl.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "complex_impl.h"
-
-long double (cimagl)(long double complex z)
-{
- return cimagl(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/creal.c b/lib/libc/wasi/libc-top-half/musl/src/complex/creal.c
deleted file mode 100644
index f6703040d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/creal.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-
-double (creal)(double complex z)
-{
- return creal(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/crealf.c b/lib/libc/wasi/libc-top-half/musl/src/complex/crealf.c
deleted file mode 100644
index 5dc3ff1d30..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/crealf.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-
-float (crealf)(float complex z)
-{
- return crealf(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/complex/creall.c b/lib/libc/wasi/libc-top-half/musl/src/complex/creall.c
deleted file mode 100644
index fd9dc3470c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/complex/creall.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <complex.h>
-
-long double (creall)(long double complex z)
-{
- return creall(z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/closedir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/closedir.c
deleted file mode 100644
index e794ae9ca4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/closedir.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <dirent.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include "__dirent.h"
-
-int closedir(DIR *dir)
-{
- int ret = close(dir->fd);
- free(dir);
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/dirfd.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/dirfd.c
deleted file mode 100644
index 6c86007399..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/dirfd.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <dirent.h>
-#include "__dirent.h"
-
-int dirfd(DIR *d)
-{
- return d->fd;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/fdopendir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/fdopendir.c
deleted file mode 100644
index d78fb87f9b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/fdopendir.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <dirent.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include "__dirent.h"
-
-DIR *fdopendir(int fd)
-{
- DIR *dir;
- struct stat st;
-
- if (fstat(fd, &st) < 0) {
- return 0;
- }
- if (fcntl(fd, F_GETFL) & O_PATH) {
- errno = EBADF;
- return 0;
- }
- if (!S_ISDIR(st.st_mode)) {
- errno = ENOTDIR;
- return 0;
- }
- if (!(dir = calloc(1, sizeof *dir))) {
- return 0;
- }
-
- fcntl(fd, F_SETFD, FD_CLOEXEC);
- dir->fd = fd;
- return dir;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/opendir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/opendir.c
deleted file mode 100644
index 5cb84e303f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/opendir.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#define _GNU_SOURCE
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include "__dirent.h"
-#include "syscall.h"
-
-DIR *opendir(const char *name)
-{
- int fd;
- DIR *dir;
-
- if ((fd = open(name, O_RDONLY|O_DIRECTORY|O_CLOEXEC)) < 0)
- return 0;
- if (!(dir = calloc(1, sizeof *dir))) {
- __syscall(SYS_close, fd);
- return 0;
- }
- dir->fd = fd;
- return dir;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir.c
deleted file mode 100644
index 569fc70577..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <dirent.h>
-#include <errno.h>
-#include <stddef.h>
-#include "__dirent.h"
-#include "syscall.h"
-
-typedef char dirstream_buf_alignment_check[1-2*(int)(
- offsetof(struct __dirstream, buf) % sizeof(off_t))];
-
-struct dirent *readdir(DIR *dir)
-{
- struct dirent *de;
-
- if (dir->buf_pos >= dir->buf_end) {
- int len = __syscall(SYS_getdents, dir->fd, dir->buf, sizeof dir->buf);
- if (len <= 0) {
- if (len < 0 && len != -ENOENT) errno = -len;
- return 0;
- }
- dir->buf_end = len;
- dir->buf_pos = 0;
- }
- de = (void *)(dir->buf + dir->buf_pos);
- dir->buf_pos += de->d_reclen;
- dir->tell = de->d_off;
- return de;
-}
-
-weak_alias(readdir, readdir64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir_r.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir_r.c
deleted file mode 100644
index e2a818f36a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/readdir_r.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-#include "__dirent.h"
-#include "lock.h"
-
-int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **restrict result)
-{
- struct dirent *de;
- int errno_save = errno;
- int ret;
-
- LOCK(dir->lock);
- errno = 0;
- de = readdir(dir);
- if ((ret = errno)) {
- UNLOCK(dir->lock);
- return ret;
- }
- errno = errno_save;
- if (de) memcpy(buf, de, de->d_reclen);
- else buf = NULL;
-
- UNLOCK(dir->lock);
- *result = buf;
- return 0;
-}
-
-weak_alias(readdir_r, readdir64_r);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/rewinddir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/rewinddir.c
deleted file mode 100644
index 7ddda43721..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/rewinddir.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <dirent.h>
-#include <unistd.h>
-#include "__dirent.h"
-#include "lock.h"
-
-void rewinddir(DIR *dir)
-{
- LOCK(dir->lock);
- lseek(dir->fd, 0, SEEK_SET);
- dir->buf_pos = dir->buf_end = 0;
- dir->tell = 0;
- UNLOCK(dir->lock);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/scandir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/scandir.c
deleted file mode 100644
index 7ee195dd8a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/scandir.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <dirent.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <errno.h>
-#include <stddef.h>
-
-int scandir(const char *path, struct dirent ***res,
- int (*sel)(const struct dirent *),
- int (*cmp)(const struct dirent **, const struct dirent **))
-{
- DIR *d = opendir(path);
- struct dirent *de, **names=0, **tmp;
- size_t cnt=0, len=0;
- int old_errno = errno;
-
- if (!d) return -1;
-
- while ((errno=0), (de = readdir(d))) {
- if (sel && !sel(de)) continue;
- if (cnt >= len) {
- len = 2*len+1;
- if (len > SIZE_MAX/sizeof *names) break;
- tmp = realloc(names, len * sizeof *names);
- if (!tmp) break;
- names = tmp;
- }
- names[cnt] = malloc(de->d_reclen);
- if (!names[cnt]) break;
- memcpy(names[cnt++], de, de->d_reclen);
- }
-
- closedir(d);
-
- if (errno) {
- if (names) while (cnt-->0) free(names[cnt]);
- free(names);
- return -1;
- }
- errno = old_errno;
-
- if (cmp) qsort(names, cnt, sizeof *names, (int (*)(const void *, const void *))cmp);
- *res = names;
- return cnt;
-}
-
-weak_alias(scandir, scandir64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/seekdir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/seekdir.c
deleted file mode 100644
index bf6cc6ec40..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/seekdir.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <dirent.h>
-#include <unistd.h>
-#include "__dirent.h"
-#include "lock.h"
-
-void seekdir(DIR *dir, long off)
-{
- LOCK(dir->lock);
- dir->tell = lseek(dir->fd, off, SEEK_SET);
- dir->buf_pos = dir->buf_end = 0;
- UNLOCK(dir->lock);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/dirent/telldir.c b/lib/libc/wasi/libc-top-half/musl/src/dirent/telldir.c
deleted file mode 100644
index cf25acff63..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/dirent/telldir.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <dirent.h>
-#include "__dirent.h"
-
-long telldir(DIR *dir)
-{
- return dir->tell;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/env/__environ.c b/lib/libc/wasi/libc-top-half/musl/src/env/__environ.c
deleted file mode 100644
index fe8abcf990..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/env/__environ.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <unistd.h>
-
-char **__environ = 0;
-weak_alias(__environ, ___environ);
-weak_alias(__environ, _environ);
-weak_alias(__environ, environ);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/env/__init_tls.c b/lib/libc/wasi/libc-top-half/musl/src/env/__init_tls.c
deleted file mode 100644
index ece8d24e86..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/env/__init_tls.c
+++ /dev/null
@@ -1,237 +0,0 @@
-#ifdef __wasilibc_unmodified_upstream
-#define SYSCALL_NO_TLS 1
-#include <elf.h>
-#endif
-#include <limits.h>
-#ifdef __wasilibc_unmodified_upstream
-#include <sys/mman.h>
-#endif
-#include <string.h>
-#include <stddef.h>
-#include "pthread_impl.h"
-#include "libc.h"
-#include "atomic.h"
-#include "syscall.h"
-
-volatile int __thread_list_lock;
-
-#ifndef __wasilibc_unmodified_upstream
-
-/* These symbols are generated by wasm-ld. __stack_high/__stack_low
- * symbols are only available in LLVM v16 and higher, therefore they're
- * defined as weak symbols and if not available, __heap_base/__data_end
- * is used instead.
- *
- * TODO: remove usage of __heap_base/__data_end for stack size calculation
- * once we drop support for LLVM v15 and older.
- */
-extern unsigned char __heap_base;
-extern unsigned char __data_end;
-extern unsigned char __global_base;
-extern weak unsigned char __stack_high;
-extern weak unsigned char __stack_low;
-
-static inline void setup_default_stack_size()
-{
- ptrdiff_t stack_size;
-
- if (&__stack_high)
- stack_size = &__stack_high - &__stack_low;
- else {
- unsigned char *sp;
- __asm__(
- ".globaltype __stack_pointer, i32\n"
- "global.get __stack_pointer\n"
- "local.set %0\n"
- : "=r"(sp));
- stack_size = sp > &__global_base ? &__heap_base - &__data_end : (ptrdiff_t)&__global_base;
- }
-
- if (stack_size > __default_stacksize)
- __default_stacksize =
- stack_size < DEFAULT_STACK_MAX ?
- stack_size : DEFAULT_STACK_MAX;
-}
-
-void __wasi_init_tp() {
- __init_tp((void *)__get_tp());
-}
-#endif
-
-int __init_tp(void *p)
-{
- pthread_t td = p;
- td->self = td;
-#ifdef __wasilibc_unmodified_upstream
- int r = __set_thread_area(TP_ADJ(p));
- if (r < 0) return -1;
- if (!r) libc.can_do_threads = 1;
- td->detach_state = DT_JOINABLE;
- td->tid = __syscall(SYS_set_tid_address, &__thread_list_lock);
-#else
- setup_default_stack_size();
- td->detach_state = DT_JOINABLE;
- /*
- * Initialize the TID to a value which doesn't conflict with
- * host-allocated TIDs, so that TID-based locks can work.
- *
- * Note:
- * - Host-allocated TIDs range from 1 to 0x1fffffff. (inclusive)
- * - __tl_lock and __lockfile uses TID 0 as "unlocked".
- * - __lockfile relies on the fact the most significant two bits
- * of TIDs are 0.
- */
- td->tid = 0x3fffffff;
-#endif
- td->locale = &libc.global_locale;
- td->robust_list.head = &td->robust_list.head;
- td->sysinfo = __sysinfo;
- td->next = td->prev = td;
- return 0;
-}
-
-#ifdef __wasilibc_unmodified_upstream
-
-static struct builtin_tls {
- char c;
- struct pthread pt;
- void *space[16];
-} builtin_tls[1];
-#define MIN_TLS_ALIGN offsetof(struct builtin_tls, pt)
-
-static struct tls_module main_tls;
-#endif
-
-#ifndef __wasilibc_unmodified_upstream
-extern void __wasm_init_tls(void*);
-#endif
-
-void *__copy_tls(unsigned char *mem)
-{
-#ifdef __wasilibc_unmodified_upstream
- pthread_t td;
- struct tls_module *p;
- size_t i;
- uintptr_t *dtv;
-
-#ifdef TLS_ABOVE_TP
- dtv = (uintptr_t*)(mem + libc.tls_size) - (libc.tls_cnt + 1);
-
- mem += -((uintptr_t)mem + sizeof(struct pthread)) & (libc.tls_align-1);
- td = (pthread_t)mem;
- mem += sizeof(struct pthread);
-
- for (i=1, p=libc.tls_head; p; i++, p=p->next) {
- dtv[i] = (uintptr_t)(mem + p->offset) + DTP_OFFSET;
- memcpy(mem + p->offset, p->image, p->len);
- }
-#else
- dtv = (uintptr_t *)mem;
-
- mem += libc.tls_size - sizeof(struct pthread);
- mem -= (uintptr_t)mem & (libc.tls_align-1);
- td = (pthread_t)mem;
-
- for (i=1, p=libc.tls_head; p; i++, p=p->next) {
- dtv[i] = (uintptr_t)(mem - p->offset) + DTP_OFFSET;
- memcpy(mem - p->offset, p->image, p->len);
- }
-#endif
- dtv[0] = libc.tls_cnt;
- td->dtv = dtv;
- return td;
-#else
- size_t tls_align = __builtin_wasm_tls_align();
- volatile void* tls_base = __builtin_wasm_tls_base();
- mem += tls_align;
- mem -= (uintptr_t)mem & (tls_align-1);
- __wasm_init_tls(mem);
- __asm__("local.get %0\n"
- "global.set __tls_base\n"
- :: "r"(tls_base));
- return mem;
-#endif
-}
-
-#ifdef __wasilibc_unmodified_upstream
-#if ULONG_MAX == 0xffffffff
-typedef Elf32_Phdr Phdr;
-#else
-typedef Elf64_Phdr Phdr;
-#endif
-
-extern weak hidden const size_t _DYNAMIC[];
-
-static void static_init_tls(size_t *aux)
-{
- unsigned char *p;
- size_t n;
- Phdr *phdr, *tls_phdr=0;
- size_t base = 0;
- void *mem;
-
- for (p=(void *)aux[AT_PHDR],n=aux[AT_PHNUM]; n; n--,p+=aux[AT_PHENT]) {
- phdr = (void *)p;
- if (phdr->p_type == PT_PHDR)
- base = aux[AT_PHDR] - phdr->p_vaddr;
- if (phdr->p_type == PT_DYNAMIC && _DYNAMIC)
- base = (size_t)_DYNAMIC - phdr->p_vaddr;
- if (phdr->p_type == PT_TLS)
- tls_phdr = phdr;
- if (phdr->p_type == PT_GNU_STACK &&
- phdr->p_memsz > __default_stacksize)
- __default_stacksize =
- phdr->p_memsz < DEFAULT_STACK_MAX ?
- phdr->p_memsz : DEFAULT_STACK_MAX;
- }
-
- if (tls_phdr) {
- main_tls.image = (void *)(base + tls_phdr->p_vaddr);
- main_tls.len = tls_phdr->p_filesz;
- main_tls.size = tls_phdr->p_memsz;
- main_tls.align = tls_phdr->p_align;
- libc.tls_cnt = 1;
- libc.tls_head = &main_tls;
- }
-
- main_tls.size += (-main_tls.size - (uintptr_t)main_tls.image)
- & (main_tls.align-1);
-#ifdef TLS_ABOVE_TP
- main_tls.offset = GAP_ABOVE_TP;
- main_tls.offset += (-GAP_ABOVE_TP + (uintptr_t)main_tls.image)
- & (main_tls.align-1);
-#else
- main_tls.offset = main_tls.size;
-#endif
- if (main_tls.align < MIN_TLS_ALIGN) main_tls.align = MIN_TLS_ALIGN;
-
- libc.tls_align = main_tls.align;
- libc.tls_size = 2*sizeof(void *) + sizeof(struct pthread)
-#ifdef TLS_ABOVE_TP
- + main_tls.offset
-#endif
- + main_tls.size + main_tls.align
- + MIN_TLS_ALIGN-1 & -MIN_TLS_ALIGN;
-
- if (libc.tls_size > sizeof builtin_tls) {
-#ifndef SYS_mmap2
-#define SYS_mmap2 SYS_mmap
-#endif
- mem = (void *)__syscall(
- SYS_mmap2,
- 0, libc.tls_size, PROT_READ|PROT_WRITE,
- MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
- /* -4095...-1 cast to void * will crash on dereference anyway,
- * so don't bloat the init code checking for error codes and
- * explicitly calling a_crash(). */
- } else {
- mem = builtin_tls;
- }
-
- /* Failure to initialize thread pointer is always fatal. */
- if (__init_tp(__copy_tls(mem)) < 0)
- a_crash();
-}
-
-weak_alias(static_init_tls, __init_tls);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/env/__libc_start_main.c b/lib/libc/wasi/libc-top-half/musl/src/env/__libc_start_main.c
deleted file mode 100644
index c5b277bdcf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/env/__libc_start_main.c
+++ /dev/null
@@ -1,97 +0,0 @@
-#include <elf.h>
-#include <poll.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <unistd.h>
-#include "syscall.h"
-#include "atomic.h"
-#include "libc.h"
-
-static void dummy(void) {}
-weak_alias(dummy, _init);
-
-extern weak hidden void (*const __init_array_start)(void), (*const __init_array_end)(void);
-
-static void dummy1(void *p) {}
-weak_alias(dummy1, __init_ssp);
-
-#define AUX_CNT 38
-
-#ifdef __GNUC__
-__attribute__((__noinline__))
-#endif
-void __init_libc(char **envp, char *pn)
-{
- size_t i, *auxv, aux[AUX_CNT] = { 0 };
- __environ = envp;
- for (i=0; envp[i]; i++);
- libc.auxv = auxv = (void *)(envp+i+1);
- for (i=0; auxv[i]; i+=2) if (auxv[i]<AUX_CNT) aux[auxv[i]] = auxv[i+1];
- __hwcap = aux[AT_HWCAP];
- if (aux[AT_SYSINFO]) __sysinfo = aux[AT_SYSINFO];
- libc.page_size = aux[AT_PAGESZ];
-
- if (!pn) pn = (void*)aux[AT_EXECFN];
- if (!pn) pn = "";
- __progname = __progname_full = pn;
- for (i=0; pn[i]; i++) if (pn[i]=='/') __progname = pn+i+1;
-
- __init_tls(aux);
- __init_ssp((void *)aux[AT_RANDOM]);
-
- if (aux[AT_UID]==aux[AT_EUID] && aux[AT_GID]==aux[AT_EGID]
- && !aux[AT_SECURE]) return;
-
- struct pollfd pfd[3] = { {.fd=0}, {.fd=1}, {.fd=2} };
- int r =
-#ifdef SYS_poll
- __syscall(SYS_poll, pfd, 3, 0);
-#else
- __syscall(SYS_ppoll, pfd, 3, &(struct timespec){0}, 0, _NSIG/8);
-#endif
- if (r<0) a_crash();
- for (i=0; i<3; i++) if (pfd[i].revents&POLLNVAL)
- if (__sys_open("/dev/null", O_RDWR)<0)
- a_crash();
- libc.secure = 1;
-}
-
-static void libc_start_init(void)
-{
- _init();
- uintptr_t a = (uintptr_t)&__init_array_start;
- for (; a<(uintptr_t)&__init_array_end; a+=sizeof(void(*)()))
- (*(void (**)(void))a)();
-}
-
-weak_alias(libc_start_init, __libc_start_init);
-
-typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
-static lsm2_fn libc_start_main_stage2;
-
-int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv,
- void (*init_dummy)(), void(*fini_dummy)(), void(*ldso_dummy)())
-{
- char **envp = argv+argc+1;
-
- /* External linkage, and explicit noinline attribute if available,
- * are used to prevent the stack frame used during init from
- * persisting for the entire process lifetime. */
- __init_libc(envp, argv[0]);
-
- /* Barrier against hoisting application code or anything using ssp
- * or thread pointer prior to its initialization above. */
- lsm2_fn *stage2 = libc_start_main_stage2;
- __asm__ ( "" : "+r"(stage2) : : "memory" );
- return stage2(main, argc, argv);
-}
-
-static int libc_start_main_stage2(int (*main)(int,char **,char **), int argc, char **argv)
-{
- char **envp = argv+argc+1;
- __libc_start_init();
-
- /* Pass control to the application */
- exit(main(argc, argv, envp));
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/env/__reset_tls.c b/lib/libc/wasi/libc-top-half/musl/src/env/__reset_tls.c
deleted file mode 100644
index 15685bc666..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/env/__reset_tls.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <string.h>
-#include "pthread_impl.h"
-#include "libc.h"
-
-void __reset_tls()
-{
- pthread_t self = __pthread_self();
- struct tls_module *p;
- size_t i, n = self->dtv[0];
- if (n) for (p=libc.tls_head, i=1; i<=n; i++, p=p->next) {
- char *mem = (char *)(self->dtv[i] - DTP_OFFSET);
- memcpy(mem, p->image, p->len);
- memset(mem+p->len, 0, p->size - p->len);
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/env/secure_getenv.c b/lib/libc/wasi/libc-top-half/musl/src/env/secure_getenv.c
deleted file mode 100644
index 72322f811b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/env/secure_getenv.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include "libc.h"
-
-char *secure_getenv(const char *name)
-{
- return libc.secure ? NULL : getenv(name);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/errno/__errno_location.c b/lib/libc/wasi/libc-top-half/musl/src/errno/__errno_location.c
deleted file mode 100644
index 7f9d6027a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/errno/__errno_location.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <errno.h>
-#include "pthread_impl.h"
-
-int *__errno_location(void)
-{
- return &__pthread_self()->errno_val;
-}
-
-weak_alias(__errno_location, ___errno_location);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/exit/_Exit.c b/lib/libc/wasi/libc-top-half/musl/src/exit/_Exit.c
deleted file mode 100644
index 7a6115c7bb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/exit/_Exit.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdlib.h>
-#include "syscall.h"
-
-_Noreturn void _Exit(int ec)
-{
- __syscall(SYS_exit_group, ec);
- for (;;) __syscall(SYS_exit, ec);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/exit/abort.c b/lib/libc/wasi/libc-top-half/musl/src/exit/abort.c
deleted file mode 100644
index f21f458eca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/exit/abort.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <stdlib.h>
-#include <signal.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-#include "atomic.h"
-#include "lock.h"
-#include "ksigaction.h"
-
-_Noreturn void abort(void)
-{
- raise(SIGABRT);
-
- /* If there was a SIGABRT handler installed and it returned, or if
- * SIGABRT was blocked or ignored, take an AS-safe lock to prevent
- * sigaction from installing a new SIGABRT handler, uninstall any
- * handler that may be present, and re-raise the signal to generate
- * the default action of abnormal termination. */
- __block_all_sigs(0);
- LOCK(__abort_lock);
- __syscall(SYS_rt_sigaction, SIGABRT,
- &(struct k_sigaction){.handler = SIG_DFL}, 0, _NSIG/8);
- __syscall(SYS_tkill, __pthread_self()->tid, SIGABRT);
- __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
- &(long[_NSIG/(8*sizeof(long))]){1UL<<(SIGABRT-1)}, 0, _NSIG/8);
-
- /* Beyond this point should be unreachable. */
- a_crash();
- raise(SIGKILL);
- _Exit(127);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/exit/abort_lock.c b/lib/libc/wasi/libc-top-half/musl/src/exit/abort_lock.c
deleted file mode 100644
index 3af72c7b6a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/exit/abort_lock.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "pthread_impl.h"
-
-volatile int __abort_lock[1];
diff --git a/lib/libc/wasi/libc-top-half/musl/src/exit/arm/__aeabi_atexit.c b/lib/libc/wasi/libc-top-half/musl/src/exit/arm/__aeabi_atexit.c
deleted file mode 100644
index ce16101ddb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/exit/arm/__aeabi_atexit.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int __cxa_atexit(void (*func)(void *), void *arg, void *dso);
-
-int __aeabi_atexit (void *obj, void (*func) (void *), void *d)
-{
- return __cxa_atexit (func, obj, d);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fcntl/fcntl.c b/lib/libc/wasi/libc-top-half/musl/src/fcntl/fcntl.c
deleted file mode 100644
index d3bff5c486..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fcntl/fcntl.c
+++ /dev/null
@@ -1,48 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <stdarg.h>
-#include <errno.h>
-#include "syscall.h"
-
-int fcntl(int fd, int cmd, ...)
-{
- unsigned long arg;
- va_list ap;
- va_start(ap, cmd);
- arg = va_arg(ap, unsigned long);
- va_end(ap);
- if (cmd == F_SETFL) arg |= O_LARGEFILE;
- if (cmd == F_SETLKW) return syscall_cp(SYS_fcntl, fd, cmd, (void *)arg);
- if (cmd == F_GETOWN) {
- struct f_owner_ex ex;
- int ret = __syscall(SYS_fcntl, fd, F_GETOWN_EX, &ex);
- if (ret == -EINVAL) return __syscall(SYS_fcntl, fd, cmd, (void *)arg);
- if (ret) return __syscall_ret(ret);
- return ex.type == F_OWNER_PGRP ? -ex.pid : ex.pid;
- }
- if (cmd == F_DUPFD_CLOEXEC) {
- int ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, arg);
- if (ret != -EINVAL) {
- if (ret >= 0)
- __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
- return __syscall_ret(ret);
- }
- ret = __syscall(SYS_fcntl, fd, F_DUPFD_CLOEXEC, 0);
- if (ret != -EINVAL) {
- if (ret >= 0) __syscall(SYS_close, ret);
- return __syscall_ret(-EINVAL);
- }
- ret = __syscall(SYS_fcntl, fd, F_DUPFD, arg);
- if (ret >= 0) __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
- return __syscall_ret(ret);
- }
- switch (cmd) {
- case F_SETLK:
- case F_GETLK:
- case F_GETOWN_EX:
- case F_SETOWN_EX:
- return syscall(SYS_fcntl, fd, cmd, (void *)arg);
- default:
- return syscall(SYS_fcntl, fd, cmd, arg);
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fcntl/open.c b/lib/libc/wasi/libc-top-half/musl/src/fcntl/open.c
deleted file mode 100644
index 1d817a2d6c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fcntl/open.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <fcntl.h>
-#include <stdarg.h>
-#include "syscall.h"
-
-int open(const char *filename, int flags, ...)
-{
- mode_t mode = 0;
-
- if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) {
- va_list ap;
- va_start(ap, flags);
- mode = va_arg(ap, mode_t);
- va_end(ap);
- }
-
- int fd = __sys_open_cp(filename, flags, mode);
- if (fd>=0 && (flags & O_CLOEXEC))
- __syscall(SYS_fcntl, fd, F_SETFD, FD_CLOEXEC);
-
- return __syscall_ret(fd);
-}
-
-weak_alias(open, open64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fcntl/openat.c b/lib/libc/wasi/libc-top-half/musl/src/fcntl/openat.c
deleted file mode 100644
index ad165ec323..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fcntl/openat.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <fcntl.h>
-#include <stdarg.h>
-#include "syscall.h"
-
-int openat(int fd, const char *filename, int flags, ...)
-{
- mode_t mode = 0;
-
- if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) {
- va_list ap;
- va_start(ap, flags);
- mode = va_arg(ap, mode_t);
- va_end(ap);
- }
-
- return syscall_cp(SYS_openat, fd, filename, flags|O_LARGEFILE, mode);
-}
-
-weak_alias(openat, openat64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fadvise.c b/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fadvise.c
deleted file mode 100644
index 75b8e1aed8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fadvise.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <fcntl.h>
-#include "syscall.h"
-
-int posix_fadvise(int fd, off_t base, off_t len, int advice)
-{
-#if defined(SYSCALL_FADVISE_6_ARG)
- /* Some archs, at least arm and powerpc, have the syscall
- * arguments reordered to avoid needing 7 argument registers
- * due to 64-bit argument alignment. */
- return -__syscall(SYS_fadvise, fd, advice,
- __SYSCALL_LL_E(base), __SYSCALL_LL_E(len));
-#else
- return -__syscall(SYS_fadvise, fd, __SYSCALL_LL_O(base),
- __SYSCALL_LL_E(len), advice);
-#endif
-}
-
-weak_alias(posix_fadvise, posix_fadvise64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fallocate.c b/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fallocate.c
deleted file mode 100644
index c57a24aef4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fcntl/posix_fallocate.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <fcntl.h>
-#include "syscall.h"
-
-int posix_fallocate(int fd, off_t base, off_t len)
-{
- return -__syscall(SYS_fallocate, fd, 0, __SYSCALL_LL_E(base),
- __SYSCALL_LL_E(len));
-}
-
-weak_alias(posix_fallocate, posix_fallocate64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/__flt_rounds.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/__flt_rounds.c
deleted file mode 100644
index ec0b3689e5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/__flt_rounds.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <float.h>
-#include <fenv.h>
-
-int __flt_rounds()
-{
- switch (fegetround()) {
-#ifdef FE_TOWARDZERO
- case FE_TOWARDZERO: return 0;
-#endif
- case FE_TONEAREST: return 1;
-#ifdef FE_UPWARD
- case FE_UPWARD: return 2;
-#endif
-#ifdef FE_DOWNWARD
- case FE_DOWNWARD: return 3;
-#endif
- }
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/aarch64/fenv.s b/lib/libc/wasi/libc-top-half/musl/src/fenv/aarch64/fenv.s
deleted file mode 100644
index 8f3ec9653c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/aarch64/fenv.s
+++ /dev/null
@@ -1,68 +0,0 @@
-.global fegetround
-.type fegetround,%function
-fegetround:
- mrs x0, fpcr
- and w0, w0, #0xc00000
- ret
-
-.global __fesetround
-.hidden __fesetround
-.type __fesetround,%function
-__fesetround:
- mrs x1, fpcr
- bic w1, w1, #0xc00000
- orr w1, w1, w0
- msr fpcr, x1
- mov w0, #0
- ret
-
-.global fetestexcept
-.type fetestexcept,%function
-fetestexcept:
- and w0, w0, #0x1f
- mrs x1, fpsr
- and w0, w0, w1
- ret
-
-.global feclearexcept
-.type feclearexcept,%function
-feclearexcept:
- and w0, w0, #0x1f
- mrs x1, fpsr
- bic w1, w1, w0
- msr fpsr, x1
- mov w0, #0
- ret
-
-.global feraiseexcept
-.type feraiseexcept,%function
-feraiseexcept:
- and w0, w0, #0x1f
- mrs x1, fpsr
- orr w1, w1, w0
- msr fpsr, x1
- mov w0, #0
- ret
-
-.global fegetenv
-.type fegetenv,%function
-fegetenv:
- mrs x1, fpcr
- mrs x2, fpsr
- stp w1, w2, [x0]
- mov w0, #0
- ret
-
-// TODO preserve some bits
-.global fesetenv
-.type fesetenv,%function
-fesetenv:
- mov x1, #0
- mov x2, #0
- cmn x0, #1
- b.eq 1f
- ldp w1, w2, [x0]
-1: msr fpcr, x1
- msr fpsr, x2
- mov w0, #0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/arm/fenv.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/arm/fenv.c
deleted file mode 100644
index ad295f58cc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/arm/fenv.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#if !__ARM_PCS_VFP
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/i386/fenv.s b/lib/libc/wasi/libc-top-half/musl/src/fenv/i386/fenv.s
deleted file mode 100644
index e7f7932a1c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/i386/fenv.s
+++ /dev/null
@@ -1,164 +0,0 @@
-.hidden __hwcap
-
-.global feclearexcept
-.type feclearexcept,@function
-feclearexcept:
- mov 4(%esp),%ecx
- and $0x3f,%ecx
- fnstsw %ax
- # consider sse fenv as well if the cpu has XMM capability
- call 1f
-1: addl $__hwcap-1b,(%esp)
- pop %edx
- testl $0x02000000,(%edx)
- jz 2f
- # maintain exceptions in the sse mxcsr, clear x87 exceptions
- test %eax,%ecx
- jz 1f
- fnclex
-1: push %edx
- stmxcsr (%esp)
- pop %edx
- and $0x3f,%eax
- or %eax,%edx
- test %edx,%ecx
- jz 1f
- not %ecx
- and %ecx,%edx
- push %edx
- ldmxcsr (%esp)
- pop %edx
-1: xor %eax,%eax
- ret
- # only do the expensive x87 fenv load/store when needed
-2: test %eax,%ecx
- jz 1b
- not %ecx
- and %ecx,%eax
- test $0x3f,%eax
- jz 1f
- fnclex
- jmp 1b
-1: sub $32,%esp
- fnstenv (%esp)
- mov %al,4(%esp)
- fldenv (%esp)
- add $32,%esp
- xor %eax,%eax
- ret
-
-.global feraiseexcept
-.type feraiseexcept,@function
-feraiseexcept:
- mov 4(%esp),%eax
- and $0x3f,%eax
- sub $32,%esp
- fnstenv (%esp)
- or %al,4(%esp)
- fldenv (%esp)
- add $32,%esp
- xor %eax,%eax
- ret
-
-.global __fesetround
-.hidden __fesetround
-.type __fesetround,@function
-__fesetround:
- mov 4(%esp),%ecx
- push %eax
- xor %eax,%eax
- fnstcw (%esp)
- andb $0xf3,1(%esp)
- or %ch,1(%esp)
- fldcw (%esp)
- # consider sse fenv as well if the cpu has XMM capability
- call 1f
-1: addl $__hwcap-1b,(%esp)
- pop %edx
- testl $0x02000000,(%edx)
- jz 1f
- stmxcsr (%esp)
- shl $3,%ch
- andb $0x9f,1(%esp)
- or %ch,1(%esp)
- ldmxcsr (%esp)
-1: pop %ecx
- ret
-
-.global fegetround
-.type fegetround,@function
-fegetround:
- push %eax
- fnstcw (%esp)
- pop %eax
- and $0xc00,%eax
- ret
-
-.global fegetenv
-.type fegetenv,@function
-fegetenv:
- mov 4(%esp),%ecx
- xor %eax,%eax
- fnstenv (%ecx)
- # consider sse fenv as well if the cpu has XMM capability
- call 1f
-1: addl $__hwcap-1b,(%esp)
- pop %edx
- testl $0x02000000,(%edx)
- jz 1f
- push %eax
- stmxcsr (%esp)
- pop %edx
- and $0x3f,%edx
- or %edx,4(%ecx)
-1: ret
-
-.global fesetenv
-.type fesetenv,@function
-fesetenv:
- mov 4(%esp),%ecx
- xor %eax,%eax
- inc %ecx
- jz 1f
- fldenv -1(%ecx)
- movl -1(%ecx),%ecx
- jmp 2f
-1: push %eax
- push %eax
- push %eax
- push %eax
- pushl $0xffff
- push %eax
- pushl $0x37f
- fldenv (%esp)
- add $28,%esp
- # consider sse fenv as well if the cpu has XMM capability
-2: call 1f
-1: addl $__hwcap-1b,(%esp)
- pop %edx
- testl $0x02000000,(%edx)
- jz 1f
- # mxcsr := same rounding mode, cleared exceptions, default mask
- and $0xc00,%ecx
- shl $3,%ecx
- or $0x1f80,%ecx
- mov %ecx,4(%esp)
- ldmxcsr 4(%esp)
-1: ret
-
-.global fetestexcept
-.type fetestexcept,@function
-fetestexcept:
- mov 4(%esp),%ecx
- and $0x3f,%ecx
- fnstsw %ax
- # consider sse fenv as well if the cpu has XMM capability
- call 1f
-1: addl $__hwcap-1b,(%esp)
- pop %edx
- testl $0x02000000,(%edx)
- jz 1f
- stmxcsr 4(%esp)
- or 4(%esp),%eax
-1: and %ecx,%eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/m68k/fenv.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/m68k/fenv.c
deleted file mode 100644
index d0658e6784..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/m68k/fenv.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <fenv.h>
-#include <features.h>
-
-#if __HAVE_68881__ || __mcffpu__
-
-static unsigned getsr()
-{
- unsigned v;
- __asm__ __volatile__ ("fmove.l %%fpsr,%0" : "=dm"(v));
- return v;
-}
-
-static void setsr(unsigned v)
-{
- __asm__ __volatile__ ("fmove.l %0,%%fpsr" : : "dm"(v));
-}
-
-static unsigned getcr()
-{
- unsigned v;
- __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=dm"(v));
- return v;
-}
-
-static void setcr(unsigned v)
-{
- __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "dm"(v));
-}
-
-int feclearexcept(int mask)
-{
- if (mask & ~FE_ALL_EXCEPT) return -1;
- setsr(getsr() & ~mask);
- return 0;
-}
-
-int feraiseexcept(int mask)
-{
- if (mask & ~FE_ALL_EXCEPT) return -1;
- setsr(getsr() | mask);
- return 0;
-}
-
-int fetestexcept(int mask)
-{
- return getsr() & mask;
-}
-
-int fegetround(void)
-{
- return getcr() & FE_UPWARD;
-}
-
-hidden int __fesetround(int r)
-{
- setcr((getcr() & ~FE_UPWARD) | r);
- return 0;
-}
-
-int fegetenv(fenv_t *envp)
-{
- envp->__control_register = getcr();
- envp->__status_register = getsr();
- __asm__ __volatile__ ("fmove.l %%fpiar,%0"
- : "=dm"(envp->__instruction_address));
- return 0;
-}
-
-int fesetenv(const fenv_t *envp)
-{
- static const fenv_t default_env = { 0 };
- if (envp == FE_DFL_ENV)
- envp = &default_env;
- setcr(envp->__control_register);
- setsr(envp->__status_register);
- __asm__ __volatile__ ("fmove.l %0,%%fpiar"
- : : "dm"(envp->__instruction_address));
- return 0;
-}
-
-#else
-
-#include "../fenv.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/mips/fenv-sf.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/mips/fenv-sf.c
deleted file mode 100644
index 4aa3dbf127..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/mips/fenv-sf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifdef __mips_soft_float
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/mips64/fenv-sf.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/mips64/fenv-sf.c
deleted file mode 100644
index 4aa3dbf127..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/mips64/fenv-sf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifdef __mips_soft_float
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/mipsn32/fenv-sf.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/mipsn32/fenv-sf.c
deleted file mode 100644
index 4aa3dbf127..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/mipsn32/fenv-sf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifdef __mips_soft_float
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv-sf.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv-sf.c
deleted file mode 100644
index d4248f26f7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc/fenv-sf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc64/fenv.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc64/fenv.c
deleted file mode 100644
index 90dabdc8c9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/powerpc64/fenv.c
+++ /dev/null
@@ -1,69 +0,0 @@
-#define _GNU_SOURCE
-#include <fenv.h>
-#include <features.h>
-
-static inline double get_fpscr_f(void)
-{
- double d;
- __asm__ __volatile__("mffs %0" : "=d"(d));
- return d;
-}
-
-static inline long get_fpscr(void)
-{
- return (union {double f; long i;}) {get_fpscr_f()}.i;
-}
-
-static inline void set_fpscr_f(double fpscr)
-{
- __asm__ __volatile__("mtfsf 255, %0" : : "d"(fpscr));
-}
-
-static void set_fpscr(long fpscr)
-{
- set_fpscr_f((union {long i; double f;}) {fpscr}.f);
-}
-
-int feclearexcept(int mask)
-{
- mask &= FE_ALL_EXCEPT;
- if (mask & FE_INVALID) mask |= FE_ALL_INVALID;
- set_fpscr(get_fpscr() & ~mask);
- return 0;
-}
-
-int feraiseexcept(int mask)
-{
- mask &= FE_ALL_EXCEPT;
- if (mask & FE_INVALID) mask |= FE_INVALID_SOFTWARE;
- set_fpscr(get_fpscr() | mask);
- return 0;
-}
-
-int fetestexcept(int mask)
-{
- return get_fpscr() & mask & FE_ALL_EXCEPT;
-}
-
-int fegetround(void)
-{
- return get_fpscr() & 3;
-}
-
-hidden int __fesetround(int r)
-{
- set_fpscr(get_fpscr() & ~3L | r);
- return 0;
-}
-
-int fegetenv(fenv_t *envp)
-{
- *envp = get_fpscr_f();
- return 0;
-}
-
-int fesetenv(const fenv_t *envp)
-{
- set_fpscr_f(envp != FE_DFL_ENV ? *envp : 0);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/riscv64/fenv-sf.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/riscv64/fenv-sf.c
deleted file mode 100644
index ecd3cb5cad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/riscv64/fenv-sf.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef __riscv_flen
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/s390x/fenv.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/s390x/fenv.c
deleted file mode 100644
index fd4e60c5eb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/s390x/fenv.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <fenv.h>
-#include <features.h>
-
-static inline unsigned get_fpc(void)
-{
- unsigned fpc;
- __asm__ __volatile__("efpc %0" : "=r"(fpc));
- return fpc;
-}
-
-static inline void set_fpc(unsigned fpc)
-{
- __asm__ __volatile__("sfpc %0" :: "r"(fpc));
-}
-
-int feclearexcept(int mask)
-{
- mask &= FE_ALL_EXCEPT;
- set_fpc(get_fpc() & ~mask);
- return 0;
-}
-
-int feraiseexcept(int mask)
-{
- mask &= FE_ALL_EXCEPT;
- set_fpc(get_fpc() | mask);
- return 0;
-}
-
-int fetestexcept(int mask)
-{
- return get_fpc() & mask & FE_ALL_EXCEPT;
-}
-
-int fegetround(void)
-{
- return get_fpc() & 3;
-}
-
-hidden int __fesetround(int r)
-{
- set_fpc(get_fpc() & ~3L | r);
- return 0;
-}
-
-int fegetenv(fenv_t *envp)
-{
- *envp = get_fpc();
- return 0;
-}
-
-int fesetenv(const fenv_t *envp)
-{
- set_fpc(envp != FE_DFL_ENV ? *envp : 0);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c b/lib/libc/wasi/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c
deleted file mode 100644
index b2495a6583..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/sh/fenv-nofpu.c
+++ /dev/null
@@ -1,3 +0,0 @@
-#if !__SH_FPU_ANY__ && !__SH4__
-#include "../fenv.c"
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/x32/fenv.s b/lib/libc/wasi/libc-top-half/musl/src/fenv/x32/fenv.s
deleted file mode 100644
index 835f23b615..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/x32/fenv.s
+++ /dev/null
@@ -1,98 +0,0 @@
-.global feclearexcept
-.type feclearexcept,@function
-feclearexcept:
- # maintain exceptions in the sse mxcsr, clear x87 exceptions
- mov %edi,%ecx
- and $0x3f,%ecx
- fnstsw %ax
- test %eax,%ecx
- jz 1f
- fnclex
-1: stmxcsr -8(%esp)
- and $0x3f,%eax
- or %eax,-8(%esp)
- test %ecx,-8(%esp)
- jz 1f
- not %ecx
- and %ecx,-8(%esp)
- ldmxcsr -8(%esp)
-1: xor %eax,%eax
- ret
-
-.global feraiseexcept
-.type feraiseexcept,@function
-feraiseexcept:
- and $0x3f,%edi
- stmxcsr -8(%esp)
- or %edi,-8(%esp)
- ldmxcsr -8(%esp)
- xor %eax,%eax
- ret
-
-.global __fesetround
-.hidden __fesetround
-.type __fesetround,@function
-__fesetround:
- push %rax
- xor %eax,%eax
- mov %edi,%ecx
- fnstcw (%esp)
- andb $0xf3,1(%esp)
- or %ch,1(%esp)
- fldcw (%esp)
- stmxcsr (%esp)
- shl $3,%ch
- andb $0x9f,1(%esp)
- or %ch,1(%esp)
- ldmxcsr (%esp)
- pop %rcx
- ret
-
-.global fegetround
-.type fegetround,@function
-fegetround:
- push %rax
- stmxcsr (%esp)
- pop %rax
- shr $3,%eax
- and $0xc00,%eax
- ret
-
-.global fegetenv
-.type fegetenv,@function
-fegetenv:
- xor %eax,%eax
- fnstenv (%edi)
- stmxcsr 28(%edi)
- ret
-
-.global fesetenv
-.type fesetenv,@function
-fesetenv:
- xor %eax,%eax
- inc %edi
- jz 1f
- fldenv -1(%edi)
- ldmxcsr 27(%edi)
- ret
-1: push %rax
- push %rax
- pushq $0xffff
- pushq $0x37f
- fldenv (%esp)
- pushq $0x1f80
- ldmxcsr (%esp)
- add $40,%esp
- ret
-
-.global fetestexcept
-.type fetestexcept,@function
-fetestexcept:
- and $0x3f,%edi
- push %rax
- stmxcsr (%esp)
- pop %rsi
- fnstsw %ax
- or %esi,%eax
- and %edi,%eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/fenv/x86_64/fenv.s b/lib/libc/wasi/libc-top-half/musl/src/fenv/x86_64/fenv.s
deleted file mode 100644
index 98d876da26..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/fenv/x86_64/fenv.s
+++ /dev/null
@@ -1,98 +0,0 @@
-.global feclearexcept
-.type feclearexcept,@function
-feclearexcept:
- # maintain exceptions in the sse mxcsr, clear x87 exceptions
- mov %edi,%ecx
- and $0x3f,%ecx
- fnstsw %ax
- test %eax,%ecx
- jz 1f
- fnclex
-1: stmxcsr -8(%rsp)
- and $0x3f,%eax
- or %eax,-8(%rsp)
- test %ecx,-8(%rsp)
- jz 1f
- not %ecx
- and %ecx,-8(%rsp)
- ldmxcsr -8(%rsp)
-1: xor %eax,%eax
- ret
-
-.global feraiseexcept
-.type feraiseexcept,@function
-feraiseexcept:
- and $0x3f,%edi
- stmxcsr -8(%rsp)
- or %edi,-8(%rsp)
- ldmxcsr -8(%rsp)
- xor %eax,%eax
- ret
-
-.global __fesetround
-.hidden __fesetround
-.type __fesetround,@function
-__fesetround:
- push %rax
- xor %eax,%eax
- mov %edi,%ecx
- fnstcw (%rsp)
- andb $0xf3,1(%rsp)
- or %ch,1(%rsp)
- fldcw (%rsp)
- stmxcsr (%rsp)
- shl $3,%ch
- andb $0x9f,1(%rsp)
- or %ch,1(%rsp)
- ldmxcsr (%rsp)
- pop %rcx
- ret
-
-.global fegetround
-.type fegetround,@function
-fegetround:
- push %rax
- stmxcsr (%rsp)
- pop %rax
- shr $3,%eax
- and $0xc00,%eax
- ret
-
-.global fegetenv
-.type fegetenv,@function
-fegetenv:
- xor %eax,%eax
- fnstenv (%rdi)
- stmxcsr 28(%rdi)
- ret
-
-.global fesetenv
-.type fesetenv,@function
-fesetenv:
- xor %eax,%eax
- inc %rdi
- jz 1f
- fldenv -1(%rdi)
- ldmxcsr 27(%rdi)
- ret
-1: push %rax
- push %rax
- pushq $0xffff
- pushq $0x37f
- fldenv (%rsp)
- pushq $0x1f80
- ldmxcsr (%rsp)
- add $40,%rsp
- ret
-
-.global fetestexcept
-.type fetestexcept,@function
-fetestexcept:
- and $0x3f,%edi
- push %rax
- stmxcsr (%rsp)
- pop %rsi
- fnstsw %ax
- or %esi,%eax
- and %edi,%eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/i386/defsysinfo.s b/lib/libc/wasi/libc-top-half/musl/src/internal/i386/defsysinfo.s
deleted file mode 100644
index f1b5b0f2f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/i386/defsysinfo.s
+++ /dev/null
@@ -1,9 +0,0 @@
-1: int $128
- ret
-
-.data
-.align 4
-.hidden __sysinfo
-.global __sysinfo
-__sysinfo:
- .long 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/procfdname.c b/lib/libc/wasi/libc-top-half/musl/src/internal/procfdname.c
deleted file mode 100644
index fd7306ab69..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/procfdname.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "syscall.h"
-
-void __procfdname(char *buf, unsigned fd)
-{
- unsigned i, j;
- for (i=0; (buf[i] = "/proc/self/fd/"[i]); i++);
- if (!fd) {
- buf[i] = '0';
- buf[i+1] = 0;
- return;
- }
- for (j=fd; j; j/=10, i++);
- buf[i] = 0;
- for (; fd; fd/=10) buf[--i] = '0' + fd%10;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/sh/__shcall.c b/lib/libc/wasi/libc-top-half/musl/src/internal/sh/__shcall.c
deleted file mode 100644
index 4e073e8ff4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/sh/__shcall.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <features.h>
-
-hidden int __shcall(void *arg, int (*func)(void *))
-{
- return func(arg);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/syscall_ret.c b/lib/libc/wasi/libc-top-half/musl/src/internal/syscall_ret.c
deleted file mode 100644
index a3f471368f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/syscall_ret.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <errno.h>
-#include "syscall.h"
-
-long __syscall_ret(unsigned long r)
-{
- if (r > -4096UL) {
- errno = -r;
- return -1;
- }
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/vdso.c b/lib/libc/wasi/libc-top-half/musl/src/internal/vdso.c
deleted file mode 100644
index d46d32281e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/vdso.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include <elf.h>
-#include <link.h>
-#include <limits.h>
-#include <stdint.h>
-#include <string.h>
-#include "libc.h"
-#include "syscall.h"
-
-#ifdef VDSO_USEFUL
-
-#if ULONG_MAX == 0xffffffff
-typedef Elf32_Ehdr Ehdr;
-typedef Elf32_Phdr Phdr;
-typedef Elf32_Sym Sym;
-typedef Elf32_Verdef Verdef;
-typedef Elf32_Verdaux Verdaux;
-#else
-typedef Elf64_Ehdr Ehdr;
-typedef Elf64_Phdr Phdr;
-typedef Elf64_Sym Sym;
-typedef Elf64_Verdef Verdef;
-typedef Elf64_Verdaux Verdaux;
-#endif
-
-static int checkver(Verdef *def, int vsym, const char *vername, char *strings)
-{
- vsym &= 0x7fff;
- for (;;) {
- if (!(def->vd_flags & VER_FLG_BASE)
- && (def->vd_ndx & 0x7fff) == vsym)
- break;
- if (def->vd_next == 0)
- return 0;
- def = (Verdef *)((char *)def + def->vd_next);
- }
- Verdaux *aux = (Verdaux *)((char *)def + def->vd_aux);
- return !strcmp(vername, strings + aux->vda_name);
-}
-
-#define OK_TYPES (1<<STT_NOTYPE | 1<<STT_OBJECT | 1<<STT_FUNC | 1<<STT_COMMON)
-#define OK_BINDS (1<<STB_GLOBAL | 1<<STB_WEAK | 1<<STB_GNU_UNIQUE)
-
-void *__vdsosym(const char *vername, const char *name)
-{
- size_t i;
- for (i=0; libc.auxv[i] != AT_SYSINFO_EHDR; i+=2)
- if (!libc.auxv[i]) return 0;
- if (!libc.auxv[i+1]) return 0;
- Ehdr *eh = (void *)libc.auxv[i+1];
- Phdr *ph = (void *)((char *)eh + eh->e_phoff);
- size_t *dynv=0, base=-1;
- for (i=0; i<eh->e_phnum; i++, ph=(void *)((char *)ph+eh->e_phentsize)) {
- if (ph->p_type == PT_LOAD)
- base = (size_t)eh + ph->p_offset - ph->p_vaddr;
- else if (ph->p_type == PT_DYNAMIC)
- dynv = (void *)((char *)eh + ph->p_offset);
- }
- if (!dynv || base==(size_t)-1) return 0;
-
- char *strings = 0;
- Sym *syms = 0;
- Elf_Symndx *hashtab = 0;
- uint16_t *versym = 0;
- Verdef *verdef = 0;
-
- for (i=0; dynv[i]; i+=2) {
- void *p = (void *)(base + dynv[i+1]);
- switch(dynv[i]) {
- case DT_STRTAB: strings = p; break;
- case DT_SYMTAB: syms = p; break;
- case DT_HASH: hashtab = p; break;
- case DT_VERSYM: versym = p; break;
- case DT_VERDEF: verdef = p; break;
- }
- }
-
- if (!strings || !syms || !hashtab) return 0;
- if (!verdef) versym = 0;
-
- for (i=0; i<hashtab[1]; i++) {
- if (!(1<<(syms[i].st_info&0xf) & OK_TYPES)) continue;
- if (!(1<<(syms[i].st_info>>4) & OK_BINDS)) continue;
- if (!syms[i].st_shndx) continue;
- if (strcmp(name, strings+syms[i].st_name)) continue;
- if (versym && !checkver(verdef, versym[i], vername, strings))
- continue;
- return (void *)(base + syms[i].st_value);
- }
-
- return 0;
-}
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/internal/version.c b/lib/libc/wasi/libc-top-half/musl/src/internal/version.c
deleted file mode 100644
index 08bbf5b2b7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/internal/version.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "version.h"
-#include "libc.h"
-
-const char __libc_version[] = VERSION;
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/ftok.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/ftok.c
deleted file mode 100644
index c36b4b6003..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/ftok.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/ipc.h>
-#include <sys/stat.h>
-
-key_t ftok(const char *path, int id)
-{
- struct stat st;
- if (stat(path, &st) < 0) return -1;
-
- return ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16) | ((id & 0xffu) << 24));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgctl.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/msgctl.c
deleted file mode 100644
index 9c11440641..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgctl.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <sys/msg.h>
-#include <endian.h>
-#include "syscall.h"
-#include "ipc.h"
-
-#if __BYTE_ORDER != __BIG_ENDIAN
-#undef SYSCALL_IPC_BROKEN_MODE
-#endif
-
-int msgctl(int q, int cmd, struct msqid_ds *buf)
-{
-#if IPC_TIME64
- struct msqid_ds out, *orig;
- if (cmd&IPC_TIME64) {
- out = (struct msqid_ds){0};
- orig = buf;
- buf = &out;
- }
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- struct msqid_ds tmp;
- if (cmd == IPC_SET) {
- tmp = *buf;
- tmp.msg_perm.mode *= 0x10000U;
- buf = &tmp;
- }
-#endif
-#ifndef SYS_ipc
- int r = __syscall(SYS_msgctl, q, IPC_CMD(cmd), buf);
-#else
- int r = __syscall(SYS_ipc, IPCOP_msgctl, q, IPC_CMD(cmd), 0, buf, 0);
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- if (r >= 0) switch (cmd | IPC_TIME64) {
- case IPC_STAT:
- case MSG_STAT:
- case MSG_STAT_ANY:
- buf->msg_perm.mode >>= 16;
- }
-#endif
-#if IPC_TIME64
- if (r >= 0 && (cmd&IPC_TIME64)) {
- buf = orig;
- *buf = out;
- IPC_HILO(buf, msg_stime);
- IPC_HILO(buf, msg_rtime);
- IPC_HILO(buf, msg_ctime);
- }
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgget.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/msgget.c
deleted file mode 100644
index 30a4b42b85..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgget.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/msg.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int msgget(key_t k, int flag)
-{
-#ifndef SYS_ipc
- return syscall(SYS_msgget, k, flag);
-#else
- return syscall(SYS_ipc, IPCOP_msgget, k, flag);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgrcv.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/msgrcv.c
deleted file mode 100644
index 9d1034b145..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgrcv.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/msg.h>
-#include "syscall.h"
-#include "ipc.h"
-
-ssize_t msgrcv(int q, void *m, size_t len, long type, int flag)
-{
-#ifndef SYS_ipc
- return syscall_cp(SYS_msgrcv, q, m, len, type, flag);
-#else
- return syscall_cp(SYS_ipc, IPCOP_msgrcv, q, len, flag, ((long[]){ (long)m, type }));
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgsnd.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/msgsnd.c
deleted file mode 100644
index 99bb17e94a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/msgsnd.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/msg.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int msgsnd(int q, const void *m, size_t len, int flag)
-{
-#ifndef SYS_ipc
- return syscall_cp(SYS_msgsnd, q, m, len, flag);
-#else
- return syscall_cp(SYS_ipc, IPCOP_msgsnd, q, len, flag, m);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/semctl.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/semctl.c
deleted file mode 100644
index bbb97d7aed..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/semctl.c
+++ /dev/null
@@ -1,69 +0,0 @@
-#include <sys/sem.h>
-#include <stdarg.h>
-#include <endian.h>
-#include "syscall.h"
-#include "ipc.h"
-
-#if __BYTE_ORDER != __BIG_ENDIAN
-#undef SYSCALL_IPC_BROKEN_MODE
-#endif
-
-union semun {
- int val;
- struct semid_ds *buf;
- unsigned short *array;
-};
-
-int semctl(int id, int num, int cmd, ...)
-{
- union semun arg = {0};
- va_list ap;
- switch (cmd & ~IPC_TIME64) {
- case SETVAL: case GETALL: case SETALL: case IPC_SET:
- case IPC_INFO: case SEM_INFO:
- case IPC_STAT & ~IPC_TIME64:
- case SEM_STAT & ~IPC_TIME64:
- case SEM_STAT_ANY & ~IPC_TIME64:
- va_start(ap, cmd);
- arg = va_arg(ap, union semun);
- va_end(ap);
- }
-#if IPC_TIME64
- struct semid_ds out, *orig;
- if (cmd&IPC_TIME64) {
- out = (struct semid_ds){0};
- orig = arg.buf;
- arg.buf = &out;
- }
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- struct semid_ds tmp;
- if (cmd == IPC_SET) {
- tmp = *arg.buf;
- tmp.sem_perm.mode *= 0x10000U;
- arg.buf = &tmp;
- }
-#endif
-#ifndef SYS_ipc
- int r = __syscall(SYS_semctl, id, num, IPC_CMD(cmd), arg.buf);
-#else
- int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, IPC_CMD(cmd), &arg.buf);
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- if (r >= 0) switch (cmd | IPC_TIME64) {
- case IPC_STAT:
- case SEM_STAT:
- case SEM_STAT_ANY:
- arg.buf->sem_perm.mode >>= 16;
- }
-#endif
-#if IPC_TIME64
- if (r >= 0 && (cmd&IPC_TIME64)) {
- arg.buf = orig;
- *arg.buf = out;
- IPC_HILO(arg.buf, sem_otime);
- IPC_HILO(arg.buf, sem_ctime);
- }
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/semget.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/semget.c
deleted file mode 100644
index 2cdf626b50..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/semget.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sys/sem.h>
-#include <limits.h>
-#include <errno.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int semget(key_t key, int n, int fl)
-{
- /* The kernel uses the wrong type for the sem_nsems member
- * of struct semid_ds, and thus might not check that the
- * n fits in the correct (per POSIX) userspace type, so
- * we have to check here. */
- if (n > USHRT_MAX) return __syscall_ret(-EINVAL);
-#ifndef SYS_ipc
- return syscall(SYS_semget, key, n, fl);
-#else
- return syscall(SYS_ipc, IPCOP_semget, key, n, fl);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/semop.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/semop.c
deleted file mode 100644
index 5f0c7deaf3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/semop.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/sem.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int semop(int id, struct sembuf *buf, size_t n)
-{
-#ifndef SYS_ipc
- return syscall(SYS_semop, id, buf, n);
-#else
- return syscall(SYS_ipc, IPCOP_semop, id, n, 0, buf);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/semtimedop.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/semtimedop.c
deleted file mode 100644
index 1632e7b03f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/semtimedop.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/sem.h>
-#include <errno.h>
-#include "syscall.h"
-#include "ipc.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-#if !defined(SYS_semtimedop) && !defined(SYS_ipc)
-#define NO_TIME32 1
-#else
-#define NO_TIME32 0
-#endif
-
-int semtimedop(int id, struct sembuf *buf, size_t n, const struct timespec *ts)
-{
-#ifdef SYS_semtimedop_time64
- time_t s = ts ? ts->tv_sec : 0;
- long ns = ts ? ts->tv_nsec : 0;
- int r = -ENOSYS;
- if (NO_TIME32 || !IS32BIT(s))
- r = __syscall(SYS_semtimedop_time64, id, buf, n,
- ts ? ((long long[]){s, ns}) : 0);
- if (NO_TIME32 || r!=-ENOSYS) return __syscall_ret(r);
- ts = ts ? (void *)(long[]){CLAMP(s), ns} : 0;
-#endif
-#if defined(SYS_ipc)
- return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts);
-#elif defined(SYS_semtimedop)
- return syscall(SYS_semtimedop, id, buf, n, ts);
-#else
- return __syscall_ret(-ENOSYS);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmat.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/shmat.c
deleted file mode 100644
index 8c7407d13f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmat.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <sys/shm.h>
-#include "syscall.h"
-#include "ipc.h"
-
-#ifndef SYS_ipc
-void *shmat(int id, const void *addr, int flag)
-{
- return (void *)syscall(SYS_shmat, id, addr, flag);
-}
-#else
-void *shmat(int id, const void *addr, int flag)
-{
- unsigned long ret;
- ret = syscall(SYS_ipc, IPCOP_shmat, id, flag, &addr, addr);
- return (ret > -(unsigned long)SHMLBA) ? (void *)ret : (void *)addr;
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmctl.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/shmctl.c
deleted file mode 100644
index 1c9f78c2f1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmctl.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <sys/shm.h>
-#include <endian.h>
-#include "syscall.h"
-#include "ipc.h"
-
-#if __BYTE_ORDER != __BIG_ENDIAN
-#undef SYSCALL_IPC_BROKEN_MODE
-#endif
-
-int shmctl(int id, int cmd, struct shmid_ds *buf)
-{
-#if IPC_TIME64
- struct shmid_ds out, *orig;
- if (cmd&IPC_TIME64) {
- out = (struct shmid_ds){0};
- orig = buf;
- buf = &out;
- }
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- struct shmid_ds tmp;
- if (cmd == IPC_SET) {
- tmp = *buf;
- tmp.shm_perm.mode *= 0x10000U;
- buf = &tmp;
- }
-#endif
-#ifndef SYS_ipc
- int r = __syscall(SYS_shmctl, id, IPC_CMD(cmd), buf);
-#else
- int r = __syscall(SYS_ipc, IPCOP_shmctl, id, IPC_CMD(cmd), 0, buf, 0);
-#endif
-#ifdef SYSCALL_IPC_BROKEN_MODE
- if (r >= 0) switch (cmd | IPC_TIME64) {
- case IPC_STAT:
- case SHM_STAT:
- case SHM_STAT_ANY:
- buf->shm_perm.mode >>= 16;
- }
-#endif
-#if IPC_TIME64
- if (r >= 0 && (cmd&IPC_TIME64)) {
- buf = orig;
- *buf = out;
- IPC_HILO(buf, shm_atime);
- IPC_HILO(buf, shm_dtime);
- IPC_HILO(buf, shm_ctime);
- }
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmdt.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/shmdt.c
deleted file mode 100644
index 572381378e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmdt.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/shm.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int shmdt(const void *addr)
-{
-#ifndef SYS_ipc
- return syscall(SYS_shmdt, addr);
-#else
- return syscall(SYS_ipc, IPCOP_shmdt, 0, 0, 0, addr);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmget.c b/lib/libc/wasi/libc-top-half/musl/src/ipc/shmget.c
deleted file mode 100644
index 7521b5fa3f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ipc/shmget.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <sys/shm.h>
-#include <stdint.h>
-#include "syscall.h"
-#include "ipc.h"
-
-int shmget(key_t key, size_t size, int flag)
-{
- if (size > PTRDIFF_MAX) size = SIZE_MAX;
-#ifndef SYS_ipc
- return syscall(SYS_shmget, key, size, flag);
-#else
- return syscall(SYS_ipc, IPCOP_shmget, key, size, flag);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/__dlsym.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/__dlsym.c
deleted file mode 100644
index 0384f97e96..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/__dlsym.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <dlfcn.h>
-#include "dynlink.h"
-
-static void *stub_dlsym(void *restrict p, const char *restrict s, void *restrict ra)
-{
- __dl_seterr("Symbol not found: %s", s);
- return 0;
-}
-
-weak_alias(stub_dlsym, __dlsym);
-
-#if _REDIR_TIME64
-weak_alias(stub_dlsym, __dlsym_redir_time64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/dlsym.s
deleted file mode 100644
index abaae4d519..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global dlsym
-.hidden __dlsym
-.type dlsym,%function
-dlsym:
- mov x2,x30
- b __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s
deleted file mode 100644
index c6c685b3d7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s
+++ /dev/null
@@ -1,31 +0,0 @@
-// size_t __tlsdesc_static(size_t *a)
-// {
-// return a[1];
-// }
-.global __tlsdesc_static
-.hidden __tlsdesc_static
-.type __tlsdesc_static,@function
-__tlsdesc_static:
- ldr x0,[x0,#8]
- ret
-
-// size_t __tlsdesc_dynamic(size_t *a)
-// {
-// struct {size_t modidx,off;} *p = (void*)a[1];
-// size_t *dtv = *(size_t**)(tp - 8);
-// return dtv[p->modidx] + p->off - tp;
-// }
-.global __tlsdesc_dynamic
-.hidden __tlsdesc_dynamic
-.type __tlsdesc_dynamic,@function
-__tlsdesc_dynamic:
- stp x1,x2,[sp,#-16]!
- mrs x1,tpidr_el0 // tp
- ldr x0,[x0,#8] // p
- ldp x0,x2,[x0] // p->modidx, p->off
- sub x2,x2,x1 // p->off - tp
- ldr x1,[x1,#-8] // dtv
- ldr x1,[x1,x0,lsl #3] // dtv[p->modidx]
- add x0,x1,x2 // dtv[p->modidx] + p->off - tp
- ldp x1,x2,[sp],#16
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/dlsym.s
deleted file mode 100644
index 2652c348d7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/dlsym.s
+++ /dev/null
@@ -1,8 +0,0 @@
-.syntax unified
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym,%function
-dlsym:
- mov r2,lr
- b __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/find_exidx.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/find_exidx.c
deleted file mode 100644
index 77c4472bf6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/arm/find_exidx.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#define _GNU_SOURCE
-#include <link.h>
-#include <stdint.h>
-
-struct find_exidx_data {
- uintptr_t pc, exidx_start;
- int exidx_len;
-};
-
-static int find_exidx(struct dl_phdr_info *info, size_t size, void *ptr)
-{
- struct find_exidx_data *data = ptr;
- const ElfW(Phdr) *phdr = info->dlpi_phdr;
- uintptr_t addr, exidx_start = 0;
- int i, match = 0, exidx_len = 0;
-
- for (i = info->dlpi_phnum; i > 0; i--, phdr++) {
- addr = info->dlpi_addr + phdr->p_vaddr;
- switch (phdr->p_type) {
- case PT_LOAD:
- match |= data->pc >= addr && data->pc < addr + phdr->p_memsz;
- break;
- case PT_ARM_EXIDX:
- exidx_start = addr;
- exidx_len = phdr->p_memsz;
- break;
- }
- }
- data->exidx_start = exidx_start;
- data->exidx_len = exidx_len;
- return match;
-}
-
-uintptr_t __gnu_Unwind_Find_exidx(uintptr_t pc, int *pcount)
-{
- struct find_exidx_data data;
- data.pc = pc;
- if (dl_iterate_phdr(find_exidx, &data) <= 0)
- return 0;
- *pcount = data.exidx_len / 8;
- return data.exidx_start;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dl_iterate_phdr.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dl_iterate_phdr.c
deleted file mode 100644
index 9546dd3609..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dl_iterate_phdr.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <elf.h>
-#include <link.h>
-#include "pthread_impl.h"
-#include "libc.h"
-
-#define AUX_CNT 38
-
-extern weak hidden const size_t _DYNAMIC[];
-
-static int static_dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void *data), void *data)
-{
- unsigned char *p;
- ElfW(Phdr) *phdr, *tls_phdr=0;
- size_t base = 0;
- size_t n;
- struct dl_phdr_info info;
- size_t i, aux[AUX_CNT] = {0};
-
- for (i=0; libc.auxv[i]; i+=2)
- if (libc.auxv[i]<AUX_CNT) aux[libc.auxv[i]] = libc.auxv[i+1];
-
- for (p=(void *)aux[AT_PHDR],n=aux[AT_PHNUM]; n; n--,p+=aux[AT_PHENT]) {
- phdr = (void *)p;
- if (phdr->p_type == PT_PHDR)
- base = aux[AT_PHDR] - phdr->p_vaddr;
- if (phdr->p_type == PT_DYNAMIC && _DYNAMIC)
- base = (size_t)_DYNAMIC - phdr->p_vaddr;
- if (phdr->p_type == PT_TLS)
- tls_phdr = phdr;
- }
- info.dlpi_addr = base;
- info.dlpi_name = "/proc/self/exe";
- info.dlpi_phdr = (void *)aux[AT_PHDR];
- info.dlpi_phnum = aux[AT_PHNUM];
- info.dlpi_adds = 0;
- info.dlpi_subs = 0;
- if (tls_phdr) {
- info.dlpi_tls_modid = 1;
- info.dlpi_tls_data = __tls_get_addr((tls_mod_off_t[]){1,0});
- } else {
- info.dlpi_tls_modid = 0;
- info.dlpi_tls_data = 0;
- }
- return (callback)(&info, sizeof (info), data);
-}
-
-weak_alias(static_dl_iterate_phdr, dl_iterate_phdr);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dladdr.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dladdr.c
deleted file mode 100644
index e5c80206a8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dladdr.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <dlfcn.h>
-
-static int stub_dladdr(const void *addr, Dl_info *info)
-{
- return 0;
-}
-
-weak_alias(stub_dladdr, dladdr);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlclose.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dlclose.c
deleted file mode 100644
index e437422a67..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlclose.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <dlfcn.h>
-#include "dynlink.h"
-
-int dlclose(void *p)
-{
- return __dl_invalid_handle(p);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlerror.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dlerror.c
deleted file mode 100644
index afe59253ea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlerror.c
+++ /dev/null
@@ -1,87 +0,0 @@
-#include <dlfcn.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include "pthread_impl.h"
-#include "dynlink.h"
-#include "lock.h"
-#include "fork_impl.h"
-
-#define malloc __libc_malloc
-#define calloc __libc_calloc
-#define realloc __libc_realloc
-#define free __libc_free
-
-char *dlerror()
-{
- pthread_t self = __pthread_self();
- if (!self->dlerror_flag) return 0;
- self->dlerror_flag = 0;
- char *s = self->dlerror_buf;
- if (s == (void *)-1)
- return "Dynamic linker failed to allocate memory for error message";
- else
- return s;
-}
-
-static volatile int freebuf_queue_lock[1];
-static void **freebuf_queue;
-volatile int *const __dlerror_lockptr = freebuf_queue_lock;
-
-void __dl_thread_cleanup(void)
-{
- pthread_t self = __pthread_self();
- if (self->dlerror_buf && self->dlerror_buf != (void *)-1) {
- LOCK(freebuf_queue_lock);
- void **p = (void **)self->dlerror_buf;
- *p = freebuf_queue;
- freebuf_queue = p;
- UNLOCK(freebuf_queue_lock);
- }
-}
-
-hidden void __dl_vseterr(const char *fmt, va_list ap)
-{
- LOCK(freebuf_queue_lock);
- void **q = freebuf_queue;
- freebuf_queue = 0;
- UNLOCK(freebuf_queue_lock);
-
- while (q) {
- void **p = *q;
- free(q);
- q = p;
- }
-
- va_list ap2;
- va_copy(ap2, ap);
- pthread_t self = __pthread_self();
- if (self->dlerror_buf != (void *)-1)
- free(self->dlerror_buf);
- size_t len = vsnprintf(0, 0, fmt, ap2);
- if (len < sizeof(void *)) len = sizeof(void *);
- va_end(ap2);
- char *buf = malloc(len+1);
- if (buf) {
- vsnprintf(buf, len+1, fmt, ap);
- } else {
- buf = (void *)-1;
- }
- self->dlerror_buf = buf;
- self->dlerror_flag = 1;
-}
-
-hidden void __dl_seterr(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- __dl_vseterr(fmt, ap);
- va_end(ap);
-}
-
-static int stub_invalid_handle(void *h)
-{
- __dl_seterr("Invalid library handle %p", (void *)h);
- return 1;
-}
-
-weak_alias(stub_invalid_handle, __dl_invalid_handle);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlinfo.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dlinfo.c
deleted file mode 100644
index b55f5fe6cf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlinfo.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#define _GNU_SOURCE
-#include <dlfcn.h>
-#include "dynlink.h"
-
-int dlinfo(void *dso, int req, void *res)
-{
- if (__dl_invalid_handle(dso)) return -1;
- if (req != RTLD_DI_LINKMAP) {
- __dl_seterr("Unsupported request %d", req);
- return -1;
- }
- *(struct link_map **)res = dso;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlopen.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dlopen.c
deleted file mode 100644
index 69372a220b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlopen.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <dlfcn.h>
-#include "dynlink.h"
-
-static void *stub_dlopen(const char *file, int mode)
-{
- __dl_seterr("Dynamic loading not supported");
- return 0;
-}
-
-weak_alias(stub_dlopen, dlopen);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlsym.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/dlsym.c
deleted file mode 100644
index 65eb27659f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/dlsym.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <dlfcn.h>
-#include "dynlink.h"
-
-void *dlsym(void *restrict p, const char *restrict s)
-{
- return __dlsym(p, s, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/dlsym.s
deleted file mode 100644
index 097e30ce9c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/dlsym.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- push (%esp)
- push 12(%esp)
- push 12(%esp)
- call __dlsym
- add $12,%esp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/tlsdesc.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/tlsdesc.s
deleted file mode 100644
index 32c8176691..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/i386/tlsdesc.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.text
-.global __tlsdesc_static
-.hidden __tlsdesc_static
-.type __tlsdesc_static,@function
-__tlsdesc_static:
- mov 4(%eax),%eax
- ret
-
-.global __tlsdesc_dynamic
-.hidden __tlsdesc_dynamic
-.type __tlsdesc_dynamic,@function
-__tlsdesc_dynamic:
- mov 4(%eax),%eax
- push %edx
- mov %gs:4,%edx
- push %ecx
- mov (%eax),%ecx
- mov 4(%eax),%eax
- add (%edx,%ecx,4),%eax
- pop %ecx
- sub %gs:0,%eax
- pop %edx
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/m68k/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/m68k/dlsym.s
deleted file mode 100644
index 5209ae1b59..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/m68k/dlsym.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- move.l (%sp),-(%sp)
- move.l 12(%sp),-(%sp)
- move.l 12(%sp),-(%sp)
- lea __dlsym-.-8,%a1
- jsr (%pc,%a1)
- add.l #12,%sp
- rts
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/microblaze/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/microblaze/dlsym.s
deleted file mode 100644
index ea9d8be09d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/microblaze/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- brid __dlsym
- add r7, r15, r0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/mips/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/mips/dlsym.s
deleted file mode 100644
index 1573e51938..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/mips/dlsym.s
+++ /dev/null
@@ -1,17 +0,0 @@
-.set noreorder
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- lui $gp, %hi(_gp_disp)
- addiu $gp, %lo(_gp_disp)
- addu $gp, $gp, $25
- move $6, $ra
- lw $25, %call16(__dlsym)($gp)
- addiu $sp, $sp, -16
- sw $ra, 12($sp)
- jalr $25
- nop
- lw $ra, 12($sp)
- jr $ra
- addiu $sp, $sp, 16
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/mips64/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/mips64/dlsym.s
deleted file mode 100644
index 32e0dddc40..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/mips64/dlsym.s
+++ /dev/null
@@ -1,17 +0,0 @@
-.set noreorder
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- lui $3, %hi(%neg(%gp_rel(dlsym)))
- daddiu $3, $3, %lo(%neg(%gp_rel(dlsym)))
- daddu $3, $3, $25
- move $6, $ra
- ld $25, %got_disp(__dlsym)($3)
- daddiu $sp, $sp, -32
- sd $ra, 24($sp)
- jalr $25
- nop
- ld $ra, 24($sp)
- jr $ra
- daddiu $sp, $sp, 32
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/mipsn32/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/mipsn32/dlsym.s
deleted file mode 100644
index 1c82da3003..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/mipsn32/dlsym.s
+++ /dev/null
@@ -1,17 +0,0 @@
-.set noreorder
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- lui $3, %hi(%neg(%gp_rel(dlsym)))
- addiu $3, $3, %lo(%neg(%gp_rel(dlsym)))
- addu $3, $3, $25
- move $6, $ra
- lw $25, %got_disp(__dlsym)($3)
- addiu $sp, $sp, -32
- sd $ra, 16($sp)
- jalr $25
- nop
- ld $ra, 16($sp)
- jr $ra
- addiu $sp, $sp, 32
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/or1k/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/or1k/dlsym.s
deleted file mode 100644
index 122475c158..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/or1k/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- l.j __dlsym
- l.ori r5, r9, 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc/dlsym.s
deleted file mode 100644
index cfe308ef57..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc/dlsym.s
+++ /dev/null
@@ -1,8 +0,0 @@
- .text
- .global dlsym
- .hidden __dlsym
- .type dlsym,@function
-dlsym:
- mflr 5 # The return address is arg3.
- b __dlsym
- .size dlsym, .-dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc64/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc64/dlsym.s
deleted file mode 100644
index a14715fd4d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/powerpc64/dlsym.s
+++ /dev/null
@@ -1,11 +0,0 @@
- .text
- .global dlsym
- .hidden __dlsym
- .type dlsym,@function
-dlsym:
- addis 2, 12, .TOC.-dlsym@ha
- addi 2, 2, .TOC.-dlsym@l
- .localentry dlsym,.-dlsym
- mflr 5 # The return address is arg3.
- b __dlsym
- .size dlsym, .-dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/riscv64/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/riscv64/dlsym.s
deleted file mode 100644
index 2bafd72d3e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/riscv64/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global dlsym
-.hidden __dlsym
-.type dlsym, %function
-dlsym:
- mv a2, ra
- tail __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/s390x/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/s390x/dlsym.s
deleted file mode 100644
index 2e9fa8fb4b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/s390x/dlsym.s
+++ /dev/null
@@ -1,6 +0,0 @@
- .global dlsym
- .hidden __dlsym
- .type dlsym,@function
-dlsym:
- lgr %r4, %r14
- jg __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/sh/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/sh/dlsym.s
deleted file mode 100644
index 11a6fff5ff..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/sh/dlsym.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym, @function
-dlsym:
- mov.l L1, r0
-1: braf r0
- mov.l @r15, r6
-
-.align 2
-L1: .long __dlsym@PLT-(1b+4-.)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/tlsdesc.c b/lib/libc/wasi/libc-top-half/musl/src/ldso/tlsdesc.c
deleted file mode 100644
index 49a1f18c03..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/tlsdesc.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stddef.h>
-#include <dynlink.h>
-
-ptrdiff_t __tlsdesc_static()
-{
- return 0;
-}
-
-weak_alias(__tlsdesc_static, __tlsdesc_dynamic);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/x32/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/x32/dlsym.s
deleted file mode 100644
index d840b955c3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/x32/dlsym.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- mov (%rsp),%rdx
- jmp __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/dlsym.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/dlsym.s
deleted file mode 100644
index d840b955c3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/dlsym.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.text
-.global dlsym
-.hidden __dlsym
-.type dlsym,@function
-dlsym:
- mov (%rsp),%rdx
- jmp __dlsym
diff --git a/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s b/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s
deleted file mode 100644
index e08f1d7df5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.text
-.global __tlsdesc_static
-.hidden __tlsdesc_static
-.type __tlsdesc_static,@function
-__tlsdesc_static:
- mov 8(%rax),%rax
- ret
-
-.global __tlsdesc_dynamic
-.hidden __tlsdesc_dynamic
-.type __tlsdesc_dynamic,@function
-__tlsdesc_dynamic:
- mov 8(%rax),%rax
- push %rdx
- mov %fs:8,%rdx
- push %rcx
- mov (%rax),%rcx
- mov 8(%rax),%rax
- add (%rdx,%rcx,8),%rax
- pop %rcx
- sub %fs:0,%rax
- pop %rdx
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/cuserid.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/cuserid.c
deleted file mode 100644
index dcaf73d4e6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/cuserid.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#define _GNU_SOURCE
-#include <pwd.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-
-char *cuserid(char *buf)
-{
- static char usridbuf[L_cuserid];
- struct passwd pw, *ppw;
- long pwb[256];
- if (buf) *buf = 0;
- getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw);
- if (!ppw)
- return buf;
- size_t len = strnlen(pw.pw_name, L_cuserid);
- if (len == L_cuserid)
- return buf;
- if (!buf) buf = usridbuf;
- memcpy(buf, pw.pw_name, len+1);
- return buf;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/daemon.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/daemon.c
deleted file mode 100644
index 1568b1dcb7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/daemon.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <unistd.h>
-
-int daemon(int nochdir, int noclose)
-{
- if (!nochdir && chdir("/"))
- return -1;
- if (!noclose) {
- int fd, failed = 0;
- if ((fd = open("/dev/null", O_RDWR)) < 0) return -1;
- if (dup2(fd, 0) < 0 || dup2(fd, 1) < 0 || dup2(fd, 2) < 0)
- failed++;
- if (fd > 2) close(fd);
- if (failed) return -1;
- }
-
- switch(fork()) {
- case 0: break;
- case -1: return -1;
- default: _exit(0);
- }
-
- if (setsid() < 0) return -1;
-
- switch(fork()) {
- case 0: break;
- case -1: return -1;
- default: _exit(0);
- }
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/err.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/err.c
deleted file mode 100644
index 0d6ab5242d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/err.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <err.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-
-extern char *__progname;
-
-void vwarn(const char *fmt, va_list ap)
-{
- fprintf (stderr, "%s: ", __progname);
- if (fmt) {
- vfprintf(stderr, fmt, ap);
- fputs (": ", stderr);
- }
- perror(0);
-}
-
-void vwarnx(const char *fmt, va_list ap)
-{
- fprintf (stderr, "%s: ", __progname);
- if (fmt) vfprintf(stderr, fmt, ap);
- putc('\n', stderr);
-}
-
-_Noreturn void verr(int status, const char *fmt, va_list ap)
-{
- vwarn(fmt, ap);
- exit(status);
-}
-
-_Noreturn void verrx(int status, const char *fmt, va_list ap)
-{
- vwarnx(fmt, ap);
- exit(status);
-}
-
-void warn(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vwarn(fmt, ap);
- va_end(ap);
-}
-
-void warnx(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vwarnx(fmt, ap);
- va_end(ap);
-}
-
-_Noreturn void err(int status, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- verr(status, fmt, ap);
- va_end(ap);
-}
-
-_Noreturn void errx(int status, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- verrx(status, fmt, ap);
- va_end(ap);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/euidaccess.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/euidaccess.c
deleted file mode 100644
index 6e1f39855e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/euidaccess.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <fcntl.h>
-
-int euidaccess(const char *filename, int amode)
-{
- return faccessat(AT_FDCWD, filename, amode, AT_EACCESS);
-}
-
-weak_alias(euidaccess, eaccess);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/ftw.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/ftw.c
deleted file mode 100644
index 506bd29ced..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/ftw.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <ftw.h>
-
-int ftw(const char *path, int (*fn)(const char *, const struct stat *, int), int fd_limit)
-{
- /* The following cast assumes that calling a function with one
- * argument more than it needs behaves as expected. This is
- * actually undefined, but works on all real-world machines. */
- return nftw(path, (int (*)())fn, fd_limit, FTW_PHYS);
-}
-
-weak_alias(ftw, ftw64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/futimes.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/futimes.c
deleted file mode 100644
index 1c19eb1fa1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/futimes.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/stat.h>
-#include <sys/time.h>
-
-int futimes(int fd, const struct timeval tv[2])
-{
- struct timespec times[2];
- if (!tv) return futimens(fd, 0);
- times[0].tv_sec = tv[0].tv_sec;
- times[0].tv_nsec = tv[0].tv_usec * 1000;
- times[1].tv_sec = tv[1].tv_sec;
- times[1].tv_nsec = tv[1].tv_usec * 1000;
- return futimens(fd, times);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/getdtablesize.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/getdtablesize.c
deleted file mode 100644
index b30c1933a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/getdtablesize.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <limits.h>
-#include <sys/resource.h>
-
-int getdtablesize(void)
-{
- struct rlimit rl;
- getrlimit(RLIMIT_NOFILE, &rl);
- return rl.rlim_cur < INT_MAX ? rl.rlim_cur : INT_MAX;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/getloadavg.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/getloadavg.c
deleted file mode 100644
index ff06de0f8d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/getloadavg.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <sys/sysinfo.h>
-
-int getloadavg(double *a, int n)
-{
- struct sysinfo si;
- if (n <= 0) return n ? -1 : 0;
- sysinfo(&si);
- if (n > 3) n = 3;
- for (int i=0; i<n; i++)
- a[i] = 1.0/(1<<SI_LOAD_SHIFT) * si.loads[i];
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/getpass.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/getpass.c
deleted file mode 100644
index d51286c0b0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/getpass.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <termios.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-
-char *getpass(const char *prompt)
-{
- int fd;
- struct termios s, t;
- ssize_t l;
- static char password[128];
-
- if ((fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_CLOEXEC)) < 0) return 0;
-
- tcgetattr(fd, &t);
- s = t;
- t.c_lflag &= ~(ECHO|ISIG);
- t.c_lflag |= ICANON;
- t.c_iflag &= ~(INLCR|IGNCR);
- t.c_iflag |= ICRNL;
- tcsetattr(fd, TCSAFLUSH, &t);
- tcdrain(fd);
-
- dprintf(fd, "%s", prompt);
-
- l = read(fd, password, sizeof password);
- if (l >= 0) {
- if (l > 0 && password[l-1] == '\n' || l==sizeof password) l--;
- password[l] = 0;
- }
-
- tcsetattr(fd, TCSAFLUSH, &s);
-
- dprintf(fd, "\n");
- close(fd);
-
- return l<0 ? 0 : password;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/getusershell.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/getusershell.c
deleted file mode 100644
index 5fecdec2e4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/getusershell.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <unistd.h>
-
-static const char defshells[] = "/bin/sh\n/bin/csh\n";
-
-static char *line;
-static size_t linesize;
-static FILE *f;
-
-void endusershell(void)
-{
- if (f) fclose(f);
- f = 0;
-}
-
-void setusershell(void)
-{
- if (!f) f = fopen("/etc/shells", "rbe");
- if (!f) f = fmemopen((void *)defshells, sizeof defshells - 1, "rb");
-}
-
-char *getusershell(void)
-{
- ssize_t l;
- if (!f) setusershell();
- if (!f) return 0;
- l = getline(&line, &linesize, f);
- if (l <= 0) return 0;
- if (line[l-1]=='\n') line[l-1]=0;
- return line;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/isastream.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/isastream.c
deleted file mode 100644
index 4dafdb0821..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/isastream.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stropts.h>
-#include <fcntl.h>
-
-int isastream(int fd)
-{
- return fcntl(fd, F_GETFD) < 0 ? -1 : 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/lutimes.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/lutimes.c
deleted file mode 100644
index dd465923ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/lutimes.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <fcntl.h>
-
-int lutimes(const char *filename, const struct timeval tv[2])
-{
- struct timespec times[2];
- if (tv) {
- times[0].tv_sec = tv[0].tv_sec;
- times[0].tv_nsec = tv[0].tv_usec * 1000;
- times[1].tv_sec = tv[1].tv_sec;
- times[1].tv_nsec = tv[1].tv_usec * 1000;
- }
- return utimensat(AT_FDCWD, filename, tv ? times : 0, AT_SYMLINK_NOFOLLOW);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/ulimit.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/ulimit.c
deleted file mode 100644
index 1f59e8e619..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/ulimit.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sys/resource.h>
-#include <ulimit.h>
-#include <stdarg.h>
-
-long ulimit(int cmd, ...)
-{
- struct rlimit rl;
- getrlimit(RLIMIT_FSIZE, &rl);
- if (cmd == UL_SETFSIZE) {
- long val;
- va_list ap;
- va_start(ap, cmd);
- val = va_arg(ap, long);
- va_end(ap);
- rl.rlim_cur = 512ULL * val;
- if (setrlimit(RLIMIT_FSIZE, &rl)) return -1;
- }
- return rl.rlim_cur / 512;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/utmpx.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/utmpx.c
deleted file mode 100644
index 7aa65da335..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/utmpx.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#define _GNU_SOURCE
-#include <utmpx.h>
-#include <stddef.h>
-#include <errno.h>
-
-void endutxent(void)
-{
-}
-
-void setutxent(void)
-{
-}
-
-struct utmpx *getutxent(void)
-{
- return NULL;
-}
-
-struct utmpx *getutxid(const struct utmpx *ut)
-{
- return NULL;
-}
-
-struct utmpx *getutxline(const struct utmpx *ut)
-{
- return NULL;
-}
-
-struct utmpx *pututxline(const struct utmpx *ut)
-{
- return NULL;
-}
-
-void updwtmpx(const char *f, const struct utmpx *u)
-{
-}
-
-static int __utmpxname(const char *f)
-{
- errno = ENOTSUP;
- return -1;
-}
-
-weak_alias(endutxent, endutent);
-weak_alias(setutxent, setutent);
-weak_alias(getutxent, getutent);
-weak_alias(getutxid, getutid);
-weak_alias(getutxline, getutline);
-weak_alias(pututxline, pututline);
-weak_alias(updwtmpx, updwtmp);
-weak_alias(__utmpxname, utmpname);
-weak_alias(__utmpxname, utmpxname);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/legacy/valloc.c b/lib/libc/wasi/libc-top-half/musl/src/legacy/valloc.c
deleted file mode 100644
index 5af2256a47..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/legacy/valloc.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-#include "libc.h"
-
-void *valloc(size_t size)
-{
- return memalign(PAGE_SIZE, size);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/adjtime.c b/lib/libc/wasi/libc-top-half/musl/src/linux/adjtime.c
deleted file mode 100644
index 5a707f2f21..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/adjtime.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/time.h>
-#include <sys/timex.h>
-#include <errno.h>
-#include "syscall.h"
-
-int adjtime(const struct timeval *in, struct timeval *out)
-{
- struct timex tx = { 0 };
- if (in) {
- if (in->tv_sec > 1000 || in->tv_usec > 1000000000) {
- errno = EINVAL;
- return -1;
- }
- tx.offset = in->tv_sec*1000000 + in->tv_usec;
- tx.modes = ADJ_OFFSET_SINGLESHOT;
- }
- if (adjtimex(&tx) < 0) return -1;
- if (out) {
- out->tv_sec = tx.offset / 1000000;
- if ((out->tv_usec = tx.offset % 1000000) < 0) {
- out->tv_sec--;
- out->tv_usec += 1000000;
- }
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/adjtimex.c b/lib/libc/wasi/libc-top-half/musl/src/linux/adjtimex.c
deleted file mode 100644
index e9d727cf3a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/adjtimex.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/timex.h>
-#include <time.h>
-
-int adjtimex(struct timex *tx)
-{
- return clock_adjtime(CLOCK_REALTIME, tx);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/arch_prctl.c b/lib/libc/wasi/libc-top-half/musl/src/linux/arch_prctl.c
deleted file mode 100644
index 94603658ab..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/arch_prctl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "syscall.h"
-#ifdef SYS_arch_prctl
-int arch_prctl(int code, unsigned long addr)
-{
- return syscall(SYS_arch_prctl, code, addr);
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/brk.c b/lib/libc/wasi/libc-top-half/musl/src/linux/brk.c
deleted file mode 100644
index a6173e07f3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/brk.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <errno.h>
-#include "syscall.h"
-
-int brk(void *end)
-{
- return __syscall_ret(-ENOMEM);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/cache.c b/lib/libc/wasi/libc-top-half/musl/src/linux/cache.c
deleted file mode 100644
index 0eb051c2d4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/cache.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include <errno.h>
-#include "syscall.h"
-#include "atomic.h"
-
-#ifdef SYS_cacheflush
-int _flush_cache(void *addr, int len, int op)
-{
- return syscall(SYS_cacheflush, addr, len, op);
-}
-weak_alias(_flush_cache, cacheflush);
-#endif
-
-#ifdef SYS_cachectl
-int __cachectl(void *addr, int len, int op)
-{
- return syscall(SYS_cachectl, addr, len, op);
-}
-weak_alias(__cachectl, cachectl);
-#endif
-
-#ifdef SYS_riscv_flush_icache
-
-#define VDSO_FLUSH_ICACHE_SYM "__vdso_flush_icache"
-#define VDSO_FLUSH_ICACHE_VER "LINUX_4.5"
-
-static void *volatile vdso_func;
-
-static int flush_icache_init(void *start, void *end, unsigned long int flags)
-{
- void *p = __vdsosym(VDSO_FLUSH_ICACHE_VER, VDSO_FLUSH_ICACHE_SYM);
- int (*f)(void *, void *, unsigned long int) =
- (int (*)(void *, void *, unsigned long int))p;
- a_cas_p(&vdso_func, (void *)flush_icache_init, p);
- return f ? f(start, end, flags) : -ENOSYS;
-}
-
-static void *volatile vdso_func = (void *)flush_icache_init;
-
-int __riscv_flush_icache(void *start, void *end, unsigned long int flags)
-{
- int (*f)(void *, void *, unsigned long int) =
- (int (*)(void *, void *, unsigned long int))vdso_func;
- if (f) {
- int r = f(start, end, flags);
- if (!r) return r;
- if (r != -ENOSYS) return __syscall_ret(r);
- }
-}
-weak_alias(__riscv_flush_icache, riscv_flush_icache);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/cap.c b/lib/libc/wasi/libc-top-half/musl/src/linux/cap.c
deleted file mode 100644
index 8d035e07a4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/cap.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "syscall.h"
-
-int capset(void *a, void *b)
-{
- return syscall(SYS_capset, a, b);
-}
-
-int capget(void *a, void *b)
-{
- return syscall(SYS_capget, a, b);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/chroot.c b/lib/libc/wasi/libc-top-half/musl/src/linux/chroot.c
deleted file mode 100644
index 0e69f145de..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/chroot.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int chroot(const char *path)
-{
- return syscall(SYS_chroot, path);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/clock_adjtime.c b/lib/libc/wasi/libc-top-half/musl/src/linux/clock_adjtime.c
deleted file mode 100644
index d4d03d24df..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/clock_adjtime.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <sys/timex.h>
-#include <time.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-
-struct ktimex64 {
- unsigned modes;
- int :32;
- long long offset, freq, maxerror, esterror;
- int status;
- int :32;
- long long constant, precision, tolerance;
- long long time_sec, time_usec;
- long long tick, ppsfreq, jitter;
- int shift;
- int :32;
- long long stabil, jitcnt, calcnt, errcnt, stbcnt;
- int tai;
- int __padding[11];
-};
-
-struct ktimex {
- unsigned modes;
- long offset, freq, maxerror, esterror;
- int status;
- long constant, precision, tolerance;
- long time_sec, time_usec;
- long tick, ppsfreq, jitter;
- int shift;
- long stabil, jitcnt, calcnt, errcnt, stbcnt;
- int tai;
- int __padding[11];
-};
-
-int clock_adjtime (clockid_t clock_id, struct timex *utx)
-{
- int r = -ENOSYS;
-#ifdef SYS_clock_adjtime64
- struct ktimex64 ktx = {
- .modes = utx->modes,
- .offset = utx->offset,
- .freq = utx->freq,
- .maxerror = utx->maxerror,
- .esterror = utx->esterror,
- .status = utx->status,
- .constant = utx->constant,
- .precision = utx->precision,
- .tolerance = utx->tolerance,
- .time_sec = utx->time.tv_sec,
- .time_usec = utx->time.tv_usec,
- .tick = utx->tick,
- .ppsfreq = utx->ppsfreq,
- .jitter = utx->jitter,
- .shift = utx->shift,
- .stabil = utx->stabil,
- .jitcnt = utx->jitcnt,
- .calcnt = utx->calcnt,
- .errcnt = utx->errcnt,
- .stbcnt = utx->stbcnt,
- .tai = utx->tai,
- };
- r = __syscall(SYS_clock_adjtime64, clock_id, &ktx);
- if (r>=0) {
- utx->modes = ktx.modes;
- utx->offset = ktx.offset;
- utx->freq = ktx.freq;
- utx->maxerror = ktx.maxerror;
- utx->esterror = ktx.esterror;
- utx->status = ktx.status;
- utx->constant = ktx.constant;
- utx->precision = ktx.precision;
- utx->tolerance = ktx.tolerance;
- utx->time.tv_sec = ktx.time_sec;
- utx->time.tv_usec = ktx.time_usec;
- utx->tick = ktx.tick;
- utx->ppsfreq = ktx.ppsfreq;
- utx->jitter = ktx.jitter;
- utx->shift = ktx.shift;
- utx->stabil = ktx.stabil;
- utx->jitcnt = ktx.jitcnt;
- utx->calcnt = ktx.calcnt;
- utx->errcnt = ktx.errcnt;
- utx->stbcnt = ktx.stbcnt;
- utx->tai = ktx.tai;
- }
- if (SYS_clock_adjtime == SYS_clock_adjtime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if ((utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec))
- return __syscall_ret(-ENOTSUP);
-#endif
- if (sizeof(time_t) > sizeof(long)) {
- struct ktimex ktx = {
- .modes = utx->modes,
- .offset = utx->offset,
- .freq = utx->freq,
- .maxerror = utx->maxerror,
- .esterror = utx->esterror,
- .status = utx->status,
- .constant = utx->constant,
- .precision = utx->precision,
- .tolerance = utx->tolerance,
- .time_sec = utx->time.tv_sec,
- .time_usec = utx->time.tv_usec,
- .tick = utx->tick,
- .ppsfreq = utx->ppsfreq,
- .jitter = utx->jitter,
- .shift = utx->shift,
- .stabil = utx->stabil,
- .jitcnt = utx->jitcnt,
- .calcnt = utx->calcnt,
- .errcnt = utx->errcnt,
- .stbcnt = utx->stbcnt,
- .tai = utx->tai,
- };
-#ifdef SYS_adjtimex
- if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &ktx);
- else
-#endif
- r = __syscall(SYS_clock_adjtime, clock_id, &ktx);
- if (r>=0) {
- utx->modes = ktx.modes;
- utx->offset = ktx.offset;
- utx->freq = ktx.freq;
- utx->maxerror = ktx.maxerror;
- utx->esterror = ktx.esterror;
- utx->status = ktx.status;
- utx->constant = ktx.constant;
- utx->precision = ktx.precision;
- utx->tolerance = ktx.tolerance;
- utx->time.tv_sec = ktx.time_sec;
- utx->time.tv_usec = ktx.time_usec;
- utx->tick = ktx.tick;
- utx->ppsfreq = ktx.ppsfreq;
- utx->jitter = ktx.jitter;
- utx->shift = ktx.shift;
- utx->stabil = ktx.stabil;
- utx->jitcnt = ktx.jitcnt;
- utx->calcnt = ktx.calcnt;
- utx->errcnt = ktx.errcnt;
- utx->stbcnt = ktx.stbcnt;
- utx->tai = ktx.tai;
- }
- return __syscall_ret(r);
- }
-#ifdef SYS_adjtimex
- if (clock_id==CLOCK_REALTIME) return syscall(SYS_adjtimex, utx);
-#endif
- return syscall(SYS_clock_adjtime, clock_id, utx);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/clone.c b/lib/libc/wasi/libc-top-half/musl/src/linux/clone.c
deleted file mode 100644
index 8c1af7d3dc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/clone.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#define _GNU_SOURCE
-#include <stdarg.h>
-#include <unistd.h>
-#include <sched.h>
-#include "pthread_impl.h"
-#include "syscall.h"
-
-int clone(int (*func)(void *), void *stack, int flags, void *arg, ...)
-{
- va_list ap;
- pid_t *ptid, *ctid;
- void *tls;
-
- va_start(ap, arg);
- ptid = va_arg(ap, pid_t *);
- tls = va_arg(ap, void *);
- ctid = va_arg(ap, pid_t *);
- va_end(ap);
-
- return __syscall_ret(__clone(func, stack, flags, arg, ptid, tls, ctid));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/copy_file_range.c b/lib/libc/wasi/libc-top-half/musl/src/linux/copy_file_range.c
deleted file mode 100644
index dd4b133336..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/copy_file_range.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags)
-{
- return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/epoll.c b/lib/libc/wasi/libc-top-half/musl/src/linux/epoll.c
deleted file mode 100644
index 93baa8147e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/epoll.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <sys/epoll.h>
-#include <signal.h>
-#include <errno.h>
-#include "syscall.h"
-
-int epoll_create(int size)
-{
- return epoll_create1(0);
-}
-
-int epoll_create1(int flags)
-{
- int r = __syscall(SYS_epoll_create1, flags);
-#ifdef SYS_epoll_create
- if (r==-ENOSYS && !flags) r = __syscall(SYS_epoll_create, 1);
-#endif
- return __syscall_ret(r);
-}
-
-int epoll_ctl(int fd, int op, int fd2, struct epoll_event *ev)
-{
- return syscall(SYS_epoll_ctl, fd, op, fd2, ev);
-}
-
-int epoll_pwait(int fd, struct epoll_event *ev, int cnt, int to, const sigset_t *sigs)
-{
- int r = __syscall_cp(SYS_epoll_pwait, fd, ev, cnt, to, sigs, _NSIG/8);
-#ifdef SYS_epoll_wait
- if (r==-ENOSYS && !sigs) r = __syscall_cp(SYS_epoll_wait, fd, ev, cnt, to);
-#endif
- return __syscall_ret(r);
-}
-
-int epoll_wait(int fd, struct epoll_event *ev, int cnt, int to)
-{
- return epoll_pwait(fd, ev, cnt, to, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/eventfd.c b/lib/libc/wasi/libc-top-half/musl/src/linux/eventfd.c
deleted file mode 100644
index 68e489c836..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/eventfd.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <sys/eventfd.h>
-#include <unistd.h>
-#include <errno.h>
-#include "syscall.h"
-
-int eventfd(unsigned int count, int flags)
-{
- int r = __syscall(SYS_eventfd2, count, flags);
-#ifdef SYS_eventfd
- if (r==-ENOSYS && !flags) r = __syscall(SYS_eventfd, count);
-#endif
- return __syscall_ret(r);
-}
-
-int eventfd_read(int fd, eventfd_t *value)
-{
- return (sizeof(*value) == read(fd, value, sizeof(*value))) ? 0 : -1;
-}
-
-int eventfd_write(int fd, eventfd_t value)
-{
- return (sizeof(value) == write(fd, &value, sizeof(value))) ? 0 : -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/fallocate.c b/lib/libc/wasi/libc-top-half/musl/src/linux/fallocate.c
deleted file mode 100644
index 7d68bc8f64..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/fallocate.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-int fallocate(int fd, int mode, off_t base, off_t len)
-{
- return syscall(SYS_fallocate, fd, mode, __SYSCALL_LL_E(base),
- __SYSCALL_LL_E(len));
-}
-
-#undef fallocate64
-weak_alias(fallocate, fallocate64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/fanotify.c b/lib/libc/wasi/libc-top-half/musl/src/linux/fanotify.c
deleted file mode 100644
index c6211afc00..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/fanotify.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "syscall.h"
-#include <sys/fanotify.h>
-
-int fanotify_init(unsigned flags, unsigned event_f_flags)
-{
- return syscall(SYS_fanotify_init, flags, event_f_flags);
-}
-
-int fanotify_mark(int fanotify_fd, unsigned flags, unsigned long long mask,
- int dfd, const char *pathname)
-{
- return syscall(SYS_fanotify_mark, fanotify_fd, flags, __SYSCALL_LL_E(mask), dfd, pathname);
-}
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/flock.c b/lib/libc/wasi/libc-top-half/musl/src/linux/flock.c
deleted file mode 100644
index 87aa5cfed2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/flock.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/file.h>
-#include "syscall.h"
-
-int flock(int fd, int op)
-{
- return syscall(SYS_flock, fd, op);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/getdents.c b/lib/libc/wasi/libc-top-half/musl/src/linux/getdents.c
deleted file mode 100644
index 796c1e5c92..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/getdents.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _BSD_SOURCE
-#include <dirent.h>
-#include <limits.h>
-#include "syscall.h"
-
-int getdents(int fd, struct dirent *buf, size_t len)
-{
- if (len>INT_MAX) len = INT_MAX;
- return syscall(SYS_getdents, fd, buf, len);
-}
-
-weak_alias(getdents, getdents64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/getrandom.c b/lib/libc/wasi/libc-top-half/musl/src/linux/getrandom.c
deleted file mode 100644
index 6cc6f6b047..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/getrandom.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/random.h>
-#include "syscall.h"
-
-ssize_t getrandom(void *buf, size_t buflen, unsigned flags)
-{
- return syscall_cp(SYS_getrandom, buf, buflen, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/gettid.c b/lib/libc/wasi/libc-top-half/musl/src/linux/gettid.c
deleted file mode 100644
index 70767137e9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/gettid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "pthread_impl.h"
-
-pid_t gettid(void)
-{
- return __pthread_self()->tid;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/inotify.c b/lib/libc/wasi/libc-top-half/musl/src/linux/inotify.c
deleted file mode 100644
index df5e48b31b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/inotify.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <sys/inotify.h>
-#include <errno.h>
-#include "syscall.h"
-
-int inotify_init()
-{
- return inotify_init1(0);
-}
-int inotify_init1(int flags)
-{
- int r = __syscall(SYS_inotify_init1, flags);
-#ifdef SYS_inotify_init
- if (r==-ENOSYS && !flags) r = __syscall(SYS_inotify_init);
-#endif
- return __syscall_ret(r);
-}
-
-int inotify_add_watch(int fd, const char *pathname, uint32_t mask)
-{
- return syscall(SYS_inotify_add_watch, fd, pathname, mask);
-}
-
-int inotify_rm_watch(int fd, int wd)
-{
- return syscall(SYS_inotify_rm_watch, fd, wd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/ioperm.c b/lib/libc/wasi/libc-top-half/musl/src/linux/ioperm.c
deleted file mode 100644
index 08c6d8b86c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/ioperm.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "syscall.h"
-
-#ifdef SYS_ioperm
-#include <sys/io.h>
-
-int ioperm(unsigned long from, unsigned long num, int turn_on)
-{
- return syscall(SYS_ioperm, from, num, turn_on);
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/iopl.c b/lib/libc/wasi/libc-top-half/musl/src/linux/iopl.c
deleted file mode 100644
index 835d3d4ed5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/iopl.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "syscall.h"
-
-#ifdef SYS_iopl
-#include <sys/io.h>
-
-int iopl(int level)
-{
- return syscall(SYS_iopl, level);
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/klogctl.c b/lib/libc/wasi/libc-top-half/musl/src/linux/klogctl.c
deleted file mode 100644
index 8102ee641c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/klogctl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/klog.h>
-#include "syscall.h"
-
-int klogctl (int type, char *buf, int len)
-{
- return syscall(SYS_syslog, type, buf, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/membarrier.c b/lib/libc/wasi/libc-top-half/musl/src/linux/membarrier.c
deleted file mode 100644
index 343f7360ee..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/membarrier.c
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <sys/membarrier.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <string.h>
-#include "pthread_impl.h"
-#include "syscall.h"
-
-static void dummy_0(void)
-{
-}
-
-weak_alias(dummy_0, __tl_lock);
-weak_alias(dummy_0, __tl_unlock);
-
-static sem_t barrier_sem;
-
-static void bcast_barrier(int s)
-{
- sem_post(&barrier_sem);
-}
-
-int __membarrier(int cmd, int flags)
-{
- int r = __syscall(SYS_membarrier, cmd, flags);
- /* Emulate the private expedited command, which is needed by the
- * dynamic linker for installation of dynamic TLS, for older
- * kernels that lack the syscall. Unlike the syscall, this only
- * synchronizes with threads of the process, not other processes
- * sharing the VM, but such sharing is not a supported usage
- * anyway. */
- if (r && cmd == MEMBARRIER_CMD_PRIVATE_EXPEDITED && !flags) {
- pthread_t self=__pthread_self(), td;
- sigset_t set;
- __block_app_sigs(&set);
- __tl_lock();
- sem_init(&barrier_sem, 0, 0);
- struct sigaction sa = {
- .sa_flags = SA_RESTART,
- .sa_handler = bcast_barrier
- };
- memset(&sa.sa_mask, -1, sizeof sa.sa_mask);
- if (!__libc_sigaction(SIGSYNCCALL, &sa, 0)) {
- for (td=self->next; td!=self; td=td->next)
- __syscall(SYS_tkill, td->tid, SIGSYNCCALL);
- for (td=self->next; td!=self; td=td->next)
- sem_wait(&barrier_sem);
- r = 0;
- sa.sa_handler = SIG_IGN;
- __libc_sigaction(SIGSYNCCALL, &sa, 0);
- }
- sem_destroy(&barrier_sem);
- __tl_unlock();
- __restore_sigs(&set);
- }
- return __syscall_ret(r);
-}
-
-void __membarrier_init(void)
-{
- /* If membarrier is linked, attempt to pre-register to be able to use
- * the private expedited command before the process becomes multi-
- * threaded, since registering later has bad, potentially unbounded
- * latency. This syscall should be essentially free, and it's arguably
- * a mistake in the API design that registration was even required.
- * For other commands, registration may impose some cost, so it's left
- * to the application to do so if desired. Unfortunately this means
- * library code initialized after the process becomes multi-threaded
- * cannot use these features without accepting registration latency. */
- __syscall(SYS_membarrier, MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0);
-}
-
-weak_alias(__membarrier, membarrier);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/memfd_create.c b/lib/libc/wasi/libc-top-half/musl/src/linux/memfd_create.c
deleted file mode 100644
index 1649fe5548..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/memfd_create.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE 1
-#include <sys/mman.h>
-#include "syscall.h"
-
-int memfd_create(const char *name, unsigned flags)
-{
- return syscall(SYS_memfd_create, name, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/mlock2.c b/lib/libc/wasi/libc-top-half/musl/src/linux/mlock2.c
deleted file mode 100644
index 10132742d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/mlock2.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#define _GNU_SOURCE 1
-#include <sys/mman.h>
-#include "syscall.h"
-
-int mlock2(const void *addr, size_t len, unsigned flags)
-{
- if (flags == 0)
- return mlock(addr, len);
- return syscall(SYS_mlock2, addr, len, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/module.c b/lib/libc/wasi/libc-top-half/musl/src/linux/module.c
deleted file mode 100644
index 33f69a0006..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/module.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "syscall.h"
-
-int init_module(void *a, unsigned long b, const char *c)
-{
- return syscall(SYS_init_module, a, b, c);
-}
-
-int delete_module(const char *a, unsigned b)
-{
- return syscall(SYS_delete_module, a, b);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/mount.c b/lib/libc/wasi/libc-top-half/musl/src/linux/mount.c
deleted file mode 100644
index 34e11af120..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/mount.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <sys/mount.h>
-#include "syscall.h"
-
-int mount(const char *special, const char *dir, const char *fstype, unsigned long flags, const void *data)
-{
- return syscall(SYS_mount, special, dir, fstype, flags, data);
-}
-
-int umount(const char *special)
-{
- return syscall(SYS_umount2, special, 0);
-}
-
-int umount2(const char *special, int flags)
-{
- return syscall(SYS_umount2, special, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/name_to_handle_at.c b/lib/libc/wasi/libc-top-half/musl/src/linux/name_to_handle_at.c
deleted file mode 100644
index cd4075bd7e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/name_to_handle_at.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-int name_to_handle_at(int dirfd, const char *pathname,
- struct file_handle *handle, int *mount_id, int flags)
-{
- return syscall(SYS_name_to_handle_at, dirfd,
- pathname, handle, mount_id, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/open_by_handle_at.c b/lib/libc/wasi/libc-top-half/musl/src/linux/open_by_handle_at.c
deleted file mode 100644
index 1c9b6a2be4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/open_by_handle_at.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-int open_by_handle_at(int mount_fd, struct file_handle *handle, int flags)
-{
- return syscall(SYS_open_by_handle_at, mount_fd, handle, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/personality.c b/lib/libc/wasi/libc-top-half/musl/src/linux/personality.c
deleted file mode 100644
index e00cf7997f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/personality.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/personality.h>
-#include "syscall.h"
-#ifdef SYS_personality
-int personality(unsigned long persona)
-{
- return syscall(SYS_personality, persona);
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/pivot_root.c b/lib/libc/wasi/libc-top-half/musl/src/linux/pivot_root.c
deleted file mode 100644
index 17e70c916e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/pivot_root.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "syscall.h"
-
-int pivot_root(const char *new, const char *old)
-{
- return syscall(SYS_pivot_root, new, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/ppoll.c b/lib/libc/wasi/libc-top-half/musl/src/linux/ppoll.c
deleted file mode 100644
index e614600ab8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/ppoll.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#define _GNU_SOURCE
-#include <poll.h>
-#include <signal.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int ppoll(struct pollfd *fds, nfds_t n, const struct timespec *to, const sigset_t *mask)
-{
- time_t s = to ? to->tv_sec : 0;
- long ns = to ? to->tv_nsec : 0;
-#ifdef SYS_ppoll_time64
- int r = -ENOSYS;
- if (SYS_ppoll == SYS_ppoll_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_ppoll_time64, fds, n,
- to ? ((long long[]){s, ns}) : 0,
- mask, _NSIG/8);
- if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS)
- return __syscall_ret(r);
- s = CLAMP(s);
-#endif
- return syscall_cp(SYS_ppoll, fds, n,
- to ? ((long[]){s, ns}) : 0, mask, _NSIG/8);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/prctl.c b/lib/libc/wasi/libc-top-half/musl/src/linux/prctl.c
deleted file mode 100644
index 19f4267cde..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/prctl.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <sys/prctl.h>
-#include <stdarg.h>
-#include "syscall.h"
-
-int prctl(int op, ...)
-{
- unsigned long x[4];
- int i;
- va_list ap;
- va_start(ap, op);
- for (i=0; i<4; i++) x[i] = va_arg(ap, unsigned long);
- va_end(ap);
- return syscall(SYS_prctl, op, x[0], x[1], x[2], x[3]);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/prlimit.c b/lib/libc/wasi/libc-top-half/musl/src/linux/prlimit.c
deleted file mode 100644
index 3df9ffba7a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/prlimit.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/resource.h>
-#include "syscall.h"
-
-#define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
-
-int prlimit(pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit)
-{
- struct rlimit tmp;
- int r;
- if (new_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
- tmp = *new_limit;
- FIX(tmp.rlim_cur);
- FIX(tmp.rlim_max);
- new_limit = &tmp;
- }
- r = syscall(SYS_prlimit64, pid, resource, new_limit, old_limit);
- if (!r && old_limit && SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
- FIX(old_limit->rlim_cur);
- FIX(old_limit->rlim_max);
- }
- return r;
-}
-
-#undef prlimit64
-weak_alias(prlimit, prlimit64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/process_vm.c b/lib/libc/wasi/libc-top-half/musl/src/linux/process_vm.c
deleted file mode 100644
index 7703bdf0c9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/process_vm.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/uio.h>
-#include "syscall.h"
-
-ssize_t process_vm_writev(pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovec *rvec, unsigned long riovcnt, unsigned long flags)
-{
- return syscall(SYS_process_vm_writev, pid, lvec, liovcnt, rvec, riovcnt, flags);
-}
-
-ssize_t process_vm_readv(pid_t pid, const struct iovec *lvec, unsigned long liovcnt, const struct iovec *rvec, unsigned long riovcnt, unsigned long flags)
-{
- return syscall(SYS_process_vm_readv, pid, lvec, liovcnt, rvec, riovcnt, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/ptrace.c b/lib/libc/wasi/libc-top-half/musl/src/linux/ptrace.c
deleted file mode 100644
index a3f393d956..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/ptrace.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <sys/ptrace.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include "syscall.h"
-
-long ptrace(int req, ...)
-{
- va_list ap;
- pid_t pid;
- void *addr, *data, *addr2 = 0;
- long ret, result;
-
- va_start(ap, req);
- pid = va_arg(ap, pid_t);
- addr = va_arg(ap, void *);
- data = va_arg(ap, void *);
- /* PTRACE_{READ,WRITE}{DATA,TEXT} (16...19) are specific to SPARC. */
-#ifdef PTRACE_READDATA
- if ((unsigned)req - PTRACE_READDATA < 4)
- addr2 = va_arg(ap, void *);
-#endif
- va_end(ap);
-
- if (req-1U < 3) data = &result;
- ret = syscall(SYS_ptrace, req, pid, addr, data, addr2);
-
- if (ret < 0 || req-1U >= 3) return ret;
- return result;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/quotactl.c b/lib/libc/wasi/libc-top-half/musl/src/linux/quotactl.c
deleted file mode 100644
index 344eb0d169..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/quotactl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/quota.h>
-#include "syscall.h"
-
-int quotactl(int cmd, const char *special, int id, char *addr)
-{
- return syscall(SYS_quotactl, cmd, special, id, addr);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/readahead.c b/lib/libc/wasi/libc-top-half/musl/src/linux/readahead.c
deleted file mode 100644
index 5c70bfd6e1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/readahead.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-ssize_t readahead(int fd, off_t pos, size_t len)
-{
- return syscall(SYS_readahead, fd, __SYSCALL_LL_O(pos), len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/reboot.c b/lib/libc/wasi/libc-top-half/musl/src/linux/reboot.c
deleted file mode 100644
index 7f12af79bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/reboot.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/reboot.h>
-#include "syscall.h"
-
-int reboot(int type)
-{
- return syscall(SYS_reboot, 0xfee1dead, 672274793, type);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/remap_file_pages.c b/lib/libc/wasi/libc-top-half/musl/src/linux/remap_file_pages.c
deleted file mode 100644
index a9699ce2e4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/remap_file_pages.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/mman.h>
-#include "syscall.h"
-
-int remap_file_pages(void *addr, size_t size, int prot, size_t pgoff, int flags)
-{
- return syscall(SYS_remap_file_pages, addr, size, prot, pgoff, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/sbrk.c b/lib/libc/wasi/libc-top-half/musl/src/linux/sbrk.c
deleted file mode 100644
index bb86630584..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/sbrk.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <stdint.h>
-#include <errno.h>
-#include "syscall.h"
-
-void *sbrk(intptr_t inc)
-{
- if (inc) return (void *)__syscall_ret(-ENOMEM);
- return (void *)__syscall(SYS_brk, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/sendfile.c b/lib/libc/wasi/libc-top-half/musl/src/linux/sendfile.c
deleted file mode 100644
index 9afe6dd61c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/sendfile.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/sendfile.h>
-#include "syscall.h"
-
-ssize_t sendfile(int out_fd, int in_fd, off_t *ofs, size_t count)
-{
- return syscall(SYS_sendfile, out_fd, in_fd, ofs, count);
-}
-
-weak_alias(sendfile, sendfile64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/setfsgid.c b/lib/libc/wasi/libc-top-half/musl/src/linux/setfsgid.c
deleted file mode 100644
index e29d9c0069..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/setfsgid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/fsuid.h>
-#include "syscall.h"
-
-int setfsgid(gid_t gid)
-{
- return syscall(SYS_setfsgid, gid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/setfsuid.c b/lib/libc/wasi/libc-top-half/musl/src/linux/setfsuid.c
deleted file mode 100644
index 1bae44186f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/setfsuid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/fsuid.h>
-#include "syscall.h"
-
-int setfsuid(uid_t uid)
-{
- return syscall(SYS_setfsuid, uid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/setgroups.c b/lib/libc/wasi/libc-top-half/musl/src/linux/setgroups.c
deleted file mode 100644
index 47142f141f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/setgroups.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <signal.h>
-#include "syscall.h"
-#include "libc.h"
-
-struct ctx {
- size_t count;
- const gid_t *list;
- int ret;
-};
-
-static void do_setgroups(void *p)
-{
- struct ctx *c = p;
- if (c->ret<0) return;
- int ret = __syscall(SYS_setgroups, c->count, c->list);
- if (ret && !c->ret) {
- /* If one thread fails to set groups after another has already
- * succeeded, forcibly killing the process is the only safe
- * thing to do. State is inconsistent and dangerous. Use
- * SIGKILL because it is uncatchable. */
- __block_all_sigs(0);
- __syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL);
- }
- c->ret = ret;
-}
-
-int setgroups(size_t count, const gid_t list[])
-{
- /* ret is initially nonzero so that failure of the first thread does not
- * trigger the safety kill above. */
- struct ctx c = { .count = count, .list = list, .ret = 1 };
- __synccall(do_setgroups, &c);
- return __syscall_ret(c.ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/sethostname.c b/lib/libc/wasi/libc-top-half/musl/src/linux/sethostname.c
deleted file mode 100644
index 9313b32455..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/sethostname.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int sethostname(const char *name, size_t len)
-{
- return syscall(SYS_sethostname, name, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/setns.c b/lib/libc/wasi/libc-top-half/musl/src/linux/setns.c
deleted file mode 100644
index 0afec813f1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/setns.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <sched.h>
-#include "syscall.h"
-
-int setns(int fd, int nstype)
-{
- return syscall(SYS_setns, fd, nstype);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/settimeofday.c b/lib/libc/wasi/libc-top-half/musl/src/linux/settimeofday.c
deleted file mode 100644
index 860fb5de97..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/settimeofday.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _BSD_SOURCE
-#include <sys/time.h>
-#include <time.h>
-#include <errno.h>
-#include "syscall.h"
-
-int settimeofday(const struct timeval *tv, const struct timezone *tz)
-{
- if (!tv) return 0;
- if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL);
- return clock_settime(CLOCK_REALTIME, &((struct timespec){
- .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000}));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/signalfd.c b/lib/libc/wasi/libc-top-half/musl/src/linux/signalfd.c
deleted file mode 100644
index 4bf43326fe..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/signalfd.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <sys/signalfd.h>
-#include <signal.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int signalfd(int fd, const sigset_t *sigs, int flags)
-{
- int ret = __syscall(SYS_signalfd4, fd, sigs, _NSIG/8, flags);
-#ifdef SYS_signalfd
- if (ret != -ENOSYS) return __syscall_ret(ret);
- ret = __syscall(SYS_signalfd, fd, sigs, _NSIG/8);
- if (ret >= 0) {
- if (flags & SFD_CLOEXEC)
- __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
- if (flags & SFD_NONBLOCK)
- __syscall(SYS_fcntl, ret, F_SETFL, O_NONBLOCK);
- }
-#endif
- return __syscall_ret(ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/splice.c b/lib/libc/wasi/libc-top-half/musl/src/linux/splice.c
deleted file mode 100644
index 78b6220d8e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/splice.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-ssize_t splice(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags)
-{
- return syscall(SYS_splice, fd_in, off_in, fd_out, off_out, len, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/stime.c b/lib/libc/wasi/libc-top-half/musl/src/linux/stime.c
deleted file mode 100644
index 7d0443ba3b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/stime.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <time.h>
-#include <sys/time.h>
-
-int stime(const time_t *t)
-{
- struct timeval tv = { .tv_sec = *t, .tv_usec = 0 };
- return settimeofday(&tv, (void *)0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/swap.c b/lib/libc/wasi/libc-top-half/musl/src/linux/swap.c
deleted file mode 100644
index 8137d51ebf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/swap.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/swap.h>
-#include "syscall.h"
-
-int swapon(const char *path, int flags)
-{
- return syscall(SYS_swapon, path, flags);
-}
-
-int swapoff(const char *path)
-{
- return syscall(SYS_swapoff, path);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/sync_file_range.c b/lib/libc/wasi/libc-top-half/musl/src/linux/sync_file_range.c
deleted file mode 100644
index 6859abc05d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/sync_file_range.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sync_file_range(int fd, off_t pos, off_t len, unsigned flags)
-{
-#if defined(SYS_sync_file_range2)
- return syscall(SYS_sync_file_range2, fd, flags,
- __SYSCALL_LL_E(pos), __SYSCALL_LL_E(len));
-#elif defined(SYS_sync_file_range)
- return syscall(SYS_sync_file_range, fd,
- __SYSCALL_LL_O(pos), __SYSCALL_LL_E(len), flags);
-#else
- return __syscall_ret(-ENOSYS);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/syncfs.c b/lib/libc/wasi/libc-top-half/musl/src/linux/syncfs.c
deleted file mode 100644
index bc7d301e51..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/syncfs.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int syncfs(int fd)
-{
- return syscall(SYS_syncfs, fd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/sysinfo.c b/lib/libc/wasi/libc-top-half/musl/src/linux/sysinfo.c
deleted file mode 100644
index db86476d0f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/sysinfo.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/sysinfo.h>
-#include "syscall.h"
-
-int __lsysinfo(struct sysinfo *info)
-{
- return syscall(SYS_sysinfo, info);
-}
-
-weak_alias(__lsysinfo, sysinfo);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/tee.c b/lib/libc/wasi/libc-top-half/musl/src/linux/tee.c
deleted file mode 100644
index a24748cfb0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/tee.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-ssize_t tee(int src, int dest, size_t len, unsigned flags)
-{
- return syscall(SYS_tee, src, dest, len, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/timerfd.c b/lib/libc/wasi/libc-top-half/musl/src/linux/timerfd.c
deleted file mode 100644
index 5bdfaf1656..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/timerfd.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <sys/timerfd.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-
-int timerfd_create(int clockid, int flags)
-{
- return syscall(SYS_timerfd_create, clockid, flags);
-}
-
-int timerfd_settime(int fd, int flags, const struct itimerspec *new, struct itimerspec *old)
-{
-#ifdef SYS_timerfd_settime64
- time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;
- long ins = new->it_interval.tv_nsec, vns = new->it_value.tv_nsec;
- int r = -ENOSYS;
- if (SYS_timerfd_settime == SYS_timerfd_settime64
- || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old))
- r = __syscall(SYS_timerfd_settime64, fd, flags,
- ((long long[]){is, ins, vs, vns}), old);
- if (SYS_timerfd_settime == SYS_timerfd_settime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if (!IS32BIT(is) || !IS32BIT(vs))
- return __syscall_ret(-ENOTSUP);
- long old32[4];
- r = __syscall(SYS_timerfd_settime, fd, flags,
- ((long[]){is, ins, vs, vns}), old32);
- if (!r && old) {
- old->it_interval.tv_sec = old32[0];
- old->it_interval.tv_nsec = old32[1];
- old->it_value.tv_sec = old32[2];
- old->it_value.tv_nsec = old32[3];
- }
- return __syscall_ret(r);
-#endif
- return syscall(SYS_timerfd_settime, fd, flags, new, old);
-}
-
-int timerfd_gettime(int fd, struct itimerspec *cur)
-{
-#ifdef SYS_timerfd_gettime64
- int r = -ENOSYS;
- if (sizeof(time_t) > 4)
- r = __syscall(SYS_timerfd_gettime64, fd, cur);
- if (SYS_timerfd_gettime == SYS_timerfd_gettime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- long cur32[4];
- r = __syscall(SYS_timerfd_gettime, fd, cur32);
- if (!r) {
- cur->it_interval.tv_sec = cur32[0];
- cur->it_interval.tv_nsec = cur32[1];
- cur->it_value.tv_sec = cur32[2];
- cur->it_value.tv_nsec = cur32[3];
- }
- return __syscall_ret(r);
-#endif
- return syscall(SYS_timerfd_gettime, fd, cur);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/unshare.c b/lib/libc/wasi/libc-top-half/musl/src/linux/unshare.c
deleted file mode 100644
index 3861db3b20..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/unshare.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <sched.h>
-#include "syscall.h"
-
-int unshare(int flags)
-{
- return syscall(SYS_unshare, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/utimes.c b/lib/libc/wasi/libc-top-half/musl/src/linux/utimes.c
deleted file mode 100644
index 6ca025d95a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/utimes.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/time.h>
-#include "fcntl.h"
-#include "syscall.h"
-
-int utimes(const char *path, const struct timeval times[2])
-{
- return __futimesat(AT_FDCWD, path, times);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/vhangup.c b/lib/libc/wasi/libc-top-half/musl/src/linux/vhangup.c
deleted file mode 100644
index 0203071506..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/vhangup.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int vhangup(void)
-{
- return syscall(SYS_vhangup);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/vmsplice.c b/lib/libc/wasi/libc-top-half/musl/src/linux/vmsplice.c
deleted file mode 100644
index ebf13ee44e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/vmsplice.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include "syscall.h"
-
-ssize_t vmsplice(int fd, const struct iovec *iov, size_t cnt, unsigned flags)
-{
- return syscall(SYS_vmsplice, fd, iov, cnt, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/wait3.c b/lib/libc/wasi/libc-top-half/musl/src/linux/wait3.c
deleted file mode 100644
index 61c735947b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/wait3.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include "syscall.h"
-
-pid_t wait3(int *status, int options, struct rusage *usage)
-{
- return wait4(-1, status, options, usage);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/wait4.c b/lib/libc/wasi/libc-top-half/musl/src/linux/wait4.c
deleted file mode 100644
index 83650e34a8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/wait4.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/wait.h>
-#include <sys/resource.h>
-#include <string.h>
-#include <errno.h>
-#include "syscall.h"
-
-pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru)
-{
- int r;
-#ifdef SYS_wait4_time64
- if (ru) {
- long long kru64[18];
- r = __syscall(SYS_wait4_time64, pid, status, options, kru64);
- if (!r) {
- ru->ru_utime = (struct timeval)
- { .tv_sec = kru64[0], .tv_usec = kru64[1] };
- ru->ru_stime = (struct timeval)
- { .tv_sec = kru64[2], .tv_usec = kru64[3] };
- char *slots = (char *)&ru->ru_maxrss;
- for (int i=0; i<14; i++)
- *(long *)(slots + i*sizeof(long)) = kru64[4+i];
- }
- if (SYS_wait4_time64 == SYS_wait4 || r != -ENOSYS)
- return __syscall_ret(r);
- }
-#endif
- char *dest = ru ? (char *)&ru->ru_maxrss - 4*sizeof(long) : 0;
- r = __syscall(SYS_wait4, pid, status, options, dest);
- if (r>0 && ru && sizeof(time_t) > sizeof(long)) {
- long kru[4];
- memcpy(kru, dest, 4*sizeof(long));
- ru->ru_utime = (struct timeval)
- { .tv_sec = kru[0], .tv_usec = kru[1] };
- ru->ru_stime = (struct timeval)
- { .tv_sec = kru[2], .tv_usec = kru[3] };
- }
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/x32/sysinfo.c b/lib/libc/wasi/libc-top-half/musl/src/linux/x32/sysinfo.c
deleted file mode 100644
index 59b3bb708f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/x32/sysinfo.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <sys/sysinfo.h>
-#include "syscall.h"
-
-#define klong long long
-#define kulong unsigned long long
-
-struct kernel_sysinfo {
- klong uptime;
- kulong loads[3];
- kulong totalram;
- kulong freeram;
- kulong sharedram;
- kulong bufferram;
- kulong totalswap;
- kulong freeswap;
- short procs;
- short pad;
- kulong totalhigh;
- kulong freehigh;
- unsigned mem_unit;
-};
-
-int __lsysinfo(struct sysinfo *info)
-{
- struct kernel_sysinfo tmp;
- int ret = syscall(SYS_sysinfo, &tmp);
- if(ret == -1) return ret;
- info->uptime = tmp.uptime;
- info->loads[0] = tmp.loads[0];
- info->loads[1] = tmp.loads[1];
- info->loads[2] = tmp.loads[2];
- kulong shifts;
- kulong max = tmp.totalram | tmp.totalswap;
- __asm__("bsr %1,%0" : "=r"(shifts) : "r"(max));
- shifts = shifts >= 32 ? shifts - 31 : 0;
- info->totalram = tmp.totalram >> shifts;
- info->freeram = tmp.freeram >> shifts;
- info->sharedram = tmp.sharedram >> shifts;
- info->bufferram = tmp.bufferram >> shifts;
- info->totalswap = tmp.totalswap >> shifts;
- info->freeswap = tmp.freeswap >> shifts;
- info->procs = tmp.procs ;
- info->totalhigh = tmp.totalhigh >> shifts;
- info->freehigh = tmp.freehigh >> shifts;
- info->mem_unit = (tmp.mem_unit ? tmp.mem_unit : 1) << shifts;
- return ret;
-}
-
-weak_alias(__lsysinfo, sysinfo);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/linux/xattr.c b/lib/libc/wasi/libc-top-half/musl/src/linux/xattr.c
deleted file mode 100644
index fea0d209ac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/linux/xattr.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <sys/xattr.h>
-#include "syscall.h"
-
-ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
-{
- return syscall(SYS_getxattr, path, name, value, size);
-}
-
-ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
-{
- return syscall(SYS_lgetxattr, path, name, value, size);
-}
-
-ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size)
-{
- return syscall(SYS_fgetxattr, filedes, name, value, size);
-}
-
-ssize_t listxattr(const char *path, char *list, size_t size)
-{
- return syscall(SYS_listxattr, path, list, size);
-}
-
-ssize_t llistxattr(const char *path, char *list, size_t size)
-{
- return syscall(SYS_llistxattr, path, list, size);
-}
-
-ssize_t flistxattr(int filedes, char *list, size_t size)
-{
- return syscall(SYS_flistxattr, filedes, list, size);
-}
-
-int setxattr(const char *path, const char *name, const void *value, size_t size, int flags)
-{
- return syscall(SYS_setxattr, path, name, value, size, flags);
-}
-
-int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
-{
- return syscall(SYS_lsetxattr, path, name, value, size, flags);
-}
-
-int fsetxattr(int filedes, const char *name, const void *value, size_t size, int flags)
-{
- return syscall(SYS_fsetxattr, filedes, name, value, size, flags);
-}
-
-int removexattr(const char *path, const char *name)
-{
- return syscall(SYS_removexattr, path, name);
-}
-
-int lremovexattr(const char *path, const char *name)
-{
- return syscall(SYS_lremovexattr, path, name);
-}
-
-int fremovexattr(int fd, const char *name)
-{
- return syscall(SYS_fremovexattr, fd, name);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/locale/bind_textdomain_codeset.c b/lib/libc/wasi/libc-top-half/musl/src/locale/bind_textdomain_codeset.c
deleted file mode 100644
index 5ebfd5e8a8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/locale/bind_textdomain_codeset.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <libintl.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-
-char *bind_textdomain_codeset(const char *domainname, const char *codeset)
-{
- if (codeset && strcasecmp(codeset, "UTF-8"))
- errno = EINVAL;
- return NULL;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/locale/dcngettext.c b/lib/libc/wasi/libc-top-half/musl/src/locale/dcngettext.c
deleted file mode 100644
index 0b53286db7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/locale/dcngettext.c
+++ /dev/null
@@ -1,283 +0,0 @@
-#include <libintl.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <ctype.h>
-#include "locale_impl.h"
-#include "atomic.h"
-#include "pleval.h"
-#include "lock.h"
-#include "fork_impl.h"
-
-#define malloc __libc_malloc
-#define calloc __libc_calloc
-#define realloc undef
-#define free undef
-
-struct binding {
- struct binding *next;
- int dirlen;
- volatile int active;
- char *domainname;
- char *dirname;
- char buf[];
-};
-
-static void *volatile bindings;
-
-static char *gettextdir(const char *domainname, size_t *dirlen)
-{
- struct binding *p;
- for (p=bindings; p; p=p->next) {
- if (!strcmp(p->domainname, domainname) && p->active) {
- *dirlen = p->dirlen;
- return (char *)p->dirname;
- }
- }
- return 0;
-}
-
-static volatile int lock[1];
-volatile int *const __gettext_lockptr = lock;
-
-char *bindtextdomain(const char *domainname, const char *dirname)
-{
- struct binding *p, *q;
-
- if (!domainname) return 0;
- if (!dirname) return gettextdir(domainname, &(size_t){0});
-
- size_t domlen = strnlen(domainname, NAME_MAX+1);
- size_t dirlen = strnlen(dirname, PATH_MAX);
- if (domlen > NAME_MAX || dirlen >= PATH_MAX) {
- errno = EINVAL;
- return 0;
- }
-
- LOCK(lock);
-
- for (p=bindings; p; p=p->next) {
- if (!strcmp(p->domainname, domainname) &&
- !strcmp(p->dirname, dirname)) {
- break;
- }
- }
-
- if (!p) {
- p = calloc(sizeof *p + domlen + dirlen + 2, 1);
- if (!p) {
- UNLOCK(lock);
- return 0;
- }
- p->next = bindings;
- p->dirlen = dirlen;
- p->domainname = p->buf;
- p->dirname = p->buf + domlen + 1;
- memcpy(p->domainname, domainname, domlen+1);
- memcpy(p->dirname, dirname, dirlen+1);
- a_cas_p(&bindings, bindings, p);
- }
-
- a_store(&p->active, 1);
-
- for (q=bindings; q; q=q->next) {
- if (!strcmp(q->domainname, domainname) && q != p)
- a_store(&q->active, 0);
- }
-
- UNLOCK(lock);
-
- return (char *)p->dirname;
-}
-
-static const char catnames[][12] = {
- "LC_CTYPE",
- "LC_NUMERIC",
- "LC_TIME",
- "LC_COLLATE",
- "LC_MONETARY",
- "LC_MESSAGES",
-};
-
-static const char catlens[] = { 8, 10, 7, 10, 11, 11 };
-
-struct msgcat {
- struct msgcat *next;
- const void *map;
- size_t map_size;
- const char *plural_rule;
- int nplurals;
- struct binding *binding;
- const struct __locale_map *lm;
- int cat;
-};
-
-static char *dummy_gettextdomain()
-{
- return "messages";
-}
-
-weak_alias(dummy_gettextdomain, __gettextdomain);
-
-char *dcngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n, int category)
-{
- static struct msgcat *volatile cats;
- struct msgcat *p;
- struct __locale_struct *loc = CURRENT_LOCALE;
- const struct __locale_map *lm;
- size_t domlen;
- struct binding *q;
- int old_errno = errno;
-
- /* match gnu gettext behaviour */
- if (!msgid1) goto notrans;
-
- if ((unsigned)category >= LC_ALL) goto notrans;
-
- if (!domainname) domainname = __gettextdomain();
-
- domlen = strnlen(domainname, NAME_MAX+1);
- if (domlen > NAME_MAX) goto notrans;
-
- for (q=bindings; q; q=q->next)
- if (!strcmp(q->domainname, domainname) && q->active)
- break;
- if (!q) goto notrans;
-
- lm = loc->cat[category];
- if (!lm) {
-notrans:
- errno = old_errno;
- return (char *) ((n == 1) ? msgid1 : msgid2);
- }
-
- for (p=cats; p; p=p->next)
- if (p->binding == q && p->lm == lm && p->cat == category)
- break;
-
- if (!p) {
- const char *dirname, *locname, *catname, *modname, *locp;
- size_t dirlen, loclen, catlen, modlen, alt_modlen;
- void *old_cats;
- size_t map_size;
-
- dirname = q->dirname;
- locname = lm->name;
- catname = catnames[category];
-
- dirlen = q->dirlen;
- loclen = strlen(locname);
- catlen = catlens[category];
-
- /* Logically split @mod suffix from locale name. */
- modname = memchr(locname, '@', loclen);
- if (!modname) modname = locname + loclen;
- alt_modlen = modlen = loclen - (modname-locname);
- loclen = modname-locname;
-
- /* Drop .charset identifier; it is not used. */
- const char *csp = memchr(locname, '.', loclen);
- if (csp) loclen = csp-locname;
-
- char name[dirlen+1 + loclen+modlen+1 + catlen+1 + domlen+3 + 1];
- const void *map;
-
- for (;;) {
- snprintf(name, sizeof name, "%s/%.*s%.*s/%s/%s.mo\0",
- dirname, (int)loclen, locname,
- (int)alt_modlen, modname, catname, domainname);
- if (map = __map_file(name, &map_size)) break;
-
- /* Try dropping @mod, _YY, then both. */
- if (alt_modlen) {
- alt_modlen = 0;
- } else if ((locp = memchr(locname, '_', loclen))) {
- loclen = locp-locname;
- alt_modlen = modlen;
- } else {
- break;
- }
- }
- if (!map) goto notrans;
-
- p = calloc(sizeof *p, 1);
- if (!p) {
- __munmap((void *)map, map_size);
- goto notrans;
- }
- p->cat = category;
- p->binding = q;
- p->lm = lm;
- p->map = map;
- p->map_size = map_size;
-
- const char *rule = "n!=1;";
- unsigned long np = 2;
- const char *r = __mo_lookup(p->map, p->map_size, "");
- char *z;
- while (r && strncmp(r, "Plural-Forms:", 13)) {
- z = strchr(r, '\n');
- r = z ? z+1 : 0;
- }
- if (r) {
- r += 13;
- while (isspace(*r)) r++;
- if (!strncmp(r, "nplurals=", 9)) {
- np = strtoul(r+9, &z, 10);
- r = z;
- }
- while (*r && *r != ';') r++;
- if (*r) {
- r++;
- while (isspace(*r)) r++;
- if (!strncmp(r, "plural=", 7))
- rule = r+7;
- }
- }
- p->nplurals = np;
- p->plural_rule = rule;
-
- do {
- old_cats = cats;
- p->next = old_cats;
- } while (a_cas_p(&cats, old_cats, p) != old_cats);
- }
-
- const char *trans = __mo_lookup(p->map, p->map_size, msgid1);
- if (!trans) goto notrans;
-
- /* Non-plural-processing gettext forms pass a null pointer as
- * msgid2 to request that dcngettext suppress plural processing. */
-
- if (msgid2 && p->nplurals) {
- unsigned long plural = __pleval(p->plural_rule, n);
- if (plural > p->nplurals) goto notrans;
- while (plural--) {
- size_t rem = p->map_size - (trans - (char *)p->map);
- size_t l = strnlen(trans, rem);
- if (l+1 >= rem)
- goto notrans;
- trans += l+1;
- }
- }
- errno = old_errno;
- return (char *)trans;
-}
-
-char *dcgettext(const char *domainname, const char *msgid, int category)
-{
- return dcngettext(domainname, msgid, 0, 1, category);
-}
-
-char *dngettext(const char *domainname, const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return dcngettext(domainname, msgid1, msgid2, n, LC_MESSAGES);
-}
-
-char *dgettext(const char *domainname, const char *msgid)
-{
- return dcngettext(domainname, msgid, 0, 1, LC_MESSAGES);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/locale/textdomain.c b/lib/libc/wasi/libc-top-half/musl/src/locale/textdomain.c
deleted file mode 100644
index d727539799..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/locale/textdomain.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <libintl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <limits.h>
-
-static char *current_domain;
-
-char *__gettextdomain()
-{
- return current_domain ? current_domain : "messages";
-}
-
-char *textdomain(const char *domainname)
-{
- if (!domainname) return __gettextdomain();
-
- size_t domlen = strlen(domainname);
- if (domlen > NAME_MAX) {
- errno = EINVAL;
- return 0;
- }
-
- if (!current_domain) {
- current_domain = malloc(NAME_MAX+1);
- if (!current_domain) return 0;
- }
-
- memcpy(current_domain, domainname, domlen+1);
-
- return current_domain;
-}
-
-char *gettext(const char *msgid)
-{
- return dgettext(0, msgid);
-}
-
-char *ngettext(const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return dngettext(0, msgid1, msgid2, n);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/calloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/calloc.c
deleted file mode 100644
index bf6bddca3f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/calloc.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include "dynlink.h"
-
-static size_t mal0_clear(char *p, size_t n)
-{
- const size_t pagesz = 4096; /* arbitrary */
- if (n < pagesz) return n;
-#ifdef __GNUC__
- typedef uint64_t __attribute__((__may_alias__)) T;
-#else
- typedef unsigned char T;
-#endif
- char *pp = p + n;
- size_t i = (uintptr_t)pp & (pagesz - 1);
- for (;;) {
- pp = memset(pp - i, 0, i);
- if (pp - p < pagesz) return pp - p;
- for (i = pagesz; i; i -= 2*sizeof(T), pp -= 2*sizeof(T))
- if (((T *)pp)[-1] | ((T *)pp)[-2])
- break;
- }
-}
-
-static int allzerop(void *p)
-{
- return 0;
-}
-weak_alias(allzerop, __malloc_allzerop);
-
-void *calloc(size_t m, size_t n)
-{
- if (n && m > (size_t)-1/n) {
- errno = ENOMEM;
- return 0;
- }
- n *= m;
- void *p = malloc(n);
- if (!p || (!__malloc_replaced && __malloc_allzerop(p)))
- return p;
- n = mal0_clear(p, n);
- return memset(p, 0, n);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/free.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/free.c
deleted file mode 100644
index 3944f7b28f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/free.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdlib.h>
-
-void free(void *p)
-{
- __libc_free(p);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/libc_calloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/libc_calloc.c
deleted file mode 100644
index d25eabea47..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/libc_calloc.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#define calloc __libc_calloc
-#define malloc __libc_malloc
-
-#include "calloc.c"
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/lite_malloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/lite_malloc.c
deleted file mode 100644
index 43a988fbb8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/lite_malloc.c
+++ /dev/null
@@ -1,118 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <limits.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include "libc.h"
-#include "lock.h"
-#include "syscall.h"
-#include "fork_impl.h"
-
-#define ALIGN 16
-
-/* This function returns true if the interval [old,new]
- * intersects the 'len'-sized interval below &libc.auxv
- * (interpreted as the main-thread stack) or below &b
- * (the current stack). It is used to defend against
- * buggy brk implementations that can cross the stack. */
-
-static int traverses_stack_p(uintptr_t old, uintptr_t new)
-{
- const uintptr_t len = 8<<20;
- uintptr_t a, b;
-
- b = (uintptr_t)libc.auxv;
- a = b > len ? b-len : 0;
- if (new>a && old<b) return 1;
-
- b = (uintptr_t)&b;
- a = b > len ? b-len : 0;
- if (new>a && old<b) return 1;
-
- return 0;
-}
-
-static volatile int lock[1];
-volatile int *const __bump_lockptr = lock;
-
-static void *__simple_malloc(size_t n)
-{
- static uintptr_t brk, cur, end;
- static unsigned mmap_step;
- size_t align=1;
- void *p;
-
- if (n > SIZE_MAX/2) {
- errno = ENOMEM;
- return 0;
- }
-
- if (!n) n++;
- while (align<n && align<ALIGN)
- align += align;
-
- LOCK(lock);
-
- cur += -cur & align-1;
-
- if (n > end-cur) {
- size_t req = n - (end-cur) + PAGE_SIZE-1 & -PAGE_SIZE;
-
- if (!cur) {
- brk = __syscall(SYS_brk, 0);
- brk += -brk & PAGE_SIZE-1;
- cur = end = brk;
- }
-
- if (brk == end && req < SIZE_MAX-brk
- && !traverses_stack_p(brk, brk+req)
- && __syscall(SYS_brk, brk+req)==brk+req) {
- brk = end += req;
- } else {
- int new_area = 0;
- req = n + PAGE_SIZE-1 & -PAGE_SIZE;
- /* Only make a new area rather than individual mmap
- * if wasted space would be over 1/8 of the map. */
- if (req-n > req/8) {
- /* Geometric area size growth up to 64 pages,
- * bounding waste by 1/8 of the area. */
- size_t min = PAGE_SIZE<<(mmap_step/2);
- if (min-n > end-cur) {
- if (req < min) {
- req = min;
- if (mmap_step < 12)
- mmap_step++;
- }
- new_area = 1;
- }
- }
- void *mem = __mmap(0, req, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (mem == MAP_FAILED || !new_area) {
- UNLOCK(lock);
- return mem==MAP_FAILED ? 0 : mem;
- }
- cur = (uintptr_t)mem;
- end = cur + req;
- }
- }
-
- p = (void *)cur;
- cur += n;
- UNLOCK(lock);
- return p;
-}
-
-weak_alias(__simple_malloc, __libc_malloc_impl);
-
-void *__libc_malloc(size_t n)
-{
- return __libc_malloc_impl(n);
-}
-
-static void *default_malloc(size_t n)
-{
- return __libc_malloc_impl(n);
-}
-
-weak_alias(default_malloc, malloc);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c
deleted file mode 100644
index e0862a83ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/aligned_alloc.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stdlib.h>
-#include <errno.h>
-#include "meta.h"
-
-void *aligned_alloc(size_t align, size_t len)
-{
- if ((align & -align) != align) {
- errno = EINVAL;
- return 0;
- }
-
- if (len > SIZE_MAX - align || align >= (1ULL<<31)*UNIT) {
- errno = ENOMEM;
- return 0;
- }
-
- if (DISABLE_ALIGNED_ALLOC) {
- errno = ENOMEM;
- return 0;
- }
-
- if (align <= UNIT) align = UNIT;
-
- unsigned char *p = malloc(len + align - UNIT);
- if (!p)
- return 0;
-
- struct meta *g = get_meta(p);
- int idx = get_slot_index(p);
- size_t stride = get_stride(g);
- unsigned char *start = g->mem->storage + stride*idx;
- unsigned char *end = g->mem->storage + stride*(idx+1) - IB;
- size_t adj = -(uintptr_t)p & (align-1);
-
- if (!adj) {
- set_size(p, end, len);
- return p;
- }
- p += adj;
- uint32_t offset = (size_t)(p-g->mem->storage)/UNIT;
- if (offset <= 0xffff) {
- *(uint16_t *)(p-2) = offset;
- p[-4] = 0;
- } else {
- // use a 32-bit offset if 16-bit doesn't fit. for this,
- // 16-bit field must be zero, [-4] byte nonzero.
- *(uint16_t *)(p-2) = 0;
- *(uint32_t *)(p-8) = offset;
- p[-4] = 1;
- }
- p[-3] = idx;
- set_size(p, end, len);
- // store offset to aligned enframing. this facilitates cycling
- // offset and also iteration of heap for debugging/measurement.
- // for extreme overalignment it won't fit but these are classless
- // allocations anyway.
- *(uint16_t *)(start - 2) = (size_t)(p-start)/UNIT;
- start[-3] = 7<<5;
- return p;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/donate.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/donate.c
deleted file mode 100644
index 41d850f357..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/donate.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <limits.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <errno.h>
-
-#include "meta.h"
-
-static void donate(unsigned char *base, size_t len)
-{
- uintptr_t a = (uintptr_t)base;
- uintptr_t b = a + len;
- a += -a & (UNIT-1);
- b -= b & (UNIT-1);
- memset(base, 0, len);
- for (int sc=47; sc>0 && b>a; sc-=4) {
- if (b-a < (size_classes[sc]+1)*UNIT) continue;
- struct meta *m = alloc_meta();
- m->avail_mask = 0;
- m->freed_mask = 1;
- m->mem = (void *)a;
- m->mem->meta = m;
- m->last_idx = 0;
- m->freeable = 0;
- m->sizeclass = sc;
- m->maplen = 0;
- *((unsigned char *)m->mem+UNIT-4) = 0;
- *((unsigned char *)m->mem+UNIT-3) = 255;
- m->mem->storage[size_classes[sc]*UNIT-4] = 0;
- queue(&ctx.active[sc], m);
- a += (size_classes[sc]+1)*UNIT;
- }
-}
-
-void __malloc_donate(char *start, char *end)
-{
- donate((void *)start, end-start);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/free.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/free.c
deleted file mode 100644
index 418a085c18..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/free.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-#include <sys/mman.h>
-
-#include "meta.h"
-
-struct mapinfo {
- void *base;
- size_t len;
-};
-
-static struct mapinfo nontrivial_free(struct meta *, int);
-
-static struct mapinfo free_group(struct meta *g)
-{
- struct mapinfo mi = { 0 };
- int sc = g->sizeclass;
- if (sc < 48) {
- ctx.usage_by_class[sc] -= g->last_idx+1;
- }
- if (g->maplen) {
- step_seq();
- record_seq(sc);
- mi.base = g->mem;
- mi.len = g->maplen*4096UL;
- } else {
- void *p = g->mem;
- struct meta *m = get_meta(p);
- int idx = get_slot_index(p);
- g->mem->meta = 0;
- // not checking size/reserved here; it's intentionally invalid
- mi = nontrivial_free(m, idx);
- }
- free_meta(g);
- return mi;
-}
-
-static int okay_to_free(struct meta *g)
-{
- int sc = g->sizeclass;
-
- if (!g->freeable) return 0;
-
- // always free individual mmaps not suitable for reuse
- if (sc >= 48 || get_stride(g) < UNIT*size_classes[sc])
- return 1;
-
- // always free groups allocated inside another group's slot
- // since recreating them should not be expensive and they
- // might be blocking freeing of a much larger group.
- if (!g->maplen) return 1;
-
- // if there is another non-full group, free this one to
- // consolidate future allocations, reduce fragmentation.
- if (g->next != g) return 1;
-
- // free any group in a size class that's not bouncing
- if (!is_bouncing(sc)) return 1;
-
- size_t cnt = g->last_idx+1;
- size_t usage = ctx.usage_by_class[sc];
-
- // if usage is high enough that a larger count should be
- // used, free the low-count group so a new one will be made.
- if (9*cnt <= usage && cnt < 20)
- return 1;
-
- // otherwise, keep the last group in a bouncing class.
- return 0;
-}
-
-static struct mapinfo nontrivial_free(struct meta *g, int i)
-{
- uint32_t self = 1u<<i;
- int sc = g->sizeclass;
- uint32_t mask = g->freed_mask | g->avail_mask;
-
- if (mask+self == (2u<<g->last_idx)-1 && okay_to_free(g)) {
- // any multi-slot group is necessarily on an active list
- // here, but single-slot groups might or might not be.
- if (g->next) {
- assert(sc < 48);
- int activate_new = (ctx.active[sc]==g);
- dequeue(&ctx.active[sc], g);
- if (activate_new && ctx.active[sc])
- activate_group(ctx.active[sc]);
- }
- return free_group(g);
- } else if (!mask) {
- assert(sc < 48);
- // might still be active if there were no allocations
- // after last available slot was taken.
- if (ctx.active[sc] != g) {
- queue(&ctx.active[sc], g);
- }
- }
- a_or(&g->freed_mask, self);
- return (struct mapinfo){ 0 };
-}
-
-void free(void *p)
-{
- if (!p) return;
-
- struct meta *g = get_meta(p);
- int idx = get_slot_index(p);
- size_t stride = get_stride(g);
- unsigned char *start = g->mem->storage + stride*idx;
- unsigned char *end = start + stride - IB;
- get_nominal_size(p, end);
- uint32_t self = 1u<<idx, all = (2u<<g->last_idx)-1;
- ((unsigned char *)p)[-3] = 255;
- // invalidate offset to group header, and cycle offset of
- // used region within slot if current offset is zero.
- *(uint16_t *)((char *)p-2) = 0;
-
- // release any whole pages contained in the slot to be freed
- // unless it's a single-slot group that will be unmapped.
- if (((uintptr_t)(start-1) ^ (uintptr_t)end) >= 2*PGSZ && g->last_idx) {
- unsigned char *base = start + (-(uintptr_t)start & (PGSZ-1));
- size_t len = (end-base) & -PGSZ;
- if (len) {
- int e = errno;
- madvise(base, len, MADV_FREE);
- errno = e;
- }
- }
-
- // atomic free without locking if this is neither first or last slot
- for (;;) {
- uint32_t freed = g->freed_mask;
- uint32_t avail = g->avail_mask;
- uint32_t mask = freed | avail;
- assert(!(mask&self));
- if (!freed || mask+self==all) break;
- if (!MT)
- g->freed_mask = freed+self;
- else if (a_cas(&g->freed_mask, freed, freed+self)!=freed)
- continue;
- return;
- }
-
- wrlock();
- struct mapinfo mi = nontrivial_free(g, idx);
- unlock();
- if (mi.len) {
- int e = errno;
- munmap(mi.base, mi.len);
- errno = e;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc.c
deleted file mode 100644
index d695ab8ec9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc.c
+++ /dev/null
@@ -1,387 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <limits.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <errno.h>
-
-#include "meta.h"
-
-LOCK_OBJ_DEF;
-
-const uint16_t size_classes[] = {
- 1, 2, 3, 4, 5, 6, 7, 8,
- 9, 10, 12, 15,
- 18, 20, 25, 31,
- 36, 42, 50, 63,
- 72, 84, 102, 127,
- 146, 170, 204, 255,
- 292, 340, 409, 511,
- 584, 682, 818, 1023,
- 1169, 1364, 1637, 2047,
- 2340, 2730, 3276, 4095,
- 4680, 5460, 6552, 8191,
-};
-
-static const uint8_t small_cnt_tab[][3] = {
- { 30, 30, 30 },
- { 31, 15, 15 },
- { 20, 10, 10 },
- { 31, 15, 7 },
- { 25, 12, 6 },
- { 21, 10, 5 },
- { 18, 8, 4 },
- { 31, 15, 7 },
- { 28, 14, 6 },
-};
-
-static const uint8_t med_cnt_tab[4] = { 28, 24, 20, 32 };
-
-struct malloc_context ctx = { 0 };
-
-struct meta *alloc_meta(void)
-{
- struct meta *m;
- unsigned char *p;
- if (!ctx.init_done) {
-#ifndef PAGESIZE
- ctx.pagesize = get_page_size();
-#endif
- ctx.secret = get_random_secret();
- ctx.init_done = 1;
- }
- size_t pagesize = PGSZ;
- if (pagesize < 4096) pagesize = 4096;
- if ((m = dequeue_head(&ctx.free_meta_head))) return m;
- if (!ctx.avail_meta_count) {
- int need_unprotect = 1;
- if (!ctx.avail_meta_area_count && ctx.brk!=-1) {
- uintptr_t new = ctx.brk + pagesize;
- int need_guard = 0;
- if (!ctx.brk) {
- need_guard = 1;
- ctx.brk = brk(0);
- // some ancient kernels returned _ebss
- // instead of next page as initial brk.
- ctx.brk += -ctx.brk & (pagesize-1);
- new = ctx.brk + 2*pagesize;
- }
- if (brk(new) != new) {
- ctx.brk = -1;
- } else {
- if (need_guard) mmap((void *)ctx.brk, pagesize,
- PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
- ctx.brk = new;
- ctx.avail_meta_areas = (void *)(new - pagesize);
- ctx.avail_meta_area_count = pagesize>>12;
- need_unprotect = 0;
- }
- }
- if (!ctx.avail_meta_area_count) {
- size_t n = 2UL << ctx.meta_alloc_shift;
- p = mmap(0, n*pagesize, PROT_NONE,
- MAP_PRIVATE|MAP_ANON, -1, 0);
- if (p==MAP_FAILED) return 0;
- ctx.avail_meta_areas = p + pagesize;
- ctx.avail_meta_area_count = (n-1)*(pagesize>>12);
- ctx.meta_alloc_shift++;
- }
- p = ctx.avail_meta_areas;
- if ((uintptr_t)p & (pagesize-1)) need_unprotect = 0;
- if (need_unprotect)
- if (mprotect(p, pagesize, PROT_READ|PROT_WRITE)
- && errno != ENOSYS)
- return 0;
- ctx.avail_meta_area_count--;
- ctx.avail_meta_areas = p + 4096;
- if (ctx.meta_area_tail) {
- ctx.meta_area_tail->next = (void *)p;
- } else {
- ctx.meta_area_head = (void *)p;
- }
- ctx.meta_area_tail = (void *)p;
- ctx.meta_area_tail->check = ctx.secret;
- ctx.avail_meta_count = ctx.meta_area_tail->nslots
- = (4096-sizeof(struct meta_area))/sizeof *m;
- ctx.avail_meta = ctx.meta_area_tail->slots;
- }
- ctx.avail_meta_count--;
- m = ctx.avail_meta++;
- m->prev = m->next = 0;
- return m;
-}
-
-static uint32_t try_avail(struct meta **pm)
-{
- struct meta *m = *pm;
- uint32_t first;
- if (!m) return 0;
- uint32_t mask = m->avail_mask;
- if (!mask) {
- if (!m) return 0;
- if (!m->freed_mask) {
- dequeue(pm, m);
- m = *pm;
- if (!m) return 0;
- } else {
- m = m->next;
- *pm = m;
- }
-
- mask = m->freed_mask;
-
- // skip fully-free group unless it's the only one
- // or it's a permanently non-freeable group
- if (mask == (2u<<m->last_idx)-1 && m->freeable) {
- m = m->next;
- *pm = m;
- mask = m->freed_mask;
- }
-
- // activate more slots in a not-fully-active group
- // if needed, but only as a last resort. prefer using
- // any other group with free slots. this avoids
- // touching & dirtying as-yet-unused pages.
- if (!(mask & ((2u<<m->mem->active_idx)-1))) {
- if (m->next != m) {
- m = m->next;
- *pm = m;
- } else {
- int cnt = m->mem->active_idx + 2;
- int size = size_classes[m->sizeclass]*UNIT;
- int span = UNIT + size*cnt;
- // activate up to next 4k boundary
- while ((span^(span+size-1)) < 4096) {
- cnt++;
- span += size;
- }
- if (cnt > m->last_idx+1)
- cnt = m->last_idx+1;
- m->mem->active_idx = cnt-1;
- }
- }
- mask = activate_group(m);
- assert(mask);
- decay_bounces(m->sizeclass);
- }
- first = mask&-mask;
- m->avail_mask = mask-first;
- return first;
-}
-
-static int alloc_slot(int, size_t);
-
-static struct meta *alloc_group(int sc, size_t req)
-{
- size_t size = UNIT*size_classes[sc];
- int i = 0, cnt;
- unsigned char *p;
- struct meta *m = alloc_meta();
- if (!m) return 0;
- size_t usage = ctx.usage_by_class[sc];
- size_t pagesize = PGSZ;
- int active_idx;
- if (sc < 9) {
- while (i<2 && 4*small_cnt_tab[sc][i] > usage)
- i++;
- cnt = small_cnt_tab[sc][i];
- } else {
- // lookup max number of slots fitting in power-of-two size
- // from a table, along with number of factors of two we
- // can divide out without a remainder or reaching 1.
- cnt = med_cnt_tab[sc&3];
-
- // reduce cnt to avoid excessive eagar allocation.
- while (!(cnt&1) && 4*cnt > usage)
- cnt >>= 1;
-
- // data structures don't support groups whose slot offsets
- // in units don't fit in 16 bits.
- while (size*cnt >= 65536*UNIT)
- cnt >>= 1;
- }
-
- // If we selected a count of 1 above but it's not sufficient to use
- // mmap, increase to 2. Then it might be; if not it will nest.
- if (cnt==1 && size*cnt+UNIT <= pagesize/2) cnt = 2;
-
- // All choices of size*cnt are "just below" a power of two, so anything
- // larger than half the page size should be allocated as whole pages.
- if (size*cnt+UNIT > pagesize/2) {
- // check/update bounce counter to start/increase retention
- // of freed maps, and inhibit use of low-count, odd-size
- // small mappings and single-slot groups if activated.
- int nosmall = is_bouncing(sc);
- account_bounce(sc);
- step_seq();
-
- // since the following count reduction opportunities have
- // an absolute memory usage cost, don't overdo them. count
- // coarse usage as part of usage.
- if (!(sc&1) && sc<32) usage += ctx.usage_by_class[sc+1];
-
- // try to drop to a lower count if the one found above
- // increases usage by more than 25%. these reduced counts
- // roughly fill an integral number of pages, just not a
- // power of two, limiting amount of unusable space.
- if (4*cnt > usage && !nosmall) {
- if (0);
- else if ((sc&3)==1 && size*cnt>8*pagesize) cnt = 2;
- else if ((sc&3)==2 && size*cnt>4*pagesize) cnt = 3;
- else if ((sc&3)==0 && size*cnt>8*pagesize) cnt = 3;
- else if ((sc&3)==0 && size*cnt>2*pagesize) cnt = 5;
- }
- size_t needed = size*cnt + UNIT;
- needed += -needed & (pagesize-1);
-
- // produce an individually-mmapped allocation if usage is low,
- // bounce counter hasn't triggered, and either it saves memory
- // or it avoids eagar slot allocation without wasting too much.
- if (!nosmall && cnt<=7) {
- req += IB + UNIT;
- req += -req & (pagesize-1);
- if (req<size+UNIT || (req>=4*pagesize && 2*cnt>usage)) {
- cnt = 1;
- needed = req;
- }
- }
-
- p = mmap(0, needed, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
- if (p==MAP_FAILED) {
- free_meta(m);
- return 0;
- }
- m->maplen = needed>>12;
- ctx.mmap_counter++;
- active_idx = (4096-UNIT)/size-1;
- if (active_idx > cnt-1) active_idx = cnt-1;
- if (active_idx < 0) active_idx = 0;
- } else {
- int j = size_to_class(UNIT+cnt*size-IB);
- int idx = alloc_slot(j, UNIT+cnt*size-IB);
- if (idx < 0) {
- free_meta(m);
- return 0;
- }
- struct meta *g = ctx.active[j];
- p = enframe(g, idx, UNIT*size_classes[j]-IB, ctx.mmap_counter);
- m->maplen = 0;
- p[-3] = (p[-3]&31) | (6<<5);
- for (int i=0; i<=cnt; i++)
- p[UNIT+i*size-4] = 0;
- active_idx = cnt-1;
- }
- ctx.usage_by_class[sc] += cnt;
- m->avail_mask = (2u<<active_idx)-1;
- m->freed_mask = (2u<<(cnt-1))-1 - m->avail_mask;
- m->mem = (void *)p;
- m->mem->meta = m;
- m->mem->active_idx = active_idx;
- m->last_idx = cnt-1;
- m->freeable = 1;
- m->sizeclass = sc;
- return m;
-}
-
-static int alloc_slot(int sc, size_t req)
-{
- uint32_t first = try_avail(&ctx.active[sc]);
- if (first) return a_ctz_32(first);
-
- struct meta *g = alloc_group(sc, req);
- if (!g) return -1;
-
- g->avail_mask--;
- queue(&ctx.active[sc], g);
- return 0;
-}
-
-void *malloc(size_t n)
-{
- if (size_overflows(n)) return 0;
- struct meta *g;
- uint32_t mask, first;
- int sc;
- int idx;
- int ctr;
-
- if (n >= MMAP_THRESHOLD) {
- size_t needed = n + IB + UNIT;
- void *p = mmap(0, needed, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANON, -1, 0);
- if (p==MAP_FAILED) return 0;
- wrlock();
- step_seq();
- g = alloc_meta();
- if (!g) {
- unlock();
- munmap(p, needed);
- return 0;
- }
- g->mem = p;
- g->mem->meta = g;
- g->last_idx = 0;
- g->freeable = 1;
- g->sizeclass = 63;
- g->maplen = (needed+4095)/4096;
- g->avail_mask = g->freed_mask = 0;
- // use a global counter to cycle offset in
- // individually-mmapped allocations.
- ctx.mmap_counter++;
- idx = 0;
- goto success;
- }
-
- sc = size_to_class(n);
-
- rdlock();
- g = ctx.active[sc];
-
- // use coarse size classes initially when there are not yet
- // any groups of desired size. this allows counts of 2 or 3
- // to be allocated at first rather than having to start with
- // 7 or 5, the min counts for even size classes.
- if (!g && sc>=4 && sc<32 && sc!=6 && !(sc&1) && !ctx.usage_by_class[sc]) {
- size_t usage = ctx.usage_by_class[sc|1];
- // if a new group may be allocated, count it toward
- // usage in deciding if we can use coarse class.
- if (!ctx.active[sc|1] || (!ctx.active[sc|1]->avail_mask
- && !ctx.active[sc|1]->freed_mask))
- usage += 3;
- if (usage <= 12)
- sc |= 1;
- g = ctx.active[sc];
- }
-
- for (;;) {
- mask = g ? g->avail_mask : 0;
- first = mask&-mask;
- if (!first) break;
- if (RDLOCK_IS_EXCLUSIVE || !MT)
- g->avail_mask = mask-first;
- else if (a_cas(&g->avail_mask, mask, mask-first)!=mask)
- continue;
- idx = a_ctz_32(first);
- goto success;
- }
- upgradelock();
-
- idx = alloc_slot(sc, n);
- if (idx < 0) {
- unlock();
- return 0;
- }
- g = ctx.active[sc];
-
-success:
- ctr = ctx.mmap_counter;
- unlock();
- return enframe(g, idx, n, ctr);
-}
-
-int is_allzero(void *p)
-{
- struct meta *g = get_meta(p);
- return g->sizeclass >= 48 ||
- get_stride(g) < UNIT*size_classes[g->sizeclass];
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc_usable_size.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc_usable_size.c
deleted file mode 100644
index ce6a960c6f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/malloc_usable_size.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <stdlib.h>
-#include "meta.h"
-
-size_t malloc_usable_size(void *p)
-{
- if (!p) return 0;
- struct meta *g = get_meta(p);
- int idx = get_slot_index(p);
- size_t stride = get_stride(g);
- unsigned char *start = g->mem->storage + stride*idx;
- unsigned char *end = start + stride - IB;
- return get_nominal_size(p, end);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/realloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/realloc.c
deleted file mode 100644
index 18769f42d8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/mallocng/realloc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <string.h>
-#include "meta.h"
-
-void *realloc(void *p, size_t n)
-{
- if (!p) return malloc(n);
- if (size_overflows(n)) return 0;
-
- struct meta *g = get_meta(p);
- int idx = get_slot_index(p);
- size_t stride = get_stride(g);
- unsigned char *start = g->mem->storage + stride*idx;
- unsigned char *end = start + stride - IB;
- size_t old_size = get_nominal_size(p, end);
- size_t avail_size = end-(unsigned char *)p;
- void *new;
-
- // only resize in-place if size class matches
- if (n <= avail_size && n<MMAP_THRESHOLD
- && size_to_class(n)+1 >= g->sizeclass) {
- set_size(p, end, n);
- return p;
- }
-
- // use mremap if old and new size are both mmap-worthy
- if (g->sizeclass>=48 && n>=MMAP_THRESHOLD) {
- assert(g->sizeclass==63);
- size_t base = (unsigned char *)p-start;
- size_t needed = (n + base + UNIT + IB + 4095) & -4096;
- new = g->maplen*4096UL == needed ? g->mem :
- mremap(g->mem, g->maplen*4096UL, needed, MREMAP_MAYMOVE);
- if (new!=MAP_FAILED) {
- g->mem = new;
- g->maplen = needed/4096;
- p = g->mem->storage + base;
- end = g->mem->storage + (needed - UNIT) - IB;
- *end = 0;
- set_size(p, end, n);
- return p;
- }
- }
-
- new = malloc(n);
- if (!new) return 0;
- memcpy(new, p, n < old_size ? n : old_size);
- free(p);
- return new;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/memalign.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/memalign.c
deleted file mode 100644
index 32cd87d812..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/memalign.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-
-void *memalign(size_t align, size_t len)
-{
- return aligned_alloc(align, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/aligned_alloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/aligned_alloc.c
deleted file mode 100644
index 4adca3b4f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/aligned_alloc.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <stdlib.h>
-#include <stdint.h>
-#include <errno.h>
-#include "malloc_impl.h"
-
-void *aligned_alloc(size_t align, size_t len)
-{
- unsigned char *mem, *new;
-
- if ((align & -align) != align) {
- errno = EINVAL;
- return 0;
- }
-
- if (len > SIZE_MAX - align ||
- (__malloc_replaced && !__aligned_alloc_replaced)) {
- errno = ENOMEM;
- return 0;
- }
-
- if (align <= SIZE_ALIGN)
- return malloc(len);
-
- if (!(mem = malloc(len + align-1)))
- return 0;
-
- new = (void *)((uintptr_t)mem + align-1 & -align);
- if (new == mem) return mem;
-
- struct chunk *c = MEM_TO_CHUNK(mem);
- struct chunk *n = MEM_TO_CHUNK(new);
-
- if (IS_MMAPPED(c)) {
- /* Apply difference between aligned and original
- * address to the "extra" field of mmapped chunk. */
- n->psize = c->psize + (new-mem);
- n->csize = c->csize - (new-mem);
- return new;
- }
-
- struct chunk *t = NEXT_CHUNK(c);
-
- /* Split the allocated chunk into two chunks. The aligned part
- * that will be used has the size in its footer reduced by the
- * difference between the aligned and original addresses, and
- * the resulting size copied to its header. A new header and
- * footer are written for the split-off part to be freed. */
- n->psize = c->csize = C_INUSE | (new-mem);
- n->csize = t->psize -= new-mem;
-
- __bin_chunk(c);
- return new;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc.c
deleted file mode 100644
index 25d00d44de..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc.c
+++ /dev/null
@@ -1,556 +0,0 @@
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <stdint.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include "libc.h"
-#include "atomic.h"
-#include "pthread_impl.h"
-#include "malloc_impl.h"
-#include "fork_impl.h"
-
-#define malloc __libc_malloc_impl
-#define realloc __libc_realloc
-#define free __libc_free
-
-#if defined(__GNUC__) && defined(__PIC__)
-#define inline inline __attribute__((always_inline))
-#endif
-
-static struct {
- volatile uint64_t binmap;
- struct bin bins[64];
- volatile int split_merge_lock[2];
-} mal;
-
-/* Synchronization tools */
-
-static inline void lock(volatile int *lk)
-{
- int need_locks = libc.need_locks;
- if (need_locks) {
- while(a_swap(lk, 1)) __wait(lk, lk+1, 1, 1);
- if (need_locks < 0) libc.need_locks = 0;
- }
-}
-
-static inline void unlock(volatile int *lk)
-{
- if (lk[0]) {
- a_store(lk, 0);
- if (lk[1]) __wake(lk, 1, 1);
- }
-}
-
-static inline void lock_bin(int i)
-{
- lock(mal.bins[i].lock);
- if (!mal.bins[i].head)
- mal.bins[i].head = mal.bins[i].tail = BIN_TO_CHUNK(i);
-}
-
-static inline void unlock_bin(int i)
-{
- unlock(mal.bins[i].lock);
-}
-
-static int first_set(uint64_t x)
-{
-#if 1
- return a_ctz_64(x);
-#else
- static const char debruijn64[64] = {
- 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
- 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
- 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
- 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
- };
- static const char debruijn32[32] = {
- 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13,
- 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14
- };
- if (sizeof(long) < 8) {
- uint32_t y = x;
- if (!y) {
- y = x>>32;
- return 32 + debruijn32[(y&-y)*0x076be629 >> 27];
- }
- return debruijn32[(y&-y)*0x076be629 >> 27];
- }
- return debruijn64[(x&-x)*0x022fdd63cc95386dull >> 58];
-#endif
-}
-
-static const unsigned char bin_tab[60] = {
- 32,33,34,35,36,36,37,37,38,38,39,39,
- 40,40,40,40,41,41,41,41,42,42,42,42,43,43,43,43,
- 44,44,44,44,44,44,44,44,45,45,45,45,45,45,45,45,
- 46,46,46,46,46,46,46,46,47,47,47,47,47,47,47,47,
-};
-
-static int bin_index(size_t x)
-{
- x = x / SIZE_ALIGN - 1;
- if (x <= 32) return x;
- if (x < 512) return bin_tab[x/8-4];
- if (x > 0x1c00) return 63;
- return bin_tab[x/128-4] + 16;
-}
-
-static int bin_index_up(size_t x)
-{
- x = x / SIZE_ALIGN - 1;
- if (x <= 32) return x;
- x--;
- if (x < 512) return bin_tab[x/8-4] + 1;
- return bin_tab[x/128-4] + 17;
-}
-
-#if 0
-void __dump_heap(int x)
-{
- struct chunk *c;
- int i;
- for (c = (void *)mal.heap; CHUNK_SIZE(c); c = NEXT_CHUNK(c))
- fprintf(stderr, "base %p size %zu (%d) flags %d/%d\n",
- c, CHUNK_SIZE(c), bin_index(CHUNK_SIZE(c)),
- c->csize & 15,
- NEXT_CHUNK(c)->psize & 15);
- for (i=0; i<64; i++) {
- if (mal.bins[i].head != BIN_TO_CHUNK(i) && mal.bins[i].head) {
- fprintf(stderr, "bin %d: %p\n", i, mal.bins[i].head);
- if (!(mal.binmap & 1ULL<<i))
- fprintf(stderr, "missing from binmap!\n");
- } else if (mal.binmap & 1ULL<<i)
- fprintf(stderr, "binmap wrongly contains %d!\n", i);
- }
-}
-#endif
-
-/* This function returns true if the interval [old,new]
- * intersects the 'len'-sized interval below &libc.auxv
- * (interpreted as the main-thread stack) or below &b
- * (the current stack). It is used to defend against
- * buggy brk implementations that can cross the stack. */
-
-static int traverses_stack_p(uintptr_t old, uintptr_t new)
-{
- const uintptr_t len = 8<<20;
- uintptr_t a, b;
-
- b = (uintptr_t)libc.auxv;
- a = b > len ? b-len : 0;
- if (new>a && old<b) return 1;
-
- b = (uintptr_t)&b;
- a = b > len ? b-len : 0;
- if (new>a && old<b) return 1;
-
- return 0;
-}
-
-/* Expand the heap in-place if brk can be used, or otherwise via mmap,
- * using an exponential lower bound on growth by mmap to make
- * fragmentation asymptotically irrelevant. The size argument is both
- * an input and an output, since the caller needs to know the size
- * allocated, which will be larger than requested due to page alignment
- * and mmap minimum size rules. The caller is responsible for locking
- * to prevent concurrent calls. */
-
-static void *__expand_heap(size_t *pn)
-{
- static uintptr_t brk;
- static unsigned mmap_step;
- size_t n = *pn;
-
- if (n > SIZE_MAX/2 - PAGE_SIZE) {
- errno = ENOMEM;
- return 0;
- }
- n += -n & PAGE_SIZE-1;
-
- if (!brk) {
- brk = __syscall(SYS_brk, 0);
- brk += -brk & PAGE_SIZE-1;
- }
-
- if (n < SIZE_MAX-brk && !traverses_stack_p(brk, brk+n)
- && __syscall(SYS_brk, brk+n)==brk+n) {
- *pn = n;
- brk += n;
- return (void *)(brk-n);
- }
-
- size_t min = (size_t)PAGE_SIZE << mmap_step/2;
- if (n < min) n = min;
- void *area = __mmap(0, n, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (area == MAP_FAILED) return 0;
- *pn = n;
- mmap_step++;
- return area;
-}
-
-static struct chunk *expand_heap(size_t n)
-{
- static void *end;
- void *p;
- struct chunk *w;
-
- /* The argument n already accounts for the caller's chunk
- * overhead needs, but if the heap can't be extended in-place,
- * we need room for an extra zero-sized sentinel chunk. */
- n += SIZE_ALIGN;
-
- p = __expand_heap(&n);
- if (!p) return 0;
-
- /* If not just expanding existing space, we need to make a
- * new sentinel chunk below the allocated space. */
- if (p != end) {
- /* Valid/safe because of the prologue increment. */
- n -= SIZE_ALIGN;
- p = (char *)p + SIZE_ALIGN;
- w = MEM_TO_CHUNK(p);
- w->psize = 0 | C_INUSE;
- }
-
- /* Record new heap end and fill in footer. */
- end = (char *)p + n;
- w = MEM_TO_CHUNK(end);
- w->psize = n | C_INUSE;
- w->csize = 0 | C_INUSE;
-
- /* Fill in header, which may be new or may be replacing a
- * zero-size sentinel header at the old end-of-heap. */
- w = MEM_TO_CHUNK(p);
- w->csize = n | C_INUSE;
-
- return w;
-}
-
-static int adjust_size(size_t *n)
-{
- /* Result of pointer difference must fit in ptrdiff_t. */
- if (*n-1 > PTRDIFF_MAX - SIZE_ALIGN - PAGE_SIZE) {
- if (*n) {
- errno = ENOMEM;
- return -1;
- } else {
- *n = SIZE_ALIGN;
- return 0;
- }
- }
- *n = (*n + OVERHEAD + SIZE_ALIGN - 1) & SIZE_MASK;
- return 0;
-}
-
-static void unbin(struct chunk *c, int i)
-{
- if (c->prev == c->next)
- a_and_64(&mal.binmap, ~(1ULL<<i));
- c->prev->next = c->next;
- c->next->prev = c->prev;
- c->csize |= C_INUSE;
- NEXT_CHUNK(c)->psize |= C_INUSE;
-}
-
-static void bin_chunk(struct chunk *self, int i)
-{
- self->next = BIN_TO_CHUNK(i);
- self->prev = mal.bins[i].tail;
- self->next->prev = self;
- self->prev->next = self;
- if (self->prev == BIN_TO_CHUNK(i))
- a_or_64(&mal.binmap, 1ULL<<i);
-}
-
-static void trim(struct chunk *self, size_t n)
-{
- size_t n1 = CHUNK_SIZE(self);
- struct chunk *next, *split;
-
- if (n >= n1 - DONTCARE) return;
-
- next = NEXT_CHUNK(self);
- split = (void *)((char *)self + n);
-
- split->psize = n | C_INUSE;
- split->csize = n1-n;
- next->psize = n1-n;
- self->csize = n | C_INUSE;
-
- int i = bin_index(n1-n);
- lock_bin(i);
-
- bin_chunk(split, i);
-
- unlock_bin(i);
-}
-
-void *malloc(size_t n)
-{
- struct chunk *c;
- int i, j;
- uint64_t mask;
-
- if (adjust_size(&n) < 0) return 0;
-
- if (n > MMAP_THRESHOLD) {
- size_t len = n + OVERHEAD + PAGE_SIZE - 1 & -PAGE_SIZE;
- char *base = __mmap(0, len, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- if (base == (void *)-1) return 0;
- c = (void *)(base + SIZE_ALIGN - OVERHEAD);
- c->csize = len - (SIZE_ALIGN - OVERHEAD);
- c->psize = SIZE_ALIGN - OVERHEAD;
- return CHUNK_TO_MEM(c);
- }
-
- i = bin_index_up(n);
- if (i<63 && (mal.binmap & (1ULL<<i))) {
- lock_bin(i);
- c = mal.bins[i].head;
- if (c != BIN_TO_CHUNK(i) && CHUNK_SIZE(c)-n <= DONTCARE) {
- unbin(c, i);
- unlock_bin(i);
- return CHUNK_TO_MEM(c);
- }
- unlock_bin(i);
- }
- lock(mal.split_merge_lock);
- for (mask = mal.binmap & -(1ULL<<i); mask; mask -= (mask&-mask)) {
- j = first_set(mask);
- lock_bin(j);
- c = mal.bins[j].head;
- if (c != BIN_TO_CHUNK(j)) {
- unbin(c, j);
- unlock_bin(j);
- break;
- }
- unlock_bin(j);
- }
- if (!mask) {
- c = expand_heap(n);
- if (!c) {
- unlock(mal.split_merge_lock);
- return 0;
- }
- }
- trim(c, n);
- unlock(mal.split_merge_lock);
- return CHUNK_TO_MEM(c);
-}
-
-int __malloc_allzerop(void *p)
-{
- return IS_MMAPPED(MEM_TO_CHUNK(p));
-}
-
-void *realloc(void *p, size_t n)
-{
- struct chunk *self, *next;
- size_t n0, n1;
- void *new;
-
- if (!p) return malloc(n);
-
- if (adjust_size(&n) < 0) return 0;
-
- self = MEM_TO_CHUNK(p);
- n1 = n0 = CHUNK_SIZE(self);
-
- if (n<=n0 && n0-n<=DONTCARE) return p;
-
- if (IS_MMAPPED(self)) {
- size_t extra = self->psize;
- char *base = (char *)self - extra;
- size_t oldlen = n0 + extra;
- size_t newlen = n + extra;
- /* Crash on realloc of freed chunk */
- if (extra & 1) a_crash();
- if (newlen < PAGE_SIZE && (new = malloc(n-OVERHEAD))) {
- n0 = n;
- goto copy_free_ret;
- }
- newlen = (newlen + PAGE_SIZE-1) & -PAGE_SIZE;
- if (oldlen == newlen) return p;
- base = __mremap(base, oldlen, newlen, MREMAP_MAYMOVE);
- if (base == (void *)-1)
- goto copy_realloc;
- self = (void *)(base + extra);
- self->csize = newlen - extra;
- return CHUNK_TO_MEM(self);
- }
-
- next = NEXT_CHUNK(self);
-
- /* Crash on corrupted footer (likely from buffer overflow) */
- if (next->psize != self->csize) a_crash();
-
- if (n < n0) {
- int i = bin_index_up(n);
- int j = bin_index(n0);
- if (i<j && (mal.binmap & (1ULL << i)))
- goto copy_realloc;
- struct chunk *split = (void *)((char *)self + n);
- self->csize = split->psize = n | C_INUSE;
- split->csize = next->psize = n0-n | C_INUSE;
- __bin_chunk(split);
- return CHUNK_TO_MEM(self);
- }
-
- lock(mal.split_merge_lock);
-
- size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next);
- if (n0+nsize >= n) {
- int i = bin_index(nsize);
- lock_bin(i);
- if (!(next->csize & C_INUSE)) {
- unbin(next, i);
- unlock_bin(i);
- next = NEXT_CHUNK(next);
- self->csize = next->psize = n0+nsize | C_INUSE;
- trim(self, n);
- unlock(mal.split_merge_lock);
- return CHUNK_TO_MEM(self);
- }
- unlock_bin(i);
- }
- unlock(mal.split_merge_lock);
-
-copy_realloc:
- /* As a last resort, allocate a new chunk and copy to it. */
- new = malloc(n-OVERHEAD);
- if (!new) return 0;
-copy_free_ret:
- memcpy(new, p, (n<n0 ? n : n0) - OVERHEAD);
- free(CHUNK_TO_MEM(self));
- return new;
-}
-
-void __bin_chunk(struct chunk *self)
-{
- struct chunk *next = NEXT_CHUNK(self);
-
- /* Crash on corrupted footer (likely from buffer overflow) */
- if (next->psize != self->csize) a_crash();
-
- lock(mal.split_merge_lock);
-
- size_t osize = CHUNK_SIZE(self), size = osize;
-
- /* Since we hold split_merge_lock, only transition from free to
- * in-use can race; in-use to free is impossible */
- size_t psize = self->psize & C_INUSE ? 0 : CHUNK_PSIZE(self);
- size_t nsize = next->csize & C_INUSE ? 0 : CHUNK_SIZE(next);
-
- if (psize) {
- int i = bin_index(psize);
- lock_bin(i);
- if (!(self->psize & C_INUSE)) {
- struct chunk *prev = PREV_CHUNK(self);
- unbin(prev, i);
- self = prev;
- size += psize;
- }
- unlock_bin(i);
- }
- if (nsize) {
- int i = bin_index(nsize);
- lock_bin(i);
- if (!(next->csize & C_INUSE)) {
- unbin(next, i);
- next = NEXT_CHUNK(next);
- size += nsize;
- }
- unlock_bin(i);
- }
-
- int i = bin_index(size);
- lock_bin(i);
-
- self->csize = size;
- next->psize = size;
- bin_chunk(self, i);
- unlock(mal.split_merge_lock);
-
- /* Replace middle of large chunks with fresh zero pages */
- if (size > RECLAIM && (size^(size-osize)) > size-osize) {
- uintptr_t a = (uintptr_t)self + SIZE_ALIGN+PAGE_SIZE-1 & -PAGE_SIZE;
- uintptr_t b = (uintptr_t)next - SIZE_ALIGN & -PAGE_SIZE;
- int e = errno;
-#if 1
- __madvise((void *)a, b-a, MADV_DONTNEED);
-#else
- __mmap((void *)a, b-a, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
-#endif
- errno = e;
- }
-
- unlock_bin(i);
-}
-
-static void unmap_chunk(struct chunk *self)
-{
- size_t extra = self->psize;
- char *base = (char *)self - extra;
- size_t len = CHUNK_SIZE(self) + extra;
- /* Crash on double free */
- if (extra & 1) a_crash();
- int e = errno;
- __munmap(base, len);
- errno = e;
-}
-
-void free(void *p)
-{
- if (!p) return;
-
- struct chunk *self = MEM_TO_CHUNK(p);
-
- if (IS_MMAPPED(self))
- unmap_chunk(self);
- else
- __bin_chunk(self);
-}
-
-void __malloc_donate(char *start, char *end)
-{
- size_t align_start_up = (SIZE_ALIGN-1) & (-(uintptr_t)start - OVERHEAD);
- size_t align_end_down = (SIZE_ALIGN-1) & (uintptr_t)end;
-
- /* Getting past this condition ensures that the padding for alignment
- * and header overhead will not overflow and will leave a nonzero
- * multiple of SIZE_ALIGN bytes between start and end. */
- if (end - start <= OVERHEAD + align_start_up + align_end_down)
- return;
- start += align_start_up + OVERHEAD;
- end -= align_end_down;
-
- struct chunk *c = MEM_TO_CHUNK(start), *n = MEM_TO_CHUNK(end);
- c->psize = n->csize = C_INUSE;
- c->csize = n->psize = C_INUSE | (end-start);
- __bin_chunk(c);
-}
-
-void __malloc_atfork(int who)
-{
- if (who<0) {
- lock(mal.split_merge_lock);
- for (int i=0; i<64; i++)
- lock(mal.bins[i].lock);
- } else if (!who) {
- for (int i=0; i<64; i++)
- unlock(mal.bins[i].lock);
- unlock(mal.split_merge_lock);
- } else {
- for (int i=0; i<64; i++)
- mal.bins[i].lock[0] = mal.bins[i].lock[1] = 0;
- mal.split_merge_lock[1] = 0;
- mal.split_merge_lock[0] = 0;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_usable_size.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_usable_size.c
deleted file mode 100644
index 672b518ad0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/oldmalloc/malloc_usable_size.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <malloc.h>
-#include "malloc_impl.h"
-
-hidden void *(*const __realloc_dep)(void *, size_t) = realloc;
-
-size_t malloc_usable_size(void *p)
-{
- return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/posix_memalign.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/posix_memalign.c
deleted file mode 100644
index ad4d8f4730..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/posix_memalign.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdlib.h>
-#include <errno.h>
-
-int posix_memalign(void **res, size_t align, size_t len)
-{
- if (align < sizeof(void *)) return EINVAL;
- void *mem = aligned_alloc(align, len);
- if (!mem) return errno;
- *res = mem;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/realloc.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/realloc.c
deleted file mode 100644
index fb0e8b7c47..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/realloc.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdlib.h>
-
-void *realloc(void *p, size_t n)
-{
- return __libc_realloc(p, n);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/reallocarray.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/reallocarray.c
deleted file mode 100644
index 4a6ebe4604..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/reallocarray.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _BSD_SOURCE
-#include <errno.h>
-#include <stdlib.h>
-
-void *reallocarray(void *ptr, size_t m, size_t n)
-{
- if (n && m > -1 / n) {
- errno = ENOMEM;
- return 0;
- }
-
- return realloc(ptr, m * n);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/malloc/replaced.c b/lib/libc/wasi/libc-top-half/musl/src/malloc/replaced.c
deleted file mode 100644
index 07fce61ec0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/malloc/replaced.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "dynlink.h"
-
-int __malloc_replaced;
-int __aligned_alloc_replaced;
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassify.c b/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassify.c
deleted file mode 100644
index f7c0e2dfac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassify.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-int __fpclassify(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i>>52 & 0x7ff;
- if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
- if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyf.c b/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyf.c
deleted file mode 100644
index fd00eb1bcd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-int __fpclassifyf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = u.i>>23 & 0xff;
- if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
- if (e==0xff) return u.i<<9 ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyl.c b/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyl.c
deleted file mode 100644
index e41781b689..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__fpclassifyl.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "libm.h"
-
-#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-int __fpclassifyl(long double x)
-{
- return __fpclassify(x);
-}
-#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
-int __fpclassifyl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- int msb = u.i.m>>63;
- if (!e && !msb)
- return u.i.m ? FP_SUBNORMAL : FP_ZERO;
- if (e == 0x7fff) {
- /* The x86 variant of 80-bit extended precision only admits
- * one representation of each infinity, with the mantissa msb
- * necessarily set. The version with it clear is invalid/nan.
- * The m68k variant, however, allows either, and tooling uses
- * the version with it clear. */
- if (__BYTE_ORDER == __LITTLE_ENDIAN && !msb)
- return FP_NAN;
- return u.i.m << 1 ? FP_NAN : FP_INFINITE;
- }
- if (!msb)
- return FP_NAN;
- return FP_NORMAL;
-}
-#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
-int __fpclassifyl(long double x)
-{
- union ldshape u = {x};
- int e = u.i.se & 0x7fff;
- u.i.se = 0;
- if (!e)
- return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO;
- if (e == 0x7fff)
- return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
- return FP_NORMAL;
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__signbit.c b/lib/libc/wasi/libc-top-half/musl/src/math/__signbit.c
deleted file mode 100644
index e700b6b75f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__signbit.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "libm.h"
-
-// FIXME: macro in math.h
-int __signbit(double x)
-{
- union {
- double d;
- uint64_t i;
- } y = { x };
- return y.i>>63;
-}
-
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__signbitf.c b/lib/libc/wasi/libc-top-half/musl/src/math/__signbitf.c
deleted file mode 100644
index 40ad3cfd0c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__signbitf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "libm.h"
-
-// FIXME: macro in math.h
-int __signbitf(float x)
-{
- union {
- float f;
- uint32_t i;
- } y = { x };
- return y.i>>31;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/__signbitl.c b/lib/libc/wasi/libc-top-half/musl/src/math/__signbitl.c
deleted file mode 100644
index 63b3dc5a08..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/__signbitl.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "libm.h"
-
-#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
-int __signbitl(long double x)
-{
- union ldshape u = {x};
- return u.i.se >> 15;
-}
-#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
-int __signbitl(long double x)
-{
- return __signbit(x);
-}
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceil.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceil.c
deleted file mode 100644
index ac80c1dce5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceil.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double ceil(double x)
-{
- __asm__ ("frintp %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceilf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceilf.c
deleted file mode 100644
index 1ef1e9c839..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/ceilf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float ceilf(float x)
-{
- __asm__ ("frintp %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabs.c
deleted file mode 100644
index 5c3ecaf44b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabs.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fabs(double x)
-{
- __asm__ ("fabs %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabsf.c
deleted file mode 100644
index 7fde981793..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fabsf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fabsf(float x)
-{
- __asm__ ("fabs %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floor.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floor.c
deleted file mode 100644
index 50ffdb281b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floor.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double floor(double x)
-{
- __asm__ ("frintm %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floorf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floorf.c
deleted file mode 100644
index 8d007e9f84..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/floorf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float floorf(float x)
-{
- __asm__ ("frintm %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fma.c
deleted file mode 100644
index 2450ea7e19..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fma.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fma(double x, double y, double z)
-{
- __asm__ ("fmadd %d0, %d1, %d2, %d3" : "=w"(x) : "w"(x), "w"(y), "w"(z));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaf.c
deleted file mode 100644
index 9a147213a0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("fmadd %s0, %s1, %s2, %s3" : "=w"(x) : "w"(x), "w"(y), "w"(z));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmax.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmax.c
deleted file mode 100644
index 86dcb3b459..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmax.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fmax(double x, double y)
-{
- __asm__ ("fmaxnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaxf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaxf.c
deleted file mode 100644
index ee5eac2d73..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmaxf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fmaxf(float x, float y)
-{
- __asm__ ("fmaxnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmin.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmin.c
deleted file mode 100644
index f1e99808e0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fmin.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fmin(double x, double y)
-{
- __asm__ ("fminnm %d0, %d1, %d2" : "=w"(x) : "w"(x), "w"(y));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fminf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fminf.c
deleted file mode 100644
index 80468f676a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/fminf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fminf(float x, float y)
-{
- __asm__ ("fminnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrint.c
deleted file mode 100644
index a9e07a93f1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrint.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-long long llrint(double x)
-{
- long long n;
- __asm__ (
- "frintx %d1, %d1\n"
- "fcvtzs %x0, %d1\n" : "=r"(n), "+w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrintf.c
deleted file mode 100644
index 12b6804f7f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llrintf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-long long llrintf(float x)
-{
- long long n;
- __asm__ (
- "frintx %s1, %s1\n"
- "fcvtzs %x0, %s1\n" : "=r"(n), "+w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llround.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llround.c
deleted file mode 100644
index e09ddd482a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llround.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llround(double x)
-{
- long long n;
- __asm__ ("fcvtas %x0, %d1" : "=r"(n) : "w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llroundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llroundf.c
deleted file mode 100644
index 16699598ac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/llroundf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llroundf(float x)
-{
- long long n;
- __asm__ ("fcvtas %x0, %s1" : "=r"(n) : "w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrint.c
deleted file mode 100644
index cb7785ad1e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrint.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-long lrint(double x)
-{
- long n;
- __asm__ (
- "frintx %d1, %d1\n"
- "fcvtzs %x0, %d1\n" : "=r"(n), "+w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrintf.c
deleted file mode 100644
index 4d750d699d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lrintf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-long lrintf(float x)
-{
- long n;
- __asm__ (
- "frintx %s1, %s1\n"
- "fcvtzs %x0, %s1\n" : "=r"(n), "+w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lround.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lround.c
deleted file mode 100644
index 85656c78d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lround.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lround(double x)
-{
- long n;
- __asm__ ("fcvtas %x0, %d1" : "=r"(n) : "w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lroundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lroundf.c
deleted file mode 100644
index 32e51f3cc3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/lroundf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lroundf(float x)
-{
- long n;
- __asm__ ("fcvtas %x0, %s1" : "=r"(n) : "w"(x));
- return n;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyint.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyint.c
deleted file mode 100644
index 9c3fdb4450..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double nearbyint(double x)
-{
- __asm__ ("frinti %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyintf.c
deleted file mode 100644
index 8e7f61df8c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/nearbyintf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float nearbyintf(float x)
-{
- __asm__ ("frinti %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rint.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rint.c
deleted file mode 100644
index 45b194b5e4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double rint(double x)
-{
- __asm__ ("frintx %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rintf.c
deleted file mode 100644
index 1ae7dd2540..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/rintf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float rintf(float x)
-{
- __asm__ ("frintx %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/round.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/round.c
deleted file mode 100644
index 897a84cc2a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/round.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double round(double x)
-{
- __asm__ ("frinta %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/roundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/roundf.c
deleted file mode 100644
index 91637eaa12..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/roundf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float roundf(float x)
-{
- __asm__ ("frinta %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrt.c
deleted file mode 100644
index fe93c3e6ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrt.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double sqrt(double x)
-{
- __asm__ ("fsqrt %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrtf.c
deleted file mode 100644
index 275c7f399c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/sqrtf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float sqrtf(float x)
-{
- __asm__ ("fsqrt %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/trunc.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/trunc.c
deleted file mode 100644
index e592147a0c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/trunc.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double trunc(double x)
-{
- __asm__ ("frintz %d0, %d1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/truncf.c b/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/truncf.c
deleted file mode 100644
index 20ef30f128..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/aarch64/truncf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float truncf(float x)
-{
- __asm__ ("frintz %s0, %s1" : "=w"(x) : "w"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabs.c
deleted file mode 100644
index 6e1d367d3d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_PCS_VFP && __ARM_FP&8
-
-double fabs(double x)
-{
- __asm__ ("vabs.f64 %P0, %P1" : "=w"(x) : "w"(x));
- return x;
-}
-
-#else
-
-#include "../fabs.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabsf.c
deleted file mode 100644
index 4a217c9889..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fabsf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_PCS_VFP && !BROKEN_VFP_ASM
-
-float fabsf(float x)
-{
- __asm__ ("vabs.f32 %0, %1" : "=t"(x) : "t"(x));
- return x;
-}
-
-#else
-
-#include "../fabsf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/fma.c
deleted file mode 100644
index 2a9b8efa77..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fma.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_FEATURE_FMA && __ARM_FP&8 && !__SOFTFP__
-
-double fma(double x, double y, double z)
-{
- __asm__ ("vfma.f64 %P0, %P1, %P2" : "+w"(z) : "w"(x), "w"(y));
- return z;
-}
-
-#else
-
-#include "../fma.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/fmaf.c
deleted file mode 100644
index a1793d27f1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/fmaf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __ARM_FEATURE_FMA && __ARM_FP&4 && !__SOFTFP__ && !BROKEN_VFP_ASM
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("vfma.f32 %0, %1, %2" : "+t"(z) : "t"(x), "t"(y));
- return z;
-}
-
-#else
-
-#include "../fmaf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrt.c
deleted file mode 100644
index 567e2e9101..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && (__ARM_FP&8)
-
-double sqrt(double x)
-{
- __asm__ ("vsqrt.f64 %P0, %P1" : "=w"(x) : "w"(x));
- return x;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrtf.c
deleted file mode 100644
index 32693293b4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/arm/sqrtf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM
-
-float sqrtf(float x)
-{
- __asm__ ("vsqrt.f32 %0, %1" : "=t"(x) : "t"(x));
- return x;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/ceil.c b/lib/libc/wasi/libc-top-half/musl/src/math/ceil.c
deleted file mode 100644
index b13e6f2d63..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/ceil.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double ceil(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i >> 63)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3ff-1) {
- FORCE_EVAL(y);
- return u.i >> 63 ? -0.0 : 1;
- }
- if (y < 0)
- return x + y + 1;
- return x + y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/ceilf.c b/lib/libc/wasi/libc-top-half/musl/src/math/ceilf.c
deleted file mode 100644
index 869835f397..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/ceilf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libm.h"
-
-float ceilf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f;
- uint32_t m;
-
- if (e >= 23)
- return x;
- if (e >= 0) {
- m = 0x007fffff >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31 == 0)
- u.i += m;
- u.i &= ~m;
- } else {
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31)
- u.f = -0.0;
- else if (u.i << 1)
- u.f = 1.0;
- }
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/copysign.c b/lib/libc/wasi/libc-top-half/musl/src/math/copysign.c
deleted file mode 100644
index b09331b687..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/copysign.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "libm.h"
-
-double copysign(double x, double y) {
- union {double f; uint64_t i;} ux={x}, uy={y};
- ux.i &= -1ULL/2;
- ux.i |= uy.i & 1ULL<<63;
- return ux.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/copysignf.c b/lib/libc/wasi/libc-top-half/musl/src/math/copysignf.c
deleted file mode 100644
index 0af6ae9b21..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/copysignf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float copysignf(float x, float y)
-{
- union {float f; uint32_t i;} ux={x}, uy={y};
- ux.i &= 0x7fffffff;
- ux.i |= uy.i & 0x80000000;
- return ux.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/fabs.c
deleted file mode 100644
index e8258cfdbc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fabs.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-double fabs(double x)
-{
- union {double f; uint64_t i;} u = {x};
- u.i &= -1ULL/2;
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/fabsf.c
deleted file mode 100644
index 4efc8d686d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fabsf.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-#include <stdint.h>
-
-float fabsf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- u.i &= 0x7fffffff;
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/floor.c b/lib/libc/wasi/libc-top-half/musl/src/math/floor.c
deleted file mode 100644
index 14a31cd8c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/floor.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "libm.h"
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double floor(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i >> 52 & 0x7ff;
- double_t y;
-
- if (e >= 0x3ff+52 || x == 0)
- return x;
- /* y = int(x) - x, where int(x) is an integer neighbor of x */
- if (u.i >> 63)
- y = x - toint + toint - x;
- else
- y = x + toint - toint - x;
- /* special case because of non-nearest rounding modes */
- if (e <= 0x3ff-1) {
- FORCE_EVAL(y);
- return u.i >> 63 ? -1 : 0;
- }
- if (y > 0)
- return x + y - 1;
- return x + y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/floorf.c b/lib/libc/wasi/libc-top-half/musl/src/math/floorf.c
deleted file mode 100644
index dceec739db..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/floorf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "libm.h"
-
-float floorf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f;
- uint32_t m;
-
- if (e >= 23)
- return x;
- if (e >= 0) {
- m = 0x007fffff >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31)
- u.i += m;
- u.i &= ~m;
- } else {
- FORCE_EVAL(x + 0x1p120f);
- if (u.i >> 31 == 0)
- u.i = 0;
- else if (u.i << 1)
- u.f = -1.0;
- }
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fmax.c b/lib/libc/wasi/libc-top-half/musl/src/math/fmax.c
deleted file mode 100644
index 94f0caa177..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fmax.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-double fmax(double x, double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? y : x;
- return x < y ? y : x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fmaxf.c b/lib/libc/wasi/libc-top-half/musl/src/math/fmaxf.c
deleted file mode 100644
index 695d8179c6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fmaxf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-float fmaxf(float x, float y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeroes, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? y : x;
- return x < y ? y : x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fmin.c b/lib/libc/wasi/libc-top-half/musl/src/math/fmin.c
deleted file mode 100644
index 08a8fd17f2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fmin.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-double fmin(double x, double y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? x : y;
- return x < y ? x : y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/fminf.c b/lib/libc/wasi/libc-top-half/musl/src/math/fminf.c
deleted file mode 100644
index 3573c7de74..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/fminf.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <math.h>
-
-float fminf(float x, float y)
-{
- if (isnan(x))
- return y;
- if (isnan(y))
- return x;
- /* handle signed zeros, see C99 Annex F.9.9.2 */
- if (signbit(x) != signbit(y))
- return signbit(x) ? x : y;
- return x < y ? x : y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/__invtrigl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/__invtrigl.s
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/__invtrigl.s
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acos.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/acos.s
deleted file mode 100644
index af423a2fcd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acos.s
+++ /dev/null
@@ -1,18 +0,0 @@
-# use acos(x) = atan2(fabs(sqrt((1-x)*(1+x))), x)
-
-.global acos
-.type acos,@function
-acos:
- fldl 4(%esp)
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs # fix sign of zero (matters in downward rounding mode)
- fxch %st(1)
- fpatan
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosf.s
deleted file mode 100644
index d2cdfdbfef..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosf.s
+++ /dev/null
@@ -1,16 +0,0 @@
-.global acosf
-.type acosf,@function
-acosf:
- flds 4(%esp)
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs # fix sign of zero (matters in downward rounding mode)
- fxch %st(1)
- fpatan
- fstps 4(%esp)
- flds 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosl.s
deleted file mode 100644
index 599c8230cd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/acosl.s
+++ /dev/null
@@ -1,14 +0,0 @@
-.global acosl
-.type acosl,@function
-acosl:
- fldt 4(%esp)
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs # fix sign of zero (matters in downward rounding mode)
- fxch %st(1)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asin.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/asin.s
deleted file mode 100644
index 2bc8356f49..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asin.s
+++ /dev/null
@@ -1,21 +0,0 @@
-.global asin
-.type asin,@function
-asin:
- fldl 4(%esp)
- mov 8(%esp),%eax
- add %eax,%eax
- cmp $0x00200000,%eax
- jb 1f
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fpatan
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
- # subnormal x, return x with underflow
-1: fsts 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinf.s
deleted file mode 100644
index 059097532e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinf.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.global asinf
-.type asinf,@function
-asinf:
- flds 4(%esp)
- mov 4(%esp),%eax
- add %eax,%eax
- cmp $0x01000000,%eax
- jb 1f
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fpatan
- fstps 4(%esp)
- flds 4(%esp)
- ret
- # subnormal x, return x with underflow
-1: fld %st(0)
- fmul %st(1)
- fstps 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinl.s
deleted file mode 100644
index e973fc85fb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/asinl.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.global asinl
-.type asinl,@function
-asinl:
- fldt 4(%esp)
- fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan.s
deleted file mode 100644
index 2c57f6b309..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan.s
+++ /dev/null
@@ -1,16 +0,0 @@
-.global atan
-.type atan,@function
-atan:
- fldl 4(%esp)
- mov 8(%esp),%eax
- add %eax,%eax
- cmp $0x00200000,%eax
- jb 1f
- fld1
- fpatan
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
- # subnormal x, return x with underflow
-1: fsts 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2.s
deleted file mode 100644
index 8bc441b1e4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.global atan2
-.type atan2,@function
-atan2:
- fldl 4(%esp)
- fldl 12(%esp)
- fpatan
- fstpl 4(%esp)
- fldl 4(%esp)
- mov 8(%esp),%eax
- add %eax,%eax
- cmp $0x00200000,%eax
- jae 1f
- # subnormal x, return x with underflow
- fsts 4(%esp)
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2f.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2f.s
deleted file mode 100644
index 3908c86df9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2f.s
+++ /dev/null
@@ -1,17 +0,0 @@
-.global atan2f
-.type atan2f,@function
-atan2f:
- flds 4(%esp)
- flds 8(%esp)
- fpatan
- fstps 4(%esp)
- flds 4(%esp)
- mov 4(%esp),%eax
- add %eax,%eax
- cmp $0x01000000,%eax
- jae 1f
- # subnormal x, return x with underflow
- fld %st(0)
- fmul %st(1)
- fstps 4(%esp)
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2l.s
deleted file mode 100644
index adf6e10aaa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atan2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atan2l
-.type atan2l,@function
-atan2l:
- fldt 4(%esp)
- fldt 16(%esp)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanf.s
deleted file mode 100644
index c2cbe2e026..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanf.s
+++ /dev/null
@@ -1,18 +0,0 @@
-.global atanf
-.type atanf,@function
-atanf:
- flds 4(%esp)
- mov 4(%esp),%eax
- add %eax,%eax
- cmp $0x01000000,%eax
- jb 1f
- fld1
- fpatan
- fstps 4(%esp)
- flds 4(%esp)
- ret
- # subnormal x, return x with underflow
-1: fld %st(0)
- fmul %st(1)
- fstps 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanl.s
deleted file mode 100644
index c508bc465b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/atanl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atanl
-.type atanl,@function
-atanl:
- fldt 4(%esp)
- fld1
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceil.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceil.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceil.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceilf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceilf.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceilf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceill.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceill.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ceill.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp2l.s
deleted file mode 100644
index 8125761d10..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp2l.s
+++ /dev/null
@@ -1 +0,0 @@
-# see exp_ld.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp_ld.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp_ld.s
deleted file mode 100644
index 99cba01fa1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/exp_ld.s
+++ /dev/null
@@ -1,93 +0,0 @@
-.global expm1l
-.type expm1l,@function
-expm1l:
- fldt 4(%esp)
- fldl2e
- fmulp
- mov $0xc2820000,%eax
- push %eax
- flds (%esp)
- pop %eax
- fucomp %st(1)
- fnstsw %ax
- sahf
- fld1
- jb 1f
- # x*log2e < -65, return -1 without underflow
- fstp %st(1)
- fchs
- ret
-1: fld %st(1)
- fabs
- fucom %st(1)
- fnstsw %ax
- fstp %st(0)
- fstp %st(0)
- sahf
- ja 1f
- f2xm1
- ret
-1: call 1f
- fld1
- fsubrp
- ret
-
-.global exp2l
-.global __exp2l
-.hidden __exp2l
-.type exp2l,@function
-exp2l:
-__exp2l:
- fldt 4(%esp)
-1: sub $12,%esp
- fld %st(0)
- fstpt (%esp)
- mov 8(%esp),%ax
- and $0x7fff,%ax
- cmp $0x3fff+13,%ax
- jb 4f # |x| < 8192
- cmp $0x3fff+15,%ax
- jae 3f # |x| >= 32768
- fsts (%esp)
- cmpl $0xc67ff800,(%esp)
- jb 2f # x > -16382
- movl $0x5f000000,(%esp)
- flds (%esp) # 0x1p63
- fld %st(1)
- fsub %st(1)
- faddp
- fucomp %st(1)
- fnstsw
- sahf
- je 2f # x - 0x1p63 + 0x1p63 == x
- movl $1,(%esp)
- flds (%esp) # 0x1p-149
- fdiv %st(1)
- fstps (%esp) # raise underflow
-2: fld1
- fld %st(1)
- frndint
- fxch %st(2)
- fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
- f2xm1
- faddp # 2^(x-rint(x))
-1: fscale
- fstp %st(1)
- add $12,%esp
- ret
-3: xor %eax,%eax
-4: cmp $0x3fff-64,%ax
- fld1
- jb 1b # |x| < 0x1p-64
- fstpt (%esp)
- fistl 8(%esp)
- fildl 8(%esp)
- fsubrp %st(1)
- addl $0x3fff,8(%esp)
- f2xm1
- fld1
- faddp # 2^(x-rint(x))
- fldt (%esp) # 2^rint(x)
- fmulp
- add $12,%esp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/expl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/expl.s
deleted file mode 100644
index b5124e8f1f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/expl.s
+++ /dev/null
@@ -1,101 +0,0 @@
-# exp(x) = 2^hi + 2^hi (2^lo - 1)
-# where hi+lo = log2e*x with 128bit precision
-# exact log2e*x calculation depends on nearest rounding mode
-# using the exact multiplication method of Dekker and Veltkamp
-
-.global expl
-.type expl,@function
-expl:
- fldt 4(%esp)
-
- # interesting case: 0x1p-32 <= |x| < 16384
- # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
- mov 12(%esp), %ax
- or $0x8000, %ax
- sub $0xbfdf, %ax
- cmp $45, %ax
- jbe 2f
- test %ax, %ax
- fld1
- js 1f
- # if |x|>=0x1p14 or nan return 2^trunc(x)
- fscale
- fstp %st(1)
- ret
- # if |x|<0x1p-32 return 1+x
-1: faddp
- ret
-
- # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
- # it will be wrong on non-nearest rounding mode
-2: fldl2e
- subl $44, %esp
- # hi = log2e_hi*x
- # 2^hi = exp2l(hi)
- fmul %st(1),%st
- fld %st(0)
- fstpt (%esp)
- fstpt 16(%esp)
- fstpt 32(%esp)
-.hidden __exp2l
- call __exp2l
- # if 2^hi == inf return 2^hi
- fld %st(0)
- fstpt (%esp)
- cmpw $0x7fff, 8(%esp)
- je 1f
- fldt 32(%esp)
- fldt 16(%esp)
- # fpu stack: 2^hi x hi
- # exact mult: x*log2e
- fld %st(1)
- # c = 0x1p32+1
- pushl $0x41f00000
- pushl $0x00100000
- fldl (%esp)
- # xh = x - c*x + c*x
- # xl = x - xh
- fmulp
- fld %st(2)
- fsub %st(1), %st
- faddp
- fld %st(2)
- fsub %st(1), %st
- # yh = log2e_hi - c*log2e_hi + c*log2e_hi
- pushl $0x3ff71547
- pushl $0x65200000
- fldl (%esp)
- # fpu stack: 2^hi x hi xh xl yh
- # lo = hi - xh*yh + xl*yh
- fld %st(2)
- fmul %st(1), %st
- fsubp %st, %st(4)
- fmul %st(1), %st
- faddp %st, %st(3)
- # yl = log2e_hi - yh
- pushl $0x3de705fc
- pushl $0x2f000000
- fldl (%esp)
- # fpu stack: 2^hi x lo xh xl yl
- # lo += xh*yl + xl*yl
- fmul %st, %st(2)
- fmulp %st, %st(1)
- fxch %st(2)
- faddp
- faddp
- # log2e_lo
- pushl $0xbfbe
- pushl $0x82f0025f
- pushl $0x2dc582ee
- fldt (%esp)
- addl $36,%esp
- # fpu stack: 2^hi x lo log2e_lo
- # lo += log2e_lo*x
- # return 2^hi + 2^hi (2^lo - 1)
- fmulp %st, %st(2)
- faddp
- f2xm1
- fmul %st(1), %st
- faddp
-1: addl $44, %esp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/expm1l.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/expm1l.s
deleted file mode 100644
index 8125761d10..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/expm1l.s
+++ /dev/null
@@ -1 +0,0 @@
-# see exp_ld.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabs.c
deleted file mode 100644
index 3967278639..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabs.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fabs(double x)
-{
- __asm__ ("fabs" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsf.c
deleted file mode 100644
index d882eee349..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fabsf(float x)
-{
- __asm__ ("fabs" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsl.c
deleted file mode 100644
index cc1c9ed9c7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fabsl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double fabsl(long double x)
-{
- __asm__ ("fabs" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floor.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/floor.s
deleted file mode 100644
index 46ba88db53..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floor.s
+++ /dev/null
@@ -1,67 +0,0 @@
-.global floorf
-.type floorf,@function
-floorf:
- flds 4(%esp)
- jmp 1f
-
-.global floorl
-.type floorl,@function
-floorl:
- fldt 4(%esp)
- jmp 1f
-
-.global floor
-.type floor,@function
-floor:
- fldl 4(%esp)
-1: mov $0x7,%al
-1: fstcw 4(%esp)
- mov 5(%esp),%ah
- mov %al,5(%esp)
- fldcw 4(%esp)
- frndint
- mov %ah,5(%esp)
- fldcw 4(%esp)
- ret
-
-.global ceil
-.type ceil,@function
-ceil:
- fldl 4(%esp)
- mov $0xb,%al
- jmp 1b
-
-.global ceilf
-.type ceilf,@function
-ceilf:
- flds 4(%esp)
- mov $0xb,%al
- jmp 1b
-
-.global ceill
-.type ceill,@function
-ceill:
- fldt 4(%esp)
- mov $0xb,%al
- jmp 1b
-
-.global trunc
-.type trunc,@function
-trunc:
- fldl 4(%esp)
- mov $0xf,%al
- jmp 1b
-
-.global truncf
-.type truncf,@function
-truncf:
- flds 4(%esp)
- mov $0xf,%al
- jmp 1b
-
-.global truncl
-.type truncl,@function
-truncl:
- fldt 4(%esp)
- mov $0xf,%al
- jmp 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorf.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorl.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/floorl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmod.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmod.c
deleted file mode 100644
index ea0c58d9b4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmod.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-double fmod(double x, double y)
-{
- unsigned short fpsr;
- // fprem does not introduce excess precision into x
- do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodf.c
deleted file mode 100644
index 90b56ab0fa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-float fmodf(float x, float y)
-{
- unsigned short fpsr;
- // fprem does not introduce excess precision into x
- do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodl.c
deleted file mode 100644
index 3daeab0600..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/fmodl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-long double fmodl(long double x, long double y)
-{
- unsigned short fpsr;
- do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypot.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypot.s
deleted file mode 100644
index 299c2e186c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypot.s
+++ /dev/null
@@ -1,45 +0,0 @@
-.global hypot
-.type hypot,@function
-hypot:
- mov 8(%esp),%eax
- mov 16(%esp),%ecx
- add %eax,%eax
- add %ecx,%ecx
- and %eax,%ecx
- cmp $0xffe00000,%ecx
- jae 2f
- or 4(%esp),%eax
- jnz 1f
- fldl 12(%esp)
- fabs
- ret
-1: mov 16(%esp),%eax
- add %eax,%eax
- or 12(%esp),%eax
- jnz 1f
- fldl 4(%esp)
- fabs
- ret
-1: fldl 4(%esp)
- fld %st(0)
- fmulp
- fldl 12(%esp)
- fld %st(0)
- fmulp
- faddp
- fsqrt
- ret
-2: sub $0xffe00000,%eax
- or 4(%esp),%eax
- jnz 1f
- fldl 4(%esp)
- fabs
- ret
-1: mov 16(%esp),%eax
- add %eax,%eax
- sub $0xffe00000,%eax
- or 12(%esp),%eax
- fldl 12(%esp)
- jnz 1f
- fabs
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypotf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypotf.s
deleted file mode 100644
index 068935e2d3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/hypotf.s
+++ /dev/null
@@ -1,42 +0,0 @@
-.global hypotf
-.type hypotf,@function
-hypotf:
- mov 4(%esp),%eax
- mov 8(%esp),%ecx
- add %eax,%eax
- add %ecx,%ecx
- and %eax,%ecx
- cmp $0xff000000,%ecx
- jae 2f
- test %eax,%eax
- jnz 1f
- flds 8(%esp)
- fabs
- ret
-1: mov 8(%esp),%eax
- add %eax,%eax
- jnz 1f
- flds 4(%esp)
- fabs
- ret
-1: flds 4(%esp)
- fld %st(0)
- fmulp
- flds 8(%esp)
- fld %st(0)
- fmulp
- faddp
- fsqrt
- ret
-2: cmp $0xff000000,%eax
- jnz 1f
- flds 4(%esp)
- fabs
- ret
-1: mov 8(%esp),%eax
- add %eax,%eax
- cmp $0xff000000,%eax
- flds 8(%esp)
- jnz 1f
- fabs
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexp.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexp.s
deleted file mode 100644
index c430f78497..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexp.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbn.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpf.s
deleted file mode 100644
index 3f8e4b95fc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbnf.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpl.s
deleted file mode 100644
index 86fe5621bd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/ldexpl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbnl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrint.c
deleted file mode 100644
index aa40081719..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrint.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrint(double x)
-{
- long long r;
- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintf.c
deleted file mode 100644
index c41a317bdb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrintf(float x)
-{
- long long r;
- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintl.c
deleted file mode 100644
index c439ef28d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/llrintl.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrintl(long double x)
-{
- long long r;
- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log.s
deleted file mode 100644
index 08c59924b4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global log
-.type log,@function
-log:
- fldln2
- fldl 4(%esp)
- fyl2x
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10.s
deleted file mode 100644
index 120e91ece8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global log10
-.type log10,@function
-log10:
- fldlg2
- fldl 4(%esp)
- fyl2x
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10f.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10f.s
deleted file mode 100644
index b055493ad4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10f.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global log10f
-.type log10f,@function
-log10f:
- fldlg2
- flds 4(%esp)
- fyl2x
- fstps 4(%esp)
- flds 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10l.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10l.s
deleted file mode 100644
index aaa44f2f8e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log10l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log10l
-.type log10l,@function
-log10l:
- fldlg2
- fldt 4(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1p.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1p.s
deleted file mode 100644
index f3c95f83ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1p.s
+++ /dev/null
@@ -1,25 +0,0 @@
-.global log1p
-.type log1p,@function
-log1p:
- mov 8(%esp),%eax
- fldln2
- and $0x7fffffff,%eax
- fldl 4(%esp)
- cmp $0x3fd28f00,%eax
- ja 1f
- cmp $0x00100000,%eax
- jb 2f
- fyl2xp1
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
-1: fld1
- faddp
- fyl2x
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
- # subnormal x, return x with underflow
-2: fsts 4(%esp)
- fstp %st(1)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pf.s
deleted file mode 100644
index 9f13d95ffb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pf.s
+++ /dev/null
@@ -1,26 +0,0 @@
-.global log1pf
-.type log1pf,@function
-log1pf:
- mov 4(%esp),%eax
- fldln2
- and $0x7fffffff,%eax
- flds 4(%esp)
- cmp $0x3e940000,%eax
- ja 1f
- cmp $0x00800000,%eax
- jb 2f
- fyl2xp1
- fstps 4(%esp)
- flds 4(%esp)
- ret
-1: fld1
- faddp
- fyl2x
- fstps 4(%esp)
- flds 4(%esp)
- ret
- # subnormal x, return x with underflow
-2: fxch
- fmul %st(1)
- fstps 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pl.s
deleted file mode 100644
index a048ab6b3d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log1pl.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.global log1pl
-.type log1pl,@function
-log1pl:
- mov 10(%esp),%eax
- fldln2
- and $0x7fffffff,%eax
- fldt 4(%esp)
- cmp $0x3ffd9400,%eax
- ja 1f
- fyl2xp1
- ret
-1: fld1
- faddp
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2.s
deleted file mode 100644
index 7eff0b616c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global log2
-.type log2,@function
-log2:
- fld1
- fldl 4(%esp)
- fyl2x
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2f.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2f.s
deleted file mode 100644
index b32fa2f76a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2f.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global log2f
-.type log2f,@function
-log2f:
- fld1
- flds 4(%esp)
- fyl2x
- fstps 4(%esp)
- flds 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2l.s
deleted file mode 100644
index c58f56fdeb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/log2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log2l
-.type log2l,@function
-log2l:
- fld1
- fldt 4(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/logf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/logf.s
deleted file mode 100644
index 4d0346a445..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/logf.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global logf
-.type logf,@function
-logf:
- fldln2
- flds 4(%esp)
- fyl2x
- fstps 4(%esp)
- flds 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/logl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/logl.s
deleted file mode 100644
index d4e3339b0d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/logl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global logl
-.type logl,@function
-logl:
- fldln2
- fldt 4(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrint.c
deleted file mode 100644
index 89563ab269..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrint.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrint(double x)
-{
- long r;
- __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintf.c
deleted file mode 100644
index 0bbf29de06..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrintf(float x)
-{
- long r;
- __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintl.c
deleted file mode 100644
index eb8c090288..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/lrintl.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrintl(long double x)
-{
- long r;
- __asm__ ("fistpl %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainder.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainder.c
deleted file mode 100644
index c083df904c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainder.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <math.h>
-
-double remainder(double x, double y)
-{
- unsigned short fpsr;
- // fprem1 does not introduce excess precision into x
- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
-
-weak_alias(remainder, drem);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderf.c
deleted file mode 100644
index 280207d26d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderf.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <math.h>
-
-float remainderf(float x, float y)
-{
- unsigned short fpsr;
- // fprem1 does not introduce excess precision into x
- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
-
-weak_alias(remainderf, dremf);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderl.c
deleted file mode 100644
index 8cf75071ed..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remainderl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-long double remainderl(long double x, long double y)
-{
- unsigned short fpsr;
- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquo.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquo.s
deleted file mode 100644
index 598e75490f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquo.s
+++ /dev/null
@@ -1,50 +0,0 @@
-.global remquof
-.type remquof,@function
-remquof:
- mov 12(%esp),%ecx
- flds 8(%esp)
- flds 4(%esp)
- mov 11(%esp),%dh
- xor 7(%esp),%dh
- jmp 1f
-
-.global remquol
-.type remquol,@function
-remquol:
- mov 28(%esp),%ecx
- fldt 16(%esp)
- fldt 4(%esp)
- mov 25(%esp),%dh
- xor 13(%esp),%dh
- jmp 1f
-
-.global remquo
-.type remquo,@function
-remquo:
- mov 20(%esp),%ecx
- fldl 12(%esp)
- fldl 4(%esp)
- mov 19(%esp),%dh
- xor 11(%esp),%dh
-1: fprem1
- fnstsw %ax
- sahf
- jp 1b
- fstp %st(1)
- mov %ah,%dl
- shr %dl
- and $1,%dl
- mov %ah,%al
- shr $5,%al
- and $2,%al
- or %al,%dl
- mov %ah,%al
- shl $2,%al
- and $4,%al
- or %al,%dl
- test %dh,%dh
- jns 1f
- neg %dl
-1: movsbl %dl,%edx
- mov %edx,(%ecx)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquof.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquof.s
deleted file mode 100644
index 511a6bc7e7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquof.s
+++ /dev/null
@@ -1 +0,0 @@
-# see remquo.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquol.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquol.s
deleted file mode 100644
index 511a6bc7e7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/remquol.s
+++ /dev/null
@@ -1 +0,0 @@
-# see remquo.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rint.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/rint.c
deleted file mode 100644
index a5276a60d8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rint.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double rint(double x)
-{
- __asm__ ("frndint" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintf.c
deleted file mode 100644
index bb4121a4e6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float rintf(float x)
-{
- __asm__ ("frndint" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintl.c
deleted file mode 100644
index e1a92077f5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/rintl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double rintl(long double x)
-{
- __asm__ ("frndint" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbln.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbln.s
deleted file mode 100644
index c430f78497..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbln.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbn.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnf.s
deleted file mode 100644
index 3f8e4b95fc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbnf.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnl.s
deleted file mode 100644
index 86fe5621bd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalblnl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see scalbnl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbn.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbn.s
deleted file mode 100644
index 8bf302f236..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbn.s
+++ /dev/null
@@ -1,33 +0,0 @@
-.global ldexp
-.type ldexp,@function
-ldexp:
- nop
-
-.global scalbln
-.type scalbln,@function
-scalbln:
- nop
-
-.global scalbn
-.type scalbn,@function
-scalbn:
- mov 12(%esp),%eax
- add $0x3ffe,%eax
- cmp $0x7ffd,%eax
- jb 1f
- sub $0x3ffe,%eax
- sar $31,%eax
- xor $0xfff,%eax
- add $0x3ffe,%eax
-1: inc %eax
- fldl 4(%esp)
- mov %eax,12(%esp)
- mov $0x80000000,%eax
- mov %eax,8(%esp)
- xor %eax,%eax
- mov %eax,4(%esp)
- fldt 4(%esp)
- fmulp
- fstpl 4(%esp)
- fldl 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnf.s
deleted file mode 100644
index 9cb9ef5fee..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnf.s
+++ /dev/null
@@ -1,32 +0,0 @@
-.global ldexpf
-.type ldexpf,@function
-ldexpf:
- nop
-
-.global scalblnf
-.type scalblnf,@function
-scalblnf:
- nop
-
-.global scalbnf
-.type scalbnf,@function
-scalbnf:
- mov 8(%esp),%eax
- add $0x3fe,%eax
- cmp $0x7fd,%eax
- jb 1f
- sub $0x3fe,%eax
- sar $31,%eax
- xor $0x1ff,%eax
- add $0x3fe,%eax
-1: inc %eax
- shl $20,%eax
- flds 4(%esp)
- mov %eax,8(%esp)
- xor %eax,%eax
- mov %eax,4(%esp)
- fldl 4(%esp)
- fmulp
- fstps 4(%esp)
- flds 4(%esp)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnl.s
deleted file mode 100644
index 54414c2e98..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/scalbnl.s
+++ /dev/null
@@ -1,32 +0,0 @@
-.global ldexpl
-.type ldexpl,@function
-ldexpl:
- nop
-
-.global scalblnl
-.type scalblnl,@function
-scalblnl:
- nop
-
-.global scalbnl
-.type scalbnl,@function
-scalbnl:
- mov 16(%esp),%eax
- add $0x3ffe,%eax
- cmp $0x7ffd,%eax
- jae 1f
- inc %eax
- fldt 4(%esp)
- mov %eax,12(%esp)
- mov $0x80000000,%eax
- mov %eax,8(%esp)
- xor %eax,%eax
- mov %eax,4(%esp)
- fldt 4(%esp)
- fmulp
- ret
-1: fildl 16(%esp)
- fldt 4(%esp)
- fscale
- fstp %st(1)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrt.c
deleted file mode 100644
index 934fbccab8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "libm.h"
-
-double sqrt(double x)
-{
- union ldshape ux;
- unsigned fpsr;
- __asm__ ("fsqrt; fnstsw %%ax": "=t"(ux.f), "=a"(fpsr) : "0"(x));
- if ((ux.i.m & 0x7ff) != 0x400)
- return (double)ux.f;
- /* Rounding to double would have encountered an exact halfway case.
- Adjust mantissa downwards if fsqrt rounded up, else upwards.
- (result of fsqrt could not have been exact) */
- ux.i.m ^= (fpsr & 0x200) + 0x300;
- return (double)ux.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtf.c
deleted file mode 100644
index 41c65c2bdb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtf.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <math.h>
-
-float sqrtf(float x)
-{
- long double t;
- /* The long double result has sufficient precision so that
- * second rounding to float still keeps the returned value
- * correctly rounded, see Pierre Roux, "Innocuous Double
- * Rounding of Basic Arithmetic Operations". */
- __asm__ ("fsqrt" : "=t"(t) : "0"(x));
- return (float)t;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtl.c b/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtl.c
deleted file mode 100644
index 864cfcc4f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/sqrtl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double sqrtl(long double x)
-{
- __asm__ ("fsqrt" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/trunc.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/trunc.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/trunc.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncf.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncf.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncf.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncl.s b/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncl.s
deleted file mode 100644
index bc29f15ce7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/i386/truncl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floor.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/m68k/sqrtl.c b/lib/libc/wasi/libc-top-half/musl/src/math/m68k/sqrtl.c
deleted file mode 100644
index b1c303c7e2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/m68k/sqrtl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __HAVE_68881__
-
-long double sqrtl(long double x)
-{
- __asm__ ("fsqrt.x %1,%0" : "=f"(x) : "fm"(x));
- return x;
-}
-
-#else
-
-#include "../sqrtl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabs.c
deleted file mode 100644
index 0a5aa3b1d4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabs.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#if !defined(__mips_soft_float) && defined(__mips_abs2008)
-
-#include <math.h>
-
-double fabs(double x)
-{
- double r;
- __asm__("abs.d %0,%1" : "=f"(r) : "f"(x));
- return r;
-}
-
-#else
-
-#include "../fabs.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabsf.c
deleted file mode 100644
index 35307be6ab..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/mips/fabsf.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#if !defined(__mips_soft_float) && defined(__mips_abs2008)
-
-#include <math.h>
-
-float fabsf(float x)
-{
- float r;
- __asm__("abs.s %0,%1" : "=f"(r) : "f"(x));
- return r;
-}
-
-#else
-
-#include "../fabsf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrt.c
deleted file mode 100644
index 595c9dbc36..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrt.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#if !defined(__mips_soft_float) && __mips >= 3
-
-#include <math.h>
-
-double sqrt(double x)
-{
- double r;
- __asm__("sqrt.d %0,%1" : "=f"(r) : "f"(x));
- return r;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrtf.c
deleted file mode 100644
index 84090d2d31..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/mips/sqrtf.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#if !defined(__mips_soft_float) && __mips >= 2
-
-#include <math.h>
-
-float sqrtf(float x)
-{
- float r;
- __asm__("sqrt.s %0,%1" : "=f"(r) : "f"(x));
- return r;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/nearbyint.c b/lib/libc/wasi/libc-top-half/musl/src/math/nearbyint.c
deleted file mode 100644
index f4e8aac4f0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/nearbyint.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <fenv.h>
-#include <math.h>
-
-/* nearbyint is the same as rint, but it must not raise the inexact exception */
-
-double nearbyint(double x)
-{
-#ifdef FE_INEXACT
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
-#endif
- x = rint(x);
-#ifdef FE_INEXACT
- if (!e)
- feclearexcept(FE_INEXACT);
-#endif
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/nearbyintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/nearbyintf.c
deleted file mode 100644
index 092e9ffae5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/nearbyintf.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <fenv.h>
-#include <math.h>
-
-float nearbyintf(float x)
-{
-#ifdef FE_INEXACT
- #pragma STDC FENV_ACCESS ON
- int e;
-
- e = fetestexcept(FE_INEXACT);
-#endif
- x = rintf(x);
-#ifdef FE_INEXACT
- if (!e)
- feclearexcept(FE_INEXACT);
-#endif
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabs.c
deleted file mode 100644
index 9453a3aa98..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
-
-#include "../fabs.c"
-
-#else
-
-double fabs(double x)
-{
- __asm__ ("fabs %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabsf.c
deleted file mode 100644
index 2e9da588dd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fabsf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
-
-#include "../fabsf.c"
-
-#else
-
-float fabsf(float x)
-{
- __asm__ ("fabs %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fma.c
deleted file mode 100644
index 0eb2ba1ef5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fma.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__) || defined(BROKEN_PPC_D_ASM)
-
-#include "../fma.c"
-
-#else
-
-double fma(double x, double y, double z)
-{
- __asm__("fmadd %0, %1, %2, %3" : "=d"(x) : "d"(x), "d"(y), "d"(z));
- return x;
-}
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fmaf.c
deleted file mode 100644
index dc1a749d98..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/fmaf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
-
-#include "../fmaf.c"
-
-#else
-
-float fmaf(float x, float y, float z)
-{
- __asm__("fmadds %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
- return x;
-}
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrt.c
deleted file mode 100644
index 8718dbd0ca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ
-
-double sqrt(double x)
-{
- __asm__ ("fsqrt %0, %1\n" : "=d" (x) : "d" (x));
- return x;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrtf.c
deleted file mode 100644
index 3431b672d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc/sqrtf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if !defined _SOFT_FLOAT && defined _ARCH_PPCSQ
-
-float sqrtf(float x)
-{
- __asm__ ("fsqrts %0, %1\n" : "=f" (x) : "f" (x));
- return x;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceil.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceil.c
deleted file mode 100644
index 4b01133660..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceil.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-double ceil(double x)
-{
- __asm__ ("frip %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#else
-
-#include "../ceil.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceilf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceilf.c
deleted file mode 100644
index 59ba39617f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/ceilf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-float ceilf(float x)
-{
- __asm__ ("frip %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../ceilf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabs.c
deleted file mode 100644
index 6123c7535c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabs.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fabs(double x)
-{
- __asm__ ("fabs %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabsf.c
deleted file mode 100644
index e9e45643d2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fabsf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fabsf(float x)
-{
- __asm__ ("fabs %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floor.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floor.c
deleted file mode 100644
index 4e6804449d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floor.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-double floor(double x)
-{
- __asm__ ("frim %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#else
-
-#include "../floor.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floorf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floorf.c
deleted file mode 100644
index e1031ef401..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/floorf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-float floorf(float x)
-{
- __asm__ ("frim %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fma.c
deleted file mode 100644
index 5aebd1ac3f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fma.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fma(double x, double y, double z)
-{
- __asm__ ("fmadd %0, %1, %2, %3" : "=d"(x) : "d"(x), "d"(y), "d"(z));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaf.c
deleted file mode 100644
index c678fefecd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("fmadds %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmax.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmax.c
deleted file mode 100644
index 992df7f124..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmax.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-double fmax(double x, double y)
-{
- __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y));
- return x;
-}
-
-#else
-
-#include "../fmax.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaxf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaxf.c
deleted file mode 100644
index 345a234a80..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmaxf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-float fmaxf(float x, float y)
-{
- __asm__ ("xsmaxdp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y));
- return x;
-}
-
-#else
-
-#include "../fmaxf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmin.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmin.c
deleted file mode 100644
index adf71bad95..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fmin.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-double fmin(double x, double y)
-{
- __asm__ ("xsmindp %x0, %x1, %x2" : "=ws"(x) : "ws"(x), "ws"(y));
- return x;
-}
-
-#else
-
-#include "../fmin.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fminf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fminf.c
deleted file mode 100644
index faf0e47e99..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/fminf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-float fminf(float x, float y)
-{
- __asm__ ("xsmindp %x0, %x1, %x2" : "=ww"(x) : "ww"(x), "ww"(y));
- return x;
-}
-
-#else
-
-#include "../fminf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrint.c
deleted file mode 100644
index 4e4b2e00a9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrint.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-long lrint(double x)
-{
- long n;
- __asm__ ("fctid %0, %1" : "=d"(n) : "d"(x));
- return n;
-}
-
-#else
-
-#include "../lrint.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrintf.c
deleted file mode 100644
index 9070fc03dc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lrintf.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-long lrintf(float x)
-{
- long n;
- __asm__ ("fctid %0, %1" : "=d"(n) : "f"(x));
- return n;
-}
-
-#else
-
-#include "../lrintf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lround.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lround.c
deleted file mode 100644
index ee4d1143c3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lround.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-long lround(double x)
-{
- long n;
- __asm__ (
- "xsrdpi %1, %1\n"
- "fctid %0, %1\n" : "=d"(n), "+d"(x));
- return n;
-}
-
-#else
-
-#include "../lround.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lroundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lroundf.c
deleted file mode 100644
index 033094ffb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/lroundf.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <math.h>
-
-#ifdef __VSX__
-
-long lroundf(float x)
-{
- long n;
- __asm__ (
- "xsrdpi %1, %1\n"
- "fctid %0, %1\n" : "=d"(n), "+f"(x));
- return n;
-}
-
-#else
-
-#include "../lroundf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/round.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/round.c
deleted file mode 100644
index 4b9318e09f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/round.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-double round(double x)
-{
- __asm__ ("frin %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#else
-
-#include "../round.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/roundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/roundf.c
deleted file mode 100644
index ae93f999ab..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/roundf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-float roundf(float x)
-{
- __asm__ ("frin %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../roundf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrt.c
deleted file mode 100644
index 13bb98d91c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrt.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double sqrt(double x)
-{
- __asm__ ("fsqrt %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrtf.c
deleted file mode 100644
index b6ecb106b6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/sqrtf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float sqrtf(float x)
-{
- __asm__ ("fsqrts %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/trunc.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/trunc.c
deleted file mode 100644
index 57918548b8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/trunc.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-double trunc(double x)
-{
- __asm__ ("friz %0, %1" : "=d"(x) : "d"(x));
- return x;
-}
-
-#else
-
-#include "../trunc.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/truncf.c b/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/truncf.c
deleted file mode 100644
index 94e638fb77..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/powerpc64/truncf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#ifdef _ARCH_PWR5X
-
-float truncf(float x)
-{
- __asm__ ("friz %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../truncf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/rint.c b/lib/libc/wasi/libc-top-half/musl/src/math/rint.c
deleted file mode 100644
index fbba390e7d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/rint.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const double_t toint = 1/EPS;
-
-double rint(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = u.i>>52 & 0x7ff;
- int s = u.i>>63;
- double_t y;
-
- if (e >= 0x3ff+52)
- return x;
- if (s)
- y = x - toint + toint;
- else
- y = x + toint - toint;
- if (y == 0)
- return s ? -0.0 : 0;
- return y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/rintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/rintf.c
deleted file mode 100644
index 9047688d24..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/rintf.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <float.h>
-#include <math.h>
-#include <stdint.h>
-
-#if FLT_EVAL_METHOD==0
-#define EPS FLT_EPSILON
-#elif FLT_EVAL_METHOD==1
-#define EPS DBL_EPSILON
-#elif FLT_EVAL_METHOD==2
-#define EPS LDBL_EPSILON
-#endif
-static const float_t toint = 1/EPS;
-
-float rintf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = u.i>>23 & 0xff;
- int s = u.i>>31;
- float_t y;
-
- if (e >= 0x7f+23)
- return x;
- if (s)
- y = x - toint + toint;
- else
- y = x + toint - toint;
- if (y == 0)
- return s ? -0.0f : 0.0f;
- return y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysign.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysign.c
deleted file mode 100644
index c7854178f0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysign.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double copysign(double x, double y)
-{
- __asm__ ("fsgnj.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../copysign.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysignf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysignf.c
deleted file mode 100644
index a125611ace..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/copysignf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float copysignf(float x, float y)
-{
- __asm__ ("fsgnj.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../copysignf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabs.c
deleted file mode 100644
index 5290b6f093..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double fabs(double x)
-{
- __asm__ ("fabs.d %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../fabs.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabsf.c
deleted file mode 100644
index f5032e354d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fabsf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float fabsf(float x)
-{
- __asm__ ("fabs.s %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../fabsf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fma.c
deleted file mode 100644
index 99b0571301..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fma.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double fma(double x, double y, double z)
-{
- __asm__ ("fmadd.d %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
- return x;
-}
-
-#else
-
-#include "../fma.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaf.c
deleted file mode 100644
index f9dc47eda9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("fmadd.s %0, %1, %2, %3" : "=f"(x) : "f"(x), "f"(y), "f"(z));
- return x;
-}
-
-#else
-
-#include "../fmaf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmax.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmax.c
deleted file mode 100644
index 023709cdfd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmax.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double fmax(double x, double y)
-{
- __asm__ ("fmax.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../fmax.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaxf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaxf.c
deleted file mode 100644
index 863d2bd17a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmaxf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float fmaxf(float x, float y)
-{
- __asm__ ("fmax.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../fmaxf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmin.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmin.c
deleted file mode 100644
index a4e3b06710..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fmin.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double fmin(double x, double y)
-{
- __asm__ ("fmin.d %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../fmin.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fminf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fminf.c
deleted file mode 100644
index 32156e80e3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/fminf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float fminf(float x, float y)
-{
- __asm__ ("fmin.s %0, %1, %2" : "=f"(x) : "f"(x), "f"(y));
- return x;
-}
-
-#else
-
-#include "../fminf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrt.c
deleted file mode 100644
index 867a504c27..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 64
-
-double sqrt(double x)
-{
- __asm__ ("fsqrt.d %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrtf.c
deleted file mode 100644
index 610c2cf800..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/riscv64/sqrtf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if __riscv_flen >= 32
-
-float sqrtf(float x)
-{
- __asm__ ("fsqrt.s %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceil.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceil.c
deleted file mode 100644
index aee17df75f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceil.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double ceil(double x)
-{
- __asm__ ("fidbra %0, 6, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../ceil.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceilf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceilf.c
deleted file mode 100644
index 29ba8d4e77..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceilf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float ceilf(float x)
-{
- __asm__ ("fiebra %0, 6, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../ceilf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceill.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceill.c
deleted file mode 100644
index b838dc13e0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/ceill.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double ceill(long double x)
-{
- __asm__ ("fixbra %0, 6, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../ceill.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabs.c
deleted file mode 100644
index 9bb51cb5ff..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabs.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double fabs(double x)
-{
- __asm__ ("lpdbr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../fabs.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsf.c
deleted file mode 100644
index 9fd96bc9d2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float fabsf(float x)
-{
- __asm__ ("lpebr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../fabsf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsl.c
deleted file mode 100644
index 65f1005d4e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fabsl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double fabsl(long double x)
-{
- __asm__ ("lpxbr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../fabsl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floor.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floor.c
deleted file mode 100644
index 4c0c7f1adb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floor.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double floor(double x)
-{
- __asm__ ("fidbra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floor.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorf.c
deleted file mode 100644
index ea28ec7ac5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float floorf(float x)
-{
- __asm__ ("fiebra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorl.c
deleted file mode 100644
index 8a0e16a2f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/floorl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double floorl(long double x)
-{
- __asm__ ("fixbra %0, 7, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../floorl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fma.c
deleted file mode 100644
index 86da0e4958..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fma.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double fma(double x, double y, double z)
-{
- __asm__ ("madbr %0, %1, %2" : "+f"(z) : "f"(x), "f"(y));
- return z;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fmaf.c
deleted file mode 100644
index f1aec6ade3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/fmaf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("maebr %0, %1, %2" : "+f"(z) : "f"(x), "f"(y));
- return z;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyint.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyint.c
deleted file mode 100644
index b70da52deb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyint.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double nearbyint(double x)
-{
- __asm__ ("fidbra %0, 0, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../nearbyint.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintf.c
deleted file mode 100644
index 704f267819..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float nearbyintf(float x)
-{
- __asm__ ("fiebra %0, 0, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../nearbyintf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintl.c
deleted file mode 100644
index b4bd5523c7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/nearbyintl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double nearbyintl(long double x)
-{
- __asm__ ("fixbra %0, 0, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../nearbyintl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rint.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rint.c
deleted file mode 100644
index b02f09eb06..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rint.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double rint(double x)
-{
- __asm__ ("fidbr %0, 0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../rint.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintf.c
deleted file mode 100644
index c9f13130cf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float rintf(float x)
-{
- __asm__ ("fiebr %0, 0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../rintf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintl.c
deleted file mode 100644
index bae53185a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/rintl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double rintl(long double x)
-{
- __asm__ ("fixbr %0, 0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../rintl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/round.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/round.c
deleted file mode 100644
index 71f8025118..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/round.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double round(double x)
-{
- __asm__ ("fidbra %0, 1, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../round.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundf.c
deleted file mode 100644
index 46d2e10c87..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float roundf(float x)
-{
- __asm__ ("fiebra %0, 1, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../roundf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundl.c
deleted file mode 100644
index ce644ddd79..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/roundl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double roundl(long double x)
-{
- __asm__ ("fixbra %0, 1, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../roundl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrt.c
deleted file mode 100644
index a80dc4a7d9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrt.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double sqrt(double x)
-{
- __asm__ ("sqdbr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../sqrt.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtf.c
deleted file mode 100644
index 52f57eb998..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float sqrtf(float x)
-{
- __asm__ ("sqebr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../sqrtf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtl.c
deleted file mode 100644
index 5702d54da0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/sqrtl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double sqrtl(long double x)
-{
- __asm__ ("sqxbr %0, %1" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../sqrtl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/trunc.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/trunc.c
deleted file mode 100644
index 3e5d8862e6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/trunc.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-double trunc(double x)
-{
- __asm__ ("fidbra %0, 5, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../trunc.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncf.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncf.c
deleted file mode 100644
index 9097bacd0c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncf.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-float truncf(float x)
-{
- __asm__ ("fiebra %0, 5, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../truncf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncl.c b/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncl.c
deleted file mode 100644
index 4eb920a519..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/s390x/truncl.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <math.h>
-
-#if defined(__HTM__) || __ARCH__ >= 9
-
-long double truncl(long double x)
-{
- __asm__ ("fixbra %0, 5, %1, 4" : "=f"(x) : "f"(x));
- return x;
-}
-
-#else
-
-#include "../truncl.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/sqrt.c
deleted file mode 100644
index 5ba2655962..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/sqrt.c
+++ /dev/null
@@ -1,158 +0,0 @@
-#include <stdint.h>
-#include <math.h>
-#include "libm.h"
-#include "sqrt_data.h"
-
-#define FENV_SUPPORT 1
-
-/* returns a*b*2^-32 - e, with error 0 <= e < 1. */
-static inline uint32_t mul32(uint32_t a, uint32_t b)
-{
- return (uint64_t)a*b >> 32;
-}
-
-/* returns a*b*2^-64 - e, with error 0 <= e < 3. */
-static inline uint64_t mul64(uint64_t a, uint64_t b)
-{
- uint64_t ahi = a>>32;
- uint64_t alo = a&0xffffffff;
- uint64_t bhi = b>>32;
- uint64_t blo = b&0xffffffff;
- return ahi*bhi + (ahi*blo >> 32) + (alo*bhi >> 32);
-}
-
-double sqrt(double x)
-{
- uint64_t ix, top, m;
-
- /* special case handling. */
- ix = asuint64(x);
- top = ix >> 52;
- if (predict_false(top - 0x001 >= 0x7ff - 0x001)) {
- /* x < 0x1p-1022 or inf or nan. */
- if (ix * 2 == 0)
- return x;
- if (ix == 0x7ff0000000000000)
- return x;
- if (ix > 0x7ff0000000000000)
- return __math_invalid(x);
- /* x is subnormal, normalize it. */
- ix = asuint64(x * 0x1p52);
- top = ix >> 52;
- top -= 52;
- }
-
- /* argument reduction:
- x = 4^e m; with integer e, and m in [1, 4)
- m: fixed point representation [2.62]
- 2^e is the exponent part of the result. */
- int even = top & 1;
- m = (ix << 11) | 0x8000000000000000;
- if (even) m >>= 1;
- top = (top + 0x3ff) >> 1;
-
- /* approximate r ~ 1/sqrt(m) and s ~ sqrt(m) when m in [1,4)
-
- initial estimate:
- 7bit table lookup (1bit exponent and 6bit significand).
-
- iterative approximation:
- using 2 goldschmidt iterations with 32bit int arithmetics
- and a final iteration with 64bit int arithmetics.
-
- details:
-
- the relative error (e = r0 sqrt(m)-1) of a linear estimate
- (r0 = a m + b) is |e| < 0.085955 ~ 0x1.6p-4 at best,
- a table lookup is faster and needs one less iteration
- 6 bit lookup table (128b) gives |e| < 0x1.f9p-8
- 7 bit lookup table (256b) gives |e| < 0x1.fdp-9
- for single and double prec 6bit is enough but for quad
- prec 7bit is needed (or modified iterations). to avoid
- one more iteration >=13bit table would be needed (16k).
-
- a newton-raphson iteration for r is
- w = r*r
- u = 3 - m*w
- r = r*u/2
- can use a goldschmidt iteration for s at the end or
- s = m*r
-
- first goldschmidt iteration is
- s = m*r
- u = 3 - s*r
- r = r*u/2
- s = s*u/2
- next goldschmidt iteration is
- u = 3 - s*r
- r = r*u/2
- s = s*u/2
- and at the end r is not computed only s.
-
- they use the same amount of operations and converge at the
- same quadratic rate, i.e. if
- r1 sqrt(m) - 1 = e, then
- r2 sqrt(m) - 1 = -3/2 e^2 - 1/2 e^3
- the advantage of goldschmidt is that the mul for s and r
- are independent (computed in parallel), however it is not
- "self synchronizing": it only uses the input m in the
- first iteration so rounding errors accumulate. at the end
- or when switching to larger precision arithmetics rounding
- errors dominate so the first iteration should be used.
-
- the fixed point representations are
- m: 2.30 r: 0.32, s: 2.30, d: 2.30, u: 2.30, three: 2.30
- and after switching to 64 bit
- m: 2.62 r: 0.64, s: 2.62, d: 2.62, u: 2.62, three: 2.62 */
-
- static const uint64_t three = 0xc0000000;
- uint64_t r, s, d, u, i;
-
- i = (ix >> 46) % 128;
- r = (uint32_t)__rsqrt_tab[i] << 16;
- /* |r sqrt(m) - 1| < 0x1.fdp-9 */
- s = mul32(m>>32, r);
- /* |s/sqrt(m) - 1| < 0x1.fdp-9 */
- d = mul32(s, r);
- u = three - d;
- r = mul32(r, u) << 1;
- /* |r sqrt(m) - 1| < 0x1.7bp-16 */
- s = mul32(s, u) << 1;
- /* |s/sqrt(m) - 1| < 0x1.7bp-16 */
- d = mul32(s, r);
- u = three - d;
- r = mul32(r, u) << 1;
- /* |r sqrt(m) - 1| < 0x1.3704p-29 (measured worst-case) */
- r = r << 32;
- s = mul64(m, r);
- d = mul64(s, r);
- u = (three<<32) - d;
- s = mul64(s, u); /* repr: 3.61 */
- /* -0x1p-57 < s - sqrt(m) < 0x1.8001p-61 */
- s = (s - 2) >> 9; /* repr: 12.52 */
- /* -0x1.09p-52 < s - sqrt(m) < -0x1.fffcp-63 */
-
- /* s < sqrt(m) < s + 0x1.09p-52,
- compute nearest rounded result:
- the nearest result to 52 bits is either s or s+0x1p-52,
- we can decide by comparing (2^52 s + 0.5)^2 to 2^104 m. */
- uint64_t d0, d1, d2;
- double y, t;
- d0 = (m << 42) - s*s;
- d1 = s - d0;
- d2 = d1 + s + 1;
- s += d1 >> 63;
- s &= 0x000fffffffffffff;
- s |= top << 52;
- y = asdouble(s);
- if (FENV_SUPPORT) {
- /* handle rounding modes and inexact exception:
- only (s+1)^2 == 2^42 m case is exact otherwise
- add a tiny value to cause the fenv effects. */
- uint64_t tiny = predict_false(d2==0) ? 0 : 0x0010000000000000;
- tiny |= (d1^d2) & 0x8000000000000000;
- t = asdouble(tiny);
- y = eval_as_double(y + t);
- }
- return y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/sqrtf.c
deleted file mode 100644
index 740d81cbab..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/sqrtf.c
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <stdint.h>
-#include <math.h>
-#include "libm.h"
-#include "sqrt_data.h"
-
-#define FENV_SUPPORT 1
-
-static inline uint32_t mul32(uint32_t a, uint32_t b)
-{
- return (uint64_t)a*b >> 32;
-}
-
-/* see sqrt.c for more detailed comments. */
-
-float sqrtf(float x)
-{
- uint32_t ix, m, m1, m0, even, ey;
-
- ix = asuint(x);
- if (predict_false(ix - 0x00800000 >= 0x7f800000 - 0x00800000)) {
- /* x < 0x1p-126 or inf or nan. */
- if (ix * 2 == 0)
- return x;
- if (ix == 0x7f800000)
- return x;
- if (ix > 0x7f800000)
- return __math_invalidf(x);
- /* x is subnormal, normalize it. */
- ix = asuint(x * 0x1p23f);
- ix -= 23 << 23;
- }
-
- /* x = 4^e m; with int e and m in [1, 4). */
- even = ix & 0x00800000;
- m1 = (ix << 8) | 0x80000000;
- m0 = (ix << 7) & 0x7fffffff;
- m = even ? m0 : m1;
-
- /* 2^e is the exponent part of the return value. */
- ey = ix >> 1;
- ey += 0x3f800000 >> 1;
- ey &= 0x7f800000;
-
- /* compute r ~ 1/sqrt(m), s ~ sqrt(m) with 2 goldschmidt iterations. */
- static const uint32_t three = 0xc0000000;
- uint32_t r, s, d, u, i;
- i = (ix >> 17) % 128;
- r = (uint32_t)__rsqrt_tab[i] << 16;
- /* |r*sqrt(m) - 1| < 0x1p-8 */
- s = mul32(m, r);
- /* |s/sqrt(m) - 1| < 0x1p-8 */
- d = mul32(s, r);
- u = three - d;
- r = mul32(r, u) << 1;
- /* |r*sqrt(m) - 1| < 0x1.7bp-16 */
- s = mul32(s, u) << 1;
- /* |s/sqrt(m) - 1| < 0x1.7bp-16 */
- d = mul32(s, r);
- u = three - d;
- s = mul32(s, u);
- /* -0x1.03p-28 < s/sqrt(m) - 1 < 0x1.fp-31 */
- s = (s - 1)>>6;
- /* s < sqrt(m) < s + 0x1.08p-23 */
-
- /* compute nearest rounded result. */
- uint32_t d0, d1, d2;
- float y, t;
- d0 = (m << 16) - s*s;
- d1 = s - d0;
- d2 = d1 + s + 1;
- s += d1 >> 31;
- s &= 0x007fffff;
- s |= ey;
- y = asfloat(s);
- if (FENV_SUPPORT) {
- /* handle rounding and inexact exception. */
- uint32_t tiny = predict_false(d2==0) ? 0 : 0x01000000;
- tiny |= (d1^d2) & 0x80000000;
- t = asfloat(tiny);
- y = eval_as_float(y + t);
- }
- return y;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/trunc.c b/lib/libc/wasi/libc-top-half/musl/src/math/trunc.c
deleted file mode 100644
index d13711b501..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/trunc.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libm.h"
-
-double trunc(double x)
-{
- union {double f; uint64_t i;} u = {x};
- int e = (int)(u.i >> 52 & 0x7ff) - 0x3ff + 12;
- uint64_t m;
-
- if (e >= 52 + 12)
- return x;
- if (e < 12)
- e = 1;
- m = -1ULL >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- u.i &= ~m;
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/truncf.c b/lib/libc/wasi/libc-top-half/musl/src/math/truncf.c
deleted file mode 100644
index 1a7d03c3bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/truncf.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "libm.h"
-
-float truncf(float x)
-{
- union {float f; uint32_t i;} u = {x};
- int e = (int)(u.i >> 23 & 0xff) - 0x7f + 9;
- uint32_t m;
-
- if (e >= 23 + 9)
- return x;
- if (e < 9)
- e = 1;
- m = -1U >> e;
- if ((u.i & m) == 0)
- return x;
- FORCE_EVAL(x + 0x1p120f);
- u.i &= ~m;
- return u.f;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/__invtrigl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/__invtrigl.s
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/__invtrigl.s
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/acosl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/acosl.s
deleted file mode 100644
index 1abca12e78..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/acosl.s
+++ /dev/null
@@ -1,16 +0,0 @@
-# see ../i386/acos.s
-
-.global acosl
-.type acosl,@function
-acosl:
- fldt 8(%esp)
-1: fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs
- fxch %st(1)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/asinl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/asinl.s
deleted file mode 100644
index 7fe9f1276a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/asinl.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.global asinl
-.type asinl,@function
-asinl:
- fldt 8(%esp)
-1: fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/atan2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/atan2l.s
deleted file mode 100644
index 1ead0788a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/atan2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atan2l
-.type atan2l,@function
-atan2l:
- fldt 8(%esp)
- fldt 24(%esp)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/atanl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/atanl.s
deleted file mode 100644
index f475fe0e9e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/atanl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atanl
-.type atanl,@function
-atanl:
- fldt 8(%esp)
- fld1
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/ceill.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/ceill.s
deleted file mode 100644
index f5cfa3b307..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/ceill.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floorl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/exp2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/exp2l.s
deleted file mode 100644
index e9edb96f23..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/exp2l.s
+++ /dev/null
@@ -1,83 +0,0 @@
-.global expm1l
-.type expm1l,@function
-expm1l:
- fldt 8(%esp)
- fldl2e
- fmulp
- movl $0xc2820000,-4(%esp)
- flds -4(%esp)
- fucomip %st(1),%st
- fld1
- jb 1f
- # x*log2e <= -65, return -1 without underflow
- fstp %st(1)
- fchs
- ret
-1: fld %st(1)
- fabs
- fucomip %st(1),%st
- fstp %st(0)
- ja 1f
- f2xm1
- ret
-1: push %rax
- call 1f
- pop %rax
- fld1
- fsubrp
- ret
-
-.global exp2l
-.type exp2l,@function
-exp2l:
- fldt 8(%esp)
-1: fld %st(0)
- sub $16,%esp
- fstpt (%esp)
- mov 8(%esp),%ax
- and $0x7fff,%ax
- cmp $0x3fff+13,%ax
- jb 4f # |x| < 8192
- cmp $0x3fff+15,%ax
- jae 3f # |x| >= 32768
- fsts (%esp)
- cmpl $0xc67ff800,(%esp)
- jb 2f # x > -16382
- movl $0x5f000000,(%esp)
- flds (%esp) # 0x1p63
- fld %st(1)
- fsub %st(1)
- faddp
- fucomip %st(1),%st
- je 2f # x - 0x1p63 + 0x1p63 == x
- movl $1,(%esp)
- flds (%esp) # 0x1p-149
- fdiv %st(1)
- fstps (%esp) # raise underflow
-2: fld1
- fld %st(1)
- frndint
- fxch %st(2)
- fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
- f2xm1
- faddp # 2^(x-rint(x))
-1: fscale
- fstp %st(1)
- add $16,%esp
- ret
-3: xor %eax,%eax
-4: cmp $0x3fff-64,%ax
- fld1
- jb 1b # |x| < 0x1p-64
- fstpt (%esp)
- fistl 8(%esp)
- fildl 8(%esp)
- fsubrp %st(1)
- addl $0x3fff,8(%esp)
- f2xm1
- fld1
- faddp # 2^(x-rint(x))
- fldt (%esp) # 2^rint(x)
- fmulp
- add $16,%esp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/expl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/expl.s
deleted file mode 100644
index 369f7bd216..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/expl.s
+++ /dev/null
@@ -1,101 +0,0 @@
-# exp(x) = 2^hi + 2^hi (2^lo - 1)
-# where hi+lo = log2e*x with 128bit precision
-# exact log2e*x calculation depends on nearest rounding mode
-# using the exact multiplication method of Dekker and Veltkamp
-
-.global expl
-.type expl,@function
-expl:
- fldt 8(%esp)
-
- # interesting case: 0x1p-32 <= |x| < 16384
- # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
- mov 16(%esp), %ax
- or $0x8000, %ax
- sub $0xbfdf, %ax
- cmp $45, %ax
- jbe 2f
- test %ax, %ax
- fld1
- js 1f
- # if |x|>=0x1p14 or nan return 2^trunc(x)
- fscale
- fstp %st(1)
- ret
- # if |x|<0x1p-32 return 1+x
-1: faddp
- ret
-
- # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
- # it will be wrong on non-nearest rounding mode
-2: fldl2e
- sub $48, %esp
- # hi = log2e_hi*x
- # 2^hi = exp2l(hi)
- fmul %st(1),%st
- fld %st(0)
- fstpt (%esp)
- fstpt 16(%esp)
- fstpt 32(%esp)
- call exp2l@PLT
- # if 2^hi == inf return 2^hi
- fld %st(0)
- fstpt (%esp)
- cmpw $0x7fff, 8(%esp)
- je 1f
- fldt 32(%esp)
- fldt 16(%esp)
- # fpu stack: 2^hi x hi
- # exact mult: x*log2e
- fld %st(1)
- # c = 0x1p32+1
- movq $0x41f0000000100000,%rax
- pushq %rax
- fldl (%esp)
- # xh = x - c*x + c*x
- # xl = x - xh
- fmulp
- fld %st(2)
- fsub %st(1), %st
- faddp
- fld %st(2)
- fsub %st(1), %st
- # yh = log2e_hi - c*log2e_hi + c*log2e_hi
- movq $0x3ff7154765200000,%rax
- pushq %rax
- fldl (%esp)
- # fpu stack: 2^hi x hi xh xl yh
- # lo = hi - xh*yh + xl*yh
- fld %st(2)
- fmul %st(1), %st
- fsubp %st, %st(4)
- fmul %st(1), %st
- faddp %st, %st(3)
- # yl = log2e_hi - yh
- movq $0x3de705fc2f000000,%rax
- pushq %rax
- fldl (%esp)
- # fpu stack: 2^hi x lo xh xl yl
- # lo += xh*yl + xl*yl
- fmul %st, %st(2)
- fmulp %st, %st(1)
- fxch %st(2)
- faddp
- faddp
- # log2e_lo
- movq $0xbfbe,%rax
- pushq %rax
- movq $0x82f0025f2dc582ee,%rax
- pushq %rax
- fldt (%esp)
- add $40,%esp
- # fpu stack: 2^hi x lo log2e_lo
- # lo += log2e_lo*x
- # return 2^hi + 2^hi (2^lo - 1)
- fmulp %st, %st(2)
- faddp
- f2xm1
- fmul %st(1), %st
- faddp
-1: add $48, %esp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/expm1l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/expm1l.s
deleted file mode 100644
index e773f08053..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/expm1l.s
+++ /dev/null
@@ -1 +0,0 @@
-# see exp2l.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabs.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabs.s
deleted file mode 100644
index 5715005e33..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabs.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.global fabs
-.type fabs,@function
-fabs:
- xor %eax,%eax
- dec %rax
- shr %rax
- movq %rax,%xmm1
- andpd %xmm1,%xmm0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsf.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsf.s
deleted file mode 100644
index 501a1f1755..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsf.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global fabsf
-.type fabsf,@function
-fabsf:
- mov $0x7fffffff,%eax
- movq %rax,%xmm1
- andps %xmm1,%xmm0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsl.s
deleted file mode 100644
index 4f215df5c6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fabsl.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global fabsl
-.type fabsl,@function
-fabsl:
- fldt 8(%esp)
- fabs
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/floorl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/floorl.s
deleted file mode 100644
index 78dcb6dadc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/floorl.s
+++ /dev/null
@@ -1,27 +0,0 @@
-.global floorl
-.type floorl,@function
-floorl:
- fldt 8(%esp)
-1: mov $0x7,%al
-1: fstcw 8(%esp)
- mov 9(%esp),%ah
- mov %al,9(%esp)
- fldcw 8(%esp)
- frndint
- mov %ah,9(%esp)
- fldcw 8(%esp)
- ret
-
-.global ceill
-.type ceill,@function
-ceill:
- fldt 8(%esp)
- mov $0xb,%al
- jmp 1b
-
-.global truncl
-.type truncl,@function
-truncl:
- fldt 8(%esp)
- mov $0xf,%al
- jmp 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fma.c
deleted file mode 100644
index 4dd53f2ac8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fma.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-
-#if __FMA__
-
-double fma(double x, double y, double z)
-{
- __asm__ ("vfmadd132sd %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
- return x;
-}
-
-#elif __FMA4__
-
-double fma(double x, double y, double z)
-{
- __asm__ ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
- return x;
-}
-
-#else
-
-#include "../fma.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmaf.c
deleted file mode 100644
index 30b971ff97..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmaf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-
-#if __FMA__
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("vfmadd132ss %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
- return x;
-}
-
-#elif __FMA4__
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("vfmaddss %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
- return x;
-}
-
-#else
-
-#include "../fmaf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmodl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmodl.s
deleted file mode 100644
index c3f790c9bf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/fmodl.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.global fmodl
-.type fmodl,@function
-fmodl:
- fldt 24(%esp)
- fldt 8(%esp)
-1: fprem
- fnstsw %ax
- testb $4,%ah
- jnz 1b
- fstp %st(1)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrint.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrint.s
deleted file mode 100644
index bf47649831..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrint.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.global llrint
-.type llrint,@function
-llrint:
- cvtsd2si %xmm0,%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintf.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintf.s
deleted file mode 100644
index d7204ac0ca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintf.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.global llrintf
-.type llrintf,@function
-llrintf:
- cvtss2si %xmm0,%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintl.s
deleted file mode 100644
index 09386079e2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/llrintl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global llrintl
-.type llrintl,@function
-llrintl:
- fldt 8(%esp)
- fistpll 8(%esp)
- mov 8(%esp),%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log10l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/log10l.s
deleted file mode 100644
index ef5bea3fb6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log10l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log10l
-.type log10l,@function
-log10l:
- fldlg2
- fldt 8(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log1pl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/log1pl.s
deleted file mode 100644
index 2e64fd4bcb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log1pl.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.global log1pl
-.type log1pl,@function
-log1pl:
- mov 14(%esp),%eax
- fldln2
- and $0x7fffffff,%eax
- fldt 8(%esp)
- cmp $0x3ffd9400,%eax
- ja 1f
- fyl2xp1
- ret
-1: fld1
- faddp
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/log2l.s
deleted file mode 100644
index bf88e8e246..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/log2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log2l
-.type log2l,@function
-log2l:
- fld1
- fldt 8(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/logl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/logl.s
deleted file mode 100644
index eff6450688..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/logl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global logl
-.type logl,@function
-logl:
- fldln2
- fldt 8(%esp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrint.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrint.s
deleted file mode 100644
index 15fc2454bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrint.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.global lrint
-.type lrint,@function
-lrint:
- cvtsd2si %xmm0,%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintf.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintf.s
deleted file mode 100644
index 488423d217..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintf.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.global lrintf
-.type lrintf,@function
-lrintf:
- cvtss2si %xmm0,%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintl.s
deleted file mode 100644
index d4355c327c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/lrintl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global lrintl
-.type lrintl,@function
-lrintl:
- fldt 8(%esp)
- fistpl 8(%esp)
- movl 8(%esp),%eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/remainderl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/remainderl.s
deleted file mode 100644
index 376ba0e2d6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/remainderl.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.global remainderl
-.type remainderl,@function
-remainderl:
- fldt 24(%esp)
- fldt 8(%esp)
-1: fprem1
- fnstsw %ax
- testb $4,%ah
- jnz 1b
- fstp %st(1)
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/rintl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/rintl.s
deleted file mode 100644
index be1d2fa735..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/rintl.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global rintl
-.type rintl,@function
-rintl:
- fldt 8(%esp)
- frndint
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrt.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrt.s
deleted file mode 100644
index d3c609f9f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrt.s
+++ /dev/null
@@ -1,4 +0,0 @@
-.global sqrt
-.type sqrt,@function
-sqrt: sqrtsd %xmm0, %xmm0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtf.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtf.s
deleted file mode 100644
index eec48c6094..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtf.s
+++ /dev/null
@@ -1,4 +0,0 @@
-.global sqrtf
-.type sqrtf,@function
-sqrtf: sqrtss %xmm0, %xmm0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtl.s
deleted file mode 100644
index 8d70856ec0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/sqrtl.s
+++ /dev/null
@@ -1,5 +0,0 @@
-.global sqrtl
-.type sqrtl,@function
-sqrtl: fldt 8(%esp)
- fsqrt
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x32/truncl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x32/truncl.s
deleted file mode 100644
index f5cfa3b307..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x32/truncl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floorl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/__invtrigl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/__invtrigl.s
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/__invtrigl.s
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/acosl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/acosl.s
deleted file mode 100644
index 88e01b49a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/acosl.s
+++ /dev/null
@@ -1,16 +0,0 @@
-# see ../i386/acos.s
-
-.global acosl
-.type acosl,@function
-acosl:
- fldt 8(%rsp)
-1: fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fabs
- fxch %st(1)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/asinl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/asinl.s
deleted file mode 100644
index ed212d9a6c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/asinl.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.global asinl
-.type asinl,@function
-asinl:
- fldt 8(%rsp)
-1: fld %st(0)
- fld1
- fsub %st(0),%st(1)
- fadd %st(2)
- fmulp
- fsqrt
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atan2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atan2l.s
deleted file mode 100644
index e5f0a3deb3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atan2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atan2l
-.type atan2l,@function
-atan2l:
- fldt 8(%rsp)
- fldt 24(%rsp)
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atanl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atanl.s
deleted file mode 100644
index df76de5de4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/atanl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global atanl
-.type atanl,@function
-atanl:
- fldt 8(%rsp)
- fld1
- fpatan
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/ceill.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/ceill.s
deleted file mode 100644
index f5cfa3b307..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/ceill.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floorl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/exp2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/exp2l.s
deleted file mode 100644
index effab2bd4e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/exp2l.s
+++ /dev/null
@@ -1,83 +0,0 @@
-.global expm1l
-.type expm1l,@function
-expm1l:
- fldt 8(%rsp)
- fldl2e
- fmulp
- movl $0xc2820000,-4(%rsp)
- flds -4(%rsp)
- fucomip %st(1),%st
- fld1
- jb 1f
- # x*log2e <= -65, return -1 without underflow
- fstp %st(1)
- fchs
- ret
-1: fld %st(1)
- fabs
- fucomip %st(1),%st
- fstp %st(0)
- ja 1f
- f2xm1
- ret
-1: push %rax
- call 1f
- pop %rax
- fld1
- fsubrp
- ret
-
-.global exp2l
-.type exp2l,@function
-exp2l:
- fldt 8(%rsp)
-1: fld %st(0)
- sub $16,%rsp
- fstpt (%rsp)
- mov 8(%rsp),%ax
- and $0x7fff,%ax
- cmp $0x3fff+13,%ax
- jb 4f # |x| < 8192
- cmp $0x3fff+15,%ax
- jae 3f # |x| >= 32768
- fsts (%rsp)
- cmpl $0xc67ff800,(%rsp)
- jb 2f # x > -16382
- movl $0x5f000000,(%rsp)
- flds (%rsp) # 0x1p63
- fld %st(1)
- fsub %st(1)
- faddp
- fucomip %st(1),%st
- je 2f # x - 0x1p63 + 0x1p63 == x
- movl $1,(%rsp)
- flds (%rsp) # 0x1p-149
- fdiv %st(1)
- fstps (%rsp) # raise underflow
-2: fld1
- fld %st(1)
- frndint
- fxch %st(2)
- fsub %st(2) # st(0)=x-rint(x), st(1)=1, st(2)=rint(x)
- f2xm1
- faddp # 2^(x-rint(x))
-1: fscale
- fstp %st(1)
- add $16,%rsp
- ret
-3: xor %eax,%eax
-4: cmp $0x3fff-64,%ax
- fld1
- jb 1b # |x| < 0x1p-64
- fstpt (%rsp)
- fistl 8(%rsp)
- fildl 8(%rsp)
- fsubrp %st(1)
- addl $0x3fff,8(%rsp)
- f2xm1
- fld1
- faddp # 2^(x-rint(x))
- fldt (%rsp) # 2^rint(x)
- fmulp
- add $16,%rsp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expl.s
deleted file mode 100644
index 798261d283..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expl.s
+++ /dev/null
@@ -1,101 +0,0 @@
-# exp(x) = 2^hi + 2^hi (2^lo - 1)
-# where hi+lo = log2e*x with 128bit precision
-# exact log2e*x calculation depends on nearest rounding mode
-# using the exact multiplication method of Dekker and Veltkamp
-
-.global expl
-.type expl,@function
-expl:
- fldt 8(%rsp)
-
- # interesting case: 0x1p-32 <= |x| < 16384
- # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
- mov 16(%rsp), %ax
- or $0x8000, %ax
- sub $0xbfdf, %ax
- cmp $45, %ax
- jbe 2f
- test %ax, %ax
- fld1
- js 1f
- # if |x|>=0x1p14 or nan return 2^trunc(x)
- fscale
- fstp %st(1)
- ret
- # if |x|<0x1p-32 return 1+x
-1: faddp
- ret
-
- # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
- # it will be wrong on non-nearest rounding mode
-2: fldl2e
- subq $48, %rsp
- # hi = log2e_hi*x
- # 2^hi = exp2l(hi)
- fmul %st(1),%st
- fld %st(0)
- fstpt (%rsp)
- fstpt 16(%rsp)
- fstpt 32(%rsp)
- call exp2l@PLT
- # if 2^hi == inf return 2^hi
- fld %st(0)
- fstpt (%rsp)
- cmpw $0x7fff, 8(%rsp)
- je 1f
- fldt 32(%rsp)
- fldt 16(%rsp)
- # fpu stack: 2^hi x hi
- # exact mult: x*log2e
- fld %st(1)
- # c = 0x1p32+1
- movq $0x41f0000000100000,%rax
- pushq %rax
- fldl (%rsp)
- # xh = x - c*x + c*x
- # xl = x - xh
- fmulp
- fld %st(2)
- fsub %st(1), %st
- faddp
- fld %st(2)
- fsub %st(1), %st
- # yh = log2e_hi - c*log2e_hi + c*log2e_hi
- movq $0x3ff7154765200000,%rax
- pushq %rax
- fldl (%rsp)
- # fpu stack: 2^hi x hi xh xl yh
- # lo = hi - xh*yh + xl*yh
- fld %st(2)
- fmul %st(1), %st
- fsubp %st, %st(4)
- fmul %st(1), %st
- faddp %st, %st(3)
- # yl = log2e_hi - yh
- movq $0x3de705fc2f000000,%rax
- pushq %rax
- fldl (%rsp)
- # fpu stack: 2^hi x lo xh xl yl
- # lo += xh*yl + xl*yl
- fmul %st, %st(2)
- fmulp %st, %st(1)
- fxch %st(2)
- faddp
- faddp
- # log2e_lo
- movq $0xbfbe,%rax
- pushq %rax
- movq $0x82f0025f2dc582ee,%rax
- pushq %rax
- fldt (%rsp)
- addq $40,%rsp
- # fpu stack: 2^hi x lo log2e_lo
- # lo += log2e_lo*x
- # return 2^hi + 2^hi (2^lo - 1)
- fmulp %st, %st(2)
- faddp
- f2xm1
- fmul %st(1), %st
- faddp
-1: addq $48, %rsp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expm1l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expm1l.s
deleted file mode 100644
index e773f08053..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/expm1l.s
+++ /dev/null
@@ -1 +0,0 @@
-# see exp2l.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabs.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabs.c
deleted file mode 100644
index 1656247770..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabs.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-double fabs(double x)
-{
- double t;
- __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0
- __asm__ ("psrlq $1, %0" : "+x"(t)); // t >>= 1
- __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsf.c
deleted file mode 100644
index 36ea7481fc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsf.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <math.h>
-
-float fabsf(float x)
-{
- float t;
- __asm__ ("pcmpeqd %0, %0" : "=x"(t)); // t = ~0
- __asm__ ("psrld $1, %0" : "+x"(t)); // t >>= 1
- __asm__ ("andps %1, %0" : "+x"(x) : "x"(t)); // x &= t
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsl.c
deleted file mode 100644
index cc1c9ed9c7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fabsl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double fabsl(long double x)
-{
- __asm__ ("fabs" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/floorl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/floorl.s
deleted file mode 100644
index 80da466095..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/floorl.s
+++ /dev/null
@@ -1,27 +0,0 @@
-.global floorl
-.type floorl,@function
-floorl:
- fldt 8(%rsp)
-1: mov $0x7,%al
-1: fstcw 8(%rsp)
- mov 9(%rsp),%ah
- mov %al,9(%rsp)
- fldcw 8(%rsp)
- frndint
- mov %ah,9(%rsp)
- fldcw 8(%rsp)
- ret
-
-.global ceill
-.type ceill,@function
-ceill:
- fldt 8(%rsp)
- mov $0xb,%al
- jmp 1b
-
-.global truncl
-.type truncl,@function
-truncl:
- fldt 8(%rsp)
- mov $0xf,%al
- jmp 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fma.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fma.c
deleted file mode 100644
index 4dd53f2ac8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fma.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-
-#if __FMA__
-
-double fma(double x, double y, double z)
-{
- __asm__ ("vfmadd132sd %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
- return x;
-}
-
-#elif __FMA4__
-
-double fma(double x, double y, double z)
-{
- __asm__ ("vfmaddsd %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
- return x;
-}
-
-#else
-
-#include "../fma.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmaf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmaf.c
deleted file mode 100644
index 30b971ff97..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmaf.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <math.h>
-
-#if __FMA__
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("vfmadd132ss %1, %2, %0" : "+x" (x) : "x" (y), "x" (z));
- return x;
-}
-
-#elif __FMA4__
-
-float fmaf(float x, float y, float z)
-{
- __asm__ ("vfmaddss %3, %2, %1, %0" : "=x" (x) : "x" (x), "x" (y), "x" (z));
- return x;
-}
-
-#else
-
-#include "../fmaf.c"
-
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmodl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmodl.c
deleted file mode 100644
index 3daeab0600..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/fmodl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-long double fmodl(long double x, long double y)
-{
- unsigned short fpsr;
- do __asm__ ("fprem; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrint.c
deleted file mode 100644
index dd38a7223a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrint.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrint(double x)
-{
- long long r;
- __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x));
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintf.c
deleted file mode 100644
index fc8625e88c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrintf(float x)
-{
- long long r;
- __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintl.c
deleted file mode 100644
index c439ef28d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/llrintl.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long long llrintl(long double x)
-{
- long long r;
- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log10l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log10l.s
deleted file mode 100644
index 48ea4af727..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log10l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log10l
-.type log10l,@function
-log10l:
- fldlg2
- fldt 8(%rsp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log1pl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log1pl.s
deleted file mode 100644
index 955c9dbff0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log1pl.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.global log1pl
-.type log1pl,@function
-log1pl:
- mov 14(%rsp),%eax
- fldln2
- and $0x7fffffff,%eax
- fldt 8(%rsp)
- cmp $0x3ffd9400,%eax
- ja 1f
- fyl2xp1
- ret
-1: fld1
- faddp
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log2l.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log2l.s
deleted file mode 100644
index ba08b9fb65..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/log2l.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global log2l
-.type log2l,@function
-log2l:
- fld1
- fldt 8(%rsp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/logl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/logl.s
deleted file mode 100644
index 20dd1f819b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/logl.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global logl
-.type logl,@function
-logl:
- fldln2
- fldt 8(%rsp)
- fyl2x
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrint.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrint.c
deleted file mode 100644
index a742fec64c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrint.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrint(double x)
-{
- long r;
- __asm__ ("cvtsd2si %1, %0" : "=r"(r) : "x"(x));
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintf.c
deleted file mode 100644
index 2ba5639dc2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintf.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrintf(float x)
-{
- long r;
- __asm__ ("cvtss2si %1, %0" : "=r"(r) : "x"(x));
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintl.c
deleted file mode 100644
index 068e2e4d62..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/lrintl.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <math.h>
-
-long lrintl(long double x)
-{
- long r;
- __asm__ ("fistpll %0" : "=m"(r) : "t"(x) : "st");
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remainderl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remainderl.c
deleted file mode 100644
index 8cf75071ed..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remainderl.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <math.h>
-
-long double remainderl(long double x, long double y)
-{
- unsigned short fpsr;
- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(x), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remquol.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remquol.c
deleted file mode 100644
index 60eef089f3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/remquol.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <math.h>
-
-long double remquol(long double x, long double y, int *quo)
-{
- signed char *cx = (void *)&x, *cy = (void *)&y;
- /* By ensuring that addresses of x and y cannot be discarded,
- * this empty asm guides GCC into representing extraction of
- * their sign bits as memory loads rather than making x and y
- * not-address-taken internally and using bitfield operations,
- * which in the end wouldn't work out, as extraction from FPU
- * registers needs to go through memory anyway. This way GCC
- * should manage to use incoming stack slots without spills. */
- __asm__ ("" :: "X"(cx), "X"(cy));
-
- long double t = x;
- unsigned fpsr;
- do __asm__ ("fprem1; fnstsw %%ax" : "+t"(t), "=a"(fpsr) : "u"(y));
- while (fpsr & 0x400);
- /* C0, C1, C3 flags in x87 status word carry low bits of quotient:
- * 15 14 13 12 11 10 9 8
- * . C3 . . . C2 C1 C0
- * . b1 . . . 0 b0 b2 */
- unsigned char i = fpsr >> 8;
- i = i>>4 | i<<4;
- /* i[5:2] is now {b0 b2 ? b1}. Retrieve {0 b2 b1 b0} via
- * in-register table lookup. */
- unsigned qbits = 0x7575313164642020 >> (i & 60);
- qbits &= 7;
-
- *quo = (cx[9]^cy[9]) < 0 ? -qbits : qbits;
- return t;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/rintl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/rintl.c
deleted file mode 100644
index e1a92077f5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/rintl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double rintl(long double x)
-{
- __asm__ ("frndint" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrt.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrt.c
deleted file mode 100644
index 657e09e3b4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrt.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-double sqrt(double x)
-{
- __asm__ ("sqrtsd %1, %0" : "=x"(x) : "x"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtf.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtf.c
deleted file mode 100644
index 720baec601..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtf.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-float sqrtf(float x)
-{
- __asm__ ("sqrtss %1, %0" : "=x"(x) : "x"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtl.c b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtl.c
deleted file mode 100644
index 864cfcc4f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/sqrtl.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <math.h>
-
-long double sqrtl(long double x)
-{
- __asm__ ("fsqrt" : "+t"(x));
- return x;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/truncl.s b/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/truncl.s
deleted file mode 100644
index f5cfa3b307..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/math/x86_64/truncl.s
+++ /dev/null
@@ -1 +0,0 @@
-# see floorl.s
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/forkpty.c b/lib/libc/wasi/libc-top-half/musl/src/misc/forkpty.c
deleted file mode 100644
index caf13adbf3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/forkpty.c
+++ /dev/null
@@ -1,57 +0,0 @@
-#include <pty.h>
-#include <utmp.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <pthread.h>
-
-int forkpty(int *pm, char *name, const struct termios *tio, const struct winsize *ws)
-{
- int m, s, ec=0, p[2], cs;
- pid_t pid=-1;
- sigset_t set, oldset;
-
- if (openpty(&m, &s, name, tio, ws) < 0) return -1;
-
- sigfillset(&set);
- pthread_sigmask(SIG_BLOCK, &set, &oldset);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- if (pipe2(p, O_CLOEXEC)) {
- close(s);
- goto out;
- }
-
- pid = fork();
- if (!pid) {
- close(m);
- close(p[0]);
- if (login_tty(s)) {
- write(p[1], &errno, sizeof errno);
- _exit(127);
- }
- close(p[1]);
- pthread_setcancelstate(cs, 0);
- pthread_sigmask(SIG_SETMASK, &oldset, 0);
- return 0;
- }
- close(s);
- close(p[1]);
- if (read(p[0], &ec, sizeof ec) > 0) {
- int status;
- waitpid(pid, &status, 0);
- pid = -1;
- errno = ec;
- }
- close(p[0]);
-
-out:
- if (pid > 0) *pm = m;
- else close(m);
-
- pthread_setcancelstate(cs, 0);
- pthread_sigmask(SIG_SETMASK, &oldset, 0);
-
- return pid;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/get_current_dir_name.c b/lib/libc/wasi/libc-top-half/musl/src/misc/get_current_dir_name.c
deleted file mode 100644
index 782cddcd82..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/get_current_dir_name.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <unistd.h>
-#include <sys/stat.h>
-
-char *get_current_dir_name(void) {
- struct stat a, b;
- char *res = getenv("PWD");
- if (res && *res && !stat(res, &a) && !stat(".", &b)
- && (a.st_dev == b.st_dev) && (a.st_ino == b.st_ino))
- return strdup(res);
- return getcwd(0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getauxval.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getauxval.c
deleted file mode 100644
index 57f21eed9e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getauxval.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <sys/auxv.h>
-#include <errno.h>
-#include "libc.h"
-
-unsigned long __getauxval(unsigned long item)
-{
- size_t *auxv = libc.auxv;
- if (item == AT_SECURE) return libc.secure;
- for (; *auxv; auxv+=2)
- if (*auxv==item) return auxv[1];
- errno = ENOENT;
- return 0;
-}
-
-weak_alias(__getauxval, getauxval);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getentropy.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getentropy.c
deleted file mode 100644
index 651ea95f14..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getentropy.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include <sys/random.h>
-#include <pthread.h>
-#include <errno.h>
-
-int getentropy(void *buffer, size_t len)
-{
- int cs, ret = 0;
- char *pos = buffer;
-
- if (len > 256) {
- errno = EIO;
- return -1;
- }
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- while (len) {
- ret = getrandom(pos, len, 0);
- if (ret < 0) {
- if (errno == EINTR) continue;
- else break;
- }
- pos += ret;
- len -= ret;
- ret = 0;
- }
-
- pthread_setcancelstate(cs, 0);
-
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getpriority.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getpriority.c
deleted file mode 100644
index 5c0b1682b6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getpriority.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/resource.h>
-#include "syscall.h"
-
-int getpriority(int which, id_t who)
-{
- int ret = syscall(SYS_getpriority, which, who);
- if (ret < 0) return ret;
- return 20-ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getresgid.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getresgid.c
deleted file mode 100644
index d00d9a99d3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getresgid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
-{
- return syscall(SYS_getresgid, rgid, egid, sgid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getresuid.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getresuid.c
deleted file mode 100644
index d75d5d4086..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getresuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
-{
- return syscall(SYS_getresuid, ruid, euid, suid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getrlimit.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getrlimit.c
deleted file mode 100644
index 2ab2f0f4fa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getrlimit.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <sys/resource.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
-
-int getrlimit(int resource, struct rlimit *rlim)
-{
- unsigned long k_rlim[2];
- int ret = syscall(SYS_prlimit64, 0, resource, 0, rlim);
- if (!ret) {
- FIX(rlim->rlim_cur);
- FIX(rlim->rlim_max);
- }
- if (!ret || errno != ENOSYS)
- return ret;
- if (syscall(SYS_getrlimit, resource, k_rlim) < 0)
- return -1;
- rlim->rlim_cur = k_rlim[0] == -1UL ? RLIM_INFINITY : k_rlim[0];
- rlim->rlim_max = k_rlim[1] == -1UL ? RLIM_INFINITY : k_rlim[1];
- FIX(rlim->rlim_cur);
- FIX(rlim->rlim_max);
- return 0;
-}
-
-weak_alias(getrlimit, getrlimit64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/getrusage.c b/lib/libc/wasi/libc-top-half/musl/src/misc/getrusage.c
deleted file mode 100644
index 8e03e2e3db..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/getrusage.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <sys/resource.h>
-#include <string.h>
-#include <errno.h>
-#include "syscall.h"
-
-int getrusage(int who, struct rusage *ru)
-{
- int r;
-#ifdef SYS_getrusage_time64
- long long kru64[18];
- r = __syscall(SYS_getrusage_time64, who, kru64);
- if (!r) {
- ru->ru_utime = (struct timeval)
- { .tv_sec = kru64[0], .tv_usec = kru64[1] };
- ru->ru_stime = (struct timeval)
- { .tv_sec = kru64[2], .tv_usec = kru64[3] };
- char *slots = (char *)&ru->ru_maxrss;
- for (int i=0; i<14; i++)
- *(long *)(slots + i*sizeof(long)) = kru64[4+i];
- }
- if (SYS_getrusage_time64 == SYS_getrusage || r != -ENOSYS)
- return __syscall_ret(r);
-#endif
- char *dest = (char *)&ru->ru_maxrss - 4*sizeof(long);
- r = __syscall(SYS_getrusage, who, dest);
- if (!r && sizeof(time_t) > sizeof(long)) {
- long kru[4];
- memcpy(kru, dest, 4*sizeof(long));
- ru->ru_utime = (struct timeval)
- { .tv_sec = kru[0], .tv_usec = kru[1] };
- ru->ru_stime = (struct timeval)
- { .tv_sec = kru[2], .tv_usec = kru[3] };
- }
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/initgroups.c b/lib/libc/wasi/libc-top-half/musl/src/misc/initgroups.c
deleted file mode 100644
index 922a958142..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/initgroups.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _GNU_SOURCE
-#include <grp.h>
-#include <limits.h>
-
-int initgroups(const char *user, gid_t gid)
-{
- gid_t groups[NGROUPS_MAX];
- int count = NGROUPS_MAX;
- if (getgrouplist(user, gid, groups, &count) < 0) return -1;
- return setgroups(count, groups);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/ioctl.c b/lib/libc/wasi/libc-top-half/musl/src/misc/ioctl.c
deleted file mode 100644
index 35804f026e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/ioctl.c
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <sys/ioctl.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/time.h>
-#include <stddef.h>
-#include <stdint.h>
-#include <string.h>
-#include <endian.h>
-#include "syscall.h"
-
-#define alignof(t) offsetof(struct { char c; t x; }, x)
-
-#define W 1
-#define R 2
-#define WR 3
-
-struct ioctl_compat_map {
- int new_req, old_req;
- unsigned char old_size, dir, force_align, noffs;
- unsigned char offsets[8];
-};
-
-#define NINTH(a,b,c,d,e,f,g,h,i,...) i
-#define COUNT(...) NINTH(__VA_ARGS__,8,7,6,5,4,3,2,1,0)
-#define OFFS(...) COUNT(__VA_ARGS__), { __VA_ARGS__ }
-
-/* yields a type for a struct with original size n, with a misaligned
- * timeval/timespec expanded from 32- to 64-bit. for use with ioctl
- * number producing macros; only size of result is meaningful. */
-#define new_misaligned(n) struct { int i; time_t t; char c[(n)-4]; }
-
-struct v4l2_event {
- uint32_t a;
- uint64_t b[8];
- uint32_t c[2], ts[2], d[9];
-};
-
-static const struct ioctl_compat_map compat_map[] = {
- { SIOCGSTAMP, SIOCGSTAMP_OLD, 8, R, 0, OFFS(0, 4) },
- { SIOCGSTAMPNS, SIOCGSTAMPNS_OLD, 8, R, 0, OFFS(0, 4) },
-
- /* SNDRV_TIMER_IOCTL_STATUS */
- { _IOR('T', 0x14, char[96]), _IOR('T', 0x14, 88), 88, R, 0, OFFS(0,4) },
-
- /* SNDRV_PCM_IOCTL_STATUS[_EXT] */
- { _IOR('A', 0x20, char[128]), _IOR('A', 0x20, char[108]), 108, R, 1, OFFS(4,8,12,16,52,56,60,64) },
- { _IOWR('A', 0x24, char[128]), _IOWR('A', 0x24, char[108]), 108, WR, 1, OFFS(4,8,12,16,52,56,60,64) },
-
- /* SNDRV_RAWMIDI_IOCTL_STATUS */
- { _IOWR('W', 0x20, char[48]), _IOWR('W', 0x20, char[36]), 36, WR, 1, OFFS(4,8) },
-
- /* SNDRV_PCM_IOCTL_SYNC_PTR - with 3 subtables */
- { _IOWR('A', 0x23, char[136]), _IOWR('A', 0x23, char[132]), 0, WR, 1, 0 },
- { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_sync_ptr (flags only) */
- { 0, 0, 32, WR, 1, OFFS(8,12,16,24,28) }, /* snd_pcm_mmap_status */
- { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_mmap_control (each member) */
-
- /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */
- { _IOWR('V', 9, new_misaligned(68)), _IOWR('V', 9, char[68]), 68, WR, 1, OFFS(20, 24) },
- { _IOWR('V', 15, new_misaligned(68)), _IOWR('V', 15, char[68]), 68, WR, 1, OFFS(20, 24) },
- { _IOWR('V', 17, new_misaligned(68)), _IOWR('V', 17, char[68]), 68, WR, 1, OFFS(20, 24) },
- { _IOWR('V', 93, new_misaligned(68)), _IOWR('V', 93, char[68]), 68, WR, 1, OFFS(20, 24) },
-
- /* VIDIOC_DQEVENT */
- { _IOR('V', 89, new_misaligned(120)), _IOR('V', 89, struct v4l2_event), sizeof(struct v4l2_event),
- R, 0, OFFS(offsetof(struct v4l2_event, ts[0]), offsetof(struct v4l2_event, ts[1])) },
-
- /* VIDIOC_OMAP3ISP_STAT_REQ */
- { _IOWR('V', 192+6, char[32]), _IOWR('V', 192+6, char[24]), 22, WR, 0, OFFS(0,4) },
-
- /* PPPIOCGIDLE */
- { _IOR('t', 63, char[16]), _IOR('t', 63, char[8]), 8, R, 0, OFFS(0,4) },
-
- /* PPGETTIME, PPSETTIME */
- { _IOR('p', 0x95, char[16]), _IOR('p', 0x95, char[8]), 8, R, 0, OFFS(0,4) },
- { _IOW('p', 0x96, char[16]), _IOW('p', 0x96, char[8]), 8, W, 0, OFFS(0,4) },
-
- /* LPSETTIMEOUT */
- { _IOW(0x6, 0xf, char[16]), 0x060f, 8, W, 0, OFFS(0,4) },
-};
-
-static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old, char *new, int dir)
-{
- int new_offset = 0;
- int old_offset = 0;
- int old_size = map->old_size;
- if (!(dir & map->dir)) return;
- if (!map->old_size) {
- /* offsets hard-coded for SNDRV_PCM_IOCTL_SYNC_PTR;
- * if another exception appears this needs changing. */
- convert_ioctl_struct(map+1, old, new, dir);
- convert_ioctl_struct(map+2, old+4, new+8, dir);
- /* snd_pcm_mmap_control, special-cased due to kernel
- * type definition having been botched. */
- int adj = BYTE_ORDER==BIG_ENDIAN ? 4 : 0;
- convert_ioctl_struct(map+3, old+68, new+72+adj, dir);
- convert_ioctl_struct(map+3, old+72, new+76+3*adj, dir);
- return;
- }
- for (int i=0; i < map->noffs; i++) {
- int ts_offset = map->offsets[i];
- int len = ts_offset-old_offset;
- if (dir==W) memcpy(old+old_offset, new+new_offset, len);
- else memcpy(new+new_offset, old+old_offset, len);
- new_offset += len;
- old_offset += len;
- long long new_ts;
- long old_ts;
- int align = map->force_align ? sizeof(time_t) : alignof(time_t);
- new_offset += (align-1) & -new_offset;
- if (dir==W) {
- memcpy(&new_ts, new+new_offset, sizeof new_ts);
- old_ts = new_ts;
- memcpy(old+old_offset, &old_ts, sizeof old_ts);
- } else {
- memcpy(&old_ts, old+old_offset, sizeof old_ts);
- new_ts = old_ts;
- memcpy(new+new_offset, &new_ts, sizeof new_ts);
- }
- new_offset += sizeof new_ts;
- old_offset += sizeof old_ts;
- }
- if (dir==W) memcpy(old+old_offset, new+new_offset, old_size-old_offset);
- else memcpy(new+new_offset, old+old_offset, old_size-old_offset);
-}
-
-int ioctl(int fd, int req, ...)
-{
- void *arg;
- va_list ap;
- va_start(ap, req);
- arg = va_arg(ap, void *);
- va_end(ap);
- int r = __syscall(SYS_ioctl, fd, req, arg);
- if (SIOCGSTAMP != SIOCGSTAMP_OLD && req && r==-ENOTTY) {
- for (int i=0; i<sizeof compat_map/sizeof *compat_map; i++) {
- if (compat_map[i].new_req != req) continue;
- union {
- long long align;
- char buf[256];
- } u;
- convert_ioctl_struct(&compat_map[i], u.buf, arg, W);
- r = __syscall(SYS_ioctl, fd, compat_map[i].old_req, u.buf);
- if (r<0) break;
- convert_ioctl_struct(&compat_map[i], u.buf, arg, R);
- break;
- }
- }
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/issetugid.c b/lib/libc/wasi/libc-top-half/musl/src/misc/issetugid.c
deleted file mode 100644
index ddc2ca0e02..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/issetugid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include "libc.h"
-
-int issetugid(void)
-{
- return libc.secure;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/lockf.c b/lib/libc/wasi/libc-top-half/musl/src/misc/lockf.c
deleted file mode 100644
index 16a80bec13..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/lockf.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-int lockf(int fd, int op, off_t size)
-{
- struct flock l = {
- .l_type = F_WRLCK,
- .l_whence = SEEK_CUR,
- .l_len = size,
- };
- switch (op) {
- case F_TEST:
- l.l_type = F_RDLCK;
- if (fcntl(fd, F_GETLK, &l) < 0)
- return -1;
- if (l.l_type == F_UNLCK || l.l_pid == getpid())
- return 0;
- errno = EACCES;
- return -1;
- case F_ULOCK:
- l.l_type = F_UNLCK;
- case F_TLOCK:
- return fcntl(fd, F_SETLK, &l);
- case F_LOCK:
- return fcntl(fd, F_SETLKW, &l);
- }
- errno = EINVAL;
- return -1;
-}
-
-weak_alias(lockf, lockf64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/login_tty.c b/lib/libc/wasi/libc-top-half/musl/src/misc/login_tty.c
deleted file mode 100644
index f0be0a09a3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/login_tty.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <utmp.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-
-int login_tty(int fd)
-{
- setsid();
- if (ioctl(fd, TIOCSCTTY, (char *)0)) return -1;
- dup2(fd, 0);
- dup2(fd, 1);
- dup2(fd, 2);
- if (fd>2) close(fd);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/mntent.c b/lib/libc/wasi/libc-top-half/musl/src/misc/mntent.c
deleted file mode 100644
index eabb8200bf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/mntent.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <mntent.h>
-#include <errno.h>
-
-static char *internal_buf;
-static size_t internal_bufsize;
-
-#define SENTINEL (char *)&internal_buf
-
-FILE *setmntent(const char *name, const char *mode)
-{
- return fopen(name, mode);
-}
-
-int endmntent(FILE *f)
-{
- if (f) fclose(f);
- return 1;
-}
-
-struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int buflen)
-{
- int cnt, n[8], use_internal = (linebuf == SENTINEL);
-
- mnt->mnt_freq = 0;
- mnt->mnt_passno = 0;
-
- do {
- if (use_internal) {
- getline(&internal_buf, &internal_bufsize, f);
- linebuf = internal_buf;
- } else {
- fgets(linebuf, buflen, f);
- }
- if (feof(f) || ferror(f)) return 0;
- if (!strchr(linebuf, '\n')) {
- fscanf(f, "%*[^\n]%*[\n]");
- errno = ERANGE;
- return 0;
- }
- cnt = sscanf(linebuf, " %n%*s%n %n%*s%n %n%*s%n %n%*s%n %d %d",
- n, n+1, n+2, n+3, n+4, n+5, n+6, n+7,
- &mnt->mnt_freq, &mnt->mnt_passno);
- } while (cnt < 2 || linebuf[n[0]] == '#');
-
- linebuf[n[1]] = 0;
- linebuf[n[3]] = 0;
- linebuf[n[5]] = 0;
- linebuf[n[7]] = 0;
-
- mnt->mnt_fsname = linebuf+n[0];
- mnt->mnt_dir = linebuf+n[2];
- mnt->mnt_type = linebuf+n[4];
- mnt->mnt_opts = linebuf+n[6];
-
- return mnt;
-}
-
-struct mntent *getmntent(FILE *f)
-{
- static struct mntent mnt;
- return getmntent_r(f, &mnt, SENTINEL, 0);
-}
-
-int addmntent(FILE *f, const struct mntent *mnt)
-{
- if (fseek(f, 0, SEEK_END)) return 1;
- return fprintf(f, "%s\t%s\t%s\t%s\t%d\t%d\n",
- mnt->mnt_fsname, mnt->mnt_dir, mnt->mnt_type, mnt->mnt_opts,
- mnt->mnt_freq, mnt->mnt_passno) < 0;
-}
-
-char *hasmntopt(const struct mntent *mnt, const char *opt)
-{
- return strstr(mnt->mnt_opts, opt);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/openpty.c b/lib/libc/wasi/libc-top-half/musl/src/misc/openpty.c
deleted file mode 100644
index c107406061..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/openpty.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pty.h>
-#include <stdio.h>
-#include <pthread.h>
-
-/* Nonstandard, but vastly superior to the standard functions */
-
-int openpty(int *pm, int *ps, char *name, const struct termios *tio, const struct winsize *ws)
-{
- int m, s, n=0, cs;
- char buf[20];
-
- m = open("/dev/ptmx", O_RDWR|O_NOCTTY);
- if (m < 0) return -1;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- if (ioctl(m, TIOCSPTLCK, &n) || ioctl (m, TIOCGPTN, &n))
- goto fail;
-
- if (!name) name = buf;
- snprintf(name, sizeof buf, "/dev/pts/%d", n);
- if ((s = open(name, O_RDWR|O_NOCTTY)) < 0)
- goto fail;
-
- if (tio) tcsetattr(s, TCSANOW, tio);
- if (ws) ioctl(s, TIOCSWINSZ, ws);
-
- *pm = m;
- *ps = s;
-
- pthread_setcancelstate(cs, 0);
- return 0;
-fail:
- close(m);
- pthread_setcancelstate(cs, 0);
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/ptsname.c b/lib/libc/wasi/libc-top-half/musl/src/misc/ptsname.c
deleted file mode 100644
index 58c151c97f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/ptsname.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <stdlib.h>
-#include <errno.h>
-
-char *ptsname(int fd)
-{
- static char buf[9 + sizeof(int)*3 + 1];
- int err = __ptsname_r(fd, buf, sizeof buf);
- if (err) {
- errno = err;
- return 0;
- }
- return buf;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/pty.c b/lib/libc/wasi/libc-top-half/musl/src/misc/pty.c
deleted file mode 100644
index a0577147a4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/pty.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-
-int posix_openpt(int flags)
-{
- int r = open("/dev/ptmx", flags);
- if (r < 0 && errno == ENOSPC) errno = EAGAIN;
- return r;
-}
-
-int grantpt(int fd)
-{
- return 0;
-}
-
-int unlockpt(int fd)
-{
- int unlock = 0;
- return ioctl(fd, TIOCSPTLCK, &unlock);
-}
-
-int __ptsname_r(int fd, char *buf, size_t len)
-{
- int pty, err;
- if (!buf) len = 0;
- if ((err = __syscall(SYS_ioctl, fd, TIOCGPTN, &pty))) return -err;
- if (snprintf(buf, len, "/dev/pts/%d", pty) >= len) return ERANGE;
- return 0;
-}
-
-weak_alias(__ptsname_r, ptsname_r);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c b/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c
deleted file mode 100644
index db8b74dc8d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/realpath.c
+++ /dev/null
@@ -1,156 +0,0 @@
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include <unistd.h>
-#include <string.h>
-
-static size_t slash_len(const char *s)
-{
- const char *s0 = s;
- while (*s == '/') s++;
- return s-s0;
-}
-
-char *realpath(const char *restrict filename, char *restrict resolved)
-{
- char stack[PATH_MAX+1];
- char output[PATH_MAX];
- size_t p, q, l, l0, cnt=0, nup=0;
- int check_dir=0;
-
- if (!filename) {
- errno = EINVAL;
- return 0;
- }
- l = strnlen(filename, sizeof stack);
- if (!l) {
- errno = ENOENT;
- return 0;
- }
- if (l >= PATH_MAX) goto toolong;
- p = sizeof stack - l - 1;
- q = 0;
- memcpy(stack+p, filename, l+1);
-
- /* Main loop. Each iteration pops the next part from stack of
- * remaining path components and consumes any slashes that follow.
- * If not a link, it's moved to output; if a link, contents are
- * pushed to the stack. */
-restart:
- for (; ; p+=slash_len(stack+p)) {
- /* If stack starts with /, the whole component is / or //
- * and the output state must be reset. */
- if (stack[p] == '/') {
- check_dir=0;
- nup=0;
- q=0;
- output[q++] = '/';
- p++;
- /* Initial // is special. */
- if (stack[p] == '/' && stack[p+1] != '/')
- output[q++] = '/';
- continue;
- }
-
- char *z = __strchrnul(stack+p, '/');
- l0 = l = z-(stack+p);
-
- if (!l && !check_dir) break;
-
- /* Skip any . component but preserve check_dir status. */
- if (l==1 && stack[p]=='.') {
- p += l;
- continue;
- }
-
- /* Copy next component onto output at least temporarily, to
- * call readlink, but wait to advance output position until
- * determining it's not a link. */
- if (q && output[q-1] != '/') {
- if (!p) goto toolong;
- stack[--p] = '/';
- l++;
- }
- if (q+l >= PATH_MAX) goto toolong;
- memcpy(output+q, stack+p, l);
- output[q+l] = 0;
- p += l;
-
- int up = 0;
- if (l0==2 && stack[p-2]=='.' && stack[p-1]=='.') {
- up = 1;
- /* Any non-.. path components we could cancel start
- * after nup repetitions of the 3-byte string "../";
- * if there are none, accumulate .. components to
- * later apply to cwd, if needed. */
- if (q <= 3*nup) {
- nup++;
- q += l;
- continue;
- }
- /* When previous components are already known to be
- * directories, processing .. can skip readlink. */
- if (!check_dir) goto skip_readlink;
- }
- ssize_t k = readlink(output, stack, p);
- if (k==p) goto toolong;
- if (!k) {
- errno = ENOENT;
- return 0;
- }
- if (k<0) {
- if (errno != EINVAL) return 0;
-skip_readlink:
- check_dir = 0;
- if (up) {
- while(q && output[q-1]!='/') q--;
- if (q>1 && (q>2 || output[0]!='/')) q--;
- continue;
- }
- if (l0) q += l;
- check_dir = stack[p];
- continue;
- }
- if (++cnt == SYMLOOP_MAX) {
- errno = ELOOP;
- return 0;
- }
-
- /* If link contents end in /, strip any slashes already on
- * stack to avoid /->// or //->/// or spurious toolong. */
- if (stack[k-1]=='/') while (stack[p]=='/') p++;
- p -= k;
- memmove(stack+p, stack, k);
-
- /* Skip the stack advancement in case we have a new
- * absolute base path. */
- goto restart;
- }
-
- output[q] = 0;
-
- if (output[0] != '/') {
- if (!getcwd(stack, sizeof stack)) return 0;
- l = strlen(stack);
- /* Cancel any initial .. components. */
- p = 0;
- while (nup--) {
- while(l>1 && stack[l-1]!='/') l--;
- if (l>1) l--;
- p += 2;
- if (p<q) p++;
- }
- if (q-p && stack[l-1]!='/') stack[l++] = '/';
- if (l + (q-p) + 1 >= PATH_MAX) goto toolong;
- memmove(output + l, output + p, q - p + 1);
- memcpy(output, stack, l);
- q = l + q-p;
- }
-
- if (resolved) return memcpy(resolved, output, q+1);
- else return strdup(output);
-
-toolong:
- errno = ENAMETOOLONG;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/setdomainname.c b/lib/libc/wasi/libc-top-half/musl/src/misc/setdomainname.c
deleted file mode 100644
index 22d3f74639..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/setdomainname.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int setdomainname(const char *name, size_t len)
-{
- return syscall(SYS_setdomainname, name, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/setpriority.c b/lib/libc/wasi/libc-top-half/musl/src/misc/setpriority.c
deleted file mode 100644
index 3098cdf4d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/setpriority.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/resource.h>
-#include "syscall.h"
-
-int setpriority(int which, id_t who, int prio)
-{
- return syscall(SYS_setpriority, which, who, prio);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/setrlimit.c b/lib/libc/wasi/libc-top-half/musl/src/misc/setrlimit.c
deleted file mode 100644
index 8340aee096..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/setrlimit.c
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <sys/resource.h>
-#include <errno.h>
-#include "syscall.h"
-#include "libc.h"
-
-#define MIN(a, b) ((a)<(b) ? (a) : (b))
-#define FIX(x) do{ if ((x)>=SYSCALL_RLIM_INFINITY) (x)=RLIM_INFINITY; }while(0)
-
-struct ctx {
- unsigned long lim[2];
- int res;
- int err;
-};
-
-static void do_setrlimit(void *p)
-{
- struct ctx *c = p;
- if (c->err>0) return;
- c->err = -__syscall(SYS_setrlimit, c->res, c->lim);
-}
-
-int setrlimit(int resource, const struct rlimit *rlim)
-{
- struct rlimit tmp;
- if (SYSCALL_RLIM_INFINITY != RLIM_INFINITY) {
- tmp = *rlim;
- FIX(tmp.rlim_cur);
- FIX(tmp.rlim_max);
- rlim = &tmp;
- }
- int ret = __syscall(SYS_prlimit64, 0, resource, rlim, 0);
- if (ret != -ENOSYS) return __syscall_ret(ret);
-
- struct ctx c = {
- .lim[0] = MIN(rlim->rlim_cur, MIN(-1UL, SYSCALL_RLIM_INFINITY)),
- .lim[1] = MIN(rlim->rlim_max, MIN(-1UL, SYSCALL_RLIM_INFINITY)),
- .res = resource, .err = -1
- };
- __synccall(do_setrlimit, &c);
- if (c.err) {
- if (c.err>0) errno = c.err;
- return -1;
- }
- return 0;
-}
-
-weak_alias(setrlimit, setrlimit64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/syscall.c b/lib/libc/wasi/libc-top-half/musl/src/misc/syscall.c
deleted file mode 100644
index 6f3ef65639..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/syscall.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#define _BSD_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-#include <stdarg.h>
-
-#undef syscall
-
-long syscall(long n, ...)
-{
- va_list ap;
- syscall_arg_t a,b,c,d,e,f;
- va_start(ap, n);
- a=va_arg(ap, syscall_arg_t);
- b=va_arg(ap, syscall_arg_t);
- c=va_arg(ap, syscall_arg_t);
- d=va_arg(ap, syscall_arg_t);
- e=va_arg(ap, syscall_arg_t);
- f=va_arg(ap, syscall_arg_t);
- va_end(ap);
- return __syscall_ret(__syscall(n,a,b,c,d,e,f));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/syslog.c b/lib/libc/wasi/libc-top-half/musl/src/misc/syslog.c
deleted file mode 100644
index b802acd9e2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/syslog.c
+++ /dev/null
@@ -1,162 +0,0 @@
-#include <stdarg.h>
-#include <sys/socket.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <time.h>
-#include <signal.h>
-#include <string.h>
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
-#include <pthread.h>
-#endif
-#include <errno.h>
-#include <fcntl.h>
-#include "lock.h"
-#include "fork_impl.h"
-
-static volatile int lock[1];
-static char log_ident[32];
-static int log_opt;
-static int log_facility = LOG_USER;
-static int log_mask = 0xff;
-static int log_fd = -1;
-volatile int *const __syslog_lockptr = lock;
-
-int setlogmask(int maskpri)
-{
- LOCK(lock);
- int ret = log_mask;
- if (maskpri) log_mask = maskpri;
- UNLOCK(lock);
- return ret;
-}
-
-static const struct {
- short sun_family;
- char sun_path[9];
-} log_addr = {
- AF_UNIX,
- "/dev/log"
-};
-
-void closelog(void)
-{
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-#endif
- LOCK(lock);
- close(log_fd);
- log_fd = -1;
- UNLOCK(lock);
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- pthread_setcancelstate(cs, 0);
-#endif
-}
-
-static void __openlog()
-{
- log_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
- if (log_fd >= 0) connect(log_fd, (void *)&log_addr, sizeof log_addr);
-}
-
-void openlog(const char *ident, int opt, int facility)
-{
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-#endif
- LOCK(lock);
-
- if (ident) {
- size_t n = strnlen(ident, sizeof log_ident - 1);
- memcpy(log_ident, ident, n);
- log_ident[n] = 0;
- } else {
- log_ident[0] = 0;
- }
- log_opt = opt;
- log_facility = facility;
-
- if ((opt & LOG_NDELAY) && log_fd<0) __openlog();
-
- UNLOCK(lock);
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- pthread_setcancelstate(cs, 0);
-#endif
-}
-
-static int is_lost_conn(int e)
-{
- return e==ECONNREFUSED || e==ECONNRESET || e==ENOTCONN || e==EPIPE;
-}
-
-static void _vsyslog(int priority, const char *message, va_list ap)
-{
- char timebuf[16];
- time_t now;
- struct tm tm;
- char buf[1024];
- int errno_save = errno;
- int pid;
- int l, l2;
- int hlen;
- int fd;
-
- if (log_fd < 0) __openlog();
-
- if (!(priority & LOG_FACMASK)) priority |= log_facility;
-
- now = time(NULL);
- gmtime_r(&now, &tm);
- strftime(timebuf, sizeof timebuf, "%b %e %T", &tm);
-
- pid = (log_opt & LOG_PID) ? getpid() : 0;
- l = snprintf(buf, sizeof buf, "<%d>%s %n%s%s%.0d%s: ",
- priority, timebuf, &hlen, log_ident, "["+!pid, pid, "]"+!pid);
- errno = errno_save;
- l2 = vsnprintf(buf+l, sizeof buf - l, message, ap);
- if (l2 >= 0) {
- if (l2 >= sizeof buf - l) l = sizeof buf - 1;
- else l += l2;
- if (buf[l-1] != '\n') buf[l++] = '\n';
- if (send(log_fd, buf, l, 0) < 0 && (!is_lost_conn(errno)
- || connect(log_fd, (void *)&log_addr, sizeof log_addr) < 0
- || send(log_fd, buf, l, 0) < 0)
- && (log_opt & LOG_CONS)) {
- fd = open("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC);
- if (fd >= 0) {
- dprintf(fd, "%.*s", l-hlen, buf+hlen);
- close(fd);
- }
- }
- if (log_opt & LOG_PERROR) dprintf(2, "%.*s", l-hlen, buf+hlen);
- }
-}
-
-static void __vsyslog(int priority, const char *message, va_list ap)
-{
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- int cs;
-#endif
- if (!(log_mask & LOG_MASK(priority&7)) || (priority&~0x3ff)) return;
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-#endif
- LOCK(lock);
- _vsyslog(priority, message, ap);
- UNLOCK(lock);
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- pthread_setcancelstate(cs, 0);
-#endif
-}
-
-void syslog(int priority, const char *message, ...)
-{
- va_list ap;
- va_start(ap, message);
- __vsyslog(priority, message, ap);
- va_end(ap);
-}
-
-weak_alias(__vsyslog, vsyslog);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/misc/wordexp.c b/lib/libc/wasi/libc-top-half/musl/src/misc/wordexp.c
deleted file mode 100644
index db83a69f37..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/misc/wordexp.c
+++ /dev/null
@@ -1,187 +0,0 @@
-#include <wordexp.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <signal.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "pthread_impl.h"
-
-static void reap(pid_t pid)
-{
- int status;
- while (waitpid(pid, &status, 0) < 0 && errno == EINTR);
-}
-
-static char *getword(FILE *f)
-{
- char *s = 0;
- return getdelim(&s, (size_t [1]){0}, 0, f) < 0 ? 0 : s;
-}
-
-static int do_wordexp(const char *s, wordexp_t *we, int flags)
-{
- size_t i, l;
- int sq=0, dq=0;
- size_t np=0;
- char *w, **tmp;
- char *redir = (flags & WRDE_SHOWERR) ? "" : "2>/dev/null";
- int err = 0;
- FILE *f;
- size_t wc = 0;
- char **wv = 0;
- int p[2];
- pid_t pid;
- sigset_t set;
-
- if (flags & WRDE_REUSE) wordfree(we);
-
- if (flags & WRDE_NOCMD) for (i=0; s[i]; i++) switch (s[i]) {
- case '\\':
- if (!sq && !s[++i]) return WRDE_SYNTAX;
- break;
- case '\'':
- if (!dq) sq^=1;
- break;
- case '"':
- if (!sq) dq^=1;
- break;
- case '(':
- if (np) {
- np++;
- break;
- }
- case ')':
- if (np) {
- np--;
- break;
- }
- case '\n':
- case '|':
- case '&':
- case ';':
- case '<':
- case '>':
- case '{':
- case '}':
- if (!(sq|dq|np)) return WRDE_BADCHAR;
- break;
- case '$':
- if (sq) break;
- if (s[i+1]=='(' && s[i+2]=='(') {
- i += 2;
- np += 2;
- break;
- } else if (s[i+1] != '(') break;
- case '`':
- if (sq) break;
- return WRDE_CMDSUB;
- }
-
- if (flags & WRDE_APPEND) {
- wc = we->we_wordc;
- wv = we->we_wordv;
- }
-
- i = wc;
- if (flags & WRDE_DOOFFS) {
- if (we->we_offs > SIZE_MAX/sizeof(void *)/4)
- goto nospace;
- i += we->we_offs;
- } else {
- we->we_offs = 0;
- }
-
- if (pipe2(p, O_CLOEXEC) < 0) goto nospace;
- __block_all_sigs(&set);
- pid = fork();
- __restore_sigs(&set);
- if (pid < 0) {
- close(p[0]);
- close(p[1]);
- goto nospace;
- }
- if (!pid) {
- if (p[1] == 1) fcntl(1, F_SETFD, 0);
- else dup2(p[1], 1);
- execl("/bin/sh", "sh", "-c",
- "eval \"printf %s\\\\\\\\0 x $1 $2\"",
- "sh", s, redir, (char *)0);
- _exit(1);
- }
- close(p[1]);
-
- f = fdopen(p[0], "r");
- if (!f) {
- close(p[0]);
- kill(pid, SIGKILL);
- reap(pid);
- goto nospace;
- }
-
- l = wv ? i+1 : 0;
-
- free(getword(f));
- if (feof(f)) {
- fclose(f);
- reap(pid);
- return WRDE_SYNTAX;
- }
-
- while ((w = getword(f))) {
- if (i+1 >= l) {
- l += l/2+10;
- tmp = realloc(wv, l*sizeof(char *));
- if (!tmp) break;
- wv = tmp;
- }
- wv[i++] = w;
- wv[i] = 0;
- }
- if (!feof(f)) err = WRDE_NOSPACE;
-
- fclose(f);
- reap(pid);
-
- if (!wv) wv = calloc(i+1, sizeof *wv);
-
- we->we_wordv = wv;
- we->we_wordc = i;
-
- if (flags & WRDE_DOOFFS) {
- if (wv) for (i=we->we_offs; i; i--)
- we->we_wordv[i-1] = 0;
- we->we_wordc -= we->we_offs;
- }
- return err;
-
-nospace:
- if (!(flags & WRDE_APPEND)) {
- we->we_wordc = 0;
- we->we_wordv = 0;
- }
- return WRDE_NOSPACE;
-}
-
-int wordexp(const char *restrict s, wordexp_t *restrict we, int flags)
-{
- int r, cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- r = do_wordexp(s, we, flags);
- pthread_setcancelstate(cs, 0);
- return r;
-}
-
-void wordfree(wordexp_t *we)
-{
- size_t i;
- if (!we->we_wordv) return;
- for (i=0; i<we->we_wordc; i++) free(we->we_wordv[we->we_offs+i]);
- free(we->we_wordv);
- we->we_wordv = 0;
- we->we_wordc = 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/madvise.c b/lib/libc/wasi/libc-top-half/musl/src/mman/madvise.c
deleted file mode 100644
index e0c7c0ec92..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/madvise.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int __madvise(void *addr, size_t len, int advice)
-{
- return syscall(SYS_madvise, addr, len, advice);
-}
-
-weak_alias(__madvise, madvise);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mincore.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mincore.c
deleted file mode 100644
index 4bb19f857c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mincore.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/mman.h>
-#include "syscall.h"
-
-int mincore (void *addr, size_t len, unsigned char *vec)
-{
- return syscall(SYS_mincore, addr, len, vec);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mlock.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mlock.c
deleted file mode 100644
index 71af582fe6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mlock.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int mlock(const void *addr, size_t len)
-{
-#ifdef SYS_mlock
- return syscall(SYS_mlock, addr, len);
-#else
- return syscall(SYS_mlock2, addr, len, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mlockall.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mlockall.c
deleted file mode 100644
index 0ba4e662c8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mlockall.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int mlockall(int flags)
-{
- return syscall(SYS_mlockall, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mmap.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mmap.c
deleted file mode 100644
index eff88d82a8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mmap.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <stdint.h>
-#include <limits.h>
-#include "syscall.h"
-
-static void dummy(void) { }
-weak_alias(dummy, __vm_wait);
-
-#define UNIT SYSCALL_MMAP2_UNIT
-#define OFF_MASK ((-0x2000ULL << (8*sizeof(syscall_arg_t)-1)) | (UNIT-1))
-
-void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
-{
- long ret;
- if (off & OFF_MASK) {
- errno = EINVAL;
- return MAP_FAILED;
- }
- if (len >= PTRDIFF_MAX) {
- errno = ENOMEM;
- return MAP_FAILED;
- }
- if (flags & MAP_FIXED) {
- __vm_wait();
- }
-#ifdef SYS_mmap2
- ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
-#else
- ret = __syscall(SYS_mmap, start, len, prot, flags, fd, off);
-#endif
- /* Fixup incorrect EPERM from kernel. */
- if (ret == -EPERM && !start && (flags&MAP_ANON) && !(flags&MAP_FIXED))
- ret = -ENOMEM;
- return (void *)__syscall_ret(ret);
-}
-
-weak_alias(__mmap, mmap);
-
-weak_alias(mmap, mmap64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mprotect.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mprotect.c
deleted file mode 100644
index 535787b9ec..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mprotect.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <sys/mman.h>
-#include "libc.h"
-#include "syscall.h"
-
-int __mprotect(void *addr, size_t len, int prot)
-{
- size_t start, end;
- start = (size_t)addr & -PAGE_SIZE;
- end = (size_t)((char *)addr + len + PAGE_SIZE-1) & -PAGE_SIZE;
- return syscall(SYS_mprotect, start, end-start, prot);
-}
-
-weak_alias(__mprotect, mprotect);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/mremap.c b/lib/libc/wasi/libc-top-half/musl/src/mman/mremap.c
deleted file mode 100644
index cc6991a635..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/mremap.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdarg.h>
-#include "syscall.h"
-
-static void dummy(void) { }
-weak_alias(dummy, __vm_wait);
-
-void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
-{
- va_list ap;
- void *new_addr = 0;
-
- if (new_len >= PTRDIFF_MAX) {
- errno = ENOMEM;
- return MAP_FAILED;
- }
-
- if (flags & MREMAP_FIXED) {
- __vm_wait();
- va_start(ap, flags);
- new_addr = va_arg(ap, void *);
- va_end(ap);
- }
-
- return (void *)syscall(SYS_mremap, old_addr, old_len, new_len, flags, new_addr);
-}
-
-weak_alias(__mremap, mremap);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/msync.c b/lib/libc/wasi/libc-top-half/musl/src/mman/msync.c
deleted file mode 100644
index fcd8cdf9fc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/msync.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int msync(void *start, size_t len, int flags)
-{
- return syscall_cp(SYS_msync, start, len, flags);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/munlock.c b/lib/libc/wasi/libc-top-half/musl/src/mman/munlock.c
deleted file mode 100644
index 2cccef0c50..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/munlock.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int munlock(const void *addr, size_t len)
-{
- return syscall(SYS_munlock, addr, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/munlockall.c b/lib/libc/wasi/libc-top-half/musl/src/mman/munlockall.c
deleted file mode 100644
index 6e9d39d684..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/munlockall.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-int munlockall(void)
-{
- return syscall(SYS_munlockall);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/munmap.c b/lib/libc/wasi/libc-top-half/musl/src/mman/munmap.c
deleted file mode 100644
index 2bf83bbe9b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/munmap.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <sys/mman.h>
-#include "syscall.h"
-
-static void dummy(void) { }
-weak_alias(dummy, __vm_wait);
-
-int __munmap(void *start, size_t len)
-{
- __vm_wait();
- return syscall(SYS_munmap, start, len);
-}
-
-weak_alias(__munmap, munmap);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/posix_madvise.c b/lib/libc/wasi/libc-top-half/musl/src/mman/posix_madvise.c
deleted file mode 100644
index e5e5acb84a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/posix_madvise.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/mman.h>
-#include "syscall.h"
-
-int posix_madvise(void *addr, size_t len, int advice)
-{
- if (advice == MADV_DONTNEED) return 0;
- return -__syscall(SYS_madvise, addr, len, advice);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mman/shm_open.c b/lib/libc/wasi/libc-top-half/musl/src/mman/shm_open.c
deleted file mode 100644
index 79784bd306..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mman/shm_open.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <sys/mman.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <limits.h>
-#include <pthread.h>
-
-char *__shm_mapname(const char *name, char *buf)
-{
- char *p;
- while (*name == '/') name++;
- if (*(p = __strchrnul(name, '/')) || p==name ||
- (p-name <= 2 && name[0]=='.' && p[-1]=='.')) {
- errno = EINVAL;
- return 0;
- }
- if (p-name > NAME_MAX) {
- errno = ENAMETOOLONG;
- return 0;
- }
- memcpy(buf, "/dev/shm/", 9);
- memcpy(buf+9, name, p-name+1);
- return buf;
-}
-
-int shm_open(const char *name, int flag, mode_t mode)
-{
- int cs;
- char buf[NAME_MAX+10];
- if (!(name = __shm_mapname(name, buf))) return -1;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- int fd = open(name, flag|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK, mode);
- pthread_setcancelstate(cs, 0);
- return fd;
-}
-
-int shm_unlink(const char *name)
-{
- char buf[NAME_MAX+10];
- if (!(name = __shm_mapname(name, buf))) return -1;
- return unlink(name);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_close.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_close.c
deleted file mode 100644
index a61f094d41..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_close.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <mqueue.h>
-#include "syscall.h"
-
-int mq_close(mqd_t mqd)
-{
- return syscall(SYS_close, mqd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_getattr.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_getattr.c
deleted file mode 100644
index dce180691f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_getattr.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <mqueue.h>
-#include "syscall.h"
-
-int mq_getattr(mqd_t mqd, struct mq_attr *attr)
-{
- return mq_setattr(mqd, 0, attr);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_notify.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_notify.c
deleted file mode 100644
index 221591c73a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_notify.c
+++ /dev/null
@@ -1,73 +0,0 @@
-#include <mqueue.h>
-#include <pthread.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <signal.h>
-#include <unistd.h>
-#include "syscall.h"
-
-struct args {
- pthread_barrier_t barrier;
- int sock;
- const struct sigevent *sev;
-};
-
-static void *start(void *p)
-{
- struct args *args = p;
- char buf[32];
- ssize_t n;
- int s = args->sock;
- void (*func)(union sigval) = args->sev->sigev_notify_function;
- union sigval val = args->sev->sigev_value;
-
- pthread_barrier_wait(&args->barrier);
- n = recv(s, buf, sizeof(buf), MSG_NOSIGNAL|MSG_WAITALL);
- close(s);
- if (n==sizeof buf && buf[sizeof buf - 1] == 1)
- func(val);
- return 0;
-}
-
-int mq_notify(mqd_t mqd, const struct sigevent *sev)
-{
- struct args args = { .sev = sev };
- pthread_attr_t attr;
- pthread_t td;
- int s;
- struct sigevent sev2;
- static const char zeros[32];
-
- if (!sev || sev->sigev_notify != SIGEV_THREAD)
- return syscall(SYS_mq_notify, mqd, sev);
-
- s = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, 0);
- if (s < 0) return -1;
- args.sock = s;
-
- if (sev->sigev_notify_attributes) attr = *sev->sigev_notify_attributes;
- else pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_barrier_init(&args.barrier, 0, 2);
-
- if (pthread_create(&td, &attr, start, &args)) {
- __syscall(SYS_close, s);
- errno = EAGAIN;
- return -1;
- }
-
- pthread_barrier_wait(&args.barrier);
- pthread_barrier_destroy(&args.barrier);
-
- sev2.sigev_notify = SIGEV_THREAD;
- sev2.sigev_signo = s;
- sev2.sigev_value.sival_ptr = (void *)&zeros;
-
- if (syscall(SYS_mq_notify, mqd, &sev2) < 0) {
- pthread_cancel(td);
- __syscall(SYS_close, s);
- return -1;
- }
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_open.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_open.c
deleted file mode 100644
index aa91d58910..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_open.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <mqueue.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include "syscall.h"
-
-mqd_t mq_open(const char *name, int flags, ...)
-{
- mode_t mode = 0;
- struct mq_attr *attr = 0;
- if (*name == '/') name++;
- if (flags & O_CREAT) {
- va_list ap;
- va_start(ap, flags);
- mode = va_arg(ap, mode_t);
- attr = va_arg(ap, struct mq_attr *);
- va_end(ap);
- }
- return syscall(SYS_mq_open, name, flags, mode, attr);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_receive.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_receive.c
deleted file mode 100644
index 0b1bb4e4fb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_receive.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <mqueue.h>
-
-ssize_t mq_receive(mqd_t mqd, char *msg, size_t len, unsigned *prio)
-{
- return mq_timedreceive(mqd, msg, len, prio, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_send.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_send.c
deleted file mode 100644
index 1acb1b78d2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_send.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <mqueue.h>
-
-int mq_send(mqd_t mqd, const char *msg, size_t len, unsigned prio)
-{
- return mq_timedsend(mqd, msg, len, prio, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_setattr.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_setattr.c
deleted file mode 100644
index eae022e946..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_setattr.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <mqueue.h>
-#include "syscall.h"
-
-int mq_setattr(mqd_t mqd, const struct mq_attr *restrict new, struct mq_attr *restrict old)
-{
- return syscall(SYS_mq_getsetattr, mqd, new, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedreceive.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedreceive.c
deleted file mode 100644
index f41b6642f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedreceive.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <mqueue.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-ssize_t mq_timedreceive(mqd_t mqd, char *restrict msg, size_t len, unsigned *restrict prio, const struct timespec *restrict at)
-{
-#ifdef SYS_mq_timedreceive_time64
- time_t s = at ? at->tv_sec : 0;
- long ns = at ? at->tv_nsec : 0;
- long r = -ENOSYS;
- if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_mq_timedreceive_time64, mqd, msg, len, prio,
- at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0);
- if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || r != -ENOSYS)
- return __syscall_ret(r);
- return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio,
- at ? ((long[]){CLAMP(s), ns}) : 0);
-#else
- return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio, at);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedsend.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedsend.c
deleted file mode 100644
index 56cfcbb833..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_timedsend.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <mqueue.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at)
-{
-#ifdef SYS_mq_timedsend_time64
- time_t s = at ? at->tv_sec : 0;
- long ns = at ? at->tv_nsec : 0;
- long r = -ENOSYS;
- if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_mq_timedsend_time64, mqd, msg, len, prio,
- at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0);
- if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || r != -ENOSYS)
- return __syscall_ret(r);
- return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio,
- at ? ((long[]){CLAMP(s), ns}) : 0);
-#else
- return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio, at);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_unlink.c b/lib/libc/wasi/libc-top-half/musl/src/mq/mq_unlink.c
deleted file mode 100644
index 6a08a4c57e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/mq/mq_unlink.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <mqueue.h>
-#include <errno.h>
-#include "syscall.h"
-
-int mq_unlink(const char *name)
-{
- int ret;
- if (*name == '/') name++;
- ret = __syscall(SYS_mq_unlink, name);
- if (ret < 0) {
- if (ret == -EPERM) ret = -EACCES;
- errno = -ret;
- return -1;
- }
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/accept.c b/lib/libc/wasi/libc-top-half/musl/src/network/accept.c
deleted file mode 100644
index a92406fa73..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/accept.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int accept(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
-{
- return socketcall_cp(accept, fd, addr, len, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/accept4.c b/lib/libc/wasi/libc-top-half/musl/src/network/accept4.c
deleted file mode 100644
index 59ab1726bd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/accept4.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int accept4(int fd, struct sockaddr *restrict addr, socklen_t *restrict len, int flg)
-{
- if (!flg) return accept(fd, addr, len);
- int ret = socketcall_cp(accept4, fd, addr, len, flg, 0, 0);
- if (ret>=0 || (errno != ENOSYS && errno != EINVAL)) return ret;
- ret = accept(fd, addr, len);
- if (ret<0) return ret;
- if (flg & SOCK_CLOEXEC)
- __syscall(SYS_fcntl, ret, F_SETFD, FD_CLOEXEC);
- if (flg & SOCK_NONBLOCK)
- __syscall(SYS_fcntl, ret, F_SETFL, O_NONBLOCK);
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/bind.c b/lib/libc/wasi/libc-top-half/musl/src/network/bind.c
deleted file mode 100644
index 07bb669aad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/bind.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int bind(int fd, const struct sockaddr *addr, socklen_t len)
-{
- return socketcall(bind, fd, addr, len, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/connect.c b/lib/libc/wasi/libc-top-half/musl/src/network/connect.c
deleted file mode 100644
index 289127be48..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/connect.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int connect(int fd, const struct sockaddr *addr, socklen_t len)
-{
- return socketcall_cp(connect, fd, addr, len, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/dn_comp.c b/lib/libc/wasi/libc-top-half/musl/src/network/dn_comp.c
deleted file mode 100644
index f0ccd160f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/dn_comp.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <string.h>
-#include <resolv.h>
-
-/* RFC 1035 message compression */
-
-/* label start offsets of a compressed domain name s */
-static int getoffs(short *offs, const unsigned char *base, const unsigned char *s)
-{
- int i=0;
- for (;;) {
- while (*s & 0xc0) {
- if ((*s & 0xc0) != 0xc0) return 0;
- s = base + ((s[0]&0x3f)<<8 | s[1]);
- }
- if (!*s) return i;
- if (s-base >= 0x4000) return 0;
- offs[i++] = s-base;
- s += *s + 1;
- }
-}
-
-/* label lengths of an ascii domain name s */
-static int getlens(unsigned char *lens, const char *s, int l)
-{
- int i=0,j=0,k=0;
- for (;;) {
- for (; j<l && s[j]!='.'; j++);
- if (j-k-1u > 62) return 0;
- lens[i++] = j-k;
- if (j==l) return i;
- k = ++j;
- }
-}
-
-/* longest suffix match of an ascii domain with a compressed domain name dn */
-static int match(int *offset, const unsigned char *base, const unsigned char *dn,
- const char *end, const unsigned char *lens, int nlen)
-{
- int l, o, m=0;
- short offs[128];
- int noff = getoffs(offs, base, dn);
- if (!noff) return 0;
- for (;;) {
- l = lens[--nlen];
- o = offs[--noff];
- end -= l;
- if (l != base[o] || memcmp(base+o+1, end, l))
- return m;
- *offset = o;
- m += l;
- if (nlen) m++;
- if (!nlen || !noff) return m;
- end--;
- }
-}
-
-int dn_comp(const char *src, unsigned char *dst, int space, unsigned char **dnptrs, unsigned char **lastdnptr)
-{
- int i, j, n, m=0, offset, bestlen=0, bestoff;
- unsigned char lens[127];
- unsigned char **p;
- const char *end;
- size_t l = strnlen(src, 255);
- if (l && src[l-1] == '.') l--;
- if (l>253 || space<=0) return -1;
- if (!l) {
- *dst = 0;
- return 1;
- }
- end = src+l;
- n = getlens(lens, src, l);
- if (!n) return -1;
-
- p = dnptrs;
- if (p && *p) for (p++; *p; p++) {
- m = match(&offset, *dnptrs, *p, end, lens, n);
- if (m > bestlen) {
- bestlen = m;
- bestoff = offset;
- if (m == l)
- break;
- }
- }
-
- /* encode unmatched part */
- if (space < l-bestlen+2+(bestlen-1 < l-1)) return -1;
- memcpy(dst+1, src, l-bestlen);
- for (i=j=0; i<l-bestlen; i+=lens[j++]+1)
- dst[i] = lens[j];
-
- /* add tail */
- if (bestlen) {
- dst[i++] = 0xc0 | bestoff>>8;
- dst[i++] = bestoff;
- } else
- dst[i++] = 0;
-
- /* save dst pointer */
- if (i>2 && lastdnptr && dnptrs && *dnptrs) {
- while (*p) p++;
- if (p+1 < lastdnptr) {
- *p++ = dst;
- *p=0;
- }
- }
- return i;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/dn_expand.c b/lib/libc/wasi/libc-top-half/musl/src/network/dn_expand.c
deleted file mode 100644
index eac343af5e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/dn_expand.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <resolv.h>
-
-int __dn_expand(const unsigned char *base, const unsigned char *end, const unsigned char *src, char *dest, int space)
-{
- const unsigned char *p = src;
- char *dend, *dbegin = dest;
- int len = -1, i, j;
- if (p==end || space <= 0) return -1;
- dend = dest + (space > 254 ? 254 : space);
- /* detect reference loop using an iteration counter */
- for (i=0; i < end-base; i+=2) {
- /* loop invariants: p<end, dest<dend */
- if (*p & 0xc0) {
- if (p+1==end) return -1;
- j = ((p[0] & 0x3f) << 8) | p[1];
- if (len < 0) len = p+2-src;
- if (j >= end-base) return -1;
- p = base+j;
- } else if (*p) {
- if (dest != dbegin) *dest++ = '.';
- j = *p++;
- if (j >= end-p || j >= dend-dest) return -1;
- while (j--) *dest++ = *p++;
- } else {
- *dest = 0;
- if (len < 0) len = p+1-src;
- return len;
- }
- }
- return -1;
-}
-
-weak_alias(__dn_expand, dn_expand);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/dn_skipname.c b/lib/libc/wasi/libc-top-half/musl/src/network/dn_skipname.c
deleted file mode 100644
index eba65bb82a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/dn_skipname.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <resolv.h>
-
-int dn_skipname(const unsigned char *s, const unsigned char *end)
-{
- const unsigned char *p = s;
- while (p < end)
- if (!*p) return p-s+1;
- else if (*p>=192)
- if (p+1<end) return p-s+2;
- else break;
- else
- if (end-p<*p+1) break;
- else p += *p + 1;
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/dns_parse.c b/lib/libc/wasi/libc-top-half/musl/src/network/dns_parse.c
deleted file mode 100644
index e6ee19d9a6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/dns_parse.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include <string.h>
-#include "lookup.h"
-
-int __dns_parse(const unsigned char *r, int rlen, int (*callback)(void *, int, const void *, int, const void *), void *ctx)
-{
- int qdcount, ancount;
- const unsigned char *p;
- int len;
-
- if (rlen<12) return -1;
- if ((r[3]&15)) return 0;
- p = r+12;
- qdcount = r[4]*256 + r[5];
- ancount = r[6]*256 + r[7];
- if (qdcount+ancount > 64) return -1;
- while (qdcount--) {
- while (p-r < rlen && *p-1U < 127) p++;
- if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6)
- return -1;
- p += 5 + !!*p;
- }
- while (ancount--) {
- while (p-r < rlen && *p-1U < 127) p++;
- if (*p>193 || (*p==193 && p[1]>254) || p>r+rlen-6)
- return -1;
- p += 1 + !!*p;
- len = p[8]*256 + p[9];
- if (p+len > r+rlen) return -1;
- if (callback(ctx, p[1], p+10, len, r) < 0) return -1;
- p += 10 + len;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/ent.c b/lib/libc/wasi/libc-top-half/musl/src/network/ent.c
deleted file mode 100644
index c6e012306d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/ent.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <netdb.h>
-
-void sethostent(int x)
-{
-}
-
-struct hostent *gethostent()
-{
- return 0;
-}
-
-struct netent *getnetent()
-{
- return 0;
-}
-
-void endhostent(void)
-{
-}
-
-weak_alias(sethostent, setnetent);
-weak_alias(endhostent, endnetent);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/ether.c b/lib/libc/wasi/libc-top-half/musl/src/network/ether.c
deleted file mode 100644
index 4304a972fe..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/ether.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdlib.h>
-#include <netinet/ether.h>
-#include <stdio.h>
-
-struct ether_addr *ether_aton_r (const char *x, struct ether_addr *p_a)
-{
- struct ether_addr a;
- char *y;
- for (int ii = 0; ii < 6; ii++) {
- unsigned long int n;
- if (ii != 0) {
- if (x[0] != ':') return 0; /* bad format */
- else x++;
- }
- n = strtoul (x, &y, 16);
- x = y;
- if (n > 0xFF) return 0; /* bad byte */
- a.ether_addr_octet[ii] = n;
- }
- if (x[0] != 0) return 0; /* bad format */
- *p_a = a;
- return p_a;
-}
-
-struct ether_addr *ether_aton (const char *x)
-{
- static struct ether_addr a;
- return ether_aton_r (x, &a);
-}
-
-char *ether_ntoa_r (const struct ether_addr *p_a, char *x) {
- char *y;
- y = x;
- for (int ii = 0; ii < 6; ii++) {
- x += sprintf (x, ii == 0 ? "%.2X" : ":%.2X", p_a->ether_addr_octet[ii]);
- }
- return y;
-}
-
-char *ether_ntoa (const struct ether_addr *p_a) {
- static char x[18];
- return ether_ntoa_r (p_a, x);
-}
-
-int ether_line(const char *l, struct ether_addr *e, char *hostname)
-{
- return -1;
-}
-
-int ether_ntohost(char *hostname, const struct ether_addr *e)
-{
- return -1;
-}
-
-int ether_hostton(const char *hostname, struct ether_addr *e)
-{
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/freeaddrinfo.c b/lib/libc/wasi/libc-top-half/musl/src/network/freeaddrinfo.c
deleted file mode 100644
index 62241c239e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/freeaddrinfo.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <stdlib.h>
-#include <stddef.h>
-#include <netdb.h>
-#include "lookup.h"
-#include "lock.h"
-
-void freeaddrinfo(struct addrinfo *p)
-{
- size_t cnt;
- for (cnt=1; p->ai_next; cnt++, p=p->ai_next);
- struct aibuf *b = (void *)((char *)p - offsetof(struct aibuf, ai));
- b -= b->slot;
- LOCK(b->lock);
- if (!(b->ref -= cnt)) free(b);
- else UNLOCK(b->lock);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gai_strerror.c b/lib/libc/wasi/libc-top-half/musl/src/network/gai_strerror.c
deleted file mode 100644
index 9596580e9f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gai_strerror.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <netdb.h>
-#include "locale_impl.h"
-
-static const char msgs[] =
- "Invalid flags\0"
- "Name does not resolve\0"
- "Try again\0"
- "Non-recoverable error\0"
- "Unknown error\0"
- "Unrecognized address family or invalid length\0"
- "Unrecognized socket type\0"
- "Unrecognized service\0"
- "Unknown error\0"
- "Out of memory\0"
- "System error\0"
- "Overflow\0"
- "\0Unknown error";
-
-const char *gai_strerror(int ecode)
-{
- const char *s;
- for (s=msgs, ecode++; ecode && *s; ecode++, s++) for (; *s; s++);
- if (!*s) s++;
- return LCTRANS_CUR(s);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getaddrinfo.c b/lib/libc/wasi/libc-top-half/musl/src/network/getaddrinfo.c
deleted file mode 100644
index efaab30682..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getaddrinfo.c
+++ /dev/null
@@ -1,135 +0,0 @@
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <string.h>
-#include <pthread.h>
-#include <unistd.h>
-#include <endian.h>
-#include <errno.h>
-#include "lookup.h"
-
-int getaddrinfo(const char *restrict host, const char *restrict serv, const struct addrinfo *restrict hint, struct addrinfo **restrict res)
-{
- struct service ports[MAXSERVS];
- struct address addrs[MAXADDRS];
- char canon[256], *outcanon;
- int nservs, naddrs, nais, canon_len, i, j, k;
- int family = AF_UNSPEC, flags = 0, proto = 0, socktype = 0;
- struct aibuf *out;
-
- if (!host && !serv) return EAI_NONAME;
-
- if (hint) {
- family = hint->ai_family;
- flags = hint->ai_flags;
- proto = hint->ai_protocol;
- socktype = hint->ai_socktype;
-
- const int mask = AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST |
- AI_V4MAPPED | AI_ALL | AI_ADDRCONFIG | AI_NUMERICSERV;
- if ((flags & mask) != flags)
- return EAI_BADFLAGS;
-
- switch (family) {
- case AF_INET:
- case AF_INET6:
- case AF_UNSPEC:
- break;
- default:
- return EAI_FAMILY;
- }
- }
-
- if (flags & AI_ADDRCONFIG) {
- /* Define the "an address is configured" condition for address
- * families via ability to create a socket for the family plus
- * routability of the loopback address for the family. */
- static const struct sockaddr_in lo4 = {
- .sin_family = AF_INET, .sin_port = 65535,
- .sin_addr.s_addr = __BYTE_ORDER == __BIG_ENDIAN
- ? 0x7f000001 : 0x0100007f
- };
- static const struct sockaddr_in6 lo6 = {
- .sin6_family = AF_INET6, .sin6_port = 65535,
- .sin6_addr = IN6ADDR_LOOPBACK_INIT
- };
- int tf[2] = { AF_INET, AF_INET6 };
- const void *ta[2] = { &lo4, &lo6 };
- socklen_t tl[2] = { sizeof lo4, sizeof lo6 };
- for (i=0; i<2; i++) {
- if (family==tf[1-i]) continue;
- int s = socket(tf[i], SOCK_CLOEXEC|SOCK_DGRAM,
- IPPROTO_UDP);
- if (s>=0) {
- int cs;
- pthread_setcancelstate(
- PTHREAD_CANCEL_DISABLE, &cs);
- int r = connect(s, ta[i], tl[i]);
- pthread_setcancelstate(cs, 0);
- close(s);
- if (!r) continue;
- }
- switch (errno) {
- case EADDRNOTAVAIL:
- case EAFNOSUPPORT:
- case EHOSTUNREACH:
- case ENETDOWN:
- case ENETUNREACH:
- break;
- default:
- return EAI_SYSTEM;
- }
- if (family == tf[i]) return EAI_NONAME;
- family = tf[1-i];
- }
- }
-
- nservs = __lookup_serv(ports, serv, proto, socktype, flags);
- if (nservs < 0) return nservs;
-
- naddrs = __lookup_name(addrs, canon, host, family, flags);
- if (naddrs < 0) return naddrs;
-
- nais = nservs * naddrs;
- canon_len = strlen(canon);
- out = calloc(1, nais * sizeof(*out) + canon_len + 1);
- if (!out) return EAI_MEMORY;
-
- if (canon_len) {
- outcanon = (void *)&out[nais];
- memcpy(outcanon, canon, canon_len+1);
- } else {
- outcanon = 0;
- }
-
- for (k=i=0; i<naddrs; i++) for (j=0; j<nservs; j++, k++) {
- out[k].slot = k;
- out[k].ai = (struct addrinfo){
- .ai_family = addrs[i].family,
- .ai_socktype = ports[j].socktype,
- .ai_protocol = ports[j].proto,
- .ai_addrlen = addrs[i].family == AF_INET
- ? sizeof(struct sockaddr_in)
- : sizeof(struct sockaddr_in6),
- .ai_addr = (void *)&out[k].sa,
- .ai_canonname = outcanon };
- if (k) out[k-1].ai.ai_next = &out[k].ai;
- switch (addrs[i].family) {
- case AF_INET:
- out[k].sa.sin.sin_family = AF_INET;
- out[k].sa.sin.sin_port = htons(ports[j].port);
- memcpy(&out[k].sa.sin.sin_addr, &addrs[i].addr, 4);
- break;
- case AF_INET6:
- out[k].sa.sin6.sin6_family = AF_INET6;
- out[k].sa.sin6.sin6_port = htons(ports[j].port);
- out[k].sa.sin6.sin6_scope_id = addrs[i].scopeid;
- memcpy(&out[k].sa.sin6.sin6_addr, &addrs[i].addr, 16);
- break;
- }
- }
- out[0].ref = nais;
- *res = &out->ai;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr.c
deleted file mode 100644
index 598e2241a9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#define _GNU_SOURCE
-
-#include <netdb.h>
-#include <errno.h>
-#include <stdlib.h>
-
-struct hostent *gethostbyaddr(const void *a, socklen_t l, int af)
-{
- static struct hostent *h;
- size_t size = 63;
- struct hostent *res;
- int err;
- do {
- free(h);
- h = malloc(size+=size+1);
- if (!h) {
- h_errno = NO_RECOVERY;
- return 0;
- }
- err = gethostbyaddr_r(a, l, af, h,
- (void *)(h+1), size-sizeof *h, &res, &h_errno);
- } while (err == ERANGE);
- return err ? 0 : h;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr_r.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr_r.c
deleted file mode 100644
index 0f1e61aa0c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyaddr_r.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#define _GNU_SOURCE
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <inttypes.h>
-
-int gethostbyaddr_r(const void *a, socklen_t l, int af,
- struct hostent *h, char *buf, size_t buflen,
- struct hostent **res, int *err)
-{
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } sa = { .sin.sin_family = af };
- socklen_t sl = af==AF_INET6 ? sizeof sa.sin6 : sizeof sa.sin;
- int i;
-
- *res = 0;
-
- /* Load address argument into sockaddr structure */
- if (af==AF_INET6 && l==16) memcpy(&sa.sin6.sin6_addr, a, 16);
- else if (af==AF_INET && l==4) memcpy(&sa.sin.sin_addr, a, 4);
- else {
- *err = NO_RECOVERY;
- return EINVAL;
- }
-
- /* Align buffer and check for space for pointers and ip address */
- i = (uintptr_t)buf & sizeof(char *)-1;
- if (!i) i = sizeof(char *);
- if (buflen <= 5*sizeof(char *)-i + l) return ERANGE;
- buf += sizeof(char *)-i;
- buflen -= 5*sizeof(char *)-i + l;
-
- h->h_addr_list = (void *)buf;
- buf += 2*sizeof(char *);
- h->h_aliases = (void *)buf;
- buf += 2*sizeof(char *);
-
- h->h_addr_list[0] = buf;
- memcpy(h->h_addr_list[0], a, l);
- buf += l;
- h->h_addr_list[1] = 0;
- h->h_aliases[0] = buf;
- h->h_aliases[1] = 0;
-
- switch (getnameinfo((void *)&sa, sl, buf, buflen, 0, 0, 0)) {
- case EAI_AGAIN:
- *err = TRY_AGAIN;
- return EAGAIN;
- case EAI_OVERFLOW:
- return ERANGE;
- default:
- case EAI_MEMORY:
- case EAI_SYSTEM:
- case EAI_FAIL:
- *err = NO_RECOVERY;
- return errno;
- case 0:
- break;
- }
-
- h->h_addrtype = af;
- h->h_length = l;
- h->h_name = h->h_aliases[0];
- *res = h;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname.c
deleted file mode 100644
index bfedf52ad6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _GNU_SOURCE
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
-
-struct hostent *gethostbyname(const char *name)
-{
- return gethostbyname2(name, AF_INET);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2.c
deleted file mode 100644
index dc9d6621be..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#define _GNU_SOURCE
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <errno.h>
-#include <stdlib.h>
-
-struct hostent *gethostbyname2(const char *name, int af)
-{
- static struct hostent *h;
- size_t size = 63;
- struct hostent *res;
- int err;
- do {
- free(h);
- h = malloc(size+=size+1);
- if (!h) {
- h_errno = NO_RECOVERY;
- return 0;
- }
- err = gethostbyname2_r(name, af, h,
- (void *)(h+1), size-sizeof *h, &res, &h_errno);
- } while (err == ERANGE);
- return err ? 0 : h;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2_r.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2_r.c
deleted file mode 100644
index fc8948776d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname2_r.c
+++ /dev/null
@@ -1,80 +0,0 @@
-#define _GNU_SOURCE
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <errno.h>
-#include <stdint.h>
-#include "lookup.h"
-
-int gethostbyname2_r(const char *name, int af,
- struct hostent *h, char *buf, size_t buflen,
- struct hostent **res, int *err)
-{
- struct address addrs[MAXADDRS];
- char canon[256];
- int i, cnt;
- size_t align, need;
-
- *res = 0;
- cnt = __lookup_name(addrs, canon, name, af, AI_CANONNAME);
- if (cnt<0) switch (cnt) {
- case EAI_NONAME:
- *err = HOST_NOT_FOUND;
- return ENOENT;
- case EAI_AGAIN:
- *err = TRY_AGAIN;
- return EAGAIN;
- default:
- case EAI_FAIL:
- *err = NO_RECOVERY;
- return EBADMSG;
- case EAI_MEMORY:
- case EAI_SYSTEM:
- *err = NO_RECOVERY;
- return errno;
- }
-
- h->h_addrtype = af;
- h->h_length = af==AF_INET6 ? 16 : 4;
-
- /* Align buffer */
- align = -(uintptr_t)buf & sizeof(char *)-1;
-
- need = 4*sizeof(char *);
- need += (cnt + 1) * (sizeof(char *) + h->h_length);
- need += strlen(name)+1;
- need += strlen(canon)+1;
- need += align;
-
- if (need > buflen) return ERANGE;
-
- buf += align;
- h->h_aliases = (void *)buf;
- buf += 3*sizeof(char *);
- h->h_addr_list = (void *)buf;
- buf += (cnt+1)*sizeof(char *);
-
- for (i=0; i<cnt; i++) {
- h->h_addr_list[i] = (void *)buf;
- buf += h->h_length;
- memcpy(h->h_addr_list[i], addrs[i].addr, h->h_length);
- }
- h->h_addr_list[i] = 0;
-
- h->h_name = h->h_aliases[0] = buf;
- strcpy(h->h_name, canon);
- buf += strlen(h->h_name)+1;
-
- if (strcmp(h->h_name, name)) {
- h->h_aliases[1] = buf;
- strcpy(h->h_aliases[1], name);
- buf += strlen(h->h_aliases[1])+1;
- } else h->h_aliases[1] = 0;
-
- h->h_aliases[2] = 0;
-
- *res = h;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname_r.c b/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname_r.c
deleted file mode 100644
index cd87254173..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/gethostbyname_r.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _GNU_SOURCE
-
-#include <sys/socket.h>
-#include <netdb.h>
-
-int gethostbyname_r(const char *name,
- struct hostent *h, char *buf, size_t buflen,
- struct hostent **res, int *err)
-{
- return gethostbyname2_r(name, AF_INET, h, buf, buflen, res, err);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getifaddrs.c b/lib/libc/wasi/libc-top-half/musl/src/network/getifaddrs.c
deleted file mode 100644
index fed75bd8d9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getifaddrs.c
+++ /dev/null
@@ -1,216 +0,0 @@
-#define _GNU_SOURCE
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <ifaddrs.h>
-#include <syscall.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include "netlink.h"
-
-#define IFADDRS_HASH_SIZE 64
-
-/* getifaddrs() reports hardware addresses with PF_PACKET that implies
- * struct sockaddr_ll. But e.g. Infiniband socket address length is
- * longer than sockaddr_ll.ssl_addr[8] can hold. Use this hack struct
- * to extend ssl_addr - callers should be able to still use it. */
-struct sockaddr_ll_hack {
- unsigned short sll_family, sll_protocol;
- int sll_ifindex;
- unsigned short sll_hatype;
- unsigned char sll_pkttype, sll_halen;
- unsigned char sll_addr[24];
-};
-
-union sockany {
- struct sockaddr sa;
- struct sockaddr_ll_hack ll;
- struct sockaddr_in v4;
- struct sockaddr_in6 v6;
-};
-
-struct ifaddrs_storage {
- struct ifaddrs ifa;
- struct ifaddrs_storage *hash_next;
- union sockany addr, netmask, ifu;
- unsigned int index;
- char name[IFNAMSIZ+1];
-};
-
-struct ifaddrs_ctx {
- struct ifaddrs_storage *first;
- struct ifaddrs_storage *last;
- struct ifaddrs_storage *hash[IFADDRS_HASH_SIZE];
-};
-
-void freeifaddrs(struct ifaddrs *ifp)
-{
- struct ifaddrs *n;
- while (ifp) {
- n = ifp->ifa_next;
- free(ifp);
- ifp = n;
- }
-}
-
-static void copy_addr(struct sockaddr **r, int af, union sockany *sa, void *addr, size_t addrlen, int ifindex)
-{
- uint8_t *dst;
- int len;
-
- switch (af) {
- case AF_INET:
- dst = (uint8_t*) &sa->v4.sin_addr;
- len = 4;
- break;
- case AF_INET6:
- dst = (uint8_t*) &sa->v6.sin6_addr;
- len = 16;
- if (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MC_LINKLOCAL(addr))
- sa->v6.sin6_scope_id = ifindex;
- break;
- default:
- return;
- }
- if (addrlen < len) return;
- sa->sa.sa_family = af;
- memcpy(dst, addr, len);
- *r = &sa->sa;
-}
-
-static void gen_netmask(struct sockaddr **r, int af, union sockany *sa, int prefixlen)
-{
- uint8_t addr[16] = {0};
- int i;
-
- if (prefixlen > 8*sizeof(addr)) prefixlen = 8*sizeof(addr);
- i = prefixlen / 8;
- memset(addr, 0xff, i);
- if (i < sizeof(addr)) addr[i++] = 0xff << (8 - (prefixlen % 8));
- copy_addr(r, af, sa, addr, sizeof(addr), 0);
-}
-
-static void copy_lladdr(struct sockaddr **r, union sockany *sa, void *addr, size_t addrlen, int ifindex, unsigned short hatype)
-{
- if (addrlen > sizeof(sa->ll.sll_addr)) return;
- sa->ll.sll_family = AF_PACKET;
- sa->ll.sll_ifindex = ifindex;
- sa->ll.sll_hatype = hatype;
- sa->ll.sll_halen = addrlen;
- memcpy(sa->ll.sll_addr, addr, addrlen);
- *r = &sa->sa;
-}
-
-static int netlink_msg_to_ifaddr(void *pctx, struct nlmsghdr *h)
-{
- struct ifaddrs_ctx *ctx = pctx;
- struct ifaddrs_storage *ifs, *ifs0;
- struct ifinfomsg *ifi = NLMSG_DATA(h);
- struct ifaddrmsg *ifa = NLMSG_DATA(h);
- struct rtattr *rta;
- int stats_len = 0;
-
- if (h->nlmsg_type == RTM_NEWLINK) {
- for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
- if (rta->rta_type != IFLA_STATS) continue;
- stats_len = RTA_DATALEN(rta);
- break;
- }
- } else {
- for (ifs0 = ctx->hash[ifa->ifa_index % IFADDRS_HASH_SIZE]; ifs0; ifs0 = ifs0->hash_next)
- if (ifs0->index == ifa->ifa_index)
- break;
- if (!ifs0) return 0;
- }
-
- ifs = calloc(1, sizeof(struct ifaddrs_storage) + stats_len);
- if (ifs == 0) return -1;
-
- if (h->nlmsg_type == RTM_NEWLINK) {
- ifs->index = ifi->ifi_index;
- ifs->ifa.ifa_flags = ifi->ifi_flags;
-
- for (rta = NLMSG_RTA(h, sizeof(*ifi)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
- switch (rta->rta_type) {
- case IFLA_IFNAME:
- if (RTA_DATALEN(rta) < sizeof(ifs->name)) {
- memcpy(ifs->name, RTA_DATA(rta), RTA_DATALEN(rta));
- ifs->ifa.ifa_name = ifs->name;
- }
- break;
- case IFLA_ADDRESS:
- copy_lladdr(&ifs->ifa.ifa_addr, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifi->ifi_index, ifi->ifi_type);
- break;
- case IFLA_BROADCAST:
- copy_lladdr(&ifs->ifa.ifa_broadaddr, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifi->ifi_index, ifi->ifi_type);
- break;
- case IFLA_STATS:
- ifs->ifa.ifa_data = (void*)(ifs+1);
- memcpy(ifs->ifa.ifa_data, RTA_DATA(rta), RTA_DATALEN(rta));
- break;
- }
- }
- if (ifs->ifa.ifa_name) {
- unsigned int bucket = ifs->index % IFADDRS_HASH_SIZE;
- ifs->hash_next = ctx->hash[bucket];
- ctx->hash[bucket] = ifs;
- }
- } else {
- ifs->ifa.ifa_name = ifs0->ifa.ifa_name;
- ifs->ifa.ifa_flags = ifs0->ifa.ifa_flags;
- for (rta = NLMSG_RTA(h, sizeof(*ifa)); NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
- switch (rta->rta_type) {
- case IFA_ADDRESS:
- /* If ifa_addr is already set we, received an IFA_LOCAL before
- * so treat this as destination address */
- if (ifs->ifa.ifa_addr)
- copy_addr(&ifs->ifa.ifa_dstaddr, ifa->ifa_family, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
- else
- copy_addr(&ifs->ifa.ifa_addr, ifa->ifa_family, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
- break;
- case IFA_BROADCAST:
- copy_addr(&ifs->ifa.ifa_broadaddr, ifa->ifa_family, &ifs->ifu, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
- break;
- case IFA_LOCAL:
- /* If ifa_addr is set and we get IFA_LOCAL, assume we have
- * a point-to-point network. Move address to correct field. */
- if (ifs->ifa.ifa_addr) {
- ifs->ifu = ifs->addr;
- ifs->ifa.ifa_dstaddr = &ifs->ifu.sa;
- memset(&ifs->addr, 0, sizeof(ifs->addr));
- }
- copy_addr(&ifs->ifa.ifa_addr, ifa->ifa_family, &ifs->addr, RTA_DATA(rta), RTA_DATALEN(rta), ifa->ifa_index);
- break;
- case IFA_LABEL:
- if (RTA_DATALEN(rta) < sizeof(ifs->name)) {
- memcpy(ifs->name, RTA_DATA(rta), RTA_DATALEN(rta));
- ifs->ifa.ifa_name = ifs->name;
- }
- break;
- }
- }
- if (ifs->ifa.ifa_addr)
- gen_netmask(&ifs->ifa.ifa_netmask, ifa->ifa_family, &ifs->netmask, ifa->ifa_prefixlen);
- }
-
- if (ifs->ifa.ifa_name) {
- if (!ctx->first) ctx->first = ifs;
- if (ctx->last) ctx->last->ifa.ifa_next = &ifs->ifa;
- ctx->last = ifs;
- } else {
- free(ifs);
- }
- return 0;
-}
-
-int getifaddrs(struct ifaddrs **ifap)
-{
- struct ifaddrs_ctx _ctx, *ctx = &_ctx;
- int r;
- memset(ctx, 0, sizeof *ctx);
- r = __rtnetlink_enumerate(AF_UNSPEC, AF_UNSPEC, netlink_msg_to_ifaddr, ctx);
- if (r == 0) *ifap = &ctx->first->ifa;
- else freeifaddrs(&ctx->first->ifa);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getnameinfo.c b/lib/libc/wasi/libc-top-half/musl/src/network/getnameinfo.c
deleted file mode 100644
index 949e18115a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getnameinfo.c
+++ /dev/null
@@ -1,200 +0,0 @@
-#include <netdb.h>
-#include <limits.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <net/if.h>
-#include <ctype.h>
-#include <resolv.h>
-#include "lookup.h"
-#include "stdio_impl.h"
-
-#define PTR_MAX (64 + sizeof ".in-addr.arpa")
-#define RR_PTR 12
-
-static char *itoa(char *p, unsigned x) {
- p += 3*sizeof(int);
- *--p = 0;
- do {
- *--p = '0' + x % 10;
- x /= 10;
- } while (x);
- return p;
-}
-
-static void mkptr4(char *s, const unsigned char *ip)
-{
- sprintf(s, "%d.%d.%d.%d.in-addr.arpa",
- ip[3], ip[2], ip[1], ip[0]);
-}
-
-static void mkptr6(char *s, const unsigned char *ip)
-{
- static const char xdigits[] = "0123456789abcdef";
- int i;
- for (i=15; i>=0; i--) {
- *s++ = xdigits[ip[i]&15]; *s++ = '.';
- *s++ = xdigits[ip[i]>>4]; *s++ = '.';
- }
- strcpy(s, "ip6.arpa");
-}
-
-static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, int family)
-{
- char line[512], *p, *z;
- unsigned char _buf[1032], atmp[16];
- struct address iplit;
- FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
- if (!f) return;
- if (family == AF_INET) {
- memcpy(atmp+12, a, 4);
- memcpy(atmp, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- a = atmp;
- }
- while (fgets(line, sizeof line, f)) {
- if ((p=strchr(line, '#'))) *p++='\n', *p=0;
-
- for (p=line; *p && !isspace(*p); p++);
- *p++ = 0;
- if (__lookup_ipliteral(&iplit, line, AF_UNSPEC)<=0)
- continue;
-
- if (iplit.family == AF_INET) {
- memcpy(iplit.addr+12, iplit.addr, 4);
- memcpy(iplit.addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- iplit.scopeid = 0;
- }
-
- if (memcmp(a, iplit.addr, 16) || iplit.scopeid != scopeid)
- continue;
-
- for (; *p && isspace(*p); p++);
- for (z=p; *z && !isspace(*z); z++);
- *z = 0;
- if (z-p < 256) {
- memcpy(buf, p, z-p+1);
- break;
- }
- }
- __fclose_ca(f);
-}
-
-static void reverse_services(char *buf, int port, int dgram)
-{
- unsigned long svport;
- char line[128], *p, *z;
- unsigned char _buf[1032];
- FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
- if (!f) return;
- while (fgets(line, sizeof line, f)) {
- if ((p=strchr(line, '#'))) *p++='\n', *p=0;
-
- for (p=line; *p && !isspace(*p); p++);
- if (!*p) continue;
- *p++ = 0;
- svport = strtoul(p, &z, 10);
-
- if (svport != port || z==p) continue;
- if (dgram && strncmp(z, "/udp", 4)) continue;
- if (!dgram && strncmp(z, "/tcp", 4)) continue;
- if (p-line > 32) continue;
-
- memcpy(buf, line, p-line);
- break;
- }
- __fclose_ca(f);
-}
-
-static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet)
-{
- if (rr != RR_PTR) return 0;
- if (__dn_expand(packet, (const unsigned char *)packet + 512,
- data, c, 256) <= 0)
- *(char *)c = 0;
- return 0;
-
-}
-
-int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl,
- char *restrict node, socklen_t nodelen,
- char *restrict serv, socklen_t servlen,
- int flags)
-{
- char ptr[PTR_MAX];
- char buf[256], num[3*sizeof(int)+1];
- int af = sa->sa_family;
- unsigned char *a;
- unsigned scopeid;
-
- switch (af) {
- case AF_INET:
- a = (void *)&((struct sockaddr_in *)sa)->sin_addr;
- if (sl < sizeof(struct sockaddr_in)) return EAI_FAMILY;
- mkptr4(ptr, a);
- scopeid = 0;
- break;
- case AF_INET6:
- a = (void *)&((struct sockaddr_in6 *)sa)->sin6_addr;
- if (sl < sizeof(struct sockaddr_in6)) return EAI_FAMILY;
- if (memcmp(a, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12))
- mkptr6(ptr, a);
- else
- mkptr4(ptr, a+12);
- scopeid = ((struct sockaddr_in6 *)sa)->sin6_scope_id;
- break;
- default:
- return EAI_FAMILY;
- }
-
- if (node && nodelen) {
- buf[0] = 0;
- if (!(flags & NI_NUMERICHOST)) {
- reverse_hosts(buf, a, scopeid, af);
- }
- if (!*buf && !(flags & NI_NUMERICHOST)) {
- unsigned char query[18+PTR_MAX], reply[512];
- int qlen = __res_mkquery(0, ptr, 1, RR_PTR,
- 0, 0, 0, query, sizeof query);
- query[3] = 0; /* don't need AD flag */
- int rlen = __res_send(query, qlen, reply, sizeof reply);
- buf[0] = 0;
- if (rlen > 0)
- __dns_parse(reply, rlen, dns_parse_callback, buf);
- }
- if (!*buf) {
- if (flags & NI_NAMEREQD) return EAI_NONAME;
- inet_ntop(af, a, buf, sizeof buf);
- if (scopeid) {
- char *p = 0, tmp[IF_NAMESIZE+1];
- if (!(flags & NI_NUMERICSCOPE) &&
- (IN6_IS_ADDR_LINKLOCAL(a) ||
- IN6_IS_ADDR_MC_LINKLOCAL(a)))
- p = if_indextoname(scopeid, tmp+1);
- if (!p)
- p = itoa(num, scopeid);
- *--p = '%';
- strcat(buf, p);
- }
- }
- if (strlen(buf) >= nodelen) return EAI_OVERFLOW;
- strcpy(node, buf);
- }
-
- if (serv && servlen) {
- char *p = buf;
- int port = ntohs(((struct sockaddr_in *)sa)->sin_port);
- buf[0] = 0;
- if (!(flags & NI_NUMERICSERV))
- reverse_services(buf, port, flags & NI_DGRAM);
- if (!*p)
- p = itoa(num, port);
- if (strlen(p) >= servlen)
- return EAI_OVERFLOW;
- strcpy(serv, p);
- }
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getpeername.c b/lib/libc/wasi/libc-top-half/musl/src/network/getpeername.c
deleted file mode 100644
index 6567b45191..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getpeername.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int getpeername(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
-{
- return socketcall(getpeername, fd, addr, len, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname.c b/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname.c
deleted file mode 100644
index dd3037678c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <netdb.h>
-
-struct servent *getservbyname(const char *name, const char *prots)
-{
- static struct servent se;
- static char *buf[2];
- struct servent *res;
- if (getservbyname_r(name, prots, &se, (void *)buf, sizeof buf, &res))
- return 0;
- return &se;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname_r.c b/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname_r.c
deleted file mode 100644
index cad6317ab8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyname_r.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include "lookup.h"
-
-#define ALIGN (sizeof(struct { char a; char *b; }) - sizeof(char *))
-
-int getservbyname_r(const char *name, const char *prots,
- struct servent *se, char *buf, size_t buflen, struct servent **res)
-{
- struct service servs[MAXSERVS];
- int cnt, proto, align;
-
- *res = 0;
-
- /* Don't treat numeric port number strings as service records. */
- char *end = "";
- strtoul(name, &end, 10);
- if (!*end) return ENOENT;
-
- /* Align buffer */
- align = -(uintptr_t)buf & ALIGN-1;
- if (buflen < 2*sizeof(char *)+align)
- return ERANGE;
- buf += align;
-
- if (!prots) proto = 0;
- else if (!strcmp(prots, "tcp")) proto = IPPROTO_TCP;
- else if (!strcmp(prots, "udp")) proto = IPPROTO_UDP;
- else return EINVAL;
-
- cnt = __lookup_serv(servs, name, proto, 0, 0);
- if (cnt<0) switch (cnt) {
- case EAI_MEMORY:
- case EAI_SYSTEM:
- return ENOMEM;
- default:
- return ENOENT;
- }
-
- se->s_name = (char *)name;
- se->s_aliases = (void *)buf;
- se->s_aliases[0] = se->s_name;
- se->s_aliases[1] = 0;
- se->s_port = htons(servs[0].port);
- se->s_proto = servs[0].proto == IPPROTO_TCP ? "tcp" : "udp";
-
- *res = se;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport.c b/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport.c
deleted file mode 100644
index c9ecbb11c8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <netdb.h>
-
-struct servent *getservbyport(int port, const char *prots)
-{
- static struct servent se;
- static long buf[32/sizeof(long)];
- struct servent *res;
- if (getservbyport_r(port, prots, &se, (void *)buf, sizeof buf, &res))
- return 0;
- return &se;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport_r.c b/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport_r.c
deleted file mode 100644
index b7f21c6b39..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getservbyport_r.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-int getservbyport_r(int port, const char *prots,
- struct servent *se, char *buf, size_t buflen, struct servent **res)
-{
- int i;
- struct sockaddr_in sin = {
- .sin_family = AF_INET,
- .sin_port = port,
- };
-
- if (!prots) {
- int r = getservbyport_r(port, "tcp", se, buf, buflen, res);
- if (r) r = getservbyport_r(port, "udp", se, buf, buflen, res);
- return r;
- }
- *res = 0;
-
- /* Align buffer */
- i = (uintptr_t)buf & sizeof(char *)-1;
- if (!i) i = sizeof(char *);
- if (buflen < 3*sizeof(char *)-i)
- return ERANGE;
- buf += sizeof(char *)-i;
- buflen -= sizeof(char *)-i;
-
- if (strcmp(prots, "tcp") && strcmp(prots, "udp")) return EINVAL;
-
- se->s_port = port;
- se->s_proto = (char *)prots;
- se->s_aliases = (void *)buf;
- buf += 2*sizeof(char *);
- buflen -= 2*sizeof(char *);
- se->s_aliases[1] = 0;
- se->s_aliases[0] = se->s_name = buf;
-
- switch (getnameinfo((void *)&sin, sizeof sin, 0, 0, buf, buflen,
- strcmp(prots, "udp") ? 0 : NI_DGRAM)) {
- case EAI_MEMORY:
- case EAI_SYSTEM:
- return ENOMEM;
- default:
- return ENOENT;
- case 0:
- break;
- }
-
- /* A numeric port string is not a service record. */
- if (strtol(buf, 0, 10)==ntohs(port)) return ENOENT;
-
- *res = se;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getsockname.c b/lib/libc/wasi/libc-top-half/musl/src/network/getsockname.c
deleted file mode 100644
index 7885fc13ba..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getsockname.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int getsockname(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
-{
- return socketcall(getsockname, fd, addr, len, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/getsockopt.c b/lib/libc/wasi/libc-top-half/musl/src/network/getsockopt.c
deleted file mode 100644
index d3640d9c91..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/getsockopt.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <errno.h>
-#include "syscall.h"
-
-int getsockopt(int fd, int level, int optname, void *restrict optval, socklen_t *restrict optlen)
-{
- long tv32[2];
- struct timeval *tv;
-
- int r = __socketcall(getsockopt, fd, level, optname, optval, optlen, 0);
-
- if (r==-ENOPROTOOPT) switch (level) {
- case SOL_SOCKET:
- switch (optname) {
- case SO_RCVTIMEO:
- case SO_SNDTIMEO:
- if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break;
- if (*optlen < sizeof *tv) return __syscall_ret(-EINVAL);
- if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD;
- if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD;
- r = __socketcall(getsockopt, fd, level, optname,
- tv32, (socklen_t[]){sizeof tv32}, 0);
- if (r<0) break;
- tv = optval;
- tv->tv_sec = tv32[0];
- tv->tv_usec = tv32[1];
- *optlen = sizeof *tv;
- break;
- case SO_TIMESTAMP:
- case SO_TIMESTAMPNS:
- if (SO_TIMESTAMP == SO_TIMESTAMP_OLD) break;
- if (optname==SO_TIMESTAMP) optname=SO_TIMESTAMP_OLD;
- if (optname==SO_TIMESTAMPNS) optname=SO_TIMESTAMPNS_OLD;
- r = __socketcall(getsockopt, fd, level,
- optname, optval, optlen, 0);
- break;
- }
- }
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/h_errno.c b/lib/libc/wasi/libc-top-half/musl/src/network/h_errno.c
deleted file mode 100644
index 638f771803..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/h_errno.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <netdb.h>
-#include "pthread_impl.h"
-
-#undef h_errno
-int h_errno;
-
-int *__h_errno_location(void)
-{
- if (!__pthread_self()->stack) return &h_errno;
- return &__pthread_self()->h_errno_val;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/herror.c b/lib/libc/wasi/libc-top-half/musl/src/network/herror.c
deleted file mode 100644
index 87f8cff4fd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/herror.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <netdb.h>
-
-void herror(const char *msg)
-{
- fprintf(stderr, "%s%s%s\n", msg?msg:"", msg?": ":"", hstrerror(h_errno));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/hstrerror.c b/lib/libc/wasi/libc-top-half/musl/src/network/hstrerror.c
deleted file mode 100644
index a4d001c534..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/hstrerror.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#define _GNU_SOURCE
-#include <netdb.h>
-#include "locale_impl.h"
-
-static const char msgs[] =
- "Host not found\0"
- "Try again\0"
- "Non-recoverable error\0"
- "Address not available\0"
- "\0Unknown error";
-
-const char *hstrerror(int ecode)
-{
- const char *s;
- for (s=msgs, ecode--; ecode && *s; ecode--, s++) for (; *s; s++);
- if (!*s) s++;
- return LCTRANS_CUR(s);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/if_freenameindex.c b/lib/libc/wasi/libc-top-half/musl/src/network/if_freenameindex.c
deleted file mode 100644
index 89bafcc0ca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/if_freenameindex.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <net/if.h>
-#include <stdlib.h>
-
-void if_freenameindex(struct if_nameindex *idx)
-{
- free(idx);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/if_indextoname.c b/lib/libc/wasi/libc-top-half/musl/src/network/if_indextoname.c
deleted file mode 100644
index 3b368bf0d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/if_indextoname.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#define _GNU_SOURCE
-#include <net/if.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include <errno.h>
-#include "syscall.h"
-
-char *if_indextoname(unsigned index, char *name)
-{
- struct ifreq ifr;
- int fd, r;
-
- if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
- ifr.ifr_ifindex = index;
- r = ioctl(fd, SIOCGIFNAME, &ifr);
- __syscall(SYS_close, fd);
- if (r < 0) {
- if (errno == ENODEV) errno = ENXIO;
- return 0;
- }
- return strncpy(name, ifr.ifr_name, IF_NAMESIZE);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/if_nameindex.c b/lib/libc/wasi/libc-top-half/musl/src/network/if_nameindex.c
deleted file mode 100644
index 2deaef7696..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/if_nameindex.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#define _GNU_SOURCE
-#include <net/if.h>
-#include <errno.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <pthread.h>
-#include "netlink.h"
-
-#define IFADDRS_HASH_SIZE 64
-
-struct ifnamemap {
- unsigned int hash_next;
- unsigned int index;
- unsigned char namelen;
- char name[IFNAMSIZ];
-};
-
-struct ifnameindexctx {
- unsigned int num, allocated, str_bytes;
- struct ifnamemap *list;
- unsigned int hash[IFADDRS_HASH_SIZE];
-};
-
-static int netlink_msg_to_nameindex(void *pctx, struct nlmsghdr *h)
-{
- struct ifnameindexctx *ctx = pctx;
- struct ifnamemap *map;
- struct rtattr *rta;
- unsigned int i;
- int index, type, namelen, bucket;
-
- if (h->nlmsg_type == RTM_NEWLINK) {
- struct ifinfomsg *ifi = NLMSG_DATA(h);
- index = ifi->ifi_index;
- type = IFLA_IFNAME;
- rta = NLMSG_RTA(h, sizeof(*ifi));
- } else {
- struct ifaddrmsg *ifa = NLMSG_DATA(h);
- index = ifa->ifa_index;
- type = IFA_LABEL;
- rta = NLMSG_RTA(h, sizeof(*ifa));
- }
- for (; NLMSG_RTAOK(rta, h); rta = RTA_NEXT(rta)) {
- if (rta->rta_type != type) continue;
-
- namelen = RTA_DATALEN(rta) - 1;
- if (namelen > IFNAMSIZ) return 0;
-
- /* suppress duplicates */
- bucket = index % IFADDRS_HASH_SIZE;
- i = ctx->hash[bucket];
- while (i) {
- map = &ctx->list[i-1];
- if (map->index == index &&
- map->namelen == namelen &&
- memcmp(map->name, RTA_DATA(rta), namelen) == 0)
- return 0;
- i = map->hash_next;
- }
-
- if (ctx->num >= ctx->allocated) {
- size_t a = ctx->allocated ? ctx->allocated * 2 + 1 : 8;
- if (a > SIZE_MAX/sizeof *map) return -1;
- map = realloc(ctx->list, a * sizeof *map);
- if (!map) return -1;
- ctx->list = map;
- ctx->allocated = a;
- }
- map = &ctx->list[ctx->num];
- map->index = index;
- map->namelen = namelen;
- memcpy(map->name, RTA_DATA(rta), namelen);
- ctx->str_bytes += namelen + 1;
- ctx->num++;
- map->hash_next = ctx->hash[bucket];
- ctx->hash[bucket] = ctx->num;
- return 0;
- }
- return 0;
-}
-
-struct if_nameindex *if_nameindex()
-{
- struct ifnameindexctx _ctx, *ctx = &_ctx;
- struct if_nameindex *ifs = 0, *d;
- struct ifnamemap *s;
- char *p;
- int i;
- int cs;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- memset(ctx, 0, sizeof(*ctx));
- if (__rtnetlink_enumerate(AF_UNSPEC, AF_INET, netlink_msg_to_nameindex, ctx) < 0) goto err;
-
- ifs = malloc(sizeof(struct if_nameindex[ctx->num+1]) + ctx->str_bytes);
- if (!ifs) goto err;
-
- p = (char*)(ifs + ctx->num + 1);
- for (i = ctx->num, d = ifs, s = ctx->list; i; i--, s++, d++) {
- d->if_index = s->index;
- d->if_name = p;
- memcpy(p, s->name, s->namelen);
- p += s->namelen;
- *p++ = 0;
- }
- d->if_index = 0;
- d->if_name = 0;
-err:
- pthread_setcancelstate(cs, 0);
- free(ctx->list);
- errno = ENOBUFS;
- return ifs;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/if_nametoindex.c b/lib/libc/wasi/libc-top-half/musl/src/network/if_nametoindex.c
deleted file mode 100644
index 331413c689..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/if_nametoindex.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#define _GNU_SOURCE
-#include <net/if.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <string.h>
-#include "syscall.h"
-
-unsigned if_nametoindex(const char *name)
-{
- struct ifreq ifr;
- int fd, r;
-
- if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
- strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
- r = ioctl(fd, SIOCGIFINDEX, &ifr);
- __syscall(SYS_close, fd);
- return r < 0 ? 0 : ifr.ifr_ifindex;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/inet_addr.c b/lib/libc/wasi/libc-top-half/musl/src/network/inet_addr.c
deleted file mode 100644
index 11ece3d6f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/inet_addr.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-in_addr_t inet_addr(const char *p)
-{
- struct in_addr a;
- if (!__inet_aton(p, &a)) return -1;
- return a.s_addr;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/inet_legacy.c b/lib/libc/wasi/libc-top-half/musl/src/network/inet_legacy.c
deleted file mode 100644
index 621b47b050..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/inet_legacy.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-in_addr_t inet_network(const char *p)
-{
- return ntohl(inet_addr(p));
-}
-
-struct in_addr inet_makeaddr(in_addr_t n, in_addr_t h)
-{
- if (n < 256) h |= n<<24;
- else if (n < 65536) h |= n<<16;
- else h |= n<<8;
- return (struct in_addr){ h };
-}
-
-in_addr_t inet_lnaof(struct in_addr in)
-{
- uint32_t h = in.s_addr;
- if (h>>24 < 128) return h & 0xffffff;
- if (h>>24 < 192) return h & 0xffff;
- return h & 0xff;
-}
-
-in_addr_t inet_netof(struct in_addr in)
-{
- uint32_t h = in.s_addr;
- if (h>>24 < 128) return h >> 24;
- if (h>>24 < 192) return h >> 16;
- return h >> 8;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/inet_ntoa.c b/lib/libc/wasi/libc-top-half/musl/src/network/inet_ntoa.c
deleted file mode 100644
index 71411e0b5f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/inet_ntoa.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <arpa/inet.h>
-#include <stdio.h>
-
-char *inet_ntoa(struct in_addr in)
-{
- static char buf[16];
- unsigned char *a = (void *)&in;
- snprintf(buf, sizeof buf, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
- return buf;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/listen.c b/lib/libc/wasi/libc-top-half/musl/src/network/listen.c
deleted file mode 100644
index f84ad03b7a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/listen.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int listen(int fd, int backlog)
-{
- return socketcall(listen, fd, backlog, 0, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_ipliteral.c b/lib/libc/wasi/libc-top-half/musl/src/network/lookup_ipliteral.c
deleted file mode 100644
index 2fddab7373..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_ipliteral.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include "lookup.h"
-
-int __lookup_ipliteral(struct address buf[static 1], const char *name, int family)
-{
- struct in_addr a4;
- struct in6_addr a6;
- if (__inet_aton(name, &a4) > 0) {
- if (family == AF_INET6) /* wrong family */
- return EAI_NONAME;
- memcpy(&buf[0].addr, &a4, sizeof a4);
- buf[0].family = AF_INET;
- buf[0].scopeid = 0;
- return 1;
- }
-
- char tmp[64];
- char *p = strchr(name, '%'), *z;
- unsigned long long scopeid = 0;
- if (p && p-name < 64) {
- memcpy(tmp, name, p-name);
- tmp[p-name] = 0;
- name = tmp;
- }
-
- if (inet_pton(AF_INET6, name, &a6) <= 0)
- return 0;
- if (family == AF_INET) /* wrong family */
- return EAI_NONAME;
-
- memcpy(&buf[0].addr, &a6, sizeof a6);
- buf[0].family = AF_INET6;
- if (p) {
- if (isdigit(*++p)) scopeid = strtoull(p, &z, 10);
- else z = p-1;
- if (*z) {
- if (!IN6_IS_ADDR_LINKLOCAL(&a6) &&
- !IN6_IS_ADDR_MC_LINKLOCAL(&a6))
- return EAI_NONAME;
- scopeid = if_nametoindex(p);
- if (!scopeid) return EAI_NONAME;
- }
- if (scopeid > UINT_MAX) return EAI_NONAME;
- }
- buf[0].scopeid = scopeid;
- return 1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_name.c b/lib/libc/wasi/libc-top-half/musl/src/network/lookup_name.c
deleted file mode 100644
index aa558c197a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_name.c
+++ /dev/null
@@ -1,425 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <net/if.h>
-#include <arpa/inet.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <pthread.h>
-#include <errno.h>
-#include <resolv.h>
-#include "lookup.h"
-#include "stdio_impl.h"
-#include "syscall.h"
-
-static int is_valid_hostname(const char *host)
-{
- const unsigned char *s;
- if (strnlen(host, 255)-1 >= 254 || mbstowcs(0, host, 0) == -1) return 0;
- for (s=(void *)host; *s>=0x80 || *s=='.' || *s=='-' || isalnum(*s); s++);
- return !*s;
-}
-
-static int name_from_null(struct address buf[static 2], const char *name, int family, int flags)
-{
- int cnt = 0;
- if (name) return 0;
- if (flags & AI_PASSIVE) {
- if (family != AF_INET6)
- buf[cnt++] = (struct address){ .family = AF_INET };
- if (family != AF_INET)
- buf[cnt++] = (struct address){ .family = AF_INET6 };
- } else {
- if (family != AF_INET6)
- buf[cnt++] = (struct address){ .family = AF_INET, .addr = { 127,0,0,1 } };
- if (family != AF_INET)
- buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } };
- }
- return cnt;
-}
-
-static int name_from_numeric(struct address buf[static 1], const char *name, int family)
-{
- return __lookup_ipliteral(buf, name, family);
-}
-
-static int name_from_hosts(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
-{
- char line[512];
- size_t l = strlen(name);
- int cnt = 0, badfam = 0, have_canon = 0;
- unsigned char _buf[1032];
- FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf);
- if (!f) switch (errno) {
- case ENOENT:
- case ENOTDIR:
- case EACCES:
- return 0;
- default:
- return EAI_SYSTEM;
- }
- while (fgets(line, sizeof line, f) && cnt < MAXADDRS) {
- char *p, *z;
-
- if ((p=strchr(line, '#'))) *p++='\n', *p=0;
- for(p=line+1; (p=strstr(p, name)) &&
- (!isspace(p[-1]) || !isspace(p[l])); p++);
- if (!p) continue;
-
- /* Isolate IP address to parse */
- for (p=line; *p && !isspace(*p); p++);
- *p++ = 0;
- switch (name_from_numeric(buf+cnt, line, family)) {
- case 1:
- cnt++;
- break;
- case 0:
- continue;
- default:
- badfam = EAI_NONAME;
- break;
- }
-
- if (have_canon) continue;
-
- /* Extract first name as canonical name */
- for (; *p && isspace(*p); p++);
- for (z=p; *z && !isspace(*z); z++);
- *z = 0;
- if (is_valid_hostname(p)) {
- have_canon = 1;
- memcpy(canon, p, z-p+1);
- }
- }
- __fclose_ca(f);
- return cnt ? cnt : badfam;
-}
-
-struct dpc_ctx {
- struct address *addrs;
- char *canon;
- int cnt;
-};
-
-#define RR_A 1
-#define RR_CNAME 5
-#define RR_AAAA 28
-
-static int dns_parse_callback(void *c, int rr, const void *data, int len, const void *packet)
-{
- char tmp[256];
- struct dpc_ctx *ctx = c;
- if (ctx->cnt >= MAXADDRS) return -1;
- switch (rr) {
- case RR_A:
- if (len != 4) return -1;
- ctx->addrs[ctx->cnt].family = AF_INET;
- ctx->addrs[ctx->cnt].scopeid = 0;
- memcpy(ctx->addrs[ctx->cnt++].addr, data, 4);
- break;
- case RR_AAAA:
- if (len != 16) return -1;
- ctx->addrs[ctx->cnt].family = AF_INET6;
- ctx->addrs[ctx->cnt].scopeid = 0;
- memcpy(ctx->addrs[ctx->cnt++].addr, data, 16);
- break;
- case RR_CNAME:
- if (__dn_expand(packet, (const unsigned char *)packet + 512,
- data, tmp, sizeof tmp) > 0 && is_valid_hostname(tmp))
- strcpy(ctx->canon, tmp);
- break;
- }
- return 0;
-}
-
-static int name_from_dns(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, const struct resolvconf *conf)
-{
- unsigned char qbuf[2][280], abuf[2][512];
- const unsigned char *qp[2] = { qbuf[0], qbuf[1] };
- unsigned char *ap[2] = { abuf[0], abuf[1] };
- int qlens[2], alens[2];
- int i, nq = 0;
- struct dpc_ctx ctx = { .addrs = buf, .canon = canon };
- static const struct { int af; int rr; } afrr[2] = {
- { .af = AF_INET6, .rr = RR_A },
- { .af = AF_INET, .rr = RR_AAAA },
- };
-
- for (i=0; i<2; i++) {
- if (family != afrr[i].af) {
- qlens[nq] = __res_mkquery(0, name, 1, afrr[i].rr,
- 0, 0, 0, qbuf[nq], sizeof *qbuf);
- if (qlens[nq] == -1)
- return EAI_NONAME;
- qbuf[nq][3] = 0; /* don't need AD flag */
- nq++;
- }
- }
-
- if (__res_msend_rc(nq, qp, qlens, ap, alens, sizeof *abuf, conf) < 0)
- return EAI_SYSTEM;
-
- for (i=0; i<nq; i++) {
- if (alens[i] < 4 || (abuf[i][3] & 15) == 2) return EAI_AGAIN;
- if ((abuf[i][3] & 15) == 3) return 0;
- if ((abuf[i][3] & 15) != 0) return EAI_FAIL;
- }
-
- for (i=0; i<nq; i++)
- __dns_parse(abuf[i], alens[i], dns_parse_callback, &ctx);
-
- if (ctx.cnt) return ctx.cnt;
- return EAI_NONAME;
-}
-
-static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family)
-{
- char search[256];
- struct resolvconf conf;
- size_t l, dots;
- char *p, *z;
-
- if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1;
-
- /* Count dots, suppress search when >=ndots or name ends in
- * a dot, which is an explicit request for global scope. */
- for (dots=l=0; name[l]; l++) if (name[l]=='.') dots++;
- if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
-
- /* Strip final dot for canon, fail if multiple trailing dots. */
- if (name[l-1]=='.') l--;
- if (!l || name[l-1]=='.') return EAI_NONAME;
-
- /* This can never happen; the caller already checked length. */
- if (l >= 256) return EAI_NONAME;
-
- /* Name with search domain appended is setup in canon[]. This both
- * provides the desired default canonical name (if the requested
- * name is not a CNAME record) and serves as a buffer for passing
- * the full requested name to name_from_dns. */
- memcpy(canon, name, l);
- canon[l] = '.';
-
- for (p=search; *p; p=z) {
- for (; isspace(*p); p++);
- for (z=p; *z && !isspace(*z); z++);
- if (z==p) break;
- if (z-p < 256 - l - 1) {
- memcpy(canon+l+1, p, z-p);
- canon[z-p+1+l] = 0;
- int cnt = name_from_dns(buf, canon, canon, family, &conf);
- if (cnt) return cnt;
- }
- }
-
- canon[l] = 0;
- return name_from_dns(buf, canon, name, family, &conf);
-}
-
-static const struct policy {
- unsigned char addr[16];
- unsigned char len, mask;
- unsigned char prec, label;
-} defpolicy[] = {
- { "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1", 15, 0xff, 50, 0 },
- { "\0\0\0\0\0\0\0\0\0\0\xff\xff", 11, 0xff, 35, 4 },
- { "\x20\2", 1, 0xff, 30, 2 },
- { "\x20\1", 3, 0xff, 5, 5 },
- { "\xfc", 0, 0xfe, 3, 13 },
-#if 0
- /* These are deprecated and/or returned to the address
- * pool, so despite the RFC, treating them as special
- * is probably wrong. */
- { "", 11, 0xff, 1, 3 },
- { "\xfe\xc0", 1, 0xc0, 1, 11 },
- { "\x3f\xfe", 1, 0xff, 1, 12 },
-#endif
- /* Last rule must match all addresses to stop loop. */
- { "", 0, 0, 40, 1 },
-};
-
-static const struct policy *policyof(const struct in6_addr *a)
-{
- int i;
- for (i=0; ; i++) {
- if (memcmp(a->s6_addr, defpolicy[i].addr, defpolicy[i].len))
- continue;
- if ((a->s6_addr[defpolicy[i].len] & defpolicy[i].mask)
- != defpolicy[i].addr[defpolicy[i].len])
- continue;
- return defpolicy+i;
- }
-}
-
-static int labelof(const struct in6_addr *a)
-{
- return policyof(a)->label;
-}
-
-static int scopeof(const struct in6_addr *a)
-{
- if (IN6_IS_ADDR_MULTICAST(a)) return a->s6_addr[1] & 15;
- if (IN6_IS_ADDR_LINKLOCAL(a)) return 2;
- if (IN6_IS_ADDR_LOOPBACK(a)) return 2;
- if (IN6_IS_ADDR_SITELOCAL(a)) return 5;
- return 14;
-}
-
-static int prefixmatch(const struct in6_addr *s, const struct in6_addr *d)
-{
- /* FIXME: The common prefix length should be limited to no greater
- * than the nominal length of the prefix portion of the source
- * address. However the definition of the source prefix length is
- * not clear and thus this limiting is not yet implemented. */
- unsigned i;
- for (i=0; i<128 && !((s->s6_addr[i/8]^d->s6_addr[i/8])&(128>>(i%8))); i++);
- return i;
-}
-
-#define DAS_USABLE 0x40000000
-#define DAS_MATCHINGSCOPE 0x20000000
-#define DAS_MATCHINGLABEL 0x10000000
-#define DAS_PREC_SHIFT 20
-#define DAS_SCOPE_SHIFT 16
-#define DAS_PREFIX_SHIFT 8
-#define DAS_ORDER_SHIFT 0
-
-static int addrcmp(const void *_a, const void *_b)
-{
- const struct address *a = _a, *b = _b;
- return b->sortkey - a->sortkey;
-}
-
-int __lookup_name(struct address buf[static MAXADDRS], char canon[static 256], const char *name, int family, int flags)
-{
- int cnt = 0, i, j;
-
- *canon = 0;
- if (name) {
- /* reject empty name and check len so it fits into temp bufs */
- size_t l = strnlen(name, 255);
- if (l-1 >= 254)
- return EAI_NONAME;
- memcpy(canon, name, l+1);
- }
-
- /* Procedurally, a request for v6 addresses with the v4-mapped
- * flag set is like a request for unspecified family, followed
- * by filtering of the results. */
- if (flags & AI_V4MAPPED) {
- if (family == AF_INET6) family = AF_UNSPEC;
- else flags -= AI_V4MAPPED;
- }
-
- /* Try each backend until there's at least one result. */
- cnt = name_from_null(buf, name, family, flags);
- if (!cnt) cnt = name_from_numeric(buf, name, family);
- if (!cnt && !(flags & AI_NUMERICHOST)) {
- cnt = name_from_hosts(buf, canon, name, family);
- if (!cnt) cnt = name_from_dns_search(buf, canon, name, family);
- }
- if (cnt<=0) return cnt ? cnt : EAI_NONAME;
-
- /* Filter/transform results for v4-mapped lookup, if requested. */
- if (flags & AI_V4MAPPED) {
- if (!(flags & AI_ALL)) {
- /* If any v6 results exist, remove v4 results. */
- for (i=0; i<cnt && buf[i].family != AF_INET6; i++);
- if (i<cnt) {
- for (j=0; i<cnt; i++) {
- if (buf[i].family == AF_INET6)
- buf[j++] = buf[i];
- }
- cnt = i = j;
- }
- }
- /* Translate any remaining v4 results to v6 */
- for (i=0; i<cnt; i++) {
- if (buf[i].family != AF_INET) continue;
- memcpy(buf[i].addr+12, buf[i].addr, 4);
- memcpy(buf[i].addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- buf[i].family = AF_INET6;
- }
- }
-
- /* No further processing is needed if there are fewer than 2
- * results or if there are only IPv4 results. */
- if (cnt<2 || family==AF_INET) return cnt;
- for (i=0; i<cnt; i++) if (buf[i].family != AF_INET) break;
- if (i==cnt) return cnt;
-
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- /* The following implements a subset of RFC 3484/6724 destination
- * address selection by generating a single 31-bit sort key for
- * each address. Rules 3, 4, and 7 are omitted for having
- * excessive runtime and code size cost and dubious benefit.
- * So far the label/precedence table cannot be customized. */
- for (i=0; i<cnt; i++) {
- int family = buf[i].family;
- int key = 0;
- struct sockaddr_in6 sa6 = { 0 }, da6 = {
- .sin6_family = AF_INET6,
- .sin6_scope_id = buf[i].scopeid,
- .sin6_port = 65535
- };
- struct sockaddr_in sa4 = { 0 }, da4 = {
- .sin_family = AF_INET,
- .sin_port = 65535
- };
- void *sa, *da;
- socklen_t salen, dalen;
- if (family == AF_INET6) {
- memcpy(da6.sin6_addr.s6_addr, buf[i].addr, 16);
- da = &da6; dalen = sizeof da6;
- sa = &sa6; salen = sizeof sa6;
- } else {
- memcpy(sa6.sin6_addr.s6_addr,
- "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
- memcpy(da6.sin6_addr.s6_addr,
- "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
- memcpy(&da4.sin_addr, buf[i].addr, 4);
- da = &da4; dalen = sizeof da4;
- sa = &sa4; salen = sizeof sa4;
- }
- const struct policy *dpolicy = policyof(&da6.sin6_addr);
- int dscope = scopeof(&da6.sin6_addr);
- int dlabel = dpolicy->label;
- int dprec = dpolicy->prec;
- int prefixlen = 0;
- int fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
- if (fd >= 0) {
- if (!connect(fd, da, dalen)) {
- key |= DAS_USABLE;
- if (!getsockname(fd, sa, &salen)) {
- if (family == AF_INET) memcpy(
- sa6.sin6_addr.s6_addr+12,
- &sa4.sin_addr, 4);
- if (dscope == scopeof(&sa6.sin6_addr))
- key |= DAS_MATCHINGSCOPE;
- if (dlabel == labelof(&sa6.sin6_addr))
- key |= DAS_MATCHINGLABEL;
- prefixlen = prefixmatch(&sa6.sin6_addr,
- &da6.sin6_addr);
- }
- }
- close(fd);
- }
- key |= dprec << DAS_PREC_SHIFT;
- key |= (15-dscope) << DAS_SCOPE_SHIFT;
- key |= prefixlen << DAS_PREFIX_SHIFT;
- key |= (MAXADDRS-i) << DAS_ORDER_SHIFT;
- buf[i].sortkey = key;
- }
- qsort(buf, cnt, sizeof *buf, addrcmp);
-
- pthread_setcancelstate(cs, 0);
-
- return cnt;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_serv.c b/lib/libc/wasi/libc-top-half/musl/src/network/lookup_serv.c
deleted file mode 100644
index ae38277851..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/lookup_serv.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "lookup.h"
-#include "stdio_impl.h"
-
-int __lookup_serv(struct service buf[static MAXSERVS], const char *name, int proto, int socktype, int flags)
-{
- char line[128];
- int cnt = 0;
- char *p, *z = "";
- unsigned long port = 0;
-
- switch (socktype) {
- case SOCK_STREAM:
- switch (proto) {
- case 0:
- proto = IPPROTO_TCP;
- case IPPROTO_TCP:
- break;
- default:
- return EAI_SERVICE;
- }
- break;
- case SOCK_DGRAM:
- switch (proto) {
- case 0:
- proto = IPPROTO_UDP;
- case IPPROTO_UDP:
- break;
- default:
- return EAI_SERVICE;
- }
- case 0:
- break;
- default:
- if (name) return EAI_SERVICE;
- buf[0].port = 0;
- buf[0].proto = proto;
- buf[0].socktype = socktype;
- return 1;
- }
-
- if (name) {
- if (!*name) return EAI_SERVICE;
- port = strtoul(name, &z, 10);
- }
- if (!*z) {
- if (port > 65535) return EAI_SERVICE;
- if (proto != IPPROTO_UDP) {
- buf[cnt].port = port;
- buf[cnt].socktype = SOCK_STREAM;
- buf[cnt++].proto = IPPROTO_TCP;
- }
- if (proto != IPPROTO_TCP) {
- buf[cnt].port = port;
- buf[cnt].socktype = SOCK_DGRAM;
- buf[cnt++].proto = IPPROTO_UDP;
- }
- return cnt;
- }
-
- if (flags & AI_NUMERICSERV) return EAI_NONAME;
-
- size_t l = strlen(name);
-
- unsigned char _buf[1032];
- FILE _f, *f = __fopen_rb_ca("/etc/services", &_f, _buf, sizeof _buf);
- if (!f) switch (errno) {
- case ENOENT:
- case ENOTDIR:
- case EACCES:
- return EAI_SERVICE;
- default:
- return EAI_SYSTEM;
- }
-
- while (fgets(line, sizeof line, f) && cnt < MAXSERVS) {
- if ((p=strchr(line, '#'))) *p++='\n', *p=0;
-
- /* Find service name */
- for(p=line; (p=strstr(p, name)); p++) {
- if (p>line && !isspace(p[-1])) continue;
- if (p[l] && !isspace(p[l])) continue;
- break;
- }
- if (!p) continue;
-
- /* Skip past canonical name at beginning of line */
- for (p=line; *p && !isspace(*p); p++);
-
- port = strtoul(p, &z, 10);
- if (port > 65535 || z==p) continue;
- if (!strncmp(z, "/udp", 4)) {
- if (proto == IPPROTO_TCP) continue;
- buf[cnt].port = port;
- buf[cnt].socktype = SOCK_DGRAM;
- buf[cnt++].proto = IPPROTO_UDP;
- }
- if (!strncmp(z, "/tcp", 4)) {
- if (proto == IPPROTO_UDP) continue;
- buf[cnt].port = port;
- buf[cnt].socktype = SOCK_STREAM;
- buf[cnt++].proto = IPPROTO_TCP;
- }
- }
- __fclose_ca(f);
- return cnt > 0 ? cnt : EAI_SERVICE;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/netlink.c b/lib/libc/wasi/libc-top-half/musl/src/network/netlink.c
deleted file mode 100644
index 94dba7f5c9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/netlink.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <errno.h>
-#include <string.h>
-#include <syscall.h>
-#include <sys/socket.h>
-#include "netlink.h"
-
-static int __netlink_enumerate(int fd, unsigned int seq, int type, int af,
- int (*cb)(void *ctx, struct nlmsghdr *h), void *ctx)
-{
- struct nlmsghdr *h;
- union {
- uint8_t buf[8192];
- struct {
- struct nlmsghdr nlh;
- struct rtgenmsg g;
- } req;
- struct nlmsghdr reply;
- } u;
- int r, ret;
-
- memset(&u.req, 0, sizeof(u.req));
- u.req.nlh.nlmsg_len = sizeof(u.req);
- u.req.nlh.nlmsg_type = type;
- u.req.nlh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
- u.req.nlh.nlmsg_seq = seq;
- u.req.g.rtgen_family = af;
- r = send(fd, &u.req, sizeof(u.req), 0);
- if (r < 0) return r;
-
- while (1) {
- r = recv(fd, u.buf, sizeof(u.buf), MSG_DONTWAIT);
- if (r <= 0) return -1;
- for (h = &u.reply; NLMSG_OK(h, (void*)&u.buf[r]); h = NLMSG_NEXT(h)) {
- if (h->nlmsg_type == NLMSG_DONE) return 0;
- if (h->nlmsg_type == NLMSG_ERROR) return -1;
- ret = cb(ctx, h);
- if (ret) return ret;
- }
- }
-}
-
-int __rtnetlink_enumerate(int link_af, int addr_af, int (*cb)(void *ctx, struct nlmsghdr *h), void *ctx)
-{
- int fd, r;
-
- fd = socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_ROUTE);
- if (fd < 0) return -1;
- r = __netlink_enumerate(fd, 1, RTM_GETLINK, link_af, cb, ctx);
- if (!r) r = __netlink_enumerate(fd, 2, RTM_GETADDR, addr_af, cb, ctx);
- __syscall(SYS_close,fd);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/netname.c b/lib/libc/wasi/libc-top-half/musl/src/network/netname.c
deleted file mode 100644
index ba6e665681..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/netname.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <netdb.h>
-
-struct netent *getnetbyaddr(uint32_t net, int type)
-{
- return 0;
-}
-
-struct netent *getnetbyname(const char *name)
-{
- return 0;
-}
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/ns_parse.c b/lib/libc/wasi/libc-top-half/musl/src/network/ns_parse.c
deleted file mode 100644
index d01da47a3d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/ns_parse.c
+++ /dev/null
@@ -1,171 +0,0 @@
-#define _BSD_SOURCE
-#include <errno.h>
-#include <stddef.h>
-#include <resolv.h>
-#include <arpa/nameser.h>
-
-const struct _ns_flagdata _ns_flagdata[16] = {
- { 0x8000, 15 },
- { 0x7800, 11 },
- { 0x0400, 10 },
- { 0x0200, 9 },
- { 0x0100, 8 },
- { 0x0080, 7 },
- { 0x0040, 6 },
- { 0x0020, 5 },
- { 0x0010, 4 },
- { 0x000f, 0 },
- { 0x0000, 0 },
- { 0x0000, 0 },
- { 0x0000, 0 },
- { 0x0000, 0 },
- { 0x0000, 0 },
- { 0x0000, 0 },
-};
-
-unsigned ns_get16(const unsigned char *cp)
-{
- return cp[0]<<8 | cp[1];
-}
-
-unsigned long ns_get32(const unsigned char *cp)
-{
- return (unsigned)cp[0]<<24 | cp[1]<<16 | cp[2]<<8 | cp[3];
-}
-
-void ns_put16(unsigned s, unsigned char *cp)
-{
- *cp++ = s>>8;
- *cp++ = s;
-}
-
-void ns_put32(unsigned long l, unsigned char *cp)
-{
- *cp++ = l>>24;
- *cp++ = l>>16;
- *cp++ = l>>8;
- *cp++ = l;
-}
-
-int ns_initparse(const unsigned char *msg, int msglen, ns_msg *handle)
-{
- int i, r;
-
- handle->_msg = msg;
- handle->_eom = msg + msglen;
- if (msglen < (2 + ns_s_max) * NS_INT16SZ) goto bad;
- NS_GET16(handle->_id, msg);
- NS_GET16(handle->_flags, msg);
- for (i = 0; i < ns_s_max; i++) NS_GET16(handle->_counts[i], msg);
- for (i = 0; i < ns_s_max; i++) {
- if (handle->_counts[i]) {
- handle->_sections[i] = msg;
- r = ns_skiprr(msg, handle->_eom, i, handle->_counts[i]);
- if (r < 0) return -1;
- msg += r;
- } else {
- handle->_sections[i] = NULL;
- }
- }
- if (msg != handle->_eom) goto bad;
- handle->_sect = ns_s_max;
- handle->_rrnum = -1;
- handle->_msg_ptr = NULL;
- return 0;
-bad:
- errno = EMSGSIZE;
- return -1;
-}
-
-int ns_skiprr(const unsigned char *ptr, const unsigned char *eom, ns_sect section, int count)
-{
- const unsigned char *p = ptr;
- int r;
-
- while (count--) {
- r = dn_skipname(p, eom);
- if (r < 0) goto bad;
- if (r + 2 * NS_INT16SZ > eom - p) goto bad;
- p += r + 2 * NS_INT16SZ;
- if (section != ns_s_qd) {
- if (NS_INT32SZ + NS_INT16SZ > eom - p) goto bad;
- p += NS_INT32SZ;
- NS_GET16(r, p);
- if (r > eom - p) goto bad;
- p += r;
- }
- }
- return p - ptr;
-bad:
- errno = EMSGSIZE;
- return -1;
-}
-
-int ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr)
-{
- int r;
-
- if (section < 0 || section >= ns_s_max) goto bad;
- if (section != handle->_sect) {
- handle->_sect = section;
- handle->_rrnum = 0;
- handle->_msg_ptr = handle->_sections[section];
- }
- if (rrnum == -1) rrnum = handle->_rrnum;
- if (rrnum < 0 || rrnum >= handle->_counts[section]) goto bad;
- if (rrnum < handle->_rrnum) {
- handle->_rrnum = 0;
- handle->_msg_ptr = handle->_sections[section];
- }
- if (rrnum > handle->_rrnum) {
- r = ns_skiprr(handle->_msg_ptr, handle->_eom, section, rrnum - handle->_rrnum);
- if (r < 0) return -1;
- handle->_msg_ptr += r;
- handle->_rrnum = rrnum;
- }
- r = ns_name_uncompress(handle->_msg, handle->_eom, handle->_msg_ptr, rr->name, NS_MAXDNAME);
- if (r < 0) return -1;
- handle->_msg_ptr += r;
- if (2 * NS_INT16SZ > handle->_eom - handle->_msg_ptr) goto size;
- NS_GET16(rr->type, handle->_msg_ptr);
- NS_GET16(rr->rr_class, handle->_msg_ptr);
- if (section != ns_s_qd) {
- if (NS_INT32SZ + NS_INT16SZ > handle->_eom - handle->_msg_ptr) goto size;
- NS_GET32(rr->ttl, handle->_msg_ptr);
- NS_GET16(rr->rdlength, handle->_msg_ptr);
- if (rr->rdlength > handle->_eom - handle->_msg_ptr) goto size;
- rr->rdata = handle->_msg_ptr;
- handle->_msg_ptr += rr->rdlength;
- } else {
- rr->ttl = 0;
- rr->rdlength = 0;
- rr->rdata = NULL;
- }
- handle->_rrnum++;
- if (handle->_rrnum > handle->_counts[section]) {
- handle->_sect = section + 1;
- if (handle->_sect == ns_s_max) {
- handle->_rrnum = -1;
- handle->_msg_ptr = NULL;
- } else {
- handle->_rrnum = 0;
- }
- }
- return 0;
-bad:
- errno = ENODEV;
- return -1;
-size:
- errno = EMSGSIZE;
- return -1;
-}
-
-int ns_name_uncompress(const unsigned char *msg, const unsigned char *eom,
- const unsigned char *src, char *dst, size_t dstsiz)
-{
- int r;
- r = dn_expand(msg, eom, src, dst, dstsiz);
- if (r < 0) errno = EMSGSIZE;
- return r;
-}
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/proto.c b/lib/libc/wasi/libc-top-half/musl/src/network/proto.c
deleted file mode 100644
index c4fd34efb0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/proto.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <netdb.h>
-#include <string.h>
-
-/* do we really need all these?? */
-
-static int idx;
-static const unsigned char protos[] = {
- "\000ip\0"
- "\001icmp\0"
- "\002igmp\0"
- "\003ggp\0"
- "\004ipencap\0"
- "\005st\0"
- "\006tcp\0"
- "\010egp\0"
- "\014pup\0"
- "\021udp\0"
- "\024hmp\0"
- "\026xns-idp\0"
- "\033rdp\0"
- "\035iso-tp4\0"
- "\044xtp\0"
- "\045ddp\0"
- "\046idpr-cmtp\0"
- "\051ipv6\0"
- "\053ipv6-route\0"
- "\054ipv6-frag\0"
- "\055idrp\0"
- "\056rsvp\0"
- "\057gre\0"
- "\062esp\0"
- "\063ah\0"
- "\071skip\0"
- "\072ipv6-icmp\0"
- "\073ipv6-nonxt\0"
- "\074ipv6-opts\0"
- "\111rspf\0"
- "\121vmtp\0"
- "\131ospf\0"
- "\136ipip\0"
- "\142encap\0"
- "\147pim\0"
- "\377raw"
-};
-
-void endprotoent(void)
-{
- idx = 0;
-}
-
-void setprotoent(int stayopen)
-{
- idx = 0;
-}
-
-struct protoent *getprotoent(void)
-{
- static struct protoent p;
- static const char *aliases;
- if (idx >= sizeof protos) return NULL;
- p.p_proto = protos[idx];
- p.p_name = (char *)&protos[idx+1];
- p.p_aliases = (char **)&aliases;
- idx += strlen(p.p_name) + 2;
- return &p;
-}
-
-struct protoent *getprotobyname(const char *name)
-{
- struct protoent *p;
- endprotoent();
- do p = getprotoent();
- while (p && strcmp(name, p->p_name));
- return p;
-}
-
-struct protoent *getprotobynumber(int num)
-{
- struct protoent *p;
- endprotoent();
- do p = getprotoent();
- while (p && p->p_proto != num);
- return p;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/recv.c b/lib/libc/wasi/libc-top-half/musl/src/network/recv.c
deleted file mode 100644
index 59700485bd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/recv.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/socket.h>
-
-ssize_t recv(int fd, void *buf, size_t len, int flags)
-{
- return recvfrom(fd, buf, len, flags, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/recvfrom.c b/lib/libc/wasi/libc-top-half/musl/src/network/recvfrom.c
deleted file mode 100644
index 61911663e0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/recvfrom.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-ssize_t recvfrom(int fd, void *restrict buf, size_t len, int flags, struct sockaddr *restrict addr, socklen_t *restrict alen)
-{
- return socketcall_cp(recvfrom, fd, buf, len, flags, addr, alen);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/recvmmsg.c b/lib/libc/wasi/libc-top-half/musl/src/network/recvmmsg.c
deleted file mode 100644
index 2978e2f64f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/recvmmsg.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <limits.h>
-#include <errno.h>
-#include <time.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-hidden void __convert_scm_timestamps(struct msghdr *, socklen_t);
-
-int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout)
-{
-#if LONG_MAX > INT_MAX
- struct mmsghdr *mh = msgvec;
- unsigned int i;
- for (i = vlen; i; i--, mh++)
- mh->msg_hdr.__pad1 = mh->msg_hdr.__pad2 = 0;
-#endif
-#ifdef SYS_recvmmsg_time64
- time_t s = timeout ? timeout->tv_sec : 0;
- long ns = timeout ? timeout->tv_nsec : 0;
- int r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags,
- timeout ? ((long long[]){s, ns}) : 0);
- if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if (vlen > IOV_MAX) vlen = IOV_MAX;
- socklen_t csize[vlen];
- for (int i=0; i<vlen; i++) csize[i] = msgvec[i].msg_hdr.msg_controllen;
- r = __syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags,
- timeout ? ((long[]){CLAMP(s), ns}) : 0);
- for (int i=0; i<r; i++)
- __convert_scm_timestamps(&msgvec[i].msg_hdr, csize[i]);
- return __syscall_ret(r);
-#else
- return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, timeout);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/recvmsg.c b/lib/libc/wasi/libc-top-half/musl/src/network/recvmsg.c
deleted file mode 100644
index 03641625e8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/recvmsg.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include <sys/socket.h>
-#include <limits.h>
-#include <time.h>
-#include <sys/time.h>
-#include <string.h>
-#include "syscall.h"
-
-hidden void __convert_scm_timestamps(struct msghdr *, socklen_t);
-
-void __convert_scm_timestamps(struct msghdr *msg, socklen_t csize)
-{
- if (SCM_TIMESTAMP == SCM_TIMESTAMP_OLD) return;
- if (!msg->msg_control || !msg->msg_controllen) return;
-
- struct cmsghdr *cmsg, *last=0;
- long tmp;
- long long tvts[2];
- int type = 0;
-
- for (cmsg=CMSG_FIRSTHDR(msg); cmsg; cmsg=CMSG_NXTHDR(msg, cmsg)) {
- if (cmsg->cmsg_level==SOL_SOCKET) switch (cmsg->cmsg_type) {
- case SCM_TIMESTAMP_OLD:
- if (type) break;
- type = SCM_TIMESTAMP;
- goto common;
- case SCM_TIMESTAMPNS_OLD:
- type = SCM_TIMESTAMPNS;
- common:
- memcpy(&tmp, CMSG_DATA(cmsg), sizeof tmp);
- tvts[0] = tmp;
- memcpy(&tmp, CMSG_DATA(cmsg) + sizeof tmp, sizeof tmp);
- tvts[1] = tmp;
- break;
- }
- last = cmsg;
- }
- if (!last || !type) return;
- if (CMSG_SPACE(sizeof tvts) > csize-msg->msg_controllen) {
- msg->msg_flags |= MSG_CTRUNC;
- return;
- }
- msg->msg_controllen += CMSG_SPACE(sizeof tvts);
- cmsg = CMSG_NXTHDR(msg, last);
- cmsg->cmsg_level = SOL_SOCKET;
- cmsg->cmsg_type = type;
- cmsg->cmsg_len = CMSG_LEN(sizeof tvts);
- memcpy(CMSG_DATA(cmsg), &tvts, sizeof tvts);
-}
-
-ssize_t recvmsg(int fd, struct msghdr *msg, int flags)
-{
- ssize_t r;
- socklen_t orig_controllen = msg->msg_controllen;
-#if LONG_MAX > INT_MAX
- struct msghdr h, *orig = msg;
- if (msg) {
- h = *msg;
- h.__pad1 = h.__pad2 = 0;
- msg = &h;
- }
-#endif
- r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0);
- if (r >= 0) __convert_scm_timestamps(msg, orig_controllen);
-#if LONG_MAX > INT_MAX
- if (orig) *orig = h;
-#endif
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_init.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_init.c
deleted file mode 100644
index 5dba9dfc3f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <resolv.h>
-
-int res_init()
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_mkquery.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_mkquery.c
deleted file mode 100644
index 33f50cb933..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_mkquery.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <resolv.h>
-#include <string.h>
-#include <time.h>
-
-int __res_mkquery(int op, const char *dname, int class, int type,
- const unsigned char *data, int datalen,
- const unsigned char *newrr, unsigned char *buf, int buflen)
-{
- int id, i, j;
- unsigned char q[280];
- struct timespec ts;
- size_t l = strnlen(dname, 255);
- int n;
-
- if (l && dname[l-1]=='.') l--;
- n = 17+l+!!l;
- if (l>253 || buflen<n || op>15u || class>255u || type>255u)
- return -1;
-
- /* Construct query template - ID will be filled later */
- memset(q, 0, n);
- q[2] = op*8 + 1;
- q[3] = 32; /* AD */
- q[5] = 1;
- memcpy((char *)q+13, dname, l);
- for (i=13; q[i]; i=j+1) {
- for (j=i; q[j] && q[j] != '.'; j++);
- if (j-i-1u > 62u) return -1;
- q[i-1] = j-i;
- }
- q[i+1] = type;
- q[i+3] = class;
-
- /* Make a reasonably unpredictable id */
- clock_gettime(CLOCK_REALTIME, &ts);
- id = ts.tv_nsec + ts.tv_nsec/65536UL & 0xffff;
- q[0] = id/256;
- q[1] = id;
-
- memcpy(buf, q, n);
- return n;
-}
-
-weak_alias(__res_mkquery, res_mkquery);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_msend.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_msend.c
deleted file mode 100644
index 3e018009eb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_msend.c
+++ /dev/null
@@ -1,188 +0,0 @@
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <stdint.h>
-#include <string.h>
-#include <poll.h>
-#include <time.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <errno.h>
-#include <pthread.h>
-#include "stdio_impl.h"
-#include "syscall.h"
-#include "lookup.h"
-
-static void cleanup(void *p)
-{
- __syscall(SYS_close, (intptr_t)p);
-}
-
-static unsigned long mtime()
-{
- struct timespec ts;
- clock_gettime(CLOCK_REALTIME, &ts);
- return (unsigned long)ts.tv_sec * 1000
- + ts.tv_nsec / 1000000;
-}
-
-int __res_msend_rc(int nqueries, const unsigned char *const *queries,
- const int *qlens, unsigned char *const *answers, int *alens, int asize,
- const struct resolvconf *conf)
-{
- int fd;
- int timeout, attempts, retry_interval, servfail_retry;
- union {
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } sa = {0}, ns[MAXNS] = {{0}};
- socklen_t sl = sizeof sa.sin;
- int nns = 0;
- int family = AF_INET;
- int rlen;
- int next;
- int i, j;
- int cs;
- struct pollfd pfd;
- unsigned long t0, t1, t2;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- timeout = 1000*conf->timeout;
- attempts = conf->attempts;
-
- for (nns=0; nns<conf->nns; nns++) {
- const struct address *iplit = &conf->ns[nns];
- if (iplit->family == AF_INET) {
- memcpy(&ns[nns].sin.sin_addr, iplit->addr, 4);
- ns[nns].sin.sin_port = htons(53);
- ns[nns].sin.sin_family = AF_INET;
- } else {
- sl = sizeof sa.sin6;
- memcpy(&ns[nns].sin6.sin6_addr, iplit->addr, 16);
- ns[nns].sin6.sin6_port = htons(53);
- ns[nns].sin6.sin6_scope_id = iplit->scopeid;
- ns[nns].sin6.sin6_family = family = AF_INET6;
- }
- }
-
- /* Get local address and open/bind a socket */
- sa.sin.sin_family = family;
- fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
-
- /* Handle case where system lacks IPv6 support */
- if (fd < 0 && family == AF_INET6 && errno == EAFNOSUPPORT) {
- fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- family = AF_INET;
- }
- if (fd < 0 || bind(fd, (void *)&sa, sl) < 0) {
- if (fd >= 0) close(fd);
- pthread_setcancelstate(cs, 0);
- return -1;
- }
-
- /* Past this point, there are no errors. Each individual query will
- * yield either no reply (indicated by zero length) or an answer
- * packet which is up to the caller to interpret. */
-
- pthread_cleanup_push(cleanup, (void *)(intptr_t)fd);
- pthread_setcancelstate(cs, 0);
-
- /* Convert any IPv4 addresses in a mixed environment to v4-mapped */
- if (family == AF_INET6) {
- setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof 0);
- for (i=0; i<nns; i++) {
- if (ns[i].sin.sin_family != AF_INET) continue;
- memcpy(ns[i].sin6.sin6_addr.s6_addr+12,
- &ns[i].sin.sin_addr, 4);
- memcpy(ns[i].sin6.sin6_addr.s6_addr,
- "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
- ns[i].sin6.sin6_family = AF_INET6;
- ns[i].sin6.sin6_flowinfo = 0;
- ns[i].sin6.sin6_scope_id = 0;
- }
- }
-
- memset(alens, 0, sizeof *alens * nqueries);
-
- pfd.fd = fd;
- pfd.events = POLLIN;
- retry_interval = timeout / attempts;
- next = 0;
- t0 = t2 = mtime();
- t1 = t2 - retry_interval;
-
- for (; t2-t0 < timeout; t2=mtime()) {
- if (t2-t1 >= retry_interval) {
- /* Query all configured namservers in parallel */
- for (i=0; i<nqueries; i++)
- if (!alens[i])
- for (j=0; j<nns; j++)
- sendto(fd, queries[i],
- qlens[i], MSG_NOSIGNAL,
- (void *)&ns[j], sl);
- t1 = t2;
- servfail_retry = 2 * nqueries;
- }
-
- /* Wait for a response, or until time to retry */
- if (poll(&pfd, 1, t1+retry_interval-t2) <= 0) continue;
-
- while ((rlen = recvfrom(fd, answers[next], asize, 0,
- (void *)&sa, (socklen_t[1]){sl})) >= 0) {
-
- /* Ignore non-identifiable packets */
- if (rlen < 4) continue;
-
- /* Ignore replies from addresses we didn't send to */
- for (j=0; j<nns && memcmp(ns+j, &sa, sl); j++);
- if (j==nns) continue;
-
- /* Find which query this answer goes with, if any */
- for (i=next; i<nqueries && (
- answers[next][0] != queries[i][0] ||
- answers[next][1] != queries[i][1] ); i++);
- if (i==nqueries) continue;
- if (alens[i]) continue;
-
- /* Only accept positive or negative responses;
- * retry immediately on server failure, and ignore
- * all other codes such as refusal. */
- switch (answers[next][3] & 15) {
- case 0:
- case 3:
- break;
- case 2:
- if (servfail_retry && servfail_retry--)
- sendto(fd, queries[i],
- qlens[i], MSG_NOSIGNAL,
- (void *)&ns[j], sl);
- default:
- continue;
- }
-
- /* Store answer in the right slot, or update next
- * available temp slot if it's already in place. */
- alens[i] = rlen;
- if (i == next)
- for (; next<nqueries && alens[next]; next++);
- else
- memcpy(answers[i], answers[next], rlen);
-
- if (next == nqueries) goto out;
- }
- }
-out:
- pthread_cleanup_pop(1);
-
- return 0;
-}
-
-int __res_msend(int nqueries, const unsigned char *const *queries,
- const int *qlens, unsigned char *const *answers, int *alens, int asize)
-{
- struct resolvconf conf;
- if (__get_resolv_conf(&conf, 0, 0) < 0) return -1;
- return __res_msend_rc(nqueries, queries, qlens, answers, alens, asize, &conf);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_query.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_query.c
deleted file mode 100644
index 506dc23126..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_query.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#define _BSD_SOURCE
-#include <resolv.h>
-#include <netdb.h>
-
-int res_query(const char *name, int class, int type, unsigned char *dest, int len)
-{
- unsigned char q[280];
- int ql = __res_mkquery(0, name, class, type, 0, 0, 0, q, sizeof q);
- if (ql < 0) return ql;
- int r = __res_send(q, ql, dest, len);
- if (r<12) {
- h_errno = TRY_AGAIN;
- return -1;
- }
- if ((dest[3] & 15) == 3) {
- h_errno = HOST_NOT_FOUND;
- return -1;
- }
- if ((dest[3] & 15) == 0 && !dest[6] && !dest[7]) {
- h_errno = NO_DATA;
- return -1;
- }
- return r;
-}
-
-weak_alias(res_query, res_search);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_querydomain.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_querydomain.c
deleted file mode 100644
index 727e6f6ba5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_querydomain.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <resolv.h>
-#include <string.h>
-
-int res_querydomain(const char *name, const char *domain, int class, int type, unsigned char *dest, int len)
-{
- char tmp[255];
- size_t nl = strnlen(name, 255);
- size_t dl = strnlen(domain, 255);
- if (nl+dl+1 > 254) return -1;
- memcpy(tmp, name, nl);
- tmp[nl] = '.';
- memcpy(tmp+nl+1, domain, dl+1);
- return res_query(tmp, class, type, dest, len);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_send.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_send.c
deleted file mode 100644
index ee4abf1f1a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_send.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <resolv.h>
-
-int __res_send(const unsigned char *msg, int msglen, unsigned char *answer, int anslen)
-{
- int r = __res_msend(1, &msg, &msglen, &answer, &anslen, anslen);
- return r<0 || !anslen ? -1 : anslen;
-}
-
-weak_alias(__res_send, res_send);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/res_state.c b/lib/libc/wasi/libc-top-half/musl/src/network/res_state.c
deleted file mode 100644
index 5c42cda5c3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/res_state.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <resolv.h>
-
-/* This is completely unused, and exists purely to satisfy broken apps. */
-
-struct __res_state *__res_state()
-{
- static struct __res_state res;
- return &res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/resolvconf.c b/lib/libc/wasi/libc-top-half/musl/src/network/resolvconf.c
deleted file mode 100644
index ceabf08084..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/resolvconf.c
+++ /dev/null
@@ -1,94 +0,0 @@
-#include "lookup.h"
-#include "stdio_impl.h"
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <netinet/in.h>
-
-int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
-{
- char line[256];
- unsigned char _buf[256];
- FILE *f, _f;
- int nns = 0;
-
- conf->ndots = 1;
- conf->timeout = 5;
- conf->attempts = 2;
- if (search) *search = 0;
-
- f = __fopen_rb_ca("/etc/resolv.conf", &_f, _buf, sizeof _buf);
- if (!f) switch (errno) {
- case ENOENT:
- case ENOTDIR:
- case EACCES:
- goto no_resolv_conf;
- default:
- return -1;
- }
-
- while (fgets(line, sizeof line, f)) {
- char *p, *z;
- if (!strchr(line, '\n') && !feof(f)) {
- /* Ignore lines that get truncated rather than
- * potentially misinterpreting them. */
- int c;
- do c = getc(f);
- while (c != '\n' && c != EOF);
- continue;
- }
- if (!strncmp(line, "options", 7) && isspace(line[7])) {
- p = strstr(line, "ndots:");
- if (p && isdigit(p[6])) {
- p += 6;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->ndots = x > 15 ? 15 : x;
- }
- p = strstr(line, "attempts:");
- if (p && isdigit(p[9])) {
- p += 9;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->attempts = x > 10 ? 10 : x;
- }
- p = strstr(line, "timeout:");
- if (p && (isdigit(p[8]) || p[8]=='.')) {
- p += 8;
- unsigned long x = strtoul(p, &z, 10);
- if (z != p) conf->timeout = x > 60 ? 60 : x;
- }
- continue;
- }
- if (!strncmp(line, "nameserver", 10) && isspace(line[10])) {
- if (nns >= MAXNS) continue;
- for (p=line+11; isspace(*p); p++);
- for (z=p; *z && !isspace(*z); z++);
- *z=0;
- if (__lookup_ipliteral(conf->ns+nns, p, AF_UNSPEC) > 0)
- nns++;
- continue;
- }
-
- if (!search) continue;
- if ((strncmp(line, "domain", 6) && strncmp(line, "search", 6))
- || !isspace(line[6]))
- continue;
- for (p=line+7; isspace(*p); p++);
- size_t l = strlen(p);
- /* This can never happen anyway with chosen buffer sizes. */
- if (l >= search_sz) continue;
- memcpy(search, p, l+1);
- }
-
- __fclose_ca(f);
-
-no_resolv_conf:
- if (!nns) {
- __lookup_ipliteral(conf->ns, "127.0.0.1", AF_UNSPEC);
- nns = 1;
- }
-
- conf->nns = nns;
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/send.c b/lib/libc/wasi/libc-top-half/musl/src/network/send.c
deleted file mode 100644
index 9f10497732..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/send.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/socket.h>
-
-ssize_t send(int fd, const void *buf, size_t len, int flags)
-{
- return sendto(fd, buf, len, flags, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/sendmmsg.c b/lib/libc/wasi/libc-top-half/musl/src/network/sendmmsg.c
deleted file mode 100644
index eeae1d0a58..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/sendmmsg.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/socket.h>
-#include <limits.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sendmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags)
-{
-#if LONG_MAX > INT_MAX
- /* Can't use the syscall directly because the kernel has the wrong
- * idea for the types of msg_iovlen, msg_controllen, and cmsg_len,
- * and the cmsg blocks cannot be modified in-place. */
- int i;
- if (vlen > IOV_MAX) vlen = IOV_MAX; /* This matches the kernel. */
- if (!vlen) return 0;
- for (i=0; i<vlen; i++) {
- /* As an unfortunate inconsistency, the sendmmsg API uses
- * unsigned int for the resulting msg_len, despite sendmsg
- * returning ssize_t. However Linux limits the total bytes
- * sent by sendmsg to INT_MAX, so the assignment is safe. */
- ssize_t r = sendmsg(fd, &msgvec[i].msg_hdr, flags);
- if (r < 0) goto error;
- msgvec[i].msg_len = r;
- }
-error:
- return i ? i : -1;
-#else
- return syscall_cp(SYS_sendmmsg, fd, msgvec, vlen, flags);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/sendmsg.c b/lib/libc/wasi/libc-top-half/musl/src/network/sendmsg.c
deleted file mode 100644
index 80cc5f41f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/sendmsg.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <sys/socket.h>
-#include <limits.h>
-#include <string.h>
-#include <errno.h>
-#include "syscall.h"
-
-ssize_t sendmsg(int fd, const struct msghdr *msg, int flags)
-{
-#if LONG_MAX > INT_MAX
- struct msghdr h;
- struct cmsghdr chbuf[1024/sizeof(struct cmsghdr)+1], *c;
- if (msg) {
- h = *msg;
- h.__pad1 = h.__pad2 = 0;
- msg = &h;
- if (h.msg_controllen) {
- if (h.msg_controllen > 1024) {
- errno = ENOMEM;
- return -1;
- }
- memcpy(chbuf, h.msg_control, h.msg_controllen);
- h.msg_control = chbuf;
- for (c=CMSG_FIRSTHDR(&h); c; c=CMSG_NXTHDR(&h,c))
- c->__pad1 = 0;
- }
- }
-#endif
- return socketcall_cp(sendmsg, fd, msg, flags, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/sendto.c b/lib/libc/wasi/libc-top-half/musl/src/network/sendto.c
deleted file mode 100644
index c598797c72..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/sendto.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-ssize_t sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
-{
- return socketcall_cp(sendto, fd, buf, len, flags, addr, alen);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/serv.c b/lib/libc/wasi/libc-top-half/musl/src/network/serv.c
deleted file mode 100644
index 41424e8063..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/serv.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <netdb.h>
-
-void endservent(void)
-{
-}
-
-void setservent(int stayopen)
-{
-}
-
-struct servent *getservent(void)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/setsockopt.c b/lib/libc/wasi/libc-top-half/musl/src/network/setsockopt.c
deleted file mode 100644
index 612a1947a1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/setsockopt.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen)
-{
- const struct timeval *tv;
- time_t s;
- suseconds_t us;
-
- int r = __socketcall(setsockopt, fd, level, optname, optval, optlen, 0);
-
- if (r==-ENOPROTOOPT) switch (level) {
- case SOL_SOCKET:
- switch (optname) {
- case SO_RCVTIMEO:
- case SO_SNDTIMEO:
- if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break;
- if (optlen < sizeof *tv) return __syscall_ret(-EINVAL);
- tv = optval;
- s = tv->tv_sec;
- us = tv->tv_usec;
- if (!IS32BIT(s)) return __syscall_ret(-ENOTSUP);
-
- if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD;
- if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD;
-
- r = __socketcall(setsockopt, fd, level, optname,
- ((long[]){s, CLAMP(us)}), 2*sizeof(long), 0);
- break;
- case SO_TIMESTAMP:
- case SO_TIMESTAMPNS:
- if (SO_TIMESTAMP == SO_TIMESTAMP_OLD) break;
- if (optname==SO_TIMESTAMP) optname=SO_TIMESTAMP_OLD;
- if (optname==SO_TIMESTAMPNS) optname=SO_TIMESTAMPNS_OLD;
- r = __socketcall(setsockopt, fd, level,
- optname, optval, optlen, 0);
- break;
- }
- }
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/shutdown.c b/lib/libc/wasi/libc-top-half/musl/src/network/shutdown.c
deleted file mode 100644
index 10ca21aa3c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/shutdown.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/socket.h>
-#include "syscall.h"
-
-int shutdown(int fd, int how)
-{
- return socketcall(shutdown, fd, how, 0, 0, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/sockatmark.c b/lib/libc/wasi/libc-top-half/musl/src/network/sockatmark.c
deleted file mode 100644
index f474551aaf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/sockatmark.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-
-int sockatmark(int s)
-{
- int ret;
- if (ioctl(s, SIOCATMARK, &ret) < 0)
- return -1;
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/socket.c b/lib/libc/wasi/libc-top-half/musl/src/network/socket.c
deleted file mode 100644
index afa1a7f3e7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/socket.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-
-int socket(int domain, int type, int protocol)
-{
- int s = __socketcall(socket, domain, type, protocol, 0, 0, 0);
- if ((s==-EINVAL || s==-EPROTONOSUPPORT)
- && (type&(SOCK_CLOEXEC|SOCK_NONBLOCK))) {
- s = __socketcall(socket, domain,
- type & ~(SOCK_CLOEXEC|SOCK_NONBLOCK),
- protocol, 0, 0, 0);
- if (s < 0) return __syscall_ret(s);
- if (type & SOCK_CLOEXEC)
- __syscall(SYS_fcntl, s, F_SETFD, FD_CLOEXEC);
- if (type & SOCK_NONBLOCK)
- __syscall(SYS_fcntl, s, F_SETFL, O_NONBLOCK);
- }
- return __syscall_ret(s);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/network/socketpair.c b/lib/libc/wasi/libc-top-half/musl/src/network/socketpair.c
deleted file mode 100644
index f348962113..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/network/socketpair.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-
-int socketpair(int domain, int type, int protocol, int fd[2])
-{
- int r = socketcall(socketpair, domain, type, protocol, fd, 0, 0);
- if (r<0 && (errno==EINVAL || errno==EPROTONOSUPPORT)
- && (type&(SOCK_CLOEXEC|SOCK_NONBLOCK))) {
- r = socketcall(socketpair, domain,
- type & ~(SOCK_CLOEXEC|SOCK_NONBLOCK),
- protocol, fd, 0, 0);
- if (r < 0) return r;
- if (type & SOCK_CLOEXEC) {
- __syscall(SYS_fcntl, fd[0], F_SETFD, FD_CLOEXEC);
- __syscall(SYS_fcntl, fd[1], F_SETFD, FD_CLOEXEC);
- }
- if (type & SOCK_NONBLOCK) {
- __syscall(SYS_fcntl, fd[0], F_SETFL, O_NONBLOCK);
- __syscall(SYS_fcntl, fd[1], F_SETFL, O_NONBLOCK);
- }
- }
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetgrent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetgrent.c
deleted file mode 100644
index 7d045fd22b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetgrent.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include "pwf.h"
-
-struct group *fgetgrent(FILE *f)
-{
- static char *line, **mem;
- static struct group gr;
- struct group *res;
- size_t size=0, nmem=0;
- __getgrent_a(f, &gr, &line, &size, &mem, &nmem, &res);
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetpwent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetpwent.c
deleted file mode 100644
index fd472a07ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetpwent.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include "pwf.h"
-
-struct passwd *fgetpwent(FILE *f)
-{
- static char *line;
- static struct passwd pw;
- size_t size=0;
- struct passwd *res;
- __getpwent_a(f, &pw, &line, &size, &res);
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetspent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetspent.c
deleted file mode 100644
index 47473bdb8c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/fgetspent.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "pwf.h"
-#include <pthread.h>
-
-struct spwd *fgetspent(FILE *f)
-{
- static char *line;
- static struct spwd sp;
- size_t size = 0;
- struct spwd *res = 0;
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- if (getline(&line, &size, f) >= 0 && __parsespent(line, &sp) >= 0) res = &sp;
- pthread_setcancelstate(cs, 0);
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_a.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_a.c
deleted file mode 100644
index afeb1eceb5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_a.c
+++ /dev/null
@@ -1,169 +0,0 @@
-#include <pthread.h>
-#include <byteswap.h>
-#include <string.h>
-#include <unistd.h>
-#include "pwf.h"
-#include "nscd.h"
-
-static char *itoa(char *p, uint32_t x)
-{
- // number of digits in a uint32_t + NUL
- p += 11;
- *--p = 0;
- do {
- *--p = '0' + x % 10;
- x /= 10;
- } while (x);
- return p;
-}
-
-int __getgr_a(const char *name, gid_t gid, struct group *gr, char **buf, size_t *size, char ***mem, size_t *nmem, struct group **res)
-{
- FILE *f;
- int rv = 0;
- int cs;
-
- *res = 0;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- f = fopen("/etc/group", "rbe");
- if (!f) {
- rv = errno;
- goto done;
- }
-
- while (!(rv = __getgrent_a(f, gr, buf, size, mem, nmem, res)) && *res) {
- if (name && !strcmp(name, (*res)->gr_name)
- || !name && (*res)->gr_gid == gid) {
- break;
- }
- }
- fclose(f);
-
- if (!*res && (rv == 0 || rv == ENOENT || rv == ENOTDIR)) {
- int32_t req = name ? GETGRBYNAME : GETGRBYGID;
- int32_t i;
- const char *key;
- int32_t groupbuf[GR_LEN] = {0};
- size_t len = 0;
- size_t grlist_len = 0;
- char gidbuf[11] = {0};
- int swap = 0;
- char *ptr;
-
- if (name) {
- key = name;
- } else {
- if (gid < 0 || gid > UINT32_MAX) {
- rv = 0;
- goto done;
- }
- key = itoa(gidbuf, gid);
- }
-
- f = __nscd_query(req, key, groupbuf, sizeof groupbuf, &swap);
- if (!f) { rv = errno; goto done; }
-
- if (!groupbuf[GRFOUND]) { rv = 0; goto cleanup_f; }
-
- if (!groupbuf[GRNAMELEN] || !groupbuf[GRPASSWDLEN]) {
- rv = EIO;
- goto cleanup_f;
- }
-
- if (groupbuf[GRNAMELEN] > SIZE_MAX - groupbuf[GRPASSWDLEN]) {
- rv = ENOMEM;
- goto cleanup_f;
- }
- len = groupbuf[GRNAMELEN] + groupbuf[GRPASSWDLEN];
-
- for (i = 0; i < groupbuf[GRMEMCNT]; i++) {
- uint32_t name_len;
- if (fread(&name_len, sizeof name_len, 1, f) < 1) {
- rv = ferror(f) ? errno : EIO;
- goto cleanup_f;
- }
- if (swap) {
- name_len = bswap_32(name_len);
- }
- if (name_len > SIZE_MAX - grlist_len
- || name_len > SIZE_MAX - len) {
- rv = ENOMEM;
- goto cleanup_f;
- }
- len += name_len;
- grlist_len += name_len;
- }
-
- if (len > *size || !*buf) {
- char *tmp = realloc(*buf, len);
- if (!tmp) {
- rv = errno;
- goto cleanup_f;
- }
- *buf = tmp;
- *size = len;
- }
-
- if (!fread(*buf, len, 1, f)) {
- rv = ferror(f) ? errno : EIO;
- goto cleanup_f;
- }
-
- if (groupbuf[GRMEMCNT] + 1 > *nmem) {
- if (groupbuf[GRMEMCNT] + 1 > SIZE_MAX/sizeof(char*)) {
- rv = ENOMEM;
- goto cleanup_f;
- }
- char **tmp = realloc(*mem, (groupbuf[GRMEMCNT]+1)*sizeof(char*));
- if (!tmp) {
- rv = errno;
- goto cleanup_f;
- }
- *mem = tmp;
- *nmem = groupbuf[GRMEMCNT] + 1;
- }
-
- if (groupbuf[GRMEMCNT]) {
- mem[0][0] = *buf + groupbuf[GRNAMELEN] + groupbuf[GRPASSWDLEN];
- for (ptr = mem[0][0], i = 0; ptr != mem[0][0]+grlist_len; ptr++)
- if (!*ptr) mem[0][++i] = ptr+1;
- mem[0][i] = 0;
-
- if (i != groupbuf[GRMEMCNT]) {
- rv = EIO;
- goto cleanup_f;
- }
- } else {
- mem[0][0] = 0;
- }
-
- gr->gr_name = *buf;
- gr->gr_passwd = gr->gr_name + groupbuf[GRNAMELEN];
- gr->gr_gid = groupbuf[GRGID];
- gr->gr_mem = *mem;
-
- if (gr->gr_passwd[-1]
- || gr->gr_passwd[groupbuf[GRPASSWDLEN]-1]) {
- rv = EIO;
- goto cleanup_f;
- }
-
- if (name && strcmp(name, gr->gr_name)
- || !name && gid != gr->gr_gid) {
- rv = EIO;
- goto cleanup_f;
- }
-
- *res = gr;
-
-cleanup_f:
- fclose(f);
- goto done;
- }
-
-done:
- pthread_setcancelstate(cs, 0);
- if (rv) errno = rv;
- return rv;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_r.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_r.c
deleted file mode 100644
index f3e8f603a3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgr_r.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "pwf.h"
-#include <pthread.h>
-
-#define FIX(x) (gr->gr_##x = gr->gr_##x-line+buf)
-
-static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, size_t size, struct group **res)
-{
- char *line = 0;
- size_t len = 0;
- char **mem = 0;
- size_t nmem = 0;
- int rv = 0;
- size_t i;
- int cs;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- rv = __getgr_a(name, gid, gr, &line, &len, &mem, &nmem, res);
- if (*res && size < len + (nmem+1)*sizeof(char *) + 32) {
- *res = 0;
- rv = ERANGE;
- }
- if (*res) {
- buf += (16-(uintptr_t)buf)%16;
- gr->gr_mem = (void *)buf;
- buf += (nmem+1)*sizeof(char *);
- memcpy(buf, line, len);
- FIX(name);
- FIX(passwd);
- for (i=0; mem[i]; i++)
- gr->gr_mem[i] = mem[i]-line+buf;
- gr->gr_mem[i] = 0;
- }
- free(mem);
- free(line);
- pthread_setcancelstate(cs, 0);
- if (rv) errno = rv;
- return rv;
-}
-
-int getgrnam_r(const char *name, struct group *gr, char *buf, size_t size, struct group **res)
-{
- return getgr_r(name, 0, gr, buf, size, res);
-}
-
-int getgrgid_r(gid_t gid, struct group *gr, char *buf, size_t size, struct group **res)
-{
- return getgr_r(0, gid, gr, buf, size, res);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent.c
deleted file mode 100644
index 835b9ab5a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "pwf.h"
-
-static FILE *f;
-static char *line, **mem;
-static struct group gr;
-
-void setgrent()
-{
- if (f) fclose(f);
- f = 0;
-}
-
-weak_alias(setgrent, endgrent);
-
-struct group *getgrent()
-{
- struct group *res;
- size_t size=0, nmem=0;
- if (!f) f = fopen("/etc/group", "rbe");
- if (!f) return 0;
- __getgrent_a(f, &gr, &line, &size, &mem, &nmem, &res);
- return res;
-}
-
-struct group *getgrgid(gid_t gid)
-{
- struct group *res;
- size_t size=0, nmem=0;
- __getgr_a(0, gid, &gr, &line, &size, &mem, &nmem, &res);
- return res;
-}
-
-struct group *getgrnam(const char *name)
-{
- struct group *res;
- size_t size=0, nmem=0;
- __getgr_a(name, 0, &gr, &line, &size, &mem, &nmem, &res);
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent_a.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent_a.c
deleted file mode 100644
index 7fc389d463..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrent_a.c
+++ /dev/null
@@ -1,68 +0,0 @@
-#include "pwf.h"
-#include <pthread.h>
-
-static unsigned atou(char **s)
-{
- unsigned x;
- for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
- return x;
-}
-
-int __getgrent_a(FILE *f, struct group *gr, char **line, size_t *size, char ***mem, size_t *nmem, struct group **res)
-{
- ssize_t l;
- char *s, *mems;
- size_t i;
- int rv = 0;
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- for (;;) {
- if ((l=getline(line, size, f)) < 0) {
- rv = ferror(f) ? errno : 0;
- free(*line);
- *line = 0;
- gr = 0;
- goto end;
- }
- line[0][l-1] = 0;
-
- s = line[0];
- gr->gr_name = s++;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; gr->gr_passwd = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; gr->gr_gid = atou(&s);
- if (*s != ':') continue;
-
- *s++ = 0; mems = s;
- break;
- }
-
- for (*nmem=!!*s; *s; s++)
- if (*s==',') ++*nmem;
- free(*mem);
- *mem = calloc(sizeof(char *), *nmem+1);
- if (!*mem) {
- rv = errno;
- free(*line);
- *line = 0;
- gr = 0;
- goto end;
- }
- if (*mems) {
- mem[0][0] = mems;
- for (s=mems, i=0; *s; s++)
- if (*s==',') *s++ = 0, mem[0][++i] = s;
- mem[0][++i] = 0;
- } else {
- mem[0][0] = 0;
- }
- gr->gr_mem = *mem;
-end:
- pthread_setcancelstate(cs, 0);
- *res = gr;
- if(rv) errno = rv;
- return rv;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrouplist.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrouplist.c
deleted file mode 100644
index 301824cec5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getgrouplist.c
+++ /dev/null
@@ -1,81 +0,0 @@
-#define _GNU_SOURCE
-#include "pwf.h"
-#include <grp.h>
-#include <string.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <byteswap.h>
-#include <errno.h>
-#include "nscd.h"
-
-int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
-{
- int rv, nlim, ret = -1;
- ssize_t i, n = 1;
- struct group gr;
- struct group *res;
- FILE *f;
- int swap = 0;
- int32_t resp[INITGR_LEN];
- uint32_t *nscdbuf = 0;
- char *buf = 0;
- char **mem = 0;
- size_t nmem = 0;
- size_t size;
- nlim = *ngroups;
- if (nlim >= 1) *groups++ = gid;
-
- f = __nscd_query(GETINITGR, user, resp, sizeof resp, &swap);
- if (!f) goto cleanup;
- if (resp[INITGRFOUND]) {
- nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t));
- if (!nscdbuf) goto cleanup;
- size_t nbytes = sizeof(*nscdbuf)*resp[INITGRNGRPS];
- if (nbytes && !fread(nscdbuf, nbytes, 1, f)) {
- if (!ferror(f)) errno = EIO;
- goto cleanup;
- }
- if (swap) {
- for (i = 0; i < resp[INITGRNGRPS]; i++)
- nscdbuf[i] = bswap_32(nscdbuf[i]);
- }
- }
- fclose(f);
-
- f = fopen("/etc/group", "rbe");
- if (!f && errno != ENOENT && errno != ENOTDIR)
- goto cleanup;
-
- if (f) {
- while (!(rv = __getgrent_a(f, &gr, &buf, &size, &mem, &nmem, &res)) && res) {
- if (nscdbuf)
- for (i=0; i < resp[INITGRNGRPS]; i++) {
- if (nscdbuf[i] == gr.gr_gid) nscdbuf[i] = gid;
- }
- for (i=0; gr.gr_mem[i] && strcmp(user, gr.gr_mem[i]); i++);
- if (!gr.gr_mem[i]) continue;
- if (++n <= nlim) *groups++ = gr.gr_gid;
- }
- if (rv) {
- errno = rv;
- goto cleanup;
- }
- }
- if (nscdbuf) {
- for(i=0; i < resp[INITGRNGRPS]; i++) {
- if (nscdbuf[i] != gid)
- if(++n <= nlim) *groups++ = nscdbuf[i];
- }
- }
-
- ret = n > nlim ? -1 : n;
- *ngroups = n;
-
-cleanup:
- if (f) fclose(f);
- free(nscdbuf);
- free(buf);
- free(mem);
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_a.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_a.c
deleted file mode 100644
index 15a70c0330..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_a.c
+++ /dev/null
@@ -1,142 +0,0 @@
-#include <pthread.h>
-#include <byteswap.h>
-#include <string.h>
-#include <unistd.h>
-#include "pwf.h"
-#include "nscd.h"
-
-static char *itoa(char *p, uint32_t x)
-{
- // number of digits in a uint32_t + NUL
- p += 11;
- *--p = 0;
- do {
- *--p = '0' + x % 10;
- x /= 10;
- } while (x);
- return p;
-}
-
-int __getpw_a(const char *name, uid_t uid, struct passwd *pw, char **buf, size_t *size, struct passwd **res)
-{
- FILE *f;
- int cs;
- int rv = 0;
-
- *res = 0;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- f = fopen("/etc/passwd", "rbe");
- if (!f) {
- rv = errno;
- goto done;
- }
-
- while (!(rv = __getpwent_a(f, pw, buf, size, res)) && *res) {
- if (name && !strcmp(name, (*res)->pw_name)
- || !name && (*res)->pw_uid == uid)
- break;
- }
- fclose(f);
-
- if (!*res && (rv == 0 || rv == ENOENT || rv == ENOTDIR)) {
- int32_t req = name ? GETPWBYNAME : GETPWBYUID;
- const char *key;
- int32_t passwdbuf[PW_LEN] = {0};
- size_t len = 0;
- char uidbuf[11] = {0};
-
- if (name) {
- key = name;
- } else {
- /* uid outside of this range can't be queried with the
- * nscd interface, but might happen if uid_t ever
- * happens to be a larger type (this is not true as of
- * now)
- */
- if(uid < 0 || uid > UINT32_MAX) {
- rv = 0;
- goto done;
- }
- key = itoa(uidbuf, uid);
- }
-
- f = __nscd_query(req, key, passwdbuf, sizeof passwdbuf, (int[]){0});
- if (!f) { rv = errno; goto done; }
-
- if(!passwdbuf[PWFOUND]) { rv = 0; goto cleanup_f; }
-
- /* A zero length response from nscd is invalid. We ignore
- * invalid responses and just report an error, rather than
- * trying to do something with them.
- */
- if (!passwdbuf[PWNAMELEN] || !passwdbuf[PWPASSWDLEN]
- || !passwdbuf[PWGECOSLEN] || !passwdbuf[PWDIRLEN]
- || !passwdbuf[PWSHELLLEN]) {
- rv = EIO;
- goto cleanup_f;
- }
-
- if ((passwdbuf[PWNAMELEN]|passwdbuf[PWPASSWDLEN]
- |passwdbuf[PWGECOSLEN]|passwdbuf[PWDIRLEN]
- |passwdbuf[PWSHELLLEN]) >= SIZE_MAX/8) {
- rv = ENOMEM;
- goto cleanup_f;
- }
-
- len = passwdbuf[PWNAMELEN] + passwdbuf[PWPASSWDLEN]
- + passwdbuf[PWGECOSLEN] + passwdbuf[PWDIRLEN]
- + passwdbuf[PWSHELLLEN];
-
- if (len > *size || !*buf) {
- char *tmp = realloc(*buf, len);
- if (!tmp) {
- rv = errno;
- goto cleanup_f;
- }
- *buf = tmp;
- *size = len;
- }
-
- if (!fread(*buf, len, 1, f)) {
- rv = ferror(f) ? errno : EIO;
- goto cleanup_f;
- }
-
- pw->pw_name = *buf;
- pw->pw_passwd = pw->pw_name + passwdbuf[PWNAMELEN];
- pw->pw_gecos = pw->pw_passwd + passwdbuf[PWPASSWDLEN];
- pw->pw_dir = pw->pw_gecos + passwdbuf[PWGECOSLEN];
- pw->pw_shell = pw->pw_dir + passwdbuf[PWDIRLEN];
- pw->pw_uid = passwdbuf[PWUID];
- pw->pw_gid = passwdbuf[PWGID];
-
- /* Don't assume that nscd made sure to null terminate strings.
- * It's supposed to, but malicious nscd should be ignored
- * rather than causing a crash.
- */
- if (pw->pw_passwd[-1] || pw->pw_gecos[-1] || pw->pw_dir[-1]
- || pw->pw_shell[passwdbuf[PWSHELLLEN]-1]) {
- rv = EIO;
- goto cleanup_f;
- }
-
- if (name && strcmp(name, pw->pw_name)
- || !name && uid != pw->pw_uid) {
- rv = EIO;
- goto cleanup_f;
- }
-
-
- *res = pw;
-cleanup_f:
- fclose(f);
- goto done;
- }
-
-done:
- pthread_setcancelstate(cs, 0);
- if (rv) errno = rv;
- return rv;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_r.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_r.c
deleted file mode 100644
index 0c87ab05d2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpw_r.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "pwf.h"
-#include <pthread.h>
-
-#define FIX(x) (pw->pw_##x = pw->pw_##x-line+buf)
-
-static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res)
-{
- char *line = 0;
- size_t len = 0;
- int rv = 0;
- int cs;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- rv = __getpw_a(name, uid, pw, &line, &len, res);
- if (*res && size < len) {
- *res = 0;
- rv = ERANGE;
- }
- if (*res) {
- memcpy(buf, line, len);
- FIX(name);
- FIX(passwd);
- FIX(gecos);
- FIX(dir);
- FIX(shell);
- }
- free(line);
- pthread_setcancelstate(cs, 0);
- if (rv) errno = rv;
- return rv;
-}
-
-int getpwnam_r(const char *name, struct passwd *pw, char *buf, size_t size, struct passwd **res)
-{
- return getpw_r(name, 0, pw, buf, size, res);
-}
-
-int getpwuid_r(uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res)
-{
- return getpw_r(0, uid, pw, buf, size, res);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent.c
deleted file mode 100644
index f2bd516e57..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "pwf.h"
-
-static FILE *f;
-static char *line;
-static struct passwd pw;
-static size_t size;
-
-void setpwent()
-{
- if (f) fclose(f);
- f = 0;
-}
-
-weak_alias(setpwent, endpwent);
-
-struct passwd *getpwent()
-{
- struct passwd *res;
- if (!f) f = fopen("/etc/passwd", "rbe");
- if (!f) return 0;
- __getpwent_a(f, &pw, &line, &size, &res);
- return res;
-}
-
-struct passwd *getpwuid(uid_t uid)
-{
- struct passwd *res;
- __getpw_a(0, uid, &pw, &line, &size, &res);
- return res;
-}
-
-struct passwd *getpwnam(const char *name)
-{
- struct passwd *res;
- __getpw_a(name, 0, &pw, &line, &size, &res);
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent_a.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent_a.c
deleted file mode 100644
index d1b4b53ce2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getpwent_a.c
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "pwf.h"
-#include <pthread.h>
-
-static unsigned atou(char **s)
-{
- unsigned x;
- for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
- return x;
-}
-
-int __getpwent_a(FILE *f, struct passwd *pw, char **line, size_t *size, struct passwd **res)
-{
- ssize_t l;
- char *s;
- int rv = 0;
- int cs;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- for (;;) {
- if ((l=getline(line, size, f)) < 0) {
- rv = ferror(f) ? errno : 0;
- free(*line);
- *line = 0;
- pw = 0;
- break;
- }
- line[0][l-1] = 0;
-
- s = line[0];
- pw->pw_name = s++;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_passwd = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_uid = atou(&s);
- if (*s != ':') continue;
-
- *s++ = 0; pw->pw_gid = atou(&s);
- if (*s != ':') continue;
-
- *s++ = 0; pw->pw_gecos = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_dir = s;
- if (!(s = strchr(s, ':'))) continue;
-
- *s++ = 0; pw->pw_shell = s;
- break;
- }
- pthread_setcancelstate(cs, 0);
- *res = pw;
- if (rv) errno = rv;
- return rv;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getspent.c
deleted file mode 100644
index 8574a480e1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspent.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pwf.h"
-
-void setspent()
-{
-}
-
-void endspent()
-{
-}
-
-struct spwd *getspent()
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam.c
deleted file mode 100644
index 709b526dc5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "pwf.h"
-
-#define LINE_LIM 256
-
-struct spwd *getspnam(const char *name)
-{
- static struct spwd sp;
- static char *line;
- struct spwd *res;
- int e;
- int orig_errno = errno;
-
- if (!line) line = malloc(LINE_LIM);
- if (!line) return 0;
- e = getspnam_r(name, &sp, line, LINE_LIM, &res);
- errno = e ? e : orig_errno;
- return res;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam_r.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam_r.c
deleted file mode 100644
index 541e85314d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/getspnam_r.c
+++ /dev/null
@@ -1,125 +0,0 @@
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <pthread.h>
-#include "pwf.h"
-
-/* This implementation support Openwall-style TCB passwords in place of
- * traditional shadow, if the appropriate directories and files exist.
- * Thus, it is careful to avoid following symlinks or blocking on fifos
- * which a malicious user might create in place of his or her TCB shadow
- * file. It also avoids any allocation to prevent memory-exhaustion
- * attacks via huge TCB shadow files. */
-
-static long xatol(char **s)
-{
- long x;
- if (**s == ':' || **s == '\n') return -1;
- for (x=0; **s-'0'<10U; ++*s) x=10*x+(**s-'0');
- return x;
-}
-
-int __parsespent(char *s, struct spwd *sp)
-{
- sp->sp_namp = s;
- if (!(s = strchr(s, ':'))) return -1;
- *s = 0;
-
- sp->sp_pwdp = ++s;
- if (!(s = strchr(s, ':'))) return -1;
- *s = 0;
-
- s++; sp->sp_lstchg = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_min = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_max = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_warn = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_inact = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_expire = xatol(&s);
- if (*s != ':') return -1;
-
- s++; sp->sp_flag = xatol(&s);
- if (*s != '\n') return -1;
- return 0;
-}
-
-static void cleanup(void *p)
-{
- fclose(p);
-}
-
-int getspnam_r(const char *name, struct spwd *sp, char *buf, size_t size, struct spwd **res)
-{
- char path[20+NAME_MAX];
- FILE *f = 0;
- int rv = 0;
- int fd;
- size_t k, l = strlen(name);
- int skip = 0;
- int cs;
- int orig_errno = errno;
-
- *res = 0;
-
- /* Disallow potentially-malicious user names */
- if (*name=='.' || strchr(name, '/') || !l)
- return errno = EINVAL;
-
- /* Buffer size must at least be able to hold name, plus some.. */
- if (size < l+100)
- return errno = ERANGE;
-
- /* Protect against truncation */
- if (snprintf(path, sizeof path, "/etc/tcb/%s/shadow", name) >= sizeof path)
- return errno = EINVAL;
-
- fd = open(path, O_RDONLY|O_NOFOLLOW|O_NONBLOCK|O_CLOEXEC);
- if (fd >= 0) {
- struct stat st = { 0 };
- errno = EINVAL;
- if (fstat(fd, &st) || !S_ISREG(st.st_mode) || !(f = fdopen(fd, "rb"))) {
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- close(fd);
- pthread_setcancelstate(cs, 0);
- return errno;
- }
- } else {
- if (errno != ENOENT && errno != ENOTDIR)
- return errno;
- f = fopen("/etc/shadow", "rbe");
- if (!f) {
- if (errno != ENOENT && errno != ENOTDIR)
- return errno;
- return 0;
- }
- }
-
- pthread_cleanup_push(cleanup, f);
- while (fgets(buf, size, f) && (k=strlen(buf))>0) {
- if (skip || strncmp(name, buf, l) || buf[l]!=':') {
- skip = buf[k-1] != '\n';
- continue;
- }
- if (buf[k-1] != '\n') {
- rv = ERANGE;
- break;
- }
-
- if (__parsespent(buf, sp) < 0) continue;
- *res = sp;
- break;
- }
- pthread_cleanup_pop(1);
- errno = rv ? rv : orig_errno;
- return rv;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/lckpwdf.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/lckpwdf.c
deleted file mode 100644
index 2feda617c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/lckpwdf.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <shadow.h>
-
-int lckpwdf()
-{
- return 0;
-}
-
-int ulckpwdf()
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd_query.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd_query.c
deleted file mode 100644
index dc3406b851..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/nscd_query.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include <sys/socket.h>
-#include <byteswap.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include "nscd.h"
-
-static const struct {
- short sun_family;
- char sun_path[21];
-} addr = {
- AF_UNIX,
- "/var/run/nscd/socket"
-};
-
-FILE *__nscd_query(int32_t req, const char *key, int32_t *buf, size_t len, int *swap)
-{
- size_t i;
- int fd;
- FILE *f = 0;
- int32_t req_buf[REQ_LEN] = {
- NSCDVERSION,
- req,
- strnlen(key,LOGIN_NAME_MAX)+1
- };
- struct msghdr msg = {
- .msg_iov = (struct iovec[]){
- {&req_buf, sizeof(req_buf)},
- {(char*)key, strlen(key)+1}
- },
- .msg_iovlen = 2
- };
- int errno_save = errno;
-
- *swap = 0;
-retry:
- memset(buf, 0, len);
- buf[0] = NSCDVERSION;
-
- fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- if (fd < 0) {
- if (errno == EAFNOSUPPORT) {
- f = fopen("/dev/null", "re");
- if (f)
- errno = errno_save;
- return f;
- }
- return 0;
- }
-
- if(!(f = fdopen(fd, "r"))) {
- close(fd);
- return 0;
- }
-
- if (req_buf[2] > LOGIN_NAME_MAX)
- return f;
-
- if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
- /* If there isn't a running nscd we simulate a "not found"
- * result and the caller is responsible for calling
- * fclose on the (unconnected) socket. The value of
- * errno must be left unchanged in this case. */
- if (errno == EACCES || errno == ECONNREFUSED || errno == ENOENT) {
- errno = errno_save;
- return f;
- }
- goto error;
- }
-
- if (sendmsg(fd, &msg, MSG_NOSIGNAL) < 0)
- goto error;
-
- if (!fread(buf, len, 1, f)) {
- /* If the VERSION entry mismatches nscd will disconnect. The
- * most likely cause is that the endianness mismatched. So, we
- * byteswap and try once more. (if we already swapped, just
- * fail out)
- */
- if (ferror(f)) goto error;
- if (!*swap) {
- fclose(f);
- for (i = 0; i < sizeof(req_buf)/sizeof(req_buf[0]); i++) {
- req_buf[i] = bswap_32(req_buf[i]);
- }
- *swap = 1;
- goto retry;
- } else {
- errno = EIO;
- goto error;
- }
- }
-
- if (*swap) {
- for (i = 0; i < len/sizeof(buf[0]); i++) {
- buf[i] = bswap_32(buf[i]);
- }
- }
-
- /* The first entry in every nscd response is the version number. This
- * really shouldn't happen, and is evidence of some form of malformed
- * response.
- */
- if(buf[0] != NSCDVERSION) {
- errno = EIO;
- goto error;
- }
-
- return f;
-error:
- fclose(f);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/putgrent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/putgrent.c
deleted file mode 100644
index 2a8257dc9c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/putgrent.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#define _GNU_SOURCE
-#include <grp.h>
-#include <stdio.h>
-
-int putgrent(const struct group *gr, FILE *f)
-{
- int r;
- size_t i;
- flockfile(f);
- if ((r = fprintf(f, "%s:%s:%u:", gr->gr_name, gr->gr_passwd, gr->gr_gid))<0) goto done;
- if (gr->gr_mem) for (i=0; gr->gr_mem[i]; i++)
- if ((r = fprintf(f, "%s%s", i?",":"", gr->gr_mem[i]))<0) goto done;
- r = fputc('\n', f);
-done:
- funlockfile(f);
- return r<0 ? -1 : 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/putpwent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/putpwent.c
deleted file mode 100644
index 312b765302..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/putpwent.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#define _GNU_SOURCE
-#include <pwd.h>
-#include <stdio.h>
-
-int putpwent(const struct passwd *pw, FILE *f)
-{
- return fprintf(f, "%s:%s:%u:%u:%s:%s:%s\n",
- pw->pw_name, pw->pw_passwd, pw->pw_uid, pw->pw_gid,
- pw->pw_gecos, pw->pw_dir, pw->pw_shell)<0 ? -1 : 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/passwd/putspent.c b/lib/libc/wasi/libc-top-half/musl/src/passwd/putspent.c
deleted file mode 100644
index 55c41bbc30..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/passwd/putspent.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <shadow.h>
-#include <stdio.h>
-
-#define NUM(n) ((n) == -1 ? 0 : -1), ((n) == -1 ? 0 : (n))
-#define STR(s) ((s) ? (s) : "")
-
-int putspent(const struct spwd *sp, FILE *f)
-{
- return fprintf(f, "%s:%s:%.*ld:%.*ld:%.*ld:%.*ld:%.*ld:%.*ld:%.*lu\n",
- STR(sp->sp_namp), STR(sp->sp_pwdp), NUM(sp->sp_lstchg),
- NUM(sp->sp_min), NUM(sp->sp_max), NUM(sp->sp_warn),
- NUM(sp->sp_inact), NUM(sp->sp_expire), NUM(sp->sp_flag)) < 0 ? -1 : 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/_Fork.c b/lib/libc/wasi/libc-top-half/musl/src/process/_Fork.c
deleted file mode 100644
index da06386815..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/_Fork.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <unistd.h>
-#include <signal.h>
-#include "syscall.h"
-#include "libc.h"
-#include "lock.h"
-#include "pthread_impl.h"
-#include "aio_impl.h"
-
-static void dummy(int x) { }
-weak_alias(dummy, __aio_atfork);
-
-pid_t _Fork(void)
-{
- pid_t ret;
- sigset_t set;
- __block_all_sigs(&set);
- __aio_atfork(-1);
- LOCK(__abort_lock);
-#ifdef SYS_fork
- ret = __syscall(SYS_fork);
-#else
- ret = __syscall(SYS_clone, SIGCHLD, 0);
-#endif
- if (!ret) {
- pthread_t self = __pthread_self();
- self->tid = __syscall(SYS_gettid);
- self->robust_list.off = 0;
- self->robust_list.pending = 0;
- self->next = self->prev = self;
- __thread_list_lock = 0;
- libc.threads_minus_1 = 0;
- if (libc.need_locks) libc.need_locks = -1;
- }
- UNLOCK(__abort_lock);
- __aio_atfork(!ret);
- __restore_sigs(&set);
- return __syscall_ret(ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/arm/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/arm/vfork.s
deleted file mode 100644
index d7ec41b33f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/arm/vfork.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.syntax unified
-.global vfork
-.type vfork,%function
-vfork:
- mov ip, r7
- mov r7, 190
- svc 0
- mov r7, ip
- .hidden __syscall_ret
- b __syscall_ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execl.c b/lib/libc/wasi/libc-top-half/musl/src/process/execl.c
deleted file mode 100644
index 5ee5c81e35..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execl.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <unistd.h>
-#include <stdarg.h>
-
-int execl(const char *path, const char *argv0, ...)
-{
- int argc;
- va_list ap;
- va_start(ap, argv0);
- for (argc=1; va_arg(ap, const char *); argc++);
- va_end(ap);
- {
- int i;
- char *argv[argc+1];
- va_start(ap, argv0);
- argv[0] = (char *)argv0;
- for (i=1; i<argc; i++)
- argv[i] = va_arg(ap, char *);
- argv[i] = NULL;
- va_end(ap);
- return execv(path, argv);
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execle.c b/lib/libc/wasi/libc-top-half/musl/src/process/execle.c
deleted file mode 100644
index 37ca50349a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execle.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <unistd.h>
-#include <stdarg.h>
-
-int execle(const char *path, const char *argv0, ...)
-{
- int argc;
- va_list ap;
- va_start(ap, argv0);
- for (argc=1; va_arg(ap, const char *); argc++);
- va_end(ap);
- {
- int i;
- char *argv[argc+1];
- char **envp;
- va_start(ap, argv0);
- argv[0] = (char *)argv0;
- for (i=1; i<=argc; i++)
- argv[i] = va_arg(ap, char *);
- envp = va_arg(ap, char **);
- va_end(ap);
- return execve(path, argv, envp);
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execlp.c b/lib/libc/wasi/libc-top-half/musl/src/process/execlp.c
deleted file mode 100644
index 5eed886e71..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execlp.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <unistd.h>
-#include <stdarg.h>
-
-int execlp(const char *file, const char *argv0, ...)
-{
- int argc;
- va_list ap;
- va_start(ap, argv0);
- for (argc=1; va_arg(ap, const char *); argc++);
- va_end(ap);
- {
- int i;
- char *argv[argc+1];
- va_start(ap, argv0);
- argv[0] = (char *)argv0;
- for (i=1; i<argc; i++)
- argv[i] = va_arg(ap, char *);
- argv[i] = NULL;
- va_end(ap);
- return execvp(file, argv);
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execv.c b/lib/libc/wasi/libc-top-half/musl/src/process/execv.c
deleted file mode 100644
index 2ac0dec013..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execv.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-
-extern char **__environ;
-
-int execv(const char *path, char *const argv[])
-{
- return execve(path, argv, __environ);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execve.c b/lib/libc/wasi/libc-top-half/musl/src/process/execve.c
deleted file mode 100644
index 70286a1739..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execve.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int execve(const char *path, char *const argv[], char *const envp[])
-{
- /* do we need to use environ if envp is null? */
- return syscall(SYS_execve, path, argv, envp);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/execvp.c b/lib/libc/wasi/libc-top-half/musl/src/process/execvp.c
deleted file mode 100644
index ef3b9dd598..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/execvp.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-
-extern char **__environ;
-
-int __execvpe(const char *file, char *const argv[], char *const envp[])
-{
- const char *p, *z, *path = getenv("PATH");
- size_t l, k;
- int seen_eacces = 0;
-
- errno = ENOENT;
- if (!*file) return -1;
-
- if (strchr(file, '/'))
- return execve(file, argv, envp);
-
- if (!path) path = "/usr/local/bin:/bin:/usr/bin";
- k = strnlen(file, NAME_MAX+1);
- if (k > NAME_MAX) {
- errno = ENAMETOOLONG;
- return -1;
- }
- l = strnlen(path, PATH_MAX-1)+1;
-
- for(p=path; ; p=z) {
- char b[l+k+1];
- z = __strchrnul(p, ':');
- if (z-p >= l) {
- if (!*z++) break;
- continue;
- }
- memcpy(b, p, z-p);
- b[z-p] = '/';
- memcpy(b+(z-p)+(z>p), file, k+1);
- execve(b, argv, envp);
- switch (errno) {
- case EACCES:
- seen_eacces = 1;
- case ENOENT:
- case ENOTDIR:
- break;
- default:
- return -1;
- }
- if (!*z++) break;
- }
- if (seen_eacces) errno = EACCES;
- return -1;
-}
-
-int execvp(const char *file, char *const argv[])
-{
- return __execvpe(file, argv, __environ);
-}
-
-weak_alias(__execvpe, execvpe);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/fexecve.c b/lib/libc/wasi/libc-top-half/musl/src/process/fexecve.c
deleted file mode 100644
index 554c1981b6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/fexecve.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int fexecve(int fd, char *const argv[], char *const envp[])
-{
- int r = __syscall(SYS_execveat, fd, "", argv, envp, AT_EMPTY_PATH);
- if (r != -ENOSYS) return __syscall_ret(r);
- char buf[15 + 3*sizeof(int)];
- __procfdname(buf, fd);
- execve(buf, argv, envp);
- if (errno == ENOENT) errno = EBADF;
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/fork.c b/lib/libc/wasi/libc-top-half/musl/src/process/fork.c
deleted file mode 100644
index 54bc289202..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/fork.c
+++ /dev/null
@@ -1,86 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include "libc.h"
-#include "lock.h"
-#include "pthread_impl.h"
-#include "fork_impl.h"
-
-static volatile int *const dummy_lockptr = 0;
-
-weak_alias(dummy_lockptr, __at_quick_exit_lockptr);
-weak_alias(dummy_lockptr, __atexit_lockptr);
-weak_alias(dummy_lockptr, __dlerror_lockptr);
-weak_alias(dummy_lockptr, __gettext_lockptr);
-weak_alias(dummy_lockptr, __locale_lockptr);
-weak_alias(dummy_lockptr, __random_lockptr);
-weak_alias(dummy_lockptr, __sem_open_lockptr);
-weak_alias(dummy_lockptr, __stdio_ofl_lockptr);
-weak_alias(dummy_lockptr, __syslog_lockptr);
-weak_alias(dummy_lockptr, __timezone_lockptr);
-weak_alias(dummy_lockptr, __bump_lockptr);
-
-weak_alias(dummy_lockptr, __vmlock_lockptr);
-
-static volatile int *const *const atfork_locks[] = {
- &__at_quick_exit_lockptr,
- &__atexit_lockptr,
- &__dlerror_lockptr,
- &__gettext_lockptr,
- &__locale_lockptr,
- &__random_lockptr,
- &__sem_open_lockptr,
- &__stdio_ofl_lockptr,
- &__syslog_lockptr,
- &__timezone_lockptr,
- &__bump_lockptr,
-};
-
-static void dummy(int x) { }
-weak_alias(dummy, __fork_handler);
-weak_alias(dummy, __malloc_atfork);
-weak_alias(dummy, __ldso_atfork);
-
-static void dummy_0(void) { }
-weak_alias(dummy_0, __tl_lock);
-weak_alias(dummy_0, __tl_unlock);
-
-pid_t fork(void)
-{
- sigset_t set;
- __fork_handler(-1);
- __block_app_sigs(&set);
- int need_locks = libc.need_locks > 0;
- if (need_locks) {
- __ldso_atfork(-1);
- __inhibit_ptc();
- for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++)
- if (*atfork_locks[i]) LOCK(*atfork_locks[i]);
- __malloc_atfork(-1);
- __tl_lock();
- }
- pthread_t self=__pthread_self(), next=self->next;
- pid_t ret = _Fork();
- int errno_save = errno;
- if (need_locks) {
- if (!ret) {
- for (pthread_t td=next; td!=self; td=td->next)
- td->tid = -1;
- if (__vmlock_lockptr) {
- __vmlock_lockptr[0] = 0;
- __vmlock_lockptr[1] = 0;
- }
- }
- __tl_unlock();
- __malloc_atfork(!ret);
- for (int i=0; i<sizeof atfork_locks/sizeof *atfork_locks; i++)
- if (*atfork_locks[i])
- if (ret) UNLOCK(*atfork_locks[i]);
- else **atfork_locks[i] = 0;
- __release_ptc();
- __ldso_atfork(!ret);
- }
- __restore_sigs(&set);
- __fork_handler(!ret);
- if (ret<0) errno = errno_save;
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/i386/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/i386/vfork.s
deleted file mode 100644
index 3d0e6d6bde..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/i386/vfork.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.global vfork
-.type vfork,@function
-vfork:
- pop %edx
- mov $190,%eax
- int $128
- push %edx
- push %eax
- .hidden __syscall_ret
- call __syscall_ret
- pop %edx
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn.c
deleted file mode 100644
index 728551b367..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn.c
+++ /dev/null
@@ -1,214 +0,0 @@
-#define _GNU_SOURCE
-#include <spawn.h>
-#include <sched.h>
-#include <unistd.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include "syscall.h"
-#include "lock.h"
-#include "pthread_impl.h"
-#include "fdop.h"
-
-struct args {
- int p[2];
- sigset_t oldmask;
- const char *path;
- const posix_spawn_file_actions_t *fa;
- const posix_spawnattr_t *restrict attr;
- char *const *argv, *const *envp;
-};
-
-static int __sys_dup2(int old, int new)
-{
-#ifdef SYS_dup2
- return __syscall(SYS_dup2, old, new);
-#else
- return __syscall(SYS_dup3, old, new, 0);
-#endif
-}
-
-static int child(void *args_vp)
-{
- int i, ret;
- struct sigaction sa = {0};
- struct args *args = args_vp;
- int p = args->p[1];
- const posix_spawn_file_actions_t *fa = args->fa;
- const posix_spawnattr_t *restrict attr = args->attr;
- sigset_t hset;
-
- close(args->p[0]);
-
- /* All signal dispositions must be either SIG_DFL or SIG_IGN
- * before signals are unblocked. Otherwise a signal handler
- * from the parent might get run in the child while sharing
- * memory, with unpredictable and dangerous results. To
- * reduce overhead, sigaction has tracked for us which signals
- * potentially have a signal handler. */
- __get_handler_set(&hset);
- for (i=1; i<_NSIG; i++) {
- if ((attr->__flags & POSIX_SPAWN_SETSIGDEF)
- && sigismember(&attr->__def, i)) {
- sa.sa_handler = SIG_DFL;
- } else if (sigismember(&hset, i)) {
- if (i-32<3U) {
- sa.sa_handler = SIG_IGN;
- } else {
- __libc_sigaction(i, 0, &sa);
- if (sa.sa_handler==SIG_IGN) continue;
- sa.sa_handler = SIG_DFL;
- }
- } else {
- continue;
- }
- __libc_sigaction(i, &sa, 0);
- }
-
- if (attr->__flags & POSIX_SPAWN_SETSID)
- if ((ret=__syscall(SYS_setsid)) < 0)
- goto fail;
-
- if (attr->__flags & POSIX_SPAWN_SETPGROUP)
- if ((ret=__syscall(SYS_setpgid, 0, attr->__pgrp)))
- goto fail;
-
- /* Use syscalls directly because the library functions attempt
- * to do a multi-threaded synchronized id-change, which would
- * trash the parent's state. */
- if (attr->__flags & POSIX_SPAWN_RESETIDS)
- if ((ret=__syscall(SYS_setgid, __syscall(SYS_getgid))) ||
- (ret=__syscall(SYS_setuid, __syscall(SYS_getuid))) )
- goto fail;
-
- if (fa && fa->__actions) {
- struct fdop *op;
- int fd;
- for (op = fa->__actions; op->next; op = op->next);
- for (; op; op = op->prev) {
- /* It's possible that a file operation would clobber
- * the pipe fd used for synchronizing with the
- * parent. To avoid that, we dup the pipe onto
- * an unoccupied fd. */
- if (op->fd == p) {
- ret = __syscall(SYS_dup, p);
- if (ret < 0) goto fail;
- __syscall(SYS_close, p);
- p = ret;
- }
- switch(op->cmd) {
- case FDOP_CLOSE:
- __syscall(SYS_close, op->fd);
- break;
- case FDOP_DUP2:
- fd = op->srcfd;
- if (fd == p) {
- ret = -EBADF;
- goto fail;
- }
- if (fd != op->fd) {
- if ((ret=__sys_dup2(fd, op->fd))<0)
- goto fail;
- } else {
- ret = __syscall(SYS_fcntl, fd, F_GETFD);
- ret = __syscall(SYS_fcntl, fd, F_SETFD,
- ret & ~FD_CLOEXEC);
- if (ret<0)
- goto fail;
- }
- break;
- case FDOP_OPEN:
- fd = __sys_open(op->path, op->oflag, op->mode);
- if ((ret=fd) < 0) goto fail;
- if (fd != op->fd) {
- if ((ret=__sys_dup2(fd, op->fd))<0)
- goto fail;
- __syscall(SYS_close, fd);
- }
- break;
- case FDOP_CHDIR:
- ret = __syscall(SYS_chdir, op->path);
- if (ret<0) goto fail;
- break;
- case FDOP_FCHDIR:
- ret = __syscall(SYS_fchdir, op->fd);
- if (ret<0) goto fail;
- break;
- }
- }
- }
-
- /* Close-on-exec flag may have been lost if we moved the pipe
- * to a different fd. We don't use F_DUPFD_CLOEXEC above because
- * it would fail on older kernels and atomicity is not needed --
- * in this process there are no threads or signal handlers. */
- __syscall(SYS_fcntl, p, F_SETFD, FD_CLOEXEC);
-
- pthread_sigmask(SIG_SETMASK, (attr->__flags & POSIX_SPAWN_SETSIGMASK)
- ? &attr->__mask : &args->oldmask, 0);
-
- int (*exec)(const char *, char *const *, char *const *) =
- attr->__fn ? (int (*)())attr->__fn : execve;
-
- exec(args->path, args->argv, args->envp);
- ret = -errno;
-
-fail:
- /* Since sizeof errno < PIPE_BUF, the write is atomic. */
- ret = -ret;
- if (ret) while (__syscall(SYS_write, p, &ret, sizeof ret) < 0);
- _exit(127);
-}
-
-
-int posix_spawn(pid_t *restrict res, const char *restrict path,
- const posix_spawn_file_actions_t *fa,
- const posix_spawnattr_t *restrict attr,
- char *const argv[restrict], char *const envp[restrict])
-{
- pid_t pid;
- char stack[1024+PATH_MAX];
- int ec=0, cs;
- struct args args;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- args.path = path;
- args.fa = fa;
- args.attr = attr ? attr : &(const posix_spawnattr_t){0};
- args.argv = argv;
- args.envp = envp;
- pthread_sigmask(SIG_BLOCK, SIGALL_SET, &args.oldmask);
-
- /* The lock guards both against seeing a SIGABRT disposition change
- * by abort and against leaking the pipe fd to fork-without-exec. */
- LOCK(__abort_lock);
-
- if (pipe2(args.p, O_CLOEXEC)) {
- UNLOCK(__abort_lock);
- ec = errno;
- goto fail;
- }
-
- pid = __clone(child, stack+sizeof stack,
- CLONE_VM|CLONE_VFORK|SIGCHLD, &args);
- close(args.p[1]);
- UNLOCK(__abort_lock);
-
- if (pid > 0) {
- if (read(args.p[0], &ec, sizeof ec) != sizeof ec) ec = 0;
- else waitpid(pid, &(int){0}, 0);
- } else {
- ec = -pid;
- }
-
- close(args.p[0]);
-
- if (!ec && res) *res = pid;
-
-fail:
- pthread_sigmask(SIG_SETMASK, &args.oldmask, 0);
- pthread_setcancelstate(cs, 0);
-
- return ec;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c
deleted file mode 100644
index 7f2590ae4e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *restrict fa, const char *restrict path)
-{
- struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
- if (!op) return ENOMEM;
- op->cmd = FDOP_CHDIR;
- op->fd = -1;
- strcpy(op->path, path);
- if ((op->next = fa->__actions)) op->next->prev = op;
- op->prev = 0;
- fa->__actions = op;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c
deleted file mode 100644
index 0c2ef8fa37..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addclose.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd)
-{
- if (fd < 0) return EBADF;
- struct fdop *op = malloc(sizeof *op);
- if (!op) return ENOMEM;
- op->cmd = FDOP_CLOSE;
- op->fd = fd;
- if ((op->next = fa->__actions)) op->next->prev = op;
- op->prev = 0;
- fa->__actions = op;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c
deleted file mode 100644
index addca4d4f0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_adddup2.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd)
-{
- if (srcfd < 0 || fd < 0) return EBADF;
- struct fdop *op = malloc(sizeof *op);
- if (!op) return ENOMEM;
- op->cmd = FDOP_DUP2;
- op->srcfd = srcfd;
- op->fd = fd;
- if ((op->next = fa->__actions)) op->next->prev = op;
- op->prev = 0;
- fa->__actions = op;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c
deleted file mode 100644
index e89ede8c3c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd)
-{
- if (fd < 0) return EBADF;
- struct fdop *op = malloc(sizeof *op);
- if (!op) return ENOMEM;
- op->cmd = FDOP_FCHDIR;
- op->fd = fd;
- if ((op->next = fa->__actions)) op->next->prev = op;
- op->prev = 0;
- fa->__actions = op;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c
deleted file mode 100644
index 82bbcec9eb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_addopen.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
-{
- if (fd < 0) return EBADF;
- struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
- if (!op) return ENOMEM;
- op->cmd = FDOP_OPEN;
- op->fd = fd;
- op->oflag = flags;
- op->mode = mode;
- strcpy(op->path, path);
- if ((op->next = fa->__actions)) op->next->prev = op;
- op->prev = 0;
- fa->__actions = op;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_destroy.c
deleted file mode 100644
index 3251babb55..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_destroy.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <spawn.h>
-#include <stdlib.h>
-#include "fdop.h"
-
-int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *fa)
-{
- struct fdop *op = fa->__actions, *next;
- while (op) {
- next = op->next;
- free(op);
- op = next;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_init.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_init.c
deleted file mode 100644
index 89d5e12789..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawn_file_actions_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawn_file_actions_init(posix_spawn_file_actions_t *fa)
-{
- fa->__actions = 0;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_destroy.c
deleted file mode 100644
index fc714a1b24..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_destroy(posix_spawnattr_t *attr)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getflags.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getflags.c
deleted file mode 100644
index aa635ddaf6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getflags.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_getflags(const posix_spawnattr_t *restrict attr, short *restrict flags)
-{
- *flags = attr->__flags;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getpgroup.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getpgroup.c
deleted file mode 100644
index 0480527d6f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getpgroup.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_getpgroup(const posix_spawnattr_t *restrict attr, pid_t *restrict pgrp)
-{
- *pgrp = attr->__pgrp;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigdefault.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigdefault.c
deleted file mode 100644
index a49050aa4f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigdefault.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_getsigdefault(const posix_spawnattr_t *restrict attr, sigset_t *restrict def)
-{
- *def = attr->__def;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigmask.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigmask.c
deleted file mode 100644
index f60ad7f375..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_getsigmask.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_getsigmask(const posix_spawnattr_t *restrict attr, sigset_t *restrict mask)
-{
- *mask = attr->__mask;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_init.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_init.c
deleted file mode 100644
index 0dcd868f3c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_init(posix_spawnattr_t *attr)
-{
- *attr = (posix_spawnattr_t){ 0 };
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_sched.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_sched.c
deleted file mode 100644
index 3143635bac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_sched.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <spawn.h>
-#include <sched.h>
-#include <errno.h>
-
-int posix_spawnattr_getschedparam(const posix_spawnattr_t *restrict attr,
- struct sched_param *restrict schedparam)
-{
- return ENOSYS;
-}
-
-int posix_spawnattr_setschedparam(posix_spawnattr_t *restrict attr,
- const struct sched_param *restrict schedparam)
-{
- return ENOSYS;
-}
-
-int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *restrict attr, int *restrict policy)
-{
- return ENOSYS;
-}
-
-int posix_spawnattr_setschedpolicy(posix_spawnattr_t *attr, int policy)
-{
- return ENOSYS;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setflags.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setflags.c
deleted file mode 100644
index 6878099212..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setflags.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <spawn.h>
-#include <errno.h>
-
-int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags)
-{
- const unsigned all_flags =
- POSIX_SPAWN_RESETIDS |
- POSIX_SPAWN_SETPGROUP |
- POSIX_SPAWN_SETSIGDEF |
- POSIX_SPAWN_SETSIGMASK |
- POSIX_SPAWN_SETSCHEDPARAM |
- POSIX_SPAWN_SETSCHEDULER |
- POSIX_SPAWN_USEVFORK |
- POSIX_SPAWN_SETSID;
- if (flags & ~all_flags) return EINVAL;
- attr->__flags = flags;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setpgroup.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setpgroup.c
deleted file mode 100644
index f39596a6ec..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setpgroup.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_setpgroup(posix_spawnattr_t *attr, pid_t pgrp)
-{
- attr->__pgrp = pgrp;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigdefault.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigdefault.c
deleted file mode 100644
index 5686972670..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigdefault.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_setsigdefault(posix_spawnattr_t *restrict attr, const sigset_t *restrict def)
-{
- attr->__def = *def;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigmask.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigmask.c
deleted file mode 100644
index f2532f8e0e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnattr_setsigmask.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <spawn.h>
-
-int posix_spawnattr_setsigmask(posix_spawnattr_t *restrict attr, const sigset_t *restrict mask)
-{
- attr->__mask = *mask;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnp.c b/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnp.c
deleted file mode 100644
index aad6133b91..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/posix_spawnp.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <spawn.h>
-#include <unistd.h>
-
-int posix_spawnp(pid_t *restrict res, const char *restrict file,
- const posix_spawn_file_actions_t *fa,
- const posix_spawnattr_t *restrict attr,
- char *const argv[restrict], char *const envp[restrict])
-{
- posix_spawnattr_t spawnp_attr = { 0 };
- if (attr) spawnp_attr = *attr;
- spawnp_attr.__fn = (void *)__execvpe;
- return posix_spawn(res, file, fa, &spawnp_attr, argv, envp);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/s390x/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/s390x/vfork.s
deleted file mode 100644
index 744f9d78d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/s390x/vfork.s
+++ /dev/null
@@ -1,6 +0,0 @@
- .global vfork
- .type vfork,%function
-vfork:
- svc 190
- .hidden __syscall_ret
- jg __syscall_ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/sh/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/sh/vfork.s
deleted file mode 100644
index 91dbde7b93..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/sh/vfork.s
+++ /dev/null
@@ -1,20 +0,0 @@
-.global vfork
-.type vfork,@function
-vfork:
- mov #95, r3
- add r3, r3
-
- trapa #31
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
- mov r0, r4
- mov.l 1f, r0
-2: braf r0
- nop
- .align 2
- .hidden __syscall_ret
-1: .long __syscall_ret@PLT-(2b+4-.)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/system.c b/lib/libc/wasi/libc-top-half/musl/src/process/system.c
deleted file mode 100644
index 5af59b809f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/system.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <sys/wait.h>
-#include <spawn.h>
-#include <errno.h>
-#include "pthread_impl.h"
-
-extern char **__environ;
-
-int system(const char *cmd)
-{
- pid_t pid;
- sigset_t old, reset;
- struct sigaction sa = { .sa_handler = SIG_IGN }, oldint, oldquit;
- int status = -1, ret;
- posix_spawnattr_t attr;
-
- pthread_testcancel();
-
- if (!cmd) return 1;
-
- sigaction(SIGINT, &sa, &oldint);
- sigaction(SIGQUIT, &sa, &oldquit);
- sigaddset(&sa.sa_mask, SIGCHLD);
- sigprocmask(SIG_BLOCK, &sa.sa_mask, &old);
-
- sigemptyset(&reset);
- if (oldint.sa_handler != SIG_IGN) sigaddset(&reset, SIGINT);
- if (oldquit.sa_handler != SIG_IGN) sigaddset(&reset, SIGQUIT);
- posix_spawnattr_init(&attr);
- posix_spawnattr_setsigmask(&attr, &old);
- posix_spawnattr_setsigdefault(&attr, &reset);
- posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF|POSIX_SPAWN_SETSIGMASK);
- ret = posix_spawn(&pid, "/bin/sh", 0, &attr,
- (char *[]){"sh", "-c", (char *)cmd, 0}, __environ);
- posix_spawnattr_destroy(&attr);
-
- if (!ret) while (waitpid(pid, &status, 0)<0 && errno == EINTR);
- sigaction(SIGINT, &oldint, NULL);
- sigaction(SIGQUIT, &oldquit, NULL);
- sigprocmask(SIG_SETMASK, &old, NULL);
-
- if (ret) errno = ret;
- return status;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/vfork.c b/lib/libc/wasi/libc-top-half/musl/src/process/vfork.c
deleted file mode 100644
index d430c13fca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/vfork.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <signal.h>
-#include "syscall.h"
-
-pid_t vfork(void)
-{
- /* vfork syscall cannot be made from C code */
-#ifdef SYS_fork
- return syscall(SYS_fork);
-#else
- return syscall(SYS_clone, SIGCHLD, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/wait.c b/lib/libc/wasi/libc-top-half/musl/src/process/wait.c
deleted file mode 100644
index 34da102d58..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/wait.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/wait.h>
-
-pid_t wait(int *status)
-{
- return waitpid((pid_t)-1, status, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/waitid.c b/lib/libc/wasi/libc-top-half/musl/src/process/waitid.c
deleted file mode 100644
index d688650d85..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/waitid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/wait.h>
-#include "syscall.h"
-
-int waitid(idtype_t type, id_t id, siginfo_t *info, int options)
-{
- return syscall_cp(SYS_waitid, type, id, info, options, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/waitpid.c b/lib/libc/wasi/libc-top-half/musl/src/process/waitpid.c
deleted file mode 100644
index 1b65bf0512..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/waitpid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/wait.h>
-#include "syscall.h"
-
-pid_t waitpid(pid_t pid, int *status, int options)
-{
- return syscall_cp(SYS_wait4, pid, status, options, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/x32/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/x32/vfork.s
deleted file mode 100644
index 0f0ca3ee48..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/x32/vfork.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.global vfork
-.type vfork,@function
-vfork:
- pop %rdx
- mov $0x4000003a,%eax /* SYS_vfork */
- syscall
- push %rdx
- mov %rax,%rdi
- .hidden __syscall_ret
- jmp __syscall_ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/process/x86_64/vfork.s b/lib/libc/wasi/libc-top-half/musl/src/process/x86_64/vfork.s
deleted file mode 100644
index 9114439031..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/process/x86_64/vfork.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.global vfork
-.type vfork,@function
-vfork:
- pop %rdx
- mov $58,%eax
- syscall
- push %rdx
- mov %rax,%rdi
- .hidden __syscall_ret
- jmp __syscall_ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/affinity.c b/lib/libc/wasi/libc-top-half/musl/src/sched/affinity.c
deleted file mode 100644
index 948ece413f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/affinity.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#define _GNU_SOURCE
-#include <sched.h>
-#include <string.h>
-#include "pthread_impl.h"
-#include "syscall.h"
-
-int sched_setaffinity(pid_t tid, size_t size, const cpu_set_t *set)
-{
- return syscall(SYS_sched_setaffinity, tid, size, set);
-}
-
-int pthread_setaffinity_np(pthread_t td, size_t size, const cpu_set_t *set)
-{
- return -__syscall(SYS_sched_setaffinity, td->tid, size, set);
-}
-
-static int do_getaffinity(pid_t tid, size_t size, cpu_set_t *set)
-{
- long ret = __syscall(SYS_sched_getaffinity, tid, size, set);
- if (ret < 0) return ret;
- if (ret < size) memset((char *)set+ret, 0, size-ret);
- return 0;
-}
-
-int sched_getaffinity(pid_t tid, size_t size, cpu_set_t *set)
-{
- return __syscall_ret(do_getaffinity(tid, size, set));
-}
-
-int pthread_getaffinity_np(pthread_t td, size_t size, cpu_set_t *set)
-{
- return -do_getaffinity(td->tid, size, set);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_cpucount.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_cpucount.c
deleted file mode 100644
index 94aa259e6a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_cpucount.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#define _GNU_SOURCE
-#include <sched.h>
-
-int __sched_cpucount(size_t size, const cpu_set_t *set)
-{
- size_t i, j, cnt=0;
- const unsigned char *p = (const void *)set;
- for (i=0; i<size; i++) for (j=0; j<8; j++)
- if (p[i] & (1<<j)) cnt++;
- return cnt;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_get_priority_max.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_get_priority_max.c
deleted file mode 100644
index 30ae5100e1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_get_priority_max.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sched.h>
-#include "syscall.h"
-
-int sched_get_priority_max(int policy)
-{
- return syscall(SYS_sched_get_priority_max, policy);
-}
-
-int sched_get_priority_min(int policy)
-{
- return syscall(SYS_sched_get_priority_min, policy);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getcpu.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getcpu.c
deleted file mode 100644
index 4ec5eaf679..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getcpu.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#define _GNU_SOURCE
-#include <errno.h>
-#include <sched.h>
-#include "syscall.h"
-#include "atomic.h"
-
-#ifdef VDSO_GETCPU_SYM
-
-static void *volatile vdso_func;
-
-typedef long (*getcpu_f)(unsigned *, unsigned *, void *);
-
-static long getcpu_init(unsigned *cpu, unsigned *node, void *unused)
-{
- void *p = __vdsosym(VDSO_GETCPU_VER, VDSO_GETCPU_SYM);
- getcpu_f f = (getcpu_f)p;
- a_cas_p(&vdso_func, (void *)getcpu_init, p);
- return f ? f(cpu, node, unused) : -ENOSYS;
-}
-
-static void *volatile vdso_func = (void *)getcpu_init;
-
-#endif
-
-int sched_getcpu(void)
-{
- int r;
- unsigned cpu;
-
-#ifdef VDSO_GETCPU_SYM
- getcpu_f f = (getcpu_f)vdso_func;
- if (f) {
- r = f(&cpu, 0, 0);
- if (!r) return cpu;
- if (r != -ENOSYS) return __syscall_ret(r);
- }
-#endif
-
- r = __syscall(SYS_getcpu, &cpu, 0, 0);
- if (!r) return cpu;
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getparam.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getparam.c
deleted file mode 100644
index 76f10e49d9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getparam.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sched.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sched_getparam(pid_t pid, struct sched_param *param)
-{
- return __syscall_ret(-ENOSYS);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getscheduler.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getscheduler.c
deleted file mode 100644
index 394e508b46..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_getscheduler.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sched.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sched_getscheduler(pid_t pid)
-{
- return __syscall_ret(-ENOSYS);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_rr_get_interval.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_rr_get_interval.c
deleted file mode 100644
index 33a3d1aeed..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_rr_get_interval.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <sched.h>
-#include "syscall.h"
-
-int sched_rr_get_interval(pid_t pid, struct timespec *ts)
-{
-#ifdef SYS_sched_rr_get_interval_time64
- /* On a 32-bit arch, use the old syscall if it exists. */
- if (SYS_sched_rr_get_interval != SYS_sched_rr_get_interval_time64) {
- long ts32[2];
- int r = __syscall(SYS_sched_rr_get_interval, pid, ts32);
- if (!r) {
- ts->tv_sec = ts32[0];
- ts->tv_nsec = ts32[1];
- }
- return __syscall_ret(r);
- }
-#endif
- /* If reaching this point, it's a 64-bit arch or time64-only
- * 32-bit arch and we can get result directly into timespec. */
- return syscall(SYS_sched_rr_get_interval, pid, ts);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setparam.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setparam.c
deleted file mode 100644
index 18623ee49b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setparam.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sched.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sched_setparam(pid_t pid, const struct sched_param *param)
-{
- return __syscall_ret(-ENOSYS);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setscheduler.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setscheduler.c
deleted file mode 100644
index 4435f21646..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_setscheduler.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sched.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sched_setscheduler(pid_t pid, int sched, const struct sched_param *param)
-{
- return __syscall_ret(-ENOSYS);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_yield.c b/lib/libc/wasi/libc-top-half/musl/src/sched/sched_yield.c
deleted file mode 100644
index ee6f0e7f16..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/sched/sched_yield.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sched.h>
-#include "syscall.h"
-
-int sched_yield()
-{
- return syscall(SYS_sched_yield);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/select/poll.c b/lib/libc/wasi/libc-top-half/musl/src/select/poll.c
deleted file mode 100644
index c84c8a999c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/select/poll.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <poll.h>
-#include <time.h>
-#include <signal.h>
-#include "syscall.h"
-
-int poll(struct pollfd *fds, nfds_t n, int timeout)
-{
-#ifdef SYS_poll
- return syscall_cp(SYS_poll, fds, n, timeout);
-#else
- return syscall_cp(SYS_ppoll, fds, n, timeout>=0 ?
- &((struct timespec){ .tv_sec = timeout/1000,
- .tv_nsec = timeout%1000*1000000 }) : 0, 0, _NSIG/8);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/select/pselect.c b/lib/libc/wasi/libc-top-half/musl/src/select/pselect.c
deleted file mode 100644
index 54cfb291bb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/select/pselect.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <sys/select.h>
-#include <signal.h>
-#include <stdint.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec *restrict ts, const sigset_t *restrict mask)
-{
- syscall_arg_t data[2] = { (uintptr_t)mask, _NSIG/8 };
- time_t s = ts ? ts->tv_sec : 0;
- long ns = ts ? ts->tv_nsec : 0;
-#ifdef SYS_pselect6_time64
- int r = -ENOSYS;
- if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
- ts ? ((long long[]){s, ns}) : 0, data);
- if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
- return __syscall_ret(r);
- s = CLAMP(s);
-#endif
- return syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
- ts ? ((long[]){s, ns}) : 0, data);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/select/select.c b/lib/libc/wasi/libc-top-half/musl/src/select/select.c
deleted file mode 100644
index 8a78688403..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/select/select.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include <sys/select.h>
-#include <signal.h>
-#include <stdint.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
-{
- time_t s = tv ? tv->tv_sec : 0;
- suseconds_t us = tv ? tv->tv_usec : 0;
- long ns;
- const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1;
-
- if (s<0 || us<0) return __syscall_ret(-EINVAL);
- if (us/1000000 > max_time - s) {
- s = max_time;
- us = 999999;
- ns = 999999999;
- } else {
- s += us/1000000;
- us %= 1000000;
- ns = us*1000;
- }
-
-#ifdef SYS_pselect6_time64
- int r = -ENOSYS;
- if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds,
- tv ? ((long long[]){s, ns}) : 0,
- ((syscall_arg_t[]){ 0, _NSIG/8 }));
- if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS)
- return __syscall_ret(r);
-#endif
-#ifdef SYS_select
- return syscall_cp(SYS_select, n, rfds, wfds, efds,
- tv ? ((long[]){s, us}) : 0);
-#else
- return syscall_cp(SYS_pselect6, n, rfds, wfds, efds,
- tv ? ((long[]){s, ns}) : 0, ((syscall_arg_t[]){ 0, _NSIG/8 }));
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/longjmp.s
deleted file mode 100644
index 0af9c50ee5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/longjmp.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.global _longjmp
-.global longjmp
-.type _longjmp,%function
-.type longjmp,%function
-_longjmp:
-longjmp:
- // IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers
- ldp x19, x20, [x0,#0]
- ldp x21, x22, [x0,#16]
- ldp x23, x24, [x0,#32]
- ldp x25, x26, [x0,#48]
- ldp x27, x28, [x0,#64]
- ldp x29, x30, [x0,#80]
- ldr x2, [x0,#104]
- mov sp, x2
- ldp d8 , d9, [x0,#112]
- ldp d10, d11, [x0,#128]
- ldp d12, d13, [x0,#144]
- ldp d14, d15, [x0,#160]
-
- cmp w1, 0
- csinc w0, w1, wzr, ne
- br x30
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/setjmp.s
deleted file mode 100644
index f49288aa1c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/aarch64/setjmp.s
+++ /dev/null
@@ -1,24 +0,0 @@
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-__setjmp:
-_setjmp:
-setjmp:
- // IHI0055B_aapcs64.pdf 5.1.1, 5.1.2 callee saved registers
- stp x19, x20, [x0,#0]
- stp x21, x22, [x0,#16]
- stp x23, x24, [x0,#32]
- stp x25, x26, [x0,#48]
- stp x27, x28, [x0,#64]
- stp x29, x30, [x0,#80]
- mov x2, sp
- str x2, [x0,#104]
- stp d8, d9, [x0,#112]
- stp d10, d11, [x0,#128]
- stp d12, d13, [x0,#144]
- stp d14, d15, [x0,#160]
- mov x0, #0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/longjmp.s
deleted file mode 100644
index 8188f06bcd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/longjmp.s
+++ /dev/null
@@ -1,16 +0,0 @@
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- mov 4(%esp),%edx
- mov 8(%esp),%eax
- cmp $1,%eax
- adc $0, %al
- mov (%edx),%ebx
- mov 4(%edx),%esi
- mov 8(%edx),%edi
- mov 12(%edx),%ebp
- mov 16(%edx),%esp
- jmp *20(%edx)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/setjmp.s
deleted file mode 100644
index 4d19cf87cb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/i386/setjmp.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.global ___setjmp
-.hidden ___setjmp
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-___setjmp:
-__setjmp:
-_setjmp:
-setjmp:
- mov 4(%esp), %eax
- mov %ebx, (%eax)
- mov %esi, 4(%eax)
- mov %edi, 8(%eax)
- mov %ebp, 12(%eax)
- lea 4(%esp), %ecx
- mov %ecx, 16(%eax)
- mov (%esp), %ecx
- mov %ecx, 20(%eax)
- xor %eax, %eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/longjmp.c b/lib/libc/wasi/libc-top-half/musl/src/setjmp/longjmp.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/longjmp.c
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/longjmp.s
deleted file mode 100644
index cdb05fb5a6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/longjmp.s
+++ /dev/null
@@ -1,14 +0,0 @@
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- movea.l 4(%sp),%a0
- move.l 8(%sp),%d0
- bne 1f
- move.l #1,%d0
-1: movem.l (%a0),%d2-%d7/%a2-%a7
- fmovem.x 52(%a0),%fp2-%fp7
- move.l 48(%a0),(%sp)
- rts
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/setjmp.s
deleted file mode 100644
index 15e549b0ef..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/m68k/setjmp.s
+++ /dev/null
@@ -1,18 +0,0 @@
-.global ___setjmp
-.hidden ___setjmp
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-___setjmp:
-__setjmp:
-_setjmp:
-setjmp:
- movea.l 4(%sp),%a0
- movem.l %d2-%d7/%a2-%a7,(%a0)
- move.l (%sp),48(%a0)
- fmovem.x %fp2-%fp7,52(%a0)
- clr.l %d0
- rts
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/longjmp.s
deleted file mode 100644
index c0760288a7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/longjmp.s
+++ /dev/null
@@ -1,29 +0,0 @@
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- addi r3, r6, 0
- bnei r3, 1f
- addi r3, r3, 1
-1: lwi r1, r5, 0
- lwi r15, r5, 4
- lwi r2, r5, 8
- lwi r13, r5, 12
- lwi r18, r5, 16
- lwi r19, r5, 20
- lwi r20, r5, 24
- lwi r21, r5, 28
- lwi r22, r5, 32
- lwi r23, r5, 36
- lwi r24, r5, 40
- lwi r25, r5, 44
- lwi r26, r5, 48
- lwi r27, r5, 52
- lwi r28, r5, 56
- lwi r29, r5, 60
- lwi r30, r5, 64
- lwi r31, r5, 68
- rtsd r15, 8
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/setjmp.s
deleted file mode 100644
index 605ab20e4b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/microblaze/setjmp.s
+++ /dev/null
@@ -1,32 +0,0 @@
-.global ___setjmp
-.hidden ___setjmp
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-___setjmp:
-__setjmp:
-_setjmp:
-setjmp:
- swi r1, r5, 0
- swi r15, r5, 4
- swi r2, r5, 8
- swi r13, r5, 12
- swi r18, r5, 16
- swi r19, r5, 20
- swi r20, r5, 24
- swi r21, r5, 28
- swi r22, r5, 32
- swi r23, r5, 36
- swi r24, r5, 40
- swi r25, r5, 44
- swi r26, r5, 48
- swi r27, r5, 52
- swi r28, r5, 56
- swi r29, r5, 60
- swi r30, r5, 64
- swi r31, r5, 68
- rtsd r15, 8
- ori r3, r0, 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/longjmp.s
deleted file mode 100644
index 1db9fd9339..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/longjmp.s
+++ /dev/null
@@ -1,25 +0,0 @@
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- l.sfeqi r4, 0
- l.bnf 1f
- l.addi r11, r4,0
- l.ori r11, r0, 1
-1: l.lwz r1, 0(r3)
- l.lwz r2, 4(r3)
- l.lwz r9, 8(r3)
- l.lwz r10, 12(r3)
- l.lwz r14, 16(r3)
- l.lwz r16, 20(r3)
- l.lwz r18, 24(r3)
- l.lwz r20, 28(r3)
- l.lwz r22, 32(r3)
- l.lwz r24, 36(r3)
- l.lwz r26, 40(r3)
- l.lwz r28, 44(r3)
- l.lwz r30, 48(r3)
- l.jr r9
- l.nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/setjmp.s
deleted file mode 100644
index 0677033843..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/or1k/setjmp.s
+++ /dev/null
@@ -1,27 +0,0 @@
-.global ___setjmp
-.hidden ___setjmp
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-___setjmp:
-__setjmp:
-_setjmp:
-setjmp:
- l.sw 0(r3), r1
- l.sw 4(r3), r2
- l.sw 8(r3), r9
- l.sw 12(r3), r10
- l.sw 16(r3), r14
- l.sw 20(r3), r16
- l.sw 24(r3), r18
- l.sw 28(r3), r20
- l.sw 32(r3), r22
- l.sw 36(r3), r24
- l.sw 40(r3), r26
- l.sw 44(r3), r28
- l.sw 48(r3), r30
- l.jr r9
- l.ori r11,r0,0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s
deleted file mode 100644
index 81d45ff60b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/longjmp.s
+++ /dev/null
@@ -1,81 +0,0 @@
- .global _longjmp
- .global longjmp
- .type _longjmp,@function
- .type longjmp,@function
-_longjmp:
-longjmp:
- # 0) move old return address into the link register
- ld 0, 0*8(3)
- mtlr 0
- # 1) restore cr
- ld 0, 1*8(3)
- mtcr 0
- # 2) restore SP
- ld 1, 2*8(3)
- # 3) restore TOC into both r2 and the caller's stack.
- # Which location is required depends on whether setjmp was called
- # locally or non-locally, but it's always safe to restore to both.
- ld 2, 3*8(3)
- std 2, 24(1)
- # 4) restore r14-r31
- ld 14, 4*8(3)
- ld 15, 5*8(3)
- ld 16, 6*8(3)
- ld 17, 7*8(3)
- ld 18, 8*8(3)
- ld 19, 9*8(3)
- ld 20, 10*8(3)
- ld 21, 11*8(3)
- ld 22, 12*8(3)
- ld 23, 13*8(3)
- ld 24, 14*8(3)
- ld 25, 15*8(3)
- ld 26, 16*8(3)
- ld 27, 17*8(3)
- ld 28, 18*8(3)
- ld 29, 19*8(3)
- ld 30, 20*8(3)
- ld 31, 21*8(3)
- # 5) restore floating point registers f14-f31
- lfd 14, 22*8(3)
- lfd 15, 23*8(3)
- lfd 16, 24*8(3)
- lfd 17, 25*8(3)
- lfd 18, 26*8(3)
- lfd 19, 27*8(3)
- lfd 20, 28*8(3)
- lfd 21, 29*8(3)
- lfd 22, 30*8(3)
- lfd 23, 31*8(3)
- lfd 24, 32*8(3)
- lfd 25, 33*8(3)
- lfd 26, 34*8(3)
- lfd 27, 35*8(3)
- lfd 28, 36*8(3)
- lfd 29, 37*8(3)
- lfd 30, 38*8(3)
- lfd 31, 39*8(3)
-
- # 6) restore vector registers v20-v31
- addi 3, 3, 40*8
- lvx 20, 0, 3 ; addi 3, 3, 16
- lvx 21, 0, 3 ; addi 3, 3, 16
- lvx 22, 0, 3 ; addi 3, 3, 16
- lvx 23, 0, 3 ; addi 3, 3, 16
- lvx 24, 0, 3 ; addi 3, 3, 16
- lvx 25, 0, 3 ; addi 3, 3, 16
- lvx 26, 0, 3 ; addi 3, 3, 16
- lvx 27, 0, 3 ; addi 3, 3, 16
- lvx 28, 0, 3 ; addi 3, 3, 16
- lvx 29, 0, 3 ; addi 3, 3, 16
- lvx 30, 0, 3 ; addi 3, 3, 16
- lvx 31, 0, 3
-
- # 7) return r4 ? r4 : 1
- mr 3, 4
- cmpwi cr7, 4, 0
- bne cr7, 1f
- li 3, 1
-1:
- blr
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s
deleted file mode 100644
index 37683fdaf4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/powerpc64/setjmp.s
+++ /dev/null
@@ -1,89 +0,0 @@
- .global __setjmp
- .global _setjmp
- .global setjmp
- .type __setjmp,@function
- .type _setjmp,@function
- .type setjmp,@function
-__setjmp:
-_setjmp:
-setjmp:
- ld 5, 24(1) # load from the TOC slot in the caller's stack frame
- b __setjmp_toc
-
- .localentry __setjmp,.-__setjmp
- .localentry _setjmp,.-_setjmp
- .localentry setjmp,.-setjmp
- mr 5, 2
-
- .global __setjmp_toc
- .hidden __setjmp_toc
- # same as normal setjmp, except TOC pointer to save is provided in r5.
- # r4 would normally be the 2nd parameter, but we're using r5 to simplify calling from sigsetjmp.
- # solves the problem of knowing whether to save the TOC pointer from r2 or the caller's stack frame.
-__setjmp_toc:
- # 0) store IP into 0, then into the jmpbuf pointed to by r3 (first arg)
- mflr 0
- std 0, 0*8(3)
- # 1) store cr
- mfcr 0
- std 0, 1*8(3)
- # 2) store SP and TOC
- std 1, 2*8(3)
- std 5, 3*8(3)
- # 3) store r14-31
- std 14, 4*8(3)
- std 15, 5*8(3)
- std 16, 6*8(3)
- std 17, 7*8(3)
- std 18, 8*8(3)
- std 19, 9*8(3)
- std 20, 10*8(3)
- std 21, 11*8(3)
- std 22, 12*8(3)
- std 23, 13*8(3)
- std 24, 14*8(3)
- std 25, 15*8(3)
- std 26, 16*8(3)
- std 27, 17*8(3)
- std 28, 18*8(3)
- std 29, 19*8(3)
- std 30, 20*8(3)
- std 31, 21*8(3)
- # 4) store floating point registers f14-f31
- stfd 14, 22*8(3)
- stfd 15, 23*8(3)
- stfd 16, 24*8(3)
- stfd 17, 25*8(3)
- stfd 18, 26*8(3)
- stfd 19, 27*8(3)
- stfd 20, 28*8(3)
- stfd 21, 29*8(3)
- stfd 22, 30*8(3)
- stfd 23, 31*8(3)
- stfd 24, 32*8(3)
- stfd 25, 33*8(3)
- stfd 26, 34*8(3)
- stfd 27, 35*8(3)
- stfd 28, 36*8(3)
- stfd 29, 37*8(3)
- stfd 30, 38*8(3)
- stfd 31, 39*8(3)
-
- # 5) store vector registers v20-v31
- addi 3, 3, 40*8
- stvx 20, 0, 3 ; addi 3, 3, 16
- stvx 21, 0, 3 ; addi 3, 3, 16
- stvx 22, 0, 3 ; addi 3, 3, 16
- stvx 23, 0, 3 ; addi 3, 3, 16
- stvx 24, 0, 3 ; addi 3, 3, 16
- stvx 25, 0, 3 ; addi 3, 3, 16
- stvx 26, 0, 3 ; addi 3, 3, 16
- stvx 27, 0, 3 ; addi 3, 3, 16
- stvx 28, 0, 3 ; addi 3, 3, 16
- stvx 29, 0, 3 ; addi 3, 3, 16
- stvx 30, 0, 3 ; addi 3, 3, 16
- stvx 31, 0, 3
-
- # 6) return 0
- li 3, 0
- blr
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/longjmp.s
deleted file mode 100644
index b2310f8ad1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/longjmp.s
+++ /dev/null
@@ -1,23 +0,0 @@
- .global _longjmp
- .global longjmp
- .type _longjmp,@function
- .type longjmp,@function
-_longjmp:
-longjmp:
-
-1:
- lmg %r6, %r15, 0(%r2)
-
- ld %f8, 10*8(%r2)
- ld %f9, 11*8(%r2)
- ld %f10, 12*8(%r2)
- ld %f11, 13*8(%r2)
- ld %f12, 14*8(%r2)
- ld %f13, 15*8(%r2)
- ld %f14, 16*8(%r2)
- ld %f15, 17*8(%r2)
-
- ltgr %r2, %r3
- bnzr %r14
- lhi %r2, 1
- br %r14
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/setjmp.s
deleted file mode 100644
index afae1b6755..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/s390x/setjmp.s
+++ /dev/null
@@ -1,25 +0,0 @@
- .global ___setjmp
- .hidden ___setjmp
- .global __setjmp
- .global _setjmp
- .global setjmp
- .type __setjmp,@function
- .type _setjmp,@function
- .type setjmp,@function
-___setjmp:
-__setjmp:
-_setjmp:
-setjmp:
- stmg %r6, %r15, 0(%r2)
-
- std %f8, 10*8(%r2)
- std %f9, 11*8(%r2)
- std %f10, 12*8(%r2)
- std %f11, 13*8(%r2)
- std %f12, 14*8(%r2)
- std %f13, 15*8(%r2)
- std %f14, 16*8(%r2)
- std %f15, 17*8(%r2)
-
- lghi %r2, 0
- br %r14
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/setjmp.c b/lib/libc/wasi/libc-top-half/musl/src/setjmp/setjmp.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/setjmp.c
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/longjmp.s
deleted file mode 100644
index 1b2661c3e5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/longjmp.s
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- xor %eax,%eax
- cmp $1,%esi /* CF = val ? 0 : 1 */
- adc %esi,%eax /* eax = val + !val */
- mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */
- mov 8(%rdi),%rbp
- mov 16(%rdi),%r12
- mov 24(%rdi),%r13
- mov 32(%rdi),%r14
- mov 40(%rdi),%r15
- mov 48(%rdi),%rsp
- jmp *56(%rdi) /* goto saved address without altering rsp */
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/setjmp.s
deleted file mode 100644
index d95e485355..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x32/setjmp.s
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-__setjmp:
-_setjmp:
-setjmp:
- mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */
- mov %rbp,8(%rdi)
- mov %r12,16(%rdi)
- mov %r13,24(%rdi)
- mov %r14,32(%rdi)
- mov %r15,40(%rdi)
- lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */
- mov %rdx,48(%rdi)
- mov (%rsp),%rdx /* save return addr ptr for new rip */
- mov %rdx,56(%rdi)
- xor %eax,%eax /* always return 0 */
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/longjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/longjmp.s
deleted file mode 100644
index 1b2661c3e5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/longjmp.s
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.global _longjmp
-.global longjmp
-.type _longjmp,@function
-.type longjmp,@function
-_longjmp:
-longjmp:
- xor %eax,%eax
- cmp $1,%esi /* CF = val ? 0 : 1 */
- adc %esi,%eax /* eax = val + !val */
- mov (%rdi),%rbx /* rdi is the jmp_buf, restore regs from it */
- mov 8(%rdi),%rbp
- mov 16(%rdi),%r12
- mov 24(%rdi),%r13
- mov 32(%rdi),%r14
- mov 40(%rdi),%r15
- mov 48(%rdi),%rsp
- jmp *56(%rdi) /* goto saved address without altering rsp */
diff --git a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/setjmp.s b/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/setjmp.s
deleted file mode 100644
index d95e485355..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/setjmp/x86_64/setjmp.s
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.global __setjmp
-.global _setjmp
-.global setjmp
-.type __setjmp,@function
-.type _setjmp,@function
-.type setjmp,@function
-__setjmp:
-_setjmp:
-setjmp:
- mov %rbx,(%rdi) /* rdi is jmp_buf, move registers onto it */
- mov %rbp,8(%rdi)
- mov %r12,16(%rdi)
- mov %r13,24(%rdi)
- mov %r14,32(%rdi)
- mov %r15,40(%rdi)
- lea 8(%rsp),%rdx /* this is our rsp WITHOUT current ret addr */
- mov %rdx,48(%rdi)
- mov (%rsp),%rdx /* save return addr ptr for new rip */
- mov %rdx,56(%rdi)
- xor %eax,%eax /* always return 0 */
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/restore.s
deleted file mode 100644
index d4e5fcf1a3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/restore.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.global __restore
-.hidden __restore
-.type __restore,%function
-__restore:
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,%function
-__restore_rt:
- mov x8,#139 // SYS_rt_sigreturn
- svc 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/sigsetjmp.s
deleted file mode 100644
index 75910c4321..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/aarch64/sigsetjmp.s
+++ /dev/null
@@ -1,21 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,%function
-.type __sigsetjmp,%function
-sigsetjmp:
-__sigsetjmp:
- cbz x1,setjmp
-
- str x30,[x0,#176]
- str x19,[x0,#176+8+8]
- mov x19,x0
-
- bl setjmp
-
- mov w1,w0
- mov x0,x19
- ldr x30,[x0,#176]
- ldr x19,[x0,#176+8+8]
-
-.hidden __sigsetjmp_tail
- b __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/arm/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/arm/restore.s
deleted file mode 100644
index fb086d9ba7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/arm/restore.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.syntax unified
-
-.global __restore
-.hidden __restore
-.type __restore,%function
-__restore:
- mov r7,#119
- swi 0x0
-
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,%function
-__restore_rt:
- mov r7,#173
- swi 0x0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/arm/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/arm/sigsetjmp.s
deleted file mode 100644
index 69ebbf4993..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/arm/sigsetjmp.s
+++ /dev/null
@@ -1,24 +0,0 @@
-.syntax unified
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,%function
-.type __sigsetjmp,%function
-sigsetjmp:
-__sigsetjmp:
- tst r1,r1
- bne 1f
- b setjmp
-
-1: str lr,[r0,#256]
- str r4,[r0,#260+8]
- mov r4,r0
-
- bl setjmp
-
- mov r1,r0
- mov r0,r4
- ldr lr,[r0,#256]
- ldr r4,[r0,#260+8]
-
-.hidden __sigsetjmp_tail
- b __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/block.c b/lib/libc/wasi/libc-top-half/musl/src/signal/block.c
deleted file mode 100644
index cc8698f0bb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/block.c
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "pthread_impl.h"
-#include "syscall.h"
-#include <signal.h>
-
-static const unsigned long all_mask[] = {
-#if ULONG_MAX == 0xffffffff && _NSIG > 65
- -1UL, -1UL, -1UL, -1UL
-#elif ULONG_MAX == 0xffffffff || _NSIG > 65
- -1UL, -1UL
-#else
- -1UL
-#endif
-};
-
-static const unsigned long app_mask[] = {
-#if ULONG_MAX == 0xffffffff
-#if _NSIG == 65
- 0x7fffffff, 0xfffffffc
-#else
- 0x7fffffff, 0xfffffffc, -1UL, -1UL
-#endif
-#else
-#if _NSIG == 65
- 0xfffffffc7fffffff
-#else
- 0xfffffffc7fffffff, -1UL
-#endif
-#endif
-};
-
-void __block_all_sigs(void *set)
-{
- __syscall(SYS_rt_sigprocmask, SIG_BLOCK, &all_mask, set, _NSIG/8);
-}
-
-void __block_app_sigs(void *set)
-{
- __syscall(SYS_rt_sigprocmask, SIG_BLOCK, &app_mask, set, _NSIG/8);
-}
-
-void __restore_sigs(void *set)
-{
- __syscall(SYS_rt_sigprocmask, SIG_SETMASK, set, 0, _NSIG/8);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/getitimer.c b/lib/libc/wasi/libc-top-half/musl/src/signal/getitimer.c
deleted file mode 100644
index 36d1eb9dc6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/getitimer.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <sys/time.h>
-#include "syscall.h"
-
-int getitimer(int which, struct itimerval *old)
-{
- if (sizeof(time_t) > sizeof(long)) {
- long old32[4];
- int r = __syscall(SYS_getitimer, which, old32);
- if (!r) {
- old->it_interval.tv_sec = old32[0];
- old->it_interval.tv_usec = old32[1];
- old->it_value.tv_sec = old32[2];
- old->it_value.tv_usec = old32[3];
- }
- return __syscall_ret(r);
- }
- return syscall(SYS_getitimer, which, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/i386/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/i386/restore.s
deleted file mode 100644
index ccc94307ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/i386/restore.s
+++ /dev/null
@@ -1,14 +0,0 @@
-.global __restore
-.hidden __restore
-.type __restore,@function
-__restore:
- popl %eax
- movl $119, %eax
- int $0x80
-
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,@function
-__restore_rt:
- movl $173, %eax
- int $0x80
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/i386/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/i386/sigsetjmp.s
deleted file mode 100644
index 690b251c4c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/i386/sigsetjmp.s
+++ /dev/null
@@ -1,26 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- mov 8(%esp),%ecx
- jecxz 1f
-
- mov 4(%esp),%eax
- popl 24(%eax)
- mov %ebx,28+8(%eax)
- mov %eax,%ebx
-
-.hidden ___setjmp
- call ___setjmp
-
- pushl 24(%ebx)
- mov %ebx,4(%esp)
- mov %eax,8(%esp)
- mov 28+8(%ebx),%ebx
-
-.hidden __sigsetjmp_tail
- jmp __sigsetjmp_tail
-
-1: jmp ___setjmp
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/kill.c b/lib/libc/wasi/libc-top-half/musl/src/signal/kill.c
deleted file mode 100644
index 0580573309..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/kill.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <signal.h>
-#include "syscall.h"
-
-int kill(pid_t pid, int sig)
-{
- return syscall(SYS_kill, pid, sig);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/killpg.c b/lib/libc/wasi/libc-top-half/musl/src/signal/killpg.c
deleted file mode 100644
index 315ed44747..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/killpg.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-int killpg(pid_t pgid, int sig)
-{
- if (pgid < 0) {
- errno = EINVAL;
- return -1;
- }
- return kill(-pgid, sig);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/m68k/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/m68k/sigsetjmp.s
deleted file mode 100644
index 09bfa64680..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/m68k/sigsetjmp.s
+++ /dev/null
@@ -1,29 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- move.l 8(%sp),%d0
- beq 1f
-
- movea.l 4(%sp),%a1
- move.l (%sp)+,156(%a1)
- move.l %a2,156+4+8(%a1)
- movea.l %a1,%a2
-
-.hidden ___setjmp
- lea ___setjmp-.-8,%a1
- jsr (%pc,%a1)
-
- move.l 156(%a2),-(%sp)
- move.l %a2,4(%sp)
- move.l %d0,8(%sp)
- movea.l 156+4+8(%a2),%a2
-
-.hidden __sigsetjmp_tail
- lea __sigsetjmp_tail-.-8,%a1
- jmp (%pc,%a1)
-
-1: lea ___setjmp-.-8,%a1
- jmp (%pc,%a1)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/restore.s
deleted file mode 100644
index b3c9f57b65..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/restore.s
+++ /dev/null
@@ -1,13 +0,0 @@
-.global __restore
-.hidden __restore
-.type __restore,@function
-__restore:
- ori r12, r0, 119
- brki r14, 0x8
-
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,@function
-__restore_rt:
- ori r12, r0, 173
- brki r14, 0x8
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/sigsetjmp.s
deleted file mode 100644
index d1dd24c029..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/microblaze/sigsetjmp.s
+++ /dev/null
@@ -1,22 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
-.hidden ___setjmp
- beqi r6, ___setjmp
-
- swi r15,r5,72
- swi r19,r5,72+4+8
-
- brlid r15,___setjmp
- ori r19,r5,0
-
- ori r6,r3,0
- ori r5,r19,0
- lwi r15,r5,72
- lwi r19,r5,72+4+8
-
-.hidden __sigsetjmp_tail
- bri __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mips/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mips/restore.s
deleted file mode 100644
index b6dadce071..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mips/restore.s
+++ /dev/null
@@ -1,15 +0,0 @@
-.set noreorder
-
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,@function
-__restore_rt:
- li $2, 4193
- syscall
-
-.global __restore
-.hidden __restore
-.type __restore,@function
-__restore:
- li $2, 4119
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mips/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mips/sigsetjmp.s
deleted file mode 100644
index 74b65ff68f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mips/sigsetjmp.s
+++ /dev/null
@@ -1,33 +0,0 @@
-.set noreorder
-
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- lui $gp, %hi(_gp_disp)
- addiu $gp, %lo(_gp_disp)
- beq $5, $0, 1f
- addu $gp, $gp, $25
-
- sw $ra, 104($4)
- sw $16, 104+4+16($4)
-
- lw $25, %call16(setjmp)($gp)
- jalr $25
- move $16, $4
-
- move $5,$2
- move $4,$16
- lw $ra, 104($4)
- lw $16, 104+4+16($4)
-
-.hidden __sigsetjmp_tail
- lw $25, %call16(__sigsetjmp_tail)($gp)
- jr $25
- nop
-
-1: lw $25, %call16(setjmp)($gp)
- jr $25
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/restore.s
deleted file mode 100644
index 401f8e7322..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/restore.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.set noreorder
-.global __restore_rt
-.global __restore
-.hidden __restore_rt
-.hidden __restore
-.type __restore_rt,@function
-.type __restore,@function
-__restore_rt:
-__restore:
- li $2,5211
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/sigsetjmp.s
deleted file mode 100644
index 156e70bd0f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mips64/sigsetjmp.s
+++ /dev/null
@@ -1,38 +0,0 @@
-.set noreorder
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- lui $3, %hi(%neg(%gp_rel(sigsetjmp)))
- daddiu $3, $3, %lo(%neg(%gp_rel(sigsetjmp)))
-
- # comparing save mask with 0, if equals to 0 then
- # sigsetjmp is equal to setjmp.
- beq $5, $0, 1f
- daddu $3, $3, $25
- sd $ra, 160($4)
- sd $16, 168($4)
-
- # save base of got so that we can use it later
- # once we return from 'longjmp'
- sd $3, 176($4)
- ld $25, %got_disp(setjmp)($3)
- jalr $25
- move $16, $4
-
- move $5, $2 # Return from 'setjmp' or 'longjmp'
- move $4, $16 # Restore the pointer-to-sigjmp_buf
- ld $ra, 160($4) # Restore ra of sigsetjmp
- ld $16, 168($4) # Restore $16 of sigsetjmp
- ld $3, 176($4) # Restore base of got
-
-.hidden __sigsetjmp_tail
- ld $25, %got_disp(__sigsetjmp_tail)($3)
- jr $25
- nop
-1:
- ld $25, %got_disp(setjmp)($3)
- jr $25
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/restore.s
deleted file mode 100644
index 4cd4e1b4e4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/restore.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.set noreorder
-.global __restore_rt
-.global __restore
-.hidden __restore_rt
-.hidden __restore
-.type __restore_rt,@function
-.type __restore,@function
-__restore_rt:
-__restore:
- li $2,6211
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/sigsetjmp.s
deleted file mode 100644
index c0c6961f8f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/mipsn32/sigsetjmp.s
+++ /dev/null
@@ -1,38 +0,0 @@
-.set noreorder
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- lui $3, %hi(%neg(%gp_rel(sigsetjmp)))
- addiu $3, $3, %lo(%neg(%gp_rel(sigsetjmp)))
-
- # comparing save mask with 0, if equals to 0 then
- # sigsetjmp is equal to setjmp.
- beq $5, $0, 1f
- addu $3, $3, $25
- sd $ra, 160($4)
- sd $16, 168($4)
-
- # save base of got so that we can use it later
- # once we return from 'longjmp'
- sd $3, 176($4)
- lw $25, %got_disp(setjmp)($3)
- jalr $25
- move $16, $4
-
- move $5, $2 # Return from 'setjmp' or 'longjmp'
- move $4, $16 # Restore the pointer-to-sigjmp_buf
- ld $ra, 160($4) # Restore ra of sigsetjmp
- ld $16, 168($4) # Restore $16 of sigsetjmp
- ld $3, 176($4) # Restore base of got
-
-.hidden __sigsetjmp_tail
- lw $25, %got_disp(__sigsetjmp_tail)($3)
- jr $25
- nop
-1:
- lw $25, %got_disp(setjmp)($3)
- jr $25
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/or1k/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/or1k/sigsetjmp.s
deleted file mode 100644
index b9bcdae1db..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/or1k/sigsetjmp.s
+++ /dev/null
@@ -1,24 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- l.sfeq r4, r0
-.hidden ___setjmp
- l.bf ___setjmp
-
- l.sw 52(r3), r9
- l.sw 52+4+8(r3), r20
-
- l.jal ___setjmp
- l.ori r20, r3, 0
-
- l.ori r4, r11, 0
- l.ori r3, r20, 0
-
- l.lwz r9, 52(r3)
-
-.hidden __sigsetjmp_tail
- l.j __sigsetjmp_tail
- l.lwz r20, 52+4+8(r3)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/restore.s
deleted file mode 100644
index 29c8afd03c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/restore.s
+++ /dev/null
@@ -1,13 +0,0 @@
- .global __restore
- .hidden __restore
- .type __restore,%function
-__restore:
- li 0, 119 #__NR_sigreturn
- sc
-
- .global __restore_rt
- .hidden __restore_rt
- .type __restore_rt,%function
-__restore_rt:
- li 0, 172 # __NR_rt_sigreturn
- sc
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/sigsetjmp.s
deleted file mode 100644
index 152c3fedd7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc/sigsetjmp.s
+++ /dev/null
@@ -1,27 +0,0 @@
- .global sigsetjmp
- .global __sigsetjmp
- .type sigsetjmp,%function
- .type __sigsetjmp,%function
-sigsetjmp:
-__sigsetjmp:
- cmpwi cr7, 4, 0
- beq- cr7, 1f
-
- mflr 5
- stw 5, 448(3)
- stw 16, 448+4+8(3)
- mr 16, 3
-
-.hidden ___setjmp
- bl ___setjmp
-
- mr 4, 3
- mr 3, 16
- lwz 5, 448(3)
- mtlr 5
- lwz 16, 448+4+8(3)
-
-.hidden __sigsetjmp_tail
- b __sigsetjmp_tail
-
-1: b ___setjmp
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/restore.s
deleted file mode 100644
index 29c8afd03c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/restore.s
+++ /dev/null
@@ -1,13 +0,0 @@
- .global __restore
- .hidden __restore
- .type __restore,%function
-__restore:
- li 0, 119 #__NR_sigreturn
- sc
-
- .global __restore_rt
- .hidden __restore_rt
- .type __restore_rt,%function
-__restore_rt:
- li 0, 172 # __NR_rt_sigreturn
- sc
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/sigsetjmp.s
deleted file mode 100644
index 410c283191..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/powerpc64/sigsetjmp.s
+++ /dev/null
@@ -1,37 +0,0 @@
- .global sigsetjmp
- .global __sigsetjmp
- .type sigsetjmp,%function
- .type __sigsetjmp,%function
- .hidden __setjmp_toc
-sigsetjmp:
-__sigsetjmp:
- addis 2, 12, .TOC.-__sigsetjmp@ha
- addi 2, 2, .TOC.-__sigsetjmp@l
- ld 5, 24(1) # load from the TOC slot in the caller's stack frame
- b 1f
-
- .localentry sigsetjmp,.-sigsetjmp
- .localentry __sigsetjmp,.-__sigsetjmp
- mr 5, 2
-
-1:
- cmpwi cr7, 4, 0
- beq- cr7, __setjmp_toc
-
- mflr 6
- std 6, 512(3)
- std 2, 512+16(3)
- std 16, 512+24(3)
- mr 16, 3
-
- bl __setjmp_toc
-
- mr 4, 3
- mr 3, 16
- ld 5, 512(3)
- mtlr 5
- ld 2, 512+16(3)
- ld 16, 512+24(3)
-
-.hidden __sigsetjmp_tail
- b __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/psiginfo.c b/lib/libc/wasi/libc-top-half/musl/src/signal/psiginfo.c
deleted file mode 100644
index 2b15982be4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/psiginfo.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <signal.h>
-
-void psiginfo(const siginfo_t *si, const char *msg)
-{
- psignal(si->si_signo, msg);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/raise.c b/lib/libc/wasi/libc-top-half/musl/src/signal/raise.c
deleted file mode 100644
index f0512019a1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/raise.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <signal.h>
-#include <stdint.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-
-int raise(int sig)
-{
- sigset_t set;
- __block_app_sigs(&set);
- int ret = syscall(SYS_tkill, __pthread_self()->tid, sig);
- __restore_sigs(&set);
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/restore.c b/lib/libc/wasi/libc-top-half/musl/src/signal/restore.c
deleted file mode 100644
index 5ec4f5dddc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/restore.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <features.h>
-
-/* These functions will not work, but suffice for targets where the
- * kernel sigaction structure does not actually use sa_restorer. */
-
-hidden void __restore()
-{
-}
-
-hidden void __restore_rt()
-{
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/restore.s
deleted file mode 100644
index 40012c757a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/restore.s
+++ /dev/null
@@ -1,8 +0,0 @@
-.global __restore
-.type __restore, %function
-__restore:
-.global __restore_rt
-.type __restore_rt, %function
-__restore_rt:
- li a7, 139 # SYS_rt_sigreturn
- ecall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/sigsetjmp.s
deleted file mode 100644
index f9bc162a0a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/riscv64/sigsetjmp.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp, %function
-.type __sigsetjmp, %function
-sigsetjmp:
-__sigsetjmp:
- bnez a1, 1f
- tail setjmp
-1:
-
- sd ra, 208(a0)
- sd s0, 224(a0)
- mv s0, a0
-
- call setjmp
-
- mv a1, a0
- mv a0, s0
- ld s0, 224(a0)
- ld ra, 208(a0)
-
-.hidden __sigsetjmp_tail
- tail __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/restore.s
deleted file mode 100644
index 88e33dbc22..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/restore.s
+++ /dev/null
@@ -1,11 +0,0 @@
- .global __restore
- .hidden __restore
- .type __restore,%function
-__restore:
- svc 119 #__NR_sigreturn
-
- .global __restore_rt
- .hidden __restore_rt
- .type __restore_rt,%function
-__restore_rt:
- svc 173 # __NR_rt_sigreturn
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/sigsetjmp.s
deleted file mode 100644
index 41b1bd9a16..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/s390x/sigsetjmp.s
+++ /dev/null
@@ -1,23 +0,0 @@
- .global sigsetjmp
- .global __sigsetjmp
- .type sigsetjmp,%function
- .type __sigsetjmp,%function
- .hidden ___setjmp
-sigsetjmp:
-__sigsetjmp:
- ltgr %r3, %r3
- jz ___setjmp
-
- stg %r14, 18*8(%r2)
- stg %r6, 20*8(%r2)
- lgr %r6, %r2
-
- brasl %r14, ___setjmp
-
- lgr %r3, %r2
- lgr %r2, %r6
- lg %r14, 18*8(%r2)
- lg %r6, 20*8(%r2)
-
-.hidden __sigsetjmp_tail
- jg __sigsetjmp_tail
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/setitimer.c b/lib/libc/wasi/libc-top-half/musl/src/signal/setitimer.c
deleted file mode 100644
index 0dfbeb4db5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/setitimer.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include <sys/time.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-
-int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
-{
- if (sizeof(time_t) > sizeof(long)) {
- time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec;
- long ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec;
- if (!IS32BIT(is) || !IS32BIT(vs))
- return __syscall_ret(-ENOTSUP);
- long old32[4];
- int r = __syscall(SYS_setitimer, which,
- ((long[]){is, ius, vs, vus}), old32);
- if (!r && old) {
- old->it_interval.tv_sec = old32[0];
- old->it_interval.tv_usec = old32[1];
- old->it_value.tv_sec = old32[2];
- old->it_value.tv_usec = old32[3];
- }
- return __syscall_ret(r);
- }
- return syscall(SYS_setitimer, which, new, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sh/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/sh/restore.s
deleted file mode 100644
index 3a92199db6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sh/restore.s
+++ /dev/null
@@ -1,24 +0,0 @@
-.global __restore
-.hidden __restore
-__restore:
- mov #119, r3 !__NR_sigreturn
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
-.global __restore_rt
-.hidden __restore_rt
-__restore_rt:
- mov #100, r3 !__NR_rt_sigreturn
- add #73, r3
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sh/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/sh/sigsetjmp.s
deleted file mode 100644
index 1e2270beec..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sh/sigsetjmp.s
+++ /dev/null
@@ -1,41 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- tst r5, r5
- bt 9f
-
- mov r4, r6
- add #60, r6
- sts pr, r0
- mov.l r0, @r6
- mov.l r8, @(4+8,r6)
-
- mov.l 1f, r0
-2: bsrf r0
- mov r4, r8
-
- mov r0, r5
- mov r8, r4
- mov r4, r6
- add #60, r6
-
- mov.l @r6, r0
- lds r0, pr
-
- mov.l 3f, r0
-4: braf r0
- mov.l @(4+8,r4), r8
-
-9: mov.l 5f, r0
-6: braf r0
- nop
-
-.align 2
-.hidden ___setjmp
-1: .long ___setjmp@PLT-(2b+4-.)
-.hidden __sigsetjmp_tail
-3: .long __sigsetjmp_tail@PLT-(4b+4-.)
-5: .long ___setjmp@PLT-(6b+4-.)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaction.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigaction.c
deleted file mode 100644
index 2203471b24..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaction.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-#include <string.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-#include "libc.h"
-#include "lock.h"
-#include "ksigaction.h"
-
-static int unmask_done;
-static unsigned long handler_set[_NSIG/(8*sizeof(long))];
-
-void __get_handler_set(sigset_t *set)
-{
- memcpy(set, handler_set, sizeof handler_set);
-}
-
-volatile int __eintr_valid_flag;
-
-int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
-{
- struct k_sigaction ksa, ksa_old;
- if (sa) {
- if ((uintptr_t)sa->sa_handler > 1UL) {
- a_or_l(handler_set+(sig-1)/(8*sizeof(long)),
- 1UL<<(sig-1)%(8*sizeof(long)));
-
- /* If pthread_create has not yet been called,
- * implementation-internal signals might not
- * yet have been unblocked. They must be
- * unblocked before any signal handler is
- * installed, so that an application cannot
- * receive an illegal sigset_t (with them
- * blocked) as part of the ucontext_t passed
- * to the signal handler. */
- if (!libc.threaded && !unmask_done) {
- __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK,
- SIGPT_SET, 0, _NSIG/8);
- unmask_done = 1;
- }
-
- if (!(sa->sa_flags & SA_RESTART)) {
- a_store(&__eintr_valid_flag, 1);
- }
- }
- ksa.handler = sa->sa_handler;
- ksa.flags = sa->sa_flags | SA_RESTORER;
- ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore;
- memcpy(&ksa.mask, &sa->sa_mask, _NSIG/8);
- }
- int r = __syscall(SYS_rt_sigaction, sig, sa?&ksa:0, old?&ksa_old:0, _NSIG/8);
- if (old && !r) {
- old->sa_handler = ksa_old.handler;
- old->sa_flags = ksa_old.flags;
- memcpy(&old->sa_mask, &ksa_old.mask, _NSIG/8);
- }
- return __syscall_ret(r);
-}
-
-int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
-{
- unsigned long set[_NSIG/(8*sizeof(long))];
-
- if (sig-32U < 3 || sig-1U >= _NSIG-1) {
- errno = EINVAL;
- return -1;
- }
-
- /* Doing anything with the disposition of SIGABRT requires a lock,
- * so that it cannot be changed while abort is terminating the
- * process and so any change made by abort can't be observed. */
- if (sig == SIGABRT) {
- __block_all_sigs(&set);
- LOCK(__abort_lock);
- }
- int r = __libc_sigaction(sig, sa, old);
- if (sig == SIGABRT) {
- UNLOCK(__abort_lock);
- __restore_sigs(&set);
- }
- return r;
-}
-
-weak_alias(__sigaction, sigaction);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaddset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigaddset.c
deleted file mode 100644
index 085d1f4ab9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaddset.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-int sigaddset(sigset_t *set, int sig)
-{
- unsigned s = sig-1;
- if (s >= _NSIG-1 || sig-32U < 3) {
- errno = EINVAL;
- return -1;
- }
- set->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaltstack.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigaltstack.c
deleted file mode 100644
index d3a6e8215f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigaltstack.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-#include "syscall.h"
-
-int sigaltstack(const stack_t *restrict ss, stack_t *restrict old)
-{
- if (ss) {
- if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < MINSIGSTKSZ) {
- errno = ENOMEM;
- return -1;
- }
- if (ss->ss_flags & SS_ONSTACK) {
- errno = EINVAL;
- return -1;
- }
- }
- return syscall(SYS_sigaltstack, ss, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigandset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigandset.c
deleted file mode 100644
index 974186f3d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigandset.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <signal.h>
-
-#define SST_SIZE (_NSIG/8/sizeof(long))
-
-int sigandset(sigset_t *dest, const sigset_t *left, const sigset_t *right)
-{
- unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right;
- for(; i < SST_SIZE; i++) d[i] = l[i] & r[i];
- return 0;
-}
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigdelset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigdelset.c
deleted file mode 100644
index ce69280e0c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigdelset.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-int sigdelset(sigset_t *set, int sig)
-{
- unsigned s = sig-1;
- if (s >= _NSIG-1 || sig-32U < 3) {
- errno = EINVAL;
- return -1;
- }
- set->__bits[s/8/sizeof *set->__bits] &=~(1UL<<(s&8*sizeof *set->__bits-1));
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigemptyset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigemptyset.c
deleted file mode 100644
index 1d07471da4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigemptyset.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <signal.h>
-#include <string.h>
-
-int sigemptyset(sigset_t *set)
-{
- set->__bits[0] = 0;
- if (sizeof(long)==4 || _NSIG > 65) set->__bits[1] = 0;
- if (sizeof(long)==4 && _NSIG > 65) {
- set->__bits[2] = 0;
- set->__bits[3] = 0;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigfillset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigfillset.c
deleted file mode 100644
index 16e7b4f5bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigfillset.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <signal.h>
-#include <limits.h>
-
-int sigfillset(sigset_t *set)
-{
-#if ULONG_MAX == 0xffffffff
- set->__bits[0] = 0x7ffffffful;
- set->__bits[1] = 0xfffffffcul;
- if (_NSIG > 65) {
- set->__bits[2] = 0xfffffffful;
- set->__bits[3] = 0xfffffffful;
- }
-#else
- set->__bits[0] = 0xfffffffc7ffffffful;
- if (_NSIG > 65) set->__bits[1] = 0xfffffffffffffffful;
-#endif
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sighold.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sighold.c
deleted file mode 100644
index cfa2306c12..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sighold.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <signal.h>
-
-int sighold(int sig)
-{
- sigset_t mask;
-
- sigemptyset(&mask);
- if (sigaddset(&mask, sig) < 0) return -1;
- return sigprocmask(SIG_BLOCK, &mask, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigignore.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigignore.c
deleted file mode 100644
index 5ba05e129d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigignore.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <signal.h>
-
-int sigignore(int sig)
-{
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_handler = SIG_IGN;
- sa.sa_flags = 0;
- return sigaction(sig, &sa, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/siginterrupt.c b/lib/libc/wasi/libc-top-half/musl/src/signal/siginterrupt.c
deleted file mode 100644
index 7006340032..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/siginterrupt.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <signal.h>
-
-int siginterrupt(int sig, int flag)
-{
- struct sigaction sa;
-
- sigaction(sig, 0, &sa);
- if (flag) sa.sa_flags &= ~SA_RESTART;
- else sa.sa_flags |= SA_RESTART;
-
- return sigaction(sig, &sa, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigisemptyset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigisemptyset.c
deleted file mode 100644
index 68b8662468..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigisemptyset.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#define _GNU_SOURCE
-#include <signal.h>
-#include <string.h>
-
-int sigisemptyset(const sigset_t *set)
-{
- for (size_t i=0; i<_NSIG/8/sizeof *set->__bits; i++)
- if (set->__bits[i]) return 0;
- return 1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigismember.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigismember.c
deleted file mode 100644
index ab87d62249..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigismember.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <signal.h>
-
-int sigismember(const sigset_t *set, int sig)
-{
- unsigned s = sig-1;
- if (s >= _NSIG-1) return 0;
- return !!(set->__bits[s/8/sizeof *set->__bits] & 1UL<<(s&8*sizeof *set->__bits-1));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/siglongjmp.c b/lib/libc/wasi/libc-top-half/musl/src/signal/siglongjmp.c
deleted file mode 100644
index bc317acce9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/siglongjmp.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <setjmp.h>
-#include <signal.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-
-_Noreturn void siglongjmp(sigjmp_buf buf, int ret)
-{
- longjmp(buf, ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/signal.c b/lib/libc/wasi/libc-top-half/musl/src/signal/signal.c
deleted file mode 100644
index 7a6dd17276..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/signal.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <signal.h>
-#include "syscall.h"
-
-void (*signal(int sig, void (*func)(int)))(int)
-{
- struct sigaction sa_old, sa = { .sa_handler = func, .sa_flags = SA_RESTART };
- if (__sigaction(sig, &sa, &sa_old) < 0)
- return SIG_ERR;
- return sa_old.sa_handler;
-}
-
-weak_alias(signal, bsd_signal);
-weak_alias(signal, __sysv_signal);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigorset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigorset.c
deleted file mode 100644
index ed488738c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigorset.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <signal.h>
-
-#define SST_SIZE (_NSIG/8/sizeof(long))
-
-int sigorset(sigset_t *dest, const sigset_t *left, const sigset_t *right)
-{
- unsigned long i = 0, *d = (void*) dest, *l = (void*) left, *r = (void*) right;
- for(; i < SST_SIZE; i++) d[i] = l[i] | r[i];
- return 0;
-}
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigpause.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigpause.c
deleted file mode 100644
index 363d2fec27..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigpause.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <signal.h>
-
-int sigpause(int sig)
-{
- sigset_t mask;
- sigprocmask(0, 0, &mask);
- sigdelset(&mask, sig);
- return sigsuspend(&mask);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigpending.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigpending.c
deleted file mode 100644
index 3d193df83c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigpending.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <signal.h>
-#include "syscall.h"
-
-int sigpending(sigset_t *set)
-{
- return syscall(SYS_rt_sigpending, set, _NSIG/8);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigprocmask.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigprocmask.c
deleted file mode 100644
index 297e20c65f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigprocmask.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-
-int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
-{
- int r = pthread_sigmask(how, set, old);
- if (!r) return r;
- errno = r;
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigqueue.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigqueue.c
deleted file mode 100644
index b75f0c5cea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigqueue.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-
-int sigqueue(pid_t pid, int sig, const union sigval value)
-{
- siginfo_t si;
- sigset_t set;
- int r;
- memset(&si, 0, sizeof si);
- si.si_signo = sig;
- si.si_code = SI_QUEUE;
- si.si_value = value;
- si.si_uid = getuid();
- __block_app_sigs(&set);
- si.si_pid = getpid();
- r = syscall(SYS_rt_sigqueueinfo, pid, sig, &si);
- __restore_sigs(&set);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrelse.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigrelse.c
deleted file mode 100644
index b4c5a00f15..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrelse.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <signal.h>
-
-int sigrelse(int sig)
-{
- sigset_t mask;
-
- sigemptyset(&mask);
- if (sigaddset(&mask, sig) < 0) return -1;
- return sigprocmask(SIG_UNBLOCK, &mask, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmax.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmax.c
deleted file mode 100644
index 44dc88ff2d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmax.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <signal.h>
-
-int __libc_current_sigrtmax()
-{
- return _NSIG-1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmin.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmin.c
deleted file mode 100644
index c5a1fd92da..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigrtmin.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <signal.h>
-
-int __libc_current_sigrtmin()
-{
- return 35;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigset.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigset.c
deleted file mode 100644
index f3e8c4077e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigset.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <signal.h>
-
-void (*sigset(int sig, void (*handler)(int)))(int)
-{
- struct sigaction sa, sa_old;
- sigset_t mask, mask_old;
-
- sigemptyset(&mask);
- if (sigaddset(&mask, sig) < 0)
- return SIG_ERR;
-
- if (handler == SIG_HOLD) {
- if (sigaction(sig, 0, &sa_old) < 0)
- return SIG_ERR;
- if (sigprocmask(SIG_BLOCK, &mask, &mask_old) < 0)
- return SIG_ERR;
- } else {
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- sigemptyset(&sa.sa_mask);
- if (sigaction(sig, &sa, &sa_old) < 0)
- return SIG_ERR;
- if (sigprocmask(SIG_UNBLOCK, &mask, &mask_old) < 0)
- return SIG_ERR;
- }
- return sigismember(&mask_old, sig) ? SIG_HOLD : sa_old.sa_handler;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp.c
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp_tail.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp_tail.c
deleted file mode 100644
index f2aa28878e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsetjmp_tail.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <setjmp.h>
-#include <signal.h>
-#include "syscall.h"
-
-hidden int __sigsetjmp_tail(sigjmp_buf jb, int ret)
-{
- void *p = jb->__ss;
- __syscall(SYS_rt_sigprocmask, SIG_SETMASK, ret?p:0, ret?0:p, _NSIG/8);
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsuspend.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigsuspend.c
deleted file mode 100644
index 36e0602c60..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigsuspend.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <signal.h>
-#include "syscall.h"
-
-int sigsuspend(const sigset_t *mask)
-{
- return syscall_cp(SYS_rt_sigsuspend, mask, _NSIG/8);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigtimedwait.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigtimedwait.c
deleted file mode 100644
index 1287174eba..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigtimedwait.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-static int do_sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict ts)
-{
-#ifdef SYS_rt_sigtimedwait_time64
- time_t s = ts ? ts->tv_sec : 0;
- long ns = ts ? ts->tv_nsec : 0;
- int r = -ENOSYS;
- if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_rt_sigtimedwait_time64, mask, si,
- ts ? ((long long[]){s, ns}) : 0, _NSIG/8);
- if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || r!=-ENOSYS)
- return r;
- return __syscall_cp(SYS_rt_sigtimedwait, mask, si,
- ts ? ((long[]){CLAMP(s), ns}) : 0, _NSIG/8);;
-#else
- return __syscall_cp(SYS_rt_sigtimedwait, mask, si, ts, _NSIG/8);
-#endif
-}
-
-int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout)
-{
- int ret;
- do ret = do_sigtimedwait(mask, si, timeout);
- while (ret==-EINTR);
- return __syscall_ret(ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigwait.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigwait.c
deleted file mode 100644
index c8822eea49..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigwait.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <signal.h>
-
-int sigwait(const sigset_t *restrict mask, int *restrict sig)
-{
- siginfo_t si;
- if (sigtimedwait(mask, &si, 0) < 0)
- return -1;
- *sig = si.si_signo;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/sigwaitinfo.c b/lib/libc/wasi/libc-top-half/musl/src/signal/sigwaitinfo.c
deleted file mode 100644
index bb51f8b523..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/sigwaitinfo.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <signal.h>
-
-int sigwaitinfo(const sigset_t *restrict mask, siginfo_t *restrict si)
-{
- return sigtimedwait(mask, si, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/getitimer.c b/lib/libc/wasi/libc-top-half/musl/src/signal/x32/getitimer.c
deleted file mode 100644
index 8a8046a76b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/getitimer.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/time.h>
-#include "syscall.h"
-
-int getitimer(int which, struct itimerval *old)
-{
- return syscall(SYS_getitimer, which, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/x32/restore.s
deleted file mode 100644
index 1117446a6c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/restore.s
+++ /dev/null
@@ -1,8 +0,0 @@
- nop
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,@function
-__restore_rt:
- mov $0x40000201, %rax /* SYS_rt_sigreturn */
- syscall
-.size __restore_rt,.-__restore_rt
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/setitimer.c b/lib/libc/wasi/libc-top-half/musl/src/signal/x32/setitimer.c
deleted file mode 100644
index 21b1f45da9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/setitimer.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/time.h>
-#include "syscall.h"
-
-int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
-{
- return syscall(SYS_setitimer, which, new, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/x32/sigsetjmp.s
deleted file mode 100644
index 1f02b0e502..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x32/sigsetjmp.s
+++ /dev/null
@@ -1,25 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- test %esi,%esi
- jz 1f
-
- popq 64(%rdi)
- mov %rbx,72+8(%rdi)
- mov %rdi,%rbx
-
- call setjmp@PLT
-
- pushq 64(%rbx)
- movl $0, 4(%rsp)
- mov %rbx,%rdi
- mov %eax,%esi
- mov 72+8(%rbx),%rbx
-
-.hidden __sigsetjmp_tail
- jmp __sigsetjmp_tail
-
-1: jmp setjmp@PLT
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/restore.s b/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/restore.s
deleted file mode 100644
index 27d6cf3103..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/restore.s
+++ /dev/null
@@ -1,8 +0,0 @@
- nop
-.global __restore_rt
-.hidden __restore_rt
-.type __restore_rt,@function
-__restore_rt:
- mov $15, %rax
- syscall
-.size __restore_rt,.-__restore_rt
diff --git a/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/sigsetjmp.s b/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/sigsetjmp.s
deleted file mode 100644
index 9a7695f96d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/signal/x86_64/sigsetjmp.s
+++ /dev/null
@@ -1,24 +0,0 @@
-.global sigsetjmp
-.global __sigsetjmp
-.type sigsetjmp,@function
-.type __sigsetjmp,@function
-sigsetjmp:
-__sigsetjmp:
- test %esi,%esi
- jz 1f
-
- popq 64(%rdi)
- mov %rbx,72+8(%rdi)
- mov %rdi,%rbx
-
- call setjmp@PLT
-
- pushq 64(%rbx)
- mov %rbx,%rdi
- mov %eax,%esi
- mov 72+8(%rbx),%rbx
-
-.hidden __sigsetjmp_tail
- jmp __sigsetjmp_tail
-
-1: jmp setjmp@PLT
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/__xstat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/__xstat.c
deleted file mode 100644
index 630936a0fa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/__xstat.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <sys/stat.h>
-
-#if !_REDIR_TIME64
-
-int __fxstat(int ver, int fd, struct stat *buf)
-{
- return fstat(fd, buf);
-}
-
-int __fxstatat(int ver, int fd, const char *path, struct stat *buf, int flag)
-{
- return fstatat(fd, path, buf, flag);
-}
-
-int __lxstat(int ver, const char *path, struct stat *buf)
-{
- return lstat(path, buf);
-}
-
-int __xstat(int ver, const char *path, struct stat *buf)
-{
- return stat(path, buf);
-}
-
-weak_alias(__fxstat, __fxstat64);
-weak_alias(__fxstatat, __fxstatat64);
-weak_alias(__lxstat, __lxstat64);
-weak_alias(__xstat, __xstat64);
-
-#endif
-
-int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev)
-{
- return mknod(path, mode, *dev);
-}
-
-int __xmknodat(int ver, int fd, const char *path, mode_t mode, dev_t *dev)
-{
- return mknodat(fd, path, mode, *dev);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/chmod.c b/lib/libc/wasi/libc-top-half/musl/src/stat/chmod.c
deleted file mode 100644
index d4f53c564e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/chmod.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int chmod(const char *path, mode_t mode)
-{
-#ifdef SYS_chmod
- return syscall(SYS_chmod, path, mode);
-#else
- return syscall(SYS_fchmodat, AT_FDCWD, path, mode);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/fchmod.c b/lib/libc/wasi/libc-top-half/musl/src/stat/fchmod.c
deleted file mode 100644
index 7a503eefc4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/fchmod.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int fchmod(int fd, mode_t mode)
-{
- int ret = __syscall(SYS_fchmod, fd, mode);
- if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
- return __syscall_ret(ret);
-
- char buf[15+3*sizeof(int)];
- __procfdname(buf, fd);
-#ifdef SYS_chmod
- return syscall(SYS_chmod, buf, mode);
-#else
- return syscall(SYS_fchmodat, AT_FDCWD, buf, mode);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/fchmodat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/fchmodat.c
deleted file mode 100644
index 4ee00b0a3e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/fchmodat.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-#include "kstat.h"
-
-int fchmodat(int fd, const char *path, mode_t mode, int flag)
-{
- if (!flag) return syscall(SYS_fchmodat, fd, path, mode, flag);
-
- if (flag != AT_SYMLINK_NOFOLLOW)
- return __syscall_ret(-EINVAL);
-
- struct kstat st;
- int ret, fd2;
- char proc[15+3*sizeof(int)];
-
- if ((ret = __syscall(SYS_fstatat, fd, path, &st, flag)))
- return __syscall_ret(ret);
- if (S_ISLNK(st.st_mode))
- return __syscall_ret(-EOPNOTSUPP);
-
- if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC)) < 0) {
- if (fd2 == -ELOOP)
- return __syscall_ret(-EOPNOTSUPP);
- return __syscall_ret(fd2);
- }
-
- __procfdname(proc, fd2);
- ret = __syscall(SYS_fstatat, AT_FDCWD, proc, &st, 0);
- if (!ret) {
- if (S_ISLNK(st.st_mode)) ret = -EOPNOTSUPP;
- else ret = __syscall(SYS_fchmodat, AT_FDCWD, proc, mode);
- }
-
- __syscall(SYS_close, fd2);
- return __syscall_ret(ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/fstat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/fstat.c
deleted file mode 100644
index 9bbb46decb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/fstat.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#define _BSD_SOURCE
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int fstat(int fd, struct stat *st)
-{
- if (fd<0) return __syscall_ret(-EBADF);
- return fstatat(fd, "", st, AT_EMPTY_PATH);
-}
-
-#if !_REDIR_TIME64
-weak_alias(fstat, fstat64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/fstatat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/fstatat.c
deleted file mode 100644
index de165b5c97..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/fstatat.c
+++ /dev/null
@@ -1,147 +0,0 @@
-#define _BSD_SOURCE
-#include <sys/stat.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdint.h>
-#include <sys/sysmacros.h>
-#include "syscall.h"
-#include "kstat.h"
-
-struct statx {
- uint32_t stx_mask;
- uint32_t stx_blksize;
- uint64_t stx_attributes;
- uint32_t stx_nlink;
- uint32_t stx_uid;
- uint32_t stx_gid;
- uint16_t stx_mode;
- uint16_t pad1;
- uint64_t stx_ino;
- uint64_t stx_size;
- uint64_t stx_blocks;
- uint64_t stx_attributes_mask;
- struct {
- int64_t tv_sec;
- uint32_t tv_nsec;
- int32_t pad;
- } stx_atime, stx_btime, stx_ctime, stx_mtime;
- uint32_t stx_rdev_major;
- uint32_t stx_rdev_minor;
- uint32_t stx_dev_major;
- uint32_t stx_dev_minor;
- uint64_t spare[14];
-};
-
-static int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, int flag)
-{
- struct statx stx;
-
- int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx);
- if (ret) return ret;
-
- *st = (struct stat){
- .st_dev = makedev(stx.stx_dev_major, stx.stx_dev_minor),
- .st_ino = stx.stx_ino,
- .st_mode = stx.stx_mode,
- .st_nlink = stx.stx_nlink,
- .st_uid = stx.stx_uid,
- .st_gid = stx.stx_gid,
- .st_rdev = makedev(stx.stx_rdev_major, stx.stx_rdev_minor),
- .st_size = stx.stx_size,
- .st_blksize = stx.stx_blksize,
- .st_blocks = stx.stx_blocks,
- .st_atim.tv_sec = stx.stx_atime.tv_sec,
- .st_atim.tv_nsec = stx.stx_atime.tv_nsec,
- .st_mtim.tv_sec = stx.stx_mtime.tv_sec,
- .st_mtim.tv_nsec = stx.stx_mtime.tv_nsec,
- .st_ctim.tv_sec = stx.stx_ctime.tv_sec,
- .st_ctim.tv_nsec = stx.stx_ctime.tv_nsec,
-#if _REDIR_TIME64
- .__st_atim32.tv_sec = stx.stx_atime.tv_sec,
- .__st_atim32.tv_nsec = stx.stx_atime.tv_nsec,
- .__st_mtim32.tv_sec = stx.stx_mtime.tv_sec,
- .__st_mtim32.tv_nsec = stx.stx_mtime.tv_nsec,
- .__st_ctim32.tv_sec = stx.stx_ctime.tv_sec,
- .__st_ctim32.tv_nsec = stx.stx_ctime.tv_nsec,
-#endif
- };
- return 0;
-}
-
-static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag)
-{
- int ret;
- struct kstat kst;
-
- if (flag==AT_EMPTY_PATH && fd>=0 && !*path) {
- ret = __syscall(SYS_fstat, fd, &kst);
- if (ret==-EBADF && __syscall(SYS_fcntl, fd, F_GETFD)>=0) {
- ret = __syscall(SYS_fstatat, fd, path, &kst, flag);
- if (ret==-EINVAL) {
- char buf[15+3*sizeof(int)];
- __procfdname(buf, fd);
-#ifdef SYS_stat
- ret = __syscall(SYS_stat, buf, &kst);
-#else
- ret = __syscall(SYS_fstatat, AT_FDCWD, buf, &kst, 0);
-#endif
- }
- }
- }
-#ifdef SYS_lstat
- else if ((fd == AT_FDCWD || *path=='/') && flag==AT_SYMLINK_NOFOLLOW)
- ret = __syscall(SYS_lstat, path, &kst);
-#endif
-#ifdef SYS_stat
- else if ((fd == AT_FDCWD || *path=='/') && !flag)
- ret = __syscall(SYS_stat, path, &kst);
-#endif
- else ret = __syscall(SYS_fstatat, fd, path, &kst, flag);
-
- if (ret) return ret;
-
- *st = (struct stat){
- .st_dev = kst.st_dev,
- .st_ino = kst.st_ino,
- .st_mode = kst.st_mode,
- .st_nlink = kst.st_nlink,
- .st_uid = kst.st_uid,
- .st_gid = kst.st_gid,
- .st_rdev = kst.st_rdev,
- .st_size = kst.st_size,
- .st_blksize = kst.st_blksize,
- .st_blocks = kst.st_blocks,
- .st_atim.tv_sec = kst.st_atime_sec,
- .st_atim.tv_nsec = kst.st_atime_nsec,
- .st_mtim.tv_sec = kst.st_mtime_sec,
- .st_mtim.tv_nsec = kst.st_mtime_nsec,
- .st_ctim.tv_sec = kst.st_ctime_sec,
- .st_ctim.tv_nsec = kst.st_ctime_nsec,
-#if _REDIR_TIME64
- .__st_atim32.tv_sec = kst.st_atime_sec,
- .__st_atim32.tv_nsec = kst.st_atime_nsec,
- .__st_mtim32.tv_sec = kst.st_mtime_sec,
- .__st_mtim32.tv_nsec = kst.st_mtime_nsec,
- .__st_ctim32.tv_sec = kst.st_ctime_sec,
- .__st_ctim32.tv_nsec = kst.st_ctime_nsec,
-#endif
- };
-
- return 0;
-}
-
-int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag)
-{
- int ret;
- if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) {
- ret = fstatat_statx(fd, path, st, flag);
- if (ret!=-ENOSYS) return __syscall_ret(ret);
- }
- ret = fstatat_kstat(fd, path, st, flag);
- return __syscall_ret(ret);
-}
-
-#if !_REDIR_TIME64
-weak_alias(fstatat, fstatat64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/futimens.c b/lib/libc/wasi/libc-top-half/musl/src/stat/futimens.c
deleted file mode 100644
index 360225b86c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/futimens.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/stat.h>
-
-int futimens(int fd, const struct timespec times[2])
-{
- return utimensat(fd, 0, times, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/lchmod.c b/lib/libc/wasi/libc-top-half/musl/src/stat/lchmod.c
deleted file mode 100644
index f324ba7983..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/lchmod.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int lchmod(const char *path, mode_t mode)
-{
- return fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/lstat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/lstat.c
deleted file mode 100644
index 6fe004dec2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/lstat.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int lstat(const char *restrict path, struct stat *restrict buf)
-{
- return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
-}
-
-#if !_REDIR_TIME64
-weak_alias(lstat, lstat64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mkdir.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mkdir.c
deleted file mode 100644
index 32625b7de3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mkdir.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int mkdir(const char *path, mode_t mode)
-{
-#ifdef SYS_mkdir
- return syscall(SYS_mkdir, path, mode);
-#else
- return syscall(SYS_mkdirat, AT_FDCWD, path, mode);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mkdirat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mkdirat.c
deleted file mode 100644
index b8bc2527d7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mkdirat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/stat.h>
-#include "syscall.h"
-
-int mkdirat(int fd, const char *path, mode_t mode)
-{
- return syscall(SYS_mkdirat, fd, path, mode);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifo.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifo.c
deleted file mode 100644
index 60efcf73f2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifo.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/stat.h>
-
-int mkfifo(const char *path, mode_t mode)
-{
- return mknod(path, mode | S_IFIFO, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifoat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifoat.c
deleted file mode 100644
index d3a1f97087..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mkfifoat.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <sys/stat.h>
-
-int mkfifoat(int fd, const char *path, mode_t mode)
-{
- return mknodat(fd, path, mode | S_IFIFO, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mknod.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mknod.c
deleted file mode 100644
index beebd84e08..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mknod.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int mknod(const char *path, mode_t mode, dev_t dev)
-{
-#ifdef SYS_mknod
- return syscall(SYS_mknod, path, mode, dev);
-#else
- return syscall(SYS_mknodat, AT_FDCWD, path, mode, dev);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/mknodat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/mknodat.c
deleted file mode 100644
index 7c97c91aaa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/mknodat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/stat.h>
-#include "syscall.h"
-
-int mknodat(int fd, const char *path, mode_t mode, dev_t dev)
-{
- return syscall(SYS_mknodat, fd, path, mode, dev);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/stat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/stat.c
deleted file mode 100644
index ea70efc4a0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/stat.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int stat(const char *restrict path, struct stat *restrict buf)
-{
- return fstatat(AT_FDCWD, path, buf, 0);
-}
-
-#if !_REDIR_TIME64
-weak_alias(stat, stat64);
-#endif
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/statvfs.c b/lib/libc/wasi/libc-top-half/musl/src/stat/statvfs.c
deleted file mode 100644
index f65d1b548d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/statvfs.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <sys/statvfs.h>
-#include <sys/statfs.h>
-#include "syscall.h"
-
-static int __statfs(const char *path, struct statfs *buf)
-{
- *buf = (struct statfs){0};
-#ifdef SYS_statfs64
- return syscall(SYS_statfs64, path, sizeof *buf, buf);
-#else
- return syscall(SYS_statfs, path, buf);
-#endif
-}
-
-static int __fstatfs(int fd, struct statfs *buf)
-{
- *buf = (struct statfs){0};
-#ifdef SYS_fstatfs64
- return syscall(SYS_fstatfs64, fd, sizeof *buf, buf);
-#else
- return syscall(SYS_fstatfs, fd, buf);
-#endif
-}
-
-weak_alias(__statfs, statfs);
-weak_alias(__fstatfs, fstatfs);
-
-static void fixup(struct statvfs *out, const struct statfs *in)
-{
- *out = (struct statvfs){0};
- out->f_bsize = in->f_bsize;
- out->f_frsize = in->f_frsize ? in->f_frsize : in->f_bsize;
- out->f_blocks = in->f_blocks;
- out->f_bfree = in->f_bfree;
- out->f_bavail = in->f_bavail;
- out->f_files = in->f_files;
- out->f_ffree = in->f_ffree;
- out->f_favail = in->f_ffree;
- out->f_fsid = in->f_fsid.__val[0];
- out->f_flag = in->f_flags;
- out->f_namemax = in->f_namelen;
-}
-
-int statvfs(const char *restrict path, struct statvfs *restrict buf)
-{
- struct statfs kbuf;
- if (__statfs(path, &kbuf)<0) return -1;
- fixup(buf, &kbuf);
- return 0;
-}
-
-int fstatvfs(int fd, struct statvfs *buf)
-{
- struct statfs kbuf;
- if (__fstatfs(fd, &kbuf)<0) return -1;
- fixup(buf, &kbuf);
- return 0;
-}
-
-weak_alias(statvfs, statvfs64);
-weak_alias(statfs, statfs64);
-weak_alias(fstatvfs, fstatvfs64);
-weak_alias(fstatfs, fstatfs64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/umask.c b/lib/libc/wasi/libc-top-half/musl/src/stat/umask.c
deleted file mode 100644
index 5ee913e2d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/umask.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/stat.h>
-#include "syscall.h"
-
-mode_t umask(mode_t mode)
-{
- return syscall(SYS_umask, mode);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stat/utimensat.c b/lib/libc/wasi/libc-top-half/musl/src/stat/utimensat.c
deleted file mode 100644
index 730723a9ea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stat/utimensat.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define NS_SPECIAL(ns) ((ns)==UTIME_NOW || (ns)==UTIME_OMIT)
-
-int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
-{
- int r;
- if (times && times[0].tv_nsec==UTIME_NOW && times[1].tv_nsec==UTIME_NOW)
- times = 0;
-#ifdef SYS_utimensat_time64
- r = -ENOSYS;
- time_t s0=0, s1=0;
- long ns0=0, ns1=0;
- if (times) {
- ns0 = times[0].tv_nsec;
- ns1 = times[1].tv_nsec;
- if (!NS_SPECIAL(ns0)) s0 = times[0].tv_sec;
- if (!NS_SPECIAL(ns1)) s1 = times[1].tv_sec;
- }
- if (SYS_utimensat == SYS_utimensat_time64 || !IS32BIT(s0) || !IS32BIT(s1))
- r = __syscall(SYS_utimensat_time64, fd, path, times ?
- ((long long[]){s0, ns0, s1, ns1}) : 0, flags);
- if (SYS_utimensat == SYS_utimensat_time64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if (!IS32BIT(s0) || !IS32BIT(s1))
- return __syscall_ret(-ENOTSUP);
- r = __syscall(SYS_utimensat, fd, path,
- times ? ((long[]){s0, ns0, s1, ns1}) : 0, flags);
-#else
- r = __syscall(SYS_utimensat, fd, path, times, flags);
-#endif
-
-#ifdef SYS_futimesat
- if (r != -ENOSYS || flags) return __syscall_ret(r);
- long *tv=0, tmp[4];
- if (times) {
- int i;
- tv = tmp;
- for (i=0; i<2; i++) {
- if (times[i].tv_nsec >= 1000000000ULL) {
- if (NS_SPECIAL(times[i].tv_nsec))
- return __syscall_ret(-ENOSYS);
- return __syscall_ret(-EINVAL);
- }
- tmp[2*i+0] = times[i].tv_sec;
- tmp[2*i+1] = times[i].tv_nsec / 1000;
- }
- }
-
- r = __syscall(SYS_futimesat, fd, path, tv);
- if (r != -ENOSYS || fd != AT_FDCWD) return __syscall_ret(r);
- r = __syscall(SYS_utimes, path, tv);
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/__lockfile.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/__lockfile.c
deleted file mode 100644
index 0f60a14990..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/__lockfile.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "stdio_impl.h"
-#include "pthread_impl.h"
-
-int __lockfile(FILE *f)
-{
- int owner = f->lock, tid = __pthread_self()->tid;
- if ((owner & ~MAYBE_WAITERS) == tid)
- return 0;
- owner = a_cas(&f->lock, 0, tid);
- if (!owner) return 1;
- while ((owner = a_cas(&f->lock, 0, tid|MAYBE_WAITERS))) {
- if ((owner & MAYBE_WAITERS) ||
- a_cas(&f->lock, owner, owner|MAYBE_WAITERS)==owner)
- __futexwait(&f->lock, owner|MAYBE_WAITERS, 1);
- }
- return 1;
-}
-
-void __unlockfile(FILE *f)
-{
- if (a_swap(&f->lock, 0) & MAYBE_WAITERS)
- __wake(&f->lock, 1, 1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/flockfile.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/flockfile.c
deleted file mode 100644
index 8e2206514c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/flockfile.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "stdio_impl.h"
-#include "pthread_impl.h"
-
-void flockfile(FILE *f)
-{
- if (!ftrylockfile(f)) return;
- __lockfile(f);
- __register_locked_file(f, __pthread_self());
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/ftrylockfile.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/ftrylockfile.c
deleted file mode 100644
index 50650585be..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/ftrylockfile.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "stdio_impl.h"
-#include "pthread_impl.h"
-#include <limits.h>
-
-void __do_orphaned_stdio_locks()
-{
- FILE *f;
- for (f=__pthread_self()->stdio_locks; f; f=f->next_locked)
- a_store(&f->lock, 0x40000000);
-}
-
-void __unlist_locked_file(FILE *f)
-{
- if (f->lockcount) {
- if (f->next_locked) f->next_locked->prev_locked = f->prev_locked;
- if (f->prev_locked) f->prev_locked->next_locked = f->next_locked;
- else __pthread_self()->stdio_locks = f->next_locked;
- }
-}
-
-void __register_locked_file(FILE *f, pthread_t self)
-{
- f->lockcount = 1;
- f->prev_locked = 0;
- f->next_locked = self->stdio_locks;
- if (f->next_locked) f->next_locked->prev_locked = f;
- self->stdio_locks = f;
-}
-
-int ftrylockfile(FILE *f)
-{
- pthread_t self = __pthread_self();
- int tid = self->tid;
- int owner = f->lock;
- if ((owner & ~MAYBE_WAITERS) == tid) {
- if (f->lockcount == LONG_MAX)
- return -1;
- f->lockcount++;
- return 0;
- }
- if (owner < 0) f->lock = owner = 0;
- if (owner || a_cas(&f->lock, 0, tid))
- return -1;
- __register_locked_file(f, self);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/funlockfile.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/funlockfile.c
deleted file mode 100644
index 44d8b0df5c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/funlockfile.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "stdio_impl.h"
-#include "pthread_impl.h"
-
-void funlockfile(FILE *f)
-{
- if (f->lockcount == 1) {
- __unlist_locked_file(f);
- f->lockcount = 0;
- __unlockfile(f);
- } else {
- f->lockcount--;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/gets.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/gets.c
deleted file mode 100644
index 17963b93e3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/gets.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "stdio_impl.h"
-#include <limits.h>
-#include <string.h>
-
-char *gets(char *s)
-{
- size_t i=0;
- int c;
- FLOCK(stdin);
- while ((c=getc_unlocked(stdin)) != EOF && c != '\n') s[i++] = c;
- s[i] = 0;
- if (c != '\n' && (!feof(stdin) || !i)) s = 0;
- FUNLOCK(stdin);
- return s;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/pclose.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/pclose.c
deleted file mode 100644
index 080a426245..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/pclose.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "stdio_impl.h"
-#include <errno.h>
-#include <unistd.h>
-
-int pclose(FILE *f)
-{
- int status, r;
- pid_t pid = f->pipe_pid;
- fclose(f);
- while ((r=__syscall(SYS_wait4, pid, &status, 0, 0)) == -EINTR);
- if (r<0) return __syscall_ret(r);
- return status;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/popen.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/popen.c
deleted file mode 100644
index 3ec833941c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/popen.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <spawn.h>
-#include "stdio_impl.h"
-#include "syscall.h"
-
-extern char **__environ;
-
-FILE *popen(const char *cmd, const char *mode)
-{
- int p[2], op, e;
- pid_t pid;
- FILE *f;
- posix_spawn_file_actions_t fa;
-
- if (*mode == 'r') {
- op = 0;
- } else if (*mode == 'w') {
- op = 1;
- } else {
- errno = EINVAL;
- return 0;
- }
-
- if (pipe2(p, O_CLOEXEC)) return NULL;
- f = fdopen(p[op], mode);
- if (!f) {
- __syscall(SYS_close, p[0]);
- __syscall(SYS_close, p[1]);
- return NULL;
- }
-
- e = ENOMEM;
- if (!posix_spawn_file_actions_init(&fa)) {
- for (FILE *l = *__ofl_lock(); l; l=l->next)
- if (l->pipe_pid && posix_spawn_file_actions_addclose(&fa, l->fd))
- goto fail;
- if (!posix_spawn_file_actions_adddup2(&fa, p[1-op], 1-op)) {
- if (!(e = posix_spawn(&pid, "/bin/sh", &fa, 0,
- (char *[]){ "sh", "-c", (char *)cmd, 0 }, __environ))) {
- posix_spawn_file_actions_destroy(&fa);
- f->pipe_pid = pid;
- if (!strchr(mode, 'e'))
- fcntl(p[op], F_SETFD, 0);
- __syscall(SYS_close, p[1-op]);
- __ofl_unlock();
- return f;
- }
- }
-fail:
- __ofl_unlock();
- posix_spawn_file_actions_destroy(&fa);
- }
- fclose(f);
- __syscall(SYS_close, p[1-op]);
-
- errno = e;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/remove.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/remove.c
deleted file mode 100644
index 942e301a4c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/remove.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int remove(const char *path)
-{
-#ifdef SYS_unlink
- int r = __syscall(SYS_unlink, path);
-#else
- int r = __syscall(SYS_unlinkat, AT_FDCWD, path, 0);
-#endif
-#ifdef SYS_rmdir
- if (r==-EISDIR) r = __syscall(SYS_rmdir, path);
-#else
- if (r==-EISDIR) r = __syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/rename.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/rename.c
deleted file mode 100644
index f540adb6cd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/rename.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int rename(const char *old, const char *new)
-{
-#if defined(SYS_rename)
- return syscall(SYS_rename, old, new);
-#elif defined(SYS_renameat)
- return syscall(SYS_renameat, AT_FDCWD, old, AT_FDCWD, new);
-#else
- return syscall(SYS_renameat2, AT_FDCWD, old, AT_FDCWD, new, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/tempnam.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/tempnam.c
deleted file mode 100644
index 565df6b656..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/tempnam.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <limits.h>
-#include <string.h>
-#include <stdlib.h>
-#include "syscall.h"
-#include "kstat.h"
-
-#define MAXTRIES 100
-
-char *tempnam(const char *dir, const char *pfx)
-{
- char s[PATH_MAX];
- size_t l, dl, pl;
- int try;
- int r;
-
- if (!dir) dir = P_tmpdir;
- if (!pfx) pfx = "temp";
-
- dl = strlen(dir);
- pl = strlen(pfx);
- l = dl + 1 + pl + 1 + 6;
-
- if (l >= PATH_MAX) {
- errno = ENAMETOOLONG;
- return 0;
- }
-
- memcpy(s, dir, dl);
- s[dl] = '/';
- memcpy(s+dl+1, pfx, pl);
- s[dl+1+pl] = '_';
- s[l] = 0;
-
- for (try=0; try<MAXTRIES; try++) {
- __randname(s+l-6);
-#ifdef SYS_lstat
- r = __syscall(SYS_lstat, s, &(struct kstat){0});
-#else
- r = __syscall(SYS_fstatat, AT_FDCWD, s,
- &(struct kstat){0}, AT_SYMLINK_NOFOLLOW);
-#endif
- if (r == -ENOENT) return strdup(s);
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpfile.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpfile.c
deleted file mode 100644
index ae493987b8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpfile.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include "stdio_impl.h"
-
-#define MAXTRIES 100
-
-FILE *tmpfile(void)
-{
- char s[] = "/tmp/tmpfile_XXXXXX";
- int fd;
- FILE *f;
- int try;
- for (try=0; try<MAXTRIES; try++) {
- __randname(s+13);
- fd = sys_open(s, O_RDWR|O_CREAT|O_EXCL, 0600);
- if (fd >= 0) {
-#ifdef SYS_unlink
- __syscall(SYS_unlink, s);
-#else
- __syscall(SYS_unlinkat, AT_FDCWD, s, 0);
-#endif
- f = __fdopen(fd, "w+");
- if (!f) __syscall(SYS_close, fd);
- return f;
- }
- }
- return 0;
-}
-
-weak_alias(tmpfile, tmpfile64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpnam.c b/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpnam.c
deleted file mode 100644
index d667a83686..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/stdio/tmpnam.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdlib.h>
-#include "syscall.h"
-#include "kstat.h"
-
-#define MAXTRIES 100
-
-char *tmpnam(char *buf)
-{
- static char internal[L_tmpnam];
- char s[] = "/tmp/tmpnam_XXXXXX";
- int try;
- int r;
- for (try=0; try<MAXTRIES; try++) {
- __randname(s+12);
-#ifdef SYS_lstat
- r = __syscall(SYS_lstat, s, &(struct kstat){0});
-#else
- r = __syscall(SYS_fstatat, AT_FDCWD, s,
- &(struct kstat){0}, AT_SYMLINK_NOFOLLOW);
-#endif
- if (r == -ENOENT) return strcpy(buf ? buf : internal, s);
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memcpy.s b/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memcpy.s
deleted file mode 100644
index 3a527e41b8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memcpy.s
+++ /dev/null
@@ -1,45 +0,0 @@
-.syntax unified
-
-.global __aeabi_memcpy8
-.global __aeabi_memcpy4
-.global __aeabi_memcpy
-.global __aeabi_memmove8
-.global __aeabi_memmove4
-.global __aeabi_memmove
-
-.type __aeabi_memcpy8,%function
-.type __aeabi_memcpy4,%function
-.type __aeabi_memcpy,%function
-.type __aeabi_memmove8,%function
-.type __aeabi_memmove4,%function
-.type __aeabi_memmove,%function
-
-__aeabi_memmove8:
-__aeabi_memmove4:
-__aeabi_memmove:
- cmp r0, r1
- bls 3f
- cmp r2, #0
- beq 2f
- adds r0, r0, r2
- adds r2, r1, r2
-1: subs r2, r2, #1
- ldrb r3, [r2]
- subs r0, r0, #1
- strb r3, [r0]
- cmp r1, r2
- bne 1b
-2: bx lr
-__aeabi_memcpy8:
-__aeabi_memcpy4:
-__aeabi_memcpy:
-3: cmp r2, #0
- beq 2f
- adds r2, r1, r2
-1: ldrb r3, [r1]
- adds r1, r1, #1
- strb r3, [r0]
- adds r0, r0, #1
- cmp r1, r2
- bne 1b
-2: bx lr
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memset.s b/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memset.s
deleted file mode 100644
index f9f605838b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/arm/__aeabi_memset.s
+++ /dev/null
@@ -1,31 +0,0 @@
-.syntax unified
-
-.global __aeabi_memclr8
-.global __aeabi_memclr4
-.global __aeabi_memclr
-.global __aeabi_memset8
-.global __aeabi_memset4
-.global __aeabi_memset
-
-.type __aeabi_memclr8,%function
-.type __aeabi_memclr4,%function
-.type __aeabi_memclr,%function
-.type __aeabi_memset8,%function
-.type __aeabi_memset4,%function
-.type __aeabi_memset,%function
-
-__aeabi_memclr8:
-__aeabi_memclr4:
-__aeabi_memclr:
- movs r2, #0
-__aeabi_memset8:
-__aeabi_memset4:
-__aeabi_memset:
- cmp r1, #0
- beq 2f
- adds r1, r0, r1
-1: strb r2, [r0]
- adds r0, r0, #1
- cmp r1, r0
- bne 1b
-2: bx lr
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memcpy.s b/lib/libc/wasi/libc-top-half/musl/src/string/i386/memcpy.s
deleted file mode 100644
index 0608dd83c7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memcpy.s
+++ /dev/null
@@ -1,32 +0,0 @@
-.global memcpy
-.global __memcpy_fwd
-.hidden __memcpy_fwd
-.type memcpy,@function
-memcpy:
-__memcpy_fwd:
- push %esi
- push %edi
- mov 12(%esp),%edi
- mov 16(%esp),%esi
- mov 20(%esp),%ecx
- mov %edi,%eax
- cmp $4,%ecx
- jc 1f
- test $3,%edi
- jz 1f
-2: movsb
- dec %ecx
- test $3,%edi
- jnz 2b
-1: mov %ecx,%edx
- shr $2,%ecx
- rep
- movsl
- and $3,%edx
- jz 1f
-2: movsb
- dec %edx
- jnz 2b
-1: pop %edi
- pop %esi
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memmove.s b/lib/libc/wasi/libc-top-half/musl/src/string/i386/memmove.s
deleted file mode 100644
index 2a6a504b32..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memmove.s
+++ /dev/null
@@ -1,22 +0,0 @@
-.global memmove
-.type memmove,@function
-memmove:
- mov 4(%esp),%eax
- sub 8(%esp),%eax
- cmp 12(%esp),%eax
-.hidden __memcpy_fwd
- jae __memcpy_fwd
- push %esi
- push %edi
- mov 12(%esp),%edi
- mov 16(%esp),%esi
- mov 20(%esp),%ecx
- lea -1(%edi,%ecx),%edi
- lea -1(%esi,%ecx),%esi
- std
- rep movsb
- cld
- lea 1(%edi),%eax
- pop %edi
- pop %esi
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memset.s b/lib/libc/wasi/libc-top-half/musl/src/string/i386/memset.s
deleted file mode 100644
index d00422c4ac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/i386/memset.s
+++ /dev/null
@@ -1,76 +0,0 @@
-.global memset
-.type memset,@function
-memset:
- mov 12(%esp),%ecx
- cmp $62,%ecx
- ja 2f
-
- mov 8(%esp),%dl
- mov 4(%esp),%eax
- test %ecx,%ecx
- jz 1f
-
- mov %dl,%dh
-
- mov %dl,(%eax)
- mov %dl,-1(%eax,%ecx)
- cmp $2,%ecx
- jbe 1f
-
- mov %dx,1(%eax)
- mov %dx,(-1-2)(%eax,%ecx)
- cmp $6,%ecx
- jbe 1f
-
- shl $16,%edx
- mov 8(%esp),%dl
- mov 8(%esp),%dh
-
- mov %edx,(1+2)(%eax)
- mov %edx,(-1-2-4)(%eax,%ecx)
- cmp $14,%ecx
- jbe 1f
-
- mov %edx,(1+2+4)(%eax)
- mov %edx,(1+2+4+4)(%eax)
- mov %edx,(-1-2-4-8)(%eax,%ecx)
- mov %edx,(-1-2-4-4)(%eax,%ecx)
- cmp $30,%ecx
- jbe 1f
-
- mov %edx,(1+2+4+8)(%eax)
- mov %edx,(1+2+4+8+4)(%eax)
- mov %edx,(1+2+4+8+8)(%eax)
- mov %edx,(1+2+4+8+12)(%eax)
- mov %edx,(-1-2-4-8-16)(%eax,%ecx)
- mov %edx,(-1-2-4-8-12)(%eax,%ecx)
- mov %edx,(-1-2-4-8-8)(%eax,%ecx)
- mov %edx,(-1-2-4-8-4)(%eax,%ecx)
-
-1: ret
-
-2: movzbl 8(%esp),%eax
- mov %edi,12(%esp)
- imul $0x1010101,%eax
- mov 4(%esp),%edi
- test $15,%edi
- mov %eax,-4(%edi,%ecx)
- jnz 2f
-
-1: shr $2, %ecx
- rep
- stosl
- mov 4(%esp),%eax
- mov 12(%esp),%edi
- ret
-
-2: xor %edx,%edx
- sub %edi,%edx
- and $15,%edx
- mov %eax,(%edi)
- mov %eax,4(%edi)
- mov %eax,8(%edi)
- mov %eax,12(%edi)
- sub %edx,%ecx
- add %edx,%edi
- jmp 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memcpy.s b/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memcpy.s
deleted file mode 100644
index 3d960efa89..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memcpy.s
+++ /dev/null
@@ -1,25 +0,0 @@
-.global memcpy
-.global __memcpy_fwd
-.hidden __memcpy_fwd
-.type memcpy,@function
-memcpy:
-__memcpy_fwd:
- mov %rdi,%rax
- cmp $8,%rdx
- jc 1f
- test $7,%edi
- jz 1f
-2: movsb
- dec %rdx
- test $7,%edi
- jnz 2b
-1: mov %rdx,%rcx
- shr $3,%rcx
- rep
- movsq
- and $7,%edx
- jz 1f
-2: movsb
- dec %edx
- jnz 2b
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memmove.s b/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memmove.s
deleted file mode 100644
index 172c025206..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memmove.s
+++ /dev/null
@@ -1,16 +0,0 @@
-.global memmove
-.type memmove,@function
-memmove:
- mov %rdi,%rax
- sub %rsi,%rax
- cmp %rdx,%rax
-.hidden __memcpy_fwd
- jae __memcpy_fwd
- mov %rdx,%rcx
- lea -1(%rdi,%rdx),%rdi
- lea -1(%rsi,%rdx),%rsi
- std
- rep movsb
- cld
- lea 1(%rdi),%rax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memset.s b/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memset.s
deleted file mode 100644
index 2d3f5e52b8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/string/x86_64/memset.s
+++ /dev/null
@@ -1,72 +0,0 @@
-.global memset
-.type memset,@function
-memset:
- movzbq %sil,%rax
- mov $0x101010101010101,%r8
- imul %r8,%rax
-
- cmp $126,%rdx
- ja 2f
-
- test %edx,%edx
- jz 1f
-
- mov %sil,(%rdi)
- mov %sil,-1(%rdi,%rdx)
- cmp $2,%edx
- jbe 1f
-
- mov %ax,1(%rdi)
- mov %ax,(-1-2)(%rdi,%rdx)
- cmp $6,%edx
- jbe 1f
-
- mov %eax,(1+2)(%rdi)
- mov %eax,(-1-2-4)(%rdi,%rdx)
- cmp $14,%edx
- jbe 1f
-
- mov %rax,(1+2+4)(%rdi)
- mov %rax,(-1-2-4-8)(%rdi,%rdx)
- cmp $30,%edx
- jbe 1f
-
- mov %rax,(1+2+4+8)(%rdi)
- mov %rax,(1+2+4+8+8)(%rdi)
- mov %rax,(-1-2-4-8-16)(%rdi,%rdx)
- mov %rax,(-1-2-4-8-8)(%rdi,%rdx)
- cmp $62,%edx
- jbe 1f
-
- mov %rax,(1+2+4+8+16)(%rdi)
- mov %rax,(1+2+4+8+16+8)(%rdi)
- mov %rax,(1+2+4+8+16+16)(%rdi)
- mov %rax,(1+2+4+8+16+24)(%rdi)
- mov %rax,(-1-2-4-8-16-32)(%rdi,%rdx)
- mov %rax,(-1-2-4-8-16-24)(%rdi,%rdx)
- mov %rax,(-1-2-4-8-16-16)(%rdi,%rdx)
- mov %rax,(-1-2-4-8-16-8)(%rdi,%rdx)
-
-1: mov %rdi,%rax
- ret
-
-2: test $15,%edi
- mov %rdi,%r8
- mov %rax,-8(%rdi,%rdx)
- mov %rdx,%rcx
- jnz 2f
-
-1: shr $3,%rcx
- rep
- stosq
- mov %r8,%rax
- ret
-
-2: xor %edx,%edx
- sub %edi,%edx
- and $15,%edx
- mov %rax,(%rdi)
- mov %rax,8(%rdi)
- sub %rdx,%rcx
- add %rdx,%rdi
- jmp 1b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/__randname.c b/lib/libc/wasi/libc-top-half/musl/src/temp/__randname.c
deleted file mode 100644
index 2bce37a0c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/__randname.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <time.h>
-#include <stdint.h>
-
-/* This assumes that a check for the
- template size has already been made */
-char *__randname(char *template)
-{
- int i;
- struct timespec ts;
- unsigned long r;
-
- __clock_gettime(CLOCK_REALTIME, &ts);
- r = ts.tv_nsec*65537 ^ (uintptr_t)&ts / 16 + (uintptr_t)template;
- for (i=0; i<6; i++, r>>=5)
- template[i] = 'A'+(r&15)+(r&16)*2;
-
- return template;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mkdtemp.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mkdtemp.c
deleted file mode 100644
index 5708257bfe..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mkdtemp.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-char *mkdtemp(char *template)
-{
- size_t l = strlen(template);
- int retries = 100;
-
- if (l<6 || memcmp(template+l-6, "XXXXXX", 6)) {
- errno = EINVAL;
- return 0;
- }
-
- do {
- __randname(template+l-6);
- if (!mkdir(template, 0700)) return template;
- } while (--retries && errno == EEXIST);
-
- memcpy(template+l-6, "XXXXXX", 6);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemp.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemp.c
deleted file mode 100644
index d8dcb8052d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemp.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-
-int mkostemp(char *template, int flags)
-{
- return __mkostemps(template, 0, flags);
-}
-
-weak_alias(mkostemp, mkostemp64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemps.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemps.c
deleted file mode 100644
index ef24eeae2c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mkostemps.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-int __mkostemps(char *template, int len, int flags)
-{
- size_t l = strlen(template);
- if (l<6 || len>l-6 || memcmp(template+l-len-6, "XXXXXX", 6)) {
- errno = EINVAL;
- return -1;
- }
-
- flags -= flags & O_ACCMODE;
- int fd, retries = 100;
- do {
- __randname(template+l-len-6);
- if ((fd = open(template, flags | O_RDWR | O_CREAT | O_EXCL, 0600))>=0)
- return fd;
- } while (--retries && errno == EEXIST);
-
- memcpy(template+l-len-6, "XXXXXX", 6);
- return -1;
-}
-
-weak_alias(__mkostemps, mkostemps);
-weak_alias(__mkostemps, mkostemps64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemp.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemp.c
deleted file mode 100644
index 166b8afe49..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemp.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdlib.h>
-
-int mkstemp(char *template)
-{
- return __mkostemps(template, 0, 0);
-}
-
-weak_alias(mkstemp, mkstemp64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemps.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemps.c
deleted file mode 100644
index 6b7531b5e9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mkstemps.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _BSD_SOURCE
-#include <stdlib.h>
-
-int mkstemps(char *template, int len)
-{
- return __mkostemps(template, len, 0);
-}
-
-weak_alias(mkstemps, mkstemps64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/temp/mktemp.c b/lib/libc/wasi/libc-top-half/musl/src/temp/mktemp.c
deleted file mode 100644
index 7b3d2648b2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/temp/mktemp.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#define _GNU_SOURCE
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/stat.h>
-
-char *mktemp(char *template)
-{
- size_t l = strlen(template);
- int retries = 100;
- struct stat st;
-
- if (l < 6 || memcmp(template+l-6, "XXXXXX", 6)) {
- errno = EINVAL;
- *template = 0;
- return template;
- }
-
- do {
- __randname(template+l-6);
- if (stat(template, &st)) {
- if (errno != ENOENT) *template = 0;
- return template;
- }
- } while (--retries);
-
- *template = 0;
- errno = EEXIST;
- return template;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/cfgetospeed.c b/lib/libc/wasi/libc-top-half/musl/src/termios/cfgetospeed.c
deleted file mode 100644
index 55fa6f55c0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/cfgetospeed.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _BSD_SOURCE
-#include <termios.h>
-#include <sys/ioctl.h>
-
-speed_t cfgetospeed(const struct termios *tio)
-{
- return tio->c_cflag & CBAUD;
-}
-
-speed_t cfgetispeed(const struct termios *tio)
-{
- return cfgetospeed(tio);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/cfmakeraw.c b/lib/libc/wasi/libc-top-half/musl/src/termios/cfmakeraw.c
deleted file mode 100644
index c9dddc12a0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/cfmakeraw.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _GNU_SOURCE
-#include <termios.h>
-
-void cfmakeraw(struct termios *t)
-{
- t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
- t->c_oflag &= ~OPOST;
- t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
- t->c_cflag &= ~(CSIZE|PARENB);
- t->c_cflag |= CS8;
- t->c_cc[VMIN] = 1;
- t->c_cc[VTIME] = 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/cfsetospeed.c b/lib/libc/wasi/libc-top-half/musl/src/termios/cfsetospeed.c
deleted file mode 100644
index c9cbdd9d9d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/cfsetospeed.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#define _BSD_SOURCE
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-int cfsetospeed(struct termios *tio, speed_t speed)
-{
- if (speed & ~CBAUD) {
- errno = EINVAL;
- return -1;
- }
- tio->c_cflag &= ~CBAUD;
- tio->c_cflag |= speed;
- return 0;
-}
-
-int cfsetispeed(struct termios *tio, speed_t speed)
-{
- return speed ? cfsetospeed(tio, speed) : 0;
-}
-
-weak_alias(cfsetospeed, cfsetspeed);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcdrain.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcdrain.c
deleted file mode 100644
index c0e542b3e5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcdrain.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-#include "syscall.h"
-
-int tcdrain(int fd)
-{
- return syscall_cp(SYS_ioctl, fd, TCSBRK, 1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcflow.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcflow.c
deleted file mode 100644
index c7fc3fe227..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcflow.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-
-int tcflow(int fd, int action)
-{
- return ioctl(fd, TCXONC, action);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcflush.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcflush.c
deleted file mode 100644
index 5022266946..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcflush.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-
-int tcflush(int fd, int queue)
-{
- return ioctl(fd, TCFLSH, queue);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetattr.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetattr.c
deleted file mode 100644
index 545a0bf8ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetattr.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-
-int tcgetattr(int fd, struct termios *tio)
-{
- if (ioctl(fd, TCGETS, tio))
- return -1;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetsid.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetsid.c
deleted file mode 100644
index 1053fd6472..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetsid.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-
-pid_t tcgetsid(int fd)
-{
- int sid;
- if (ioctl(fd, TIOCGSID, &sid) < 0)
- return -1;
- return sid;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetwinsize.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetwinsize.c
deleted file mode 100644
index 9b3a65a40d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcgetwinsize.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-#include "syscall.h"
-
-int tcgetwinsize(int fd, struct winsize *wsz)
-{
- return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsendbreak.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcsendbreak.c
deleted file mode 100644
index b6df0a23a3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsendbreak.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-
-int tcsendbreak(int fd, int dur)
-{
- /* nonzero duration is implementation-defined, so ignore it */
- return ioctl(fd, TCSBRK, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetattr.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetattr.c
deleted file mode 100644
index 94df18f91e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetattr.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-
-int tcsetattr(int fd, int act, const struct termios *tio)
-{
- if (act < 0 || act > 2) {
- errno = EINVAL;
- return -1;
- }
- return ioctl(fd, TCSETS+act, tio);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetwinsize.c b/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetwinsize.c
deleted file mode 100644
index e01d0e2546..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/termios/tcsetwinsize.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <termios.h>
-#include <sys/ioctl.h>
-#include "syscall.h"
-
-int tcsetwinsize(int fd, const struct winsize *wsz)
-{
- return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__lock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__lock.c
deleted file mode 100644
index 60eece49a2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__lock.c
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "pthread_impl.h"
-
-/* This lock primitive combines a flag (in the sign bit) and a
- * congestion count (= threads inside the critical section, CS) in a
- * single int that is accessed through atomic operations. The states
- * of the int for value x are:
- *
- * x == 0: unlocked and no thread inside the critical section
- *
- * x < 0: locked with a congestion of x-INT_MIN, including the thread
- * that holds the lock
- *
- * x > 0: unlocked with a congestion of x
- *
- * or in an equivalent formulation x is the congestion count or'ed
- * with INT_MIN as a lock flag.
- */
-
-void __lock(volatile int *l)
-{
- int need_locks = libc.need_locks;
- if (!need_locks) return;
- /* fast path: INT_MIN for the lock, +1 for the congestion */
- int current = a_cas(l, 0, INT_MIN + 1);
- if (need_locks < 0) libc.need_locks = 0;
- if (!current) return;
- /* A first spin loop, for medium congestion. */
- for (unsigned i = 0; i < 10; ++i) {
- if (current < 0) current -= INT_MIN + 1;
- // assertion: current >= 0
- int val = a_cas(l, current, INT_MIN + (current + 1));
- if (val == current) return;
- current = val;
- }
- // Spinning failed, so mark ourselves as being inside the CS.
- current = a_fetch_add(l, 1) + 1;
- /* The main lock acquisition loop for heavy congestion. The only
- * change to the value performed inside that loop is a successful
- * lock via the CAS that acquires the lock. */
- for (;;) {
- /* We can only go into wait, if we know that somebody holds the
- * lock and will eventually wake us up, again. */
- if (current < 0) {
- __futexwait(l, current, 1);
- current -= INT_MIN + 1;
- }
- /* assertion: current > 0, the count includes us already. */
- int val = a_cas(l, current, INT_MIN + current);
- if (val == current) return;
- current = val;
- }
-}
-
-void __unlock(volatile int *l)
-{
- /* Check l[0] to see if we are multi-threaded. */
- if (l[0] < 0) {
- if (a_fetch_add(l, -(INT_MIN + 1)) != (INT_MIN + 1)) {
- __wake(l, 1, 1);
- }
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__set_thread_area.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__set_thread_area.c
deleted file mode 100644
index 152a6a216b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__set_thread_area.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "pthread_impl.h"
-
-int __set_thread_area(void *p)
-{
-#ifdef SYS_set_thread_area
- return __syscall(SYS_set_thread_area, p);
-#else
- return -ENOSYS;
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__syscall_cp.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__syscall_cp.c
deleted file mode 100644
index 42a01674bf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__syscall_cp.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "pthread_impl.h"
-#include "syscall.h"
-
-hidden long __syscall_cp_c();
-
-static long sccp(syscall_arg_t nr,
- syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
- syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
-{
- return __syscall(nr, u, v, w, x, y, z);
-}
-
-weak_alias(sccp, __syscall_cp_c);
-
-long (__syscall_cp)(syscall_arg_t nr,
- syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
- syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
-{
- return __syscall_cp_c(nr, u, v, w, x, y, z);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__timedwait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__timedwait.c
deleted file mode 100644
index 7d6f6be4ad..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__timedwait.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <pthread.h>
-#include <time.h>
-#include <errno.h>
-#include "futex.h"
-#include "syscall.h"
-#include "pthread_impl.h"
-
-#ifdef __wasilibc_unmodified_upstream
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-static int __futex4_cp(volatile void *addr, int op, int val, const struct timespec *to)
-{
- int r;
-#ifdef SYS_futex_time64
- time_t s = to ? to->tv_sec : 0;
- long ns = to ? to->tv_nsec : 0;
- r = -ENOSYS;
- if (SYS_futex == SYS_futex_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_futex_time64, addr, op, val,
- to ? ((long long[]){s, ns}) : 0);
- if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r;
- to = to ? (void *)(long[]){CLAMP(s), ns} : 0;
-#endif
- r = __syscall_cp(SYS_futex, addr, op, val, to);
- if (r != -ENOSYS) return r;
- return __syscall_cp(SYS_futex, addr, op & ~FUTEX_PRIVATE, val, to);
-}
-
-static volatile int dummy = 0;
-weak_alias(dummy, __eintr_valid_flag);
-#else
-static int __futex4_cp(volatile void *addr, int op, int val, const struct timespec *to)
-{
- int64_t max_wait_ns = -1;
- if (to) {
- max_wait_ns = (int64_t)(to->tv_sec * 1000000000 + to->tv_nsec);
- }
- return __wasilibc_futex_wait(addr, op, val, max_wait_ns);
-}
-#endif
-
-int __timedwait_cp(volatile int *addr, int val,
- clockid_t clk, const struct timespec *at, int priv)
-{
- int r;
- struct timespec to, *top=0;
-
- if (priv) priv = FUTEX_PRIVATE;
-
- if (at) {
- if (at->tv_nsec >= 1000000000UL) return EINVAL;
- if (__clock_gettime(clk, &to)) return EINVAL;
- to.tv_sec = at->tv_sec - to.tv_sec;
- if ((to.tv_nsec = at->tv_nsec - to.tv_nsec) < 0) {
- to.tv_sec--;
- to.tv_nsec += 1000000000;
- }
- if (to.tv_sec < 0) return ETIMEDOUT;
- top = &to;
- }
-
- r = -__futex4_cp(addr, FUTEX_WAIT|priv, val, top);
- if (r != EINTR && r != ETIMEDOUT && r != ECANCELED) r = 0;
-#ifdef __wasilibc_unmodified_upstream
- /* Mitigate bug in old kernels wrongly reporting EINTR for non-
- * interrupting (SA_RESTART) signal handlers. This is only practical
- * when NO interrupting signal handlers have been installed, and
- * works by sigaction tracking whether that's the case. */
- if (r == EINTR && !__eintr_valid_flag) r = 0;
-#endif
-
- return r;
-}
-
-int __timedwait(volatile int *addr, int val,
- clockid_t clk, const struct timespec *at, int priv)
-{
- int cs, r;
- __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- r = __timedwait_cp(addr, val, clk, at, priv);
- __pthread_setcancelstate(cs, 0);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__tls_get_addr.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__tls_get_addr.c
deleted file mode 100644
index 19524fe076..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__tls_get_addr.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-void *__tls_get_addr(tls_mod_off_t *v)
-{
- pthread_t self = __pthread_self();
- return (void *)(self->dtv[v[0]] + v[1]);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__unmapself.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__unmapself.c
deleted file mode 100644
index 31d94e67ed..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__unmapself.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "pthread_impl.h"
-#include "atomic.h"
-#include "syscall.h"
-/* cheat and reuse CRTJMP macro from dynlink code */
-#include "dynlink.h"
-
-static void *unmap_base;
-static size_t unmap_size;
-static char shared_stack[256];
-
-static void do_unmap()
-{
- __syscall(SYS_munmap, unmap_base, unmap_size);
- __syscall(SYS_exit);
-}
-
-void __unmapself(void *base, size_t size)
-{
- char *stack = shared_stack + sizeof shared_stack;
- stack -= (uintptr_t)stack % 16;
- unmap_base = base;
- unmap_size = size;
- CRTJMP(do_unmap, stack);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/__wait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/__wait.c
deleted file mode 100644
index 7ffa9872d9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/__wait.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "pthread_impl.h"
-#ifndef __wasilibc_unmodified_upstream
-#include "assert.h"
-#endif
-
-#ifndef __wasilibc_unmodified_upstream
-// Use WebAssembly's `wait` instruction to implement a futex. Note that `op` is
-// unused but retained as a parameter to match the original signature of the
-// syscall and that, for `max_wait_ns`, -1 (or any negative number) means wait
-// indefinitely.
-//
-// Adapted from Emscripten: see
-// https://github.com/emscripten-core/emscripten/blob/058a9fff/system/lib/pthread/emscripten_futex_wait.c#L111-L150.
-int __wasilibc_futex_wait(volatile void *addr, int op, int val, int64_t max_wait_ns)
-{
- if ((((intptr_t)addr) & 3) != 0) {
- return -EINVAL;
- }
-
- int ret = __builtin_wasm_memory_atomic_wait32((int *)addr, val, max_wait_ns);
-
- // memory.atomic.wait32 returns:
- // 0 => "ok", woken by another agent.
- // 1 => "not-equal", loaded value != expected value
- // 2 => "timed-out", the timeout expired
- if (ret == 1) {
- return -EWOULDBLOCK;
- }
- if (ret == 2) {
- return -ETIMEDOUT;
- }
- assert(ret == 0);
- return 0;
-}
-#endif
-
-void __wait(volatile int *addr, volatile int *waiters, int val, int priv)
-{
- int spins=100;
- if (priv) priv = FUTEX_PRIVATE;
- while (spins-- && (!waiters || !*waiters)) {
- if (*addr==val) a_spin();
- else return;
- }
- if (waiters) a_inc(waiters);
- while (*addr==val) {
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_futex, addr, FUTEX_WAIT|priv, val, 0) != -ENOSYS
- || __syscall(SYS_futex, addr, FUTEX_WAIT, val, 0);
-#else
- __wasilibc_futex_wait(addr, FUTEX_WAIT, val, -1);
-#endif
- }
- if (waiters) a_dec(waiters);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s
deleted file mode 100644
index fd0df34b04..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__set_thread_area.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- msr tpidr_el0,x0
- mov w0,#0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__unmapself.s
deleted file mode 100644
index 2c5d254f7b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/__unmapself.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __unmapself
-.type __unmapself,%function
-__unmapself:
- mov x8,#215 // SYS_munmap
- svc 0
- mov x8,#93 // SYS_exit
- svc 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/clone.s
deleted file mode 100644
index e3c83395ca..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/clone.s
+++ /dev/null
@@ -1,30 +0,0 @@
-// __clone(func, stack, flags, arg, ptid, tls, ctid)
-// x0, x1, w2, x3, x4, x5, x6
-
-// syscall(SYS_clone, flags, stack, ptid, tls, ctid)
-// x8, x0, x1, x2, x3, x4
-
-.global __clone
-.hidden __clone
-.type __clone,%function
-__clone:
- // align stack and save func,arg
- and x1,x1,#-16
- stp x0,x3,[x1,#-16]!
-
- // syscall
- uxtw x0,w2
- mov x2,x4
- mov x3,x5
- mov x4,x6
- mov x8,#220 // SYS_clone
- svc #0
-
- cbz x0,1f
- // parent
- ret
- // child
-1: ldp x1,x0,[sp],#16
- blr x1
- mov x8,#93 // SYS_exit
- svc #0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/syscall_cp.s
deleted file mode 100644
index 41db68af95..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/aarch64/syscall_cp.s
+++ /dev/null
@@ -1,32 +0,0 @@
-// __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z)
-// x0 x1 x2 x3 x4 x5 x6 x7
-
-// syscall(nr, u, v, w, x, y, z)
-// x8 x0 x1 x2 x3 x4 x5
-
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,%function
-__syscall_cp_asm:
-__cp_begin:
- ldr w0,[x0]
- cbnz w0,__cp_cancel
- mov x8,x1
- mov x0,x2
- mov x1,x3
- mov x2,x4
- mov x3,x5
- mov x4,x6
- mov x5,x7
- svc 0
-__cp_end:
- ret
-__cp_cancel:
- b __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s
deleted file mode 100644
index 2585620c44..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__aeabi_read_tp.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.syntax unified
-.global __aeabi_read_tp
-.type __aeabi_read_tp,%function
-__aeabi_read_tp:
- ldr r0,1f
- add r0,r0,pc
- ldr r0,[r0]
-2: bx r0
- .align 2
-1: .word __a_gettp_ptr - 2b
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__set_thread_area.c b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__set_thread_area.c
deleted file mode 100644
index 09de65aab0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__set_thread_area.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdint.h>
-#include <elf.h>
-#include "pthread_impl.h"
-#include "libc.h"
-
-#define HWCAP_TLS (1 << 15)
-
-extern hidden const unsigned char
- __a_barrier_oldkuser[], __a_barrier_v6[], __a_barrier_v7[],
- __a_cas_v6[], __a_cas_v7[],
- __a_gettp_cp15[];
-
-#define __a_barrier_kuser 0xffff0fa0
-#define __a_barrier_oldkuser (uintptr_t)__a_barrier_oldkuser
-#define __a_barrier_v6 (uintptr_t)__a_barrier_v6
-#define __a_barrier_v7 (uintptr_t)__a_barrier_v7
-
-#define __a_cas_kuser 0xffff0fc0
-#define __a_cas_v6 (uintptr_t)__a_cas_v6
-#define __a_cas_v7 (uintptr_t)__a_cas_v7
-
-#define __a_gettp_kuser 0xffff0fe0
-#define __a_gettp_cp15 (uintptr_t)__a_gettp_cp15
-
-extern hidden uintptr_t __a_barrier_ptr, __a_cas_ptr, __a_gettp_ptr;
-
-int __set_thread_area(void *p)
-{
-#if !__ARM_ARCH_7A__ && !__ARM_ARCH_7R__ && __ARM_ARCH < 7
- if (__hwcap & HWCAP_TLS) {
- size_t *aux;
- __a_cas_ptr = __a_cas_v7;
- __a_barrier_ptr = __a_barrier_v7;
- for (aux=libc.auxv; *aux; aux+=2) {
- if (*aux != AT_PLATFORM) continue;
- const char *s = (void *)aux[1];
- if (s[0]!='v' || s[1]!='6' || s[2]-'0'<10u) break;
- __a_cas_ptr = __a_cas_v6;
- __a_barrier_ptr = __a_barrier_v6;
- break;
- }
- } else {
- int ver = *(int *)0xffff0ffc;
- __a_gettp_ptr = __a_gettp_kuser;
- __a_cas_ptr = __a_cas_kuser;
- __a_barrier_ptr = __a_barrier_kuser;
- if (ver < 2) a_crash();
- if (ver < 3) __a_barrier_ptr = __a_barrier_oldkuser;
- }
-#endif
- return __syscall(0xf0005, p);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__unmapself.s
deleted file mode 100644
index 29c2d07b16..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/__unmapself.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.syntax unified
-.text
-.global __unmapself
-.type __unmapself,%function
-__unmapself:
- mov r7,#91
- svc 0
- mov r7,#1
- svc 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/atomics.s b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/atomics.s
deleted file mode 100644
index da50508d8d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/atomics.s
+++ /dev/null
@@ -1,106 +0,0 @@
-.syntax unified
-.text
-
-.global __a_barrier_dummy
-.hidden __a_barrier_dummy
-.type __a_barrier_dummy,%function
-__a_barrier_dummy:
- bx lr
-
-.global __a_barrier_oldkuser
-.hidden __a_barrier_oldkuser
-.type __a_barrier_oldkuser,%function
-__a_barrier_oldkuser:
- push {r0,r1,r2,r3,ip,lr}
- mov r1,r0
- mov r2,sp
- ldr ip,=0xffff0fc0
- bl 1f
- pop {r0,r1,r2,r3,ip,lr}
- bx lr
-1: bx ip
-
-.global __a_barrier_v6
-.hidden __a_barrier_v6
-.type __a_barrier_v6,%function
-__a_barrier_v6:
- .arch armv6t2
- mcr p15,0,r0,c7,c10,5
- bx lr
-
-.global __a_barrier_v7
-.hidden __a_barrier_v7
-.type __a_barrier_v7,%function
-__a_barrier_v7:
- .arch armv7-a
- dmb ish
- bx lr
-
-.global __a_cas_dummy
-.hidden __a_cas_dummy
-.type __a_cas_dummy,%function
-__a_cas_dummy:
- mov r3,r0
- ldr r0,[r2]
- subs r0,r3,r0
- streq r1,[r2]
- bx lr
-
-.global __a_cas_v6
-.hidden __a_cas_v6
-.type __a_cas_v6,%function
-__a_cas_v6:
- .arch armv6t2
- mov r3,r0
- mcr p15,0,r0,c7,c10,5
-1: ldrex r0,[r2]
- subs r0,r3,r0
- strexeq r0,r1,[r2]
- teqeq r0,#1
- beq 1b
- mcr p15,0,r0,c7,c10,5
- bx lr
-
-.global __a_cas_v7
-.hidden __a_cas_v7
-.type __a_cas_v7,%function
-__a_cas_v7:
- .arch armv7-a
- mov r3,r0
- dmb ish
-1: ldrex r0,[r2]
- subs r0,r3,r0
- strexeq r0,r1,[r2]
- teqeq r0,#1
- beq 1b
- dmb ish
- bx lr
-
-.global __a_gettp_cp15
-.hidden __a_gettp_cp15
-.type __a_gettp_cp15,%function
-__a_gettp_cp15:
- mrc p15,0,r0,c13,c0,3
- bx lr
-
-/* Tag this file with minimum ISA level so as not to affect linking. */
-.object_arch armv4t
-.eabi_attribute 6,2
-
-.data
-.align 2
-
-.global __a_barrier_ptr
-.hidden __a_barrier_ptr
-__a_barrier_ptr:
- .word __a_barrier_dummy
-
-.global __a_cas_ptr
-.hidden __a_cas_ptr
-__a_cas_ptr:
- .word __a_cas_dummy
-
-.global __a_gettp_ptr
-.hidden __a_gettp_ptr
-__a_gettp_ptr:
- .word __a_gettp_cp15
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/clone.s
deleted file mode 100644
index bb0965dafe..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/clone.s
+++ /dev/null
@@ -1,28 +0,0 @@
-.syntax unified
-.text
-.global __clone
-.hidden __clone
-.type __clone,%function
-__clone:
- stmfd sp!,{r4,r5,r6,r7}
- mov r7,#120
- mov r6,r3
- mov r5,r0
- mov r0,r2
- and r1,r1,#-16
- ldr r2,[sp,#16]
- ldr r3,[sp,#20]
- ldr r4,[sp,#24]
- svc 0
- tst r0,r0
- beq 1f
- ldmfd sp!,{r4,r5,r6,r7}
- bx lr
-
-1: mov r0,r6
- bl 3f
-2: mov r7,#1
- svc 0
- b 2b
-
-3: bx r5
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/arm/syscall_cp.s
deleted file mode 100644
index e607dd426a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/arm/syscall_cp.s
+++ /dev/null
@@ -1,29 +0,0 @@
-.syntax unified
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,%function
-__syscall_cp_asm:
- mov ip,sp
- stmfd sp!,{r4,r5,r6,r7}
-__cp_begin:
- ldr r0,[r0]
- cmp r0,#0
- bne __cp_cancel
- mov r7,r1
- mov r0,r2
- mov r1,r3
- ldmfd ip,{r2,r3,r4,r5,r6}
- svc 0
-__cp_end:
- ldmfd sp!,{r4,r5,r6,r7}
- bx lr
-__cp_cancel:
- ldmfd sp!,{r4,r5,r6,r7}
- b __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/call_once.c b/lib/libc/wasi/libc-top-half/musl/src/thread/call_once.c
deleted file mode 100644
index 5ed30183df..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/call_once.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-void call_once(once_flag *flag, void (*func)(void))
-{
- __pthread_once(flag, func);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/clone.c b/lib/libc/wasi/libc-top-half/musl/src/thread/clone.c
deleted file mode 100644
index be80c8ea48..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/clone.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <errno.h>
-#include "pthread_impl.h"
-
-int __clone(int (*func)(void *), void *stack, int flags, void *arg, ...)
-{
- return -ENOSYS;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_broadcast.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_broadcast.c
deleted file mode 100644
index e76b5a81bd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_broadcast.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-int cnd_broadcast(cnd_t *c)
-{
- /* This internal function never fails, and always returns zero,
- * which matches the value thrd_success is defined with. */
- return __private_cond_signal((pthread_cond_t *)c, -1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_destroy.c
deleted file mode 100644
index 453c90be51..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <threads.h>
-
-void cnd_destroy(cnd_t *c)
-{
- /* For private cv this is a no-op */
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_init.c
deleted file mode 100644
index 18c508557f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <threads.h>
-
-int cnd_init(cnd_t *c)
-{
- *c = (cnd_t){ 0 };
- return thrd_success;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_signal.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_signal.c
deleted file mode 100644
index 02cdc6c60a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_signal.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-int cnd_signal(cnd_t *c)
-{
- /* This internal function never fails, and always returns zero,
- * which matches the value thrd_success is defined with. */
- return __private_cond_signal((pthread_cond_t *)c, 1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_timedwait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_timedwait.c
deleted file mode 100644
index 2802af522a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_timedwait.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-#include <errno.h>
-
-int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts)
-{
- int ret = __pthread_cond_timedwait((pthread_cond_t *)c, (pthread_mutex_t *)m, ts);
- switch (ret) {
- /* May also return EINVAL or EPERM. */
- default: return thrd_error;
- case 0: return thrd_success;
- case ETIMEDOUT: return thrd_timedout;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_wait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_wait.c
deleted file mode 100644
index 602796f85b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/cnd_wait.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <threads.h>
-
-int cnd_wait(cnd_t *c, mtx_t *m)
-{
- /* Calling cnd_timedwait with a null pointer is an extension.
- * It is convenient here to avoid duplication of the logic
- * for return values. */
- return cnd_timedwait(c, m, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/default_attr.c b/lib/libc/wasi/libc-top-half/musl/src/thread/default_attr.c
deleted file mode 100644
index dce9640964..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/default_attr.c
+++ /dev/null
@@ -1,4 +0,0 @@
-#include "pthread_impl.h"
-
-unsigned __default_stacksize = DEFAULT_STACK_SIZE;
-unsigned __default_guardsize = DEFAULT_GUARD_SIZE;
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__set_thread_area.s
deleted file mode 100644
index aa6852beb6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__set_thread_area.s
+++ /dev/null
@@ -1,47 +0,0 @@
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- push %ebx
- push $0x51
- push $0xfffff
- push 16(%esp)
- call 1f
-1: addl $4f-1b,(%esp)
- pop %ecx
- mov (%ecx),%edx
- push %edx
- mov %esp,%ebx
- xor %eax,%eax
- mov $243,%al
- int $128
- testl %eax,%eax
- jnz 2f
- movl (%esp),%edx
- movl %edx,(%ecx)
- leal 3(,%edx,8),%edx
-3: movw %dx,%gs
-1:
- addl $16,%esp
- popl %ebx
- ret
-2:
- mov %ebx,%ecx
- xor %eax,%eax
- xor %ebx,%ebx
- xor %edx,%edx
- mov %ebx,(%esp)
- mov $1,%bl
- mov $16,%dl
- mov $123,%al
- int $128
- testl %eax,%eax
- jnz 1b
- mov $7,%dl
- inc %al
- jmp 3b
-
-.data
- .align 4
-4: .long -1
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__unmapself.s
deleted file mode 100644
index d6569594ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/__unmapself.s
+++ /dev/null
@@ -1,11 +0,0 @@
-.text
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- movl $91,%eax
- movl 4(%esp),%ebx
- movl 8(%esp),%ecx
- int $128
- xorl %ebx,%ebx
- movl $1,%eax
- int $128
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/i386/clone.s
deleted file mode 100644
index e237d3c632..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/clone.s
+++ /dev/null
@@ -1,49 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- push %ebp
- mov %esp,%ebp
- push %ebx
- push %esi
- push %edi
-
- xor %eax,%eax
- push $0x51
- mov %gs,%ax
- push $0xfffff
- shr $3,%eax
- push 28(%ebp)
- push %eax
- mov $120,%al
-
- mov 12(%ebp),%ecx
- mov 16(%ebp),%ebx
- and $-16,%ecx
- sub $16,%ecx
- mov 20(%ebp),%edi
- mov %edi,(%ecx)
- mov 24(%ebp),%edx
- mov %esp,%esi
- mov 32(%ebp),%edi
- mov 8(%ebp),%ebp
- int $128
- test %eax,%eax
- jnz 1f
-
- mov %ebp,%eax
- xor %ebp,%ebp
- call *%eax
- mov %eax,%ebx
- xor %eax,%eax
- inc %eax
- int $128
- hlt
-
-1: add $16,%esp
- pop %edi
- pop %esi
- pop %ebx
- pop %ebp
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/i386/syscall_cp.s
deleted file mode 100644
index 7dce1eb3ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/syscall_cp.s
+++ /dev/null
@@ -1,41 +0,0 @@
-.text
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
- mov 4(%esp),%ecx
- pushl %ebx
- pushl %esi
- pushl %edi
- pushl %ebp
-__cp_begin:
- movl (%ecx),%eax
- testl %eax,%eax
- jnz __cp_cancel
- movl 24(%esp),%eax
- movl 28(%esp),%ebx
- movl 32(%esp),%ecx
- movl 36(%esp),%edx
- movl 40(%esp),%esi
- movl 44(%esp),%edi
- movl 48(%esp),%ebp
- int $128
-__cp_end:
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
- ret
-__cp_cancel:
- popl %ebp
- popl %edi
- popl %esi
- popl %ebx
- jmp __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/tls.s b/lib/libc/wasi/libc-top-half/musl/src/thread/i386/tls.s
deleted file mode 100644
index 6e4c4cb928..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/i386/tls.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.text
-.global ___tls_get_addr
-.type ___tls_get_addr,@function
-___tls_get_addr:
- mov %gs:4,%edx
- mov (%eax),%ecx
- mov 4(%eax),%eax
- add (%edx,%ecx,4),%eax
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/lock_ptc.c b/lib/libc/wasi/libc-top-half/musl/src/thread/lock_ptc.c
deleted file mode 100644
index 7adedab75b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/lock_ptc.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <pthread.h>
-
-static pthread_rwlock_t lock = PTHREAD_RWLOCK_INITIALIZER;
-
-void __inhibit_ptc()
-{
- pthread_rwlock_wrlock(&lock);
-}
-
-void __acquire_ptc()
-{
- pthread_rwlock_rdlock(&lock);
-}
-
-void __release_ptc()
-{
- pthread_rwlock_unlock(&lock);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s
deleted file mode 100644
index 86886da8a5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/__m68k_read_tp.s
+++ /dev/null
@@ -1,8 +0,0 @@
-.text
-.global __m68k_read_tp
-.type __m68k_read_tp,@function
-__m68k_read_tp:
- move.l #333,%d0
- trap #0
- move.l %d0,%a0
- rts
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/clone.s
deleted file mode 100644
index f6dfa06f49..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/clone.s
+++ /dev/null
@@ -1,25 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- movem.l %d2-%d5,-(%sp)
- move.l #120,%d0
- move.l 28(%sp),%d1
- move.l 24(%sp),%d2
- and.l #-16,%d2
- move.l 36(%sp),%d3
- move.l 44(%sp),%d4
- move.l 40(%sp),%d5
- move.l 20(%sp),%a0
- move.l 32(%sp),%a1
- trap #0
- tst.l %d0
- beq 1f
- movem.l (%sp)+,%d2-%d5
- rts
-1: move.l %a1,-(%sp)
- jsr (%a0)
- move.l #1,%d0
- trap #0
- clr.b 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/syscall_cp.s
deleted file mode 100644
index 5628a896e5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/m68k/syscall_cp.s
+++ /dev/null
@@ -1,26 +0,0 @@
-.text
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
- movem.l %d2-%d5,-(%sp)
- movea.l 20(%sp),%a0
-__cp_begin:
- move.l (%a0),%d0
- bne __cp_cancel
- movem.l 24(%sp),%d0-%d5/%a0
- trap #0
-__cp_end:
- movem.l (%sp)+,%d2-%d5
- rts
-__cp_cancel:
- movem.l (%sp)+,%d2-%d5
- move.l __cancel-.-8,%a1
- jmp (%pc,%a1)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s
deleted file mode 100644
index 9a226a9157..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__set_thread_area.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- ori r21, r5, 0
- rtsd r15, 8
- ori r3, r0, 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__unmapself.s
deleted file mode 100644
index b180de60a6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/__unmapself.s
+++ /dev/null
@@ -1,8 +0,0 @@
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- ori r12, r0, 91
- brki r14, 0x8
- ori r12, r0, 1
- brki r14, 0x8
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/clone.s
deleted file mode 100644
index b68cc5fc22..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/clone.s
+++ /dev/null
@@ -1,30 +0,0 @@
-.global __clone
-.hidden __clone
-.type __clone,@function
-
-# r5, r6, r7, r8, r9, r10, stack
-# fn, st, fl, ar, pt, tl, ct
-# fl, st, __, pt, ct, tl
-
-__clone:
- andi r6, r6, -16
- addi r6, r6, -16
- swi r5, r6, 0
- swi r8, r6, 4
-
- ori r5, r7, 0
- ori r8, r9, 0
- lwi r9, r1, 28
- ori r12, r0, 120
-
- brki r14, 8
- beqi r3, 1f
- rtsd r15, 8
- nop
-
-1: lwi r3, r1, 0
- lwi r5, r1, 4
- brald r15, r3
- nop
- ori r12, r0, 1
- brki r14, 8
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/syscall_cp.s
deleted file mode 100644
index b0df61c571..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/microblaze/syscall_cp.s
+++ /dev/null
@@ -1,27 +0,0 @@
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-__cp_begin:
- lwi r5, r5, 0
- bnei r5, __cp_cancel
- addi r12, r6, 0
- add r5, r7, r0
- add r6, r8, r0
- add r7, r9, r0
- add r8, r10, r0
- lwi r9, r1, 28
- lwi r10, r1, 32
- brki r14, 0x8
-__cp_end:
- rtsd r15, 8
- nop
-__cp_cancel:
- bri __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips/__unmapself.s
deleted file mode 100644
index ba139dc8e7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/__unmapself.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.set noreorder
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- move $sp, $25
- li $2, 4091
- syscall
- li $4, 0
- li $2, 4001
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips/clone.s
deleted file mode 100644
index 0446338568..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/clone.s
+++ /dev/null
@@ -1,36 +0,0 @@
-.set noreorder
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- # Save function pointer and argument pointer on new thread stack
- and $5, $5, -8
- subu $5, $5, 16
- sw $4, 0($5)
- sw $7, 4($5)
- # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
- move $4, $6
- lw $6, 16($sp)
- lw $7, 20($sp)
- lw $9, 24($sp)
- subu $sp, $sp, 16
- sw $9, 16($sp)
- li $2, 4120
- syscall
- beq $7, $0, 1f
- nop
- addu $sp, $sp, 16
- jr $ra
- subu $2, $0, $2
-1: beq $2, $0, 1f
- nop
- addu $sp, $sp, 16
- jr $ra
- nop
-1: lw $25, 0($sp)
- lw $4, 4($sp)
- jalr $25
- nop
- move $4, $2
- li $2, 4001
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips/syscall_cp.s
deleted file mode 100644
index d284626450..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips/syscall_cp.s
+++ /dev/null
@@ -1,53 +0,0 @@
-.set noreorder
-
-.global __cp_begin
-.hidden __cp_begin
-.type __cp_begin,@function
-.global __cp_end
-.hidden __cp_end
-.type __cp_end,@function
-.global __cp_cancel
-.hidden __cp_cancel
-.type __cp_cancel,@function
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
- subu $sp, $sp, 32
-__cp_begin:
- lw $4, 0($4)
- bne $4, $0, __cp_cancel
- move $2, $5
- move $4, $6
- move $5, $7
- lw $6, 48($sp)
- lw $7, 52($sp)
- lw $8, 56($sp)
- lw $9, 60($sp)
- lw $10,64($sp)
- sw $8, 16($sp)
- sw $9, 20($sp)
- sw $10,24($sp)
- sw $2, 28($sp)
- lw $2, 28($sp)
- syscall
-__cp_end:
- beq $7, $0, 1f
- addu $sp, $sp, 32
- subu $2, $0, $2
-1: jr $ra
- nop
-
-__cp_cancel:
- move $2, $ra
- bal 1f
- addu $sp, $sp, 32
- .gpword .
- .gpword __cancel
-1: lw $3, ($ra)
- subu $3, $ra, $3
- lw $25, 4($ra)
- addu $25, $25, $3
- jr $25
- move $ra, $2
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/__unmapself.s
deleted file mode 100644
index f6795cda28..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/__unmapself.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.set noreorder
-.global __unmapself
-.type __unmapself, @function
-__unmapself:
- li $2, 5011
- syscall
- li $4, 0
- li $2, 5058
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/clone.s
deleted file mode 100644
index 2d86899a1d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/clone.s
+++ /dev/null
@@ -1,34 +0,0 @@
-.set noreorder
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- # Save function pointer and argument pointer on new thread stack
- and $5, $5, -16 # aligning stack to double word
- dsubu $5, $5, 16
- sd $4, 0($5) # save function pointer
- sd $7, 8($5) # save argument pointer
-
- # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
- # sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls)
- move $4, $6
- move $6, $8
- move $7, $9
- move $8, $10
- li $2, 5055
- syscall
- beq $7, $0, 1f
- nop
- jr $ra
- dsubu $2, $0, $2
-1: beq $2, $0, 1f
- nop
- jr $ra
- nop
-1: ld $25, 0($sp) # function pointer
- ld $4, 8($sp) # argument pointer
- jalr $25 # call the user's function
- nop
- move $4, $2
- li $2, 5058
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/syscall_cp.s
deleted file mode 100644
index 0d4ede7635..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mips64/syscall_cp.s
+++ /dev/null
@@ -1,52 +0,0 @@
-.set noreorder
-.global __cp_begin
-.hidden __cp_begin
-.type __cp_begin,@function
-.global __cp_end
-.hidden __cp_end
-.type __cp_end,@function
-.global __cp_cancel
-.hidden __cp_cancel
-.type __cp_cancel,@function
-.global __cp_cancel_data
-.hidden __cp_cancel_data
-.type __cp_cancel_data,@function
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-__cp_begin:
- lw $4, 0($4)
- bne $4, $0, __cp_cancel
- move $2, $5
- move $4, $6
- move $5, $7
- move $6, $8
- move $7, $9
- move $8, $10
- move $9, $11
- ld $10, 0($sp)
- syscall
-__cp_end:
- beq $7, $0, 1f
- nop
- dsubu $2, $0, $2
-1: jr $ra
- nop
-
- # if cancellation flag is 1 then call __cancel
-__cp_cancel:
- move $2, $ra
-.align 8
- bal 1f
- nop
-__cp_cancel_data:
- .gpdword __cp_cancel_data
- .gpdword __cancel
-1: ld $3, ($ra)
- dsubu $3, $ra, $3
- ld $25, 8($ra)
- daddu $25, $25, $3
- jr $25
- move $ra, $2
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/__unmapself.s
deleted file mode 100644
index 4b032e5e58..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/__unmapself.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.set noreorder
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- li $2, 6011
- syscall
- li $4, 0
- li $2, 6058
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/clone.s
deleted file mode 100644
index 4d3c8c7a25..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/clone.s
+++ /dev/null
@@ -1,34 +0,0 @@
-.set noreorder
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- # Save function pointer and argument pointer on new thread stack
- and $5, $5, -16 # aligning stack to double word
- subu $5, $5, 16
- sw $4, 0($5) # save function pointer
- sw $7, 4($5) # save argument pointer
-
- # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,tls,ctid)
- # sys_clone(u64 flags, u64 ustack_base, u64 parent_tidptr, u64 child_tidptr, u64 tls)
- move $4, $6
- move $6, $8
- move $7, $9
- move $8, $10
- li $2, 6055
- syscall
- beq $7, $0, 1f
- nop
- jr $ra
- subu $2, $0, $2
-1: beq $2, $0, 1f
- nop
- jr $ra
- nop
-1: lw $25, 0($sp) # function pointer
- lw $4, 4($sp) # argument pointer
- jalr $25 # call the user's function
- nop
- move $4, $2
- li $2, 6058
- syscall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s
deleted file mode 100644
index e85615bcb3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mipsn32/syscall_cp.s
+++ /dev/null
@@ -1,51 +0,0 @@
-.set noreorder
-.global __cp_begin
-.hidden __cp_begin
-.type __cp_begin,@function
-.global __cp_end
-.hidden __cp_end
-.type __cp_end,@function
-.global __cp_cancel
-.hidden __cp_cancel
-.type __cp_cancel,@function
-.global __cp_cancel_data
-.hidden __cp_cancel_data
-.type __cp_cancel_data,@function
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-__cp_begin:
- lw $4, 0($4)
- bne $4, $0, __cp_cancel
- move $2, $5
- move $4, $6
- move $5, $7
- move $6, $8
- move $7, $9
- move $8, $10
- move $9, $11
- lw $10, 0($sp)
- syscall
-__cp_end:
- beq $7, $0, 1f
- nop
- subu $2, $0, $2
-1: jr $ra
- nop
-
- # if cancellation flag is 1 then call __cancel
-__cp_cancel:
- move $2, $ra
- bal 1f
- nop
-__cp_cancel_data:
- .gpword __cp_cancel_data
- .gpword __cancel
-1: lw $3, 0($ra)
- subu $3, $ra, $3
- lw $25, 4($ra)
- addu $25, $25, $3
- jr $25
- move $ra, $2
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_destroy.c
deleted file mode 100644
index 40a089998f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_destroy.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <threads.h>
-
-void mtx_destroy(mtx_t *mtx)
-{
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_init.c
deleted file mode 100644
index 4826f76b11..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_init.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-int mtx_init(mtx_t *m, int type)
-{
- *m = (mtx_t){
- ._m_type = ((type&mtx_recursive) ? PTHREAD_MUTEX_RECURSIVE : PTHREAD_MUTEX_NORMAL),
- };
- return thrd_success;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_lock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_lock.c
deleted file mode 100644
index 5c2415c1ac..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_lock.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-int mtx_lock(mtx_t *m)
-{
- if (m->_m_type == PTHREAD_MUTEX_NORMAL && !a_cas(&m->_m_lock, 0, EBUSY))
- return thrd_success;
- /* Calling mtx_timedlock with a null pointer is an extension.
- * It is convenient, here to avoid duplication of the logic
- * for return values. */
- return mtx_timedlock(m, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_timedlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_timedlock.c
deleted file mode 100644
index d22c8cf448..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_timedlock.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-#include <errno.h>
-
-int mtx_timedlock(mtx_t *restrict m, const struct timespec *restrict ts)
-{
- int ret = __pthread_mutex_timedlock((pthread_mutex_t *)m, ts);
- switch (ret) {
- default: return thrd_error;
- case 0: return thrd_success;
- case ETIMEDOUT: return thrd_timedout;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_trylock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_trylock.c
deleted file mode 100644
index 40a8b8c297..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_trylock.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-int mtx_trylock(mtx_t *m)
-{
- if (m->_m_type == PTHREAD_MUTEX_NORMAL)
- return (a_cas(&m->_m_lock, 0, EBUSY) & EBUSY) ? thrd_busy : thrd_success;
-
- int ret = __pthread_mutex_trylock((pthread_mutex_t *)m);
- switch (ret) {
- default: return thrd_error;
- case 0: return thrd_success;
- case EBUSY: return thrd_busy;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_unlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_unlock.c
deleted file mode 100644
index 2e5c8cf6bf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/mtx_unlock.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-int mtx_unlock(mtx_t *mtx)
-{
- /* The only cases where pthread_mutex_unlock can return an
- * error are undefined behavior for C11 mtx_unlock, so we can
- * assume it does not return an error and simply tail call. */
- return __pthread_mutex_unlock((pthread_mutex_t *)mtx);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__set_thread_area.s
deleted file mode 100644
index b9ffb9303b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__set_thread_area.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- l.ori r10, r3, 0
- l.jr r9
- l.ori r11, r0, 0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__unmapself.s
deleted file mode 100644
index 6c0fa2acf2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/__unmapself.s
+++ /dev/null
@@ -1,8 +0,0 @@
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- l.ori r11, r0, 215 /* __NR_munmap */
- l.sys 1
- l.ori r3, r0, 0
- l.ori r11, r0, 93 /* __NR_exit */
- l.sys 1
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/clone.s
deleted file mode 100644
index 2473ac2040..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/clone.s
+++ /dev/null
@@ -1,31 +0,0 @@
-/* int clone(fn, stack, flags, arg, ptid, tls, ctid)
- * r3 r4 r5 r6 sp+0 sp+4 sp+8
- * sys_clone(flags, stack, ptid, ctid, tls)
- */
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- l.addi r4, r4, -8
- l.sw 0(r4), r3
- l.sw 4(r4), r6
- /* (fn, st, fl, ar, pt, tl, ct) => (fl, st, pt, ct, tl) */
- l.ori r3, r5, 0
- l.lwz r5, 0(r1)
- l.lwz r6, 8(r1)
- l.lwz r7, 4(r1)
- l.ori r11, r0, 220 /* __NR_clone */
- l.sys 1
-
- l.sfeqi r11, 0
- l.bf 1f
- l.nop
- l.jr r9
- l.nop
-
-1: l.lwz r11, 0(r1)
- l.jalr r11
- l.lwz r3, 4(r1)
-
- l.ori r11, r0, 93 /* __NR_exit */
- l.sys 1
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/syscall_cp.s
deleted file mode 100644
index 7951166ed9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/or1k/syscall_cp.s
+++ /dev/null
@@ -1,29 +0,0 @@
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-__cp_begin:
- l.lwz r3, 0(r3)
- l.sfeqi r3, 0
- l.bnf __cp_cancel
- l.ori r11, r4, 0
- l.ori r3, r5, 0
- l.ori r4, r6, 0
- l.ori r5, r7, 0
- l.ori r6, r8, 0
- l.lwz r7, 0(r1)
- l.lwz r8, 4(r1)
- l.sys 1
-__cp_end:
- l.jr r9
- l.nop
-__cp_cancel:
- l.j __cancel
- l.nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s
deleted file mode 100644
index 86c498fa38..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__set_thread_area.s
+++ /dev/null
@@ -1,12 +0,0 @@
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area, %function
-__set_thread_area:
- # mov pointer in reg3 into r2
- mr 2, 3
- # put 0 into return reg
- li 3, 0
- # return
- blr
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__unmapself.s
deleted file mode 100644
index c9360b47a6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/__unmapself.s
+++ /dev/null
@@ -1,9 +0,0 @@
- .text
- .global __unmapself
- .type __unmapself,%function
-__unmapself:
- li 0, 91 # __NR_munmap
- sc
- li 0, 1 #__NR_exit
- sc
- blr
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/clone.s
deleted file mode 100644
index da13f446c0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/clone.s
+++ /dev/null
@@ -1,73 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone, %function
-__clone:
-# int clone(fn, stack, flags, arg, ptid, tls, ctid)
-# a b c d e f g
-# 3 4 5 6 7 8 9
-# pseudo C code:
-# tid = syscall(SYS_clone,c,b,e,f,g);
-# if (!tid) syscall(SYS_exit, a(d));
-# return tid;
-
-# SYS_clone = 120
-# SYS_exit = 1
-
-# store non-volatile regs r30, r31 on stack in order to put our
-# start func and its arg there
-stwu 30, -16(1)
-stw 31, 4(1)
-
-# save r3 (func) into r30, and r6(arg) into r31
-mr 30, 3
-mr 31, 6
-
-# create initial stack frame for new thread
-clrrwi 4, 4, 4
-li 0, 0
-stwu 0, -16(4)
-
-#move c into first arg
-mr 3, 5
-#mr 4, 4
-mr 5, 7
-mr 6, 8
-mr 7, 9
-
-# move syscall number into r0
-li 0, 120
-
-sc
-
-# check for syscall error
-bns+ 1f # jump to label 1 if no summary overflow.
-#else
-neg 3, 3 #negate the result (errno)
-1:
-# compare sc result with 0
-cmpwi cr7, 3, 0
-
-# if not 0, jump to end
-bne cr7, 2f
-
-#else: we're the child
-#call funcptr: move arg (d) into r3
-mr 3, 31
-#move r30 (funcptr) into CTR reg
-mtctr 30
-# call CTR reg
-bctrl
-# mov SYS_exit into r0 (the exit param is already in r3)
-li 0, 1
-sc
-
-2:
-
-# restore stack
-lwz 30, 0(1)
-lwz 31, 4(1)
-addi 1, 1, 16
-
-blr
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/syscall_cp.s
deleted file mode 100644
index 77f8938dc8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc/syscall_cp.s
+++ /dev/null
@@ -1,59 +0,0 @@
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-
-#r0: volatile. may be modified during linkage.
-#r1: stack frame: 16 byte alignment.
-#r2: tls/thread pointer on pp32
-#r3,r4: return values, first args
-#r5-r10: args
-#r11-r12: volatile. may be modified during linkage
-#r13: "small data area" pointer
-#r14 - r30: local vars
-#r31: local or environment pointer
-
-#r1, r14-31: belong to the caller, must be saved and restored
-#r0, r3-r12, ctr, xer: volatile, not preserved
-#r0,r11,r12: may be altered by cross-module call,
-#"a func cannot depend on that these regs have the values placed by the caller"
-
-#the fields CR2,CR2,CR4 of the cond reg must be preserved
-#LR (link reg) shall contain the funcs return address
- .text
- .type __syscall_cp_asm,%function
-__syscall_cp_asm:
- # at enter: r3 = pointer to self->cancel, r4: syscall no, r5: first arg, r6: 2nd, r7: 3rd, r8: 4th, r9: 5th, r10: 6th
-__cp_begin:
- # r3 holds first argument, its a pointer to self->cancel.
- # we must compare the dereferenced value with 0 and jump to __cancel if its not
-
- lwz 0, 0(3) #deref pointer into r0
-
- cmpwi cr7, 0, 0 #compare r0 with 0, store result in cr7.
- beq+ cr7, 1f #jump to label 1 if r0 was 0
-
- b __cp_cancel #else call cancel
-1:
- #ok, the cancel flag was not set
- # syscall: number goes to r0, the rest 3-8
- mr 0, 4 # put the system call number into r0
- mr 3, 5 # Shift the arguments: arg1
- mr 4, 6 # arg2
- mr 5, 7 # arg3
- mr 6, 8 # arg4
- mr 7, 9 # arg5
- mr 8, 10 # arg6
- sc
-__cp_end:
- bnslr+ # return if no summary overflow.
- #else negate result.
- neg 3, 3
- blr
-__cp_cancel:
- b __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s
deleted file mode 100644
index bb9c55d6d3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__set_thread_area.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area, %function
-__set_thread_area:
- mr 13, 3
- li 3, 0
- blr
-
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__unmapself.s
deleted file mode 100644
index c9360b47a6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/__unmapself.s
+++ /dev/null
@@ -1,9 +0,0 @@
- .text
- .global __unmapself
- .type __unmapself,%function
-__unmapself:
- li 0, 91 # __NR_munmap
- sc
- li 0, 1 #__NR_exit
- sc
- blr
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/clone.s
deleted file mode 100644
index 41cb6787a7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/clone.s
+++ /dev/null
@@ -1,48 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone, %function
-__clone:
- # int clone(fn, stack, flags, arg, ptid, tls, ctid)
- # a b c d e f g
- # 3 4 5 6 7 8 9
- # pseudo C code:
- # tid = syscall(SYS_clone,c,b,e,f,g);
- # if (!tid) syscall(SYS_exit, a(d));
- # return tid;
-
- # create initial stack frame for new thread
- clrrdi 4, 4, 4
- li 0, 0
- stdu 0,-32(4)
-
- # save fn and arg to child stack
- std 3, 8(4)
- std 6, 16(4)
-
- # shuffle args into correct registers and call SYS_clone
- mr 3, 5
- #mr 4, 4
- mr 5, 7
- mr 6, 8
- mr 7, 9
- li 0, 120 # SYS_clone = 120
- sc
-
- # if error, negate return (errno)
- bns+ 1f
- neg 3, 3
-
-1: # if we're the parent, return
- cmpwi cr7, 3, 0
- bnelr cr7
-
- # we're the child. call fn(arg)
- ld 3, 16(1)
- ld 12, 8(1)
- mtctr 12
- bctrl
-
- # call SYS_exit. exit code is already in r3 from fn return value
- li 0, 1 # SYS_exit = 1
- sc
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s
deleted file mode 100644
index ef50ed0073..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/powerpc64/syscall_cp.s
+++ /dev/null
@@ -1,44 +0,0 @@
- .global __cp_begin
- .hidden __cp_begin
- .global __cp_end
- .hidden __cp_end
- .global __cp_cancel
- .hidden __cp_cancel
- .hidden __cancel
- .global __syscall_cp_asm
- .hidden __syscall_cp_asm
- .text
- .type __syscall_cp_asm,%function
-__syscall_cp_asm:
- # at enter: r3 = pointer to self->cancel, r4: syscall no, r5: first arg, r6: 2nd, r7: 3rd, r8: 4th, r9: 5th, r10: 6th
-__cp_begin:
- # if (self->cancel) goto __cp_cancel
- lwz 0, 0(3)
- cmpwi cr7, 0, 0
- bne- cr7, __cp_cancel
-
- # make syscall
- mr 0, 4
- mr 3, 5
- mr 4, 6
- mr 5, 7
- mr 6, 8
- mr 7, 9
- mr 8, 10
- sc
-
-__cp_end:
- # return error ? -r3 : r3
- bnslr+
- neg 3, 3
- blr
-
-__cp_cancel:
- mflr 0
- bl 1f
- .long .TOC.-.
-1: mflr 3
- lwa 2, 0(3)
- add 2, 2, 3
- mtlr 0
- b __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_atfork.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_atfork.c
deleted file mode 100644
index 7649740165..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_atfork.c
+++ /dev/null
@@ -1,49 +0,0 @@
-#include <pthread.h>
-#include "libc.h"
-#include "lock.h"
-
-static struct atfork_funcs {
- void (*prepare)(void);
- void (*parent)(void);
- void (*child)(void);
- struct atfork_funcs *prev, *next;
-} *funcs;
-
-static volatile int lock[1];
-
-void __fork_handler(int who)
-{
- struct atfork_funcs *p;
- if (!funcs) return;
- if (who < 0) {
- LOCK(lock);
- for (p=funcs; p; p = p->next) {
- if (p->prepare) p->prepare();
- funcs = p;
- }
- } else {
- for (p=funcs; p; p = p->prev) {
- if (!who && p->parent) p->parent();
- else if (who && p->child) p->child();
- funcs = p;
- }
- UNLOCK(lock);
- }
-}
-
-int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void))
-{
- struct atfork_funcs *new = malloc(sizeof *new);
- if (!new) return -1;
-
- LOCK(lock);
- new->next = funcs;
- new->prev = 0;
- new->prepare = prepare;
- new->parent = parent;
- new->child = child;
- if (funcs) funcs->prev = new;
- funcs = new;
- UNLOCK(lock);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_destroy.c
deleted file mode 100644
index b5845dd0f5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_destroy(pthread_attr_t *a)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_get.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_get.c
deleted file mode 100644
index 0ac251c674..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_get.c
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state)
-{
- *state = a->_a_detach;
- return 0;
-}
-int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size)
-{
- *size = a->_a_guardsize;
- return 0;
-}
-
-int pthread_attr_getinheritsched(const pthread_attr_t *restrict a, int *restrict inherit)
-{
- *inherit = a->_a_sched;
- return 0;
-}
-
-#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
-int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param)
-{
- param->sched_priority = a->_a_prio;
- return 0;
-}
-
-int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict policy)
-{
- *policy = a->_a_policy;
- return 0;
-}
-#endif
-
-int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope)
-{
- *scope = PTHREAD_SCOPE_SYSTEM;
- return 0;
-}
-
-int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size)
-{
- if (!a->_a_stackaddr)
- return EINVAL;
- *size = a->_a_stacksize;
- *addr = (void *)(a->_a_stackaddr - *size);
- return 0;
-}
-
-int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size)
-{
- *size = a->_a_stacksize;
- return 0;
-}
-
-int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared)
-{
- *pshared = !!a->__attr;
- return 0;
-}
-
-#ifdef __wasilibc_unmodified_upstream /* Forward declaration of WASI's `__clockid` type. */
-int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
-{
- *clk = a->__attr & 0x7fffffff;
- return 0;
-}
-#endif
-
-int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
-{
- *pshared = a->__attr>>31;
- return 0;
-}
-
-int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol)
-{
- *protocol = a->__attr / 8U % 2;
- return 0;
-}
-int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared)
-{
- *pshared = a->__attr / 128U % 2;
- return 0;
-}
-
-int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
-{
- *robust = a->__attr / 4U % 2;
- return 0;
-}
-
-int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
-{
- *type = a->__attr & 3;
- return 0;
-}
-
-int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
-{
- *pshared = a->__attr[0];
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_init.c
deleted file mode 100644
index 463a8d2075..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_init.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_init(pthread_attr_t *a)
-{
- *a = (pthread_attr_t){0};
- __acquire_ptc();
- a->_a_stacksize = __default_stacksize;
- a->_a_guardsize = __default_guardsize;
- __release_ptc();
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c
deleted file mode 100644
index 1b7127839a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setdetachstate.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setdetachstate(pthread_attr_t *a, int state)
-{
- if (state > 1U) return EINVAL;
- a->_a_detach = state;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c
deleted file mode 100644
index 1c5c60acbc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setguardsize.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setguardsize(pthread_attr_t *a, size_t size)
-{
- if (size > SIZE_MAX/8) return EINVAL;
- a->_a_guardsize = size;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c
deleted file mode 100644
index ca264be7c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setinheritsched.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-#include "syscall.h"
-
-int pthread_attr_setinheritsched(pthread_attr_t *a, int inherit)
-{
- if (inherit > 1U) return EINVAL;
- a->_a_sched = inherit;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c
deleted file mode 100644
index d4c1204fdc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedparam.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param)
-{
- a->_a_prio = param->sched_priority;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c
deleted file mode 100644
index bb71f393e2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setschedpolicy.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setschedpolicy(pthread_attr_t *a, int policy)
-{
- a->_a_policy = policy;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setscope.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setscope.c
deleted file mode 100644
index 46b520c041..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setscope.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setscope(pthread_attr_t *a, int scope)
-{
- switch (scope) {
- case PTHREAD_SCOPE_SYSTEM:
- return 0;
- case PTHREAD_SCOPE_PROCESS:
- return ENOTSUP;
- default:
- return EINVAL;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstack.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstack.c
deleted file mode 100644
index 1eddcbd6eb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstack.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setstack(pthread_attr_t *a, void *addr, size_t size)
-{
- if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL;
- a->_a_stackaddr = (size_t)addr + size;
- a->_a_stacksize = size;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstacksize.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstacksize.c
deleted file mode 100644
index 9c6a8806ee..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_attr_setstacksize.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_attr_setstacksize(pthread_attr_t *a, size_t size)
-{
- if (size-PTHREAD_STACK_MIN > SIZE_MAX/4) return EINVAL;
- a->_a_stackaddr = 0;
- a->_a_stacksize = size;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_destroy.c
deleted file mode 100644
index a347a2c12a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_destroy.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_barrier_destroy(pthread_barrier_t *b)
-{
- if (b->_b_limit < 0) {
- if (b->_b_lock) {
- int v;
- a_or(&b->_b_lock, INT_MIN);
- while ((v = b->_b_lock) & INT_MAX)
- __wait(&b->_b_lock, 0, v, 0);
- }
-#ifdef __wasilibc_unmodified_upstream /* WASI does not understand processes or locking between them. */
- __vm_wait();
-#endif
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_init.c
deleted file mode 100644
index 4c3cb28d44..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_init.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count)
-{
- if (count-1 > INT_MAX-1) return EINVAL;
- *b = (pthread_barrier_t){ ._b_limit = count-1 | (a?a->__attr:0) };
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_wait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_wait.c
deleted file mode 100644
index 0891b713ec..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrier_wait.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "pthread_impl.h"
-
-static int pshared_barrier_wait(pthread_barrier_t *b)
-{
- int limit = (b->_b_limit & INT_MAX) + 1;
- int ret = 0;
- int v, w;
-
- if (limit==1) return PTHREAD_BARRIER_SERIAL_THREAD;
-
- while ((v=a_cas(&b->_b_lock, 0, limit)))
- __wait(&b->_b_lock, &b->_b_waiters, v, 0);
-
- /* Wait for <limit> threads to get to the barrier */
- if (++b->_b_count == limit) {
- a_store(&b->_b_count, 0);
- ret = PTHREAD_BARRIER_SERIAL_THREAD;
- if (b->_b_waiters2) __wake(&b->_b_count, -1, 0);
- } else {
- a_store(&b->_b_lock, 0);
- if (b->_b_waiters) __wake(&b->_b_lock, 1, 0);
- while ((v=b->_b_count)>0)
- __wait(&b->_b_count, &b->_b_waiters2, v, 0);
- }
-
-#ifdef __wasilibc_unmodified_upstream /* WASI does not understand processes or locking between them. */
- __vm_lock();
-#endif
-
- /* Ensure all threads have a vm lock before proceeding */
- if (a_fetch_add(&b->_b_count, -1)==1-limit) {
- a_store(&b->_b_count, 0);
- if (b->_b_waiters2) __wake(&b->_b_count, -1, 0);
- } else {
- while ((v=b->_b_count))
- __wait(&b->_b_count, &b->_b_waiters2, v, 0);
- }
-
- /* Perform a recursive unlock suitable for self-sync'd destruction */
- do {
- v = b->_b_lock;
- w = b->_b_waiters;
- } while (a_cas(&b->_b_lock, v, v==INT_MIN+1 ? 0 : v-1) != v);
-
- /* Wake a thread waiting to reuse or destroy the barrier */
- if (v==INT_MIN+1 || (v==1 && w))
- __wake(&b->_b_lock, 1, 0);
-
-#ifdef __wasilibc_unmodified_upstream /* WASI does not understand processes or locking between them. */
- __vm_unlock();
-#endif
-
- return ret;
-}
-
-struct instance
-{
- volatile int count;
- volatile int last;
- volatile int waiters;
- volatile int finished;
-};
-
-int pthread_barrier_wait(pthread_barrier_t *b)
-{
- int limit = b->_b_limit;
- struct instance *inst;
-
- /* Trivial case: count was set at 1 */
- if (!limit) return PTHREAD_BARRIER_SERIAL_THREAD;
-
- /* Process-shared barriers require a separate, inefficient wait */
- if (limit < 0) return pshared_barrier_wait(b);
-
- /* Otherwise we need a lock on the barrier object */
- while (a_swap(&b->_b_lock, 1))
- __wait(&b->_b_lock, &b->_b_waiters, 1, 1);
- inst = b->_b_inst;
-
- /* First thread to enter the barrier becomes the "instance owner" */
- if (!inst) {
- struct instance new_inst = { 0 };
- int spins = 200;
- b->_b_inst = inst = &new_inst;
- a_store(&b->_b_lock, 0);
- if (b->_b_waiters) __wake(&b->_b_lock, 1, 1);
- while (spins-- && !inst->finished)
- a_spin();
- a_inc(&inst->finished);
- while (inst->finished == 1)
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_futex,&inst->finished,FUTEX_WAIT|FUTEX_PRIVATE,1,0) != -ENOSYS
- || __syscall(SYS_futex,&inst->finished,FUTEX_WAIT,1,0);
-#else
- __futexwait(&inst->finished, 1, 0);
-#endif
- return PTHREAD_BARRIER_SERIAL_THREAD;
- }
-
- /* Last thread to enter the barrier wakes all non-instance-owners */
- if (++inst->count == limit) {
- b->_b_inst = 0;
- a_store(&b->_b_lock, 0);
- if (b->_b_waiters) __wake(&b->_b_lock, 1, 1);
- a_store(&inst->last, 1);
- if (inst->waiters)
- __wake(&inst->last, -1, 1);
- } else {
- a_store(&b->_b_lock, 0);
- if (b->_b_waiters) __wake(&b->_b_lock, 1, 1);
- __wait(&inst->last, &inst->waiters, 0, 1);
- }
-
- /* Last thread to exit the barrier wakes the instance owner */
- if (a_fetch_add(&inst->count,-1)==1 && a_fetch_add(&inst->finished,1))
- __wake(&inst->finished, 1, 1);
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c
deleted file mode 100644
index adec738fd6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_barrierattr_destroy(pthread_barrierattr_t *a)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_init.c
deleted file mode 100644
index fa742bb734..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_barrierattr_init(pthread_barrierattr_t *a)
-{
- *a = (pthread_barrierattr_t){0};
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c
deleted file mode 100644
index c2d2929dcf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_barrierattr_setpshared.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared)
-{
- if (pshared > 1U) return EINVAL;
- a->__attr = pshared ? INT_MIN : 0;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cancel.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cancel.c
deleted file mode 100644
index 2f9d5e975f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cancel.c
+++ /dev/null
@@ -1,101 +0,0 @@
-#define _GNU_SOURCE
-#include <string.h>
-#include "pthread_impl.h"
-#include "syscall.h"
-
-hidden long __cancel(), __syscall_cp_asm(), __syscall_cp_c();
-
-long __cancel()
-{
- pthread_t self = __pthread_self();
- if (self->canceldisable == PTHREAD_CANCEL_ENABLE || self->cancelasync)
- pthread_exit(PTHREAD_CANCELED);
- self->canceldisable = PTHREAD_CANCEL_DISABLE;
- return -ECANCELED;
-}
-
-long __syscall_cp_asm(volatile void *, syscall_arg_t,
- syscall_arg_t, syscall_arg_t, syscall_arg_t,
- syscall_arg_t, syscall_arg_t, syscall_arg_t);
-
-long __syscall_cp_c(syscall_arg_t nr,
- syscall_arg_t u, syscall_arg_t v, syscall_arg_t w,
- syscall_arg_t x, syscall_arg_t y, syscall_arg_t z)
-{
- pthread_t self;
- long r;
- int st;
-
- if ((st=(self=__pthread_self())->canceldisable)
- && (st==PTHREAD_CANCEL_DISABLE || nr==SYS_close))
- return __syscall(nr, u, v, w, x, y, z);
-
- r = __syscall_cp_asm(&self->cancel, nr, u, v, w, x, y, z);
- if (r==-EINTR && nr!=SYS_close && self->cancel &&
- self->canceldisable != PTHREAD_CANCEL_DISABLE)
- r = __cancel();
- return r;
-}
-
-static void _sigaddset(sigset_t *set, int sig)
-{
- unsigned s = sig-1;
- set->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1);
-}
-
-extern hidden const char __cp_begin[1], __cp_end[1], __cp_cancel[1];
-
-static void cancel_handler(int sig, siginfo_t *si, void *ctx)
-{
- pthread_t self = __pthread_self();
- ucontext_t *uc = ctx;
- uintptr_t pc = uc->uc_mcontext.MC_PC;
-
- a_barrier();
- if (!self->cancel || self->canceldisable == PTHREAD_CANCEL_DISABLE) return;
-
- _sigaddset(&uc->uc_sigmask, SIGCANCEL);
-
- if (self->cancelasync || pc >= (uintptr_t)__cp_begin && pc < (uintptr_t)__cp_end) {
- uc->uc_mcontext.MC_PC = (uintptr_t)__cp_cancel;
-#ifdef CANCEL_GOT
- uc->uc_mcontext.MC_GOT = CANCEL_GOT;
-#endif
- return;
- }
-
- __syscall(SYS_tkill, self->tid, SIGCANCEL);
-}
-
-void __testcancel()
-{
- pthread_t self = __pthread_self();
- if (self->cancel && !self->canceldisable)
- __cancel();
-}
-
-static void init_cancellation()
-{
- struct sigaction sa = {
- .sa_flags = SA_SIGINFO | SA_RESTART,
- .sa_sigaction = cancel_handler
- };
- memset(&sa.sa_mask, -1, _NSIG/8);
- __libc_sigaction(SIGCANCEL, &sa, 0);
-}
-
-int pthread_cancel(pthread_t t)
-{
- static int init;
- if (!init) {
- init_cancellation();
- init = 1;
- }
- a_store(&t->cancel, 1);
- if (t == pthread_self()) {
- if (t->canceldisable == PTHREAD_CANCEL_ENABLE && t->cancelasync)
- pthread_exit(PTHREAD_CANCELED);
- return 0;
- }
- return pthread_kill(t, SIGCANCEL);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cleanup_push.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cleanup_push.c
deleted file mode 100644
index 9b21764b56..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cleanup_push.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "pthread_impl.h"
-
-static void dummy(struct __ptcb *cb)
-{
-}
-weak_alias(dummy, __do_cleanup_push);
-weak_alias(dummy, __do_cleanup_pop);
-
-void _pthread_cleanup_push(struct __ptcb *cb, void (*f)(void *), void *x)
-{
- cb->__f = f;
- cb->__x = x;
- __do_cleanup_push(cb);
-}
-
-void _pthread_cleanup_pop(struct __ptcb *cb, int run)
-{
- __do_cleanup_pop(cb);
- if (run) cb->__f(cb->__x);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_broadcast.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_broadcast.c
deleted file mode 100644
index 6bfab78f96..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_broadcast.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_cond_broadcast(pthread_cond_t *c)
-{
- if (!c->_c_shared) return __private_cond_signal(c, -1);
- if (!c->_c_waiters) return 0;
- a_inc(&c->_c_seq);
- __wake(&c->_c_seq, -1, 0);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_destroy.c
deleted file mode 100644
index 8c5551600e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_destroy.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_cond_destroy(pthread_cond_t *c)
-{
- if (c->_c_shared && c->_c_waiters) {
- int cnt;
- a_or(&c->_c_waiters, 0x80000000);
- a_inc(&c->_c_seq);
- __wake(&c->_c_seq, -1, 0);
- while ((cnt = c->_c_waiters) & 0x7fffffff)
- __wait(&c->_c_waiters, 0, cnt, 0);
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_init.c
deleted file mode 100644
index 8c484ddcde..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_init.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a)
-{
- *c = (pthread_cond_t){0};
- if (a) {
- c->_c_clock = a->__attr & 0x7fffffff;
- if (a->__attr>>31) c->_c_shared = (void *)-1;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_signal.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_signal.c
deleted file mode 100644
index 575ad54bc0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_signal.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_cond_signal(pthread_cond_t *c)
-{
- if (!c->_c_shared) return __private_cond_signal(c, 1);
- if (!c->_c_waiters) return 0;
- a_inc(&c->_c_seq);
- __wake(&c->_c_seq, 1, 0);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_timedwait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_timedwait.c
deleted file mode 100644
index ba985f9116..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_timedwait.c
+++ /dev/null
@@ -1,230 +0,0 @@
-#include "pthread_impl.h"
-
-#ifndef __wasilibc_unmodified_upstream
-#include <common/clock.h>
-#endif
-
-/*
- * struct waiter
- *
- * Waiter objects have automatic storage on the waiting thread, and
- * are used in building a linked list representing waiters currently
- * waiting on the condition variable or a group of waiters woken
- * together by a broadcast or signal; in the case of signal, this is a
- * degenerate list of one member.
- *
- * Waiter lists attached to the condition variable itself are
- * protected by the lock on the cv. Detached waiter lists are never
- * modified again, but can only be traversed in reverse order, and are
- * protected by the "barrier" locks in each node, which are unlocked
- * in turn to control wake order.
- *
- * Since process-shared cond var semantics do not necessarily allow
- * one thread to see another's automatic storage (they may be in
- * different processes), the waiter list is not used for the
- * process-shared case, but the structure is still used to store data
- * needed by the cancellation cleanup handler.
- */
-
-struct waiter {
- struct waiter *prev, *next;
- volatile int state, barrier;
- volatile int *notify;
-};
-
-/* Self-synchronized-destruction-safe lock functions */
-
-static inline void lock(volatile int *l)
-{
- if (a_cas(l, 0, 1)) {
- a_cas(l, 1, 2);
- do __wait(l, 0, 2, 1);
- while (a_cas(l, 0, 2));
- }
-}
-
-static inline void unlock(volatile int *l)
-{
- if (a_swap(l, 0)==2)
- __wake(l, 1, 1);
-}
-
-static inline void unlock_requeue(volatile int *l, volatile int *r, int w)
-{
- a_store(l, 0);
-#ifdef __wasilibc_unmodified_upstream
- if (w) __wake(l, 1, 1);
- else __syscall(SYS_futex, l, FUTEX_REQUEUE|FUTEX_PRIVATE, 0, 1, r) != -ENOSYS
- || __syscall(SYS_futex, l, FUTEX_REQUEUE, 0, 1, r);
-#else
- // Always wake due to lack of requeue system call in WASI
- // This can impact the performance, so we might need to re-visit that decision
- __wake(l, 1, 1);
-#endif
-}
-
-enum {
- WAITING,
- SIGNALED,
- LEAVING,
-};
-
-int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec *restrict ts)
-{
- struct waiter node = { 0 };
- int e, seq, clock = c->_c_clock, cs, shared=0, oldstate, tmp;
-#ifndef __wasilibc_unmodified_upstream
- struct __clockid clock_id = { .id = clock };
-#endif
- volatile int *fut;
-
- if ((m->_m_type&15) && (m->_m_lock&INT_MAX) != __pthread_self()->tid)
- return EPERM;
-
- if (ts && ts->tv_nsec >= 1000000000UL)
- return EINVAL;
-
- __pthread_testcancel();
-
- if (c->_c_shared) {
- shared = 1;
- fut = &c->_c_seq;
- seq = c->_c_seq;
- a_inc(&c->_c_waiters);
- } else {
- lock(&c->_c_lock);
-
- seq = node.barrier = 2;
- fut = &node.barrier;
- node.state = WAITING;
- node.next = c->_c_head;
- c->_c_head = &node;
- if (!c->_c_tail) c->_c_tail = &node;
- else node.next->prev = &node;
-
- unlock(&c->_c_lock);
- }
-
- __pthread_mutex_unlock(m);
-
- __pthread_setcancelstate(PTHREAD_CANCEL_MASKED, &cs);
- if (cs == PTHREAD_CANCEL_DISABLE) __pthread_setcancelstate(cs, 0);
-
-#ifdef __wasilibc_unmodified_upstream
- do e = __timedwait_cp(fut, seq, clock, ts, !shared);
-#else
- do e = __timedwait_cp(fut, seq, &clock_id, ts, !shared);
-#endif
- while (*fut==seq && (!e || e==EINTR));
- if (e == EINTR) e = 0;
-
- if (shared) {
- /* Suppress cancellation if a signal was potentially
- * consumed; this is a legitimate form of spurious
- * wake even if not. */
- if (e == ECANCELED && c->_c_seq != seq) e = 0;
- if (a_fetch_add(&c->_c_waiters, -1) == -0x7fffffff)
- __wake(&c->_c_waiters, 1, 0);
- oldstate = WAITING;
- goto relock;
- }
-
- oldstate = a_cas(&node.state, WAITING, LEAVING);
-
- if (oldstate == WAITING) {
- /* Access to cv object is valid because this waiter was not
- * yet signaled and a new signal/broadcast cannot return
- * after seeing a LEAVING waiter without getting notified
- * via the futex notify below. */
-
- lock(&c->_c_lock);
-
- if (c->_c_head == &node) c->_c_head = node.next;
- else if (node.prev) node.prev->next = node.next;
- if (c->_c_tail == &node) c->_c_tail = node.prev;
- else if (node.next) node.next->prev = node.prev;
-
- unlock(&c->_c_lock);
-
- if (node.notify) {
- if (a_fetch_add(node.notify, -1)==1)
- __wake(node.notify, 1, 1);
- }
- } else {
- /* Lock barrier first to control wake order. */
- lock(&node.barrier);
- }
-
-relock:
- /* Errors locking the mutex override any existing error or
- * cancellation, since the caller must see them to know the
- * state of the mutex. */
- if ((tmp = pthread_mutex_lock(m))) e = tmp;
-
- if (oldstate == WAITING) goto done;
-
- if (!node.next && !(m->_m_type & 8))
- a_inc(&m->_m_waiters);
-
- /* Unlock the barrier that's holding back the next waiter, and
- * either wake it or requeue it to the mutex. */
- if (node.prev) {
- int val = m->_m_lock;
- if (val>0) a_cas(&m->_m_lock, val, val|0x80000000);
- unlock_requeue(&node.prev->barrier, &m->_m_lock, m->_m_type & (8|128));
- } else if (!(m->_m_type & 8)) {
- a_dec(&m->_m_waiters);
- }
-
- /* Since a signal was consumed, cancellation is not permitted. */
- if (e == ECANCELED) e = 0;
-
-done:
- __pthread_setcancelstate(cs, 0);
-
- if (e == ECANCELED) {
- __pthread_testcancel();
- __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
- }
-
- return e;
-}
-
-int __private_cond_signal(pthread_cond_t *c, int n)
-{
- struct waiter *p, *first=0;
- volatile int ref = 0;
- int cur;
-
- lock(&c->_c_lock);
- for (p=c->_c_tail; n && p; p=p->prev) {
- if (a_cas(&p->state, WAITING, SIGNALED) != WAITING) {
- ref++;
- p->notify = &ref;
- } else {
- n--;
- if (!first) first=p;
- }
- }
- /* Split the list, leaving any remainder on the cv. */
- if (p) {
- if (p->next) p->next->prev = 0;
- p->next = 0;
- } else {
- c->_c_head = 0;
- }
- c->_c_tail = p;
- unlock(&c->_c_lock);
-
- /* Wait for any waiters in the LEAVING state to remove
- * themselves from the list before returning or allowing
- * signaled threads to proceed. */
- while ((cur = ref)) __wait(&ref, 0, cur, 1);
-
- /* Allow first signaled waiter, if any, to proceed. */
- if (first) unlock(&first->barrier);
-
- return 0;
-}
-
-weak_alias(__pthread_cond_timedwait, pthread_cond_timedwait);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_wait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_wait.c
deleted file mode 100644
index 8735bf1478..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_cond_wait.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m)
-{
- return pthread_cond_timedwait(c, m, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_destroy.c
deleted file mode 100644
index c54ec4122e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_condattr_destroy(pthread_condattr_t *a)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_init.c
deleted file mode 100644
index a41741b4ec..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_condattr_init(pthread_condattr_t *a)
-{
- *a = (pthread_condattr_t){0};
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setclock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setclock.c
deleted file mode 100644
index 21ca070c3e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setclock.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pthread_impl.h"
-
-#ifndef __wasilibc_unmodified_upstream
-#include <common/clock.h>
-#endif
-
-int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk)
-{
-#ifdef __wasilibc_unmodified_upstream
- if (clk < 0 || clk-2U < 2) return EINVAL;
-#else
- if (clk->id < 0 || clk->id-2U < 2) return EINVAL;
-#endif
- a->__attr &= 0x80000000;
-#ifdef __wasilibc_unmodified_upstream
- a->__attr |= clk;
-#else
- a->__attr |= clk->id;
-#endif
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setpshared.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setpshared.c
deleted file mode 100644
index 51453e0480..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_condattr_setpshared.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared)
-{
- if (pshared > 1U) return EINVAL;
- a->__attr &= 0x7fffffff;
- a->__attr |= (unsigned)pshared<<31;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_create.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_create.c
deleted file mode 100644
index 676e2ccf95..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_create.c
+++ /dev/null
@@ -1,585 +0,0 @@
-#define _GNU_SOURCE
-#include "pthread_impl.h"
-#include "stdio_impl.h"
-#include "libc.h"
-#include "lock.h"
-#ifdef __wasilibc_unmodified_upstream
-#include <sys/mman.h>
-#endif
-#include <string.h>
-#include <stddef.h>
-#ifndef __wasilibc_unmodified_upstream
-#include <stdatomic.h>
-#endif
-
-#include <stdalign.h>
-
-static void dummy_0()
-{
-}
-weak_alias(dummy_0, __acquire_ptc);
-weak_alias(dummy_0, __release_ptc);
-weak_alias(dummy_0, __pthread_tsd_run_dtors);
-weak_alias(dummy_0, __do_orphaned_stdio_locks);
-#ifdef __wasilibc_unmodified_upstream
-weak_alias(dummy_0, __dl_thread_cleanup);
-weak_alias(dummy_0, __membarrier_init);
-#endif
-
-static int tl_lock_count;
-static int tl_lock_waiters;
-
-void __tl_lock(void)
-{
- int tid = __pthread_self()->tid;
- int val = __thread_list_lock;
- if (val == tid) {
- tl_lock_count++;
- return;
- }
- while ((val = a_cas(&__thread_list_lock, 0, tid)))
- __wait(&__thread_list_lock, &tl_lock_waiters, val, 0);
-}
-
-void __tl_unlock(void)
-{
- if (tl_lock_count) {
- tl_lock_count--;
- return;
- }
- a_store(&__thread_list_lock, 0);
- if (tl_lock_waiters) __wake(&__thread_list_lock, 1, 0);
-}
-
-void __tl_sync(pthread_t td)
-{
- a_barrier();
- int val = __thread_list_lock;
- if (!val) return;
- __wait(&__thread_list_lock, &tl_lock_waiters, val, 0);
- if (tl_lock_waiters) __wake(&__thread_list_lock, 1, 0);
-}
-
-#ifdef __wasilibc_unmodified_upstream
-_Noreturn void __pthread_exit(void *result)
-#else
-static void __pthread_exit(void *result)
-#endif
-{
- pthread_t self = __pthread_self();
- sigset_t set;
-
- self->canceldisable = 1;
- self->cancelasync = 0;
- self->result = result;
-
- while (self->cancelbuf) {
- void (*f)(void *) = self->cancelbuf->__f;
- void *x = self->cancelbuf->__x;
- self->cancelbuf = self->cancelbuf->__next;
- f(x);
- }
-
- __pthread_tsd_run_dtors();
-
-#ifdef __wasilibc_unmodified_upstream
- __block_app_sigs(&set);
-#endif
-
- /* This atomic potentially competes with a concurrent pthread_detach
- * call; the loser is responsible for freeing thread resources. */
- int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING);
-
- if (state==DT_DETACHED && self->map_base) {
- /* Since __unmapself bypasses the normal munmap code path,
- * explicitly wait for vmlock holders first. This must be
- * done before any locks are taken, to avoid lock ordering
- * issues that could lead to deadlock. */
-#ifdef __wasilibc_unmodified_upstream
- __vm_wait();
-#endif
- }
-
- /* Access to target the exiting thread with syscalls that use
- * its kernel tid is controlled by killlock. For detached threads,
- * any use past this point would have undefined behavior, but for
- * joinable threads it's a valid usage that must be handled.
- * Signals must be blocked since pthread_kill must be AS-safe. */
- LOCK(self->killlock);
-
- /* The thread list lock must be AS-safe, and thus depends on
- * application signals being blocked above. */
- __tl_lock();
-
- /* If this is the only thread in the list, don't proceed with
- * termination of the thread, but restore the previous lock and
- * signal state to prepare for exit to call atexit handlers. */
- if (self->next == self) {
- __tl_unlock();
- UNLOCK(self->killlock);
- self->detach_state = state;
-#ifdef __wasilibc_unmodified_upstream
- __restore_sigs(&set);
-#endif
- exit(0);
- }
-
- /* At this point we are committed to thread termination. */
-
-#ifdef __wasilibc_unmodified_upstream
- /* Process robust list in userspace to handle non-pshared mutexes
- * and the detached thread case where the robust list head will
- * be invalid when the kernel would process it. */
- __vm_lock();
-#endif
- volatile void *volatile *rp;
- while ((rp=self->robust_list.head) && rp != &self->robust_list.head) {
- pthread_mutex_t *m = (void *)((char *)rp
- - offsetof(pthread_mutex_t, _m_next));
- int waiters = m->_m_waiters;
- int priv = (m->_m_type & 128) ^ 128;
- self->robust_list.pending = rp;
- self->robust_list.head = *rp;
- int cont = a_swap(&m->_m_lock, 0x40000000);
- self->robust_list.pending = 0;
- if (cont < 0 || waiters)
- __wake(&m->_m_lock, 1, priv);
- }
-#ifdef __wasilibc_unmodified_upstream
- __vm_unlock();
-#endif
-
- __do_orphaned_stdio_locks();
-#ifdef __wasilibc_unmodified_upstream
- __dl_thread_cleanup();
-#endif
-
- /* Last, unlink thread from the list. This change will not be visible
- * until the lock is released, which only happens after SYS_exit
- * has been called, via the exit futex address pointing at the lock.
- * This needs to happen after any possible calls to LOCK() that might
- * skip locking if process appears single-threaded. */
- if (!--libc.threads_minus_1) libc.need_locks = -1;
- self->next->prev = self->prev;
- self->prev->next = self->next;
- self->prev = self->next = self;
-
-#ifndef __wasilibc_unmodified_upstream
- /* On Linux, the thread is created with CLONE_CHILD_CLEARTID,
- * and this lock will unlock by kernel when this thread terminates.
- * So we should unlock it here in WebAssembly.
- * See also set_tid_address(2) */
- __tl_unlock();
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
- if (state==DT_DETACHED && self->map_base) {
- /* Detached threads must block even implementation-internal
- * signals, since they will not have a stack in their last
- * moments of existence. */
- __block_all_sigs(&set);
-
- /* Robust list will no longer be valid, and was already
- * processed above, so unregister it with the kernel. */
- if (self->robust_list.off)
- __syscall(SYS_set_robust_list, 0, 3*sizeof(long));
-
- /* The following call unmaps the thread's stack mapping
- * and then exits without touching the stack. */
- __unmapself(self->map_base, self->map_size);
- }
-#else
- if (state==DT_DETACHED && self->map_base) {
- // __syscall(SYS_exit) would unlock the thread, list
- // do it manually here
- __tl_unlock();
- free(self->map_base);
- // Can't use `exit()` here, because it is too high level
- return;
- }
-#endif
-
- /* Wake any joiner. */
- a_store(&self->detach_state, DT_EXITED);
- __wake(&self->detach_state, 1, 1);
-
- /* After the kernel thread exits, its tid may be reused. Clear it
- * to prevent inadvertent use and inform functions that would use
- * it that it's no longer available. */
- self->tid = 0;
- UNLOCK(self->killlock);
-
-#ifdef __wasilibc_unmodified_upstream
- for (;;) __syscall(SYS_exit, 0);
-#else
- // __syscall(SYS_exit) would unlock the thread, list
- // do it manually here
- __tl_unlock();
- // Can't use `exit()` here, because it is too high level
-#endif
-}
-
-void __do_cleanup_push(struct __ptcb *cb)
-{
- struct pthread *self = __pthread_self();
- cb->__next = self->cancelbuf;
- self->cancelbuf = cb;
-}
-
-void __do_cleanup_pop(struct __ptcb *cb)
-{
- __pthread_self()->cancelbuf = cb->__next;
-}
-
-struct start_args {
-#ifdef __wasilibc_unmodified_upstream
- void *(*start_func)(void *);
- void *start_arg;
- volatile int control;
- unsigned long sig_mask[_NSIG/8/sizeof(long)];
-#else
- /*
- * Note: the offset of the "stack" and "tls_base" members
- * in this structure is hardcoded in wasi_thread_start.
- */
- void *stack;
- void *tls_base;
- void *(*start_func)(void *);
- void *start_arg;
-#endif
-};
-
-#ifdef __wasilibc_unmodified_upstream
-static int start(void *p)
-{
- struct start_args *args = p;
- int state = args->control;
- if (state) {
- if (a_cas(&args->control, 1, 2)==1)
- __wait(&args->control, 0, 2, 1);
- if (args->control) {
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_set_tid_address, &args->control);
- for (;;) __syscall(SYS_exit, 0);
-#endif
- }
- }
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->sig_mask, 0, _NSIG/8);
-#endif
- __pthread_exit(args->start_func(args->start_arg));
- return 0;
-}
-
-static int start_c11(void *p)
-{
- struct start_args *args = p;
- int (*start)(void*) = (int(*)(void*)) args->start_func;
- __pthread_exit((void *)(uintptr_t)start(args->start_arg));
- return 0;
-}
-#else
-
-/*
- * We want to ensure wasi_thread_start is linked whenever
- * pthread_create is used. The following reference is to ensure that.
- * Otherwise, the linker doesn't notice the dependency because
- * wasi_thread_start is used indirectly via a wasm export.
- */
-void wasi_thread_start(int tid, void *p);
-hidden void *__dummy_reference = wasi_thread_start;
-
-hidden void __wasi_thread_start_C(int tid, void *p)
-{
- struct start_args *args = p;
- pthread_t self = __pthread_self();
- // Set the thread ID (TID) on the pthread structure. The TID is stored
- // atomically since it is also stored by the parent thread; this way,
- // whichever thread (parent or child) reaches this point first can proceed
- // without waiting.
- atomic_store((atomic_int *) &(self->tid), tid);
- // Execute the user's start function.
- __pthread_exit(args->start_func(args->start_arg));
-}
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
-#define ROUND(x) (((x)+PAGE_SIZE-1)&-PAGE_SIZE)
-#else
-/*
- * As we allocate stack with malloc() instead of mmap/mprotect,
- * there is no point to round it up to PAGE_SIZE.
- * Instead, round up to a sane alignment.
- * Note: PAGE_SIZE is rather big on WASM. (65536)
- */
-#define ROUND(x) (((x)+16-1)&-16)
-#endif
-
-/* pthread_key_create.c overrides this */
-static volatile size_t dummy = 0;
-weak_alias(dummy, __pthread_tsd_size);
-static void *dummy_tsd[1] = { 0 };
-weak_alias(dummy_tsd, __pthread_tsd_main);
-
-static FILE *volatile dummy_file = 0;
-weak_alias(dummy_file, __stdin_used);
-weak_alias(dummy_file, __stdout_used);
-weak_alias(dummy_file, __stderr_used);
-
-static void init_file_lock(FILE *f)
-{
- if (f && f->lock<0) f->lock = 0;
-}
-
-int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp, void *(*entry)(void *), void *restrict arg)
-{
- int ret, c11 = (attrp == __ATTRP_C11_THREAD);
- size_t size, guard;
- struct pthread *self, *new;
- unsigned char *map = 0, *stack = 0, *tsd = 0, *stack_limit;
-#ifdef __wasilibc_unmodified_upstream
- unsigned flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND
- | CLONE_THREAD | CLONE_SYSVSEM | CLONE_SETTLS
- | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | CLONE_DETACHED;
-#endif
- pthread_attr_t attr = { 0 };
- sigset_t set;
-#ifndef __wasilibc_unmodified_upstream
- size_t tls_size = __builtin_wasm_tls_size();
- size_t tls_align = __builtin_wasm_tls_align();
- void* tls_base = __builtin_wasm_tls_base();
- void* new_tls_base;
- size_t tls_offset;
- tls_size += tls_align;
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
- if (!libc.can_do_threads) return ENOSYS;
-#endif
- self = __pthread_self();
- if (!libc.threaded) {
- for (FILE *f=*__ofl_lock(); f; f=f->next)
- init_file_lock(f);
- __ofl_unlock();
- init_file_lock(__stdin_used);
- init_file_lock(__stdout_used);
- init_file_lock(__stderr_used);
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, SIGPT_SET, 0, _NSIG/8);
-#endif
- self->tsd = (void **)__pthread_tsd_main;
-#ifdef __wasilibc_unmodified_upstream
- __membarrier_init();
-#endif
- libc.threaded = 1;
- }
- if (attrp && !c11) attr = *attrp;
-
- __acquire_ptc();
- if (!attrp || c11) {
- attr._a_stacksize = __default_stacksize;
- attr._a_guardsize = __default_guardsize;
- }
-
- if (attr._a_stackaddr) {
-#ifdef __wasilibc_unmodified_upstream
- size_t need = libc.tls_size + __pthread_tsd_size;
-#else
- size_t need = tls_size + __pthread_tsd_size;
-#endif
- size = attr._a_stacksize;
- stack = (void *)(attr._a_stackaddr & -16);
- stack_limit = (void *)(attr._a_stackaddr - size);
- /* Use application-provided stack for TLS only when
- * it does not take more than ~12% or 2k of the
- * application's stack space. */
- if (need < size/8 && need < 2048) {
- tsd = stack - __pthread_tsd_size;
-#ifdef __wasilibc_unmodified_upstream
- stack = tsd - libc.tls_size;
-#else
- stack = tsd - tls_size;
-#endif
- memset(stack, 0, need);
- } else {
- size = ROUND(need);
- }
- guard = 0;
- } else {
- guard = ROUND(attr._a_guardsize);
- size = guard + ROUND(attr._a_stacksize
-#ifdef __wasilibc_unmodified_upstream
- + libc.tls_size + __pthread_tsd_size);
-#else
- + tls_size + __pthread_tsd_size);
-#endif
- }
-
- if (!tsd) {
-#ifdef __wasilibc_unmodified_upstream
- if (guard) {
- map = __mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0);
- if (map == MAP_FAILED) goto fail;
- if (__mprotect(map+guard, size-guard, PROT_READ|PROT_WRITE)
- && errno != ENOSYS) {
- __munmap(map, size);
- goto fail;
- }
- } else {
- map = __mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0);
- if (map == MAP_FAILED) goto fail;
- }
-#else
- map = malloc(size);
- if (!map) goto fail;
-#endif
- tsd = map + size - __pthread_tsd_size;
- if (!stack) {
-#ifdef __wasilibc_unmodified_upstream
- stack = tsd - libc.tls_size;
-#else
- stack = tsd - tls_size;
-#endif
- stack_limit = map + guard;
- }
- }
-
-#ifdef __wasilibc_unmodified_upstream
- new = __copy_tls(tsd - libc.tls_size);
-#else
- new_tls_base = __copy_tls(tsd - tls_size);
- tls_offset = new_tls_base - tls_base;
- new = (void*)((uintptr_t)self + tls_offset);
-#endif
- new->map_base = map;
- new->map_size = size;
- new->stack = stack;
- new->stack_size = stack - stack_limit;
- new->guard_size = guard;
- new->self = new;
- new->tsd = (void *)tsd;
- new->locale = &libc.global_locale;
- if (attr._a_detach) {
- new->detach_state = DT_DETACHED;
- } else {
- new->detach_state = DT_JOINABLE;
- }
- new->robust_list.head = &new->robust_list.head;
- new->canary = self->canary;
- new->sysinfo = self->sysinfo;
-
- /* Setup argument structure for the new thread on its stack.
- * It's safe to access from the caller only until the thread
- * list is unlocked. */
-#ifdef __wasilibc_unmodified_upstream
- stack -= (uintptr_t)stack % sizeof(uintptr_t);
- stack -= sizeof(struct start_args);
- struct start_args *args = (void *)stack;
- args->start_func = entry;
- args->start_arg = arg;
- args->control = attr._a_sched ? 1 : 0;
-
- /* Application signals (but not the synccall signal) must be
- * blocked before the thread list lock can be taken, to ensure
- * that the lock is AS-safe. */
- __block_app_sigs(&set);
-
- /* Ensure SIGCANCEL is unblocked in new thread. This requires
- * working with a copy of the set so we can restore the
- * original mask in the calling thread. */
- memcpy(&args->sig_mask, &set, sizeof args->sig_mask);
- args->sig_mask[(SIGCANCEL-1)/8/sizeof(long)] &=
- ~(1UL<<((SIGCANCEL-1)%(8*sizeof(long))));
-#else
- /* Align the stack to struct start_args */
- stack -= sizeof(struct start_args);
- stack -= (uintptr_t)stack % alignof(struct start_args);
- struct start_args *args = (void *)stack;
-
- /* Align the stack to 16 and store it */
- new->stack = (void *)((uintptr_t) stack & -16);
- /* Correct the stack size */
- new->stack_size = stack - stack_limit;
-
- args->stack = new->stack; /* just for convenience of asm trampoline */
- args->start_func = entry;
- args->start_arg = arg;
- args->tls_base = (void*)new_tls_base;
-#endif
-
- __tl_lock();
- if (!libc.threads_minus_1++) libc.need_locks = 1;
-#ifdef __wasilibc_unmodified_upstream
- ret = __clone((c11 ? start_c11 : start), stack, flags, args, &new->tid, TP_ADJ(new), &__thread_list_lock);
-#else
- /* Instead of `__clone`, WASI uses a host API to instantiate a new version
- * of the current module and start executing the entry function. The
- * wasi-threads specification requires the module to export a
- * `wasi_thread_start` function, which is invoked with `args`. */
- ret = __wasi_thread_spawn((void *) args);
-#endif
-
-#ifdef __wasilibc_unmodified_upstream
- /* All clone failures translate to EAGAIN. If explicit scheduling
- * was requested, attempt it before unlocking the thread list so
- * that the failed thread is never exposed and so that we can
- * clean up all transient resource usage before returning. */
- if (ret < 0) {
- ret = -EAGAIN;
- } else if (attr._a_sched) {
- ret = __syscall(SYS_sched_setscheduler,
- new->tid, attr._a_policy, &attr._a_prio);
- if (a_swap(&args->control, ret ? 3 : 0)==2)
- __wake(&args->control, 1, 1);
- if (ret)
- __wait(&args->control, 0, 3, 0);
- }
-#else
- /* `wasi_thread_spawn` will either return a host-provided thread ID (TID)
- * (`>= 0`) or an error code (`< 0`). As in the unmodified version, all
- * spawn failures translate to EAGAIN; unlike the modified version, there is
- * no need to "start up" the child thread--the host does this. If the spawn
- * did succeed, then we store the TID atomically, since this parent thread
- * is racing with the child thread to set this field; this way, whichever
- * thread reaches this point first can continue without waiting. */
- if (ret < 0) {
- ret = -EAGAIN;
- } else {
- atomic_store((atomic_int *) &(new->tid), ret);
- }
-#endif
-
- if (ret >= 0) {
- new->next = self->next;
- new->prev = self;
- new->next->prev = new;
- new->prev->next = new;
- } else {
- if (!--libc.threads_minus_1) libc.need_locks = 0;
- }
- __tl_unlock();
-#ifdef __wasilibc_unmodified_upstream
- __restore_sigs(&set);
-#endif
- __release_ptc();
-
- if (ret < 0) {
-#ifdef __wasilibc_unmodified_upstream
- if (map) __munmap(map, size);
-#else
- free(map);
-#endif
- return -ret;
- }
-
- *res = new;
- return 0;
-fail:
- __release_ptc();
- return EAGAIN;
-}
-
-#ifdef __wasilibc_unmodified_upstream
-weak_alias(__pthread_exit, pthread_exit);
-#endif
-weak_alias(__pthread_create, pthread_create);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_detach.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_detach.c
deleted file mode 100644
index 77772af2c6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_detach.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-static int __pthread_detach(pthread_t t)
-{
- /* If the cas fails, detach state is either already-detached
- * or exiting/exited, and pthread_join will trap or cleanup. */
- if (a_cas(&t->detach_state, DT_JOINABLE, DT_DETACHED) != DT_JOINABLE)
- return __pthread_join(t, 0);
- return 0;
-}
-
-weak_alias(__pthread_detach, pthread_detach);
-weak_alias(__pthread_detach, thrd_detach);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_equal.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_equal.c
deleted file mode 100644
index dbb7365587..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_equal.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <pthread.h>
-#include <threads.h>
-
-static int __pthread_equal(pthread_t a, pthread_t b)
-{
- return a==b;
-}
-
-weak_alias(__pthread_equal, pthread_equal);
-weak_alias(__pthread_equal, thrd_equal);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getattr_np.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getattr_np.c
deleted file mode 100644
index 2881831f8c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getattr_np.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#define _GNU_SOURCE
-#include "pthread_impl.h"
-#include "libc.h"
-#include <sys/mman.h>
-
-int pthread_getattr_np(pthread_t t, pthread_attr_t *a)
-{
- *a = (pthread_attr_t){0};
- a->_a_detach = t->detach_state>=DT_DETACHED;
- a->_a_guardsize = t->guard_size;
- if (t->stack) {
- a->_a_stackaddr = (uintptr_t)t->stack;
- a->_a_stacksize = t->stack_size;
- } else {
- char *p = (void *)libc.auxv;
- size_t l = PAGE_SIZE;
- p += -(uintptr_t)p & PAGE_SIZE-1;
- a->_a_stackaddr = (uintptr_t)p;
- while (mremap(p-l-PAGE_SIZE, PAGE_SIZE, 2*PAGE_SIZE, 0)==MAP_FAILED && errno==ENOMEM)
- l += PAGE_SIZE;
- a->_a_stacksize = l;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getconcurrency.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getconcurrency.c
deleted file mode 100644
index 269429a8ab..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getconcurrency.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <pthread.h>
-
-int pthread_getconcurrency()
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getcpuclockid.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getcpuclockid.c
deleted file mode 100644
index 9df14fb689..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getcpuclockid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_getcpuclockid(pthread_t t, clockid_t *clockid)
-{
- *clockid = (-t->tid-1)*8U + 6;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getname_np.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getname_np.c
deleted file mode 100644
index 85504e45dc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getname_np.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/prctl.h>
-
-#include "pthread_impl.h"
-
-int pthread_getname_np(pthread_t thread, char *name, size_t len)
-{
- int fd, cs, status = 0;
- char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
-
- if (len < 16) return ERANGE;
-
- if (thread == pthread_self())
- return prctl(PR_GET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
-
- snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- if ((fd = open(f, O_RDONLY|O_CLOEXEC)) < 0 || (len = read(fd, name, len)) == -1) status = errno;
- else name[len-1] = 0; /* remove trailing new line only if successful */
- if (fd >= 0) close(fd);
- pthread_setcancelstate(cs, 0);
- return status;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getschedparam.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getschedparam.c
deleted file mode 100644
index c098befb1b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getschedparam.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "pthread_impl.h"
-#include "lock.h"
-
-int pthread_getschedparam(pthread_t t, int *restrict policy, struct sched_param *restrict param)
-{
- int r;
- sigset_t set;
- __block_app_sigs(&set);
- LOCK(t->killlock);
- if (!t->tid) {
- r = ESRCH;
- } else {
- r = -__syscall(SYS_sched_getparam, t->tid, param);
- if (!r) {
- *policy = __syscall(SYS_sched_getscheduler, t->tid);
- }
- }
- UNLOCK(t->killlock);
- __restore_sigs(&set);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getspecific.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getspecific.c
deleted file mode 100644
index d9342a560f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_getspecific.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-static void *__pthread_getspecific(pthread_key_t k)
-{
- struct pthread *self = __pthread_self();
- return self->tsd[k];
-}
-
-weak_alias(__pthread_getspecific, pthread_getspecific);
-weak_alias(__pthread_getspecific, tss_get);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_join.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_join.c
deleted file mode 100644
index b06e7e75ef..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_join.c
+++ /dev/null
@@ -1,46 +0,0 @@
-#define _GNU_SOURCE
-#include "pthread_impl.h"
-#ifdef __wasilibc_unmodified_upstream
-#include <sys/mman.h>
-#endif
-
-static void dummy1(pthread_t t)
-{
-}
-weak_alias(dummy1, __tl_sync);
-
-static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec *at)
-{
- int state, cs, r = 0;
- __pthread_testcancel();
- __pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- if (cs == PTHREAD_CANCEL_ENABLE) __pthread_setcancelstate(cs, 0);
- while ((state = t->detach_state) && r != ETIMEDOUT && r != EINVAL) {
- if (state >= DT_DETACHED) a_crash();
- r = __timedwait_cp(&t->detach_state, state, CLOCK_REALTIME, at, 1);
- }
- __pthread_setcancelstate(cs, 0);
- if (r == ETIMEDOUT || r == EINVAL) return r;
- __tl_sync(t);
- if (res) *res = t->result;
-#ifdef __wasilibc_unmodified_upstream
- if (t->map_base) __munmap(t->map_base, t->map_size);
-#else
- if (t->map_base) free(t->map_base);
-#endif
- return 0;
-}
-
-int __pthread_join(pthread_t t, void **res)
-{
- return __pthread_timedjoin_np(t, res, 0);
-}
-
-static int __pthread_tryjoin_np(pthread_t t, void **res)
-{
- return t->detach_state==DT_JOINABLE ? EBUSY : __pthread_join(t, res);
-}
-
-weak_alias(__pthread_tryjoin_np, pthread_tryjoin_np);
-weak_alias(__pthread_timedjoin_np, pthread_timedjoin_np);
-weak_alias(__pthread_join, pthread_join);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_key_create.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_key_create.c
deleted file mode 100644
index dd47caa51d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_key_create.c
+++ /dev/null
@@ -1,95 +0,0 @@
-#include "pthread_impl.h"
-
-volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX;
-void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 };
-
-static void (*keys[PTHREAD_KEYS_MAX])(void *);
-
-static pthread_rwlock_t key_lock = PTHREAD_RWLOCK_INITIALIZER;
-
-static pthread_key_t next_key;
-
-static void nodtor(void *dummy)
-{
-}
-
-static void dummy_0(void)
-{
-}
-
-weak_alias(dummy_0, __tl_lock);
-weak_alias(dummy_0, __tl_unlock);
-
-int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
-{
- pthread_t self = __pthread_self();
-
- /* This can only happen in the main thread before
- * pthread_create has been called. */
- if (!self->tsd) self->tsd = __pthread_tsd_main;
-
- /* Purely a sentinel value since null means slot is free. */
- if (!dtor) dtor = nodtor;
-
- __pthread_rwlock_wrlock(&key_lock);
- pthread_key_t j = next_key;
- do {
- if (!keys[j]) {
- keys[next_key = *k = j] = dtor;
- __pthread_rwlock_unlock(&key_lock);
- return 0;
- }
- } while ((j=(j+1)%PTHREAD_KEYS_MAX) != next_key);
-
- __pthread_rwlock_unlock(&key_lock);
- return EAGAIN;
-}
-
-int __pthread_key_delete(pthread_key_t k)
-{
- sigset_t set;
- pthread_t self = __pthread_self(), td=self;
-
-#ifdef __wasilibc_unmodified_upstream
- __block_app_sigs(&set);
-#endif
- __pthread_rwlock_wrlock(&key_lock);
-
- __tl_lock();
- do td->tsd[k] = 0;
- while ((td=td->next)!=self);
- __tl_unlock();
-
- keys[k] = 0;
-
- __pthread_rwlock_unlock(&key_lock);
-#ifdef __wasilibc_unmodified_upstream
- __restore_sigs(&set);
-#endif
-
- return 0;
-}
-
-void __pthread_tsd_run_dtors()
-{
- pthread_t self = __pthread_self();
- int i, j;
- for (j=0; self->tsd_used && j<PTHREAD_DESTRUCTOR_ITERATIONS; j++) {
- __pthread_rwlock_rdlock(&key_lock);
- self->tsd_used = 0;
- for (i=0; i<PTHREAD_KEYS_MAX; i++) {
- void *val = self->tsd[i];
- void (*dtor)(void *) = keys[i];
- self->tsd[i] = 0;
- if (val && dtor && dtor != nodtor) {
- __pthread_rwlock_unlock(&key_lock);
- dtor(val);
- __pthread_rwlock_rdlock(&key_lock);
- }
- }
- __pthread_rwlock_unlock(&key_lock);
- }
-}
-
-weak_alias(__pthread_key_create, pthread_key_create);
-weak_alias(__pthread_key_delete, pthread_key_delete);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_kill.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_kill.c
deleted file mode 100644
index 79ddb20978..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_kill.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "pthread_impl.h"
-#include "lock.h"
-
-int pthread_kill(pthread_t t, int sig)
-{
- int r;
- sigset_t set;
- /* Block not just app signals, but internal ones too, since
- * pthread_kill is used to implement pthread_cancel, which
- * must be async-cancel-safe. */
- __block_all_sigs(&set);
- LOCK(t->killlock);
- r = t->tid ? -__syscall(SYS_tkill, t->tid, sig)
- : (sig+0U >= _NSIG ? EINVAL : 0);
- UNLOCK(t->killlock);
- __restore_sigs(&set);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_consistent.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_consistent.c
deleted file mode 100644
index 27c74e5b6a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_consistent.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-#include "atomic.h"
-
-int pthread_mutex_consistent(pthread_mutex_t *m)
-{
- int old = m->_m_lock;
- int own = old & 0x3fffffff;
- if (!(m->_m_type & 4) || !own || !(old & 0x40000000))
- return EINVAL;
- if (own != __pthread_self()->tid)
- return EPERM;
- a_and(&m->_m_lock, ~0x40000000);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_destroy.c
deleted file mode 100644
index e53c39c684..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_destroy.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutex_destroy(pthread_mutex_t *mutex)
-{
-#ifdef __wasilibc_unmodified_upstream
- /* If the mutex being destroyed is process-shared and has nontrivial
- * type (tracking ownership), it might be in the pending slot of a
- * robust_list; wait for quiescence. */
- if (mutex->_m_type > 128) __vm_wait();
-#else
- /* For now, wasi-libc chooses to avoid implementing robust mutex support
- * though this could be added later. The error code indicates that the
- * mutex was an invalid type, but it would be more accurate as
- * "unimplemented". */
- if (mutex->_m_type > 128) return EINVAL;
-#endif
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c
deleted file mode 100644
index 8c75a6612c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_getprioceiling.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutex_getprioceiling(const pthread_mutex_t *restrict m, int *restrict ceiling)
-{
- return EINVAL;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_init.c
deleted file mode 100644
index acf45a7468..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_init.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a)
-{
- *m = (pthread_mutex_t){0};
- if (a) m->_m_type = a->__attr;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_lock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_lock.c
deleted file mode 100644
index 638d4b8697..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_lock.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_mutex_lock(pthread_mutex_t *m)
-{
- if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
- && !a_cas(&m->_m_lock, 0, EBUSY))
- return 0;
-
- return __pthread_mutex_timedlock(m, 0);
-}
-
-weak_alias(__pthread_mutex_lock, pthread_mutex_lock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c
deleted file mode 100644
index 681f07c885..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_setprioceiling.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutex_setprioceiling(pthread_mutex_t *restrict m, int ceiling, int *restrict old)
-{
- return EINVAL;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c
deleted file mode 100644
index d22196a55a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c
+++ /dev/null
@@ -1,96 +0,0 @@
-#include "pthread_impl.h"
-
-#ifdef __wasilibc_unmodified_upstream
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-static int __futex4(volatile void *addr, int op, int val, const struct timespec *to)
-{
-#ifdef SYS_futex_time64
- time_t s = to ? to->tv_sec : 0;
- long ns = to ? to->tv_nsec : 0;
- int r = -ENOSYS;
- if (SYS_futex == SYS_futex_time64 || !IS32BIT(s))
- r = __syscall(SYS_futex_time64, addr, op, val,
- to ? ((long long[]){s, ns}) : 0);
- if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r;
- to = to ? (void *)(long[]){CLAMP(s), ns} : 0;
-#endif
- return __syscall(SYS_futex, addr, op, val, to);
-}
-
-static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct timespec *restrict at)
-{
- int type = m->_m_type;
- int priv = (type & 128) ^ 128;
- pthread_t self = __pthread_self();
- int e;
-
- if (!priv) self->robust_list.pending = &m->_m_next;
-
- do e = -__futex4(&m->_m_lock, FUTEX_LOCK_PI|priv, 0, at);
- while (e==EINTR);
- if (e) self->robust_list.pending = 0;
-
- switch (e) {
- case 0:
- /* Catch spurious success for non-robust mutexes. */
- if (!(type&4) && ((m->_m_lock & 0x40000000) || m->_m_waiters)) {
- a_store(&m->_m_waiters, -1);
- __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
- self->robust_list.pending = 0;
- break;
- }
- /* Signal to trylock that we already have the lock. */
- m->_m_count = -1;
- return __pthread_mutex_trylock(m);
- case ETIMEDOUT:
- return e;
- case EDEADLK:
- if ((type&3) == PTHREAD_MUTEX_ERRORCHECK) return e;
- }
- do e = __timedwait(&(int){0}, 0, CLOCK_REALTIME, at, 1);
- while (e != ETIMEDOUT);
- return e;
-}
-#endif
-
-int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
-{
- if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
- && !a_cas(&m->_m_lock, 0, EBUSY))
- return 0;
-
- int type = m->_m_type;
- int r, t, priv = (type & 128) ^ 128;
-
- r = __pthread_mutex_trylock(m);
- if (r != EBUSY) return r;
-
-#ifdef __wasilibc_unmodified_upstream
- if (type&8) return pthread_mutex_timedlock_pi(m, at);
-#endif
-
- int spins = 100;
- while (spins-- && m->_m_lock && !m->_m_waiters) a_spin();
-
- while ((r=__pthread_mutex_trylock(m)) == EBUSY) {
- r = m->_m_lock;
- int own = r & 0x3fffffff;
- if (!own && (!r || (type&4)))
- continue;
- if ((type&3) == PTHREAD_MUTEX_ERRORCHECK
- && own == __pthread_self()->tid)
- return EDEADLK;
-
- a_inc(&m->_m_waiters);
- t = r | 0x80000000;
- a_cas(&m->_m_lock, r, t);
- r = __timedwait(&m->_m_lock, t, CLOCK_REALTIME, at, priv);
- a_dec(&m->_m_waiters);
- if (r && r != EINTR) break;
- }
- return r;
-}
-
-weak_alias(__pthread_mutex_timedlock, pthread_mutex_timedlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_trylock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_trylock.c
deleted file mode 100644
index c60b45feef..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_trylock.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_mutex_trylock_owner(pthread_mutex_t *m)
-{
- int old, own;
- int type = m->_m_type;
- pthread_t self = __pthread_self();
- int tid = self->tid;
-
- old = m->_m_lock;
- own = old & 0x3fffffff;
- if (own == tid) {
- if ((type&8) && m->_m_count<0) {
- old &= 0x40000000;
- m->_m_count = 0;
- goto success;
- }
- if ((type&3) == PTHREAD_MUTEX_RECURSIVE) {
- if ((unsigned)m->_m_count >= INT_MAX) return EAGAIN;
- m->_m_count++;
- return 0;
- }
- }
- if (own == 0x3fffffff) return ENOTRECOVERABLE;
- if (own || (old && !(type & 4))) return EBUSY;
-
- if (type & 128) {
- if (!self->robust_list.off) {
- self->robust_list.off = (char*)&m->_m_lock-(char *)&m->_m_next;
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_set_robust_list, &self->robust_list, 3*sizeof(long));
-#endif
- }
- if (m->_m_waiters) tid |= 0x80000000;
- self->robust_list.pending = &m->_m_next;
- }
- tid |= old & 0x40000000;
-
- if (a_cas(&m->_m_lock, old, tid) != old) {
- self->robust_list.pending = 0;
- if ((type&12)==12 && m->_m_waiters) return ENOTRECOVERABLE;
- return EBUSY;
- }
-
-success:
- if ((type&8) && m->_m_waiters) {
- int priv = (type & 128) ^ 128;
-#ifdef __wasilibc_unmodified_upstream
- __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
-#endif
- self->robust_list.pending = 0;
- return (type&4) ? ENOTRECOVERABLE : EBUSY;
- }
-
- volatile void *next = self->robust_list.head;
- m->_m_next = next;
- m->_m_prev = &self->robust_list.head;
- if (next != &self->robust_list.head) *(volatile void *volatile *)
- ((char *)next - sizeof(void *)) = &m->_m_next;
- self->robust_list.head = &m->_m_next;
- self->robust_list.pending = 0;
-
- if (old) {
- m->_m_count = 0;
- return EOWNERDEAD;
- }
-
- return 0;
-}
-
-int __pthread_mutex_trylock(pthread_mutex_t *m)
-{
- if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL)
- return a_cas(&m->_m_lock, 0, EBUSY) & EBUSY;
- return __pthread_mutex_trylock_owner(m);
-}
-
-weak_alias(__pthread_mutex_trylock, pthread_mutex_trylock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_unlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_unlock.c
deleted file mode 100644
index 6beaacbc64..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutex_unlock.c
+++ /dev/null
@@ -1,60 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_mutex_unlock(pthread_mutex_t *m)
-{
- pthread_t self;
- int waiters = m->_m_waiters;
- int cont;
- int type = m->_m_type & 15;
- int priv = (m->_m_type & 128) ^ 128;
- int new = 0;
- int old;
-
- if (type != PTHREAD_MUTEX_NORMAL) {
- self = __pthread_self();
- old = m->_m_lock;
- int own = old & 0x3fffffff;
- if (own != self->tid)
- return EPERM;
- if ((type&3) == PTHREAD_MUTEX_RECURSIVE && m->_m_count)
- return m->_m_count--, 0;
- if ((type&4) && (old&0x40000000))
- new = 0x7fffffff;
- if (!priv) {
- self->robust_list.pending = &m->_m_next;
-#ifdef __wasilibc_unmodified_upstream
- __vm_lock();
-#endif
- }
- volatile void *prev = m->_m_prev;
- volatile void *next = m->_m_next;
- *(volatile void *volatile *)prev = next;
- if (next != &self->robust_list.head) *(volatile void *volatile *)
- ((char *)next - sizeof(void *)) = prev;
- }
-#ifdef __wasilibc_unmodified_upstream
- if (type&8) {
- if (old<0 || a_cas(&m->_m_lock, old, new)!=old) {
- if (new) a_store(&m->_m_waiters, -1);
- __syscall(SYS_futex, &m->_m_lock, FUTEX_UNLOCK_PI|priv);
- }
- cont = 0;
- waiters = 0;
- } else {
- cont = a_swap(&m->_m_lock, new);
- }
-#else
- cont = a_swap(&m->_m_lock, new);
-#endif
- if (type != PTHREAD_MUTEX_NORMAL && !priv) {
- self->robust_list.pending = 0;
-#ifdef __wasilibc_unmodified_upstream
- __vm_unlock();
-#endif
- }
- if (waiters || cont<0)
- __wake(&m->_m_lock, 1, priv);
- return 0;
-}
-
-weak_alias(__pthread_mutex_unlock, pthread_mutex_unlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c
deleted file mode 100644
index 9fd6974727..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutexattr_destroy(pthread_mutexattr_t *a)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_init.c
deleted file mode 100644
index 0b72c1ba5f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutexattr_init(pthread_mutexattr_t *a)
-{
- *a = (pthread_mutexattr_t){0};
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c
deleted file mode 100644
index 84b02ba130..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setprotocol.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "pthread_impl.h"
-#include "syscall.h"
-
-static volatile int check_pi_result = -1;
-
-int pthread_mutexattr_setprotocol(pthread_mutexattr_t *a, int protocol)
-{
- int r;
- switch (protocol) {
- case PTHREAD_PRIO_NONE:
- a->__attr &= ~8;
- return 0;
- case PTHREAD_PRIO_INHERIT:
-#ifdef __wasilibc_unmodified_upstream
- r = check_pi_result;
- if (r < 0) {
- volatile int lk = 0;
- r = -__syscall(SYS_futex, &lk, FUTEX_LOCK_PI, 0, 0);
- a_store(&check_pi_result, r);
- }
- if (r) return r;
- a->__attr |= 8;
- return 0;
-#else
- return ENOTSUP;
-#endif
- case PTHREAD_PRIO_PROTECT:
- return ENOTSUP;
- default:
- return EINVAL;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c
deleted file mode 100644
index 100f6ff203..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setpshared.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutexattr_setpshared(pthread_mutexattr_t *a, int pshared)
-{
- if (pshared > 1U) return EINVAL;
- a->__attr &= ~128U;
- a->__attr |= pshared<<7;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c
deleted file mode 100644
index 649a89130c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "pthread_impl.h"
-#include "syscall.h"
-
-static volatile int check_robust_result = -1;
-
-int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust)
-{
-#ifdef __wasilibc_unmodified_upstream
- if (robust > 1U) return EINVAL;
- if (robust) {
- int r = check_robust_result;
- if (r < 0) {
- void *p;
- size_t l;
- r = -__syscall(SYS_get_robust_list, 0, &p, &l);
- a_store(&check_robust_result, r);
- }
- if (r) return r;
- a->__attr |= 4;
- return 0;
- }
- a->__attr &= ~4;
- return 0;
-#else
- return EINVAL;
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_settype.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_settype.c
deleted file mode 100644
index cd7a80e342..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_mutexattr_settype.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_mutexattr_settype(pthread_mutexattr_t *a, int type)
-{
- if ((unsigned)type > 2) return EINVAL;
- a->__attr = (a->__attr & ~3) | type;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_once.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_once.c
deleted file mode 100644
index 8e8d40ae83..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_once.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "pthread_impl.h"
-
-static void undo(void *control)
-{
- /* Wake all waiters, since the waiter status is lost when
- * resetting control to the initial state. */
- if (a_swap(control, 0) == 3)
- __wake(control, -1, 1);
-}
-
-hidden int __pthread_once_full(pthread_once_t *control, void (*init)(void))
-{
- /* Try to enter initializing state. Four possibilities:
- * 0 - we're the first or the other cancelled; run init
- * 1 - another thread is running init; wait
- * 2 - another thread finished running init; just return
- * 3 - another thread is running init, waiters present; wait */
-
- for (;;) switch (a_cas(control, 0, 1)) {
- case 0:
- pthread_cleanup_push(undo, control);
- init();
- pthread_cleanup_pop(0);
-
- if (a_swap(control, 2) == 3)
- __wake(control, -1, 1);
- return 0;
- case 1:
- /* If this fails, so will __wait. */
- a_cas(control, 1, 3);
- case 3:
- __wait(control, 0, 3, 1);
- continue;
- case 2:
- return 0;
- }
-}
-
-int __pthread_once(pthread_once_t *control, void (*init)(void))
-{
- /* Return immediately if init finished before, but ensure that
- * effects of the init routine are visible to the caller. */
- if (*(volatile int *)control == 2) {
- a_barrier();
- return 0;
- }
- return __pthread_once_full(control, init);
-}
-
-weak_alias(__pthread_once, pthread_once);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_destroy.c
deleted file mode 100644
index 49ecfbd028..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_rwlock_destroy(pthread_rwlock_t *rw)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_init.c
deleted file mode 100644
index a2c0b478c7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_init.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a)
-{
- *rw = (pthread_rwlock_t){0};
- if (a) rw->_rw_shared = a->__attr[0]*128;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c
deleted file mode 100644
index 8546c07d2e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_rdlock.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_rdlock(pthread_rwlock_t *rw)
-{
- return __pthread_rwlock_timedrdlock(rw, 0);
-}
-
-weak_alias(__pthread_rwlock_rdlock, pthread_rwlock_rdlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c
deleted file mode 100644
index 8cdd8ecf17..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedrdlock.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
-{
- int r, t;
-
- r = pthread_rwlock_tryrdlock(rw);
- if (r != EBUSY) return r;
-
- int spins = 100;
- while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();
-
- while ((r=__pthread_rwlock_tryrdlock(rw))==EBUSY) {
- if (!(r=rw->_rw_lock) || (r&0x7fffffff)!=0x7fffffff) continue;
- t = r | 0x80000000;
- a_inc(&rw->_rw_waiters);
- a_cas(&rw->_rw_lock, r, t);
- r = __timedwait(&rw->_rw_lock, t, CLOCK_REALTIME, at, rw->_rw_shared^128);
- a_dec(&rw->_rw_waiters);
- if (r && r != EINTR) return r;
- }
- return r;
-}
-
-weak_alias(__pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c
deleted file mode 100644
index d77706e6bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_timedwrlock.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at)
-{
- int r, t;
-
- r = pthread_rwlock_trywrlock(rw);
- if (r != EBUSY) return r;
-
- int spins = 100;
- while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();
-
- while ((r=__pthread_rwlock_trywrlock(rw))==EBUSY) {
- if (!(r=rw->_rw_lock)) continue;
- t = r | 0x80000000;
- a_inc(&rw->_rw_waiters);
- a_cas(&rw->_rw_lock, r, t);
- r = __timedwait(&rw->_rw_lock, t, CLOCK_REALTIME, at, rw->_rw_shared^128);
- a_dec(&rw->_rw_waiters);
- if (r && r != EINTR) return r;
- }
- return r;
-}
-
-weak_alias(__pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c
deleted file mode 100644
index c13bc9cc19..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_tryrdlock.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
-{
- int val, cnt;
- do {
- val = rw->_rw_lock;
- cnt = val & 0x7fffffff;
- if (cnt == 0x7fffffff) return EBUSY;
- if (cnt == 0x7ffffffe) return EAGAIN;
- } while (a_cas(&rw->_rw_lock, val, val+1) != val);
- return 0;
-}
-
-weak_alias(__pthread_rwlock_tryrdlock, pthread_rwlock_tryrdlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c
deleted file mode 100644
index 64d9d3121a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_trywrlock.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
-{
- if (a_cas(&rw->_rw_lock, 0, 0x7fffffff)) return EBUSY;
- return 0;
-}
-
-weak_alias(__pthread_rwlock_trywrlock, pthread_rwlock_trywrlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_unlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_unlock.c
deleted file mode 100644
index 9ae27ad2b3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_unlock.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_unlock(pthread_rwlock_t *rw)
-{
- int val, cnt, waiters, new, priv = rw->_rw_shared^128;
-
- do {
- val = rw->_rw_lock;
- cnt = val & 0x7fffffff;
- waiters = rw->_rw_waiters;
- new = (cnt == 0x7fffffff || cnt == 1) ? 0 : val-1;
- } while (a_cas(&rw->_rw_lock, val, new) != val);
-
- if (!new && (waiters || val<0))
- __wake(&rw->_rw_lock, cnt, priv);
-
- return 0;
-}
-
-weak_alias(__pthread_rwlock_unlock, pthread_rwlock_unlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c
deleted file mode 100644
index 46a3b3a5b0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlock_wrlock.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_rwlock_wrlock(pthread_rwlock_t *rw)
-{
- return __pthread_rwlock_timedwrlock(rw, 0);
-}
-
-weak_alias(__pthread_rwlock_wrlock, pthread_rwlock_wrlock);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c
deleted file mode 100644
index fc8d611aea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_rwlockattr_destroy(pthread_rwlockattr_t *a)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_init.c
deleted file mode 100644
index e742069447..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_init.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_rwlockattr_init(pthread_rwlockattr_t *a)
-{
- *a = (pthread_rwlockattr_t){0};
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c
deleted file mode 100644
index e7061973d6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_rwlockattr_setpshared.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int pshared)
-{
- if (pshared > 1U) return EINVAL;
- a->__attr[0] = pshared;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_self.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_self.c
deleted file mode 100644
index 1f3eee1d16..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_self.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-#if !defined(__wasilibc_unmodified_upstream) && defined(__wasm__) && \
- defined(_REENTRANT)
-_Thread_local struct pthread __wasilibc_pthread_self;
-#endif
-
-static pthread_t __pthread_self_internal()
-{
- return __pthread_self();
-}
-
-weak_alias(__pthread_self_internal, pthread_self);
-weak_alias(__pthread_self_internal, thrd_current);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setattr_default_np.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setattr_default_np.c
deleted file mode 100644
index 58486220e0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setattr_default_np.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#define _GNU_SOURCE
-#include "pthread_impl.h"
-#include <string.h>
-
-#define MIN(a,b) ((a)<(b) ? (a) : (b))
-#define MAX(a,b) ((a)>(b) ? (a) : (b))
-
-int pthread_setattr_default_np(const pthread_attr_t *attrp)
-{
- /* Reject anything in the attr object other than stack/guard size. */
- pthread_attr_t tmp = *attrp, zero = { 0 };
- tmp._a_stacksize = 0;
- tmp._a_guardsize = 0;
- if (memcmp(&tmp, &zero, sizeof tmp))
- return EINVAL;
-
- unsigned stack = MIN(attrp->_a_stacksize, DEFAULT_STACK_MAX);
- unsigned guard = MIN(attrp->_a_guardsize, DEFAULT_GUARD_MAX);
-
- __inhibit_ptc();
- __default_stacksize = MAX(__default_stacksize, stack);
- __default_guardsize = MAX(__default_guardsize, guard);
- __release_ptc();
-
- return 0;
-}
-
-int pthread_getattr_default_np(pthread_attr_t *attrp)
-{
- __acquire_ptc();
- *attrp = (pthread_attr_t) {
- ._a_stacksize = __default_stacksize,
- ._a_guardsize = __default_guardsize,
- };
- __release_ptc();
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcancelstate.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcancelstate.c
deleted file mode 100644
index 4f7a00e585..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcancelstate.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-
-int __pthread_setcancelstate(int new, int *old)
-{
-#if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT)
- if (new > 2U) return EINVAL;
- struct pthread *self = __pthread_self();
- if (old) *old = self->canceldisable;
- self->canceldisable = new;
-#endif
- return 0;
-}
-
-weak_alias(__pthread_setcancelstate, pthread_setcancelstate);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcanceltype.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcanceltype.c
deleted file mode 100644
index bf0a3f383d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setcanceltype.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_setcanceltype(int new, int *old)
-{
- struct pthread *self = __pthread_self();
- if (new > 1U) return EINVAL;
- if (old) *old = self->cancelasync;
- self->cancelasync = new;
- if (new) pthread_testcancel();
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setconcurrency.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setconcurrency.c
deleted file mode 100644
index 091abf98c8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setconcurrency.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <pthread.h>
-#include <errno.h>
-
-int pthread_setconcurrency(int val)
-{
- if (val < 0) return EINVAL;
- if (val > 0) return EAGAIN;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setname_np.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setname_np.c
deleted file mode 100644
index fc2d230618..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setname_np.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#define _GNU_SOURCE
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/prctl.h>
-
-#include "pthread_impl.h"
-
-int pthread_setname_np(pthread_t thread, const char *name)
-{
- int fd, cs, status = 0;
- char f[sizeof "/proc/self/task//comm" + 3*sizeof(int)];
- size_t len;
-
- if ((len = strnlen(name, 16)) > 15) return ERANGE;
-
- if (thread == pthread_self())
- return prctl(PR_SET_NAME, (unsigned long)name, 0UL, 0UL, 0UL) ? errno : 0;
-
- snprintf(f, sizeof f, "/proc/self/task/%d/comm", thread->tid);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
- if ((fd = open(f, O_WRONLY|O_CLOEXEC)) < 0 || write(fd, name, len) < 0) status = errno;
- if (fd >= 0) close(fd);
- pthread_setcancelstate(cs, 0);
- return status;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedparam.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedparam.c
deleted file mode 100644
index 76d4d45a3c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedparam.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-#include "lock.h"
-
-int pthread_setschedparam(pthread_t t, int policy, const struct sched_param *param)
-{
- int r;
- sigset_t set;
- __block_app_sigs(&set);
- LOCK(t->killlock);
- r = !t->tid ? ESRCH : -__syscall(SYS_sched_setscheduler, t->tid, policy, param);
- UNLOCK(t->killlock);
- __restore_sigs(&set);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedprio.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedprio.c
deleted file mode 100644
index fc2e13ddb3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setschedprio.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-#include "lock.h"
-
-int pthread_setschedprio(pthread_t t, int prio)
-{
- int r;
- sigset_t set;
- __block_app_sigs(&set);
- LOCK(t->killlock);
- r = !t->tid ? ESRCH : -__syscall(SYS_sched_setparam, t->tid, &prio);
- UNLOCK(t->killlock);
- __restore_sigs(&set);
- return r;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setspecific.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setspecific.c
deleted file mode 100644
index 55e46a8993..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_setspecific.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_setspecific(pthread_key_t k, const void *x)
-{
- struct pthread *self = __pthread_self();
- /* Avoid unnecessary COW */
- if (self->tsd[k] != x) {
- self->tsd[k] = (void *)x;
- self->tsd_used = 1;
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_sigmask.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_sigmask.c
deleted file mode 100644
index f188782a32..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_sigmask.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <signal.h>
-#include <errno.h>
-#include "syscall.h"
-
-int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
-{
- int ret;
- if (set && (unsigned)how - SIG_BLOCK > 2U) return EINVAL;
- ret = -__syscall(SYS_rt_sigprocmask, how, set, old, _NSIG/8);
- if (!ret && old) {
- if (sizeof old->__bits[0] == 8) {
- old->__bits[0] &= ~0x380000000ULL;
- } else {
- old->__bits[0] &= ~0x80000000UL;
- old->__bits[1] &= ~0x3UL;
- }
- }
- return ret;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_destroy.c
deleted file mode 100644
index e65a820c3d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_spin_destroy(pthread_spinlock_t *s)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_init.c
deleted file mode 100644
index 681881cf36..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_spin_init(pthread_spinlock_t *s, int shared)
-{
- return *s = 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_lock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_lock.c
deleted file mode 100644
index ded2b653c4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_lock.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "pthread_impl.h"
-#include <errno.h>
-
-int pthread_spin_lock(pthread_spinlock_t *s)
-{
- while (*(volatile int *)s || a_cas(s, 0, EBUSY)) a_spin();
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_trylock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_trylock.c
deleted file mode 100644
index 5284fdac24..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_trylock.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-#include <errno.h>
-
-int pthread_spin_trylock(pthread_spinlock_t *s)
-{
- return a_cas(s, 0, EBUSY);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_unlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_unlock.c
deleted file mode 100644
index 724d9e0d65..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_spin_unlock.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "pthread_impl.h"
-
-int pthread_spin_unlock(pthread_spinlock_t *s)
-{
- a_store(s, 0);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_testcancel.c b/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_testcancel.c
deleted file mode 100644
index d772449d94..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/pthread_testcancel.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "pthread_impl.h"
-
-static void dummy()
-{
-}
-
-weak_alias(dummy, __testcancel);
-
-void __pthread_testcancel()
-{
- __testcancel();
-}
-
-weak_alias(__pthread_testcancel, pthread_testcancel);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s
deleted file mode 100644
index 828154d297..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__set_thread_area.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.global __set_thread_area
-.type __set_thread_area, %function
-__set_thread_area:
- mv tp, a0
- li a0, 0
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__unmapself.s
deleted file mode 100644
index 2849119c39..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/__unmapself.s
+++ /dev/null
@@ -1,7 +0,0 @@
-.global __unmapself
-.type __unmapself, %function
-__unmapself:
- li a7, 215 # SYS_munmap
- ecall
- li a7, 93 # SYS_exit
- ecall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/clone.s
deleted file mode 100644
index db908248cd..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/clone.s
+++ /dev/null
@@ -1,34 +0,0 @@
-# __clone(func, stack, flags, arg, ptid, tls, ctid)
-# a0, a1, a2, a3, a4, a5, a6
-
-# syscall(SYS_clone, flags, stack, ptid, tls, ctid)
-# a7 a0, a1, a2, a3, a4
-
-.global __clone
-.type __clone, %function
-__clone:
- # Save func and arg to stack
- addi a1, a1, -16
- sd a0, 0(a1)
- sd a3, 8(a1)
-
- # Call SYS_clone
- mv a0, a2
- mv a2, a4
- mv a3, a5
- mv a4, a6
- li a7, 220 # SYS_clone
- ecall
-
- beqz a0, 1f
- # Parent
- ret
-
- # Child
-1: ld a1, 0(sp)
- ld a0, 8(sp)
- jalr a1
-
- # Exit
- li a7, 93 # SYS_exit
- ecall
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/syscall_cp.s
deleted file mode 100644
index eeef6391bf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/riscv64/syscall_cp.s
+++ /dev/null
@@ -1,29 +0,0 @@
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm, %function
-__syscall_cp_asm:
-__cp_begin:
- lw t0, 0(a0)
- bnez t0, __cp_cancel
-
- mv t0, a1
- mv a0, a2
- mv a1, a3
- mv a2, a4
- mv a3, a5
- mv a4, a6
- mv a5, a7
- ld a6, 0(sp)
- mv a7, t0
- ecall
-__cp_end:
- ret
-__cp_cancel:
- tail __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__set_thread_area.s
deleted file mode 100644
index 00a11e2544..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__set_thread_area.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area, %function
-__set_thread_area:
- sar %a1, %r2
- srlg %r2, %r2, 32
- sar %a0, %r2
- lghi %r2, 0
- br %r14
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s b/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s
deleted file mode 100644
index 8ee92de8ea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__tls_get_offset.s
+++ /dev/null
@@ -1,17 +0,0 @@
- .global __tls_get_offset
- .type __tls_get_offset,%function
-__tls_get_offset:
- stmg %r14, %r15, 112(%r15)
- aghi %r15, -160
-
- la %r2, 0(%r2, %r12)
- brasl %r14, __tls_get_addr
-
- ear %r1, %a0
- sllg %r1, %r1, 32
- ear %r1, %a1
-
- sgr %r2, %r1
-
- lmg %r14, %r15, 272(%r15)
- br %r14
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__unmapself.s
deleted file mode 100644
index 48b312cd30..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/__unmapself.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.text
-.global __unmapself
-.type __unmapself, @function
-__unmapself:
- svc 91 # SYS_munmap
- svc 1 # SYS_exit
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/clone.s
deleted file mode 100644
index 2125f20b83..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/clone.s
+++ /dev/null
@@ -1,54 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone, %function
-__clone:
- # int clone(
- # fn, a = r2
- # stack, b = r3
- # flags, c = r4
- # arg, d = r5
- # ptid, e = r6
- # tls, f = *(r15+160)
- # ctid) g = *(r15+168)
- #
- # pseudo C code:
- # tid = syscall(SYS_clone,b,c,e,g,f);
- # if (!tid) syscall(SYS_exit, a(d));
- # return tid;
-
- # preserve call-saved register used as syscall arg
- stg %r6, 48(%r15)
-
- # create initial stack frame for new thread
- nill %r3, 0xfff8
- aghi %r3, -160
- lghi %r0, 0
- stg %r0, 0(%r3)
-
- # save fn and arg to child stack
- stg %r2, 8(%r3)
- stg %r5, 16(%r3)
-
- # shuffle args into correct registers and call SYS_clone
- lgr %r2, %r3
- lgr %r3, %r4
- lgr %r4, %r6
- lg %r5, 168(%r15)
- lg %r6, 160(%r15)
- svc 120
-
- # restore call-saved register
- lg %r6, 48(%r15)
-
- # if error or if we're the parent, return
- ltgr %r2, %r2
- bnzr %r14
-
- # we're the child. call fn(arg)
- lg %r1, 8(%r15)
- lg %r2, 16(%r15)
- basr %r14, %r1
-
- # call SYS_exit. exit code is already in r2 from fn return value
- svc 1
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/syscall_cp.s
deleted file mode 100644
index d094cbf5ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/s390x/syscall_cp.s
+++ /dev/null
@@ -1,34 +0,0 @@
- .global __cp_begin
- .hidden __cp_begin
- .global __cp_end
- .hidden __cp_end
- .global __cp_cancel
- .hidden __cp_cancel
- .hidden __cancel
- .global __syscall_cp_asm
- .hidden __syscall_cp_asm
- .text
- .type __syscall_cp_asm,%function
-__syscall_cp_asm:
-__cp_begin:
- icm %r2, 15, 0(%r2)
- jne __cp_cancel
-
- stg %r6, 48(%r15)
- stg %r7, 56(%r15)
- lgr %r1, %r3
- lgr %r2, %r4
- lgr %r3, %r5
- lgr %r4, %r6
- lg %r5, 160(%r15)
- lg %r6, 168(%r15)
- lg %r7, 176(%r15)
- svc 0
-
-__cp_end:
- lg %r7, 56(%r15)
- lg %r6, 48(%r15)
- br %r14
-
-__cp_cancel:
- jg __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_destroy.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_destroy.c
deleted file mode 100644
index f4aced5da9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_destroy.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <semaphore.h>
-
-int sem_destroy(sem_t *sem)
-{
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_getvalue.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_getvalue.c
deleted file mode 100644
index d9d8307177..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_getvalue.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <semaphore.h>
-
-int sem_getvalue(sem_t *restrict sem, int *restrict valp)
-{
- int val = sem->__val[0];
- *valp = val < 0 ? 0 : val;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_init.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_init.c
deleted file mode 100644
index 5509243438..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_init.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <semaphore.h>
-#include <limits.h>
-#include <errno.h>
-
-int sem_init(sem_t *sem, int pshared, unsigned value)
-{
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- return -1;
- }
- sem->__val[0] = value;
- sem->__val[1] = 0;
- sem->__val[2] = pshared ? 0 : 128;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_open.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_open.c
deleted file mode 100644
index 0ad29de96c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_open.c
+++ /dev/null
@@ -1,182 +0,0 @@
-#include <semaphore.h>
-#include <sys/mman.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-#include <time.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include "lock.h"
-#include "fork_impl.h"
-
-#define malloc __libc_malloc
-#define calloc __libc_calloc
-#define realloc undef
-#define free undef
-
-static struct {
- ino_t ino;
- sem_t *sem;
- int refcnt;
-} *semtab;
-static volatile int lock[1];
-volatile int *const __sem_open_lockptr = lock;
-
-#define FLAGS (O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK)
-
-sem_t *sem_open(const char *name, int flags, ...)
-{
- va_list ap;
- mode_t mode;
- unsigned value;
- int fd, i, e, slot, first=1, cnt, cs;
- sem_t newsem;
- void *map;
- char tmp[64];
- struct timespec ts;
- struct stat st;
- char buf[NAME_MAX+10];
-
- if (!(name = __shm_mapname(name, buf)))
- return SEM_FAILED;
-
- LOCK(lock);
- /* Allocate table if we don't have one yet */
- if (!semtab && !(semtab = calloc(sizeof *semtab, SEM_NSEMS_MAX))) {
- UNLOCK(lock);
- return SEM_FAILED;
- }
-
- /* Reserve a slot in case this semaphore is not mapped yet;
- * this is necessary because there is no way to handle
- * failures after creation of the file. */
- slot = -1;
- for (cnt=i=0; i<SEM_NSEMS_MAX; i++) {
- cnt += semtab[i].refcnt;
- if (!semtab[i].sem && slot < 0) slot = i;
- }
- /* Avoid possibility of overflow later */
- if (cnt == INT_MAX || slot < 0) {
- errno = EMFILE;
- UNLOCK(lock);
- return SEM_FAILED;
- }
- /* Dummy pointer to make a reservation */
- semtab[slot].sem = (sem_t *)-1;
- UNLOCK(lock);
-
- flags &= (O_CREAT|O_EXCL);
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- /* Early failure check for exclusive open; otherwise the case
- * where the semaphore already exists is expensive. */
- if (flags == (O_CREAT|O_EXCL) && access(name, F_OK) == 0) {
- errno = EEXIST;
- goto fail;
- }
-
- for (;;) {
- /* If exclusive mode is not requested, try opening an
- * existing file first and fall back to creation. */
- if (flags != (O_CREAT|O_EXCL)) {
- fd = open(name, FLAGS);
- if (fd >= 0) {
- if (fstat(fd, &st) < 0 ||
- (map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
- close(fd);
- goto fail;
- }
- close(fd);
- break;
- }
- if (errno != ENOENT)
- goto fail;
- }
- if (!(flags & O_CREAT))
- goto fail;
- if (first) {
- first = 0;
- va_start(ap, flags);
- mode = va_arg(ap, mode_t) & 0666;
- value = va_arg(ap, unsigned);
- va_end(ap);
- if (value > SEM_VALUE_MAX) {
- errno = EINVAL;
- goto fail;
- }
- sem_init(&newsem, 1, value);
- }
- /* Create a temp file with the new semaphore contents
- * and attempt to atomically link it as the new name */
- clock_gettime(CLOCK_REALTIME, &ts);
- snprintf(tmp, sizeof(tmp), "/dev/shm/tmp-%d", (int)ts.tv_nsec);
- fd = open(tmp, O_CREAT|O_EXCL|FLAGS, mode);
- if (fd < 0) {
- if (errno == EEXIST) continue;
- goto fail;
- }
- if (write(fd, &newsem, sizeof newsem) != sizeof newsem || fstat(fd, &st) < 0 ||
- (map = mmap(0, sizeof(sem_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
- close(fd);
- unlink(tmp);
- goto fail;
- }
- close(fd);
- e = link(tmp, name) ? errno : 0;
- unlink(tmp);
- if (!e) break;
- munmap(map, sizeof(sem_t));
- /* Failure is only fatal when doing an exclusive open;
- * otherwise, next iteration will try to open the
- * existing file. */
- if (e != EEXIST || flags == (O_CREAT|O_EXCL))
- goto fail;
- }
-
- /* See if the newly mapped semaphore is already mapped. If
- * so, unmap the new mapping and use the existing one. Otherwise,
- * add it to the table of mapped semaphores. */
- LOCK(lock);
- for (i=0; i<SEM_NSEMS_MAX && semtab[i].ino != st.st_ino; i++);
- if (i<SEM_NSEMS_MAX) {
- munmap(map, sizeof(sem_t));
- semtab[slot].sem = 0;
- slot = i;
- map = semtab[i].sem;
- }
- semtab[slot].refcnt++;
- semtab[slot].sem = map;
- semtab[slot].ino = st.st_ino;
- UNLOCK(lock);
- pthread_setcancelstate(cs, 0);
- return map;
-
-fail:
- pthread_setcancelstate(cs, 0);
- LOCK(lock);
- semtab[slot].sem = 0;
- UNLOCK(lock);
- return SEM_FAILED;
-}
-
-int sem_close(sem_t *sem)
-{
- int i;
- LOCK(lock);
- for (i=0; i<SEM_NSEMS_MAX && semtab[i].sem != sem; i++);
- if (--semtab[i].refcnt) {
- UNLOCK(lock);
- return 0;
- }
- semtab[i].sem = 0;
- semtab[i].ino = 0;
- UNLOCK(lock);
- munmap(sem, sizeof *sem);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_post.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_post.c
deleted file mode 100644
index 31e3293d20..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_post.c
+++ /dev/null
@@ -1,17 +0,0 @@
-#include <semaphore.h>
-#include "pthread_impl.h"
-
-int sem_post(sem_t *sem)
-{
- int val, waiters, priv = sem->__val[2];
- do {
- val = sem->__val[0];
- waiters = sem->__val[1];
- if (val == SEM_VALUE_MAX) {
- errno = EOVERFLOW;
- return -1;
- }
- } while (a_cas(sem->__val, val, val+1+(val<0)) != val);
- if (val<0 || waiters) __wake(sem->__val, 1, priv);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_timedwait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_timedwait.c
deleted file mode 100644
index 58d3ebfefc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_timedwait.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <semaphore.h>
-#include "pthread_impl.h"
-
-static void cleanup(void *p)
-{
- a_dec(p);
-}
-
-int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at)
-{
- pthread_testcancel();
-
- if (!sem_trywait(sem)) return 0;
-
- int spins = 100;
- while (spins-- && sem->__val[0] <= 0 && !sem->__val[1]) a_spin();
-
- while (sem_trywait(sem)) {
- int r;
- a_inc(sem->__val+1);
- a_cas(sem->__val, 0, -1);
- pthread_cleanup_push(cleanup, (void *)(sem->__val+1));
- r = __timedwait_cp(sem->__val, -1, CLOCK_REALTIME, at, sem->__val[2]);
- pthread_cleanup_pop(1);
- if (r) {
- errno = r;
- return -1;
- }
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_trywait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_trywait.c
deleted file mode 100644
index 04edf46b52..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_trywait.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <semaphore.h>
-#include "pthread_impl.h"
-
-int sem_trywait(sem_t *sem)
-{
- int val;
- while ((val=sem->__val[0]) > 0) {
- int new = val-1-(val==1 && sem->__val[1]);
- if (a_cas(sem->__val, val, new)==val) return 0;
- }
- errno = EAGAIN;
- return -1;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_unlink.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_unlink.c
deleted file mode 100644
index c06134bd49..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_unlink.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <semaphore.h>
-#include <sys/mman.h>
-
-int sem_unlink(const char *name)
-{
- return shm_unlink(name);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_wait.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sem_wait.c
deleted file mode 100644
index 264194f97c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sem_wait.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <semaphore.h>
-
-int sem_wait(sem_t *sem)
-{
- return sem_timedwait(sem, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__set_thread_area.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__set_thread_area.c
deleted file mode 100644
index 34264bddd9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__set_thread_area.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "pthread_impl.h"
-#include "libc.h"
-#include <elf.h>
-
-/* Also perform sh-specific init */
-
-#define CPU_HAS_LLSC 0x0040
-#define CPU_HAS_CAS_L 0x0400
-
-extern hidden const char __sh_cas_gusa[], __sh_cas_llsc[], __sh_cas_imask[], __sh_cas_cas_l[];
-
-hidden const void *__sh_cas_ptr;
-
-hidden unsigned __sh_nommu;
-
-int __set_thread_area(void *p)
-{
- size_t *aux;
- __asm__ __volatile__ ( "ldc %0, gbr" : : "r"(p) : "memory" );
-#ifndef __SH4A__
- __sh_cas_ptr = __sh_cas_gusa;
-#if !defined(__SH3__) && !defined(__SH4__)
- for (aux=libc.auxv; *aux; aux+=2) {
- if (*aux != AT_PLATFORM) continue;
- const char *s = (void *)aux[1];
- if (s[0]!='s' || s[1]!='h' || s[2]!='2' || s[3]-'0'<10u) break;
- __sh_cas_ptr = __sh_cas_imask;
- __sh_nommu = 1;
- }
-#endif
- if (__hwcap & CPU_HAS_CAS_L)
- __sh_cas_ptr = __sh_cas_cas_l;
- else if (__hwcap & CPU_HAS_LLSC)
- __sh_cas_ptr = __sh_cas_llsc;
-#endif
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself.c b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself.c
deleted file mode 100644
index 35fb3c92d0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "pthread_impl.h"
-
-hidden void __unmapself_sh_mmu(void *, size_t);
-hidden void __unmapself_sh_nommu(void *, size_t);
-
-#if !defined(__SH3__) && !defined(__SH4__)
-#define __unmapself __unmapself_sh_nommu
-#include "dynlink.h"
-#undef CRTJMP
-#define CRTJMP(pc,sp) __asm__ __volatile__( \
- "mov.l @%0+,r0 ; mov.l @%0,r12 ; jmp @r0 ; mov %1,r15" \
- : : "r"(pc), "r"(sp) : "r0", "memory" )
-#include "../__unmapself.c"
-#undef __unmapself
-extern hidden unsigned __sh_nommu;
-#else
-#define __sh_nommu 0
-#endif
-
-void __unmapself(void *base, size_t size)
-{
- if (__sh_nommu) __unmapself_sh_nommu(base, size);
- else __unmapself_sh_mmu(base, size);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s
deleted file mode 100644
index 688087b80f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/__unmapself_mmu.s
+++ /dev/null
@@ -1,23 +0,0 @@
-.text
-.global __unmapself_sh_mmu
-.hidden __unmapself_sh_mmu
-.type __unmapself_sh_mmu, @function
-__unmapself_sh_mmu:
- mov #91, r3 ! SYS_munmap
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
- mov #1, r3 ! SYS_exit
- mov #0, r4
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/atomics.s b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/atomics.s
deleted file mode 100644
index 9d9fcb6eda..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/atomics.s
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Contract for all versions is same as cas.l r2,r3,@r0
- * pr and r1 are also clobbered (by jsr & r1 as temp).
- * r0,r2,r4-r15 must be preserved.
- * r3 contains result (==r2 iff cas succeeded). */
-
- .align 2
-.global __sh_cas_gusa
-.hidden __sh_cas_gusa
-__sh_cas_gusa:
- mov.l r5,@-r15
- mov.l r4,@-r15
- mov r0,r4
- mova 1f,r0
- mov r15,r1
- mov #(0f-1f),r15
-0: mov.l @r4,r5
- cmp/eq r5,r2
- bf 1f
- mov.l r3,@r4
-1: mov r1,r15
- mov r5,r3
- mov r4,r0
- mov.l @r15+,r4
- rts
- mov.l @r15+,r5
-
-.global __sh_cas_llsc
-.hidden __sh_cas_llsc
-__sh_cas_llsc:
- mov r0,r1
- .word 0x00ab /* synco */
-0: .word 0x0163 /* movli.l @r1,r0 */
- cmp/eq r0,r2
- bf 1f
- mov r3,r0
- .word 0x0173 /* movco.l r0,@r1 */
- bf 0b
- mov r2,r0
-1: .word 0x00ab /* synco */
- mov r0,r3
- rts
- mov r1,r0
-
-.global __sh_cas_imask
-.hidden __sh_cas_imask
-__sh_cas_imask:
- mov r0,r1
- stc sr,r0
- mov.l r0,@-r15
- or #0xf0,r0
- ldc r0,sr
- mov.l @r1,r0
- cmp/eq r0,r2
- bf 1f
- mov.l r3,@r1
-1: ldc.l @r15+,sr
- mov r0,r3
- rts
- mov r1,r0
-
-.global __sh_cas_cas_l
-.hidden __sh_cas_cas_l
-__sh_cas_cas_l:
- rts
- .word 0x2323 /* cas.l r2,r3,@r0 */
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/clone.s
deleted file mode 100644
index 9cfd8623c5..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/clone.s
+++ /dev/null
@@ -1,54 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone, @function
-__clone:
-! incoming: fn stack flags arg ptid tls ctid
-! r4 r5 r6 r7 @r15 @(4,r15) @(8,r15)
-
- mov #-16, r0
- and r0, r5
-
- mov r4, r1 ! r1 = fn
- mov r7, r2 ! r2 = arg
-
- mov #120, r3 ! r3 = __NR_clone
- mov r6, r4 ! r4 = flags
- !mov r5, r5 ! r5 = stack
- mov.l @r15, r6 ! r6 = ptid
- mov.l @(8,r15), r7 ! r7 = ctid
- mov.l @(4,r15), r0 ! r0 = tls
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
- cmp/eq #0, r0
- bt 1f
-
- ! we are the parent, return
- rts
- nop
-
-1: ! we are the child, call fn(arg)
- mov.l 1f, r0
- mov r1, r5
- bsrf r0
- mov r2, r4
-
-2: mov #1, r3 ! __NR_exit
- mov r0, r4
- trapa #31
-
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
-.align 2
-.hidden __shcall
-1: .long __shcall@PCREL+(.-2b)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/sh/syscall_cp.s
deleted file mode 100644
index bb848ef3b6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/sh/syscall_cp.s
+++ /dev/null
@@ -1,45 +0,0 @@
-.text
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm, @function
-__syscall_cp_asm:
-
-__cp_begin:
- mov.l @r4, r4
- tst r4, r4
- bf __cp_cancel
- mov r5, r3
- mov r6, r4
- mov r7, r5
- mov.l @r15, r6
- mov.l @(4,r15), r7
- mov.l @(8,r15), r0
- mov.l @(12,r15), r1
- trapa #31
-
-__cp_end:
- ! work around hardware bug
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
- rts
- nop
-
-__cp_cancel:
- mov.l 2f, r0
- braf r0
- nop
-1:
-
-.align 2
-2: .long __cancel@PCREL-(1b-.)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/synccall.c b/lib/libc/wasi/libc-top-half/musl/src/thread/synccall.c
deleted file mode 100644
index d58c851fcf..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/synccall.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include "pthread_impl.h"
-#include <semaphore.h>
-#include <string.h>
-
-static void dummy_0(void)
-{
-}
-
-weak_alias(dummy_0, __tl_lock);
-weak_alias(dummy_0, __tl_unlock);
-
-static int target_tid;
-static void (*callback)(void *), *context;
-static sem_t target_sem, caller_sem;
-
-static void dummy(void *p)
-{
-}
-
-static void handler(int sig)
-{
- if (__pthread_self()->tid != target_tid) return;
-
- int old_errno = errno;
-
- /* Inform caller we have received signal and wait for
- * the caller to let us make the callback. */
- sem_post(&caller_sem);
- sem_wait(&target_sem);
-
- callback(context);
-
- /* Inform caller we've complered the callback and wait
- * for the caller to release us to return. */
- sem_post(&caller_sem);
- sem_wait(&target_sem);
-
- /* Inform caller we are returning and state is destroyable. */
- sem_post(&caller_sem);
-
- errno = old_errno;
-}
-
-void __synccall(void (*func)(void *), void *ctx)
-{
- sigset_t oldmask;
- int cs, i, r;
- struct sigaction sa = { .sa_flags = SA_RESTART, .sa_handler = handler };
- pthread_t self = __pthread_self(), td;
- int count = 0;
-
- /* Blocking signals in two steps, first only app-level signals
- * before taking the lock, then all signals after taking the lock,
- * is necessary to achieve AS-safety. Blocking them all first would
- * deadlock if multiple threads called __synccall. Waiting to block
- * any until after the lock would allow re-entry in the same thread
- * with the lock already held. */
- __block_app_sigs(&oldmask);
- __tl_lock();
- __block_all_sigs(0);
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
-
- sem_init(&target_sem, 0, 0);
- sem_init(&caller_sem, 0, 0);
-
- if (!libc.threads_minus_1 || __syscall(SYS_gettid) != self->tid)
- goto single_threaded;
-
- callback = func;
- context = ctx;
-
- /* Block even implementation-internal signals, so that nothing
- * interrupts the SIGSYNCCALL handlers. The main possible source
- * of trouble is asynchronous cancellation. */
- memset(&sa.sa_mask, -1, sizeof sa.sa_mask);
- __libc_sigaction(SIGSYNCCALL, &sa, 0);
-
-
- for (td=self->next; td!=self; td=td->next) {
- target_tid = td->tid;
- while ((r = -__syscall(SYS_tkill, td->tid, SIGSYNCCALL)) == EAGAIN);
- if (r) {
- /* If we failed to signal any thread, nop out the
- * callback to abort the synccall and just release
- * any threads already caught. */
- callback = func = dummy;
- break;
- }
- sem_wait(&caller_sem);
- count++;
- }
- target_tid = 0;
-
- /* Serialize execution of callback in caught threads, or just
- * release them all if synccall is being aborted. */
- for (i=0; i<count; i++) {
- sem_post(&target_sem);
- sem_wait(&caller_sem);
- }
-
- sa.sa_handler = SIG_IGN;
- __libc_sigaction(SIGSYNCCALL, &sa, 0);
-
-single_threaded:
- func(ctx);
-
- /* Only release the caught threads once all threads, including the
- * caller, have returned from the callback function. */
- for (i=0; i<count; i++)
- sem_post(&target_sem);
- for (i=0; i<count; i++)
- sem_wait(&caller_sem);
-
- sem_destroy(&caller_sem);
- sem_destroy(&target_sem);
-
- pthread_setcancelstate(cs, 0);
- __tl_unlock();
- __restore_sigs(&oldmask);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/syscall_cp.c b/lib/libc/wasi/libc-top-half/musl/src/thread/syscall_cp.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/syscall_cp.c
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_create.c b/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_create.c
deleted file mode 100644
index 76a683dbf8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_create.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
-{
- int ret = __pthread_create(thr, __ATTRP_C11_THREAD, (void *(*)(void *))func, arg);
- switch (ret) {
- case 0: return thrd_success;
- case EAGAIN: return thrd_nomem;
- default: return thrd_error;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_exit.c b/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_exit.c
deleted file mode 100644
index 9b291ae3db..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_exit.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-#include <stdint.h>
-
-_Noreturn void thrd_exit(int result)
-{
- __pthread_exit((void*)(intptr_t)result);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_join.c b/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_join.c
deleted file mode 100644
index 0d5fd302d1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_join.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdint.h>
-#include <threads.h>
-#include <pthread.h>
-
-int thrd_join(thrd_t t, int *res)
-{
- void *pthread_res;
- __pthread_join(t, &pthread_res);
- if (res) *res = (int)(intptr_t)pthread_res;
- return thrd_success;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_yield.c b/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_yield.c
deleted file mode 100644
index f7ad13219c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/thrd_yield.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <threads.h>
-#include "syscall.h"
-
-void thrd_yield()
-{
- __syscall(SYS_sched_yield);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/tls.c b/lib/libc/wasi/libc-top-half/musl/src/thread/tls.c
deleted file mode 100644
index e69de29bb2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/tls.c
+++ /dev/null
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_create.c b/lib/libc/wasi/libc-top-half/musl/src/thread/tss_create.c
deleted file mode 100644
index 6d6ef96b4c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_create.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-int tss_create(tss_t *tss, tss_dtor_t dtor)
-{
- /* Different error returns are possible. C glues them together into
- * just failure notification. Can't be optimized to a tail call,
- * unless thrd_error equals EAGAIN. */
- return __pthread_key_create(tss, dtor) ? thrd_error : thrd_success;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_delete.c b/lib/libc/wasi/libc-top-half/musl/src/thread/tss_delete.c
deleted file mode 100644
index 6f51b07eb9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_delete.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <threads.h>
-#include <pthread.h>
-
-void tss_delete(tss_t key)
-{
- __pthread_key_delete(key);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_set.c b/lib/libc/wasi/libc-top-half/musl/src/thread/tss_set.c
deleted file mode 100644
index 70c4fb723c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/tss_set.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "pthread_impl.h"
-#include <threads.h>
-
-int tss_set(tss_t k, void *x)
-{
- struct pthread *self = __pthread_self();
- /* Avoid unnecessary COW */
- if (self->tsd[k] != x) {
- self->tsd[k] = x;
- self->tsd_used = 1;
- }
- return thrd_success;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/vmlock.c b/lib/libc/wasi/libc-top-half/musl/src/thread/vmlock.c
deleted file mode 100644
index fa0a8e3c2e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/vmlock.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "pthread_impl.h"
-#include "fork_impl.h"
-
-static volatile int vmlock[2];
-volatile int *const __vmlock_lockptr = vmlock;
-
-void __vm_wait()
-{
- int tmp;
- while ((tmp=vmlock[0]))
- __wait(vmlock, vmlock+1, tmp, 1);
-}
-
-void __vm_lock()
-{
- a_inc(vmlock);
-}
-
-void __vm_unlock()
-{
- if (a_fetch_add(vmlock, -1)==1 && vmlock[1])
- __wake(vmlock, -1, 1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__set_thread_area.s
deleted file mode 100644
index c0fee87e6a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__set_thread_area.s
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- mov %edi,%esi /* shift for syscall */
- movl $0x1002,%edi /* SET_FS register */
- movl $0x4000009e,%eax /* set fs segment to */
- syscall /* arch_prctl(SET_FS, arg)*/
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__unmapself.s
deleted file mode 100644
index d9254601ff..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/__unmapself.s
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.text
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- movl $0x4000000b,%eax /* SYS_munmap */
- syscall /* munmap(arg2,arg3) */
- xor %rdi,%rdi /* exit() args: always return success */
- movl $0x4000003c,%eax /* SYS_exit */
- syscall /* exit(0) */
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x32/clone.s
deleted file mode 100644
index b870880f93..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/clone.s
+++ /dev/null
@@ -1,26 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- movl $0x40000038,%eax /* SYS_clone */
- mov %rdi,%r11
- mov %rdx,%rdi
- mov %r8,%rdx
- mov %r9,%r8
- mov 8(%rsp),%r10
- mov %r11,%r9
- and $-16,%rsi
- sub $8,%rsi
- mov %rcx,(%rsi)
- syscall
- test %eax,%eax
- jnz 1f
- xor %ebp,%ebp
- pop %rdi
- call *%r9
- mov %eax,%edi
- movl $0x4000003c,%eax /* SYS_exit */
- syscall
- hlt
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x32/syscall_cp.s
deleted file mode 100644
index 4f101716d4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x32/syscall_cp.s
+++ /dev/null
@@ -1,31 +0,0 @@
-.text
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-
-__cp_begin:
- mov (%rdi),%eax
- test %eax,%eax
- jnz __cp_cancel
- mov %rdi,%r11
- mov %rsi,%rax
- mov %rdx,%rdi
- mov %rcx,%rsi
- mov %r8,%rdx
- mov %r9,%r10
- mov 8(%rsp),%r8
- mov 16(%rsp),%r9
- mov %r11,8(%rsp)
- syscall
-__cp_end:
- ret
-__cp_cancel:
- jmp __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s
deleted file mode 100644
index 7347ff4dc1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__set_thread_area.s
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.text
-.global __set_thread_area
-.hidden __set_thread_area
-.type __set_thread_area,@function
-__set_thread_area:
- mov %rdi,%rsi /* shift for syscall */
- movl $0x1002,%edi /* SET_FS register */
- movl $158,%eax /* set fs segment to */
- syscall /* arch_prctl(SET_FS, arg)*/
- ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__unmapself.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__unmapself.s
deleted file mode 100644
index e2689e6505..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/__unmapself.s
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2011-2012 Nicholas J. Kain, licensed under standard MIT license */
-.text
-.global __unmapself
-.type __unmapself,@function
-__unmapself:
- movl $11,%eax /* SYS_munmap */
- syscall /* munmap(arg2,arg3) */
- xor %rdi,%rdi /* exit() args: always return success */
- movl $60,%eax /* SYS_exit */
- syscall /* exit(0) */
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/clone.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/clone.s
deleted file mode 100644
index 6e47bc0a37..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/clone.s
+++ /dev/null
@@ -1,28 +0,0 @@
-.text
-.global __clone
-.hidden __clone
-.type __clone,@function
-__clone:
- xor %eax,%eax
- mov $56,%al
- mov %rdi,%r11
- mov %rdx,%rdi
- mov %r8,%rdx
- mov %r9,%r8
- mov 8(%rsp),%r10
- mov %r11,%r9
- and $-16,%rsi
- sub $8,%rsi
- mov %rcx,(%rsi)
- syscall
- test %eax,%eax
- jnz 1f
- xor %ebp,%ebp
- pop %rdi
- call *%r9
- mov %eax,%edi
- xor %eax,%eax
- mov $60,%al
- syscall
- hlt
-1: ret
diff --git a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/syscall_cp.s b/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/syscall_cp.s
deleted file mode 100644
index 4f101716d4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/thread/x86_64/syscall_cp.s
+++ /dev/null
@@ -1,31 +0,0 @@
-.text
-.global __cp_begin
-.hidden __cp_begin
-.global __cp_end
-.hidden __cp_end
-.global __cp_cancel
-.hidden __cp_cancel
-.hidden __cancel
-.global __syscall_cp_asm
-.hidden __syscall_cp_asm
-.type __syscall_cp_asm,@function
-__syscall_cp_asm:
-
-__cp_begin:
- mov (%rdi),%eax
- test %eax,%eax
- jnz __cp_cancel
- mov %rdi,%r11
- mov %rsi,%rax
- mov %rdx,%rdi
- mov %rcx,%rsi
- mov %r8,%rdx
- mov %r9,%r10
- mov 8(%rsp),%r8
- mov 16(%rsp),%r9
- mov %r11,8(%rsp)
- syscall
-__cp_end:
- ret
-__cp_cancel:
- jmp __cancel
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/__map_file.c b/lib/libc/wasi/libc-top-half/musl/src/time/__map_file.c
deleted file mode 100644
index d3cefa8284..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/__map_file.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include "syscall.h"
-#include "kstat.h"
-
-const char unsigned *__map_file(const char *pathname, size_t *size)
-{
- struct kstat st;
- const unsigned char *map = MAP_FAILED;
- int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
- if (fd < 0) return 0;
- if (!syscall(SYS_fstat, fd, &st)) {
- map = __mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- *size = st.st_size;
- }
- __syscall(SYS_close, fd);
- return map == MAP_FAILED ? 0 : map;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock.c
deleted file mode 100644
index 6724012b92..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <time.h>
-#include <limits.h>
-
-clock_t clock()
-{
- struct timespec ts;
-
- if (__clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts))
- return -1;
-
- if (ts.tv_sec > LONG_MAX/1000000
- || ts.tv_nsec/1000 > LONG_MAX-1000000*ts.tv_sec)
- return -1;
-
- return ts.tv_sec*1000000 + ts.tv_nsec/1000;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock_getcpuclockid.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock_getcpuclockid.c
deleted file mode 100644
index 8a0e2d4c3a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock_getcpuclockid.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <time.h>
-#include <errno.h>
-#include <unistd.h>
-#include "syscall.h"
-
-int clock_getcpuclockid(pid_t pid, clockid_t *clk)
-{
- struct timespec ts;
- clockid_t id = (-pid-1)*8U + 2;
- int ret = __syscall(SYS_clock_getres, id, &ts);
- if (ret) return -ret;
- *clk = id;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock_getres.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock_getres.c
deleted file mode 100644
index 81c6703761..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock_getres.c
+++ /dev/null
@@ -1,21 +0,0 @@
-#include <time.h>
-#include "syscall.h"
-
-int clock_getres(clockid_t clk, struct timespec *ts)
-{
-#ifdef SYS_clock_getres_time64
- /* On a 32-bit arch, use the old syscall if it exists. */
- if (SYS_clock_getres != SYS_clock_getres_time64) {
- long ts32[2];
- int r = __syscall(SYS_clock_getres, clk, ts32);
- if (!r && ts) {
- ts->tv_sec = ts32[0];
- ts->tv_nsec = ts32[1];
- }
- return __syscall_ret(r);
- }
-#endif
- /* If reaching this point, it's a 64-bit arch or time64-only
- * 32-bit arch and we can get result directly into timespec. */
- return syscall(SYS_clock_getres, clk, ts);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock_gettime.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock_gettime.c
deleted file mode 100644
index 3e1d0975b1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock_gettime.c
+++ /dev/null
@@ -1,107 +0,0 @@
-#include <time.h>
-#include <errno.h>
-#include <stdint.h>
-#include "syscall.h"
-#include "atomic.h"
-
-#ifdef VDSO_CGT_SYM
-
-static void *volatile vdso_func;
-
-#ifdef VDSO_CGT32_SYM
-static void *volatile vdso_func_32;
-static int cgt_time32_wrap(clockid_t clk, struct timespec *ts)
-{
- long ts32[2];
- int (*f)(clockid_t, long[2]) =
- (int (*)(clockid_t, long[2]))vdso_func_32;
- int r = f(clk, ts32);
- if (!r) {
- /* Fallback to syscalls if time32 overflowed. Maybe
- * we lucked out and somehow migrated to a kernel with
- * time64 syscalls available. */
- if (ts32[0] < 0) {
- a_cas_p(&vdso_func, (void *)cgt_time32_wrap, 0);
- return -ENOSYS;
- }
- ts->tv_sec = ts32[0];
- ts->tv_nsec = ts32[1];
- }
- return r;
-}
-#endif
-
-static int cgt_init(clockid_t clk, struct timespec *ts)
-{
- void *p = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
-#ifdef VDSO_CGT32_SYM
- if (!p) {
- void *q = __vdsosym(VDSO_CGT32_VER, VDSO_CGT32_SYM);
- if (q) {
- a_cas_p(&vdso_func_32, 0, q);
- p = cgt_time32_wrap;
- }
- }
-#endif
- int (*f)(clockid_t, struct timespec *) =
- (int (*)(clockid_t, struct timespec *))p;
- a_cas_p(&vdso_func, (void *)cgt_init, p);
- return f ? f(clk, ts) : -ENOSYS;
-}
-
-static void *volatile vdso_func = (void *)cgt_init;
-
-#endif
-
-int __clock_gettime(clockid_t clk, struct timespec *ts)
-{
- int r;
-
-#ifdef VDSO_CGT_SYM
- int (*f)(clockid_t, struct timespec *) =
- (int (*)(clockid_t, struct timespec *))vdso_func;
- if (f) {
- r = f(clk, ts);
- if (!r) return r;
- if (r == -EINVAL) return __syscall_ret(r);
- /* Fall through on errors other than EINVAL. Some buggy
- * vdso implementations return ENOSYS for clocks they
- * can't handle, rather than making the syscall. This
- * also handles the case where cgt_init fails to find
- * a vdso function to use. */
- }
-#endif
-
-#ifdef SYS_clock_gettime64
- r = -ENOSYS;
- if (sizeof(time_t) > 4)
- r = __syscall(SYS_clock_gettime64, clk, ts);
- if (SYS_clock_gettime == SYS_clock_gettime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- long ts32[2];
- r = __syscall(SYS_clock_gettime, clk, ts32);
- if (r==-ENOSYS && clk==CLOCK_REALTIME) {
- r = __syscall(SYS_gettimeofday, ts32, 0);
- ts32[1] *= 1000;
- }
- if (!r) {
- ts->tv_sec = ts32[0];
- ts->tv_nsec = ts32[1];
- return r;
- }
- return __syscall_ret(r);
-#else
- r = __syscall(SYS_clock_gettime, clk, ts);
- if (r == -ENOSYS) {
- if (clk == CLOCK_REALTIME) {
- __syscall(SYS_gettimeofday, ts, 0);
- ts->tv_nsec = (int)ts->tv_nsec * 1000;
- return 0;
- }
- r = -EINVAL;
- }
- return __syscall_ret(r);
-#endif
-}
-
-weak_alias(__clock_gettime, clock_gettime);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock_nanosleep.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock_nanosleep.c
deleted file mode 100644
index e195499cc0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock_nanosleep.c
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <time.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63))
-
-int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
-{
- if (clk == CLOCK_THREAD_CPUTIME_ID) return EINVAL;
-#ifdef SYS_clock_nanosleep_time64
- time_t s = req->tv_sec;
- long ns = req->tv_nsec;
- int r = -ENOSYS;
- if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || !IS32BIT(s))
- r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags,
- ((long long[]){s, ns}), rem);
- if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || r!=-ENOSYS)
- return -r;
- long long extra = s - CLAMP(s);
- long ts32[2] = { CLAMP(s), ns };
- if (clk == CLOCK_REALTIME && !flags)
- r = __syscall_cp(SYS_nanosleep, &ts32, &ts32);
- else
- r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32);
- if (r==-EINTR && rem && !(flags & TIMER_ABSTIME)) {
- rem->tv_sec = ts32[0] + extra;
- rem->tv_nsec = ts32[1];
- }
- return -r;
-#else
- if (clk == CLOCK_REALTIME && !flags)
- return -__syscall_cp(SYS_nanosleep, req, rem);
- return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
-#endif
-}
-
-weak_alias(__clock_nanosleep, clock_nanosleep);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/clock_settime.c b/lib/libc/wasi/libc-top-half/musl/src/time/clock_settime.c
deleted file mode 100644
index 1004ed1528..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/clock_settime.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <time.h>
-#include <errno.h>
-#include "syscall.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-
-int clock_settime(clockid_t clk, const struct timespec *ts)
-{
-#ifdef SYS_clock_settime64
- time_t s = ts->tv_sec;
- long ns = ts->tv_nsec;
- int r = -ENOSYS;
- if (SYS_clock_settime == SYS_clock_settime64 || !IS32BIT(s))
- r = __syscall(SYS_clock_settime64, clk,
- ((long long[]){s, ns}));
- if (SYS_clock_settime == SYS_clock_settime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if (!IS32BIT(s))
- return __syscall_ret(-ENOTSUP);
- return syscall(SYS_clock_settime, clk, ((long[]){s, ns}));
-#else
- return syscall(SYS_clock_settime, clk, ts);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/gettimeofday.c b/lib/libc/wasi/libc-top-half/musl/src/time/gettimeofday.c
deleted file mode 100644
index 691f8e9043..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/gettimeofday.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <time.h>
-#include <sys/time.h>
-#include "syscall.h"
-
-int gettimeofday(struct timeval *restrict tv, void *restrict tz)
-{
- struct timespec ts;
- if (!tv) return 0;
- clock_gettime(CLOCK_REALTIME, &ts);
- tv->tv_sec = ts.tv_sec;
- tv->tv_usec = (int)ts.tv_nsec / 1000;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/nanosleep.c b/lib/libc/wasi/libc-top-half/musl/src/time/nanosleep.c
deleted file mode 100644
index bc9f7895fa..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/nanosleep.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <time.h>
-#include "syscall.h"
-
-int nanosleep(const struct timespec *req, struct timespec *rem)
-{
- return __syscall_ret(-__clock_nanosleep(CLOCK_REALTIME, 0, req, rem));
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/time.c b/lib/libc/wasi/libc-top-half/musl/src/time/time.c
deleted file mode 100644
index ad0480f9ea..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/time.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <time.h>
-#include "syscall.h"
-
-time_t time(time_t *t)
-{
- struct timespec ts;
- __clock_gettime(CLOCK_REALTIME, &ts);
- if (t) *t = ts.tv_sec;
- return ts.tv_sec;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/timer_create.c b/lib/libc/wasi/libc-top-half/musl/src/time/timer_create.c
deleted file mode 100644
index 4bef239051..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/timer_create.c
+++ /dev/null
@@ -1,129 +0,0 @@
-#include <time.h>
-#include <setjmp.h>
-#include <limits.h>
-#include "pthread_impl.h"
-#include "atomic.h"
-
-struct ksigevent {
- union sigval sigev_value;
- int sigev_signo;
- int sigev_notify;
- int sigev_tid;
-};
-
-struct start_args {
- pthread_barrier_t b;
- struct sigevent *sev;
-};
-
-static void dummy_0()
-{
-}
-weak_alias(dummy_0, __pthread_tsd_run_dtors);
-
-static void cleanup_fromsig(void *p)
-{
- pthread_t self = __pthread_self();
- __pthread_tsd_run_dtors();
- self->cancel = 0;
- self->cancelbuf = 0;
- self->canceldisable = 0;
- self->cancelasync = 0;
- __reset_tls();
- longjmp(p, 1);
-}
-
-static void *start(void *arg)
-{
- pthread_t self = __pthread_self();
- struct start_args *args = arg;
- jmp_buf jb;
-
- void (*notify)(union sigval) = args->sev->sigev_notify_function;
- union sigval val = args->sev->sigev_value;
-
- pthread_barrier_wait(&args->b);
- for (;;) {
- siginfo_t si;
- while (sigwaitinfo(SIGTIMER_SET, &si) < 0);
- if (si.si_code == SI_TIMER && !setjmp(jb)) {
- pthread_cleanup_push(cleanup_fromsig, jb);
- notify(val);
- pthread_cleanup_pop(1);
- }
- if (self->timer_id < 0) break;
- }
- __syscall(SYS_timer_delete, self->timer_id & INT_MAX);
- return 0;
-}
-
-int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res)
-{
- volatile static int init = 0;
- pthread_t td;
- pthread_attr_t attr;
- int r;
- struct start_args args;
- struct ksigevent ksev, *ksevp=0;
- int timerid;
- sigset_t set;
-
- switch (evp ? evp->sigev_notify : SIGEV_SIGNAL) {
- case SIGEV_NONE:
- case SIGEV_SIGNAL:
- case SIGEV_THREAD_ID:
- if (evp) {
- ksev.sigev_value = evp->sigev_value;
- ksev.sigev_signo = evp->sigev_signo;
- ksev.sigev_notify = evp->sigev_notify;
- if (evp->sigev_notify == SIGEV_THREAD_ID)
- ksev.sigev_tid = evp->sigev_notify_thread_id;
- else
- ksev.sigev_tid = 0;
- ksevp = &ksev;
- }
- if (syscall(SYS_timer_create, clk, ksevp, &timerid) < 0)
- return -1;
- *res = (void *)(intptr_t)timerid;
- break;
- case SIGEV_THREAD:
- if (!init) {
- struct sigaction sa = { .sa_handler = SIG_DFL };
- __libc_sigaction(SIGTIMER, &sa, 0);
- a_store(&init, 1);
- }
- if (evp->sigev_notify_attributes)
- attr = *evp->sigev_notify_attributes;
- else
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- pthread_barrier_init(&args.b, 0, 2);
- args.sev = evp;
-
- __block_app_sigs(&set);
- __syscall(SYS_rt_sigprocmask, SIG_BLOCK, SIGTIMER_SET, 0, _NSIG/8);
- r = pthread_create(&td, &attr, start, &args);
- __restore_sigs(&set);
- if (r) {
- errno = r;
- return -1;
- }
-
- ksev.sigev_value.sival_ptr = 0;
- ksev.sigev_signo = SIGTIMER;
- ksev.sigev_notify = SIGEV_THREAD_ID;
- ksev.sigev_tid = td->tid;
- if (syscall(SYS_timer_create, clk, &ksev, &timerid) < 0)
- timerid = -1;
- td->timer_id = timerid;
- pthread_barrier_wait(&args.b);
- if (timerid < 0) return -1;
- *res = (void *)(INTPTR_MIN | (uintptr_t)td>>1);
- break;
- default:
- errno = EINVAL;
- return -1;
- }
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/timer_delete.c b/lib/libc/wasi/libc-top-half/musl/src/time/timer_delete.c
deleted file mode 100644
index b0bfac0968..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/timer_delete.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <time.h>
-#include <limits.h>
-#include "pthread_impl.h"
-
-int timer_delete(timer_t t)
-{
- if ((intptr_t)t < 0) {
- pthread_t td = (void *)((uintptr_t)t << 1);
- a_store(&td->timer_id, td->timer_id | INT_MIN);
- __syscall(SYS_tkill, td->tid, SIGTIMER);
- return 0;
- }
- return __syscall(SYS_timer_delete, t);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/timer_getoverrun.c b/lib/libc/wasi/libc-top-half/musl/src/time/timer_getoverrun.c
deleted file mode 100644
index e7f891e404..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/timer_getoverrun.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <time.h>
-#include <limits.h>
-#include "pthread_impl.h"
-
-int timer_getoverrun(timer_t t)
-{
- if ((intptr_t)t < 0) {
- pthread_t td = (void *)((uintptr_t)t << 1);
- t = (void *)(uintptr_t)(td->timer_id & INT_MAX);
- }
- return syscall(SYS_timer_getoverrun, t);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/timer_gettime.c b/lib/libc/wasi/libc-top-half/musl/src/time/timer_gettime.c
deleted file mode 100644
index 21c9d32c3f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/timer_gettime.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <time.h>
-#include <limits.h>
-#include "pthread_impl.h"
-
-int timer_gettime(timer_t t, struct itimerspec *val)
-{
- if ((intptr_t)t < 0) {
- pthread_t td = (void *)((uintptr_t)t << 1);
- t = (void *)(uintptr_t)(td->timer_id & INT_MAX);
- }
-#ifdef SYS_timer_gettime64
- int r = -ENOSYS;
- if (sizeof(time_t) > 4)
- r = __syscall(SYS_timer_gettime64, t, val);
- if (SYS_timer_gettime == SYS_timer_gettime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- long val32[4];
- r = __syscall(SYS_timer_gettime, t, val32);
- if (!r) {
- val->it_interval.tv_sec = val32[0];
- val->it_interval.tv_nsec = val32[1];
- val->it_value.tv_sec = val32[2];
- val->it_value.tv_nsec = val32[3];
- }
- return __syscall_ret(r);
-#endif
- return syscall(SYS_timer_gettime, t, val);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/timer_settime.c b/lib/libc/wasi/libc-top-half/musl/src/time/timer_settime.c
deleted file mode 100644
index 373f00ced7..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/timer_settime.c
+++ /dev/null
@@ -1,37 +0,0 @@
-#include <time.h>
-#include <limits.h>
-#include "pthread_impl.h"
-
-#define IS32BIT(x) !((x)+0x80000000ULL>>32)
-
-int timer_settime(timer_t t, int flags, const struct itimerspec *restrict val, struct itimerspec *restrict old)
-{
- if ((intptr_t)t < 0) {
- pthread_t td = (void *)((uintptr_t)t << 1);
- t = (void *)(uintptr_t)(td->timer_id & INT_MAX);
- }
-#ifdef SYS_timer_settime64
- time_t is = val->it_interval.tv_sec, vs = val->it_value.tv_sec;
- long ins = val->it_interval.tv_nsec, vns = val->it_value.tv_nsec;
- int r = -ENOSYS;
- if (SYS_timer_settime == SYS_timer_settime64
- || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old))
- r = __syscall(SYS_timer_settime64, t, flags,
- ((long long[]){is, ins, vs, vns}), old);
- if (SYS_timer_settime == SYS_timer_settime64 || r!=-ENOSYS)
- return __syscall_ret(r);
- if (!IS32BIT(is) || !IS32BIT(vs))
- return __syscall_ret(-ENOTSUP);
- long old32[4];
- r = __syscall(SYS_timer_settime, t, flags,
- ((long[]){is, ins, vs, vns}), old32);
- if (!r && old) {
- old->it_interval.tv_sec = old32[0];
- old->it_interval.tv_nsec = old32[1];
- old->it_value.tv_sec = old32[2];
- old->it_value.tv_nsec = old32[3];
- }
- return __syscall_ret(r);
-#endif
- return syscall(SYS_timer_settime, t, flags, val, old);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/times.c b/lib/libc/wasi/libc-top-half/musl/src/time/times.c
deleted file mode 100644
index c4a100f79b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/times.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/times.h>
-#include "syscall.h"
-
-clock_t times(struct tms *tms)
-{
- return __syscall(SYS_times, tms);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/time/utime.c b/lib/libc/wasi/libc-top-half/musl/src/time/utime.c
deleted file mode 100644
index e7592b2978..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/time/utime.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <utime.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <fcntl.h>
-
-int utime(const char *path, const struct utimbuf *times)
-{
- return utimensat(AT_FDCWD, path, times ? ((struct timespec [2]){
- { .tv_sec = times->actime }, { .tv_sec = times->modtime }})
- : 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/_exit.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/_exit.c
deleted file mode 100644
index 769948232e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/_exit.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-
-_Noreturn void _exit(int status)
-{
- _Exit(status);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/access.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/access.c
deleted file mode 100644
index d6eed68398..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/access.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int access(const char *filename, int amode)
-{
-#ifdef SYS_access
- return syscall(SYS_access, filename, amode);
-#else
- return syscall(SYS_faccessat, AT_FDCWD, filename, amode, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/acct.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/acct.c
deleted file mode 100644
index 308ffc3821..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/acct.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-
-int acct(const char *filename)
-{
- return syscall(SYS_acct, filename);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/alarm.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/alarm.c
deleted file mode 100644
index a5e0c822a0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/alarm.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-#include <sys/time.h>
-#include "syscall.h"
-
-unsigned alarm(unsigned seconds)
-{
- struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 };
- setitimer(ITIMER_REAL, &it, &old);
- return old.it_value.tv_sec + !!old.it_value.tv_usec;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/chdir.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/chdir.c
deleted file mode 100644
index 5ba78b6317..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/chdir.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int chdir(const char *path)
-{
- return syscall(SYS_chdir, path);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/chown.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/chown.c
deleted file mode 100644
index 14b032550d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/chown.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int chown(const char *path, uid_t uid, gid_t gid)
-{
-#ifdef SYS_chown
- return syscall(SYS_chown, path, uid, gid);
-#else
- return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/close.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/close.c
deleted file mode 100644
index a2105f5060..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/close.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include "aio_impl.h"
-#include "syscall.h"
-
-static int dummy(int fd)
-{
- return fd;
-}
-
-weak_alias(dummy, __aio_close);
-
-int close(int fd)
-{
- fd = __aio_close(fd);
- int r = __syscall_cp(SYS_close, fd);
- if (r == -EINTR) r = 0;
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/ctermid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/ctermid.c
deleted file mode 100644
index 1612770af1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/ctermid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-char *ctermid(char *s)
-{
- return s ? strcpy(s, "/dev/tty") : "/dev/tty";
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/dup.c
deleted file mode 100644
index 7fee01201b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int dup(int fd)
-{
- return syscall(SYS_dup, fd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup2.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/dup2.c
deleted file mode 100644
index 8f43c6ddfe..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup2.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int dup2(int old, int new)
-{
- int r;
-#ifdef SYS_dup2
- while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
-#else
- if (old==new) {
- r = __syscall(SYS_fcntl, old, F_GETFD);
- if (r >= 0) return old;
- } else {
- while ((r=__syscall(SYS_dup3, old, new, 0))==-EBUSY);
- }
-#endif
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup3.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/dup3.c
deleted file mode 100644
index f919f79125..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/dup3.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int __dup3(int old, int new, int flags)
-{
- int r;
-#ifdef SYS_dup2
- if (old==new) return __syscall_ret(-EINVAL);
- if (flags & O_CLOEXEC) {
- while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
- if (r!=-ENOSYS) return __syscall_ret(r);
- }
- while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
- if (flags & O_CLOEXEC) __syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
-#else
- while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
-#endif
- return __syscall_ret(r);
-}
-
-weak_alias(__dup3, dup3);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/faccessat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/faccessat.c
deleted file mode 100644
index 557503eb6d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/faccessat.c
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include "syscall.h"
-#include "pthread_impl.h"
-
-struct ctx {
- int fd;
- const char *filename;
- int amode;
- int p;
-};
-
-static int checker(void *p)
-{
- struct ctx *c = p;
- int ret;
- if (__syscall(SYS_setregid, __syscall(SYS_getegid), -1)
- || __syscall(SYS_setreuid, __syscall(SYS_geteuid), -1))
- __syscall(SYS_exit, 1);
- ret = __syscall(SYS_faccessat, c->fd, c->filename, c->amode, 0);
- __syscall(SYS_write, c->p, &ret, sizeof ret);
- return 0;
-}
-
-int faccessat(int fd, const char *filename, int amode, int flag)
-{
- if (flag) {
- int ret = __syscall(SYS_faccessat2, fd, filename, amode, flag);
- if (ret != -ENOSYS) return __syscall_ret(ret);
- }
-
- if (flag & ~AT_EACCESS)
- return __syscall_ret(-EINVAL);
-
- if (!flag || (getuid()==geteuid() && getgid()==getegid()))
- return syscall(SYS_faccessat, fd, filename, amode);
-
- char stack[1024];
- sigset_t set;
- pid_t pid;
- int status;
- int ret, p[2];
-
- if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
- struct ctx c = { .fd = fd, .filename = filename, .amode = amode, .p = p[1] };
-
- __block_all_sigs(&set);
-
- pid = __clone(checker, stack+sizeof stack, 0, &c);
- __syscall(SYS_close, p[1]);
-
- if (pid<0 || __syscall(SYS_read, p[0], &ret, sizeof ret) != sizeof(ret))
- ret = -EBUSY;
- __syscall(SYS_close, p[0]);
- __syscall(SYS_wait4, pid, &status, __WCLONE, 0);
-
- __restore_sigs(&set);
-
- return __syscall_ret(ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchdir.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/fchdir.c
deleted file mode 100644
index dee45ba68e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchdir.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int fchdir(int fd)
-{
- int ret = __syscall(SYS_fchdir, fd);
- if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
- return __syscall_ret(ret);
-
- char buf[15+3*sizeof(int)];
- __procfdname(buf, fd);
- return syscall(SYS_chdir, buf);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchown.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/fchown.c
deleted file mode 100644
index 737b3672fc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchown.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int fchown(int fd, uid_t uid, gid_t gid)
-{
- int ret = __syscall(SYS_fchown, fd, uid, gid);
- if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0)
- return __syscall_ret(ret);
-
- char buf[15+3*sizeof(int)];
- __procfdname(buf, fd);
-#ifdef SYS_chown
- return syscall(SYS_chown, buf, uid, gid);
-#else
- return syscall(SYS_fchownat, AT_FDCWD, buf, uid, gid, 0);
-#endif
-
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchownat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/fchownat.c
deleted file mode 100644
index 62457a3ec0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/fchownat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag)
-{
- return syscall(SYS_fchownat, fd, path, uid, gid, flag);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/fdatasync.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/fdatasync.c
deleted file mode 100644
index 3895ae530c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/fdatasync.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int fdatasync(int fd)
-{
- return syscall_cp(SYS_fdatasync, fd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/fsync.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/fsync.c
deleted file mode 100644
index 7a1c80b5de..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/fsync.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int fsync(int fd)
-{
- return syscall_cp(SYS_fsync, fd);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/ftruncate.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/ftruncate.c
deleted file mode 100644
index b41be0fa6f..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/ftruncate.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int ftruncate(int fd, off_t length)
-{
- return syscall(SYS_ftruncate, fd, __SYSCALL_LL_O(length));
-}
-
-weak_alias(ftruncate, ftruncate64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getcwd.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getcwd.c
deleted file mode 100644
index f407ffe07e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getcwd.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-#include <string.h>
-#include "syscall.h"
-
-char *getcwd(char *buf, size_t size)
-{
- char tmp[buf ? 1 : PATH_MAX];
- if (!buf) {
- buf = tmp;
- size = sizeof tmp;
- } else if (!size) {
- errno = EINVAL;
- return 0;
- }
- long ret = syscall(SYS_getcwd, buf, size);
- if (ret < 0)
- return 0;
- if (ret == 0 || buf[0] != '/') {
- errno = ENOENT;
- return 0;
- }
- return buf == tmp ? strdup(buf) : buf;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getegid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getegid.c
deleted file mode 100644
index 6287490da2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getegid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-gid_t getegid(void)
-{
- return __syscall(SYS_getegid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/geteuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/geteuid.c
deleted file mode 100644
index 88f2cd5382..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/geteuid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-uid_t geteuid(void)
-{
- return __syscall(SYS_geteuid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getgid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getgid.c
deleted file mode 100644
index 1c9fe7157b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getgid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-gid_t getgid(void)
-{
- return __syscall(SYS_getgid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getgroups.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getgroups.c
deleted file mode 100644
index 0e6e63af01..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getgroups.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int getgroups(int count, gid_t list[])
-{
- return syscall(SYS_getgroups, count, list);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/gethostname.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/gethostname.c
deleted file mode 100644
index 633ef571a4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/gethostname.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <sys/utsname.h>
-
-int gethostname(char *name, size_t len)
-{
- size_t i;
- struct utsname uts;
- if (uname(&uts)) return -1;
- if (len > sizeof uts.nodename) len = sizeof uts.nodename;
- for (i=0; i<len && (name[i] = uts.nodename[i]); i++);
- if (i && i==len) name[i-1] = 0;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin.c
deleted file mode 100644
index 06011913a0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include <stdlib.h>
-
-char *getlogin(void)
-{
- return getenv("LOGNAME");
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin_r.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin_r.c
deleted file mode 100644
index 53866c6dce..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getlogin_r.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-int getlogin_r(char *name, size_t size)
-{
- char *logname = getlogin();
- if (!logname) return ENXIO; /* or...? */
- if (strlen(logname) >= size) return ERANGE;
- strcpy(name, logname);
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgid.c
deleted file mode 100644
index d295bfd59b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t getpgid(pid_t pid)
-{
- return syscall(SYS_getpgid, pid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgrp.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgrp.c
deleted file mode 100644
index 90e9bb07f6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpgrp.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t getpgrp(void)
-{
- return __syscall(SYS_getpgid, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getpid.c
deleted file mode 100644
index a6d4e6d1bc..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getpid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t getpid(void)
-{
- return __syscall(SYS_getpid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getppid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getppid.c
deleted file mode 100644
index 05cade53b6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getppid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t getppid(void)
-{
- return __syscall(SYS_getppid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getsid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getsid.c
deleted file mode 100644
index 93ba690e7e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getsid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t getsid(pid_t pid)
-{
- return syscall(SYS_getsid, pid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/getuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/getuid.c
deleted file mode 100644
index 61309d1b79..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/getuid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-uid_t getuid(void)
-{
- return __syscall(SYS_getuid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/isatty.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/isatty.c
deleted file mode 100644
index 75a9c186a9..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/isatty.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include "syscall.h"
-
-int isatty(int fd)
-{
- struct winsize wsz;
- unsigned long r = syscall(SYS_ioctl, fd, TIOCGWINSZ, &wsz);
- if (r == 0) return 1;
- if (errno != EBADF) errno = ENOTTY;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/lchown.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/lchown.c
deleted file mode 100644
index ccd5ee0255..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/lchown.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int lchown(const char *path, uid_t uid, gid_t gid)
-{
-#ifdef SYS_lchown
- return syscall(SYS_lchown, path, uid, gid);
-#else
- return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/link.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/link.c
deleted file mode 100644
index feec18e533..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/link.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int link(const char *existing, const char *new)
-{
-#ifdef SYS_link
- return syscall(SYS_link, existing, new);
-#else
- return syscall(SYS_linkat, AT_FDCWD, existing, AT_FDCWD, new, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/linkat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/linkat.c
deleted file mode 100644
index 6a9a0b7759..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/linkat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int linkat(int fd1, const char *existing, int fd2, const char *new, int flag)
-{
- return syscall(SYS_linkat, fd1, existing, fd2, new, flag);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/lseek.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/lseek.c
deleted file mode 100644
index 48a638a37c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/lseek.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-off_t __lseek(int fd, off_t offset, int whence)
-{
-#ifdef SYS__llseek
- off_t result;
-#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
- return syscall(SYS__llseek, fd, offset>>32, offset, &result, whence) ? -1 : result;
-#else
- return llseek(fd, offset>>32, offset, &result, whence) ? -1 : result;
-#endif
-#else
-#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
- return syscall(SYS_lseek, fd, offset, whence);
-#else
- return lseek(fd, offset, whence);
-#endif
-#endif
-}
-
-weak_alias(__lseek, lseek);
-weak_alias(__lseek, lseek64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/mips/pipe.s b/lib/libc/wasi/libc-top-half/musl/src/unistd/mips/pipe.s
deleted file mode 100644
index ba2c39a304..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/mips/pipe.s
+++ /dev/null
@@ -1,20 +0,0 @@
-.set noreorder
-
-.global pipe
-.type pipe,@function
-pipe:
- lui $gp, %hi(_gp_disp)
- addiu $gp, %lo(_gp_disp)
- addu $gp, $gp, $25
- li $2, 4042
- syscall
- beq $7, $0, 1f
- nop
- lw $25, %call16(__syscall_ret)($gp)
- jr $25
- subu $4, $0, $2
-1: sw $2, 0($4)
- sw $3, 4($4)
- move $2, $0
- jr $ra
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/mips64/pipe.s b/lib/libc/wasi/libc-top-half/musl/src/unistd/mips64/pipe.s
deleted file mode 100644
index f8a27dccfb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/mips64/pipe.s
+++ /dev/null
@@ -1,19 +0,0 @@
-.set noreorder
-.global pipe
-.type pipe,@function
-pipe:
- lui $3, %hi(%neg(%gp_rel(pipe)))
- daddiu $3, $3, %lo(%neg(%gp_rel(pipe)))
- daddu $3, $3, $25
- li $2, 5021
- syscall
- beq $7, $0, 1f
- nop
- ld $25, %got_disp(__syscall_ret)($3)
- jr $25
- dsubu $4, $0, $2
-1: sw $2, 0($4)
- sw $3, 4($4)
- move $2, $0
- jr $ra
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/lseek.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/lseek.c
deleted file mode 100644
index 60e74a51f8..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/lseek.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-off_t __lseek(int fd, off_t offset, int whence)
-{
- register long long r4 __asm__("$4") = fd;
- register long long r5 __asm__("$5") = offset;
- register long long r6 __asm__("$6") = whence;
- register long long r7 __asm__("$7");
- register long long r2 __asm__("$2") = SYS_lseek;
- __asm__ __volatile__ (
- "syscall"
- : "+&r"(r2), "=r"(r7)
- : "r"(r4), "r"(r5), "r"(r6)
- : SYSCALL_CLOBBERLIST);
- return r7 ? __syscall_ret(-r2) : r2;
-}
-
-weak_alias(__lseek, lseek);
-weak_alias(__lseek, lseek64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/pipe.s b/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/pipe.s
deleted file mode 100644
index 80f882e2b1..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/mipsn32/pipe.s
+++ /dev/null
@@ -1,19 +0,0 @@
-.set noreorder
-.global pipe
-.type pipe,@function
-pipe:
- lui $3, %hi(%neg(%gp_rel(pipe)))
- addiu $3, $3, %lo(%neg(%gp_rel(pipe)))
- addu $3, $3, $25
- li $2, 6021
- syscall
- beq $7, $0, 1f
- nop
- lw $25, %got_disp(__syscall_ret)($3)
- jr $25
- subu $4, $0, $2
-1: sw $2, 0($4)
- sw $3, 4($4)
- move $2, $0
- jr $ra
- nop
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/nice.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/nice.c
deleted file mode 100644
index 1c2295ffc6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/nice.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <sys/resource.h>
-#include <limits.h>
-#include "syscall.h"
-
-int nice(int inc)
-{
- int prio = inc;
- // Only query old priority if it can affect the result.
- // This also avoids issues with integer overflow.
- if (inc > -2*NZERO && inc < 2*NZERO)
- prio += getpriority(PRIO_PROCESS, 0);
- if (prio > NZERO-1) prio = NZERO-1;
- if (prio < -NZERO) prio = -NZERO;
- if (setpriority(PRIO_PROCESS, 0, prio)) {
- if (errno == EACCES)
- errno = EPERM;
- return -1;
- } else {
- return prio;
- }
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pause.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pause.c
deleted file mode 100644
index 90bbf4ca8a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pause.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int pause(void)
-{
-#ifdef SYS_pause
- return syscall_cp(SYS_pause);
-#else
- return syscall_cp(SYS_ppoll, 0, 0, 0, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe.c
deleted file mode 100644
index d07b8d24ae..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int pipe(int fd[2])
-{
-#ifdef SYS_pipe
- return syscall(SYS_pipe, fd);
-#else
- return syscall(SYS_pipe2, fd, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe2.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe2.c
deleted file mode 100644
index f24f74fb03..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pipe2.c
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int pipe2(int fd[2], int flag)
-{
- if (!flag) return pipe(fd);
- int ret = __syscall(SYS_pipe2, fd, flag);
- if (ret != -ENOSYS) return __syscall_ret(ret);
- ret = pipe(fd);
- if (ret) return ret;
- if (flag & O_CLOEXEC) {
- __syscall(SYS_fcntl, fd[0], F_SETFD, FD_CLOEXEC);
- __syscall(SYS_fcntl, fd[1], F_SETFD, FD_CLOEXEC);
- }
- if (flag & O_NONBLOCK) {
- __syscall(SYS_fcntl, fd[0], F_SETFL, O_NONBLOCK);
- __syscall(SYS_fcntl, fd[1], F_SETFL, O_NONBLOCK);
- }
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pread.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pread.c
deleted file mode 100644
index 5681b045d6..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pread.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t pread(int fd, void *buf, size_t size, off_t ofs)
-{
- return syscall_cp(SYS_pread, fd, buf, size, __SYSCALL_LL_PRW(ofs));
-}
-
-weak_alias(pread, pread64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/preadv.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/preadv.c
deleted file mode 100644
index 8376d60f2a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/preadv.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _BSD_SOURCE
-#include <sys/uio.h>
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t preadv(int fd, const struct iovec *iov, int count, off_t ofs)
-{
- return syscall_cp(SYS_preadv, fd, iov, count,
- (long)(ofs), (long)(ofs>>32));
-}
-
-weak_alias(preadv, preadv64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pwrite.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pwrite.c
deleted file mode 100644
index ca37657622..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pwrite.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)
-{
- return syscall_cp(SYS_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs));
-}
-
-weak_alias(pwrite, pwrite64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/pwritev.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/pwritev.c
deleted file mode 100644
index f5a612c486..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/pwritev.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _BSD_SOURCE
-#include <sys/uio.h>
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs)
-{
- return syscall_cp(SYS_pwritev, fd, iov, count,
- (long)(ofs), (long)(ofs>>32));
-}
-
-weak_alias(pwritev, pwritev64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/read.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/read.c
deleted file mode 100644
index f3589c05c3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/read.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t read(int fd, void *buf, size_t count)
-{
- return syscall_cp(SYS_read, fd, buf, count);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/readlink.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/readlink.c
deleted file mode 100644
index 32f4537f97..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/readlink.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize)
-{
- char dummy[1];
- if (!bufsize) {
- buf = dummy;
- bufsize = 1;
- }
-#ifdef SYS_readlink
- int r = __syscall(SYS_readlink, path, buf, bufsize);
-#else
- int r = __syscall(SYS_readlinkat, AT_FDCWD, path, buf, bufsize);
-#endif
- if (buf == dummy && r > 0) r = 0;
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/readlinkat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/readlinkat.c
deleted file mode 100644
index f79d3d1428..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/readlinkat.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize)
-{
- char dummy[1];
- if (!bufsize) {
- buf = dummy;
- bufsize = 1;
- }
- int r = __syscall(SYS_readlinkat, fd, path, buf, bufsize);
- if (buf == dummy && r > 0) r = 0;
- return __syscall_ret(r);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/readv.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/readv.c
deleted file mode 100644
index 91e6de8167..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/readv.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/uio.h>
-#include "syscall.h"
-
-ssize_t readv(int fd, const struct iovec *iov, int count)
-{
- return syscall_cp(SYS_readv, fd, iov, count);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/renameat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/renameat.c
deleted file mode 100644
index c3b40a258b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/renameat.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <stdio.h>
-#include "syscall.h"
-
-int renameat(int oldfd, const char *old, int newfd, const char *new)
-{
-#ifdef SYS_renameat
- return syscall(SYS_renameat, oldfd, old, newfd, new);
-#else
- return syscall(SYS_renameat2, oldfd, old, newfd, new, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/rmdir.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/rmdir.c
deleted file mode 100644
index 6825ffc835..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/rmdir.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int rmdir(const char *path)
-{
-#ifdef SYS_rmdir
- return syscall(SYS_rmdir, path);
-#else
- return syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setegid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setegid.c
deleted file mode 100644
index e6da2573c0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setegid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "libc.h"
-#include "syscall.h"
-
-int setegid(gid_t egid)
-{
- return __setxid(SYS_setresgid, -1, egid, -1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/seteuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/seteuid.c
deleted file mode 100644
index ef8b9df43b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/seteuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int seteuid(uid_t euid)
-{
- return __setxid(SYS_setresuid, -1, euid, -1);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setgid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setgid.c
deleted file mode 100644
index bae4616adb..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setgid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setgid(gid_t gid)
-{
- return __setxid(SYS_setgid, gid, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgid.c
deleted file mode 100644
index 061606951d..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int setpgid(pid_t pid, pid_t pgid)
-{
- return syscall(SYS_setpgid, pid, pgid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgrp.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgrp.c
deleted file mode 100644
index a2a37f65f3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setpgrp.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <unistd.h>
-
-pid_t setpgrp(void)
-{
- return setpgid(0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setregid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setregid.c
deleted file mode 100644
index f5a8972ae4..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setregid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setregid(gid_t rgid, gid_t egid)
-{
- return __setxid(SYS_setregid, rgid, egid, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setresgid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setresgid.c
deleted file mode 100644
index b9af540af2..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setresgid.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setresgid(gid_t rgid, gid_t egid, gid_t sgid)
-{
- return __setxid(SYS_setresgid, rgid, egid, sgid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setresuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setresuid.c
deleted file mode 100644
index 83692b4c99..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setresuid.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setresuid(uid_t ruid, uid_t euid, uid_t suid)
-{
- return __setxid(SYS_setresuid, ruid, euid, suid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setreuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setreuid.c
deleted file mode 100644
index 3fcc59e292..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setreuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setreuid(uid_t ruid, uid_t euid)
-{
- return __setxid(SYS_setreuid, ruid, euid, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setsid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setsid.c
deleted file mode 100644
index 609bbe4ace..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setsid.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-pid_t setsid(void)
-{
- return syscall(SYS_setsid);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setuid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setuid.c
deleted file mode 100644
index 602ecbbf44..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setuid.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-#include "libc.h"
-
-int setuid(uid_t uid)
-{
- return __setxid(SYS_setuid, uid, 0, 0);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/setxid.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/setxid.c
deleted file mode 100644
index 487c1a160a..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/setxid.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <unistd.h>
-#include <signal.h>
-#include "syscall.h"
-#include "libc.h"
-
-struct ctx {
- int id, eid, sid;
- int nr, ret;
-};
-
-static void do_setxid(void *p)
-{
- struct ctx *c = p;
- if (c->ret<0) return;
- int ret = __syscall(c->nr, c->id, c->eid, c->sid);
- if (ret && !c->ret) {
- /* If one thread fails to set ids after another has already
- * succeeded, forcibly killing the process is the only safe
- * thing to do. State is inconsistent and dangerous. Use
- * SIGKILL because it is uncatchable. */
- __block_all_sigs(0);
- __syscall(SYS_kill, __syscall(SYS_getpid), SIGKILL);
- }
- c->ret = ret;
-}
-
-int __setxid(int nr, int id, int eid, int sid)
-{
- /* ret is initially nonzero so that failure of the first thread does not
- * trigger the safety kill above. */
- struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = 1 };
- __synccall(do_setxid, &c);
- return __syscall_ret(c.ret);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/sh/pipe.s b/lib/libc/wasi/libc-top-half/musl/src/unistd/sh/pipe.s
deleted file mode 100644
index 46c4908e7b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/sh/pipe.s
+++ /dev/null
@@ -1,27 +0,0 @@
-.global pipe
-.type pipe, @function
-pipe:
- mov #42, r3
- trapa #31
-
- ! work around hardware bug
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
- or r0, r0
-
- cmp/pz r0
- bt 1f
-
- mov.l L1, r1
- braf r1
- mov r0, r4
-
-1: mov.l r0, @(0,r4)
- mov.l r1, @(4,r4)
- rts
- mov #0, r0
-
-.align 2
-L1: .long __syscall_ret@PLT-(1b-.)
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/sleep.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/sleep.c
deleted file mode 100644
index d64509413e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/sleep.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <unistd.h>
-#include <time.h>
-
-unsigned sleep(unsigned seconds)
-{
- struct timespec tv = { .tv_sec = seconds, .tv_nsec = 0 };
- if (nanosleep(&tv, &tv))
- return tv.tv_sec;
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/symlink.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/symlink.c
deleted file mode 100644
index 0973d78a89..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/symlink.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int symlink(const char *existing, const char *new)
-{
-#ifdef SYS_symlink
- return syscall(SYS_symlink, existing, new);
-#else
- return syscall(SYS_symlinkat, existing, AT_FDCWD, new);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/symlinkat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/symlinkat.c
deleted file mode 100644
index d1c59b4db0..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/symlinkat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int symlinkat(const char *existing, int fd, const char *new)
-{
- return syscall(SYS_symlinkat, existing, fd, new);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/sync.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/sync.c
deleted file mode 100644
index f18765aa85..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/sync.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-void sync(void)
-{
- __syscall(SYS_sync);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/tcgetpgrp.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/tcgetpgrp.c
deleted file mode 100644
index 50080c7e8e..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/tcgetpgrp.c
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <unistd.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-pid_t tcgetpgrp(int fd)
-{
- int pgrp;
- if (ioctl(fd, TIOCGPGRP, &pgrp) < 0)
- return -1;
- return pgrp;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/tcsetpgrp.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/tcsetpgrp.c
deleted file mode 100644
index 67c38cb45c..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/tcsetpgrp.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-int tcsetpgrp(int fd, pid_t pgrp)
-{
- int pgrp_int = pgrp;
- return ioctl(fd, TIOCSPGRP, &pgrp_int);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/truncate.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/truncate.c
deleted file mode 100644
index 9729680076..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/truncate.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int truncate(const char *path, off_t length)
-{
- return syscall(SYS_truncate, path, __SYSCALL_LL_O(length));
-}
-
-weak_alias(truncate, truncate64);
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname.c
deleted file mode 100644
index 0f3e11411b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname.c
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <limits.h>
-
-char *ttyname(int fd)
-{
- static char buf[TTY_NAME_MAX];
- int result;
- if ((result = ttyname_r(fd, buf, sizeof buf))) {
- errno = result;
- return NULL;
- }
- return buf;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname_r.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname_r.c
deleted file mode 100644
index 82acb75e19..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/ttyname_r.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <unistd.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include "syscall.h"
-
-int ttyname_r(int fd, char *name, size_t size)
-{
- struct stat st1, st2;
- char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2];
- ssize_t l;
-
- if (!isatty(fd)) return errno;
-
- __procfdname(procname, fd);
- l = readlink(procname, name, size);
-
- if (l < 0) return errno;
- else if (l == size) return ERANGE;
-
- name[l] = 0;
-
- if (stat(name, &st1) || fstat(fd, &st2))
- return errno;
- if (st1.st_dev != st2.st_dev || st1.st_ino != st2.st_ino)
- return ENODEV;
-
- return 0;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/ualarm.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/ualarm.c
deleted file mode 100644
index 2985855c72..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/ualarm.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <sys/time.h>
-
-unsigned ualarm(unsigned value, unsigned interval)
-{
- struct itimerval it = {
- .it_interval.tv_usec = interval,
- .it_value.tv_usec = value
- }, it_old;
- setitimer(ITIMER_REAL, &it, &it_old);
- return it_old.it_value.tv_sec*1000000 + it_old.it_value.tv_usec;
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/unlink.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/unlink.c
deleted file mode 100644
index c40c28d50b..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/unlink.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include "syscall.h"
-
-int unlink(const char *path)
-{
-#ifdef SYS_unlink
- return syscall(SYS_unlink, path);
-#else
- return syscall(SYS_unlinkat, AT_FDCWD, path, 0);
-#endif
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/unlinkat.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/unlinkat.c
deleted file mode 100644
index e0e25d22a3..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/unlinkat.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-int unlinkat(int fd, const char *path, int flag)
-{
- return syscall(SYS_unlinkat, fd, path, flag);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/usleep.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/usleep.c
deleted file mode 100644
index 6c96652691..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/usleep.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#define _GNU_SOURCE
-#include <unistd.h>
-#include <time.h>
-
-int usleep(unsigned useconds)
-{
- struct timespec tv = {
- .tv_sec = useconds/1000000,
- .tv_nsec = (useconds%1000000)*1000
- };
- return nanosleep(&tv, &tv);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/write.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/write.c
deleted file mode 100644
index 8fd5bc5c26..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/write.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-ssize_t write(int fd, const void *buf, size_t count)
-{
- return syscall_cp(SYS_write, fd, buf, count);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/writev.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/writev.c
deleted file mode 100644
index 5a46c951af..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/writev.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <sys/uio.h>
-#include "syscall.h"
-
-ssize_t writev(int fd, const struct iovec *iov, int count)
-{
- return syscall_cp(SYS_writev, fd, iov, count);
-}
diff --git a/lib/libc/wasi/libc-top-half/musl/src/unistd/x32/lseek.c b/lib/libc/wasi/libc-top-half/musl/src/unistd/x32/lseek.c
deleted file mode 100644
index 3263642953..0000000000
--- a/lib/libc/wasi/libc-top-half/musl/src/unistd/x32/lseek.c
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <unistd.h>
-#include "syscall.h"
-
-off_t __lseek(int fd, off_t offset, int whence)
-{
- off_t ret;
- __asm__ __volatile__ ("syscall"
- : "=a"(ret)
- : "a"(SYS_lseek), "D"(fd), "S"(offset), "d"(whence)
- : "rcx", "r11", "memory");
- return ret < 0 ? __syscall_ret(ret) : ret;
-}
-
-weak_alias(__lseek, lseek);
-weak_alias(__lseek, lseek64);