diff options
Diffstat (limited to 'compat')
-rw-r--r-- | compat/mkdir.c | 24 | ||||
-rw-r--r-- | compat/poll/poll.c (renamed from compat/win32/poll.c) | 14 | ||||
-rw-r--r-- | compat/poll/poll.h (renamed from compat/win32/poll.h) | 0 |
3 files changed, 35 insertions, 3 deletions
diff --git a/compat/mkdir.c b/compat/mkdir.c new file mode 100644 index 0000000000..9e253fb72f --- /dev/null +++ b/compat/mkdir.c @@ -0,0 +1,24 @@ +#include "../git-compat-util.h" +#undef mkdir + +/* for platforms that can't deal with a trailing '/' */ +int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) +{ + int retval; + char *tmp_dir = NULL; + size_t len = strlen(dir); + + if (len && dir[len-1] == '/') { + if ((tmp_dir = strdup(dir)) == NULL) + return -1; + tmp_dir[len-1] = '\0'; + } + else + tmp_dir = (char *)dir; + + retval = mkdir(tmp_dir, mode); + if (tmp_dir != dir) + free(tmp_dir); + + return retval; +} diff --git a/compat/win32/poll.c b/compat/poll/poll.c index 403eaa7a3c..7d226ecb29 100644 --- a/compat/win32/poll.c +++ b/compat/poll/poll.c @@ -24,7 +24,9 @@ # pragma GCC diagnostic ignored "-Wtype-limits" #endif -#include <malloc.h> +#if defined(WIN32) +# include <malloc.h> +#endif #include <sys/types.h> @@ -48,7 +50,9 @@ #else # include <sys/time.h> # include <sys/socket.h> -# include <sys/select.h> +# ifndef NO_SYS_SELECT_H +# include <sys/select.h> +# endif # include <unistd.h> #endif @@ -302,6 +306,10 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds) || socket_errno == ECONNABORTED || socket_errno == ENETRESET) happened |= POLLHUP; + /* some systems can't use recv() on non-socket, including HP NonStop */ + else if (/* (r == -1) && */ socket_errno == ENOTSOCK) + happened |= (POLLIN | POLLRDNORM) & sought; + else happened |= POLLERR; } @@ -349,7 +357,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) /* EFAULT is not necessary to implement, but let's do it in the simplest case. */ - if (!pfd) + if (!pfd && nfd) { errno = EFAULT; return -1; diff --git a/compat/win32/poll.h b/compat/poll/poll.h index b7aa59d973..b7aa59d973 100644 --- a/compat/win32/poll.h +++ b/compat/poll/poll.h |