Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add F_PUNCHHOLE and fpunchhole_t #3337

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 41 additions & 39 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ BUFSIZ
BUS_ADRALN
BUS_ADRERR
BUS_OBJERR
CCStatus
CCCryptorStatus
CCRandomGenerateBytes
CCRNGStatus
CCRandomGenerateBytes
CCStatus
CIGNORE
CLD_CONTINUED
CLD_DUMPED
Expand Down Expand Up @@ -442,6 +442,7 @@ F_NOCACHE
F_NODIRECT
F_PEOFPOSMODE
F_PREALLOCATE
F_PUNCHHOLE
F_RDADVISE
F_RDAHEAD
F_RDLCK
Expand Down Expand Up @@ -640,8 +641,8 @@ IPV6_PKTINFO
IPV6_RECVPKTINFO
IPV6_RECVTCLASS
IPV6_TCLASS
IP_HDRINCL
IP_BOUND_IF
IP_HDRINCL
IP_PKTINFO
IP_RECVDSTADDR
IP_RECVIF
Expand Down Expand Up @@ -677,20 +678,20 @@ KERN_FAILURE
KERN_FILE
KERN_HOSTID
KERN_HOSTNAME
KERN_IPC
KERN_INSUFFICIENT_BUFFER_SIZE
KERN_INVALID_ADDRESS
KERN_INVALID_ARGUMENT
KERN_INVALID_HOST
KERN_INVALID_LEDGER
KERN_INVALID_MEMORY_CONTROL
KERN_INVALID_NAME
KERN_INVALID_POLICY
KERN_INVALID_OBJECT
KERN_INVALID_POLICY
KERN_INVALID_RIGHT
KERN_INVALID_SECURITY
KERN_INVALID_TASK
KERN_INVALID_RIGHT
KERN_INVALID_VALUE
KERN_IPC
KERN_JOB_CONTROL
KERN_KDBUFWAIT
KERN_KDCPUMAP
Expand All @@ -714,11 +715,11 @@ KERN_KDSET_TYPEFILTER
KERN_KDTHRMAP
KERN_KDWRITEMAP
KERN_KDWRITETR
KERN_LOGSIGEXIT
KERN_LOCK_OWNED
KERN_LOCK_OWNED_SELF
KERN_LOCK_SET_DESTROYED
KERN_LOCK_UNSTABLE
KERN_LOGSIGEXIT
KERN_LOW_PRI_DELAY
KERN_LOW_PRI_WINDOW
KERN_MAXFILES
Expand Down Expand Up @@ -780,9 +781,9 @@ KERN_SAFEBOOT
KERN_SAVED_IDS
KERN_SECURELVL
KERN_SEMAPHORE_DESTROYED
KERN_SUCCESS
KERN_SHREG_PRIVATIZABLE
KERN_SPECULATIVE_READS
KERN_SUCCESS
KERN_SUGID_COREDUMP
KERN_SYMFILE
KERN_SYSV
Expand Down Expand Up @@ -1272,8 +1273,8 @@ SAE_ASSOCID_ANY
SAE_CONNID_ALL
SAE_CONNID_ANY
SCALE_PPM
SCHED_OTHER
SCHED_FIFO
SCHED_OTHER
SCHED_RR
SCM_CREDS
SCM_RIGHTS
Expand Down Expand Up @@ -1369,12 +1370,12 @@ TCP_MAXSEG
TCP_NOOPT
TCP_NOPUSH
THOUSEP
THREAD_BACKGROUND_POLICY
THREAD_BACKGROUND_POLICY_DARWIN_BG
THREAD_BACKGROUND_POLICY_COUNT
THREAD_AFFINITY_POLICY
THREAD_AFFINITY_POLICY_COUNT
THREAD_AFFINITY_TAG_NULL
THREAD_BACKGROUND_POLICY
THREAD_BACKGROUND_POLICY_COUNT
THREAD_BACKGROUND_POLICY_DARWIN_BG
THREAD_BASIC_INFO
THREAD_BASIC_INFO_COUNT
THREAD_EXTENDED_INFO
Expand Down Expand Up @@ -1671,10 +1672,10 @@ XATTR_SHOWCOMPRESSION
XUCRED_VERSION
YESEXPR
YESSTR
_CS_PATH
_CS_DARWIN_USER_CACHE_DIR
_CS_DARWIN_USER_DIR
_CS_DARWIN_USER_TEMP_DIR
_CS_DARWIN_USER_CACHE_DIR
_CS_PATH
_IOFBF
_IOLBF
_IONBF
Expand Down Expand Up @@ -1742,8 +1743,8 @@ _SC_PRIORITY_SCHEDULING
_SC_RAW_SOCKETS
_SC_READER_WRITER_LOCKS
_SC_REALTIME_SIGNALS
_SC_RE_DUP_MAX
_SC_REGEXP
_SC_RE_DUP_MAX
_SC_RTSIG_MAX
_SC_SAVED_IDS
_SC_SEMAPHORES
Expand Down Expand Up @@ -1843,6 +1844,7 @@ backtrace_from_fp
backtrace_image_offsets
backtrace_symbols
backtrace_symbols_fd
basename
boolean_t
bpf_hdr
brk
Expand Down Expand Up @@ -1870,6 +1872,7 @@ ctime_r
ctl_info
difftime
dirfd
dirname
disconnectx
dqblk
duplocale
Expand All @@ -1889,6 +1892,7 @@ flistxattr
fmemopen
fmount
forkpty
fpunchhole_t
freadlink
freeifaddrs
freelocale
Expand Down Expand Up @@ -2004,13 +2008,13 @@ malloc_zone_t
malloc_zone_valloc
max_align_t
mcontext_t
memory_object_t
mem_entry_name_port_t
memory_object_offset_t
memory_object_t
memset_pattern16
memset_pattern4
memset_pattern8
memset_pattern16
memset_s
mem_entry_name_port_t
mincore
mkdirat
mkfifoat
Expand All @@ -2032,21 +2036,21 @@ openat
openpty
os_log_create
os_log_t
os_log_type_t
os_log_type_enabled
os_log_type_t
os_signpost_enabled
os_signpost_id_generate
os_signpost_id_make_with_pointer
os_signpost_id_t
os_signpost_type_t
os_unfair_lock
os_unfair_lock_assert_not_owner
os_unfair_lock_assert_owner
os_unfair_lock_lock
os_unfair_lock_s
os_unfair_lock_t
os_unfair_lock_lock
os_unfair_lock_trylock
os_unfair_lock_unlock
os_unfair_lock_assert_owner
os_unfair_lock_assert_not_owner
pause
policy_t
popen
Expand Down Expand Up @@ -2077,21 +2081,21 @@ posix_spawnp
preadv
proc_bsdinfo
proc_kmsgbuf
proc_libversion
proc_listallpids
proc_listchildpids
proc_listpgrppids
proc_listpids
proc_libversion
proc_name
proc_pidinfo
proc_pidfdinfo
proc_pidfileportinfo
proc_pidinfo
proc_pidpath
proc_regionfilename
proc_set_no_smt
proc_setthread_no_smt
proc_set_csm
proc_set_no_smt
proc_setthread_csm
proc_setthread_no_smt
proc_taskallinfo
proc_taskinfo
proc_threadinfo
Expand All @@ -2102,33 +2106,33 @@ pseudo_AF_RTIP
pseudo_AF_XTP
pthread_attr_getschedparam
pthread_attr_setschedparam
pthread_cancel
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_cpu_number_np
pthread_create_from_mach_thread
pthread_from_mach_thread_np
pthread_get_stackaddr_np
pthread_get_stacksize_np
pthread_getname_np
pthread_getschedparam
pthread_introspection_getspecific_np
pthread_introspection_hook_t
pthread_introspection_hook_install
pthread_introspection_hook_t
pthread_introspection_setspecific_np
pthread_jit_write_callback_t
pthread_jit_write_freeze_callbacks_np
pthread_jit_write_protect_np
pthread_jit_write_protect_supported_np
pthread_jit_write_with_callback_np
pthread_setschedparam
pthread_cancel
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_from_mach_thread_np
pthread_get_stackaddr_np
pthread_get_stacksize_np
pthread_getname_np
pthread_kill
pthread_main_np
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
pthread_setname_np
pthread_setschedparam
pthread_stack_frame_decode_np
ptrace
pututxline
Expand Down Expand Up @@ -2236,11 +2240,11 @@ thread_identifier_info_t
thread_info
thread_info_t
thread_inspect_t
thread_policy_set
thread_policy_get
thread_policy_set
time_value_t
timeval32
timex
time_value_t
truncate
ttyname_r
ucontext_t
Expand All @@ -2261,5 +2265,3 @@ wait4
waitid
xsw_usage
xucred
dirname
basename
8 changes: 8 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ s! {
pub fst_bytesalloc: ::off_t,
}

