threadstubs2.patch????????¹u`¹ugCmBINPÞIndex: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.1201
diff -u -r1.1201 ChangeLog
--- ChangeLog	5 Aug 2002 22:36:00 -0000	1.1201
+++ ChangeLog	6 Aug 2002 01:45:06 -0000
@@ -1,3 +1,15 @@
+2002-08-06  Daniel Steffen  <das@users.sourceforge.net>
+
+	* generic/tclInt.decls:
+	* unix/tclUnixThrd.c: Added stubs and implementations for
+	non-threaded build for the tclUnixThrd.c procs TclpReaddir,
+	TclpLocaltime, TclpGmtime and TclpInetNtoa.
+	Fixes link errors in stubbed & threaded extensions that include
+	tclUnixPort.h and use any of the procs readdir, localtime, 
+	gmtime or inet_ntoa (e.g. TclX 8.4) [Bug 589526]
+	* generic/tclIntPlatDecls.h:
+	* generic/tclStubInit.c: Regen.
+
 2002-08-05  Don Porter  <dgp@users.sourceforge.net>
 
 	* library/tcltest/tcltest.tcl:	The setup and cleanup scripts are now
Index: generic/tclInt.decls
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.decls,v
retrieving revision 1.54
diff -u -r1.54 tclInt.decls
--- generic/tclInt.decls	5 Aug 2002 03:24:40 -0000	1.54
+++ generic/tclInt.decls	6 Aug 2002 01:45:06 -0000
@@ -954,3 +954,21 @@
     TclFile TclpCreateTempFile(CONST char *contents)
 }
 
+# Added in 8.4:
+
+declare 10 unix {
+    Tcl_DirEntry * TclpReaddir(DIR * dir)
+}
+
+declare 11 unix {
+    struct tm * TclpLocaltime(time_t * clock)
+}
+
+declare 12 unix {
+    struct tm * TclpGmtime(time_t * clock)
+}
+
+declare 13 unix {
+    char * TclpInetNtoa(struct in_addr addr)
+}
+
Index: generic/tclIntPlatDecls.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclIntPlatDecls.h,v
retrieving revision 1.17
diff -u -r1.17 tclIntPlatDecls.h
--- generic/tclIntPlatDecls.h	19 Apr 2002 14:18:38 -0000	1.17
+++ generic/tclIntPlatDecls.h	6 Aug 2002 01:45:06 -0000
@@ -59,6 +59,14 @@
 /* 9 */
 EXTERN TclFile		TclpCreateTempFile _ANSI_ARGS_((
 				CONST char * contents));
+/* 10 */
+EXTERN Tcl_DirEntry *	TclpReaddir _ANSI_ARGS_((DIR * dir));
+/* 11 */
+EXTERN struct tm *	TclpLocaltime _ANSI_ARGS_((time_t * clock));
+/* 12 */
+EXTERN struct tm *	TclpGmtime _ANSI_ARGS_((time_t * clock));
+/* 13 */
+EXTERN char *		TclpInetNtoa _ANSI_ARGS_((struct in_addr addr));
 #endif /* UNIX */
 #ifdef __WIN32__
 /* 0 */
@@ -218,6 +226,10 @@
     TclFile (*tclpOpenFile) _ANSI_ARGS_((CONST char * fname, int mode)); /* 7 */
     int (*tclUnixWaitForFile) _ANSI_ARGS_((int fd, int mask, int timeout)); /* 8 */
     TclFile (*tclpCreateTempFile) _ANSI_ARGS_((CONST char * contents)); /* 9 */
+    Tcl_DirEntry * (*tclpReaddir) _ANSI_ARGS_((DIR * dir)); /* 10 */
+    struct tm * (*tclpLocaltime) _ANSI_ARGS_((time_t * clock)); /* 11 */
+    struct tm * (*tclpGmtime) _ANSI_ARGS_((time_t * clock)); /* 12 */
+    char * (*tclpInetNtoa) _ANSI_ARGS_((struct in_addr addr)); /* 13 */
 #endif /* UNIX */
 #ifdef __WIN32__
     void (*tclWinConvertError) _ANSI_ARGS_((DWORD errCode)); /* 0 */
@@ -331,6 +343,22 @@
 #ifndef TclpCreateTempFile
 #define TclpCreateTempFile \
 	(tclIntPlatStubsPtr->tclpCreateTempFile) /* 9 */
+#endif
+#ifndef TclpReaddir
+#define TclpReaddir \
+	(tclIntPlatStubsPtr->tclpReaddir) /* 10 */
+#endif
+#ifndef TclpLocaltime
+#define TclpLocaltime \
+	(tclIntPlatStubsPtr->tclpLocaltime) /* 11 */
+#endif
+#ifndef TclpGmtime
+#define TclpGmtime \
+	(tclIntPlatStubsPtr->tclpGmtime) /* 12 */
+#endif
+#ifndef TclpInetNtoa
+#define TclpInetNtoa \
+	(tclIntPlatStubsPtr->tclpInetNtoa) /* 13 */
 #endif
 #endif /* UNIX */
 #ifdef __WIN32__
Index: generic/tclStubInit.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclStubInit.c,v
retrieving revision 1.73
diff -u -r1.73 tclStubInit.c
--- generic/tclStubInit.c	17 Jul 2002 18:21:55 -0000	1.73
+++ generic/tclStubInit.c	6 Aug 2002 01:45:06 -0000
@@ -267,6 +267,10 @@
     TclpOpenFile, /* 7 */
     TclUnixWaitForFile, /* 8 */
     TclpCreateTempFile, /* 9 */
+    TclpReaddir, /* 10 */
+    TclpLocaltime, /* 11 */
+    TclpGmtime, /* 12 */
+    TclpInetNtoa, /* 13 */
 #endif /* UNIX */
 #ifdef __WIN32__
     TclWinConvertError, /* 0 */
Index: unix/tclUnixThrd.c
===================================================================
RCS file: /cvsroot/tcl/tcl/unix/tclUnixThrd.c,v
retrieving revision 1.20
diff -u -r1.20 tclUnixThrd.c
--- unix/tclUnixThrd.c	28 Jun 2002 09:56:54 -0000	1.20
+++ unix/tclUnixThrd.c	6 Aug 2002 01:45:06 -0000
@@ -13,10 +13,10 @@
  */
 
 #include "tclInt.h"
+#include "tclPort.h"
 
 #ifdef TCL_THREADS
 
-#include "tclPort.h"
 #include "pthread.h"
 
 typedef struct ThreadSpecificData {
@@ -772,6 +772,7 @@
 	*condPtr = NULL;
     }
 }
+#endif /* TCL_THREADS */
 
 /*
  *----------------------------------------------------------------------
@@ -790,7 +791,7 @@
  *----------------------------------------------------------------------
  */
 
-#ifndef HAVE_READDIR_R
+#if defined(TCL_THREADS) && !defined(HAVE_READDIR_R)
 TCL_DECLARE_MUTEX( rdMutex )
 #undef readdir
 #endif
@@ -798,8 +799,9 @@
 Tcl_DirEntry *
 TclpReaddir(DIR * dir)
 {
-    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
     Tcl_DirEntry *ent;
+#ifdef TCL_THREADS
+    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
 
 #ifdef HAVE_READDIR_R
     ent = &tsdPtr->rdbuf.ent; 
@@ -823,10 +825,17 @@
     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;
 }
 
-#if !defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R)
+#if defined(TCL_THREADS) && (!defined(HAVE_GMTIME_R) || !defined(HAVE_LOCALTIME_R))
 TCL_DECLARE_MUTEX( tmMutex )
 #undef localtime
 #undef gmtime
@@ -835,6 +844,7 @@
 struct tm *
 TclpLocaltime(time_t * clock)
 {
+#ifdef TCL_THREADS
     ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
 
 #ifdef HAVE_LOCALTIME_R
@@ -843,13 +853,17 @@
     Tcl_MutexLock( &tmMutex );
     memcpy( (VOID *) &tsdPtr->ltbuf, (VOID *) localtime( clock ), sizeof (struct tm) );
     Tcl_MutexUnlock( &tmMutex );
-	return &tsdPtr->ltbuf;
+    return &tsdPtr->ltbuf;
 #endif    
+#else
+    return localtime(clock);
+#endif
 }
 
 struct tm *
 TclpGmtime(time_t * clock)
 {
+#ifdef TCL_THREADS
     ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
 
 #ifdef HAVE_GMTIME_R
@@ -860,11 +874,15 @@
     Tcl_MutexUnlock( &tmMutex );
     return &tsdPtr->gtbuf;
 #endif    
+#else
+    return gmtime(clock);
+#endif
 }
 
 char *
 TclpInetNtoa(struct in_addr addr)
 {
+#ifdef TCL_THREADS
     ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
     union {
     	unsigned long l;
@@ -874,8 +892,12 @@
     u.l = (unsigned long) addr.s_addr;
     sprintf(tsdPtr->nabuf, "%u.%u.%u.%u", u.b[0], u.b[1], u.b[2], u.b[3]);
     return tsdPtr->nabuf;
+#else
+    return inet_ntoa(addr);
+#endif
 }
 
+#ifdef TCL_THREADS
 /*
  * Additions by AOL for specialized thread memory allocator.
  */
