# this is almost always a win. the kernel uses it, too.
CFLAGS+= -mpreferred-stack-boundary=2
+# use regparm for all functions - C functions called from assembly (or
+# vice versa) need __cdecl now
+CFLAGS+= -mregparm=3
+
+# use -mrtd (same __cdecl requirements as above)
+CFLAGS+= -mrtd
+
+# this is the logical complement to -mregparm=3.
+# it doesn't currently buy us anything, but if anything ever tries
+# to return small structures, let's be prepared
+CFLAGS+= -freg-struct-return
+
LDFLAGS+= -N --no-check-sections
ifeq "$(shell uname -s)" "FreeBSD"
* address space, and returns the physical address of the new location
* to the prefix in %edi.
*/
-void relocate ( struct i386_all_regs *ix86 ) {
+__cdecl void relocate ( struct i386_all_regs *ix86 ) {
struct memory_map memmap;
unsigned long start, end, size, padded_size;
unsigned long new_start, new_end;
* INT 13 handler
*
*/
-static void int13 ( struct i386_all_regs *ix86 ) {
+static __cdecl void int13 ( struct i386_all_regs *ix86 ) {
int command = ix86->regs.ah;
unsigned int bios_drive = ix86->regs.dl;
unsigned int original_bios_drive = bios_drive;
* @v es:di Address of PXE parameter block
* @ret ax PXE exit code
*/
-void pxe_api_call ( struct i386_all_regs *ix86 ) {
+__cdecl void pxe_api_call ( struct i386_all_regs *ix86 ) {
int opcode = ix86->regs.bx;
userptr_t parameters = real_to_user ( ix86->segs.es, ix86->regs.di );
size_t param_len;
* @v es:di Address of PXE parameter block
* @ret ax PXE exit code
*/
-void pxe_loader_call ( struct i386_all_regs *ix86 ) {
+__cdecl void pxe_loader_call ( struct i386_all_regs *ix86 ) {
userptr_t uparams = real_to_user ( ix86->segs.es, ix86->regs.di );
struct s_UNDI_LOADER params;
PXENV_EXIT_t ret;
*
* @ret rc Return status code
*/
-int main ( void ) {
+__cdecl int main ( void ) {
initialise();
startup();
/** Declare a variable or data structure as unused. */
#define __unused __attribute__ (( unused ))
+/** Apply standard C calling conventions */
+#define __cdecl __attribute__ (( cdecl , regparm(0) ))
+
/**
* Declare a function as used.
*