Browse Source

Replace elist.h with uthash.h for scan_devices string list

Luke Dashjr 12 years ago
parent
commit
6be60216bb
3 changed files with 14 additions and 12 deletions
  1. 5 3
      fpgautils.c
  2. 1 3
      miner.c
  3. 8 6
      miner.h

+ 5 - 3
fpgautils.c

@@ -39,6 +39,8 @@
 #include <windows.h>
 #include <windows.h>
 #include <io.h>
 #include <io.h>
 
 
+#include "utlist.h"
+
 #define dlsym (void*)GetProcAddress
 #define dlsym (void*)GetProcAddress
 #define dlclose FreeLibrary
 #define dlclose FreeLibrary
 
 
@@ -363,7 +365,7 @@ int _serial_detect(struct device_drv *api, detectone_func_t detectone, autoscan_
 	size_t namel = strlen(api->name);
 	size_t namel = strlen(api->name);
 	size_t dnamel = strlen(api->dname);
 	size_t dnamel = strlen(api->dname);
 
 
-	list_for_each_entry_safe(iter, tmp, &scan_devices, list) {
+	DL_FOREACH_SAFE(scan_devices, iter, tmp) {
 		dev = iter->string;
 		dev = iter->string;
 		if ((colon = strchr(dev, ':')) && colon[1] != '\0') {
 		if ((colon = strchr(dev, ':')) && colon[1] != '\0') {
 			size_t idlen = colon - dev;
 			size_t idlen = colon - dev;
@@ -392,10 +394,10 @@ int _serial_detect(struct device_drv *api, detectone_func_t detectone, autoscan_
 		if (serial_claim(dev, NULL))
 		if (serial_claim(dev, NULL))
 		{
 		{
 			applog(LOG_DEBUG, "%s is already claimed... skipping probes", dev);
 			applog(LOG_DEBUG, "%s is already claimed... skipping probes", dev);
-			string_elist_del(iter);
+			string_elist_del(&scan_devices, iter);
 		}
 		}
 		else if (detectone(dev)) {
 		else if (detectone(dev)) {
-			string_elist_del(iter);
+			string_elist_del(&scan_devices, iter);
 			inhibitauto = true;
 			inhibitauto = true;
 			++found;
 			++found;
 		}
 		}

+ 1 - 3
miner.c

@@ -152,7 +152,7 @@ static char detect_algo;
 bool opt_restart = true;
 bool opt_restart = true;
 static bool opt_nogpu;
 static bool opt_nogpu;
 
 
-struct list_head scan_devices;
+struct string_elist *scan_devices;
 bool opt_force_dev_init;
 bool opt_force_dev_init;
 static signed int devices_enabled;
 static signed int devices_enabled;
 static bool opt_removedisabled;
 static bool opt_removedisabled;
@@ -8506,8 +8506,6 @@ int main(int argc, char *argv[])
 	HASH_ADD_STR(blocks, hash, block);
 	HASH_ADD_STR(blocks, hash, block);
 	strcpy(current_block, block->hash);
 	strcpy(current_block, block->hash);
 
 
-	INIT_LIST_HEAD(&scan_devices);
-
 	mutex_init(&submitting_lock);
 	mutex_init(&submitting_lock);
 	INIT_LIST_HEAD(&submit_waiting);
 	INIT_LIST_HEAD(&submit_waiting);
 
 

+ 8 - 6
miner.h

@@ -39,6 +39,7 @@
 #include "uthash.h"
 #include "uthash.h"
 #include "logging.h"
 #include "logging.h"
 #include "util.h"
 #include "util.h"
+#include "utlist.h"
 
 
 #ifdef HAVE_OPENCL
 #ifdef HAVE_OPENCL
 #include "CL/cl.h"
 #include "CL/cl.h"
@@ -627,24 +628,25 @@ struct string_elist {
 	char *string;
 	char *string;
 	bool free_me;
 	bool free_me;
 
 
-	struct list_head list;
+	struct string_elist *prev;
+	struct string_elist *next;
 };
 };
 
 
-static inline void string_elist_add(const char *s, struct list_head *head)
+static inline void string_elist_add(const char *s, struct string_elist **head)
 {
 {
 	struct string_elist *n;
 	struct string_elist *n;
 
 
 	n = calloc(1, sizeof(*n));
 	n = calloc(1, sizeof(*n));
 	n->string = strdup(s);
 	n->string = strdup(s);
 	n->free_me = true;
 	n->free_me = true;
-	list_add_tail(&n->list, head);
+	DL_APPEND(*head, n);
 }
 }
 
 
-static inline void string_elist_del(struct string_elist *item)
+static inline void string_elist_del(struct string_elist **head, struct string_elist *item)
 {
 {
 	if (item->free_me)
 	if (item->free_me)
 		free(item->string);
 		free(item->string);
-	list_del(&item->list);
+	DL_DELETE(*head, item);
 	free(item);
 	free(item);
 }
 }
 
 
@@ -936,7 +938,7 @@ extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user
 #define _MAX_INTENSITY_STR "14"
 #define _MAX_INTENSITY_STR "14"
 #endif
 #endif
 
 
-extern struct list_head scan_devices;
+extern struct string_elist *scan_devices;
 extern bool opt_force_dev_init;
 extern bool opt_force_dev_init;
 extern int nDevs;
 extern int nDevs;
 extern int opt_n_threads;
 extern int opt_n_threads;