Ver Fonte

FreeBSD port

rdb há 16 anos atrás
pai
commit
a307a23b41
1 ficheiros alterados com 9 adições e 5 exclusões
  1. 9 5
      direct/src/directbase/ppython.cxx

+ 9 - 5
direct/src/directbase/ppython.cxx

@@ -125,14 +125,14 @@ int main(int argc, char **argv)
 
 
 ///////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////
 //
 //
-// Linux and OSX Version
+// Linux and OSX and FreeBSD Version
 //
 //
 // This would probably work on most unixes, with the possible
 // This would probably work on most unixes, with the possible
 // exception of the /proc/self/exe bit.
 // exception of the /proc/self/exe bit.
 //
 //
 ///////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////
 
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
 
 
 #ifdef BUILDING_GENPYCODE
 #ifdef BUILDING_GENPYCODE
 #define LINK_SOURCE "/bin/genpycode"
 #define LINK_SOURCE "/bin/genpycode"
@@ -156,9 +156,9 @@ int main(int argc, char **argv)
 #include <unistd.h>
 #include <unistd.h>
 #include <string.h>
 #include <string.h>
 #include <sys/param.h>
 #include <sys/param.h>
-#ifdef __APPLE__
+#if defined( __APPLE__)
   #include <sys/malloc.h>
   #include <sys/malloc.h>
-#else
+#elif !defined(__FreeBSD__)
   #include <malloc.h>
   #include <malloc.h>
 #endif
 #endif
 
 
@@ -180,8 +180,12 @@ int main(int argc, char **argv)
   char *modargv[1024];
   char *modargv[1024];
   int fnlen,modargc;
   int fnlen,modargc;
 
 
-  // Ask linux for the file name of this executable.
+  // Ask the OS for the file name of this executable.
+#ifdef __FreeBSD__
+  int ok = readlink("/proc/curproc/file", fnbuf, PATH_MAX-1);
+#else
   int ok = readlink("/proc/self/exe", fnbuf, PATH_MAX-1);
   int ok = readlink("/proc/self/exe", fnbuf, PATH_MAX-1);
+#endif
   if (ok<0) {
   if (ok<0) {
     if (argc>0) strcpy(fnbuf, argv[0]);
     if (argc>0) strcpy(fnbuf, argv[0]);
     else errorexit("Cannot read /proc/sys/exe");
     else errorexit("Cannot read /proc/sys/exe");