Skip to content

Commit 0ae389f

Browse files
committed
rtlib/darwin: fix compiler errors on mac os
1 parent 20aa98f commit 0ae389f

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/rtlib/profile_cycles.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ typedef struct _FB_PROFILER_CYCLES
9797
/* FIXME: creating a library with other sections causes dxe3gen to fail
9898
** when building the DXE dynamic link library support for DOS
9999
*/
100-
#if !defined(HOST_DOS)
100+
/* FIXME: Mach-O custom sections must follow the format __<segment>,__<section>.
101+
** The section name can be a maximum of 16 characters long,
102+
** so fb_profilecycledata (19 chars) is too long
103+
*/
104+
#if !defined(HOST_DARWIN) && !defined(HOST_DOS)
101105

102106
/* make sure there is at least one record in the profile data section */
103107
static FB_PROFILE_RECORD_VERSION

src/rtlib/thread_call.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ FBTHREAD *fb_ThreadCall( void *proc, int abi, ssize_t stack_size, int num_args,
3030

3131
#else
3232

33+
#ifdef HOST_DARWIN
34+
#include <ffi/ffi.h>
35+
#else
3336
#include <ffi.h>
37+
#endif
3438

3539
#define FB_THREADCALL_MAX_ELEMS 1024
3640

@@ -65,21 +69,21 @@ static void freeStruct( ffi_type *arg )
6569
{
6670
int i = 0;
6771
ffi_type **elem = arg->elements;
68-
72+
6973
while( *elem != NULL )
7074
{
7175
/* cap element count to limit buffer overrun */
7276
if ( i >= FB_THREADCALL_MAX_ELEMS )
7377
break;
74-
78+
7579
/* free embedded types */
7680
if( (*elem)->type == FFI_TYPE_STRUCT )
7781
freeStruct( *elem );
78-
82+
7983
elem++;
8084
i++;
8185
}
82-
86+
8387
free( arg->elements );
8488
free( arg );
8589
}
@@ -96,10 +100,10 @@ static ffi_type *getStruct( va_list *args_list )
96100
ffi_arg->size = 0;
97101
ffi_arg->alignment = 0;
98102
ffi_arg->type = FFI_TYPE_STRUCT;
99-
ffi_arg->elements =
103+
ffi_arg->elements =
100104
(ffi_type **)malloc( sizeof( ffi_type * ) * ( num_elems + 1 ) );
101105
ffi_arg->elements[num_elems] = NULL;
102-
106+
103107
/* scan elements */
104108
for( i=0; i<num_elems; i++ )
105109
{
@@ -117,7 +121,7 @@ static ffi_type *getStruct( va_list *args_list )
117121
return NULL;
118122
}
119123
}
120-
124+
121125
return ffi_arg;
122126
}
123127

@@ -151,13 +155,13 @@ FBTHREAD *fb_ThreadCall( void *proc, int abi, ssize_t stack_size, int num_args,
151155
void **values;
152156
FBTHREADCALL *param;
153157
int i, j;
154-
158+
155159
/* initialize lists and arrays */
156160
ffi_args = (ffi_type **)malloc( sizeof( ffi_type * ) * num_args );
157161
values = (void **)malloc( sizeof( void * ) * num_args );
158-
va_list args_list;
162+
va_list args_list;
159163
va_start(args_list, num_args);
160-
164+
161165
/* scan arguments and values from var_args */
162166
for( i=0; i<num_args; i++ )
163167
{
@@ -177,15 +181,15 @@ FBTHREAD *fb_ThreadCall( void *proc, int abi, ssize_t stack_size, int num_args,
177181
values[i] = va_arg( args_list, void * );
178182
}
179183
va_end( args_list );
180-
184+
181185
/* pack into thread parameter */
182186
param = malloc( sizeof( FBTHREADCALL ) );
183187
param->proc = proc;
184188
param->abi = abi;
185189
param->num_args = num_args;
186190
param->ffi_arg_types = ffi_args;
187191
param->values = values;
188-
192+
189193
/* actually start thread */
190194
return fb_ThreadCreate( threadproc, (void *)param, stack_size );
191195
}
@@ -214,18 +218,18 @@ static FBCALL void threadproc( void *param )
214218
/* prep FFI call interface */
215219
if( status == FFI_OK )
216220
#endif
217-
status = ffi_prep_cif(
221+
status = ffi_prep_cif(
218222
&cif, // handle
219223
abi, // ABI (CDECL or STDCALL on x86, host default on x86_64)
220224
info->num_args, // number of arguments
221225
&ffi_type_void, // return type
222226
info->ffi_arg_types // argument types
223227
);
224-
228+
225229
/* execute */
226230
if( status == FFI_OK )
227231
ffi_call( &cif, FFI_FN( info->proc ), NULL, info->values );
228-
232+
229233

230234
/* free memory and exit */
231235
for( i=0; i<info->num_args; i++ )

0 commit comments

Comments
 (0)