Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
fix windows GCC now :)
Browse files Browse the repository at this point in the history
- more checks for pthread: attribute init, stack setting

Belonging to [master]:
  - #2215
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Feb 16, 2018
1 parent 325b392 commit 69b2c90
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
35 changes: 33 additions & 2 deletions Compiler/runtime/System_omc.c
Expand Up @@ -815,8 +815,39 @@ extern void* System_launchParallelTasks(threadData_t *threadData, int numThreads
#if defined(__MINGW32__)
/* adrpo: set thread stack size on Windows to 4MB */
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 4194304);
if (pthread_attr_init(&attr))
{
const char *tok[1] = {strerror(errno)};
data.fail = 1;
c_add_message(NULL,5999,
ErrorType_scripting,
ErrorLevel_internal,
gettext("System.launchParallelTasks: failed to initialize the pthread attributes: %s"),
NULL,
0);
MMC_THROW_INTERNAL();
}
/* try to set a stack size of 4MB */
if (pthread_attr_setstacksize(&attr, 4194304))
{
/* did not work, try half 2MB */
if (pthread_attr_setstacksize(&attr, 2097152))
{
/* did not work, try half 1MB */
if (pthread_attr_setstacksize(&attr, 1048576))
{
const char *tok[1] = {strerror(errno)};
data.fail = 1;
c_add_message(NULL,5999,
ErrorType_scripting,
ErrorLevel_internal,
gettext("System.launchParallelTasks: failed to set the pthread stack size to 1MB: %s"),
NULL,
0);
MMC_THROW_INTERNAL();
}
}
}
#endif

#else /* MSVC */
Expand Down
Expand Up @@ -40,7 +40,11 @@
#include <assert.h>

#if defined(__MINGW32__) || defined(_MSC_VER)
// #include <winsock2.h> /* htonl */

#if defined(__MINGW32__)
#include <winsock2.h> /* htonl */
#endif

#if defined(_MSC_VER)
#include <stdint.h> /* for int32_t */
#endif
Expand Down

0 comments on commit 69b2c90

Please sign in to comment.