> How about this patch. this also works.
>
> Is it acceptable ?
I change the code.
this is more readable.
--------
Hiroshi Ito
Media Lab. Inc.,
URL http://www.mlb.co.jp ( Sorry, Japanese only. )
TEL +81-3-5294-7255 FAX +81-3-5294-7256
Index: src/jtag/jtag.c
===================================================================
--- src/jtag/jtag.c (リビジョン 1183)
+++ src/jtag/jtag.c (作業コピー)
@@ -401,6 +401,21 @@
return t + offset;
}
+void cmd_queue_make_align(void)
+{
+ cmd_queue_page_t *p_page = cmd_queue_pages;
+ if (!p_page) return;
+
+ while (p_page->next)
+ p_page = p_page->next;
+
+ if ( p_page->used & (sizeof(void*)-1) ) {
+ p_page->used += sizeof(void*) - (p_page->used & (sizeof(void*)-1));
+ if ( p_page->used >= CMD_QUEUE_PAGE_SIZE )
+ p_page->used = CMD_QUEUE_PAGE_SIZE;
+ }
+}
+
void cmd_queue_free(void)
{
cmd_queue_page_t *page = cmd_queue_pages;
@@ -461,6 +476,7 @@
last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
(*last_cmd)->next = NULL;
last_comand_pointer = &((*last_cmd)->next);
@@ -470,7 +486,7 @@
(*last_cmd)->cmd.scan = cmd_queue_alloc(sizeof(scan_command_t));
(*last_cmd)->cmd.scan->ir_scan = 1;
(*last_cmd)->cmd.scan->num_fields = jtag_num_devices; /* one field
per device */
- (*last_cmd)->cmd.scan->fields = cmd_queue_alloc(jtag_num_devices *
sizeof(scan_field_t));
+ (*last_cmd)->cmd.scan->fields = cmd_queue_alloc(jtag_num_devices *
sizeof(scan_field_t) );
(*last_cmd)->cmd.scan->end_state = state;
for (i = 0; i < jtag_num_devices; i++)
@@ -550,6 +566,7 @@
last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
(*last_cmd)->next = NULL;
last_comand_pointer = &((*last_cmd)->next);
@@ -614,6 +631,7 @@
}
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
last_comand_pointer = &((*last_cmd)->next);
(*last_cmd)->next = NULL;
@@ -704,16 +722,17 @@
}
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
last_comand_pointer = &((*last_cmd)->next);
(*last_cmd)->next = NULL;
(*last_cmd)->type = JTAG_SCAN;
/* allocate memory for dr scan command */
- (*last_cmd)->cmd.scan = cmd_queue_alloc(sizeof(scan_command_t));
+ (*last_cmd)->cmd.scan = cmd_queue_alloc(sizeof(scan_command_t) );
(*last_cmd)->cmd.scan->ir_scan = 0;
(*last_cmd)->cmd.scan->num_fields = num_fields + bypass_devices;
- (*last_cmd)->cmd.scan->fields = cmd_queue_alloc((num_fields +
bypass_devices) * sizeof(scan_field_t));
+ (*last_cmd)->cmd.scan->fields = cmd_queue_alloc((num_fields +
bypass_devices) * sizeof(scan_field_t) );
(*last_cmd)->cmd.scan->end_state = end_state;
for (i = 0; i < jtag_num_devices; i++)
@@ -785,6 +804,7 @@
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
last_comand_pointer = &((*last_cmd)->next);
(*last_cmd)->next = NULL;
@@ -831,12 +851,13 @@
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
last_comand_pointer = &((*last_cmd)->next);
(*last_cmd)->next = NULL;
(*last_cmd)->type = JTAG_STATEMOVE;
- (*last_cmd)->cmd.statemove =
cmd_queue_alloc(sizeof(statemove_command_t));
+ (*last_cmd)->cmd.statemove =
cmd_queue_alloc(sizeof(statemove_command_t) );
(*last_cmd)->cmd.statemove->end_state = state;
@@ -887,6 +908,7 @@
int i;
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
last_comand_pointer = &((*last_cmd)->next);
(*last_cmd)->next = NULL;
@@ -907,6 +929,7 @@
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
(*last_cmd)->next = NULL;
last_comand_pointer = &((*last_cmd)->next);
@@ -1039,6 +1062,7 @@
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
(*last_cmd)->next = NULL;
last_comand_pointer = &((*last_cmd)->next);
@@ -1065,6 +1089,7 @@
jtag_command_t **last_cmd = jtag_get_last_command_p();
/* allocate memory for a new list member */
+ cmd_queue_make_align();
*last_cmd = cmd_queue_alloc(sizeof(jtag_command_t));
(*last_cmd)->next = NULL;
last_comand_pointer = &((*last_cmd)->next);
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development