Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ea0f80

Browse files
committed
Make the GCC-4.8 compiler happy by moving declarations to the top of the function.
1 parent 520ad57 commit 5ea0f80

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

Modules/_ctypes/libffi_osx/ffi.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ initialize_aggregate(
3838
/*@out@*/ ffi_type* arg)
3939
{
4040
/*@-usedef@*/
41+
ffi_type** ptr;
4142

4243
if (arg == NULL || arg->elements == NULL ||
4344
arg->size != 0 || arg->alignment != 0)
4445
return FFI_BAD_TYPEDEF;
4546

46-
ffi_type** ptr = &(arg->elements[0]);
47+
ptr = &(arg->elements[0]);
4748

4849
while ((*ptr) != NULL)
4950
{
@@ -135,16 +136,16 @@ ffi_prep_cif(
135136
/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type* rtype,
136137
/*@dependent@*/ ffi_type** atypes)
137138
{
139+
unsigned int bytes = 0;
140+
unsigned int i;
141+
ffi_type** ptr;
142+
138143
if (cif == NULL)
139144
return FFI_BAD_TYPEDEF;
140145

141146
if (abi <= FFI_FIRST_ABI || abi > FFI_DEFAULT_ABI)
142147
return FFI_BAD_ABI;
143148

144-
unsigned int bytes = 0;
145-
unsigned int i;
146-
ffi_type** ptr;
147-
148149
cif->abi = abi;
149150
cif->arg_types = atypes;
150151
cif->nargs = nargs;

Modules/_ctypes/libffi_osx/x86/x86-ffi64.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,16 @@ classify_argument(
225225
/* Merge the fields of structure. */
226226
for (ptr = type->elements; *ptr != NULL; ptr++)
227227
{
228+
int num, pos;
229+
228230
byte_offset = ALIGN(byte_offset, (*ptr)->alignment);
229231

230-
int num = classify_argument(*ptr, subclasses, byte_offset % 8);
232+
num = classify_argument(*ptr, subclasses, byte_offset % 8);
231233

232234
if (num == 0)
233235
return 0;
234236

235-
int pos = byte_offset / 8;
237+
pos = byte_offset / 8;
236238

237239
for (i = 0; i < num; i++)
238240
{
@@ -589,11 +591,12 @@ ffi_prep_closure(
589591
void (*fun)(ffi_cif*, void*, void**, void*),
590592
void* user_data)
591593
{
594+
volatile unsigned short* tramp;
595+
592596
if (cif->abi != FFI_UNIX64)
593597
return FFI_BAD_ABI;
594598

595-
volatile unsigned short* tramp =
596-
(volatile unsigned short*)&closure->tramp[0];
599+
tramp = (volatile unsigned short*)&closure->tramp[0];
597600

598601
tramp[0] = 0xbb49; /* mov <code>, %r11 */
599602
*(void* volatile*)&tramp[1] = ffi_closure_unix64;

0 commit comments

Comments
 (0)