Tcl Source Code

View Ticket
Login
Ticket UUID: 219024
Title: Thread support on DIgital-Unix (Tru64-Unix)
Type: Bug Created on: 2000-10-26 01:09:35
Submitter: nobody Assigned to: nobody
Subsystem: 49. Threading Severity:
Priority: 2 Last modified: 2000-10-26 08:33:10
Status: Closed Closed by: welch
Resolution: Fixed Closed on: 2000-10-26 01:33:10
Version: obsolete: 8.3b1
Description:
OriginalBugID: 4010 Bug
Version: 8.3b1
SubmitDate: '2000-01-12'
LastModified: '2000-01-25'
Severity: SER
Status: Released
Submitter: techsupp
ChangedBy: hobbs
RelatedBugIDs: 4063
OS: Digital Unix
OSVersion: 4.0F
Machine: Alpha Server
FixedDate: '2000-01-25'
FixedInVersion: 8.3b2
ClosedDate: '2000-10-25'


Name: kazuro furukawa

Comments:
These patches are essentially the same as the one I submitted last april for 8.1b3.

ReproducibleScript:
./configure --enable-threads
make test

ObservedBehavior:
Configuration and compilation fails if the thread support is enabled.

DesiredBehavior:
Successful test results.

Patch:
*** tcl.m4.org  Thu Dec 23 08:05:20 1999
--- tcl.m4      Tue Jan 11 19:38:11 2000
***************
*** 362,386 ****
        AC_DEFINE(_REENTRANT)
        AC_DEFINE(_THREAD_SAFE)

!       AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
!       if test "$tcl_ok" = "yes"; then
!           # The space is needed
!           THREADS_LIBS=" -lpthread"
        else
!           AC_CHECK_LIB(pthreads,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
            if test "$tcl_ok" = "yes"; then
                # The space is needed
!               THREADS_LIBS=" -lpthreads"
            else
!               AC_CHECK_LIB(c,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
!               if test "$tcl_ok" = "no"; then
!                   TCL_THREADS=0
!                   AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
!               fi
            fi
        fi
      else
        TCL_THREADS=0
        AC_MSG_RESULT(no (default))
      fi
  ])
--- 362,394 ----
        AC_DEFINE(_REENTRANT)
        AC_DEFINE(_THREAD_SAFE)

!       # "&& test" cannot be replaced with "-a"
!       if test -f /usr/bin/uname && test "`/usr/bin/uname -s`" = "OSF1" ; then
!           # if compaq tru64, process later in SC_CONFIG_CFLAGS
!           # since it needs cflags modification
!           dothread=yes
        else
!           AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
            if test "$tcl_ok" = "yes"; then
                # The space is needed
!               THREADS_LIBS=" -lpthread"
            else
!               AC_CHECK_LIB(pthreads,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
!               if test "$tcl_ok" = "yes"; then
!                   # The space is needed
!                   THREADS_LIBS=" -lpthreads"
!               else
!                   AC_CHECK_LIB(c,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
!                   if test "$tcl_ok" = "no"; then
!                       TCL_THREADS=0
!                       AC_MSG_WARN("Don t know how to find pthread lib on your system - you must disable thread support or edit the LIBS in the Makefile...")
!                   fi
!               fi
            fi
        fi
      else
        TCL_THREADS=0
+       dothread=no
        AC_MSG_RESULT(no (default))
      fi
  ])
***************
*** 840,845 ****
--- 848,870 ----
            DL_LIBS=""
            LDFLAGS=""
            LD_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
+           if test "$dothread" = "yes" ; then
+               # see pthread_intro(3) for pthread support on osf1, k.furukawa
+               if test "$CC" != "gcc" -a `$CC -v 2>&1 | grep -c gcc` = "0" ; then
+                   # pthread with cc
+                   EXTRA_CFLAGS="-std1 -pthread"
+                   LDFLAGS="-pthread"
+               else
+                   # pthread with gcc
+                   EXTRA_CFLAGS="-D_THREAD_SAFE"
+                   LIBS='${LIBS} -lpthread -lmach -lexc -lc'
+               fi
+           else
+               if test "$CC" != "gcc" -a `$CC -v 2>&1 | grep -c gcc` = "0" ; then
+                   # full ansi with cc
+                   EXTRA_CFLAGS="-std1"
+               fi
+           fi
            ;;
        RISCos-*)
            SHLIB_CFLAGS="-G 0"

*** tclUnixThrd.c.org   Wed Aug 11 02:17:27 1999
--- tclUnixThrd.c       Tue Jan 11 15:47:52 2000
***************
*** 84,89 ****
--- 84,102 ----

      pthread_attr_init(&attr);
      pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
+ 
+ #ifdef __osf__
+     /*
+      * on alpha/tru64unix we need a larger stack to execute "regexp", 
+      * which may consume 30k bytes, while the default per thread is 8k. 
+      * even "unknown" procedure may seg-faults, since it uses "regexp". 
+      * i don't know how much is optimal. simple test for the stack is
+      * "testthread send [testthread create] {regexp t t}" and more 
+      * serious test seems to be http.test.  k.furukawa
+      */
+     pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN*32);
+ #endif /* __osf__ */
+ 
      if (pthread_create((pthread_t *)idPtr, &attr,
            (void * (*)())proc, (void *)clientData) &&
            pthread_create((pthread_t *)idPtr, NULL,

*** tclThreadTest.c.org Wed Dec 22 08:58:04 1999
--- tclThreadTest.c     Tue Jan 11 15:41:33 2000
***************
*** 493,499 ****
      Tcl_Channel errChannel;
      char *errorInfo, *script;
      char *argv[3];
!     char buf[10];
      sprintf(buf, "%ld", (long) Tcl_GetCurrentThread());

      errorInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);
--- 493,499 ----
      Tcl_Channel errChannel;
      char *errorInfo, *script;
      char *argv[3];
!     char buf[TCL_INTEGER_SPACE];
      sprintf(buf, "%ld", (long) Tcl_GetCurrentThread());

      errorInfo = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY);

PatchFiles:
tcl.m4
    tclUnixThrd.c
    tclThreadTest.c



A variation of these were made for 8.3b2.  4063 has slight mods to it
that are in 8.3.0. 
-- 01/25/2000 hobbs