Merge branch 'avrdudes:main' into main

This commit is contained in:
Dawid Buchwald 2022-01-08 19:44:20 +01:00 committed by GitHub
commit a8de8b8b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 17 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ INSTALL
Makefile.in Makefile.in
Makefile Makefile
ac_cfg.h.in ac_cfg.h.in
ac_cfg.h.in~
aclocal.m4 aclocal.m4
autom4te.cache autom4te.cache
configure configure

1
NEWS
View File

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

View File

@ -299,7 +299,7 @@ endif()
if(NOT WIN32) if(NOT WIN32)
set(LIB_MATH m) set(LIB_MATH m)
#add_compile_options(-Wall -Wextra -pedantic) add_compile_options(-Wall) # -Wextra
endif() endif()
if(MSVC) if(MSVC)

View File

@ -103,11 +103,28 @@ avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p)
#define TPI_PARITY_MASK 0x2000 #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 static uint16_t
tpi_byte2frame(uint8_t byte) tpi_byte2frame(uint8_t byte)
{ {
uint16_t frame = 0xc00f; uint16_t frame = 0xc00f;
int parity = __builtin_popcount(byte) & 1; int parity = count1s(byte) & 1;
frame |= ((byte << 5) & 0x1fe0); frame |= ((byte << 5) & 0x1fe0);
@ -123,7 +140,7 @@ tpi_frame2byte(uint16_t frame, uint8_t * byte)
/* drop idle and start bit(s) */ /* drop idle and start bit(s) */
*byte = (frame >> 5) & 0xff; *byte = (frame >> 5) & 0xff;
int parity = __builtin_popcount(*byte) & 1; int parity = count1s(*byte) & 1;
int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0; int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0;
return parity != parity_rcvd; return parity != parity_rcvd;

View File

@ -21,7 +21,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <io.h> #include <io.h>
#include <intrin.h>
#include <malloc.h> #include <malloc.h>
#pragma comment(lib, "advapi32.lib") #pragma comment(lib, "advapi32.lib")
@ -35,19 +34,6 @@
#define setvbuf msvc_setvbuf #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( static inline int msvc_setvbuf(
FILE* const public_stream, FILE* const public_stream,
char* const buffer, char* const buffer,