]> rtime.felk.cvut.cz Git - orte.git/commitdiff
Update ul_gavl* files to kill some compiler warnings
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 9 Sep 2013 20:40:02 +0000 (22:40 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 9 Sep 2013 20:40:02 +0000 (22:40 +0200)
I copied the files from upstream ulut repository
(git://git.code.sf.net/p/ulan/ulut).

orte/include/ul_gavl.h
orte/include/ul_gavlcust.h
orte/include/ul_gavlflesint.h
orte/include/ul_gavlrepcust.h
orte/include/ul_utdefs.h
orte/include/ul_utmalloc.h [new file with mode: 0644]
orte/liborte/ul_gavl.c
orte/liborte/ul_gavlprim.c

index 9fbe4a4aed3b3cfa873af0f3a1a434fa922668cd..d27f812b97eb26c5cde956ba4dcecd1a149856db 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
 #define GAVL_UNBALANCED_SUPPORT
 
 /* function to compare fields of two items */
-typedef int gavl_cmp_fnc_t(const void *a, const void *b);
+typedef int gavl_cmp_fnc_t(const void *a, const void *b) UL_ATTR_REENTRANT;
 
 /**
  * struct gavl_node - Structure Representing Node of Generic AVL Tree
@@ -101,6 +101,8 @@ gavl_next_node(const gavl_node_t *node);
 gavl_node_t *
 gavl_prev_node(const gavl_node_t *node);
 
+#if !defined(SDCC) && !defined(__SDCC)
+
 int
 gavl_is_empty(const gavl_root_t *root);
 
@@ -198,6 +200,8 @@ gavl_node2key(const gavl_root_t *root, const gavl_node_t *node)
   return (void*)(p+root->key_offs);
 }
 
+#endif /*SDCC*/
+
 int
 gavl_balance_one(gavl_node_t **subtree);
 
@@ -247,6 +251,8 @@ gavl_delete_and_next_node(gavl_root_t *root, gavl_node_t *node);
 /*===========================================================*/
 /* iterators for generic GAVL type */
 
+#if !defined(SDCC) && !defined(__SDCC)
+
 typedef struct {
   gavl_root_t *container;
   gavl_node_t *node;
@@ -302,21 +308,21 @@ gavl_delete_it(gavl_it_t *it)
 }
 
 static inline int 
-gavl_find_it(gavl_root_t *container, void *key, gavl_it_t *it)
+gavl_find_it(gavl_root_t *container, const void *key, gavl_it_t *it)
 {
   it->container=container;
   return (it->node=gavl_find_first_node(container, key))!=0;
 }
 
 static inline int 
-gavl_find_first_it(gavl_root_t *container, void *key, gavl_it_t *it)
+gavl_find_first_it(gavl_root_t *container, const void *key, gavl_it_t *it)
 {
   it->container=container;
   return (it->node=gavl_find_first_node(container, key))!=0;
 }
 
 static inline int 
-gavl_find_after_it(gavl_root_t *container, void *key, gavl_it_t *it)
+gavl_find_after_it(gavl_root_t *container, const void *key, gavl_it_t *it)
 {
   it->container=container;
   return (it->node=gavl_find_after_node(container, key))!=0;
@@ -351,12 +357,14 @@ gavl_find_after_it(gavl_root_t *container, void *key, gavl_it_t *it)
 #define gavl_generic_for_each_cut(item_t, root, ptr) \
        for(;(ptr=(item_t*)gavl_cut_first(root));)
 
+#endif /*SDCC*/
+
 /*===========================================================*/
 /* basic types compare functions */
 
-int gavl_cmp_int(const void *a, const void *b);
-int gavl_cmp_long(const void *a, const void *b);
-int gavl_cmp_ptr(const void *a, const void *b);
+int gavl_cmp_int(const void *a, const void *b) UL_ATTR_REENTRANT;
+int gavl_cmp_long(const void *a, const void *b) UL_ATTR_REENTRANT;
+int gavl_cmp_ptr(const void *a, const void *b) UL_ATTR_REENTRANT;
 
 /*===========================================================*/
 /* More functions useful for partially balanced trees */
@@ -412,7 +420,7 @@ typedef struct{
     int cust_cmp_fnc(cust_key_t *a, cust_key_t *b) */
 
 /* Declaration of new custom tree with internal node */
-#define GAVL_CUST_NODE_INT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+#define GAVL_CUST_NODE_INT_DEC_SCOPE(cust_scope, cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
                cust_root_node, cust_item_node, cust_item_key, cust_cmp_fnc) \
 \
 static inline cust_item_t * \
@@ -423,16 +431,16 @@ static inline cust_key_t *\
 cust_prefix##_node2key(const cust_root_t *root, gavl_node_t *node)\
   { return &(cust_prefix##_node2item(root, node)->cust_item_key);}\
 \
-void cust_prefix##_init_root_field(cust_root_t *root);\
-int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep);\
-cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key);\
-cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key);\
-cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key);\
-int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\
-int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\
-int cust_prefix##_delete(cust_root_t *root, cust_item_t *item);\
-gavl_node_t *cust_prefix##_first_node(const cust_root_t *root);\
-gavl_node_t *cust_prefix##_last_node(const cust_root_t *root);\
+cust_scope void cust_prefix##_init_root_field(cust_root_t *root);\
+cust_scope int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep);\
+cust_scope cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key);\
+cust_scope cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key);\
+cust_scope cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key);\
+cust_scope int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\
+cust_scope int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\
+cust_scope int cust_prefix##_delete(cust_root_t *root, cust_item_t *item);\
+cust_scope gavl_node_t *cust_prefix##_first_node(const cust_root_t *root);\
+cust_scope gavl_node_t *cust_prefix##_last_node(const cust_root_t *root);\
 \
 static inline void \
 cust_prefix##_init_detached(cust_item_t *item){\
