Cleanup Cygwin builds.

* windows/Makefile.am (loaddrv_LDFLAGS): remove, the -mno-cygwin
flag is supposed to be set in CFLAGS by ./configure
* configure.ac: add a check for the presence of usleep(), add a
check whether the linker accepts -static
* avrdude.h: protect prototype for usleep by !defined(HAVE_USLEEP)
* ppwin.c (usleep): protect by !defined(HAVE_USLEEP)
* main.c: silence "array subscript of type char" compiler warnings
by casting all arguments to tolower()/toupper() and isspace()/
isdigit()/ispunct() to "int"
* butterfly.c: (Dito.)
* avr910.c: (Dito.)




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@936 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2010-01-22 16:40:17 +00:00
parent 1c4db09770
commit 83fa6c7934
9 changed files with 59 additions and 32 deletions

View File

@ -1,3 +1,18 @@
2010-01-22 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Cleanup Cygwin builds.
* windows/Makefile.am (loaddrv_LDFLAGS): remove, the -mno-cygwin
flag is supposed to be set in CFLAGS by ./configure
* configure.ac: add a check for the presence of usleep(), add a
check whether the linker accepts -static
* avrdude.h: protect prototype for usleep by !defined(HAVE_USLEEP)
* ppwin.c (usleep): protect by !defined(HAVE_USLEEP)
* main.c: silence "array subscript of type char" compiler warnings
by casting all arguments to tolower()/toupper() and isspace()/
isdigit()/ispunct() to "int"
* butterfly.c: (Dito.)
* avr910.c: (Dito.)
2010-01-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2010-01-19 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: Bump for post-5.10. * configure.ac: Bump for post-5.10.

View File

