Darwin: Silence Clang warnings.
authorZachary Waldowski <zwaldowski@gmail.com>
Thu, 12 Apr 2012 03:26:04 +0000 (23:26 -0400)
committerZachary Waldowski <zwaldowski@gmail.com>
Sat, 30 Nov 2013 08:47:58 +0000 (03:47 -0500)
src/arm/ffi.c
src/dlmalloc.c
src/x86/ffi.c

index e452a6e..e2a8380 100644 (file)
@@ -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: ;
index 3e2ea6f..2c55ceb 100644 (file)
@@ -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)) 
index 307cd19..ba33775 100644 (file)
@@ -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: