Use C89/C99/C++ compliant boolean types

git-svn-id: svn://svn.berlios.de/openocd/trunk@1370 b42882b7-edfa-0310-969c-e2dbd0fdcd60
This commit is contained in:
kc8apf 2009-02-10 18:21:17 +00:00
parent 725749de20
commit e77ae9096a
14 changed files with 54 additions and 30 deletions

View File

@ -11,6 +11,7 @@ AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(elf.h) AC_CHECK_HEADERS(elf.h)
AC_CHECK_HEADERS(strings.h) AC_CHECK_HEADERS(strings.h)
AC_CHECK_HEADERS(stdbool.h)
AC_HEADER_TIME AC_HEADER_TIME

View File

@ -45,6 +45,21 @@ typedef unsigned long long u64;
typedef struct jtag_tap_s jtag_tap_t; 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! /* DANGER!!!! here be dragons!
* *

View File

@ -112,11 +112,11 @@ void bitbang_path_move(pathmove_command_t *cmd)
state_count = 0; state_count = 0;
while (num_states) 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; 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; tms = 1;
} }

View File

@ -194,9 +194,9 @@ void bitq_path_move(pathmove_command_t* cmd)
for (i = 0; i<=cmd->num_states; i++) 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); 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); bitq_io(1, 0, 0);
else else
{ {

View File

@ -562,9 +562,9 @@ void ft2232_add_pathmove(pathmove_command_t* cmd)
while (num_states_batch--) 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); 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); buf_set_u32(&tms_byte, bit_count++, 1, 0x1);
else else
{ {

View File

@ -230,11 +230,11 @@ void gw16012_path_move(pathmove_command_t *cmd)
while (num_states) while (num_states)
{ {
gw16012_control(0x0); /* single-bit mode */ 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 */ 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 */ gw16012_data(0x2); /* TCK cycle with TMS high */
} }

View File

@ -366,11 +366,11 @@ void jlink_path_move(int num_states, tap_state_t *path)
for (i = 0; i < num_states; i++) 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); 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); jlink_tap_append_step(1, 0);
} }

View 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"); LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
exit(-1); exit(-1);
} }
if ( tap_state_transition(cur_state, 1) != path[i] if ( tap_state_transition(cur_state, true) != path[i]
&& tap_state_transition(cur_state, 0) != 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])); LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state), tap_state_name(path[i]));
exit(-1); exit(-1);
@ -2920,6 +2920,7 @@ void jtag_tap_handle_event( jtag_tap_t * tap, enum jtag_tap_event e)
} }
} }
/*-----<Cable Helper API>---------------------------------------*/ /*-----<Cable Helper API>---------------------------------------*/
/* these Cable Helper API functions are all documented in the jtag.h header file, /* 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; return end_state_follower;
} }
int tap_move_ndx( tap_state_t astate ) 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() */ /* 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; return ndx;
} }
int tap_get_tms_path( tap_state_t from, tap_state_t to ) 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 /* 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)]; 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 /* A switch() is used because it is symbol dependent
(not value dependent like an array), and can also check bounds. (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_DRPAUSE:
case TAP_IRSHIFT: case TAP_IRSHIFT:
case TAP_IRPAUSE: case TAP_IRPAUSE:
is_stable = 1; is_stable = true;
break; break;
default: default:
is_stable = 0; is_stable = false;
} }
return is_stable; 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; tap_state_t new_state;

View File

@ -29,6 +29,7 @@
#include "command.h" #include "command.h"
#if 0 #if 0
#define _DEBUG_JTAG_IO_ #define _DEBUG_JTAG_IO_
#endif #endif
@ -37,6 +38,7 @@
#define DEBUG_JTAG_IOZ 64 #define DEBUG_JTAG_IOZ 64
#endif #endif
/* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf /* 16 Tap States, from page 21 of ASSET InterTech, Inc.'s svf.pdf
*/ */
enum tap_state { enum tap_state {
@ -57,6 +59,7 @@ typedef struct tap_transition_s
//extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */ //extern tap_transition_t tap_transitions[16]; /* describe the TAP state diagram */
/*-----<Cable Helper API>-------------------------------------------*/ /*-----<Cable Helper API>-------------------------------------------*/
/* The "Cable Helper API" is what the cable drivers can use to help implement /* 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 * 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 * 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. * @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. * @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 * Function tap_state_name
@ -168,6 +171,7 @@ const char* tap_state_name(tap_state_t state);
/*-----</Cable Helper API>------------------------------------------*/ /*-----</Cable Helper API>------------------------------------------*/
extern tap_state_t cmd_queue_end_state; /* finish DR scans in dr_end_state */ 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 */ extern tap_state_t cmd_queue_cur_state; /* current TAP state */

View File

@ -927,11 +927,11 @@ void rlink_path_move(pathmove_command_t *cmd)
state_count = 0; state_count = 0;
while (num_states) 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; 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; tms = 1;
} }

View File

@ -268,13 +268,13 @@ void usbprog_path_move(pathmove_command_t *cmd)
state_count = 0; state_count = 0;
while (num_states) 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"); */ /* LOG_INFO("1"); */
usbprog_write(0, 0, 0); usbprog_write(0, 0, 0);
usbprog_write(1, 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"); */ /* LOG_INFO("2"); */
usbprog_write(0, 1, 0); usbprog_write(0, 1, 0);

View 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; 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); 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 // nothing to do
} }

View File

@ -764,11 +764,11 @@ int interface_jtag_add_pathmove(int num_states, tap_state_t *path)
while (num_states) 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; 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; tms = 1;
} }

View File

@ -201,11 +201,11 @@ static void xsvf_add_statemove(tap_state_t state)
int j = (move >> i) & 1; int j = (move >> i) & 1;
if (j) if (j)
{ {
curstate = tap_state_transition(curstate, TRUE); curstate = tap_state_transition(curstate, true);
} }
else else
{ {
curstate = tap_state_transition(curstate, FALSE); curstate = tap_state_transition(curstate, false);
} }
moves[i] = curstate; moves[i] = curstate;
} }