2 * Copyright (C) 2011, The AROS Development Team. All rights reserved.
3 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
5 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
11 /* Abuse the d7 register to return condition codes */
12 register UWORD AROS_LIBFUNC_cc
asm ("d7");
14 /* This ensures that 'SetSR' and friends actually work */
17 do { AROS_LIBFUNC_cc = (v) | (AROS_LIBFUNC_cc & ~(m)); } while (0)
21 #define AROS_CCWRAP(t,func, subfunc) \
22 asm ( ".global " _S(func) "\n" _S(func) ":\n" \
24 "movem.l %d7/%a0-%a1,%sp@-\n" \
26 "jsr " _S(subfunc) "\n" \
27 "move.w %d7,%sp@(3*4)\n" \
28 "movem.l %sp@+,%d7/%a0-%a1\n" \
32 #define AROS_LH2(t,n,a1,a2,bt,bn,o,s) \
33 AROS_CCWRAP(t, AROS_SLIB_ENTRY(n,s,o), AROS_SLIB_ENTRY(n##_cc,s,o)) \
34 __AROS_LH2(t, n##_cc, AROS_LHA(a1), AROS_LHA(a2), bt, bn, o, s)
37 #define AROS_LH1(t,n,a1,bt,bn,o,s) \
38 AROS_CCWRAP(t, AROS_SLIB_ENTRY(n,s,o), AROS_SLIB_ENTRY(n##_cc,s,o)) \
39 __AROS_LH1(t, n##_cc, AROS_LHA(a1), bt, bn, o, s)
42 #define AROS_LH1QUAD1(t,n,a1,a2,bt,bn,o,s) \
43 AROS_CCWRAP(t, AROS_SLIB_ENTRY(n,s,o), AROS_SLIB_ENTRY(n##_cc,s,o)) \
44 __AROS_LH1QUAD1(t, n##_cc, AROS_LHA(a1), AROS_LHAQUAD(a2), bt, bn, o, s)
47 #define AROS_LHQUAD1(t,n,a1,bt,bn,o,s) \
48 AROS_CCWRAP(t, AROS_SLIB_ENTRY(n,s,o), AROS_SLIB_ENTRY(n##_cc,s,o)) \
49 __AROS_LHQUAD1(t, n##_cc, AROS_LHAQUAD(a1), bt, bn, o, s)
52 #define AROS_LHQUAD2(t,n,a1,a2,bt,bn,o,s) \
53 AROS_CCWRAP(t, AROS_SLIB_ENTRY(n,s,o), AROS_SLIB_ENTRY(n##_cc,s,o)) \
54 __AROS_LHQUAD2(t, n##_cc, AROS_LHAQUAD(a1), AROS_LHAQUAD(a2), bt, bn, o, s)
56 #endif /* LIBCALL_CC_H */