Date: Sun Jan 09 11:16:49 -0800 2005
Files: unix/tcl.m4 unix/tclUnixPort.h unix/tclConfig.h.in unix/tclUnixThrd.c
Bugid: 1095909

--- unix/tcl.m4.readdir.old	2005-01-04 08:32:22.000000000 -0800
+++ unix/tcl.m4	2005-01-04 08:29:59.000000000 -0800
@@ -514,43 +514,6 @@
 	    fi
 	fi
 	LIBS=$ac_saved_libs
-	AC_CHECK_FUNCS(readdir_r)
-	if test "x$ac_cv_func_readdir_r" = "xyes"; then
-            AC_MSG_CHECKING([how many args readdir_r takes])
-	    # IRIX 5.3 has a 2 arg version of readdir_r
-	    # while other systems have a 3 arg version.
-	    AC_CACHE_VAL(tcl_cv_two_arg_readdir_r,
-	        AC_TRY_COMPILE([#include <stdlib.h>
-#include <sys/types.h>
-#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>
-#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])
-	        AC_DEFINE(HAVE_TWO_ARG_READDIR_R)
-	    elif test "x$tcl_cv_three_arg_readdir_r" = "xyes" ; then
-                AC_MSG_RESULT([3])
-	        AC_DEFINE(HAVE_THREE_ARG_READDIR_R)
-	    else
-	        AC_MSG_ERROR([unknown number of args for readdir_r])
-	    fi
-	fi
     else
 	TCL_THREADS=0
 	AC_MSG_RESULT([no (default)])
--- unix/tclUnixPort.h.readdir.old	2004-11-13 04:29:46.000000000 -0800
+++ unix/tclUnixPort.h	2005-01-04 12:30:46.000000000 -0800
@@ -56,11 +56,9 @@
 #ifdef HAVE_STRUCT_DIRENT64
 typedef struct dirent64	Tcl_DirEntry;
 #   define TclOSreaddir		readdir64
-#   define TclOSreaddir_r	readdir64_r
 #else
 typedef struct dirent	Tcl_DirEntry;
 #   define TclOSreaddir		readdir
-#   define TclOSreaddir_r	readdir_r
 #endif
 
 #ifdef HAVE_TYPE_OFF64_T
@@ -558,17 +556,13 @@
 EXTERN void	TclpMutexInit _ANSI_ARGS_((TclpMutex *mPtr));
 EXTERN void	TclpMutexLock _ANSI_ARGS_((TclpMutex *mPtr));
 EXTERN void	TclpMutexUnlock _ANSI_ARGS_((TclpMutex *mPtr));
-EXTERN Tcl_DirEntry * 	TclpReaddir(DIR *);
 EXTERN struct tm *     	TclpLocaltime(CONST time_t *);
 EXTERN struct tm *     	TclpGmtime(CONST time_t *);
 EXTERN char *          	TclpInetNtoa(struct in_addr);
-#   define readdir(x)	TclpReaddir(x)
 /* #define localtime(x)	TclpLocaltime(x)
  * #define gmtime(x)	TclpGmtime(x)    */
 #   undef inet_ntoa
 #   define inet_ntoa(x)	TclpInetNtoa(x)
-#   undef TclOSreaddir
-#   define TclOSreaddir(x) TclpReaddir(x)
 #   ifdef MAC_OSX_TCL
 /* 
  * On Mac OS X, realpath is currently not
--- unix/tclConfig.h.in.readdir.old	2004-11-24 13:05:11.000000000 -0800
+++ unix/tclConfig.h.in	2005-01-04 08:34:05.000000000 -0800
@@ -63,9 +63,6 @@
 /* Does putenv() copy strings or incorporate them by reference? */
 #undef HAVE_PUTENV_THAT_COPIES
 
-/* Define to 1 if you have the `readdir_r' function. */
-#undef HAVE_READDIR_R
-
 /* Are characters signed? */
 #undef HAVE_SIGNED_CHAR
 
--- unix/tclUnixThrd.c.readdir.old	2004-11-24 13:05:12.000000000 -0800
+++ unix/tclUnixThrd.c	2005-01-09 11:16:46.052938278 -0800
@@ -20,10 +20,6 @@
 
 typedef struct ThreadSpecificData {
     char	    	nabuf[16];
-    struct {
-	Tcl_DirEntry ent;
-	char name[MAXNAMLEN+1];
-    } rdbuf;
 } ThreadSpecificData;
 
 static Tcl_ThreadDataKey dataKey;
@@ -867,56 +863,18 @@
  * Side effects:
  *	See documentation of C functions.
  *
+ * Notes:
+ * 	TclpReaddir is no longer used by the core (see 1095909),
+ * 	but it appears in the internal stubs table (see #589526).
  *----------------------------------------------------------------------
  */
 
-#if defined(TCL_THREADS) && !defined(HAVE_READDIR_R)
-TCL_DECLARE_MUTEX( rdMutex )
-#undef readdir
-#endif
-
 Tcl_DirEntry *
 TclpReaddir(DIR * dir)
 {
-    Tcl_DirEntry *ent;
-#ifdef TCL_THREADS
-    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
-
-#ifdef HAVE_READDIR_R
-    ent = &tsdPtr->rdbuf.ent;
-# ifdef HAVE_TWO_ARG_READDIR_R
-    if (TclOSreaddir_r(dir, ent) != 0) {
-# else /* HAVE_THREE_ARG_READDIR_R */
-    if (TclOSreaddir_r(dir, ent, &ent) != 0) {
-# endif /* HAVE_TWO_ARG_READDIR_R */
-	ent = NULL;
-    }
-
-#else /* !HAVE_READDIR_R */
-
-    Tcl_MutexLock(&rdMutex);
-#   ifdef HAVE_STRUCT_DIRENT64
-    ent = readdir64(dir);
-#   else /* !HAVE_STRUCT_DIRENT64 */
-    ent = readdir(dir);
-#   endif /* HAVE_STRUCT_DIRENT64 */
-    if (ent != NULL) {
-	memcpy((VOID *) &tsdPtr->rdbuf.ent, (VOID *) ent,
-		sizeof(tsdPtr->rdbuf));
-	ent = &tsdPtr->rdbuf.ent;
-    }
-    Tcl_MutexUnlock(&rdMutex);
-
-#endif /* HAVE_READDIR_R */
-#else
-#   ifdef HAVE_STRUCT_DIRENT64
-    ent = readdir64(dir);
-#   else /* !HAVE_STRUCT_DIRENT64 */
-    ent = readdir(dir);
-#   endif /* HAVE_STRUCT_DIRENT64 */
-#endif
-    return ent;
+    return TclOSreaddir(dir);
 }
+
 char *
 TclpInetNtoa(struct in_addr addr)
 {
