X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fhelper%2Freplacements.h;h=ac5009549a347166f035b4f71e32ffea1814d388;hb=1457a1ab425febd3dfceeb8c908b69135ff0b8b6;hp=1e2fbf20f9ef349484cd48dde2aefcc12aede0cd;hpb=d4b7cbff88bb5eb14fececdbd8e2a0b3e58ce6e0;p=fw%2Fopenocd diff --git a/src/helper/replacements.h b/src/helper/replacements.h index 1e2fbf20f..ac5009549 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -25,6 +25,8 @@ #ifndef OPENOCD_HELPER_REPLACEMENTS_H #define OPENOCD_HELPER_REPLACEMENTS_H +#include + /* MIN,MAX macros */ #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) @@ -199,6 +201,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