1 #ifndef UTILITY_HOOKS_H
2 #define UTILITY_HOOKS_H
5 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
10 # include <exec/types.h>
13 # include <exec/nodes.h>
15 #ifndef AROS_ASMCALL_H
16 # include <aros/asmcall.h>
22 struct MinNode h_MinNode
;
23 IPTR (*h_Entry
)(); /* Main entry point */
24 IPTR (*h_SubEntry
)(); /* Secondary entry point */
25 APTR h_Data
; /* Whatever you want */
28 /* You can use this if you want for casting function pointers. */
29 typedef IPTR (*HOOKFUNC
)(struct Hook
*, APTR
, APTR
);
32 Calling conventions for Amiga Hooks.
34 The callback hook is invoked with the following parameters, which
35 on an Amiga/m68k are passed in the following registers:
37 A0 - pointer to the Hook data structure
38 A2 - pointer to Hook specific data ("object")
39 A1 - pointer to Hook parameters ("message")
41 When the Hook is invoked, control is passed to the h_Entry function.
42 This function MUST be defined in the following manner for correct
43 operation on all systems.
45 AROS_UFH3( return type , function name ,
46 AROS_UFHA(struct Hook *, hook, A0),
47 AROS_UFHA(APTR, object, A2),
48 AROS_UFHA(APTR, message, A1)
51 Note the order of the arguments, hook, object, message.
53 ----------------------------------------------------------------------
54 Note for people using Amiga compilers without registerized arguments
55 ----------------------------------------------------------------------
57 If your compiler cannot accept these parameters in these registers
58 (where applicable), you will have to define a small assembly stub
59 to push the arguments on the stack, and then call the h_SubEntry
62 However this is unlikely to be required unless you are trying to
63 compile your program on an Amiga with a very old compiler.
65 A sample stub (in new Motorola m68k syntax):
71 move.l (h_SubEntry,a0),a0
76 There is a suitable function defined in amiga.lib called HookEntry
77 that can be used for this purpose. See the documentation of HookEntry
82 #define CALLHOOKPKT(hook, object, message) \
85 IPTR, ((struct Hook *) hook)->h_Entry, \
86 AROS_UFCA(struct Hook *, hook, A0), \
87 AROS_UFCA(APTR, object, A2), \
88 AROS_UFCA(APTR, message, A1) \
91 #endif /* UTILITY_HOOKS_H */