libwpp: Use __int64 instead of long long.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-03-13 16:47:26 +01:00
parent 9068ad0f09
commit 595386250a
3 changed files with 28 additions and 59 deletions

View File

@ -171,11 +171,11 @@ ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
#include <limits.h> #include <limits.h>
#ifndef LLONG_MAX #ifndef LLONG_MAX
# define LLONG_MAX ((long long)0x7fffffff << 32 | 0xffffffff) # define LLONG_MAX ((__int64)0x7fffffff << 32 | 0xffffffff)
# define LLONG_MIN (-LLONG_MAX - 1) # define LLONG_MIN (-LLONG_MAX - 1)
#endif #endif
#ifndef ULLONG_MAX #ifndef ULLONG_MAX
# define ULLONG_MAX ((long long)0xffffffff << 32 | 0xffffffff) # define ULLONG_MAX ((__int64)0xffffffff << 32 | 0xffffffff)
#endif #endif
#ifndef HAVE_UNISTD_H #ifndef HAVE_UNISTD_H
@ -899,29 +899,21 @@ static int make_number(int radix, YYSTYPE *val, const char *str, int len)
is_u++; is_u++;
} }
if(is_ll) if(is_u && is_ll)
{ {
/* Assume as in the declaration of wrc_ull_t and wrc_sll_t */ errno = 0;
#ifdef HAVE_LONG_LONG val->ull = strtoull(str, NULL, radix);
if (is_u) if (val->ull == ULLONG_MAX && errno == ERANGE)
{ ppy_error("integer constant %s is too large\n", str);
errno = 0; return tULONGLONG;
val->ull = strtoull(str, NULL, radix); }
if (val->ull == ULLONG_MAX && errno == ERANGE) else if(!is_u && is_ll)
ppy_error("integer constant %s is too large\n", str); {
return tULONGLONG; errno = 0;
} val->sll = strtoll(str, NULL, radix);
else if ((val->sll == LLONG_MIN || val->sll == LLONG_MAX) && errno == ERANGE)
{ ppy_error("integer constant %s is too large\n", str);
errno = 0; return tSLONGLONG;
val->sll = strtoll(str, NULL, radix);
if ((val->sll == LLONG_MIN || val->sll == LLONG_MAX) && errno == ERANGE)
ppy_error("integer constant %s is too large\n", str);
return tSLONGLONG;
}
#else
pp_internal_error(__FILE__, __LINE__, "long long constants not supported on this platform");
#endif
} }
else if(is_u && is_l) else if(is_u && is_l)
{ {

View File

@ -81,9 +81,9 @@
if(cv_signed(v1) && cv_signed(v2)) \ if(cv_signed(v1) && cv_signed(v2)) \
r.val.sll = v1.val.sll OP v2.val.sll; \ r.val.sll = v1.val.sll OP v2.val.sll; \
else if(cv_signed(v1) && !cv_signed(v2)) \ else if(cv_signed(v1) && !cv_signed(v2)) \
r.val.sll = v1.val.sll OP (wrc_sll_t) v2.val.ull; \ r.val.sll = v1.val.sll OP (__int64) v2.val.ull; \
else if(!cv_signed(v1) && cv_signed(v2)) \ else if(!cv_signed(v1) && cv_signed(v2)) \
r.val.sll = (wrc_sll_t) v1.val.ull OP v2.val.sll; \ r.val.sll = (__int64) v1.val.ull OP v2.val.sll; \
else \ else \
r.val.ull = v1.val.ull OP v2.val.ull; r.val.ull = v1.val.ull OP v2.val.ull;
@ -128,8 +128,8 @@ static int nmacro_args;
unsigned int uint; unsigned int uint;
long slong; long slong;
unsigned long ulong; unsigned long ulong;
wrc_sll_t sll; __int64 sll;
wrc_ull_t ull; unsigned __int64 ull;
int *iptr; int *iptr;
char *cptr; char *cptr;
cval_t cval; cval_t cval;
@ -539,12 +539,12 @@ static int boolean(cval_t *v)
{ {
switch(v->type) switch(v->type)
{ {
case cv_sint: return v->val.si != (int)0; case cv_sint: return v->val.si != 0;
case cv_uint: return v->val.ui != (unsigned int)0; case cv_uint: return v->val.ui != 0;
case cv_slong: return v->val.sl != (long)0; case cv_slong: return v->val.sl != 0;
case cv_ulong: return v->val.ul != (unsigned long)0; case cv_ulong: return v->val.ul != 0;
case cv_sll: return v->val.sll != (wrc_sll_t)0; case cv_sll: return v->val.sll != 0;
case cv_ull: return v->val.ull != (wrc_ull_t)0; case cv_ull: return v->val.ull != 0;
} }
return 0; return 0;
} }

View File

@ -20,10 +20,6 @@
#ifndef __WINE_WPP_PRIVATE_H #ifndef __WINE_WPP_PRIVATE_H
#define __WINE_WPP_PRIVATE_H #define __WINE_WPP_PRIVATE_H
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -136,25 +132,6 @@ typedef struct
int seen_junk; /* Set when junk is seen */ int seen_junk; /* Set when junk is seen */
} include_state_t; } include_state_t;
/*
* If the configure says we have long long then we can use it. Presumably
* if we have long long then we have strtoull and strtoll too. If that is
* not the case we will need to add to the configure tests.
* If we do not have long long , then we revert to a simple 'long' for now.
* This should prevent most unexpected things with other compilers than
* gcc and egcs for now.
* In the future it should be possible to use another way, like a
* structure, so that we can emulate the MS compiler.
*/
#ifdef HAVE_LONG_LONG
typedef long long wrc_sll_t;
typedef unsigned long long wrc_ull_t;
#else
typedef long wrc_sll_t;
typedef unsigned long wrc_ull_t;
#endif
#define SIZE_CHAR 1 #define SIZE_CHAR 1
#define SIZE_SHORT 2 #define SIZE_SHORT 2
#define SIZE_INT 3 #define SIZE_INT 3
@ -191,8 +168,8 @@ typedef struct cval {
unsigned int ui; unsigned int ui;
long sl; long sl;
unsigned long ul; unsigned long ul;
wrc_sll_t sll; __int64 sll;
wrc_ull_t ull; unsigned __int64 ull;
} val; } val;
} cval_t; } cval_t;