summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2013-06-02 15:54:54 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-06-02 15:54:54 -0700
commit29d5350c0115d8847d010830b0dcca429b038e31 (patch)
tree598980e3e9e7265abb7292849420292e43244ac8 /compat
parentMerge branch 'vv/help-unknown-ref' (diff)
parentcompate/clipped-write.c: large write(2) fails on Mac OS X/XNU (diff)
downloadtgif-29d5350c0115d8847d010830b0dcca429b038e31.tar.xz
Merge branch 'fc/macos-x-clipped-write'
Mac OS X does not like to write(2) more than INT_MAX number of bytes. * fc/macos-x-clipped-write: compate/clipped-write.c: large write(2) fails on Mac OS X/XNU
Diffstat (limited to 'compat')
-rw-r--r--compat/clipped-write.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/compat/clipped-write.c b/compat/clipped-write.c
new file mode 100644
index 0000000000..b8f98ff77f
--- /dev/null
+++ b/compat/clipped-write.c
@@ -0,0 +1,13 @@
+#include "../git-compat-util.h"
+#undef write
+
+/*
+ * Version of write that will write at most INT_MAX bytes.
+ * Workaround a xnu bug on Mac OS X
+ */
+ssize_t clipped_write(int fildes, const void *buf, size_t nbyte)
+{
+ if (nbyte > INT_MAX)
+ nbyte = INT_MAX;
+ return write(fildes, buf, nbyte);
+}