Basic integrate of lastest perl into ansiperl
Nick Ing-Simmons [Fri, 21 Nov 1997 00:54:43 +0000 (00:54 +0000)]
p4raw-id: //depot/ansiperl@272

23 files changed:
global.sym
miniperlmain.c
perl.c
perl.h
pp_ctl.c
sv.c
t/lib/thread.t [changed mode: 0755->0644]
t/op/nothread.t [changed mode: 0755->0644]
toke.c
win32/Makefile
win32/config.bc
win32/config.vc
win32/config_H.bc
win32/config_H.vc
win32/makedef.pl
win32/makefile.mk
win32/perllib.c
win32/win32.c
win32/win32.h
win32/win32iop.h
win32/win32sck.c
win32/win32thread.c
win32/win32thread.h

index b720369..e422fba 100644 (file)
@@ -974,6 +974,7 @@ pp_tied
 pp_time
 pp_tms
 pp_trans
+pp_threadsv
 pp_truncate
 pp_uc
 pp_ucfirst
index 27ad541..81e6493 100644 (file)
@@ -25,6 +25,10 @@ char **env;
 {
     int exitstatus;
 
+#ifdef USE_THREADS
+    MUTEX_INIT(&malloc_mutex); 
+#endif
+
     PERL_SYS_INIT(&argc,&argv);
 
     perl_init_i18nl10n(1);
diff --git a/perl.c b/perl.c
index 6f3e15c..db5821c 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1686,6 +1686,9 @@ GNU General Public License, which may be found in the Perl 5.0 source kit.\n\n")
        break;
     case '-':
     case 0:
+#ifdef WIN32
+    case '\r':
+#endif
     case '\n':
     case '\t':
        break;
@@ -1987,7 +1990,7 @@ SV *sv;
     if (strEQ(origfilename,"-"))
        scriptname = "";
     if (fdscript >= 0) {
-       rsfp = PerlIO_fdopen(fdscript,"r");
+       rsfp = PerlIO_fdopen(fdscript,PERL_SCRIPT_MODE);
 #if defined(HAS_FCNTL) && defined(F_SETFD)
        if (rsfp)
            fcntl(PerlIO_fileno(rsfp),F_SETFD,1);  /* ensure close-on-exec */
@@ -2071,7 +2074,7 @@ sed %s -e \"/^[^#]/b\" \
        rsfp = PerlIO_stdin();
     }
     else {
-       rsfp = PerlIO_open(scriptname,"r");
+       rsfp = PerlIO_open(scriptname,PERL_SCRIPT_MODE);
 #if defined(HAS_FCNTL) && defined(F_SETFD)
        if (rsfp)
            fcntl(PerlIO_fileno(rsfp),F_SETFD,1);  /* ensure close-on-exec */
diff --git a/perl.h b/perl.h
index 9facb91..4cbc677 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -2293,6 +2293,10 @@ EXT bool numeric_local INIT(TRUE);    /* Assume local numerics */
 #define printf PerlIO_stdoutf
 #endif
 
+#ifndef PERL_SCRIPT_MODE
+#define PERL_SCRIPT_MODE "r"
+#endif
+
 /*
  * nice_chunk and nice_chunk size need to be set
  * and queried under the protection of sv_mutex
index 8691cfa..dadc145 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2368,7 +2368,7 @@ PP(pp_require)
     )
     {
        tryname = name;
-       tryrsfp = PerlIO_open(name,"r");
+       tryrsfp = PerlIO_open(name,PERL_SCRIPT_MODE);
     }
     else {
        AV *ar = GvAVn(incgv);
@@ -2391,7 +2391,7 @@ PP(pp_require)
                sv_setpvf(namesv, "%s/%s", dir, name);
 #endif
                tryname = SvPVX(namesv);
-               tryrsfp = PerlIO_open(tryname, "r");
+               tryrsfp = PerlIO_open(tryname, PERL_SCRIPT_MODE);
                if (tryrsfp) {
                    if (tryname[0] == '.' && tryname[1] == '/')
                        tryname += 2;
diff --git a/sv.c b/sv.c
index 408cc77..9a7f075 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3219,6 +3219,10 @@ screamer2:
        }
     }
 
+#ifdef WIN32
+    win32_strip_return(sv);
+#endif
+
     return (SvCUR(sv) - append) ? SvPVX(sv) : Nullch;
 }
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/toke.c b/toke.c
index 00825b2..f643732 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -187,7 +187,7 @@ missingterm(char *s)
     char q;
     if (s) {
        char *nl = strrchr(s,'\n');
-       if (nl)
+       if (nl) 
            *nl = '\0';
     }
     else if (multi_close < 32 || multi_close == 127) {
@@ -219,6 +219,19 @@ depcom(void)
     deprecate("comma-less variable list");
 }
 
+#ifdef WIN32
+
+static I32
+win32_textfilter(int idx, SV *sv, int maxlen)
+{
+ I32 count = FILTER_READ(idx+1, sv, maxlen);
+ if (count > 0 && !maxlen)
+  win32_strip_return(sv);
+ return count;
+}
+#endif
+
+
 void
 lex_start(SV *line)
 {
@@ -1159,6 +1172,7 @@ filter_read(int idx, SV *buf_sv, int maxlen)
                else
                    return 0 ;          /* end of file */
            }
+
        }
        return SvCUR(buf_sv);
     }
