Skip to content

Commit f3cffbd

Browse files
committed
src: use uint32_t for process initialization flags enum
Refs: nodejs#45221
1 parent 2a29df6 commit f3cffbd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/node.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ void ResetSignalHandlers() {
432432
}
433433

434434
static std::atomic<uint32_t> init_process_flags = 0;
435+
static_assert(
436+
std::is_same_v<std::underlying_type_t<ProcessInitializationFlags::Flags>,
437+
uint32_t>);
435438

436439
static void PlatformInit(ProcessInitializationFlags::Flags flags) {
437440
// init_process_flags is accessed in ResetStdio(),
@@ -1057,7 +1060,7 @@ std::unique_ptr<InitializationResult> InitializeOncePerProcess(
10571060
}
10581061

10591062
void TearDownOncePerProcess() {
1060-
const uint64_t flags = init_process_flags.load();
1063+
const uint32_t flags = init_process_flags.load();
10611064
ResetStdio();
10621065
if (!(flags & ProcessInitializationFlags::kNoDefaultSignalHandling)) {
10631066
ResetSignalHandlers();

src/node.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,8 @@ class Environment;
227227
class MultiIsolatePlatform;
228228
class InitializationResultImpl;
229229

230-
namespace ProcessFlags {
231-
// TODO(addaleax): Switch to uint32_t to match std::atomic<uint32_t>
232-
// init_process_flags in node.cc
233-
enum Flags : uint64_t {
230+
namespace ProcessInitializationFlags {
231+
enum Flags : uint32_t {
234232
kNoFlags = 0,
235233
// Enable stdio inheritance, which is disabled by default.
236234
// This flag is also implied by kNoStdioInitialization.
@@ -270,9 +268,8 @@ enum Flags : uint64_t {
270268
kNoParseGlobalDebugVariables | kNoAdjustResourceLimits |
271269
kNoUseLargePages | kNoPrintHelpOrVersionOutput,
272270
};
273-
} // namespace ProcessFlags
274-
// TODO(addaleax): Make this the canonical name, as it is more descriptive.
275-
namespace ProcessInitializationFlags = ProcessFlags;
271+
} // namespace ProcessInitializationFlags
272+
namespace ProcessFlags = ProcessInitializationFlags; // Legacy alias.
276273

277274
class NODE_EXTERN InitializationResult {
278275
public:

0 commit comments

Comments
 (0)