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

Signal controlling constants for windows #1626

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,9 @@ fn test_windows(target: &str) {
match name {
// FIXME: API error:
// SIG_ERR type is "void (*)(int)", not "int"
"SIG_ERR" => true,
"SIG_ERR" |
// Similar for SIG_DFL/IGN/GET/SGE/ACK
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add them with the right type ?

"SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true,
_ => false,
}
});
Expand Down
6 changes: 6 additions & 0 deletions src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,13 @@ pub const SIGSEGV: ::c_int = 11;
pub const SIGTERM: ::c_int = 15;
pub const SIGABRT: ::c_int = 22;
pub const NSIG: ::c_int = 23;

pub const SIG_ERR: ::c_int = -1;
Copy link
Member

Choose a reason for hiding this comment

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

#define SIG_ERR ((_crt_signal_t)-1)

Also libc defines sighandler_t as usize when in reality it is:
typedef void (__CRTDECL* _crt_signal_t)(int);

Copy link
Contributor

Choose a reason for hiding this comment

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

Also libc defines sighandler_t as usize when in reality it is:
typedef void (__CRTDECL* _crt_signal_t)(int);

I'll take a PR to fix this, but I'll prefer if this change were in a different PR, and not here. We probably need to do a crater run while rolling in this change.

Copy link
Member

Choose a reason for hiding this comment

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

Just keep in mind we can't naively use extern "C" fn(c_int) as the type because SIG_DFL has a value of 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we need Option<extern "C" fn(c_int) -> ()> or similar (I'm not sure what to do about the __CRTDECL or whether extern "system" or some other ABI has to be used for windows.

Copy link
Member

Choose a reason for hiding this comment

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

__CRTDECL is __cdecl which is extern "cdecl" or extern "C". Most of the CRT uses __CRTDECL.

pub const SIG_DFL: ::sighandler_t = 0;
pub const SIG_IGN: ::sighandler_t = 1;
pub const SIG_GET: ::sighandler_t = 2;
pub const SIG_SGE: ::sighandler_t = 3;
pub const SIG_ACK: ::sighandler_t = 4;
gnzlbg marked this conversation as resolved.
Show resolved Hide resolved

// inline comment below appeases style checker
#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if "
Expand Down