@ -624,7 +624,7 @@ static int avr910_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd = malloc(4 + blocksize); cmd = malloc(4 + blocksize);
if (!cmd) rval = -1; if (!cmd) rval = -1;
cmd[0] = 'B'; cmd[0] = 'B';
cmd[3] = toupper(m->desc[0]); cmd[3] = toupper((int)(m->desc[0]));
while (addr < max_addr) { while (addr < max_addr) {
if ((max_addr - addr) < blocksize) { if ((max_addr - addr) < blocksize) {
@ -714,7 +714,7 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int blocksize = PDATA(pgm)->buffersize; int blocksize = PDATA(pgm)->buffersize;
cmd[0] = 'g'; cmd[0] = 'g';
cmd[3] = toupper(m->desc[0]); cmd[3] = toupper((int)(m->desc[0]));
avr910_set_addr(pgm, addr); avr910_set_addr(pgm, addr);

View File

@ -39,14 +39,9 @@ extern int quell_progress; /* quiteness level (-q, -qq) */
extern "C" { extern "C" {
#endif #endif
/* usleep replacements */ #if !defined(HAVE_USLEEP)
/* sleep Windows in ms, Unix usleep in us
#define usleep(us) Sleep((us)<20000?20:us/1000)
#define usleep(us) Sleep(us/1000)
#define ANTIWARP 3
#define usleep(us) Sleep(us/1000*ANTIWARP)
*/
int usleep(unsigned int us); int usleep(unsigned int us);
#endif
#if !defined(HAVE_GETTIMEOFDAY) #if !defined(HAVE_GETTIMEOFDAY)
struct timezone; struct timezone;

View File

@ -423,7 +423,7 @@ static int butterfly_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
{ {
cmd[0] = 'B'; cmd[0] = 'B';
cmd[1] = 0; cmd[1] = 0;
if ((cmd[3] = toupper(m->desc[0])) == 'E') { /* write to eeprom */ if ((cmd[3] = toupper((int)(m->desc[0]))) == 'E') { /* write to eeprom */
cmd[2] = 1; cmd[2] = 1;
cmd[4] = value; cmd[4] = value;
size = 5; size = 5;
@ -572,7 +572,7 @@ static int butterfly_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd = malloc(4+blocksize); cmd = malloc(4+blocksize);
if (!cmd) return -1; if (!cmd) return -1;
cmd[0] = 'B'; cmd[0] = 'B';
cmd[3] = toupper(m->desc[0]); cmd[3] = toupper((int)(m->desc[0]));
while (addr < max_addr) { while (addr < max_addr) {
if ((max_addr - addr) < blocksize) { if ((max_addr - addr) < blocksize) {
@ -613,7 +613,7 @@ static int butterfly_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int blocksize = PDATA(pgm)->buffersize; int blocksize = PDATA(pgm)->buffersize;
cmd[0] = 'g'; cmd[0] = 'g';
cmd[3] = toupper(m->desc[0]); cmd[3] = toupper((int)(m->desc[0]));
if (use_ext_addr) { if (use_ext_addr) {
butterfly_set_extaddr(pgm, addr); butterfly_set_extaddr(pgm, addr);

View File

@ -77,7 +77,7 @@ AC_C_CONST
AC_HEADER_TIME AC_HEADER_TIME
# Checks for library functions. # Checks for library functions.
AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday]) AC_CHECK_FUNCS([memset select strcasecmp strdup strerror strncasecmp strtol strtoul gettimeofday usleep])
AC_MSG_CHECKING([for a Win32 HID libray]) AC_MSG_CHECKING([for a Win32 HID libray])
SAVED_LIBS="${LIBS}" SAVED_LIBS="${LIBS}"
@ -273,7 +273,7 @@ case $target in
# does this compiler support -mno-cygwin? # does this compiler support -mno-cygwin?
AC_MSG_CHECKING([if $CC accepts -mno-cygwin]) AC_MSG_CHECKING([if $CC accepts -mno-cygwin])
safe_CFLAGS=$CFLAGS safe_CFLAGS="$CFLAGS"
CFLAGS="$ENABLE_WARNINGS -mno-cygwin" CFLAGS="$ENABLE_WARNINGS -mno-cygwin"
AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [
@ -283,7 +283,7 @@ case $target in
no_cygwin=no no_cygwin=no
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
]) ])
CFLAGS=$safe_CFLAGS CFLAGS="$safe_CFLAGS"
if test x$no_cygwin = xyes; then if test x$no_cygwin = xyes; then
CFLAGS="${CFLAGS} -mno-cygwin" CFLAGS="${CFLAGS} -mno-cygwin"
@ -295,9 +295,26 @@ case $target in
AC_MSG_NOTICE([]) AC_MSG_NOTICE([])
fi fi
fi fi
AC_MSG_CHECKING([if linker accepts -static])
safe_LDFLAGS="$LDFLAGS"
LDFLAGS="${LDFLAGS} -static"
AC_TRY_LINK(, [ int main () { return 0 ; } ], [
can_link_static=yes
AC_MSG_RESULT([yes])
], [
can_link_static_cygwin=no
AC_MSG_RESULT([no])
])
LDFLAGS="$safe_LDFLAGS"
if test x$can_link_static = xyes; then
LDFLAGS="${LDFLAGS} -static"
fi
WINDOWS_DIRS="windows" WINDOWS_DIRS="windows"
CFLAGS="${CFLAGS} -DWIN32NATIVE" CFLAGS="${CFLAGS} -DWIN32NATIVE"
LDFLAGS="${LDFLAGS} -static"
;; ;;
esac esac
AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS) AC_SUBST(WINDOWS_DIRS,$WINDOWS_DIRS)

8
main.c
View File

@ -1131,7 +1131,7 @@ int main(int argc, char * argv [])
else else
safemode_response = yes; safemode_response = yes;
if (tolower(safemode_response[0]) == 'y') { if (tolower((int)(safemode_response[0])) == 'y') {
/* Enough chit-chat, time to program some fuses and check them */ /* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_fuse, "fuse", pgm, p, if (safemode_writefuse (safemode_fuse, "fuse", pgm, p,
@ -1159,7 +1159,7 @@ int main(int argc, char * argv [])
else else
safemode_response = yes; safemode_response = yes;
if (tolower(safemode_response[0]) == 'y') { if (tolower((int)(safemode_response[0])) == 'y') {
/* Enough chit-chat, time to program some fuses and check them */ /* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p, if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p,
@ -1184,7 +1184,7 @@ int main(int argc, char * argv [])
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
else else
safemode_response = yes; safemode_response = yes;
if (tolower(safemode_response[0]) == 'y') { if (tolower((int)(safemode_response[0])) == 'y') {
/* Enough chit-chat, time to program some fuses and check them */ /* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p, if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p,
@ -1209,7 +1209,7 @@ int main(int argc, char * argv [])
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] "); safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
else else
safemode_response = yes; safemode_response = yes;
if (tolower(safemode_response[0]) == 'y') { if (tolower((int)(safemode_response[0])) == 'y') {
/* Enough chit-chat, time to program some fuses and check them */ /* Enough chit-chat, time to program some fuses and check them */
if (safemode_writefuse (safemode_efuse, "efuse", pgm, p, if (safemode_writefuse (safemode_efuse, "efuse", pgm, p,

View File

@ -374,6 +374,7 @@ int gettimeofday(struct timeval *tv, struct timezone *unused){
#endif #endif
#if !defined(HAVE_USLEEP)
int usleep(unsigned int us) int usleep(unsigned int us)
{ {
int has_highperf; int has_highperf;
@ -384,7 +385,7 @@ int usleep(unsigned int us)
// verify - increasing the delay helps sometimes but not // verify - increasing the delay helps sometimes but not
// realiably. There must be some other problem. Maybe just // realiably. There must be some other problem. Maybe just
// with my test-hardware maybe in the code-base. // with my test-hardware maybe in the code-base.
//// us=(unsigned long) (us*1.5); //// us=(unsigned long) (us*1.5);
has_highperf=QueryPerformanceFrequency(&freq); has_highperf=QueryPerformanceFrequency(&freq);
@ -393,7 +394,7 @@ int usleep(unsigned int us)
if (has_highperf) { if (has_highperf) {
QueryPerformanceCounter(&start); QueryPerformanceCounter(&start);
loopend.QuadPart=start.QuadPart+freq.QuadPart*us/(1000*1000); loopend.QuadPart=start.QuadPart+freq.QuadPart*us/(1000*1000);
do { do {
QueryPerformanceCounter(&stop); QueryPerformanceCounter(&stop);
} while (stop.QuadPart<=loopend.QuadPart); } while (stop.QuadPart<=loopend.QuadPart);
} }
@ -405,11 +406,12 @@ int usleep(unsigned int us)
DEBUG_QueryPerformanceCounter(&stop); DEBUG_QueryPerformanceCounter(&stop);
} }
DEBUG_DisplayTimingInfo(start, stop, freq, us, has_highperf); DEBUG_DisplayTimingInfo(start, stop, freq, us, has_highperf);
return 0; return 0;
} }
#endif /* !HAVE_USLEEP */
#endif #endif

14
term.c
View File

@ -125,12 +125,12 @@ static int nexttok(char * buf, char ** tok, char ** next)
char * q, * n; char * q, * n;
q = buf; q = buf;
while (isspace(*q)) while (isspace((int)*q))
q++; q++;
/* isolate first token */ /* isolate first token */
n = q+1; n = q+1;
while (*n && !isspace(*n)) while (*n && !isspace((int)*n))
n++; n++;
if (*n) { if (*n) {
@ -139,7 +139,7 @@ static int nexttok(char * buf, char ** tok, char ** next)
} }
/* find start of next token */ /* find start of next token */
while (isspace(*n)) while (isspace((int)*n))
n++; n++;
*tok = q; *tok = q;
@ -189,9 +189,9 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
for (i=0; i<n; i++) { for (i=0; i<n; i++) {
memcpy(b, p, n); memcpy(b, p, n);
buffer[i] = '.'; buffer[i] = '.';
if (isalpha(b[i]) || isdigit(b[i]) || ispunct(b[i])) if (isalpha((int)(b[i])) || isdigit((int)(b[i])) || ispunct((int)(b[i])))
buffer[i] = b[i]; buffer[i] = b[i];
else if (isspace(b[i])) else if (isspace((int)(b[i])))
buffer[i] = ' '; buffer[i] = ' ';
} }
@ -909,7 +909,7 @@ int terminal_mode(PROGRAMMER * pgm, struct avrpart * p)
* find the start of the command, skipping any white space * find the start of the command, skipping any white space
*/ */
q = cmdbuf; q = cmdbuf;
while (*q && isspace(*q)) while (*q && isspace((int)*q))
q++; q++;
/* skip blank lines and comments */ /* skip blank lines and comments */

View File

@ -37,8 +37,6 @@ EXTRA_DIST = \
bin_PROGRAMS = loaddrv bin_PROGRAMS = loaddrv
loaddrv_LDFLAGS = -mno-cygwin
loaddrv_SOURCES = \ loaddrv_SOURCES = \
loaddrv.c \ loaddrv.c \
loaddrv.h loaddrv.h