Tcl Source Code

Hex Artifact Content
Login

Artifact 077ca26d9a30694786fdc65d57989fbed73e9503:

Attachment "976496.patch" to ticket [976496ffff] added by dgp 2004-06-24 03:35:43.
0000: 49 6e 64 65 78 3a 20 67 65 6e 65 72 69 63 2f 74  Index: generic/t
0010: 63 6c 49 6e 74 2e 64 65 63 6c 73 0a 3d 3d 3d 3d  clInt.decls.====
0020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
0060: 52 43 53 20 66 69 6c 65 3a 20 2f 63 76 73 72 6f  RCS file: /cvsro
0070: 6f 74 2f 74 63 6c 2f 74 63 6c 2f 67 65 6e 65 72  ot/tcl/tcl/gener
0080: 69 63 2f 74 63 6c 49 6e 74 2e 64 65 63 6c 73 2c  ic/tclInt.decls,
0090: 76 0a 72 65 74 72 69 65 76 69 6e 67 20 72 65 76  v.retrieving rev
00a0: 69 73 69 6f 6e 20 31 2e 37 34 0a 64 69 66 66 20  ision 1.74.diff 
00b0: 2d 75 20 2d 72 31 2e 37 34 20 74 63 6c 49 6e 74  -u -r1.74 tclInt
00c0: 2e 64 65 63 6c 73 0a 2d 2d 2d 20 67 65 6e 65 72  .decls.--- gener
00d0: 69 63 2f 74 63 6c 49 6e 74 2e 64 65 63 6c 73 09  ic/tclInt.decls.
00e0: 35 20 4a 75 6e 20 32 30 30 34 20 31 37 3a 33 31  5 Jun 2004 17:31
00f0: 3a 30 38 20 2d 30 30 30 30 09 31 2e 37 34 0a 2b  :08 -0000.1.74.+
0100: 2b 2b 20 67 65 6e 65 72 69 63 2f 74 63 6c 49 6e  ++ generic/tclIn
0110: 74 2e 64 65 63 6c 73 09 32 33 20 4a 75 6e 20 32  t.decls.23 Jun 2
0120: 30 30 34 20 32 30 3a 32 33 3a 30 36 20 2d 30 30  004 20:23:06 -00
0130: 30 30 0a 40 40 20 2d 37 34 35 2c 36 20 2b 37 34  00.@@ -745,6 +74
0140: 35 2c 34 38 20 40 40 0a 20 20 20 20 20 20 73 74  5,48 @@.      st
0150: 72 75 63 74 20 74 6d 20 2a 54 63 6c 70 47 6d 74  ruct tm *TclpGmt
0160: 69 6d 65 28 43 4f 4e 53 54 20 74 69 6d 65 5f 74  ime(CONST time_t
0170: 20 2a 63 6c 6f 63 6b 29 0a 20 7d 0a 20 0a 2b 23   *clock). }. .+#
0180: 20 46 6f 72 20 74 68 65 20 6e 65 77 20 22 54 68   For the new "Th
0190: 72 65 61 64 20 53 74 6f 72 61 67 65 22 20 73 75  read Storage" su
01a0: 62 73 79 73 74 65 6d 2e 0a 2b 0a 2b 64 65 63 6c  bsystem..+.+decl
01b0: 61 72 65 20 31 38 34 20 67 65 6e 65 72 69 63 20  are 184 generic 
01c0: 7b 0a 2b 20 20 20 20 20 76 6f 69 64 20 54 63 6c  {.+     void Tcl
01d0: 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63  ThreadStorageLoc
01e0: 6b 49 6e 69 74 28 76 6f 69 64 29 20 20 20 20 20  kInit(void)     
01f0: 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65 20 31 38 35  .+}.+declare 185
0200: 20 67 65 6e 65 72 69 63 20 7b 0a 2b 20 20 20 20   generic {.+    
0210: 20 76 6f 69 64 20 54 63 6c 54 68 72 65 61 64 53   void TclThreadS
0220: 74 6f 72 61 67 65 4c 6f 63 6b 28 76 6f 69 64 29  torageLock(void)
0230: 20 20 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72       .+}.+declar
0240: 65 20 31 38 36 20 67 65 6e 65 72 69 63 20 7b 0a  e 186 generic {.
0250: 2b 20 20 20 20 20 76 6f 69 64 20 54 63 6c 54 68  +     void TclTh
0260: 72 65 61 64 53 74 6f 72 61 67 65 55 6e 6c 6f 63  readStorageUnloc
0270: 6b 28 76 6f 69 64 29 20 20 20 20 20 0a 2b 7d 0a  k(void)     .+}.
0280: 2b 64 65 63 6c 61 72 65 20 31 38 37 20 67 65 6e  +declare 187 gen
0290: 65 72 69 63 20 7b 0a 2b 20 20 20 20 20 76 6f 69  eric {.+     voi
02a0: 64 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61  d TclThreadStora
02b0: 67 65 50 72 69 6e 74 28 46 49 4c 45 20 2a 6f 75  gePrint(FILE *ou
02c0: 74 46 69 6c 65 2c 20 69 6e 74 20 66 6c 61 67 73  tFile, int flags
02d0: 29 20 20 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61  )     .+}.+decla
02e0: 72 65 20 31 38 38 20 67 65 6e 65 72 69 63 20 7b  re 188 generic {
02f0: 0a 2b 20 20 20 20 20 54 63 6c 5f 48 61 73 68 54  .+     Tcl_HashT
0300: 61 62 6c 65 20 2a 54 63 6c 54 68 72 65 61 64 53  able *TclThreadS
0310: 74 6f 72 61 67 65 47 65 74 48 61 73 68 54 61 62  torageGetHashTab
0320: 6c 65 28 54 63 6c 5f 54 68 72 65 61 64 49 64 20  le(Tcl_ThreadId 
0330: 69 64 29 20 20 20 20 20 0a 2b 7d 0a 2b 64 65 63  id)     .+}.+dec
0340: 6c 61 72 65 20 31 38 39 20 67 65 6e 65 72 69 63  lare 189 generic
0350: 20 7b 0a 2b 20 20 20 20 20 54 63 6c 5f 48 61 73   {.+     Tcl_Has
0360: 68 54 61 62 6c 65 20 2a 54 63 6c 54 68 72 65 61  hTable *TclThrea
0370: 64 53 74 6f 72 61 67 65 49 6e 69 74 28 54 63 6c  dStorageInit(Tcl
0380: 5f 54 68 72 65 61 64 49 64 20 69 64 2c 20 76 6f  _ThreadId id, vo
0390: 69 64 20 2a 72 65 73 65 72 76 65 64 29 20 20 20  id *reserved)   
03a0: 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65 20 31    .+}.+declare 1
03b0: 39 30 20 67 65 6e 65 72 69 63 20 7b 0a 2b 20 20  90 generic {.+  
03c0: 20 20 20 76 6f 69 64 20 54 63 6c 54 68 72 65 61     void TclThrea
03d0: 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 49  dStorageDataKeyI
03e0: 6e 69 74 28 54 63 6c 5f 54 68 72 65 61 64 44 61  nit(Tcl_ThreadDa
03f0: 74 61 4b 65 79 20 2a 6b 65 79 50 74 72 29 20 20  taKey *keyPtr)  
0400: 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65 20     .+}.+declare 
0410: 31 39 31 20 67 65 6e 65 72 69 63 20 7b 0a 2b 20  191 generic {.+ 
0420: 20 20 20 20 76 6f 69 64 20 2a 54 63 6c 54 68 72      void *TclThr
0430: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
0440: 79 47 65 74 28 54 63 6c 5f 54 68 72 65 61 64 44  yGet(Tcl_ThreadD
0450: 61 74 61 4b 65 79 20 2a 6b 65 79 50 74 72 29 20  ataKey *keyPtr) 
0460: 20 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65      .+}.+declare
0470: 20 31 39 32 20 67 65 6e 65 72 69 63 20 7b 0a 2b   192 generic {.+
0480: 20 20 20 20 20 76 6f 69 64 20 54 63 6c 54 68 72       void TclThr
0490: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
04a0: 79 53 65 74 28 54 63 6c 5f 54 68 72 65 61 64 44  ySet(Tcl_ThreadD
04b0: 61 74 61 4b 65 79 20 2a 6b 65 79 50 74 72 2c 20  ataKey *keyPtr, 
04c0: 76 6f 69 64 20 2a 64 61 74 61 29 20 20 20 20 20  void *data)     
04d0: 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65 20 31 39 33  .+}.+declare 193
04e0: 20 67 65 6e 65 72 69 63 20 7b 0a 2b 20 20 20 20   generic {.+    
04f0: 20 76 6f 69 64 20 54 63 6c 46 69 6e 61 6c 69 7a   void TclFinaliz
0500: 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 54 68  eThreadStorageTh
0510: 72 65 61 64 28 54 63 6c 5f 54 68 72 65 61 64 49  read(Tcl_ThreadI
0520: 64 20 69 64 29 20 20 20 20 20 0a 2b 7d 0a 2b 64  d id)     .+}.+d
0530: 65 63 6c 61 72 65 20 31 39 34 20 67 65 6e 65 72  eclare 194 gener
0540: 69 63 20 7b 0a 2b 20 20 20 20 20 76 6f 69 64 20  ic {.+     void 
0550: 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61  TclFinalizeThrea
0560: 64 53 74 6f 72 61 67 65 28 76 6f 69 64 29 20 20  dStorage(void)  
0570: 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72 65 20     .+}.+declare 
0580: 31 39 35 20 67 65 6e 65 72 69 63 20 7b 0a 2b 20  195 generic {.+ 
0590: 20 20 20 20 76 6f 69 64 20 54 63 6c 46 69 6e 61      void TclFina
05a0: 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67  lizeThreadStorag
05b0: 65 44 61 74 61 28 54 63 6c 5f 54 68 72 65 61 64  eData(Tcl_Thread
05c0: 44 61 74 61 4b 65 79 20 2a 6b 65 79 50 74 72 29  DataKey *keyPtr)
05d0: 20 20 20 20 20 0a 2b 7d 0a 2b 64 65 63 6c 61 72       .+}.+declar
05e0: 65 20 31 39 36 20 67 65 6e 65 72 69 63 20 7b 0a  e 196 generic {.
05f0: 2b 20 20 20 20 20 76 6f 69 64 20 54 63 6c 46 69  +     void TclFi
0600: 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72  nalizeThreadStor
0610: 61 67 65 44 61 74 61 4b 65 79 28 54 63 6c 5f 54  ageDataKey(Tcl_T
0620: 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a 6b 65  hreadDataKey *ke
0630: 79 50 74 72 29 0a 2b 7d 0a 2b 0a 20 23 23 23 23  yPtr).+}.+. ####
0640: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0650: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0660: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0670: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23  ################
0680: 23 23 23 23 23 23 23 23 23 23 0a 20 0a 20 23 20  ##########. . # 
0690: 44 65 66 69 6e 65 20 74 68 65 20 70 6c 61 74 66  Define the platf
06a0: 6f 72 6d 20 73 70 65 63 69 66 69 63 20 69 6e 74  orm specific int
06b0: 65 72 6e 61 6c 20 54 63 6c 20 69 6e 74 65 72 66  ernal Tcl interf
06c0: 61 63 65 2e 20 54 68 65 73 65 20 66 75 6e 63 74  ace. These funct
06d0: 69 6f 6e 73 20 61 72 65 0a 49 6e 64 65 78 3a 20  ions are.Index: 
06e0: 67 65 6e 65 72 69 63 2f 74 63 6c 49 6e 74 44 65  generic/tclIntDe
06f0: 63 6c 73 2e 68 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  cls.h.==========
0700: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0710: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0720: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0730: 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69  =========.RCS fi
0740: 6c 65 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c  le: /cvsroot/tcl
0750: 2f 74 63 6c 2f 67 65 6e 65 72 69 63 2f 74 63 6c  /tcl/generic/tcl
0760: 49 6e 74 44 65 63 6c 73 2e 68 2c 76 0a 72 65 74  IntDecls.h,v.ret
0770: 72 69 65 76 69 6e 67 20 72 65 76 69 73 69 6f 6e  rieving revision
0780: 20 31 2e 36 34 0a 64 69 66 66 20 2d 75 20 2d 72   1.64.diff -u -r
0790: 31 2e 36 34 20 74 63 6c 49 6e 74 44 65 63 6c 73  1.64 tclIntDecls
07a0: 2e 68 0a 2d 2d 2d 20 67 65 6e 65 72 69 63 2f 74  .h.--- generic/t
07b0: 63 6c 49 6e 74 44 65 63 6c 73 2e 68 09 37 20 4a  clIntDecls.h.7 J
07c0: 75 6e 20 32 30 30 34 20 31 36 3a 34 38 3a 34 35  un 2004 16:48:45
07d0: 20 2d 30 30 30 30 09 31 2e 36 34 0a 2b 2b 2b 20   -0000.1.64.+++ 
07e0: 67 65 6e 65 72 69 63 2f 74 63 6c 49 6e 74 44 65  generic/tclIntDe
07f0: 63 6c 73 2e 68 09 32 33 20 4a 75 6e 20 32 30 30  cls.h.23 Jun 200
0800: 34 20 32 30 3a 32 33 3a 30 37 20 2d 30 30 30 30  4 20:23:07 -0000
0810: 0a 40 40 20 2d 39 36 39 2c 36 20 2b 39 36 39 2c  .@@ -969,6 +969,
0820: 38 30 20 40 40 0a 20 2f 2a 20 31 38 33 20 2a 2f  80 @@. /* 183 */
0830: 0a 20 45 58 54 45 52 4e 20 73 74 72 75 63 74 20  . EXTERN struct 
0840: 74 6d 20 2a 09 54 63 6c 70 47 6d 74 69 6d 65 20  tm *.TclpGmtime 
0850: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 43 4f 4e  _ANSI_ARGS_((CON
0860: 53 54 20 74 69 6d 65 5f 74 20 2a 20 63 6c 6f 63  ST time_t * cloc
0870: 6b 29 29 3b 0a 20 23 65 6e 64 69 66 0a 2b 23 69  k));. #endif.+#i
0880: 66 6e 64 65 66 20 54 63 6c 54 68 72 65 61 64 53  fndef TclThreadS
0890: 74 6f 72 61 67 65 4c 6f 63 6b 49 6e 69 74 5f 54  torageLockInit_T
08a0: 43 4c 5f 44 45 43 4c 41 52 45 44 0a 2b 23 64 65  CL_DECLARED.+#de
08b0: 66 69 6e 65 20 54 63 6c 54 68 72 65 61 64 53 74  fine TclThreadSt
08c0: 6f 72 61 67 65 4c 6f 63 6b 49 6e 69 74 5f 54 43  orageLockInit_TC
08d0: 4c 5f 44 45 43 4c 41 52 45 44 0a 2b 2f 2a 20 31  L_DECLARED.+/* 1
08e0: 38 34 20 2a 2f 0a 2b 45 58 54 45 52 4e 20 76 6f  84 */.+EXTERN vo
08f0: 69 64 09 09 54 63 6c 54 68 72 65 61 64 53 74 6f  id..TclThreadSto
0900: 72 61 67 65 4c 6f 63 6b 49 6e 69 74 20 5f 41 4e  rageLockInit _AN
0910: 53 49 5f 41 52 47 53 5f 28 28 76 6f 69 64 29 29  SI_ARGS_((void))
0920: 3b 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66 6e 64  ;.+#endif.+#ifnd
0930: 65 66 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72  ef TclThreadStor
0940: 61 67 65 4c 6f 63 6b 5f 54 43 4c 5f 44 45 43 4c  ageLock_TCL_DECL
0950: 41 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54 63  ARED.+#define Tc
0960: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f  lThreadStorageLo
0970: 63 6b 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a  ck_TCL_DECLARED.
0980: 2b 2f 2a 20 31 38 35 20 2a 2f 0a 2b 45 58 54 45  +/* 185 */.+EXTE
0990: 52 4e 20 76 6f 69 64 09 09 54 63 6c 54 68 72 65  RN void..TclThre
09a0: 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 20 5f 41  adStorageLock _A
09b0: 4e 53 49 5f 41 52 47 53 5f 28 28 76 6f 69 64 29  NSI_ARGS_((void)
09c0: 29 3b 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66 6e  );.+#endif.+#ifn
09d0: 64 65 66 20 54 63 6c 54 68 72 65 61 64 53 74 6f  def TclThreadSto
09e0: 72 61 67 65 55 6e 6c 6f 63 6b 5f 54 43 4c 5f 44  rageUnlock_TCL_D
09f0: 45 43 4c 41 52 45 44 0a 2b 23 64 65 66 69 6e 65  ECLARED.+#define
0a00: 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67   TclThreadStorag
0a10: 65 55 6e 6c 6f 63 6b 5f 54 43 4c 5f 44 45 43 4c  eUnlock_TCL_DECL
0a20: 41 52 45 44 0a 2b 2f 2a 20 31 38 36 20 2a 2f 0a  ARED.+/* 186 */.
0a30: 2b 45 58 54 45 52 4e 20 76 6f 69 64 09 09 54 63  +EXTERN void..Tc
0a40: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 55 6e  lThreadStorageUn
0a50: 6c 6f 63 6b 20 5f 41 4e 53 49 5f 41 52 47 53 5f  lock _ANSI_ARGS_
0a60: 28 28 76 6f 69 64 29 29 3b 0a 2b 23 65 6e 64 69  ((void));.+#endi
0a70: 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 54 68  f.+#ifndef TclTh
0a80: 72 65 61 64 53 74 6f 72 61 67 65 50 72 69 6e 74  readStoragePrint
0a90: 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a 2b 23  _TCL_DECLARED.+#
0aa0: 64 65 66 69 6e 65 20 54 63 6c 54 68 72 65 61 64  define TclThread
0ab0: 53 74 6f 72 61 67 65 50 72 69 6e 74 5f 54 43 4c  StoragePrint_TCL
0ac0: 5f 44 45 43 4c 41 52 45 44 0a 2b 2f 2a 20 31 38  _DECLARED.+/* 18
0ad0: 37 20 2a 2f 0a 2b 45 58 54 45 52 4e 20 76 6f 69  7 */.+EXTERN voi
0ae0: 64 09 09 54 63 6c 54 68 72 65 61 64 53 74 6f 72  d..TclThreadStor
0af0: 61 67 65 50 72 69 6e 74 20 5f 41 4e 53 49 5f 41  agePrint _ANSI_A
0b00: 52 47 53 5f 28 28 46 49 4c 45 20 2a 20 6f 75 74  RGS_((FILE * out
0b10: 46 69 6c 65 2c 20 0a 2b 09 09 09 09 69 6e 74 20  File, .+....int 
0b20: 66 6c 61 67 73 29 29 3b 0a 2b 23 65 6e 64 69 66  flags));.+#endif
0b30: 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 54 68 72  .+#ifndef TclThr
0b40: 65 61 64 53 74 6f 72 61 67 65 47 65 74 48 61 73  eadStorageGetHas
0b50: 68 54 61 62 6c 65 5f 54 43 4c 5f 44 45 43 4c 41  hTable_TCL_DECLA
0b60: 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c  RED.+#define Tcl
0b70: 54 68 72 65 61 64 53 74 6f 72 61 67 65 47 65 74  ThreadStorageGet
0b80: 48 61 73 68 54 61 62 6c 65 5f 54 43 4c 5f 44 45  HashTable_TCL_DE
0b90: 43 4c 41 52 45 44 0a 2b 2f 2a 20 31 38 38 20 2a  CLARED.+/* 188 *
0ba0: 2f 0a 2b 45 58 54 45 52 4e 20 54 63 6c 5f 48 61  /.+EXTERN Tcl_Ha
0bb0: 73 68 54 61 62 6c 65 20 2a 09 54 63 6c 54 68 72  shTable *.TclThr
0bc0: 65 61 64 53 74 6f 72 61 67 65 47 65 74 48 61 73  eadStorageGetHas
0bd0: 68 54 61 62 6c 65 20 5f 41 4e 53 49 5f 41 52 47  hTable _ANSI_ARG
0be0: 53 5f 28 28 0a 2b 09 09 09 09 54 63 6c 5f 54 68  S_((.+....Tcl_Th
0bf0: 72 65 61 64 49 64 20 69 64 29 29 3b 0a 2b 23 65  readId id));.+#e
0c00: 6e 64 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63  ndif.+#ifndef Tc
0c10: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 49 6e  lThreadStorageIn
0c20: 69 74 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a  it_TCL_DECLARED.
0c30: 2b 23 64 65 66 69 6e 65 20 54 63 6c 54 68 72 65  +#define TclThre
0c40: 61 64 53 74 6f 72 61 67 65 49 6e 69 74 5f 54 43  adStorageInit_TC
0c50: 4c 5f 44 45 43 4c 41 52 45 44 0a 2b 2f 2a 20 31  L_DECLARED.+/* 1
0c60: 38 39 20 2a 2f 0a 2b 45 58 54 45 52 4e 20 54 63  89 */.+EXTERN Tc
0c70: 6c 5f 48 61 73 68 54 61 62 6c 65 20 2a 09 54 63  l_HashTable *.Tc
0c80: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 49 6e  lThreadStorageIn
0c90: 69 74 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28  it _ANSI_ARGS_((
0ca0: 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69 64 2c  Tcl_ThreadId id,
0cb0: 20 0a 2b 09 09 09 09 76 6f 69 64 20 2a 20 72 65   .+....void * re
0cc0: 73 65 72 76 65 64 29 29 3b 0a 2b 23 65 6e 64 69  served));.+#endi
0cd0: 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 54 68  f.+#ifndef TclTh
0ce0: 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b  readStorageDataK
0cf0: 65 79 49 6e 69 74 5f 54 43 4c 5f 44 45 43 4c 41  eyInit_TCL_DECLA
0d00: 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c  RED.+#define Tcl
0d10: 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74  ThreadStorageDat
0d20: 61 4b 65 79 49 6e 69 74 5f 54 43 4c 5f 44 45 43  aKeyInit_TCL_DEC
0d30: 4c 41 52 45 44 0a 2b 2f 2a 20 31 39 30 20 2a 2f  LARED.+/* 190 */
0d40: 0a 2b 45 58 54 45 52 4e 20 76 6f 69 64 09 09 54  .+EXTERN void..T
0d50: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
0d60: 61 74 61 4b 65 79 49 6e 69 74 20 5f 41 4e 53 49  ataKeyInit _ANSI
0d70: 5f 41 52 47 53 5f 28 28 0a 2b 09 09 09 09 54 63  _ARGS_((.+....Tc
0d80: 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20  l_ThreadDataKey 
0d90: 2a 20 6b 65 79 50 74 72 29 29 3b 0a 2b 23 65 6e  * keyPtr));.+#en
0da0: 64 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c  dif.+#ifndef Tcl
0db0: 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74  ThreadStorageDat
0dc0: 61 4b 65 79 47 65 74 5f 54 43 4c 5f 44 45 43 4c  aKeyGet_TCL_DECL
0dd0: 41 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54 63  ARED.+#define Tc
0de0: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61  lThreadStorageDa
0df0: 74 61 4b 65 79 47 65 74 5f 54 43 4c 5f 44 45 43  taKeyGet_TCL_DEC
0e00: 4c 41 52 45 44 0a 2b 2f 2a 20 31 39 31 20 2a 2f  LARED.+/* 191 */
0e10: 0a 2b 45 58 54 45 52 4e 20 76 6f 69 64 20 2a 09  .+EXTERN void *.
0e20: 09 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67  .TclThreadStorag
0e30: 65 44 61 74 61 4b 65 79 47 65 74 20 5f 41 4e 53  eDataKeyGet _ANS
0e40: 49 5f 41 52 47 53 5f 28 28 0a 2b 09 09 09 09 54  I_ARGS_((.+....T
0e50: 63 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79  cl_ThreadDataKey
0e60: 20 2a 20 6b 65 79 50 74 72 29 29 3b 0a 2b 23 65   * keyPtr));.+#e
0e70: 6e 64 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63  ndif.+#ifndef Tc
0e80: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61  lThreadStorageDa
0e90: 74 61 4b 65 79 53 65 74 5f 54 43 4c 5f 44 45 43  taKeySet_TCL_DEC
0ea0: 4c 41 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54  LARED.+#define T
0eb0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
0ec0: 61 74 61 4b 65 79 53 65 74 5f 54 43 4c 5f 44 45  ataKeySet_TCL_DE
0ed0: 43 4c 41 52 45 44 0a 2b 2f 2a 20 31 39 32 20 2a  CLARED.+/* 192 *
0ee0: 2f 0a 2b 45 58 54 45 52 4e 20 76 6f 69 64 09 09  /.+EXTERN void..
0ef0: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
0f00: 44 61 74 61 4b 65 79 53 65 74 20 5f 41 4e 53 49  DataKeySet _ANSI
0f10: 5f 41 52 47 53 5f 28 28 0a 2b 09 09 09 09 54 63  _ARGS_((.+....Tc
0f20: 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20  l_ThreadDataKey 
0f30: 2a 20 6b 65 79 50 74 72 2c 20 76 6f 69 64 20 2a  * keyPtr, void *
0f40: 20 64 61 74 61 29 29 3b 0a 2b 23 65 6e 64 69 66   data));.+#endif
0f50: 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 46 69 6e  .+#ifndef TclFin
0f60: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
0f70: 67 65 54 68 72 65 61 64 5f 54 43 4c 5f 44 45 43  geThread_TCL_DEC
0f80: 4c 41 52 45 44 0a 2b 23 64 65 66 69 6e 65 20 54  LARED.+#define T
0f90: 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64  clFinalizeThread
0fa0: 53 74 6f 72 61 67 65 54 68 72 65 61 64 5f 54 43  StorageThread_TC
0fb0: 4c 5f 44 45 43 4c 41 52 45 44 0a 2b 2f 2a 20 31  L_DECLARED.+/* 1
0fc0: 39 33 20 2a 2f 0a 2b 45 58 54 45 52 4e 20 76 6f  93 */.+EXTERN vo
0fd0: 69 64 09 09 54 63 6c 46 69 6e 61 6c 69 7a 65 54  id..TclFinalizeT
0fe0: 68 72 65 61 64 53 74 6f 72 61 67 65 54 68 72 65  hreadStorageThre
0ff0: 61 64 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28  ad _ANSI_ARGS_((
1000: 0a 2b 09 09 09 09 54 63 6c 5f 54 68 72 65 61 64  .+....Tcl_Thread
1010: 49 64 20 69 64 29 29 3b 0a 2b 23 65 6e 64 69 66  Id id));.+#endif
1020: 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 46 69 6e  .+#ifndef TclFin
1030: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
1040: 67 65 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a  ge_TCL_DECLARED.
1050: 2b 23 64 65 66 69 6e 65 20 54 63 6c 46 69 6e 61  +#define TclFina
1060: 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67  lizeThreadStorag
1070: 65 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a 2b  e_TCL_DECLARED.+
1080: 2f 2a 20 31 39 34 20 2a 2f 0a 2b 45 58 54 45 52  /* 194 */.+EXTER
1090: 4e 20 76 6f 69 64 09 09 54 63 6c 46 69 6e 61 6c  N void..TclFinal
10a0: 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67 65  izeThreadStorage
10b0: 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 76 6f   _ANSI_ARGS_((vo
10c0: 69 64 29 29 3b 0a 2b 23 65 6e 64 69 66 0a 2b 23  id));.+#endif.+#
10d0: 69 66 6e 64 65 66 20 54 63 6c 46 69 6e 61 6c 69  ifndef TclFinali
10e0: 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  zeThreadStorageD
10f0: 61 74 61 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44  ata_TCL_DECLARED
1100: 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c 46 69 6e  .+#define TclFin
1110: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
1120: 67 65 44 61 74 61 5f 54 43 4c 5f 44 45 43 4c 41  geData_TCL_DECLA
1130: 52 45 44 0a 2b 2f 2a 20 31 39 35 20 2a 2f 0a 2b  RED.+/* 195 */.+
1140: 45 58 54 45 52 4e 20 76 6f 69 64 09 09 54 63 6c  EXTERN void..Tcl
1150: 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74  FinalizeThreadSt
1160: 6f 72 61 67 65 44 61 74 61 20 5f 41 4e 53 49 5f  orageData _ANSI_
1170: 41 52 47 53 5f 28 28 0a 2b 09 09 09 09 54 63 6c  ARGS_((.+....Tcl
1180: 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a  _ThreadDataKey *
1190: 20 6b 65 79 50 74 72 29 29 3b 0a 2b 23 65 6e 64   keyPtr));.+#end
11a0: 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 46  if.+#ifndef TclF
11b0: 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f  inalizeThreadSto
11c0: 72 61 67 65 44 61 74 61 4b 65 79 5f 54 43 4c 5f  rageDataKey_TCL_
11d0: 44 45 43 4c 41 52 45 44 0a 2b 23 64 65 66 69 6e  DECLARED.+#defin
11e0: 65 20 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72  e TclFinalizeThr
11f0: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
1200: 79 5f 54 43 4c 5f 44 45 43 4c 41 52 45 44 0a 2b  y_TCL_DECLARED.+
1210: 2f 2a 20 31 39 36 20 2a 2f 0a 2b 45 58 54 45 52  /* 196 */.+EXTER
1220: 4e 20 76 6f 69 64 09 09 54 63 6c 46 69 6e 61 6c  N void..TclFinal
1230: 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67 65  izeThreadStorage
1240: 44 61 74 61 4b 65 79 20 5f 41 4e 53 49 5f 41 52  DataKey _ANSI_AR
1250: 47 53 5f 28 28 0a 2b 09 09 09 09 54 63 6c 5f 54  GS_((.+....Tcl_T
1260: 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a 20 6b  hreadDataKey * k
1270: 65 79 50 74 72 29 29 3b 0a 2b 23 65 6e 64 69 66  eyPtr));.+#endif
1280: 0a 20 0a 20 74 79 70 65 64 65 66 20 73 74 72 75  . . typedef stru
1290: 63 74 20 54 63 6c 49 6e 74 53 74 75 62 73 20 7b  ct TclIntStubs {
12a0: 0a 20 20 20 20 20 69 6e 74 20 6d 61 67 69 63 3b  .     int magic;
12b0: 0a 40 40 20 2d 31 31 37 33 2c 36 20 2b 31 32 34  .@@ -1173,6 +124
12c0: 37 2c 31 39 20 40 40 0a 20 20 20 20 20 54 63 6c  7,19 @@.     Tcl
12d0: 5f 4f 62 6a 20 2a 20 28 2a 74 63 6c 44 62 4e 65  _Obj * (*tclDbNe
12e0: 77 4c 69 73 74 4f 62 6a 44 69 72 65 63 74 29 20  wListObjDirect) 
12f0: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 69 6e 74  _ANSI_ARGS_((int
1300: 20 6f 62 6a 63 2c 20 54 63 6c 5f 4f 62 6a 20 2a   objc, Tcl_Obj *
1310: 2a 20 6f 62 6a 76 2c 20 43 4f 4e 53 54 20 63 68  * objv, CONST ch
1320: 61 72 20 2a 20 66 69 6c 65 2c 20 69 6e 74 20 6c  ar * file, int l
1330: 69 6e 65 29 29 3b 20 2f 2a 20 31 38 31 20 2a 2f  ine)); /* 181 */
1340: 0a 20 20 20 20 20 73 74 72 75 63 74 20 74 6d 20  .     struct tm 
1350: 2a 20 28 2a 74 63 6c 70 4c 6f 63 61 6c 74 69 6d  * (*tclpLocaltim
1360: 65 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28  e) _ANSI_ARGS_((
1370: 43 4f 4e 53 54 20 74 69 6d 65 5f 74 20 2a 20 63  CONST time_t * c
1380: 6c 6f 63 6b 29 29 3b 20 2f 2a 20 31 38 32 20 2a  lock)); /* 182 *
1390: 2f 0a 20 20 20 20 20 73 74 72 75 63 74 20 74 6d  /.     struct tm
13a0: 20 2a 20 28 2a 74 63 6c 70 47 6d 74 69 6d 65 29   * (*tclpGmtime)
13b0: 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 43 4f   _ANSI_ARGS_((CO
13c0: 4e 53 54 20 74 69 6d 65 5f 74 20 2a 20 63 6c 6f  NST time_t * clo
13d0: 63 6b 29 29 3b 20 2f 2a 20 31 38 33 20 2a 2f 0a  ck)); /* 183 */.
13e0: 2b 20 20 20 20 76 6f 69 64 20 28 2a 74 63 6c 54  +    void (*tclT
13f0: 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b  hreadStorageLock
1400: 49 6e 69 74 29 20 5f 41 4e 53 49 5f 41 52 47 53  Init) _ANSI_ARGS
1410: 5f 28 28 76 6f 69 64 29 29 3b 20 2f 2a 20 31 38  _((void)); /* 18
1420: 34 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 28  4 */.+    void (
1430: 2a 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67  *tclThreadStorag
1440: 65 4c 6f 63 6b 29 20 5f 41 4e 53 49 5f 41 52 47  eLock) _ANSI_ARG
1450: 53 5f 28 28 76 6f 69 64 29 29 3b 20 2f 2a 20 31  S_((void)); /* 1
1460: 38 35 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20  85 */.+    void 
1470: 28 2a 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61  (*tclThreadStora
1480: 67 65 55 6e 6c 6f 63 6b 29 20 5f 41 4e 53 49 5f  geUnlock) _ANSI_
1490: 41 52 47 53 5f 28 28 76 6f 69 64 29 29 3b 20 2f  ARGS_((void)); /
14a0: 2a 20 31 38 36 20 2a 2f 0a 2b 20 20 20 20 76 6f  * 186 */.+    vo
14b0: 69 64 20 28 2a 74 63 6c 54 68 72 65 61 64 53 74  id (*tclThreadSt
14c0: 6f 72 61 67 65 50 72 69 6e 74 29 20 5f 41 4e 53  oragePrint) _ANS
14d0: 49 5f 41 52 47 53 5f 28 28 46 49 4c 45 20 2a 20  I_ARGS_((FILE * 
14e0: 6f 75 74 46 69 6c 65 2c 20 69 6e 74 20 66 6c 61  outFile, int fla
14f0: 67 73 29 29 3b 20 2f 2a 20 31 38 37 20 2a 2f 0a  gs)); /* 187 */.
1500: 2b 20 20 20 20 54 63 6c 5f 48 61 73 68 54 61 62  +    Tcl_HashTab
1510: 6c 65 20 2a 20 28 2a 74 63 6c 54 68 72 65 61 64  le * (*tclThread
1520: 53 74 6f 72 61 67 65 47 65 74 48 61 73 68 54 61  StorageGetHashTa
1530: 62 6c 65 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f  ble) _ANSI_ARGS_
1540: 28 28 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69  ((Tcl_ThreadId i
1550: 64 29 29 3b 20 2f 2a 20 31 38 38 20 2a 2f 0a 2b  d)); /* 188 */.+
1560: 20 20 20 20 54 63 6c 5f 48 61 73 68 54 61 62 6c      Tcl_HashTabl
1570: 65 20 2a 20 28 2a 74 63 6c 54 68 72 65 61 64 53  e * (*tclThreadS
1580: 74 6f 72 61 67 65 49 6e 69 74 29 20 5f 41 4e 53  torageInit) _ANS
1590: 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 54 68 72  I_ARGS_((Tcl_Thr
15a0: 65 61 64 49 64 20 69 64 2c 20 76 6f 69 64 20 2a  eadId id, void *
15b0: 20 72 65 73 65 72 76 65 64 29 29 3b 20 2f 2a 20   reserved)); /* 
15c0: 31 38 39 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64  189 */.+    void
15d0: 20 28 2a 74 63 6c 54 68 72 65 61 64 53 74 6f 72   (*tclThreadStor
15e0: 61 67 65 44 61 74 61 4b 65 79 49 6e 69 74 29 20  ageDataKeyInit) 
15f0: 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c  _ANSI_ARGS_((Tcl
1600: 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a  _ThreadDataKey *
1610: 20 6b 65 79 50 74 72 29 29 3b 20 2f 2a 20 31 39   keyPtr)); /* 19
1620: 30 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 2a  0 */.+    void *
1630: 20 28 2a 74 63 6c 54 68 72 65 61 64 53 74 6f 72   (*tclThreadStor
1640: 61 67 65 44 61 74 61 4b 65 79 47 65 74 29 20 5f  ageDataKeyGet) _
1650: 41 4e 53 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f  ANSI_ARGS_((Tcl_
1660: 54 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a 20  ThreadDataKey * 
1670: 6b 65 79 50 74 72 29 29 3b 20 2f 2a 20 31 39 31  keyPtr)); /* 191
1680: 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 28 2a   */.+    void (*
1690: 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  tclThreadStorage
16a0: 44 61 74 61 4b 65 79 53 65 74 29 20 5f 41 4e 53  DataKeySet) _ANS
16b0: 49 5f 41 52 47 53 5f 28 28 54 63 6c 5f 54 68 72  I_ARGS_((Tcl_Thr
16c0: 65 61 64 44 61 74 61 4b 65 79 20 2a 20 6b 65 79  eadDataKey * key
16d0: 50 74 72 2c 20 76 6f 69 64 20 2a 20 64 61 74 61  Ptr, void * data
16e0: 29 29 3b 20 2f 2a 20 31 39 32 20 2a 2f 0a 2b 20  )); /* 192 */.+ 
16f0: 20 20 20 76 6f 69 64 20 28 2a 74 63 6c 46 69 6e     void (*tclFin
1700: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
1710: 67 65 54 68 72 65 61 64 29 20 5f 41 4e 53 49 5f  geThread) _ANSI_
1720: 41 52 47 53 5f 28 28 54 63 6c 5f 54 68 72 65 61  ARGS_((Tcl_Threa
1730: 64 49 64 20 69 64 29 29 3b 20 2f 2a 20 31 39 33  dId id)); /* 193
1740: 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 28 2a   */.+    void (*
1750: 74 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61  tclFinalizeThrea
1760: 64 53 74 6f 72 61 67 65 29 20 5f 41 4e 53 49 5f  dStorage) _ANSI_
1770: 41 52 47 53 5f 28 28 76 6f 69 64 29 29 3b 20 2f  ARGS_((void)); /
1780: 2a 20 31 39 34 20 2a 2f 0a 2b 20 20 20 20 76 6f  * 194 */.+    vo
1790: 69 64 20 28 2a 74 63 6c 46 69 6e 61 6c 69 7a 65  id (*tclFinalize
17a0: 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74  ThreadStorageDat
17b0: 61 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28  a) _ANSI_ARGS_((
17c0: 54 63 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65  Tcl_ThreadDataKe
17d0: 79 20 2a 20 6b 65 79 50 74 72 29 29 3b 20 2f 2a  y * keyPtr)); /*
17e0: 20 31 39 35 20 2a 2f 0a 2b 20 20 20 20 76 6f 69   195 */.+    voi
17f0: 64 20 28 2a 74 63 6c 46 69 6e 61 6c 69 7a 65 54  d (*tclFinalizeT
1800: 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61  hreadStorageData
1810: 4b 65 79 29 20 5f 41 4e 53 49 5f 41 52 47 53 5f  Key) _ANSI_ARGS_
1820: 28 28 54 63 6c 5f 54 68 72 65 61 64 44 61 74 61  ((Tcl_ThreadData
1830: 4b 65 79 20 2a 20 6b 65 79 50 74 72 29 29 3b 20  Key * keyPtr)); 
1840: 2f 2a 20 31 39 36 20 2a 2f 0a 20 7d 20 54 63 6c  /* 196 */. } Tcl
1850: 49 6e 74 53 74 75 62 73 3b 0a 20 0a 20 23 69 66  IntStubs;. . #if
1860: 64 65 66 20 5f 5f 63 70 6c 75 73 70 6c 75 73 0a  def __cplusplus.
1870: 40 40 20 2d 31 38 31 37 2c 36 20 2b 31 39 30 34  @@ -1817,6 +1904
1880: 2c 35 38 20 40 40 0a 20 23 64 65 66 69 6e 65 20  ,58 @@. #define 
1890: 54 63 6c 70 47 6d 74 69 6d 65 20 5c 0a 20 09 28  TclpGmtime \. .(
18a0: 74 63 6c 49 6e 74 53 74 75 62 73 50 74 72 2d 3e  tclIntStubsPtr->
18b0: 74 63 6c 70 47 6d 74 69 6d 65 29 20 2f 2a 20 31  tclpGmtime) /* 1
18c0: 38 33 20 2a 2f 0a 20 23 65 6e 64 69 66 0a 2b 23  83 */. #endif.+#
18d0: 69 66 6e 64 65 66 20 54 63 6c 54 68 72 65 61 64  ifndef TclThread
18e0: 53 74 6f 72 61 67 65 4c 6f 63 6b 49 6e 69 74 0a  StorageLockInit.
18f0: 2b 23 64 65 66 69 6e 65 20 54 63 6c 54 68 72 65  +#define TclThre
1900: 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 49 6e 69  adStorageLockIni
1910: 74 20 5c 0a 2b 09 28 74 63 6c 49 6e 74 53 74 75  t \.+.(tclIntStu
1920: 62 73 50 74 72 2d 3e 74 63 6c 54 68 72 65 61 64  bsPtr->tclThread
1930: 53 74 6f 72 61 67 65 4c 6f 63 6b 49 6e 69 74 29  StorageLockInit)
1940: 20 2f 2a 20 31 38 34 20 2a 2f 0a 2b 23 65 6e 64   /* 184 */.+#end
1950: 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 54  if.+#ifndef TclT
1960: 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b  hreadStorageLock
1970: 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c 54 68 72  .+#define TclThr
1980: 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 20 5c  eadStorageLock \
1990: 0a 2b 09 28 74 63 6c 49 6e 74 53 74 75 62 73 50  .+.(tclIntStubsP
19a0: 74 72 2d 3e 74 63 6c 54 68 72 65 61 64 53 74 6f  tr->tclThreadSto
19b0: 72 61 67 65 4c 6f 63 6b 29 20 2f 2a 20 31 38 35  rageLock) /* 185
19c0: 20 2a 2f 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66   */.+#endif.+#if
19d0: 6e 64 65 66 20 54 63 6c 54 68 72 65 61 64 53 74  ndef TclThreadSt
19e0: 6f 72 61 67 65 55 6e 6c 6f 63 6b 0a 2b 23 64 65  orageUnlock.+#de
19f0: 66 69 6e 65 20 54 63 6c 54 68 72 65 61 64 53 74  fine TclThreadSt
1a00: 6f 72 61 67 65 55 6e 6c 6f 63 6b 20 5c 0a 2b 09  orageUnlock \.+.
1a10: 28 74 63 6c 49 6e 74 53 74 75 62 73 50 74 72 2d  (tclIntStubsPtr-
1a20: 3e 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67  >tclThreadStorag
1a30: 65 55 6e 6c 6f 63 6b 29 20 2f 2a 20 31 38 36 20  eUnlock) /* 186 
1a40: 2a 2f 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66 6e  */.+#endif.+#ifn
1a50: 64 65 66 20 54 63 6c 54 68 72 65 61 64 53 74 6f  def TclThreadSto
1a60: 72 61 67 65 50 72 69 6e 74 0a 2b 23 64 65 66 69  ragePrint.+#defi
1a70: 6e 65 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72  ne TclThreadStor
1a80: 61 67 65 50 72 69 6e 74 20 5c 0a 2b 09 28 74 63  agePrint \.+.(tc
1a90: 6c 49 6e 74 53 74 75 62 73 50 74 72 2d 3e 74 63  lIntStubsPtr->tc
1aa0: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 50 72  lThreadStoragePr
1ab0: 69 6e 74 29 20 2f 2a 20 31 38 37 20 2a 2f 0a 2b  int) /* 187 */.+
1ac0: 23 65 6e 64 69 66 0a 2b 23 69 66 6e 64 65 66 20  #endif.+#ifndef 
1ad0: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
1ae0: 47 65 74 48 61 73 68 54 61 62 6c 65 0a 2b 23 64  GetHashTable.+#d
1af0: 65 66 69 6e 65 20 54 63 6c 54 68 72 65 61 64 53  efine TclThreadS
1b00: 74 6f 72 61 67 65 47 65 74 48 61 73 68 54 61 62  torageGetHashTab
1b10: 6c 65 20 5c 0a 2b 09 28 74 63 6c 49 6e 74 53 74  le \.+.(tclIntSt
1b20: 75 62 73 50 74 72 2d 3e 74 63 6c 54 68 72 65 61  ubsPtr->tclThrea
1b30: 64 53 74 6f 72 61 67 65 47 65 74 48 61 73 68 54  dStorageGetHashT
1b40: 61 62 6c 65 29 20 2f 2a 20 31 38 38 20 2a 2f 0a  able) /* 188 */.
1b50: 2b 23 65 6e 64 69 66 0a 2b 23 69 66 6e 64 65 66  +#endif.+#ifndef
1b60: 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67   TclThreadStorag
1b70: 65 49 6e 69 74 0a 2b 23 64 65 66 69 6e 65 20 54  eInit.+#define T
1b80: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 49  clThreadStorageI
1b90: 6e 69 74 20 5c 0a 2b 09 28 74 63 6c 49 6e 74 53  nit \.+.(tclIntS
1ba0: 74 75 62 73 50 74 72 2d 3e 74 63 6c 54 68 72 65  tubsPtr->tclThre
1bb0: 61 64 53 74 6f 72 61 67 65 49 6e 69 74 29 20 2f  adStorageInit) /
1bc0: 2a 20 31 38 39 20 2a 2f 0a 2b 23 65 6e 64 69 66  * 189 */.+#endif
1bd0: 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 54 68 72  .+#ifndef TclThr
1be0: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
1bf0: 79 49 6e 69 74 0a 2b 23 64 65 66 69 6e 65 20 54  yInit.+#define T
1c00: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
1c10: 61 74 61 4b 65 79 49 6e 69 74 20 5c 0a 2b 09 28  ataKeyInit \.+.(
1c20: 74 63 6c 49 6e 74 53 74 75 62 73 50 74 72 2d 3e  tclIntStubsPtr->
1c30: 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  tclThreadStorage
1c40: 44 61 74 61 4b 65 79 49 6e 69 74 29 20 2f 2a 20  DataKeyInit) /* 
1c50: 31 39 30 20 2a 2f 0a 2b 23 65 6e 64 69 66 0a 2b  190 */.+#endif.+
1c60: 23 69 66 6e 64 65 66 20 54 63 6c 54 68 72 65 61  #ifndef TclThrea
1c70: 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 47  dStorageDataKeyG
1c80: 65 74 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c 54  et.+#define TclT
1c90: 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61  hreadStorageData
1ca0: 4b 65 79 47 65 74 20 5c 0a 2b 09 28 74 63 6c 49  KeyGet \.+.(tclI
1cb0: 6e 74 53 74 75 62 73 50 74 72 2d 3e 74 63 6c 54  ntStubsPtr->tclT
1cc0: 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61  hreadStorageData
1cd0: 4b 65 79 47 65 74 29 20 2f 2a 20 31 39 31 20 2a  KeyGet) /* 191 *
1ce0: 2f 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66 6e 64  /.+#endif.+#ifnd
1cf0: 65 66 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72  ef TclThreadStor
1d00: 61 67 65 44 61 74 61 4b 65 79 53 65 74 0a 2b 23  ageDataKeySet.+#
1d10: 64 65 66 69 6e 65 20 54 63 6c 54 68 72 65 61 64  define TclThread
1d20: 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 53 65  StorageDataKeySe
1d30: 74 20 5c 0a 2b 09 28 74 63 6c 49 6e 74 53 74 75  t \.+.(tclIntStu
1d40: 62 73 50 74 72 2d 3e 74 63 6c 54 68 72 65 61 64  bsPtr->tclThread
1d50: 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 53 65  StorageDataKeySe
1d60: 74 29 20 2f 2a 20 31 39 32 20 2a 2f 0a 2b 23 65  t) /* 192 */.+#e
1d70: 6e 64 69 66 0a 2b 23 69 66 6e 64 65 66 20 54 63  ndif.+#ifndef Tc
1d80: 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53  lFinalizeThreadS
1d90: 74 6f 72 61 67 65 54 68 72 65 61 64 0a 2b 23 64  torageThread.+#d
1da0: 65 66 69 6e 65 20 54 63 6c 46 69 6e 61 6c 69 7a  efine TclFinaliz
1db0: 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 54 68  eThreadStorageTh
1dc0: 72 65 61 64 20 5c 0a 2b 09 28 74 63 6c 49 6e 74  read \.+.(tclInt
1dd0: 53 74 75 62 73 50 74 72 2d 3e 74 63 6c 46 69 6e  StubsPtr->tclFin
1de0: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
1df0: 67 65 54 68 72 65 61 64 29 20 2f 2a 20 31 39 33  geThread) /* 193
1e00: 20 2a 2f 0a 2b 23 65 6e 64 69 66 0a 2b 23 69 66   */.+#endif.+#if
1e10: 6e 64 65 66 20 54 63 6c 46 69 6e 61 6c 69 7a 65  ndef TclFinalize
1e20: 54 68 72 65 61 64 53 74 6f 72 61 67 65 0a 2b 23  ThreadStorage.+#
1e30: 64 65 66 69 6e 65 20 54 63 6c 46 69 6e 61 6c 69  define TclFinali
1e40: 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 20  zeThreadStorage 
1e50: 5c 0a 2b 09 28 74 63 6c 49 6e 74 53 74 75 62 73  \.+.(tclIntStubs
1e60: 50 74 72 2d 3e 74 63 6c 46 69 6e 61 6c 69 7a 65  Ptr->tclFinalize
1e70: 54 68 72 65 61 64 53 74 6f 72 61 67 65 29 20 2f  ThreadStorage) /
1e80: 2a 20 31 39 34 20 2a 2f 0a 2b 23 65 6e 64 69 66  * 194 */.+#endif
1e90: 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 46 69 6e  .+#ifndef TclFin
1ea0: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
1eb0: 67 65 44 61 74 61 0a 2b 23 64 65 66 69 6e 65 20  geData.+#define 
1ec0: 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61  TclFinalizeThrea
1ed0: 64 53 74 6f 72 61 67 65 44 61 74 61 20 5c 0a 2b  dStorageData \.+
1ee0: 09 28 74 63 6c 49 6e 74 53 74 75 62 73 50 74 72  .(tclIntStubsPtr
1ef0: 2d 3e 74 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72  ->tclFinalizeThr
1f00: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 29 20  eadStorageData) 
1f10: 2f 2a 20 31 39 35 20 2a 2f 0a 2b 23 65 6e 64 69  /* 195 */.+#endi
1f20: 66 0a 2b 23 69 66 6e 64 65 66 20 54 63 6c 46 69  f.+#ifndef TclFi
1f30: 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72  nalizeThreadStor
1f40: 61 67 65 44 61 74 61 4b 65 79 0a 2b 23 64 65 66  ageDataKey.+#def
1f50: 69 6e 65 20 54 63 6c 46 69 6e 61 6c 69 7a 65 54  ine TclFinalizeT
1f60: 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61  hreadStorageData
1f70: 4b 65 79 20 5c 0a 2b 09 28 74 63 6c 49 6e 74 53  Key \.+.(tclIntS
1f80: 74 75 62 73 50 74 72 2d 3e 74 63 6c 46 69 6e 61  tubsPtr->tclFina
1f90: 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67  lizeThreadStorag
1fa0: 65 44 61 74 61 4b 65 79 29 20 2f 2a 20 31 39 36  eDataKey) /* 196
1fb0: 20 2a 2f 0a 2b 23 65 6e 64 69 66 0a 20 0a 20 23   */.+#endif. . #
1fc0: 65 6e 64 69 66 20 2f 2a 20 64 65 66 69 6e 65 64  endif /* defined
1fd0: 28 55 53 45 5f 54 43 4c 5f 53 54 55 42 53 29 20  (USE_TCL_STUBS) 
1fe0: 26 26 20 21 64 65 66 69 6e 65 64 28 55 53 45 5f  && !defined(USE_
1ff0: 54 43 4c 5f 53 54 55 42 5f 50 52 4f 43 53 29 20  TCL_STUB_PROCS) 
2000: 2a 2f 0a 20 0a 49 6e 64 65 78 3a 20 67 65 6e 65  */. .Index: gene
2010: 72 69 63 2f 74 63 6c 53 74 75 62 49 6e 69 74 2e  ric/tclStubInit.
2020: 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  c.==============
2030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2060: 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a 20  =====.RCS file: 
2070: 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63 6c  /cvsroot/tcl/tcl
2080: 2f 67 65 6e 65 72 69 63 2f 74 63 6c 53 74 75 62  /generic/tclStub
2090: 49 6e 69 74 2e 63 2c 76 0a 72 65 74 72 69 65 76  Init.c,v.retriev
20a0: 69 6e 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 39  ing revision 1.9
20b0: 38 0a 64 69 66 66 20 2d 75 20 2d 72 31 2e 39 38  8.diff -u -r1.98
20c0: 20 74 63 6c 53 74 75 62 49 6e 69 74 2e 63 0a 2d   tclStubInit.c.-
20d0: 2d 2d 20 67 65 6e 65 72 69 63 2f 74 63 6c 53 74  -- generic/tclSt
20e0: 75 62 49 6e 69 74 2e 63 09 37 20 4a 75 6e 20 32  ubInit.c.7 Jun 2
20f0: 30 30 34 20 31 36 3a 34 38 3a 34 35 20 2d 30 30  004 16:48:45 -00
2100: 30 30 09 31 2e 39 38 0a 2b 2b 2b 20 67 65 6e 65  00.1.98.+++ gene
2110: 72 69 63 2f 74 63 6c 53 74 75 62 49 6e 69 74 2e  ric/tclStubInit.
2120: 63 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30  c.23 Jun 2004 20
2130: 3a 32 33 3a 30 37 20 2d 30 30 30 30 0a 40 40 20  :23:07 -0000.@@ 
2140: 2d 32 36 38 2c 36 20 2b 32 36 38 2c 31 39 20 40  -268,6 +268,19 @
2150: 40 0a 20 20 20 20 20 54 63 6c 44 62 4e 65 77 4c  @.     TclDbNewL
2160: 69 73 74 4f 62 6a 44 69 72 65 63 74 2c 20 2f 2a  istObjDirect, /*
2170: 20 31 38 31 20 2a 2f 0a 20 20 20 20 20 54 63 6c   181 */.     Tcl
2180: 70 4c 6f 63 61 6c 74 69 6d 65 2c 20 2f 2a 20 31  pLocaltime, /* 1
2190: 38 32 20 2a 2f 0a 20 20 20 20 20 54 63 6c 70 47  82 */.     TclpG
21a0: 6d 74 69 6d 65 2c 20 2f 2a 20 31 38 33 20 2a 2f  mtime, /* 183 */
21b0: 0a 2b 20 20 20 20 54 63 6c 54 68 72 65 61 64 53  .+    TclThreadS
21c0: 74 6f 72 61 67 65 4c 6f 63 6b 49 6e 69 74 2c 20  torageLockInit, 
21d0: 2f 2a 20 31 38 34 20 2a 2f 0a 2b 20 20 20 20 54  /* 184 */.+    T
21e0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c  clThreadStorageL
21f0: 6f 63 6b 2c 20 2f 2a 20 31 38 35 20 2a 2f 0a 2b  ock, /* 185 */.+
2200: 20 20 20 20 54 63 6c 54 68 72 65 61 64 53 74 6f      TclThreadSto
2210: 72 61 67 65 55 6e 6c 6f 63 6b 2c 20 2f 2a 20 31  rageUnlock, /* 1
2220: 38 36 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 54 68  86 */.+    TclTh
2230: 72 65 61 64 53 74 6f 72 61 67 65 50 72 69 6e 74  readStoragePrint
2240: 2c 20 2f 2a 20 31 38 37 20 2a 2f 0a 2b 20 20 20  , /* 187 */.+   
2250: 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67   TclThreadStorag
2260: 65 47 65 74 48 61 73 68 54 61 62 6c 65 2c 20 2f  eGetHashTable, /
2270: 2a 20 31 38 38 20 2a 2f 0a 2b 20 20 20 20 54 63  * 188 */.+    Tc
2280: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 49 6e  lThreadStorageIn
2290: 69 74 2c 20 2f 2a 20 31 38 39 20 2a 2f 0a 2b 20  it, /* 189 */.+ 
22a0: 20 20 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72     TclThreadStor
22b0: 61 67 65 44 61 74 61 4b 65 79 49 6e 69 74 2c 20  ageDataKeyInit, 
22c0: 2f 2a 20 31 39 30 20 2a 2f 0a 2b 20 20 20 20 54  /* 190 */.+    T
22d0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
22e0: 61 74 61 4b 65 79 47 65 74 2c 20 2f 2a 20 31 39  ataKeyGet, /* 19
22f0: 31 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 54 68 72  1 */.+    TclThr
2300: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
2310: 79 53 65 74 2c 20 2f 2a 20 31 39 32 20 2a 2f 0a  ySet, /* 192 */.
2320: 2b 20 20 20 20 54 63 6c 46 69 6e 61 6c 69 7a 65  +    TclFinalize
2330: 54 68 72 65 61 64 53 74 6f 72 61 67 65 54 68 72  ThreadStorageThr
2340: 65 61 64 2c 20 2f 2a 20 31 39 33 20 2a 2f 0a 2b  ead, /* 193 */.+
2350: 20 20 20 20 54 63 6c 46 69 6e 61 6c 69 7a 65 54      TclFinalizeT
2360: 68 72 65 61 64 53 74 6f 72 61 67 65 2c 20 2f 2a  hreadStorage, /*
2370: 20 31 39 34 20 2a 2f 0a 2b 20 20 20 20 54 63 6c   194 */.+    Tcl
2380: 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74  FinalizeThreadSt
2390: 6f 72 61 67 65 44 61 74 61 2c 20 2f 2a 20 31 39  orageData, /* 19
23a0: 35 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 46 69 6e  5 */.+    TclFin
23b0: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
23c0: 67 65 44 61 74 61 4b 65 79 2c 20 2f 2a 20 31 39  geDataKey, /* 19
23d0: 36 20 2a 2f 0a 20 7d 3b 0a 20 0a 20 54 63 6c 49  6 */. };. . TclI
23e0: 6e 74 50 6c 61 74 53 74 75 62 73 20 74 63 6c 49  ntPlatStubs tclI
23f0: 6e 74 50 6c 61 74 53 74 75 62 73 20 3d 20 7b 0a  ntPlatStubs = {.
2400: 49 6e 64 65 78 3a 20 67 65 6e 65 72 69 63 2f 74  Index: generic/t
2410: 63 6c 54 68 72 65 61 64 2e 63 0a 3d 3d 3d 3d 3d  clThread.c.=====
2420: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2430: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2440: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2450: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 52  ==============.R
2460: 43 53 20 66 69 6c 65 3a 20 2f 63 76 73 72 6f 6f  CS file: /cvsroo
2470: 74 2f 74 63 6c 2f 74 63 6c 2f 67 65 6e 65 72 69  t/tcl/tcl/generi
2480: 63 2f 74 63 6c 54 68 72 65 61 64 2e 63 2c 76 0a  c/tclThread.c,v.
2490: 72 65 74 72 69 65 76 69 6e 67 20 72 65 76 69 73  retrieving revis
24a0: 69 6f 6e 20 31 2e 37 0a 64 69 66 66 20 2d 75 20  ion 1.7.diff -u 
24b0: 2d 72 31 2e 37 20 74 63 6c 54 68 72 65 61 64 2e  -r1.7 tclThread.
24c0: 63 0a 2d 2d 2d 20 67 65 6e 65 72 69 63 2f 74 63  c.--- generic/tc
24d0: 6c 54 68 72 65 61 64 2e 63 09 32 33 20 41 70 72  lThread.c.23 Apr
24e0: 20 32 30 30 34 20 30 37 3a 32 31 3a 33 36 20 2d   2004 07:21:36 -
24f0: 30 30 30 30 09 31 2e 37 0a 2b 2b 2b 20 67 65 6e  0000.1.7.+++ gen
2500: 65 72 69 63 2f 74 63 6c 54 68 72 65 61 64 2e 63  eric/tclThread.c
2510: 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30 3a  .23 Jun 2004 20:
2520: 32 33 3a 30 38 20 2d 30 30 30 30 0a 40 40 20 2d  23:08 -0000.@@ -
2530: 38 39 2c 31 38 20 2b 38 39 2c 33 30 20 40 40 0a  89,18 +89,30 @@.
2540: 20 20 20 20 20 20 2a 2f 0a 20 0a 20 20 20 20 20        */. .     
2550: 69 66 20 28 2a 6b 65 79 50 74 72 20 3d 3d 20 4e  if (*keyPtr == N
2560: 55 4c 4c 29 20 7b 0a 2b 23 69 66 64 65 66 20 55  ULL) {.+#ifdef U
2570: 53 45 5f 54 48 52 45 41 44 5f 53 54 4f 52 41 47  SE_THREAD_STORAG
2580: 45 0a 2b 09 54 63 6c 54 68 72 65 61 64 53 74 6f  E.+.TclThreadSto
2590: 72 61 67 65 44 61 74 61 4b 65 79 49 6e 69 74 28  rageDataKeyInit(
25a0: 6b 65 79 50 74 72 29 3b 0a 2b 23 65 6c 73 65 0a  keyPtr);.+#else.
25b0: 20 09 54 63 6c 70 54 68 72 65 61 64 44 61 74 61   .TclpThreadData
25c0: 4b 65 79 49 6e 69 74 28 6b 65 79 50 74 72 29 3b  KeyInit(keyPtr);
25d0: 0a 2b 23 65 6e 64 69 66 0a 20 20 20 20 20 7d 0a  .+#endif.     }.
25e0: 20 0a 20 20 20 20 20 2f 2a 0a 20 20 20 20 20 20   .     /*.      
25f0: 2a 20 49 6e 69 74 69 61 6c 69 7a 65 20 74 68 65  * Initialize the
2600: 20 6b 65 79 20 66 6f 72 20 74 68 69 73 20 74 68   key for this th
2610: 72 65 61 64 2e 0a 20 20 20 20 20 20 2a 2f 0a 2d  read..      */.-
2620: 0a 2b 23 69 66 64 65 66 20 55 53 45 5f 54 48 52  .+#ifdef USE_THR
2630: 45 41 44 5f 53 54 4f 52 41 47 45 0a 2b 20 20 20  EAD_STORAGE.+   
2640: 20 72 65 73 75 6c 74 20 3d 20 54 63 6c 54 68 72   result = TclThr
2650: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
2660: 79 47 65 74 28 6b 65 79 50 74 72 29 3b 0a 2b 23  yGet(keyPtr);.+#
2670: 65 6c 73 65 0a 20 20 20 20 20 72 65 73 75 6c 74  else.     result
2680: 20 3d 20 54 63 6c 70 54 68 72 65 61 64 44 61 74   = TclpThreadDat
2690: 61 4b 65 79 47 65 74 28 6b 65 79 50 74 72 29 3b  aKeyGet(keyPtr);
26a0: 0a 2b 23 65 6e 64 69 66 0a 2b 0a 20 20 20 20 20  .+#endif.+.     
26b0: 69 66 20 28 72 65 73 75 6c 74 20 3d 3d 20 4e 55  if (result == NU
26c0: 4c 4c 29 20 7b 0a 20 09 72 65 73 75 6c 74 20 20  LL) {. .result  
26d0: 3d 20 28 56 4f 49 44 20 2a 29 63 6b 61 6c 6c 6f  = (VOID *)ckallo
26e0: 63 28 28 73 69 7a 65 5f 74 29 73 69 7a 65 29 3b  c((size_t)size);
26f0: 0a 20 09 6d 65 6d 73 65 74 28 72 65 73 75 6c 74  . .memset(result
2700: 2c 20 30 2c 20 28 73 69 7a 65 5f 74 29 73 69 7a  , 0, (size_t)siz
2710: 65 29 3b 0a 2b 23 69 66 64 65 66 20 55 53 45 5f  e);.+#ifdef USE_
2720: 54 48 52 45 41 44 5f 53 54 4f 52 41 47 45 0a 2b  THREAD_STORAGE.+
2730: 20 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61    TclThreadStora
2740: 67 65 44 61 74 61 4b 65 79 53 65 74 28 6b 65 79  geDataKeySet(key
2750: 50 74 72 2c 20 72 65 73 75 6c 74 29 3b 0a 2b 23  Ptr, result);.+#
2760: 65 6c 73 65 0a 20 09 54 63 6c 70 54 68 72 65 61  else. .TclpThrea
2770: 64 44 61 74 61 4b 65 79 53 65 74 28 6b 65 79 50  dDataKeySet(keyP
2780: 74 72 2c 20 72 65 73 75 6c 74 29 3b 0a 2b 23 65  tr, result);.+#e
2790: 6e 64 69 66 0a 20 20 20 20 20 7d 0a 20 23 65 6c  ndif.     }. #el
27a0: 73 65 0a 20 20 20 20 20 69 66 20 28 2a 6b 65 79  se.     if (*key
27b0: 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 40  Ptr == NULL) {.@
27c0: 40 20 2d 31 33 37 2c 37 20 2b 31 34 39 2c 31 31  @ -137,7 +149,11
27d0: 20 40 40 0a 20 09 09 09 09 20 2a 20 72 65 61 6c   @@. .... * real
27e0: 6c 79 20 28 70 74 68 72 65 61 64 5f 6b 65 79 5f  ly (pthread_key_
27f0: 74 20 2a 2a 29 20 2a 2f 0a 20 7b 0a 20 23 69 66  t **) */. {. #if
2800: 64 65 66 20 54 43 4c 5f 54 48 52 45 41 44 53 0a  def TCL_THREADS.
2810: 2b 23 69 66 64 65 66 20 55 53 45 5f 54 48 52 45  +#ifdef USE_THRE
2820: 41 44 5f 53 54 4f 52 41 47 45 0a 2b 20 20 20 20  AD_STORAGE.+    
2830: 72 65 74 75 72 6e 20 28 56 4f 49 44 20 2a 29 54  return (VOID *)T
2840: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
2850: 61 74 61 4b 65 79 47 65 74 28 6b 65 79 50 74 72  ataKeyGet(keyPtr
2860: 29 3b 0a 2b 23 65 6c 73 65 0a 20 20 20 20 20 72  );.+#else.     r
2870: 65 74 75 72 6e 20 28 56 4f 49 44 20 2a 29 54 63  eturn (VOID *)Tc
2880: 6c 70 54 68 72 65 61 64 44 61 74 61 4b 65 79 47  lpThreadDataKeyG
2890: 65 74 28 6b 65 79 50 74 72 29 3b 0a 2b 23 65 6e  et(keyPtr);.+#en
28a0: 64 69 66 0a 20 23 65 6c 73 65 0a 20 20 20 20 20  dif. #else.     
28b0: 63 68 61 72 20 2a 72 65 73 75 6c 74 20 3d 20 2a  char *result = *
28c0: 28 63 68 61 72 20 2a 2a 29 6b 65 79 50 74 72 3b  (char **)keyPtr;
28d0: 0a 20 20 20 20 20 72 65 74 75 72 6e 20 28 56 4f  .     return (VO
28e0: 49 44 20 2a 29 72 65 73 75 6c 74 3b 0a 40 40 20  ID *)result;.@@ 
28f0: 2d 31 36 39 2c 39 20 2b 31 38 35 2c 31 37 20 40  -169,9 +185,17 @
2900: 40 0a 20 7b 0a 20 23 69 66 64 65 66 20 54 43 4c  @. {. #ifdef TCL
2910: 5f 54 48 52 45 41 44 53 0a 20 20 20 20 20 69 66  _THREADS.     if
2920: 20 28 2a 6b 65 79 50 74 72 20 3d 3d 20 4e 55 4c   (*keyPtr == NUL
2930: 4c 29 20 7b 0a 2b 23 69 66 64 65 66 20 55 53 45  L) {.+#ifdef USE
2940: 5f 54 48 52 45 41 44 5f 53 54 4f 52 41 47 45 0a  _THREAD_STORAGE.
2950: 2b 09 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61  +.TclThreadStora
2960: 67 65 44 61 74 61 4b 65 79 49 6e 69 74 28 6b 65  geDataKeyInit(ke
2970: 79 50 74 72 29 3b 0a 2b 23 65 6c 73 65 0a 20 09  yPtr);.+#else. .
2980: 54 63 6c 70 54 68 72 65 61 64 44 61 74 61 4b 65  TclpThreadDataKe
2990: 79 49 6e 69 74 28 6b 65 79 50 74 72 29 3b 0a 2b  yInit(keyPtr);.+
29a0: 23 65 6e 64 69 66 0a 20 20 20 20 20 7d 0a 2b 23  #endif.     }.+#
29b0: 69 66 64 65 66 20 55 53 45 5f 54 48 52 45 41 44  ifdef USE_THREAD
29c0: 5f 53 54 4f 52 41 47 45 0a 2b 20 20 20 20 54 63  _STORAGE.+    Tc
29d0: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61  lThreadStorageDa
29e0: 74 61 4b 65 79 53 65 74 28 6b 65 79 50 74 72 2c  taKeySet(keyPtr,
29f0: 20 64 61 74 61 29 3b 0a 2b 23 65 6c 73 65 0a 20   data);.+#else. 
2a00: 20 20 20 20 54 63 6c 70 54 68 72 65 61 64 44 61      TclpThreadDa
2a10: 74 61 4b 65 79 53 65 74 28 6b 65 79 50 74 72 2c  taKeySet(keyPtr,
2a20: 20 64 61 74 61 29 3b 0a 2b 23 65 6e 64 69 66 0a   data);.+#endif.
2a30: 20 23 65 6c 73 65 0a 20 20 20 20 20 2a 6b 65 79   #else.     *key
2a40: 50 74 72 20 3d 20 28 54 63 6c 5f 54 68 72 65 61  Ptr = (Tcl_Threa
2a50: 64 44 61 74 61 4b 65 79 29 64 61 74 61 3b 0a 20  dDataKey)data;. 
2a60: 23 65 6e 64 69 66 20 2f 2a 20 54 43 4c 5f 54 48  #endif /* TCL_TH
2a70: 52 45 41 44 53 20 2a 2f 0a 40 40 20 2d 34 30 39  READS */.@@ -409
2a80: 2c 37 20 2b 34 33 33 2c 31 31 20 40 40 0a 20 20  ,7 +433,11 @@.  
2a90: 20 20 20 66 6f 72 20 28 69 3d 30 20 3b 20 69 3c     for (i=0 ; i<
2aa0: 6b 65 79 52 65 63 6f 72 64 2e 6e 75 6d 20 3b 20  keyRecord.num ; 
2ab0: 69 2b 2b 29 20 7b 0a 20 09 6b 65 79 50 74 72 20  i++) {. .keyPtr 
2ac0: 3d 20 28 54 63 6c 5f 54 68 72 65 61 64 44 61 74  = (Tcl_ThreadDat
2ad0: 61 4b 65 79 20 2a 29 20 6b 65 79 52 65 63 6f 72  aKey *) keyRecor
2ae0: 64 2e 6c 69 73 74 5b 69 5d 3b 0a 20 23 69 66 64  d.list[i];. #ifd
2af0: 65 66 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 2b  ef TCL_THREADS.+
2b00: 23 69 66 64 65 66 20 55 53 45 5f 54 48 52 45 41  #ifdef USE_THREA
2b10: 44 5f 53 54 4f 52 41 47 45 0a 2b 20 20 54 63 6c  D_STORAGE.+  Tcl
2b20: 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53 74  FinalizeThreadSt
2b30: 6f 72 61 67 65 44 61 74 61 28 6b 65 79 50 74 72  orageData(keyPtr
2b40: 29 3b 0a 2b 23 65 6c 73 65 0a 20 09 54 63 6c 70  );.+#else. .Tclp
2b50: 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 44 61  FinalizeThreadDa
2b60: 74 61 28 6b 65 79 50 74 72 29 3b 0a 2b 23 65 6e  ta(keyPtr);.+#en
2b70: 64 69 66 0a 20 23 65 6c 73 65 0a 20 09 69 66 20  dif. #else. .if 
2b80: 28 2a 6b 65 79 50 74 72 20 21 3d 20 4e 55 4c 4c  (*keyPtr != NULL
2b90: 29 20 7b 0a 20 09 20 20 20 20 63 6b 66 72 65 65  ) {. .    ckfree
2ba0: 28 28 63 68 61 72 20 2a 29 2a 6b 65 79 50 74 72  ((char *)*keyPtr
2bb0: 29 3b 0a 40 40 20 2d 34 34 39 2c 37 20 2b 34 37  );.@@ -449,7 +47
2bc0: 37 2c 31 31 20 40 40 0a 20 20 20 20 20 54 63 6c  7,11 @@.     Tcl
2bd0: 70 4d 61 73 74 65 72 4c 6f 63 6b 28 29 3b 0a 20  pMasterLock();. 
2be0: 20 20 20 20 66 6f 72 20 28 69 3d 30 20 3b 20 69      for (i=0 ; i
2bf0: 3c 6b 65 79 52 65 63 6f 72 64 2e 6e 75 6d 20 3b  <keyRecord.num ;
2c00: 20 69 2b 2b 29 20 7b 0a 20 09 6b 65 79 50 74 72   i++) {. .keyPtr
2c10: 20 3d 20 28 54 63 6c 5f 54 68 72 65 61 64 44 61   = (Tcl_ThreadDa
2c20: 74 61 4b 65 79 20 2a 29 6b 65 79 52 65 63 6f 72  taKey *)keyRecor
2c30: 64 2e 6c 69 73 74 5b 69 5d 3b 0a 2b 23 69 66 64  d.list[i];.+#ifd
2c40: 65 66 20 55 53 45 5f 54 48 52 45 41 44 5f 53 54  ef USE_THREAD_ST
2c50: 4f 52 41 47 45 0a 2b 20 20 54 63 6c 46 69 6e 61  ORAGE.+  TclFina
2c60: 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67  lizeThreadStorag
2c70: 65 44 61 74 61 4b 65 79 28 6b 65 79 50 74 72 29  eDataKey(keyPtr)
2c80: 3b 0a 2b 23 65 6c 73 65 0a 20 09 54 63 6c 70 46  ;.+#else. .TclpF
2c90: 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 44 61 74  inalizeThreadDat
2ca0: 61 4b 65 79 28 6b 65 79 50 74 72 29 3b 0a 2b 23  aKey(keyPtr);.+#
2cb0: 65 6e 64 69 66 0a 20 20 20 20 20 7d 0a 20 20 20  endif.     }.   
2cc0: 20 20 69 66 20 28 6b 65 79 52 65 63 6f 72 64 2e    if (keyRecord.
2cd0: 6c 69 73 74 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a  list != NULL) {.
2ce0: 20 09 63 6b 66 72 65 65 28 28 63 68 61 72 20 2a   .ckfree((char *
2cf0: 29 6b 65 79 52 65 63 6f 72 64 2e 6c 69 73 74 29  )keyRecord.list)
2d00: 3b 0a 40 40 20 2d 34 35 38 2c 36 20 2b 34 39 30  ;.@@ -458,6 +490
2d10: 2c 31 31 20 40 40 0a 20 20 20 20 20 6b 65 79 52  ,11 @@.     keyR
2d20: 65 63 6f 72 64 2e 6d 61 78 20 3d 20 30 3b 0a 20  ecord.max = 0;. 
2d30: 20 20 20 20 6b 65 79 52 65 63 6f 72 64 2e 6e 75      keyRecord.nu
2d40: 6d 20 3d 20 30 3b 0a 20 0a 2b 23 69 66 64 65 66  m = 0;. .+#ifdef
2d50: 20 55 53 45 5f 54 48 52 45 41 44 5f 53 54 4f 52   USE_THREAD_STOR
2d60: 41 47 45 0a 2b 20 20 20 20 2f 2a 20 63 61 6c 6c  AGE.+    /* call
2d70: 20 70 6c 61 74 66 6f 72 6d 20 73 70 65 63 69 66   platform specif
2d80: 69 63 20 74 68 72 65 61 64 20 73 74 6f 72 61 67  ic thread storag
2d90: 65 20 6d 61 73 74 65 72 20 63 6c 65 61 6e 75 70  e master cleanup
2da0: 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 46 69 6e 61   */.+    TclFina
2db0: 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61 67  lizeThreadStorag
2dc0: 65 28 29 3b 0a 2b 23 65 6e 64 69 66 0a 2b 0a 20  e();.+#endif.+. 
2dd0: 20 20 20 20 66 6f 72 20 28 69 3d 30 20 3b 20 69      for (i=0 ; i
2de0: 3c 6d 75 74 65 78 52 65 63 6f 72 64 2e 6e 75 6d  <mutexRecord.num
2df0: 20 3b 20 69 2b 2b 29 20 7b 0a 20 09 6d 75 74 65   ; i++) {. .mute
2e00: 78 50 74 72 20 3d 20 28 54 63 6c 5f 4d 75 74 65  xPtr = (Tcl_Mute
2e10: 78 20 2a 29 6d 75 74 65 78 52 65 63 6f 72 64 2e  x *)mutexRecord.
2e20: 6c 69 73 74 5b 69 5d 3b 0a 20 09 69 66 20 28 6d  list[i];. .if (m
2e30: 75 74 65 78 50 74 72 20 21 3d 20 4e 55 4c 4c 29  utexPtr != NULL)
2e40: 20 7b 0a 49 6e 64 65 78 3a 20 67 65 6e 65 72 69   {.Index: generi
2e50: 63 2f 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61  c/tclThreadStora
2e60: 67 65 2e 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ge.c.===========
2e70: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2e80: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2e90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
2ea0: 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c  ========.RCS fil
2eb0: 65 3a 20 67 65 6e 65 72 69 63 2f 74 63 6c 54 68  e: generic/tclTh
2ec0: 72 65 61 64 53 74 6f 72 61 67 65 2e 63 0a 64 69  readStorage.c.di
2ed0: 66 66 20 2d 4e 20 67 65 6e 65 72 69 63 2f 74 63  ff -N generic/tc
2ee0: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 2e 63  lThreadStorage.c
2ef0: 0a 2d 2d 2d 20 2f 64 65 76 2f 6e 75 6c 6c 09 31  .--- /dev/null.1
2f00: 20 4a 61 6e 20 31 39 37 30 20 30 30 3a 30 30 3a   Jan 1970 00:00:
2f10: 30 30 20 2d 30 30 30 30 0a 2b 2b 2b 20 67 65 6e  00 -0000.+++ gen
2f20: 65 72 69 63 2f 74 63 6c 54 68 72 65 61 64 53 74  eric/tclThreadSt
2f30: 6f 72 61 67 65 2e 63 09 32 33 20 4a 75 6e 20 32  orage.c.23 Jun 2
2f40: 30 30 34 20 32 30 3a 32 33 3a 30 38 20 2d 30 30  004 20:23:08 -00
2f50: 30 30 0a 40 40 20 2d 30 2c 30 20 2b 31 2c 31 30  00.@@ -0,0 +1,10
2f60: 31 33 20 40 40 0a 2b 2f 2a 0a 2b 20 2a 20 74 63  13 @@.+/*.+ * tc
2f70: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 2e 63  lThreadStorage.c
2f80: 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 09 54 68 69 73   --.+ *.+ *.This
2f90: 20 66 69 6c 65 20 69 6d 70 6c 65 6d 65 6e 74 73   file implements
2fa0: 20 70 6c 61 74 66 6f 72 6d 20 69 6e 64 65 70 65   platform indepe
2fb0: 6e 64 65 6e 74 20 74 68 72 65 61 64 20 73 74 6f  ndent thread sto
2fc0: 72 61 67 65 20 6f 70 65 72 61 74 69 6f 6e 73 2e  rage operations.
2fd0: 0a 2b 20 2a 0a 2b 20 2a 20 43 6f 70 79 72 69 67  .+ *.+ * Copyrig
2fe0: 68 74 20 28 63 29 20 32 30 30 33 2d 32 30 30 34  ht (c) 2003-2004
2ff0: 20 62 79 20 4a 6f 65 20 4d 69 73 74 61 63 68 6b   by Joe Mistachk
3000: 69 6e 0a 2b 20 2a 0a 2b 20 2a 20 53 65 65 20 74  in.+ *.+ * See t
3010: 68 65 20 66 69 6c 65 20 22 6c 69 63 65 6e 73 65  he file "license
3020: 2e 74 65 72 6d 73 22 20 66 6f 72 20 69 6e 66 6f  .terms" for info
3030: 72 6d 61 74 69 6f 6e 20 6f 6e 20 75 73 61 67 65  rmation on usage
3040: 20 61 6e 64 20 72 65 64 69 73 74 72 69 62 75 74   and redistribut
3050: 69 6f 6e 0a 2b 20 2a 20 6f 66 20 74 68 69 73 20  ion.+ * of this 
3060: 66 69 6c 65 2c 20 61 6e 64 20 66 6f 72 20 61 20  file, and for a 
3070: 44 49 53 43 4c 41 49 4d 45 52 20 4f 46 20 41 4c  DISCLAIMER OF AL
3080: 4c 20 57 41 52 52 41 4e 54 49 45 53 2e 0a 2b 20  L WARRANTIES..+ 
3090: 2a 0a 2b 20 2a 20 52 43 53 3a 20 40 28 23 29 20  *.+ * RCS: @(#) 
30a0: 24 49 64 24 0a 2b 20 2a 2f 0a 2b 0a 2b 23 69 6e  $Id$.+ */.+.+#in
30b0: 63 6c 75 64 65 20 22 74 63 6c 49 6e 74 2e 68 22  clude "tclInt.h"
30c0: 0a 2b 0a 2b 23 69 66 20 64 65 66 69 6e 65 64 28  .+.+#if defined(
30d0: 54 43 4c 5f 54 48 52 45 41 44 53 29 20 26 26 20  TCL_THREADS) && 
30e0: 64 65 66 69 6e 65 64 28 55 53 45 5f 54 48 52 45  defined(USE_THRE
30f0: 41 44 5f 53 54 4f 52 41 47 45 29 0a 2b 0a 2b 2f  AD_STORAGE).+.+/
3100: 2a 0a 2b 20 2a 20 54 68 69 73 20 69 73 20 74 68  *.+ * This is th
3110: 65 20 74 68 72 65 61 64 20 73 74 6f 72 61 67 65  e thread storage
3120: 20 63 61 63 68 65 20 61 72 72 61 79 20 61 6e 64   cache array and
3130: 20 69 74 27 73 20 61 63 63 6f 6d 70 61 6e 79 69   it's accompanyi
3140: 6e 67 20 6d 75 74 65 78 2e 0a 2b 20 2a 20 54 68  ng mutex..+ * Th
3150: 65 20 65 6c 65 6d 65 6e 74 73 20 61 72 65 20 70  e elements are p
3160: 61 69 72 73 20 6f 66 20 74 68 72 65 61 64 20 49  airs of thread I
3170: 64 20 61 6e 64 20 61 6e 20 61 73 73 6f 63 69 61  d and an associa
3180: 74 65 64 20 68 61 73 68 20 74 61 62 6c 65 0a 2b  ted hash table.+
3190: 20 2a 20 70 6f 69 6e 74 65 72 3b 20 74 68 65 20   * pointer; the 
31a0: 68 61 73 68 20 74 61 62 6c 65 20 62 65 69 6e 67  hash table being
31b0: 20 70 6f 69 6e 74 65 64 20 74 6f 20 63 6f 6e 74   pointed to cont
31c0: 61 69 6e 73 20 74 68 65 20 74 68 72 65 61 64 20  ains the thread 
31d0: 73 74 6f 72 61 67 65 0a 2b 20 2a 20 66 6f 72 20  storage.+ * for 
31e0: 69 74 27 73 20 61 73 73 6f 63 69 61 74 65 64 20  it's associated 
31f0: 74 68 72 65 61 64 2e 20 54 68 65 20 70 75 72 70  thread. The purp
3200: 6f 73 65 20 6f 66 20 74 68 69 73 20 63 61 63 68  ose of this cach
3210: 65 20 69 73 20 74 6f 20 6d 69 6e 69 6d 69 7a 65  e is to minimize
3220: 0a 2b 20 2a 20 74 68 65 20 6e 75 6d 62 65 72 20  .+ * the number 
3230: 6f 66 20 68 61 73 68 20 74 61 62 6c 65 20 6c 6f  of hash table lo
3240: 6f 6b 75 70 73 20 69 6e 20 74 68 65 20 6d 61 73  okups in the mas
3250: 74 65 72 20 74 68 72 65 61 64 20 73 74 6f 72 61  ter thread stora
3260: 67 65 20 68 61 73 68 0a 2b 20 2a 20 74 61 62 6c  ge hash.+ * tabl
3270: 65 2e 0a 2b 20 2a 2f 0a 2b 73 74 61 74 69 63 20  e..+ */.+static 
3280: 54 63 6c 5f 4d 75 74 65 78 20 74 68 72 65 61 64  Tcl_Mutex thread
3290: 53 74 6f 72 61 67 65 4c 6f 63 6b 3b 0a 2b 0a 2b  StorageLock;.+.+
32a0: 2f 2a 0a 2b 20 2a 20 54 68 69 73 20 69 73 20 74  /*.+ * This is t
32b0: 68 65 20 73 74 72 75 63 74 20 75 73 65 64 20 66  he struct used f
32c0: 6f 72 20 61 20 74 68 72 65 61 64 20 73 74 6f 72  or a thread stor
32d0: 61 67 65 20 63 61 63 68 65 20 73 6c 6f 74 2e 20  age cache slot. 
32e0: 49 74 20 63 6f 6e 74 61 69 6e 73 0a 2b 20 2a 20  It contains.+ * 
32f0: 74 68 65 20 6f 77 6e 69 6e 67 20 74 68 72 65 61  the owning threa
3300: 64 20 49 64 20 61 6e 64 20 74 68 65 20 61 73 73  d Id and the ass
3310: 6f 63 69 61 74 65 64 20 68 61 73 68 20 74 61 62  ociated hash tab
3320: 6c 65 20 70 6f 69 6e 74 65 72 2e 0a 2b 20 2a 2f  le pointer..+ */
3330: 0a 2b 74 79 70 65 64 65 66 20 73 74 72 75 63 74  .+typedef struct
3340: 20 54 68 72 65 61 64 53 74 6f 72 61 67 65 20 7b   ThreadStorage {
3350: 0a 2b 20 20 54 63 6c 5f 54 68 72 65 61 64 49 64  .+  Tcl_ThreadId
3360: 20 69 64 3b 20 20 20 20 20 20 20 20 20 20 20 20   id;            
3370: 20 2f 2a 20 74 68 65 20 6f 77 6e 69 6e 67 20 74   /* the owning t
3380: 68 72 65 61 64 20 69 64 20 2a 2f 0a 2b 20 20 54  hread id */.+  T
3390: 63 6c 5f 48 61 73 68 54 61 62 6c 65 20 2a 68 61  cl_HashTable *ha
33a0: 73 68 54 61 62 6c 65 50 74 72 3b 20 2f 2a 20 74  shTablePtr; /* t
33b0: 68 65 20 68 61 73 68 20 74 61 62 6c 65 20 66 6f  he hash table fo
33c0: 72 20 74 68 65 20 74 68 72 65 61 64 20 2a 2f 0a  r the thread */.
33d0: 2b 7d 20 54 68 72 65 61 64 53 74 6f 72 61 67 65  +} ThreadStorage
33e0: 3b 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68 65 73  ;.+.+/*.+ * Thes
33f0: 65 20 61 72 65 20 74 68 65 20 70 72 6f 74 6f 74  e are the protot
3400: 79 70 65 73 20 66 6f 72 20 74 68 65 20 63 75 73  ypes for the cus
3410: 74 6f 6d 20 68 61 73 68 20 74 61 62 6c 65 20 61  tom hash table a
3420: 6c 6c 6f 63 61 74 69 6f 6e 0a 2b 20 2a 20 66 75  llocation.+ * fu
3430: 6e 63 74 69 6f 6e 73 20 75 73 65 64 20 62 79 20  nctions used by 
3440: 74 68 65 20 74 68 72 65 61 64 20 73 74 6f 72 61  the thread stora
3450: 67 65 20 73 75 62 73 79 73 74 65 6d 2e 0a 2b 20  ge subsystem..+ 
3460: 2a 2f 0a 2b 73 74 61 74 69 63 20 54 63 6c 5f 48  */.+static Tcl_H
3470: 61 73 68 45 6e 74 72 79 20 2a 09 41 6c 6c 6f 63  ashEntry *.Alloc
3480: 54 68 72 65 61 64 53 74 6f 72 61 67 65 45 6e 74  ThreadStorageEnt
3490: 72 79 20 5f 41 4e 53 49 5f 41 52 47 53 5f 28 28  ry _ANSI_ARGS_((
34a0: 0a 2b 09 09 09 20 20 20 20 54 63 6c 5f 48 61 73  .+...    Tcl_Has
34b0: 68 54 61 62 6c 65 20 2a 74 61 62 6c 65 50 74 72  hTable *tablePtr
34c0: 2c 20 76 6f 69 64 20 2a 6b 65 79 50 74 72 29 29  , void *keyPtr))
34d0: 3b 0a 2b 73 74 61 74 69 63 20 76 6f 69 64 09 09  ;.+static void..
34e0: 46 72 65 65 54 68 72 65 61 64 53 74 6f 72 61 67  FreeThreadStorag
34f0: 65 45 6e 74 72 79 20 5f 41 4e 53 49 5f 41 52 47  eEntry _ANSI_ARG
3500: 53 5f 28 28 0a 2b 09 09 09 20 20 20 20 54 63 6c  S_((.+...    Tcl
3510: 5f 48 61 73 68 45 6e 74 72 79 20 2a 68 50 74 72  _HashEntry *hPtr
3520: 29 29 3b 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68  ));.+.+/*.+ * Th
3530: 69 73 20 69 73 20 74 68 65 20 68 61 73 68 20 6b  is is the hash k
3540: 65 79 20 74 79 70 65 20 66 6f 72 20 74 68 72 65  ey type for thre
3550: 61 64 20 73 74 6f 72 61 67 65 2e 20 57 65 20 4d  ad storage. We M
3560: 55 53 54 20 75 73 65 20 74 68 69 73 20 69 6e 0a  UST use this in.
3570: 2b 20 2a 20 63 6f 6d 62 69 6e 61 74 69 6f 6e 20  + * combination 
3580: 77 69 74 68 20 74 68 65 20 6e 65 77 20 68 61 73  with the new has
3590: 68 20 6b 65 79 20 74 79 70 65 20 66 6c 61 67 20  h key type flag 
35a0: 54 43 4c 5f 48 41 53 48 5f 4b 45 59 5f 53 59 53  TCL_HASH_KEY_SYS
35b0: 54 45 4d 5f 48 41 53 48 0a 2b 20 2a 20 62 65 63  TEM_HASH.+ * bec
35c0: 61 75 73 65 20 74 68 65 73 65 20 68 61 73 68 20  ause these hash 
35d0: 74 61 62 6c 65 73 20 4d 41 59 20 62 65 20 75 73  tables MAY be us
35e0: 65 64 20 62 79 20 74 68 65 20 74 68 72 65 61 64  ed by the thread
35f0: 65 64 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61  ed memory alloca
3600: 74 6f 72 2e 0a 2b 20 2a 2f 0a 2b 54 63 6c 5f 48  tor..+ */.+Tcl_H
3610: 61 73 68 4b 65 79 54 79 70 65 20 74 63 6c 54 68  ashKeyType tclTh
3620: 72 65 61 64 53 74 6f 72 61 67 65 48 61 73 68 4b  readStorageHashK
3630: 65 79 54 79 70 65 20 3d 20 7b 0a 2b 20 20 20 20  eyType = {.+    
3640: 54 43 4c 5f 48 41 53 48 5f 4b 45 59 5f 54 59 50  TCL_HASH_KEY_TYP
3650: 45 5f 56 45 52 53 49 4f 4e 2c 20 20 20 20 20 20  E_VERSION,      
3660: 20 20 20 20 2f 2a 20 76 65 72 73 69 6f 6e 20 2a      /* version *
3670: 2f 0a 2b 20 20 20 20 54 43 4c 5f 48 41 53 48 5f  /.+    TCL_HASH_
3680: 4b 45 59 5f 53 59 53 54 45 4d 5f 48 41 53 48 2c  KEY_SYSTEM_HASH,
3690: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 66 6c             /* fl
36a0: 61 67 73 20 2a 2f 0a 2b 20 20 20 20 4e 55 4c 4c  ags */.+    NULL
36b0: 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  ,               
36c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
36d0: 2f 2a 20 68 61 73 68 4b 65 79 50 72 6f 63 20 2a  /* hashKeyProc *
36e0: 2f 0a 2b 20 20 20 20 4e 55 4c 4c 2c 20 20 20 20  /.+    NULL,    
36f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
3700: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 63 6f             /* co
3710: 6d 70 61 72 65 4b 65 79 73 50 72 6f 63 20 2a 2f  mpareKeysProc */
3720: 0a 2b 20 20 20 20 41 6c 6c 6f 63 54 68 72 65 61  .+    AllocThrea
3730: 64 53 74 6f 72 61 67 65 45 6e 74 72 79 2c 20 20  dStorageEntry,  
3740: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 61 6c 6c            /* all
3750: 6f 63 45 6e 74 72 79 50 72 6f 63 20 2a 2f 0a 2b  ocEntryProc */.+
3760: 20 20 20 20 46 72 65 65 54 68 72 65 61 64 53 74      FreeThreadSt
3770: 6f 72 61 67 65 45 6e 74 72 79 20 20 20 20 20 20  orageEntry      
3780: 20 20 20 20 20 20 20 20 2f 2a 20 66 72 65 65 45          /* freeE
3790: 6e 74 72 79 50 72 6f 63 20 2a 2f 0a 2b 7d 3b 0a  ntryProc */.+};.
37a0: 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68 69 73 20 69  +.+/*.+ * This i
37b0: 73 20 61 6e 20 69 6e 76 61 6c 69 64 20 74 68 72  s an invalid thr
37c0: 65 61 64 20 76 61 6c 75 65 2e 0a 2b 20 2a 2f 0a  ead value..+ */.
37d0: 2b 23 64 65 66 69 6e 65 20 53 54 4f 52 41 47 45  +#define STORAGE
37e0: 5f 49 4e 56 41 4c 49 44 5f 54 48 52 45 41 44 20  _INVALID_THREAD 
37f0: 20 28 54 63 6c 5f 54 68 72 65 61 64 49 64 29 30   (Tcl_ThreadId)0
3800: 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68 69 73 20  .+.+/*.+ * This 
3810: 69 73 20 74 68 65 20 76 61 6c 75 65 20 66 6f 72  is the value for
3820: 20 61 6e 20 69 6e 76 61 6c 69 64 20 74 68 72 65   an invalid thre
3830: 61 64 20 73 74 6f 72 61 67 65 20 6b 65 79 2e 0a  ad storage key..
3840: 2b 20 2a 2f 0a 2b 23 64 65 66 69 6e 65 20 53 54  + */.+#define ST
3850: 4f 52 41 47 45 5f 49 4e 56 41 4c 49 44 5f 4b 45  ORAGE_INVALID_KE
3860: 59 20 20 20 20 20 30 0a 2b 0a 2b 2f 2a 0a 2b 20  Y     0.+.+/*.+ 
3870: 2a 20 54 68 69 73 20 69 73 20 74 68 65 20 66 69  * This is the fi
3880: 72 73 74 20 76 61 6c 69 64 20 6b 65 79 20 66 6f  rst valid key fo
3890: 72 20 75 73 65 20 62 79 20 65 78 74 65 72 6e 61  r use by externa
38a0: 6c 20 63 61 6c 6c 65 72 73 2e 0a 2b 20 2a 20 41  l callers..+ * A
38b0: 6c 6c 20 74 68 65 20 76 61 6c 75 65 73 20 62 65  ll the values be
38c0: 6c 6f 77 20 74 68 69 73 20 61 72 65 20 52 45 53  low this are RES
38d0: 45 52 56 45 44 20 66 6f 72 20 66 75 74 75 72 65  ERVED for future
38e0: 20 75 73 65 2e 0a 2b 20 2a 2f 0a 2b 23 64 65 66   use..+ */.+#def
38f0: 69 6e 65 20 53 54 4f 52 41 47 45 5f 46 49 52 53  ine STORAGE_FIRS
3900: 54 5f 4b 45 59 20 20 20 20 20 20 20 31 30 31 0a  T_KEY       101.
3910: 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68 69 73 20 69  +.+/*.+ * This i
3920: 73 20 74 68 65 20 64 65 66 61 75 6c 74 20 6e 75  s the default nu
3930: 6d 62 65 72 20 6f 66 20 74 68 72 65 61 64 20 73  mber of thread s
3940: 74 6f 72 61 67 65 20 63 61 63 68 65 20 73 6c 6f  torage cache slo
3950: 74 73 2e 0a 2b 20 2a 20 54 68 69 73 20 64 65 66  ts..+ * This def
3960: 69 6e 65 20 6d 61 79 20 6e 65 65 64 20 74 6f 20  ine may need to 
3970: 62 65 20 66 69 6e 65 20 74 75 6e 65 64 20 66 6f  be fine tuned fo
3980: 72 20 6d 61 78 69 6d 75 6d 20 70 65 72 66 6f 72  r maximum perfor
3990: 6d 61 6e 63 65 2e 0a 2b 20 2a 2f 0a 2b 23 64 65  mance..+ */.+#de
39a0: 66 69 6e 65 20 53 54 4f 52 41 47 45 5f 43 41 43  fine STORAGE_CAC
39b0: 48 45 5f 53 4c 4f 54 53 20 20 20 20 20 39 37 0a  HE_SLOTS     97.
39c0: 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68 69 73 20 69  +.+/*.+ * This i
39d0: 73 20 74 68 65 20 6d 61 73 74 65 72 20 74 68 72  s the master thr
39e0: 65 61 64 20 73 74 6f 72 61 67 65 20 68 61 73 68  ead storage hash
39f0: 20 74 61 62 6c 65 2e 20 49 74 20 69 73 20 6b 65   table. It is ke
3a00: 79 65 64 20 6f 6e 0a 2b 20 2a 20 74 68 72 65 61  yed on.+ * threa
3a10: 64 20 49 64 20 61 6e 64 20 63 6f 6e 74 61 69 6e  d Id and contain
3a20: 73 20 76 61 6c 75 65 73 20 74 68 61 74 20 61 72  s values that ar
3a30: 65 20 68 61 73 68 20 74 61 62 6c 65 73 20 66 6f  e hash tables fo
3a40: 72 20 65 61 63 68 20 74 68 72 65 61 64 2e 0a 2b  r each thread..+
3a50: 20 2a 20 54 68 65 20 74 68 72 65 61 64 20 73 70   * The thread sp
3a60: 65 63 69 66 69 63 20 68 61 73 68 20 74 61 62 6c  ecific hash tabl
3a70: 65 73 20 63 6f 6e 74 61 69 6e 20 74 68 65 20 61  es contain the a
3a80: 63 74 75 61 6c 20 74 68 72 65 61 64 20 73 74 6f  ctual thread sto
3a90: 72 61 67 65 2e 0a 2b 20 2a 2f 0a 2b 73 74 61 74  rage..+ */.+stat
3aa0: 69 63 20 54 63 6c 5f 48 61 73 68 54 61 62 6c 65  ic Tcl_HashTable
3ab0: 20 2a 74 68 72 65 61 64 53 74 6f 72 61 67 65 48   *threadStorageH
3ac0: 61 73 68 54 61 62 6c 65 50 74 72 20 3d 20 4e 55  ashTablePtr = NU
3ad0: 4c 4c 3b 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 20 54 68  LL;.+.+/*.+ * Th
3ae0: 69 73 20 69 73 20 74 68 65 20 6e 65 78 74 20 74  is is the next t
3af0: 68 72 65 61 64 20 64 61 74 61 20 6b 65 79 20 76  hread data key v
3b00: 61 6c 75 65 20 74 6f 20 75 73 65 2e 20 57 65 20  alue to use. We 
3b10: 69 6e 63 72 65 6d 65 6e 74 20 74 68 69 73 0a 2b  increment this.+
3b20: 20 2a 20 65 76 65 72 79 74 69 6d 65 20 77 65 20   * everytime we 
3b30: 22 61 6c 6c 6f 63 61 74 65 22 20 6f 6e 65 2e 20  "allocate" one. 
3b40: 49 74 20 69 73 20 69 6e 69 74 69 61 6c 6c 79 20  It is initially 
3b50: 73 65 74 20 74 6f 20 31 20 69 6e 0a 2b 20 2a 20  set to 1 in.+ * 
3b60: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
3b70: 49 6e 69 74 2e 0a 2b 20 2a 2f 0a 2b 73 74 61 74  Init..+ */.+stat
3b80: 69 63 20 69 6e 74 20 6e 65 78 74 54 68 72 65 61  ic int nextThrea
3b90: 64 53 74 6f 72 61 67 65 4b 65 79 20 3d 20 53 54  dStorageKey = ST
3ba0: 4f 52 41 47 45 5f 49 4e 56 41 4c 49 44 5f 4b 45  ORAGE_INVALID_KE
3bb0: 59 3b 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 20 48 61 76  Y;.+.+/*.+ * Hav
3bc0: 65 20 77 65 20 69 6e 69 74 69 61 6c 69 7a 65 64  e we initialized
3bd0: 20 74 68 65 20 74 68 72 65 61 64 20 73 74 6f 72   the thread stor
3be0: 61 67 65 20 6d 75 74 65 78 20 79 65 74 3f 0a 2b  age mutex yet?.+
3bf0: 20 2a 2f 0a 2b 73 74 61 74 69 63 20 69 6e 74 20   */.+static int 
3c00: 69 6e 69 74 54 68 72 65 61 64 53 74 6f 72 61 67  initThreadStorag
3c10: 65 20 3d 20 30 3b 0a 2b 0a 2b 2f 2a 0a 2b 20 2a  e = 0;.+.+/*.+ *
3c20: 20 54 68 69 73 20 69 73 20 74 68 65 20 6d 61 73   This is the mas
3c30: 74 65 72 20 74 68 72 65 61 64 20 73 74 6f 72 61  ter thread stora
3c40: 67 65 20 63 61 63 68 65 2e 20 50 65 72 20 6b 65  ge cache. Per ke
3c50: 6e 6e 79 6b 62 27 73 20 69 64 65 61 2c 20 74 68  nnykb's idea, th
3c60: 69 73 0a 2b 20 2a 20 70 72 65 76 65 6e 74 73 20  is.+ * prevents 
3c70: 75 6e 6e 65 63 65 73 73 61 72 79 20 6c 6f 6f 6b  unnecessary look
3c80: 75 70 73 20 66 6f 72 20 74 68 72 65 61 64 73 20  ups for threads 
3c90: 74 68 61 74 20 75 73 65 20 61 20 6c 6f 74 20 6f  that use a lot o
3ca0: 66 20 74 68 72 65 61 64 0a 2b 20 2a 20 73 74 6f  f thread.+ * sto
3cb0: 72 61 67 65 2e 0a 2b 20 2a 2f 0a 2b 73 74 61 74  rage..+ */.+stat
3cc0: 69 63 20 76 6f 6c 61 74 69 6c 65 20 54 68 72 65  ic volatile Thre
3cd0: 61 64 53 74 6f 72 61 67 65 20 74 68 72 65 61 64  adStorage thread
3ce0: 53 74 6f 72 61 67 65 43 61 63 68 65 5b 53 54 4f  StorageCache[STO
3cf0: 52 41 47 45 5f 43 41 43 48 45 5f 53 4c 4f 54 53  RAGE_CACHE_SLOTS
3d00: 5d 3b 0a 2b 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d  ];.+.+..+/*.+ *-
3d10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3d20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3d30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3d40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3d50: 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 54 63  -----.+ *.+ * Tc
3d60: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f  lThreadStorageLo
3d70: 63 6b 49 6e 69 74 0a 2b 20 2a 0a 2b 20 2a 20 20  ckInit.+ *.+ *  
3d80: 20 20 20 20 54 68 69 73 20 70 72 6f 63 65 64 75      This procedu
3d90: 72 65 20 69 73 20 75 73 65 64 20 74 6f 20 69 6e  re is used to in
3da0: 69 74 69 61 6c 69 7a 65 20 74 68 65 20 6c 6f 63  itialize the loc
3db0: 6b 20 74 68 61 74 20 73 65 72 69 61 6c 69 7a 65  k that serialize
3dc0: 73 0a 2b 20 2a 20 20 20 20 20 20 63 72 65 61 74  s.+ *      creat
3dd0: 69 6f 6e 20 6f 66 20 74 68 72 65 61 64 20 73 74  ion of thread st
3de0: 6f 72 61 67 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 52  orage..+ *.+ * R
3df0: 65 73 75 6c 74 73 3a 0a 2b 20 2a 20 20 20 20 20  esults:.+ *     
3e00: 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53   None..+ *.+ * S
3e10: 69 64 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a  ide effects:.+ *
3e20: 20 20 20 20 20 20 54 68 65 20 6d 61 73 74 65 72        The master
3e30: 20 6c 6f 63 6b 20 69 73 20 61 63 71 75 69 72 65   lock is acquire
3e40: 64 20 61 6e 64 20 70 6f 73 73 69 62 6c 79 20 69  d and possibly i
3e50: 6e 69 74 69 61 6c 69 7a 65 64 20 66 6f 72 20 74  nitialized for t
3e60: 68 65 0a 2b 20 2a 20 20 20 20 20 20 66 69 72 73  he.+ *      firs
3e70: 74 20 74 69 6d 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d  t time..+ *.+ *-
3e80: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3e90: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
3ec0: 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76 6f  -----.+ */.+.+vo
3ed0: 69 64 0a 2b 54 63 6c 54 68 72 65 61 64 53 74 6f  id.+TclThreadSto
3ee0: 72 61 67 65 4c 6f 63 6b 49 6e 69 74 28 29 0a 2b  rageLockInit().+
3ef0: 7b 0a 2b 20 20 20 20 69 66 20 28 21 69 6e 69 74  {.+    if (!init
3f00: 54 68 72 65 61 64 53 74 6f 72 61 67 65 29 20 7b  ThreadStorage) {
3f10: 0a 2b 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20  .+        /*.+  
3f20: 20 20 20 20 20 20 20 2a 20 4d 75 74 65 78 65 73         * Mutexes
3f30: 20 69 6e 20 54 63 6c 20 61 72 65 20 73 65 6c 66   in Tcl are self
3f40: 20 69 6e 69 74 69 61 6c 69 7a 69 6e 67 2c 20 61   initializing, a
3f50: 6e 64 20 77 65 20 61 72 65 20 74 61 6b 69 6e 67  nd we are taking
3f60: 0a 2b 20 20 20 20 20 20 20 20 20 2a 20 61 64 76  .+         * adv
3f70: 61 6e 74 61 67 65 20 6f 66 20 74 68 61 74 20 66  antage of that f
3f80: 61 63 74 20 73 69 6e 63 65 20 74 68 69 73 20 66  act since this f
3f90: 69 6c 65 20 63 61 6e 6e 6f 74 20 63 6f 6e 74 61  ile cannot conta
3fa0: 69 6e 0a 2b 20 20 20 20 20 20 20 20 20 2a 20 70  in.+         * p
3fb0: 6c 61 74 66 6f 72 6d 20 73 70 65 63 69 66 69 63  latform specific
3fc0: 20 63 61 6c 6c 73 2e 0a 2b 20 20 20 20 20 20 20   calls..+       
3fd0: 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 69 6e    */.+        in
3fe0: 69 74 54 68 72 65 61 64 53 74 6f 72 61 67 65 20  itThreadStorage 
3ff0: 3d 20 31 3b 0a 2b 20 20 20 20 7d 0a 2b 7d 0a 2b  = 1;.+    }.+}.+
4000: 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d  ..+/*.+ *-------
4010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4040: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
4050: 2b 20 2a 0a 2b 20 2a 20 54 63 6c 54 68 72 65 61  + *.+ * TclThrea
4060: 64 53 74 6f 72 61 67 65 4c 6f 63 6b 0a 2b 20 2a  dStorageLock.+ *
4070: 0a 2b 20 2a 20 20 20 20 20 20 54 68 69 73 20 70  .+ *      This p
4080: 72 6f 63 65 64 75 72 65 20 69 73 20 75 73 65 64  rocedure is used
4090: 20 74 6f 20 67 72 61 62 20 61 20 6c 6f 63 6b 20   to grab a lock 
40a0: 74 68 61 74 20 73 65 72 69 61 6c 69 7a 65 73 20  that serializes 
40b0: 63 72 65 61 74 69 6f 6e 0a 2b 20 2a 20 20 20 20  creation.+ *    
40c0: 20 20 6f 66 20 74 68 72 65 61 64 20 73 74 6f 72    of thread stor
40d0: 61 67 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20  age..+ *.+ *    
40e0: 20 20 54 68 69 73 20 6c 6f 63 6b 20 6d 75 73 74    This lock must
40f0: 20 62 65 20 64 69 66 66 65 72 65 6e 74 20 74 68   be different th
4100: 61 6e 20 74 68 65 20 69 6e 69 74 4c 6f 63 6b 20  an the initLock 
4110: 62 65 63 61 75 73 65 20 74 68 65 0a 2b 20 2a 20  because the.+ * 
4120: 20 20 20 20 20 69 6e 69 74 4c 6f 63 6b 20 69 73       initLock is
4130: 20 68 65 6c 64 20 64 75 72 69 6e 67 20 63 72 65   held during cre
4140: 61 74 69 6f 6e 20 6f 66 20 73 79 6e 63 72 6f 6e  ation of syncron
4150: 69 7a 61 74 69 6f 6e 20 6f 62 6a 65 63 74 73 2e  ization objects.
4160: 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73 75 6c 74 73  .+ *.+ * Results
4170: 3a 0a 2b 20 2a 20 20 20 20 20 20 4e 6f 6e 65 2e  :.+ *      None.
4180: 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66  .+ *.+ * Side ef
4190: 66 65 63 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20  fects:.+ *      
41a0: 41 63 71 75 69 72 65 20 74 68 65 20 74 68 72 65  Acquire the thre
41b0: 61 64 20 73 74 6f 72 61 67 65 20 6d 75 74 65 78  ad storage mutex
41c0: 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d  ..+ *.+ *-------
41d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
41e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
41f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4200: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
4210: 2b 20 2a 2f 0a 2b 0a 2b 76 6f 69 64 0a 2b 54 63  + */.+.+void.+Tc
4220: 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f  lThreadStorageLo
4230: 63 6b 28 29 0a 2b 7b 0a 2b 20 20 20 20 54 63 6c  ck().+{.+    Tcl
4240: 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63  ThreadStorageLoc
4250: 6b 49 6e 69 74 28 29 3b 0a 2b 20 20 20 20 54 63  kInit();.+    Tc
4260: 6c 5f 4d 75 74 65 78 4c 6f 63 6b 28 26 74 68 72  l_MutexLock(&thr
4270: 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 29 3b  eadStorageLock);
4280: 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d  .+}.+..+/*.+ *--
4290: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
42a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
42b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
42c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
42d0: 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c  ----.+ *.+ * Tcl
42e0: 54 68 72 65 61 64 53 74 6f 72 61 67 65 55 6e 6c  ThreadStorageUnl
42f0: 6f 63 6b 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20  ock.+ *.+ *     
4300: 20 54 68 69 73 20 70 72 6f 63 65 64 75 72 65 20   This procedure 
4310: 69 73 20 75 73 65 64 20 74 6f 20 72 65 6c 65 61  is used to relea
4320: 73 65 20 61 20 6c 6f 63 6b 20 74 68 61 74 20 73  se a lock that s
4330: 65 72 69 61 6c 69 7a 65 73 20 63 72 65 61 74 69  erializes creati
4340: 6f 6e 0a 2b 20 2a 20 20 20 20 20 20 6f 66 20 74  on.+ *      of t
4350: 68 72 65 61 64 20 73 74 6f 72 61 67 65 2e 0a 2b  hread storage..+
4360: 20 2a 0a 2b 20 2a 20 52 65 73 75 6c 74 73 3a 0a   *.+ * Results:.
4370: 2b 20 2a 20 20 20 20 20 20 4e 6f 6e 65 2e 0a 2b  + *      None..+
4380: 20 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66 66 65   *.+ * Side effe
4390: 63 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 52 65  cts:.+ *      Re
43a0: 6c 65 61 73 65 20 74 68 65 20 74 68 72 65 61 64  lease the thread
43b0: 20 73 74 6f 72 61 67 65 20 6d 75 74 65 78 2e 0a   storage mutex..
43c0: 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d  + *.+ *---------
43d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
43e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
43f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4400: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20  -------------.+ 
4410: 2a 2f 0a 2b 0a 2b 76 6f 69 64 0a 2b 54 63 6c 54  */.+.+void.+TclT
4420: 68 72 65 61 64 53 74 6f 72 61 67 65 55 6e 6c 6f  hreadStorageUnlo
4430: 63 6b 28 29 0a 2b 7b 0a 2b 20 20 20 20 54 63 6c  ck().+{.+    Tcl
4440: 5f 4d 75 74 65 78 55 6e 6c 6f 63 6b 28 26 74 68  _MutexUnlock(&th
4450: 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 29  readStorageLock)
4460: 3b 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d  ;.+}.+..+/*.+ *-
4470: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4480: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4490: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
44a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
44b0: 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 41 6c  -----.+ *.+ * Al
44c0: 6c 6f 63 54 68 72 65 61 64 53 74 6f 72 61 67 65  locThreadStorage
44d0: 45 6e 74 72 79 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a  Entry --.+ *.+ *
44e0: 09 20 20 20 20 41 6c 6c 6f 63 61 74 65 20 73 70  .    Allocate sp
44f0: 61 63 65 20 66 6f 72 20 61 20 54 63 6c 5f 48 61  ace for a Tcl_Ha
4500: 73 68 45 6e 74 72 79 20 75 73 69 6e 67 20 54 63  shEntry using Tc
4510: 6c 70 53 79 73 41 6c 6c 6f 63 20 28 6e 6f 74 20  lpSysAlloc (not 
4520: 0a 2b 20 2a 20 20 20 20 20 20 63 6b 61 6c 6c 6f  .+ *      ckallo
4530: 63 29 2e 20 57 65 20 64 6f 20 74 68 69 73 20 62  c). We do this b
4540: 65 63 61 75 73 65 20 74 68 65 20 74 68 72 65 61  ecause the threa
4550: 64 65 64 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63  ded memory alloc
4560: 61 74 6f 72 20 4d 41 59 20 0a 2b 20 2a 20 20 20  ator MAY .+ *   
4570: 20 20 20 75 73 65 20 74 68 65 20 74 68 72 65 61     use the threa
4580: 64 20 73 74 6f 72 61 67 65 20 68 61 73 68 20 74  d storage hash t
4590: 61 62 6c 65 73 2e 0a 2b 20 2a 0a 2b 20 2a 20 52  ables..+ *.+ * R
45a0: 65 73 75 6c 74 73 3a 0a 2b 20 2a 09 20 20 20 20  esults:.+ *.    
45b0: 54 68 65 20 72 65 74 75 72 6e 20 76 61 6c 75 65  The return value
45c0: 20 69 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f   is a pointer to
45d0: 20 74 68 65 20 63 72 65 61 74 65 64 20 65 6e 74   the created ent
45e0: 72 79 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65  ry..+ *.+ * Side
45f0: 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 20 20   effects:.+ *.  
4600: 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d    None..+ *.+ *-
4610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4650: 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 73 74  -----.+ */.+.+st
4660: 61 74 69 63 20 54 63 6c 5f 48 61 73 68 45 6e 74  atic Tcl_HashEnt
4670: 72 79 20 2a 0a 2b 41 6c 6c 6f 63 54 68 72 65 61  ry *.+AllocThrea
4680: 64 53 74 6f 72 61 67 65 45 6e 74 72 79 28 74 61  dStorageEntry(ta
4690: 62 6c 65 50 74 72 2c 20 6b 65 79 50 74 72 29 0a  blePtr, keyPtr).
46a0: 2b 20 20 20 20 54 63 6c 5f 48 61 73 68 54 61 62  +    Tcl_HashTab
46b0: 6c 65 20 2a 74 61 62 6c 65 50 74 72 3b 09 2f 2a  le *tablePtr;./*
46c0: 20 48 61 73 68 20 74 61 62 6c 65 2e 20 2a 2f 0a   Hash table. */.
46d0: 2b 20 20 20 20 76 6f 69 64 20 2a 6b 65 79 50 74  +    void *keyPt
46e0: 72 3b 09 09 2f 2a 20 4b 65 79 20 74 6f 20 73 74  r;../* Key to st
46f0: 6f 72 65 20 69 6e 20 74 68 65 20 68 61 73 68 20  ore in the hash 
4700: 74 61 62 6c 65 20 65 6e 74 72 79 2e 20 2a 2f 0a  table entry. */.
4710: 2b 7b 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73 68  +{.+    Tcl_Hash
4720: 45 6e 74 72 79 20 2a 68 50 74 72 3b 0a 2b 0a 2b  Entry *hPtr;.+.+
4730: 20 20 20 20 68 50 74 72 20 3d 20 28 54 63 6c 5f      hPtr = (Tcl_
4740: 48 61 73 68 45 6e 74 72 79 20 2a 29 54 63 6c 70  HashEntry *)Tclp
4750: 53 79 73 41 6c 6c 6f 63 28 73 69 7a 65 6f 66 28  SysAlloc(sizeof(
4760: 54 63 6c 5f 48 61 73 68 45 6e 74 72 79 29 2c 20  Tcl_HashEntry), 
4770: 30 29 3b 0a 2b 20 20 20 20 68 50 74 72 2d 3e 6b  0);.+    hPtr->k
4780: 65 79 2e 6f 6e 65 57 6f 72 64 56 61 6c 75 65 20  ey.oneWordValue 
4790: 3d 20 28 63 68 61 72 20 2a 29 6b 65 79 50 74 72  = (char *)keyPtr
47a0: 3b 0a 2b 0a 2b 20 20 20 20 72 65 74 75 72 6e 20  ;.+.+    return 
47b0: 68 50 74 72 3b 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a 0a  hPtr;.+}.+..+/*.
47c0: 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  + *-------------
47d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
47e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
47f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4800: 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20  ---------.+ *.+ 
4810: 2a 20 46 72 65 65 54 68 72 65 61 64 53 74 6f 72  * FreeThreadStor
4820: 61 67 65 45 6e 74 72 79 20 2d 2d 0a 2b 20 2a 0a  ageEntry --.+ *.
4830: 2b 20 2a 09 20 20 20 20 46 72 65 65 73 20 73 70  + *.    Frees sp
4840: 61 63 65 20 66 6f 72 20 61 20 54 63 6c 5f 48 61  ace for a Tcl_Ha
4850: 73 68 45 6e 74 72 79 20 75 73 69 6e 67 20 54 63  shEntry using Tc
4860: 6c 70 53 79 73 46 72 65 65 20 28 6e 6f 74 20 63  lpSysFree (not c
4870: 6b 66 72 65 65 29 2e 20 0a 2b 20 2a 20 20 20 20  kfree). .+ *    
4880: 20 20 57 65 20 64 6f 20 74 68 69 73 20 62 65 63    We do this bec
4890: 61 75 73 65 20 74 68 65 20 74 68 72 65 61 64 65  ause the threade
48a0: 64 20 6d 65 6d 6f 72 79 20 61 6c 6c 6f 63 61 74  d memory allocat
48b0: 6f 72 20 4d 41 59 20 75 73 65 20 74 68 65 20 0a  or MAY use the .
48c0: 2b 20 2a 20 20 20 20 20 20 74 68 72 65 61 64 20  + *      thread 
48d0: 73 74 6f 72 61 67 65 20 68 61 73 68 20 74 61 62  storage hash tab
48e0: 6c 65 73 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73  les..+ *.+ * Res
48f0: 75 6c 74 73 3a 0a 2b 20 2a 09 20 20 20 20 4e 6f  ults:.+ *.    No
4900: 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65  ne..+ *.+ * Side
4910: 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 20 20   effects:.+ *.  
4920: 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d    None..+ *.+ *-
4930: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4940: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4950: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4960: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4970: 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 73 74  -----.+ */.+.+st
4980: 61 74 69 63 20 76 6f 69 64 0a 2b 46 72 65 65 54  atic void.+FreeT
4990: 68 72 65 61 64 53 74 6f 72 61 67 65 45 6e 74 72  hreadStorageEntr
49a0: 79 28 68 50 74 72 29 0a 2b 20 20 20 20 54 63 6c  y(hPtr).+    Tcl
49b0: 5f 48 61 73 68 45 6e 74 72 79 20 2a 68 50 74 72  _HashEntry *hPtr
49c0: 3b 09 2f 2a 20 48 61 73 68 20 65 6e 74 72 79 20  ;./* Hash entry 
49d0: 74 6f 20 66 72 65 65 2e 20 2a 2f 0a 2b 7b 0a 2b  to free. */.+{.+
49e0: 20 20 20 20 54 63 6c 70 53 79 73 46 72 65 65 28      TclpSysFree(
49f0: 28 63 68 61 72 20 2a 29 68 50 74 72 29 3b 0a 2b  (char *)hPtr);.+
4a00: 7d 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d  }.+..+/*.+ *----
4a10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4a20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4a30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4a40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4a50: 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 20 54 63 6c 54  --.+ *.+ *  TclT
4a60: 68 72 65 61 64 53 74 6f 72 61 67 65 50 72 69 6e  hreadStoragePrin
4a70: 74 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20  t --.+ *.+ *    
4a80: 20 20 54 68 69 73 20 70 72 6f 63 65 64 75 72 65    This procedure
4a90: 20 70 72 69 6e 74 73 20 6f 75 74 20 74 68 65 20   prints out the 
4aa0: 63 6f 6e 74 65 6e 74 73 20 6f 66 20 74 68 65 20  contents of the 
4ab0: 6d 61 73 74 65 72 20 74 68 72 65 61 64 0a 2b 20  master thread.+ 
4ac0: 2a 20 20 20 20 20 20 73 74 6f 72 61 67 65 20 68  *      storage h
4ad0: 61 73 68 20 74 61 62 6c 65 2c 20 74 68 65 20 74  ash table, the t
4ae0: 68 72 65 61 64 20 73 74 6f 72 61 67 65 20 63 61  hread storage ca
4af0: 63 68 65 2c 20 61 6e 64 20 74 68 65 20 6e 65 78  che, and the nex
4b00: 74 20 6b 65 79 0a 2b 20 2a 20 20 20 20 20 20 76  t key.+ *      v
4b10: 61 6c 75 65 20 74 6f 20 74 68 65 20 73 70 65 63  alue to the spec
4b20: 69 66 69 65 64 20 66 69 6c 65 2e 0a 2b 20 2a 0a  ified file..+ *.
4b30: 2b 20 2a 20 20 20 20 20 20 54 68 69 73 20 61 73  + *      This as
4b40: 73 75 6d 65 73 20 74 68 61 74 20 74 68 72 65 61  sumes that threa
4b50: 64 20 73 74 6f 72 61 67 65 20 6c 6f 63 6b 20 69  d storage lock i
4b60: 73 20 68 65 6c 64 2e 0a 2b 20 2a 0a 2b 20 2a 20  s held..+ *.+ * 
4b70: 52 65 73 75 6c 74 73 3a 0a 2b 20 2a 20 20 20 20  Results:.+ *    
4b80: 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20    None..+ *.+ * 
4b90: 53 69 64 65 20 65 66 66 65 63 74 73 3a 0a 2b 20  Side effects:.+ 
4ba0: 2a 20 20 20 20 20 20 54 68 65 20 74 68 72 65 61  *      The threa
4bb0: 64 20 73 74 6f 72 61 67 65 20 6c 6f 63 6b 20 69  d storage lock i
4bc0: 73 20 61 63 71 75 69 72 65 64 20 61 6e 64 20 72  s acquired and r
4bd0: 65 6c 65 61 73 65 64 2e 0a 2b 20 2a 0a 2b 20 2a  eleased..+ *.+ *
4be0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4bf0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4c00: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4c10: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
4c20: 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76  ------.+ */.+.+v
4c30: 6f 69 64 0a 2b 54 63 6c 54 68 72 65 61 64 53 74  oid.+TclThreadSt
4c40: 6f 72 61 67 65 50 72 69 6e 74 28 6f 75 74 46 69  oragePrint(outFi
4c50: 6c 65 2c 20 66 6c 61 67 73 29 0a 2b 20 20 20 20  le, flags).+    
4c60: 46 49 4c 45 20 2a 6f 75 74 46 69 6c 65 3b 20 20  FILE *outFile;  
4c70: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 54              /* T
4c80: 68 65 20 66 69 6c 65 20 74 6f 20 70 72 69 6e 74  he file to print
4c90: 20 74 68 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e   the information
4ca0: 20 74 6f 2e 20 2a 2f 0a 2b 20 20 20 20 69 6e 74   to. */.+    int
4cb0: 20 66 6c 61 67 73 3b 20 20 20 20 20 20 20 20 20   flags;         
4cc0: 20 20 20 20 20 20 20 20 20 2f 2a 20 52 65 73 65           /* Rese
4cd0: 72 76 65 64 20 66 6f 72 20 66 75 74 75 72 65 20  rved for future 
4ce0: 75 73 65 2e 20 2a 2f 0a 2b 7b 0a 2b 20 20 20 20  use. */.+{.+    
4cf0: 54 63 6c 5f 48 61 73 68 45 6e 74 72 79 20 2a 68  Tcl_HashEntry *h
4d00: 50 74 72 3b 0a 2b 20 20 20 20 54 63 6c 5f 48 61  Ptr;.+    Tcl_Ha
4d10: 73 68 53 65 61 72 63 68 20 73 65 61 72 63 68 3b  shSearch search;
4d20: 0a 2b 23 69 66 20 30 0a 2b 20 20 20 20 2f 2a 20  .+#if 0.+    /* 
4d30: 50 6c 65 61 73 65 20 73 65 65 20 63 6f 6d 6d 65  Please see comme
4d40: 6e 74 20 72 65 67 61 72 64 69 6e 67 20 54 63 6c  nt regarding Tcl
4d50: 5f 48 61 73 68 53 74 61 74 73 20 62 65 6c 6f 77  _HashStats below
4d60: 2e 20 2a 2f 0a 2b 20 20 20 20 43 4f 4e 53 54 20  . */.+    CONST 
4d70: 63 68 61 72 20 2a 73 74 61 74 73 3b 0a 2b 23 65  char *stats;.+#e
4d80: 6e 64 69 66 0a 2b 20 20 20 20 69 6e 74 20 68 65  ndif.+    int he
4d90: 61 64 65 72 3b 0a 2b 20 20 20 20 69 6e 74 20 69  ader;.+    int i
4da0: 6e 64 65 78 3b 0a 2b 0a 2b 20 20 20 20 69 66 20  ndex;.+.+    if 
4db0: 28 74 68 72 65 61 64 53 74 6f 72 61 67 65 48 61  (threadStorageHa
4dc0: 73 68 54 61 62 6c 65 50 74 72 20 21 3d 20 4e 55  shTablePtr != NU
4dd0: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 68  LL) {.+        h
4de0: 50 74 72 20 3d 20 54 63 6c 5f 46 69 72 73 74 48  Ptr = Tcl_FirstH
4df0: 61 73 68 45 6e 74 72 79 28 74 68 72 65 61 64 53  ashEntry(threadS
4e00: 74 6f 72 61 67 65 48 61 73 68 54 61 62 6c 65 50  torageHashTableP
4e10: 74 72 2c 20 26 73 65 61 72 63 68 29 3b 0a 2b 0a  tr, &search);.+.
4e20: 2b 20 20 20 20 20 20 20 20 69 66 20 28 68 50 74  +        if (hPt
4e30: 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20  r != NULL) {.+  
4e40: 20 20 20 20 20 20 20 20 20 20 66 70 72 69 6e 74            fprint
4e50: 66 28 6f 75 74 46 69 6c 65 2c 20 22 6d 61 73 74  f(outFile, "mast
4e60: 65 72 20 74 68 72 65 61 64 20 73 74 6f 72 61 67  er thread storag
4e70: 65 20 68 61 73 68 20 74 61 62 6c 65 3a 5c 6e 22  e hash table:\n"
4e80: 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  );.+            
4e90: 66 6f 72 20 28 3b 20 68 50 74 72 20 21 3d 20 4e  for (; hPtr != N
4ea0: 55 4c 4c 3b 20 68 50 74 72 20 3d 20 54 63 6c 5f  ULL; hPtr = Tcl_
4eb0: 4e 65 78 74 48 61 73 68 45 6e 74 72 79 28 26 73  NextHashEntry(&s
4ec0: 65 61 72 63 68 29 29 20 7b 0a 2b 20 20 20 20 20  earch)) {.+     
4ed0: 20 20 20 20 20 20 20 20 20 20 20 66 70 72 69 6e             fprin
4ee0: 74 66 28 6f 75 74 46 69 6c 65 2c 20 22 6d 61 73  tf(outFile, "mas
4ef0: 74 65 72 20 65 6e 74 72 79 20 70 74 72 20 25 70  ter entry ptr %p
4f00: 2c 20 74 68 72 65 61 64 20 25 70 2c 20 74 68 72  , thread %p, thr
4f10: 65 61 64 20 74 61 62 6c 65 20 70 74 72 20 25 70  ead table ptr %p
4f20: 5c 6e 22 2c 0a 2b 20 20 20 20 20 20 20 20 20 20  \n",.+          
4f30: 20 20 20 20 20 20 20 20 20 20 68 50 74 72 2c 20            hPtr, 
4f40: 54 63 6c 5f 47 65 74 48 61 73 68 4b 65 79 28 74  Tcl_GetHashKey(t
4f50: 68 72 65 61 64 53 74 6f 72 61 67 65 48 61 73 68  hreadStorageHash
4f60: 54 61 62 6c 65 50 74 72 2c 20 68 50 74 72 29 2c  TablePtr, hPtr),
4f70: 20 54 63 6c 5f 47 65 74 48 61 73 68 56 61 6c 75   Tcl_GetHashValu
4f80: 65 28 68 50 74 72 29 29 3b 0a 2b 20 20 20 20 20  e(hPtr));.+     
4f90: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20         }.+      
4fa0: 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20    } else {.+    
4fb0: 20 20 20 20 20 20 20 20 66 70 72 69 6e 74 66 28          fprintf(
4fc0: 6f 75 74 46 69 6c 65 2c 20 22 6d 61 73 74 65 72  outFile, "master
4fd0: 20 74 68 72 65 61 64 20 73 74 6f 72 61 67 65 20   thread storage 
4fe0: 68 61 73 68 20 74 61 62 6c 65 20 68 61 73 20 6e  hash table has n
4ff0: 6f 20 65 6e 74 72 69 65 73 5c 6e 22 29 3b 0a 2b  o entries\n");.+
5000: 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 7d          }.+    }
5010: 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20   else {.+       
5020: 20 66 70 72 69 6e 74 66 28 6f 75 74 46 69 6c 65   fprintf(outFile
5030: 2c 20 22 6d 61 73 74 65 72 20 74 68 72 65 61 64  , "master thread
5040: 20 73 74 6f 72 61 67 65 20 68 61 73 68 20 74 61   storage hash ta
5050: 62 6c 65 20 6e 6f 74 20 69 6e 69 74 69 61 6c 69  ble not initiali
5060: 7a 65 64 5c 6e 22 29 3b 0a 2b 20 20 20 20 7d 0a  zed\n");.+    }.
5070: 2b 0a 2b 20 20 20 20 68 65 61 64 65 72 20 3d 20  +.+    header = 
5080: 30 3b 20 2f 2a 20 77 65 20 68 61 76 65 20 6e 6f  0; /* we have no
5090: 74 20 6f 75 74 70 75 74 20 74 68 65 20 68 65 61  t output the hea
50a0: 64 65 72 20 79 65 74 2e 20 2a 2f 0a 2b 20 20 20  der yet. */.+   
50b0: 20 66 6f 72 20 28 69 6e 64 65 78 20 3d 20 30 3b   for (index = 0;
50c0: 20 69 6e 64 65 78 20 3c 20 53 54 4f 52 41 47 45   index < STORAGE
50d0: 5f 43 41 43 48 45 5f 53 4c 4f 54 53 3b 20 69 6e  _CACHE_SLOTS; in
50e0: 64 65 78 2b 2b 29 20 7b 0a 2b 20 20 20 20 20 20  dex++) {.+      
50f0: 20 20 69 66 20 28 74 68 72 65 61 64 53 74 6f 72    if (threadStor
5100: 61 67 65 43 61 63 68 65 5b 69 6e 64 65 78 5d 2e  ageCache[index].
5110: 69 64 20 21 3d 20 53 54 4f 52 41 47 45 5f 49 4e  id != STORAGE_IN
5120: 56 41 4c 49 44 5f 54 48 52 45 41 44 29 20 7b 0a  VALID_THREAD) {.
5130: 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20  +            if 
5140: 28 21 68 65 61 64 65 72 29 20 7b 0a 2b 20 20 20  (!header) {.+   
5150: 20 20 20 20 20 20 20 20 20 20 20 20 20 66 70 72               fpr
5160: 69 6e 74 66 28 6f 75 74 46 69 6c 65 2c 20 22 74  intf(outFile, "t
5170: 68 72 65 61 64 20 73 74 6f 72 61 67 65 20 63 61  hread storage ca
5180: 63 68 65 20 28 25 64 20 74 6f 74 61 6c 20 73 6c  che (%d total sl
5190: 6f 74 73 29 3a 5c 6e 22 2c 20 53 54 4f 52 41 47  ots):\n", STORAG
51a0: 45 5f 43 41 43 48 45 5f 53 4c 4f 54 53 29 3b 0a  E_CACHE_SLOTS);.
51b0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
51c0: 20 68 65 61 64 65 72 20 3d 20 31 3b 0a 2b 20 20   header = 1;.+  
51d0: 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 0a 2b 20            }.+.+ 
51e0: 20 20 20 20 20 20 20 20 20 20 20 66 70 72 69 6e             fprin
51f0: 74 66 28 6f 75 74 46 69 6c 65 2c 20 22 73 6c 6f  tf(outFile, "slo
5200: 74 20 25 64 2c 20 74 68 72 65 61 64 20 25 70 2c  t %d, thread %p,
5210: 20 74 68 72 65 61 64 20 74 61 62 6c 65 20 70 74   thread table pt
5220: 72 20 25 70 5c 6e 22 2c 0a 2b 20 20 20 20 20 20  r %p\n",.+      
5230: 20 20 20 20 20 20 20 20 20 20 69 6e 64 65 78 2c            index,
5240: 20 74 68 72 65 61 64 53 74 6f 72 61 67 65 43 61   threadStorageCa
5250: 63 68 65 5b 69 6e 64 65 78 5d 2e 69 64 2c 0a 2b  che[index].id,.+
5260: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
5270: 74 68 72 65 61 64 53 74 6f 72 61 67 65 43 61 63  threadStorageCac
5280: 68 65 5b 69 6e 64 65 78 5d 2e 68 61 73 68 54 61  he[index].hashTa
5290: 62 6c 65 50 74 72 29 3b 0a 2b 23 69 66 20 30 0a  blePtr);.+#if 0.
52a0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 0a  +            /*.
52b0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 20  +             * 
52c0: 43 75 72 72 65 6e 74 6c 79 20 64 69 73 61 62 6c  Currently disabl
52d0: 65 64 20 64 75 65 20 74 6f 20 54 63 6c 5f 48 61  ed due to Tcl_Ha
52e0: 73 68 53 74 61 74 73 20 75 73 65 20 6f 66 20 63  shStats use of c
52f0: 6b 61 6c 6c 6f 63 20 61 6e 64 20 63 6b 66 72 65  kalloc and ckfre
5300: 65 2e 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  e..+            
5310: 20 2a 20 50 6c 65 61 73 65 20 6e 6f 74 65 20 74   * Please note t
5320: 68 61 74 20 74 68 69 73 20 63 61 6e 20 70 72 6f  hat this can pro
5330: 64 75 63 65 20 61 20 4c 4f 54 20 6f 66 20 6f 75  duce a LOT of ou
5340: 74 70 75 74 2e 0a 2b 20 20 20 20 20 20 20 20 20  tput..+         
5350: 20 20 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20      */.+        
5360: 20 20 20 20 69 66 20 28 74 68 72 65 61 64 53 74      if (threadSt
5370: 6f 72 61 67 65 43 61 63 68 65 5b 69 6e 64 65 78  orageCache[index
5380: 5d 2e 68 61 73 68 54 61 62 6c 65 50 74 72 20 21  ].hashTablePtr !
5390: 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20  = NULL) {.+     
53a0: 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 73             stats
53b0: 20 3d 20 54 63 6c 5f 48 61 73 68 53 74 61 74 73   = Tcl_HashStats
53c0: 28 74 68 72 65 61 64 53 74 6f 72 61 67 65 43 61  (threadStorageCa
53d0: 63 68 65 5b 69 6e 64 65 78 5d 2e 68 61 73 68 54  che[index].hashT
53e0: 61 62 6c 65 50 74 72 29 3b 0a 2b 20 20 20 20 20  ablePtr);.+     
53f0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73             if (s
5400: 74 61 74 73 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a  tats != NULL) {.
5410: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
5420: 20 20 20 20 20 66 70 72 69 6e 74 66 28 6f 75 74       fprintf(out
5430: 46 69 6c 65 2c 20 22 25 73 5c 6e 22 2c 20 73 74  File, "%s\n", st
5440: 61 74 73 29 3b 0a 2b 20 20 20 20 20 20 20 20 20  ats);.+         
5450: 20 20 20 20 20 20 20 20 20 20 20 63 6b 66 72 65             ckfre
5460: 65 28 28 76 6f 69 64 20 2a 29 73 74 61 74 73 29  e((void *)stats)
5470: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  ;.+             
5480: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20     } else {.+   
5490: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
54a0: 20 66 70 72 69 6e 74 66 28 6f 75 74 46 69 6c 65   fprintf(outFile
54b0: 2c 20 22 63 6f 75 6c 64 20 6e 6f 74 20 67 65 74  , "could not get
54c0: 20 74 61 62 6c 65 20 73 74 61 74 69 73 74 69 63   table statistic
54d0: 73 20 66 6f 72 20 73 6c 6f 74 20 25 64 5c 6e 22  s for slot %d\n"
54e0: 2c 20 69 6e 64 65 78 29 3b 0a 2b 20 20 20 20 20  , index);.+     
54f0: 20 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 20 20             }.+  
5500: 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 23 65 6e            }.+#en
5510: 64 69 66 0a 2b 20 20 20 20 20 20 20 20 7d 20 65  dif.+        } e
5520: 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 20  lse {.+         
5530: 20 20 20 2f 2a 20 66 70 72 69 6e 74 66 28 6f 75     /* fprintf(ou
5540: 74 46 69 6c 65 2c 20 22 63 61 63 68 65 20 73 6c  tFile, "cache sl
5550: 6f 74 20 25 64 20 6e 6f 74 20 75 73 65 64 5c 6e  ot %d not used\n
5560: 22 2c 20 69 6e 64 65 78 29 3b 20 2a 2f 0a 2b 20  ", index); */.+ 
5570: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 7d 0a         }.+    }.
5580: 2b 0a 2b 20 20 20 20 69 66 20 28 21 68 65 61 64  +.+    if (!head
5590: 65 72 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 66  er) {.+        f
55a0: 70 72 69 6e 74 66 28 6f 75 74 46 69 6c 65 2c 20  printf(outFile, 
55b0: 22 74 68 72 65 61 64 20 73 74 6f 72 61 67 65 20  "thread storage 
55c0: 63 61 63 68 65 20 69 73 20 65 6d 70 74 79 20 28  cache is empty (
55d0: 25 64 20 74 6f 74 61 6c 20 73 6c 6f 74 73 29 5c  %d total slots)\
55e0: 6e 22 2c 20 53 54 4f 52 41 47 45 5f 43 41 43 48  n", STORAGE_CACH
55f0: 45 5f 53 4c 4f 54 53 29 3b 0a 2b 20 20 20 20 20  E_SLOTS);.+     
5600: 20 20 20 68 65 61 64 65 72 20 3d 20 31 3b 0a 2b     header = 1;.+
5610: 20 20 20 20 7d 0a 2b 0a 2b 20 20 20 20 2f 2a 20      }.+.+    /* 
5620: 53 68 6f 77 20 74 68 65 20 6e 65 78 74 20 64 61  Show the next da
5630: 74 61 20 6b 65 79 20 76 61 6c 75 65 2e 20 2a 2f  ta key value. */
5640: 0a 2b 20 20 20 20 66 70 72 69 6e 74 66 28 6f 75  .+    fprintf(ou
5650: 74 46 69 6c 65 2c 20 22 6e 65 78 74 20 64 61 74  tFile, "next dat
5660: 61 20 6b 65 79 20 76 61 6c 75 65 20 69 73 3a 20  a key value is: 
5670: 25 64 5c 6e 22 2c 20 6e 65 78 74 54 68 72 65 61  %d\n", nextThrea
5680: 64 53 74 6f 72 61 67 65 4b 65 79 29 3b 0a 2b 7d  dStorageKey);.+}
5690: 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d  .+..+/*.+ *-----
56a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
56b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
56c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
56d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
56e0: 2d 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c 54 68 72  -.+ *.+ * TclThr
56f0: 65 61 64 53 74 6f 72 61 67 65 47 65 74 48 61 73  eadStorageGetHas
5700: 68 54 61 62 6c 65 20 2d 2d 0a 2b 20 2a 0a 2b 20  hTable --.+ *.+ 
5710: 2a 20 20 20 20 20 20 54 68 69 73 20 70 72 6f 63  *      This proc
5720: 65 64 75 72 65 20 72 65 74 75 72 6e 73 20 61 20  edure returns a 
5730: 68 61 73 68 20 74 61 62 6c 65 20 70 6f 69 6e 74  hash table point
5740: 65 72 20 74 6f 20 62 65 20 75 73 65 64 20 66 6f  er to be used fo
5750: 72 20 74 68 72 65 61 64 0a 2b 20 2a 20 20 20 20  r thread.+ *    
5760: 20 20 73 74 6f 72 61 67 65 20 66 6f 72 20 74 68    storage for th
5770: 65 20 73 70 65 63 69 66 69 65 64 20 74 68 72 65  e specified thre
5780: 61 64 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73 75  ad..+ *.+ * Resu
5790: 6c 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 41 20  lts:.+ *      A 
57a0: 68 61 73 68 20 74 61 62 6c 65 20 70 6f 69 6e 74  hash table point
57b0: 65 72 20 66 6f 72 20 74 68 65 20 73 70 65 63 69  er for the speci
57c0: 66 69 65 64 20 74 68 72 65 61 64 2c 20 6f 72 20  fied thread, or 
57d0: 4e 55 4c 4c 0a 2b 20 2a 20 20 20 20 20 20 69 66  NULL.+ *      if
57e0: 20 74 68 65 20 68 61 73 68 20 74 61 62 6c 65 20   the hash table 
57f0: 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 63 72 65  has not been cre
5800: 61 74 65 64 20 79 65 74 2e 0a 2b 20 2a 0a 2b 20  ated yet..+ *.+ 
5810: 2a 20 20 20 20 20 20 54 68 69 73 20 61 73 73 75  *      This assu
5820: 6d 65 73 20 74 68 61 74 20 74 68 72 65 61 64 20  mes that thread 
5830: 73 74 6f 72 61 67 65 20 6c 6f 63 6b 20 69 73 20  storage lock is 
5840: 68 65 6c 64 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69  held..+ *.+ * Si
5850: 64 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 20  de effects:.+ * 
5860: 20 20 20 20 20 4d 61 79 20 63 68 61 6e 67 65 20       May change 
5870: 61 6e 20 65 6e 74 72 79 20 69 6e 20 74 68 65 20  an entry in the 
5880: 6d 61 73 74 65 72 20 74 68 72 65 61 64 20 73 74  master thread st
5890: 6f 72 61 67 65 20 63 61 63 68 65 20 74 6f 20 70  orage cache to p
58a0: 6f 69 6e 74 0a 2b 20 2a 20 20 20 20 20 20 74 6f  oint.+ *      to
58b0: 20 74 68 65 20 73 70 65 63 69 66 69 65 64 20 74   the specified t
58c0: 68 72 65 61 64 20 61 6e 64 20 69 74 27 73 20 61  hread and it's a
58d0: 73 73 6f 63 69 61 74 65 64 20 68 61 73 68 20 74  ssociated hash t
58e0: 61 62 6c 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d  able..+ *.+ *---
58f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5900: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5910: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5920: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
5930: 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 54 63 6c 5f  ---.+ */.+.+Tcl_
5940: 48 61 73 68 54 61 62 6c 65 20 2a 0a 2b 54 63 6c  HashTable *.+Tcl
5950: 54 68 72 65 61 64 53 74 6f 72 61 67 65 47 65 74  ThreadStorageGet
5960: 48 61 73 68 54 61 62 6c 65 28 69 64 29 0a 2b 20  HashTable(id).+ 
5970: 20 20 20 54 63 6c 5f 54 68 72 65 61 64 49 64 20     Tcl_ThreadId 
5980: 69 64 3b 20 20 20 20 2f 2a 20 49 64 20 6f 66 20  id;    /* Id of 
5990: 74 68 65 20 74 68 72 65 61 64 20 74 6f 20 67 65  the thread to ge
59a0: 74 20 74 68 65 20 68 61 73 68 20 74 61 62 6c 65  t the hash table
59b0: 20 66 6f 72 20 2a 2f 0a 2b 7b 0a 2b 20 20 20 20   for */.+{.+    
59c0: 69 6e 74 20 69 6e 64 65 78 20 3d 20 28 69 6e 74  int index = (int
59d0: 29 69 64 20 25 20 53 54 4f 52 41 47 45 5f 43 41  )id % STORAGE_CA
59e0: 43 48 45 5f 53 4c 4f 54 53 3b 0a 2b 20 20 20 20  CHE_SLOTS;.+    
59f0: 54 63 6c 5f 48 61 73 68 45 6e 74 72 79 20 2a 68  Tcl_HashEntry *h
5a00: 50 74 72 3b 0a 2b 20 20 20 20 69 6e 74 20 6e 65  Ptr;.+    int ne
5a10: 77 3b 0a 2b 0a 2b 20 20 20 20 2f 2a 0a 2b 20 20  w;.+.+    /*.+  
5a20: 20 20 20 2a 20 49 74 27 73 20 69 6d 70 6f 72 74     * It's import
5a30: 61 6e 74 20 74 68 61 74 20 77 65 20 70 69 63 6b  ant that we pick
5a40: 20 75 70 20 74 68 65 20 68 61 73 68 20 74 61 62   up the hash tab
5a50: 6c 65 20 70 6f 69 6e 74 65 72 20 42 45 46 4f 52  le pointer BEFOR
5a60: 45 0a 2b 20 20 20 20 20 2a 20 63 6f 6d 70 61 72  E.+     * compar
5a70: 69 6e 67 20 74 68 72 65 61 64 20 49 64 20 69 6e  ing thread Id in
5a80: 20 63 61 73 65 20 61 6e 6f 74 68 65 72 20 74 68   case another th
5a90: 72 65 61 64 20 69 73 20 69 6e 20 74 68 65 20 63  read is in the c
5aa0: 72 69 74 69 63 61 6c 0a 2b 20 20 20 20 20 2a 20  ritical.+     * 
5ab0: 72 65 67 69 6f 6e 20 63 68 61 6e 67 69 6e 67 20  region changing 
5ac0: 74 68 69 6e 67 73 20 6f 75 74 20 66 72 6f 6d 20  things out from 
5ad0: 75 6e 64 65 72 20 79 6f 75 2e 0a 2b 20 20 20 20  under you..+    
5ae0: 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73   */.+    Tcl_Has
5af0: 68 54 61 62 6c 65 20 2a 68 61 73 68 54 61 62 6c  hTable *hashTabl
5b00: 65 50 74 72 20 3d 20 74 68 72 65 61 64 53 74 6f  ePtr = threadSto
5b10: 72 61 67 65 43 61 63 68 65 5b 69 6e 64 65 78 5d  rageCache[index]
5b20: 2e 68 61 73 68 54 61 62 6c 65 50 74 72 3b 0a 2b  .hashTablePtr;.+
5b30: 0a 2b 20 20 20 20 69 66 20 28 74 68 72 65 61 64  .+    if (thread
5b40: 53 74 6f 72 61 67 65 43 61 63 68 65 5b 69 6e 64  StorageCache[ind
5b50: 65 78 5d 2e 69 64 20 21 3d 20 69 64 29 20 7b 0a  ex].id != id) {.
5b60: 2b 20 20 20 20 20 20 20 20 54 63 6c 54 68 72 65  +        TclThre
5b70: 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 28 29 3b  adStorageLock();
5b80: 0a 2b 0a 2b 20 20 20 20 20 20 20 20 2f 2a 20 6d  .+.+        /* m
5b90: 61 6b 65 20 73 75 72 65 20 74 68 65 20 6d 61 73  ake sure the mas
5ba0: 74 65 72 20 68 61 73 68 20 74 61 62 6c 65 20 69  ter hash table i
5bb0: 73 20 69 6e 69 74 69 61 6c 69 7a 65 64 2e 20 2a  s initialized. *
5bc0: 2f 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 54 68  /.+        TclTh
5bd0: 72 65 61 64 53 74 6f 72 61 67 65 49 6e 69 74 28  readStorageInit(
5be0: 53 54 4f 52 41 47 45 5f 49 4e 56 41 4c 49 44 5f  STORAGE_INVALID_
5bf0: 54 48 52 45 41 44 2c 20 4e 55 4c 4c 29 3b 0a 2b  THREAD, NULL);.+
5c00: 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 74 68  .+        if (th
5c10: 72 65 61 64 53 74 6f 72 61 67 65 48 61 73 68 54  readStorageHashT
5c20: 61 62 6c 65 50 74 72 20 21 3d 20 4e 55 4c 4c 29  ablePtr != NULL)
5c30: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20   {.+            
5c40: 2f 2a 20 69 74 27 73 20 6e 6f 74 20 69 6e 20 74  /* it's not in t
5c50: 68 65 20 63 61 63 68 65 2c 20 73 6f 20 77 65 20  he cache, so we 
5c60: 6c 6f 6f 6b 20 69 74 20 75 70 2e 2e 2e 20 2a 2f  look it up... */
5c70: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 68 50  .+            hP
5c80: 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 48 61 73  tr = Tcl_FindHas
5c90: 68 45 6e 74 72 79 28 74 68 72 65 61 64 53 74 6f  hEntry(threadSto
5ca0: 72 61 67 65 48 61 73 68 54 61 62 6c 65 50 74 72  rageHashTablePtr
5cb0: 2c 20 28 63 68 61 72 20 2a 29 69 64 29 3b 0a 2b  , (char *)id);.+
5cc0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 69 66  .+            if
5cd0: 20 28 68 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20   (hPtr != NULL) 
5ce0: 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  {.+             
5cf0: 20 20 20 2f 2a 20 77 65 20 66 6f 75 6e 64 20 69     /* we found i
5d00: 74 2c 20 65 78 74 72 61 63 74 20 74 68 65 20 68  t, extract the h
5d10: 61 73 68 20 74 61 62 6c 65 20 70 6f 69 6e 74 65  ash table pointe
5d20: 72 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20  r. */.+         
5d30: 20 20 20 20 20 20 20 68 61 73 68 54 61 62 6c 65         hashTable
5d40: 50 74 72 20 3d 20 54 63 6c 5f 47 65 74 48 61 73  Ptr = Tcl_GetHas
5d50: 68 56 61 6c 75 65 28 68 50 74 72 29 3b 0a 2b 20  hValue(hPtr);.+ 
5d60: 20 20 20 20 20 20 20 20 20 20 20 7d 20 65 6c 73             } els
5d70: 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20  e {.+           
5d80: 20 20 20 20 20 2f 2a 20 74 68 65 20 74 68 72 65       /* the thre
5d90: 61 64 20 73 70 65 63 69 66 69 63 20 68 61 73 68  ad specific hash
5da0: 20 74 61 62 6c 65 20 69 73 20 6e 6f 74 20 66 6f   table is not fo
5db0: 75 6e 64 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20  und. */.+       
5dc0: 20 20 20 20 20 20 20 20 20 68 61 73 68 54 61 62           hashTab
5dd0: 6c 65 50 74 72 20 3d 20 4e 55 4c 4c 3b 0a 2b 20  lePtr = NULL;.+ 
5de0: 20 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 0a 2b             }.+.+
5df0: 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28              if (
5e00: 68 61 73 68 54 61 62 6c 65 50 74 72 20 3d 3d 20  hashTablePtr == 
5e10: 4e 55 4c 4c 29 20 7b 20 20 20 20 20 20 20 20 20  NULL) {         
5e20: 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20   .+             
5e30: 20 20 20 68 61 73 68 54 61 62 6c 65 50 74 72 20     hashTablePtr 
5e40: 3d 20 28 54 63 6c 5f 48 61 73 68 54 61 62 6c 65  = (Tcl_HashTable
5e50: 20 2a 29 54 63 6c 70 53 79 73 41 6c 6c 6f 63 28   *)TclpSysAlloc(
5e60: 73 69 7a 65 6f 66 28 54 63 6c 5f 48 61 73 68 54  sizeof(Tcl_HashT
5e70: 61 62 6c 65 29 2c 20 30 29 3b 0a 2b 20 20 20 20  able), 0);.+    
5e80: 20 20 20 20 20 20 0a 2b 20 20 20 20 20 20 20 20        .+        
5e90: 20 20 20 20 20 20 20 20 69 66 20 28 68 61 73 68          if (hash
5ea0: 54 61 62 6c 65 50 74 72 20 21 3d 20 4e 55 4c 4c  TablePtr != NULL
5eb0: 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20  ) {.+           
5ec0: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 49 6e 69           Tcl_Ini
5ed0: 74 43 75 73 74 6f 6d 48 61 73 68 54 61 62 6c 65  tCustomHashTable
5ee0: 28 68 61 73 68 54 61 62 6c 65 50 74 72 2c 20 54  (hashTablePtr, T
5ef0: 43 4c 5f 43 55 53 54 4f 4d 5f 54 59 50 45 5f 4b  CL_CUSTOM_TYPE_K
5f00: 45 59 53 2c 20 26 74 63 6c 54 68 72 65 61 64 53  EYS, &tclThreadS
5f10: 74 6f 72 61 67 65 48 61 73 68 4b 65 79 54 79 70  torageHashKeyTyp
5f20: 65 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 0a  e);.+          .
5f30: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
5f40: 20 20 20 20 20 2f 2a 20 61 64 64 20 6e 65 77 20       /* add new 
5f50: 74 68 72 65 61 64 20 73 74 6f 72 61 67 65 20 68  thread storage h
5f60: 61 73 68 20 74 61 62 6c 65 20 74 6f 20 74 68 65  ash table to the
5f70: 20 6d 61 73 74 65 72 20 68 61 73 68 20 74 61 62   master hash tab
5f80: 6c 65 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20  le */.+         
5f90: 20 20 20 20 20 20 20 20 20 20 20 68 50 74 72 20             hPtr 
5fa0: 3d 20 54 63 6c 5f 43 72 65 61 74 65 48 61 73 68  = Tcl_CreateHash
5fb0: 45 6e 74 72 79 28 74 68 72 65 61 64 53 74 6f 72  Entry(threadStor
5fc0: 61 67 65 48 61 73 68 54 61 62 6c 65 50 74 72 2c  ageHashTablePtr,
5fd0: 20 28 63 68 61 72 20 2a 29 69 64 2c 20 26 6e 65   (char *)id, &ne
5fe0: 77 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 0a  w);.+          .
5ff0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
6000: 20 20 20 20 20 69 66 20 28 68 50 74 72 20 21 3d       if (hPtr !=
6010: 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20   NULL) {.+      
6020: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
6030: 20 20 54 63 6c 5f 53 65 74 48 61 73 68 56 61 6c    Tcl_SetHashVal
6040: 75 65 28 68 50 74 72 2c 20 68 61 73 68 54 61 62  ue(hPtr, hashTab
6050: 6c 65 50 74 72 29 3b 0a 2b 20 20 20 20 20 20 20  lePtr);.+       
6060: 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 20 65               } e
6070: 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 20  lse {.+         
6080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54                 T
6090: 63 6c 5f 50 61 6e 69 63 28 22 54 63 6c 5f 43 72  cl_Panic("Tcl_Cr
60a0: 65 61 74 65 48 61 73 68 45 6e 74 72 79 20 66 61  eateHashEntry fa
60b0: 69 6c 65 64 20 66 72 6f 6d 20 54 63 6c 54 68 72  iled from TclThr
60c0: 65 61 64 53 74 6f 72 61 67 65 49 6e 69 74 21 22  eadStorageInit!"
60d0: 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  );.+            
60e0: 20 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20          }.+     
60f0: 20 20 20 20 20 20 20 20 20 20 20 7d 20 65 6c 73             } els
6100: 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20  e {.+           
6110: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 50 61 6e           Tcl_Pan
6120: 69 63 28 22 63 6f 75 6c 64 20 6e 6f 74 20 61 6c  ic("could not al
6130: 6c 6f 63 61 74 65 20 74 68 72 65 61 64 20 73 70  locate thread sp
6140: 65 63 69 66 69 63 20 68 61 73 68 20 74 61 62 6c  ecific hash tabl
6150: 65 2c 20 54 63 6c 70 53 79 73 41 6c 6c 6f 63 20  e, TclpSysAlloc 
6160: 66 61 69 6c 65 64 20 66 72 6f 6d 20 54 63 6c 54  failed from TclT
6170: 68 72 65 61 64 53 74 6f 72 61 67 65 47 65 74 48  hreadStorageGetH
6180: 61 73 68 54 61 62 6c 65 21 22 29 3b 0a 2b 20 20  ashTable!");.+  
6190: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a                }.
61a0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 2b  +            }.+
61b0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a  .+            /*
61c0: 20 6e 6f 77 2c 20 77 65 20 70 75 74 20 69 74 20   now, we put it 
61d0: 69 6e 20 74 68 65 20 63 61 63 68 65 20 73 69 6e  in the cache sin
61e0: 63 65 20 69 74 20 69 73 20 68 69 67 68 6c 79 20  ce it is highly 
61f0: 6c 69 6b 65 6c 79 20 69 74 20 77 69 6c 6c 0a 2b  likely it will.+
6200: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62                 b
6210: 65 20 6e 65 65 64 65 64 20 61 67 61 69 6e 20 73  e needed again s
6220: 68 6f 72 74 6c 79 2e 20 2a 2f 0a 2b 20 20 20 20  hortly. */.+    
6230: 20 20 20 20 20 20 20 20 74 68 72 65 61 64 53 74          threadSt
6240: 6f 72 61 67 65 43 61 63 68 65 5b 69 6e 64 65 78  orageCache[index
6250: 5d 2e 69 64 20 3d 20 69 64 3b 0a 2b 20 20 20 20  ].id = id;.+    
6260: 20 20 20 20 20 20 20 20 74 68 72 65 61 64 53 74          threadSt
6270: 6f 72 61 67 65 43 61 63 68 65 5b 69 6e 64 65 78  orageCache[index
6280: 5d 2e 68 61 73 68 54 61 62 6c 65 50 74 72 20 3d  ].hashTablePtr =
6290: 20 68 61 73 68 54 61 62 6c 65 50 74 72 3b 0a 2b   hashTablePtr;.+
62a0: 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b          } else {
62b0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a  .+            /*
62c0: 20 77 65 20 63 61 6e 6e 6f 74 20 6c 6f 6f 6b 20   we cannot look 
62d0: 69 74 20 75 70 2c 20 74 68 65 20 6d 61 73 74 65  it up, the maste
62e0: 72 20 68 61 73 68 20 74 61 62 6c 65 20 68 61 73  r hash table has
62f0: 20 6e 6f 74 20 62 65 65 6e 20 69 6e 69 74 69 61   not been initia
6300: 6c 69 7a 65 64 2e 20 2a 2f 0a 2b 20 20 20 20 20  lized. */.+     
6310: 20 20 20 20 20 20 20 68 61 73 68 54 61 62 6c 65         hashTable
6320: 50 74 72 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20  Ptr = NULL;.+   
6330: 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20       }.+        
6340: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
6350: 55 6e 6c 6f 63 6b 28 29 3b 0a 2b 20 20 20 20 7d  Unlock();.+    }
6360: 0a 2b 0a 2b 20 20 20 20 72 65 74 75 72 6e 20 68  .+.+    return h
6370: 61 73 68 54 61 62 6c 65 50 74 72 3b 0a 2b 7d 0a  ashTablePtr;.+}.
6380: 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d  +..+/*.+ *------
6390: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
63a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
63b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
63c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
63d0: 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c 54 68 72 65  .+ *.+ * TclThre
63e0: 61 64 53 74 6f 72 61 67 65 49 6e 69 74 20 2d 2d  adStorageInit --
63f0: 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 68  .+ *.+ *      Th
6400: 69 73 20 70 72 6f 63 65 64 75 72 65 20 69 6e 69  is procedure ini
6410: 74 69 61 6c 69 7a 65 73 20 61 20 74 68 72 65 61  tializes a threa
6420: 64 20 73 70 65 63 69 66 69 63 20 68 61 73 68 20  d specific hash 
6430: 74 61 62 6c 65 20 66 6f 72 20 74 68 65 0a 2b 20  table for the.+ 
6440: 2a 20 20 20 20 20 20 63 75 72 72 65 6e 74 20 74  *      current t
6450: 68 72 65 61 64 2e 20 49 74 20 6d 61 79 20 61 6c  hread. It may al
6460: 73 6f 20 69 6e 69 74 69 61 6c 69 7a 65 20 74 68  so initialize th
6470: 65 20 6d 61 73 74 65 72 20 68 61 73 68 20 74 61  e master hash ta
6480: 62 6c 65 20 77 68 69 63 68 0a 2b 20 2a 20 20 20  ble which.+ *   
6490: 20 20 20 73 74 6f 72 65 73 20 61 6c 6c 20 74 68     stores all th
64a0: 65 20 74 68 72 65 61 64 20 73 70 65 63 69 66 69  e thread specifi
64b0: 63 20 68 61 73 68 20 74 61 62 6c 65 73 2e 0a 2b  c hash tables..+
64c0: 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 68 69 73   *.+ *      This
64d0: 20 61 73 73 75 6d 65 73 20 74 68 61 74 20 74 68   assumes that th
64e0: 72 65 61 64 20 73 74 6f 72 61 67 65 20 6c 6f 63  read storage loc
64f0: 6b 20 69 73 20 68 65 6c 64 2e 0a 2b 20 2a 0a 2b  k is held..+ *.+
6500: 20 2a 20 52 65 73 75 6c 74 73 3a 0a 2b 20 2a 20   * Results:.+ * 
6510: 20 20 20 20 20 41 20 68 61 73 68 20 74 61 62 6c       A hash tabl
6520: 65 20 70 6f 69 6e 74 65 72 20 66 6f 72 20 74 68  e pointer for th
6530: 65 20 73 70 65 63 69 66 69 65 64 20 74 68 72 65  e specified thre
6540: 61 64 2c 20 6f 72 20 4e 55 4c 4c 20 69 66 20 77  ad, or NULL if w
6550: 65 20 61 72 65 0a 2b 20 2a 20 20 20 20 20 20 62  e are.+ *      b
6560: 65 20 63 61 6c 6c 65 64 20 74 6f 20 69 6e 69 74  e called to init
6570: 69 61 6c 69 7a 65 20 74 68 65 20 6d 61 73 74 65  ialize the maste
6580: 72 20 68 61 73 68 20 74 61 62 6c 65 20 6f 6e 6c  r hash table onl
6590: 79 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20  y..+ *.+ * Side 
65a0: 65 66 66 65 63 74 73 3a 0a 2b 20 2a 20 20 20 20  effects:.+ *    
65b0: 20 20 54 68 65 20 74 68 72 65 61 64 20 73 70 65    The thread spe
65c0: 63 69 66 69 63 20 68 61 73 68 20 74 61 62 6c 65  cific hash table
65d0: 20 6d 61 79 20 62 65 20 69 6e 69 74 69 61 6c 69   may be initiali
65e0: 7a 65 64 20 61 6e 64 20 61 64 64 65 64 20 74 6f  zed and added to
65f0: 20 74 68 65 0a 2b 20 2a 20 20 20 20 20 20 6d 61   the.+ *      ma
6600: 73 74 65 72 20 68 61 73 68 20 74 61 62 6c 65 2e  ster hash table.
6610: 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d  .+ *.+ *--------
6620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6650: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b  --------------.+
6660: 20 2a 2f 0a 2b 0a 2b 54 63 6c 5f 48 61 73 68 54   */.+.+Tcl_HashT
6670: 61 62 6c 65 20 2a 0a 2b 54 63 6c 54 68 72 65 61  able *.+TclThrea
6680: 64 53 74 6f 72 61 67 65 49 6e 69 74 28 69 64 2c  dStorageInit(id,
6690: 20 72 65 73 65 72 76 65 64 29 0a 2b 20 20 20 20   reserved).+    
66a0: 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69 64 3b  Tcl_ThreadId id;
66b0: 20 20 20 20 2f 2a 20 49 64 20 6f 66 20 74 68 65      /* Id of the
66c0: 20 74 68 72 65 61 64 20 74 6f 20 67 65 74 20 74   thread to get t
66d0: 68 65 20 68 61 73 68 20 74 61 62 6c 65 20 66 6f  he hash table fo
66e0: 72 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 2a  r */.+    void *
66f0: 72 65 73 65 72 76 65 64 3b 20 20 20 20 20 2f 2a  reserved;     /*
6700: 20 72 65 73 65 72 76 65 64 20 66 6f 72 20 66 75   reserved for fu
6710: 74 75 72 65 20 75 73 65 20 2a 2f 0a 2b 7b 0a 2b  ture use */.+{.+
6720: 23 69 66 20 30 20 2f 2a 20 23 69 66 64 65 66 20  #if 0 /* #ifdef 
6730: 54 43 4c 5f 54 48 52 45 41 44 5f 53 54 4f 52 41  TCL_THREAD_STORA
6740: 47 45 5f 44 45 42 55 47 20 2a 2f 0a 2b 20 20 20  GE_DEBUG */.+   
6750: 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67   TclThreadStorag
6760: 65 50 72 69 6e 74 28 73 74 64 65 72 72 2c 20 30  ePrint(stderr, 0
6770: 29 3b 0a 2b 23 65 6e 64 69 66 0a 2b 0a 2b 20 20  );.+#endif.+.+  
6780: 20 20 69 66 20 28 74 68 72 65 61 64 53 74 6f 72    if (threadStor
6790: 61 67 65 48 61 73 68 54 61 62 6c 65 50 74 72 20  ageHashTablePtr 
67a0: 3d 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20  == NULL) {.+    
67b0: 20 20 20 20 2f 2a 20 6c 6f 6f 6b 73 20 6c 69 6b      /* looks lik
67c0: 65 20 77 65 20 68 61 76 65 6e 27 74 20 63 72 65  e we haven't cre
67d0: 61 74 65 64 20 74 68 65 20 6f 75 74 65 72 20 68  ated the outer h
67e0: 61 73 68 20 74 61 62 6c 65 20 79 65 74 0a 2b 20  ash table yet.+ 
67f0: 20 20 20 20 20 20 20 20 20 20 77 65 20 63 61 6e            we can
6800: 20 6a 75 73 74 20 64 6f 20 74 68 61 74 20 6e 6f   just do that no
6810: 77 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 74  w. */.+        t
6820: 68 72 65 61 64 53 74 6f 72 61 67 65 48 61 73 68  hreadStorageHash
6830: 54 61 62 6c 65 50 74 72 20 3d 20 28 54 63 6c 5f  TablePtr = (Tcl_
6840: 48 61 73 68 54 61 62 6c 65 20 2a 29 54 63 6c 70  HashTable *)Tclp
6850: 53 79 73 41 6c 6c 6f 63 28 73 69 7a 65 6f 66 28  SysAlloc(sizeof(
6860: 54 63 6c 5f 48 61 73 68 54 61 62 6c 65 29 2c 20  Tcl_HashTable), 
6870: 30 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 69  0);.+.+        i
6880: 66 20 28 74 68 72 65 61 64 53 74 6f 72 61 67 65  f (threadStorage
6890: 48 61 73 68 54 61 62 6c 65 50 74 72 20 21 3d 20  HashTablePtr != 
68a0: 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20  NULL) {.+       
68b0: 20 20 20 20 20 2f 2a 20 69 6e 69 74 69 61 6c 69       /* initiali
68c0: 7a 65 20 74 68 65 20 68 61 73 68 20 74 61 62 6c  ze the hash tabl
68d0: 65 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20  e */.+          
68e0: 20 20 54 63 6c 5f 49 6e 69 74 43 75 73 74 6f 6d    Tcl_InitCustom
68f0: 48 61 73 68 54 61 62 6c 65 28 74 68 72 65 61 64  HashTable(thread
6900: 53 74 6f 72 61 67 65 48 61 73 68 54 61 62 6c 65  StorageHashTable
6910: 50 74 72 2c 20 54 43 4c 5f 43 55 53 54 4f 4d 5f  Ptr, TCL_CUSTOM_
6920: 54 59 50 45 5f 4b 45 59 53 2c 20 26 74 63 6c 54  TYPE_KEYS, &tclT
6930: 68 72 65 61 64 53 74 6f 72 61 67 65 48 61 73 68  hreadStorageHash
6940: 4b 65 79 54 79 70 65 29 3b 0a 2b 20 20 20 20 20  KeyType);.+     
6950: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20     } else {.+   
6960: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 50 61 6e           Tcl_Pan
6970: 69 63 28 22 63 6f 75 6c 64 20 6e 6f 74 20 61 6c  ic("could not al
6980: 6c 6f 63 61 74 65 20 6d 61 73 74 65 72 20 74 68  locate master th
6990: 72 65 61 64 20 73 74 6f 72 61 67 65 20 68 61 73  read storage has
69a0: 68 20 74 61 62 6c 65 2c 20 54 63 6c 70 53 79 73  h table, TclpSys
69b0: 41 6c 6c 6f 63 20 66 61 69 6c 65 64 20 66 72 6f  Alloc failed fro
69c0: 6d 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61  m TclThreadStora
69d0: 67 65 49 6e 69 74 21 22 29 3b 0a 2b 20 20 20 20  geInit!");.+    
69e0: 20 20 20 20 7d 0a 2b 0a 2b 20 20 20 20 20 20 20      }.+.+       
69f0: 20 2f 2a 20 77 65 20 61 6c 73 6f 20 69 6e 69 74   /* we also init
6a00: 69 61 6c 69 7a 65 20 74 68 65 20 63 61 63 68 65  ialize the cache
6a10: 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 6d 65  . */.+        me
6a20: 6d 73 65 74 28 28 54 68 72 65 61 64 53 74 6f 72  mset((ThreadStor
6a30: 61 67 65 20 2a 29 26 74 68 72 65 61 64 53 74 6f  age *)&threadSto
6a40: 72 61 67 65 43 61 63 68 65 2c 20 30 2c 20 73 69  rageCache, 0, si
6a50: 7a 65 6f 66 28 54 68 72 65 61 64 53 74 6f 72 61  zeof(ThreadStora
6a60: 67 65 29 20 2a 20 53 54 4f 52 41 47 45 5f 43 41  ge) * STORAGE_CA
6a70: 43 48 45 5f 53 4c 4f 54 53 29 3b 0a 2b 0a 2b 20  CHE_SLOTS);.+.+ 
6a80: 20 20 20 20 20 20 20 2f 2a 20 6e 6f 77 2c 20 77         /* now, w
6a90: 65 20 73 65 74 20 74 68 65 20 66 69 72 73 74 20  e set the first 
6aa0: 76 61 6c 75 65 20 74 6f 20 62 65 20 75 73 65 64  value to be used
6ab0: 20 66 6f 72 20 61 20 74 68 72 65 61 64 20 64 61   for a thread da
6ac0: 74 61 20 6b 65 79 2e 20 2a 2f 0a 2b 20 20 20 20  ta key. */.+    
6ad0: 20 20 20 20 6e 65 78 74 54 68 72 65 61 64 53 74      nextThreadSt
6ae0: 6f 72 61 67 65 4b 65 79 20 3d 20 53 54 4f 52 41  orageKey = STORA
6af0: 47 45 5f 46 49 52 53 54 5f 4b 45 59 3b 0a 2b 20  GE_FIRST_KEY;.+ 
6b00: 20 20 20 7d 0a 2b 0a 2b 20 20 20 20 72 65 74 75     }.+.+    retu
6b10: 72 6e 20 4e 55 4c 4c 3b 0a 2b 7d 0a 2b 0c 0a 2b  rn NULL;.+}.+..+
6b20: 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  /*.+ *----------
6b30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6b40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6b50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6b60: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a  ------------.+ *
6b70: 0a 2b 20 2a 20 54 63 6c 54 68 72 65 61 64 53 74  .+ * TclThreadSt
6b80: 6f 72 61 67 65 44 61 74 61 4b 65 79 49 6e 69 74  orageDataKeyInit
6b90: 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20   --.+ *.+ *     
6ba0: 20 54 68 69 73 20 70 72 6f 63 65 64 75 72 65 20   This procedure 
6bb0: 69 6e 69 74 69 61 6c 69 7a 65 73 20 61 20 74 68  initializes a th
6bc0: 72 65 61 64 20 73 70 65 63 69 66 69 63 20 64 61  read specific da
6bd0: 74 61 20 62 6c 6f 63 6b 20 6b 65 79 2e 0a 2b 20  ta block key..+ 
6be0: 2a 20 20 20 20 20 20 45 61 63 68 20 74 68 72 65  *      Each thre
6bf0: 61 64 20 68 61 73 20 74 61 62 6c 65 20 6f 66 20  ad has table of 
6c00: 70 6f 69 6e 74 65 72 73 20 74 6f 20 74 68 72 65  pointers to thre
6c10: 61 64 20 73 70 65 63 69 66 69 63 20 64 61 74 61  ad specific data
6c20: 2e 0a 2b 20 2a 20 20 20 20 20 20 61 6c 6c 20 74  ..+ *      all t
6c30: 68 72 65 61 64 73 20 61 67 72 65 65 20 6f 6e 20  hreads agree on 
6c40: 77 68 69 63 68 20 74 61 62 6c 65 20 65 6e 74 72  which table entr
6c50: 79 20 69 73 20 75 73 65 64 20 62 79 20 65 61 63  y is used by eac
6c60: 68 20 6d 6f 64 75 6c 65 2e 0a 2b 20 2a 20 20 20  h module..+ *   
6c70: 20 20 20 74 68 69 73 20 69 73 20 72 65 6d 65 6d     this is remem
6c80: 62 65 72 65 64 20 69 6e 20 61 20 22 64 61 74 61  bered in a "data
6c90: 20 6b 65 79 22 2c 20 74 68 61 74 20 69 73 20 6a   key", that is j
6ca0: 75 73 74 20 61 6e 20 69 6e 64 65 78 20 69 6e 74  ust an index int
6cb0: 6f 0a 2b 20 2a 20 20 20 20 20 20 74 68 69 73 20  o.+ *      this 
6cc0: 74 61 62 6c 65 2e 20 20 54 6f 20 61 6c 6c 6f 77  table.  To allow
6cd0: 20 73 65 6c 66 20 69 6e 69 74 69 61 6c 69 7a 61   self initializa
6ce0: 74 69 6f 6e 2c 20 74 68 65 20 69 6e 74 65 72 66  tion, the interf
6cf0: 61 63 65 0a 2b 20 2a 20 20 20 20 20 20 70 61 73  ace.+ *      pas
6d00: 73 65 73 20 61 20 70 6f 69 6e 74 65 72 20 74 6f  ses a pointer to
6d10: 20 74 68 69 73 20 6b 65 79 20 61 6e 64 20 74 68   this key and th
6d20: 65 20 66 69 72 73 74 20 74 68 72 65 61 64 20 74  e first thread t
6d30: 6f 20 75 73 65 0a 2b 20 2a 20 20 20 20 20 20 74  o use.+ *      t
6d40: 68 65 20 6b 65 79 20 66 69 6c 6c 73 20 69 6e 20  he key fills in 
6d50: 74 68 65 20 70 6f 69 6e 74 65 72 20 74 6f 20 74  the pointer to t
6d60: 68 65 20 6b 65 79 2e 20 20 54 68 65 20 6b 65 79  he key.  The key
6d70: 20 73 68 6f 75 6c 64 20 62 65 0a 2b 20 2a 20 20   should be.+ *  
6d80: 20 20 20 20 61 20 70 72 6f 63 65 73 73 2d 77 69      a process-wi
6d90: 64 65 20 73 74 61 74 69 63 2e 0a 2b 20 2a 0a 2b  de static..+ *.+
6da0: 20 2a 20 52 65 73 75 6c 74 73 3a 0a 2b 20 2a 20   * Results:.+ * 
6db0: 20 20 20 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b       None..+ *.+
6dc0: 20 2a 20 53 69 64 65 20 65 66 66 65 63 74 73 3a   * Side effects:
6dd0: 0a 2b 20 2a 20 20 20 20 20 20 57 69 6c 6c 20 61  .+ *      Will a
6de0: 6c 6c 6f 63 61 74 65 20 6d 65 6d 6f 72 79 20 74  llocate memory t
6df0: 68 65 20 66 69 72 73 74 20 74 69 6d 65 20 74 68  he first time th
6e00: 69 73 20 70 72 6f 63 65 73 73 20 63 61 6c 6c 73  is process calls
6e10: 20 66 6f 72 0a 2b 20 2a 20 20 20 20 20 20 74 68   for.+ *      th
6e20: 69 73 20 6b 65 79 2e 20 20 49 6e 20 74 68 69 73  is key.  In this
6e30: 20 63 61 73 65 20 69 74 20 6d 6f 64 69 66 69 65   case it modifie
6e40: 73 20 69 74 73 20 61 72 67 75 6d 65 6e 74 0a 2b  s its argument.+
6e50: 20 2a 20 20 20 20 20 20 74 6f 20 68 6f 6c 64 20   *      to hold 
6e60: 74 68 65 20 70 6f 69 6e 74 65 72 20 74 6f 20 69  the pointer to i
6e70: 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 62 6f 75 74  nformation about
6e80: 20 74 68 65 20 6b 65 79 2e 0a 2b 20 2a 0a 2b 20   the key..+ *.+ 
6e90: 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  *---------------
6ea0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6ec0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
6ed0: 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b  -------.+ */.+.+
6ee0: 76 6f 69 64 0a 2b 54 63 6c 54 68 72 65 61 64 53  void.+TclThreadS
6ef0: 74 6f 72 61 67 65 44 61 74 61 4b 65 79 49 6e 69  torageDataKeyIni
6f00: 74 28 6b 65 79 50 74 72 29 0a 2b 20 20 20 20 54  t(keyPtr).+    T
6f10: 63 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79  cl_ThreadDataKey
6f20: 20 2a 6b 65 79 50 74 72 3b 20 20 2f 2a 20 49 64   *keyPtr;  /* Id
6f30: 65 6e 74 69 66 69 65 72 20 66 6f 72 20 74 68 65  entifier for the
6f40: 20 64 61 74 61 20 63 68 75 6e 6b 2c 0a 2b 20 20   data chunk,.+  
6f50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
6f60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2a                 *
6f70: 20 72 65 61 6c 6c 79 20 28 69 6e 74 20 2a 2a 29   really (int **)
6f80: 20 2a 2f 0a 2b 7b 0a 2b 20 20 20 20 69 6e 74 20   */.+{.+    int 
6f90: 2a 69 6e 64 65 78 50 74 72 3b 0a 2b 20 20 20 20  *indexPtr;.+    
6fa0: 69 6e 74 20 6e 65 77 4b 65 79 3b 0a 2b 0a 2b 20  int newKey;.+.+ 
6fb0: 20 20 20 69 66 20 28 2a 6b 65 79 50 74 72 20 3d     if (*keyPtr =
6fc0: 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20  = NULL) {.+     
6fd0: 20 20 20 69 6e 64 65 78 50 74 72 20 3d 20 28 69     indexPtr = (i
6fe0: 6e 74 20 2a 29 54 63 6c 70 53 79 73 41 6c 6c 6f  nt *)TclpSysAllo
6ff0: 63 28 73 69 7a 65 6f 66 28 69 6e 74 29 2c 20 30  c(sizeof(int), 0
7000: 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 69 66  );.+.+        if
7010: 20 28 69 6e 64 65 78 50 74 72 20 21 3d 20 4e 55   (indexPtr != NU
7020: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20  LL) {.+         
7030: 20 20 20 2f 2a 0a 2b 20 20 20 20 20 20 20 20 20     /*.+         
7040: 20 20 20 20 2a 20 57 65 20 6d 75 73 74 20 63 61      * We must ca
7050: 6c 6c 20 74 68 69 73 20 6e 6f 77 20 74 6f 20 6d  ll this now to m
7060: 61 6b 65 20 73 75 72 65 0a 2b 20 20 20 20 20 20  ake sure.+      
7070: 20 20 20 20 20 20 20 2a 20 74 68 61 74 20 6e 65         * that ne
7080: 78 74 54 68 72 65 61 64 53 74 6f 72 61 67 65 4b  xtThreadStorageK
7090: 65 79 20 68 61 73 20 61 20 77 65 6c 6c 20 64 65  ey has a well de
70a0: 66 69 6e 65 64 0a 2b 20 20 20 20 20 20 20 20 20  fined.+         
70b0: 20 20 20 20 2a 20 76 61 6c 75 65 2e 0a 2b 20 20      * value..+  
70c0: 20 20 20 20 20 20 20 20 20 20 20 2a 2f 0a 2b 20             */.+ 
70d0: 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 54 68             TclTh
70e0: 72 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 28  readStorageLock(
70f0: 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 20 20  );.+.+          
7100: 20 20 2f 2a 20 6d 61 6b 65 20 73 75 72 65 20 74    /* make sure t
7110: 68 65 20 6d 61 73 74 65 72 20 68 61 73 68 20 74  he master hash t
7120: 61 62 6c 65 20 69 73 20 69 6e 69 74 69 61 6c 69  able is initiali
7130: 7a 65 64 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20  zed. */.+       
7140: 20 20 20 20 20 54 63 6c 54 68 72 65 61 64 53 74       TclThreadSt
7150: 6f 72 61 67 65 49 6e 69 74 28 53 54 4f 52 41 47  orageInit(STORAG
7160: 45 5f 49 4e 56 41 4c 49 44 5f 54 48 52 45 41 44  E_INVALID_THREAD
7170: 2c 20 4e 55 4c 4c 29 3b 0a 2b 0a 2b 20 20 20 20  , NULL);.+.+    
7180: 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20 20 20          /*.+    
7190: 20 20 20 20 20 20 20 20 20 2a 20 54 68 65 73 65           * These
71a0: 20 64 61 74 61 20 6b 65 79 20 76 61 6c 75 65 73   data key values
71b0: 20 61 72 65 20 73 65 71 75 65 6e 74 69 61 6c 6c   are sequentiall
71c0: 79 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  y.+             
71d0: 2a 20 61 73 73 69 67 6e 65 64 20 61 6e 64 20 77  * assigned and w
71e0: 65 20 6d 75 73 74 20 75 73 65 20 74 68 65 20 73  e must use the s
71f0: 74 6f 72 61 67 65 0a 2b 20 20 20 20 20 20 20 20  torage.+        
7200: 20 20 20 20 20 2a 20 6c 6f 63 6b 20 74 6f 20 70       * lock to p
7210: 72 65 76 65 6e 74 20 73 65 72 69 6f 75 73 20 70  revent serious p
7220: 72 6f 62 6c 65 6d 73 20 68 65 72 65 2e 0a 2b 20  roblems here..+ 
7230: 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 41 6c              * Al
7240: 73 6f 20 6e 6f 74 65 20 74 68 61 74 20 74 68 65  so note that the
7250: 20 63 61 6c 6c 65 72 20 73 68 6f 75 6c 64 0a 2b   caller should.+
7260: 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 20 4e               * N
7270: 4f 54 20 6d 61 6b 65 20 61 6e 79 20 61 73 73 75  OT make any assu
7280: 6d 70 74 69 6f 6e 73 20 61 62 6f 75 74 20 74 68  mptions about th
7290: 65 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  e.+             
72a0: 2a 20 70 72 6f 76 69 64 65 64 20 76 61 6c 75 65  * provided value
72b0: 73 2e 20 49 6e 20 70 61 72 74 69 63 75 6c 61 72  s. In particular
72c0: 2c 20 77 65 20 6d 61 79 0a 2b 20 20 20 20 20 20  , we may.+      
72d0: 20 20 20 20 20 20 20 2a 20 6e 65 65 64 20 74 6f         * need to
72e0: 20 72 65 73 65 72 76 65 20 73 6f 6d 65 20 76 61   reserve some va
72f0: 6c 75 65 73 20 69 6e 20 74 68 65 0a 2b 20 20 20  lues in the.+   
7300: 20 20 20 20 20 20 20 20 20 20 2a 20 66 75 74 75            * futu
7310: 72 65 2e 0a 2b 20 20 20 20 20 20 20 20 20 20 20  re..+           
7320: 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20    */.+          
7330: 20 20 6e 65 77 4b 65 79 20 3d 20 6e 65 78 74 54    newKey = nextT
7340: 68 72 65 61 64 53 74 6f 72 61 67 65 4b 65 79 2b  hreadStorageKey+
7350: 2b 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  +;.+            
7360: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
7370: 55 6e 6c 6f 63 6b 28 29 3b 0a 2b 0a 2b 20 20 20  Unlock();.+.+   
7380: 20 20 20 20 20 20 20 20 20 2a 69 6e 64 65 78 50           *indexP
7390: 74 72 20 3d 20 6e 65 77 4b 65 79 3b 0a 2b 20 20  tr = newKey;.+  
73a0: 20 20 20 20 20 20 20 20 20 20 2a 6b 65 79 50 74            *keyPt
73b0: 72 20 3d 20 28 54 63 6c 5f 54 68 72 65 61 64 44  r = (Tcl_ThreadD
73c0: 61 74 61 4b 65 79 29 69 6e 64 65 78 50 74 72 3b  ataKey)indexPtr;
73d0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 54 63  .+            Tc
73e0: 6c 52 65 6d 65 6d 62 65 72 44 61 74 61 4b 65 79  lRememberDataKey
73f0: 28 6b 65 79 50 74 72 29 3b 0a 2b 20 20 20 20 20  (keyPtr);.+     
7400: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20     } else {.+   
7410: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 50 61 6e           Tcl_Pan
7420: 69 63 28 22 54 63 6c 70 53 79 73 41 6c 6c 6f 63  ic("TclpSysAlloc
7430: 20 66 61 69 6c 65 64 20 66 72 6f 6d 20 54 63 6c   failed from Tcl
7440: 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74  ThreadStorageDat
7450: 61 4b 65 79 49 6e 69 74 21 22 29 3b 20 2f 2a 20  aKeyInit!"); /* 
7460: 74 68 69 73 20 73 68 6f 75 6c 64 20 61 6c 73 6f  this should also
7470: 20 62 65 20 61 20 66 61 74 61 6c 20 65 72 72 6f   be a fatal erro
7480: 72 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 7d 0a  r */.+        }.
7490: 2b 20 20 20 20 7d 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a  +    }.+}.+..+/*
74a0: 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .+ *------------
74b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
74c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
74d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
74e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b  ----------.+ *.+
74f0: 20 2a 20 54 63 6c 54 68 72 65 61 64 53 74 6f 72   * TclThreadStor
7500: 61 67 65 44 61 74 61 4b 65 79 47 65 74 20 2d 2d  ageDataKeyGet --
7510: 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 68  .+ *.+ *      Th
7520: 69 73 20 70 72 6f 63 65 64 75 72 65 20 72 65 74  is procedure ret
7530: 75 72 6e 73 20 61 20 70 6f 69 6e 74 65 72 20 74  urns a pointer t
7540: 6f 20 61 20 62 6c 6f 63 6b 20 6f 66 20 74 68 72  o a block of thr
7550: 65 61 64 20 6c 6f 63 61 6c 20 73 74 6f 72 61 67  ead local storag
7560: 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73 75 6c  e..+ *.+ * Resul
7570: 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 41 20 74  ts:.+ *      A t
7580: 68 72 65 61 64 2d 73 70 65 63 69 66 69 63 20 70  hread-specific p
7590: 6f 69 6e 74 65 72 20 74 6f 20 74 68 65 20 64 61  ointer to the da
75a0: 74 61 20 73 74 72 75 63 74 75 72 65 2c 20 6f 72  ta structure, or
75b0: 20 4e 55 4c 4c 0a 2b 20 2a 20 20 20 20 20 20 69   NULL.+ *      i
75c0: 66 20 74 68 65 20 6d 65 6d 6f 72 79 20 68 61 73  f the memory has
75d0: 20 6e 6f 74 20 62 65 65 6e 20 61 73 73 69 67 6e   not been assign
75e0: 65 64 20 74 6f 20 74 68 69 73 20 6b 65 79 20 66  ed to this key f
75f0: 6f 72 20 74 68 69 73 20 74 68 72 65 61 64 2e 0a  or this thread..
7600: 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66 66  + *.+ * Side eff
7610: 65 63 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 4e  ects:.+ *      N
7620: 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d  one..+ *.+ *----
7630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7640: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7650: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7660: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7670: 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76 6f 69 64 20  --.+ */.+.+void 
7680: 2a 0a 2b 54 63 6c 54 68 72 65 61 64 53 74 6f 72  *.+TclThreadStor
7690: 61 67 65 44 61 74 61 4b 65 79 47 65 74 28 6b 65  ageDataKeyGet(ke
76a0: 79 50 74 72 29 0a 2b 20 20 20 20 54 63 6c 5f 54  yPtr).+    Tcl_T
76b0: 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a 6b 65  hreadDataKey *ke
76c0: 79 50 74 72 3b 20 20 2f 2a 20 49 64 65 6e 74 69  yPtr;  /* Identi
76d0: 66 69 65 72 20 66 6f 72 20 74 68 65 20 64 61 74  fier for the dat
76e0: 61 20 63 68 75 6e 6b 2c 0a 2b 20 20 20 20 20 20  a chunk,.+      
76f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
7700: 20 20 20 20 20 20 20 20 20 20 20 2a 20 72 65 61             * rea
7710: 6c 6c 79 20 28 69 6e 74 20 2a 2a 29 20 2a 2f 0a  lly (int **) */.
7720: 2b 7b 0a 2b 20 20 20 20 69 6e 74 20 2a 69 6e 64  +{.+    int *ind
7730: 65 78 50 74 72 20 3d 20 2a 28 69 6e 74 20 2a 2a  exPtr = *(int **
7740: 29 6b 65 79 50 74 72 3b 0a 2b 20 20 20 20 76 6f  )keyPtr;.+    vo
7750: 69 64 20 2a 72 65 73 75 6c 74 3b 0a 2b 20 20 20  id *result;.+   
7760: 20 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69 64   Tcl_ThreadId id
7770: 20 3d 20 54 63 6c 5f 47 65 74 43 75 72 72 65 6e   = Tcl_GetCurren
7780: 74 54 68 72 65 61 64 28 29 3b 0a 2b 20 20 20 20  tThread();.+    
7790: 54 63 6c 5f 48 61 73 68 54 61 62 6c 65 20 2a 68  Tcl_HashTable *h
77a0: 61 73 68 54 61 62 6c 65 50 74 72 3b 0a 2b 20 20  ashTablePtr;.+  
77b0: 20 20 54 63 6c 5f 48 61 73 68 45 6e 74 72 79 20    Tcl_HashEntry 
77c0: 2a 68 50 74 72 3b 0a 2b 0a 2b 20 20 20 20 69 66  *hPtr;.+.+    if
77d0: 20 28 69 6e 64 65 78 50 74 72 20 3d 3d 20 4e 55   (indexPtr == NU
77e0: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 72  LL) {.+        r
77f0: 65 73 75 6c 74 20 3d 20 4e 55 4c 4c 3b 0a 2b 20  esult = NULL;.+ 
7800: 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20     } else {.+   
7810: 20 20 20 20 20 68 61 73 68 54 61 62 6c 65 50 74       hashTablePt
7820: 72 20 3d 20 54 63 6c 54 68 72 65 61 64 53 74 6f  r = TclThreadSto
7830: 72 61 67 65 47 65 74 48 61 73 68 54 61 62 6c 65  rageGetHashTable
7840: 28 69 64 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20  (id);.+.+       
7850: 20 69 66 20 28 68 61 73 68 54 61 62 6c 65 50 74   if (hashTablePt
7860: 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20  r != NULL) {.+  
7870: 20 20 20 20 20 20 20 20 20 20 68 50 74 72 20 3d            hPtr =
7880: 20 54 63 6c 5f 46 69 6e 64 48 61 73 68 45 6e 74   Tcl_FindHashEnt
7890: 72 79 28 68 61 73 68 54 61 62 6c 65 50 74 72 2c  ry(hashTablePtr,
78a0: 20 28 63 68 61 72 20 2a 29 2a 69 6e 64 65 78 50   (char *)*indexP
78b0: 74 72 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20  tr);.+.+        
78c0: 20 20 20 20 69 66 20 28 68 50 74 72 20 21 3d 20      if (hPtr != 
78d0: 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20  NULL) {.+       
78e0: 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20           result 
78f0: 3d 20 28 76 6f 69 64 20 2a 29 54 63 6c 5f 47 65  = (void *)Tcl_Ge
7900: 74 48 61 73 68 56 61 6c 75 65 28 68 50 74 72 29  tHashValue(hPtr)
7910: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 7d  ;.+            }
7920: 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20   else {.+       
7930: 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 20           result 
7940: 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 20 20 20  = NULL;.+       
7950: 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20       }.+        
7960: 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20  } else {.+      
7970: 20 20 20 20 20 20 54 63 6c 5f 50 61 6e 69 63 28        Tcl_Panic(
7980: 22 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67  "TclThreadStorag
7990: 65 47 65 74 48 61 73 68 54 61 62 6c 65 20 66 61  eGetHashTable fa
79a0: 69 6c 65 64 20 66 72 6f 6d 20 54 63 6c 54 68 72  iled from TclThr
79b0: 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65  eadStorageDataKe
79c0: 79 47 65 74 21 22 29 3b 0a 2b 20 20 20 20 20 20  yGet!");.+      
79d0: 20 20 20 20 20 20 72 65 73 75 6c 74 20 3d 20 4e        result = N
79e0: 55 4c 4c 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a  ULL;.+        }.
79f0: 2b 20 20 20 20 7d 0a 2b 20 20 20 20 72 65 74 75  +    }.+    retu
7a00: 72 6e 20 72 65 73 75 6c 74 3b 0a 2b 7d 0a 2b 0c  rn result;.+}.+.
7a10: 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d  .+/*.+ *--------
7a20: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7a30: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7a40: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7a50: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b  --------------.+
7a60: 20 2a 0a 2b 20 2a 20 54 63 6c 54 68 72 65 61 64   *.+ * TclThread
7a70: 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 53 65  StorageDataKeySe
7a80: 74 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20  t --.+ *.+ *    
7a90: 20 20 54 68 69 73 20 70 72 6f 63 65 64 75 72 65    This procedure
7aa0: 20 73 65 74 73 20 74 68 65 20 70 6f 69 6e 74 65   sets the pointe
7ab0: 72 20 74 6f 20 61 20 62 6c 6f 63 6b 20 6f 66 20  r to a block of 
7ac0: 74 68 72 65 61 64 20 6c 6f 63 61 6c 20 73 74 6f  thread local sto
7ad0: 72 61 67 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65  rage..+ *.+ * Re
7ae0: 73 75 6c 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20  sults:.+ *      
7af0: 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69  None..+ *.+ * Si
7b00: 64 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 20  de effects:.+ * 
7b10: 20 20 20 20 20 53 65 74 73 20 75 70 20 74 68 65       Sets up the
7b20: 20 74 68 72 65 61 64 20 73 6f 20 66 75 74 75 72   thread so futur
7b30: 65 20 63 61 6c 6c 73 20 74 6f 20 54 63 6c 54 68  e calls to TclTh
7b40: 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b  readStorageDataK
7b50: 65 79 47 65 74 0a 2b 20 2a 20 20 20 20 20 20 77  eyGet.+ *      w
7b60: 69 74 68 20 74 68 69 73 20 6b 65 79 20 77 69 6c  ith this key wil
7b70: 6c 20 72 65 74 75 72 6e 20 74 68 65 20 64 61 74  l return the dat
7b80: 61 20 70 6f 69 6e 74 65 72 2e 0a 2b 20 2a 0a 2b  a pointer..+ *.+
7b90: 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d   *--------------
7ba0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7bb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7bc0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
7bd0: 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a  --------.+ */.+.
7be0: 2b 76 6f 69 64 0a 2b 54 63 6c 54 68 72 65 61 64  +void.+TclThread
7bf0: 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 53 65  StorageDataKeySe
7c00: 74 28 6b 65 79 50 74 72 2c 20 64 61 74 61 29 0a  t(keyPtr, data).
7c10: 2b 20 20 20 20 54 63 6c 5f 54 68 72 65 61 64 44  +    Tcl_ThreadD
7c20: 61 74 61 4b 65 79 20 2a 6b 65 79 50 74 72 3b 20  ataKey *keyPtr; 
7c30: 20 2f 2a 20 49 64 65 6e 74 69 66 69 65 72 20 66   /* Identifier f
7c40: 6f 72 20 74 68 65 20 64 61 74 61 20 63 68 75 6e  or the data chun
7c50: 6b 2c 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  k,.+            
7c60: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
7c70: 20 20 20 20 20 2a 20 72 65 61 6c 6c 79 20 28 70       * really (p
7c80: 74 68 72 65 61 64 5f 6b 65 79 5f 74 20 2a 2a 29  thread_key_t **)
7c90: 20 2a 2f 0a 2b 20 20 20 20 76 6f 69 64 20 2a 64   */.+    void *d
7ca0: 61 74 61 3b 20 20 20 20 20 20 20 20 20 20 20 20  ata;            
7cb0: 20 20 20 20 20 2f 2a 20 54 68 72 65 61 64 20 6c       /* Thread l
7cc0: 6f 63 61 6c 20 73 74 6f 72 61 67 65 20 2a 2f 0a  ocal storage */.
7cd0: 2b 7b 0a 2b 20 20 20 20 69 6e 74 20 2a 69 6e 64  +{.+    int *ind
7ce0: 65 78 50 74 72 20 3d 20 2a 28 69 6e 74 20 2a 2a  exPtr = *(int **
7cf0: 29 6b 65 79 50 74 72 3b 0a 2b 20 20 20 20 54 63  )keyPtr;.+    Tc
7d00: 6c 5f 54 68 72 65 61 64 49 64 20 69 64 20 3d 20  l_ThreadId id = 
7d10: 54 63 6c 5f 47 65 74 43 75 72 72 65 6e 74 54 68  Tcl_GetCurrentTh
7d20: 72 65 61 64 28 29 3b 0a 2b 20 20 20 20 54 63 6c  read();.+    Tcl
7d30: 5f 48 61 73 68 54 61 62 6c 65 20 2a 68 61 73 68  _HashTable *hash
7d40: 54 61 62 6c 65 50 74 72 3b 0a 2b 20 20 20 20 54  TablePtr;.+    T
7d50: 63 6c 5f 48 61 73 68 45 6e 74 72 79 20 2a 68 50  cl_HashEntry *hP
7d60: 74 72 3b 0a 2b 20 20 20 20 69 6e 74 20 6e 65 77  tr;.+    int new
7d70: 3b 0a 2b 0a 2b 20 20 20 20 68 61 73 68 54 61 62  ;.+.+    hashTab
7d80: 6c 65 50 74 72 20 3d 20 54 63 6c 54 68 72 65 61  lePtr = TclThrea
7d90: 64 53 74 6f 72 61 67 65 47 65 74 48 61 73 68 54  dStorageGetHashT
7da0: 61 62 6c 65 28 69 64 29 3b 0a 2b 0a 2b 20 20 20  able(id);.+.+   
7db0: 20 69 66 20 28 68 61 73 68 54 61 62 6c 65 50 74   if (hashTablePt
7dc0: 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20  r != NULL) {.+  
7dd0: 20 20 20 20 20 20 68 50 74 72 20 3d 20 54 63 6c        hPtr = Tcl
7de0: 5f 46 69 6e 64 48 61 73 68 45 6e 74 72 79 28 68  _FindHashEntry(h
7df0: 61 73 68 54 61 62 6c 65 50 74 72 2c 20 28 63 68  ashTablePtr, (ch
7e00: 61 72 20 2a 29 2a 69 6e 64 65 78 50 74 72 29 3b  ar *)*indexPtr);
7e10: 0a 2b 0a 2b 20 20 20 20 20 20 20 20 2f 2a 20 64  .+.+        /* d
7e20: 6f 65 73 20 74 68 65 20 69 74 65 6d 20 6e 65 65  oes the item nee
7e30: 64 20 74 6f 20 62 65 20 63 72 65 61 74 65 64 3f  d to be created?
7e40: 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 69 66 20   */.+        if 
7e50: 28 68 50 74 72 20 3d 3d 20 4e 55 4c 4c 29 20 7b  (hPtr == NULL) {
7e60: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 68 50  .+            hP
7e70: 74 72 20 3d 20 54 63 6c 5f 43 72 65 61 74 65 48  tr = Tcl_CreateH
7e80: 61 73 68 45 6e 74 72 79 28 68 61 73 68 54 61 62  ashEntry(hashTab
7e90: 6c 65 50 74 72 2c 20 28 63 68 61 72 20 2a 29 2a  lePtr, (char *)*
7ea0: 69 6e 64 65 78 50 74 72 2c 20 26 6e 65 77 29 3b  indexPtr, &new);
7eb0: 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b 0a 2b 20  .+        }.+.+ 
7ec0: 20 20 20 20 20 20 20 69 66 20 28 68 50 74 72 20         if (hPtr 
7ed0: 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20  != NULL) {.+    
7ee0: 20 20 20 20 20 20 20 20 54 63 6c 5f 53 65 74 48          Tcl_SetH
7ef0: 61 73 68 56 61 6c 75 65 28 68 50 74 72 2c 20 64  ashValue(hPtr, d
7f00: 61 74 61 29 3b 0a 2b 20 20 20 20 20 20 20 20 7d  ata);.+        }
7f10: 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20   else {.+       
7f20: 20 20 20 20 20 54 63 6c 5f 50 61 6e 69 63 28 22       Tcl_Panic("
7f30: 63 6f 75 6c 64 20 6e 6f 74 20 73 65 74 20 68 61  could not set ha
7f40: 73 68 20 65 6e 74 72 79 20 76 61 6c 75 65 20 66  sh entry value f
7f50: 72 6f 6d 20 54 63 6c 54 68 72 65 61 64 53 74 6f  rom TclThreadSto
7f60: 72 61 67 65 44 61 74 61 4b 65 79 53 65 74 22 29  rageDataKeySet")
7f70: 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a 2b 20 20  ;.+        }.+  
7f80: 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 20 20    } else {.+    
7f90: 20 20 20 20 54 63 6c 5f 50 61 6e 69 63 28 22 54      Tcl_Panic("T
7fa0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 47  clThreadStorageG
7fb0: 65 74 48 61 73 68 54 61 62 6c 65 20 66 61 69 6c  etHashTable fail
7fc0: 65 64 20 66 72 6f 6d 20 54 63 6c 54 68 72 65 61  ed from TclThrea
7fd0: 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79 53  dStorageDataKeyS
7fe0: 65 74 21 22 29 3b 0a 2b 20 20 20 20 7d 0a 2b 7d  et!");.+    }.+}
7ff0: 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d  .+..+/*.+ *-----
8000: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8030: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8040: 2d 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c 46 69 6e  -.+ *.+ * TclFin
8050: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
8060: 67 65 54 68 72 65 61 64 20 2d 2d 0a 2b 20 2a 0a  geThread --.+ *.
8070: 2b 20 2a 20 20 20 20 20 20 54 68 69 73 20 70 72  + *      This pr
8080: 6f 63 65 64 75 72 65 20 63 6c 65 61 6e 73 20 75  ocedure cleans u
8090: 70 20 74 68 65 20 74 68 72 65 61 64 20 73 74 6f  p the thread sto
80a0: 72 61 67 65 20 68 61 73 68 20 74 61 62 6c 65 20  rage hash table 
80b0: 66 6f 72 20 74 68 65 0a 2b 20 2a 20 20 20 20 20  for the.+ *     
80c0: 20 73 70 65 63 69 66 69 65 64 20 74 68 72 65 61   specified threa
80d0: 64 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73 75 6c  d..+ *.+ * Resul
80e0: 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 4e 6f 6e  ts:.+ *      Non
80f0: 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64 65 20  e..+ *.+ * Side 
8100: 65 66 66 65 63 74 73 3a 0a 2b 20 2a 20 20 20 20  effects:.+ *    
8110: 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d    None..+ *.+ *-
8120: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8130: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8140: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8150: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8160: 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 76 6f 69 64  -----.+ */.+void
8170: 0a 2b 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72  .+TclFinalizeThr
8180: 65 61 64 53 74 6f 72 61 67 65 54 68 72 65 61 64  eadStorageThread
8190: 28 69 64 29 0a 2b 20 20 20 20 54 63 6c 5f 54 68  (id).+    Tcl_Th
81a0: 72 65 61 64 49 64 20 69 64 3b 20 20 20 20 2f 2a  readId id;    /*
81b0: 20 49 64 20 6f 66 20 74 68 65 20 74 68 72 65 61   Id of the threa
81c0: 64 20 74 6f 20 66 69 6e 61 6c 69 7a 65 20 2a 2f  d to finalize */
81d0: 0a 2b 7b 0a 2b 20 20 20 20 69 6e 74 20 69 6e 64  .+{.+    int ind
81e0: 65 78 20 3d 20 28 69 6e 74 29 69 64 20 25 20 53  ex = (int)id % S
81f0: 54 4f 52 41 47 45 5f 43 41 43 48 45 5f 53 4c 4f  TORAGE_CACHE_SLO
8200: 54 53 3b 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73  TS;.+    Tcl_Has
8210: 68 54 61 62 6c 65 20 2a 68 61 73 68 54 61 62 6c  hTable *hashTabl
8220: 65 50 74 72 3b 20 2f 2a 20 68 61 73 68 20 74 61  ePtr; /* hash ta
8230: 62 6c 65 20 66 6f 72 20 63 75 72 72 65 6e 74 20  ble for current 
8240: 74 68 72 65 61 64 20 2a 2f 0a 2b 20 20 20 20 54  thread */.+    T
8250: 63 6c 5f 48 61 73 68 45 6e 74 72 79 20 2a 68 50  cl_HashEntry *hP
8260: 74 72 3b 20 20 2f 2a 20 68 61 73 68 20 65 6e 74  tr;  /* hash ent
8270: 72 79 20 66 6f 72 20 63 75 72 72 65 6e 74 20 74  ry for current t
8280: 68 72 65 61 64 20 69 6e 20 6d 61 73 74 65 72 20  hread in master 
8290: 74 61 62 6c 65 20 2a 2f 0a 2b 0a 2b 20 20 20 20  table */.+.+    
82a0: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
82b0: 4c 6f 63 6b 28 29 3b 0a 2b 20 20 20 20 69 66 20  Lock();.+    if 
82c0: 28 74 68 72 65 61 64 53 74 6f 72 61 67 65 48 61  (threadStorageHa
82d0: 73 68 54 61 62 6c 65 50 74 72 20 21 3d 20 4e 55  shTablePtr != NU
82e0: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 68  LL) {.+        h
82f0: 50 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 48 61  Ptr = Tcl_FindHa
8300: 73 68 45 6e 74 72 79 28 74 68 72 65 61 64 53 74  shEntry(threadSt
8310: 6f 72 61 67 65 48 61 73 68 54 61 62 6c 65 50 74  orageHashTablePt
8320: 72 2c 20 28 63 68 61 72 20 2a 29 69 64 29 3b 0a  r, (char *)id);.
8330: 2b 0a 2b 20 20 20 20 20 20 20 20 69 66 20 28 68  +.+        if (h
8340: 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b  Ptr != NULL) {.+
8350: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 77              /* w
8360: 65 20 66 6f 75 6e 64 20 69 74 2c 20 65 78 74 72  e found it, extr
8370: 61 63 74 20 74 68 65 20 68 61 73 68 20 74 61 62  act the hash tab
8380: 6c 65 20 70 6f 69 6e 74 65 72 2e 20 2a 2f 0a 2b  le pointer. */.+
8390: 20 20 20 20 20 20 20 20 20 20 20 20 68 61 73 68              hash
83a0: 54 61 62 6c 65 50 74 72 20 3d 20 54 63 6c 5f 47  TablePtr = Tcl_G
83b0: 65 74 48 61 73 68 56 61 6c 75 65 28 68 50 74 72  etHashValue(hPtr
83c0: 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 20 20  );.+.+          
83d0: 20 20 69 66 20 28 68 61 73 68 54 61 62 6c 65 50    if (hashTableP
83e0: 74 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20  tr != NULL) {.+ 
83f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f                 /
8400: 2a 20 64 65 6c 65 74 65 20 74 68 72 65 61 64 20  * delete thread 
8410: 73 70 65 63 69 66 69 63 20 68 61 73 68 20 74 61  specific hash ta
8420: 62 6c 65 20 61 6e 64 20 66 72 65 65 20 74 68 65  ble and free the
8430: 20 73 74 72 75 63 74 2e 20 2a 2f 0a 2b 20 20 20   struct. */.+   
8440: 20 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c               Tcl
8450: 5f 44 65 6c 65 74 65 48 61 73 68 54 61 62 6c 65  _DeleteHashTable
8460: 28 68 61 73 68 54 61 62 6c 65 50 74 72 29 3b 0a  (hashTablePtr);.
8470: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
8480: 20 54 63 6c 70 53 79 73 46 72 65 65 28 28 63 68   TclpSysFree((ch
8490: 61 72 20 2a 29 68 61 73 68 54 61 62 6c 65 50 74  ar *)hashTablePt
84a0: 72 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20  r);.+           
84b0: 20 7d 0a 2b 0a 2b 20 20 20 20 20 20 20 20 20 20   }.+.+          
84c0: 20 20 2f 2a 20 64 65 6c 65 74 65 20 74 68 72 65    /* delete thre
84d0: 61 64 20 73 70 65 63 69 66 69 63 20 65 6e 74 72  ad specific entr
84e0: 79 20 66 72 6f 6d 20 6d 61 73 74 65 72 20 68 61  y from master ha
84f0: 73 68 20 74 61 62 6c 65 2e 20 2a 2f 0a 2b 20 20  sh table. */.+  
8500: 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f 44 65            Tcl_De
8510: 6c 65 74 65 48 61 73 68 45 6e 74 72 79 28 68 50  leteHashEntry(hP
8520: 74 72 29 3b 0a 2b 20 20 20 20 20 20 20 20 7d 0a  tr);.+        }.
8530: 2b 20 20 20 20 7d 0a 2b 0a 2b 20 20 20 20 2f 2a  +    }.+.+    /*
8540: 0a 2b 20 20 20 20 20 2a 20 4d 61 6b 65 20 73 75  .+     * Make su
8550: 72 65 20 63 61 63 68 65 20 65 6e 74 72 79 20 66  re cache entry f
8560: 6f 72 20 74 68 69 73 20 74 68 72 65 61 64 20 69  or this thread i
8570: 73 20 4e 55 4c 4c 2e 0a 2b 20 20 20 20 20 2a 2f  s NULL..+     */
8580: 0a 2b 20 20 20 20 69 66 20 28 74 68 72 65 61 64  .+    if (thread
8590: 53 74 6f 72 61 67 65 43 61 63 68 65 5b 69 6e 64  StorageCache[ind
85a0: 65 78 5d 2e 69 64 20 3d 3d 20 69 64 29 20 7b 0a  ex].id == id) {.
85b0: 2b 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20 20  +        /*.+   
85c0: 20 20 20 20 20 20 2a 20 57 65 20 64 6f 20 6e 6f        * We do no
85d0: 74 20 73 74 65 70 20 6f 6e 20 61 6e 6f 74 68 65  t step on anothe
85e0: 72 20 74 68 72 65 61 64 27 73 20 63 61 63 68 65  r thread's cache
85f0: 20 65 6e 74 72 79 2e 0a 2b 20 20 20 20 20 20 20   entry..+       
8600: 20 20 2a 20 54 68 69 73 20 69 73 20 65 73 70 65    * This is espe
8610: 63 69 61 6c 6c 79 20 69 6d 70 6f 72 74 61 6e 74  cially important
8620: 20 69 66 20 77 65 20 61 72 65 20 63 72 65 61 74   if we are creat
8630: 69 6e 67 0a 2b 20 20 20 20 20 20 20 20 20 2a 20  ing.+         * 
8640: 61 6e 64 20 65 78 69 74 69 6e 67 20 61 20 6c 6f  and exiting a lo
8650: 74 20 6f 66 20 74 68 72 65 61 64 73 2e 0a 2b 20  t of threads..+ 
8660: 20 20 20 20 20 20 20 20 2a 2f 0a 2b 20 20 20 20          */.+    
8670: 20 20 20 20 74 68 72 65 61 64 53 74 6f 72 61 67      threadStorag
8680: 65 43 61 63 68 65 5b 69 6e 64 65 78 5d 2e 69 64  eCache[index].id
8690: 20 3d 20 53 54 4f 52 41 47 45 5f 49 4e 56 41 4c   = STORAGE_INVAL
86a0: 49 44 5f 54 48 52 45 41 44 3b 0a 2b 20 20 20 20  ID_THREAD;.+    
86b0: 20 20 20 20 74 68 72 65 61 64 53 74 6f 72 61 67      threadStorag
86c0: 65 43 61 63 68 65 5b 69 6e 64 65 78 5d 2e 68 61  eCache[index].ha
86d0: 73 68 54 61 62 6c 65 50 74 72 20 3d 20 4e 55 4c  shTablePtr = NUL
86e0: 4c 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 54  L;.+    }.+    T
86f0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 55  clThreadStorageU
8700: 6e 6c 6f 63 6b 28 29 3b 0a 2b 7d 0a 2b 0c 0a 2b  nlock();.+}.+..+
8710: 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  /*.+ *----------
8720: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8730: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8740: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8750: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a  ------------.+ *
8760: 0a 2b 20 2a 20 54 63 6c 46 69 6e 61 6c 69 7a 65  .+ * TclFinalize
8770: 54 68 72 65 61 64 53 74 6f 72 61 67 65 20 2d 2d  ThreadStorage --
8780: 0a 2b 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 68  .+ *.+ *      Th
8790: 69 73 20 70 72 6f 63 65 64 75 72 65 20 63 6c 65  is procedure cle
87a0: 61 6e 73 20 75 70 20 74 68 65 20 6d 61 73 74 65  ans up the maste
87b0: 72 20 74 68 72 65 61 64 20 73 74 6f 72 61 67 65  r thread storage
87c0: 20 68 61 73 68 20 74 61 62 6c 65 2c 0a 2b 20 2a   hash table,.+ *
87d0: 20 20 20 20 20 20 61 6c 6c 20 74 68 72 65 61 64        all thread
87e0: 20 73 70 65 63 69 66 69 63 20 68 61 73 68 20 74   specific hash t
87f0: 61 62 6c 65 73 2c 20 61 6e 64 20 74 68 65 20 74  ables, and the t
8800: 68 72 65 61 64 20 73 74 6f 72 61 67 65 20 63 61  hread storage ca
8810: 63 68 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73  che..+ *.+ * Res
8820: 75 6c 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 4e  ults:.+ *      N
8830: 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64  one..+ *.+ * Sid
8840: 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 20 20  e effects:.+ *  
8850: 20 20 20 20 54 68 65 20 6d 61 73 74 65 72 20 74      The master t
8860: 68 72 65 61 64 20 73 74 6f 72 61 67 65 20 68 61  hread storage ha
8870: 73 68 20 74 61 62 6c 65 20 61 6e 64 20 74 68 72  sh table and thr
8880: 65 61 64 20 73 74 6f 72 61 67 65 20 63 61 63 68  ead storage cach
8890: 65 20 61 72 65 0a 2b 20 2a 20 20 20 20 20 20 72  e are.+ *      r
88a0: 65 73 65 74 20 74 6f 20 74 68 65 69 72 20 69 6e  eset to their in
88b0: 69 74 69 61 6c 20 28 65 6d 70 74 79 29 20 73 74  itial (empty) st
88c0: 61 74 65 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d  ate..+ *.+ *----
88d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
88e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
88f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8900: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
8910: 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76 6f 69 64 0a  --.+ */.+.+void.
8920: 2b 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65  +TclFinalizeThre
8930: 61 64 53 74 6f 72 61 67 65 28 29 0a 2b 7b 0a 2b  adStorage().+{.+
8940: 20 20 20 20 54 63 6c 5f 48 61 73 68 54 61 62 6c      Tcl_HashTabl
8950: 65 20 2a 68 61 73 68 54 61 62 6c 65 50 74 72 3b  e *hashTablePtr;
8960: 20 2f 2a 20 68 61 73 68 20 74 61 62 6c 65 20 66   /* hash table f
8970: 6f 72 20 63 75 72 72 65 6e 74 20 74 68 72 65 61  or current threa
8980: 64 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61  d */.+    Tcl_Ha
8990: 73 68 53 65 61 72 63 68 20 73 65 61 72 63 68 3b  shSearch search;
89a0: 20 2f 2a 20 77 65 20 6e 65 65 64 20 74 6f 20 68   /* we need to h
89b0: 69 74 20 65 76 65 72 79 20 74 68 72 65 61 64 20  it every thread 
89c0: 77 69 74 68 20 74 68 69 73 20 73 65 61 72 63 68  with this search
89d0: 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73   */.+    Tcl_Has
89e0: 68 45 6e 74 72 79 20 2a 68 50 74 72 3b 20 20 2f  hEntry *hPtr;  /
89f0: 2a 20 68 61 73 68 20 65 6e 74 72 79 20 66 6f 72  * hash entry for
8a00: 20 63 75 72 72 65 6e 74 20 74 68 72 65 61 64 20   current thread 
8a10: 69 6e 20 6d 61 73 74 65 72 20 74 61 62 6c 65 20  in master table 
8a20: 2a 2f 0a 2b 0a 2b 20 20 20 20 54 63 6c 54 68 72  */.+.+    TclThr
8a30: 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 28 29  eadStorageLock()
8a40: 3b 0a 2b 20 20 20 20 69 66 20 28 74 68 72 65 61  ;.+    if (threa
8a50: 64 53 74 6f 72 61 67 65 48 61 73 68 54 61 62 6c  dStorageHashTabl
8a60: 65 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a  ePtr != NULL) {.
8a70: 2b 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20 20  +        /*.+   
8a80: 20 20 20 20 20 20 2a 20 57 65 20 61 72 65 20 67        * We are g
8a90: 6f 69 6e 67 20 74 6f 20 64 65 6c 65 74 65 20 74  oing to delete t
8aa0: 68 65 20 68 61 73 68 20 74 61 62 6c 65 20 66 6f  he hash table fo
8ab0: 72 20 65 76 65 72 79 20 74 68 72 65 61 64 20 6e  r every thread n
8ac0: 6f 77 2e 20 54 68 69 73 0a 2b 20 20 20 20 20 20  ow. This.+      
8ad0: 20 20 20 2a 20 68 61 73 68 20 74 61 62 6c 65 20     * hash table 
8ae0: 73 68 6f 75 6c 64 20 62 65 20 65 6d 70 74 79 20  should be empty 
8af0: 61 74 20 74 68 69 73 20 70 6f 69 6e 74 2c 20 65  at this point, e
8b00: 78 63 65 70 74 20 66 6f 72 20 6f 6e 65 20 65 6e  xcept for one en
8b10: 74 72 79 0a 2b 20 20 20 20 20 20 20 20 20 2a 20  try.+         * 
8b20: 66 6f 72 20 74 68 65 20 63 75 72 72 65 6e 74 20  for the current 
8b30: 74 68 72 65 61 64 2e 0a 2b 20 20 20 20 20 20 20  thread..+       
8b40: 20 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 66 6f    */.+        fo
8b50: 72 20 28 68 50 74 72 20 3d 20 54 63 6c 5f 46 69  r (hPtr = Tcl_Fi
8b60: 72 73 74 48 61 73 68 45 6e 74 72 79 28 74 68 72  rstHashEntry(thr
8b70: 65 61 64 53 74 6f 72 61 67 65 48 61 73 68 54 61  eadStorageHashTa
8b80: 62 6c 65 50 74 72 2c 20 26 73 65 61 72 63 68 29  blePtr, &search)
8b90: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  ;.+             
8ba0: 20 20 20 68 50 74 72 20 21 3d 20 4e 55 4c 4c 3b     hPtr != NULL;
8bb0: 20 68 50 74 72 20 3d 20 54 63 6c 5f 4e 65 78 74   hPtr = Tcl_Next
8bc0: 48 61 73 68 45 6e 74 72 79 28 26 73 65 61 72 63  HashEntry(&searc
8bd0: 68 29 29 20 7b 0a 2b 0a 2b 20 20 20 20 20 20 20  h)) {.+.+       
8be0: 20 20 20 20 20 2f 2a 20 67 65 74 20 74 68 65 20       /* get the 
8bf0: 68 61 73 68 20 74 61 62 6c 65 20 63 6f 72 72 65  hash table corre
8c00: 73 70 6f 6e 64 69 6e 67 20 74 6f 20 74 68 65 20  sponding to the 
8c10: 74 68 72 65 61 64 20 69 6e 20 71 75 65 73 74 69  thread in questi
8c20: 6f 6e 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20  on. */.+        
8c30: 20 20 20 20 68 61 73 68 54 61 62 6c 65 50 74 72      hashTablePtr
8c40: 20 3d 20 54 63 6c 5f 47 65 74 48 61 73 68 56 61   = Tcl_GetHashVa
8c50: 6c 75 65 28 68 50 74 72 29 3b 0a 2b 0a 2b 20 20  lue(hPtr);.+.+  
8c60: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 68 61            if (ha
8c70: 73 68 54 61 62 6c 65 50 74 72 20 21 3d 20 4e 55  shTablePtr != NU
8c80: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20  LL) {.+         
8c90: 20 20 20 20 20 20 20 2f 2a 20 64 65 6c 65 74 65         /* delete
8ca0: 20 74 68 72 65 61 64 20 73 70 65 63 69 66 69 63   thread specific
8cb0: 20 68 61 73 68 20 74 61 62 6c 65 20 61 6e 64 20   hash table and 
8cc0: 66 72 65 65 20 74 68 65 20 73 74 72 75 63 74 2e  free the struct.
8cd0: 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20 20   */.+           
8ce0: 20 20 20 20 20 54 63 6c 5f 44 65 6c 65 74 65 48       Tcl_DeleteH
8cf0: 61 73 68 54 61 62 6c 65 28 68 61 73 68 54 61 62  ashTable(hashTab
8d00: 6c 65 50 74 72 29 3b 0a 2b 20 20 20 20 20 20 20  lePtr);.+       
8d10: 20 20 20 20 20 20 20 20 20 54 63 6c 70 53 79 73           TclpSys
8d20: 46 72 65 65 28 28 63 68 61 72 20 2a 29 68 61 73  Free((char *)has
8d30: 68 54 61 62 6c 65 50 74 72 29 3b 0a 2b 20 20 20  hTablePtr);.+   
8d40: 20 20 20 20 20 20 20 20 20 7d 0a 2b 0a 2b 20 20           }.+.+  
8d50: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 64 65 6c            /* del
8d60: 65 74 65 20 74 68 72 65 61 64 20 73 70 65 63 69  ete thread speci
8d70: 66 69 63 20 65 6e 74 72 79 20 66 72 6f 6d 20 6d  fic entry from m
8d80: 61 73 74 65 72 20 68 61 73 68 20 74 61 62 6c 65  aster hash table
8d90: 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20  . */.+          
8da0: 20 20 54 63 6c 5f 53 65 74 48 61 73 68 56 61 6c    Tcl_SetHashVal
8db0: 75 65 28 68 50 74 72 2c 20 4e 55 4c 4c 29 3b 0a  ue(hPtr, NULL);.
8dc0: 2b 20 20 20 20 20 20 20 20 7d 0a 2b 0a 2b 20 20  +        }.+.+  
8dd0: 20 20 20 20 20 20 54 63 6c 5f 44 65 6c 65 74 65        Tcl_Delete
8de0: 48 61 73 68 54 61 62 6c 65 28 74 68 72 65 61 64  HashTable(thread
8df0: 53 74 6f 72 61 67 65 48 61 73 68 54 61 62 6c 65  StorageHashTable
8e00: 50 74 72 29 3b 0a 2b 20 20 20 20 20 20 20 20 54  Ptr);.+        T
8e10: 63 6c 70 53 79 73 46 72 65 65 28 28 63 68 61 72  clpSysFree((char
8e20: 20 2a 29 74 68 72 65 61 64 53 74 6f 72 61 67 65   *)threadStorage
8e30: 48 61 73 68 54 61 62 6c 65 50 74 72 29 3b 0a 2b  HashTablePtr);.+
8e40: 0a 2b 20 20 20 20 20 20 20 20 2f 2a 20 72 65 73  .+        /* res
8e50: 65 74 20 74 68 69 73 20 73 6f 20 74 68 61 74 20  et this so that 
8e60: 6e 65 78 74 20 74 69 6d 65 20 61 72 6f 75 6e 64  next time around
8e70: 20 77 65 20 6b 6e 6f 77 20 69 74 27 73 20 6e 6f   we know it's no
8e80: 74 20 76 61 6c 69 64 2e 20 2a 2f 0a 2b 20 20 20  t valid. */.+   
8e90: 20 20 20 20 20 74 68 72 65 61 64 53 74 6f 72 61       threadStora
8ea0: 67 65 48 61 73 68 54 61 62 6c 65 50 74 72 20 3d  geHashTablePtr =
8eb0: 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 7d 0a 2b 0a   NULL;.+    }.+.
8ec0: 2b 20 20 20 20 2f 2a 20 63 6c 65 61 72 20 6f 75  +    /* clear ou
8ed0: 74 20 74 68 65 20 74 68 72 65 61 64 20 73 74 6f  t the thread sto
8ee0: 72 61 67 65 20 63 61 63 68 65 20 61 73 20 77 65  rage cache as we
8ef0: 6c 6c 20 2a 2f 0a 2b 20 20 20 20 6d 65 6d 73 65  ll */.+    memse
8f00: 74 28 28 54 68 72 65 61 64 53 74 6f 72 61 67 65  t((ThreadStorage
8f10: 20 2a 29 26 74 68 72 65 61 64 53 74 6f 72 61 67   *)&threadStorag
8f20: 65 43 61 63 68 65 2c 20 30 2c 20 73 69 7a 65 6f  eCache, 0, sizeo
8f30: 66 28 54 68 72 65 61 64 53 74 6f 72 61 67 65 29  f(ThreadStorage)
8f40: 20 2a 20 53 54 4f 52 41 47 45 5f 43 41 43 48 45   * STORAGE_CACHE
8f50: 5f 53 4c 4f 54 53 29 3b 0a 2b 0a 2b 20 20 20 20  _SLOTS);.+.+    
8f60: 2f 2a 20 72 65 73 65 74 20 74 68 69 73 20 74 6f  /* reset this to
8f70: 20 7a 65 72 6f 2c 20 69 74 20 77 69 6c 6c 20 62   zero, it will b
8f80: 65 20 73 65 74 20 74 6f 20 53 54 4f 52 41 47 45  e set to STORAGE
8f90: 5f 46 49 52 53 54 5f 4b 45 59 20 69 66 20 74 68  _FIRST_KEY if th
8fa0: 65 20 0a 2b 20 20 20 20 20 20 20 74 68 72 65 61  e .+       threa
8fb0: 64 20 73 74 6f 72 61 67 65 20 73 75 62 73 79 73  d storage subsys
8fc0: 74 65 6d 20 67 65 74 73 20 72 65 69 6e 69 74 69  tem gets reiniti
8fd0: 61 6c 69 7a 65 64 20 2a 2f 20 20 20 20 20 20 20  alized */       
8fe0: 0a 2b 20 20 20 20 6e 65 78 74 54 68 72 65 61 64  .+    nextThread
8ff0: 53 74 6f 72 61 67 65 4b 65 79 20 3d 20 53 54 4f  StorageKey = STO
9000: 52 41 47 45 5f 49 4e 56 41 4c 49 44 5f 4b 45 59  RAGE_INVALID_KEY
9010: 3b 0a 2b 0a 2b 20 20 20 20 54 63 6c 54 68 72 65  ;.+.+    TclThre
9020: 61 64 53 74 6f 72 61 67 65 55 6e 6c 6f 63 6b 28  adStorageUnlock(
9030: 29 3b 0a 2b 7d 0a 2b 0c 0a 2b 2f 2a 0a 2b 20 2a  );.+}.+..+/*.+ *
9040: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9050: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9060: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9070: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9080: 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 54  ------.+ *.+ * T
9090: 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64  clFinalizeThread
90a0: 53 74 6f 72 61 67 65 44 61 74 61 20 2d 2d 0a 2b  StorageData --.+
90b0: 20 2a 0a 2b 20 2a 20 20 20 20 20 20 54 68 69 73   *.+ *      This
90c0: 20 70 72 6f 63 65 64 75 72 65 20 63 6c 65 61 6e   procedure clean
90d0: 73 20 75 70 20 74 68 65 20 74 68 72 65 61 64 2d  s up the thread-
90e0: 6c 6f 63 61 6c 20 73 74 6f 72 61 67 65 2e 20 20  local storage.  
90f0: 54 68 69 73 20 69 73 0a 2b 20 2a 20 20 20 20 20  This is.+ *     
9100: 20 63 61 6c 6c 65 64 20 6f 6e 63 65 20 66 6f 72   called once for
9110: 20 65 61 63 68 20 74 68 72 65 61 64 2e 0a 2b 20   each thread..+ 
9120: 2a 0a 2b 20 2a 20 52 65 73 75 6c 74 73 3a 0a 2b  *.+ * Results:.+
9130: 20 2a 20 20 20 20 20 20 4e 6f 6e 65 2e 0a 2b 20   *      None..+ 
9140: 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66 66 65 63  *.+ * Side effec
9150: 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 46 72 65  ts:.+ *      Fre
9160: 65 73 20 75 70 20 74 68 65 20 6d 65 6d 6f 72 79  es up the memory
9170: 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d  ..+ *.+ *-------
9180: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9190: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
91a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
91b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a  ---------------.
91c0: 2b 20 2a 2f 0a 2b 0a 2b 76 6f 69 64 0a 2b 54 63  + */.+.+void.+Tc
91d0: 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61 64 53  lFinalizeThreadS
91e0: 74 6f 72 61 67 65 44 61 74 61 28 6b 65 79 50 74  torageData(keyPt
91f0: 72 29 0a 2b 20 20 20 20 54 63 6c 5f 54 68 72 65  r).+    Tcl_Thre
9200: 61 64 44 61 74 61 4b 65 79 20 2a 6b 65 79 50 74  adDataKey *keyPt
9210: 72 3b 0a 2b 7b 0a 2b 20 20 20 20 76 6f 69 64 20  r;.+{.+    void 
9220: 2a 72 65 73 75 6c 74 3b 0a 2b 20 20 20 20 69 6e  *result;.+    in
9230: 74 20 2a 69 6e 64 65 78 50 74 72 3b 0a 2b 20 20  t *indexPtr;.+  
9240: 20 20 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69    Tcl_ThreadId i
9250: 64 20 3d 20 54 63 6c 5f 47 65 74 43 75 72 72 65  d = Tcl_GetCurre
9260: 6e 74 54 68 72 65 61 64 28 29 3b 0a 2b 20 20 20  ntThread();.+   
9270: 20 54 63 6c 5f 48 61 73 68 54 61 62 6c 65 20 2a   Tcl_HashTable *
9280: 68 61 73 68 54 61 62 6c 65 50 74 72 3b 20 2f 2a  hashTablePtr; /*
9290: 20 68 61 73 68 20 74 61 62 6c 65 20 66 6f 72 20   hash table for 
92a0: 63 75 72 72 65 6e 74 20 74 68 72 65 61 64 20 2a  current thread *
92b0: 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73 68 45  /.+    Tcl_HashE
92c0: 6e 74 72 79 20 2a 68 50 74 72 3b 20 2f 2a 20 68  ntry *hPtr; /* h
92d0: 61 73 68 20 65 6e 74 72 79 20 66 6f 72 20 64 61  ash entry for da
92e0: 74 61 20 6b 65 79 20 69 6e 20 63 75 72 72 65 6e  ta key in curren
92f0: 74 20 74 68 72 65 61 64 20 2a 2f 0a 2b 0a 2b 20  t thread */.+.+ 
9300: 20 20 20 69 66 20 28 2a 6b 65 79 50 74 72 20 21     if (*keyPtr !
9310: 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20  = NULL) {.+     
9320: 20 20 20 69 6e 64 65 78 50 74 72 20 3d 20 2a 28     indexPtr = *(
9330: 69 6e 74 20 2a 2a 29 6b 65 79 50 74 72 3b 0a 2b  int **)keyPtr;.+
9340: 0a 2b 20 20 20 20 20 20 20 20 68 61 73 68 54 61  .+        hashTa
9350: 62 6c 65 50 74 72 20 3d 20 54 63 6c 54 68 72 65  blePtr = TclThre
9360: 61 64 53 74 6f 72 61 67 65 47 65 74 48 61 73 68  adStorageGetHash
9370: 54 61 62 6c 65 28 69 64 29 3b 0a 2b 0a 2b 20 20  Table(id);.+.+  
9380: 20 20 20 20 20 20 69 66 20 28 68 61 73 68 54 61        if (hashTa
9390: 62 6c 65 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20  blePtr != NULL) 
93a0: 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 68  {.+            h
93b0: 50 74 72 20 3d 20 54 63 6c 5f 46 69 6e 64 48 61  Ptr = Tcl_FindHa
93c0: 73 68 45 6e 74 72 79 28 68 61 73 68 54 61 62 6c  shEntry(hashTabl
93d0: 65 50 74 72 2c 20 28 63 68 61 72 20 2a 29 2a 69  ePtr, (char *)*i
93e0: 6e 64 65 78 50 74 72 29 3b 0a 2b 0a 2b 20 20 20  ndexPtr);.+.+   
93f0: 20 20 20 20 20 20 20 20 20 69 66 20 28 68 50 74           if (hPt
9400: 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20  r != NULL) {.+  
9410: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65                re
9420: 73 75 6c 74 20 3d 20 54 63 6c 5f 47 65 74 48 61  sult = Tcl_GetHa
9430: 73 68 56 61 6c 75 65 28 68 50 74 72 29 3b 0a 2b  shValue(hPtr);.+
9440: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .+              
9450: 20 20 69 66 20 28 72 65 73 75 6c 74 20 21 3d 20    if (result != 
9460: 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20  NULL) {.+       
9470: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20               /* 
9480: 74 68 69 73 20 6d 75 73 74 20 62 65 20 63 6b 66  this must be ckf
9490: 72 65 65 20 62 65 63 61 75 73 65 20 74 63 6c 54  ree because tclT
94a0: 68 72 65 61 64 2e 63 20 0a 2b 20 20 20 20 20 20  hread.c .+      
94b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
94c0: 20 61 6c 6c 6f 63 61 74 65 73 20 74 68 65 73 65   allocates these
94d0: 20 75 73 69 6e 67 20 63 6b 61 6c 6c 6f 63 2e 20   using ckalloc. 
94e0: 2a 2f 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20  */.+            
94f0: 20 20 20 20 20 20 20 20 63 6b 66 72 65 65 28 28          ckfree((
9500: 63 68 61 72 20 2a 29 72 65 73 75 6c 74 29 3b 0a  char *)result);.
9510: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
9520: 20 7d 0a 2b 0a 2b 20 20 20 20 20 20 20 20 20 20   }.+.+          
9530: 20 20 20 20 20 20 54 63 6c 5f 53 65 74 48 61 73        Tcl_SetHas
9540: 68 56 61 6c 75 65 28 68 50 74 72 2c 20 4e 55 4c  hValue(hPtr, NUL
9550: 4c 29 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20  L);.+           
9560: 20 7d 0a 2b 20 20 20 20 20 20 20 20 7d 20 65 6c   }.+        } el
9570: 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20  se {.+          
9580: 20 20 54 63 6c 5f 50 61 6e 69 63 28 22 54 63 6c    Tcl_Panic("Tcl
9590: 54 68 72 65 61 64 53 74 6f 72 61 67 65 47 65 74  ThreadStorageGet
95a0: 48 61 73 68 54 61 62 6c 65 20 66 61 69 6c 65 64  HashTable failed
95b0: 20 66 72 6f 6d 20 54 63 6c 46 69 6e 61 6c 69 7a   from TclFinaliz
95c0: 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61  eThreadStorageDa
95d0: 74 61 21 22 29 3b 0a 2b 20 20 20 20 20 20 20 20  ta!");.+        
95e0: 7d 0a 2b 20 20 20 20 7d 0a 2b 7d 0a 2b 0c 0a 2b  }.+    }.+}.+..+
95f0: 2f 2a 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  /*.+ *----------
9600: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9610: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9620: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9630: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a  ------------.+ *
9640: 0a 2b 20 2a 20 54 63 6c 46 69 6e 61 6c 69 7a 65  .+ * TclFinalize
9650: 54 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74  ThreadStorageDat
9660: 61 4b 65 79 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20  aKey --.+ *.+ * 
9670: 20 20 20 20 20 54 68 69 73 20 70 72 6f 63 65 64       This proced
9680: 75 72 65 20 69 73 20 69 6e 76 6f 6b 65 64 20 74  ure is invoked t
9690: 6f 20 63 6c 65 61 6e 20 75 70 20 6f 6e 65 20 6b  o clean up one k
96a0: 65 79 2e 20 20 54 68 69 73 20 69 73 20 61 0a 2b  ey.  This is a.+
96b0: 20 2a 20 20 20 20 20 20 70 72 6f 63 65 73 73 2d   *      process-
96c0: 77 69 64 65 20 73 74 6f 72 61 67 65 20 69 64 65  wide storage ide
96d0: 6e 74 69 66 69 65 72 2e 20 20 54 68 65 20 74 68  ntifier.  The th
96e0: 72 65 61 64 20 66 69 6e 61 6c 69 7a 61 74 69 6f  read finalizatio
96f0: 6e 20 63 6f 64 65 0a 2b 20 2a 20 20 20 20 20 20  n code.+ *      
9700: 63 6c 65 61 6e 73 20 75 70 20 74 68 65 20 74 68  cleans up the th
9710: 72 65 61 64 20 6c 6f 63 61 6c 20 73 74 6f 72 61  read local stora
9720: 67 65 20 69 74 73 65 6c 66 2e 0a 2b 20 2a 0a 2b  ge itself..+ *.+
9730: 20 2a 20 20 20 20 20 20 54 68 69 73 20 61 73 73   *      This ass
9740: 75 6d 65 73 20 74 68 65 20 6d 61 73 74 65 72 20  umes the master 
9750: 6c 6f 63 6b 20 69 73 20 68 65 6c 64 2e 0a 2b 20  lock is held..+ 
9760: 2a 0a 2b 20 2a 20 52 65 73 75 6c 74 73 3a 0a 2b  *.+ * Results:.+
9770: 20 2a 20 20 20 20 20 20 4e 6f 6e 65 2e 0a 2b 20   *      None..+ 
9780: 2a 0a 2b 20 2a 20 53 69 64 65 20 65 66 66 65 63  *.+ * Side effec
9790: 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 54 68 65  ts:.+ *      The
97a0: 20 6b 65 79 20 69 73 20 64 65 61 6c 6c 6f 63 61   key is dealloca
97b0: 74 65 64 2e 0a 2b 20 2a 0a 2b 20 2a 2d 2d 2d 2d  ted..+ *.+ *----
97c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
97d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
97e0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
97f0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9800: 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76 6f 69 64 0a  --.+ */.+.+void.
9810: 2b 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65  +TclFinalizeThre
9820: 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79  adStorageDataKey
9830: 28 6b 65 79 50 74 72 29 0a 2b 20 20 20 20 54 63  (keyPtr).+    Tc
9840: 6c 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20  l_ThreadDataKey 
9850: 2a 6b 65 79 50 74 72 3b 0a 2b 7b 0a 2b 20 20 20  *keyPtr;.+{.+   
9860: 20 69 6e 74 20 2a 69 6e 64 65 78 50 74 72 3b 0a   int *indexPtr;.
9870: 2b 20 20 20 20 54 63 6c 5f 48 61 73 68 54 61 62  +    Tcl_HashTab
9880: 6c 65 20 2a 68 61 73 68 54 61 62 6c 65 50 74 72  le *hashTablePtr
9890: 3b 20 2f 2a 20 68 61 73 68 20 74 61 62 6c 65 20  ; /* hash table 
98a0: 66 6f 72 20 63 75 72 72 65 6e 74 20 74 68 72 65  for current thre
98b0: 61 64 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48  ad */.+    Tcl_H
98c0: 61 73 68 53 65 61 72 63 68 20 73 65 61 72 63 68  ashSearch search
98d0: 3b 20 2f 2a 20 77 65 20 6e 65 65 64 20 74 6f 20  ; /* we need to 
98e0: 68 69 74 20 65 76 65 72 79 20 74 68 72 65 61 64  hit every thread
98f0: 20 77 69 74 68 20 74 68 69 73 20 73 65 61 72 63   with this searc
9900: 68 20 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61  h */.+    Tcl_Ha
9910: 73 68 45 6e 74 72 79 20 2a 68 50 74 72 3b 20 2f  shEntry *hPtr; /
9920: 2a 20 68 61 73 68 20 65 6e 74 72 79 20 66 6f 72  * hash entry for
9930: 20 63 75 72 72 65 6e 74 20 74 68 72 65 61 64 20   current thread 
9940: 69 6e 20 6d 61 73 74 65 72 20 74 61 62 6c 65 20  in master table 
9950: 2a 2f 0a 2b 20 20 20 20 54 63 6c 5f 48 61 73 68  */.+    Tcl_Hash
9960: 45 6e 74 72 79 20 2a 68 44 61 74 61 50 74 72 3b  Entry *hDataPtr;
9970: 20 2f 2a 20 68 61 73 68 20 65 6e 74 72 79 20 66   /* hash entry f
9980: 6f 72 20 64 61 74 61 20 6b 65 79 20 69 6e 20 63  or data key in c
9990: 75 72 72 65 6e 74 20 74 68 72 65 61 64 20 2a 2f  urrent thread */
99a0: 0a 2b 0a 2b 20 20 20 20 69 66 20 28 2a 6b 65 79  .+.+    if (*key
99b0: 50 74 72 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 2b  Ptr != NULL) {.+
99c0: 20 20 20 20 20 20 20 20 69 6e 64 65 78 50 74 72          indexPtr
99d0: 20 3d 20 2a 28 69 6e 74 20 2a 2a 29 6b 65 79 50   = *(int **)keyP
99e0: 74 72 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 54  tr;.+.+        T
99f0: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 4c  clThreadStorageL
9a00: 6f 63 6b 28 29 3b 0a 2b 20 20 20 20 20 20 20 20  ock();.+        
9a10: 69 66 20 28 74 68 72 65 61 64 53 74 6f 72 61 67  if (threadStorag
9a20: 65 48 61 73 68 54 61 62 6c 65 50 74 72 20 21 3d  eHashTablePtr !=
9a30: 20 4e 55 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20   NULL) {.+      
9a40: 20 20 20 20 20 20 2f 2a 0a 2b 20 20 20 20 20 20        /*.+      
9a50: 20 20 20 20 20 20 20 2a 20 57 65 20 61 72 65 20         * We are 
9a60: 67 6f 69 6e 67 20 74 6f 20 64 65 6c 65 74 65 20  going to delete 
9a70: 74 68 65 20 73 70 65 63 69 66 69 65 64 20 64 61  the specified da
9a80: 74 61 20 6b 65 79 20 65 6e 74 72 79 20 66 72 6f  ta key entry fro
9a90: 6d 20 65 76 65 72 79 20 74 68 72 65 61 64 2e 0a  m every thread..
9aa0: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 2a 2f  +             */
9ab0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 66 6f  .+            fo
9ac0: 72 20 28 68 50 74 72 20 3d 20 54 63 6c 5f 46 69  r (hPtr = Tcl_Fi
9ad0: 72 73 74 48 61 73 68 45 6e 74 72 79 28 74 68 72  rstHashEntry(thr
9ae0: 65 61 64 53 74 6f 72 61 67 65 48 61 73 68 54 61  eadStorageHashTa
9af0: 62 6c 65 50 74 72 2c 20 26 73 65 61 72 63 68 29  blePtr, &search)
9b00: 3b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20  ;.+             
9b10: 20 20 20 20 20 20 20 68 50 74 72 20 21 3d 20 4e         hPtr != N
9b20: 55 4c 4c 3b 20 68 50 74 72 20 3d 20 54 63 6c 5f  ULL; hPtr = Tcl_
9b30: 4e 65 78 74 48 61 73 68 45 6e 74 72 79 28 26 73  NextHashEntry(&s
9b40: 65 61 72 63 68 29 29 20 7b 0a 2b 0a 2b 20 20 20  earch)) {.+.+   
9b50: 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20               /* 
9b60: 67 65 74 20 74 68 65 20 68 61 73 68 20 74 61 62  get the hash tab
9b70: 6c 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67  le corresponding
9b80: 20 74 6f 20 74 68 65 20 74 68 72 65 61 64 20 69   to the thread i
9b90: 6e 20 71 75 65 73 74 69 6f 6e 2e 20 2a 2f 0a 2b  n question. */.+
9ba0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9bb0: 68 61 73 68 54 61 62 6c 65 50 74 72 20 3d 20 54  hashTablePtr = T
9bc0: 63 6c 5f 47 65 74 48 61 73 68 56 61 6c 75 65 28  cl_GetHashValue(
9bd0: 68 50 74 72 29 3b 0a 2b 0a 2b 20 20 20 20 20 20  hPtr);.+.+      
9be0: 20 20 20 20 20 20 20 20 20 20 69 66 20 28 68 61            if (ha
9bf0: 73 68 54 61 62 6c 65 50 74 72 20 21 3d 20 4e 55  shTablePtr != NU
9c00: 4c 4c 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 20  LL) {.+         
9c10: 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 6e 6f             /* no
9c20: 77 20 66 69 6e 64 20 74 68 65 20 65 6e 74 72 79  w find the entry
9c30: 20 66 6f 72 20 74 68 65 20 73 70 65 63 69 66 69   for the specifi
9c40: 65 64 20 64 61 74 61 20 6b 65 79 2e 20 2a 2f 0a  ed data key. */.
9c50: 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  +               
9c60: 20 20 20 20 20 68 44 61 74 61 50 74 72 20 3d 20       hDataPtr = 
9c70: 54 63 6c 5f 46 69 6e 64 48 61 73 68 45 6e 74 72  Tcl_FindHashEntr
9c80: 79 28 68 61 73 68 54 61 62 6c 65 50 74 72 2c 20  y(hashTablePtr, 
9c90: 28 63 68 61 72 20 2a 29 2a 69 6e 64 65 78 50 74  (char *)*indexPt
9ca0: 72 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20 20 20  r);.+.+         
9cb0: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 68             if (h
9cc0: 44 61 74 61 50 74 72 20 21 3d 20 4e 55 4c 4c 29  DataPtr != NULL)
9cd0: 20 7b 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20   {.+            
9ce0: 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 64              /* d
9cf0: 65 6c 65 74 65 20 74 68 65 20 64 61 74 61 20 6b  elete the data k
9d00: 65 79 20 66 6f 72 20 74 68 69 73 20 74 68 72 65  ey for this thre
9d10: 61 64 2e 20 2a 2f 0a 2b 20 20 20 20 20 20 20 20  ad. */.+        
9d20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9d30: 54 63 6c 5f 44 65 6c 65 74 65 48 61 73 68 45 6e  Tcl_DeleteHashEn
9d40: 74 72 79 28 68 44 61 74 61 50 74 72 29 3b 0a 2b  try(hDataPtr);.+
9d50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
9d60: 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20 20 20      }.+         
9d70: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20         }.+      
9d80: 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 20 20 20        }.+       
9d90: 20 7d 0a 2b 20 20 20 20 20 20 20 20 54 63 6c 54   }.+        TclT
9da0: 68 72 65 61 64 53 74 6f 72 61 67 65 55 6e 6c 6f  hreadStorageUnlo
9db0: 63 6b 28 29 3b 0a 2b 0a 2b 20 20 20 20 20 20 20  ck();.+.+       
9dc0: 20 54 63 6c 70 53 79 73 46 72 65 65 28 28 63 68   TclpSysFree((ch
9dd0: 61 72 20 2a 29 69 6e 64 65 78 50 74 72 29 3b 0a  ar *)indexPtr);.
9de0: 2b 20 20 20 20 20 20 20 20 2a 6b 65 79 50 74 72  +        *keyPtr
9df0: 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 7d 0a   = NULL;.+    }.
9e00: 2b 7d 0a 2b 0a 2b 23 65 6c 73 65 20 2f 2a 20 21  +}.+.+#else /* !
9e10: 64 65 66 69 6e 65 64 28 54 43 4c 5f 54 48 52 45  defined(TCL_THRE
9e20: 41 44 53 29 20 7c 7c 20 21 64 65 66 69 6e 65 64  ADS) || !defined
9e30: 28 55 53 45 5f 54 48 52 45 41 44 5f 53 54 4f 52  (USE_THREAD_STOR
9e40: 41 47 45 29 20 2a 2f 20 0a 2b 0a 2b 73 74 61 74  AGE) */ .+.+stat
9e50: 69 63 20 76 6f 69 64 20 54 68 72 65 61 64 53 74  ic void ThreadSt
9e60: 6f 72 61 67 65 50 61 6e 69 63 20 5f 41 4e 53 49  oragePanic _ANSI
9e70: 5f 41 52 47 53 5f 28 28 0a 2b 20 20 20 20 20 20  _ARGS_((.+      
9e80: 20 20 20 20 43 4f 4e 53 54 20 63 68 61 72 20 2a      CONST char *
9e90: 6d 65 73 73 61 67 65 29 29 3b 0a 2b 0a 2b 2f 2a  message));.+.+/*
9ea0: 0a 2b 20 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  .+ *------------
9eb0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9ec0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9ed0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
9ee0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 0a 2b  ----------.+ *.+
9ef0: 20 2a 20 54 68 72 65 61 64 53 74 6f 72 61 67 65   * ThreadStorage
9f00: 50 61 6e 69 63 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a  Panic --.+ *.+ *
9f10: 20 20 20 20 20 20 50 61 6e 69 63 20 69 66 20 54        Panic if T
9f20: 63 6c 20 77 61 73 20 63 6f 6d 70 69 6c 65 64 20  cl was compiled 
9f30: 77 69 74 68 6f 75 74 20 54 43 4c 5f 54 48 52 45  without TCL_THRE
9f40: 41 44 53 20 6f 72 20 77 69 74 68 6f 75 74 20 0a  ADS or without .
9f50: 2b 20 2a 20 20 20 20 20 20 55 53 45 5f 54 48 52  + *      USE_THR
9f60: 45 41 44 5f 53 54 4f 52 41 47 45 20 61 6e 64 20  EAD_STORAGE and 
9f70: 61 20 74 68 72 65 61 64 20 73 74 6f 72 61 67 65  a thread storage
9f80: 20 66 75 6e 63 74 69 6f 6e 20 68 61 73 20 62 65   function has be
9f90: 65 6e 20 0a 2b 20 2a 20 20 20 20 20 20 63 61 6c  en .+ *      cal
9fa0: 6c 65 64 2e 0a 2b 20 2a 0a 2b 20 2a 20 52 65 73  led..+ *.+ * Res
9fb0: 75 6c 74 73 3a 0a 2b 20 2a 20 20 20 20 20 20 4e  ults:.+ *      N
9fc0: 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 53 69 64  one..+ *.+ * Sid
9fd0: 65 20 65 66 66 65 63 74 73 3a 0a 2b 20 2a 09 20  e effects:.+ *. 
9fe0: 20 20 20 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a     None..+ *.+ *
9ff0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
a000: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
a010: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
a020: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
a030: 2d 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 73 74 61  ------.+ */.+sta
a040: 74 69 63 20 76 6f 69 64 20 54 68 72 65 61 64 53  tic void ThreadS
a050: 74 6f 72 61 67 65 50 61 6e 69 63 28 6d 65 73 73  toragePanic(mess
a060: 61 67 65 29 0a 2b 20 20 20 20 43 4f 4e 53 54 20  age).+    CONST 
a070: 63 68 61 72 20 2a 6d 65 73 73 61 67 65 3b 20 2f  char *message; /
a080: 2a 20 63 75 72 72 65 6e 74 6c 79 20 69 67 6e 6f  * currently igno
a090: 72 65 64 20 2a 2f 0a 2b 7b 0a 2b 23 69 66 64 65  red */.+{.+#ifde
a0a0: 66 20 54 43 4c 5f 54 48 52 45 41 44 53 0a 2b 20  f TCL_THREADS.+ 
a0b0: 20 23 69 66 64 65 66 20 55 53 45 5f 54 48 52 45   #ifdef USE_THRE
a0c0: 41 44 5f 53 54 4f 52 41 47 45 0a 2b 20 20 20 20  AD_STORAGE.+    
a0d0: 2f 2a 20 0a 2b 20 20 20 20 20 2a 20 44 6f 20 6e  /* .+     * Do n
a0e0: 6f 74 68 69 6e 67 2c 20 65 76 65 72 79 74 68 69  othing, everythi
a0f0: 6e 67 20 69 73 20 4f 4b 2e 20 48 6f 77 65 76 65  ng is OK. Howeve
a100: 72 2c 20 74 68 69 73 20 73 68 6f 75 6c 64 20 6e  r, this should n
a110: 65 76 65 72 20 68 61 70 70 65 6e 20 0a 2b 20 20  ever happen .+  
a120: 20 20 20 2a 20 62 65 63 61 75 73 65 20 74 68 69     * because thi
a130: 73 20 66 75 6e 63 74 69 6f 6e 20 6f 6e 6c 79 20  s function only 
a140: 67 65 74 73 20 63 61 6c 6c 65 64 20 62 79 20 74  gets called by t
a150: 68 65 20 64 75 6d 6d 79 20 74 68 72 65 61 64 20  he dummy thread 
a160: 73 74 6f 72 61 67 65 20 0a 2b 20 20 20 20 20 2a  storage .+     *
a170: 20 66 75 6e 63 74 69 6f 6e 73 20 28 75 73 65 64   functions (used
a180: 20 77 68 65 6e 20 6f 6e 65 20 6f 72 20 62 6f 74   when one or bot
a190: 68 20 6f 66 20 74 68 65 73 65 20 44 45 46 49 4e  h of these DEFIN
a1a0: 45 53 20 61 72 65 20 6e 6f 74 20 70 72 65 73 65  ES are not prese
a1b0: 6e 74 29 2e 0a 2b 20 20 20 20 20 2a 2f 0a 2b 20  nt)..+     */.+ 
a1c0: 20 23 65 6c 73 65 0a 2b 20 20 20 20 54 63 6c 5f   #else.+    Tcl_
a1d0: 50 61 6e 69 63 28 22 54 63 6c 20 77 61 73 20 6e  Panic("Tcl was n
a1e0: 6f 74 20 63 6f 6d 70 69 6c 65 64 20 77 69 74 68  ot compiled with
a1f0: 20 74 68 72 65 61 64 20 73 74 6f 72 61 67 65 20   thread storage 
a200: 65 6e 61 62 6c 65 64 2e 22 29 3b 0a 2b 20 20 23  enabled.");.+  #
a210: 65 6e 64 69 66 0a 2b 23 65 6c 73 65 0a 2b 20 20  endif.+#else.+  
a220: 20 20 54 63 6c 5f 50 61 6e 69 63 28 22 54 63 6c    Tcl_Panic("Tcl
a230: 20 77 61 73 20 6e 6f 74 20 63 6f 6d 70 69 6c 65   was not compile
a240: 64 20 77 69 74 68 20 74 68 72 65 61 64 73 20 65  d with threads e
a250: 6e 61 62 6c 65 64 2e 22 29 3b 0a 2b 23 65 6e 64  nabled.");.+#end
a260: 69 66 0a 2b 7d 0a 2b 0c 0a 2b 76 6f 69 64 0a 2b  if.+}.+..+void.+
a270: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
a280: 4c 6f 63 6b 49 6e 69 74 28 29 0a 2b 7b 0a 2b 20  LockInit().+{.+ 
a290: 20 20 20 54 68 72 65 61 64 53 74 6f 72 61 67 65     ThreadStorage
a2a0: 50 61 6e 69 63 28 4e 55 4c 4c 29 3b 0a 2b 7d 0a  Panic(NULL);.+}.
a2b0: 2b 0c 0a 2b 76 6f 69 64 0a 2b 54 63 6c 54 68 72  +..+void.+TclThr
a2c0: 65 61 64 53 74 6f 72 61 67 65 4c 6f 63 6b 28 29  eadStorageLock()
a2d0: 0a 2b 7b 0a 2b 20 20 20 20 54 68 72 65 61 64 53  .+{.+    ThreadS
a2e0: 74 6f 72 61 67 65 50 61 6e 69 63 28 4e 55 4c 4c  toragePanic(NULL
a2f0: 29 3b 0a 2b 7d 0a 2b 0c 0a 2b 76 6f 69 64 0a 2b  );.+}.+..+void.+
a300: 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  TclThreadStorage
a310: 55 6e 6c 6f 63 6b 28 29 0a 2b 7b 0a 2b 20 20 20  Unlock().+{.+   
a320: 20 54 68 72 65 61 64 53 74 6f 72 61 67 65 50 61   ThreadStoragePa
a330: 6e 69 63 28 4e 55 4c 4c 29 3b 0a 2b 7d 0a 2b 0c  nic(NULL);.+}.+.
a340: 0a 2b 76 6f 69 64 0a 2b 54 63 6c 54 68 72 65 61  .+void.+TclThrea
a350: 64 53 74 6f 72 61 67 65 50 72 69 6e 74 28 6f 75  dStoragePrint(ou
a360: 74 46 69 6c 65 2c 20 66 6c 61 67 73 29 0a 2b 20  tFile, flags).+ 
a370: 20 20 20 46 49 4c 45 20 2a 6f 75 74 46 69 6c 65     FILE *outFile
a380: 3b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 0a  ;              .
a390: 2b 20 20 20 20 69 6e 74 20 66 6c 61 67 73 3b 20  +    int flags; 
a3a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a3b0: 20 0a 2b 7b 0a 2b 20 20 20 20 54 68 72 65 61 64   .+{.+    Thread
a3c0: 53 74 6f 72 61 67 65 50 61 6e 69 63 28 4e 55 4c  StoragePanic(NUL
a3d0: 4c 29 3b 0a 2b 7d 0a 2b 0c 0a 2b 54 63 6c 5f 48  L);.+}.+..+Tcl_H
a3e0: 61 73 68 54 61 62 6c 65 20 2a 0a 2b 54 63 6c 54  ashTable *.+TclT
a3f0: 68 72 65 61 64 53 74 6f 72 61 67 65 47 65 74 48  hreadStorageGetH
a400: 61 73 68 54 61 62 6c 65 28 69 64 29 0a 2b 20 20  ashTable(id).+  
a410: 20 20 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69    Tcl_ThreadId i
a420: 64 3b 0a 2b 7b 0a 2b 20 20 20 20 54 68 72 65 61  d;.+{.+    Threa
a430: 64 53 74 6f 72 61 67 65 50 61 6e 69 63 28 4e 55  dStoragePanic(NU
a440: 4c 4c 29 3b 0a 2b 20 20 20 20 72 65 74 75 72 6e  LL);.+    return
a450: 20 4e 55 4c 4c 3b 0a 2b 7d 0a 2b 0c 0a 2b 54 63   NULL;.+}.+..+Tc
a460: 6c 5f 48 61 73 68 54 61 62 6c 65 20 2a 0a 2b 54  l_HashTable *.+T
a470: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 49  clThreadStorageI
a480: 6e 69 74 28 69 64 2c 20 72 65 73 65 72 76 65 64  nit(id, reserved
a490: 29 0a 2b 20 20 20 20 54 63 6c 5f 54 68 72 65 61  ).+    Tcl_Threa
a4a0: 64 49 64 20 69 64 3b 20 20 20 20 0a 2b 20 20 20  dId id;    .+   
a4b0: 20 76 6f 69 64 20 2a 72 65 73 65 72 76 65 64 3b   void *reserved;
a4c0: 0a 2b 7b 0a 2b 20 20 20 20 54 68 72 65 61 64 53  .+{.+    ThreadS
a4d0: 74 6f 72 61 67 65 50 61 6e 69 63 28 4e 55 4c 4c  toragePanic(NULL
a4e0: 29 3b 0a 2b 20 20 20 20 72 65 74 75 72 6e 20 4e  );.+    return N
a4f0: 55 4c 4c 3b 0a 2b 7d 0a 2b 0c 0a 2b 76 6f 69 64  ULL;.+}.+..+void
a500: 0a 2b 54 63 6c 54 68 72 65 61 64 53 74 6f 72 61  .+TclThreadStora
a510: 67 65 44 61 74 61 4b 65 79 49 6e 69 74 28 6b 65  geDataKeyInit(ke
a520: 79 50 74 72 29 0a 2b 20 20 20 20 54 63 6c 5f 54  yPtr).+    Tcl_T
a530: 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a 6b 65  hreadDataKey *ke
a540: 79 50 74 72 3b 20 20 0a 2b 7b 0a 2b 20 20 20 20  yPtr;  .+{.+    
a550: 54 68 72 65 61 64 53 74 6f 72 61 67 65 50 61 6e  ThreadStoragePan
a560: 69 63 28 4e 55 4c 4c 29 3b 0a 2b 7d 20 20 20 20  ic(NULL);.+}    
a570: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a580: 20 20 20 20 20 20 20 20 20 20 20 20 0a 2b 0c 0a              .+..
a590: 2b 76 6f 69 64 20 2a 0a 2b 54 63 6c 54 68 72 65  +void *.+TclThre
a5a0: 61 64 53 74 6f 72 61 67 65 44 61 74 61 4b 65 79  adStorageDataKey
a5b0: 47 65 74 28 6b 65 79 50 74 72 29 0a 2b 20 20 20  Get(keyPtr).+   
a5c0: 20 54 63 6c 5f 54 68 72 65 61 64 44 61 74 61 4b   Tcl_ThreadDataK
a5d0: 65 79 20 2a 6b 65 79 50 74 72 3b 20 20 0a 2b 7b  ey *keyPtr;  .+{
a5e0: 0a 2b 20 20 20 20 54 68 72 65 61 64 53 74 6f 72  .+    ThreadStor
a5f0: 61 67 65 50 61 6e 69 63 28 4e 55 4c 4c 29 3b 0a  agePanic(NULL);.
a600: 2b 20 20 20 20 72 65 74 75 72 6e 20 4e 55 4c 4c  +    return NULL
a610: 3b 0a 2b 7d 20 20 20 20 20 20 20 20 20 20 20 20  ;.+}            
a620: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a630: 20 20 20 20 0a 2b 0c 0a 2b 76 6f 69 64 0a 2b 54      .+..+void.+T
a640: 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65 44  clThreadStorageD
a650: 61 74 61 4b 65 79 53 65 74 28 6b 65 79 50 74 72  ataKeySet(keyPtr
a660: 2c 20 64 61 74 61 29 0a 2b 20 20 20 20 54 63 6c  , data).+    Tcl
a670: 5f 54 68 72 65 61 64 44 61 74 61 4b 65 79 20 2a  _ThreadDataKey *
a680: 6b 65 79 50 74 72 3b 20 20 20 20 20 20 20 20 20  keyPtr;         
a690: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
a6a0: 20 20 20 20 20 20 20 20 0a 2b 20 20 20 20 76 6f          .+    vo
a6b0: 69 64 20 2a 64 61 74 61 3b 20 20 20 20 20 20 20  id *data;       
a6c0: 20 20 20 20 20 20 20 20 20 20 0a 2b 7b 0a 2b 20            .+{.+ 
a6d0: 20 20 20 54 68 72 65 61 64 53 74 6f 72 61 67 65     ThreadStorage
a6e0: 50 61 6e 69 63 28 4e 55 4c 4c 29 3b 0a 2b 7d 0a  Panic(NULL);.+}.
a6f0: 2b 0c 0a 2b 76 6f 69 64 0a 2b 54 63 6c 46 69 6e  +..+void.+TclFin
a700: 61 6c 69 7a 65 54 68 72 65 61 64 53 74 6f 72 61  alizeThreadStora
a710: 67 65 54 68 72 65 61 64 28 69 64 29 0a 2b 20 20  geThread(id).+  
a720: 20 20 54 63 6c 5f 54 68 72 65 61 64 49 64 20 69    Tcl_ThreadId i
a730: 64 3b 20 20 20 20 0a 2b 7b 0a 2b 20 20 20 20 54  d;    .+{.+    T
a740: 68 72 65 61 64 53 74 6f 72 61 67 65 50 61 6e 69  hreadStoragePani
a750: 63 28 4e 55 4c 4c 29 3b 0a 2b 7d 0a 2b 0c 0a 2b  c(NULL);.+}.+..+
a760: 76 6f 69 64 0a 2b 54 63 6c 46 69 6e 61 6c 69 7a  void.+TclFinaliz
a770: 65 54 68 72 65 61 64 53 74 6f 72 61 67 65 28 29  eThreadStorage()
a780: 0a 2b 7b 0a 2b 20 20 20 20 54 68 72 65 61 64 53  .+{.+    ThreadS
a790: 74 6f 72 61 67 65 50 61 6e 69 63 28 4e 55 4c 4c  toragePanic(NULL
a7a0: 29 3b 0a 2b 7d 0a 2b 0c 0a 2b 76 6f 69 64 0a 2b  );.+}.+..+void.+
a7b0: 54 63 6c 46 69 6e 61 6c 69 7a 65 54 68 72 65 61  TclFinalizeThrea
a7c0: 64 53 74 6f 72 61 67 65 44 61 74 61 28 6b 65 79  dStorageData(key
a7d0: 50 74 72 29 0a 2b 20 20 20 20 54 63 6c 5f 54 68  Ptr).+    Tcl_Th
a7e0: 72 65 61 64 44 61 74 61 4b 65 79 20 2a 6b 65 79  readDataKey *key
a7f0: 50 74 72 3b 0a 2b 7b 0a 2b 20 20 20 20 54 68 72  Ptr;.+{.+    Thr
a800: 65 61 64 53 74 6f 72 61 67 65 50 61 6e 69 63 28  eadStoragePanic(
a810: 4e 55 4c 4c 29 3b 0a 2b 7d 0a 2b 0c 0a 2b 76 6f  NULL);.+}.+..+vo
a820: 69 64 0a 2b 54 63 6c 46 69 6e 61 6c 69 7a 65 54  id.+TclFinalizeT
a830: 68 72 65 61 64 53 74 6f 72 61 67 65 44 61 74 61  hreadStorageData
a840: 4b 65 79 28 6b 65 79 50 74 72 29 0a 2b 20 20 20  Key(keyPtr).+   
a850: 20 54 63 6c 5f 54 68 72 65 61 64 44 61 74 61 4b   Tcl_ThreadDataK
a860: 65 79 20 2a 6b 65 79 50 74 72 3b 0a 2b 7b 0a 2b  ey *keyPtr;.+{.+
a870: 20 20 20 20 54 68 72 65 61 64 53 74 6f 72 61 67      ThreadStorag
a880: 65 50 61 6e 69 63 28 4e 55 4c 4c 29 3b 0a 2b 7d  ePanic(NULL);.+}
a890: 0a 2b 0a 2b 23 65 6e 64 69 66 20 2f 2a 20 64 65  .+.+#endif /* de
a8a0: 66 69 6e 65 64 28 54 43 4c 5f 54 48 52 45 41 44  fined(TCL_THREAD
a8b0: 53 29 20 26 26 20 64 65 66 69 6e 65 64 28 55 53  S) && defined(US
a8c0: 45 5f 54 48 52 45 41 44 5f 53 54 4f 52 41 47 45  E_THREAD_STORAGE
a8d0: 29 20 2a 2f 0a 49 6e 64 65 78 3a 20 75 6e 69 78  ) */.Index: unix
a8e0: 2f 4d 61 6b 65 66 69 6c 65 2e 69 6e 0a 3d 3d 3d  /Makefile.in.===
a8f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a900: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a910: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a920: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
a930: 0a 52 43 53 20 66 69 6c 65 3a 20 2f 63 76 73 72  .RCS file: /cvsr
a940: 6f 6f 74 2f 74 63 6c 2f 74 63 6c 2f 75 6e 69 78  oot/tcl/tcl/unix
a950: 2f 4d 61 6b 65 66 69 6c 65 2e 69 6e 2c 76 0a 72  /Makefile.in,v.r
a960: 65 74 72 69 65 76 69 6e 67 20 72 65 76 69 73 69  etrieving revisi
a970: 6f 6e 20 31 2e 31 33 38 0a 64 69 66 66 20 2d 75  on 1.138.diff -u
a980: 20 2d 72 31 2e 31 33 38 20 4d 61 6b 65 66 69 6c   -r1.138 Makefil
a990: 65 2e 69 6e 0a 2d 2d 2d 20 75 6e 69 78 2f 4d 61  e.in.--- unix/Ma
a9a0: 6b 65 66 69 6c 65 2e 69 6e 09 31 31 20 4a 75 6e  kefile.in.11 Jun
a9b0: 20 32 30 30 34 20 32 31 3a 33 30 3a 30 38 20 2d   2004 21:30:08 -
a9c0: 30 30 30 30 09 31 2e 31 33 38 0a 2b 2b 2b 20 75  0000.1.138.+++ u
a9d0: 6e 69 78 2f 4d 61 6b 65 66 69 6c 65 2e 69 6e 09  nix/Makefile.in.
a9e0: 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30 3a 32  23 Jun 2004 20:2
a9f0: 33 3a 30 39 20 2d 30 30 30 30 0a 40 40 20 2d 33  3:09 -0000.@@ -3
aa00: 31 33 2c 38 20 2b 33 31 33 2c 38 20 40 40 0a 20  13,8 +313,8 @@. 
aa10: 09 74 63 6c 4f 62 6a 2e 6f 20 74 63 6c 50 61 6e  .tclObj.o tclPan
aa20: 69 63 2e 6f 20 74 63 6c 50 61 72 73 65 2e 6f 20  ic.o tclParse.o 
aa30: 74 63 6c 50 61 72 73 65 45 78 70 72 2e 6f 20 74  tclParseExpr.o t
aa40: 63 6c 50 61 74 68 4f 62 6a 2e 6f 20 74 63 6c 50  clPathObj.o tclP
aa50: 69 70 65 2e 6f 20 5c 0a 20 09 74 63 6c 50 6b 67  ipe.o \. .tclPkg
aa60: 2e 6f 20 74 63 6c 50 6b 67 43 6f 6e 66 69 67 2e  .o tclPkgConfig.
aa70: 6f 20 74 63 6c 50 6f 73 69 78 53 74 72 2e 6f 20  o tclPosixStr.o 
aa80: 74 63 6c 50 72 65 73 65 72 76 65 2e 6f 20 74 63  tclPreserve.o tc
aa90: 6c 50 72 6f 63 2e 6f 20 74 63 6c 52 65 67 65 78  lProc.o tclRegex
aaa0: 70 2e 6f 20 5c 0a 20 09 74 63 6c 52 65 73 6f 6c  p.o \. .tclResol
aab0: 76 65 2e 6f 20 74 63 6c 52 65 73 75 6c 74 2e 6f  ve.o tclResult.o
aac0: 20 74 63 6c 53 63 61 6e 2e 6f 20 74 63 6c 53 74   tclScan.o tclSt
aad0: 72 69 6e 67 4f 62 6a 2e 6f 20 74 63 6c 54 68 72  ringObj.o tclThr
aae0: 65 61 64 2e 6f 20 5c 0a 2d 09 20 74 63 6c 54 68  ead.o \.-. tclTh
aaf0: 72 65 61 64 41 6c 6c 6f 63 2e 6f 20 74 63 6c 54  readAlloc.o tclT
ab00: 68 72 65 61 64 4a 6f 69 6e 2e 6f 20 74 63 6c 53  hreadJoin.o tclS
ab10: 74 75 62 49 6e 69 74 2e 6f 20 74 63 6c 53 74 75  tubInit.o tclStu
ab20: 62 4c 69 62 2e 6f 20 5c 0a 2d 09 74 63 6c 54 69  bLib.o \.-.tclTi
ab30: 6d 65 72 2e 6f 20 74 63 6c 54 72 61 63 65 2e 6f  mer.o tclTrace.o
ab40: 20 74 63 6c 55 74 66 2e 6f 20 74 63 6c 55 74 69   tclUtf.o tclUti
ab50: 6c 2e 6f 20 74 63 6c 56 61 72 2e 6f 0a 2b 09 74  l.o tclVar.o.+.t
ab60: 63 6c 54 68 72 65 61 64 41 6c 6c 6f 63 2e 6f 20  clThreadAlloc.o 
ab70: 74 63 6c 54 68 72 65 61 64 4a 6f 69 6e 2e 6f 20  tclThreadJoin.o 
ab80: 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  tclThreadStorage
ab90: 2e 6f 20 74 63 6c 53 74 75 62 49 6e 69 74 2e 6f  .o tclStubInit.o
aba0: 20 5c 0a 2b 09 74 63 6c 53 74 75 62 4c 69 62 2e   \.+.tclStubLib.
abb0: 6f 20 74 63 6c 54 69 6d 65 72 2e 6f 20 74 63 6c  o tclTimer.o tcl
abc0: 54 72 61 63 65 2e 6f 20 74 63 6c 55 74 66 2e 6f  Trace.o tclUtf.o
abd0: 20 74 63 6c 55 74 69 6c 2e 6f 20 74 63 6c 56 61   tclUtil.o tclVa
abe0: 72 2e 6f 0a 20 0a 20 53 54 55 42 5f 4c 49 42 5f  r.o. . STUB_LIB_
abf0: 4f 42 4a 53 20 3d 20 74 63 6c 53 74 75 62 4c 69  OBJS = tclStubLi
ac00: 62 2e 6f 20 24 7b 43 4f 4d 50 41 54 5f 4f 42 4a  b.o ${COMPAT_OBJ
ac10: 53 7d 0a 20 0a 40 40 20 2d 34 30 32 2c 36 20 2b  S}. .@@ -402,6 +
ac20: 34 30 32 2c 37 20 40 40 0a 20 09 24 28 47 45 4e  402,7 @@. .$(GEN
ac30: 45 52 49 43 5f 44 49 52 29 2f 74 63 6c 54 68 72  ERIC_DIR)/tclThr
ac40: 65 61 64 2e 63 20 5c 0a 20 09 24 28 47 45 4e 45  ead.c \. .$(GENE
ac50: 52 49 43 5f 44 49 52 29 2f 74 63 6c 54 68 72 65  RIC_DIR)/tclThre
ac60: 61 64 41 6c 6c 6f 63 2e 63 20 5c 0a 20 09 24 28  adAlloc.c \. .$(
ac70: 47 45 4e 45 52 49 43 5f 44 49 52 29 2f 74 63 6c  GENERIC_DIR)/tcl
ac80: 54 68 72 65 61 64 4a 6f 69 6e 2e 63 20 5c 0a 2b  ThreadJoin.c \.+
ac90: 09 24 28 47 45 4e 45 52 49 43 5f 44 49 52 29 2f  .$(GENERIC_DIR)/
aca0: 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  tclThreadStorage
acb0: 2e 63 20 5c 0a 20 09 24 28 47 45 4e 45 52 49 43  .c \. .$(GENERIC
acc0: 5f 44 49 52 29 2f 74 63 6c 54 69 6d 65 72 2e 63  _DIR)/tclTimer.c
acd0: 20 5c 0a 20 09 24 28 47 45 4e 45 52 49 43 5f 44   \. .$(GENERIC_D
ace0: 49 52 29 2f 74 63 6c 54 72 61 63 65 2e 63 20 5c  IR)/tclTrace.c \
acf0: 0a 20 09 24 28 47 45 4e 45 52 49 43 5f 44 49 52  . .$(GENERIC_DIR
ad00: 29 2f 74 63 6c 55 74 69 6c 2e 63 20 5c 0a 40 40  )/tclUtil.c \.@@
ad10: 20 2d 31 30 35 30 2c 36 20 2b 31 30 35 31 2c 39   -1050,6 +1051,9
ad20: 20 40 40 0a 20 74 63 6c 54 68 72 65 61 64 4a 6f   @@. tclThreadJo
ad30: 69 6e 2e 6f 3a 20 24 28 47 45 4e 45 52 49 43 5f  in.o: $(GENERIC_
ad40: 44 49 52 29 2f 74 63 6c 54 68 72 65 61 64 4a 6f  DIR)/tclThreadJo
ad50: 69 6e 2e 63 0a 20 09 24 28 43 43 29 20 2d 63 20  in.c. .$(CC) -c 
ad60: 24 28 43 43 5f 53 57 49 54 43 48 45 53 29 20 24  $(CC_SWITCHES) $
ad70: 28 47 45 4e 45 52 49 43 5f 44 49 52 29 2f 74 63  (GENERIC_DIR)/tc
ad80: 6c 54 68 72 65 61 64 4a 6f 69 6e 2e 63 0a 20 0a  lThreadJoin.c. .
ad90: 2b 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67  +tclThreadStorag
ada0: 65 2e 6f 3a 20 24 28 47 45 4e 45 52 49 43 5f 44  e.o: $(GENERIC_D
adb0: 49 52 29 2f 74 63 6c 54 68 72 65 61 64 53 74 6f  IR)/tclThreadSto
adc0: 72 61 67 65 2e 63 0a 2b 09 24 28 43 43 29 20 2d  rage.c.+.$(CC) -
add0: 63 20 24 28 43 43 5f 53 57 49 54 43 48 45 53 29  c $(CC_SWITCHES)
ade0: 20 24 28 47 45 4e 45 52 49 43 5f 44 49 52 29 2f   $(GENERIC_DIR)/
adf0: 74 63 6c 54 68 72 65 61 64 53 74 6f 72 61 67 65  tclThreadStorage
ae00: 2e 63 0a 2b 0a 20 74 63 6c 54 68 72 65 61 64 54  .c.+. tclThreadT
ae10: 65 73 74 2e 6f 3a 20 24 28 47 45 4e 45 52 49 43  est.o: $(GENERIC
ae20: 5f 44 49 52 29 2f 74 63 6c 54 68 72 65 61 64 54  _DIR)/tclThreadT
ae30: 65 73 74 2e 63 0a 20 09 24 28 43 43 29 20 2d 63  est.c. .$(CC) -c
ae40: 20 24 28 43 43 5f 53 57 49 54 43 48 45 53 29 20   $(CC_SWITCHES) 
ae50: 24 28 47 45 4e 45 52 49 43 5f 44 49 52 29 2f 74  $(GENERIC_DIR)/t
ae60: 63 6c 54 68 72 65 61 64 54 65 73 74 2e 63 0a 20  clThreadTest.c. 
ae70: 0a 49 6e 64 65 78 3a 20 75 6e 69 78 2f 63 6f 6e  .Index: unix/con
ae80: 66 69 67 75 72 65 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d  figure.=========
ae90: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aea0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aeb0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
aec0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66  ==========.RCS f
aed0: 69 6c 65 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63  ile: /cvsroot/tc
aee0: 6c 2f 74 63 6c 2f 75 6e 69 78 2f 63 6f 6e 66 69  l/tcl/unix/confi
aef0: 67 75 72 65 2c 76 0a 72 65 74 72 69 65 76 69 6e  gure,v.retrievin
af00: 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 31 31 34  g revision 1.114
af10: 0a 64 69 66 66 20 2d 75 20 2d 72 31 2e 31 31 34  .diff -u -r1.114
af20: 20 63 6f 6e 66 69 67 75 72 65 0a 2d 2d 2d 20 75   configure.--- u
af30: 6e 69 78 2f 63 6f 6e 66 69 67 75 72 65 09 32 33  nix/configure.23
af40: 20 4a 75 6e 20 32 30 30 34 20 30 30 3a 32 35 3a   Jun 2004 00:25:
af50: 30 33 20 2d 30 30 30 30 09 31 2e 31 31 34 0a 2b  03 -0000.1.114.+
af60: 2b 2b 20 75 6e 69 78 2f 63 6f 6e 66 69 67 75 72  ++ unix/configur
af70: 65 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30  e.23 Jun 2004 20
af80: 3a 32 33 3a 31 30 20 2d 30 30 30 30 0a 40 40 20  :23:10 -0000.@@ 
af90: 2d 32 38 35 34 2c 36 20 2b 32 38 35 34 2c 31 32  -2854,6 +2854,12
afa0: 20 40 40 0a 20 23 64 65 66 69 6e 65 20 55 53 45   @@. #define USE
afb0: 5f 54 48 52 45 41 44 5f 41 4c 4c 4f 43 20 31 0a  _THREAD_ALLOC 1.
afc0: 20 5f 41 43 45 4f 46 0a 20 0a 2b 09 23 20 55 53   _ACEOF. .+.# US
afd0: 45 5f 54 48 52 45 41 44 5f 53 54 4f 52 41 47 45  E_THREAD_STORAGE
afe0: 20 74 65 6c 6c 73 20 75 73 20 74 6f 20 75 73 65   tells us to use
aff0: 20 74 68 65 20 6e 65 77 20 67 65 6e 65 72 69 63   the new generic
b000: 20 74 68 72 65 61 64 0a 2b 09 23 20 73 74 6f 72   thread.+.# stor
b010: 61 67 65 20 73 75 62 73 79 73 74 65 6d 2e 0a 2b  age subsystem..+
b020: 09 63 61 74 20 3e 3e 63 6f 6e 66 64 65 66 73 2e  .cat >>confdefs.
b030: 68 20 3c 3c 5c 5f 41 43 45 4f 46 0a 2b 23 64 65  h <<\_ACEOF.+#de
b040: 66 69 6e 65 20 55 53 45 5f 54 48 52 45 41 44 5f  fine USE_THREAD_
b050: 53 54 4f 52 41 47 45 20 31 0a 2b 5f 41 43 45 4f  STORAGE 1.+_ACEO
b060: 46 0a 2b 0a 20 09 63 61 74 20 3e 3e 63 6f 6e 66  F.+. .cat >>conf
b070: 64 65 66 73 2e 68 20 3c 3c 5c 5f 41 43 45 4f 46  defs.h <<\_ACEOF
b080: 0a 20 23 64 65 66 69 6e 65 20 5f 52 45 45 4e 54  . #define _REENT
b090: 52 41 4e 54 20 31 0a 20 5f 41 43 45 4f 46 0a 49  RANT 1. _ACEOF.I
b0a0: 6e 64 65 78 3a 20 75 6e 69 78 2f 74 63 6c 2e 6d  ndex: unix/tcl.m
b0b0: 34 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  4.==============
b0c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b0d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b0e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b0f0: 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a 20  =====.RCS file: 
b100: 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63 6c  /cvsroot/tcl/tcl
b110: 2f 75 6e 69 78 2f 74 63 6c 2e 6d 34 2c 76 0a 72  /unix/tcl.m4,v.r
b120: 65 74 72 69 65 76 69 6e 67 20 72 65 76 69 73 69  etrieving revisi
b130: 6f 6e 20 31 2e 31 31 37 0a 64 69 66 66 20 2d 75  on 1.117.diff -u
b140: 20 2d 72 31 2e 31 31 37 20 74 63 6c 2e 6d 34 0a   -r1.117 tcl.m4.
b150: 2d 2d 2d 20 75 6e 69 78 2f 74 63 6c 2e 6d 34 09  --- unix/tcl.m4.
b160: 32 33 20 4a 75 6e 20 32 30 30 34 20 30 30 3a 32  23 Jun 2004 00:2
b170: 34 3a 34 31 20 2d 30 30 30 30 09 31 2e 31 31 37  4:41 -0000.1.117
b180: 0a 2b 2b 2b 20 75 6e 69 78 2f 74 63 6c 2e 6d 34  .+++ unix/tcl.m4
b190: 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30 3a  .23 Jun 2004 20:
b1a0: 32 33 3a 31 31 20 2d 30 30 30 30 0a 40 40 20 2d  23:11 -0000.@@ -
b1b0: 34 32 38 2c 36 20 2b 34 32 38 2c 39 20 40 40 0a  428,6 +428,9 @@.
b1c0: 20 09 23 20 55 53 45 5f 54 48 52 45 41 44 5f 41   .# USE_THREAD_A
b1d0: 4c 4c 4f 43 20 74 65 6c 6c 73 20 75 73 20 74 6f  LLOC tells us to
b1e0: 20 74 72 79 20 74 68 65 20 73 70 65 63 69 61 6c   try the special
b1f0: 20 74 68 72 65 61 64 2d 62 61 73 65 64 0a 20 09   thread-based. .
b200: 23 20 61 6c 6c 6f 63 61 74 6f 72 20 74 68 61 74  # allocator that
b210: 20 73 69 67 6e 69 66 69 63 61 6e 74 6c 79 20 72   significantly r
b220: 65 64 75 63 65 73 20 6c 6f 63 6b 20 63 6f 6e 74  educes lock cont
b230: 65 6e 74 69 6f 6e 0a 20 09 41 43 5f 44 45 46 49  ention. .AC_DEFI
b240: 4e 45 28 55 53 45 5f 54 48 52 45 41 44 5f 41 4c  NE(USE_THREAD_AL
b250: 4c 4f 43 29 0a 2b 09 23 20 55 53 45 5f 54 48 52  LOC).+.# USE_THR
b260: 45 41 44 5f 53 54 4f 52 41 47 45 20 74 65 6c 6c  EAD_STORAGE tell
b270: 73 20 75 73 20 74 6f 20 75 73 65 20 74 68 65 20  s us to use the 
b280: 6e 65 77 20 67 65 6e 65 72 69 63 20 74 68 72 65  new generic thre
b290: 61 64 20 0a 2b 09 23 20 73 74 6f 72 61 67 65 20  ad .+.# storage 
b2a0: 73 75 62 73 79 73 74 65 6d 2e 20 0a 2b 09 41 43  subsystem. .+.AC
b2b0: 5f 44 45 46 49 4e 45 28 55 53 45 5f 54 48 52 45  _DEFINE(USE_THRE
b2c0: 41 44 5f 53 54 4f 52 41 47 45 29 0a 20 09 41 43  AD_STORAGE). .AC
b2d0: 5f 44 45 46 49 4e 45 28 5f 52 45 45 4e 54 52 41  _DEFINE(_REENTRA
b2e0: 4e 54 29 0a 20 09 41 43 5f 44 45 46 49 4e 45 28  NT). .AC_DEFINE(
b2f0: 5f 54 48 52 45 41 44 5f 53 41 46 45 29 0a 20 09  _THREAD_SAFE). .
b300: 41 43 5f 43 48 45 43 4b 5f 4c 49 42 28 70 74 68  AC_CHECK_LIB(pth
b310: 72 65 61 64 2c 70 74 68 72 65 61 64 5f 6d 75 74  read,pthread_mut
b320: 65 78 5f 69 6e 69 74 2c 74 63 6c 5f 6f 6b 3d 79  ex_init,tcl_ok=y
b330: 65 73 2c 74 63 6c 5f 6f 6b 3d 6e 6f 29 0a 49 6e  es,tcl_ok=no).In
b340: 64 65 78 3a 20 77 69 6e 2f 4d 61 6b 65 66 69 6c  dex: win/Makefil
b350: 65 2e 69 6e 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  e.in.===========
b360: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b380: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b390: 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c  ========.RCS fil
b3a0: 65 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f  e: /cvsroot/tcl/
b3b0: 74 63 6c 2f 77 69 6e 2f 4d 61 6b 65 66 69 6c 65  tcl/win/Makefile
b3c0: 2e 69 6e 2c 76 0a 72 65 74 72 69 65 76 69 6e 67  .in,v.retrieving
b3d0: 20 72 65 76 69 73 69 6f 6e 20 31 2e 37 37 0a 64   revision 1.77.d
b3e0: 69 66 66 20 2d 75 20 2d 72 31 2e 37 37 20 4d 61  iff -u -r1.77 Ma
b3f0: 6b 65 66 69 6c 65 2e 69 6e 0a 2d 2d 2d 20 77 69  kefile.in.--- wi
b400: 6e 2f 4d 61 6b 65 66 69 6c 65 2e 69 6e 09 31 34  n/Makefile.in.14
b410: 20 4a 75 6e 20 32 30 30 34 20 32 32 3a 31 34 3a   Jun 2004 22:14:
b420: 31 32 20 2d 30 30 30 30 09 31 2e 37 37 0a 2b 2b  12 -0000.1.77.++
b430: 2b 20 77 69 6e 2f 4d 61 6b 65 66 69 6c 65 2e 69  + win/Makefile.i
b440: 6e 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32 30  n.23 Jun 2004 20
b450: 3a 32 33 3a 31 31 20 2d 30 30 30 30 0a 40 40 20  :23:11 -0000.@@ 
b460: 2d 32 36 35 2c 36 20 2b 32 36 35 2c 37 20 40 40  -265,6 +265,7 @@
b470: 0a 20 09 74 63 6c 54 68 72 65 61 64 2e 24 28 4f  . .tclThread.$(O
b480: 42 4a 45 58 54 29 20 5c 0a 20 09 74 63 6c 54 68  BJEXT) \. .tclTh
b490: 72 65 61 64 41 6c 6c 6f 63 2e 24 28 4f 42 4a 45  readAlloc.$(OBJE
b4a0: 58 54 29 20 5c 0a 20 09 74 63 6c 54 68 72 65 61  XT) \. .tclThrea
b4b0: 64 4a 6f 69 6e 2e 24 28 4f 42 4a 45 58 54 29 20  dJoin.$(OBJEXT) 
b4c0: 5c 0a 2b 09 74 63 6c 54 68 72 65 61 64 53 74 6f  \.+.tclThreadSto
b4d0: 72 61 67 65 2e 24 28 4f 42 4a 45 58 54 29 20 5c  rage.$(OBJEXT) \
b4e0: 0a 20 09 74 63 6c 54 69 6d 65 72 2e 24 28 4f 42  . .tclTimer.$(OB
b4f0: 4a 45 58 54 29 20 5c 0a 20 09 74 63 6c 54 72 61  JEXT) \. .tclTra
b500: 63 65 2e 24 28 4f 42 4a 45 58 54 29 20 5c 0a 20  ce.$(OBJEXT) \. 
b510: 09 74 63 6c 55 74 66 2e 24 28 4f 42 4a 45 58 54  .tclUtf.$(OBJEXT
b520: 29 20 5c 0a 49 6e 64 65 78 3a 20 77 69 6e 2f 63  ) \.Index: win/c
b530: 6f 6e 66 69 67 75 72 65 0a 3d 3d 3d 3d 3d 3d 3d  onfigure.=======
b540: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b550: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b560: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b570: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53  ============.RCS
b580: 20 66 69 6c 65 3a 20 2f 63 76 73 72 6f 6f 74 2f   file: /cvsroot/
b590: 74 63 6c 2f 74 63 6c 2f 77 69 6e 2f 63 6f 6e 66  tcl/tcl/win/conf
b5a0: 69 67 75 72 65 2c 76 0a 72 65 74 72 69 65 76 69  igure,v.retrievi
b5b0: 6e 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 37 31  ng revision 1.71
b5c0: 0a 64 69 66 66 20 2d 75 20 2d 72 31 2e 37 31 20  .diff -u -r1.71 
b5d0: 63 6f 6e 66 69 67 75 72 65 0a 2d 2d 2d 20 77 69  configure.--- wi
b5e0: 6e 2f 63 6f 6e 66 69 67 75 72 65 09 31 31 20 4a  n/configure.11 J
b5f0: 75 6e 20 32 30 30 34 20 32 30 3a 32 35 3a 32 34  un 2004 20:25:24
b600: 20 2d 30 30 30 30 09 31 2e 37 31 0a 2b 2b 2b 20   -0000.1.71.+++ 
b610: 77 69 6e 2f 63 6f 6e 66 69 67 75 72 65 09 32 33  win/configure.23
b620: 20 4a 75 6e 20 32 30 30 34 20 32 30 3a 32 33 3a   Jun 2004 20:23:
b630: 31 32 20 2d 30 30 30 30 0a 40 40 20 2d 32 39 36  12 -0000.@@ -296
b640: 37 2c 36 20 2b 32 39 36 37 2c 31 32 20 40 40 0a  7,6 +2967,12 @@.
b650: 20 23 64 65 66 69 6e 65 20 55 53 45 5f 54 48 52   #define USE_THR
b660: 45 41 44 5f 41 4c 4c 4f 43 20 31 0a 20 5f 41 43  EAD_ALLOC 1. _AC
b670: 45 4f 46 0a 20 0a 2b 09 23 20 55 53 45 5f 54 48  EOF. .+.# USE_TH
b680: 52 45 41 44 5f 53 54 4f 52 41 47 45 20 74 65 6c  READ_STORAGE tel
b690: 6c 73 20 75 73 20 74 6f 20 75 73 65 20 74 68 65  ls us to use the
b6a0: 20 6e 65 77 20 67 65 6e 65 72 69 63 20 74 68 72   new generic thr
b6b0: 65 61 64 0a 2b 09 23 20 73 74 6f 72 61 67 65 20  ead.+.# storage 
b6c0: 73 75 62 73 79 73 74 65 6d 2e 0a 2b 09 63 61 74  subsystem..+.cat
b6d0: 20 3e 3e 63 6f 6e 66 64 65 66 73 2e 68 20 3c 3c   >>confdefs.h <<
b6e0: 5c 5f 41 43 45 4f 46 0a 2b 23 64 65 66 69 6e 65  \_ACEOF.+#define
b6f0: 20 55 53 45 5f 54 48 52 45 41 44 5f 53 54 4f 52   USE_THREAD_STOR
b700: 41 47 45 20 31 0a 2b 5f 41 43 45 4f 46 0a 2b 0a  AGE 1.+_ACEOF.+.
b710: 20 20 20 20 20 65 6c 73 65 0a 20 09 54 43 4c 5f       else. .TCL_
b720: 54 48 52 45 41 44 53 3d 30 0a 20 09 65 63 68 6f  THREADS=0. .echo
b730: 20 22 24 61 73 5f 6d 65 3a 24 4c 49 4e 45 4e 4f   "$as_me:$LINENO
b740: 3a 20 72 65 73 75 6c 74 3a 20 6e 6f 20 28 64 65  : result: no (de
b750: 66 61 75 6c 74 29 22 20 3e 26 35 0a 49 6e 64 65  fault)" >&5.Inde
b760: 78 3a 20 77 69 6e 2f 6d 61 6b 65 66 69 6c 65 2e  x: win/makefile.
b770: 76 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  vc.=============
b780: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b790: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b7a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
b7b0: 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c 65 3a  ======.RCS file:
b7c0: 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f 74 63   /cvsroot/tcl/tc
b7d0: 6c 2f 77 69 6e 2f 6d 61 6b 65 66 69 6c 65 2e 76  l/win/makefile.v
b7e0: 63 2c 76 0a 72 65 74 72 69 65 76 69 6e 67 20 72  c,v.retrieving r
b7f0: 65 76 69 73 69 6f 6e 20 31 2e 31 32 38 0a 64 69  evision 1.128.di
b800: 66 66 20 2d 75 20 2d 72 31 2e 31 32 38 20 6d 61  ff -u -r1.128 ma
b810: 6b 65 66 69 6c 65 2e 76 63 0a 2d 2d 2d 20 77 69  kefile.vc.--- wi
b820: 6e 2f 6d 61 6b 65 66 69 6c 65 2e 76 63 09 32 33  n/makefile.vc.23
b830: 20 4a 75 6e 20 32 30 30 34 20 31 39 3a 32 33 3a   Jun 2004 19:23:
b840: 34 39 20 2d 30 30 30 30 09 31 2e 31 32 38 0a 2b  49 -0000.1.128.+
b850: 2b 2b 20 77 69 6e 2f 6d 61 6b 65 66 69 6c 65 2e  ++ win/makefile.
b860: 76 63 09 32 33 20 4a 75 6e 20 32 30 30 34 20 32  vc.23 Jun 2004 2
b870: 30 3a 32 33 3a 31 32 20 2d 30 30 30 30 0a 40 40  0:23:12 -0000.@@
b880: 20 2d 38 30 2c 36 20 2b 38 30 2c 37 20 40 40 0a   -80,6 +80,7 @@.
b890: 20 23 09 09 09 20 20 20 69 6e 73 69 64 65 20 69   #...   inside i
b8a0: 74 2e 0a 20 23 09 09 74 68 72 65 61 64 73 20 3d  t.. #..threads =
b8b0: 20 20 54 75 72 6e 73 20 6f 6e 20 66 75 6c 6c 20    Turns on full 
b8c0: 6d 75 6c 74 69 74 68 72 65 61 64 69 6e 67 20 73  multithreading s
b8d0: 75 70 70 6f 72 74 2e 0a 20 23 09 09 74 68 72 64  upport.. #..thrd
b8e0: 61 6c 6c 6f 63 20 3d 20 55 73 65 20 74 68 65 20  alloc = Use the 
b8f0: 74 68 72 65 61 64 20 61 6c 6c 6f 63 61 74 6f 72  thread allocator
b900: 20 28 73 68 61 72 65 64 20 67 6c 6f 62 61 6c 20   (shared global 
b910: 66 72 65 65 20 70 6f 6f 6c 29 2e 0a 2b 23 09 09  free pool)..+#..
b920: 74 68 72 64 73 74 6f 72 61 67 65 20 3d 20 55 73  thrdstorage = Us
b930: 65 20 74 68 65 20 67 65 6e 65 72 69 63 20 74 68  e the generic th
b940: 72 65 61 64 20 73 74 6f 72 61 67 65 20 73 75 70  read storage sup
b950: 70 6f 72 74 2e 0a 20 23 09 09 73 79 6d 62 6f 6c  port.. #..symbol
b960: 73 20 3d 20 20 41 64 64 73 20 73 79 6d 62 6f 6c  s =  Adds symbol
b970: 73 20 66 6f 72 20 73 74 65 70 20 64 65 62 75 67  s for step debug
b980: 67 69 6e 67 2e 0a 20 23 09 09 70 72 6f 66 69 6c  ging.. #..profil
b990: 65 20 3d 20 20 41 64 64 73 20 70 72 6f 66 69 6c  e =  Adds profil
b9a0: 69 6e 67 20 68 6f 6f 6b 73 2e 20 20 4d 61 70 20  ing hooks.  Map 
b9b0: 66 69 6c 65 20 69 73 20 61 73 73 75 6d 65 64 2e  file is assumed.
b9c0: 0a 20 23 09 09 6c 6f 69 6d 70 61 63 74 20 3d 20  . #..loimpact = 
b9d0: 20 41 64 64 73 20 61 20 66 6c 61 67 20 66 6f 72   Adds a flag for
b9e0: 20 68 6f 77 20 4e 54 20 74 72 65 61 74 73 20 74   how NT treats t
b9f0: 68 65 20 68 65 61 70 20 74 6f 20 6b 65 65 70 20  he heap to keep 
ba00: 6d 65 6d 6f 72 79 0a 40 40 20 2d 33 30 38 2c 36  memory.@@ -308,6
ba10: 20 2b 33 30 39 2c 37 20 40 40 0a 20 09 24 28 54   +309,7 @@. .$(T
ba20: 4d 50 5f 44 49 52 29 5c 74 63 6c 54 68 72 65 61  MP_DIR)\tclThrea
ba30: 64 2e 6f 62 6a 20 5c 0a 20 09 24 28 54 4d 50 5f  d.obj \. .$(TMP_
ba40: 44 49 52 29 5c 74 63 6c 54 68 72 65 61 64 41 6c  DIR)\tclThreadAl
ba50: 6c 6f 63 2e 6f 62 6a 20 5c 0a 20 09 24 28 54 4d  loc.obj \. .$(TM
ba60: 50 5f 44 49 52 29 5c 74 63 6c 54 68 72 65 61 64  P_DIR)\tclThread
ba70: 4a 6f 69 6e 2e 6f 62 6a 20 5c 0a 2b 09 24 28 54  Join.obj \.+.$(T
ba80: 4d 50 5f 44 49 52 29 5c 74 63 6c 54 68 72 65 61  MP_DIR)\tclThrea
ba90: 64 53 74 6f 72 61 67 65 2e 6f 62 6a 20 5c 0a 20  dStorage.obj \. 
baa0: 09 24 28 54 4d 50 5f 44 49 52 29 5c 74 63 6c 54  .$(TMP_DIR)\tclT
bab0: 69 6d 65 72 2e 6f 62 6a 20 5c 0a 20 09 24 28 54  imer.obj \. .$(T
bac0: 4d 50 5f 44 49 52 29 5c 74 63 6c 54 72 61 63 65  MP_DIR)\tclTrace
bad0: 2e 6f 62 6a 20 5c 0a 20 09 24 28 54 4d 50 5f 44  .obj \. .$(TMP_D
bae0: 49 52 29 5c 74 63 6c 55 74 66 2e 6f 62 6a 20 5c  IR)\tclUtf.obj \
baf0: 0a 49 6e 64 65 78 3a 20 77 69 6e 2f 72 75 6c 65  .Index: win/rule
bb00: 73 2e 76 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  s.vc.===========
bb10: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bb20: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bb30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
bb40: 3d 3d 3d 3d 3d 3d 3d 3d 0a 52 43 53 20 66 69 6c  ========.RCS fil
bb50: 65 3a 20 2f 63 76 73 72 6f 6f 74 2f 74 63 6c 2f  e: /cvsroot/tcl/
bb60: 74 63 6c 2f 77 69 6e 2f 72 75 6c 65 73 2e 76 63  tcl/win/rules.vc
bb70: 2c 76 0a 72 65 74 72 69 65 76 69 6e 67 20 72 65  ,v.retrieving re
bb80: 76 69 73 69 6f 6e 20 31 2e 31 38 0a 64 69 66 66  vision 1.18.diff
bb90: 20 2d 75 20 2d 72 31 2e 31 38 20 72 75 6c 65 73   -u -r1.18 rules
bba0: 2e 76 63 0a 2d 2d 2d 20 77 69 6e 2f 72 75 6c 65  .vc.--- win/rule
bbb0: 73 2e 76 63 09 37 20 46 65 62 20 32 30 30 34 20  s.vc.7 Feb 2004 
bbc0: 32 31 3a 34 37 3a 31 39 20 2d 30 30 30 30 09 31  21:47:19 -0000.1
bbd0: 2e 31 38 0a 2b 2b 2b 20 77 69 6e 2f 72 75 6c 65  .18.+++ win/rule
bbe0: 73 2e 76 63 09 32 33 20 4a 75 6e 20 32 30 30 34  s.vc.23 Jun 2004
bbf0: 20 32 30 3a 32 33 3a 31 32 20 2d 30 30 30 30 0a   20:23:12 -0000.
bc00: 40 40 20 2d 31 37 39 2c 36 20 2b 31 37 39 2c 31  @@ -179,6 +179,1
bc10: 32 20 40 40 0a 20 21 65 6c 73 65 0a 20 55 53 45  2 @@. !else. USE
bc20: 5f 54 48 52 45 41 44 5f 41 4c 4c 4f 43 20 3d 20  _THREAD_ALLOC = 
bc30: 30 0a 20 21 65 6e 64 69 66 0a 2b 21 69 66 20 5b  0. !endif.+!if [
bc40: 6e 6d 61 6b 65 68 6c 70 20 2d 66 20 24 28 4f 50  nmakehlp -f $(OP
bc50: 54 53 29 20 22 74 68 72 64 73 74 6f 72 61 67 65  TS) "thrdstorage
bc60: 22 5d 0a 2b 21 6d 65 73 73 61 67 65 20 2a 2a 2a  "].+!message ***
bc70: 20 44 6f 69 6e 67 20 74 68 72 64 73 74 6f 72 61   Doing thrdstora
bc80: 67 65 0a 2b 55 53 45 5f 54 48 52 45 41 44 5f 53  ge.+USE_THREAD_S
bc90: 54 4f 52 41 47 45 20 3d 20 31 0a 2b 21 65 6c 73  TORAGE = 1.+!els
bca0: 65 0a 2b 55 53 45 5f 54 48 52 45 41 44 5f 53 54  e.+USE_THREAD_ST
bcb0: 4f 52 41 47 45 20 3d 20 30 0a 2b 21 65 6e 64 69  ORAGE = 0.+!endi
bcc0: 66 0a 20 21 69 66 20 5b 6e 6d 61 6b 65 68 6c 70  f. !if [nmakehlp
bcd0: 20 2d 66 20 24 28 4f 50 54 53 29 20 22 75 6e 63   -f $(OPTS) "unc
bce0: 68 65 63 6b 65 64 22 5d 0a 20 21 6d 65 73 73 61  hecked"]. !messa
bcf0: 67 65 20 2a 2a 2a 20 44 6f 69 6e 67 20 75 6e 63  ge *** Doing unc
bd00: 68 65 63 6b 65 64 0a 20 55 4e 43 48 45 43 4b 45  hecked. UNCHECKE
bd10: 44 20 3d 20 31 0a 40 40 20 2d 33 32 33 2c 36 20  D = 1.@@ -323,6 
bd20: 2b 33 32 39 2c 39 20 40 40 0a 20 21 69 66 20 24  +329,9 @@. !if $
bd30: 28 55 53 45 5f 54 48 52 45 41 44 5f 41 4c 4c 4f  (USE_THREAD_ALLO
bd40: 43 29 0a 20 4f 50 54 44 45 46 49 4e 45 53 09 3d  C). OPTDEFINES.=
bd50: 20 24 28 4f 50 54 44 45 46 49 4e 45 53 29 20 2d   $(OPTDEFINES) -
bd60: 44 55 53 45 5f 54 48 52 45 41 44 5f 41 4c 4c 4f  DUSE_THREAD_ALLO
bd70: 43 3d 31 0a 20 21 65 6e 64 69 66 0a 2b 21 69 66  C=1. !endif.+!if
bd80: 20 24 28 55 53 45 5f 54 48 52 45 41 44 5f 53 54   $(USE_THREAD_ST
bd90: 4f 52 41 47 45 29 0a 2b 4f 50 54 44 45 46 49 4e  ORAGE).+OPTDEFIN
bda0: 45 53 09 3d 20 24 28 4f 50 54 44 45 46 49 4e 45  ES.= $(OPTDEFINE
bdb0: 53 29 20 2d 44 55 53 45 5f 54 48 52 45 41 44 5f  S) -DUSE_THREAD_
bdc0: 53 54 4f 52 41 47 45 3d 31 0a 2b 21 65 6e 64 69  STORAGE=1.+!endi
bdd0: 66 0a 20 21 65 6e 64 69 66 0a 20 21 69 66 20 24  f. !endif. !if $
bde0: 28 53 54 41 54 49 43 5f 42 55 49 4c 44 29 0a 20  (STATIC_BUILD). 
bdf0: 4f 50 54 44 45 46 49 4e 45 53 09 3d 20 24 28 4f  OPTDEFINES.= $(O
be00: 50 54 44 45 46 49 4e 45 53 29 20 2d 44 53 54 41  PTDEFINES) -DSTA
be10: 54 49 43 5f 42 55 49 4c 44 0a 49 6e 64 65 78 3a  TIC_BUILD.Index:
be20: 20 77 69 6e 2f 74 63 6c 2e 6d 34 0a 3d 3d 3d 3d   win/tcl.m4.====
be30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
be40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
be50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
be60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a  ===============.
be70: 52 43 53 20 66 69 6c 65 3a 20 2f 63 76 73 72 6f  RCS file: /cvsro
be80: 6f 74 2f 74 63 6c 2f 74 63 6c 2f 77 69 6e 2f 74  ot/tcl/tcl/win/t
be90: 63 6c 2e 6d 34 2c 76 0a 72 65 74 72 69 65 76 69  cl.m4,v.retrievi
bea0: 6e 67 20 72 65 76 69 73 69 6f 6e 20 31 2e 35 35  ng revision 1.55
beb0: 0a 64 69 66 66 20 2d 75 20 2d 72 31 2e 35 35 20  .diff -u -r1.55 
bec0: 74 63 6c 2e 6d 34 0a 2d 2d 2d 20 77 69 6e 2f 74  tcl.m4.--- win/t
bed0: 63 6c 2e 6d 34 09 36 20 4f 63 74 20 32 30 30 33  cl.m4.6 Oct 2003
bee0: 20 31 39 3a 30 38 3a 34 35 20 2d 30 30 30 30 09   19:08:45 -0000.
bef0: 31 2e 35 35 0a 2b 2b 2b 20 77 69 6e 2f 74 63 6c  1.55.+++ win/tcl
bf00: 2e 6d 34 09 32 33 20 4a 75 6e 20 32 30 30 34 20  .m4.23 Jun 2004 
bf10: 32 30 3a 32 33 3a 31 32 20 2d 30 30 30 30 0a 40  20:23:12 -0000.@
bf20: 40 20 2d 32 35 37 2c 36 20 2b 32 35 37 2c 39 20  @ -257,6 +257,9 
bf30: 40 40 0a 20 09 23 20 55 53 45 5f 54 48 52 45 41  @@. .# USE_THREA
bf40: 44 5f 41 4c 4c 4f 43 20 74 65 6c 6c 73 20 75 73  D_ALLOC tells us
bf50: 20 74 6f 20 74 72 79 20 74 68 65 20 73 70 65 63   to try the spec
bf60: 69 61 6c 20 74 68 72 65 61 64 2d 62 61 73 65 64  ial thread-based
bf70: 0a 20 09 23 20 61 6c 6c 6f 63 61 74 6f 72 20 74  . .# allocator t
bf80: 68 61 74 20 73 69 67 6e 69 66 69 63 61 6e 74 6c  hat significantl
bf90: 79 20 72 65 64 75 63 65 73 20 6c 6f 63 6b 20 63  y reduces lock c
bfa0: 6f 6e 74 65 6e 74 69 6f 6e 0a 20 09 41 43 5f 44  ontention. .AC_D
bfb0: 45 46 49 4e 45 28 55 53 45 5f 54 48 52 45 41 44  EFINE(USE_THREAD
bfc0: 5f 41 4c 4c 4f 43 29 0a 2b 09 23 20 55 53 45 5f  _ALLOC).+.# USE_
bfd0: 54 48 52 45 41 44 5f 53 54 4f 52 41 47 45 20 74  THREAD_STORAGE t
bfe0: 65 6c 6c 73 20 75 73 20 74 6f 20 75 73 65 20 74  ells us to use t
bff0: 68 65 20 6e 65 77 20 67 65 6e 65 72 69 63 20 74  he new generic t
c000: 68 72 65 61 64 20 0a 2b 09 23 20 73 74 6f 72 61  hread .+.# stora
c010: 67 65 20 73 75 62 73 79 73 74 65 6d 2e 20 0a 2b  ge subsystem. .+
c020: 09 41 43 5f 44 45 46 49 4e 45 28 55 53 45 5f 54  .AC_DEFINE(USE_T
c030: 48 52 45 41 44 5f 53 54 4f 52 41 47 45 29 0a 20  HREAD_STORAGE). 
c040: 20 20 20 20 65 6c 73 65 0a 20 09 54 43 4c 5f 54      else. .TCL_T
c050: 48 52 45 41 44 53 3d 30 0a 20 09 41 43 5f 4d 53  HREADS=0. .AC_MS
c060: 47 5f 52 45 53 55 4c 54 28 5b 6e 6f 20 28 64 65  G_RESULT([no (de
c070: 66 61 75 6c 74 29 5d 29 0a                       fault)]).