2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Resource Tracking
8 This file can be included more than once
11 /* Resource Tracking currently disabled on native platforms */
12 #if (AROS_FLAVOUR & AROS_FLAVOUR_NATIVE)
20 #if ENABLE_RT || defined(RT_INTERNAL)
22 # include <exec/types.h>
27 /* Put code which must be defined only once here */
37 RTT_SCREEN
, /* Screen before Window, so the windows are closed before the screen */
40 /* Don't add anything below here !!! */
63 RTTO_OpenScreenTagList
,
68 RTTO_OpenWindowTagList
,
74 void RT_IntInitB (void);
75 void RT_IntInitE (void);
76 void RT_IntExitB (void);
77 void RT_IntExitE (void);
78 IPTR
RT_IntAdd (int rtt
, const char * file
, int line
, ...); /* Add a resource for tracking */
79 IPTR
RT_IntCheck (int rtt
, const char * file
, int line
, int op
, ...); /* Check a resource before use */
80 IPTR
RT_IntFree (int rtt
, const char * file
, int line
, ...); /* Stop tracking of a resource */
81 void RT_IntEnter (const char * functionname
, const char * filename
, int line
);
82 void RT_IntTrack (int rtt
, const char * file
, int line
, APTR res
, ...);
87 # define RT_Add(rtt, args...) RT_IntAdd (rtt, __FILE__, __LINE__, ##args)
88 # define RT_Check(rtt, op, args...) RT_IntCheck (rtt, __FILE__, __LINE__, op, ##args)
89 # define RT_Free(rtt, args...) RT_IntFree (rtt, __FILE__, __LINE__, ##args)
90 # define RT_Enter(fn) RT_IntEnter (fn,__FILE__, __LINE__)
91 # define RT_Track(rtt, res...) RT_IntTrack (rtt, __FILE__, __LINE__, ##res)
92 # endif /* ENABLE_RT */
93 # endif /* AROS_RT_H */
95 /* Add a resource for tracking which must not be freed. */
102 # ifndef PROTO_EXEC_H
103 # include <proto/exec.h>
107 void RT_InitExec (void);
108 void RT_ExitExec (void);
111 # define RT_INITEXEC RT_InitExec(),
112 # define RT_EXITEXEC RT_ExitExec(),
115 # define AllocMem(size,flags) (APTR)RT_Add(RTT_ALLOCMEM,(size),(flags))
117 # define FreeMem(ptr,size) (void)RT_Free(RTT_ALLOCMEM,(ptr),(size))
119 # define AllocVec(size,flags) (APTR)RT_Add(RTT_ALLOCVEC,(size),(flags))
121 # define FreeVec(ptr) (void)RT_Free(RTT_ALLOCVEC,(ptr))
123 # define OpenLibrary(name,ver) (APTR)RT_Add(RTT_LIBRARY,(name),(ver))
125 # define CloseLibrary(lib) (void)RT_Free(RTT_LIBRARY,(lib))
126 # undef CreateMsgPort
127 # define CreateMsgPort() (APTR)RT_Add(RTT_PORT,NULL,0)
128 # undef DeleteMsgPort
129 # define DeleteMsgPort(mp) (void)RT_Free(RTT_PORT,(mp))
131 # define CreatePort(name,pri) (APTR)RT_Add(RTT_PORT,(name),(pri))
133 # define DeletePort(mp) (void)RT_Free(RTT_PORT,(mp))
135 # define PutMsg(mp,msg) (void)RT_Check(RTT_PORT,RTTO_PutMsg,(mp),(msg))
137 # define GetMsg(mp) (struct Message *)RT_Check(RTT_PORT,RTTO_GetMsg,(mp))
141 # endif /* ENABLE_RT_EXEC */
148 # include <proto/dos.h>
152 void RT_InitDos (void);
153 void RT_ExitDos (void);
156 # define RT_INITDOS RT_InitDos(),
157 # define RT_EXITDOS RT_ExitDos(),
160 # define Open(path,mode) (BPTR)RT_Add(RTT_FILE,(path),(mode))
162 # define Close(fh) (void)RT_Free(RTT_FILE,(fh))
164 # define Read(fh,buffer,length) (LONG)RT_Check(RTT_FILE,RTTO_Read,(fh),(buffer),(length))
166 # define Write(fh,buffer,length) (LONG)RT_Check(RTT_FILE,RTTO_Write,(fh),(buffer),(length))
170 # endif /* ENABLE_RT_DOS */
172 # undef RT_INITINTUITION
173 # undef RT_EXITINTUITION
175 # if ENABLE_RT_INTUITION
176 # ifndef PROTO_INTUITION_H
177 # include <proto/intuition.h>
181 void RT_InitIntuition (void);
182 void RT_ExitIntuition (void);
185 # define RT_INITINTUITION RT_InitIntuition(),
186 # define RT_EXITINTUITION RT_ExitIntuition(),
189 # define OpenScreen(ns) (struct Screen *)RT_Add(RTT_SCREEN,RTTO_OpenScreen,(ns))
190 # undef OpenScreenTagList
191 # define OpenScreenTagList(ns,tl) (struct Screen *)RT_Add(RTT_SCREEN,RTTO_OpenScreenTagList,(ns),(tl))
192 # undef OpenScreenTags
193 # define OpenScreenTags(ns,tag...) (struct Screen *)RT_Add(RTT_SCREEN,RTTO_OpenScreenTags,(ns),##tag)
195 # define CloseScreen(s) (void)RT_Free(RTT_SCREEN,(s))
196 # undef ScreenToFront
197 # define ScreenToFront(s) (void)RT_Check(RTT_SCREEN,RTTO_ScreenToFront,(s))
199 # define ScreenToBack(s) (void)RT_Check(RTT_SCREEN,RTTO_ScreenToBack,(s))
202 # define OpenWindow(nw) (struct Window *)RT_Add(RTT_WINDOW,RTTO_OpenWindow,(nw))
203 # undef OpenWindowTagList
204 # define OpenWindowTagList(nw,tl) (struct Window *)RT_Add(RTT_WINDOW,RTTO_OpenWindowTagList,(nw),(tl))
205 # undef OpenWindowTags
206 # define OpenWindowTags(nw,tag...) (struct Window *)RT_Add(RTT_WINDOW,RTTO_OpenWindowTags,(nw),##tag)
208 # define CloseWindow(w) (void)RT_Free(RTT_WINDOW,(w))
209 # undef WindowToFront
210 # define WindowToFront(w) (void)RT_Check(RTT_WINDOW,RTTO_WindowToFront,(w))
212 # define WindowToBack(w) (void)RT_Check(RTT_WINDOW,RTTO_WindowToBack,(w))
214 # define RT_INITINTUITION
215 # define RT_EXITINTUITION
216 # endif /* ENABLE_RT_INTUITION */
217 # endif /* ENABLE_RT */
235 #else /* ENABLE_RT || defined(RT_INTERNAL) */
237 # define RT_Init() /* eps */
238 # define RT_Exit() /* eps */
239 # define RT_Add(rtt, args...) /* eps */
240 # define RT_Check(rtt, args...) /* eps */
241 # define RT_Free(rtt, args...) /* eps */
242 # define RT_Enter() /* eps */
243 # define RT_Leave() /* eps */
245 #endif /* ENABLE_RT || defined(RT_INTERNAL) */