@@ -1179,9 +1193,15 @@ filter_read(int idx, SV *buf_sv, int maxlen)
     return (*funcp)(idx, buf_sv, maxlen);
 }
 
+
 static char *
 filter_gets(register SV *sv, register FILE *fp, STRLEN append)
 {
+#ifdef WIN32FILTER
+    if (!rsfp_filters) {
+       filter_add(win32_textfilter,NULL);
+    }
+#endif
     if (rsfp_filters) {
 
        if (!append)
@@ -1193,7 +1213,6 @@ filter_gets(register SV *sv, register FILE *fp, STRLEN append)
     }
     else 
         return (sv_gets(sv, fp, append));
-    
 }
 
 
@@ -1724,9 +1743,11 @@ yylex(void)
        }
        goto retry;
     case '\r':
+#ifndef WIN32CHEAT
        warn("Illegal character \\%03o (carriage return)", '\r');
        croak(
       "(Maybe you didn't strip carriage returns after a network transfer?)\n");
+#endif
     case ' ': case '\t': case '\f': case 013:
        s++;
        goto retry;
index d2e4641..8993691 100644 (file)
@@ -20,7 +20,7 @@ CORECCOPT=
 
 #
 # uncomment next line if you want debug version of perl (big,slow)
-#CFG=Debug
+CFG=Debug
 
 #
 # set the install locations of the compiler include/libraries
@@ -166,7 +166,8 @@ CORE_C=     ..\av.c         \
        ..\taint.c      \
        ..\toke.c       \
        ..\universal.c  \
-       ..\util.c
+       ..\util.c       \
+       ..\malloc.c
 
 CORE_OBJ= ..\av.obj    \
        ..\deb.obj      \
@@ -193,7 +194,8 @@ CORE_OBJ= ..\av.obj \
        ..\taint.obj    \
        ..\toke.obj     \
        ..\universal.obj\
-       ..\util.obj
+       ..\util.obj     \
+       ..\malloc.obj      
 
 WIN32_C = perllib.c \
        win32.c \
@@ -335,7 +337,7 @@ $(WIN32_OBJ) : $(CORE_H)
 $(CORE_OBJ)  : $(CORE_H)
 $(DLL_OBJ)   : $(CORE_H) 
 
-perldll.def : $(MINIPERL) $(CONFIGPM)
+perldll.def : $(MINIPERL) $(CONFIGPM) makedef.pl
        $(MINIPERL) -w makedef.pl $(DEFINES) $(CCTYPE) > perldll.def
 
 $(PERLDLL): perldll.def $(CORE_OBJ) $(WIN32_OBJ) $(DLL_OBJ)
index e3559a0..7554ae5 100644 (file)
@@ -162,7 +162,7 @@ d_msgctl='define'
 d_msgget='define'
 d_msgrcv='define'
 d_msgsnd='define'
-d_mymalloc='undef'
+d_mymalloc='define'
 d_nice='undef'
 d_oldarchlib='undef'
 d_oldsock='undef'
index c117689..4e12767 100644 (file)
@@ -162,7 +162,7 @@ d_msgctl='define'
 d_msgget='define'
 d_msgrcv='define'
 d_msgsnd='define'
-d_mymalloc='undef'
+d_mymalloc='define'
 d_nice='undef'
 d_oldarchlib='undef'
 d_oldsock='undef'
index 3ba2481..ad7bcaf 100644 (file)
 /* MYMALLOC:
  *     This symbol, if defined, indicates that we're using our own malloc.
  */
-/*#define MYMALLOC                     /**/
+#define MYMALLOC                       /**/
 
 /* OLDARCHLIB:
  *     This variable, if defined, holds the name of the directory in
index d2c6d47..12321b2 100644 (file)
 /* MYMALLOC:
  *     This symbol, if defined, indicates that we're using our own malloc.
  */
-/*#define MYMALLOC                     /**/
+#define MYMALLOC                       /**/
 
 /* OLDARCHLIB:
  *     This variable, if defined, holds the name of the directory in
index abc89d8..55b3e29 100644 (file)
@@ -20,10 +20,23 @@ while (@ARGV && $ARGV[0] =~ /^-/)
   $define{$1} = 1 if ($flag =~ /^-D(\w+)$/);
  } 
 
+open(CFG,'config.h') || die "Cannot open config.h:$!";
+while (<CFG>)
+ {
+  $define{$1} = 1 if /^\s*#\s*define\s+(MYMALLOC)\b/;
+ }
+close(CFG);
+
 warn join(' ',keys %define)."\n";
 
 my $CCTYPE = shift || "MSVC";
 
+print "LIBRARY Perl\n";
+print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
+print "CODE LOADONCALL\n";
+print "DATA LOADONCALL NONSHARED MULTIPLE\n";
+print "EXPORTS\n";
+
 $skip_sym=<<'!END!OF!SKIP!';
 Perl_block_type
 Perl_additem
@@ -143,6 +156,20 @@ Perl_cshname
 Perl_opsave
 !END!OF!SKIP!
 
+if ($define{'MYMALLOC'})
+ {
+  $skip_sym .= <<'!END!OF!SKIP!';
+Perl_safefree
+Perl_safemalloc
+Perl_saferealloc
+Perl_safecalloc
+!END!OF!SKIP!
+  emit_symbol('Perl_malloc');
+  emit_symbol('Perl_free');
+  emit_symbol('Perl_realloc');
+  emit_symbol('Perl_calloc');
+ }
+
 unless ($define{'USE_THREADS'})
  {
   $skip_sym .= <<'!END!OF!SKIP!';
@@ -193,12 +220,6 @@ unless ($define{'USE_THREADS'})
 # sticks in front of them.
 
 
-print "LIBRARY Perl\n";
-print "DESCRIPTION 'Perl interpreter, export autogenerated'\n";
-print "CODE LOADONCALL\n";
-print "DATA LOADONCALL NONSHARED MULTIPLE\n";
-print "EXPORTS\n";
-
 open (GLOBAL, "<../global.sym") || die "failed to open global.sym" . $!;
 while (<GLOBAL>) {
        my $symbol;
@@ -232,6 +253,7 @@ while (<DATA>) {
        my $symbol;
        next if (!/^[A-Za-z]/);
        next if (/^#/);
+        s/\r//g;
        $symbol = $_;
        next if ($skip_sym =~ m/^$symbol/m);
         $symbol = "Perl_".$symbol if ($define{'USE_THISPTR'} 
@@ -402,4 +424,6 @@ win32_open_osfhandle
 win32_get_osfhandle
 Perl_win32_init
 Perl_init_os_extras
+Perl_getTHR
+Perl_setTHR
 RunPerl
index 2b7dc8c..03788c7 100644 (file)
@@ -234,7 +234,8 @@ CORE_C=     ..\av.c         \
        ..\taint.c      \
        ..\toke.c       \
        ..\universal.c  \
-       ..\util.c
+       ..\util.c       \
+       ..\malloc.c
 
 CORE_OBJ= ..\av.obj    \
        ..\deb.obj      \
@@ -261,7 +262,8 @@ CORE_OBJ= ..\av.obj \
        ..\taint.obj    \
        ..\toke.obj     \
        ..\universal.obj\
-       ..\util.obj
+       ..\util.obj     \
+       ..\malloc.obj
 
 WIN32_C = perllib.c \
        win32.c \
index 8483606..c24941f 100644 (file)
@@ -15,6 +15,10 @@ RunPerl(int argc, char **argv, char **env, void *iosubsystem)
     int exitstatus;
     PerlInterpreter *my_perl;
 
+#ifdef USE_THREADS
+    MUTEX_INIT(&malloc_mutex); 
+#endif
+
     PERL_SYS_INIT(&argc,&argv);
 
     perl_init_i18nl10n(1);
index 4551679..28454e8 100644 (file)
@@ -1303,6 +1303,85 @@ win32_putchar(int c)
     return putchar(c);
 }
 
+#ifdef MYMALLOC
+
+#ifndef USE_PERL_SBRK
+
+static char *committed = NULL;
+static char *base      = NULL;
+static char *reserved  = NULL;
+static char *brk       = NULL;
+static DWORD pagesize  = 0;
+static DWORD allocsize = 0;
+
+void *
+sbrk(int need)
+{
+ void *result;
+ if (!pagesize)
+  {SYSTEM_INFO info;
+   GetSystemInfo(&info);
+   /* Pretend page size is larger so we don't perpetually
+    * call the OS to commit just one page ...
+    */
+   pagesize = info.dwPageSize << 3;
+   allocsize = info.dwAllocationGranularity;
+  }
+ /* This scheme fails eventually if request for contiguous
+  * block is denied so reserve big blocks - this is only 
+  * address space not memory ...
+  */
+ if (brk+need >= reserved)
+  {
+   DWORD size = 64*1024*1024;
+   char *addr;
+   if (committed && reserved && committed < reserved)
+    {
+     /* Commit last of previous chunk cannot span allocations */
+     addr = VirtualAlloc(committed,reserved-committed,MEM_COMMIT,PAGE_READWRITE);
+     if (addr)
+      committed = reserved;
+    }
+   /* Reserve some (more) space 
+    * Note this is a little sneaky, 1st call passes NULL as reserved
+    * so lets system choose where we start, subsequent calls pass
+    * the old end address so ask for a contiguous block
+    */
+   addr  = VirtualAlloc(reserved,size,MEM_RESERVE,PAGE_NOACCESS);
+   if (addr)
+    {
+     reserved = addr+size;
+     if (!base)
+      base = addr;
+     if (!committed)
+      committed = base;
+     if (!brk)
+      brk = committed;
+    }
+   else
+    {
+     return (void *) -1;
+    }
+  }
+ result = brk;
+ brk += need;
+ if (brk > committed)
+  {
+   DWORD size = ((brk-committed + pagesize -1)/pagesize) * pagesize;
+   char *addr = VirtualAlloc(committed,size,MEM_COMMIT,PAGE_READWRITE);
+   if (addr)
+    {
+     committed += size;
+    }
+   else
+    return (void *) -1;
+  }
+ return result;
+}
+
+#endif
+#endif
+
 DllExport void*
 win32_malloc(size_t size)
 {
@@ -1327,6 +1406,7 @@ win32_free(void *block)
     free(block);
 }
 
+
 int
 win32_open_osfhandle(long handle, int flags)
 {
@@ -1645,6 +1725,32 @@ Perl_win32_init(int *argcp, char ***argvp)
 #endif
 }
 
+#ifdef USE_BINMODE_SCRIPTS
+
+void
+win32_strip_return(SV *sv)
+{
+ char *s = SvPVX(sv);
+ char *e = s+SvCUR(sv);
+ char *d = s;
+ while (s < e)
+  {
+   if (*s == '\r' && s[1] == '\n')
+    {
+     *d++ = '\n';
+     s += 2;
+    }
+   else 
+    {
+     *d++ = *s++;
+    }   
+  }
+ SvCUR_set(sv,d-SvPVX(sv)); 
+}
+
+#endif
+
+
 
 
 
index 18bf8a2..9086f31 100644 (file)
@@ -145,4 +145,22 @@ typedef  char *            caddr_t;        /* In malloc.c (core address). */
 #include <sys/socket.h>
 #include <netdb.h>
 
+#ifdef MYMALLOC
+#define EMBEDMYMALLOC  /**/
+/* #define USE_PERL_SBRK       /**/
+/* #define PERL_SBRK_VIA_MALLOC        /**/
+#endif
+
+#ifdef PERLDLL
+#define PERL_CORE
+#endif
+
+#ifdef USE_BINMODE_SCRIPTS
+#define PERL_SCRIPT_MODE "rb"
+EXT void win32_strip_return(struct sv *sv);
+#else
+#define PERL_SCRIPT_MODE "r"
+#define win32_strip_return(sv) NOOP
+#endif
+
 #endif /* _INC_WIN32_PERL5 */
index a60194d..bd70def 100644 (file)
@@ -219,10 +219,17 @@ END_EXTERN_C
 #define puts                   win32_puts
 #define getchar                        win32_getchar
 #define putchar                        win32_putchar
+
+#if !defined(MYMALLOC) || !defined(PERLDLL)
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
 #define malloc                 win32_malloc
 #define calloc                 win32_calloc
 #define realloc                        win32_realloc
 #define free                   win32_free
+#endif
 
 #define pipe(fd)               win32_pipe((fd), 512, O_BINARY)
 #define pause()                        win32_sleep((32767L << 16) + 32767)
index 559691a..b4f40f0 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #define WIN32IO_IS_STDIO
-#define WIN32SCK_IS_STDSCK
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include "EXTERN.h"
 #include <assert.h>
 #include <io.h>
 
+#undef htonl
+#undef htons
+#undef ntohl
+#undef ntohs
+#undef inet_addr
+#undef inet_ntoa
+#undef socket
+#undef bind
+#undef listen
+#undef accept
+#undef connect
+#undef send
+#undef sendto
+#undef recv
+#undef recvfrom
+#undef shutdown
+#undef closesocket
+#undef ioctlsocket
+#undef setsockopt
+#undef getsockopt
+#undef getpeername
+#undef getsockname
+#undef gethostname
+#undef gethostbyname
+#undef gethostbyaddr
+#undef getprotobyname
+#undef getprotobynumber
+#undef getservbyname
+#undef getservbyport
+#undef select
+#undef endhostent
+#undef endnetent
+#undef endprotoent
+#undef endservent
+#undef getnetent
+#undef getnetbyname
+#undef getnetbyaddr
+#undef getprotoent
+#undef getservent
+#undef sethostent
+#undef setnetent
+#undef setprotoent
+#undef setservent
+
 /* thanks to Beverly Brown     (beverly@datacube.com) */
 #ifdef USE_SOCKETS_AS_HANDLES
 #      define OPEN_SOCKET(x)   _open_osfhandle(x,O_RDWR|O_BINARY)
