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)
90 #define CALCHASH(res) \
91 ((((ULONG)res) + (((ULONG)res)>>4) +(((ULONG)res)>>8) + (((ULONG)res)>>12) + \
92 (((ULONG)res)>>16) + (((ULONG)res)>>20) +(((ULONG)res)>>24) + (((ULONG)res)>>28)) \
99 RT_AllocFunc AllocFunc
;
100 RT_FreeFunc FreeFunc
;
101 RT_SearchFunc SearchFunc
;
102 RT_ShowError ShowError
;
103 RT_CheckFunc CheckFunc
;
106 #define GetRTData() \
108 struct IntETask * et; \
110 et = (struct IntETask *)GetETask (FindTask(NULL)); \
114 && ((RTData *)et->iet_RT)->rtd_Version == RT_VERSION \
118 #define SetRTData(rtd) \
120 struct IntETask * et; \
122 et = (struct IntETask *)GetETask (FindTask(NULL)); \
130 /* Return values of SearchFunc */
131 #define RT_SEARCH_FOUND 0
132 #define RT_SEARCH_NOT_FOUND 1
133 #define RT_SEARCH_SIZE_MISMATCH 2
139 extern RTDesc
const * RT_Resources
[RTT_MAX
];
141 #define GetRTDesc(no) RT_Resources[no]
142 #define GetRTField(no,f) (GetRTDesc(no) ? GetRTDesc(no)->f : NULL)
143 #define GetRTSize(no) (GetRTDesc(no) ? GetRTDesc(no)->Size : 0)
144 #define GetRTAllocFunc(no) (GetRTField(no,AllocFunc))
145 #define GetRTFreeFunc(no) (GetRTField(no,FreeFunc))
146 #define GetRTSearchFunc(no) (GetRTField(no,SearchFunc))
147 #define GetRTShowError(no) (GetRTField(no,ShowError))
148 #define GetRTCheckFunc(no) (GetRTField(no,CheckFunc))
150 extern void RT_FreeResource (RTData
* rtd
, int rtt
, RTNode
* rtnode
);
152 #define ALIGNED_PTR 0x00000001 /* Must be aligned */
153 #define NULL_PTR 0x00000002 /* May be NULL */
154 extern BOOL
CheckPtr (APTR ptr
, ULONG flags
);
155 extern BOOL
CheckArea (APTR ptr
, ULONG size
, ULONG flags
);
157 extern IPTR
RT_Search (RTData
* rtd
, int rtt
, RTNode
** rtptr
, va_list args
);