This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: mips va_arg question
- From: "Dave Korn" <dk at artimi dot com>
- To: "'Mile Davidovic'" <mdavidyu at yahoo dot com>,"'Richard Sandiford'" <rsandifo at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Thu, 12 Aug 2004 14:03:17 +0100
- Subject: RE: mips va_arg question
> -----Original Message-----
> From: gcc-owner On Behalf Of Mile Davidovic
> Sent: 12 August 2004 13:56
> Thanks a lot.
>
> This code is little snapshots from pretty large SW
> with underlaying RTOS and we have problem with calling
> function with variable number of arguments from
> threads.
>
> I am very thankfull for Your effort.
It is sometimes a problem with some combinations of CPU, OS and C
library/runtime, that the stack pointer doesn't acquire the correct aligment
when a new thread is started.
The compiler always makes functions adjust the stack pointer by a multiple
of the aligment, so it guarantees that if the code starts off executing with
an aligned stack, it will stay aligned, but the compiler has no control over
how the OS initialises the state of a new thread and whether or not it
aligns the initial value of the SP correctly.
For example, in once case I came across, the first thread in a process is
setup with a correctly aligned stack but subsequent threads spawned by the
application itself have unaligned stacks.
So the answer to your problem may well be that when you spawn a thread, it
should be started at an asm wrapper function that adjusts the stack aligment
as needed and then calls out to the actual C language function you wanted;
from that point on the stack will stay aligned.
cheers,
DaveK
--
Can't think of a witty .sigline today....