]> git.sur5r.net Git - openocd/commitdiff
Use C89/C99/C++ compliant boolean types
authorkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 10 Feb 2009 18:21:17 +0000 (18:21 +0000)
committerkc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 10 Feb 2009 18:21:17 +0000 (18:21 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1370 b42882b7-edfa-0310-969c-e2dbd0fdcd60

14 files changed:
configure.in
src/helper/types.h
src/jtag/bitbang.c
src/jtag/bitq.c
src/jtag/ft2232.c
src/jtag/gw16012.c
src/jtag/jlink.c
src/jtag/jtag.c
src/jtag/jtag.h
src/jtag/rlink/rlink.c
src/jtag/usbprog.c
src/jtag/vsllink.c
src/jtag/zy1000.c
src/xsvf/xsvf.c

index 792e6f8c7401bf33c2319699e8bf9a24d373fec4..e6c6473e41e255083d05cdf87e998f47df13d3ea 100644 (file)
@@ -11,6 +11,7 @@ AC_CHECK_HEADERS(sys/param.h)
 AC_CHECK_HEADERS(sys/time.h)
 AC_CHECK_HEADERS(elf.h)
 AC_CHECK_HEADERS(strings.h)
+AC_CHECK_HEADERS(stdbool.h)
 
 AC_HEADER_TIME
 
index 82368a9246aa8f399ceb90e9c65259a104ccd22d..047f76c2fda4c5970b8e8dd48e046aeeecefafc1 100644 (file)
@@ -45,6 +45,21 @@ typedef unsigned long long u64;
 
 typedef struct jtag_tap_s jtag_tap_t;
 
+#ifdef HAVE_STDBOOL_H
+#include <stdbool.h>
+#else  /* HAVE_STDBOOL_H */
+#define __bool_true_false_are_defined 1
+
+#ifndef __cplusplus
+
+#define false  0
+#define true           1
+
+#define bool           _Bool
+typedef int _Bool;
+#endif /* __cplusplus */
+
+#endif /* HAVE_STDBOOL_H */
 
 /* DANGER!!!! here be dragons!
  *
index 48bda0f4b8f7004c6468473b3a2ea8cbce4ae765..92ba6cc0aa755f5f1b87971e5403dbaf371de2fe 100644 (file)
@@ -112,11 +112,11 @@ void bitbang_path_move(pathmove_command_t *cmd)
        state_count = 0;
        while (num_states)
        {
-               if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+               if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                {
                        tms = 0;
                }
-               else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+               else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                {
                        tms = 1;
                }
index 392e3d3da9017e262abc75eb46e97869ff66c288..0d71c3018061ed9b033f7ddcf17745853b90e2ad 100644 (file)
@@ -194,9 +194,9 @@ void bitq_path_move(pathmove_command_t* cmd)
 
        for (i = 0; i<=cmd->num_states; i++)
        {
-               if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[i])
+               if (tap_state_transition(tap_get_state(), false) == cmd->path[i])
                        bitq_io(0, 0, 0);
-               else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[i])
+               else if (tap_state_transition(tap_get_state(), true) == cmd->path[i])
                        bitq_io(1, 0, 0);
                else
                {
index 9a3c986fecf6f70cb2944785dfd4bebbfb16fb82..115cd7c24d81a51c496d41cd5ee1b76e243e40a9 100644 (file)
@@ -562,9 +562,9 @@ void ft2232_add_pathmove(pathmove_command_t* cmd)
 
                while (num_states_batch--)
                {
-                       if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+                       if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                                buf_set_u32(&tms_byte, bit_count++, 1, 0x0);
-                       else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+                       else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                                buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
                        else
                        {
index 622c81f3286a16aae2d3ddbe9fbc0bccb2593a16..3d72aa27e4799d7e2a3b41dcf2c827e47eea08d0 100644 (file)
@@ -230,11 +230,11 @@ void gw16012_path_move(pathmove_command_t *cmd)
        while (num_states)
        {
                gw16012_control(0x0); /* single-bit mode */
-               if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+               if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                {
                        gw16012_data(0x0); /* TCK cycle with TMS low */
                }
-               else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+               else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                {
                        gw16012_data(0x2); /* TCK cycle with TMS high */
                }
index 26f9233008c1ab895afb60ebf43631385e96b601..bfd3a7803a6f40cd42ca1e9e3e3f0dc4ba15bda9 100644 (file)
@@ -366,11 +366,11 @@ void jlink_path_move(int num_states, tap_state_t *path)
 
        for (i = 0; i < num_states; i++)
        {
-               if (path[i] == tap_state_transition(tap_get_state(), FALSE))
+               if (path[i] == tap_state_transition(tap_get_state(), false))
                {
                        jlink_tap_append_step(0, 0);
                }
-               else if (path[i] == tap_state_transition(tap_get_state(), TRUE))
+               else if (path[i] == tap_state_transition(tap_get_state(), true))
                {
                        jlink_tap_append_step(1, 0);
                }
index b811cb7d5a58377f13770ddbd2e427348d80c181..ae51ebc16ce0114dfddb07800baff3ed56d7605a 100644 (file)
@@ -957,8 +957,8 @@ void jtag_add_pathmove(int num_states, tap_state_t *path)
                        LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
                        exit(-1);
                }
-               if ( tap_state_transition(cur_state, 1)  != path[i]
-                 && tap_state_transition(cur_state, 0) != path[i])
+               if ( tap_state_transition(cur_state, true)  != path[i]
+                 && tap_state_transition(cur_state, false) != path[i])
                {
                        LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i]));
                        exit(-1);
