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

Macos aarch64 clock uptime const #2689

Merged
merged 3 commits into from
Feb 18, 2022

Conversation

lyinch
Copy link
Contributor

@lyinch lyinch commented Feb 17, 2022

This will add the constant CLOCK_UPTIME_RAW from time.h on macos apple silicon. I don't know if the same constant also exists for other systems, so I put it into the most specific file. Background is this issue: rust-lang/rust#91417 which might need the constant.

On my machine, it is defined as:

typedef enum {
_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
#define CLOCK_REALTIME _CLOCK_REALTIME
_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
#endif
_CLOCK_PROCESS_CPUTIME_ID __CLOCK_AVAILABILITY = 12,
#define CLOCK_PROCESS_CPUTIME_ID _CLOCK_PROCESS_CPUTIME_ID
_CLOCK_THREAD_CPUTIME_ID __CLOCK_AVAILABILITY = 16
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
} clockid_t;

I ran the tests in libc-test :

% cargo test
   Compiling libc v0.2.118 (/Users/backes/dev/libc)
   Compiling libc-test v0.2.118 (/Users/backes/dev/libc/libc-test)
    Finished test [unoptimized + debuginfo] target(s) in 10.40s
     Running test/cmsg.rs (/Users/backes/dev/libc/target/debug/deps/cmsg-1a9cf9acb3bfd606)

running 5 tests
test t::test_cmsg_firsthdr ... ok
test t::test_cmsg_data ... ok
test t::test_cmsg_space ... ok
test t::test_cmsg_len ... ok
test t::test_cmsg_nxthdr ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.32s

     Running test/errqueue.rs (/Users/backes/dev/libc/target/debug/deps/errqueue-34a57aa145f73969)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running test/linux_elf.rs (/Users/backes/dev/libc/target/debug/deps/linux_elf-0d81190c35086f0f)
PASSED 0 tests
     Running test/linux_fcntl.rs (/Users/backes/dev/libc/target/debug/deps/linux_fcntl-35043d47b0ba1ab8)
PASSED 0 tests
     Running test/linux_if_arp.rs (/Users/backes/dev/libc/target/debug/deps/linux_if_arp-7d13a47b02694998)
PASSED 0 tests
     Running test/linux_ipv6.rs (/Users/backes/dev/libc/target/debug/deps/linux_ipv6-019e5b7c295e467b)
PASSED 0 tests
     Running test/linux_strerror_r.rs (/Users/backes/dev/libc/target/debug/deps/linux_strerror_r-177f4ad6f4f31457)
PASSED 0 tests
     Running test/linux_termios.rs (/Users/backes/dev/libc/target/debug/deps/linux_termios-0ef27e1d55afb4db)
PASSED 0 tests
     Running test/main.rs (/Users/backes/dev/libc/target/debug/deps/main-112b28ce12de7d4b)
RUNNING ALL TESTS
PASSED 13288 tests
     Running test/semver.rs (/Users/backes/dev/libc/target/debug/deps/semver-e9e1e170582c8b37)
PASSED 1 tests
     Running test/sigrt.rs (/Users/backes/dev/libc/target/debug/deps/sigrt-13dc29f6aa83ea4c)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@Amanieu
Copy link
Member

Amanieu commented Feb 18, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Feb 18, 2022

📌 Commit 16214c4 has been approved by Amanieu

bors added a commit that referenced this pull request Feb 18, 2022
Macos aarch64 clock uptime const

This will add the constant `CLOCK_UPTIME_RAW` from `time.h` on macos apple silicon. I don't know if the same constant also exists for other systems, so I put it into the most specific file. Background is this issue: rust-lang/rust#91417 which might need the constant.

On my machine, it is defined as:

