Re: [AD] [PATCH] Solaris Fixes and dev notes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I've commited the attached patch that should incorporate all of teh changes 
you mentioned. Please confirm if it does indeed work.

Evert
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	12 Jun 2005 07:59:35 -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	12 Jun 2005 07:59:37 -0000
@@ -448,6 +448,14 @@
    fi
 fi
 
+dnl Test for Solaris 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	12 Jun 2005 07:59:38 -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,9 +370,12 @@
    
       /* Use argv[0] directly if we can */
       #ifdef ALLEGRO_HAVE_PROCFS_ARGCV
-         if (_find_executable_file(psinfo.pr_argv[0], output, size))
-            return;
-      #else
+         if (psinfo.pr_argv && psinfo.pr_argc) {
+            if (_find_executable_file(psinfo.pr_argv[0], output, size))
+               return;
+         }
+         else {
+      #endif
          /* Emulate it */
          /* We use the pr_psargs field to find argv[0]
          * This is better than using the pr_fname field because we need the
@@ -367,6 +387,8 @@
          if (s) s[0] = '\0';
          if (_find_executable_file(psinfo.pr_psargs, output, size))
             return;
+      #ifdef ALLEGRO_HAVE_PROCFS_ARGCV
+         }
       #endif
 
       /* Try the pr_fname just for completeness' sake if argv[0] fails */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/