diff --git a/inc/fuse/winfsp_fuse.h b/inc/fuse/winfsp_fuse.h index 4da6b6e6..cc5d7fde 100644 --- a/inc/fuse/winfsp_fuse.h +++ b/inc/fuse/winfsp_fuse.h @@ -138,6 +138,11 @@ struct fuse_statvfs #define FSP_FUSE_ENV_INIT { 'C', malloc, free } +/* + * Note that long is 8 bytes long in Cygwin64 and 4 bytes long in Win64. + * For this reason we avoid using long anywhere in these headers. + */ + #else #error unsupported environment #endif diff --git a/src/dll/fuse/fuse_opt.c b/src/dll/fuse/fuse_opt.c index 3ee521ba..59d58653 100644 --- a/src/dll/fuse/fuse_opt.c +++ b/src/dll/fuse/fuse_opt.c @@ -23,11 +23,11 @@ #define fsp_fuse_opt_match_exact ((const char *)1) /* exact option match */ #define fsp_fuse_opt_match_next ((const char *)2) /* option match, value is next arg */ -#if 1 -typedef long int strtoint_result_t; +#if defined(_WIN64) +typedef long long strtoint_result_t; #else /* cannot use long long in 32-bit builds because we are missing symbol __allmul */ -typedef long long int strtoint_result_t; +typedef long strtoint_result_t; #endif static strtoint_result_t strtoint(const char *p, const char *endp, int base, int is_signed) @@ -299,7 +299,17 @@ static int fsp_fuse_opt_process_arg(struct fsp_fuse_env *env, else if (2 <= h) VAR(data, opt, char) = (char)llv; else if (1 == l) + { +#if defined(_WIN64) + /* long is 8 bytes long in Cygwin64 and 4 bytes long in Win64 */ + if ('C' == env->environment) + VAR(data, opt, long long) = (long long)llv; + else + VAR(data, opt, long) = (long)llv; +#else VAR(data, opt, long) = (long)llv; +#endif + } else if (2 <= l) VAR(data, opt, long long) = (long long)llv; else diff --git a/tst/winfsp-tests/fuse-opt-test.c b/tst/winfsp-tests/fuse-opt-test.c index 2e907274..f20b8aee 100644 --- a/tst/winfsp-tests/fuse-opt-test.c +++ b/tst/winfsp-tests/fuse-opt-test.c @@ -303,7 +303,11 @@ void fuse_opt_parse_test(void) ASSERT(0 == strcmp("WwWw", data.w)); ASSERT(1 == data.x); ASSERT((long)040000000001 == data.y); - ASSERT(((long long)0x100000001 & 0xffffffff)== data.z); +#if defined(_WIN64) + ASSERT((long long)0x100000001 == data.z); +#else + ASSERT(((long long)0x100000001 & 0xffffffff) == data.z); +#endif ASSERT(+1234567890 == data.dec); ASSERT(-1234567890 == data.neg); ASSERT(0xABCDEF == data.hex);