```C
typedef enum {
_CLOCK_REALTIME __CLOCK_AVAILABILITY = 0,
#define CLOCK_REALTIME _CLOCK_REALTIME
_CLOCK_MONOTONIC __CLOCK_AVAILABILITY = 6,
#define CLOCK_MONOTONIC _CLOCK_MONOTONIC
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
#endif
_CLOCK_PROCESS_CPUTIME_ID __CLOCK_AVAILABILITY = 12,
#define CLOCK_PROCESS_CPUTIME_ID _CLOCK_PROCESS_CPUTIME_ID
_CLOCK_THREAD_CPUTIME_ID __CLOCK_AVAILABILITY = 16
#define CLOCK_THREAD_CPUTIME_ID _CLOCK_THREAD_CPUTIME_ID
} clockid_t;
```

I ran the tests in `libc-test` :
```
% cargo test
   Compiling libc v0.2.118 (/Users/backes/dev/libc)
   Compiling libc-test v0.2.118 (/Users/backes/dev/libc/libc-test)
    Finished test [unoptimized + debuginfo] target(s) in 10.40s
     Running test/cmsg.rs (/Users/backes/dev/libc/target/debug/deps/cmsg-1a9cf9acb3bfd606)

running 5 tests
test t::test_cmsg_firsthdr ... ok
test t::test_cmsg_data ... ok
test t::test_cmsg_space ... ok
test t::test_cmsg_len ... ok
test t::test_cmsg_nxthdr ... ok

test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.32s

     Running test/errqueue.rs (/Users/backes/dev/libc/target/debug/deps/errqueue-34a57aa145f73969)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running test/linux_elf.rs (/Users/backes/dev/libc/target/debug/deps/linux_elf-0d81190c35086f0f)
PASSED 0 tests
     Running test/linux_fcntl.rs (/Users/backes/dev/libc/target/debug/deps/linux_fcntl-35043d47b0ba1ab8)
PASSED 0 tests
     Running test/linux_if_arp.rs (/Users/backes/dev/libc/target/debug/deps/linux_if_arp-7d13a47b02694998)
PASSED 0 tests
     Running test/linux_ipv6.rs (/Users/backes/dev/libc/target/debug/deps/linux_ipv6-019e5b7c295e467b)
PASSED 0 tests
     Running test/linux_strerror_r.rs (/Users/backes/dev/libc/target/debug/deps/linux_strerror_r-177f4ad6f4f31457)
PASSED 0 tests
     Running test/linux_termios.rs (/Users/backes/dev/libc/target/debug/deps/linux_termios-0ef27e1d55afb4db)
PASSED 0 tests
     Running test/main.rs (/Users/backes/dev/libc/target/debug/deps/main-112b28ce12de7d4b)
RUNNING ALL TESTS
PASSED 13288 tests
     Running test/semver.rs (/Users/backes/dev/libc/target/debug/deps/semver-e9e1e170582c8b37)
PASSED 1 tests
     Running test/sigrt.rs (/Users/backes/dev/libc/target/debug/deps/sigrt-13dc29f6aa83ea4c)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
```
@bors
Copy link
Contributor

bors commented Feb 18, 2022

⌛ Testing commit 16214c4 with merge e306013...

@bors
Copy link
Contributor

bors commented Feb 18, 2022

💔 Test failed - checks-actions

@Amanieu
Copy link
Member

Amanieu commented Feb 18, 2022

@bors retry

@bors
Copy link
Contributor

bors commented Feb 18, 2022

⌛ Testing commit 16214c4 with merge 06a5677...

@bors
Copy link
Contributor

bors commented Feb 18, 2022

☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13
Approved by: Amanieu
Pushing 06a5677 to master...

@bors bors merged commit 06a5677 into rust-lang:master Feb 18, 2022
@lyinch lyinch mentioned this pull request Feb 18, 2022
bors added a commit that referenced this pull request Feb 19, 2022
Bump version to 0.2.119

I'd like a new release because rust-lang/rust#94100 requires the merged PR: #2689
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 18, 2022
Issue rust-lang#91417 fix

This is a regression test and a fixes rust-lang#91417
It also bumps the libc version to 0.2.119 because it requires the constant introduced here: rust-lang/libc#2689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants