Use the new <asm_defs.h> header in x86 assembly files. Particularly

added FUNCTION_END() calls for a good deal of functions. The respective
ELF symbols do now have a correct size.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27718 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2008-09-23 22:50:30 +00:00
parent 4069a00744
commit 8cc146385f
14 changed files with 119 additions and 56 deletions
+36 -25
View File
@@ -11,6 +11,7 @@
#include <arch/x86/arch_cpu.h> #include <arch/x86/arch_cpu.h>
#include <arch/x86/arch_kernel.h> #include <arch/x86/arch_kernel.h>
#include <arch/x86/descriptors.h> #include <arch/x86/descriptors.h>
#include <asm_defs.h>
#include <commpage_defs.h> #include <commpage_defs.h>
#include <thread_types.h> #include <thread_types.h>
@@ -21,8 +22,6 @@
#include "syscall_table.h" #include "syscall_table.h"
#define FUNCTION(x) .global x; .type x,@function; x
#define UPDATE_THREAD_USER_TIME_COMMON() \ #define UPDATE_THREAD_USER_TIME_COMMON() \
movl %eax, %ebx; /* save for later */ \ movl %eax, %ebx; /* save for later */ \
movl %edx, %ecx; \ movl %edx, %ecx; \
@@ -168,23 +167,23 @@
.text .text
#define TRAP_ERRC(name, vector) \ #define TRAP_ERRC(name, vector) \
.globl name; \
.align 8; \ .align 8; \
name: \ FUNCTION(name): \
pushl $vector; \ pushl $vector; \
pushl $-1; \ pushl $-1; \
pushl $-1; \ pushl $-1; \
jmp int_bottom jmp int_bottom; \
FUNCTION_END(name)
#define TRAP(name, vector) \ #define TRAP(name, vector) \
.globl name; \
.align 8; \ .align 8; \
name: \ FUNCTION(name): \
pushl $0; \ pushl $0; \
pushl $vector; \ pushl $vector; \
pushl %edx; \ pushl %edx; \
pushl %eax; \ pushl %eax; \
jmp int_bottom jmp int_bottom; \
FUNCTION_END(name)
TRAP(trap0, 0) TRAP(trap0, 0)
TRAP(trap1, 1) TRAP(trap1, 1)
@@ -195,9 +194,8 @@ TRAP(trap5, 5)
TRAP(trap6, 6) TRAP(trap6, 6)
TRAP(trap7, 7) TRAP(trap7, 7)
.globl double_fault;
.align 8; .align 8;
double_fault: FUNCTION(double_fault):
pushl $-1; // user-ss pushl $-1; // user-ss
pushl $-1; // user-esp pushl $-1; // user-esp
pushl $-1; // flags pushl $-1; // flags
@@ -208,6 +206,7 @@ double_fault:
pushl $-1; pushl $-1;
pushl $-1; pushl $-1;
jmp int_bottom jmp int_bottom
FUNCTION_END(double_fault)
TRAP(trap9, 9) TRAP(trap9, 9)
TRAP_ERRC(trap10, 10) TRAP_ERRC(trap10, 10)
@@ -254,8 +253,7 @@ TRAP(trap255, 255)
.align 16 .align 16
.globl int_bottom STATIC_FUNCTION(int_bottom):
int_bottom:
PUSH_IFRAME_BOTTOM(IFRAME_TYPE_OTHER) PUSH_IFRAME_BOTTOM(IFRAME_TYPE_OTHER)
movl %esp, %ebp // frame pointer is the iframe movl %esp, %ebp // frame pointer is the iframe
@@ -282,9 +280,10 @@ int_bottom:
call *gInterruptHandlerTable(, %eax, 4) call *gInterruptHandlerTable(, %eax, 4)
POP_IFRAME_AND_RETURN() POP_IFRAME_AND_RETURN()
FUNCTION_END(int_bottom)
int_bottom_user: STATIC_FUNCTION(int_bottom_user):
movl $KERNEL_DATA_SEG,%eax movl $KERNEL_DATA_SEG,%eax
cld cld
movl %eax,%ds movl %eax,%ds
@@ -327,9 +326,10 @@ int_bottom_user:
// update the thread's kernel time and return // update the thread's kernel time and return
UPDATE_THREAD_KERNEL_TIME() UPDATE_THREAD_KERNEL_TIME()
POP_IFRAME_AND_RETURN() POP_IFRAME_AND_RETURN()
FUNCTION_END(int_bottom_user)
int_bottom_vm86: STATIC_FUNCTION(int_bottom_vm86):
movl $KERNEL_DATA_SEG,%eax movl $KERNEL_DATA_SEG,%eax
cld cld
movl %eax,%ds movl %eax,%ds
@@ -354,27 +354,28 @@ int_bottom_vm86:
popa; popa;
addl $16,%esp; addl $16,%esp;
iret iret
FUNCTION_END(int_bottom_vm86)
// test interrupt handler for performance measurements // test interrupt handler for performance measurements
.align 16 .align 16
.globl trap98 FUNCTION(trap98):
trap98:
iret iret
FUNCTION_END(trap98)
.align 16 .align 16
.globl trap99 FUNCTION(trap99):
trap99:
// push error, vector, orig_edx, orig_eax, and other registers // push error, vector, orig_edx, orig_eax, and other registers
PUSH_IFRAME_BOTTOM_SYSCALL() PUSH_IFRAME_BOTTOM_SYSCALL()
call handle_syscall call handle_syscall
POP_IFRAME_AND_RETURN() POP_IFRAME_AND_RETURN()
FUNCTION_END(trap99)
handle_syscall: STATIC_FUNCTION(handle_syscall):
// save %eax, the number of the syscall // save %eax, the number of the syscall
movl %eax, %esi movl %eax, %esi
@@ -440,8 +441,9 @@ handle_syscall:
lea -4(%ebp), %esp // remove all parameters from the stack lea -4(%ebp), %esp // remove all parameters from the stack
ret ret
FUNCTION_END(handle_syscall)
do_pre_syscall_debug: STATIC_FUNCTION(do_pre_syscall_debug):
movl %esp, %eax // syscall parameters movl %esp, %eax // syscall parameters
push %eax push %eax
movl IFRAME_orig_eax(%ebp), %eax // syscall number movl IFRAME_orig_eax(%ebp), %eax // syscall number
@@ -449,8 +451,9 @@ handle_syscall:
call user_debug_pre_syscall call user_debug_pre_syscall
addl $8, %esp addl $8, %esp
jmp pre_syscall_debug_done jmp pre_syscall_debug_done
FUNCTION_END(do_pre_syscall_debug)
post_syscall_work: STATIC_FUNCTION(post_syscall_work):
// clear the 64 bit return value and syscall restarted bits // clear the 64 bit return value and syscall restarted bits
testl $(THREAD_FLAGS_64_BIT_SYSCALL_RETURN \ testl $(THREAD_FLAGS_64_BIT_SYSCALL_RETURN \
| THREAD_FLAGS_SYSCALL_RESTARTED), THREAD_flags(%edi) | THREAD_FLAGS_SYSCALL_RESTARTED), THREAD_flags(%edi)
@@ -481,9 +484,10 @@ handle_syscall:
call user_debug_post_syscall call user_debug_post_syscall
addl $24, %esp addl $24, %esp
1: 1:
FUNCTION_END(post_syscall_work)
bad_syscall_number: bad_syscall_number:
kernel_exit_work: STATIC_FUNCTION(kernel_exit_work):
// if no signals are pending and the thread shall not be debugged, we can // if no signals are pending and the thread shall not be debugged, we can
// use the quick kernel exit function // use the quick kernel exit function
testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD) \ testl $(THREAD_FLAGS_SIGNALS_PENDING | THREAD_FLAGS_DEBUG_THREAD) \
@@ -511,19 +515,22 @@ handle_syscall:
call x86_init_user_debug_at_kernel_exit call x86_init_user_debug_at_kernel_exit
1: 1:
POP_IFRAME_AND_RETURN() POP_IFRAME_AND_RETURN()
FUNCTION_END(kernel_exit_work)
kernel_exit_handle_signals: STATIC_FUNCTION(kernel_exit_handle_signals):
// make sure interrupts are enabled (they are, when coming from a syscall // make sure interrupts are enabled (they are, when coming from a syscall
// but otherwise they might be disabled) // but otherwise they might be disabled)
sti sti
call thread_at_kernel_exit // also disables interrupts call thread_at_kernel_exit // also disables interrupts
jmp kernel_exit_work_done jmp kernel_exit_work_done
FUNCTION_END(kernel_exit_handle_signals)
bad_syscall_params: STATIC_FUNCTION(bad_syscall_params):
// clear the fault handler and exit normally // clear the fault handler and exit normally
movl %dr3, %edi movl %dr3, %edi
movl $0, THREAD_fault_handler(%edi) movl $0, THREAD_fault_handler(%edi)
jmp kernel_exit_work jmp kernel_exit_work
FUNCTION_END(bad_syscall_params)
/*! Handler called by the sysenter instruction /*! Handler called by the sysenter instruction
@@ -569,6 +576,7 @@ FUNCTION(x86_sysenter):
popfl popfl
sysexit sysexit
FUNCTION_END(x86_sysenter)
/*! Is copied to the signal stack call to restore the original frame when /*! Is copied to the signal stack call to restore the original frame when
@@ -586,6 +594,7 @@ FUNCTION(i386_return_from_signal):
lea 4(%esp), %edx lea 4(%esp), %edx
int $99 int $99
ret ret
FUNCTION_END(i386_return_from_signal)
FUNCTION(i386_end_return_from_signal): FUNCTION(i386_end_return_from_signal):
@@ -607,6 +616,7 @@ FUNCTION(i386_restore_frame_from_syscall):
// update the thread's kernel time and return // update the thread's kernel time and return
UPDATE_THREAD_KERNEL_TIME() UPDATE_THREAD_KERNEL_TIME()
POP_IFRAME_AND_RETURN() POP_IFRAME_AND_RETURN()
FUNCTION_END(i386_restore_frame_from_syscall)
/* status_t x86_vm86_enter(struct vm86_iframe *frame) */ /* status_t x86_vm86_enter(struct vm86_iframe *frame) */
@@ -644,6 +654,7 @@ FUNCTION(x86_vm86_enter):
popa popa
addl $16, %esp addl $16, %esp
iret iret
FUNCTION_END(x86_vm86_enter)
/* void x86_vm86_return(struct vm86_iframe *frame, status_t retval) */ /* void x86_vm86_return(struct vm86_iframe *frame, status_t retval) */
@@ -679,4 +690,4 @@ FUNCTION(x86_vm86_return):
popl %edi popl %edi
popf popf
ret ret
FUNCTION_END(x86_vm86_return)
+4 -6
View File
@@ -7,9 +7,7 @@
# include "asm_offsets.h" # include "asm_offsets.h"
#endif #endif
#include <asm_defs.h>
#define FUNCTION(x) .global x; .type x,@function; x
#define SYM(x) .global x; x
// We don't need the indirection in the boot loader. // We don't need the indirection in the boot loader.
@@ -26,7 +24,7 @@ FUNCTION(memcpy_generic):
movl %edi,%eax /* save dest ptr as return address */ movl %edi,%eax /* save dest ptr as return address */
movl 16(%esp),%esi /* source */ movl 16(%esp),%esi /* source */
movl 20(%esp),%ecx /* count */ movl 20(%esp),%ecx /* count */
/* move by words */ /* move by words */
cld cld
shrl $2,%ecx shrl $2,%ecx
@@ -38,11 +36,11 @@ FUNCTION(memcpy_generic):
andl $3,%ecx andl $3,%ecx
rep rep
movsb movsb
popl %edi popl %edi
popl %esi popl %esi
ret ret
SYM(memcpy_generic_end): SYMBOL(memcpy_generic_end):
#if !_BOOT_MODE #if !_BOOT_MODE
+25 -2
View File
@@ -7,11 +7,12 @@
* Distributed under the terms of the NewOS License. * Distributed under the terms of the NewOS License.
*/ */
#include <asm_defs.h>
#include <arch/x86/descriptors.h> #include <arch/x86/descriptors.h>
#include "syscall_numbers.h" #include "syscall_numbers.h"
#define FUNCTION(x) .global x; .type x,@function; x
.text .text
@@ -20,30 +21,35 @@ FUNCTION(arch_cpu_user_TLB_invalidate):
movl %cr3,%eax movl %cr3,%eax
movl %eax,%cr3 movl %eax,%cr3
ret ret
FUNCTION_END(arch_cpu_user_TLB_invalidate)
/* void i386_fnsave(void *fpu_state); */ /* void i386_fnsave(void *fpu_state); */
FUNCTION(i386_fnsave): FUNCTION(i386_fnsave):
movl 4(%esp), %eax movl 4(%esp), %eax
fnsave (%eax) fnsave (%eax)
ret ret
FUNCTION_END(i386_fnsave)
/* void i386_fxsave(void *fpu_state); */ /* void i386_fxsave(void *fpu_state); */
FUNCTION(i386_fxsave): FUNCTION(i386_fxsave):
movl 4(%esp), %eax movl 4(%esp), %eax
fxsave (%eax) fxsave (%eax)
ret ret
FUNCTION_END(i386_fxsave)
/* void i386_frstor(const void *fpu_state); */ /* void i386_frstor(const void *fpu_state); */
FUNCTION(i386_frstor): FUNCTION(i386_frstor):
movl 4(%esp), %eax movl 4(%esp), %eax
frstor (%eax) frstor (%eax)
ret ret
FUNCTION_END(i386_frstor)
/* void i386_fxrstor(const void *fpu_state); */ /* void i386_fxrstor(const void *fpu_state); */
FUNCTION(i386_fxrstor): FUNCTION(i386_fxrstor):
movl 4(%esp), %eax movl 4(%esp), %eax
fxrstor (%eax) fxrstor (%eax)
ret ret
FUNCTION_END(i386_fxrstor)
/* void i386_fsave_swap(void *old_fpu_state, const void *new_fpu_state); */ /* void i386_fsave_swap(void *old_fpu_state, const void *new_fpu_state); */
FUNCTION(i386_fnsave_swap): FUNCTION(i386_fnsave_swap):
@@ -52,6 +58,7 @@ FUNCTION(i386_fnsave_swap):
movl 8(%esp),%eax movl 8(%esp),%eax
frstor (%eax) frstor (%eax)
ret ret
FUNCTION_END(i386_fnsave_swap)
/* void i386_fxsave_swap(void *old_fpu_state, const void *new_fpu_state); */ /* void i386_fxsave_swap(void *old_fpu_state, const void *new_fpu_state); */
FUNCTION(i386_fxsave_swap): FUNCTION(i386_fxsave_swap):
@@ -60,39 +67,46 @@ FUNCTION(i386_fxsave_swap):
movl 8(%esp),%eax movl 8(%esp),%eax
fxrstor (%eax) fxrstor (%eax)
ret ret
FUNCTION_END(i386_fxsave_swap)
/* uint32 x86_read_ebp(); */ /* uint32 x86_read_ebp(); */
FUNCTION(x86_read_ebp): FUNCTION(x86_read_ebp):
movl %ebp, %eax movl %ebp, %eax
ret ret
FUNCTION_END(x86_read_ebp)
/* uint32 x86_read_cr0(); */ /* uint32 x86_read_cr0(); */
FUNCTION(x86_read_cr0): FUNCTION(x86_read_cr0):
movl %cr0, %eax movl %cr0, %eax
ret ret
FUNCTION_END(x86_read_cr0)
/* void x86_write_cr0(uint32 value); */ /* void x86_write_cr0(uint32 value); */
FUNCTION(x86_write_cr0): FUNCTION(x86_write_cr0):
movl 4(%esp), %eax movl 4(%esp), %eax
movl %eax, %cr0 movl %eax, %cr0
ret ret
FUNCTION_END(x86_write_cr0)
/* uint32 x86_read_cr4(); */ /* uint32 x86_read_cr4(); */
FUNCTION(x86_read_cr4): FUNCTION(x86_read_cr4):
movl %cr4, %eax movl %cr4, %eax
ret ret
FUNCTION_END(x86_read_cr4)
/* void x86_write_cr4(uint32 value); */ /* void x86_write_cr4(uint32 value); */
FUNCTION(x86_write_cr4): FUNCTION(x86_write_cr4):
movl 4(%esp), %eax movl 4(%esp), %eax
movl %eax, %cr4 movl %eax, %cr4
ret ret
FUNCTION_END(x86_write_cr4)
/* uint64 x86_read_msr(uint32 register); */ /* uint64 x86_read_msr(uint32 register); */
FUNCTION(x86_read_msr): FUNCTION(x86_read_msr):
movl 4(%esp), %ecx movl 4(%esp), %ecx
rdmsr rdmsr
ret ret
FUNCTION_END(x86_read_msr)
/* void x86_write_msr(uint32 register, uint64 value); */ /* void x86_write_msr(uint32 register, uint64 value); */
FUNCTION(x86_write_msr): FUNCTION(x86_write_msr):
@@ -101,6 +115,7 @@ FUNCTION(x86_write_msr):
movl 12(%esp), %edx movl 12(%esp), %edx
wrmsr wrmsr
ret ret
FUNCTION_END(x86_write_msr)
/* void i386_context_switch(struct arch_thread *old_state, struct arch_thread *new_state, addr new_pgdir); */ /* void i386_context_switch(struct arch_thread *old_state, struct arch_thread *new_state, addr new_pgdir); */
FUNCTION(i386_context_switch): FUNCTION(i386_context_switch):
@@ -119,12 +134,14 @@ skip_pgdir_swap:
lss (%eax),%esp lss (%eax),%esp
popa popa
ret ret
FUNCTION_END(i386_context_switch)
/* void i386_swap_pgdir(addr new_pgdir); */ /* void i386_swap_pgdir(addr new_pgdir); */
FUNCTION(i386_swap_pgdir): FUNCTION(i386_swap_pgdir):
movl 4(%esp),%eax movl 4(%esp),%eax
movl %eax,%cr3 movl %eax,%cr3
ret ret
FUNCTION_END(i386_swap_pgdir)
/* thread exit stub - is copied to the userspace stack in arch_thread_enter_uspace() */ /* thread exit stub - is copied to the userspace stack in arch_thread_enter_uspace() */
.align 4 .align 4
@@ -136,6 +153,7 @@ FUNCTION(x86_userspace_thread_exit):
movl $SYSCALL_EXIT_THREAD, %eax movl $SYSCALL_EXIT_THREAD, %eax
int $99 int $99
.align 4 .align 4
FUNCTION_END(x86_userspace_thread_exit)
FUNCTION(x86_end_userspace_thread_exit): FUNCTION(x86_end_userspace_thread_exit):
@@ -157,6 +175,7 @@ FUNCTION(x86_enter_userspace):
pushl $USER_CODE_SEG // user code segment pushl $USER_CODE_SEG // user code segment
pushl %eax // user IP pushl %eax // user IP
iret iret
FUNCTION_END(x86_enter_userspace)
/* void i386_switch_stack_and_call(addr stack, void (*func)(void *), void *arg); */ /* void i386_switch_stack_and_call(addr stack, void (*func)(void *), void *arg); */
FUNCTION(i386_switch_stack_and_call): FUNCTION(i386_switch_stack_and_call):
@@ -169,6 +188,7 @@ FUNCTION(i386_switch_stack_and_call):
call *%ecx // call the target function call *%ecx // call the target function
_loop: _loop:
jmp _loop jmp _loop
FUNCTION_END(i386_switch_stack_and_call)
null_idt_descr: null_idt_descr:
.word 0 .word 0
@@ -179,6 +199,7 @@ FUNCTION(reboot):
int $0 int $0
done: done:
jmp done jmp done
FUNCTION_END(reboot)
FUNCTION(arch_debug_save_registers): FUNCTION(arch_debug_save_registers):
@@ -219,6 +240,7 @@ FUNCTION(arch_debug_save_registers):
popl %eax popl %eax
popl %esi popl %esi
ret ret
FUNCTION_END(arch_debug_save_registers)
/* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */ /* status_t arch_cpu_user_memcpy(void *to, const void *from, size_t size, addr_t *faultHandler) */
FUNCTION(arch_cpu_user_memcpy): FUNCTION(arch_cpu_user_memcpy):
@@ -231,7 +253,7 @@ FUNCTION(arch_cpu_user_memcpy):
/* set the fault handler */ /* set the fault handler */
movl 24(%esp),%edx /* fault handler */ movl 24(%esp),%edx /* fault handler */
movl (%edx),%eax movl (%edx),%eax
movl $.L_user_memcpy_error, (%edx) movl $.L_user_memcpy_error, (%edx)
/* move by words */ /* move by words */
cld cld
@@ -261,4 +283,5 @@ FUNCTION(arch_cpu_user_memcpy):
popl %edi popl %edi
popl %esi popl %esi
ret ret
FUNCTION_END(arch_cpu_user_memcpy)
+4 -1
View File
@@ -6,8 +6,8 @@
* Distributed under the terms of the NewOS License. * Distributed under the terms of the NewOS License.
*/ */
#include <asm_defs.h>
#define FUNCTION(x) .global x; .type x,@function; x
.text .text
@@ -26,6 +26,7 @@ FUNCTION(get_current_cpuid):
popl %ebx popl %ebx
xorl %eax, %eax /* return B_OK */ xorl %eax, %eax /* return B_OK */
ret ret
FUNCTION_END(get_current_cpuid)
/* unsigned int get_eflags(void) */ /* unsigned int get_eflags(void) */
@@ -33,6 +34,7 @@ FUNCTION(get_eflags):
pushfl pushfl
popl %eax popl %eax
ret ret
FUNCTION_END(get_eflags)
/* void set_eflags(unsigned int val) */ /* void set_eflags(unsigned int val) */
@@ -40,3 +42,4 @@ FUNCTION(set_eflags):
pushl 4(%esp) pushl 4(%esp)
popfl popfl
ret ret
FUNCTION_END(set_eflags)
+6 -4
View File
@@ -3,8 +3,8 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#define FUNCTION(x) .global x; .type x,@function; x #include <asm_defs.h>
#define SYM(x) .global x; x
.text .text
@@ -14,7 +14,8 @@
FUNCTION(_user_syscall_int): FUNCTION(_user_syscall_int):
int $99 int $99
ret ret
SYM(_user_syscall_int_end): FUNCTION_END(_user_syscall_int)
SYMBOL(_user_syscall_int_end):
// Intel sysenter/sysexit // Intel sysenter/sysexit
@@ -24,6 +25,7 @@ FUNCTION(_user_syscall_sysenter):
movl %esp, %ecx movl %esp, %ecx
sysenter sysenter
ret ret
SYM(_user_syscall_sysenter_end): FUNCTION_END(_user_syscall_sysenter)
SYMBOL(_user_syscall_sysenter_end):
+15 -2
View File
@@ -6,7 +6,8 @@
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#define FUNCTION(x) .global x; .type x,@function; x #include <asm_defs.h>
.text .text
@@ -17,6 +18,7 @@ FUNCTION(atomic_set):
lock lock
xchg %eax,(%edx) xchg %eax,(%edx)
ret ret
FUNCTION_END(atomic_set)
/* int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst) */ /* int32 atomic_test_and_set(vint32 *value, int32 newValue, int32 testAgainst) */
FUNCTION(atomic_test_and_set): FUNCTION(atomic_test_and_set):
@@ -26,6 +28,7 @@ FUNCTION(atomic_test_and_set):
lock lock
cmpxchgl %ecx,(%edx) cmpxchgl %ecx,(%edx)
ret ret
FUNCTION_END(atomic_test_and_set)
/* int32 atomic_add(vint32 *value, int32 addValue) */ /* int32 atomic_add(vint32 *value, int32 addValue) */
FUNCTION(atomic_add): FUNCTION(atomic_add):
@@ -34,6 +37,7 @@ FUNCTION(atomic_add):
lock lock
xaddl %eax,(%edx) xaddl %eax,(%edx)
ret ret
FUNCTION_END(atomic_add)
/* int32 atomic_and(vint32 *value, int32 andValue) */ /* int32 atomic_and(vint32 *value, int32 andValue) */
FUNCTION(atomic_and): FUNCTION(atomic_and):
@@ -46,6 +50,7 @@ _atomic_and1:
cmpxchgl %ecx,(%edx) cmpxchgl %ecx,(%edx)
jnz _atomic_and1 jnz _atomic_and1
ret ret
FUNCTION_END(atomic_and)
/* int32 atomic_or(vint32 *value, int32 orValue) */ /* int32 atomic_or(vint32 *value, int32 orValue) */
FUNCTION(atomic_or): FUNCTION(atomic_or):
@@ -58,7 +63,8 @@ _atomic_or1:
cmpxchgl %ecx,(%edx) cmpxchgl %ecx,(%edx)
jnz _atomic_or1 jnz _atomic_or1
ret ret
FUNCTION_END(atomic_or)
/* int32 atomic_get(vint32 *value) */ /* int32 atomic_get(vint32 *value) */
FUNCTION(atomic_get): FUNCTION(atomic_get):
movl 4(%esp), %edx movl 4(%esp), %edx
@@ -69,6 +75,7 @@ _atomic_get1:
cmpxchgl %ecx, (%edx) cmpxchgl %ecx, (%edx)
jnz _atomic_get1 jnz _atomic_get1
ret ret
FUNCTION_END(atomic_get)
/* int64 atomic_set64(vint64 *value, int64 newValue) */ /* int64 atomic_set64(vint64 *value, int64 newValue) */
FUNCTION(atomic_set64): FUNCTION(atomic_set64):
@@ -86,6 +93,7 @@ _atomic_set64_1:
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_set64)
/* int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) */ /* int64 atomic_test_and_set64(vint64 *value, int64 newValue, int64 testAgainst) */
FUNCTION(atomic_test_and_set64): FUNCTION(atomic_test_and_set64):
@@ -101,6 +109,7 @@ FUNCTION(atomic_test_and_set64):
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_test_and_set64)
/* int64 atomic_add64(vint64 *value, int64 addValue) */ /* int64 atomic_add64(vint64 *value, int64 addValue) */
FUNCTION(atomic_add64): FUNCTION(atomic_add64):
@@ -120,6 +129,7 @@ _atomic_add64_1:
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_add64)
/* int64 atomic_and64(vint64 *value, int64 andValue) */ /* int64 atomic_and64(vint64 *value, int64 andValue) */
FUNCTION(atomic_and64): FUNCTION(atomic_and64):
@@ -139,6 +149,7 @@ _atomic_and64_1:
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_and64)
/* int64 atomic_or64(vint64 *value, int64 orValue) */ /* int64 atomic_or64(vint64 *value, int64 orValue) */
FUNCTION(atomic_or64): FUNCTION(atomic_or64):
@@ -158,6 +169,7 @@ _atomic_or64_1:
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_or64)
/* int64 atomic_get64(vint64 *value) */ /* int64 atomic_get64(vint64 *value) */
FUNCTION(atomic_get64): FUNCTION(atomic_get64):
@@ -175,3 +187,4 @@ _atomic_get64_1:
pop %ebx pop %ebx
pop %ebp pop %ebp
ret ret
FUNCTION_END(atomic_get64)
+6 -2
View File
@@ -3,8 +3,7 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include <asm_defs.h>
#define FUNCTION(x) .global x; .type x,@function; x
/* uint16 __swap_int16(uint16 value) */ /* uint16 __swap_int16(uint16 value) */
@@ -13,6 +12,7 @@ FUNCTION(__swap_int16):
bswap %eax bswap %eax
shr $16, %eax shr $16, %eax
ret ret
FUNCTION_END(__swap_int16)
/* this one is much faster on a P4, courtesy of Marcus Overhagen, /* this one is much faster on a P4, courtesy of Marcus Overhagen,
* a good candidate for per processor optimizations: */ * a good candidate for per processor optimizations: */
@@ -28,6 +28,7 @@ FUNCTION(__swap_int32):
movl 4(%esp), %eax movl 4(%esp), %eax
bswap %eax bswap %eax
ret ret
FUNCTION_END(__swap_int32)
/* uint64 __swap_int64(uint64 value) */ /* uint64 __swap_int64(uint64 value) */
FUNCTION(__swap_int64): FUNCTION(__swap_int64):
@@ -36,6 +37,7 @@ FUNCTION(__swap_int64):
bswap %eax bswap %eax
bswap %edx bswap %edx
ret ret
FUNCTION_END(__swap_int64)
/* float __swap_float(float value) */ /* float __swap_float(float value) */
FUNCTION(__swap_float): FUNCTION(__swap_float):
@@ -44,6 +46,7 @@ FUNCTION(__swap_float):
movl %eax, 4(%esp) movl %eax, 4(%esp)
fld 4(%esp) fld 4(%esp)
ret ret
FUNCTION_END(__swap_float)
/* double __swap_double(double value) */ /* double __swap_double(double value) */
FUNCTION(__swap_double): FUNCTION(__swap_double):
@@ -55,3 +58,4 @@ FUNCTION(__swap_double):
movl %edx, 8(%esp) movl %edx, 8(%esp)
fldl 4(%esp) fldl 4(%esp)
ret ret
FUNCTION_END(__swap_double)
@@ -1,11 +1,13 @@
/* /*
* Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. All rights reserved. * Copyright 2005, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#define FUNCTION(x) .global x; .type x,@function; x #include <asm_defs.h>
/* void *get_stack_frame() */ /* void *get_stack_frame() */
FUNCTION(get_stack_frame): FUNCTION(get_stack_frame):
mov %ebp, %eax mov %ebp, %eax
ret ret
FUNCTION_END(get_stack_frame)
+7 -7
View File
@@ -14,15 +14,15 @@
* branch to the syscall vector in the commpage * branch to the syscall vector in the commpage
*/ */
#include <asm_defs.h>
#include <commpage_defs.h> #include <commpage_defs.h>
#define _SYSCALL(name, n) \ #define _SYSCALL(name, n) \
.globl name; \ .align 8; \
.type name,@function; \ FUNCTION(name): \
.align 8; \ movl $n,%eax; \
name: \ jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_SYSCALL * 4); \
movl $n,%eax; \ FUNCTION_END(name)
jmp *(USER_COMMPAGE_ADDR + COMMPAGE_ENTRY_X86_SYSCALL * 4)
#define SYSCALL0(name, n) _SYSCALL(name, n) #define SYSCALL0(name, n) _SYSCALL(name, n)
#define SYSCALL1(name, n) _SYSCALL(name, n) #define SYSCALL1(name, n) _SYSCALL(name, n)
@@ -3,7 +3,8 @@
** Distributed under the terms of the NewOS License. ** Distributed under the terms of the NewOS License.
*/ */
#define FUNCTION(x) .global x; .type x,@function; x #include <asm_defs.h>
.text .text
@@ -15,6 +16,7 @@ FUNCTION(__x86_setup_system_time):
movl 4(%esp),%eax movl 4(%esp),%eax
movl %eax,cv_factor movl %eax,cv_factor
ret ret
FUNCTION_END(__x86_setup_system_time)
/* long long system_time(); */ /* long long system_time(); */
FUNCTION(system_time): FUNCTION(system_time):
@@ -36,3 +38,4 @@ FUNCTION(system_time):
popl %ecx popl %ecx
popl %ebx popl %ebx
ret ret
FUNCTION_END(system_time)
@@ -1,5 +1,7 @@
SubDir HAIKU_TOP src system libroot posix arch x86 ; SubDir HAIKU_TOP src system libroot posix arch x86 ;
UsePrivateSystemHeaders ;
local genericSources = local genericSources =
setjmp_save_sigs.c setjmp_save_sigs.c
longjmp_return.c longjmp_return.c
@@ -1,4 +1,4 @@
/* /*
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved. ** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the Haiku License. ** Distributed under the terms of the Haiku License.
*/ */
@@ -14,6 +14,6 @@
#define JMP_REGS_ESP 16 #define JMP_REGS_ESP 16
#define JMP_REGS_PC 20 #define JMP_REGS_PC 20
#define FUNCTION(x) .global x; .type x,@function; x #include <asm_defs.h>
#endif /* SETJMP_INTERNAL_H */ #endif /* SETJMP_INTERNAL_H */
@@ -1,4 +1,4 @@
/* /*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License. ** Distributed under the terms of the Haiku License.
*/ */
@@ -36,6 +36,7 @@ FUNCTION(_longjmp):
add $8, %esp add $8, %esp
ret ret
FUNCTION_END(siglongjmp)
#pragma weak longjmp=siglongjmp #pragma weak longjmp=siglongjmp
@@ -4,7 +4,6 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "setjmp_internal.h" #include "setjmp_internal.h"
@@ -39,6 +38,7 @@ sigsetjmp_setjmp_entry:
mov %edx, JMP_REGS_PC(%eax) mov %edx, JMP_REGS_PC(%eax)
jmp __setjmp_save_sigs jmp __setjmp_save_sigs
FUNCTION_END(sigsetjmp)
/* int setjmp(jmp_buf buffer) */ /* int setjmp(jmp_buf buffer) */
@@ -55,6 +55,7 @@ FUNCTION(setjmp):
add $8, %esp add $8, %esp
ret ret
FUNCTION_END(setjmp)
#pragma weak _setjmp=setjmp #pragma weak _setjmp=setjmp