From 7f0379c8dda0b34d75ca1234e4068aeac9ac8841 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 9 Nov 2020 08:09:27 +0100 Subject: libtrace: Move _Record_Stream_header_initialize() This fixes the build if no function sections are used. --- cpukit/libtrace/record/record-stream-header.c | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 cpukit/libtrace/record/record-stream-header.c (limited to 'cpukit/libtrace/record/record-stream-header.c') diff --git a/cpukit/libtrace/record/record-stream-header.c b/cpukit/libtrace/record/record-stream-header.c new file mode 100644 index 0000000000..40356a369c --- /dev/null +++ b/cpukit/libtrace/record/record-stream-header.c @@ -0,0 +1,140 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/* + * Copyright (C) 2018, 2019 embedded brains GmbH + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include +#include + +size_t _Record_Stream_header_initialize( Record_Stream_header *header ) +{ + rtems_record_item *items; + size_t available; + size_t used; + const char *str; + +#if BYTE_ORDER == LITTLE_ENDIAN +#if __INTPTR_WIDTH__ == 32 + header->format = RTEMS_RECORD_FORMAT_LE_32, +#elif __INTPTR_WIDTH__ == 64 + header->format = RTEMS_RECORD_FORMAT_LE_64, +#else +#error "unexpected __INTPTR_WIDTH__" +#endif +#elif BYTE_ORDER == BIG_ENDIAN +#if __INTPTR_WIDTH__ == 32 + header->format = RTEMS_RECORD_FORMAT_BE_32, +#elif __INTPTR_WIDTH__ == 64 + header->format = RTEMS_RECORD_FORMAT_BE_64, +#else +#error "unexpected __INTPTR_WIDTH__" +#endif +#else +#error "unexpected BYTE_ORDER" +#endif + + header->magic = RTEMS_RECORD_MAGIC; + + header->Version.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_VERSION ); + header->Version.data = RTEMS_RECORD_THE_VERSION; + + header->Processor_maximum.event = + RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PROCESSOR_MAXIMUM ); + header->Processor_maximum.data = rtems_scheduler_get_processor_maximum() - 1; + + header->Count.event = RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_PER_CPU_COUNT ); + header->Count.data = _Record_Configuration.item_count; + + header->Frequency.event = + RTEMS_RECORD_TIME_EVENT( 0, RTEMS_RECORD_FREQUENCY ); + header->Frequency.data = rtems_counter_frequency(); + + items = header->Info; + available = RTEMS_ARRAY_SIZE( header->Info ); + + str = CPU_NAME; + used = _Record_String_to_items( + RTEMS_RECORD_ARCH, + str, + strlen( str ), + items, + available + ); + items += used; + available -= used; + + str = CPU_MODEL_NAME; + used = _Record_String_to_items( + RTEMS_RECORD_MULTILIB, + str, + strlen( str ), + items, + available + ); + items += used; + available -= used; + + str = rtems_board_support_package(); + used = _Record_String_to_items( + RTEMS_RECORD_BSP, + str, + strlen( str ), + items, + available + ); + items += used; + available -= used; + + str = rtems_version_control_key(); + used = _Record_String_to_items( + RTEMS_RECORD_VERSION_CONTROL_KEY, + str, + strlen( str ), + items, + available + ); + items += used; + available -= used; + + str = __VERSION__; + used = _Record_String_to_items( + RTEMS_RECORD_TOOLS, + str, + strlen( str ), + items, + available + ); + items += used; + + return (size_t) ( (char *) items - (char *) header ); +} -- cgit v1.2.3