| #ifndef INCLUDED_ARGS_H |
| #define INCLUDED_ARGS_H |
| |
| /* This defines the calling sequences for integers and floats. */ |
| #define I0 eax |
| #define I1 edx |
| #define I2 ecx |
| |
| typedef unsigned int size_t; |
| |
| extern void (*callthis)(void); |
| extern unsigned long eax,ebx,ecx,edx,esi,edi,esp,ebp; |
| extern unsigned long sret_eax; |
| extern volatile unsigned long volatile_var; |
| extern void snapshot (void); |
| extern void snapshot_ret (void); |
| extern void *iamcu_memset (void *, int, size_t); |
| #define WRAP_CALL(N) \ |
| (callthis = (void (*)()) (N), (typeof (&N)) snapshot) |
| #define WRAP_RET(N) \ |
| (callthis = (void (*)()) (N), (typeof (&N)) snapshot_ret) |
| |
| /* Clear all scratch integer registers. */ |
| #define clear_int_hardware_registers \ |
| asm __volatile__ ("xor %%eax, %%eax\n\t" \ |
| "xor %%edx, %%edx\n\t" \ |
| "xor %%ecx, %%ecx\n\t" \ |
| ::: "eax", "edx", "ecx"); |
| |
| /* Clear all scratch integer registers, excluding the one used to return |
| aggregate. */ |
| #define clear_non_sret_int_hardware_registers \ |
| asm __volatile__ ("xor %%edx, %%edx\n\t" \ |
| "xor %%ecx, %%ecx\n\t" \ |
| ::: "edx", "ecx"); |
| |
| /* This is the list of registers available for passing arguments. Not all of |
| these are used or even really available. */ |
| struct IntegerRegisters |
| { |
| unsigned long eax, ebx, ecx, edx, esi, edi; |
| }; |
| |
| /* Implemented in scalarargs.c */ |
| extern struct IntegerRegisters iregs, iregbits; |
| extern unsigned int num_iregs; |
| |
| #define check_int_arguments do { \ |
| assert (num_iregs <= 0 || (iregs.I0 & iregbits.I0) == (I0 & iregbits.I0)); \ |
| assert (num_iregs <= 1 || (iregs.I1 & iregbits.I1) == (I1 & iregbits.I1)); \ |
| assert (num_iregs <= 2 || (iregs.I2 & iregbits.I2) == (I2 & iregbits.I2)); \ |
| } while (0) |
| |
| #define check_char_arguments check_int_arguments |
| #define check_short_arguments check_int_arguments |
| #define check_long_arguments check_int_arguments |
| #define check_float_arguments check_int_arguments |
| #define check_double_arguments check_int_arguments |
| #define check_ldouble_arguments check_int_arguments |
| |
| /* Clear register struct. */ |
| #define clear_struct_registers \ |
| eax = edx = ecx = 0; \ |
| iamcu_memset (&iregs, 0, sizeof iregs); |
| |
| /* Clear both hardware and register structs for integers. */ |
| #define clear_int_registers \ |
| clear_struct_registers \ |
| clear_int_hardware_registers |
| |
| /* Clear both hardware and register structs for integers, excluding the |
| one used to return aggregate. */ |
| #define clear_non_sret_int_registers \ |
| clear_struct_registers \ |
| clear_non_sret_int_hardware_registers |
| |
| #endif /* INCLUDED_ARGS_H */ |