summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authordas <das>2007-04-23 20:35:55 (GMT)
committerdas <das>2007-04-23 20:35:55 (GMT)
commitc93886c791c9d180c4e5fe39020495c2220bc3e6 (patch)
tree2f952ac8a6f3a4fa8111ba107482dc69f22c830a /unix
parentb2d416baafa945b216378335885f99238f38966e (diff)
downloadtcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.zip
tcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.tar.gz
tcl-c93886c791c9d180c4e5fe39020495c2220bc3e6.tar.bz2
* unix/tclUnixFCmd.c: add workaround for crashing bug in fts_open()
* unix/tclUnixInit.c: without FTS_NOSTAT on 64bit Darwin 8 or earlier.
Diffstat (limited to 'unix')
-rw-r--r--unix/tclUnixFCmd.c47
-rw-r--r--unix/tclUnixInit.c6
2 files changed, 35 insertions, 18 deletions
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 13a2a6e..aef6b5b 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFCmd.c,v 1.60 2006/11/15 20:08:45 dgp Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.61 2007/04/23 20:35:55 das Exp $
*
* Portions of this code were derived from NetBSD source code which has the
* following copyright notice:
@@ -234,6 +234,26 @@ MODULE_SCOPE long tclMacOSXDarwinRelease;
#define haveRealpath 1
#endif
#endif /* NO_REALPATH */
+
+#ifdef HAVE_FTS
+#ifdef HAVE_STRUCT_STAT64
+/* fts doesn't do stat64 */
+#define noFtsStat 1
+#elif defined(__APPLE__) && defined(__LP64__) && \
+ defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+/*
+ * prior to Darwin 9, 64bit fts_open() without FTS_NOSTAT may crash (due to a
+ * 64bit-unsafe ALIGN macro); if we could be running on pre-10.5 OSX, check
+ * Darwin release at runtime and do a separate stat() if necessary.
+ */
+MODULE_SCOPE long tclMacOSXDarwinRelease;
+#define noFtsStat (tclMacOSXDarwinRelease < 9)
+#else
+#define noFtsStat 0
+#endif
+#endif /* HAVE_FTS */
+
/*
*---------------------------------------------------------------------------
@@ -1020,13 +1040,8 @@ TraverseUnixTree(
}
#else /* HAVE_FTS */
paths[0] = source;
- fts = fts_open((char**)paths, FTS_PHYSICAL|FTS_NOCHDIR|
-#ifdef HAVE_STRUCT_STAT64
- FTS_NOSTAT, /* fts doesn't do stat64 */
-#else
- (doRewind ? FTS_NOSTAT : 0), /* no need to stat for delete */
-#endif
- NULL);
+ fts = fts_open((char**)paths, FTS_PHYSICAL | FTS_NOCHDIR |
+ (noFtsStat || doRewind ? FTS_NOSTAT : 0), NULL);
if (fts == NULL) {
errfile = source;
goto end;
@@ -1064,15 +1079,15 @@ TraverseUnixTree(
break;
}
if (!doRewind) { /* no need to stat for delete */
-#ifdef HAVE_STRUCT_STAT64
- statBufPtr = &statBuf;
- if (TclOSlstat(ent->fts_path, statBufPtr) != 0) {
- errfile = ent->fts_path;
- break;
+ if (noFtsStat) {
+ statBufPtr = &statBuf;
+ if (TclOSlstat(ent->fts_path, statBufPtr) != 0) {
+ errfile = ent->fts_path;
+ break;
+ }
+ } else {
+ statBufPtr = ent->fts_statp;
}
-#else
- statBufPtr = ent->fts_statp;
-#endif
}
result = (*traverseProc)(sourcePtr, targetPtr, statBufPtr, type,
errorPtr);
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 854624f..d4f1003 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclUnixInit.c,v 1.69 2007/04/17 14:49:53 dkf Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.70 2007/04/23 20:35:55 das Exp $
*/
#include "tclInt.h"
@@ -332,7 +332,9 @@ static int MacOSXGetLibraryPath(Tcl_Interp *interp,
#endif /* HAVE_COREFOUNDATION */
#if defined(__APPLE__) && (defined(TCL_LOAD_FROM_MEMORY) || ( \
defined(TCL_THREADS) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
- MAC_OS_X_VERSION_MIN_REQUIRED < 1030))
+ MAC_OS_X_VERSION_MIN_REQUIRED < 1030) || ( \
+ defined(__LP64__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \
+ MAC_OS_X_VERSION_MIN_REQUIRED < 1050))
/*
* Need to check Darwin release at runtime in tclUnixFCmd.c and tclLoadDyld.c:
* initialize release global at startup from uname().