Merge branch 'master' of github.com:ckolivas/cgminer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
diff --git a/api-example.c b/api-example.c
index 13b8f2d..9bd4479 100644
--- a/api-example.c
+++ b/api-example.c
@@ -145,6 +145,7 @@
static const char SEPARATOR = '|';
static const char COMMA = ',';
static const char EQ = '=';
+static int ONLY = 0;
void display(char *buf)
{
@@ -242,9 +243,12 @@ int callapi(char *command, char *host, short int port)
buf[p] = '\0';
}
- printf("Reply was '%s'\n", buf);
-
- display(buf);
+ if (ONLY)
+ printf("%s\n", buf);
+ else {
+ printf("Reply was '%s'\n", buf);
+ display(buf);
+ }
}
CLOSESOCKET(sock);
@@ -274,6 +278,7 @@ int main(int argc, char *argv[])
char *host = "127.0.0.1";
short int port = 4028;
char *ptr;
+ int i = 1;
if (argc > 1)
if (strcmp(argv[1], "-?") == 0
@@ -283,20 +288,26 @@ int main(int argc, char *argv[])
return 1;
}
- if (argc > 1) {
- ptr = trim(argv[1]);
+ if (argc > 1)
+ if (strcmp(argv[1], "-o") == 0) {
+ ONLY = 1;
+ i = 2;
+ }
+
+ if (argc > i) {
+ ptr = trim(argv[i++]);
if (strlen(ptr) > 0)
command = ptr;
}
- if (argc > 2) {
- ptr = trim(argv[2]);
+ if (argc > i) {
+ ptr = trim(argv[i++]);
if (strlen(ptr) > 0)
host = ptr;
}
- if (argc > 3) {
- ptr = trim(argv[3]);
+ if (argc > i) {
+ ptr = trim(argv[i]);
if (strlen(ptr) > 0)
port = atoi(ptr);
}
diff --git a/cgminer.c b/cgminer.c
index 7a98837..3bf285f 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -5786,28 +5786,12 @@ struct work *get_queued(struct cgpu_info *cgpu)
return ret;
}
-/* This function is for including work in the given que hashtable.
- * The calling function must lock access to the que if it is required. */
-struct work *add_to_work_que(struct work *que, struct work *work)
-{
- HASH_ADD_INT(que, id, work);
- return que;
-}
-
-/* This function is for removing work from the given que hashtable.
- * The calling function must lock access to the que if it is required. */
-struct work *del_from_work_que(struct work *que, struct work *work)
-{
- HASH_DEL(que, work);
- return que;
-}
-
/* This function is for finding an already queued work item in the
* given que hashtable. Code using this function must be able
* to handle NULL as a return which implies there is no matching work.
* The calling function must lock access to the que if it is required.
* The common values for midstatelen, offset, datalen are 32, 64, 12 */
-struct work *find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen)
+struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen)
{
struct work *work, *tmp, *ret = NULL;
@@ -5832,7 +5816,7 @@ struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate,
struct work *ret;
rd_lock(&cgpu->qlock);
- ret = find_work_bymidstate(cgpu->queued_work, midstate, midstatelen, data, offset, datalen);
+ ret = __find_work_bymidstate(cgpu->queued_work, midstate, midstatelen, data, offset, datalen);
rd_unlock(&cgpu->qlock);
return ret;
diff --git a/miner.h b/miner.h
index 0595f94..04c8a46 100644
--- a/miner.h
+++ b/miner.h
@@ -1144,6 +1144,11 @@ struct work {
double work_difficulty;
+ // Allow devices to identify work if multiple sub-devices
+ int subid;
+ // Allow devices to flag work for their own purposes
+ bool devflag;
+
struct timeval tv_getwork;
struct timeval tv_getwork_reply;
struct timeval tv_cloned;
@@ -1183,9 +1188,7 @@ struct modminer_fpga_state {
extern void get_datestamp(char *, struct timeval *);
extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern struct work *get_queued(struct cgpu_info *cgpu);
-extern struct work *add_to_work_que(struct work *que, struct work *work);
-extern struct work *del_from_work_que(struct work *que, struct work *work);
-extern struct work *find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
+extern struct work *__find_work_bymidstate(struct work *que, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern struct work *find_queued_work_bymidstate(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern void work_completed(struct cgpu_info *cgpu, struct work *work);
extern void hash_queued_work(struct thr_info *mythr);