Browse Source

Bugfix: DevAPI: Update includes from uthash to utlist and support older versions of uthash

Luke Dashjr 10 years ago
parent
commit
a6b19235e6
2 changed files with 14 additions and 3 deletions
  1. 11 0
      deviceapi.c
  2. 3 3
      deviceapi.h

+ 11 - 0
deviceapi.c

@@ -25,6 +25,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <utlist.h>
+
 #include "compat.h"
 #include "deviceapi.h"
 #include "logging.h"
@@ -77,8 +79,17 @@ int sort_drv_by_priority(struct driver_registration * const a, struct driver_reg
 void bfg_devapi_init()
 {
 	_bfg_register_driver(NULL);
+#ifdef LL_SORT2
 	LL_SORT2(_bfg_drvreg1, sort_drv_by_dname, next_dname);
 	LL_SORT2(_bfg_drvreg2, sort_drv_by_priority, next_prio);
+#else
+	#define next next_dname
+	LL_SORT(_bfg_drvreg1, sort_drv_by_dname);
+	#undef next
+	#define next next_prio
+	LL_SORT(_bfg_drvreg2, sort_drv_by_priority);
+	#undef next
+#endif
 }
 
 

+ 3 - 3
deviceapi.h

@@ -5,7 +5,7 @@
 #include <stdint.h>
 #include <sys/time.h>
 
-#include <uthash.h>
+#include <utlist.h>
 
 #include "miner.h"
 
@@ -23,9 +23,9 @@ extern struct driver_registration *_bfg_drvreg2;
 extern void bfg_devapi_init();
 
 #define BFG_FOREACH_DRIVER_BY_DNAME(reg, tmp)  \
-	LL_FOREACH_SAFE2(_bfg_drvreg1, reg, tmp, next_dname)
+	LL_FOREACH2(_bfg_drvreg1, tmp=reg, next_dname)
 #define BFG_FOREACH_DRIVER_BY_PRIORITY(reg, tmp)  \
-	LL_FOREACH_SAFE2(_bfg_drvreg2, reg, tmp, next_prio)
+	LL_FOREACH2(_bfg_drvreg2, tmp=reg, next_prio)
 
 extern void _bfg_register_driver(const struct device_drv *);
 #define BFG_REGISTER_DRIVER(drv)                \