Skip to content

Commit d237eb2

Browse files
authored
Merge branch 'master' into Enable1_redundant_connect
2 parents 5a445f2 + 853b72b commit d237eb2

File tree

16 files changed

+216
-113
lines changed

16 files changed

+216
-113
lines changed

Complex.mo

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,12 @@ operator record Complex "Complex number with overloaded operators"
249249
end 'String';
250250

251251
annotation (
252-
version="4.1.0",
253-
versionDate="2024-01-12",
254-
dateModified = "2024-01-12 19:40:00Z",
252+
version="4.2.0 dev",
253+
versionDate="20xx-xx-xx",
254+
dateModified = "2025-05-23 15:00:00Z",
255255
revisionId="$Format:%h %ci$",
256256
conversion(
257+
noneFromVersion="4.1.0",
257258
noneFromVersion="4.0.0",
258259
noneFromVersion="3.2.3",
259260
noneFromVersion="3.2.2",

Modelica/Resources/BuildProjects/CMake/src.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ set(EXTC_SOURCES
7070
"${MODELICA_SOURCE_DIR}/ModelicaRandom.h"
7171
"${MODELICA_SOURCE_DIR}/ModelicaStrings.c"
7272
"${MODELICA_SOURCE_DIR}/ModelicaStrings.h"
73-
"${MODELICA_SOURCE_DIR}/gconstructor.h"
73+
"${MODELICA_SOURCE_DIR}/g2constructor.h"
7474
"${MODELICA_SOURCE_DIR}/stdint_msvc.h"
7575
"${MODELICA_SOURCE_DIR}/stdint_wrap.h"
7676
"${MODELICA_SOURCE_DIR}/uthash.h"
@@ -84,7 +84,7 @@ set(TABLES_SOURCES
8484
"${MODELICA_SOURCE_DIR}/ModelicaStandardTables.h"
8585
"${MODELICA_SOURCE_DIR}/ModelicaStandardTablesUsertab.c"
8686
"${MODELICA_SOURCE_DIR}/ModelicaMatIO.h"
87-
"${MODELICA_SOURCE_DIR}/gconstructor.h"
87+
"${MODELICA_SOURCE_DIR}/g2constructor.h"
8888
"${MODELICA_SOURCE_DIR}/stdint_msvc.h"
8989
"${MODELICA_SOURCE_DIR}/stdint_wrap.h"
9090
"${MODELICA_SOURCE_DIR}/uthash.h"

Modelica/Resources/C-Sources/ModelicaInternal.c

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
*/
3131

3232
/* Changelog:
33+
Oct. 20, 2024: by Thomas Beutlich
34+
Removed legacy behaviour in ModelicaInternal_stat for
35+
MSVC Visual Studio >= 2015 (ticket #4473)
36+
3337
Jan. 15, 2024: by Thomas Beutlich
3438
Utilized ModelicaDuplicateString and
3539
ModelicaDuplicateStringWithErrorReturn (ticket #3686)
@@ -279,7 +283,7 @@ void ModelicaInternal_setenv(_In_z_ const char* name,
279283
#define HASH_NO_STDINT 1
280284
#define HASH_NONFATAL_OOM 1
281285
#include "uthash.h"
282-
#include "gconstructor.h"
286+
#include "g2constructor.h"
283287

284288
#include <string.h>
285289
#include <stdio.h>
@@ -402,10 +406,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
402406
struct _stat fileInfo;
403407
int statReturn = _stat(name, &fileInfo);
404408
if (0 != statReturn) {
405-
/* For some reason _stat requires "a:\" and "a:\test1" but fails
406-
* on "a:" and "a:\test1\", respectively. It could be handled in the
407-
* Modelica code, but seems better to have it here.
408-
*/
409+
/* _stat requires "a:\" instead of "a:" */
409410
const char* firstSlash = strpbrk(name, "/\\");
410411
const char* firstColon = strchr(name, ':');
411412
const char c = (NULL != firstColon) ? firstColon[1] : '\0';
@@ -419,6 +420,11 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
419420
free(nameTmp);
420421
}
421422
}
423+
#if defined(_MSC_VER) && _MSC_VER >= 1900
424+
/* _stat accepts both "a:\dir" and "a:\dir\" */
425+
#else
426+
/* _stat requires "a:\dir" instead of "a:\dir\" */
427+
/* required for VS 2013 and earlier */
422428
else if (NULL != firstSlash && len > 1 &&
423429
('/' == name[len - 1] || '\\' == name[len - 1])) {
424430
char* nameTmp = (char*)malloc(len*(sizeof(char)));
@@ -429,6 +435,7 @@ static ModelicaFileType Internal_stat(_In_z_ const char* name) {
429435
free(nameTmp);
430436
}
431437
}
438+
#endif
432439
}
433440
if ( statReturn != 0 ) {
434441
type = FileType_NoFile;
@@ -774,16 +781,16 @@ typedef struct FileCache {
774781
static FileCache* fileCache = NULL;
775782
#if defined(_POSIX_) && !defined(NO_MUTEX)
776783
#include <pthread.h>
777-
#if defined(G_HAS_CONSTRUCTORS)
784+
#if defined(G2_HAS_CONSTRUCTORS)
778785
static pthread_mutex_t m;
779-
G_DEFINE_CONSTRUCTOR(initializeMutex)
780-
static void initializeMutex(void) {
786+
G2_DEFINE_CONSTRUCTOR(G2_FUNCNAME(initializeMutex))
787+
static void G2_FUNCNAME(initializeMutex)(void) {
781788
if (pthread_mutex_init(&m, NULL) != 0) {
782789
ModelicaError("Initialization of mutex failed\n");
783790
}
784791
}
785-
G_DEFINE_DESTRUCTOR(destroyMutex)
786-
static void destroyMutex(void) {
792+
G2_DEFINE_DESTRUCTOR(G2_FUNCNAME(destroyMutex))
793+
static void G2_FUNCNAME(destroyMutex)(void) {
787794
if (pthread_mutex_destroy(&m) != 0) {
788795
ModelicaError("Destruction of mutex failed\n");
789796
}
@@ -793,24 +800,24 @@ static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
793800
#endif
794801
#define MUTEX_LOCK() pthread_mutex_lock(&m)
795802
#define MUTEX_UNLOCK() pthread_mutex_unlock(&m)
796-
#elif defined(_WIN32) && defined(G_HAS_CONSTRUCTORS)
803+
#elif defined(_WIN32) && defined(G2_HAS_CONSTRUCTORS)
797804
#if !defined(WIN32_LEAN_AND_MEAN)
798805
#define WIN32_LEAN_AND_MEAN
799806
#endif
800807
#include <windows.h>
801808
static CRITICAL_SECTION cs;
802-
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
803-
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(ModelicaInternal_initializeCS)
809+
#ifdef G2_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
810+
#pragma G2_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaInternal_initializeCS))
804811
#endif
805-
G_DEFINE_CONSTRUCTOR(ModelicaInternal_initializeCS)
806-
static void ModelicaInternal_initializeCS(void) {
812+
G2_DEFINE_CONSTRUCTOR(G2_FUNCNAME(ModelicaInternal_initializeCS))
813+
static void G2_FUNCNAME(ModelicaInternal_initializeCS)(void) {
807814
InitializeCriticalSection(&cs);
808815
}
809-
#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
810-
#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(ModelicaInternal_deleteCS)
816+
#ifdef G2_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
817+
#pragma G2_DEFINE_DESTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaInternal_deleteCS))
811818
#endif
812-
G_DEFINE_DESTRUCTOR(ModelicaInternal_deleteCS)
813-
static void ModelicaInternal_deleteCS(void) {
819+
G2_DEFINE_DESTRUCTOR(G2_FUNCNAME(ModelicaInternal_deleteCS))
820+
static void G2_FUNCNAME(ModelicaInternal_deleteCS)(void) {
814821
DeleteCriticalSection(&cs);
815822
}
816823
#define MUTEX_LOCK() EnterCriticalSection(&cs)

Modelica/Resources/C-Sources/ModelicaRandom.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#include <string.h>
4949
#include "ModelicaInternal.h"
5050
#include "ModelicaUtilities.h"
51-
#include "gconstructor.h"
51+
#include "g2constructor.h"
5252

5353
/* The standard way to detect POSIX is to check _POSIX_VERSION,
5454
* which is defined in <unistd.h>
@@ -68,24 +68,24 @@ static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
6868
#define MUTEX_UNLOCK() pthread_mutex_unlock(&m)
6969

7070
/* On Windows systems define a critical section using the single static variable "cs" */
71-
#elif defined(_WIN32) && defined(G_HAS_CONSTRUCTORS)
71+
#elif defined(_WIN32) && defined(G2_HAS_CONSTRUCTORS)
7272
#if !defined(WIN32_LEAN_AND_MEAN)
7373
#define WIN32_LEAN_AND_MEAN
7474
#endif
7575
#include <windows.h>
7676
static CRITICAL_SECTION cs;
77-
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
78-
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(ModelicaRandom_initializeCS)
77+
#ifdef G2_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
78+
#pragma G2_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaRandom_initializeCS))
7979
#endif
80-
G_DEFINE_CONSTRUCTOR(ModelicaRandom_initializeCS)
81-
static void ModelicaRandom_initializeCS(void) {
80+
G2_DEFINE_CONSTRUCTOR(G2_FUNCNAME(ModelicaRandom_initializeCS))
81+
static void G2_FUNCNAME(ModelicaRandom_initializeCS)(void) {
8282
InitializeCriticalSection(&cs);
8383
}
84-
#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
85-
#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(ModelicaRandom_deleteCS)
84+
#ifdef G2_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
85+
#pragma G2_DEFINE_DESTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaRandom_deleteCS))
8686
#endif
87-
G_DEFINE_DESTRUCTOR(ModelicaRandom_deleteCS)
88-
static void ModelicaRandom_deleteCS(void) {
87+
G2_DEFINE_DESTRUCTOR(G2_FUNCNAME(ModelicaRandom_deleteCS))
88+
static void G2_FUNCNAME(ModelicaRandom_deleteCS)(void) {
8989
DeleteCriticalSection(&cs);
9090
}
9191
#define MUTEX_LOCK() EnterCriticalSection(&cs)

Modelica/Resources/C-Sources/ModelicaStandardTables.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
#define uthash_strlen(s) key_strlen(s)
195195
#define HASH_NONFATAL_OOM 1
196196
#include "uthash.h"
197-
#include "gconstructor.h"
197+
#include "g2constructor.h"
198198
#endif
199199
#include <assert.h>
200200
#include <float.h>
@@ -433,16 +433,16 @@ typedef struct TableShare {
433433
static TableShare* tableShare = NULL;
434434
#if defined(_POSIX_) && !defined(NO_MUTEX)
435435
#include <pthread.h>
436-
#if defined(G_HAS_CONSTRUCTORS)
436+
#if defined(G2_HAS_CONSTRUCTORS)
437437
static pthread_mutex_t m;
438-
G_DEFINE_CONSTRUCTOR(initializeMutex)
439-
static void initializeMutex(void) {
438+
G2_DEFINE_CONSTRUCTOR(G2_FUNCNAME(initializeMutex))
439+
static void G2_FUNCNAME(initializeMutex)(void) {
440440
if (pthread_mutex_init(&m, NULL) != 0) {
441441
ModelicaError("Initialization of mutex failed\n");
442442
}
443443
}
444-
G_DEFINE_DESTRUCTOR(destroyMutex)
445-
static void destroyMutex(void) {
444+
G2_DEFINE_DESTRUCTOR(G2_FUNCNAME(destroyMutex))
445+
static void G2_FUNCNAME(destroyMutex)(void) {
446446
if (pthread_mutex_destroy(&m) != 0) {
447447
ModelicaError("Destruction of mutex failed\n");
448448
}
@@ -452,24 +452,24 @@ static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
452452
#endif
453453
#define MUTEX_LOCK() pthread_mutex_lock(&m)
454454
#define MUTEX_UNLOCK() pthread_mutex_unlock(&m)
455-
#elif defined(_WIN32) && defined(G_HAS_CONSTRUCTORS)
455+
#elif defined(_WIN32) && defined(G2_HAS_CONSTRUCTORS)
456456
#if !defined(WIN32_LEAN_AND_MEAN)
457457
#define WIN32_LEAN_AND_MEAN
458458
#endif
459459
#include <windows.h>
460460
static CRITICAL_SECTION cs;
461-
#ifdef G_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
462-
#pragma G_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(ModelicaStandardTables_initializeCS)
461+
#ifdef G2_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
462+
#pragma G2_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaStandardTables_initializeCS))
463463
#endif
464-
G_DEFINE_CONSTRUCTOR(ModelicaStandardTables_initializeCS)
465-
static void ModelicaStandardTables_initializeCS(void) {
464+
G2_DEFINE_CONSTRUCTOR(G2_FUNCNAME(ModelicaStandardTables_initializeCS))
465+
static void G2_FUNCNAME(ModelicaStandardTables_initializeCS)(void) {
466466
InitializeCriticalSection(&cs);
467467
}
468-
#ifdef G_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
469-
#pragma G_DEFINE_DESTRUCTOR_PRAGMA_ARGS(ModelicaStandardTables_deleteCS)
468+
#ifdef G2_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
469+
#pragma G2_DEFINE_DESTRUCTOR_PRAGMA_ARGS(G2_FUNCNAME(ModelicaStandardTables_deleteCS))
470470
#endif
471-
G_DEFINE_DESTRUCTOR(ModelicaStandardTables_deleteCS)
472-
static void ModelicaStandardTables_deleteCS(void) {
471+
G2_DEFINE_DESTRUCTOR(G2_FUNCNAME(ModelicaStandardTables_deleteCS))
472+
static void G2_FUNCNAME(ModelicaStandardTables_deleteCS)(void) {
473473
DeleteCriticalSection(&cs);
474474
}
475475
#define MUTEX_LOCK() EnterCriticalSection(&cs)

0 commit comments

Comments
 (0)