[xiph-cvs] cvs commit: vorbis-tools/ogg123 Makefile.am ogg123.c

Stan Seibert volsung at xiph.org
Mon Dec 17 09:28:36 PST 2001



volsung     01/12/17 09:28:35

  Modified:    .        Tag: volsung_kc_20011011 acinclude.m4 configure.in
               ogg123   Tag: volsung_kc_20011011 Makefile.am ogg123.c
  Log:
  Various fixes for Solaris.

Revision  Changes    Path
No                   revision

No                   revision

1.9.4.3   +192 -0    vorbis-tools/acinclude.m4

Index: acinclude.m4
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/acinclude.m4,v
retrieving revision 1.9.4.2
retrieving revision 1.9.4.3
diff -u -r1.9.4.2 -r1.9.4.3
--- acinclude.m4	2001/12/16 04:38:35	1.9.4.2
+++ acinclude.m4	2001/12/17 17:28:32	1.9.4.3
@@ -509,3 +509,195 @@
   AC_SUBST(CURL_LIBS)
   rm -f conf.curltest
 ])
+
+
+dnl ACX_PTHREAD macro by Steven G. Johnson <stevenj at alum.mit.edu> and
+dnl Alejandro Forero Cuervo <bachue at bachue.com>.  Found at:
+dnl http://www.gnu.org/software/ac-archive/Installed_Packages/acx_pthread.html
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+acx_pthread_ok=no
+
+# First, check if the POSIX threads header, pthread.h, is available.
+# If it isn't, don't bother looking for the threads libraries.
+AC_CHECK_HEADER(pthread.h, , acx_pthread_ok=noheader)
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test x"$acx_pthread_ok" = xno; then
+                PTHREAD_LIBS=""
+                PTHREAD_CFLAGS=""
+        fi
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+fi
+
+# Create a list of thread flags to try.  Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt"
+
+# The ordering *is* (sometimes) important.  Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+#       other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+#      doesn't hurt to check since this sometimes defines pthreads too;
+#      also defines -D_REENTRANT)
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+
+case "${host_cpu}-${host_os}" in
+        *solaris*)
+
+        # On Solaris (at least, for some versions), libc contains stubbed
+        # (non-functional) versions of the pthreads routines, so link-based
+        # tests will erroneously succeed.  (We need to link with -pthread or
+        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather
+        # a function called by this macro, so we could check for that, but
+        # who knows whether they'll stub that too in a future libc.)  So,
+        # we'll just look for -pthreads and -lpthread first:
+
+        acx_pthread_flags="pthread -pthread -pthreads -mt $acx_pthread_flags"
+        ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+        case $flag in
+                none)
+                AC_MSG_CHECKING([whether pthreads work without any flags])
+                ;;
+
+                -*)
+                AC_MSG_CHECKING([whether pthreads work with $flag])
+                PTHREAD_CFLAGS="$flag"
+                ;;
+
+                *)
+                AC_MSG_CHECKING([for the pthreads library -l$flag])
+                PTHREAD_LIBS="-l$flag"
+                ;;
+        esac
+
+        save_LIBS="$LIBS"
+        save_CFLAGS="$CFLAGS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Check for various functions.  We must include pthread.h,
+        # since some functions may be macros.  (On the Sequent, we
+        # need a special flag -Kthread to make this header compile.)
+        # We check for pthread_join because it is in -lpthread on IRIX
+        # while pthread_create is in libc.  We check for pthread_attr_init
+        # due to DEC craziness with -lpthreads.  We check for
+        # pthread_cleanup_push because it is one of the few pthread
+        # functions on Solaris that doesn't have a non-functional libc stub.
+        # We try pthread_create on general principles.
+        AC_TRY_LINK([#include <pthread.h>],
+                    [pthread_t th; pthread_join(th, 0);
+                     pthread_attr_init(0); pthread_cleanup_push(0, 0);
+                     pthread_create(0,0,0,0);
+                     pthread_cancel(0); pthread_cleanup_pop(0); ],
+                    [acx_pthread_ok=yes])
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        AC_MSG_RESULT($acx_pthread_ok)
+        if test "x$acx_pthread_ok" = xyes; then
+                break;
+        fi
+
+        PTHREAD_LIBS=""
+        PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+        save_LIBS="$LIBS"
+        LIBS="$PTHREAD_LIBS $LIBS"
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+        # Detect AIX lossage: threads are created detached by default
+        # and the JOINABLE attribute has a nonstandard name (UNDETACHED).
+        AC_MSG_CHECKING([for joinable pthread attribute])
+        AC_TRY_LINK([#include <pthread.h>],
+                    [int attr=PTHREAD_CREATE_JOINABLE;],
+                    ok=PTHREAD_CREATE_JOINABLE, ok=unknown)
+        if test x"$ok" = xunknown; then
+                AC_TRY_LINK([#include <pthread.h>],
+                            [int attr=PTHREAD_CREATE_UNDETACHED;],
+                            ok=PTHREAD_CREATE_UNDETACHED, ok=unknown)
+        fi
+        if test x"$ok" != xPTHREAD_CREATE_JOINABLE; then
+                AC_DEFINE(PTHREAD_CREATE_JOINABLE, $ok,
+                          [Define to the necessary symbol if this constant
+                           uses a non-standard name on your system.])
+        fi
+        AC_MSG_RESULT(${ok})
+        if test x"$ok" = xunknown; then
+                AC_MSG_WARN([we do not know how to create joinable pthreads])
+        fi
+
+        AC_MSG_CHECKING([if more special flags are required for pthreads])
+        flag=no
+        case "${host_cpu}-${host_os}" in
+                *-aix* | *-freebsd*)     flag="-D_THREAD_SAFE";;
+                *solaris* | alpha*-osf*) flag="-D_REENTRANT";;
+        esac
+        AC_MSG_RESULT(${flag})
+        if test "x$flag" != xno; then
+                PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+        fi
+
+        LIBS="$save_LIBS"
+        CFLAGS="$save_CFLAGS"
+
+        # More AIX lossage: must compile with cc_r
+        AC_CHECK_PROG(PTHREAD_CC, cc_r, cc_r, ${CC})
+else
+        PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+        :
+else
+        acx_pthread_ok=no
+        $2
+fi
+
+])

