summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDyld.c
diff options
context:
space:
mode:
authordas <das>2006-07-20 06:18:37 (GMT)
committerdas <das>2006-07-20 06:18:37 (GMT)
commit012ac88ab78de5f4b8f0e7b196e1746bb75bdf9b (patch)
treed0364276ac6c8c4168a1e2ff1c15ccf01d284585 /unix/tclLoadDyld.c
parentf2a1ea5dbae4b3440723227e75a0c9da1d88ff93 (diff)
downloadtcl-012ac88ab78de5f4b8f0e7b196e1746bb75bdf9b.zip
tcl-012ac88ab78de5f4b8f0e7b196e1746bb75bdf9b.tar.gz
tcl-012ac88ab78de5f4b8f0e7b196e1746bb75bdf9b.tar.bz2
* macosx/tclMacOSXNotify.c (Tcl_InitNotifier, Tcl_WaitForEvent): create
notifier thread lazily upon first call to Tcl_WaitForEvent() rather than in Tcl_InitNotifier(). Allows calling exeve() in processes where the event loop has not yet been run (Darwin's execve() fails in processes with more than one thread), in particular allows embedders to call fork() followed by execve(), previously the pthread_atfork() child handler's call to Tcl_InitNotifier() would immediately recreate the notifier thread in the child after a fork. * macosx/tclMacOSXFCmd.c (TclMacOSXCopyFileAttributes): add support * macosx/tclMacOSXNotify.c (Tcl_InitNotifier): for weakly * unix/tclUnixInit.c (Tcl_GetEncodingNameFromEnvironment): importing symbols not available on OSX 10.2 or 10.3, enables binaires built on later OSX versions to run on earlier ones. * macosx/Tcl.xcodeproj/project.pbxproj: enable weak-linking; turn on extra warnings. * macosx/README: document how to enable weak-linking; cleanup. * unix/tclUnixPort.h: add support for weak-linking; conditionalize AvailabilityMacros.h inclusion; only disable realpath on 10.2 or earlier when threads are enabled. * unix/tclLoadDyld.c (TclpLoadMemoryGetBuffer): change runtime Darwin * unix/tclUnixInit.c (TclpInitPlatform): release check to use global initialized once. * unix/tclUnixFCmd.c (DoRenameFile, TclpObjNormalizePath): add runtime Darwin release check to determine if realpath is threadsafe. * unix/configure.in: add check on Darwin for compiler support of weak * unix/tcl.m4: import and for AvailabilityMacros.h header; move Darwin specific checks & defines that are only relevant to the tcl build out of tcl.m4; restrict framework option to Darwin; cleanup quoting and help messages. * unix/configure: autoconf-2.59 * unix/tclConfig.h.in: autoheader-2.59 * unix/tclLoadDyld.c (TclpLoadMemory): fix signed-with-unsigned comparison and other warnings from gcc4 -Wextra.
Diffstat (limited to 'unix/tclLoadDyld.c')
-rw-r--r--unix/tclLoadDyld.c32
1 files changed, 9 insertions, 23 deletions
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 81f59be..332c6c1 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDyld.c,v 1.23 2006/03/16 09:15:43 das Exp $
+ * RCS: @(#) $Id: tclLoadDyld.c,v 1.24 2006/07/20 06:18:38 das Exp $
*/
#include "tclInt.h"
@@ -34,11 +34,7 @@ typedef struct Tcl_DyldLoadHandle {
} Tcl_DyldLoadHandle;
#ifdef TCL_LOAD_FROM_MEMORY
-typedef struct ThreadSpecificData {
- int haveLoadMemory;
-} ThreadSpecificData;
-
-static Tcl_ThreadDataKey dataKey;
+MODULE_SCOPE long tclMacOSXDarwinRelease;
#endif
/*
@@ -389,23 +385,13 @@ TclpLoadMemoryGetBuffer(
Tcl_Interp *interp, /* Used for error reporting. */
int size) /* Size of desired buffer. */
{
- ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
void *buffer = NULL;
- if (!tsdPtr->haveLoadMemory) {
- /*
- * NSCreateObjectFileImageFromMemory is available but always fails
- * prior to Darwin 7.
- */
-
- struct utsname name;
-
- if (!uname(&name)) {
- long release = strtol(name.release, NULL, 10);
- tsdPtr->haveLoadMemory = (release >= 7) ? 1 : -1;
- }
- }
- if (tsdPtr->haveLoadMemory > 0) {
+ /*
+ * NSCreateObjectFileImageFromMemory is available but always fails
+ * prior to Darwin 7.
+ */
+ if (tclMacOSXDarwinRelease >= 7) {
/*
* We must allocate the buffer using vm_allocate, because
* NSCreateObjectFileImageFromMemory will dispose of it using
@@ -478,14 +464,14 @@ TclpLoadMemory(
#define mh_size sizeof(struct mach_header_64)
#endif
- if (codeSize >= sizeof(struct fat_header)
+ if ((size_t) codeSize >= sizeof(struct fat_header)
&& fh->magic == OSSwapHostToBigInt32(FAT_MAGIC)) {
/*
* Fat binary, try to find mach_header for our architecture
*/
uint32_t fh_nfat_arch = OSSwapBigToHostInt32(fh->nfat_arch);
- if (codeSize >= sizeof(struct fat_header) +
+ if ((size_t) codeSize >= sizeof(struct fat_header) +
fh_nfat_arch * sizeof(struct fat_arch)) {
void *fatarchs = buffer + sizeof(struct fat_header);
CONST NXArchInfo *arch = NXGetLocalArchInfo();