@@ -249,15 +292,13 @@ win32_recvfrom(SOCKET s, char *buf, int len, int flags, struct sockaddr *from, i
 
 /* select contributed by Vincent R. Slyngstad (vrs@ibeam.intel.com) */
 int
-win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const struct timeval* timeout)
+win32_select(int nfds, int* rd, int* wr, int* ex, const struct timeval* timeout)
 {
-    int r;
-#ifdef USE_SOCKETS_AS_HANDLES
-    Perl_fd_set dummy;
+    long r;
+    int dummy = 0;
     int i, fd, bit, offset;
-    FD_SET nrd, nwr, nex, *prd, *pwr, *pex;
+    FD_SET nrd, nwr, nex,*prd,*pwr,*pex;
 
-    PERL_FD_ZERO(&dummy);
     if (!rd)
        rd = &dummy, prd = NULL;
     else
@@ -276,11 +317,13 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const
     FD_ZERO(&nex);
     for (i = 0; i < nfds; i++) {
        fd = TO_SOCKET(i);
-       if (PERL_FD_ISSET(i,rd))
+       bit = 1L<<(i % (sizeof(int)*8));
+       offset = i / (sizeof(int)*8);
+       if (rd[offset] & bit)
            FD_SET(fd, &nrd);
-       if (PERL_FD_ISSET(i,wr))
+       if (wr[offset] & bit)
            FD_SET(fd, &nwr);
-       if (PERL_FD_ISSET(i,ex))
+       if (ex[offset] & bit)
            FD_SET(fd, &nex);
     }
 
@@ -288,16 +331,21 @@ win32_select(int nfds, Perl_fd_set* rd, Perl_fd_set* wr, Perl_fd_set* ex, const
 
     for (i = 0; i < nfds; i++) {
        fd = TO_SOCKET(i);
-       if (PERL_FD_ISSET(i,rd) && !FD_ISSET(fd, &nrd))
-           PERL_FD_CLR(i,rd);
-       if (PERL_FD_ISSET(i,wr) && !FD_ISSET(fd, &nwr))
-           PERL_FD_CLR(i,wr);
-       if (PERL_FD_ISSET(i,ex) && !FD_ISSET(fd, &nex))
-           PERL_FD_CLR(i,ex);
+       bit = 1L<<(i % (sizeof(int)*8));
+       offset = i / (sizeof(int)*8);
+       if (rd[offset] & bit) {
+           if (!__WSAFDIsSet(fd, &nrd))
+               rd[offset] &= ~bit;
+       }
+       if (wr[offset] & bit) {
+           if (!__WSAFDIsSet(fd, &nwr))
+               wr[offset] &= ~bit;
+       }
+       if (ex[offset] & bit) {
+           if (!__WSAFDIsSet(fd, &nex))
+               ex[offset] &= ~bit;
+       }
     }
-#else
-    SOCKET_TEST_ERROR(r = select(nfds, rd, wr, ex, timeout));
-#endif
     return r;
 }
 
index 4dbc750..c0c3c60 100644 (file)
@@ -1,6 +1,20 @@
 #include "EXTERN.h"
 #include "perl.h"
 
+__declspec(thread) struct thread *Perl_current_thread = NULL;
+
+void
+Perl_setTHR(struct thread *t)
+{
+ Perl_current_thread = t;
+}
+
+struct thread *
+Perl_getTHR(void)
+{
+ return Perl_current_thread;
+}
+
 void
 Perl_alloc_thread_key(void)
 {
index 0c6bb55..38e66e9 100644 (file)
@@ -97,7 +97,7 @@ typedef HANDLE perl_mutex;
        }                                                       \
     } STMT_END
 
-#define THR ((struct thread *) TlsGetValue(thr_key))
+
 #define THREAD_CREATE(t, f)    Perl_thread_create(t, f)
 #define THREAD_POST_CREATE(t)  NOOP
 #define THREAD_RET_TYPE                DWORD WINAPI
@@ -105,14 +105,28 @@ typedef HANDLE perl_mutex;
 
 typedef THREAD_RET_TYPE thread_func_t(void *);
 
+
 START_EXTERN_C
+
+#if defined(PERLDLL) && (!defined(__BORLANDC__) || defined(_DLL))
+extern __declspec(thread) struct thread *Perl_current_thread;
+#define SET_THR(t)             (Perl_current_thread = t)
+#define THR                    Perl_current_thread
+#else
+#define THR                    Perl_getTHR()
+#define SET_THR(t)             Perl_setTHR(t)
+#endif
+
 void Perl_alloc_thread_key _((void));
 int Perl_thread_create _((struct thread *thr, thread_func_t *fn));
 void Perl_set_thread_self _((struct thread *thr));
+struct thread *Perl_getTHR _((void));
+void Perl_setTHR _((struct thread *t));
+
 END_EXTERN_C
 
 #define INIT_THREADS NOOP
-#define ALLOC_THREAD_KEY Perl_alloc_thread_key()
+#define ALLOC_THREAD_KEY NOOP
 #define SET_THREAD_SELF(thr) Perl_set_thread_self(thr)
 
 #define JOIN(t, avp)                                                   \
@@ -122,12 +136,7 @@ END_EXTERN_C
            croak("panic: JOIN");                                       \
     } STMT_END
 
-#define SET_THR(t)                                     \
-    STMT_START {                                       \
-       if (TlsSetValue(thr_key, (void *) (t)) == 0)    \
-           croak("panic: TlsSetValue");                \
-    } STMT_END
-
 #define YIELD                  Sleep(0)
 
 #endif /* _WIN32THREAD_H */
+