pollita         Fri Jan  5 21:30:06 2007 UTC

  Modified files:              
    /php-src/ext/posix  config.m4 posix.c 
  Log:
  Refix posix_ttyname(), test for a working implementation of ttyname_r() -- 
which BSD doesn't have
  
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/config.m4?r1=1.15&r2=1.16&diff_format=u
Index: php-src/ext/posix/config.m4
diff -u php-src/ext/posix/config.m4:1.15 php-src/ext/posix/config.m4:1.16
--- php-src/ext/posix/config.m4:1.15    Thu Dec  7 01:41:29 2006
+++ php-src/ext/posix/config.m4 Fri Jan  5 21:30:06 2007
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.15 2006/12/07 01:41:29 iliaa Exp $
+dnl $Id: config.m4,v 1.16 2007/01/05 21:30:06 pollita Exp $
 dnl
 
 PHP_ARG_ENABLE(posix,whether to enable POSIX-like functions,
@@ -11,5 +11,22 @@
 
   AC_CHECK_HEADERS(sys/mkdev.h)
 
-  AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo 
mknod getrlimit getlogin getgroups makedev initgroups getpwuid_r getgrgid_r 
ttyname_r)
+  AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo 
mknod getrlimit getlogin getgroups makedev initgroups getpwuid_r getgrgid_r)
+
+  AC_MSG_CHECKING([for working ttyname_r() implementation])
+  AC_TRY_RUN([
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+       char buf[64];
+
+       return ttyname_r(0, buf, 64) ? 1 : 0;
+}
+  ],[
+    AC_MSG_RESULT([yes])
+    AC_DEFINE(HAVE_TTYNAME_R, 1, [Whether you have a working ttyname_r])
+  ],[
+    AC_MSG_RESULT([no, posix_ttyname() will be thread-unsafe])
+  ])
 fi
http://cvs.php.net/viewvc.cgi/php-src/ext/posix/posix.c?r1=1.86&r2=1.87&diff_format=u
Index: php-src/ext/posix/posix.c
diff -u php-src/ext/posix/posix.c:1.86 php-src/ext/posix/posix.c:1.87
--- php-src/ext/posix/posix.c:1.86      Fri Jan  5 20:01:44 2007
+++ php-src/ext/posix/posix.c   Fri Jan  5 21:30:06 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: posix.c,v 1.86 2007/01/05 20:01:44 pollita Exp $ */
+/* $Id: posix.c,v 1.87 2007/01/05 21:30:06 pollita Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -147,7 +147,7 @@
 static PHP_MINFO_FUNCTION(posix)
 {
        php_info_print_table_start();
-       php_info_print_table_row(2, "Revision", "$Revision: 1.86 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.87 $");
        php_info_print_table_end();
 }
 /* }}} */
@@ -575,12 +575,7 @@
                        fd = Z_LVAL_PP(z_fd);
        }
 #if HAVE_TTYNAME_R
-#ifdef _SC_TTY_NAME_MAX
        buflen = sysconf(_SC_TTY_NAME_MAX);
-#else
-       /* Arbitrary buffer size for systems which don't extrospect their tty 
name lengths, way overkill */
-       buflen = 64;
-#endif
        p = emalloc(buflen);
 
        if (ttyname_r(fd, p, buflen)) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to