|
11 | 11 | #include "textflag.h"
|
12 | 12 |
|
13 | 13 | // Exit the entire program (like C exit)
|
14 |
| -TEXT runtime·exit(SB),NOSPLIT,$0 |
15 |
| - MOVL $1, AX |
16 |
| - INT $0x80 |
17 |
| - MOVL $0xf1, 0xf1 // crash |
18 |
| - RET |
19 |
| - |
20 |
| -// Exit this OS thread (like pthread_exit, which eventually |
21 |
| -// calls __bsdthread_terminate). |
22 |
| -TEXT exit1<>(SB),NOSPLIT,$16-0 |
23 |
| - // __bsdthread_terminate takes 4 word-size arguments. |
24 |
| - // Set them all to 0. (None are an exit status.) |
25 |
| - MOVL $0, 0(SP) |
26 |
| - MOVL $0, 4(SP) |
27 |
| - MOVL $0, 8(SP) |
28 |
| - MOVL $0, 12(SP) |
29 |
| - MOVL $361, AX |
30 |
| - INT $0x80 |
31 |
| - JAE 2(PC) |
| 14 | +TEXT runtime·exit(SB),NOSPLIT,$0-4 |
| 15 | + MOVL code+0(FP), AX |
| 16 | + PUSHL BP |
| 17 | + MOVL SP, BP |
| 18 | + SUBL $4, SP // allocate space for callee args |
| 19 | + ANDL $~15, SP // align stack |
| 20 | + MOVL AX, 0(SP) |
| 21 | + CALL libc_exit(SB) |
32 | 22 | MOVL $0xf1, 0xf1 // crash
|
| 23 | + MOVL BP, SP |
| 24 | + POPL BP |
33 | 25 | RET
|
34 | 26 |
|
35 |
| -GLOBL exitStack<>(SB),RODATA,$(4*4) |
36 |
| -DATA exitStack<>+0x00(SB)/4, $0 |
37 |
| -DATA exitStack<>+0x04(SB)/4, $0 |
38 |
| -DATA exitStack<>+0x08(SB)/4, $0 |
39 |
| -DATA exitStack<>+0x0c(SB)/4, $0 |
40 |
| - |
41 |
| -// func exitThread(wait *uint32) |
| 27 | +// Not used on Darwin. |
42 | 28 | TEXT runtime·exitThread(SB),NOSPLIT,$0-4
|
43 |
| - MOVL wait+0(FP), AX |
44 |
| - // We're done using the stack. |
45 |
| - MOVL $0, (AX) |
46 |
| - // __bsdthread_terminate takes 4 arguments, which it expects |
47 |
| - // on the stack. They should all be 0, so switch over to a |
48 |
| - // fake stack of 0s. It won't write to the stack. |
49 |
| - MOVL $exitStack<>(SB), SP |
50 |
| - MOVL $361, AX // __bsdthread_terminate |
51 |
| - INT $0x80 |
52 | 29 | MOVL $0xf1, 0xf1 // crash
|
53 |
| - JMP 0(PC) |
| 30 | + RET |
54 | 31 |
|
55 | 32 | TEXT runtime·open(SB),NOSPLIT,$0
|
56 | 33 | MOVL $5, AX
|
@@ -437,38 +414,8 @@ TEXT runtime·mach_semaphore_signal_all(SB),NOSPLIT,$0
|
437 | 414 | RET
|
438 | 415 |
|
439 | 416 | // func setldt(entry int, address int, limit int)
|
440 |
| -// entry and limit are ignored. |
441 | 417 | TEXT runtime·setldt(SB),NOSPLIT,$32
|
442 |
| - MOVL address+4(FP), BX // aka base |
443 |
| - |
444 |
| - /* |
445 |
| - * When linking against the system libraries, |
446 |
| - * we use its pthread_create and let it set up %gs |
447 |
| - * for us. When we do that, the private storage |
448 |
| - * we get is not at 0(GS) but at 0x18(GS). |
449 |
| - * The linker rewrites 0(TLS) into 0x18(GS) for us. |
450 |
| - * To accommodate that rewrite, we translate the |
451 |
| - * address here so that 0x18(GS) maps to 0(address). |
452 |
| - * |
453 |
| - * Constant must match the one in cmd/link/internal/ld/sym.go. |
454 |
| - */ |
455 |
| - SUBL $0x18, BX |
456 |
| - |
457 |
| - /* |
458 |
| - * Must set up as USER_CTHREAD segment because |
459 |
| - * Darwin forces that value into %gs for signal handlers, |
460 |
| - * and if we don't set one up, we'll get a recursive |
461 |
| - * fault trying to get into the signal handler. |
462 |
| - * Since we have to set one up anyway, it might as |
463 |
| - * well be the value we want. So don't bother with |
464 |
| - * i386_set_ldt. |
465 |
| - */ |
466 |
| - MOVL BX, 4(SP) |
467 |
| - MOVL $3, AX // thread_fast_set_cthread_self - machdep call #3 |
468 |
| - INT $0x82 // sic: 0x82, not 0x80, for machdep call |
469 |
| - |
470 |
| - XORL AX, AX |
471 |
| - MOVW GS, AX |
| 418 | + // Nothing to do on Darwin, pthread already set thread-local storage up. |
472 | 419 | RET
|
473 | 420 |
|
474 | 421 | TEXT runtime·sysctl(SB),NOSPLIT,$0
|
@@ -531,11 +478,11 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$0
|
531 | 478 | // Someday the convention will be D is always cleared.
|
532 | 479 | CLD
|
533 | 480 |
|
534 |
| - CALL runtime·stackcheck(SB) // just in case |
535 | 481 | CALL runtime·mstart(SB)
|
536 | 482 |
|
537 |
| - // mstart shouldn't ever return, and if it does, we shouldn't ever join to this thread |
538 |
| - // to get its return status. But tell pthread everything is ok, just in case. |
| 483 | + // Go is all done with this OS thread. |
| 484 | + // Tell pthread everything is ok (we never join with this thread, so |
| 485 | + // the value here doesn't really matter). |
539 | 486 | XORL AX, AX
|
540 | 487 | RET
|
541 | 488 |
|
@@ -565,26 +512,24 @@ TEXT runtime·pthread_attr_init_trampoline(SB),NOSPLIT,$0-8
|
565 | 512 | MOVL AX, ret+4(FP)
|
566 | 513 | RET
|
567 | 514 |
|
568 |
| -TEXT runtime·pthread_attr_setstack_trampoline(SB),NOSPLIT,$0-16 |
| 515 | +TEXT runtime·pthread_attr_setstacksize_trampoline(SB),NOSPLIT,$0-12 |
569 | 516 | MOVL attr+0(FP), AX
|
570 |
| - MOVL addr+4(FP), CX |
571 |
| - MOVL size+8(FP), DX |
| 517 | + MOVL size+4(FP), CX |
572 | 518 |
|
573 | 519 | PUSHL BP
|
574 | 520 | MOVL SP, BP
|
575 | 521 |
|
576 |
| - SUBL $12, SP |
| 522 | + SUBL $8, SP |
577 | 523 | ANDL $~15, SP
|
578 | 524 |
|
579 | 525 | MOVL AX, 0(SP)
|
580 | 526 | MOVL CX, 4(SP)
|
581 |
| - MOVL DX, 8(SP) |
582 |
| - CALL libc_pthread_attr_setstack(SB) |
| 527 | + CALL libc_pthread_attr_setstacksize(SB) |
583 | 528 |
|
584 | 529 | MOVL BP, SP
|
585 | 530 | POPL BP
|
586 | 531 |
|
587 |
| - MOVL AX, ret+12(FP) |
| 532 | + MOVL AX, ret+8(FP) |
588 | 533 | RET
|
589 | 534 |
|
590 | 535 | TEXT runtime·pthread_attr_setdetachstate_trampoline(SB),NOSPLIT,$0-12
|
|
0 commit comments