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

Added all definitions from linux/ptp-clock.h #3353

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3336,6 +3336,8 @@ fn test_linux(target: &str) {
"linux/netlink.h",
// FIXME: requires Linux >= 5.6:
[!musl]: "linux/openat2.h",
"linux/ptp_clock.h",
// FIXME: requires Linux >= 5.6:
[!musl]: "linux/ptrace.h",
"linux/quota.h",
"linux/random.h",
Expand Down
23 changes: 23 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,29 @@ PTHREAD_PRIO_PROTECT
PTHREAD_PROCESS_PRIVATE
PTHREAD_PROCESS_SHARED
PTHREAD_STACK_MIN
PTP_CLOCK_GETCAPS
PTP_CLOCK_GETCAPS2
PTP_ENABLE_PPS
PTP_ENABLE_PPS2
PTP_EXTTS_REQUEST
PTP_EXTTS_REQUEST2
PTP_MAX_SAMPLES
PTP_PEROUT_REQUEST
PTP_PEROUT_REQUEST2
PTP_PF_EXTTS
PTP_PF_NONE
PTP_PF_PEROUT
PTP_PF_PHYSYNC
PTP_PIN_GETFUNC
PTP_PIN_GETFUNC2
PTP_PIN_SETFUNC
PTP_PIN_SETFUNC2
PTP_SYS_OFFSET
PTP_SYS_OFFSET2
PTP_SYS_OFFSET_EXTENDED
PTP_SYS_OFFSET_EXTENDED2
PTP_SYS_OFFSET_PRECISE
PTP_SYS_OFFSET_PRECISE2
PTRACE_ATTACH
PTRACE_CONT
PTRACE_DETACH
Expand Down
108 changes: 108 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,73 @@ s! {
pub val: ::c_int,
}

// linux/ptp_clock.h
pub struct ptp_clock_time {
pub sec: ::__s64,
pub nsec: ::__u32,
pub reserved: ::__u32,
}

pub struct ptp_clock_caps {
pub max_adj: ::c_int,
pub n_alarm: ::c_int,
pub n_ext_ts: ::c_int,
pub n_per_out: ::c_int,
pub pps: ::c_int,
pub n_pins: ::c_int,
pub cross_timestamping: ::c_int,
pub adjust_phase: ::c_int,
pub rsv: [::c_int; 12],
}

pub struct ptp_extts_request {
pub index: ::c_uint,
pub flags: ::c_uint,
pub rsv: [::c_uint; 2],
}

pub struct ptp_perout_request {
pub anonymous_1: __c_anonymous_ptp_perout_request_1,
pub period: ptp_clock_time,
pub index: ::c_uint,
pub flags: ::c_uint,
pub anonymous_2: __c_anonymous_ptp_perout_request_2,
}

pub struct ptp_sys_offset {
pub n_samples: ::c_uint,
pub rsv: [::c_uint; 3],
pub ts: [ptp_clock_time; 51],
}

pub struct ptp_sys_offset_extended {
pub n_samples: ::c_uint,
pub rsv: [::c_uint; 3],
pub ts: [[ptp_clock_time; 3]; 25],
}

pub struct ptp_sys_offset_precise {
pub device: ptp_clock_time,
pub sys_realtime: ptp_clock_time,
pub sys_monoraw: ptp_clock_time,
pub rsv: [::c_uint; 4],
}

pub struct ptp_pin_desc {
pub name: [::c_char; 64],
pub index: ::c_uint,
pub func: ::c_uint,
pub chan: ::c_uint,
pub rsv: [::c_uint; 5],
}

pub struct ptp_extts_event {
pub t: ptp_clock_time,
index: ::c_uint,
flags: ::c_uint,
rsv: [::c_uint; 2],
}

// linux/sctp.h

pub struct sctp_initmsg {
Expand Down Expand Up @@ -804,6 +871,19 @@ s_no_extra_traits! {
pub d_type: ::c_uchar,
pub d_name: [::c_char; 256],
}

// linux/ptp_clock.h
#[cfg(libc_union)]
pub union __c_anonymous_ptp_perout_request_1 {
pub start: ptp_clock_time,
pub phase: ptp_clock_time,
}

#[cfg(libc_union)]
pub union __c_anonymous_ptp_perout_request_2 {
pub on: ptp_clock_time,
pub rsv: [::c_uint; 4],
}
Comment on lines +877 to +886
Copy link
Contributor

Choose a reason for hiding this comment

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

based on

    #[cfg(libc_union)]
    pub union __c_anonymous_ifr_ifru {
        pub ifru_addr: ::sockaddr,
        pub ifru_dstaddr: ::sockaddr,

these need that #[cfg(libc_union)] pragma. Then at the use site they need a "default" (highest size and alignment of the variants, I guess)

    pub struct ifreq {
        /// interface name, e.g. "en0"
        pub ifr_name: [::c_char; ::IFNAMSIZ],
        #[cfg(libc_union)]
        pub ifr_ifru: __c_anonymous_ifr_ifru,
        #[cfg(not(libc_union))]
        pub ifr_ifru: ::sockaddr,
    }

}

s_no_extra_traits! {
Expand Down Expand Up @@ -3182,6 +3262,34 @@ pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13;
pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14;
pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15;

// linux/ptp_clock.h
pub const PTP_MAX_SAMPLES: ::c_uint = 25;

pub const PTP_CLOCK_GETCAPS: ::c_uint = 0x80503d01;
pub const PTP_EXTTS_REQUEST: ::c_uint = 0x40103d02;
pub const PTP_PEROUT_REQUEST: ::c_uint = 0x40383d03;
pub const PTP_ENABLE_PPS: ::c_uint = 0x40043d04;
pub const PTP_SYS_OFFSET: ::c_uint = 0x43403d05;
pub const PTP_PIN_GETFUNC: ::c_uint = 0xc0603d06;
pub const PTP_PIN_SETFUNC: ::c_uint = 0x40603d07;
pub const PTP_SYS_OFFSET_PRECISE: ::c_uint = 0xc0403d08;
pub const PTP_SYS_OFFSET_EXTENDED: ::c_uint = 0xc4c03d09;

pub const PTP_CLOCK_GETCAPS2: ::c_uint = 0x80503d0a;
pub const PTP_EXTTS_REQUEST2: ::c_uint = 0x40103d0b;
pub const PTP_PEROUT_REQUEST2: ::c_uint = 0x40383d0c;
pub const PTP_ENABLE_PPS2: ::c_uint = 0x40043d0d;
pub const PTP_SYS_OFFSET2: ::c_uint = 0x43403d0e;
pub const PTP_PIN_GETFUNC2: ::c_uint = 0xc0603d0f;
pub const PTP_PIN_SETFUNC2: ::c_uint = 0x40603d10;
pub const PTP_SYS_OFFSET_PRECISE2: ::c_uint = 0xc0403d11;
pub const PTP_SYS_OFFSET_EXTENDED2: ::c_uint = 0xc4c03d12;

pub const PTP_PF_NONE: ::c_uint = 0;
pub const PTP_PF_EXTTS: ::c_uint = 1;
pub const PTP_PF_PEROUT: ::c_uint = 2;
pub const PTP_PF_PHYSYNC: ::c_uint = 3;

// linux/tls.h
pub const TLS_GET_RECORD_TYPE: ::c_int = 2;

Expand Down