Re: [AD] [PATCH] Solaris Fixes and dev notes |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Sunday 05 June 2005 19:26, Shawn Walker wrote:
> A further note I forgot: the data member allegro was trying to access is
> definitely a valid part of the struct, it was just NULL in this
particular
> case. Why, I can't say. Maybe under another set of circumstances the
struct
> works just fine. However, I'm going to bet that getexecname() will be far
> more reliable and appears to have been in Solaris for a long time now
(since
> 1997).
Proposed patch attached. Please check if it works as it should. The
configure check works by checking if getexecname() is present in libc.
Allegro already has a function for finding an executable, either in the
current directory or in the path if the path is relative, so I ended up
using that one instead.
Evert
? allegro.vcproj
? cvs.diff
? sw.c.patch
? test.c.patch
? todo.diff
Index: aclocal.m4
===================================================================
RCS file: /cvsroot/alleg/allegro/aclocal.m4,v
retrieving revision 1.77
diff -u -r1.77 aclocal.m4
--- aclocal.m4 24 May 2005 14:58:27 -0000 1.77
+++ aclocal.m4 5 Jun 2005 19:31:47 -0000
@@ -218,6 +218,19 @@
AC_MSG_RESULT($allegro_procfs_argcv)
dnl
+dnl Test for getexecname() on Solaris
+dnl
+dnl Variables:
+dnl allegro_sys_getexecname=(yes|no)
+dnl
+AC_MSG_CHECKING(for getexecname)
+AC_DEFUN(ALLEGRO_SYS_GETEXECNAME,
+ [AC_CHECK_LIB(c, getexecname,
+ [allegro_sys_getexecname = yes], [allegro_sys_getexecname=no])]
+)
+AC_MSG_RESULT($allegro_sys_getexecname)
+
+dnl
dnl Test for X-Windows support.
dnl
dnl Variables:
Index: configure.in
===================================================================
RCS file: /cvsroot/alleg/allegro/configure.in,v
retrieving revision 1.90
diff -u -r1.90 configure.in
--- configure.in 24 May 2005 14:58:27 -0000 1.90
+++ configure.in 5 Jun 2005 19:31:48 -0000
@@ -448,6 +448,14 @@
fi
fi
+dnl Test for Soalris like getexecname().
+ALLEGRO_SYS_GETEXECNAME
+if test "$allegro_sys_getexecname" = yes; then
+ AC_DEFINE(ALLEGRO_HAVE_GETEXECNAME,1,
+ [Define to 1 if you have getexecname])
+fi
+
+
dnl Test for X-Windows support.
ALLEGRO_ACTEST_SUPPORT_XWINDOWS
if test "$allegro_support_xwindows" = yes; then
Index: src/unix/usystem.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/usystem.c,v
retrieving revision 1.34
diff -u -r1.34 usystem.c
--- src/unix/usystem.c 12 Mar 2005 06:29:06 -0000 1.34
+++ src/unix/usystem.c 5 Jun 2005 19:31:49 -0000
@@ -319,6 +319,8 @@
#ifdef ALLEGRO_HAVE_SV_PROCFS
struct prpsinfo psinfo;
int fd;
+ #endif
+ #if defined ALLEGRO_HAVE_SV_PROCFS || defined ALLEGRO_SYS_GETEXECNAME
char *s;
#endif
char linkname[1024];
@@ -327,11 +329,26 @@
FILE *pipe;
pid_t pid;
int len;
+
+ #ifdef ALLEGRO_HAVE_GETEXECNAME
+ s = getexecname();
+ if (s) {
+ if (s[0] == '/') { /* Absolute path */
+ do_uconvert (s, U_ASCII, output, U_CURRENT, size);
+ return;
+ }
+ else { /* Not an absolute path */
+ if (_find_executable_file(s, output, size))
+ return;
+ }
+ }
+ s = NULL;
+ #endif
/* We need the PID in order to query procfs */
pid = getpid();
- /* First try a Linux-like procfs */
+ /* Try a Linux-like procfs */
/* get symolic link to executable from proc fs */
sprintf (linkname, "/proc/%d/exe", pid);
if (stat (linkname, &finfo) == 0) {
@@ -353,8 +370,10 @@
/* Use argv[0] directly if we can */
#ifdef ALLEGRO_HAVE_PROCFS_ARGCV
- if (_find_executable_file(psinfo.pr_argv[0], output, size))
- return;
+ if (psinfo.pr_argv) {
+ if (_find_executable_file(psinfo.pr_argv[0], output, size))
+ return;
+ }
#else
/* Emulate it */
/* We use the pr_psargs field to find argv[0]