Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Remove a lot of dead code: macOS < 10.9 is no longer supported |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk | main |
| Files: | files | file ages | folders |
| SHA3-256: |
89dee6b1b8462614fb73684174a74b4d |
| User & Date: | jan.nijtmans 2024-12-04 20:31:44.485 |
Context
|
2024-12-05
| ||
| 10:07 | Fix [aaa84fbbc5]: zipfs info on mountpoint of executable returns zero offset in field 4 check-in: 3d62ee540d user: jan.nijtmans tags: trunk, main | |
|
2024-12-04
| ||
| 20:31 | Remove a lot of dead code: macOS < 10.9 is no longer supported check-in: 89dee6b1b8 user: jan.nijtmans tags: trunk, main | |
| 17:55 | Remove a lot of dead code: macOS < 10.9 is no longer supported check-in: dbc6e5ebd3 user: jan.nijtmans tags: core-8-branch | |
| 14:37 | One more TCL_UNUSED() usage check-in: 615fbeeddb user: jan.nijtmans tags: trunk, main | |
Changes
Changes to macosx/tclMacOSXBundle.c.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 | #include "tclPort.h" #include "tclInt.h" #ifdef HAVE_COREFOUNDATION #include <CoreFoundation/CoreFoundation.h> | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include "tclPort.h"
#include "tclInt.h"
#ifdef HAVE_COREFOUNDATION
#include <CoreFoundation/CoreFoundation.h>
#include <dlfcn.h>
#ifdef TCL_DEBUG_LOAD
#define TclLoadDbgMsg(m, ...) \
do { \
fprintf(stderr, "%s:%d: %s(): " m ".\n", \
strrchr(__FILE__, '/')+1, __LINE__, __func__, \
##__VA_ARGS__); \
|
| ︙ | ︙ | |||
98 99 100 101 102 103 104 |
OpenResourceMap(
CFBundleRef bundleRef)
{
static int initialized = FALSE;
static short (*openresourcemap)(CFBundleRef) = NULL;
if (!initialized) {
| < < < < < < < < < < < < < < < < < < < | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
OpenResourceMap(
CFBundleRef bundleRef)
{
static int initialized = FALSE;
static short (*openresourcemap)(CFBundleRef) = NULL;
if (!initialized) {
{
openresourcemap = (short (*)(CFBundleRef))dlsym(RTLD_NEXT,
"CFBundleOpenBundleResourceMap");
#ifdef TCL_DEBUG_LOAD
if (!openresourcemap) {
const char *errMsg = dlerror();
TclLoadDbgMsg("dlsym() failed: %s", errMsg);
}
#endif /* TCL_DEBUG_LOAD */
}
initialized = TRUE;
}
if (openresourcemap) {
return openresourcemap(bundleRef);
}
return -1;
|
| ︙ | ︙ | |||
248 249 250 251 252 253 254 |
*/
CFURLGetFileSystemRepresentation(libURL, TRUE,
(unsigned char *) libraryPath, maxPathLen);
CFRelease(libURL);
}
if (versionedBundleRef) {
| < < < < < < < | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
*/
CFURLGetFileSystemRepresentation(libURL, TRUE,
(unsigned char *) libraryPath, maxPathLen);
CFRelease(libURL);
}
if (versionedBundleRef) {
{
CFRelease(versionedBundleRef);
}
}
}
if (libraryPath[0]) {
|
| ︙ | ︙ |
Changes to macosx/tclMacOSXFCmd.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <libkern/OSByteOrder.h> #endif /* Darwin 8 copyfile API. */ #ifdef HAVE_COPYFILE #ifdef HAVE_COPYFILE_H #include <copyfile.h> | < < < < < < < < < < < < < < | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #include <libkern/OSByteOrder.h> #endif /* Darwin 8 copyfile API. */ #ifdef HAVE_COPYFILE #ifdef HAVE_COPYFILE_H #include <copyfile.h> #else /* HAVE_COPYFILE_H */ int copyfile(const char *from, const char *to, void *state, uint32_t flags); #define COPYFILE_ACL (1<<0) #define COPYFILE_XATTR (1<<2) #define COPYFILE_NOFOLLOW_SRC (1<<18) #endif /* HAVE_COPYFILE_H */ #endif /* HAVE_COPYFILE */ #ifdef WEAK_IMPORT_COPYFILE #define MayUseCopyFile() (copyfile != NULL) #elif defined(HAVE_COPYFILE) #define MayUseCopyFile() (1) |
| ︙ | ︙ |
Changes to macosx/tclMacOSXNotify.c.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 | * In macOS 10.12 the os_unfair_lock was introduced as a replacement for the * OSSpinLock, and the OSSpinLock was deprecated. */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 #define USE_OS_UNFAIR_LOCK #include <os/lock.h> | < < < | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | * In macOS 10.12 the os_unfair_lock was introduced as a replacement for the * OSSpinLock, and the OSSpinLock was deprecated. */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 #define USE_OS_UNFAIR_LOCK #include <os/lock.h> #endif #ifdef HAVE_COREFOUNDATION /* Traditional unix select-based notifier is * in tclUnixNotfy.c */ #include <CoreFoundation/CoreFoundation.h> #include <pthread.h> #if !defined(USE_OS_UNFAIR_LOCK) /* * We use the Darwin-native spinlock API rather than pthread mutexes for * notifier locking: this radically simplifies the implementation and lowers * overhead. Note that these are not pure spinlocks, they employ various * strategies to back off and relinquish the processor, making them immune to |
| ︙ | ︙ | |||
50 51 52 53 54 55 56 | #pragma GCC diagnostic ignored "-Wunused-function" /* * Use OSSpinLock API where available (Tiger or later). */ #include <libkern/OSAtomic.h> | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
#pragma GCC diagnostic ignored "-Wunused-function"
/*
* Use OSSpinLock API where available (Tiger or later).
*/
#include <libkern/OSAtomic.h>
/*
* Wrappers so that we get warnings in just one small part of this file.
*/
static inline void
SpinLockLock(
OSSpinLock *lock)
|
| ︙ | ︙ | |||
141 142 143 144 145 146 147 |
}
static inline bool
SpinLockTry(
OSSpinLock *lock)
{
return OSSpinLockTry(lock);
}
| < | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
}
static inline bool
SpinLockTry(
OSSpinLock *lock)
{
return OSSpinLockTry(lock);
}
#define SPINLOCK_INIT OS_SPINLOCK_INIT
#else
/*
* Otherwise, use commpage spinlock SPI directly.
*/
|
| ︙ | ︙ | |||
216 217 218 219 220 221 222 | #define UNLOCK_NOTIFIER_INIT SpinLockUnlock(¬ifierInitLock) #define LOCK_NOTIFIER SpinLockLock(¬ifierLock) #define UNLOCK_NOTIFIER SpinLockUnlock(¬ifierLock) #define LOCK_NOTIFIER_TSD SpinLockLock(&tsdPtr->tsdLock) #define UNLOCK_NOTIFIER_TSD SpinLockUnlock(&tsdPtr->tsdLock) #endif | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#define UNLOCK_NOTIFIER_INIT SpinLockUnlock(¬ifierInitLock)
#define LOCK_NOTIFIER SpinLockLock(¬ifierLock)
#define UNLOCK_NOTIFIER SpinLockUnlock(¬ifierLock)
#define LOCK_NOTIFIER_TSD SpinLockLock(&tsdPtr->tsdLock)
#define UNLOCK_NOTIFIER_TSD SpinLockUnlock(&tsdPtr->tsdLock)
#endif
/*
* This structure is used to keep track of the notifier info for a registered
* file.
*/
typedef struct FileHandler {
int fd;
|
| ︙ | ︙ | |||
404 405 406 407 408 409 410 |
CFRunLoopTimerRef runLoopTimer;
/* Wakes up CFRunLoop after given timeout when
* running embedded. */
/* End tsdLock section */
CFTimeInterval waitTime; /* runLoopTimer wait time when running
* embedded. */
| < | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
CFRunLoopTimerRef runLoopTimer;
/* Wakes up CFRunLoop after given timeout when
* running embedded. */
/* End tsdLock section */
CFTimeInterval waitTime; /* runLoopTimer wait time when running
* embedded. */
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
/*
* The following static indicates the number of threads that have initialized
* notifiers.
|
| ︙ | ︙ | |||
516 517 518 519 520 521 522 | int onList, int signalNotifier); #ifdef HAVE_PTHREAD_ATFORK static int atForkInit = 0; static void AtForkPrepare(void); static void AtForkParent(void); static void AtForkChild(void); | < < < < < < < < < < < < < < < < < < < < < < | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | int onList, int signalNotifier); #ifdef HAVE_PTHREAD_ATFORK static int atForkInit = 0; static void AtForkPrepare(void); static void AtForkParent(void); static void AtForkChild(void); #endif /* HAVE_PTHREAD_ATFORK */ /* *---------------------------------------------------------------------- * * LookUpFileHandler -- * |
| ︙ | ︙ | |||
702 703 704 705 706 707 708 |
LOCK_NOTIFIER_INIT;
#ifdef HAVE_PTHREAD_ATFORK
/*
* Install pthread_atfork handlers to reinitialize the notifier in the
* child of a fork.
*/
| | | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
LOCK_NOTIFIER_INIT;
#ifdef HAVE_PTHREAD_ATFORK
/*
* Install pthread_atfork handlers to reinitialize the notifier in the
* child of a fork.
*/
if (!atForkInit) {
int result = pthread_atfork(AtForkPrepare, AtForkParent, AtForkChild);
if (result) {
Tcl_Panic("Tcl_InitNotifier: %s", "pthread_atfork failed");
}
atForkInit = 1;
}
|
| ︙ | ︙ | |||
745 746 747 748 749 750 751 | /* * Create notifier thread lazily in Tcl_WaitForEvent() to avoid * interfering with fork() followed immediately by execve() (we cannot * execve() when more than one thread is present). */ notifierThreadRunning = 0; | < < | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
/*
* Create notifier thread lazily in Tcl_WaitForEvent() to avoid
* interfering with fork() followed immediately by execve() (we cannot
* execve() when more than one thread is present).
*/
notifierThreadRunning = 0;
}
notifierCount++;
UNLOCK_NOTIFIER_INIT;
return tsdPtr;
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
869 870 871 872 873 874 875 |
TclpFinalizeNotifier(
TCL_UNUSED(void *))
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
LOCK_NOTIFIER_INIT;
notifierCount--;
| < | 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
TclpFinalizeNotifier(
TCL_UNUSED(void *))
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
LOCK_NOTIFIER_INIT;
notifierCount--;
/*
* If this is the last thread to use the notifier, close the notifier pipe
* and wait for the background thread to terminate.
*/
if (notifierCount == 0) {
|
| ︙ | ︙ | |||
913 914 915 916 917 918 919 | TclAsyncMarkFromNotifier(); } } close(receivePipe); triggerPipe = -1; } | < | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
TclAsyncMarkFromNotifier();
}
}
close(receivePipe);
triggerPipe = -1;
}
}
UNLOCK_NOTIFIER_INIT;
LOCK_NOTIFIER_TSD; /* For concurrency with Tcl_AlertNotifier */
if (tsdPtr->runLoop) {
tsdPtr->runLoop = NULL;
|
| ︙ | ︙ | |||
1602 1603 1604 1605 1606 1607 1608 |
OnOffWaitingList(
ThreadSpecificData *tsdPtr,
int onList,
int signalNotifier)
{
int changeWaitingList;
| < < < < < | 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
OnOffWaitingList(
ThreadSpecificData *tsdPtr,
int onList,
int signalNotifier)
{
int changeWaitingList;
changeWaitingList = (!onList ^ !tsdPtr->onList);
if (changeWaitingList) {
if (onList) {
tsdPtr->nextPtr = waitingListPtr;
if (waitingListPtr) {
waitingListPtr->prevPtr = tsdPtr;
}
|
| ︙ | ︙ | |||
1700 1701 1702 1703 1704 1705 1706 |
runLoopStatus = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
waitTime, FALSE);
switch (runLoopStatus) {
case kCFRunLoopRunFinished:
Tcl_Panic("Tcl_Sleep: CFRunLoop finished");
break;
case kCFRunLoopRunStopped:
| < | 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 |
runLoopStatus = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
waitTime, FALSE);
switch (runLoopStatus) {
case kCFRunLoopRunFinished:
Tcl_Panic("Tcl_Sleep: CFRunLoop finished");
break;
case kCFRunLoopRunStopped:
waitTime = waitEnd - CFAbsoluteTimeGetCurrent();
break;
case kCFRunLoopRunTimedOut:
waitTime = 0;
break;
}
} while (waitTime > 0);
|
| ︙ | ︙ | |||
2229 2230 2231 2232 2233 2234 2235 |
UNLOCK_NOTIFIER_INIT;
#endif
asyncPending = 0;
if (tsdPtr->runLoop) {
tsdPtr->runLoop = NULL;
| < < < < < < < < < < < < < < < < < < < < < | 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 |
UNLOCK_NOTIFIER_INIT;
#endif
asyncPending = 0;
if (tsdPtr->runLoop) {
tsdPtr->runLoop = NULL;
tsdPtr->runLoopSource = NULL;
tsdPtr->runLoopTimer = NULL;
}
if (notifierCount > 0) {
notifierCount = 1;
notifierThreadRunning = 0;
/*
* Restart the notifier thread for signal handling.
*/
StartNotifierThread();
}
}
|
| ︙ | ︙ |
Changes to unix/configure.
| ︙ | ︙ | |||
10499 10500 10501 10502 10503 10504 10505 |
fi
printf "%s\n" "#define TCL_LOAD_FROM_MEMORY 1" >>confdefs.h
printf "%s\n" "#define TCL_WIDE_CLICKS 1" >>confdefs.h
| < < < < < < < < | | < < < < < < < | | | | | | | < < < < < < < | | | | < | 10499 10500 10501 10502 10503 10504 10505 10506 10507 10508 10509 10510 10511 10512 10513 10514 10515 10516 10517 10518 10519 10520 10521 10522 10523 10524 10525 10526 10527 10528 10529 10530 10531 10532 10533 10534 10535 10536 10537 10538 10539 10540 10541 10542 10543 10544 10545 10546 10547 10548 10549 10550 10551 10552 10553 10554 10555 10556 10557 10558 10559 10560 10561 10562 10563 10564 10565 10566 10567 10568 10569 10570 10571 10572 10573 10574 10575 10576 10577 10578 10579 10580 10581 10582 10583 10584 10585 10586 10587 10588 10589 10590 10591 |
fi
printf "%s\n" "#define TCL_LOAD_FROM_MEMORY 1" >>confdefs.h
printf "%s\n" "#define TCL_WIDE_CLICKS 1" >>confdefs.h
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if weak import is available" >&5
printf %s "checking if weak import is available... " >&6; }
if test ${tcl_cv_cc_weak_import+y}
then :
printf %s "(cached) " >&6
else case e in #(
e)
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int rand(void) __attribute__((weak_import));
int
main (void)
{
rand();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
tcl_cv_cc_weak_import=yes
else case e in #(
e) tcl_cv_cc_weak_import=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$hold_cflags ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_weak_import" >&5
printf "%s\n" "$tcl_cv_cc_weak_import" >&6; }
if test $tcl_cv_cc_weak_import = yes; then
printf "%s\n" "#define HAVE_WEAK_IMPORT 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if Darwin SUSv3 extensions are available" >&5
printf %s "checking if Darwin SUSv3 extensions are available... " >&6; }
if test ${tcl_cv_cc_darwin_c_source+y}
then :
printf %s "(cached) " >&6
else case e in #(
e)
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#define _DARWIN_C_SOURCE 1
#include <sys/cdefs.h>
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
tcl_cv_cc_darwin_c_source=yes
else case e in #(
e) tcl_cv_cc_darwin_c_source=no ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS=$hold_cflags ;;
esac
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_darwin_c_source" >&5
printf "%s\n" "$tcl_cv_cc_darwin_c_source" >&6; }
if test $tcl_cv_cc_darwin_c_source = yes; then
printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h
fi
# Build .bundle dltest binaries in addition to .dylib
DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
DLTEST_SUFFIX=".bundle"
else
DLTEST_LD='${SHLIB_LD}'
DLTEST_SUFFIX=""
|
| ︙ | ︙ |
Changes to unix/configure.ac.
| ︙ | ︙ | |||
532 533 534 535 536 537 538 |
AC_CHECK_HEADERS(libkern/OSAtomic.h)
AC_CHECK_FUNCS(OSSpinLockLock)
fi
AC_DEFINE(TCL_LOAD_FROM_MEMORY, 1,
[Can this platform load code from memory?])
AC_DEFINE(TCL_WIDE_CLICKS, 1,
[Does this platform have wide high-resolution clicks?])
| < < | | < < < < < < < | | | | | | | | | | | < < < < < < < | | | | | | | < | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
AC_CHECK_HEADERS(libkern/OSAtomic.h)
AC_CHECK_FUNCS(OSSpinLockLock)
fi
AC_DEFINE(TCL_LOAD_FROM_MEMORY, 1,
[Can this platform load code from memory?])
AC_DEFINE(TCL_WIDE_CLICKS, 1,
[Does this platform have wide high-resolution clicks?])
AC_CACHE_CHECK([if weak import is available], tcl_cv_cc_weak_import, [
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
int rand(void) __attribute__((weak_import));
]], [[rand();]])],
[tcl_cv_cc_weak_import=yes],[tcl_cv_cc_weak_import=no])
CFLAGS=$hold_cflags])
if test $tcl_cv_cc_weak_import = yes; then
AC_DEFINE(HAVE_WEAK_IMPORT, 1, [Is weak import available?])
fi
AC_CACHE_CHECK([if Darwin SUSv3 extensions are available],
tcl_cv_cc_darwin_c_source, [
hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#define _DARWIN_C_SOURCE 1
#include <sys/cdefs.h>
]], [[]])],[tcl_cv_cc_darwin_c_source=yes],[tcl_cv_cc_darwin_c_source=no])
CFLAGS=$hold_cflags])
if test $tcl_cv_cc_darwin_c_source = yes; then
AC_DEFINE(_DARWIN_C_SOURCE, 1,
[Are Darwin SUSv3 extensions available?])
fi
# Build .bundle dltest binaries in addition to .dylib
DLTEST_LD='${CC} -bundle -Wl,-w ${CFLAGS} ${LDFLAGS}'
DLTEST_SUFFIX=".bundle"
else
DLTEST_LD='${SHLIB_LD}'
DLTEST_SUFFIX=""
|
| ︙ | ︙ |
Changes to unix/tclConfig.h.in.
1 2 3 4 5 6 7 8 9 |
/* ../unix/tclConfig.h.in. Generated from configure.ac by autoheader. */
#ifndef _TCLCONFIG
#define _TCLCONFIG
/* Is gettimeofday() actually declared in <sys/time.h>? */
#undef GETTOD_NOT_DECLARED
| < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/* ../unix/tclConfig.h.in. Generated from configure.ac by autoheader. */
#ifndef _TCLCONFIG
#define _TCLCONFIG
/* Is gettimeofday() actually declared in <sys/time.h>? */
#undef GETTOD_NOT_DECLARED
/* Define to 1 if the system has the type 'blkcnt_t'. */
#undef HAVE_BLKCNT_T
/* Defined when compiler supports casting to union type. */
#undef HAVE_CAST_TO_UNION
/* Define to 1 if you have the 'cfmakeraw' function. */
|
| ︙ | ︙ |
Changes to unix/tclLoadDyld.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | #include "tclInt.h" #ifndef MODULE_SCOPE # define MODULE_SCOPE extern #endif | < < < < < < < < < < < < < < < < < < < < < | < | | | < < < < | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include "tclInt.h"
#ifndef MODULE_SCOPE
# define MODULE_SCOPE extern
#endif
/*
* Use includes for the API we're using.
*/
#include <dlfcn.h>
#if defined(TCL_LOAD_FROM_MEMORY)
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <mach-o/dyld.h>
#include <mach-o/fat.h>
#include <mach-o/swap.h>
#include <mach-o/arch.h>
#include <libkern/OSByteOrder.h>
#include <mach/mach.h>
typedef struct Tcl_DyldModuleHandle {
struct Tcl_DyldModuleHandle *nextPtr;
NSModule module;
} Tcl_DyldModuleHandle;
#endif /* TCL_LOAD_FROM_MEMORY */
typedef struct {
void *dlHandle;
#if defined(TCL_LOAD_FROM_MEMORY)
const struct mach_header *dyldLibHeader;
Tcl_DyldModuleHandle *modulePtr;
#endif
} Tcl_DyldLoadHandle;
/*
* Static functions defined in this file.
*/
static void * FindSymbol(Tcl_Interp *interp,
Tcl_LoadHandle loadHandle, const char *symbol);
static void UnloadFile(Tcl_LoadHandle handle);
|
| ︙ | ︙ | |||
97 98 99 100 101 102 103 | * * Side effects: * None. * *---------------------------------------------------------------------- */ | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
#if defined(TCL_LOAD_FROM_MEMORY)
static const char *
DyldOFIErrorMsg(
int err)
{
switch (err) {
case NSObjectFileImageSuccess:
return NULL;
|
| ︙ | ︙ | |||
119 120 121 122 123 124 125 |
return "bad object file format";
case NSObjectFileImageAccess:
return "cannot read object file";
default:
return "unknown error";
}
}
| | | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
return "bad object file format";
case NSObjectFileImageAccess:
return "cannot read object file";
default:
return "unknown error";
}
}
#endif /* TCL_LOAD_FROM_MEMORY */
/*
*----------------------------------------------------------------------
*
* TclpDlopen --
*
* Dynamically loads a binary code file into memory and returns a handle
|
| ︙ | ︙ | |||
156 157 158 159 160 161 162 |
* function which should be used for this
* file. */
int flags)
{
Tcl_DyldLoadHandle *dyldLoadHandle;
Tcl_LoadHandle newHandle;
void *dlHandle = NULL;
| | < < < < < < < < | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
* function which should be used for this
* file. */
int flags)
{
Tcl_DyldLoadHandle *dyldLoadHandle;
Tcl_LoadHandle newHandle;
void *dlHandle = NULL;
#if defined(TCL_LOAD_FROM_MEMORY)
const struct mach_header *dyldLibHeader = NULL;
Tcl_DyldModuleHandle *modulePtr = NULL;
#endif
const char *errMsg = NULL;
int result;
Tcl_DString ds;
const char *nativePath, *nativeFileName = NULL;
int dlopenflags = 0;
/*
* First try the full path the user gave us. This is particularly
* important if the cwd is inside a vfs, and we are trying to load using a
* relative path.
*/
nativePath = (const char *)Tcl_FSGetNativePath(pathPtr);
if (Tcl_UtfToExternalDStringEx(interp, NULL, TclGetString(pathPtr),
TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return TCL_ERROR;
}
nativeFileName = Tcl_DStringValue(&ds);
/*
* Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]
*/
if (flags & TCL_LOAD_GLOBAL) {
dlopenflags |= RTLD_GLOBAL;
} else {
|
| ︙ | ︙ | |||
215 216 217 218 219 220 221 |
*/
dlHandle = dlopen(nativeFileName, dlopenflags);
if (!dlHandle) {
errMsg = dlerror();
}
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | | < < < < < < < | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
*/
dlHandle = dlopen(nativeFileName, dlopenflags);
if (!dlHandle) {
errMsg = dlerror();
}
}
if (dlHandle) {
dyldLoadHandle = (Tcl_DyldLoadHandle *)Tcl_Alloc(sizeof(Tcl_DyldLoadHandle));
dyldLoadHandle->dlHandle = dlHandle;
#if defined(TCL_LOAD_FROM_MEMORY)
dyldLoadHandle->dyldLibHeader = dyldLibHeader;
dyldLoadHandle->modulePtr = modulePtr;
#endif /* TCL_LOAD_FROM_MEMORY */
newHandle = (Tcl_LoadHandle)Tcl_Alloc(sizeof(*newHandle));
newHandle->clientData = dyldLoadHandle;
newHandle->findSymbolProcPtr = &FindSymbol;
newHandle->unloadFileProcPtr = &UnloadFile;
*unloadProcPtr = &UnloadFile;
*loadHandle = newHandle;
result = TCL_OK;
} else {
Tcl_Obj *errObj;
TclNewObj(errObj);
if (errMsg != NULL) {
Tcl_AppendToObj(errObj, errMsg, TCL_INDEX_NONE);
}
Tcl_SetObjResult(interp, errObj);
result = TCL_ERROR;
}
Tcl_DStringFree(&ds);
return result;
}
|
| ︙ | ︙ | |||
351 352 353 354 355 356 357 |
if (Tcl_UtfToExternalDStringEx(interp, NULL, symbol, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return NULL;
}
native = Tcl_DStringValue(&ds);
if (dyldLoadHandle->dlHandle) {
| < < | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
if (Tcl_UtfToExternalDStringEx(interp, NULL, symbol, TCL_INDEX_NONE, 0, &ds, NULL) != TCL_OK) {
Tcl_DStringFree(&ds);
return NULL;
}
native = Tcl_DStringValue(&ds);
if (dyldLoadHandle->dlHandle) {
proc = (Tcl_LibraryInitProc *)dlsym(dyldLoadHandle->dlHandle, native);
if (!proc) {
errMsg = dlerror();
}
} else {
#if defined(TCL_LOAD_FROM_MEMORY)
NSSymbol nsSymbol = NULL;
Tcl_DString newName;
/*
* dyld adds an underscore to the beginning of symbol names.
*/
|
| ︙ | ︙ | |||
411 412 413 414 415 416 417 |
nsSymbol = NSLookupSymbolInModule(
dyldLoadHandle->modulePtr->module, native);
}
if (nsSymbol) {
proc = (Tcl_LibraryInitProc *)NSAddressOfSymbol(nsSymbol);
}
Tcl_DStringFree(&newName);
| | | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
nsSymbol = NSLookupSymbolInModule(
dyldLoadHandle->modulePtr->module, native);
}
if (nsSymbol) {
proc = (Tcl_LibraryInitProc *)NSAddressOfSymbol(nsSymbol);
}
Tcl_DStringFree(&newName);
#endif /* TCL_LOAD_FROM_MEMORY */
}
Tcl_DStringFree(&ds);
if (errMsg && (interp != NULL)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"cannot find symbol \"%s\": %s", symbol, errMsg));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol,
(char *)NULL);
|
| ︙ | ︙ | |||
452 453 454 455 456 457 458 |
Tcl_LoadHandle loadHandle) /* loadHandle returned by a previous call to
* TclpDlopen(). The loadHandle is a token
* that represents the loaded file. */
{
Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *)loadHandle->clientData;
if (dyldLoadHandle->dlHandle) {
| < < | | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
Tcl_LoadHandle loadHandle) /* loadHandle returned by a previous call to
* TclpDlopen(). The loadHandle is a token
* that represents the loaded file. */
{
Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *)loadHandle->clientData;
if (dyldLoadHandle->dlHandle) {
(void) dlclose(dyldLoadHandle->dlHandle);
} else {
#if defined(TCL_LOAD_FROM_MEMORY)
Tcl_DyldModuleHandle *modulePtr = dyldLoadHandle->modulePtr;
while (modulePtr != NULL) {
void *ptr = modulePtr;
(void) NSUnLinkModule(modulePtr->module,
NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES);
modulePtr = modulePtr->nextPtr;
Tcl_Free(ptr);
}
#endif /* TCL_LOAD_FROM_MEMORY */
}
Tcl_Free(dyldLoadHandle);
Tcl_Free(loadHandle);
}
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ | |||
497 498 499 500 501 502 503 |
MODULE_SCOPE void *
TclpLoadMemoryGetBuffer(
size_t size) /* Size of desired buffer. */
{
void *buffer = NULL;
/*
| < < < < < | | | | | | < | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
MODULE_SCOPE void *
TclpLoadMemoryGetBuffer(
size_t size) /* Size of desired buffer. */
{
void *buffer = NULL;
/*
* We must allocate the buffer using vm_allocate, because
* NSCreateObjectFileImageFromMemory will dispose of it using
* vm_deallocate.
*/
if (vm_allocate(mach_task_self(), (vm_address_t *) &buffer, size, 1)) {
buffer = NULL;
}
return buffer;
}
#endif /* TCL_LOAD_FROM_MEMORY */
/*
*----------------------------------------------------------------------
|
| ︙ | ︙ |
Changes to unix/tclUnixFCmd.c.
| ︙ | ︙ | |||
240 241 242 243 244 245 246 |
return realpath(path, resolved);
}
#else
# define Realpath realpath
#endif /* PURIFY */
#ifndef NO_REALPATH
| < < < < < < < < < < < < < < < < < < | < < < < < < < | < | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
return realpath(path, resolved);
}
#else
# define Realpath realpath
#endif /* PURIFY */
#ifndef NO_REALPATH
# define haveRealpath 1
#endif /* NO_REALPATH */
#ifdef HAVE_FTS
#if defined(HAVE_STRUCT_STAT64) && !defined(__APPLE__)
/* fts doesn't do stat64 */
# define noFtsStat 1
#else
# define noFtsStat 0
#endif
#endif /* HAVE_FTS */
/*
*---------------------------------------------------------------------------
|
| ︙ | ︙ |
Changes to unix/tclUnixInit.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tclUnixInit.c -- * * Contains the Unix-specific interpreter initialization functions. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 1999 Scriptics Corporation. * All rights reserved. */ #include "tclInt.h" #ifdef HAVE_LANGINFO # include <langinfo.h> | < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tclUnixInit.c -- * * Contains the Unix-specific interpreter initialization functions. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 1999 Scriptics Corporation. * All rights reserved. */ #include "tclInt.h" #ifdef HAVE_LANGINFO # include <langinfo.h> #endif #include <sys/resource.h> #if defined(__FreeBSD__) && defined(__GNUC__) # include <floatingpoint.h> #endif #if defined(__bsdi__) # include <sys/param.h> |
| ︙ | ︙ | |||
317 318 319 320 321 322 323 |
{"zh_tw.big5", "big5"},
};
#ifdef HAVE_COREFOUNDATION
static int MacOSXGetLibraryPath(Tcl_Interp *interp,
int maxPathLen, char *tclLibPath);
#endif /* HAVE_COREFOUNDATION */
| < < < < < < < < < < < < < < | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
{"zh_tw.big5", "big5"},
};
#ifdef HAVE_COREFOUNDATION
static int MacOSXGetLibraryPath(Tcl_Interp *interp,
int maxPathLen, char *tclLibPath);
#endif /* HAVE_COREFOUNDATION */
/*
*---------------------------------------------------------------------------
*
* TclpInitPlatform --
*
* Initialize all the platform-dependent things like signals and
|
| ︙ | ︙ | |||
418 419 420 421 422 423 424 |
* In case the initial locale is not "C", ensure that the numeric
* processing is done in "C" locale regardless. This is needed because Tcl
* relies on routines like strtol/strtoul, but should not have locale dependent
* behavior.
*/
setlocale(LC_NUMERIC, "C");
| < < < < < < < < < < | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
* In case the initial locale is not "C", ensure that the numeric
* processing is done in "C" locale regardless. This is needed because Tcl
* relies on routines like strtol/strtoul, but should not have locale dependent
* behavior.
*/
setlocale(LC_NUMERIC, "C");
}
/*
*---------------------------------------------------------------------------
*
* TclpInitLibraryPath --
*
|
| ︙ | ︙ | |||
739 740 741 742 743 744 745 | * Side effects: * Sets "tclDefaultLibrary", "tcl_pkgPath", and "tcl_platform" Tcl * variables. * *---------------------------------------------------------------------- */ | | | 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 | * Side effects: * Sets "tclDefaultLibrary", "tcl_pkgPath", and "tcl_platform" Tcl * variables. * *---------------------------------------------------------------------- */ #if defined(HAVE_COREFOUNDATION) /* * Helper because whether CFLocaleCopyCurrent and CFLocaleGetIdentifier are * strongly or weakly bound varies by version of OSX, triggering warnings. */ static inline void InitMacLocaleInfoVar( |
| ︙ | ︙ | |||
774 775 776 777 778 779 780 |
if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
Tcl_ResetResult(interp);
}
Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
}
CFRelease(localeRef);
}
| | | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 |
if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
Tcl_ResetResult(interp);
}
Tcl_SetVar2(interp, "::tcl::mac::locale", NULL, loc, TCL_GLOBAL_ONLY);
}
CFRelease(localeRef);
}
#endif /*defined(HAVE_COREFOUNDATION)*/
void
TclpSetVariables(
Tcl_Interp *interp)
{
#ifdef __CYGWIN__
SYSTEM_INFO sysInfo;
|
| ︙ | ︙ | |||
799 800 801 802 803 804 805 |
#ifdef HAVE_COREFOUNDATION
char tclLibPath[MAXPATHLEN + 1];
/*
* Set msgcat fallback locale to current CFLocale identifier.
*/
| < < | 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
#ifdef HAVE_COREFOUNDATION
char tclLibPath[MAXPATHLEN + 1];
/*
* Set msgcat fallback locale to current CFLocale identifier.
*/
InitMacLocaleInfoVar(CFLocaleCopyCurrent, CFLocaleGetIdentifier, interp);
if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) {
const char *str;
CFBundleRef bundleRef;
Tcl_DString ds;
Tcl_SetVar2(interp, "tclDefaultLibrary", NULL, tclLibPath, TCL_GLOBAL_ONLY);
|
| ︙ | ︙ |
Changes to unix/tclUnixPort.h.
| ︙ | ︙ | |||
555 556 557 558 559 560 561 | /* *--------------------------------------------------------------------------- * Include AvailabilityMacros.h here (when available) to ensure any symbolic * MAC_OS_X_VERSION_* constants passed on the command line are translated. *--------------------------------------------------------------------------- */ | < | < < < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 |
/*
*---------------------------------------------------------------------------
* Include AvailabilityMacros.h here (when available) to ensure any symbolic
* MAC_OS_X_VERSION_* constants passed on the command line are translated.
*---------------------------------------------------------------------------
*/
# include <AvailabilityMacros.h>
/*
*---------------------------------------------------------------------------
* Support for weak import.
*---------------------------------------------------------------------------
*/
# ifdef HAVE_WEAK_IMPORT
# ifndef WEAK_IMPORT_ATTRIBUTE
# define WEAK_IMPORT_ATTRIBUTE __attribute__((weak_import))
# endif
# endif /* HAVE_WEAK_IMPORT */
/*
* For now, test exec-17.1 fails (I/O setup after closing stdout) with
* posix_spawnp(), but the classic implementation (based on fork()+execvp())
* works well under macOS.
*/
# undef HAVE_POSIX_SPAWNP
# undef HAVE_VFORK
|
| ︙ | ︙ |