Mesa (thalloc): thalloc: Add stubs for talloc functions.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Jan 6 19:47:56 UTC 2011


Module: Mesa
Branch: thalloc
Commit: 2f138b70adbf6faf8a682bccbe24e44aca0d2ba3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f138b70adbf6faf8a682bccbe24e44aca0d2ba3

Author: José Fonseca <jfonseca at vmware.com>
Date:   Thu Jan  6 19:47:12 2011 +0000

thalloc: Add stubs for talloc functions.

---

 src/glsl/SConscript    |    3 +-
 src/mesa/SConscript    |    2 +-
 src/thalloc/SConscript |    4 +-
 src/thalloc/talloc.h   |  131 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 136 insertions(+), 4 deletions(-)

diff --git a/src/glsl/SConscript b/src/glsl/SConscript
index f179721..3f5ea66 100644
--- a/src/glsl/SConscript
+++ b/src/glsl/SConscript
@@ -9,8 +9,7 @@ env.Prepend(CPPPATH = [
     '#src/mesa',
 ])
 
-if env['platform'] == 'windows':
-    env.Prepend(CPPPATH = ['#src/talloc'])
+env.Prepend(CPPPATH = ['#src/thalloc'])
 
 sources = [
     'glcpp/glcpp-lex.c',
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index cc4ad09..a656451 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -17,11 +17,11 @@ if env['platform'] == 'windows':
         '_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
         'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
     ])
-    env.Prepend(CPPPATH = ['#src/talloc'])
 else:
     env.Append(CPPDEFINES = [
         'IN_DRI_DRIVER', # enable the remap table (for DRI drivers)
     ])
+env.Prepend(CPPPATH = ['#src/thalloc'])
 
 #
 # Source files
diff --git a/src/thalloc/SConscript b/src/thalloc/SConscript
index 2a7146d..5b264a3 100644
--- a/src/thalloc/SConscript
+++ b/src/thalloc/SConscript
@@ -4,7 +4,9 @@ env = env.Clone()
 
 thalloc = env.ConvenienceLibrary(
     target = 'thalloc',
-    source = ['halloc.c'],
+    source = [
+        'halloc.c',
+    ],
 )
 
 Export('thalloc')
diff --git a/src/thalloc/talloc.h b/src/thalloc/talloc.h
new file mode 100644
index 0000000..e7cb5ce
--- /dev/null
+++ b/src/thalloc/talloc.h
@@ -0,0 +1,131 @@
+/*
+ * Based exclusively from reading the talloc documentation.
+ */
+
+#ifndef _TALLOC_H_
+#define _TALLOC_H_
+
+#include <assert.h>
+#include <string.h>
+#include <stdarg.h>
+
+static inline char *
+talloc_asprintf(const void *t, const char *fmt, ...) {
+   assert(0);
+   return NULL;
+}
+
+static inline char *
+talloc_asprintf_append(char *s, const char *fmt, ...) {
+   assert(0);
+   return NULL;
+}
+
+static inline void *
+talloc_autofree_context(void) {
+   assert(0);
+   return NULL;
+}
+
+static inline int
+talloc_free(void *ptr) {
+   assert(0);
+   return 0;
+}
+   
+static inline void *
+talloc_init(const char *fmt, ...) {
+   assert(0);
+   return NULL;
+}
+
+static inline void *
+talloc_parent(const void *ptr) {
+   assert(0);
+   return NULL;
+}
+
+static inline void *
+talloc_realloc_size(const void *ctx, void *ptr, size_t size) {
+   assert(0);
+   return NULL;
+}
+
+static inline void *
+talloc_reference(const void *ctx, const void *ptr) {
+   assert(0);
+   return NULL;
+}
+
+static inline void 
+talloc_set_destructor(void *ctx, int (*destructor)(void*)) {
+   assert(0);
+}
+
+static inline void *
+talloc_size(const void *ctx, size_t size) {
+   assert(0);
+   return NULL;
+}
+
+#define talloc_new(_ctx) talloc_strdup(_ctx, __FILE__ )
+
+#define talloc(_ctx, _type) (_type *)talloc_size(_ctx, sizeof(_type))
+#define talloc_array_size(_ctx, _size, _count) talloc_size(_ctx, _size * _count)
+#define talloc_array(_ctx, _type, _count) (_type *)talloc_size(_ctx, sizeof(_type) * _count)
+
+#define talloc_steal(new_ctx, _ptr) _ptr /* FIXME */
+
+static inline char *
+talloc_strdup(const void *ctx, const char *p) {
+   size_t size = strlen(p) + 1;
+   char *ptr = (char *)talloc_size(ctx, size);
+   if (ptr) {
+      memcpy(ptr, p, size);
+   }
+   return ptr;
+}
+
+static inline char *
+talloc_strdup_append(const void *t, const char *p) {
+   assert(0);
+   return NULL;
+}
+
+static inline char *
+talloc_strndup(const void *t, const char *p, size_t n) {
+   assert(0);
+   return NULL;
+}
+
+static inline char *
+talloc_strndup_append(char *s, const char *p, size_t n) {
+   assert(0);
+   return NULL;
+}
+
+static inline int
+talloc_unlink(const void *ctx, const void *ptr) {
+   assert(0);
+   return 0;
+}
+
+static inline char *
+talloc_vasprintf_append(char *s, const char *fmt, va_list ap) {
+   assert(0);
+   return NULL;
+}
+
+static inline void *
+talloc_zero_size(const void *ctx, size_t size) {
+   void *ptr = talloc_size(ctx, size);
+   if (ptr) {
+      memset(ptr, 0, size);
+   }
+   return ptr;
+}
+
+#define talloc_zero(_ctx, _type) (_type *)talloc_zero_size(_ctx, sizeof(_type))
+#define talloc_zero_array(_ctx, _type, _count) (_type *)talloc_zero_size(_ctx, sizeof(_type) * _count)
+
+#endif




More information about the mesa-commit mailing list