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:
		
							parent
							
								
									5fd3f34273
								
							
						
					
					
						commit
						a16308efdb
					
				@ -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 \
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								include/minix/compiler-ack.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								include/minix/compiler-ack.h
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										25
									
								
								include/minix/compiler.h
									
									
									
									
									
										Normal 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 */
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
/*	add64() - 64 bit addition			Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_add64
 | 
			
		||||
 | 
			
		||||
@ -12,7 +14,7 @@ _add64:
 | 
			
		||||
	movl	12(%esp), %edx
 | 
			
		||||
	adcl	20(%esp), %edx
 | 
			
		||||
	movl	%edx, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: add64.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
/*	add64u() - unsigned to 64 bit addition		Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_add64u, _add64ul
 | 
			
		||||
 | 
			
		||||
@ -14,7 +16,7 @@ _add64ul:
 | 
			
		||||
	movl	12(%esp), %edx
 | 
			
		||||
	adcl	$0, %edx
 | 
			
		||||
	movl	%edx, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: add64u.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
/*	cvu64() - unsigned converted to 64 bit		Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_cvu64, _cvul64
 | 
			
		||||
 | 
			
		||||
@ -11,7 +13,7 @@ _cvul64:
 | 
			
		||||
	movl	8(%esp), %edx
 | 
			
		||||
	movl	%edx, (%eax)
 | 
			
		||||
	movl	$0, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: cvu64.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,8 @@
 | 
			
		||||
/*	make64() - make a 64 bit number from two 32 bit halves */
 | 
			
		||||
/*							Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_make64
 | 
			
		||||
 | 
			
		||||
@ -11,7 +13,7 @@ _make64:
 | 
			
		||||
	movl	%edx, (%eax)
 | 
			
		||||
	movl	12(%esp), %edx
 | 
			
		||||
	movl	%edx, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: make64.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,8 @@
 | 
			
		||||
/*	mul64u() - unsigned long by unsigned multiply giving 64 bit result */
 | 
			
		||||
/*							Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_mul64u
 | 
			
		||||
 | 
			
		||||
@ -12,7 +14,7 @@ _mul64u:
 | 
			
		||||
	movl	%eax, (%ecx)
 | 
			
		||||
	movl	%edx, 4(%ecx)
 | 
			
		||||
	movl	%ecx, %eax
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: mul64u.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
/*	sub64() - 64 bit subtraction			Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_sub64
 | 
			
		||||
 | 
			
		||||
@ -12,7 +14,7 @@ _sub64:
 | 
			
		||||
	movl	12(%esp), %edx
 | 
			
		||||
	sbbl	20(%esp), %edx
 | 
			
		||||
	movl	%edx, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: sub64.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,7 @@
 | 
			
		||||
/*	sub64() - unsigned from 64 bit subtraction	Author: Kees J. Bot */
 | 
			
		||||
/*								7 Dec 1995 */
 | 
			
		||||
#include <minix/compiler.h>
 | 
			
		||||
 | 
			
		||||
.text
 | 
			
		||||
.globl	_sub64u, _sub64ul
 | 
			
		||||
 | 
			
		||||
@ -14,7 +16,7 @@ _sub64ul:
 | 
			
		||||
	movl	12(%esp), %edx
 | 
			
		||||
	sbbl	$0, %edx
 | 
			
		||||
	movl	%edx, 4(%eax)
 | 
			
		||||
	ret
 | 
			
		||||
	ret BYTES_TO_POP_ON_STRUCT_RETURN
 | 
			
		||||
 | 
			
		||||
/* */
 | 
			
		||||
/* $PchId: sub64u.ack.s,v 1.2 1996/04/11 18:59:57 philip Exp $ */
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user