Darwin/x86_64: Fix 64-bit type shortening warnings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
diff --git a/src/closures.c b/src/closures.c
index 4d0a0b6..6eac601 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -264,7 +264,7 @@ static int
open_temp_exec_file_dir (const char *dir)
{
static const char suffix[] = "/ffiXXXXXX";
- int lendir = strlen (dir);
+ size_t lendir = strlen (dir);
char *tempname = __builtin_alloca (lendir + sizeof (suffix));
if (!tempname)
diff --git a/src/prep_cif.c b/src/prep_cif.c
index a66ee23..e216ef0 100644
--- a/src/prep_cif.c
+++ b/src/prep_cif.c
@@ -187,7 +187,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi,
{
/* Add any padding if necessary */
if (((*ptr)->alignment - 1) & bytes)
- bytes = ALIGN(bytes, (*ptr)->alignment);
+ bytes = (unsigned)ALIGN(bytes, (*ptr)->alignment);
#ifdef TILE
if (bytes < 10 * FFI_SIZEOF_ARG &&
diff --git a/src/x86/ffi64.c b/src/x86/ffi64.c
index bd917f0..fd31424 100644
--- a/src/x86/ffi64.c
+++ b/src/x86/ffi64.c
@@ -152,7 +152,7 @@ merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2)
See the x86-64 PS ABI for details.
*/
-static int
+static size_t
classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
size_t byte_offset)
{
@@ -168,7 +168,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
case FFI_TYPE_SINT64:
case FFI_TYPE_POINTER:
{
- int size = byte_offset + type->size;
+ size_t size = byte_offset + type->size;
if (size <= 4)
{
@@ -209,8 +209,8 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
return 2;
case FFI_TYPE_STRUCT:
{
- const int UNITS_PER_WORD = 8;
- int words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
+ const size_t UNITS_PER_WORD = 8;
+ size_t words = (type->size + UNITS_PER_WORD - 1) / UNITS_PER_WORD;
ffi_type **ptr;
int i;
enum x86_64_reg_class subclasses[MAX_CLASSES];
@@ -233,7 +233,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
/* Merge the fields of structure. */
for (ptr = type->elements; *ptr != NULL; ptr++)
{
- int num;
+ size_t num;
byte_offset = ALIGN (byte_offset, (*ptr)->alignment);
@@ -242,7 +242,7 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
return 0;
for (i = 0; i < num; i++)
{
- int pos = byte_offset / 8;
+ size_t pos = byte_offset / 8;
classes[i + pos] =
merge_classes (subclasses[i], classes[i + pos]);
}
@@ -306,11 +306,12 @@ classify_argument (ffi_type *type, enum x86_64_reg_class classes[],
class. Return zero iff parameter should be passed in memory, otherwise
the number of registers. */
-static int
+static size_t
examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
_Bool in_return, int *pngpr, int *pnsse)
{
- int i, n, ngpr, nsse;
+ size_t n;
+ int i, ngpr, nsse;
n = classify_argument (type, classes, 0);
if (n == 0)
@@ -351,9 +352,9 @@ examine_argument (ffi_type *type, enum x86_64_reg_class classes[MAX_CLASSES],
ffi_status
ffi_prep_cif_machdep (ffi_cif *cif)
{
- int gprcount, ssecount, i, avn, n, ngpr, nsse, flags;
+ int gprcount, ssecount, i, avn, ngpr, nsse, flags;
enum x86_64_reg_class classes[MAX_CLASSES];
- size_t bytes;
+ size_t bytes, n;
gprcount = ssecount = 0;
@@ -411,7 +412,7 @@ ffi_prep_cif_machdep (ffi_cif *cif)
if (ssecount)
flags |= 1 << 11;
cif->flags = flags;
- cif->bytes = ALIGN (bytes, 8);
+ cif->bytes = (unsigned)ALIGN (bytes, 8);
return FFI_OK;
}
@@ -454,8 +455,7 @@ ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
for (i = 0; i < avn; ++i)
{
- size_t size = arg_types[i]->size;
- int n;
+ size_t n, size = arg_types[i]->size;
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
if (n == 0
@@ -584,7 +584,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
if (ret != FFI_TYPE_VOID)
{
enum x86_64_reg_class classes[MAX_CLASSES];
- int n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
+ size_t n = examine_argument (cif->rtype, classes, 1, &ngpr, &nsse);
if (n == 0)
{
/* The return value goes in memory. Arrange for the closure
@@ -611,7 +611,7 @@ ffi_closure_unix64_inner(ffi_closure *closure, void *rvalue,
for (i = 0; i < avn; ++i)
{
enum x86_64_reg_class classes[MAX_CLASSES];
- int n;
+ size_t n;
n = examine_argument (arg_types[i], classes, 0, &ngpr, &nsse);
if (n == 0