You probably mean something like the attached test. What do you want to
know about it ? I can run it on x86 and on ARM.

        Danny

On Mon, 2009-06-08 at 18:16 +0900, Pawel Veselov wrote:
> Should the prologue code be rewritten to have
> a thread created before main() is called?
> 
> Also, it'd be interesting to see where are the
> new thread stacks are created, I've looked
> at how other OSes do that, and they just
> simply create a new segment. Since m$ seem
> to not give you stack segment for the stack
> completely, it should allocate thread stacks
> somewhere in that stack segment.
> 
> 
> On Mon, Jun 8, 2009 at 6:06 PM, Johnny Willemsen <jwillem...@remedy.nl> wrote:
> > Hi,
> >
> >> gcc code may user more of the stack than whatever code that msvc
> >> produces, thus
> >> dipping into the red zone more often. So far, I don't see how the 64k
> >> limit of the
> >> stack on the main thread can be avoided at all..
> >
> > The only option I see (which also Danny proposed) is to create a worker 
> > thread, use that as main thread, then we can control the stack size.
> >
> > I will rewrite a few tests at our side to get some objects from the heap 
> > instead of from the stack.
> >
> > Johnny
> >
> >
> 
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
#include <stdio.h>
#include <string.h>

#include <windows.h>
#include <winbase.h>

#define	STACK_SIZE	33000
#define STACK_SIZE_PARAM_IS_A_RESERVATION     0x00010000

void Print(char *s);
char	outbuf[32];

void more(void)
{
	char	buf[STACK_SIZE];

	Print("In deeper function\n");
}

void large(void)
{
	char	buf[STACK_SIZE];

	sprintf(outbuf, "Size : %d\n", sizeof(buf));
	Print(outbuf);
	memset(&buf, 0, STACK_SIZE);
	Print("After memset\n");

	more();

	Print("returning\n");
}

DWORD thread(void *p)
{
	Print("begin thread\n");
	large();
	Print("end thread\n");
}

int main(int argc, char *argv[])
{
	HANDLE	t;

	Print("In main\n");
	t = CreateThread(NULL, 0x100000,
			&thread,
			NULL,
			STACK_SIZE_PARAM_IS_A_RESERVATION,
			NULL);

	WaitForSingleObject(t, 10000);
	return 0;
}

void Print(char *s)
{
#ifdef WIN32
	HANDLE	h;
	DWORD	r;

	h = CreateFile(L"/temp/out.txt", GENERIC_WRITE, 0, NULL,
			OPEN_ALWAYS,
			FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, NULL);
	SetFilePointer(h, 0L, NULL, FILE_END);
	WriteFile(h, s, strlen(s), &r, NULL);
	CloseHandle(h);
#else
#endif
}
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to