From 21d7fc58b664a08e1f7856fc9dc8a2a0076d83bf Mon Sep 17 00:00:00 2001
From: Marius Greuel <greuelm@mgtek.com>
Date: Fri, 7 Jan 2022 23:56:58 +0100
Subject: [PATCH 1/4] Add -Wall to CMake compiler options

---
 src/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0048bf7c..8fbb21d7 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -299,7 +299,7 @@ endif()
 
 if(NOT WIN32)
     set(LIB_MATH m)
-    #add_compile_options(-Wall -Wextra -pedantic)
+    add_compile_options(-Wall) # -Wextra
 endif()
 
 if(MSVC)

From d2ae6a824fe9ba71b527f4ba1dc783c351a63b15 Mon Sep 17 00:00:00 2001
From: Marius Greuel <greuelm@mgtek.com>
Date: Sat, 8 Jan 2022 16:08:35 +0100
Subject: [PATCH 2/4] Add C code alternative to __builtin_popcount.

---
 src/avrftdi_tpi.c      | 21 +++++++++++++++++++--
 src/msvc/msvc_compat.h | 14 --------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/avrftdi_tpi.c b/src/avrftdi_tpi.c
index d82444e8..efb56266 100644
--- a/src/avrftdi_tpi.c
+++ b/src/avrftdi_tpi.c
@@ -103,11 +103,28 @@ avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p)
 
 #define TPI_PARITY_MASK 0x2000
 
+static inline int count1s(unsigned int x)
+{
+#if defined(__GNUC__)
+	return __builtin_popcount(x);
+#else
+	int count = 0;
+
+	while (x)
+	{
+		count += x & 1;
+		x >>= 1;
+	}
+
+	return count;
+#endif
+}
+
 static uint16_t
 tpi_byte2frame(uint8_t byte)
 {
 	uint16_t frame = 0xc00f;
-	int parity = __builtin_popcount(byte) & 1;
+	int parity = count1s(byte) & 1;
 
 	frame |= ((byte << 5) & 0x1fe0);
 
@@ -123,7 +140,7 @@ tpi_frame2byte(uint16_t frame, uint8_t * byte)
 	/* drop idle and start bit(s) */
 	*byte = (frame >> 5) & 0xff;
 
-	int parity = __builtin_popcount(*byte) & 1;
+	int parity = count1s(*byte) & 1;
 	int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0;
 
 	return parity != parity_rcvd;
diff --git a/src/msvc/msvc_compat.h b/src/msvc/msvc_compat.h
index bfc44a6f..eb3e026a 100644
--- a/src/msvc/msvc_compat.h
+++ b/src/msvc/msvc_compat.h
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <stdlib.h>
 #include <io.h>
-#include <intrin.h> 
 #include <malloc.h> 
 
 #pragma comment(lib, "advapi32.lib")
@@ -35,19 +34,6 @@
 
 #define setvbuf msvc_setvbuf
 
-static inline int __builtin_popcount(unsigned int v)
-{
-    int count = 0;
-
-    while (v)
-    {
-        count += v & 1;
-        v >>= 1;
-    }
-
-    return count;
-}
-
 static inline int msvc_setvbuf(
     FILE* const public_stream,
     char* const buffer,

From b13c61893b6b33097ddbce440cd5fb61e85af3ce Mon Sep 17 00:00:00 2001
From: Yegor Yefremov <yegorslists@googlemail.com>
Date: Sat, 8 Jan 2022 18:05:47 +0100
Subject: [PATCH 3/4] Ignore ac_cfg.h.in~

Ignore temporary ac_cfg.h.in~ file.
---
 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 60305807..70fcb545 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,7 @@ INSTALL
 Makefile.in
 Makefile
 ac_cfg.h.in
+ac_cfg.h.in~
 aclocal.m4
 autom4te.cache
 configure

From e3338c428ffa8791df704344600e3df157102e52 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Sat, 8 Jan 2022 18:27:48 +0100
Subject: [PATCH 4/4] Add PR #810

---
 NEWS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/NEWS b/NEWS
index 65265d4e..d3687459 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,7 @@ Changes since version 6.4:
     - Fix typos all over the code #807
     - Add MSVC builds and better WinUSB/FTDI support #798
     - buspirate: fix invalidScanfArgType_int warning #808
+    - Ignore ac_cfg.h.in~ #810
 
   * Internals: