Skip to content

signal: make evsig_base atomic.#1105

Open
htuch wants to merge 1 commit intolibevent:masterfrom
htuch:atomic-signal-base
Open

signal: make evsig_base atomic.#1105
htuch wants to merge 1 commit intolibevent:masterfrom
htuch:atomic-signal-base

Conversation

@htuch
Copy link
Copy Markdown

@htuch htuch commented Oct 13, 2020

Fixes #779.

Signed-off-by: Harvey Tuch htuch@google.com

Fixes libevent#779.

Signed-off-by: Harvey Tuch <htuch@google.com>
#include <sys/socket.h>
#endif
#include <signal.h>
#include <stdatomic.h>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This breaks windows build:

D:\a\libevent\libevent\signal.c(47): fatal error C1083: Cannot open include file: 'stdatomic.h': No such file or directory [D:\a\libevent\libevent\build\event_core_shared.vcxproj]

https://github.com/libevent/libevent/pull/1105/checks?check_run_id=1245032772#step:5:126

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@htuch can you address this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't currently have the ability to build on Windows, so not sure if I can help with this.

@yogo1212
Copy link
Copy Markdown
Contributor

yogo1212 commented Oct 23, 2022

microsoft explicitly excludes stdatomics from the list of supported features in their standard library.
the c++ <atomic> is supported, however.

in mimalloc, the Interlocked* API is used to implement the corresponding features.
https://github.com/microsoft/mimalloc/blob/master/include/mimalloc-atomic.h

maybe the simplest solution is to do something similar?

#if defined(_MSC_VER)
// might have to loop _load:
#define atomic_load(object) InterlockedCompareExchange((object), 0, 0)
#define atomic_store(object, value) (void) InterlockedExchange((object), (value))
#endif

@azat
Copy link
Copy Markdown
Member

azat commented Oct 23, 2022

Yes, this will work. @yogo1212 can you submit a PR?

@yogo1212 yogo1212 mentioned this pull request Oct 26, 2022
@azat
Copy link
Copy Markdown
Member

azat commented Nov 12, 2022

Closed in favor of #1363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

evsig_base is thread unsafe

3 participants