|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_STRERROR_R) && defined(NEEDS_STRERROR_R_DECL)
|
|
Packit Service |
c5cf8c |
#if defined(STRERROR_R_CHAR_P)
|
|
Packit Service |
c5cf8c |
char *strerror_r(int errnum, char *strerrbuf, size_t buflen);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
int strerror_r(int errnum, char *strerrbuf, size_t buflen);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ideally, provides a thread-safe version of strerror */
|
|
Packit Service |
c5cf8c |
const char *MPIR_Strerror(int errnum)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_STRERROR_R)
|
|
Packit Service |
c5cf8c |
char *buf;
|
|
Packit Service |
c5cf8c |
MPIR_Per_thread_t *per_thread = NULL;
|
|
Packit Service |
c5cf8c |
int err = 0;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPID_THREADPRIV_KEY_GET_ADDR(MPIR_ThreadInfo.isThreaded, MPIR_Per_thread_key,
|
|
Packit Service |
c5cf8c |
MPIR_Per_thread, per_thread, &err;;
|
|
Packit Service |
c5cf8c |
MPIR_Assert(err == 0);
|
|
Packit Service |
c5cf8c |
buf = per_thread->strerrbuf;
|
|
Packit Service |
c5cf8c |
#if defined(STRERROR_R_CHAR_P)
|
|
Packit Service |
c5cf8c |
/* strerror_r returns char ptr (old GNU-flavor). Static strings for known
|
|
Packit Service |
c5cf8c |
* errnums are in returned buf, unknown errnums put a message in buf and
|
|
Packit Service |
c5cf8c |
* return buf */
|
|
Packit Service |
c5cf8c |
buf = strerror_r(errnum, buf, MPIR_STRERROR_BUF_SIZE);
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
/* strerror_r returns an int */
|
|
Packit Service |
c5cf8c |
strerror_r(errnum, buf, MPIR_STRERROR_BUF_SIZE);
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
return buf;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_STRERROR)
|
|
Packit Service |
c5cf8c |
/* MT - not guaranteed to be thread-safe, but on may platforms it will be
|
|
Packit Service |
c5cf8c |
* anyway for the most common cases (looking up an error string in a table
|
|
Packit Service |
c5cf8c |
* of constants).
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Using a mutex here would be an option, but then you need a version
|
|
Packit Service |
c5cf8c |
* without the mutex to call when interpreting errors from mutex functions
|
|
Packit Service |
c5cf8c |
* themselves. */
|
|
Packit Service |
c5cf8c |
return strerror(errnum);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
/* nowadays this case is most likely to happen because of a configure or
|
|
Packit Service |
c5cf8c |
* internal header file inclusion bug rather than an actually missing
|
|
Packit Service |
c5cf8c |
* strerror routine */
|
|
Packit Service |
c5cf8c |
return "(strerror() unavailable on this platform)"
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
}
|