Who's Online
18 user(s) are online (
12 user(s) are browsing
Forums )
Members: 0
Guests: 18
more...
Topic options
View mode
Newest First
Re: A1222 support in the SDK and problems
Posted on:
1/23 16:00
#61
Not too shy to talk
Joined: 2021/4/23 7:00Last Login
: Yesterday 20:43
From Central Bohemia, Czech Republic
Group:
Registered Users
I tried to link it with gcc 11.2 and 10.3, still receive allingnment error.
Next I will try pointers workaround.
@all, thanks for advice
AmigaOS3: Amiga 1200AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Re: A1222 support in the SDK and problems
Posted on:
1/24 17:59
#62
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: Yesterday 22:46
From Finland
Group:
Registered Users
@sailor
You could use a method similar to what has been used in m68k-amigaos C code to allocate long word aligned structures like FileInfoBlock from the stack:
static char align_buffer [ 3 * sizeof (double)- 1 ];
double * T1ptr ;
double * T2ptr ;
#define T1 (*T1ptr)
#define T2 (*T2ptr)
__attribute__ (( constructor ))
static void __init_T1T2 ( void )
{
T1ptr = ( double *)((( uintptr_t ) align_buffer + sizeof (double) - 1 ) & ~( sizeof (double) - 1 ));
T2ptr = T1ptr + 1 ;
}
If T1 and T2 were arrays instead of simple double variables you could even make use of C's pointer/array equivalence to get rid of the ugly macros.
Re: A1222 support in the SDK and problems
Posted on:
1/24 19:59
#63
Not too shy to talk
Joined: 2021/4/23 7:00Last Login
: Yesterday 20:43
From Central Bohemia, Czech Republic
Group:
Registered Users
@salass00 interesting idea - many thanks. For the first time I heard about constructor attribute. Looks nice, on weekend I will test. Before you post this advice, I had in plan more dirty solution, something like: double Tarray[3]; double *pT,*pT1; pT= (double*)((long)(Tarray +1) - (long)(Tarray % 8)); pT1= pT+1; Thx!
Edited by sailor on 2025/1/24 20:47:35 Edited by sailor on 2025/1/24 20:48:45 Edited by sailor on 2025/1/24 20:53:08 Edited by sailor on 2025/1/24 20:53:41
AmigaOS3: Amiga 1200AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Re: A1222 support in the SDK and problems
Posted on:
1/25 12:31
#64
Not too shy to talk
Joined: 2021/4/23 7:00Last Login
: Yesterday 20:43
From Central Bohemia, Czech Republic
Group:
Registered Users
@salass00 thanks, it works nice! For global vars and global arrys too.
Edited by sailor on 2025/1/25 12:58:29 Edited by sailor on 2025/1/25 12:58:47
AmigaOS3: Amiga 1200AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Re: A1222 support in the SDK and problems
Posted on:
1/30 14:49
#65
Not too shy to talk
Joined: 2021/4/23 7:00Last Login
: Yesterday 20:43
From Central Bohemia, Czech Republic
Group:
Registered Users
@salass00Quote:
salass00 wrote:@sailor You could use a method similar to what has been used in m68k-amigaos C code to allocate long word aligned structures like FileInfoBlock from the stack:
static char align_buffer [ 3 * sizeof (double)- 1 ];
double * T1ptr ;
double * T2ptr ;
#define T1 (*T1ptr)
#define T2 (*T2ptr)
__attribute__ (( constructor ))
static void __init_T1T2 ( void )
{
T1ptr = ( double *)((( uintptr_t ) align_buffer + sizeof (double) - 1 ) & ~( sizeof (double) - 1 ));
T2ptr = T1ptr + 1 ;
}
If T1 and T2 were arrays instead of simple double variables you could even make use of C's pointer/array equivalence to get rid of the ugly macros. If I used single dimension array, as you said alignment is easy for array[A]:
static char align_buffer [( A + 1 )* sizeof (double)- 1 ];
double *array;
__attribute__ (( constructor ))
static void __init_array ( void )
{
array = ( double *)((( uintptr_t ) align_buffer + sizeof (double) - 1 ) & ~( sizeof (double) - 1 ));
}
And please, how it will work for multidimensional arrays - like array[A][B][C]? Should I use this?
static char align_buffer [( A * B * C + 1 )* sizeof (double)- 1 ];
double (*array)[ A ][ B ][ C ];
__attribute__ (( constructor ))
static void __init_array ( void )
{
array = ( double *)((( uintptr_t ) align_buffer + sizeof (double) - 1 ) & ~( sizeof (double) - 1 ));
}
and in the rest of code use normally
array[a][b][c] ?
AmigaOS3: Amiga 1200AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Re: A1222 support in the SDK and problems
Posted on:
Yesterday 19:23
#66
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: Yesterday 22:46
From Finland
Group:
Registered Users
@sailor
I could be wrong but I don't think definining a pointer to a multi-dimensional array will work. In my experience multi-dimensional arrays in C are quite limited in how they can be used so I almost never use them in my code.
What should work however is something like (not quite as elegant):
static char align_buffer [( A * B * C + 1 )* sizeof (double)- 1 ];
double *array[ A ][ B ];
__attribute__ (( constructor ))
static void __init_array ( void )
{
double * p = ( double *)((( uintptr_t ) align_buffer + sizeof (double) - 1 ) & ~( sizeof (double) - 1 ));
int i , j ;
for ( i = 0 ; i < A ; i ++)
{
for ( j = 0 ; j < B ; j ++)
{
array[ i ][ j ] = p ;
p += C ;
}
}
}
Re: A1222 support in the SDK and problems
Posted on:
Yesterday 20:18
#67
Just popping in
Joined: 2018/3/1 21:08Last Login
: Yesterday 20:15
From italy
Group:
Registered Users
How can we get a fixed version of GCC to avoid all these workarounds/hacks? Is there a guy able to fix it for a native version of GCC?
Memento audere semper!
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)