forked from OSchip/llvm-project
Minor code cleanup of Klocwork issues
Minor code cleanup of Klocwork issues. Fatal messages are given no return attribute. Define and use KMP_NORETURN to work for multiple C++ versions. Patch by Terry Wilmarth Differential Revision: https://reviews.llvm.org/D37275 llvm-svn: 312538
This commit is contained in:
parent
ab48e5e244
commit
6a393f75f4
|
@ -3036,7 +3036,7 @@ extern int __kmp_get_global_thread_id_reg(void);
|
|||
extern void __kmp_exit_thread(int exit_status);
|
||||
extern void __kmp_abort(char const *format, ...);
|
||||
extern void __kmp_abort_thread(void);
|
||||
extern void __kmp_abort_process(void);
|
||||
KMP_NORETURN extern void __kmp_abort_process(void);
|
||||
extern void __kmp_warn(char const *format, ...);
|
||||
|
||||
extern void __kmp_set_num_threads(int new_nth, int gtid);
|
||||
|
|
|
@ -1892,7 +1892,7 @@ static int __kmp_affinity_create_cpuinfo_map(AddrUnsPair **address2os,
|
|||
continue;
|
||||
}
|
||||
unsigned level;
|
||||
if (KMP_SSCANF(buf, "node_%d id", &level) == 1) {
|
||||
if (KMP_SSCANF(buf, "node_%u id", &level) == 1) {
|
||||
CHECK_LINE;
|
||||
char *p = strchr(buf + sizeof(s4) - 1, ':');
|
||||
unsigned val;
|
||||
|
@ -4038,12 +4038,11 @@ static void __kmp_aux_affinity_initialize(void) {
|
|||
if (f == NULL) {
|
||||
int code = errno;
|
||||
if (__kmp_cpuinfo_file != NULL) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantOpenFileForReading, filename),
|
||||
KMP_ERR(code), KMP_HNT(NameComesFrom_CPUINFO_FILE),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code),
|
||||
KMP_HNT(NameComesFrom_CPUINFO_FILE), __kmp_msg_null);
|
||||
} else {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantOpenFileForReading, filename),
|
||||
KMP_ERR(code), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantOpenFileForReading, filename), KMP_ERR(code),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
}
|
||||
int line = 0;
|
||||
|
|
|
@ -64,8 +64,7 @@ public:
|
|||
}
|
||||
int error = errno;
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FatalSysError), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -79,8 +78,7 @@ public:
|
|||
}
|
||||
int error = errno;
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FatalSysError), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -307,8 +305,7 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
}
|
||||
int error = errno;
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FatalSysError), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -322,8 +319,7 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
}
|
||||
int error = errno;
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FatalSysError), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FatalSysError), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -438,8 +434,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (__kmp_SetThreadGroupAffinity(GetCurrentThread(), &ga, NULL) == 0) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetThreadAffMask),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetThreadAffMask), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -447,8 +443,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (!SetThreadAffinityMask(GetCurrentThread(), *mask)) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetThreadAffMask),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetThreadAffMask), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -463,9 +459,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (__kmp_GetThreadGroupAffinity(GetCurrentThread(), &ga) == 0) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(FunctionError, "GetThreadGroupAffinity()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "GetThreadGroupAffinity()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -479,9 +474,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (!GetProcessAffinityMask(GetCurrentProcess(), &newMask, &sysMask)) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(FunctionError, "GetProcessAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "GetProcessAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -489,9 +483,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (!retval) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(FunctionError, "SetThreadAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "SetThreadAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
@ -499,9 +492,8 @@ class KMPNativeAffinity : public KMPAffinity {
|
|||
if (!newMask) {
|
||||
DWORD error = GetLastError();
|
||||
if (abort_on_error) {
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(FunctionError, "SetThreadAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "SetThreadAffinityMask()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
}
|
||||
*mask = retval;
|
||||
|
|
|
@ -74,8 +74,8 @@ int __kmp_debug_assert(char const *msg, char const *file, int line) {
|
|||
#endif // USE_ASSERT_SEG
|
||||
#endif
|
||||
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(AssertionFailure, file, line),
|
||||
KMP_HNT(SubmitBugReport), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(AssertionFailure, file, line), KMP_HNT(SubmitBugReport),
|
||||
__kmp_msg_null);
|
||||
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -1137,11 +1137,10 @@ __kmp_dispatch_init(ident_t *loc, int gtid, enum sched_type schedule, T lb,
|
|||
break;
|
||||
|
||||
default: {
|
||||
__kmp_msg(kmp_ms_fatal, // Severity
|
||||
KMP_MSG(UnknownSchedTypeDetected), // Primary message
|
||||
KMP_HNT(GetNewerLibrary), // Hint
|
||||
__kmp_msg_null // Variadic argument list terminator
|
||||
);
|
||||
__kmp_fatal(KMP_MSG(UnknownSchedTypeDetected), // Primary message
|
||||
KMP_HNT(GetNewerLibrary), // Hint
|
||||
__kmp_msg_null // Variadic argument list terminator
|
||||
);
|
||||
} break;
|
||||
} // switch
|
||||
pr->schedule = schedule;
|
||||
|
@ -2287,11 +2286,10 @@ static int __kmp_dispatch_next(ident_t *loc, int gtid, kmp_int32 *p_last,
|
|||
break;
|
||||
default: {
|
||||
status = 0; // to avoid complaints on uninitialized variable use
|
||||
__kmp_msg(kmp_ms_fatal, // Severity
|
||||
KMP_MSG(UnknownSchedTypeDetected), // Primary message
|
||||
KMP_HNT(GetNewerLibrary), // Hint
|
||||
__kmp_msg_null // Variadic argument list terminator
|
||||
);
|
||||
__kmp_fatal(KMP_MSG(UnknownSchedTypeDetected), // Primary message
|
||||
KMP_HNT(GetNewerLibrary), // Hint
|
||||
__kmp_msg_null // Variadic argument list terminator
|
||||
);
|
||||
} break;
|
||||
} // switch
|
||||
} // if tc == 0;
|
||||
|
|
|
@ -109,8 +109,7 @@ char *__kmp_env_get(char const *name) {
|
|||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantGetEnvVar, name), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
// Variable is not found, it's ok, just continue.
|
||||
} else {
|
||||
|
@ -127,8 +126,8 @@ char *__kmp_env_get(char const *name) {
|
|||
if (error != ERROR_SUCCESS) {
|
||||
// Unexpected error. The variable should be in the environment,
|
||||
// and buffer should be large enough.
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
KMP_INTERNAL_FREE((void *)result);
|
||||
result = NULL;
|
||||
}; // if
|
||||
|
@ -163,8 +162,7 @@ int __kmp_env_exists(char const *name) {
|
|||
if (rc == 0) {
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantGetEnvVar, name), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
return 0;
|
||||
}; // if
|
||||
|
@ -185,8 +183,8 @@ void __kmp_env_set(char const *name, char const *value, int overwrite) {
|
|||
// more than ~2.5 GB of memory, entire system feels bad. Sometimes
|
||||
// application is killed (by OS?), sometimes system stops
|
||||
// responding... But this error message never appears. --ln
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name),
|
||||
KMP_HNT(NotEnoughMemory), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetEnvVar, name), KMP_HNT(NotEnoughMemory),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
#elif KMP_OS_WINDOWS
|
||||
BOOL rc;
|
||||
|
@ -198,15 +196,13 @@ void __kmp_env_set(char const *name, char const *value, int overwrite) {
|
|||
}; // if
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_ENVVAR_NOT_FOUND) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantGetEnvVar, name), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
}; // if
|
||||
rc = SetEnvironmentVariable(name, value);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetEnvVar, name), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
|
@ -222,8 +218,7 @@ void __kmp_env_unset(char const *name) {
|
|||
BOOL rc = SetEnvironmentVariable(name, NULL);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEnvVar, name), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetEnvVar, name), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
#else
|
||||
#error Unknown or unsupported OS.
|
||||
|
@ -453,8 +448,8 @@ void __kmp_env_blk_init(kmp_env_blk_t *block, // M: Block to initialize.
|
|||
char *mem = GetEnvironmentStrings();
|
||||
if (mem == NULL) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantGetEnvironment), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantGetEnvironment), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
___kmp_env_blk_parse_windows(block, mem);
|
||||
FreeEnvironmentStrings(mem);
|
||||
|
|
|
@ -113,7 +113,7 @@ void __kmp_error_construct(kmp_i18n_id_t id, // Message identifier.
|
|||
ident_t const *ident // Construct ident.
|
||||
) {
|
||||
char const *construct = __kmp_pragma(ct, ident);
|
||||
__kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct), __kmp_msg_null);
|
||||
__kmp_fatal(__kmp_msg_format(id, construct), __kmp_msg_null);
|
||||
KMP_INTERNAL_FREE(CCAST(char *, construct));
|
||||
}
|
||||
|
||||
|
@ -124,8 +124,7 @@ void __kmp_error_construct2(kmp_i18n_id_t id, // Message identifier.
|
|||
) {
|
||||
char const *construct1 = __kmp_pragma(ct, ident);
|
||||
char const *construct2 = __kmp_pragma(cons->type, cons->ident);
|
||||
__kmp_msg(kmp_ms_fatal, __kmp_msg_format(id, construct1, construct2),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(__kmp_msg_format(id, construct1, construct2), __kmp_msg_null);
|
||||
KMP_INTERNAL_FREE(CCAST(char *, construct1));
|
||||
KMP_INTERNAL_FREE(CCAST(char *, construct2));
|
||||
}
|
||||
|
|
|
@ -850,17 +850,18 @@ void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, ...) {
|
|||
__kmp_printf("%s", buffer.str);
|
||||
__kmp_str_buf_free(&buffer);
|
||||
|
||||
if (severity == kmp_ms_fatal) {
|
||||
#if KMP_OS_WINDOWS
|
||||
__kmp_thread_sleep(
|
||||
500); /* Delay to give message a chance to appear before reaping */
|
||||
#endif
|
||||
__kmp_abort_process();
|
||||
}; // if
|
||||
|
||||
// __kmp_release_bootstrap_lock( & lock ); // GEH - this lock causing tests
|
||||
// to hang on OS X*.
|
||||
|
||||
} // __kmp_msg
|
||||
|
||||
void __kmp_fatal(kmp_msg_t message, ...) {
|
||||
__kmp_msg(kmp_ms_fatal, message, __kmp_msg_null);
|
||||
#if KMP_OS_WINDOWS
|
||||
// Delay to give message a chance to appear before reaping
|
||||
__kmp_thread_sleep(500);
|
||||
#endif
|
||||
__kmp_abort_process();
|
||||
} // __kmp_fatal
|
||||
|
||||
// end of file //
|
||||
|
|
|
@ -142,17 +142,17 @@ typedef enum kmp_msg_severity kmp_msg_severity_t;
|
|||
// mandatory. Any number of system errors and hints may be specified. Argument
|
||||
// list must be finished with __kmp_msg_null.
|
||||
void __kmp_msg(kmp_msg_severity_t severity, kmp_msg_t message, ...);
|
||||
KMP_NORETURN void __kmp_fatal(kmp_msg_t message, ...);
|
||||
|
||||
// Helper macros to make calls shorter in simple cases.
|
||||
#define KMP_INFORM(...) \
|
||||
__kmp_msg(kmp_ms_inform, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_WARNING(...) \
|
||||
__kmp_msg(kmp_ms_warning, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_FATAL(...) \
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_FATAL(...) __kmp_fatal(KMP_MSG(__VA_ARGS__), __kmp_msg_null)
|
||||
#define KMP_SYSFAIL(func, error) \
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, func), KMP_SYSERRCODE(error), \
|
||||
__kmp_msg_null)
|
||||
__kmp_fatal(KMP_MSG(FunctionError, func), KMP_SYSERRCODE(error), \
|
||||
__kmp_msg_null)
|
||||
|
||||
// Check error, if not zero, generate fatal error message.
|
||||
#define KMP_CHECK_SYSFAIL(func, error) \
|
||||
|
|
|
@ -154,8 +154,9 @@ LINKAGE void __kmp_itt_region_forking(int gtid, int team_size, int barriers) {
|
|||
} else { // Region domain exists for this location
|
||||
// Check if team size was changed. Then create new region domain for this
|
||||
// location
|
||||
int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
if (__kmp_itt_region_team_size[frm] != team_size) {
|
||||
unsigned int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
if ((frm < KMP_MAX_FRAME_DOMAINS) &&
|
||||
(__kmp_itt_region_team_size[frm] != team_size)) {
|
||||
const char *buff = NULL;
|
||||
kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
|
||||
buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
|
||||
|
@ -231,8 +232,9 @@ LINKAGE void __kmp_itt_frame_submit(int gtid, __itt_timestamp begin,
|
|||
} else { // Region domain exists for this location
|
||||
// Check if team size was changed. Then create new region domain for this
|
||||
// location
|
||||
int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
if (__kmp_itt_region_team_size[frm] != team_size) {
|
||||
unsigned int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
if ((frm < KMP_MAX_FRAME_DOMAINS) &&
|
||||
(__kmp_itt_region_team_size[frm] != team_size)) {
|
||||
const char *buff = NULL;
|
||||
kmp_str_loc_t str_loc = __kmp_str_loc_init(loc->psource, 1);
|
||||
buff = __kmp_str_format("%s$omp$parallel:%d@%s:%d:%d", str_loc.func,
|
||||
|
@ -443,7 +445,7 @@ LINKAGE void __kmp_itt_region_joined(int gtid) {
|
|||
}
|
||||
ident_t *loc = __kmp_thread_from_gtid(gtid)->th.th_ident;
|
||||
if (loc && loc->reserved_2) {
|
||||
int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
unsigned int frm = (loc->reserved_2 & 0x0000FFFF) - 1;
|
||||
if (frm < KMP_MAX_FRAME_DOMAINS) {
|
||||
KMP_ITT_DEBUG_LOCK();
|
||||
__itt_frame_end_v3(__kmp_itt_region_domains[frm], NULL);
|
||||
|
|
|
@ -294,6 +294,15 @@ extern "C" {
|
|||
#define KMP_ALIGN(bytes) __declspec(align(bytes))
|
||||
#endif
|
||||
|
||||
// Define attribute that indicates a function does not return
|
||||
#if __cplusplus >= 201103L
|
||||
#define KMP_NORETURN [[noreturn]]
|
||||
#elif KMP_OS_WINDOWS
|
||||
#define KMP_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#define KMP_NORETURN __attribute__((noreturn))
|
||||
#endif
|
||||
|
||||
/* General purpose fence types for memory operations */
|
||||
enum kmp_mem_fence_type {
|
||||
kmp_no_fence, /* No memory fence */
|
||||
|
|
|
@ -309,8 +309,8 @@ void __kmp_check_stack_overlap(kmp_info_t *th) {
|
|||
(size_t)TCR_PTR(f_th->th.th_info.ds.ds_stacksize),
|
||||
"th_%d stack (overlapped)", __kmp_gtid_from_thread(f_th));
|
||||
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(StackOverlap),
|
||||
KMP_HNT(ChangeStackLimit), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(StackOverlap), KMP_HNT(ChangeStackLimit),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3665,12 +3665,12 @@ int __kmp_register_root(int initial_thread) {
|
|||
/* see if there are too many threads */
|
||||
if (__kmp_all_nth >= capacity && !__kmp_expand_threads(1, 1)) {
|
||||
if (__kmp_tp_cached) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantRegisterNewThread),
|
||||
KMP_HNT(Set_ALL_THREADPRIVATE, __kmp_tp_capacity),
|
||||
KMP_HNT(PossibleSystemLimitOnThreads), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantRegisterNewThread),
|
||||
KMP_HNT(Set_ALL_THREADPRIVATE, __kmp_tp_capacity),
|
||||
KMP_HNT(PossibleSystemLimitOnThreads), __kmp_msg_null);
|
||||
} else {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantRegisterNewThread),
|
||||
KMP_HNT(SystemLimitOnThreads), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantRegisterNewThread), KMP_HNT(SystemLimitOnThreads),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
}; // if
|
||||
|
||||
|
@ -4474,8 +4474,8 @@ __kmp_set_thread_affinity_mask_full_tmp(kmp_affin_mask_t *old_mask) {
|
|||
status = __kmp_get_system_affinity(old_mask, TRUE);
|
||||
int error = errno;
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(ChangeThreadAffMaskError),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(ChangeThreadAffMaskError), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
}
|
||||
__kmp_set_system_affinity(__kmp_affin_fullMask, TRUE);
|
||||
|
@ -6319,9 +6319,8 @@ void __kmp_register_library_startup(void) {
|
|||
char *duplicate_ok = __kmp_env_get("KMP_DUPLICATE_LIB_OK");
|
||||
if (!__kmp_str_match_true(duplicate_ok)) {
|
||||
// That's not allowed. Issue fatal error.
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(DuplicateLibrary, KMP_LIBRARY_FILE, file_name),
|
||||
KMP_HNT(DuplicateLibrary), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(DuplicateLibrary, KMP_LIBRARY_FILE, file_name),
|
||||
KMP_HNT(DuplicateLibrary), __kmp_msg_null);
|
||||
}; // if
|
||||
KMP_INTERNAL_FREE(duplicate_ok);
|
||||
__kmp_duplicate_library_ok = 1;
|
||||
|
@ -6626,8 +6625,8 @@ static void __kmp_do_serial_initialize(void) {
|
|||
library. For dynamic library, we already have _fini and DllMain. */
|
||||
int rc = atexit(__kmp_internal_end_atexit);
|
||||
if (rc != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, "atexit()"), KMP_ERR(rc),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "atexit()"), KMP_ERR(rc),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -433,8 +433,8 @@ void __kmp_terminate_thread(int gtid) {
|
|||
KA_TRACE(10, ("__kmp_terminate_thread: kill (%d)\n", gtid));
|
||||
status = pthread_cancel(th->th.th_info.ds.ds_thread);
|
||||
if (status != 0 && status != ESRCH) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantTerminateWorkerThread), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantTerminateWorkerThread), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
#endif
|
||||
__kmp_yield(TRUE);
|
||||
|
@ -808,13 +808,11 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
|
|||
#ifdef KMP_THREAD_ATTR
|
||||
status = pthread_attr_init(&thread_attr);
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantInitThreadAttrs), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantInitThreadAttrs), KMP_ERR(status), __kmp_msg_null);
|
||||
}; // if
|
||||
status = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetWorkerState), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetWorkerState), KMP_ERR(status), __kmp_msg_null);
|
||||
}; // if
|
||||
|
||||
/* Set stack size for this thread now.
|
||||
|
@ -846,8 +844,8 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
|
|||
}; // if
|
||||
#endif /* KMP_BACKUP_STKSIZE */
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetWorkerStackSize, stack_size),
|
||||
KMP_ERR(status), KMP_HNT(ChangeWorkerStackSize), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetWorkerStackSize, stack_size), KMP_ERR(status),
|
||||
KMP_HNT(ChangeWorkerStackSize), __kmp_msg_null);
|
||||
}; // if
|
||||
#endif /* _POSIX_THREAD_ATTR_STACKSIZE */
|
||||
|
||||
|
@ -858,19 +856,17 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
|
|||
if (status != 0 || !handle) { // ??? Why do we check handle??
|
||||
#ifdef _POSIX_THREAD_ATTR_STACKSIZE
|
||||
if (status == EINVAL) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetWorkerStackSize, stack_size),
|
||||
KMP_ERR(status), KMP_HNT(IncreaseWorkerStackSize),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetWorkerStackSize, stack_size), KMP_ERR(status),
|
||||
KMP_HNT(IncreaseWorkerStackSize), __kmp_msg_null);
|
||||
};
|
||||
if (status == ENOMEM) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetWorkerStackSize, stack_size),
|
||||
KMP_ERR(status), KMP_HNT(DecreaseWorkerStackSize),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetWorkerStackSize, stack_size), KMP_ERR(status),
|
||||
KMP_HNT(DecreaseWorkerStackSize), __kmp_msg_null);
|
||||
};
|
||||
#endif /* _POSIX_THREAD_ATTR_STACKSIZE */
|
||||
if (status == EAGAIN) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(NoResourcesForWorkerThread),
|
||||
KMP_ERR(status), KMP_HNT(Decrease_NUM_THREADS), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(NoResourcesForWorkerThread), KMP_ERR(status),
|
||||
KMP_HNT(Decrease_NUM_THREADS), __kmp_msg_null);
|
||||
}; // if
|
||||
KMP_SYSFAIL("pthread_create", status);
|
||||
}; // if
|
||||
|
@ -931,13 +927,11 @@ void __kmp_create_monitor(kmp_info_t *th) {
|
|||
}
|
||||
status = pthread_attr_init(&thread_attr);
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantInitThreadAttrs), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantInitThreadAttrs), KMP_ERR(status), __kmp_msg_null);
|
||||
}; // if
|
||||
status = pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE);
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetMonitorState), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetMonitorState), KMP_ERR(status), __kmp_msg_null);
|
||||
}; // if
|
||||
|
||||
#ifdef _POSIX_THREAD_ATTR_STACKSIZE
|
||||
|
@ -991,20 +985,19 @@ retry:
|
|||
__kmp_monitor_stksize *= 2;
|
||||
goto retry;
|
||||
}
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal, KMP_MSG(CantSetMonitorStackSize, __kmp_monitor_stksize),
|
||||
KMP_ERR(status), KMP_HNT(IncreaseMonitorStackSize), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetMonitorStackSize, __kmp_monitor_stksize),
|
||||
KMP_ERR(status), KMP_HNT(IncreaseMonitorStackSize),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
if (status == ENOMEM) {
|
||||
__kmp_msg(
|
||||
kmp_ms_fatal, KMP_MSG(CantSetMonitorStackSize, __kmp_monitor_stksize),
|
||||
KMP_ERR(status), KMP_HNT(DecreaseMonitorStackSize), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetMonitorStackSize, __kmp_monitor_stksize),
|
||||
KMP_ERR(status), KMP_HNT(DecreaseMonitorStackSize),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
#endif /* _POSIX_THREAD_ATTR_STACKSIZE */
|
||||
if (status == EAGAIN) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(NoResourcesForMonitorThread),
|
||||
KMP_ERR(status), KMP_HNT(DecreaseNumberOfThreadsInUse),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(NoResourcesForMonitorThread), KMP_ERR(status),
|
||||
KMP_HNT(DecreaseNumberOfThreadsInUse), __kmp_msg_null);
|
||||
}; // if
|
||||
KMP_SYSFAIL("pthread_create", status);
|
||||
}; // if
|
||||
|
@ -1076,8 +1069,7 @@ void __kmp_reap_monitor(kmp_info_t *th) {
|
|||
KA_TRACE(10, ("__kmp_reap_monitor: try to join with monitor\n"));
|
||||
status = pthread_join(th->th.th_info.ds.ds_thread, &exit_val);
|
||||
if (exit_val != th) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(ReapMonitorError), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(ReapMonitorError), KMP_ERR(status), __kmp_msg_null);
|
||||
}
|
||||
|
||||
th->th.th_info.ds.ds_tid = KMP_GTID_DNE;
|
||||
|
@ -1104,8 +1096,7 @@ void __kmp_reap_worker(kmp_info_t *th) {
|
|||
#ifdef KMP_DEBUG
|
||||
/* Don't expose these to the user until we understand when they trigger */
|
||||
if (status != 0) {
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(ReapWorkerError), KMP_ERR(status),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(ReapWorkerError), KMP_ERR(status), __kmp_msg_null);
|
||||
}
|
||||
if (exit_val != th) {
|
||||
KA_TRACE(10, ("__kmp_reap_worker: worker T#%d did not reap properly, "
|
||||
|
|
|
@ -848,9 +848,8 @@ void __kmp_initialize_system_tick(void) {
|
|||
status = QueryPerformanceFrequency(&freq);
|
||||
if (!status) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal,
|
||||
KMP_MSG(FunctionError, "QueryPerformanceFrequency()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "QueryPerformanceFrequency()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
|
||||
} else {
|
||||
__kmp_win32_tick = ((double)1.0) / (double)freq.QuadPart;
|
||||
|
@ -966,8 +965,7 @@ void *__stdcall __kmp_launch_monitor(void *arg) {
|
|||
status = SetThreadPriority(monitor, THREAD_PRIORITY_HIGHEST);
|
||||
if (!status) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetThreadPriority), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetThreadPriority), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
|
||||
/* register us as monitor */
|
||||
|
@ -1008,8 +1006,7 @@ void *__stdcall __kmp_launch_monitor(void *arg) {
|
|||
status = SetThreadPriority(monitor, THREAD_PRIORITY_NORMAL);
|
||||
if (!status) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetThreadPriority), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetThreadPriority), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
|
||||
if (__kmp_global.g.g_abort != 0) {
|
||||
|
@ -1109,8 +1106,7 @@ void __kmp_create_worker(int gtid, kmp_info_t *th, size_t stack_size) {
|
|||
|
||||
if (handle == 0) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantCreateThread), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantCreateThread), KMP_ERR(error), __kmp_msg_null);
|
||||
} else {
|
||||
th->th.th_info.ds.ds_thread = handle;
|
||||
}
|
||||
|
@ -1147,8 +1143,7 @@ void __kmp_create_monitor(kmp_info_t *th) {
|
|||
__kmp_monitor_ev = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
if (__kmp_monitor_ev == NULL) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantCreateEvent), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantCreateEvent), KMP_ERR(error), __kmp_msg_null);
|
||||
}; // if
|
||||
#if USE_ITT_BUILD
|
||||
__kmp_itt_system_object_created(__kmp_monitor_ev, "Event");
|
||||
|
@ -1177,8 +1172,7 @@ void __kmp_create_monitor(kmp_info_t *th) {
|
|||
STACK_SIZE_PARAM_IS_A_RESERVATION, &idThread);
|
||||
if (handle == 0) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantCreateThread), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantCreateThread), KMP_ERR(error), __kmp_msg_null);
|
||||
} else
|
||||
th->th.th_info.ds.ds_thread = handle;
|
||||
|
||||
|
@ -1200,8 +1194,8 @@ int __kmp_is_thread_alive(kmp_info_t *th, DWORD *exit_val) {
|
|||
rc = GetExitCodeThread(th->th.th_info.ds.ds_thread, exit_val);
|
||||
if (rc == 0) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, "GetExitCodeThread()"),
|
||||
KMP_ERR(error), __kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "GetExitCodeThread()"), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
return (*exit_val == STILL_ACTIVE);
|
||||
}
|
||||
|
@ -1299,8 +1293,7 @@ void __kmp_reap_monitor(kmp_info_t *th) {
|
|||
status = SetEvent(__kmp_monitor_ev);
|
||||
if (status == FALSE) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantSetEvent), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantSetEvent), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
KA_TRACE(10, ("__kmp_reap_monitor: reaping thread (%d)\n",
|
||||
th->th.th_info.ds.ds_gtid));
|
||||
|
@ -1338,8 +1331,8 @@ static sig_func_t __kmp_signal(int signum, sig_func_t handler) {
|
|||
sig_func_t old = signal(signum, handler);
|
||||
if (old == SIG_ERR) {
|
||||
int error = errno;
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, "signal"), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "signal"), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}; // if
|
||||
return old;
|
||||
}
|
||||
|
@ -1418,8 +1411,8 @@ void __kmp_thread_sleep(int millis) {
|
|||
status = SleepEx((DWORD)millis, FALSE);
|
||||
if (status) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(FunctionError, "SleepEx()"), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(FunctionError, "SleepEx()"), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1453,8 +1446,7 @@ void __kmp_free_handle(kmp_thread_t tHandle) {
|
|||
rc = CloseHandle(tHandle);
|
||||
if (!rc) {
|
||||
DWORD error = GetLastError();
|
||||
__kmp_msg(kmp_ms_fatal, KMP_MSG(CantCloseHandle), KMP_ERR(error),
|
||||
__kmp_msg_null);
|
||||
__kmp_fatal(KMP_MSG(CantCloseHandle), KMP_ERR(error), __kmp_msg_null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue