SDL_GetBasePath / OpenBSD

Hi all,

For my first submission I wanted to implement SDL_GetBasePath for OpenBSD.

Hope it is helpful.

Kind regards.
-------------- next part --------------
diff -r 4f139e059592 src/filesystem/unix/SDL_sysfilesystem.c
— a/src/filesystem/unix/SDL_sysfilesystem.c Fri Jan 22 13:12:16 2016 -0800
+++ b/src/filesystem/unix/SDL_sysfilesystem.c Sat Jan 23 16:07:21 2016 +0000
@@ -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 @@
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);

Hi all,

For my first submission I wanted to implement SDL_GetBasePath for OpenBSD.

Hope it is helpful.

Kind regards.
-------------- next part --------------
diff -r 4f139e059592 src/filesystem/unix/SDL_sysfilesystem.c
— a/src/filesystem/unix/SDL_sysfilesystem.c Fri Jan 22 13:12:16 2016 -0800
+++ b/src/filesystem/unix/SDL_sysfilesystem.c Sat Jan 23 16:07:21 2016 +0000
@@ -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 @@
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);

Got it, thanks!

https://hg.libsdl.org/SDL/rev/698a7d8626b9On Sun, Jan 24, 2016 at 4:01 AM, David CARLIER wrote:

Hi all,

For my first submission I wanted to implement SDL_GetBasePath for OpenBSD.

Hope it is helpful.

Kind regards.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Is OPENBSD defined by the SDL compilation process? Because on my
machine only OpenBSD is predefined.

Regards,–
David Demelier

Thanks for the submission, but it would probably be better if you posted this to the issue tracker. That’s where submissions get seen and acted on by the SDL team the most easily.
MasonFrom: David CARLIER
To: sdl at lists.libsdl.org
Sent: Saturday, January 23, 2016 11:12 AM
Subject: [SDL] SDL_GetBasePath / OpenBSD

Hi all,

For my first submission I wanted to implement SDL_GetBasePath for OpenBSD.

Hope it is helpful.

Kind regards.

Hi it is has been already merged since then but yes you re right I ll do
like this next time (if any …).

Kind regards.On 8 March 2016 at 21:07, Mason Wheeler wrote:

Thanks for the submission, but it would probably be better if you posted
this to the issue tracker. That’s where submissions get seen and acted on
by the SDL team the most easily.
Mason


From: David CARLIER <@David_CARLIER>
To: sdl at lists.libsdl.org
Sent: Saturday, January 23, 2016 11:12 AM
Subject: [SDL] SDL_GetBasePath / OpenBSD

Hi all,

For my first submission I wanted to implement SDL_GetBasePath for OpenBSD.

Hope it is helpful.

Kind regards.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org