]> git.sur5r.net Git - openocd/commitdiff
Don Porges fixed c99 issues.
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 9 Apr 2008 05:55:23 +0000 (05:55 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Wed, 9 Apr 2008 05:55:23 +0000 (05:55 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@553 b42882b7-edfa-0310-969c-e2dbd0fdcd60

14 files changed:
configure.in
src/helper/command.c
src/helper/log.c
src/helper/replacements.c
src/helper/replacements.h
src/helper/time_support.c
src/helper/time_support.h
src/jtag/amt_jtagaccel.c
src/jtag/bitbang.c
src/jtag/bitq.c
src/jtag/ft2232.c
src/jtag/gw16012.c
src/jtag/jtag.c
src/jtag/presto.c

index f2351fa00c4cb8a7fe2331ded60dd846b89175d0..8c5a21028fd20fccdb20362ac37718804c80593c 100644 (file)
@@ -7,9 +7,14 @@ AC_CANONICAL_HOST
 
 AC_CHECK_HEADERS(jtag_minidriver.h)
 AC_CHECK_HEADERS(sys/param.h)
+AC_CHECK_HEADERS(sys/time.h)
 AC_CHECK_HEADERS(elf.h)
+AC_CHECK_HEADERS(strings.h)
+
+AC_HEADER_TIME
 
 AC_C_BIGENDIAN
+AC_C_VARARRAYS
 
 AC_CHECK_FUNCS(strndup)
 AC_CHECK_FUNCS(strnlen)
index ef5673336f026746880f1302e4feb6e1f7acb864..ec7cc6bb7cd2e962d2f9b95ddcd0cc39ae6629eb 100644 (file)
@@ -142,10 +142,10 @@ command_t* register_command(command_context_t *context, command_t *parent, char
 
 int unregister_command(command_context_t *context, char *name)
 {
-       unique_length_dirty = 1;
-       
        command_t *c, *p = NULL, *c2;
        
+       unique_length_dirty = 1;
+       
        if ((!context) || (!name))
                return ERROR_INVALID_ARGUMENTS;
        
@@ -452,7 +452,11 @@ int command_run_file(command_context_t *context, FILE *file, enum command_mode m
 void command_print_help_line(command_context_t* context, struct command_s *command, int indent)
 {
        command_t *c;
+       #ifdef HAVE_C_VARRAYS
        char indent_text[indent + 2];
+       #else
+       char indent_text[68];
+       #endif
        char *help = "no help available";
        char name_buf[64];
        
@@ -578,12 +582,13 @@ int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **ar
 
 int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
-       if (argc<1)
-               return ERROR_COMMAND_SYNTAX_ERROR;
-       
        duration_t duration;
        char *duration_text;
        int retval;
+       float t;
+       
+       if (argc<1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
        
        duration_start_measure(&duration);
        
@@ -591,7 +596,7 @@ int handle_time_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
        
        duration_stop_measure(&duration, &duration_text);
        
-       float t=duration.duration.tv_sec;
+       t=duration.duration.tv_sec;
        t+=((float)duration.duration.tv_usec / 1000000.0);
        command_print(cmd_ctx, "%s took %fs", args[0], t);
        
index d0f0e3ddb4ba615727a72c82c0bb34d450850af0..34e73b6a2a826680f158b409894ec691bceea514 100644 (file)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdarg.h>
-#include <time.h>
 
 int debug_level = -1;
 
@@ -61,6 +60,7 @@ static int count = 0;
  */
 static void log_puts(enum log_levels level, const char *file, int line, const char *function, const char *string)
 {
+       char *f;
        if (level == LOG_LVL_OUTPUT)
        {
                /* do not prepend any headers, just print out what we were given and return */
@@ -69,7 +69,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
                return;
        }
 
-       char *f = strrchr(file, '/');
+       f = strrchr(file, '/');
        if (f != NULL)
                file = f + 1;
 
@@ -112,12 +112,12 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch
 void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
 {
        char *string;
+       va_list ap;
 
        count++;
        if (level > debug_level)
                return;
 
-       va_list ap;
        va_start(ap, format);
 
        string = alloc_vprintf(format, ap);
@@ -133,12 +133,12 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f
 void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
 {
        char *string;
+       va_list ap;
 
        count++;
        if (level > debug_level)
                return;
        
-       va_list ap;
        va_start(ap, format);
        
        string = alloc_vprintf(format, ap);
@@ -276,6 +276,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
        for (;;)
        {
                char *t = string;
+               va_list ap_copy;
+               int ret;
                string = realloc(string, size);
                if (string == NULL)
                {
@@ -284,10 +286,8 @@ char *alloc_vprintf(const char *fmt, va_list ap)
                        return NULL;
                }
 
-               va_list ap_copy;
                va_copy(ap_copy, ap);
 
-               int ret;
                ret = vsnprintf(string, size, fmt, ap_copy);
                /* NB! The result of the vsnprintf() might be an *EMPTY* string! */
                if ((ret >= 0) && ((ret + 1) < size))
index 7a6729b8129f6938243f9f39022c2a4227453209..bebca28e22c9224c7a457bdf3937feb94bfa931f 100644 (file)
@@ -25,7 +25,9 @@
 
 #include <stdlib.h>
 #include <string.h>
+#ifdef HAVE_STRINGS_H
 #include <strings.h>
+#endif
 /* 
  * clear_malloc
  *
index 4df7601244013de95d1e1a7baa081e722fff0b82..71e4c66ca1c11ec2ede038c91b8629c5f73fb71a 100644 (file)
@@ -187,7 +187,7 @@ static __inline int close_socket(int sock)
 static __inline void socket_nonblock(int fd)
 {
 #ifdef _WIN32
-       long nonblock = 1;
+       unsigned long nonblock = 1;
        ioctlsocket(fd, FIONBIO, &nonblock );
 #else
        int oldopts = fcntl(fd, F_GETFL, 0);
index 267746145f895636ea66ae0ac3eca753b3fc3f4e..e97993be6a298d6db98b5f6c8634c3d1cb643c01 100644 (file)
@@ -26,8 +26,6 @@
 #include "log.h"
 
 #include <stdlib.h>
-#include <sys/time.h>
-#include <time.h>
 
 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
 int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
index 05dc91190a2a802c99deab20e51aafe771ca7fee..311c88d32e8fd655b3dae9046d2d0fba7b7ab1de 100644 (file)
 #ifndef TIME_SUPPORT_H
 #define TIME_SUPPORT_H
 
-#include <sys/time.h>
-#include <time.h>
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
 
 extern int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
 extern int timeval_add(struct timeval *result, struct timeval *x, struct timeval *y);
index 1a34073a4645f1315e02b185154d282871746172..b94b6f7605ef8dc51f0a74e65319bf6afae0b7ab 100644 (file)
@@ -34,9 +34,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <sys/time.h>
-#include <time.h>
-
 #if PARPORT_USE_PPDEV == 1
 #include <linux/parport.h>
 #include <linux/ppdev.h>
index f79d2af7248c74010fabd5ac39c60b13cb6a62dd..79f77b5624bb4ea3b636acb3dbe6c9c001679bb3 100644 (file)
@@ -34,9 +34,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <sys/time.h>
-#include <time.h>
-
 bitbang_interface_t *bitbang_interface;
 
 int bitbang_execute_queue(void);
index e2a243fbf386f9a1b8011c60a514144a03cb58e8..93bb30638beee9fe248526ae9729cf227b432d8a 100644 (file)
@@ -34,9 +34,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <sys/time.h>
-#include <time.h>
-
 
 bitq_interface_t *bitq_interface; /* low level bit queue interface */
 
index 20824bbbd51e1675f25d3ed3c8bc3cbbfffae125..2740c3be124da0c942aecc00a45bf50b24c96787 100644 (file)
@@ -46,9 +46,6 @@
 #include <ftdi.h>
 #endif
 
-#include <sys/time.h>
-#include <time.h>
-
 /* enable this to debug io latency
  */
 #if 0
@@ -455,11 +452,11 @@ void ft2232_add_pathmove(pathmove_command_t *cmd)
        state_count = 0;
        while (num_states)
        {
-               tms_byte = 0x0;
                int bit_count = 0;
                
                int num_states_batch = num_states > 7 ? 7 : num_states;
 
+               tms_byte = 0x0;
                /* command "Clock Data to TMS/CS Pin (no Read)" */
                BUFFER_ADD = 0x4b;
                /* number of states remaining */
index 8caaba63f7a6fd3b6b7b0a86375766ee60c2a526..8c7dc81b97f4be0fb10eb70fcaee712838a10e00 100644 (file)
@@ -50,9 +50,6 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <sys/time.h>
-#include <time.h>
-
 #if PARPORT_USE_PPDEV == 1
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <dev/ppbus/ppi.h>
index 291c40107c791e4e6c9b5298c9be8bbc2445ed2a..b177c8e2434d9f41b2ea7b0d9348b9b1084bc035 100644 (file)
@@ -361,6 +361,7 @@ void* cmd_queue_alloc(size_t size)
 {
        cmd_queue_page_t **p_page = &cmd_queue_pages;
        int offset;
+       u8 *t;
 
        if (*p_page)
        {
@@ -381,7 +382,7 @@ void* cmd_queue_alloc(size_t size)
        offset = (*p_page)->used;
        (*p_page)->used += size;
        
-       u8 *t=(u8 *)((*p_page)->address);
+       t=(u8 *)((*p_page)->address);
        return t + offset;
 }
 
@@ -425,9 +426,11 @@ static void jtag_prelude(enum tap_state state)
 
 void jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
 {
+       int retval;
+       
        jtag_prelude(state);
        
-       int retval=interface_jtag_add_ir_scan(num_fields, fields, cmd_queue_end_state);
+       retval=interface_jtag_add_ir_scan(num_fields, fields, cmd_queue_end_state);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -511,9 +514,11 @@ int MINIDRIVER(interface_jtag_add_ir_scan)(int num_fields, scan_field_t *fields,
 
 void jtag_add_plain_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state)
 {
+       int retval;
+       
        jtag_prelude(state);
        
-       int retval=interface_jtag_add_plain_ir_scan(num_fields, fields, cmd_queue_end_state);
+       retval=interface_jtag_add_plain_ir_scan(num_fields, fields, cmd_queue_end_state);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -557,9 +562,11 @@ int MINIDRIVER(interface_jtag_add_plain_ir_scan)(int num_fields, scan_field_t *f
 
 void jtag_add_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
 {
+       int retval;
+       
        jtag_prelude(state);
 
-       int retval=interface_jtag_add_dr_scan(num_fields, fields, cmd_queue_end_state);
+       retval=interface_jtag_add_dr_scan(num_fields, fields, cmd_queue_end_state);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -742,9 +749,11 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num,
 
 void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
 {
+       int retval;
+       
        jtag_prelude(state);
 
-       int retval=interface_jtag_add_plain_dr_scan(num_fields, fields, cmd_queue_end_state);
+       retval=interface_jtag_add_plain_dr_scan(num_fields, fields, cmd_queue_end_state);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -815,6 +824,10 @@ int MINIDRIVER(interface_jtag_add_tlr)()
 
 void jtag_add_pathmove(int num_states, enum tap_state *path)
 {
+       enum tap_state cur_state=cmd_queue_cur_state;
+       int i;
+       int retval;
+
        /* the last state has to be a stable state */
        if (tap_move_map[path[num_states - 1]] == -1)
        {
@@ -822,8 +835,6 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
                exit(-1);
        }
 
-       enum tap_state cur_state=cmd_queue_cur_state;
-       int i;
        for (i=0; i<num_states; i++)
        {
                if ((tap_transitions[cur_state].low != path[i])&&
@@ -839,7 +850,7 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
        
        cmd_queue_cur_state = path[num_states - 1];
 
-       int retval=interface_jtag_add_pathmove(num_states, path);
+       retval=interface_jtag_add_pathmove(num_states, path);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -885,10 +896,12 @@ int MINIDRIVER(interface_jtag_add_runtest)(int num_cycles, enum tap_state state)
 
 void jtag_add_runtest(int num_cycles, enum tap_state state)
 {
+       int retval;
+       
        jtag_prelude(state);
        
        /* executed by sw or hw fifo */
-       int retval=interface_jtag_add_runtest(num_cycles, cmd_queue_end_state);
+       retval=interface_jtag_add_runtest(num_cycles, cmd_queue_end_state);
        if (retval!=ERROR_OK)
                jtag_error=retval;
 }
@@ -1275,6 +1288,8 @@ void jtag_sleep(u32 us)
        usleep(us);
 }
 
+int cwvx_device_num = -1, cwvx_version_num, cwvx_part_num;
+
 /* Try to examine chain layout according to IEEE 1149.1 ยง12
  */
 int jtag_examine_chain()
@@ -1355,6 +1370,13 @@ int jtag_examine_chain()
                        LOG_INFO("JTAG device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)", 
                                idcode, manufacturer, part, version);
                        
+                       /* Total hacky hack!    PORGES */
+                       if (manufacturer == 0x1a2) {
+                           cwvx_device_num = device_count-1;
+                           cwvx_part_num = part;
+                           cwvx_version_num = version;
+                       }
+                       
                        bit_count += 32;
                }
        }
index d9661fc41f6afb1bc15760920d847aaca3c9836a..aa82f4133c4e0bacc656505da62f555fc63c6004 100644 (file)
@@ -40,9 +40,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 
-#include <sys/time.h>
-#include <time.h>
-
 /* PRESTO access library includes */
 #if BUILD_PRESTO_FTD2XX == 1
 #include <ftd2xx.h>