diff options
author | Tim Newsome <tim@sifive.com> | 2017-12-13 14:32:11 -0800 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2017-12-14 12:36:42 -0800 |
commit | 7eceac758ca08c3feeb77167ee2eb9829b1d93bc (patch) | |
tree | adc4be7b0fe852771b98dc209738263702a2c6d7 /src/helper | |
parent | 3624d5e5eb3810e1277b56f99d94242210cfc4d8 (diff) | |
download | riscv-openocd-7eceac758ca08c3feeb77167ee2eb9829b1d93bc.zip riscv-openocd-7eceac758ca08c3feeb77167ee2eb9829b1d93bc.tar.gz riscv-openocd-7eceac758ca08c3feeb77167ee2eb9829b1d93bc.tar.bz2 |
Use abstraction because Windows is not POSIX
Fixes #138
Change-Id: I4d9b49762e318fe91f1561ed315829b43daefef4
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/replacements.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 1e2fbf2..f43b7e0 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 |