cdecl calling convention expects the callee to pop the hidden pointer on

struct return. For example, GCC and LLVM comply with this (tested on IA32).

ACK doesn't seem to follow this convention and expects the caller to clean up
the stack. Compiling hand-written ACK-compliant assembly code (returning a 
struct) with GCC or LLVM used to break things (4-bytes misaligned stack).

The patch fixes this problem.
This commit is contained in:
Lorenzo Cavallaro
2010-03-24 17:25:17 +00:00
parent 5fd3f34273
commit a16308efdb
10 changed files with 57 additions and 8 deletions

View File

@@ -21,7 +21,8 @@ INCS+= minix/a.out.h minix/bitmap.h minix/callnr.h minix/cdrom.h \
minix/rs.h minix/safecopies.h minix/sef.h minix/sound.h \
minix/sys_config.h minix/sysinfo.h minix/syslib.h \
minix/sysutil.h minix/tty.h minix/type.h minix/types.h \
minix/u64.h minix/vfsif.h minix/vm.h
minix/u64.h minix/vfsif.h minix/vm.h \
minix/compiler.h minix/compiler-ack.h
INCS+= net/hton.h net/if.h net/ioctl.h net/netlib.h
INCS+= net/gen/arp_io.h net/gen/dhcp.h net/gen/ether.h \
net/gen/eth_hdr.h net/gen/eth_io.h net/gen/icmp.h \

View File

@@ -0,0 +1,9 @@
/* Definitions for ACK-specific features. */
#ifndef _MINIX_COMPILER_ACK_H
#define _MINIX_COMPILER_ACK_H
/* ACK expects the caller to pop the hidden pointer on struct return. */
#define BYTES_TO_POP_ON_STRUCT_RETURN
#endif /* _MINIX_COMPILER_ACK_H */

25
include/minix/compiler.h Normal file
View File

@@ -0,0 +1,25 @@
/* Definitions for compiler-specific features. */
#ifndef _MINIX_COMPILER_H
#define _MINIX_COMPILER_H
/*===========================================================================*
* Compiler overrides *
*===========================================================================*/
/* ACK */
#ifdef __ACK__
#include <minix/compiler-ack.h>
#endif
/*===========================================================================*
* Default values *
*===========================================================================*/
/*
* cdecl calling convention expects the callee to pop the hidden pointer on
* struct return. For example, GCC and LLVM comply with this (tested on IA32).
*/
#ifndef BYTES_TO_POP_ON_STRUCT_RETURN
#define BYTES_TO_POP_ON_STRUCT_RETURN $4
#endif
#endif /* _MINIX_COMPILER_H */