Darwin: Silence Clang 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index e452a6e..e2a8380 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -77,19 +77,19 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
break;
-
+
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
break;
-
+
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
break;
-
+
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
break;
-
+
case FFI_TYPE_STRUCT:
memcpy(argp, *p_argv, (*p_arg)->size);
break;
@@ -117,11 +117,12 @@ static size_t ffi_put_arg(ffi_type **arg_type, void **arg, char *stack)
}
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments
-
+
The vfp_space parameter is the load area for VFP regs, the return
value is cif->vfp_used (word bitset of VFP regs used for passing
arguments). These are only used for the VFP hard-float ABI.
*/
+int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
{
register unsigned int i;
@@ -129,7 +130,7 @@ int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
register char *argp;
register ffi_type **p_arg;
argp = stack;
-
+
if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
*(void **) argp = ecif->rvalue;
@@ -149,6 +150,7 @@ int ffi_prep_args_SYSV(char *stack, extended_cif *ecif, float *vfp_space)
return 0;
}
+int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
{
// make sure we are using FFI_VFP
@@ -160,13 +162,13 @@ int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
register ffi_type **p_arg;
char stack_used = 0;
char done_with_regs = 0;
- char is_vfp_type;
+ int is_vfp_type;
/* the first 4 words on the stack are used for values passed in core
* registers. */
regp = stack;
eo_regp = argp = regp + 16;
-
+
/* if the function returns an FFI_TYPE_STRUCT in memory, that address is
* passed in r0 to the function */
@@ -194,7 +196,7 @@ int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
else if (!done_with_regs && !is_vfp_type)
{
char *tregp = ffi_align(p_arg, regp);
- size_t size = (*p_arg)->size;
+ size_t size = (*p_arg)->size;
size = (size < 4)? 4 : size; // pad
/* Check if there is space left in the aligned register area to place
* the argument */
@@ -206,10 +208,10 @@ int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
FFI_ASSERT(regp <= argp);
continue;
}
- /* In case there are no arguments in the stack area yet,
+ /* In case there are no arguments in the stack area yet,
the argument is passed in the remaining core registers and on the
stack. */
- else if (!stack_used)
+ else if (!stack_used)
{
stack_used = 1;
done_with_regs = 1;
@@ -231,7 +233,7 @@ int ffi_prep_args_VFP(char *stack, extended_cif *ecif, float *vfp_space)
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
int type_code;
- /* Round the stack up to a multiple of 8 bytes. This isn't needed
+ /* Round the stack up to a multiple of 8 bytes. This isn't needed
everywhere, but it is on some platforms, and it doesn't harm anything
when it isn't needed. */
cif->bytes = (cif->bytes + 7) & ~7;
@@ -302,7 +304,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
{
extended_cif ecif;
- int small_struct = (cif->flags == FFI_TYPE_INT
+ int small_struct = (cif->flags == FFI_TYPE_INT
&& cif->rtype->type == FFI_TYPE_STRUCT);
int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT
|| cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE);
@@ -315,7 +317,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
- if ((rvalue == NULL) &&
+ if ((rvalue == NULL) &&
(cif->flags == FFI_TYPE_STRUCT))
{
ecif.rvalue = alloca(cif->rtype->size);
@@ -330,7 +332,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
else
ecif.rvalue = rvalue;
- switch (cif->abi)
+ switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
@@ -346,9 +348,9 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
FFI_ASSERT(0);
break;
}
- if (small_struct)
+ if (small_struct && rvalue != NULL)
memcpy (rvalue, &temp, cif->rtype->size);
- else if (vfp_struct)
+ else if (vfp_struct && rvalue != NULL)
memcpy (rvalue, ecif.rvalue, cif->rtype->size);
}
@@ -366,6 +368,7 @@ void ffi_closure_VFP (ffi_closure *);
/* This function is jumped to by the trampoline */
+unsigned int ffi_closure_inner (ffi_closure *closure, void **respp, void *args, void *vfp_args);
unsigned int
ffi_closure_inner (ffi_closure *closure,
void **respp, void *args, void *vfp_args)
@@ -375,10 +378,10 @@ ffi_closure_inner (ffi_closure *closure,
void **arg_area;
cif = closure->cif;
- arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/* this call will initialize ARG_AREA, such that each
- * element in that array points to the corresponding
+ * element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address. */
@@ -393,7 +396,7 @@ ffi_closure_inner (ffi_closure *closure,
}
/*@-exportheader@*/
-static void
+static void
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
void **avalue, ffi_cif *cif,
/* Used only under VFP hard-float ABI. */
@@ -429,12 +432,12 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
p_argv++;
argp += z;
}
-
+
return;
}
/*@-exportheader@*/
-static void
+static void
ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
void **avalue, ffi_cif *cif,
/* Used only under VFP hard-float ABI. */
@@ -447,7 +450,7 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
register ffi_type **p_arg;
char done_with_regs = 0;
char stack_used = 0;
- char is_vfp_type;
+ int is_vfp_type;
FFI_ASSERT(cif->abi == FFI_VFP);
regp = stack;
@@ -463,7 +466,7 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
{
size_t z;
- is_vfp_type = vfp_type_p (*p_arg);
+ is_vfp_type = vfp_type_p (*p_arg);
if(vi < cif->vfp_nargs && is_vfp_type)
{
@@ -474,12 +477,12 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
{
char* tregp = ffi_align(p_arg, regp);
- z = (*p_arg)->size;
+ z = (*p_arg)->size;
z = (z < 4)? 4 : z; // pad
-
+
/* if the arguments either fits into the registers or uses registers
* and stack, while we haven't read other things from the stack */
- if(tregp + z <= eo_regp || !stack_used)
+ if(tregp + z <= eo_regp || !stack_used)
{
/* because we're little endian, this is what it turns into. */
*p_argv = (void*) tregp;
@@ -518,7 +521,7 @@ ffi_prep_incoming_args_VFP(char *stack, void **rvalue,
p_argv++;
argp += z;
}
-
+
return;
}
@@ -881,7 +884,7 @@ static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
}
/* Found regs to allocate. */
cif->vfp_used |= new_used;
- cif->vfp_args[cif->vfp_nargs++] = reg;
+ cif->vfp_args[cif->vfp_nargs++] = (typeof(*(cif->vfp_args)))reg;
/* Update vfp_reg_free. */
if (cif->vfp_used & (1 << cif->vfp_reg_free))
@@ -889,7 +892,7 @@ static int place_vfp_arg (ffi_cif *cif, ffi_type *t)
reg += nregs;
while (cif->vfp_used & (1 << reg))
reg += 1;
- cif->vfp_reg_free = reg;
+ cif->vfp_reg_free = (typeof(cif->vfp_reg_free))reg;
}
return 0;
next_reg: ;
diff --git a/src/dlmalloc.c b/src/dlmalloc.c
index 3e2ea6f..2c55ceb 100644
--- a/src/dlmalloc.c
+++ b/src/dlmalloc.c
@@ -3388,7 +3388,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) {
*ss = m->seg; /* Push current record */
m->seg.base = tbase;
m->seg.size = tsize;
- set_segment_flags(&m->seg, mmapped);
+ (void)set_segment_flags(&m->seg, mmapped);
m->seg.next = ss;
/* Insert trailing fenceposts */
@@ -3548,7 +3548,7 @@ static void* sys_alloc(mstate m, size_t nb) {
if (!is_initialized(m)) { /* first-time initialization */
m->seg.base = m->least_addr = tbase;
m->seg.size = tsize;
- set_segment_flags(&m->seg, mmap_flag);
+ (void)set_segment_flags(&m->seg, mmap_flag);
m->magic = mparams.magic;
init_bins(m);
if (is_global(m))
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 307cd19..ba33775 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -42,6 +42,7 @@
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
+void ffi_prep_args(char *stack, extended_cif *ecif);
void ffi_prep_args(char *stack, extended_cif *ecif)
{
register unsigned int i;
@@ -341,7 +342,7 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
ecif.cif = cif;
ecif.avalue = avalue;
-
+
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
@@ -363,9 +364,9 @@ void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
#endif
else
ecif.rvalue = rvalue;
-
-
- switch (cif->abi)
+
+
+ switch (cif->abi)
{
#ifdef X86_WIN64
case FFI_WIN64:
@@ -456,16 +457,16 @@ ffi_closure_win64_inner (ffi_closure *closure, void *args) {
void *resp = &result;
cif = closure->cif;
- arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/* this call will initialize ARG_AREA, such that each
- * element in that array points to the corresponding
+ * element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will change RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, &resp, arg_area, cif);
-
+
(closure->fun) (cif, resp, arg_area, closure->user_data);
/* The result is returned in rax. This does the right thing for
@@ -485,10 +486,10 @@ ffi_closure_SYSV_inner (ffi_closure *closure, void **respp, void *args)
void **arg_area;
cif = closure->cif;
- arg_area = (void**) alloca (cif->nargs * sizeof (void*));
+ arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/* this call will initialize ARG_AREA, such that each
- * element in that array points to the corresponding
+ * element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will change RESP to point to the
* structure return address. */
@@ -552,12 +553,12 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
#endif
{
z = (*p_arg)->size;
-
+
/* because we're little endian, this is what it turns into. */
-
+
*p_argv = (void*) argp;
}
-
+
p_argv++;
#ifdef X86_WIN64
argp += (z + sizeof(void*) - 1) & ~(sizeof(void*) - 1);
@@ -565,7 +566,7 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue, void **avalue,
argp += z;
#endif
}
-
+
return;
}
@@ -653,7 +654,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
#ifdef X86_WIN64
#define ISFLOAT(IDX) (cif->arg_types[IDX]->type == FFI_TYPE_FLOAT || cif->arg_types[IDX]->type == FFI_TYPE_DOUBLE)
#define FLAG(IDX) (cif->nargs>(IDX)&&ISFLOAT(IDX)?(1<<(IDX)):0)
- if (cif->abi == FFI_WIN64)
+ if (cif->abi == FFI_WIN64)
{
int mask = FLAG(0)|FLAG(1)|FLAG(2)|FLAG(3);
FFI_INIT_TRAMPOLINE_WIN64 (&closure->tramp[0],
@@ -694,7 +695,7 @@ ffi_prep_closure_loc (ffi_closure* closure,
{
return FFI_BAD_ABI;
}
-
+
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
@@ -732,7 +733,7 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
}
-
+
#ifdef X86_WIN32
if (cif->abi == FFI_SYSV)
{
@@ -754,7 +755,7 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
return FFI_OK;
}
-static void
+static void
ffi_prep_args_raw(char *stack, extended_cif *ecif)
{
memcpy (stack, ecif->avalue, ecif->cif->bytes);
@@ -773,7 +774,7 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
ecif.cif = cif;
ecif.avalue = avalue;
-
+
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
@@ -785,9 +786,9 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *fake_avalue)
}
else
ecif.rvalue = rvalue;
-
-
- switch (cif->abi)
+
+
+ switch (cif->abi)
{
#ifdef X86_WIN32
case FFI_SYSV: