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