public
anonymous / __thread-tls-2.patch
Created

__thread-tls-2.patch

  • Download Gist
__thread-tls-2.patch
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532
Index: acinclude.m4
===================================================================
RCS file: /repository/php-src/acinclude.m4,v
retrieving revision 1.332.2.14.2.26.2.9
diff -u -r1.332.2.14.2.26.2.9 acinclude.m4
--- acinclude.m4 24 Jul 2008 14:17:54 -0000 1.332.2.14.2.26.2.9
+++ acinclude.m4 24 Aug 2008 15:16:48 -0000
@@ -2703,7 +2703,7 @@
enable-libtool-lock | with-pic | with-tags | enable-shared | enable-static | enable-fast-install | with-gnu-ld[)];;
# Allow certain TSRM options
- with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads[)];;
+ with-tsrm-pth | with-tsrm-st | with-tsrm-pthreads | with-tsrm-native-tls [)];;
# Allow certain Zend options
with-zend-vm | enable-maintainer-zts | enable-inline-optimization[)];;
Index: configure.in
===================================================================
RCS file: /repository/php-src/configure.in,v
retrieving revision 1.579.2.52.2.77.2.29
diff -u -r1.579.2.52.2.77.2.29 configure.in
--- configure.in 1 Aug 2008 00:46:20 -0000 1.579.2.52.2.77.2.29
+++ configure.in 24 Aug 2008 15:16:48 -0000
@@ -1088,6 +1088,7 @@
TSRM_BASIC_CHECKS
if test "$PHP_THREAD_SAFETY" = "yes"; then
TSRM_THREADS_CHECKS
+ TSRM___THREAD_CHECKS
fi
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $LDFLAGS"
Index: TSRM/TSRM.c
===================================================================
RCS file: /repository/TSRM/TSRM.c,v
retrieving revision 1.68.2.3.2.1.2.2
diff -u -r1.68.2.3.2.1.2.2 TSRM.c
--- TSRM/TSRM.c 7 Feb 2008 09:06:45 -0000 1.68.2.3.2.1.2.2
+++ TSRM/TSRM.c 24 Aug 2008 15:16:48 -0000
@@ -23,7 +23,7 @@
typedef struct _tsrm_tls_entry tsrm_tls_entry;
struct _tsrm_tls_entry {
- void **storage;
+ void *storage;
int count;
THREAD_T thread_id;
tsrm_tls_entry *next;
@@ -31,6 +31,7 @@
typedef struct {
+ ts_rsrc_offset offset;
size_t size;
ts_allocate_ctor ctor;
ts_allocate_dtor dtor;
@@ -42,6 +43,7 @@
static tsrm_tls_entry **tsrm_tls_table=NULL;
static int tsrm_tls_table_size;
static ts_rsrc_id id_count;
+static size_t rsrcs_size;
/* The resource sizes table */
static tsrm_resource_type *resource_types_table=NULL;
@@ -61,31 +63,61 @@
static int tsrm_error_level;
static FILE *tsrm_error_file;
+#ifdef USE___THREAD
+TSRM_API TSRM_TLS void *tsrm_ls_cache = 0;
+#endif
+
+#ifdef PASS_TSRMLS
+# define CALL_TSRMG_CTOR(ctor, globale, storage) (ctor)((globale), (storage))
+# define CALL_TSRMG_DTOR(ctor, globale, storage) (ctor)((globale), (storage))
+# define CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, storage) tsrm_new_thread_begin_handler((thread_id), (storage))
+# define CALL_NEW_THREAD_END_HANDLER(thread_id, storage) tsrm_new_thread_end_handler((thread_id), (storage))
+#else
+# define CALL_TSRMG_CTOR(ctor, globale, storage) (ctor)((globale))
+# define CALL_TSRMG_DTOR(ctor, globale, storage) (ctor)((globale))
+# define CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, storage) tsrm_new_thread_begin_handler((thread_id))
+# define CALL_NEW_THREAD_END_HANDLER(thread_id, storage) tsrm_new_thread_end_handler((thread_id))
+#endif
+
+#ifndef TSRM_MM_ALIGNMENT
+# define TSRM_MM_ALIGNMENT 8
+#elif TSRM_MM_ALIGNMENT < 4
+# undef TSRM_MM_ALIGNMENT
+# define TSRM_MM_ALIGNMENT 8
+#endif
+
+#define TSRMG_PTR(storage, offset) ((void *)((tsrm_uintptr_t)storage + offset))
+
+#ifdef USE___THREAD
+# define TSRM_RETURN_TSRM_LS(array) array
+#else
+# define TSRM_RETURN_TSRM_LS(array) &array
+#endif
#if TSRM_DEBUG
#define TSRM_ERROR(args) tsrm_error args
-#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
+#define TSRM_SAFE_RETURN_RSRC(array, id, range) \
{ \
- int unshuffled_offset = TSRM_UNSHUFFLE_RSRC_ID(offset); \
+ int unshuffled_id = TSRM_UNSHUFFLE_RSRC_ID(id); \
\
- if (offset==0) { \
- return &array; \
- } else if ((unshuffled_offset)>=0 && (unshuffled_offset)<(range)) { \
+ if (id==0) { \
+ return TSRM_RETURN_TSRM_LS(array); \
+ } else if ((unshuffled_id)>=0 && (unshuffled_id)<(range)) { \
TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Successfully fetched resource id %d for thread id %ld - 0x%0.8X", \
- unshuffled_offset, (long) thread_resources->thread_id, array[unshuffled_offset])); \
- return array[unshuffled_offset]; \
+ unshuffled_id, (long) thread_resources->thread_id, TSRMG_PTR(array, resource_types_table[unshuffled_id].offset))); \
+ return TSRMG_PTR(array, resource_types_table[unshuffled_id].offset); \
} else { \
TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Resource id %d is out of range (%d..%d)", \
- unshuffled_offset, TSRM_SHUFFLE_RSRC_ID(0), TSRM_SHUFFLE_RSRC_ID(thread_resources->count-1))); \
+ unshuffled_id, TSRM_SHUFFLE_RSRC_ID(0), TSRM_SHUFFLE_RSRC_ID(thread_resources->count-1))); \
return NULL; \
} \
}
#else
#define TSRM_ERROR(args)
-#define TSRM_SAFE_RETURN_RSRC(array, offset, range) \
- if (offset==0) { \
- return &array; \
+#define TSRM_SAFE_RETURN_RSRC(array, id, range) \
+ if (id==0) { \
+ return TSRM_RETURN_TSRM_LS(array); \
} else { \
- return array[TSRM_UNSHUFFLE_RSRC_ID(offset)]; \
+ return TSRMG_PTR(array, resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(id)].offset); \
}
#endif
@@ -175,11 +207,8 @@
next_p = p->next;
for (j=0; j<p->count; j++) {
- if (p->storage[j]) {
- if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
- resource_types_table[j].dtor(p->storage[j], &p->storage);
- }
- free(p->storage[j]);
+ if (resource_types_table && !resource_types_table[j].done && resource_types_table[j].dtor) {
+ CALL_TSRMG_CTOR(resource_types_table[j].dtor, TSRMG_PTR(p->storage, resource_types_table[j].offset), &p->storage);
}
}
free(p->storage);
@@ -212,9 +241,10 @@
/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
+TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, ts_rsrc_offset *rsrc_offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor)
{
int i;
+ ts_rsrc_offset offset = 0;
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new resource id, %d bytes", size));
@@ -235,6 +265,16 @@
}
resource_types_table_size = id_count;
}
+ if (TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id) > 0) {
+ offset = resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id-1)].offset
+ + resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id-1)].size;
+ }
+ offset = ((TSRM_MM_ALIGNMENT + offset - 1) & ~(TSRM_MM_ALIGNMENT - 1));
+ if (rsrc_offset) {
+ *rsrc_offset = offset;
+ }
+
+ resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].offset = offset;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].ctor = ctor;
resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].dtor = dtor;
@@ -248,11 +288,13 @@
if (p->count < id_count) {
int j;
- p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count);
+ p->storage = realloc(p->storage, offset + size);
+#ifdef USE___THREAD
+ tsrm_ls_cache = p->storage;
+#endif
for (j=p->count; j<id_count; j++) {
- p->storage[j] = (void *) malloc(resource_types_table[j].size);
if (resource_types_table[j].ctor) {
- resource_types_table[j].ctor(p->storage[j], &p->storage);
+ CALL_TSRMG_CTOR(resource_types_table[j].ctor, TSRMG_PTR(p->storage, resource_types_table[j].offset), &p->storage);
}
}
p->count = id_count;
@@ -260,9 +302,10 @@
p = p->next;
}
}
+ rsrcs_size = offset + size;
tsrm_mutex_unlock(tsmm_mutex);
- TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id));
+ TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d, offset %u", *rsrc_id, *rsrc_offset));
return *rsrc_id;
}
@@ -273,31 +316,30 @@
TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Creating data structures for thread %x", thread_id));
(*thread_resources_ptr) = (tsrm_tls_entry *) malloc(sizeof(tsrm_tls_entry));
- (*thread_resources_ptr)->storage = (void **) malloc(sizeof(void *)*id_count);
+ (*thread_resources_ptr)->storage = malloc(rsrcs_size);
(*thread_resources_ptr)->count = id_count;
(*thread_resources_ptr)->thread_id = thread_id;
(*thread_resources_ptr)->next = NULL;
/* Set thread local storage to this new thread resources structure */
tsrm_tls_set(*thread_resources_ptr);
+#ifdef USE___THREAD
+ tsrm_ls_cache = (*thread_resources_ptr)->storage;
+#endif
if (tsrm_new_thread_begin_handler) {
- tsrm_new_thread_begin_handler(thread_id, &((*thread_resources_ptr)->storage));
+ CALL_NEW_THREAD_BEGIN_HANDLER(thread_id, &(*thread_resources_ptr)->storage);
}
for (i=0; i<id_count; i++) {
- if (resource_types_table[i].done) {
- (*thread_resources_ptr)->storage[i] = NULL;
- } else
- {
- (*thread_resources_ptr)->storage[i] = (void *) malloc(resource_types_table[i].size);
+ if (!resource_types_table[i].done) {
if (resource_types_table[i].ctor) {
- resource_types_table[i].ctor((*thread_resources_ptr)->storage[i], &(*thread_resources_ptr)->storage);
+ CALL_TSRMG_CTOR(resource_types_table[i].ctor, TSRMG_PTR((*thread_resources_ptr)->storage, resource_types_table[i].offset), &(*thread_resources_ptr)->storage);
}
}
}
if (tsrm_new_thread_end_handler) {
- tsrm_new_thread_end_handler(thread_id, &((*thread_resources_ptr)->storage));
+ CALL_NEW_THREAD_END_HANDLER(thread_id, &(*thread_resources_ptr)->storage);
}
tsrm_mutex_unlock(tsmm_mutex);
@@ -390,12 +432,9 @@
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, TSRMG_PTR(thread_resources->storage, resource_types_table[i].offset), &thread_resources->storage);
}
}
- for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
- }
free(thread_resources->storage);
free(thread_resources);
thread_resources = next;
@@ -413,6 +452,9 @@
/* Set thread local storage to this new thread resources structure */
tsrm_tls_set(new_ctx);
+#ifdef USE___THREAD
+ tsrm_ls_cache = ((tsrm_tls_entry*)new_ctx)->storage;
+#endif
/* return old context, so caller can restore it when they're done */
return current;
@@ -455,12 +497,9 @@
if (thread_resources->thread_id == thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, TSRMG_PTR(thread_resources->storage, resource_types_table[i].offset), &thread_resources->storage);
}
}
- for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
- }
free(thread_resources->storage);
if (last) {
last->next = thread_resources->next;
@@ -497,12 +536,9 @@
if (thread_resources->thread_id != thread_id) {
for (i=0; i<thread_resources->count; i++) {
if (resource_types_table[i].dtor) {
- resource_types_table[i].dtor(thread_resources->storage[i], &thread_resources->storage);
+ CALL_TSRMG_DTOR(resource_types_table[i].dtor, TSRMG_PTR(thread_resources->storage, resource_types_table[i].offset), &thread_resources->storage);
}
}
- for (i=0; i<thread_resources->count; i++) {
- free(thread_resources->storage[i]);
- }
free(thread_resources->storage);
if (last) {
last->next = thread_resources->next;
@@ -541,12 +577,10 @@
tsrm_tls_entry *p = tsrm_tls_table[i];
while (p) {
- if (p->count > j && p->storage[j]) {
+ if (p->count > j) {
if (resource_types_table && resource_types_table[j].dtor) {
- resource_types_table[j].dtor(p->storage[j], &p->storage);
+ CALL_TSRMG_DTOR(resource_types_table[j].dtor, TSRMG_PTR(p->storage, resource_types_table[j].offset), &p->storage);
}
- free(p->storage[j]);
- p->storage[j] = NULL;
}
p = p->next;
}
Index: TSRM/TSRM.h
===================================================================
RCS file: /repository/TSRM/TSRM.h,v
retrieving revision 1.50.2.2.2.4.2.2
diff -u -r1.50.2.2.2.4.2.2 TSRM.h
--- TSRM/TSRM.h 30 Jan 2008 09:41:11 -0000 1.50.2.2.2.4.2.2
+++ TSRM/TSRM.h 24 Aug 2008 15:16:48 -0000
@@ -61,6 +61,7 @@
#endif
typedef int ts_rsrc_id;
+typedef tsrm_uintptr_t ts_rsrc_offset;
/* Define THREAD_T and MUTEX_T */
#ifdef TSRM_WIN32
@@ -90,21 +91,78 @@
# define MUTEX_T beos_ben *
#endif
-typedef void (*ts_allocate_ctor)(void *, void ***);
-typedef void (*ts_allocate_dtor)(void *, void ***);
-
#define THREAD_HASH_OF(thr,ts) (unsigned long)thr%(unsigned long)ts
#ifdef __cplusplus
extern "C" {
#endif
+#ifdef USE___THREAD
+
+# ifdef TSRM_WIN32
+# define TSRM_TLS __declspec(thread)
+# else
+# define TSRM_TLS __thread
+# endif
+
+TSRM_API extern TSRM_TLS void *tsrm_ls_cache;
+
+#define TSRMG(id, type, element) \
+ ((type)((tsrm_uintptr_t)tsrm_ls_cache + id##_offset))->element
+
+#define TSRMLS_INIT() tsrm_ls_cache = (void *) ts_resource_ex(0, NULL);
+#define TSRMLS_FETCH()
+#define TSRMLS_FETCH_FROM_CTX(ctx)
+#define TSRMLS_SET_CTX(ctx)
+#define TSRMLS_D void
+#define TSRMLS_DC
+#define TSRMLS_C
+#define TSRMLS_CC
+
+#else /* USE___THREAD */
+
+#define TSRMG(id, type, element) \
+ ((type)(*(tsrm_uintptr_t *)tsrm_ls + id##_offset))->element
+
+#define TSRMLS_INIT() TSRMLS_FETCH()
+#define TSRMLS_FETCH() void **tsrm_ls = (void **) ts_resource_ex(0, NULL);
+
+#define TSRMLS_FETCH_FROM_CTX(ctx) void **tsrm_ls = (void **) ctx
+#define TSRMLS_SET_CTX(ctx) ctx = (void **) tsrm_ls
+#define TSRMLS_D void **tsrm_ls
+#define TSRMLS_DC , TSRMLS_D
+#define TSRMLS_C tsrm_ls
+#define TSRMLS_CC , TSRMLS_C
+#define PASS_TSRMLS 1
+
+#endif /* USE___THREAD */
+
+#define TSRMG_DH(type, id) \
+ TSRM_API extern ts_rsrc_id id; \
+ TSRM_API extern ts_rsrc_offset id##_offset;
+
+#define TSRMG_D(type, id) \
+ TSRM_API ts_rsrc_id id; \
+ TSRM_API ts_rsrc_offset id##_offset;
+
+#define TSRMG_ALLOCATE(id, size, ctor, dtor) \
+ TSRMG_ALLOCATE_EX(id, id##_offset, size, ctor, dtor);
+
+#define TSRMG_ALLOCATE_EX(id, offset, size, ctor, dtor) \
+ ts_allocate_id(&(id), &(offset), (size), (ctor), (dtor));
+
+#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
+#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
+
+typedef void (*ts_allocate_ctor)(void * TSRMLS_DC);
+typedef void (*ts_allocate_dtor)(void * TSRMLS_DC);
+
/* startup/shutdown */
TSRM_API int tsrm_startup(int expected_threads, int expected_resources, int debug_level, char *debug_filename);
TSRM_API void tsrm_shutdown(void);
/* allocates a new thread-safe-resource id */
-TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
+TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, ts_rsrc_offset *rsrc_offset, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor);
/* fetches the requested resource for the current thread */
TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id);
@@ -125,8 +183,8 @@
#define TSRM_ERROR_LEVEL_CORE 2
#define TSRM_ERROR_LEVEL_INFO 3
-typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id, void ***tsrm_ls);
-typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id, void ***tsrm_ls);
+typedef void (*tsrm_thread_begin_func_t)(THREAD_T thread_id TSRMLS_DC);
+typedef void (*tsrm_thread_end_func_t)(THREAD_T thread_id TSRMLS_DC);
TSRM_API int tsrm_error(int level, const char *format, ...);
@@ -148,24 +206,13 @@
TSRM_API void *tsrm_set_interpreter_context(void *new_ctx);
TSRM_API void tsrm_free_interpreter_context(void *context);
-#define TSRM_SHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)+1)
-#define TSRM_UNSHUFFLE_RSRC_ID(rsrc_id) ((rsrc_id)-1)
-
-#define TSRMLS_FETCH() void ***tsrm_ls = (void ***) ts_resource_ex(0, NULL)
-#define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = (void ***) ctx
-#define TSRMLS_SET_CTX(ctx) ctx = (void ***) tsrm_ls
-#define TSRMG(id, type, element) (((type) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(id)])->element)
-#define TSRMLS_D void ***tsrm_ls
-#define TSRMLS_DC , TSRMLS_D
-#define TSRMLS_C tsrm_ls
-#define TSRMLS_CC , TSRMLS_C
-
#ifdef __cplusplus
}
#endif
#else /* non ZTS */
+#define TSRMLS_INIT()
#define TSRMLS_FETCH()
#define TSRMLS_FETCH_FROM_CTX(ctx)
#define TSRMLS_SET_CTX(ctx)
Index: TSRM/configure.in
===================================================================
RCS file: /repository/TSRM/configure.in,v
retrieving revision 1.17
diff -u -r1.17 configure.in
--- TSRM/configure.in 8 Aug 2001 10:26:21 -0000 1.17
+++ TSRM/configure.in 24 Aug 2008 15:16:49 -0000
@@ -11,6 +11,7 @@
TSRM_BASIC_CHECKS
TSRM_THREADS_CHECKS
+TSRM___THREAD_CHECKS
AM_PROG_LIBTOOL
if test "$enable_debug" != "yes"; then
Index: TSRM/tsrm.m4
===================================================================
RCS file: /repository/TSRM/tsrm.m4,v
retrieving revision 1.17.4.1
diff -u -r1.17.4.1 tsrm.m4
--- TSRM/tsrm.m4 22 Aug 2006 13:01:44 -0000 1.17.4.1
+++ TSRM/tsrm.m4 24 Aug 2008 15:16:49 -0000
@@ -21,6 +21,71 @@
fi
])
+AC_DEFUN([TSRM___THREAD_CHECKS],[
+ AC_ARG_WITH(tsrm-native-tls,
+ [ --with-tsrm-native-tls
+ Use native TLS],[
+ USE___THREAD=yes
+ ],[
+ USE___THREAD=no
+ ])
+
+ if test $USE___THREAD = yes; then
+ AC_CACHE_CHECK([for __thread specifier], ac_cv_tsrm_have___thread, [
+ AC_TRY_RUN([
+ __thread int foo = 42;
+ int main() {
+ return foo - 42;
+ }
+ ],[
+ ac_cv_tsrm_have___thread=yes
+ ],[
+ ac_cv_tsrm_have___thread=no
+ ])
+ ])
+ AC_MSG_CHECKING(wether to use native TLS)
+ if test $ac_cv_tsrm_have___thread = yes; then
+ AC_DEFINE(USE___THREAD, 1, [wether to use native TLS])
+ else
+ AC_MSG_ERROR([__thread specifier not available])
+ fi
+ AC_MSG_RESULT(yes)
+ fi
+])
+
+dnl test and set the memory alignment
+AC_DEFUN([TSRM_MM_ALIGN_CHECK], [
+ AC_CACHE_CHECK([for MM alignment], ac_cv_tsrm_mm_align, [
+ AC_TRY_RUN([
+ #include <stdio.h>
+
+ typedef union _mm_align_test {
+ void *ptr;
+ double dbl;
+ long lng;
+ } mm_align_test;
+
+ #if (defined (__GNUC__) && __GNUC__ >= 2)
+ #define TSRM_MM_ALIGNMENT (__alignof__ (mm_align_test))
+ #else
+ #define TSRM_MM_ALIGNMENT (sizeof(mm_align_test))
+ #endif
+
+ int main()
+ {
+ FILE *fp;
+ fp = fopen("conftest.tsrm", "w");
+ fprintf(fp, "%d\n", TSRM_MM_ALIGNMENT);
+ fclose(fp);
+ return 0;
+ }
+ ],[
+ ac_cv_tsrm_mm_align=`cat conftest.tsrm | cut -d ' ' -f 1`
+ ])
+ ])
+ AC_DEFINE_UNQUOTED(TSRM_MM_ALIGNMENT, $ac_cv_tsrm_mm_align, [ ])
+])
+
AC_DEFUN([TSRM_BASIC_CHECKS],[
AC_REQUIRE([AC_PROG_CC])dnl
@@ -29,6 +94,7 @@
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_CHECK_HEADERS(stdarg.h)
+TSRM_MM_ALIGN_CHECK()
])
Index: TSRM/tsrm_virtual_cwd.c
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.c,v
retrieving revision 1.74.2.9.2.35.2.13
diff -u -r1.74.2.9.2.35.2.13 tsrm_virtual_cwd.c
--- TSRM/tsrm_virtual_cwd.c 19 Aug 2008 15:00:20 -0000 1.74.2.9.2.35.2.13
+++ TSRM/tsrm_virtual_cwd.c 24 Aug 2008 15:16:49 -0000
@@ -55,7 +55,7 @@
#endif
#ifdef ZTS
-ts_rsrc_id cwd_globals_id;
+TSRMG_D(virtual_cwd_globals, cwd_globals_id);
#else
virtual_cwd_globals cwd_globals;
#endif
@@ -311,7 +311,7 @@
main_cwd_state.cwd = strdup(cwd);
#ifdef ZTS
- ts_allocate_id(&cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
+ TSRMG_ALLOCATE(cwd_globals_id, sizeof(virtual_cwd_globals), (ts_allocate_ctor) cwd_globals_ctor, (ts_allocate_dtor) cwd_globals_dtor);
#else
cwd_globals_ctor(&cwd_globals TSRMLS_CC);
#endif
Index: TSRM/tsrm_virtual_cwd.h
===================================================================
RCS file: /repository/TSRM/tsrm_virtual_cwd.h,v
retrieving revision 1.48.2.5.2.8.2.5
diff -u -r1.48.2.5.2.8.2.5 tsrm_virtual_cwd.h
--- TSRM/tsrm_virtual_cwd.h 12 Aug 2008 08:01:24 -0000 1.48.2.5.2.8.2.5
+++ TSRM/tsrm_virtual_cwd.h 24 Aug 2008 15:16:49 -0000
@@ -222,7 +222,7 @@
} virtual_cwd_globals;
#ifdef ZTS
-extern ts_rsrc_id cwd_globals_id;
+TSRMG_DH(virtual_cwd_globals, cwd_globals_id);
# define CWDG(v) TSRMG(cwd_globals_id, virtual_cwd_globals *, v)
#else
extern virtual_cwd_globals cwd_globals;
Index: TSRM/tsrm_win32.c
===================================================================
RCS file: /repository/TSRM/tsrm_win32.c,v
retrieving revision 1.27.2.1.2.7.2.2
diff -u -r1.27.2.1.2.7.2.2 tsrm_win32.c
--- TSRM/tsrm_win32.c 29 May 2008 11:31:02 -0000 1.27.2.1.2.7.2.2
+++ TSRM/tsrm_win32.c 24 Aug 2008 15:16:49 -0000
@@ -71,7 +71,7 @@
TSRM_API void tsrm_win32_startup(void)
{
#ifdef ZTS
- ts_allocate_id(&win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_ctor)tsrm_win32_dtor);
+ TSRMG_ALLOCATE(win32_globals_id, sizeof(tsrm_win32_globals), (ts_allocate_ctor)tsrm_win32_ctor, (ts_allocate_dtor)tsrm_win32_dtor);
#else
tsrm_win32_ctor(&win32_globals TSRMLS_CC);
#endif
Index: Zend/zend.c
===================================================================
RCS file: /repository/ZendEngine2/zend.c,v
retrieving revision 1.308.2.12.2.35.2.23
diff -u -r1.308.2.12.2.35.2.23 zend.c
--- Zend/zend.c 15 Aug 2008 19:47:23 -0000 1.308.2.12.2.35.2.23
+++ Zend/zend.c 24 Aug 2008 15:16:49 -0000
@@ -98,8 +98,8 @@
#ifdef ZTS
-ZEND_API int compiler_globals_id;
-ZEND_API int executor_globals_id;
+TSRMG_D(zend_compiler_globals, compiler_globals_id);
+TSRMG_D(zend_executor_globals, executor_globals_id);
static HashTable *global_function_table = NULL;
static HashTable *global_class_table = NULL;
static HashTable *global_constants_table = NULL;
@@ -606,8 +606,8 @@
#ifdef ZTS
zend_compiler_globals *compiler_globals;
zend_executor_globals *executor_globals;
- extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
- extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+ TSRMG_DH(zend_ini_scanner_globals, ini_scanner_globals_id);
+ TSRMG_DH(zend_php_scanner_globals, language_scanner_globals_id);
#else
extern zend_ini_scanner_globals ini_scanner_globals;
extern zend_php_scanner_globals language_scanner_globals;
@@ -673,10 +673,10 @@
Z_TYPE(zval_used_for_init) = IS_NULL;
#ifdef ZTS
- ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
- ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
- ts_allocate_id(&language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
- ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
+ TSRMG_ALLOCATE(compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
+ TSRMG_ALLOCATE(executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
+ TSRMG_ALLOCATE(language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
+ TSRMG_ALLOCATE(ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
compiler_globals = ts_resource(compiler_globals_id);
executor_globals = ts_resource(executor_globals_id);
@@ -750,9 +750,9 @@
zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
free(compiler_globals->function_table);
free(compiler_globals->class_table);
- compiler_globals_ctor(compiler_globals, tsrm_ls);
+ compiler_globals_ctor(compiler_globals TSRMLS_CC);
free(EG(zend_constants));
- executor_globals_ctor(executor_globals, tsrm_ls);
+ executor_globals_ctor(executor_globals TSRMLS_CC);
global_persistent_list = &EG(persistent_list);
zend_copy_ini_directives(TSRMLS_C);
#endif
Index: Zend/zend_API.c
===================================================================
RCS file: /repository/ZendEngine2/zend_API.c,v
retrieving revision 1.296.2.27.2.34.2.53
diff -u -r1.296.2.27.2.34.2.53 zend_API.c
--- Zend/zend_API.c 22 Aug 2008 14:51:30 -0000 1.296.2.27.2.34.2.53
+++ Zend/zend_API.c 24 Aug 2008 15:16:49 -0000
@@ -1574,7 +1574,7 @@
/* Initialize module globals */
if (module->globals_size) {
#ifdef ZTS
- ts_allocate_id(module->globals_id_ptr, module->globals_size, (ts_allocate_ctor) module->globals_ctor, (ts_allocate_dtor) module->globals_dtor);
+ TSRMG_ALLOCATE_EX((*module->globals_id_ptr), (*module->globals_offset), module->globals_size, module->globals_ctor, module->globals_dtor);
#else
if (module->globals_ctor) {
module->globals_ctor(module->globals_ptr TSRMLS_CC);
Index: Zend/zend_API.h
===================================================================
RCS file: /repository/ZendEngine2/zend_API.h,v
retrieving revision 1.207.2.8.2.8.2.18
diff -u -r1.207.2.8.2.8.2.18 zend_API.h
--- Zend/zend_API.h 12 Aug 2008 21:45:52 -0000 1.207.2.8.2.8.2.18
+++ Zend/zend_API.h 24 Aug 2008 15:16:49 -0000
@@ -140,11 +140,11 @@
#ifdef ZTS
#define ZEND_DECLARE_MODULE_GLOBALS(module_name) \
- ts_rsrc_id module_name##_globals_id;
+ TSRMG_D(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_EXTERN_MODULE_GLOBALS(module_name) \
- extern ts_rsrc_id module_name##_globals_id;
+ TSRMG_DH(zend_##module_name##_globals, module_name##_globals_id);
#define ZEND_INIT_MODULE_GLOBALS(module_name, globals_ctor, globals_dtor) \
- ts_allocate_id(&module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
+ TSRMG_ALLOCATE(module_name##_globals_id, sizeof(zend_##module_name##_globals), (ts_allocate_ctor) globals_ctor, (ts_allocate_dtor) globals_dtor);
#else
Index: Zend/zend_alloc.c
===================================================================
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.16
diff -u -r1.144.2.3.2.43.2.16 zend_alloc.c
--- Zend/zend_alloc.c 15 Aug 2008 19:47:23 -0000 1.144.2.3.2.43.2.16
+++ Zend/zend_alloc.c 24 Aug 2008 15:16:50 -0000
@@ -2265,7 +2265,7 @@
} zend_alloc_globals;
#ifdef ZTS
-static int alloc_globals_id;
+TSRMG_D(zend_alloc_globals, alloc_globals_id);
# define AG(v) TSRMG(alloc_globals_id, zend_alloc_globals *, v)
#else
# define AG(v) (alloc_globals.v)
@@ -2521,7 +2521,7 @@
ZEND_API void start_memory_manager(TSRMLS_D)
{
#ifdef ZTS
- ts_allocate_id(&alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
+ TSRMG_ALLOCATE(alloc_globals_id, sizeof(zend_alloc_globals), (ts_allocate_ctor) alloc_globals_ctor, (ts_allocate_dtor) alloc_globals_dtor);
#else
alloc_globals_ctor(&alloc_globals);
#endif
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/ZendEngine2/zend_compile.c,v
retrieving revision 1.647.2.27.2.41.2.83
diff -u -r1.647.2.27.2.41.2.83 zend_compile.c
--- Zend/zend_compile.c 22 Aug 2008 15:54:20 -0000 1.647.2.27.2.41.2.83
+++ Zend/zend_compile.c 24 Aug 2008 15:16:50 -0000
@@ -2197,7 +2197,7 @@
start_op_number = get_next_op_number(CG(active_op_array));
-#ifdef ZTS
+#ifdef PASS_TSRMLS
zend_stack_apply_with_argument(&CG(switch_cond_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_switch_expr TSRMLS_CC);
zend_stack_apply_with_argument(&CG(foreach_copy_stack), ZEND_STACK_APPLY_TOPDOWN, (int (*)(void *element, void *)) generate_free_foreach_copy TSRMLS_CC);
#else
Index: Zend/zend_gc.c
===================================================================
RCS file: /repository/ZendEngine2/zend_gc.c,v
retrieving revision 1.1.2.16
diff -u -r1.1.2.16 zend_gc.c
--- Zend/zend_gc.c 15 Aug 2008 19:47:24 -0000 1.1.2.16
+++ Zend/zend_gc.c 24 Aug 2008 15:16:50 -0000
@@ -25,7 +25,7 @@
#define GC_ROOT_BUFFER_MAX_ENTRIES 10000
#ifdef ZTS
-ZEND_API int gc_globals_id;
+TSRMG_D(zend_gc_globals, gc_globals_id);
#else
ZEND_API zend_gc_globals gc_globals;
#endif
@@ -78,7 +78,7 @@
ZEND_API void gc_globals_ctor(TSRMLS_D)
{
#ifdef ZTS
- ts_allocate_id(&gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
+ TSRMG_ALLOCATE(gc_globals_id, sizeof(zend_gc_globals), (ts_allocate_ctor) gc_globals_ctor_ex, (ts_allocate_dtor) root_buffer_dtor);
#else
gc_globals_ctor_ex(&gc_globals);
#endif
Index: Zend/zend_gc.h
===================================================================
RCS file: /repository/ZendEngine2/zend_gc.h,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 zend_gc.h
--- Zend/zend_gc.h 15 Aug 2008 19:47:24 -0000 1.1.2.8
+++ Zend/zend_gc.h 24 Aug 2008 15:16:50 -0000
@@ -130,7 +130,7 @@
#ifdef ZTS
BEGIN_EXTERN_C()
-ZEND_API extern int gc_globals_id;
+TSRMG_DH(zend_gc_globals, gc_globals_id);
END_EXTERN_C()
#define GC_G(v) TSRMG(gc_globals_id, zend_gc_globals *, v)
#else
Index: Zend/zend_globals.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals.h,v
retrieving revision 1.141.2.3.2.7.2.19
diff -u -r1.141.2.3.2.7.2.19 zend_globals.h
--- Zend/zend_globals.h 14 Aug 2008 10:24:51 -0000 1.141.2.3.2.7.2.19
+++ Zend/zend_globals.h 24 Aug 2008 15:16:50 -0000
@@ -45,8 +45,8 @@
#ifdef ZTS
BEGIN_EXTERN_C()
-ZEND_API extern int compiler_globals_id;
-ZEND_API extern int executor_globals_id;
+TSRMG_DH(zend_compiler_globals, compiler_globals_id);
+TSRMG_DH(zend_executor_globals, executor_globals_id);
END_EXTERN_C()
#endif
Index: Zend/zend_globals_macros.h
===================================================================
RCS file: /repository/ZendEngine2/zend_globals_macros.h,v
retrieving revision 1.22.2.1.2.4.2.2
diff -u -r1.22.2.1.2.4.2.2 zend_globals_macros.h
--- Zend/zend_globals_macros.h 16 Mar 2008 21:05:33 -0000 1.22.2.1.2.4.2.2
+++ Zend/zend_globals_macros.h 24 Aug 2008 15:16:50 -0000
@@ -32,10 +32,13 @@
/* Compiler */
#ifdef ZTS
# define CG(v) TSRMG(compiler_globals_id, zend_compiler_globals *, v)
-int zendparse(void *compiler_globals);
#else
# define CG(v) (compiler_globals.v)
extern ZEND_API struct _zend_compiler_globals compiler_globals;
+#endif
+#ifdef PASS_TSRMLS
+int zendparse(void *compiler_globals);
+#else
int zendparse(void);
#endif
@@ -51,7 +54,7 @@
/* Language Scanner */
#ifdef ZTS
# define LANG_SCNG(v) TSRMG(language_scanner_globals_id, zend_php_scanner_globals *, v)
-extern ZEND_API ts_rsrc_id language_scanner_globals_id;
+TSRMG_DH(zend_php_scanner_globals, language_scanner_globals_id);
#else
# define LANG_SCNG(v) (language_scanner_globals.v)
extern ZEND_API zend_php_scanner_globals language_scanner_globals;
@@ -61,7 +64,7 @@
/* INI Scanner */
#ifdef ZTS
# define INI_SCNG(v) TSRMG(ini_scanner_globals_id, zend_ini_scanner_globals *, v)
-extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
+TSRMG_DH(zend_ini_scanner_globals, ini_scanner_globals_id);
#else
# define INI_SCNG(v) (ini_scanner_globals.v)
extern ZEND_API zend_ini_scanner_globals ini_scanner_globals;
Index: Zend/zend_ini_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_ini_parser.y,v
retrieving revision 1.41.2.2.2.2.2.5
diff -u -r1.41.2.2.2.2.2.5 zend_ini_parser.y
--- Zend/zend_ini_parser.y 16 Mar 2008 21:05:33 -0000 1.41.2.2.2.2.2.5
+++ Zend/zend_ini_parser.y 24 Aug 2008 15:16:50 -0000
@@ -32,7 +32,7 @@
#define YYERROR_VERBOSE
#define YYSTYPE zval
-#ifdef ZTS
+#ifdef PASS_TSRMLS
#define YYPARSE_PARAM tsrm_ls
#define YYLEX_PARAM tsrm_ls
int ini_parse(void *arg);
Index: Zend/zend_ini_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_ini_scanner.l,v
retrieving revision 1.41.2.2.2.2.2.10
diff -u -r1.41.2.2.2.2.2.10 zend_ini_scanner.l
--- Zend/zend_ini_scanner.l 17 Aug 2008 21:55:26 -0000 1.41.2.2.2.2.2.10
+++ Zend/zend_ini_scanner.l 24 Aug 2008 15:16:50 -0000
@@ -98,7 +98,7 @@
/* Globals Macros */
#define SCNG INI_SCNG
#ifdef ZTS
-ZEND_API ts_rsrc_id ini_scanner_globals_id;
+TSRMG_D(zend_ini_scanner_globals, ini_scanner_globals_id);
#else
ZEND_API zend_ini_scanner_globals ini_scanner_globals;
#endif
Index: Zend/zend_language_parser.y
===================================================================
RCS file: /repository/ZendEngine2/zend_language_parser.y,v
retrieving revision 1.160.2.4.2.8.2.25
diff -u -r1.160.2.4.2.8.2.25 zend_language_parser.y
--- Zend/zend_language_parser.y 12 Aug 2008 10:23:02 -0000 1.160.2.4.2.8.2.25
+++ Zend/zend_language_parser.y 24 Aug 2008 15:16:51 -0000
@@ -38,7 +38,7 @@
#define YYERROR_VERBOSE
#define YYSTYPE znode
-#ifdef ZTS
+#ifdef PASS_TSRMLS
# define YYPARSE_PARAM tsrm_ls
# define YYLEX_PARAM tsrm_ls
#endif
Index: Zend/zend_language_scanner.l
===================================================================
RCS file: /repository/ZendEngine2/zend_language_scanner.l,v
retrieving revision 1.131.2.11.2.13.2.31
diff -u -r1.131.2.11.2.13.2.31 zend_language_scanner.l
--- Zend/zend_language_scanner.l 15 Aug 2008 19:47:28 -0000 1.131.2.11.2.13.2.31
+++ Zend/zend_language_scanner.l 24 Aug 2008 15:16:52 -0000
@@ -85,7 +85,7 @@
/* Globals Macros */
#define SCNG LANG_SCNG
#ifdef ZTS
-ZEND_API ts_rsrc_id language_scanner_globals_id;
+TSRMG_D(zend_php_scanner_globals, language_scanner_globals_id);
#else
ZEND_API zend_php_scanner_globals language_scanner_globals;
#endif
Index: Zend/zend_modules.h
===================================================================
RCS file: /repository/ZendEngine2/zend_modules.h,v
retrieving revision 1.67.2.3.2.4.2.6
diff -u -r1.67.2.3.2.4.2.6 zend_modules.h
--- Zend/zend_modules.h 12 Aug 2008 17:20:24 -0000 1.67.2.3.2.4.2.6
+++ Zend/zend_modules.h 24 Aug 2008 15:16:52 -0000
@@ -50,7 +50,7 @@
#define NO_MODULE_GLOBALS 0, NULL, NULL, NULL
#ifdef ZTS
-# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id
+# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals_id, &module_name##_globals_id_offset
#else
# define ZEND_MODULE_GLOBALS(module_name) sizeof(zend_##module_name##_globals), &module_name##_globals
#endif
@@ -85,6 +85,7 @@
size_t globals_size;
#ifdef ZTS
ts_rsrc_id* globals_id_ptr;
+ ts_rsrc_offset* globals_offset;
#else
void* globals_ptr;
#endif
Index: ext/standard/basic_functions.c
===================================================================
RCS file: /repository/php-src/ext/standard/basic_functions.c,v
retrieving revision 1.725.2.31.2.64.2.62
diff -u -r1.725.2.31.2.64.2.62 basic_functions.c
--- ext/standard/basic_functions.c 23 Aug 2008 19:22:08 -0000 1.725.2.31.2.64.2.62
+++ ext/standard/basic_functions.c 24 Aug 2008 15:17:01 -0000
@@ -109,7 +109,7 @@
#include "php_ticks.h"
#ifdef ZTS
-PHPAPI int basic_globals_id;
+TSRMG_D(php_basic_globals, basic_globals_id);
#else
PHPAPI php_basic_globals basic_globals;
#endif
@@ -3980,9 +3980,9 @@
PHP_MINIT_FUNCTION(basic) /* {{{ */
{
#ifdef ZTS
- ts_allocate_id(&basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
+ TSRMG_ALLOCATE(basic_globals_id, sizeof(php_basic_globals), (ts_allocate_ctor) basic_globals_ctor, (ts_allocate_dtor) basic_globals_dtor);
#ifdef PHP_WIN32
- ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor );
+ TSRMG_ALLOCATE(php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor)php_win32_core_globals_ctor, (ts_allocate_dtor)php_win32_core_globals_dtor);
#endif
#else
basic_globals_ctor(&basic_globals TSRMLS_CC);
Index: ext/standard/basic_functions.h
===================================================================
RCS file: /repository/php-src/ext/standard/basic_functions.h,v
retrieving revision 1.139.2.4.2.6.2.9
diff -u -r1.139.2.4.2.6.2.9 basic_functions.h
--- ext/standard/basic_functions.h 15 Apr 2008 08:44:21 -0000 1.139.2.4.2.6.2.9
+++ ext/standard/basic_functions.h 24 Aug 2008 15:17:01 -0000
@@ -228,7 +228,7 @@
#ifdef ZTS
#define BG(v) TSRMG(basic_globals_id, php_basic_globals *, v)
-PHPAPI extern int basic_globals_id;
+TSRMG_DH(php_basic_globals, basic_globals_id);
#else
#define BG(v) (basic_globals.v)
PHPAPI extern php_basic_globals basic_globals;
Index: ext/standard/dir.c
===================================================================
RCS file: /repository/php-src/ext/standard/dir.c,v
retrieving revision 1.147.2.3.2.12.2.11
diff -u -r1.147.2.3.2.12.2.11 dir.c
--- ext/standard/dir.c 11 Aug 2008 23:14:36 -0000 1.147.2.3.2.12.2.11
+++ ext/standard/dir.c 24 Aug 2008 15:17:01 -0000
@@ -57,7 +57,7 @@
#ifdef ZTS
#define DIRG(v) TSRMG(dir_globals_id, php_dir_globals *, v)
-int dir_globals_id;
+TSRMG_D(php_dir_globals, dir_globals_id);
#else
#define DIRG(v) (dir_globals.v)
php_dir_globals dir_globals;
@@ -131,7 +131,7 @@
dir_class_entry_ptr = zend_register_internal_class(&dir_class_entry TSRMLS_CC);
#ifdef ZTS
- ts_allocate_id(&dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
+ TSRMG_ALLOCATE(dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
#endif
dirsep_str[0] = DEFAULT_SLASH;
Index: ext/standard/file.c
===================================================================
RCS file: /repository/php-src/ext/standard/file.c,v
retrieving revision 1.409.2.6.2.28.2.21
diff -u -r1.409.2.6.2.28.2.21 file.c
--- ext/standard/file.c 12 Aug 2008 19:38:54 -0000 1.409.2.6.2.28.2.21
+++ ext/standard/file.c 24 Aug 2008 15:17:01 -0000
@@ -111,7 +111,7 @@
#include "zend_API.h"
#ifdef ZTS
-int file_globals_id;
+TSRMG_D(php_file_globals, file_globals_id);
#else
php_file_globals file_globals;
#endif
@@ -183,7 +183,7 @@
le_stream_context = zend_register_list_destructors_ex(file_context_dtor, NULL, "stream-context", module_number);
#ifdef ZTS
- ts_allocate_id(&file_globals_id, sizeof(php_file_globals), (ts_allocate_ctor) file_globals_ctor, (ts_allocate_dtor) file_globals_dtor);
+ TSRMG_ALLOCATE(file_globals_id, sizeof(php_file_globals), (ts_allocate_ctor) file_globals_ctor, (ts_allocate_dtor) file_globals_dtor);
#else
file_globals_ctor(&file_globals TSRMLS_CC);
#endif
Index: ext/standard/file.h
===================================================================
RCS file: /repository/php-src/ext/standard/file.h,v
retrieving revision 1.94.2.2.2.5.2.2
diff -u -r1.94.2.2.2.5.2.2 file.h
--- ext/standard/file.h 31 Dec 2007 07:17:14 -0000 1.94.2.2.2.5.2.2
+++ ext/standard/file.h 24 Aug 2008 15:17:01 -0000
@@ -126,7 +126,7 @@
#ifdef ZTS
#define FG(v) TSRMG(file_globals_id, php_file_globals *, v)
-extern PHPAPI int file_globals_id;
+TSRMG_DH(php_file_globals, file_globals_id);
#else
#define FG(v) (file_globals.v)
extern PHPAPI php_file_globals file_globals;
Index: ext/standard/info.c
===================================================================
RCS file: /repository/php-src/ext/standard/info.c,v
retrieving revision 1.249.2.10.2.14.2.11
diff -u -r1.249.2.10.2.14.2.11 info.c
--- ext/standard/info.c 13 Aug 2008 00:53:28 -0000 1.249.2.10.2.14.2.11
+++ ext/standard/info.c 24 Aug 2008 15:17:01 -0000
@@ -503,7 +503,11 @@
#endif
#ifdef ZTS
+# ifdef USE___THREAD
+ php_info_print_table_row(2, "Thread Safety", "enabled, native TLS" );
+# else
php_info_print_table_row(2, "Thread Safety", "enabled" );
+# endif
#else
php_info_print_table_row(2, "Thread Safety", "disabled" );
#endif
Index: ext/standard/lcg.c
===================================================================
RCS file: /repository/php-src/ext/standard/lcg.c,v
retrieving revision 1.41.2.1.2.2.2.2
diff -u -r1.41.2.1.2.2.2.2 lcg.c
--- ext/standard/lcg.c 31 Dec 2007 07:17:15 -0000 1.41.2.1.2.2.2.2
+++ ext/standard/lcg.c 24 Aug 2008 15:17:01 -0000
@@ -32,7 +32,7 @@
#endif
#ifdef ZTS
-int lcg_globals_id;
+TSRMG_D(php_lcg_globals, lcg_globals_id);
#else
static php_lcg_globals lcg_globals;
#endif
@@ -101,7 +101,7 @@
PHP_MINIT_FUNCTION(lcg) /* {{{ */
{
#ifdef ZTS
- ts_allocate_id(&lcg_globals_id, sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
+ TSRMG_ALLOCATE(lcg_globals_id, sizeof(php_lcg_globals), (ts_allocate_ctor) lcg_init_globals, NULL);
#else
lcg_init_globals(&lcg_globals);
#endif
Index: main/SAPI.c
===================================================================
RCS file: /repository/php-src/main/SAPI.c,v
retrieving revision 1.202.2.7.2.15.2.4
diff -u -r1.202.2.7.2.15.2.4 SAPI.c
--- main/SAPI.c 18 Mar 2008 21:42:50 -0000 1.202.2.7.2.15.2.4
+++ main/SAPI.c 24 Aug 2008 15:17:02 -0000
@@ -53,7 +53,7 @@
#include "php_content_types.h"
#ifdef ZTS
-SAPI_API int sapi_globals_id;
+TSRMG_D(sapi_globals_struct, sapi_globals_id);
#else
sapi_globals_struct sapi_globals;
#endif
@@ -80,7 +80,7 @@
sapi_module = *sf;
#ifdef ZTS
- ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
+ TSRMG_ALLOCATE(sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
#else
sapi_globals_ctor(&sapi_globals);
#endif
Index: main/SAPI.h
===================================================================
RCS file: /repository/php-src/main/SAPI.h,v
retrieving revision 1.114.2.1.2.3.2.3
diff -u -r1.114.2.1.2.3.2.3 SAPI.h
--- main/SAPI.h 18 Mar 2008 21:42:50 -0000 1.114.2.1.2.3.2.3
+++ main/SAPI.h 24 Aug 2008 15:17:02 -0000
@@ -137,7 +137,7 @@
BEGIN_EXTERN_C()
#ifdef ZTS
# define SG(v) TSRMG(sapi_globals_id, sapi_globals_struct *, v)
-SAPI_API extern int sapi_globals_id;
+TSRMG_DH(sapi_globals_struct, sapi_globals_id);
#else
# define SG(v) (sapi_globals.v)
extern SAPI_API sapi_globals_struct sapi_globals;
Index: main/main.c
===================================================================
RCS file: /repository/php-src/main/main.c,v
retrieving revision 1.640.2.23.2.57.2.31
diff -u -r1.640.2.23.2.57.2.31 main.c
--- main/main.c 23 Aug 2008 17:55:50 -0000 1.640.2.23.2.57.2.31
+++ main/main.c 24 Aug 2008 15:17:02 -0000
@@ -96,7 +96,7 @@
#ifndef ZTS
php_core_globals core_globals;
#else
-PHPAPI int core_globals_id;
+TSRMG_D(php_core_globals, core_globals_id);
#endif
#define SAFE_FILENAME(f) ((f)?(f):"-")
@@ -1657,8 +1657,6 @@
char *php_os;
#ifdef ZTS
zend_executor_globals *executor_globals;
- void ***tsrm_ls;
-
php_core_globals *core_globals;
#endif
#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
@@ -1691,7 +1689,7 @@
#endif
#ifdef ZTS
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
module_shutdown = 0;
@@ -1725,10 +1723,10 @@
#ifdef ZTS
executor_globals = ts_resource(executor_globals_id);
- ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
+ TSRMG_ALLOCATE(core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
core_globals = ts_resource(core_globals_id);
#ifdef PHP_WIN32
- ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
+ TSRMG_ALLOCATE(php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
#endif
#endif
gc_globals_ctor(TSRMLS_C);
Index: main/output.c
===================================================================
RCS file: /repository/php-src/main/output.c,v
retrieving revision 1.167.2.3.2.4.2.9
diff -u -r1.167.2.3.2.4.2.9 output.c
--- main/output.c 18 Aug 2008 07:46:31 -0000 1.167.2.3.2.4.2.9
+++ main/output.c 24 Aug 2008 15:17:02 -0000
@@ -41,7 +41,7 @@
#endif
#ifdef ZTS
-int output_globals_id;
+TSRMG_D(php_output_globals, output_globals_id);
#else
php_output_globals output_globals;
#endif
@@ -71,7 +71,7 @@
PHPAPI void php_output_startup(void)
{
#ifdef ZTS
- ts_allocate_id(&output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
+ TSRMG_ALLOCATE(output_globals_id, sizeof(php_output_globals), (ts_allocate_ctor) php_output_init_globals, NULL);
#else
php_output_init_globals(&output_globals TSRMLS_CC);
#endif
Index: main/php.h
===================================================================
RCS file: /repository/php-src/main/php.h,v
retrieving revision 1.221.2.4.2.8.2.10
diff -u -r1.221.2.4.2.8.2.10 php.h
--- main/php.h 22 Aug 2008 12:59:46 -0000 1.221.2.4.2.8.2.10
+++ main/php.h 24 Aug 2008 15:17:02 -0000
@@ -289,7 +289,7 @@
PHPAPI void php_verror(const char *docref, const char *params, int type, const char *format, va_list args TSRMLS_DC) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
-#ifdef ZTS
+#ifdef PASS_TSRMLS
#define PHP_ATTR_FMT_OFFSET 1
#else
#define PHP_ATTR_FMT_OFFSET 0
Index: main/php_globals.h
===================================================================
RCS file: /repository/php-src/main/php_globals.h,v
retrieving revision 1.98.2.1.2.7.2.5
diff -u -r1.98.2.1.2.7.2.5 php_globals.h
--- main/php_globals.h 18 Mar 2008 21:42:50 -0000 1.98.2.1.2.7.2.5
+++ main/php_globals.h 24 Aug 2008 15:17:02 -0000
@@ -27,7 +27,7 @@
#ifdef ZTS
# define PG(v) TSRMG(core_globals_id, php_core_globals *, v)
-extern PHPAPI int core_globals_id;
+TSRMG_DH(php_core_globals, core_globals_id);
#else
# define PG(v) (core_globals.v)
extern ZEND_API struct _php_core_globals core_globals;
Index: main/php_output.h
===================================================================
RCS file: /repository/php-src/main/php_output.h,v
retrieving revision 1.53.2.1.2.1.2.1
diff -u -r1.53.2.1.2.1.2.1 php_output.h
--- main/php_output.h 31 Dec 2007 07:17:17 -0000 1.53.2.1.2.1.2.1
+++ main/php_output.h 24 Aug 2008 15:17:02 -0000
@@ -94,7 +94,7 @@
#ifdef ZTS
#define OG(v) TSRMG(output_globals_id, php_output_globals *, v)
-ZEND_API extern int output_globals_id;
+TSRMG_DH(php_output_globals, output_globals_id);
#else
#define OG(v) (output_globals.v)
ZEND_API extern php_output_globals output_globals;
Index: sapi/apache/php_apache.c
===================================================================
RCS file: /repository/php-src/sapi/apache/php_apache.c,v
retrieving revision 1.89.2.4.2.6.2.5
diff -u -r1.89.2.4.2.6.2.5 php_apache.c
--- sapi/apache/php_apache.c 20 Jul 2008 14:28:41 -0000 1.89.2.4.2.6.2.5
+++ sapi/apache/php_apache.c 24 Aug 2008 15:17:02 -0000
@@ -139,7 +139,7 @@
static PHP_MINIT_FUNCTION(apache)
{
#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
#else
php_apache_globals_ctor(&php_apache_info TSRMLS_CC);
#endif
Index: sapi/apache2handler/php_apache.h
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/php_apache.h,v
retrieving revision 1.8.2.1.2.2.2.2
diff -u -r1.8.2.1.2.2.2.2 php_apache.h
--- sapi/apache2handler/php_apache.h 30 Jan 2008 09:41:12 -0000 1.8.2.1.2.2.2.2
+++ sapi/apache2handler/php_apache.h 24 Aug 2008 15:17:03 -0000
@@ -75,7 +75,7 @@
extern zend_module_entry apache2_module_entry;
#ifdef ZTS
-extern int php_apache2_info_id;
+TSRMG_DH(php_apache2_info_struct, php_apache2_info_id);
#define AP2(v) TSRMG(php_apache2_info_id, php_apache2_info_struct *, v)
#else
extern php_apache2_info_struct php_apache2_info;
Index: sapi/apache2handler/php_functions.c
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/php_functions.c,v
retrieving revision 1.18.2.6.2.5.2.4
diff -u -r1.18.2.6.2.5.2.4 php_functions.c
--- sapi/apache2handler/php_functions.c 16 Jul 2008 11:59:15 -0000 1.18.2.6.2.5.2.4
+++ sapi/apache2handler/php_functions.c 24 Aug 2008 15:17:03 -0000
@@ -49,7 +49,7 @@
#include "php_apache.h"
#ifdef ZTS
-int php_apache2_info_id;
+TSRMG_D(php_apache2_info_struct, php_apache2_info_id);
#else
php_apache2_info_struct php_apache2_info;
#endif
@@ -548,7 +548,7 @@
static PHP_MINIT_FUNCTION(apache)
{
#ifdef ZTS
- ts_allocate_id(&php_apache2_info_id, sizeof(php_apache2_info_struct), (ts_allocate_ctor) NULL, NULL);
+ TSRMG_ALLOCATE(php_apache2_info_id, sizeof(php_apache2_info_struct), NULL, NULL);
#endif
REGISTER_INI_ENTRIES();
return SUCCESS;
Index: sapi/apache2handler/sapi_apache2.c
===================================================================
RCS file: /repository/php-src/sapi/apache2handler/sapi_apache2.c,v
retrieving revision 1.57.2.10.2.15.2.3
diff -u -r1.57.2.10.2.15.2.3 sapi_apache2.c
--- sapi/apache2handler/sapi_apache2.c 18 Mar 2008 22:23:20 -0000 1.57.2.10.2.15.2.3
+++ sapi/apache2handler/sapi_apache2.c 24 Aug 2008 15:17:03 -0000
@@ -417,6 +417,7 @@
}
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
+ TSRMLS_INIT();
#endif
sapi_startup(&apache2_sapi_module);
apache2_sapi_module.startup(&apache2_sapi_module);
@@ -504,7 +505,7 @@
apr_bucket *bucket;
apr_status_t rv;
request_rec * volatile parent_req = NULL;
- TSRMLS_FETCH();
+ TSRMLS_INIT();
#define PHPAP_INI_OFF php_apache_ini_dtor(r, parent_req TSRMLS_CC);
Index: sapi/apache_hooks/php_apache.c
===================================================================
RCS file: /repository/php-src/sapi/apache_hooks/php_apache.c,v
retrieving revision 1.19.2.3.2.5.2.4
diff -u -r1.19.2.3.2.5.2.4 php_apache.c
--- sapi/apache_hooks/php_apache.c 20 Jul 2008 14:28:41 -0000 1.19.2.3.2.5.2.4
+++ sapi/apache_hooks/php_apache.c 24 Aug 2008 15:17:03 -0000
@@ -1436,7 +1436,7 @@
zend_class_entry ce;
#ifdef ZTS
- ts_allocate_id(&php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_apache_info_id, sizeof(php_apache_info_struct), (ts_allocate_ctor) php_apache_globals_ctor, NULL);
#else
php_apache_globals_ctor(&php_apache_info TSRMLS_CC);
#endif
Index: sapi/cgi/cgi_main.c
===================================================================
RCS file: /repository/php-src/sapi/cgi/cgi_main.c,v
retrieving revision 1.267.2.15.2.50.2.25
diff -u -r1.267.2.15.2.50.2.25 cgi_main.c
--- sapi/cgi/cgi_main.c 18 Aug 2008 10:49:35 -0000 1.267.2.15.2.50.2.25
+++ sapi/cgi/cgi_main.c 24 Aug 2008 15:17:03 -0000
@@ -183,7 +183,7 @@
/* }}} */
#ifdef ZTS
-static int php_cgi_globals_id;
+TSRMG_D(php_cgi_globals_struct, php_cgi_globals_id);
#define CGIG(v) TSRMG(php_cgi_globals_id, php_cgi_globals_struct *, v)
#else
static php_cgi_globals_struct php_cgi_globals;
@@ -1317,7 +1317,7 @@
static PHP_MINIT_FUNCTION(cgi)
{
#ifdef ZTS
- ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
+ TSRMG_ALLOCATE(php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
#else
php_cgi_globals_ctor(&php_cgi_globals TSRMLS_CC);
#endif
@@ -1377,10 +1377,6 @@
int ini_entries_len = 0;
/* end of temporary locals */
-#ifdef ZTS
- void ***tsrm_ls;
-#endif
-
int max_requests = 500;
int requests = 0;
int fastcgi = fcgi_is_fastcgi();
@@ -1422,7 +1418,7 @@
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
sapi_startup(&cgi_sapi_module);
Index: sapi/cli/php_cli.c
===================================================================
RCS file: /repository/php-src/sapi/cli/php_cli.c,v
retrieving revision 1.129.2.13.2.22.2.15
diff -u -r1.129.2.13.2.22.2.15 php_cli.c
--- sapi/cli/php_cli.c 14 Aug 2008 09:46:26 -0000 1.129.2.13.2.22.2.15
+++ sapi/cli/php_cli.c 24 Aug 2008 15:17:03 -0000
@@ -603,9 +603,6 @@
const char *param_error=NULL;
int hide_argv = 0;
/* end of temporary locals */
-#ifdef ZTS
- void ***tsrm_ls;
-#endif
#ifdef PHP_CLI_WIN32_NO_CONSOLE
int argc = __argc;
char **argv = __argv;
@@ -641,7 +638,7 @@
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
+ TSRMLS_INIT();
#endif
cli_sapi_module.ini_defaults = sapi_cli_ini_defaults;
Index: sapi/embed/php_embed.c
===================================================================
RCS file: /repository/php-src/sapi/embed/php_embed.c,v
retrieving revision 1.11.2.1.2.5.2.3
diff -u -r1.11.2.1.2.5.2.3 php_embed.c
--- sapi/embed/php_embed.c 25 Mar 2008 22:05:22 -0000 1.11.2.1.2.5.2.3
+++ sapi/embed/php_embed.c 24 Aug 2008 15:17:03 -0000
@@ -143,9 +143,6 @@
int php_embed_init(int argc, char **argv PTSRMLS_DC)
{
zend_llist global_vars;
-#ifdef ZTS
- void ***tsrm_ls = NULL;
-#endif
#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
@@ -160,8 +157,8 @@
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
- tsrm_ls = ts_resource(0);
- *ptsrm_ls = tsrm_ls;
+ TSRMLS_INIT();
+ *ptsrm_ls = ts_resource_ex(0, NULL);
#endif
sapi_startup(&php_embed_module);
Index: sapi/embed/php_embed.h
===================================================================
RCS file: /repository/php-src/sapi/embed/php_embed.h,v
retrieving revision 1.6.2.2.2.1.2.1
diff -u -r1.6.2.2.2.1.2.1 php_embed.h
--- sapi/embed/php_embed.h 31 Dec 2007 07:17:18 -0000 1.6.2.2.2.1.2.1
+++ sapi/embed/php_embed.h 24 Aug 2008 15:17:03 -0000
@@ -27,14 +27,14 @@
#include <main/php_ini.h>
#include <zend_ini.h>
-#ifdef ZTS
-#define PTSRMLS_D void ****ptsrm_ls
+#ifdef PASS_TSRMLS
+#define PTSRMLS_D void ***ptsrm_ls
#define PTSRMLS_DC , PTSRMLS_D
#define PTSRMLS_C &tsrm_ls
#define PTSRMLS_CC , PTSRMLS_C
#define PHP_EMBED_START_BLOCK(x,y) { \
- void ***tsrm_ls; \
+ void **tsrm_ls; \
php_embed_init(x, y PTSRMLS_CC); \
zend_first_try {
Index: sapi/litespeed/lsapi_main.c
===================================================================
RCS file: /repository/php-src/sapi/litespeed/lsapi_main.c,v
retrieving revision 1.7.2.2
diff -u -r1.7.2.2 lsapi_main.c
--- sapi/litespeed/lsapi_main.c 5 Aug 2008 22:37:32 -0000 1.7.2.2
+++ sapi/litespeed/lsapi_main.c 24 Aug 2008 15:17:03 -0000
@@ -80,7 +80,6 @@
zend_executor_globals *executor_globals;
php_core_globals *core_globals;
sapi_globals_struct *sapi_globals;
-void ***tsrm_ls;
#endif
zend_module_entry litespeed_module_entry;
@@ -706,6 +705,7 @@
#ifdef ZTS
tsrm_startup(1, 1, 0, NULL);
+ TSRMLS_INIT();
#endif
if (argc > 1 ) {
@@ -724,7 +724,6 @@
executor_globals = ts_resource(executor_globals_id);
core_globals = ts_resource(core_globals_id);
sapi_globals = ts_resource(sapi_globals_id);
- tsrm_ls = ts_resource(0);
SG(request_info).path_translated = NULL;
#endif
Index: sapi/milter/php_milter.c
===================================================================
RCS file: /repository/php-src/sapi/milter/php_milter.c,v
retrieving revision 1.14.2.2.2.3.2.6
diff -u -r1.14.2.2.2.3.2.6 php_milter.c
--- sapi/milter/php_milter.c 13 Aug 2008 00:53:28 -0000 1.14.2.2.2.3.2.6
+++ sapi/milter/php_milter.c 24 Aug 2008 15:17:03 -0000
@@ -1000,8 +1000,6 @@
char *param_error=NULL;
/* end of temporary locals */
- void ***tsrm_ls;
-
#ifdef HAVE_SIGNAL_H
#if defined(SIGPIPE) && defined(SIG_IGN)
signal(SIGPIPE, SIG_IGN); /* ignore SIGPIPE in standalone mode so
@@ -1015,6 +1013,7 @@
tsrm_startup(1, 1, 0, NULL);
+ TSRMLS_INIT();
sapi_startup(&milter_sapi_module);
while ((c=ap_php_getopt(argc, argv, OPTSTRING))!=-1) {
@@ -1032,8 +1031,6 @@
milter_sapi_module.executable_location = argv[0];
- tsrm_ls = ts_resource(0);
-
sapi_module.startup(&milter_sapi_module);
zend_first_try {

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.