From a41f4a0c08e126cf3d3f04a2bf878d605c983362 Mon Sep 17 00:00:00 2001 From: Michel Machado Date: Wed, 14 May 2014 09:44:36 -0400 Subject: [PATCH] Add support for Windows/Cygwin This commit is based on Tom Hall's patch. --- Makefile | 7 +++++++ README | 4 ++++ utils.c | 4 ++-- utils.h | 6 +++++- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3ab0701..4a1df3b 100644 --- a/Makefile +++ b/Makefile @@ -12,5 +12,12 @@ mac: gcc -o f3write utils.o f3write.o -lm gcc -o f3read utils.o f3read.o +cygwin: + gcc -Wall -Wno-char-subscripts -DCYGWIN -c utils.c + gcc -Wall -Wno-char-subscripts -DCYGWIN -c f3write.c + gcc -Wall -Wno-char-subscripts -DCYGWIN -c f3read.c + gcc -o f3write utils.o f3write.o -lm + gcc -o f3read utils.o f3read.o + clean: rm -f *.o f3write f3read diff --git a/README b/README index 0ac0912..a4e3fe9 100644 --- a/README +++ b/README @@ -6,6 +6,10 @@ make linux make mac +### Compile on Windows with Cygwin + +make cygwin + ### Use example ./f3write /media/5EBD-5C80/ diff --git a/utils.c b/utils.c index 0595e29..db22f68 100644 --- a/utils.c +++ b/utils.c @@ -141,7 +141,7 @@ void print_header(FILE *f, char *name) "\n", name); } -#ifdef APPLE_MAC +#if defined(APPLE_MAC) || defined (CYGWIN) #include #include @@ -216,4 +216,4 @@ int lrand48_r(struct drand48_data *buffer, long int *result) return __nrand48_r(buffer->__x, buffer, result); } -#endif /* APPLE_MAC */ +#endif /* APPLE_MAC or CYGWIN */ diff --git a/utils.h b/utils.h index 556503e..771e384 100644 --- a/utils.h +++ b/utils.h @@ -64,6 +64,10 @@ static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice) } } +#endif /* APPLE_MAC */ + +#if defined(APPLE_MAC) || defined(CYGWIN) + /* * The following functions were copied from GNU Library C to make F3 * more portable. @@ -89,6 +93,6 @@ extern int srand48_r(long int __seedval, struct drand48_data *__buffer) extern int lrand48_r(struct drand48_data *__restrict __buffer, long int *__restrict __result) __attribute__ ((nonnull(1, 2))); -#endif /* APPLE_MAC */ +#endif /* APPLE_MAC or CYGWIN */ #endif /* HEADER_UTILS_H */