xref: /haiku/src/kits/media/RealtimeAlloc.cpp (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 /***********************************************************************
2  * AUTHOR: Marcus Overhagen
3  *   FILE: RealtimeAlloc.cpp
4  *  DESCR:
5  ***********************************************************************/
6 
7 #include <SupportDefs.h>
8 #include <RealtimeAlloc.h>
9 #include <malloc.h>
10 #include "debug.h"
11 
12 
13 struct rtm_pool
14 {
15 };
16 
17 extern "C" {
18 	rtm_pool * _rtm_pool;
19 };
20 
21 
22 status_t
23 rtm_create_pool(rtm_pool ** out_pool, size_t total_size, const char * name)
24 {
25 	BROKEN();
26 	*out_pool = (rtm_pool *) 0x55557777;
27 	TRACE("  new pool = %p\n", *out_pool);
28 	/* If out_pool is NULL, the default pool will be created if it isn't already. */
29 	/* If the default pool is already created, it will return EALREADY. */
30 	return B_OK;
31 }
32 
33 
34 status_t
35 rtm_delete_pool(rtm_pool * pool)
36 {
37 	BROKEN();
38 	TRACE("  pool = %p\n", pool);
39 	return B_OK;
40 }
41 
42 
43 void *
44 rtm_alloc(rtm_pool * pool, size_t size)
45 {
46 	BROKEN();
47 	TRACE("  pool = %p\n", pool);
48 	/* If NULL is passed for pool, the default pool is used (if created). */
49 	void *p = malloc(size);
50 	TRACE("  returning ptr = %p\n", p);
51 	return p;
52 }
53 
54 
55 status_t
56 rtm_free(void * data)
57 {
58 	BROKEN();
59 	TRACE("  ptr = %p\n", data);
60 	free(data);
61 	return B_OK;
62 }
63 
64 
65 status_t
66 rtm_realloc(void ** data, size_t new_size)
67 {
68 	BROKEN();
69 	TRACE("  ptr = %p\n", *data);
70 	void * newptr = realloc(*data, new_size);
71 	if (newptr) {
72 		*data = newptr;
73 		TRACE("  new ptr = %p\n", *data);
74 		return B_OK;
75 	} else
76 		return B_ERROR;
77 }
78 
79 
80 status_t
81 rtm_size_for(void * data)
82 {
83 	UNIMPLEMENTED();
84 	TRACE("  ptr = %p\n", data);
85 	return 0;
86 }
87 
88 
89 status_t
90 rtm_phys_size_for(void * data)
91 {
92 	UNIMPLEMENTED();
93 	TRACE("  ptr = %p\n", data);
94 	return 0;
95 }
96 
97 
98 rtm_pool *
99 rtm_default_pool()
100 {
101 	BROKEN();
102 	/* Return the default pool, or NULL if not yet initialized */
103 	TRACE("  returning pool = %p\n", (void *) 0x22229999);
104 	return (rtm_pool *) 0x22229999;
105 }
106 
107 
108 /****************************************************************************/
109 /* undocumented symboles that libmedia.so exports */
110 /* the following function declarations are guessed and are still wrong */
111 /****************************************************************************/
112 
113 extern "C" {
114 
115 status_t rtm_create_pool_etc(rtm_pool ** out_pool, size_t total_size, const char * name, int32 param4, int32 param5, ...);
116 
117 void rtm_get_pool(rtm_pool *pool,void *data,int32 param3,int32 param4, ...);
118 
119 }
120 
121 /*
122 param5 of rtm_create_pool_etc matches
123 param3 of rtm_get_pool
124 and might be a pointer into some structure
125 
126 param4 of rtm_create_pool_etc is 0 in the Doom game,
127 and might be a Flags field
128 
129 param4 of rtm_get_pool is 0x00000003 in the Doom game,
130 and might be a Flags field
131 
132 */
133 
134 status_t
135 rtm_create_pool_etc(rtm_pool ** out_pool, size_t total_size, const char * name, int32 param4, int32 param5, ...)
136 {
137 	BROKEN();
138 	*out_pool = (rtm_pool *) 0x44448888;
139 	TRACE("  new pool = %p\n", *out_pool);
140 	TRACE("  size = %d\n",(int)total_size);
141 	TRACE("  name = %s\n",name);
142 	TRACE("  param4 = 0x%08x\n",(int)param4);
143 	TRACE("  param5 = 0x%08x\n",(int)param5);
144 	return B_OK;
145 }
146 
147 
148 void
149 rtm_get_pool(rtm_pool *pool,void *data,int32 param3, int32 param4, ...)
150 {
151 	UNIMPLEMENTED();
152 	TRACE("  pool = %p\n", pool);
153 	TRACE("  ptr = %p\n", data);
154 	TRACE("  param3 = 0x%08x\n",(int)param3);
155 	TRACE("  param4 = 0x%08x\n",(int)param4);
156 }
157 
158