X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-compat-util.h;h=0c98c9937df14bfa8be4f58cae84aa16029be883;hb=9470657ad0d0472e3e3c2e352334f60e7bd777c1;hp=4185b12741f802842f2aebc128c61051db65c13d;hpb=5e80092f7e6db09a40a62e837ca3f74f0bc5ad73;p=git.git diff --git a/git-compat-util.h b/git-compat-util.h index 4185b127..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 @@ -110,4 +132,7 @@ static inline int sane_case(int x, int high) return x; } +#ifndef MAXPATHLEN +#define MAXPATHLEN 256 +#endif #endif