Skip to content

Commit 9260222

Browse files
committed
src: fix build on certain platforms
The `double` fields in `performance_state` could previously have been aligned at 4-byte instead of 8-byte boundaries, which would have made creating an Float64Array them as a array buffer view for an ArrayBuffer extending over the entire struct an invalid operation. Ref: 67269fd
1 parent 7721456 commit 9260222

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/node_http2.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ enum Http2PaddingBufferFields {
6767
};
6868

6969
struct http2_state {
70+
// doubles first so that they are always sizeof(double)-aligned
71+
double session_state_buffer[IDX_SESSION_STATE_COUNT];
72+
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
7073
uint32_t padding_buffer[PADDING_BUF_FIELD_COUNT];
7174
uint32_t options_buffer[IDX_OPTIONS_FLAGS + 1];
7275
uint32_t settings_buffer[IDX_SETTINGS_COUNT + 1];
73-
double session_state_buffer[IDX_SESSION_STATE_COUNT];
74-
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
7576
};
7677

7778
Freelist<nghttp2_data_chunk_t, FREELIST_MAX>

src/node_perf_common.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ enum PerformanceEntryType {
6161
} while (0);
6262

6363
struct performance_state {
64-
uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
64+
// doubles first so that they are always sizeof(double)-aligned
6565
double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
66+
uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
6667
};
6768

6869
} // namespace performance

0 commit comments

Comments
 (0)