Skip to content

Commit

Permalink
src: fix build on certain platforms
Browse files Browse the repository at this point in the history
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
  • Loading branch information
addaleax committed Aug 24, 2017
1 parent 7721456 commit 9260222
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ enum Http2PaddingBufferFields {
};

struct http2_state {
// doubles first so that they are always sizeof(double)-aligned
double session_state_buffer[IDX_SESSION_STATE_COUNT];
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
uint32_t padding_buffer[PADDING_BUF_FIELD_COUNT];
uint32_t options_buffer[IDX_OPTIONS_FLAGS + 1];
uint32_t settings_buffer[IDX_SETTINGS_COUNT + 1];
double session_state_buffer[IDX_SESSION_STATE_COUNT];
double stream_state_buffer[IDX_STREAM_STATE_COUNT];
};

Freelist<nghttp2_data_chunk_t, FREELIST_MAX>
Expand Down
3 changes: 2 additions & 1 deletion src/node_perf_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ enum PerformanceEntryType {
} while (0);

struct performance_state {
uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
// doubles first so that they are always sizeof(double)-aligned
double milestones[NODE_PERFORMANCE_MILESTONE_INVALID];
uint32_t observers[NODE_PERFORMANCE_ENTRY_TYPE_INVALID];
};

} // namespace performance
Expand Down

0 comments on commit 9260222

Please sign in to comment.