David Carlier implemented SDL_GetBasePath() for OpenBSD this feature is utilized by the upcoming falltergeist port I'm working on.
The change was accepted and committed upstream in: - 698a7d8626b95e3147b9ff8242d7023cb91f6a20 - https://hg.libsdl.org/SDL/raw-rev/698a7d8626b9 - https://hg.libsdl.org/SDL/rev/698a7d8626b9 I prepared some trivial sample code to test the change before & after the patch: - https://gist.github.com/mulander/5c6bb3b66a5a4df4f32f Initially I wanted to implement a similar change in falltergeist until we obtain a newer SDL (there is no SDL2 version released with this change) but bentleyy@ suggested that it might be better to just backport the SDL2 patch. This patch of course should die as soon as a new upstream release hits. Feedback? Better ways to do this? OK's? Regards, Adam Index: Makefile =================================================================== RCS file: /cvs/ports/devel/sdl2/Makefile,v retrieving revision 1.14 diff -u -p -r1.14 Makefile --- Makefile 19 Mar 2016 11:34:50 -0000 1.14 +++ Makefile 27 Mar 2016 20:55:14 -0000 @@ -4,7 +4,7 @@ COMMENT= cross-platform multimedia libra BROKEN-hppa= src/atomic/SDL_spinlock.c:101:2: error: #error Please implement for your platform. V= 2.0.4 -REVISION= 0 +REVISION= 1 DISTNAME= SDL2-${V} PKGNAME= sdl2-${V} CATEGORIES= devel Index: patches/patch-src_filesystem_unix_SDL_sysfilesystem_c =================================================================== RCS file: patches/patch-src_filesystem_unix_SDL_sysfilesystem_c diff -N patches/patch-src_filesystem_unix_SDL_sysfilesystem_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_filesystem_unix_SDL_sysfilesystem_c 27 Mar 2016 20:55:14 -0000 @@ -0,0 +1,46 @@ +$OpenBSD$ +Backport 698a7d8626b95e3147b9ff8242d7023cb91f6a20 to SDL2 v2.0.4 +David Carlier implemented SDL_GetBasePath() for OpenBSD + +This change is now present upstream, delete this patch when we hit +a SDL2 version containing the changeset + +--- src/filesystem/unix/SDL_sysfilesystem.c.orig Sun Mar 27 22:39:42 2016 ++++ src/filesystem/unix/SDL_sysfilesystem.c Sun Mar 27 22:42:57 2016 +@@ -33,7 +33,7 @@ + #include <sys/types.h> + #include <limits.h> + +-#ifdef __FREEBSD__ ++#if defined(__FREEBSD__) || defined(__OPENBSD__) + #include <sys/sysctl.h> + #endif + +@@ -90,7 +90,26 @@ SDL_GetBasePath(void) + return NULL; + } + } +-#elif defined(__SOLARIS__) ++#endif ++#if defined(__OPENBSD__) ++ char **retvalargs; ++ size_t len; ++ const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; ++ if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { ++ retvalargs = SDL_malloc(len); ++ if (!retvalargs) { ++ SDL_OutOfMemory(); ++ return NULL; ++ } ++ sysctl(mib, 4, retvalargs, &len, NULL, 0); ++ retval = SDL_malloc(PATH_MAX + 1); ++ if (retval) ++ realpath(retvalargs[0], retval); ++ ++ SDL_free(retvalargs); ++ } ++#endif ++#if defined(__SOLARIS__) + const char *path = getexecname(); + if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ + retval = SDL_strdup(path);