From 4efcddea7f7a57c72f0d88c9dad5cdf084f6d157 Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Mon, 23 Feb 2009 22:04:57 +0000
Subject: [PATCH] More fixes for Solaris, including fixes for the Sunpro
 compiler: * avr.h: Remove stray semicolon. * configure.ac: Add check for
 predefined types uint_t and ulong_t. * confwin.c: Include "avrdude.h" on top
 to avoid empty translation unit warning. * ppwin.c: (Ditto.) * ser_win32.c:
 (Ditto.) * serbb_win32.c: (Ditto.) * jtagmkII.c (jtagmkII_recv): remove
 unreachable "return". * stk500.c (stk500_initialize): (Ditto.) * par.c: Test
 for both, __sun__ and __sun to see whether we are being compiled on Solaris.
 * ppi.c: (Ditto.) * stk500v2.c: Implement the DEBUG and DEBUGRECV macros in a
 way that is compatible with the ISO C99 standard. * usbtiny.c: Only typedef
 uint_t and ulong_t if they have not been found already by the autoconf
 checks.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@804 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog     | 20 ++++++++++++++++++++
 avr.h         |  2 +-
 configure.ac  |  7 +++++++
 confwin.c     |  1 +
 jtagmkII.c    |  1 -
 par.c         |  2 +-
 ppi.c         |  2 +-
 ppiwin.c      |  2 +-
 ser_win32.c   |  3 ++-
 serbb_win32.c |  3 ++-
 stk500.c      |  1 -
 stk500v2.c    |  8 ++++----
 usbtiny.c     |  4 ++++
 13 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2b5d6e6b..7df811f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2009-02-23  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	More fixes for Solaris, including fixes for the Sunpro compiler:
+	* avr.h: Remove stray semicolon.
+	* configure.ac: Add check for predefined types uint_t and ulong_t.
+	* confwin.c: Include "avrdude.h" on top to avoid empty translation
+	unit warning.
+	* ppwin.c: (Ditto.)
+	* ser_win32.c: (Ditto.)
+	* serbb_win32.c: (Ditto.)
+	* jtagmkII.c (jtagmkII_recv): remove unreachable "return".
+	* stk500.c (stk500_initialize): (Ditto.)
+	* par.c: Test for both, __sun__ and __sun to see whether we are
+	being compiled on Solaris.
+	* ppi.c: (Ditto.)
+	* stk500v2.c: Implement the DEBUG and DEBUGRECV macros in a way
+	that is compatible with the ISO C99 standard.
+	* usbtiny.c: Only typedef uint_t and ulong_t if they have not
+	been found already by the autoconf checks.
+
 2009-02-23  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	bug #22204: Solaris10/11 Undefiniertes Symbol gethostbyname socket
diff --git a/avr.h b/avr.h
index 15b979ce..9be67ce1 100644
--- a/avr.h
+++ b/avr.h
@@ -61,7 +61,7 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size);
 
 int avr_get_cycle_count(PROGRAMMER * pgm, AVRPART * p, int * cycles);
 
-int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles);;
+int avr_put_cycle_count(PROGRAMMER * pgm, AVRPART * p, int cycles);
 
 int avr_mem_hiaddr(AVRMEM * mem);
 
diff --git a/configure.ac b/configure.ac
index 515e53a5..411b55c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,13 @@ fi
 LIBS="${SAVED_LIBS}"
 AC_SUBST(LIBHID, $LIBHID)
 
