diff options
author | orivej <orivej@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:01 +0300 |
commit | 2d37894b1b037cf24231090eda8589bbb44fb6fc (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/llvm12/lib/Support/Errno.cpp | |
parent | 718c552901d703c502ccbefdfc3c9028d608b947 (diff) | |
download | ydb-2d37894b1b037cf24231090eda8589bbb44fb6fc.tar.gz |
Restoring authorship annotation for <orivej@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/Support/Errno.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/Support/Errno.cpp | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/contrib/libs/llvm12/lib/Support/Errno.cpp b/contrib/libs/llvm12/lib/Support/Errno.cpp index e4ee5c8e03..d18231c6eb 100644 --- a/contrib/libs/llvm12/lib/Support/Errno.cpp +++ b/contrib/libs/llvm12/lib/Support/Errno.cpp @@ -1,75 +1,75 @@ -//===- Errno.cpp - errno support --------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file implements the errno wrappers. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Support/Errno.h" -#include "llvm/Config/config.h" -#include "llvm/Support/raw_ostream.h" -#include <string.h> - -#if HAVE_ERRNO_H -#include <errno.h> -#endif - -//===----------------------------------------------------------------------===// -//=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. -//===----------------------------------------------------------------------===// - -namespace llvm { -namespace sys { - -#if HAVE_ERRNO_H -std::string StrError() { - return StrError(errno); -} -#endif // HAVE_ERRNO_H - -std::string StrError(int errnum) { - std::string str; - if (errnum == 0) - return str; -#if defined(HAVE_STRERROR_R) || HAVE_DECL_STRERROR_S - const int MaxErrStrLen = 2000; - char buffer[MaxErrStrLen]; - buffer[0] = '\0'; -#endif - -#ifdef HAVE_STRERROR_R - // strerror_r is thread-safe. -#if defined(__GLIBC__) && defined(_GNU_SOURCE) - // glibc defines its own incompatible version of strerror_r - // which may not use the buffer supplied. - str = strerror_r(errnum, buffer, MaxErrStrLen - 1); -#else - strerror_r(errnum, buffer, MaxErrStrLen - 1); - str = buffer; -#endif -#elif HAVE_DECL_STRERROR_S // "Windows Secure API" - strerror_s(buffer, MaxErrStrLen - 1, errnum); - str = buffer; -#elif defined(HAVE_STRERROR) - // Copy the thread un-safe result of strerror into - // the buffer as fast as possible to minimize impact - // of collision of strerror in multiple threads. - str = strerror(errnum); -#else - // Strange that this system doesn't even have strerror - // but, oh well, just use a generic message - raw_string_ostream stream(str); - stream << "Error #" << errnum; - stream.flush(); -#endif - return str; -} - -} // namespace sys -} // namespace llvm +//===- Errno.cpp - errno support --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file implements the errno wrappers. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/Errno.h" +#include "llvm/Config/config.h" +#include "llvm/Support/raw_ostream.h" +#include <string.h> + +#if HAVE_ERRNO_H +#include <errno.h> +#endif + +//===----------------------------------------------------------------------===// +//=== WARNING: Implementation here must contain only TRULY operating system +//=== independent code. +//===----------------------------------------------------------------------===// + +namespace llvm { +namespace sys { + +#if HAVE_ERRNO_H +std::string StrError() { + return StrError(errno); +} +#endif // HAVE_ERRNO_H + +std::string StrError(int errnum) { + std::string str; + if (errnum == 0) + return str; +#if defined(HAVE_STRERROR_R) || HAVE_DECL_STRERROR_S + const int MaxErrStrLen = 2000; + char buffer[MaxErrStrLen]; + buffer[0] = '\0'; +#endif + +#ifdef HAVE_STRERROR_R + // strerror_r is thread-safe. +#if defined(__GLIBC__) && defined(_GNU_SOURCE) + // glibc defines its own incompatible version of strerror_r + // which may not use the buffer supplied. + str = strerror_r(errnum, buffer, MaxErrStrLen - 1); +#else + strerror_r(errnum, buffer, MaxErrStrLen - 1); + str = buffer; +#endif +#elif HAVE_DECL_STRERROR_S // "Windows Secure API" + strerror_s(buffer, MaxErrStrLen - 1, errnum); + str = buffer; +#elif defined(HAVE_STRERROR) + // Copy the thread un-safe result of strerror into + // the buffer as fast as possible to minimize impact + // of collision of strerror in multiple threads. + str = strerror(errnum); +#else + // Strange that this system doesn't even have strerror + // but, oh well, just use a generic message + raw_string_ostream stream(str); + stream << "Error #" << errnum; + stream.flush(); +#endif + return str; +} + +} // namespace sys +} // namespace llvm |