diff options
author | Tim Newsome <tim@sifive.com> | 2017-12-13 13:13:22 -0800 |
---|---|---|
committer | Freddie Chopin <freddie.chopin@gmail.com> | 2018-01-25 16:44:06 +0000 |
commit | 64f1f7b1c179dcce4e008bef6bf9515c47ae4100 (patch) | |
tree | a794f86845ec6ed21d387f1970f6c86018fe1058 /src/helper | |
parent | 2428722a23d8a08b15331ab95884762e5f329a02 (diff) | |
download | riscv-openocd-64f1f7b1c179dcce4e008bef6bf9515c47ae4100.zip riscv-openocd-64f1f7b1c179dcce4e008bef6bf9515c47ae4100.tar.gz riscv-openocd-64f1f7b1c179dcce4e008bef6bf9515c47ae4100.tar.bz2 |
Add read buffer to bitbang, improving performance.
Previously for every bit scanned OpenOCD would write the bit, wait for
that bit to be scanned, and then read the result. This involves at least
2 context switches. Most of the time the next bit scanned does not
depend on the last bit we read, so with a buffer we now write a bunch of
bits to be scanned all at once, and then we wait for them all to be
scanned and have a result.
This reduces the time for one testcase where OpenOCD connects to a
simulator from 12.30s to 5.35s!
Running all our tests went from 13m13s to 3m55s.
Change-Id: Ie9fcea043ac1d7877a521125334ed47d4b3e1615
Signed-off-by: Tim Newsome <tim@sifive.com>
Reviewed-on: http://openocd.zylin.com/4312
Tested-by: jenkins
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
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 |