ams: deduplicate static initialization logic
This commit is contained in:
@@ -34,7 +34,8 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
EventLogTransmitter &EventLogTransmitter::GetDefaultInstance() {
|
||||
static constinit EventLogTransmitter s_default_event_log_transmitter(DefaultFlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(EventLogTransmitter, s_default_event_log_transmitter, DefaultFlushFunction);
|
||||
|
||||
return s_default_event_log_transmitter;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,10 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
bool DefaultFlushFunction(const u8 *data, size_t size) {
|
||||
/* Declare persistent clock-updated state storage. */
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(bool, s_is_user_system_clock_updated, false);
|
||||
|
||||
/* Update clock. */
|
||||
static constinit bool s_is_user_system_clock_updated = false;
|
||||
if (!s_is_user_system_clock_updated) {
|
||||
UpdateUserSystemClock(data, size);
|
||||
s_is_user_system_clock_updated = true;
|
||||
@@ -84,8 +86,8 @@ namespace ams::lm::srv {
|
||||
}
|
||||
|
||||
LogBuffer &LogBuffer::GetDefaultInstance() {
|
||||
static constinit u8 s_default_buffers[128_KB * 2];
|
||||
static constinit LogBuffer s_default_log_buffer(s_default_buffers, sizeof(s_default_buffers), DefaultFlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(u8, s_default_buffers[128_KB * 2]);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(LogBuffer, s_default_log_buffer, s_default_buffers, sizeof(s_default_buffers), DefaultFlushFunction);
|
||||
|
||||
return s_default_log_buffer;
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
namespace ams::lm::srv {
|
||||
|
||||
CustomSinkBuffer &LogGetterImpl::GetBuffer() {
|
||||
static constinit u8 s_buffer[32_KB];
|
||||
static constinit CustomSinkBuffer s_custom_sink_buffer(s_buffer, sizeof(s_buffer), FlushFunction);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(u8, s_buffer[32_KB]);
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(CustomSinkBuffer, s_custom_sink_buffer, s_buffer, sizeof(s_buffer), FlushFunction);
|
||||
|
||||
return s_custom_sink_buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace ams::lm::srv {
|
||||
size_t carry_size;
|
||||
bool ends_with_text_log;
|
||||
};
|
||||
static constinit PreviousPacketContext s_previous_packet_context = {};
|
||||
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(PreviousPacketContext, s_previous_packet_context);
|
||||
|
||||
/* Get the packet header. */
|
||||
auto *header = static_cast<const impl::LogPacketHeader *>(buffer);
|
||||
|
||||
Reference in New Issue
Block a user