@@ -476,6 +484,11 @@ cust_prefix##_cut_first(cust_root_t *root)\
 /*** Iterators ***/\
 UL_ITBASE_SORT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t)
 
+#define GAVL_CUST_NODE_INT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+               cust_root_node, cust_item_node, cust_item_key, cust_cmp_fnc) \
+       GAVL_CUST_NODE_INT_DEC_SCOPE(extern, cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+               cust_root_node, cust_item_node, cust_item_key, cust_cmp_fnc)
+
 #define gavl_cust_for_each(cust_prefix, root, ptr) \
        for(ptr=cust_prefix##_first(root);ptr;ptr=cust_prefix##_next((root),ptr))
 
index df5d3f71d040f44c653ddc80aca0c7316de60be7..7761454e3a35a0c2e112099c6b168d2af2d67cb8 100644 (file)
@@ -60,7 +60,7 @@ void cust_prefix##_init_root_field(cust_root_t *root)\
   root->cust_root_node=NULL;\
 }\
 \
-int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep)\
+int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep)\
 {\
   int cmp=1;\
   gavl_node_t *n, *p;\
@@ -81,7 +81,7 @@ int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_nod
   return cmp;\
 }\
 \
-cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key)\
 {\
   gavl_node_t *node;\
   if(cust_prefix##_search_node(root, key, &node))\
@@ -89,12 +89,12 @@ cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\
   return cust_prefix##_node2item(root,node);\
 }\
 \
-cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key)\
 {\
   return cust_prefix##_find(root, key);\
 }\
 \
-cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key)\
 {\
   gavl_node_t *node;\
   if(cust_prefix##_search_node(root, key, &node)<=0){\
@@ -121,7 +121,6 @@ int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node)\
 \
 int cust_prefix##_delete(cust_root_t *root, cust_item_t *item)\
 {\
-  int ret;\
   gavl_node_t *n, *p;\
   if(!item) return -1;\
   /*if(cust_prefix##_search_node(root, &item->cust_item_key, &n))*/\
@@ -130,8 +129,7 @@ int cust_prefix##_delete(cust_root_t *root, cust_item_t *item)\
   for(p=n; p->parent; p=p->parent);\
   if(p!=root->cust_root_node)\
     return -1;\
-  ret=gavl_delete_primitive(&root->cust_root_node, n);\
-  return 1;\
+  return gavl_delete_primitive(&root->cust_root_node, n);\
 }\
 \
 gavl_node_t *cust_prefix##_first_node(const cust_root_t *root)\
index 7733d4090db0a41eb88ce1f6611d3a6326653597..7eef3b4683b29234cf80129f6cbdc10e4fe60158 100644 (file)
@@ -32,7 +32,7 @@ extern "C" {
 #endif
 
 /* Declaration of tree with first/last enhanced speed functions with internal node */
-#define GAVL_FLES_INT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+#define GAVL_FLES_INT_DEC_SCOPE(cust_scope, cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
                cust_root_field, cust_item_node, cust_item_key, cust_cmp_fnc) \
 \
 static inline cust_item_t * \
@@ -43,15 +43,15 @@ static inline cust_key_t *\
 cust_prefix##_node2key(const cust_root_t *root, gavl_node_t *node)\
   { return &(cust_prefix##_node2item(root, node)->cust_item_key);}\
 \
-void cust_prefix##_init_root_field(cust_root_t *root);\
-int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep);\
-cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key);\
-cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key);\
-cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key);\
-int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\
-cust_item_t *cust_prefix##_cut_first(cust_root_t *root);\
-int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\
-int cust_prefix##_delete(cust_root_t *root, cust_item_t *item);\
+cust_scope void cust_prefix##_init_root_field(cust_root_t *root);\
+cust_scope int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep);\
+cust_scope cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key);\
+cust_scope cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key);\
+cust_scope cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key);\
+cust_scope int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\
+cust_scope cust_item_t *cust_prefix##_cut_first(cust_root_t *root);\
+cust_scope int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\
+cust_scope int cust_prefix##_delete(cust_root_t *root, cust_item_t *item);\
 \
 static inline void \
 cust_prefix##_init_detached(cust_item_t *item){\
@@ -99,6 +99,10 @@ cust_prefix##_is_empty(const cust_root_t *root)\
 /*** Iterators ***/\
 UL_ITBASE_SORT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t)
 
+#define GAVL_FLES_INT_DEC(cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+               cust_root_field, cust_item_node, cust_item_key, cust_cmp_fnc) \
+       GAVL_FLES_INT_DEC_SCOPE(extern, cust_prefix, cust_root_t, cust_item_t, cust_key_t,\
+               cust_root_field, cust_item_node, cust_item_key, cust_cmp_fnc)
 
 /**
  * GAVL_FLES_INT_IMP - Implementation of new custom tree with fast first/last functions
@@ -136,7 +140,7 @@ void cust_prefix##_init_root_field(cust_root_t *root)\
   root->cust_root_field.count=0;\
 }\
 \
-int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep, int mode)\
+int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep, int mode)\
 {\
   int cmp=1;\
   gavl_node_t *n, *p;\
@@ -174,12 +178,12 @@ int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t *key, gavl_no
   return cmp;\
 }\
 \
-int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep)\
+int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep)\
 {\
   return cust_prefix##_search_node4(root, key, nodep, 0);\
 }\
 \
-cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key)\
 {\
   gavl_node_t *node;\
   if(cust_prefix##_search_node4(root, key, &node, 0))\
@@ -187,7 +191,7 @@ cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\
   return cust_prefix##_node2item(root,node);\
 }\
 \
-cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key)\
 {\
   gavl_node_t *n;\
   if(cust_prefix##_search_node4(root, key, &n, GAVL_FFIRST))\
@@ -195,7 +199,7 @@ cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\
   return cust_prefix##_node2item(root,n);\
 }\
 \
-cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key)\
+cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key)\
 {\
   gavl_node_t *node;\
   if(cust_prefix##_search_node4(root, key, &node, GAVL_FAFTER)<=0){\
index 158da3d2201f15bf190a70c9e1108d795cec2c9c..f1384705cbf9fb28b4a63fce6066ff60f36ea462 100644 (file)
@@ -147,7 +147,6 @@ int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node)\
 \
 int cust_prefix##_delete(cust_root_t *root, cust_item_t *item)\
 {\
-  int ret;\
   gavl_node_t *n, *p;\
   if(!item) return -1;\
   n=&item->cust_item_node;\
@@ -155,8 +154,7 @@ int cust_prefix##_delete(cust_root_t *root, cust_item_t *item)\
   for(p=n; p->parent; p=p->parent);\
   if(p!=root->cust_root_node)\
     return -1;\
-  ret=gavl_delete_primitive(&root->cust_root_node, n);\
-  return 1;\
+  return gavl_delete_primitive(&root->cust_root_node, n);\
 }\
 \
 gavl_node_t *cust_prefix##_first_node(const cust_root_t *root)\
index 6b5eb4ee773c0f556fbbee6f48903a604f734aef..b00ea9207b41539305555bc0f2defa6417225d09 100644 (file)
@@ -17,6 +17,38 @@ extern "C" {
 #define inline _inline
 #endif
 
+#if !defined(UL_BUILD_BUG_ON_MSG_LINE) && defined(__OPTIMIZE__) && \
+  ((__GNUC__ * 1000 + __GNUC_MINOR__) >= 4004)
+#define UL_BUILD_BUG_ON_MSG_LINE_EXP1(condition, msg, line) \
+({ \
+  if (!!(condition)) { \
+    void compile_time_bug_on_line_ ## line (void) __attribute__((error(msg))); \
+    compile_time_bug_on_line_ ## line (); \
+  } \
+})
+#define UL_BUILD_BUG_ON_MSG_LINE(condition, msg, line) \
+  UL_BUILD_BUG_ON_MSG_LINE_EXP1(condition, msg, line)
+#endif /*UL_BUILD_BUG_ON_MSG for GCC*/
+
+#ifndef UL_BUILD_BUG_ON_MSG_LINE
+#define UL_BUILD_BUG_ON_MSG_LINE(condition, msg, line) \
+  ((void)sizeof(char[1 - 2*!!(condition)]))
+#endif /*UL_BUILD_BUG_ON_MSG*/
+
+#ifndef UL_BUILD_BUG_ON_MSG
+#define UL_BUILD_BUG_ON_MSG(condition, msg) \
+  UL_BUILD_BUG_ON_MSG_LINE(condition, msg, __LINE__)
+#endif /*UL_BUILD_BUG_ON_MSG*/
+
+#ifndef UL_BUILD_BUG_ON
+#define UL_BUILD_BUG_ON(condition) \
+  UL_BUILD_BUG_ON_MSG(condition, "Build time check " #condition " failed")
+#endif /*UL_BUILD_BUG_ON*/
+
+#if !defined(UL_OFFSETOF) && defined(__GNUC__) && __GNUC__ >= 4
+#define UL_OFFSETOF(_type, _member) __builtin_offsetof(_type, _member)
+#endif /*UL_OFFSETOF*/
+
 #ifndef UL_OFFSETOF
 /* offset of structure field */
 #define UL_OFFSETOF(_type,_member) \
@@ -34,27 +66,35 @@ extern "C" {
 #endif /*__GNUC__*/
 #endif /*UL_CONTAINEROF*/
 
+#ifndef UL_NOPSTATEMENT
+#define UL_NOPSTATEMENT do { } while(0)
+#endif
+
 #ifndef ul_cyclic_gt
 #define ul_cyclic_gt(x,y) \
        ((sizeof(x)>=sizeof(long long))&&(sizeof(y)>=sizeof(long long))? \
-               (long long)((long long)(x)-(long long)(y))>0: \
+               (long long)((unsigned long long)(x)-(unsigned long long)(y))>0: \
         (sizeof(x)>=sizeof(long))&&(sizeof(y)>=sizeof(long))? \
-               (long)((long)(x)-(long)(y))>0: /* x,y casts to suppress warnings only*/ \
-        (sizeof(x)>=sizeof(int))&&(sizeof(y)>=sizeof(int))?(int)((x)-(y))>0: \
-        (sizeof(x)>=sizeof(short))&&(sizeof(y)>=sizeof(short))?(short)((x)-(y))>0: \
-        (signed char)((x)-(y))>0 \
+               (long)((unsigned long)(x)-(unsigned long)(y))>0: \
+        (sizeof(x)>=sizeof(int))&&(sizeof(y)>=sizeof(int))? \
+               (int)((unsigned int)(x)-(unsigned int)(y))>0: \
+        (sizeof(x)>=sizeof(short))&&(sizeof(y)>=sizeof(short))? \
+               (short)((unsigned short)(x)-(unsigned short)(y))>0: \
+        (signed char)((unsigned char)(x)-(unsigned char)(y))>0 \
        )
 #endif /*ul_cyclic_gt*/
 
 #ifndef ul_cyclic_ge
 #define ul_cyclic_ge(x,y) \
        ((sizeof(x)>=sizeof(long long))&&(sizeof(y)>=sizeof(long long))? \
-               (long long)((long long)(x)-(long long)(y))>=0: \
+               (long long)((unsigned long long)(x)-(unsigned long long)(y))>=0: \
         (sizeof(x)>=sizeof(long))&&(sizeof(y)>=sizeof(long))? \
-               (long)((long)(x)-(long)(y))>=0: /* x,y casts to suppress warnings only*/ \
-        (sizeof(x)>=sizeof(int))&&(sizeof(y)>=sizeof(int))?(int)((x)-(y))>=0: \
-        (sizeof(x)>=sizeof(short))&&(sizeof(y)>=sizeof(short))?(short)((x)-(y))>=0: \
-        (signed char)((x)-(y))>=0 \
+               (long)((unsigned long)(x)-(unsigned long)(y))>=0: \
+        (sizeof(x)>=sizeof(int))&&(sizeof(y)>=sizeof(int))? \
+               (int)((unsigned int)(x)-(unsigned int)(y))>=0: \
+        (sizeof(x)>=sizeof(short))&&(sizeof(y)>=sizeof(short))? \
+               (short)((unsigned short)(x)-(unsigned short)(y))>=0: \
+        (signed char)((unsigned char)(x)-(unsigned char)(y))>=0 \
        )
 #endif /*ul_cyclic_ge*/
 
@@ -74,6 +114,14 @@ extern "C" {
   __attribute__((const))
 #define        UL_ATTR_UNUSED                          \
   __attribute__((unused))
+#define UL_ATTR_CONSTRUCTOR                    \
+  __attribute__((constructor))
+#define        UL_ATTR_DESCRUCTOR                      \
+  __attribute__((destructor))
+#define        UL_ATTR_ALWAYS_INLINE                   \
+  __attribute__((always_inline))
+#define        UL_ATTR_WEAK                            \
+  __attribute__((weak))
 #endif  /*UL_ATTR_UNUSED*/
 #else  /* !__GNUC__ */
 #ifndef UL_ATTR_UNUSED
@@ -83,9 +131,46 @@ extern "C" {
 #define UL_ATTR_NORETURN
 #define UL_ATTR_CONST
 #define UL_ATTR_UNUSED
+#define        UL_ATTR_CONSTRUCTOR
+#define        UL_ATTR_DESCRUCTOR
+#define        UL_ATTR_ALWAYS_INLINE
+#define UL_ATTR_WEAK
 #endif  /*UL_ATTR_UNUSED*/
 #endif /* !__GNUC__ */
 
+#ifndef UL_ATTR_REENTRANT
+#if (!defined(SDCC) && !defined(__SDCC)) || defined(SDCC_z80) || defined(__SDCC_z80)
+  #define UL_ATTR_REENTRANT
+#else
+  #define UL_ATTR_REENTRANT __reentrant
+#endif
+#endif /*UL_ATTR_REENTRANT*/
+
+/* The cast idea based on libHX by Jan Engelhardt */
+#define UL_TYPEOF_REFX(ref_asterisks, ptr_type) \
+  typeof(ref_asterisks(union { int z; typeof(ptr_type) x; }){0}.x)
+
+#ifdef __GNUC__
+#define UL_CAST_UNQX(ref_asterisks, new_type, expr) ({ \
+  UL_BUILD_BUG_ON_MSG(!__builtin_types_compatible_p\
+    (UL_TYPEOF_REFX(ref_asterisks, expr), \
+     UL_TYPEOF_REFX(ref_asterisks,new_type)), \
+       "Qualifiers stripping cast to incompatible type"); \
+  (new_type)(expr); \
+})
+#else /*__GNUC__*/
+#define UL_CAST_UNQX(ref_asterisks, new_type, expr) ((new_type)(expr))
+#endif /*__GNUC__*/
+
+#define UL_CAST_UNQ1(new_type, expr) \
+  UL_CAST_UNQX(*, new_type, expr)
+
+#define UL_CAST_UNQ2(new_type, expr) \
+  UL_CAST_UNQX(**, new_type, expr)
+
+#define UL_CAST_UNQ3(new_type, expr) \
+  UL_CAST_UNQX(**, new_type, expr)
+
 #ifdef __cplusplus
 } /* extern "C"*/
 #endif
diff --git a/orte/include/ul_utmalloc.h b/orte/include/ul_utmalloc.h
new file mode 100644 (file)
index 0000000..cad9c7f
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef _UL_UTMALLOC_H
+#define _UL_UTMALLOC_H
+
+#if !defined(__RTL__)&&!defined(__KERNEL__)
+
+#include <malloc.h>
+
+#else /*__RTL__ or __KERNEL__*/
+
+#ifdef UL_WITH_RTL_MALLOC
+#include <rtl_malloc.h>
+#define malloc    rt_malloc
+#define free      rt_free
+#define realloc   rt_realloc
+#endif /*UL_WITH_RTL_MALLOC*/
+
+#endif /*__RTL__ or __KERNEL__*/
+
+#endif /*_UL_UTMALLOC_H*/
index 90ba3fc24176bab7623617a99d9e3181b2a92695..94cb319d5e322e5970966f7860d78612036b1bc6 100644 (file)
 
  *******************************************************************/
 
-#include <orte_all.h>
-//#include <string.h>
-//#include "ul_utmalloc.h"
-
+#include <string.h>
+#include "ul_utmalloc.h"
 #include "ul_gavl.h"
 
 int 
@@ -123,7 +121,7 @@ gavl_search_node(const gavl_root_t *root, const void *key,
       break;
     }
   }
