From 0b992c5bbe7e5770550caa372cabccbdb02cde69 Mon Sep 17 00:00:00 2001 From: "mshah@teja.com" Date: Sat, 25 Sep 2004 13:12:12 -0700 Subject: [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. --- compat-cygwin.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 compat-cygwin.c (limited to 'compat-cygwin.c') 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 +#include +#include + +#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); +} -- cgit v1.2.3-65-gdbad