5 Copyright © 1995-96, The AROS Development Team. All rights reserved.
8 Desc: Common header file for RT
11 #define ENABLE_RT 0 /* no RT inside this file */
15 #include <exec/lists.h>
18 #include <aros/system.h>
19 #include <exec/tasks.h>
20 #include <exec/ports.h>
21 #include <exec/memory.h>
22 #include <exec/execbase.h>
25 #include <proto/exec.h>
26 #include <proto/dos.h>
27 #include <proto/intuition.h>
28 #include <proto/arossupport.h>
29 #include <proto/alib.h>
33 #define RT_VERSION 1 /* Current version of RT */
35 #define HASH_BITS 4 /* Size of hash in bits and entries */
36 #define HASH_SIZE (1L << HASH_BITS)
40 const char * Function
;
46 #define STACKDEPTH 256
49 /* This is what is behind etask->iet_RT */
52 ULONG rtd_Version
; /* RT_VERSION */
53 struct MinList rtd_ResHash
[RTT_MAX
][HASH_SIZE
];
55 RTStack rtd_CallStack
[STACKDEPTH
];
58 extern RTData
* intRT
; /* Global variable in case no ETask is available */
69 /* Private flags of resource nodes */
70 #define RTNF_DONT_FREE 0x80000000 /* Resource must not be freed */
75 APTR Resource
; /* This should be common to every resource */
79 typedef struct __RTDesc RTDesc
;
81 typedef IPTR (* RT_AllocFunc
) (RTData
* rtd
, RTNode
*, va_list, BOOL
* success
);
82 typedef IPTR (* RT_FreeFunc
) (RTData
* rtd
, RTNode
*);
83 typedef IPTR (* RT_SearchFunc
) (RTData
* rtd
, int, RTNode
**, va_list);
84 typedef IPTR (* RT_ShowError
) (RTData
* rtd
, int, RTNode
*, IPTR
, int, const char * file
, ULONG line
, va_list);
85 typedef IPTR (* RT_CheckFunc
) (RTData
* rtd
, int, const char * file
, ULONG line
, ULONG op
, va_list);
87 #define HASH_BASE(rtn) (((Resource *)rtn)->Resource)
91 #define CALCHASH(res) \
92 ((((IPTR)res) + (((IPTR)res)>>4) + (((IPTR)res)>>8 ) + (((IPTR)res)>>12) + \
93 (((IPTR)res)>>16) + (((IPTR)res)>>20) +(((IPTR)res)>>24) + (((IPTR)res)>>28) + \
94 (((IPTR)res)>>32) + (((IPTR)res)>>36) +(((IPTR)res)>>40) + (((IPTR)res)>>44) + \
95 (((IPTR)res)>>48) + (((IPTR)res)>>52) +(((IPTR)res)>>56) + (((IPTR)res)>>60)) \
98 #define CALCHASH(res) \
99 ((((ULONG)res) + (((ULONG)res)>>4) +(((ULONG)res)>>8) + (((ULONG)res)>>12) + \
100 (((ULONG)res)>>16) + (((ULONG)res)>>20) +(((ULONG)res)>>24) + (((ULONG)res)>>28)) \
108 RT_AllocFunc AllocFunc
;
109 RT_FreeFunc FreeFunc
;
110 RT_SearchFunc SearchFunc
;
111 RT_ShowError ShowError
;
112 RT_CheckFunc CheckFunc
;
115 #define GetRTData() \
117 struct IntETask * et; \
119 et = (struct IntETask *)GetETask (FindTask(NULL)); \
123 && ((RTData *)et->iet_RT)->rtd_Version == RT_VERSION \
127 #define SetRTData(rtd) \
129 struct IntETask * et; \
131 et = (struct IntETask *)GetETask (FindTask(NULL)); \
139 /* Return values of SearchFunc */
140 #define RT_SEARCH_FOUND 0
141 #define RT_SEARCH_NOT_FOUND 1
142 #define RT_SEARCH_SIZE_MISMATCH 2
148 extern RTDesc
const * RT_Resources
[RTT_MAX
];
150 #define GetRTDesc(no) RT_Resources[no]
151 #define GetRTField(no,f) (GetRTDesc(no) ? GetRTDesc(no)->f : NULL)
152 #define GetRTSize(no) (GetRTDesc(no) ? GetRTDesc(no)->Size : 0)
153 #define GetRTAllocFunc(no) (GetRTField(no,AllocFunc))
154 #define GetRTFreeFunc(no) (GetRTField(no,FreeFunc))
155 #define GetRTSearchFunc(no) (GetRTField(no,SearchFunc))
156 #define GetRTShowError(no) (GetRTField(no,ShowError))
157 #define GetRTCheckFunc(no) (GetRTField(no,CheckFunc))
159 extern void RT_FreeResource (RTData
* rtd
, int rtt
, RTNode
* rtnode
);
161 #define ALIGNED_PTR 0x00000001 /* Must be aligned */
162 #define NULL_PTR 0x00000002 /* May be NULL */
163 extern BOOL
CheckPtr (APTR ptr
, ULONG flags
);
164 extern BOOL
CheckArea (APTR ptr
, ULONG size
, ULONG flags
);
166 extern IPTR
RT_Search (RTData
* rtd
, int rtt
, RTNode
** rtptr
, va_list args
);