this break windows build. Please apply the following patch:<div><div>Index: Errno.cpp</div><div>===================================================================</div><div>--- Errno.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 74696)</div>
<div>+++ Errno.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)</div><div>@@ -47,10 +47,10 @@</div><div> # else</div><div> strerror_r(errnum,buffer,MaxErrStrLen-1);</div><div> # endif</div>
<div>-#elif HAVE_STRERROR_S // Windows.</div><div>+#elif defined(HAVE_STRERROR_S) // Windows.</div><div> if (errnum)</div><div> strerror_s(buffer, errnum);</div><div>-#elif HAVE_STRERROR</div><div>+#elif defined(HAVE_STRERROR)</div>
<div> // Copy the thread un-safe result of strerror into</div><div> // the buffer as fast as possible to minimize impact</div><div> // of collision of strerror in multiple threads.</div><div><br></div><br><div class="gmail_quote">
On Thu, Jul 2, 2009 at 2:11 AM, Jeffrey Yasskin <span dir="ltr"><<a href="mailto:jyasskin@google.com">jyasskin@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: jyasskin<br>
Date: Wed Jul 1 13:11:20 2009<br>
New Revision: 74621<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=74621&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=74621&view=rev</a><br>
Log:<br>
Add a portable strerror*() wrapper, llvm::sys::StrError(). This includes the<br>
Windows variant, strerror_s, but I couldn't test that.<br>
<br>
I'll update configure and <a href="http://config.h.in" target="_blank">config.h.in</a> in a subsequent patch.<br>
<br>
Added:<br>
llvm/trunk/include/llvm/System/Errno.h<br>
llvm/trunk/lib/System/Errno.cpp<br>
Modified:<br>
llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
llvm/trunk/cmake/config-ix.cmake<br>
llvm/trunk/include/llvm/Config/config.h.cmake<br>
llvm/trunk/lib/System/CMakeLists.txt<br>
llvm/trunk/lib/System/Unix/Unix.h<br>
llvm/trunk/tools/gold/gold-plugin.cpp<br>
<br>
Modified: llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a> (original)<br>
+++ llvm/trunk/autoconf/<a href="http://configure.ac" target="_blank">configure.ac</a> Wed Jul 1 13:11:20 2009<br>
@@ -914,7 +914,8 @@<br>
AC_CHECK_FUNCS([powf fmodf strtof round ])<br>
AC_CHECK_FUNCS([getpagesize getrusage getrlimit setrlimit gettimeofday ])<br>
AC_CHECK_FUNCS([isatty mkdtemp mkstemp ])<br>
-AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup strerror strerror_r ])<br>
+AC_CHECK_FUNCS([mktemp realpath sbrk setrlimit strdup ])<br>
+AC_CHECK_FUNCS([strerror strerror_r strerror_s ])<br>
AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])<br>
AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp])<br>
AC_C_PRINTF_A<br>
<br>
Modified: llvm/trunk/cmake/config-ix.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/cmake/config-ix.cmake (original)<br>
+++ llvm/trunk/cmake/config-ix.cmake Wed Jul 1 13:11:20 2009<br>
@@ -67,6 +67,9 @@<br>
HAVE_MALLOC_ZONE_STATISTICS)<br>
check_symbol_exists(pthread_mutex_lock pthread.h HAVE_PTHREAD_MUTEX_LOCK)<br>
check_symbol_exists(strtoll stdlib.h HAVE_STRTOLL)<br>
+check_symbol_exists(strerror string.h HAVE_STRERROR)<br>
+check_symbol_exists(strerror_r string.h HAVE_STRERROR_R)<br>
+check_symbol_exists(strerror_s string.h HAVE_STRERROR_S)<br>
<br>
check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)<br>
if( LLVM_USING_GLIBC )<br>
<br>
Modified: llvm/trunk/include/llvm/Config/config.h.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Config/config.h.cmake (original)<br>
+++ llvm/trunk/include/llvm/Config/config.h.cmake Wed Jul 1 13:11:20 2009<br>
@@ -364,10 +364,13 @@<br>
#undef HAVE_STRDUP<br>
<br>
/* Define to 1 if you have the `strerror' function. */<br>
-#undef HAVE_STRERROR<br>
+#cmakedefine HAVE_STRERROR<br>
<br>
/* Define to 1 if you have the `strerror_r' function. */<br>
-#undef HAVE_STRERROR_R<br>
+#cmakedefine HAVE_STRERROR_R<br>
+<br>
+/* Define to 1 if you have the `strerror_s' function. */<br>
+#cmakedefine HAVE_STRERROR_S<br>
<br>
/* Define to 1 if you have the <strings.h> header file. */<br>
#undef HAVE_STRINGS_H<br>
<br>
Added: llvm/trunk/include/llvm/System/Errno.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Errno.h?rev=74621&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Errno.h?rev=74621&view=auto</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/include/llvm/System/Errno.h (added)<br>
+++ llvm/trunk/include/llvm/System/Errno.h Wed Jul 1 13:11:20 2009<br>
@@ -0,0 +1,34 @@<br>
+//===- llvm/System/Errno.h - Portable+convenient errno handling -*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// This file declares some portable and convenient functions to deal with errno.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#ifndef LLVM_SYSTEM_ERRNO_H<br>
+#define LLVM_SYSTEM_ERRNO_H<br>
+<br>
+#include <string><br>
+<br>
+namespace llvm {<br>
+namespace sys {<br>
+<br>
+/// Returns a string representation of the errno value, using whatever<br>
+/// thread-safe variant of strerror() is available. Be sure to call this<br>
+/// immediately after the function that set errno, or errno may have been<br>
+/// overwritten by an intervening call.<br>
+std::string StrError();<br>
+<br>
+/// Like the no-argument version above, but uses \p errnum instead of errno.<br>
+std::string StrError(int errnum);<br>
+<br>
+} // namespace sys<br>
+} // namespace llvm<br>
+<br>
+#endif // LLVM_SYSTEM_ERRNO_H<br>
<br>
Modified: llvm/trunk/lib/System/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/CMakeLists.txt?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/CMakeLists.txt?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/lib/System/CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/System/CMakeLists.txt Wed Jul 1 13:11:20 2009<br>
@@ -3,6 +3,7 @@<br>
Atomic.cpp<br>
Disassembler.cpp<br>
DynamicLibrary.cpp<br>
+ Errno.cpp<br>
Host.cpp<br>
IncludeFile.cpp<br>
Memory.cpp<br>
<br>
Added: llvm/trunk/lib/System/Errno.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Errno.cpp?rev=74621&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Errno.cpp?rev=74621&view=auto</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/lib/System/Errno.cpp (added)<br>
+++ llvm/trunk/lib/System/Errno.cpp Wed Jul 1 13:11:20 2009<br>
@@ -0,0 +1,71 @@<br>
+//===- Errno.cpp - errno support --------------------------------*- C++ -*-===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// This file implements the errno wrappers.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "llvm/System/Errno.h"<br>
+#include "llvm/Config/config.h" // Get autoconf configuration settings<br>
+<br>
+#if HAVE_STRING_H<br>
+#include <string.h><br>
+<br>
+//===----------------------------------------------------------------------===//<br>
+//=== WARNING: Implementation here must contain only TRULY operating system<br>
+//=== independent code.<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+namespace llvm {<br>
+namespace sys {<br>
+<br>
+#if HAVE_ERRNO_H<br>
+#include <errno.h><br>
+std::string StrError() {<br>
+ return StrError(errno);<br>
+}<br>
+#endif // HAVE_ERRNO_H<br>
+<br>
+std::string StrError(int errnum) {<br>
+ const int MaxErrStrLen = 2000;<br>
+ char buffer[MaxErrStrLen];<br>
+ buffer[0] = '\0';<br>
+ char* str = buffer;<br>
+#ifdef HAVE_STRERROR_R<br>
+ // strerror_r is thread-safe.<br>
+ if (errnum)<br>
+# if defined(__GLIBC__) && defined(_GNU_SOURCE)<br>
+ // glibc defines its own incompatible version of strerror_r<br>
+ // which may not use the buffer supplied.<br>
+ str = strerror_r(errnum,buffer,MaxErrStrLen-1);<br>
+# else<br>
+ strerror_r(errnum,buffer,MaxErrStrLen-1);<br>
+# endif<br>
+#elif HAVE_STRERROR_S // Windows.<br>
+ if (errnum)<br>
+ strerror_s(buffer, errnum);<br>
+#elif HAVE_STRERROR<br>
+ // Copy the thread un-safe result of strerror into<br>
+ // the buffer as fast as possible to minimize impact<br>
+ // of collision of strerror in multiple threads.<br>
+ if (errnum)<br>
+ strncpy(buffer,strerror(errnum),MaxErrStrLen-1);<br>
+ buffer[MaxErrStrLen-1] = '\0';<br>
+#else<br>
+ // Strange that this system doesn't even have strerror<br>
+ // but, oh well, just use a generic message<br>
+ sprintf(buffer, "Error #%d", errnum);<br>
+#endif<br>
+ return str;<br>
+}<br>
+<br>
+} // namespace sys<br>
+} // namespace llvm<br>
+<br>
+#endif // HAVE_STRING_H<br>
<br>
Modified: llvm/trunk/lib/System/Unix/Unix.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Unix.h?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Unix.h?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/lib/System/Unix/Unix.h (original)<br>
+++ llvm/trunk/lib/System/Unix/Unix.h Wed Jul 1 13:11:20 2009<br>
@@ -20,6 +20,7 @@<br>
//===----------------------------------------------------------------------===//<br>
<br>
#include "llvm/Config/config.h" // Get autoconf configuration settings<br>
+#include "llvm/System/Errno.h"<br>
#include <cstdlib><br>
#include <cstdio><br>
#include <cstring><br>
@@ -77,34 +78,9 @@<br>
std::string* ErrMsg, const std::string& prefix, int errnum = -1) {<br>
if (!ErrMsg)<br>
return true;<br>
- char buffer[MAXPATHLEN];<br>
- buffer[0] = 0;<br>
- char* str = buffer;<br>
if (errnum == -1)<br>
errnum = errno;<br>
-#ifdef HAVE_STRERROR_R<br>
- // strerror_r is thread-safe.<br>
- if (errnum)<br>
-# if defined(__GLIBC__) && defined(_GNU_SOURCE)<br>
- // glibc defines its own incompatible version of strerror_r<br>
- // which may not use the buffer supplied.<br>
- str = strerror_r(errnum,buffer,MAXPATHLEN-1);<br>
-# else<br>
- strerror_r(errnum,buffer,MAXPATHLEN-1);<br>
-# endif<br>
-#elif HAVE_STRERROR<br>
- // Copy the thread un-safe result of strerror into<br>
- // the buffer as fast as possible to minimize impact<br>
- // of collision of strerror in multiple threads.<br>
- if (errnum)<br>
- strncpy(buffer,strerror(errnum),MAXPATHLEN-1);<br>
- buffer[MAXPATHLEN-1] = 0;<br>
-#else<br>
- // Strange that this system doesn't even have strerror<br>
- // but, oh well, just use a generic message<br>
- sprintf(buffer, "Error #%d", errnum);<br>
-#endif<br>
- *ErrMsg = prefix + ": " + str;<br>
+ *ErrMsg = prefix + ": " + llvm::sys::StrError(errnum);<br>
return true;<br>
}<br>
<br>
<br>
Modified: llvm/trunk/tools/gold/gold-plugin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=74621&r1=74620&r2=74621&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=74621&r1=74620&r2=74621&view=diff</a><br>
<br>
==============================================================================<br>
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)<br>
+++ llvm/trunk/tools/gold/gold-plugin.cpp Wed Jul 1 13:11:20 2009<br>
@@ -17,6 +17,7 @@<br>
#include "llvm-c/lto.h"<br>
<br>
#include "llvm/Support/raw_ostream.h"<br>
+#include "llvm/System/Errno.h"<br>
#include "llvm/System/Path.h"<br>
#include "llvm/System/Program.h"<br>
<br>
@@ -183,7 +184,7 @@<br>
(*message)(LDPL_ERROR,<br>
"Failed to seek to archive member of %s at offset %d: %s\n",<br>
file->name,<br>
- file->offset, strerror(errno));<br>
+ file->offset, sys::StrError(errno).c_str());<br>
return LDPS_ERR;<br>
}<br>
buf = malloc(file->filesize);<br>
@@ -198,7 +199,7 @@<br>
"Failed to read archive member of %s at offset %d: %s\n",<br>
file->name,<br>
file->offset,<br>
- strerror(errno));<br>
+ sys::StrError(errno).c_str());<br>
free(buf);<br>
return LDPS_ERR;<br>
}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>-Howard<br>
</div>