aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormshah@teja.com <mshah@teja.com>2004-09-25 13:12:12 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:22 -0700
commit0b992c5bbe7e5770550caa372cabccbdb02cde69 (patch)
treed96bc91f0bceaf28b5b3b2d4d6ae25a7a10f14c9 /compat-cygwin.c
parentAdd system-specific compatibility functions to make (diff)
downloadsparse-0b992c5bbe7e5770550caa372cabccbdb02cde69.tar.gz
sparse-0b992c5bbe7e5770550caa372cabccbdb02cde69.tar.bz2
sparse-0b992c5bbe7e5770550caa372cabccbdb02cde69.zip
[PATCH] WinGW/CygWin compatibility support
First cut at CygWin/MinGW compat support. Currently, for mingw, I am using windows API to identify the files uniquely, which is somewhat heavy because I have to open both the files simultaneously to compare the indices, will replace it to a lighter version later if I find out how to do that.
Diffstat (limited to 'compat-cygwin.c')
-rw-r--r--compat-cygwin.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/compat-cygwin.c b/compat-cygwin.c
new file mode 100644
index 0000000..13e125c
--- /dev/null
+++ b/compat-cygwin.c
@@ -0,0 +1,43 @@
+/*
+ * Cygwin Compatibility functions
+ *
+ *
+ * Licensed under the Open Software License version 1.1
+ */
+
+
+
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lib.h"
+#include "token.h"
+
+void *blob_alloc(unsigned long size)
+{
+ void *ptr;
+ size = (size + 4095) & ~4095;
+ ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (ptr == MAP_FAILED)
+ ptr = NULL;
+ else
+ memset(ptr, 0, size);
+ return ptr;
+}
+
+void blob_free(void *addr, unsigned long size)
+{
+ size = (size + 4095) & ~4095;
+ munmap(addr, size);
+}
+
+long double string_to_ld(const char *nptr, char **endptr)
+{
+ return strtod(nptr, endptr);
+}
+
+int identical_files(struct stream* s, struct stat *st, const char * name)
+{
+ return (s->dev == st->st_dev && s->ino == st->st_ino);
+}