+# Check for types
+
+# Solaris has uint_t and ulong_t typedefs in <sys/types.h>, avoid
+# the redeclaration in usbtiny.c.
+AC_CHECK_TYPES([uint_t], [], [], [#include <sys/types.h>])
+AC_CHECK_TYPES([ulong_t], [], [], [#include <sys/types.h>])
+
 # Checks for misc stuff.
 
 AC_ARG_ENABLE(
diff --git a/confwin.c b/confwin.c
index 1496c682..0ae373ae 100644
--- a/confwin.c
+++ b/confwin.c
@@ -18,6 +18,7 @@
  */
 
 
+#include "avrdude.h"
 
 #if defined(WIN32NATIVE)
 
diff --git a/jtagmkII.c b/jtagmkII.c
index 30743b5d..15160af1 100644
--- a/jtagmkII.c
+++ b/jtagmkII.c
@@ -595,7 +595,6 @@ int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg) {
     }
     free(*msg);
   }
-  return 0;
 }
 
 
diff --git a/par.c b/par.c
index caf0ee9a..1aa3e2c8 100644
--- a/par.c
+++ b/par.c
@@ -32,7 +32,7 @@
 # include "freebsd_ppi.h"
 #elif defined(__linux__)
 # include "linux_ppdev.h"
-#elif defined(__sun__) && defined(__svr4__) /* Solaris */
+#elif defined(__sun__) || defined(__sun) /* Solaris */
 # include "solaris_ecpp.h"
 #endif
 
diff --git a/ppi.c b/ppi.c
index ed50212b..4397d000 100644
--- a/ppi.c
+++ b/ppi.c
@@ -37,7 +37,7 @@
 # include "freebsd_ppi.h"
 #elif defined(__linux__)
 # include "linux_ppdev.h"
-#elif defined(__sun__) && defined(__svr4__) /* Solaris */
+#elif defined(__sun__) || defined(__sun) /* Solaris */
 # include "solaris_ecpp.h"
 #endif
 
diff --git a/ppiwin.c b/ppiwin.c
index 49c83e3f..f9c51b54 100644
--- a/ppiwin.c
+++ b/ppiwin.c
@@ -32,6 +32,7 @@ reg = register as defined in an enum in ppi.h. This must be converted
 
 
 #include "ac_cfg.h"
+#include "avrdude.h"
 
 #if defined (WIN32NATIVE)
 
@@ -45,7 +46,6 @@ reg = register as defined in an enum in ppi.h. This must be converted
 #include <sys/time.h>
 #include <windows.h>
 
-#include "avrdude.h"
 #include "serial.h"
 #include "ppi.h"
 
diff --git a/ser_win32.c b/ser_win32.c
index fdb49735..aa4cc34c 100644
--- a/ser_win32.c
+++ b/ser_win32.c
@@ -24,13 +24,14 @@
  * Native Win32 serial interface for avrdude.
  */
 
+#include "avrdude.h"
+
 #if defined(WIN32NATIVE)
 
 #include <windows.h>
 #include <stdio.h>
 #include <ctype.h>   /* for isprint */
 
-#include "avrdude.h"
 #include "serial.h"
 
 long serial_recv_timeout = 5000; /* ms */
diff --git a/serbb_win32.c b/serbb_win32.c
index a297f829..8c755210 100644
--- a/serbb_win32.c
+++ b/serbb_win32.c
@@ -24,6 +24,8 @@
  * Win32 serial bitbanging interface for avrdude.
  */
 
+#include "avrdude.h"
+
 #if defined(WIN32NATIVE)
 
 
@@ -32,7 +34,6 @@
 #include <windows.h>
 #include <stdio.h>
 
-#include "avrdude.h"
 #include "avr.h"
 #include "pindefs.h"
 #include "pgm.h"
diff --git a/stk500.c b/stk500.c
index 03ee5b83..fe8c9275 100644
--- a/stk500.c
+++ b/stk500.c
@@ -539,7 +539,6 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
     if (stk500_getsync(pgm) < 0)
       return -1;
     goto retry;
-    return -1;
   }
   else if (buf[0] != Resp_STK_INSYNC) {
     fprintf(stderr,
diff --git a/stk500v2.c b/stk500v2.c
index 145fdb8e..d0a7491d 100644
--- a/stk500v2.c
+++ b/stk500v2.c
@@ -70,15 +70,15 @@
 #define STK500V2_XTAL 7372800U
 
 #if 0
-#define DEBUG(format,args...) fprintf(stderr, format, ## args)
+#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
 #else
-#define DEBUG(format,args...)
+#define DEBUG(...)
 #endif
 
 #if 0
-#define DEBUGRECV(format,args...) fprintf(stderr, format, ## args)
+#define DEBUGRECV(...) fprintf(stderr, __VA_ARGS__)
 #else
-#define DEBUGRECV(format,args...)
+#define DEBUGRECV(...)
 #endif
 
 enum hvmode
diff --git a/usbtiny.c b/usbtiny.c
index 167e46a8..a2e15b0c 100644
--- a/usbtiny.c
+++ b/usbtiny.c
@@ -41,8 +41,12 @@
 #if defined(HAVE_LIBUSB)      // we use LIBUSB to talk to the board
 #include <usb.h>
 
+#ifndef HAVE_UINT_T
 typedef	unsigned int	uint_t;
+#endif
+#ifndef HAVE_ULONG_T
 typedef	unsigned long	ulong_t;
+#endif
 
 extern int avr_write_byte_default ( PROGRAMMER* pgm, AVRPART* p,
 				    AVRMEM* mem, ulong_t addr,