Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 136 lines (123 sloc) 2.769 kb
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
/*
 * This file is part of cgreenlet. CGreenlet is free software available
 * under the terms of the MIT license. Consult the file LICENSE that was
 * shipped together with this source file for the exact licensing terms.
 *
 * Copyright (c) 2012 by the cgreenlet authors. See the file AUTHORS for a
 * full list.
 */

#if defined(__WIN32__) || defined(__APPLE__)
# define cdecl(s) _##s
#else
# define cdecl(s) s
#endif

.text

.globl cdecl(_greenlet_savecontext)
.globl cdecl(_greenlet_switchcontext)
.globl cdecl(_greenlet_newstack)

#if defined(__x86_64__)

cdecl(_greenlet_savecontext):
    .cfi_startproc
    .cfi_def_cfa %rsp,8
    movq (%rsp), %rax
    movq %rax, (%rdi)
    movq %rsp, %rax
    addq $0x8, %rax
    movq %rax, 0x8(%rdi)
    movq %rbp, 0x10(%rdi)
    movq %rbx, 0x18(%rdi)
    movq %r12, 0x20(%rdi)
    movq %r13, 0x28(%rdi)
    movq %r14, 0x30(%rdi)
    movq %r15, 0x38(%rdi)
    movq $0x0, %rax
    ret
    .cfi_endproc

cdecl(_greenlet_switchcontext):
    .cfi_startproc
    .cfi_def_cfa %rsp,0
    movq 0x8(%rdi), %rsp
    movq 0x10(%rdi), %rbp
    movq 0x18(%rdi), %rbx
    movq 0x20(%rdi), %r12
    movq 0x28(%rdi), %r13
    movq 0x30(%rdi), %r14
    movq 0x38(%rdi), %r15
    testq %rsi, %rsi
    jnz 1f
    movq $0x1, %rax
    jmpq *(%rdi)
1:
    pushq (%rdi)
    .cfi_def_cfa %rsp,8
    movq %rdx, %rdi
    callq *%rsi
    movq $0x1, %rax
    ret
    .cfi_endproc

cdecl(_greenlet_newstack):
    .cfi_startproc
    .cfi_def_cfa %rsp,8
    movq %rdi, %rsp
    movq %rdx, %rdi
    pushq $0x0
    jmpq *%rsi
    .cfi_endproc
 
#elif defined(__i386__)

cdecl(_greenlet_savecontext):
    .cfi_startproc
    .cfi_def_cfa %esp,8
    movl %edi, %eax
    movl 0x4(%esp), %edi
    movl (%esp), %ecx
    movl %ecx, (%edi)
    movl %esp, %ecx
    addl $0x4, %ecx
    movl %ecx, 0x4(%edi)
    movl %ebp, 0x8(%edi)
    movl %ebx, 0xc(%edi)
    movl %esi, 0x10(%edi)
    movl %eax, 0x14(%edi)
    movl %eax, %edi
    movl $0x0, %eax
    ret
    .cfi_endproc

cdecl(_greenlet_switchcontext):
    .cfi_startproc
    .cfi_def_cfa %esp,0
    movl 0x4(%esp), %edi
    movl 0x8(%esp), %eax
    movl 0xc(%esp), %ecx
    movl (%edi), %edx
    movl 0x4(%edi), %esp
    movl 0x8(%edi), %ebp
    movl 0xc(%edi), %ebx
    movl 0x10(%edi), %esi
    movl 0x14(%edi), %edi
    testl %eax, %eax
    jnz .Linject
    movl $0x1, %eax
    jmpl *%edx
.Linject:
    pushl %edx
    .cfi_def_cfa %esp,4
    pushl %ecx
    .cfi_def_cfa %esp,8
    calll *%eax
    popl %ecx
    .cfi_def_cfa %esp,4
    movl $0x1, %eax
    ret
    .cfi_endproc

cdecl(_greenlet_newstack):
    .cfi_startproc
    .cfi_def_cfa %esp,4
    movl %esp, %edi
    movl 0x4(%edi), %esp
    movl 0x8(%edi), %eax
    movl 0xc(%edi), %ecx
    pushl %ecx
    pushl $0x0
    jmpl *%eax
    .cfi_endproc

#endif
Something went wrong with that request. Please try again.