Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
29 user(s) are online (22 user(s) are browsing Forums)

Members: 0
Guests: 29

more...

Support us!

Headlines

 
  Register To Post  

« 1 2 3 (4)
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
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 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@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.

Go to top
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
@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 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
@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 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
@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 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Just can't stay away
Just can't stay away


See User information
@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 *= (double *)(((uintptr_t)align_buffer sizeof(double) - 1) & ~(sizeof(double) - 1));
    
int ij;

    for (
0Ai++)
    {
        for (
0Bj++)
        {
            array[
i][j] = p;
            
+= C;
        }
    }
}

Go to top
Re: A1222 support in the SDK and problems
Just popping in
Just popping in


See User information
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!
Go to top
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
@flash
native SPE version of gcc libraries will be fine, of course.
NXP had CodeWarrior IDE for SPE in past, but there were other compiller than gcc.
It will solve workarounds with float / double calls.

But global variable alignment error is probably directly in gcc - linking script error like salass00 said.

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top
Re: A1222 support in the SDK and problems
Home away from home
Home away from home


See User information
@sailor

static char align_buffer[3*sizeof(double)-1];


-1 ??


char does NOT add a extra 0\,
its not a string, so why do you want on less char?
a string is a class, not a array for chars.

GCC should automatilcy allign data, and you can use compiler options for it, "packed".

https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Type-Attributes.html

(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: A1222 support in the SDK and problems
Not too shy to talk
Not too shy to talk


See User information
@LiveForItQuote:
LiveForIt wrote:@sailor
static char align_buffer[3*sizeof(double)-1];

-1 ??
char does NOT add a extra 0\,
its not a string, so why do you want on less char?
a string is a class, not a array for chars.

This is code from salass00 hint (see above). If I understand it correctly, "-1" is here to allocate only needed memory, not more:
allign_buffer should have size at least ( nr.of variables + 1 )*( sizeof(variable)) - we need to shift variable to correct aligned address.
If variable is not correctly alligned, is shifted of certain nr. of bytes ( i.e. maximally of var.size -1 ). Shifting of var.size have no sense, because it have the same alignment like original. Thus we allocated one byte less.
Of course, if var.size is less then 8 bytes, this shape should be corrected a little.
Quote:
GCC should automatilcy allign data, and you can use compiler options for it, "packed".

https://gcc.gnu.org/onlinedocs/gcc-4.0.1/gcc/Type-Attributes.html

Yes, in theory. Please, see post nr.53. Aligning not works always for global variables. In that case I need 8-byte alignment for experiments with SPE SIMD unit.
And this workaround helps me much.
This error is connected to gcc linker script ( see comment )

AmigaOS3: Amiga 1200
AmigaOS4: Micro A1-C, AmigaOne XE, Pegasos II, Sam440ep, Sam440ep-flex, AmigaOne X1000
MorphOS: Efika 5200b, Pegasos I, Pegasos II, Powerbook, Mac Mini, iMac, Powermac Quad
Go to top

  Register To Post
« 1 2 3 (4)

 




Currently Active Users Viewing This Thread: 2 ( 0 members and 2 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project