From 3624d5e5eb3810e1277b56f99d94242210cfc4d8 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 13 Dec 2017 14:23:05 -0800 Subject: [PATCH 1/2] Add win32 build to travis. Change-Id: I8ce62ff321c6f3627d42fff13236f7fc9440d429 --- .travis.yml | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index a99f743e0..2ec1ede93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,16 @@ dist: trusty matrix: include: - os: linux - env: BUILD=x86_64-linux-gnu + env: + - BUILD=x86_64-linux-gnu + - EXECUTABLE=openocd compiler: gcc - os: linux - env: BUILD=i686-linux-gnu CFLAGS=-m32 + env: + - BUILD=i686-linux-gnu + - CFLAGS=-m32 + - EXECUTABLE=openocd addons: apt: packages: @@ -16,17 +21,33 @@ matrix: compiler: gcc - os: linux - env: BUILD=x86_64-linux-gnu + env: + - BUILD=x86_64-linux-gnu + - EXECUTABLE=openocd compiler: clang - os: linux - env: BUILD=i686-linux-gnu CFLAGS=-m32 + env: + - BUILD=i686-linux-gnu + - CFLAGS=-m32 + - EXECUTABLE=openocd compiler: clang addons: apt: packages: - gcc-multilib + - os: linux + env: + - BUILD=i686-w64-mingw + - CONFIGURE_ARGS="--build=i686-unknown-linux-gnu --host=i686-w64-mingw32" + - EXECUTABLE=openocd.exe + compiler: i686-w64-mingw32-gcc + addons: + apt: + packages: + - binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 + script: - - ./bootstrap && ./configure --enable-remote-bitbang --enable-jtag_vpi && make - - file src/openocd + - ./bootstrap && ./configure --enable-remote-bitbang --enable-jtag_vpi $CONFIGURE_ARGS && make + - file src/$EXECUTABLE From 7eceac758ca08c3feeb77167ee2eb9829b1d93bc Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 13 Dec 2017 14:32:11 -0800 Subject: [PATCH 2/2] Use abstraction because Windows is not POSIX Fixes #138 Change-Id: I4d9b49762e318fe91f1561ed315829b43daefef4 --- src/helper/replacements.h | 11 +++++++++++ src/jtag/drivers/remote_bitbang.c | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 1e2fbf20f..f43b7e0f3 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -199,6 +199,17 @@ static inline int close_socket(int sock) #endif } +static inline void socket_block(int fd) +{ +#ifdef _WIN32 + unsigned long nonblock = 0; + ioctlsocket(fd, FIONBIO, &nonblock); +#else + int oldopts = fcntl(fd, F_GETFL, 0); + fcntl(fd, F_SETFL, oldopts & ~O_NONBLOCK); +#endif +} + static inline void socket_nonblock(int fd) { #ifdef _WIN32 diff --git a/src/jtag/drivers/remote_bitbang.c b/src/jtag/drivers/remote_bitbang.c index 5e78ccb45..4e1995c0c 100644 --- a/src/jtag/drivers/remote_bitbang.c +++ b/src/jtag/drivers/remote_bitbang.c @@ -59,7 +59,7 @@ static int remote_bitbang_buf_full(void) /* Read any incoming data, placing it into the buffer. */ static void remote_bitbang_fill_buf(void) { - fcntl(remote_bitbang_fd, F_SETFL, O_NONBLOCK); + socket_nonblock(remote_bitbang_fd); while (!remote_bitbang_buf_full()) { unsigned contiguous_available_space; if (remote_bitbang_end >= remote_bitbang_start) { @@ -148,7 +148,7 @@ static int remote_bitbang_rread(void) } /* Enable blocking access. */ - fcntl(remote_bitbang_fd, F_SETFL, 0); + socket_block(remote_bitbang_fd); char c; ssize_t count = read(remote_bitbang_fd, &c, 1); if (count == 1) {