Index: unix/configure
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/configure,v
retrieving revision 1.129
diff -u -r1.129 configure
--- unix/configure	24 Nov 2004 20:12:18 -0000	1.129
+++ unix/configure	25 Nov 2004 00:30:42 -0000
@@ -4218,6 +4218,13 @@
 #define _REENTRANT 1
 _ACEOF
 
+	if test "`uname -s`" = "SunOS" ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define _POSIX_PTHREAD_SEMANTICS 1
+_ACEOF
+
+	fi
 
 cat >>confdefs.h <<\_ACEOF
 #define _THREAD_SAFE 1
@@ -4982,7 +4989,13 @@
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/dir.h>
+#ifdef NO_DIRENT_H
+# include <sys/dir.h>  /* logic from tcl/compat/dirent.h *
+# define dirent direct  *                                */
+#else
+# include <dirent.h>
+#endif
+
 int
 main ()
 {
@@ -5025,7 +5038,13 @@
 /* end confdefs.h.  */
 #include <stdlib.h>
 #include <sys/types.h>
-#include <sys/dir.h>
+#ifdef NO_DIRENT_H
+# include <sys/dir.h>  /* logic from tcl/compat/dirent.h *
+# define dirent direct  *                                */
+#else
+# include <dirent.h>
+#endif
+
 int
 main ()
 {
Index: unix/tcl.m4
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tcl.m4,v
retrieving revision 1.129
diff -u -r1.129 tcl.m4
--- unix/tcl.m4	24 Nov 2004 20:12:19 -0000	1.129
+++ unix/tcl.m4	25 Nov 2004 00:30:42 -0000
@@ -438,6 +438,10 @@
 	AC_DEFINE(USE_THREAD_STORAGE, 1,
 	    [Use the generic thread storage subsystem?])
 	AC_DEFINE(_REENTRANT, 1, [Do we want the reentrant OS API?])
+	if test "`uname -s`" = "SunOS" ; then
+	    AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1,
+		    [Do we really want to follow the standard? Yes we do!])
+	fi
 	AC_DEFINE(_THREAD_SAFE, 1, [Do we want the thread-safe OS API?])
 	AC_CHECK_LIB(pthread,pthread_mutex_init,tcl_ok=yes,tcl_ok=no)
 	if test "$tcl_ok" = "no"; then
@@ -518,12 +522,24 @@
 	    AC_CACHE_VAL(tcl_cv_two_arg_readdir_r,
 	        AC_TRY_COMPILE([#include <stdlib.h>
 #include <sys/types.h>
-#include <sys/dir.h>], [readdir_r(NULL, NULL);],
+#ifdef NO_DIRENT_H
+# include <sys/dir.h>  /* logic from tcl/compat/dirent.h *
+# define dirent direct  *                                */
+#else
+# include <dirent.h>
+#endif
+], [readdir_r(NULL, NULL);],
 	        tcl_cv_two_arg_readdir_r=yes, tcl_cv_two_arg_readdir_r=no))
 	    AC_CACHE_VAL(tcl_cv_three_arg_readdir_r,
 	        AC_TRY_COMPILE([#include <stdlib.h>
 #include <sys/types.h>
-#include <sys/dir.h>], [readdir_r(NULL, NULL, NULL);],
+#ifdef NO_DIRENT_H
+# include <sys/dir.h>  /* logic from tcl/compat/dirent.h *
+# define dirent direct  *                                */
+#else
+# include <dirent.h>
+#endif
+], [readdir_r(NULL, NULL, NULL);],
 	        tcl_cv_three_arg_readdir_r=yes, tcl_cv_three_arg_readdir_r=no))
 	    if test "x$tcl_cv_two_arg_readdir_r" = "xyes" ; then
                 AC_MSG_RESULT([2])