-  if(mode&GAVL_FAFTER){
+  if((mode&GAVL_FAFTER)&&!(mode&GAVL_FCMP)){
     if(cmp<=0)
       if(p) p=gavl_next_node(p);
     *nodep=p;
@@ -264,7 +262,7 @@ gavl_insert(gavl_root_t *root, void *item, int mode)
                        (mode|GAVL_FCMP), &where);
   if((mode!=GAVL_FAFTER) && !cmp) return -1;
   if(root->node_offs<0){
-    n2add=MALLOC(sizeof(gavl_node_t)+sizeof(void*));
+    n2add=malloc(sizeof(gavl_node_t)+sizeof(void*));
     if(!n2add) return -1;
     *(void**)(n2add+1)=item;
   } else {
@@ -321,7 +319,7 @@ gavl_delete(gavl_root_t *root, void *item)
   /* delete_primitive called directly for speedup */
   ret=gavl_delete_primitive(&root->root_node, n);
   if(root->node_offs<0)
-    FREE(n);
+    free(n);
   return ret;
 }
 
@@ -380,21 +378,21 @@ gavl_delete_and_next_node(gavl_root_t *root, gavl_node_t *node)
 /*===========================================================*/
 /* basic types compare functions */
 
-int gavl_cmp_int(const void *a, const void *b)
+int gavl_cmp_int(const void *a, const void *b) UL_ATTR_REENTRANT
 {
   if (*(int*)a>*(int*)b) return 1;
   if (*(int*)a<*(int*)b) return -1;
   return 0;
 }
 
-int gavl_cmp_long(const void *a, const void *b)
+int gavl_cmp_long(const void *a, const void *b) UL_ATTR_REENTRANT
 {
   if (*(long*)a>*(long*)b) return 1;
   if (*(long*)a<*(long*)b) return -1;
   return 0;
 }
 
-int gavl_cmp_ptr(const void *a, const void *b)
+int gavl_cmp_ptr(const void *a, const void *b) UL_ATTR_REENTRANT
 {
   if (*(void**)a>*(void**)b) return 1;
   if (*(void**)a<*(void**)b) return -1;
@@ -592,7 +590,7 @@ gavl_cut_first(gavl_root_t *root)
     return NULL;
   item=gavl_node2item(root,n);
   if(root->node_offs<0)
-    FREE(n);
+    free(n);
   return item;
 }
 
index 1abd18de4df761d4902bd77ebf27f479b0a25f8a..491ecd7b9f37fcb46e602246b0c162475487f21b 100644 (file)
@@ -21,8 +21,7 @@
 
  *******************************************************************/
 
-//#include <string.h>
-#include <orte_all.h>
+#include <string.h>
 #include "ul_gavl.h"
 
 int 
@@ -78,6 +77,10 @@ gavl_prev_node(const gavl_node_t *node)
   }
 }
 
+#if defined(SDCC) || defined(__SDCC)
+#pragma save
+#pragma nogcse
+#endif /*SDCC*/
 /**
  * gavl_balance_one - Balance One Node to Enhance Balance Factor
  * @subtree:   pointer to pointer to node for which balance is enhanced
@@ -214,6 +217,9 @@ gavl_balance_one(gavl_node_t **subtree)
   /*printf("#%d",ret);*/
   return(ret);
 }
+#if defined(SDCC) || defined(__SDCC)
+#pragma restore
+#endif /*SDCC*/
 
 /**
  * gavl_insert_primitive_at - Low Lewel Routine to Insert Node into Tree