pub struct fpunchhole_t {
pub fp_flags: ::c_uint, /* unused */
pub reserved: ::c_uint, /* (to maintain 8-byte alignment) */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: there is no need to expose this field, its sole role is mentioned in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you're right. If I make these private, can people still instantiate the struct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be best to leave them available. I don't believe there's any chance of misuse, and their purposes might change in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point it s easier to instantiate that way indeed. another note, you can amend your commit message with adding
close #<issue id>.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added that to the one of the commit messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, you just need to rebase into 1 commit and you re good :)

pub fp_offset: ::off_t, /* IN: start of the region */
pub fp_length: ::off_t, /* IN: size of the region */
}

pub struct radvisory {
pub ra_offset: ::off_t,
pub ra_count: ::c_int,
Expand Down Expand Up @@ -3241,6 +3248,7 @@ pub const F_GLOBAL_NOCACHE: ::c_int = 55;
pub const F_NODIRECT: ::c_int = 62;
pub const F_LOG2PHYS_EXT: ::c_int = 65;
pub const F_BARRIERFSYNC: ::c_int = 85;
pub const F_PUNCHHOLE: ::c_int = 99;
pub const F_GETPATH_NOFIRMLINK: ::c_int = 102;

pub const F_ALLOCATECONTIG: ::c_uint = 0x02;
Expand Down