X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=git-compat-util.h;h=0c98c9937df14bfa8be4f58cae84aa16029be883;hb=e4e79a217576d24ef4d73b620766f62b155bcd98;hp=ead0ede5872e3c1ca10596010d4827ed726ff394;hpb=252fef7149204d52ed4b46fd7e8ac8c803ceb0aa;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index ead0ede5..0c98c993 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -84,6 +84,28 @@ static inline void *xcalloc(size_t nmemb, size_t size) return ret; } +static inline ssize_t xread(int fd, void *buf, size_t len) +{ + ssize_t nr; + while (1) { + nr = read(fd, buf, len); + if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) + continue; + return nr; + } +} + +static inline ssize_t xwrite(int fd, const void *buf, size_t len) +{ + ssize_t nr; + while (1) { + nr = write(fd, buf, len); + if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) + continue; + return nr; + } +} + /* Sane ctype - no locale, and works with signed chars */ #undef isspace #undef isdigit