@@ -2920,6 +2920,7 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
        }
 }
 
+
 /*-----<Cable Helper API>---------------------------------------*/
 
 /*  these Cable Helper API functions are all documented in the jtag.h header file,
@@ -2964,6 +2965,7 @@ tap_state_t tap_get_end_state()
        return end_state_follower;
 }
 
+
 int tap_move_ndx( tap_state_t astate )
 {
        /* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */
@@ -2994,6 +2996,7 @@ int tap_move_ndx( tap_state_t astate )
        return ndx;
 }
 
+
 int tap_get_tms_path( tap_state_t from, tap_state_t to )
 {
        /* tap_move[i][j]: tap movement command to go from state i to state j
@@ -3035,9 +3038,10 @@ int tap_get_tms_path( tap_state_t from, tap_state_t to )
        return tms_seqs[tap_move_ndx(from)][tap_move_ndx(to)];
 }
 
-int tap_is_state_stable(tap_state_t astate)
+
+bool tap_is_state_stable(tap_state_t astate)
 {
-       int is_stable;
+       bool is_stable;
 
        /*      A switch() is used because it is symbol dependent
                (not value dependent like an array), and can also check bounds.
@@ -3050,16 +3054,16 @@ int tap_is_state_stable(tap_state_t astate)
        case TAP_DRPAUSE:
        case TAP_IRSHIFT:
        case TAP_IRPAUSE:
-               is_stable = 1;
+               is_stable = true;
                break;
        default:
-               is_stable = 0;
+               is_stable = false;
        }
 
        return is_stable;
 }
 
-tap_state_t tap_state_transition(tap_state_t cur_state, int tms)
+tap_state_t tap_state_transition(tap_state_t cur_state, bool tms)
 {
        tap_state_t new_state;
 
index 895afe1fb2ca5a4e5d46bf6201b571265b1c8b41..386d517e13510ab77c64268a1ef521c5310494b5 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "command.h"
 
+
 #if 0
 #define _DEBUG_JTAG_IO_
 #endif
@@ -37,6 +38,7 @@
 #define DEBUG_JTAG_IOZ 64
 #endif
 
+
 /* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
  */
 enum tap_state {
@@ -57,6 +59,7 @@ typedef struct tap_transition_s
 
 //extern tap_transition_t tap_transitions[16];    /* describe the TAP state diagram */
 
+
 /*-----<Cable Helper API>-------------------------------------------*/
 
 /* The "Cable Helper API" is what the cable drivers can use to help implement
@@ -147,9 +150,9 @@ int tap_move_ndx(tap_state_t astate);
 
 /**
  * Function tap_is_state_stable
- * returns TRUE if the \a astate is stable.
+ * returns true if the \a astate is stable.
  */
-int tap_is_state_stable(tap_state_t astate);
+bool tap_is_state_stable(tap_state_t astate);
 
 /**
  * Function tap_state_transition
@@ -158,7 +161,7 @@ int tap_is_state_stable(tap_state_t astate);
  * @param tms is either zero or non-zero, just like a real TMS line in a jtag interface.
  * @return tap_state_t - the next state a TAP would enter.
  */
-tap_state_t tap_state_transition(tap_state_t current_state, int tms);
+tap_state_t tap_state_transition(tap_state_t current_state, bool tms);
 
 /**
  * Function tap_state_name
@@ -168,6 +171,7 @@ const char* tap_state_name(tap_state_t state);
 
 /*-----</Cable Helper API>------------------------------------------*/
 
+
 extern tap_state_t cmd_queue_end_state;         /* finish DR scans in dr_end_state */
 extern tap_state_t cmd_queue_cur_state;         /* current TAP state */
 
index 80bd08afb5606a24785189bedef463ac72514729..380d451bbe9c8591db7328f29dc869dcd9cfea10 100644 (file)
@@ -927,11 +927,11 @@ void rlink_path_move(pathmove_command_t *cmd)
        state_count = 0;
        while (num_states)
        {
-               if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+               if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                {
                        tms = 0;
                }
-               else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+               else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                {
                        tms = 1;
                }
index 773f2977a4990d446cf090fe09a8bf8c9b1ef694..6c62afc114e871df89480f1d63f8d7f3b7e01736 100644 (file)
@@ -268,13 +268,13 @@ void usbprog_path_move(pathmove_command_t *cmd)
        state_count = 0;
        while (num_states)
        {
-               if (tap_state_transition(tap_get_state(), FALSE) == cmd->path[state_count])
+               if (tap_state_transition(tap_get_state(), false) == cmd->path[state_count])
                {
                        /* LOG_INFO("1"); */
                        usbprog_write(0, 0, 0);
                        usbprog_write(1, 0, 0);
                }
-               else if (tap_state_transition(tap_get_state(), TRUE) == cmd->path[state_count])
+               else if (tap_state_transition(tap_get_state(), true) == cmd->path[state_count])
                {
                        /* LOG_INFO("2"); */
                        usbprog_write(0, 1, 0);
index fd2b397ec145160383222af192d67cb91bdc38e1..8cf7e52ed618dc3255bf082faee114c269a27402 100644 (file)
@@ -634,11 +634,11 @@ void vsllink_add_path(int start, int num, tap_state_t *path)
                        vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0;
                }
 
-               if (path[i - start] == tap_state_transition(tap_get_state(), TRUE))
+               if (path[i - start] == tap_state_transition(tap_get_state(), true))
                {
                        vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7);
                }
-               else if (path[i - start] == tap_state_transition(tap_get_state(), FALSE))
+               else if (path[i - start] == tap_state_transition(tap_get_state(), false))
                {
                        // nothing to do
                }
index de13ba4d2c8bfd3ad44d42cbab8e8f2a77630ceb..a2c145730125191afd31a42be89101e64df90661 100644 (file)
@@ -764,11 +764,11 @@ int interface_jtag_add_pathmove(int num_states, tap_state_t *path)
 
        while (num_states)
        {
-               if (tap_state_transition(cur_state, FALSE) == path[state_count])
+               if (tap_state_transition(cur_state, false) == path[state_count])
                {
                        tms = 0;
                }
-               else if (tap_state_transition(cur_state, TRUE) == path[state_count])
+               else if (tap_state_transition(cur_state, true) == path[state_count])
                {
                        tms = 1;
                }
index 855021df75118ee59b54b9844caa06bd30d51743..e3153a3e03e34cea2641a33212130344746e8b1c 100644 (file)
@@ -201,11 +201,11 @@ static void xsvf_add_statemove(tap_state_t state)
                int j = (move >> i) & 1;
                if (j)
                {
-                       curstate = tap_state_transition(curstate, TRUE);
+                       curstate = tap_state_transition(curstate, true);
                }
                else
                {
-                       curstate = tap_state_transition(curstate, FALSE);
+                       curstate = tap_state_transition(curstate, false);
                }
                moves[i] = curstate;
        }