Skip to content

Commit

Permalink
[#81] Fix socket_macros header for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Jan 14, 2024
1 parent 92f4fed commit dbe188a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<!-- NOTE: Add new entries sorted by issue number to minimize the possibility of conflicts when merging. -->

* Fix `clock_nanosleep` on macOS [#80](https://github.com/eclipse-iceoryx/iceoryx2/issues/80)
* Fix broken `sighandler_t` translation [#81](https://github.com/eclipse-iceoryx/iceoryx2/issues/81)

### Refactoring

Expand Down
6 changes: 5 additions & 1 deletion iceoryx2-pal/posix/src/c/socket_macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifdef _WIN64
#include <MSWSock.h>
// clang-format off
// the include order is important, since some headers are defining macros that
// are used in the next header
#include <WinSock2.h>
#include <Windows.h>
#include <MSWSock.h>
#include <io.h>
// clang-format on
#else
#include <sys/select.h>
#include <sys/socket.h>
Expand Down
10 changes: 5 additions & 5 deletions iceoryx2-pal/posix/src/windows/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ impl SigAction {
const fn new() -> Self {
Self {
action: UnsafeCell::new(sigaction_t {
sa_handler: 0,
sa_mask: sigset_t {},
sa_flags: 0,
iox2_sa_handler: 0,
iox2_sa_mask: sigset_t {},
iox2_sa_flags: 0,
}),
mtx: Mutex::new(),
}
Expand Down Expand Up @@ -76,7 +76,7 @@ static SIG_ACTION: SigAction = SigAction::new();

unsafe extern "system" fn ctrl_handler(value: u32) -> i32 {
let action =
core::mem::transmute::<sighandler_t, extern "C" fn(int)>(SIG_ACTION.get().sa_handler);
core::mem::transmute::<sighandler_t, extern "C" fn(int)>(SIG_ACTION.get().iox2_sa_handler);

let sigval = win32_event_to_signal(value);

Expand Down Expand Up @@ -106,7 +106,7 @@ pub unsafe fn sigaction(sig: int, act: *const sigaction_t, oact: *mut sigaction_
(*oact) = SIG_ACTION.set(*act);

if sig == SIGTERM {
if (*act).sa_handler == 0 {
if (*act).iox2_sa_handler == 0 {
SetConsoleCtrlHandler(None, FALSE);
} else {
SetConsoleCtrlHandler(Some(ctrl_handler), TRUE);
Expand Down
12 changes: 6 additions & 6 deletions iceoryx2-pal/posix/src/windows/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ impl Struct for sched_param {}
#[derive(Clone, Copy)]
#[repr(C)]
pub struct sigaction_t {
pub sa_handler: sighandler_t,
pub sa_mask: sigset_t,
pub sa_flags: int,
pub iox2_sa_handler: sighandler_t,
pub iox2_sa_mask: sigset_t,
pub iox2_sa_flags: int,
}

impl Struct for sigaction_t {
fn new() -> Self {
Self {
sa_handler: 0,
sa_mask: sigset_t::new(),
sa_flags: 0,
iox2_sa_handler: 0,
iox2_sa_mask: sigset_t::new(),
iox2_sa_flags: 0,
}
}
}
Expand Down

0 comments on commit dbe188a

Please sign in to comment.