ports/lang/mtasc/files/patch-extc_extc_stubs.c
Stanislav Sedov c6762e8051 - Update lang/ocaml to 3.11.0. [1]
- Fix devel/cil build with 3.11.0 by using proper object file name
- Fix devel/deputy build with 3.11.0 by using proper object file name
- Fix lang/mtasc. Ocamlp4 syntax has changed and usage of ';' as delimiters
  is not allowed now.
- Fix usage message in lang/mtasc.
- Implement a FreeBSD specific code for retriving the executable path in lang/mtasc.
- Update devel/omake to 0.9.8.5.
- Fix devel/omake compilation with 3.11 by dropping an unused reference from the code.
- Fix www/geneweb build with 3.11 by not emitting errors for warnings.
- Fix print/advi build. [2]
- Update lang/cduce to 0.5.3 (this fixes build with ocaml 3.11.0).

PR:		ports/130845 [1] [2] (based on)
Submitted by:	Hirohisa Yamaguchi <umq@ueo.co.jp> [1],
		Tsurutani Naoki <turutani@scphys.kyoto-u.ac.jp> [2]
2009-04-11 13:23:05 +00:00

42 lines
1 KiB
C

--- extc/extc_stubs.c.orig 2007-03-05 14:09:37.000000000 +0300
+++ extc/extc_stubs.c 2009-04-11 12:57:23.000000000 +0400
@@ -32,6 +32,11 @@
# include <sys/syslimits.h>
# include <mach-o/dyld.h>
#endif
+#ifdef __FreeBSD__
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# include <sys/user.h>
+#endif
#define zval(z) ((z_streamp)(z))
@@ -125,7 +130,26 @@
}
CAMLprim value executable_path(value u) {
-#ifdef _WIN32
+#if defined(__FreeBSD__)
+ char pathname[PATH_MAX];
+ int error, name[4];
+ size_t len;
+ pid_t pid;
+
+ pid = getpid();
+ name[0] = CTL_KERN;
+ name[1] = KERN_PROC;
+ name[2] = KERN_PROC_PATHNAME;
+ name[3] = pid;
+
+ len = sizeof(pathname);
+ error = sysctl(name, 4, pathname, &len, NULL, 0);
+ if (error < 0 && errno != ESRCH)
+ warn("sysctl: kern.proc.pathname: %d", pid);
+ if (error < 0)
+ return caml_copy_string("-");
+ return caml_copy_string(pathname);
+#elif defined(_WIN32)
char path[MAX_PATH];
if( GetModuleFileName(NULL,path,MAX_PATH) == 0 )
failwith("executable_path");