Skip to content

Commit

Permalink
Merge pull request #27 from konstin/update-trampolines
Browse files Browse the repository at this point in the history
Update trampolines code
  • Loading branch information
njsmith authored Jan 25, 2024
2 parents 61ff56c + 3d067ee commit dda22e6
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 44 deletions.
61 changes: 35 additions & 26 deletions src/trampolines/windows-trampolines/posy-trampoline/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ debug = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
windows-sys = { version = "0.42.0", features = [
windows-sys = { version = "0.52.0", features = [
"Win32_Foundation",
"Win32_Security",
"Win32_Storage_FileSystem",
Expand All @@ -49,8 +49,8 @@ windows-sys = { version = "0.42.0", features = [
# - Use -Zbuild-std=... -Zbuild-std-features=compiler-builtins-mem, which enables
# the mem feature on the built-in builtins.
#compiler_builtins = { version = "*", features = ["mem"]}
ufmt-write = "*"
ufmt = "*"
ufmt-write = "0.1.0"
ufmt = "0.2.0"

[build-dependencies]
embed-manifest = "*"
embed-manifest = "1.4.0"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(default_alloc_error_handler)]
#![no_std]
#![no_main]
#![windows_subsystem = "console"]
Expand All @@ -7,4 +6,4 @@
#[no_mangle]
pub extern "C" fn entry() -> ! {
posy_trampoline::bounce::bounce(false)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(default_alloc_error_handler)]
#![no_std]
#![no_main]
#![windows_subsystem = "windows"]
Expand All @@ -7,4 +6,4 @@
#[no_mangle]
pub extern "C" fn entry() -> ! {
posy_trampoline::bounce::bounce(true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use windows_sys::Win32::{
Environment::{GetCommandLineA, GetEnvironmentVariableA, SetCurrentDirectoryA},
JobObjects::*,
Threading::*,
WindowsProgramming::INFINITE,
},
UI::WindowsAndMessaging::*,
};
Expand All @@ -32,7 +31,7 @@ fn getenv(name: &CStr) -> Option<CString> {
value.capacity() as u32,
);
value.set_len(count as usize);
return Some(CString::from_vec_with_nul_unchecked(value));
Some(CString::from_vec_with_nul_unchecked(value))
}
}

Expand All @@ -45,7 +44,7 @@ fn make_child_cmdline(is_gui: bool) -> Vec<u8> {
} else {
c!("POSY_PYTHON")
};
let python_exe = getenv(&envvar);
let python_exe = getenv(envvar);
if python_exe.is_none() {
eprintln!(
"need {} to be set",
Expand All @@ -56,9 +55,9 @@ fn make_child_cmdline(is_gui: bool) -> Vec<u8> {
let python_exe = python_exe.unwrap_unchecked();

let mut child_cmdline = Vec::<u8>::new();
child_cmdline.push('"' as u8);
child_cmdline.push(b'"');
for byte in python_exe.as_bytes() {
if *byte == '"' as u8 {
if *byte == b'"' {
// 3 double quotes: one to end the quoted span, one to become a literal double-quote,
// and one to start a new quoted span.
child_cmdline.extend(br#"""""#);
Expand Down Expand Up @@ -139,12 +138,12 @@ fn close_handles(si: &STARTUPINFOA) {
SetStdHandle(handle, INVALID_HANDLE_VALUE);
}

if si.cbReserved2 == 0 || si.lpReserved2 == null_mut() {
if si.cbReserved2 == 0 || si.lpReserved2.is_null() {
return;
}
let crt_magic = si.lpReserved2 as *const u32;
let handle_count = crt_magic.read_unaligned() as isize;
let handle_start = crt_magic.offset(1 + handle_count as isize);
let handle_start = crt_magic.offset(1 + handle_count);
for i in 0..handle_count {
CloseHandle(handle_start.offset(i).read_unaligned() as HANDLE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl uWrite for DiagnosticBuffer {
#[macro_export]
macro_rules! eprintln {
($($tt:tt)*) => {{
let mut d = crate::diagnostics::DiagnosticBuffer::new();
let mut d = $crate::diagnostics::DiagnosticBuffer::new();
_ = ufmt::uwriteln!(&mut d, $($tt)*);
d.display();
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ macro_rules! check {
);
let msg = core::slice::from_raw_parts(msg_ptr, size as usize);
let msg = core::str::from_utf8_unchecked(msg);
crate::eprintln!("Error: {} (from {})", msg, stringify!($e));
$crate::eprintln!("Error: {} (from {})", msg, stringify!($e));
ExitProcess(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsafe impl GlobalAlloc for SystemAlloc {
}

#[panic_handler]
pub extern "C" fn panic(info: &core::panic::PanicInfo) -> ! {
fn panic(info: &core::panic::PanicInfo) -> ! {
if let Some(location) = info.location() {
let mut msg = "(couldn't format message)";
if let Some(msg_args) = info.message() {
Expand Down

0 comments on commit dda22e6

Please sign in to comment.