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

Exposed malloc_size on Mac #2921

Merged
merged 3 commits into from Sep 23, 2022
Merged

Exposed malloc_size on Mac #2921

merged 3 commits into from Sep 23, 2022

Conversation

naricc
Copy link
Contributor

@naricc naricc commented Sep 23, 2022

This change exposes malloc_size, which is available in libc on MacOSX.

@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.

@naricc naricc changed the title Exposed malloc_size on bsd Exposed malloc_size on Mac Sep 23, 2022
@JohnTitor
Copy link
Member

@devnexen
Copy link
Contributor

I may suggest to add malloc_good_size as well since they re somewhat related, but no worries it can be added in a separate PR otherwise :).

@naricc
Copy link
Contributor Author

naricc commented Sep 23, 2022

@JohnTitor I've added it to apple.txt. I've got to admit I am a little confused though; what is apple.txt actually used for?

@devnexen That is a good idea; I may as well add it while I am doing this, since they tend to be used together.

@JohnTitor
Copy link
Member

@JohnTitor I've added it to apple.txt. I've got to admit I am a little confused though; what is apple.txt actually used for?

Read https://github.com/rust-lang/libc/blob/master/CONTRIBUTING.md and

libc/libc-test/build.rs

Lines 85 to 153 in d696739

fn do_semver() {
let mut out = PathBuf::from(env::var("OUT_DIR").unwrap());
out.push("semver.rs");
let mut output = BufWriter::new(File::create(&out).unwrap());
let family = env::var("CARGO_CFG_TARGET_FAMILY").unwrap();
let vendor = env::var("CARGO_CFG_TARGET_VENDOR").unwrap();
let os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
// `libc-test/semver` dir.
let mut semver_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
semver_root.push("semver");
// NOTE: Windows has the same `family` as `os`, no point in including it
// twice.
// NOTE: Android doesn't include the unix file (or the Linux file) because
// there are some many definitions missing it's actually easier just to
// maintain a file for Android.
if family != os && os != "android" {
process_semver_file(&mut output, &mut semver_root, &family);
}
process_semver_file(&mut output, &mut semver_root, &vendor);
process_semver_file(&mut output, &mut semver_root, &os);
let os_arch = format!("{}-{}", os, arch);
process_semver_file(&mut output, &mut semver_root, &os_arch);
if target_env != "" {
let os_env = format!("{}-{}", os, target_env);
process_semver_file(&mut output, &mut semver_root, &os_env);
let os_env_arch = format!("{}-{}-{}", os, target_env, arch);
process_semver_file(&mut output, &mut semver_root, &os_env_arch);
}
}
fn process_semver_file<W: Write, P: AsRef<Path>>(output: &mut W, path: &mut PathBuf, file: P) {
// NOTE: `path` is reused between calls, so always remove the file again.
path.push(file);
path.set_extension("txt");
println!("cargo:rerun-if-changed={}", path.display());
let input_file = match File::open(&*path) {
Ok(file) => file,
Err(ref err) if err.kind() == io::ErrorKind::NotFound => {
path.pop();
return;
}
Err(err) => panic!("unexpected error opening file: {}", err),
};
let input = BufReader::new(input_file);
write!(output, "// Source: {}.\n", path.display()).unwrap();
output.write(b"use libc::{\n").unwrap();
for line in input.lines() {
let line = line.unwrap().into_bytes();
match line.first() {
// Ignore comments and empty lines.
Some(b'#') | None => continue,
_ => {
output.write(b" ").unwrap();
output.write(&line).unwrap();
output.write(b",\n").unwrap();
}
}
}
output.write(b"};\n\n").unwrap();
path.pop();
}
. On FLOSS, CONTRIBUTING.md contains useful information for new contributors and it's good to read in general :)

@bors r+

@bors
Copy link
Contributor

bors commented Sep 23, 2022

📌 Commit ada0d39 has been approved by JohnTitor

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Sep 23, 2022

⌛ Testing commit ada0d39 with merge 40f3556...

bors added a commit that referenced this pull request Sep 23, 2022
Exposed malloc_size on Mac

This change exposes malloc_size, which is available in libc on MacOSX.
@bors
Copy link
Contributor

bors commented Sep 23, 2022

💔 Test failed - checks-actions

@JohnTitor
Copy link
Member

Let me check if it's spurious or not, @bors retry

@bors
Copy link
Contributor

bors commented Sep 23, 2022

⌛ Testing commit ada0d39 with merge 35cd8f0...

@bors
Copy link
Contributor

bors commented Sep 23, 2022

☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14
Approved by: JohnTitor
Pushing 35cd8f0 to master...

@bors bors merged commit 35cd8f0 into rust-lang:master Sep 23, 2022
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.

None yet

6 participants