Compare commits
12
Commits
tclrules
...
bug-1224888
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10a75a238f | ||
|
|
f73d5a0757 | ||
|
|
3bb01c5691 | ||
|
|
00abed5cc3 | ||
|
|
5dbd8b7848 | ||
|
|
2796ce74b7 | ||
|
|
7aac132135 | ||
|
|
b2b8105060 | ||
|
|
a0229a373b | ||
|
|
5dcedd1e2c | ||
|
|
2b7076b60d | ||
|
|
1933cc20ba |
Vendored
+99
@@ -7418,6 +7418,105 @@ $as_echo "#define NO_UNAME 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
echo "$as_me:$LINENO: checking for dladdr" >&5
|
||||
echo $ECHO_N "checking for dladdr... $ECHO_C" >&6
|
||||
if test "${ac_cv_func_dladdr+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
/* Define dladdr to an innocuous variant, in case <limits.h> declares dladdr.
|
||||
For example, HP-UX 11i <limits.h> declares gettimeofday. */
|
||||
#define dladdr innocuous_dladdr
|
||||
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char dladdr (); below.
|
||||
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|
||||
<limits.h> exists even on freestanding compilers. */
|
||||
|
||||
#ifdef __STDC__
|
||||
# include <limits.h>
|
||||
#else
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#undef dladdr
|
||||
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char dladdr ();
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_dladdr) || defined (__stub___dladdr)
|
||||
choke me
|
||||
#else
|
||||
char (*f) () = dladdr;
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return f != dladdr;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag"
|
||||
|| test ! -s conftest.err'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
ac_cv_func_dladdr=yes
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_func_dladdr=no
|
||||
fi
|
||||
rm -f conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: $ac_cv_func_dladdr" >&5
|
||||
echo "${ECHO_T}$ac_cv_func_dladdr" >&6
|
||||
if test $ac_cv_func_dladdr = yes; then
|
||||
:
|
||||
else
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define NO_DLADDR 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if test "`uname -s`" = "Darwin" && test "${TCL_THREADS}" = 1 && \
|
||||
test "`uname -r | awk -F. '{print $1}'`" -lt 7; then
|
||||
|
||||
@@ -214,6 +214,7 @@ AC_CHECK_FUNC(strerror, , [AC_DEFINE(NO_STRERROR, 1, [Do we have strerror()])])
|
||||
AC_CHECK_FUNC(getwd, , [AC_DEFINE(NO_GETWD, 1, [Do we have getwd()])])
|
||||
AC_CHECK_FUNC(wait3, , [AC_DEFINE(NO_WAIT3, 1, [Do we have wait3()])])
|
||||
AC_CHECK_FUNC(uname, , [AC_DEFINE(NO_UNAME, 1, [Do we have uname()])])
|
||||
AC_CHECK_FUNC(dladdr, , [AC_DEFINE(NO_DLADDR)])
|
||||
|
||||
if test "`uname -s`" = "Darwin" && test "${TCL_THREADS}" = 1 && \
|
||||
test "`uname -r | awk -F. '{print [$]1}'`" -lt 7; then
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ extern Tcl_PackageInitProc Tclxttest_Init;
|
||||
# define MODULE_SCOPE extern
|
||||
#endif
|
||||
MODULE_SCOPE int TCL_LOCAL_APPINIT(Tcl_Interp *);
|
||||
MODULE_SCOPE int main(int, char **);
|
||||
int main(int, char **);
|
||||
|
||||
/*
|
||||
* The following #if block allows you to change how Tcl finds the startup
|
||||
|
||||
@@ -12,6 +12,12 @@
|
||||
|
||||
#include "tclInt.h"
|
||||
#include "tclFileSystem.h"
|
||||
#if !defined(NO_DLADDR) && !defined(NO_DLFCN_H)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
#include <mach-o/dyld.h>
|
||||
#endif
|
||||
|
||||
static int NativeMatchType(Tcl_Interp *interp, const char* nativeEntry,
|
||||
const char* nativeName, Tcl_GlobTypeData *types);
|
||||
@@ -44,6 +50,7 @@ TclpFindExecutable(
|
||||
int length;
|
||||
char buf[PATH_MAX * 2];
|
||||
char name[PATH_MAX * TCL_UTF_MAX + 1];
|
||||
|
||||
GetModuleFileNameW(NULL, buf, PATH_MAX);
|
||||
cygwin_conv_path(3, buf, name, PATH_MAX);
|
||||
length = strlen(name);
|
||||
@@ -58,12 +65,89 @@ TclpFindExecutable(
|
||||
const char *name, *p;
|
||||
Tcl_StatBuf statBuf;
|
||||
Tcl_DString buffer, nameString, cwd, utfName;
|
||||
#ifdef __APPLE__
|
||||
char *buf;
|
||||
uint32_t bufSize;
|
||||
#elif !defined(DJGPP)
|
||||
int i;
|
||||
unsigned long pid;
|
||||
static CONST char *exepaths[] = {
|
||||
"/proc/%lu/exe", "/proc/%lu/file", "/proc/%lu/object/a.out",
|
||||
"/proc/curproc/file"
|
||||
};
|
||||
char buf1[PATH_MAX+1], buf2[64];
|
||||
ssize_t readlink_res;
|
||||
#endif
|
||||
#if !defined(NO_DLADDR) && !defined(NO_DLFCN_H)
|
||||
Dl_info dlinfoBuffer;
|
||||
void *sym;
|
||||
#endif
|
||||
|
||||
if (argv0 == NULL) {
|
||||
return;
|
||||
}
|
||||
Tcl_DStringInit(&buffer);
|
||||
|
||||
/*
|
||||
* The executable name is sometimes available to us directly, which is
|
||||
* useful because it's not always there in argv[0]; that's a value that is
|
||||
* set by the code that invoked this process and it sometimes lies. [Bug
|
||||
* 1224888]
|
||||
*
|
||||
* Our options for independently determining it are to scrape it out of
|
||||
* /proc (if that's mounted, and we have readlink(2)) or to pick the
|
||||
* information out of the dynamic loader (assuming we're using a
|
||||
* compatible one and it supports the relevant - common - extension).
|
||||
*
|
||||
* On OSX, we can use the _NSGetExecutablePath function to retrieve the
|
||||
* name of the main process. This is documented on the dyld(3) manual
|
||||
* page.
|
||||
*
|
||||
* For a list of various techniques and links to more details on how to
|
||||
* implement them, see the Stack Overflow master question at
|
||||
* http://stackoverflow.com/q/1023306/301832
|
||||
*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
buf = NULL;
|
||||
bufSize = 0;
|
||||
_NSGetExecutablePath(buf, &bufSize);
|
||||
if (bufSize > 0) {
|
||||
buf = ckalloc(bufSize+1);
|
||||
if (_NSGetExecutablePath(buf, &bufSize) == 0) {
|
||||
name = buf;
|
||||
goto gotName;
|
||||
}
|
||||
ckfree(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
#if !defined(__APPLE__) && !defined(DJGPP)
|
||||
pid = getpid();
|
||||
for (i=0 ; i<sizeof(exepaths)/sizeof(*exepaths) ; i++) {
|
||||
sprintf(buf2, exepaths[i], pid);
|
||||
readlink_res = readlink(buf2, buf1, PATH_MAX);
|
||||
if (readlink_res > 0 && buf1[0] == '/') {
|
||||
buf1[readlink_res] = '\0';
|
||||
name = buf1;
|
||||
goto gotName;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(NO_DLADDR) && !defined(NO_DLFCN_H)
|
||||
sym = dlsym(RTLD_DEFAULT, "main");
|
||||
if (sym == NULL) {
|
||||
sym = dlsym(RTLD_DEFAULT, "_main");
|
||||
}
|
||||
if (sym != NULL && dladdr(sym, &dlinfoBuffer)
|
||||
&& dlinfoBuffer.dli_fname[0] == '/') {
|
||||
name = dlinfoBuffer.dli_fname;
|
||||
goto gotName;
|
||||
}
|
||||
#endif
|
||||
|
||||
name = argv0;
|
||||
for (p = name; *p != '\0'; p++) {
|
||||
if (*p == '/') {
|
||||
@@ -191,6 +275,11 @@ TclpFindExecutable(
|
||||
Tcl_DStringFree(&utfName);
|
||||
|
||||
done:
|
||||
#ifdef __APPLE__
|
||||
if (buf != NULL) {
|
||||
ckfree(buf);
|
||||
}
|
||||
#endif /* __APPLE__ */
|
||||
Tcl_DStringFree(&buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user