Merge pull request #145 from riscv/rbb_win

Fix Windows build
update_defines
Tim Newsome 2017-12-21 14:04:33 -08:00 committed by GitHub
commit b01075eaa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 8 deletions

View File

@ -4,11 +4,16 @@ dist: trusty
matrix: matrix:
include: include:
- os: linux - os: linux
env: BUILD=x86_64-linux-gnu env:
- BUILD=x86_64-linux-gnu
- EXECUTABLE=openocd
compiler: gcc compiler: gcc
- os: linux - os: linux
env: BUILD=i686-linux-gnu CFLAGS=-m32 env:
- BUILD=i686-linux-gnu
- CFLAGS=-m32
- EXECUTABLE=openocd
addons: addons:
apt: apt:
packages: packages:
@ -16,17 +21,33 @@ matrix:
compiler: gcc compiler: gcc
- os: linux - os: linux
env: BUILD=x86_64-linux-gnu env:
- BUILD=x86_64-linux-gnu
- EXECUTABLE=openocd
compiler: clang compiler: clang
- os: linux - os: linux
env: BUILD=i686-linux-gnu CFLAGS=-m32 env:
- BUILD=i686-linux-gnu
- CFLAGS=-m32
- EXECUTABLE=openocd
compiler: clang compiler: clang
addons: addons:
apt: apt:
packages: packages:
- gcc-multilib - 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: script:
- ./bootstrap && ./configure --enable-remote-bitbang --enable-jtag_vpi && make - ./bootstrap && ./configure --enable-remote-bitbang --enable-jtag_vpi $CONFIGURE_ARGS && make
- file src/openocd - file src/$EXECUTABLE

View File

@ -199,6 +199,17 @@ static inline int close_socket(int sock)
#endif #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) static inline void socket_nonblock(int fd)
{ {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -59,7 +59,7 @@ static int remote_bitbang_buf_full(void)
/* Read any incoming data, placing it into the buffer. */ /* Read any incoming data, placing it into the buffer. */
static void remote_bitbang_fill_buf(void) 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()) { while (!remote_bitbang_buf_full()) {
unsigned contiguous_available_space; unsigned contiguous_available_space;
if (remote_bitbang_end >= remote_bitbang_start) { if (remote_bitbang_end >= remote_bitbang_start) {
@ -148,7 +148,7 @@ static int remote_bitbang_rread(void)
} }
/* Enable blocking access. */ /* Enable blocking access. */
fcntl(remote_bitbang_fd, F_SETFL, 0); socket_block(remote_bitbang_fd);
char c; char c;
ssize_t count = read(remote_bitbang_fd, &c, 1); ssize_t count = read(remote_bitbang_fd, &c, 1);
if (count == 1) { if (count == 1) {