Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 78.6% 11 / 0 / 14
Functions: 100.0% 3 / 0 / 3
Branches: -% 0 / 0 / 0

OMCompiler/SimulationRuntime/c/util/omc_init.c
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 #include <stdio.h>
29 #include "omc_init.h"
30 #include "omc_stackoverflow.h"
31
32 #if defined(OM_HAVE_PTHREADS)
33 pthread_key_t mmc_thread_data_key = 0;
34 pthread_once_t mmc_init_once = PTHREAD_ONCE_INIT;
35 #else
36 threadData_t *OMC_MAIN_THREADDATA_NAME = 0;
37 #endif
38
39 3847 static void mmc_init_nogc_once(void)
40 {
41 #if defined(OM_HAVE_PTHREADS)
42 3847 pthread_key_create(&mmc_thread_data_key,NULL);
43 #endif
44 #if !defined(OMC_MINIMAL_RUNTIME)
45 /* Stack overflow detection is too expensive and fun for small targets
46 * C-code is usually not generated for stack overflow detection anyway... */
47 3847 init_metamodelica_segv_handler();
48 #endif
49 3847 }
50
51 /* The key and the signal handler's alternate stack are per process, but
52 * fmi{1,2,3}Instantiate calls this once per instance. */
53 3847 void mmc_init_nogc(void)
54 {
55 #if defined(OM_HAVE_PTHREADS)
56 static pthread_once_t nogc_once = PTHREAD_ONCE_INIT;
57 3847 pthread_once(&nogc_once, mmc_init_nogc_once);
58 #else
59 static int initialized = 0;
60 if (!initialized) {
61 initialized = 1;
62 mmc_init_nogc_once();
63 }
64 #endif
65 3847 }
66
67 #if defined(OMC_MINIMAL_RUNTIME)
68 ✗ void mmc_init(void)
69 {
70 ✗ fprintf(stderr, "Error: called mmc_init (requesting garbage collection) when OMC was compiled with a minimal runtime system.");
71 ✗ exit(1);
72 }
73 #else
74 #include "../gc/omc_gc.h"
75 3840 void mmc_init(void)
76 {
77 3840 mmc_init_nogc();
78 2677 mmc_GC_init();
79 3840 }
80 #endif
81