mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
Add support for /proc/curproc for FreeBSD
This commit is contained in:
parent
ea3a9ffaa8
commit
961a754ec4
@ -84,9 +84,15 @@
|
|||||||
#define GLOBAL_ARGV
|
#define GLOBAL_ARGV
|
||||||
#define GLOBAL_ARGC
|
#define GLOBAL_ARGC
|
||||||
|
|
||||||
// Can we read the file /proc/self/cmdline to determine our
|
// Can we read the file /proc/curproc/* to determine our
|
||||||
// command-line arguments at static init time?
|
// command-line arguments at static init time?
|
||||||
|
#define HAVE_PROC_SELF_EXE
|
||||||
|
#define HAVE_PROC_SELF_MAPS
|
||||||
|
#define HAVE_PROC_SELF_ENVIRON
|
||||||
#define HAVE_PROC_SELF_CMDLINE
|
#define HAVE_PROC_SELF_CMDLINE
|
||||||
|
#define HAVE_PROC_CURPROC_FILE 1
|
||||||
|
#define HAVE_PROC_CURPROC_MAP 1
|
||||||
|
#define HAVE_PROC_CURPROC_CMDLINE 1
|
||||||
|
|
||||||
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
||||||
// to nonempty if we should use <iostream>, or empty if we should use
|
// to nonempty if we should use <iostream>, or empty if we should use
|
||||||
|
@ -235,9 +235,12 @@
|
|||||||
// Can we safely call getenv() at static init time?
|
// Can we safely call getenv() at static init time?
|
||||||
#define STATIC_INIT_GETENV 1
|
#define STATIC_INIT_GETENV 1
|
||||||
|
|
||||||
// Can we read the file /proc/self/environ to determine our
|
// Can we read the files /proc/self/* to determine our
|
||||||
// environment variables at static init time?
|
// environment variables at static init time?
|
||||||
|
#define HAVE_PROC_SELF_EXE 1
|
||||||
|
#define HAVE_PROC_SELF_MAPS 1
|
||||||
#define HAVE_PROC_SELF_ENVIRON 1
|
#define HAVE_PROC_SELF_ENVIRON 1
|
||||||
|
#define HAVE_PROC_SELF_CMDLINE 1
|
||||||
|
|
||||||
// Do we have a global pair of argc/argv variables that we can read at
|
// Do we have a global pair of argc/argv variables that we can read at
|
||||||
// static init time? Should we prototype them? What are they called?
|
// static init time? Should we prototype them? What are they called?
|
||||||
@ -246,10 +249,6 @@
|
|||||||
#define GLOBAL_ARGV
|
#define GLOBAL_ARGV
|
||||||
#define GLOBAL_ARGC
|
#define GLOBAL_ARGC
|
||||||
|
|
||||||
// Can we read the file /proc/self/cmdline to determine our
|
|
||||||
// command-line arguments at static init time?
|
|
||||||
#define HAVE_PROC_SELF_CMDLINE 1
|
|
||||||
|
|
||||||
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
||||||
// to nonempty if we should use <iostream>, or empty if we should use
|
// to nonempty if we should use <iostream>, or empty if we should use
|
||||||
// <iostream.h>.
|
// <iostream.h>.
|
||||||
|
@ -187,9 +187,12 @@
|
|||||||
// Can we safely call getenv() at static init time?
|
// Can we safely call getenv() at static init time?
|
||||||
#define STATIC_INIT_GETENV 1
|
#define STATIC_INIT_GETENV 1
|
||||||
|
|
||||||
// Can we read the file /proc/self/environ to determine our
|
// Can we read the file /proc/self/* to determine our
|
||||||
// environment variables at static init time?
|
// environment variables at static init time?
|
||||||
#define HAVE_PROC_SELF_ENVIRON 1
|
#define HAVE_PROC_SELF_EXE
|
||||||
|
#define HAVE_PROC_SELF_MAPS
|
||||||
|
#define HAVE_PROC_SELF_ENVIRON
|
||||||
|
#define HAVE_PROC_SELF_CMDLINE
|
||||||
|
|
||||||
// Do we have a global pair of argc/argv variables that we can read at
|
// Do we have a global pair of argc/argv variables that we can read at
|
||||||
// static init time? Should we prototype them? What are they called?
|
// static init time? Should we prototype them? What are they called?
|
||||||
@ -198,10 +201,6 @@
|
|||||||
#define GLOBAL_ARGV __Argv
|
#define GLOBAL_ARGV __Argv
|
||||||
#define GLOBAL_ARGC __Argc
|
#define GLOBAL_ARGC __Argc
|
||||||
|
|
||||||
// Can we read the file /proc/self/cmdline to determine our
|
|
||||||
// command-line arguments at static init time?
|
|
||||||
#define HAVE_PROC_SELF_CMDLINE
|
|
||||||
|
|
||||||
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
||||||
// to nonempty if we should use <iostream>, or empty if we should use
|
// to nonempty if we should use <iostream>, or empty if we should use
|
||||||
// <iostream.h>.
|
// <iostream.h>.
|
||||||
|
@ -74,9 +74,12 @@
|
|||||||
// Can we safely call getenv() at static init time?
|
// Can we safely call getenv() at static init time?
|
||||||
#define STATIC_INIT_GETENV 1
|
#define STATIC_INIT_GETENV 1
|
||||||
|
|
||||||
// Can we read the file /proc/self/environ to determine our
|
// Can we read the file /proc/self/* to determine our
|
||||||
// environment variables at static init time?
|
// environment variables at static init time?
|
||||||
|
#define HAVE_PROC_SELF_EXE
|
||||||
|
#define HAVE_PROC_SELF_MAPS
|
||||||
#define HAVE_PROC_SELF_ENVIRON
|
#define HAVE_PROC_SELF_ENVIRON
|
||||||
|
#define HAVE_PROC_SELF_CMDLINE
|
||||||
|
|
||||||
// Do we have a global pair of argc/argv variables that we can read at
|
// Do we have a global pair of argc/argv variables that we can read at
|
||||||
// static init time? Should we prototype them? What are they called?
|
// static init time? Should we prototype them? What are they called?
|
||||||
@ -85,10 +88,6 @@
|
|||||||
#define GLOBAL_ARGV __argv
|
#define GLOBAL_ARGV __argv
|
||||||
#define GLOBAL_ARGC __argc
|
#define GLOBAL_ARGC __argc
|
||||||
|
|
||||||
// Can we read the file /proc/self/cmdline to determine our
|
|
||||||
// command-line arguments at static init time?
|
|
||||||
#define HAVE_PROC_SELF_CMDLINE
|
|
||||||
|
|
||||||
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
// Should we include <iostream> or <iostream.h>? Define HAVE_IOSTREAM
|
||||||
// to nonempty if we should use <iostream>, or empty if we should use
|
// to nonempty if we should use <iostream>, or empty if we should use
|
||||||
// <iostream.h>.
|
// <iostream.h>.
|
||||||
|
@ -529,9 +529,15 @@ $[cdefine HAVE_IOS_BINARY]
|
|||||||
/* Can we safely call getenv() at static init time? */
|
/* Can we safely call getenv() at static init time? */
|
||||||
$[cdefine STATIC_INIT_GETENV]
|
$[cdefine STATIC_INIT_GETENV]
|
||||||
|
|
||||||
/* Can we read the file /proc/self/environ to determine our
|
/* Can we read the file /proc/self/* to determine our
|
||||||
environment variables at static init time? */
|
environment variables at static init time? */
|
||||||
|
$[cdefine HAVE_PROC_SELF_EXE]
|
||||||
|
$[cdefine HAVE_PROC_SELF_MAPS]
|
||||||
$[cdefine HAVE_PROC_SELF_ENVIRON]
|
$[cdefine HAVE_PROC_SELF_ENVIRON]
|
||||||
|
$[cdefine HAVE_PROC_SELF_CMDLINE]
|
||||||
|
$[cdefine HAVE_PROC_CURPROC_FILE]
|
||||||
|
$[cdefine HAVE_PROC_CURPROC_MAP]
|
||||||
|
$[cdefine HAVE_PROC_CURPROC_CMDLINE]
|
||||||
|
|
||||||
/* Do we have a global pair of argc/argv variables that we can read at
|
/* Do we have a global pair of argc/argv variables that we can read at
|
||||||
static init time? Should we prototype them? What are they called? */
|
static init time? Should we prototype them? What are they called? */
|
||||||
@ -540,10 +546,6 @@ $[cdefine PROTOTYPE_GLOBAL_ARGV]
|
|||||||
$[cdefine GLOBAL_ARGV]
|
$[cdefine GLOBAL_ARGV]
|
||||||
$[cdefine GLOBAL_ARGC]
|
$[cdefine GLOBAL_ARGC]
|
||||||
|
|
||||||
/* Can we read the file /proc/self/cmdline to determine our
|
|
||||||
command-line arguments at static init time? */
|
|
||||||
$[cdefine HAVE_PROC_SELF_CMDLINE]
|
|
||||||
|
|
||||||
/* Define if you have the <io.h> header file. */
|
/* Define if you have the <io.h> header file. */
|
||||||
$[cdefine HAVE_IO_H]
|
$[cdefine HAVE_IO_H]
|
||||||
|
|
||||||
|
@ -460,10 +460,14 @@ read_args() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_PROC_SELF_MAPS)
|
#if defined(HAVE_PROC_SELF_MAPS) || defined(HAVE_PROC_CURPROC_MAP)
|
||||||
// This is how you tell whether or not libdtool.so is loaded,
|
// This is how you tell whether or not libdtool.so is loaded,
|
||||||
// and if so, where it was loaded from.
|
// and if so, where it was loaded from.
|
||||||
|
#ifdef HAVE_PROC_CURPROC_MAP
|
||||||
|
pifstream maps("/proc/curproc/map");
|
||||||
|
#else
|
||||||
pifstream maps("/proc/self/maps");
|
pifstream maps("/proc/self/maps");
|
||||||
|
#endif
|
||||||
while (!maps.fail() && !maps.eof()) {
|
while (!maps.fail() && !maps.eof()) {
|
||||||
char buffer[PATH_MAX];
|
char buffer[PATH_MAX];
|
||||||
buffer[0] = 0;
|
buffer[0] = 0;
|
||||||
@ -502,11 +506,15 @@ read_args() {
|
|||||||
}
|
}
|
||||||
#endif // WIN32_VC
|
#endif // WIN32_VC
|
||||||
|
|
||||||
#if defined(HAVE_PROC_SELF_EXE)
|
#if defined(HAVE_PROC_SELF_EXE) || defined(HAVE_PROC_CURPROC_FILE)
|
||||||
// This is more reliable than using (argc,argv), so it given precedence.
|
// This is more reliable than using (argc,argv), so it given precedence.
|
||||||
if (_binary_name.empty()) {
|
if (_binary_name.empty()) {
|
||||||
char readlinkbuf[PATH_MAX];
|
char readlinkbuf[PATH_MAX];
|
||||||
|
#ifdef HAVE_PROC_CURPROC_FILE
|
||||||
|
int pathlen = readlink("/proc/curproc/file",readlinkbuf,PATH_MAX-1);
|
||||||
|
#else
|
||||||
int pathlen = readlink("/proc/self/exe",readlinkbuf,PATH_MAX-1);
|
int pathlen = readlink("/proc/self/exe",readlinkbuf,PATH_MAX-1);
|
||||||
|
#endif
|
||||||
if (pathlen > 0) {
|
if (pathlen > 0) {
|
||||||
readlinkbuf[pathlen] = 0;
|
readlinkbuf[pathlen] = 0;
|
||||||
_binary_name = readlinkbuf;
|
_binary_name = readlinkbuf;
|
||||||
@ -538,18 +546,26 @@ read_args() {
|
|||||||
_args.push_back(GLOBAL_ARGV[i]);
|
_args.push_back(GLOBAL_ARGV[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(HAVE_PROC_SELF_CMDLINE)
|
#elif defined(HAVE_PROC_SELF_CMDLINE) || defined(HAVE_PROC_CURPROC_CMDLINE)
|
||||||
// In Linux, and possibly in other systems as well, we might not be
|
// In Linux, and possibly in other systems as well, we might not be
|
||||||
// able to use the global ARGC/ARGV variables at static init time.
|
// able to use the global ARGC/ARGV variables at static init time.
|
||||||
// However, we may be lucky and have a file called
|
// However, we may be lucky and have a file called
|
||||||
// /proc/self/cmdline that may be read to determine all of our
|
// /proc/self/cmdline that may be read to determine all of our
|
||||||
// command-line arguments.
|
// command-line arguments.
|
||||||
|
|
||||||
|
#ifdef HAVE_PROC_CURPROC_CMDLINE
|
||||||
|
pifstream proc("/proc/curproc/cmdline");
|
||||||
|
if (proc.fail()) {
|
||||||
|
cerr << "Cannot read /proc/curproc/cmdline; command-line arguments unavailable to config.\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
pifstream proc("/proc/self/cmdline");
|
pifstream proc("/proc/self/cmdline");
|
||||||
if (proc.fail()) {
|
if (proc.fail()) {
|
||||||
cerr << "Cannot read /proc/self/cmdline; command-line arguments unavailable to config.\n";
|
cerr << "Cannot read /proc/self/cmdline; command-line arguments unavailable to config.\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int ch = proc.get();
|
int ch = proc.get();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -994,6 +994,9 @@ DTOOL_CONFIG=[
|
|||||||
("HAVE_PROC_SELF_MAPS", 'UNDEF', '1'),
|
("HAVE_PROC_SELF_MAPS", 'UNDEF', '1'),
|
||||||
("HAVE_PROC_SELF_ENVIRON", 'UNDEF', '1'),
|
("HAVE_PROC_SELF_ENVIRON", 'UNDEF', '1'),
|
||||||
("HAVE_PROC_SELF_CMDLINE", 'UNDEF', '1'),
|
("HAVE_PROC_SELF_CMDLINE", 'UNDEF', '1'),
|
||||||
|
("HAVE_PROC_CURPROC_FILE", 'UNDEF', 'UNDEF'),
|
||||||
|
("HAVE_PROC_CURPROC_MAP", 'UNDEF', 'UNDEF'),
|
||||||
|
("HAVE_PROC_SELF_CMDLINE", 'UNDEF', 'UNDEF'),
|
||||||
("HAVE_GLOBAL_ARGV", '1', 'UNDEF'),
|
("HAVE_GLOBAL_ARGV", '1', 'UNDEF'),
|
||||||
("PROTOTYPE_GLOBAL_ARGV", 'UNDEF', 'UNDEF'),
|
("PROTOTYPE_GLOBAL_ARGV", 'UNDEF', 'UNDEF'),
|
||||||
("GLOBAL_ARGV", '__argv', 'UNDEF'),
|
("GLOBAL_ARGV", '__argv', 'UNDEF'),
|
||||||
@ -1112,6 +1115,12 @@ def WriteConfigSettings():
|
|||||||
dtool_config["HAVE_CGGL"] = '1'
|
dtool_config["HAVE_CGGL"] = '1'
|
||||||
dtool_config["HAVE_CGDX9"] = '1'
|
dtool_config["HAVE_CGDX9"] = '1'
|
||||||
|
|
||||||
|
if (not sys.platform.startswith("linux")):
|
||||||
|
dtool_config["HAVE_PROC_SELF_EXE"] = 'UNDEF'
|
||||||
|
dtool_config["HAVE_PROC_SELF_MAPS"] = 'UNDEF'
|
||||||
|
dtool_config["HAVE_PROC_SELF_CMDLINE"] = 'UNDEF'
|
||||||
|
dtool_config["HAVE_PROC_SELF_ENVIRON"] = 'UNDEF'
|
||||||
|
|
||||||
if (sys.platform == "darwin"):
|
if (sys.platform == "darwin"):
|
||||||
dtool_config["PYTHON_FRAMEWORK"] = 'Python'
|
dtool_config["PYTHON_FRAMEWORK"] = 'Python'
|
||||||
dtool_config["HAVE_MALLOC_H"] = 'UNDEF'
|
dtool_config["HAVE_MALLOC_H"] = 'UNDEF'
|
||||||
@ -1121,16 +1130,15 @@ def WriteConfigSettings():
|
|||||||
dtool_config["HAVE_XF86DGA"] = 'UNDEF'
|
dtool_config["HAVE_XF86DGA"] = 'UNDEF'
|
||||||
dtool_config["IS_LINUX"] = 'UNDEF'
|
dtool_config["IS_LINUX"] = 'UNDEF'
|
||||||
dtool_config["IS_OSX"] = '1'
|
dtool_config["IS_OSX"] = '1'
|
||||||
dtool_config["HAVE_PROC_SELF_EXE"] = 'UNDEF'
|
|
||||||
dtool_config["HAVE_PROC_SELF_MAPS"] = 'UNDEF'
|
|
||||||
dtool_config["HAVE_PROC_SELF_CMDLINE"] = 'UNDEF'
|
|
||||||
dtool_config["HAVE_PROC_SELF_ENVIRON"] = 'UNDEF'
|
|
||||||
|
|
||||||
if (sys.platform.startswith("freebsd")):
|
if (sys.platform.startswith("freebsd")):
|
||||||
dtool_config["IS_LINUX"] = 'UNDEF'
|
dtool_config["IS_LINUX"] = 'UNDEF'
|
||||||
dtool_config["IS_FREEBSD"] = '1'
|
dtool_config["IS_FREEBSD"] = '1'
|
||||||
dtool_config["HAVE_ALLOCA_H"] = 'UNDEF'
|
dtool_config["HAVE_ALLOCA_H"] = 'UNDEF'
|
||||||
dtool_config["HAVE_MALLOC_H"] = 'UNDEF'
|
dtool_config["HAVE_MALLOC_H"] = 'UNDEF'
|
||||||
|
dtool_config["HAVE_PROC_CURPROC_FILE"] = '1'
|
||||||
|
dtool_config["HAVE_PROC_CURPROC_MAP"] = '1'
|
||||||
|
dtool_config["HAVE_PROC_CURPROC_CMDLINE"] = '1'
|
||||||
|
|
||||||
if (OPTIMIZE <= 3):
|
if (OPTIMIZE <= 3):
|
||||||
if (dtool_config["HAVE_NET"] != 'UNDEF'):
|
if (dtool_config["HAVE_NET"] != 'UNDEF'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user