1.21.2.1.2.7 +2 -47     vorbis-tools/configure.in

Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/configure.in,v
retrieving revision 1.21.2.1.2.6
retrieving revision 1.21.2.1.2.7
diff -u -r1.21.2.1.2.6 -r1.21.2.1.2.7
--- configure.in	2001/12/17 14:06:08	1.21.2.1.2.6
+++ configure.in	2001/12/17 17:28:33	1.21.2.1.2.7
@@ -76,51 +76,6 @@
 LDFLAGS="$LDFLAGS $ldflags_save"
 
 dnl --------------------------------------------------
-dnl Check for pthreads (from Miod Vallat <miod at openbsd.org>)
-dnl --------------------------------------------------
- 
-AC_CACHE_CHECK(
-        [if compiler natively does POSIX threads],
-        ogg123_cv_gcc_pthread,
-        ac_save_CFLAGS=$CFLAGS
-        AC_LANG_SAVE
-        AC_LANG_C
-        AC_TRY_LINK([#include <pthread.h>],
-                [void *p = pthread_create;],
-                ogg123_cv_gcc_pthread=yes,
-                ogg123_cv_gcc_pthread=no
-        )
-        AC_LANG_RESTORE
-        CFLAGS=$ac_save_CFLAGS
-	
-        if test $ogg123_cv_gcc_pthread = no
-        then
-            CFLAGS="$CFLAGS -pthread"
-            AC_LANG_SAVE
-            AC_LANG_C
-            AC_TRY_LINK([#include <pthread.h>],
-                    [void *p = pthread_create;],
-                    ogg123_cv_gcc_pthread=flag,
-                    ogg123_cv_gcc_pthread=no
-            )
-            AC_LANG_RESTORE
-        fi
-)
-if test $ogg123_cv_gcc_pthread = yes
-then
-        THREAD_LIBS=""
-        THREAD_CFLAGS=""
-elif test $ogg123_cv_gcc_pthread = flag
-then
-        THREAD_LIBS=""
-        THREAD_CFLAGS="-pthread"
-else
-        dnl AC_CHECK_HEADERS(pthread.h) unreliable
-        AC_CHECK_LIB(pthread,pthread_create,THREAD_LIBS=-lpthread,
-             [AC_CHECK_LIB(c_r,pthread_create,THREAD_LIBS=-lc_r)])
-fi
-
-dnl --------------------------------------------------
 dnl Check for libraries
 dnl --------------------------------------------------
 
@@ -129,6 +84,8 @@
 AM_PATH_AO(,AC_MSG_ERROR(libao needed!))
 AM_PATH_CURL(,AC_MSG_ERROR(libcurl needed!))
 
+ACX_PTHREAD(,AC_MSG_ERROR(POSIX threads required!))
+
 SOCKET_LIBS=
 AC_CHECK_LIB(socket, socket, SOCKET_LIBS="-lsocket")
 AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="-lnsl $SOCKET_LIBS")
@@ -161,8 +118,6 @@
 
 AC_SUBST(DEBUG)
 AC_SUBST(PROFILE)
-AC_SUBST(THREAD_LIBS)
-AC_SUBST(THREAD_CFLAGS)
 AC_SUBST(SOCKET_LIBS)
 AC_SUBST(SHARE_CFLAGS)
 AC_SUBST(SHARE_LIBS)

No                   revision

No                   revision

1.14.2.4.2.8 +2 -2      vorbis-tools/ogg123/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Makefile.am,v
retrieving revision 1.14.2.4.2.7
retrieving revision 1.14.2.4.2.8
diff -u -r1.14.2.4.2.7 -r1.14.2.4.2.8
--- Makefile.am	2001/12/16 04:38:36	1.14.2.4.2.7
+++ Makefile.am	2001/12/17 17:28:33	1.14.2.4.2.8
@@ -9,10 +9,10 @@
 man_MANS = ogg123.1
 
 INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @AO_CFLAGS@ @CURL_CFLAGS@ \
-           @THREAD_CFLAGS@ @SHARE_CFLAGS@
+           @PTHREAD_CFLAGS@ @SHARE_CFLAGS@
 
 ogg123_LDADD = @VORBISFILE_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@ @AO_LIBS@ \
-               @SOCKET_LIBS@ @SHARE_LIBS@ @CURL_LIBS@ @THREAD_LIBS@
+               @SOCKET_LIBS@ @SHARE_LIBS@ @CURL_LIBS@ @PTHREAD_LIBS@
 ogg123_DEPENDENCIES = @SHARE_LIBS@
 ogg123_SOURCES = audio.c buffer.c callbacks.c \
                  cfgfile_options.c cmdline_options.c \

1.39.2.30.2.25 +4 -5      vorbis-tools/ogg123/ogg123.c

Index: ogg123.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.c,v
retrieving revision 1.39.2.30.2.24
retrieving revision 1.39.2.30.2.25
diff -u -r1.39.2.30.2.24 -r1.39.2.30.2.25
--- ogg123.c	2001/12/16 22:56:56	1.39.2.30.2.24
+++ ogg123.c	2001/12/17 17:28:34	1.39.2.30.2.25
@@ -14,7 +14,7 @@
  *                                                                  *
  ********************************************************************
 
- last mod: $Id: ogg123.c,v 1.39.2.30.2.24 2001/12/16 22:56:56 volsung Exp $
+ last mod: $Id: ogg123.c,v 1.39.2.30.2.25 2001/12/17 17:28:34 volsung Exp $
 
  ********************************************************************/
 
@@ -94,8 +94,10 @@
   switch (signo) {
   case SIGALRM:
     sig_request.ticks++;
-    if (sig_request.ticks < options.delay)
+    if (sig_request.ticks < options.delay) {
+      signal (SIGALRM, signal_handler);
       alarm(1);
+    }
     break;
 
   case SIGINT:
@@ -124,9 +126,6 @@
 
   case SIGCONT:
     break;  /* Don't need to do anything special to resume */
-
-  default:
-    psignal (signo, "Unknown signal caught");
   }
 }
 

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list