fuse: better handling of long (Cygwin64 vs Win64)

This commit is contained in:
Bill Zissimopoulos 2016-05-31 11:12:01 -07:00
parent 300ce8485b
commit 765bb1e1a3
3 changed files with 23 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
#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);