Secondary platform change request

2014-04-30 Thread Wolf
Since the original MinGW refuses to support 64-bit, I would like to 
discuss whether we should remove i686-mingw32 from the secondary 
platforms list and replace it with MinGW-w64.


Re: Questions about trampolines

2005-03-14 Thread Clifford Wolf
On Mon, Mar 14, 2005 at 08:34:32AM +0100, ?yvind Harboe wrote:
> > > - Lately e.g. the AMD CPU has added support for making it impossible
> > >   to execute code on the stack. The town isn't big enough for
> > >   both stack based trampolines and stack code execution protection. 
> > >   What happens now? 
> > 
> > Usually it is possible to disable this stack protection. If it is not
> > possible, then that's a very serious limitation.

But OpenBSD either ignores it or gcc doesn't set the stack executable on
OpenBSD.

At least my trampoline example (http://www.clifford.at/cfun/gccfeat/gccfeat01.c)
segfaults on OpenBSD when trying to execute the trampoline code..

> I believe e.g. Windows XP service pack 2 has this protection enabled. 

I don't think so. Afaik even an Opteron (and the compatibles) only have an
extra "execute" page permission when running 64 bit programs. It doesn't
change anything for 32 bit binaries.

There is a pentium CPU register which contains the highest executeabe
address. But using it "the right way" would require rebuilding all apps so
all executeable adrresses are in the lower half of the virtual memory and
all data in the upper half. This couldn't be done with a simple change in
the operating system (unless there really aren't any executeable
addresses above the stack frame - then it could be done for the stack but
not for all other data segments).

yours,
 - clifford

-- 
| Clifford Wolf /-=[ www.clifford.at ]==[ Tel: +43-699-10063494 ]=-\
|--/ www.cngw.org - www.ccc.de =[ Fax: +43-2235-42788-4 ]=-|
|-=[ EDEN Creations -- www.edenevents.at ]==[ IRC: www.freenode.net ]=-|
\==[ www.rocklinux.org ]===[ www.rocklinux.net ]===[ www.linbit.com ]==/
 
When your hammer is C++, everything begins to look like a thumb.
 


pgptMvLNXPaWo.pgp
Description: PGP signature


Re: Questions about trampolines

2005-03-14 Thread Clifford Wolf
Hi,

On Mon, Mar 14, 2005 at 02:11:51PM +0100, Marc Espie wrote:
> In article <[EMAIL PROTECTED]> you write:
> >Well as I said above, trampolines or an equivalent are currently critically
> >needed by some front ends (and of course by anyone using the (very useful 
> >IMO)
> >extension of nested functions in C).
> 
> This is your opinion, but I've yet to find an actual piece of code in a
> real project that uses that extension.

http://svn.clifford.at/spl/trunk/modules/mod_xml.c

.. much easier this way as by passing everything with the userdata pointer.

I've also seen already APIs with callbacks which do not support userdata
pointers. While I am agree that those APIs are broken it is still a good
feeling to know that it is possible to work around this issues using nested
functions...

yours,
 - clifford

-- 
bash -c "gcc -o mysdldemo -Wall -O2 -lSDL -lm -pthread -x c <( echo -e '
#include \n#include \nint main(){SDL_Surface*s;SDL_Event
e;int x,y,n;SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(640,480,32,0);for(x=0;
x<640;x++)for(y=0;y<480;y++){float _Complex z=0, c=((x-400)/200.0) + ((y-240)/
200.0)*1.0fi;for(n=1;n<64;n++){z=z*z+c;if(cabsf(z)>2){((Uint32*)s->pixels)[x+y
*640]=n<<3;n=99;}}}SDL_UpdateRect(s,0,0,s->w,s->h);do SDL_WaitEvent(&e); while
(e.type!=SDL_QUIT&&e.type!=SDL_KEYDOWN);SDL_Quit();return 0;}' ); ./mysdldemo"
 
Programming graphics in X is like finding sqrt(pi) using Roman numerals.
 


pgpxjVrWkAgnJ.pgp
Description: PGP signature


Re: Merging calls to `abort'

2005-03-15 Thread Clifford Wolf
Hi,

On Sun, Mar 13, 2005 at 03:01:00PM +0200, Kai Henningsen wrote:
> Most of the rest of the error handling in this project is concerned with  
> the absence of the feature I loved in the IBM PL/I compilers under the  
> name "SNAP;" - putting out a stack backtrace (the usual idiom for abort()  
> was "SNAP; STOP;" IIRC). Now *that* would be a useful feature to have.  

It is there: __builtin_return_address(n)

I have a small example of how to use that on my homepage:

http://www.clifford.at/cfun/elfstuff/backtrace.c

This example is using the ELF dladdr() function - so it can only resolve
symbols in a .so file - not in the main program. (I think it works if the
main program is compiled with -rdynamic - but I didn't check that).

I hope that helps.

yours,
 - clifford

-- 
  _   __  __  $_ = q 7nz!y="Ccv'Dpgiutvcbb'oj'Pocj'*'qqq[
 / ___/ __ \/ __ `/ | /| / /  ej`q[iv`";!|=1;!y=~t%].[%nz!z=!1;gps]1..6[{
/ /__/ / / / /_/ /| |/ |/ /   qsjou"!z\c";tfmfdu]voefg,voefg,voefg,0.05[;
\___/_/ /_/\__, / |__/|__/!z=~t/].[/dis]pse]!1[^!_[/fh;}qsjou !z;%fh;
 CCC Wien //www.cngw.org  qsjou "\o"7;s/\n//g;y/[b-za]!/)a-z($/;eval;
 
Unix is the answer, but only if you phrase the question very carefully.
 


pgpWZjTpDIdF3.pgp
Description: PGP signature


Re: Merging calls to `abort'

2005-03-15 Thread Clifford Wolf
Hi,

On Fri, Mar 11, 2005 at 03:28:19PM -0500, Richard Stallman wrote:
> Currently, I believe, GCC combines various calls to abort in a single
> function, because it knows that none of them returns.

afaics it is more generic. It merges them because it knows that it doesn't
make any difference. This is a "problem" we always will have when debugging
optimized programs and has nothing to do with the abort() function as it
is. E.g.:

  #include 

  int main(int argc)
  {
char str[] = "Howdy!";
if (argc > 1) {
printf("Got arguments.\n");
puts(str);
} else {
printf("Got no arguments.\n");
puts(str);
}
return 0;
  }

When compiled with -Os, the compiler will only generate two function calls.
In the printf-case it is possible to distinguish by looking at the
parameter, in the puts case there is no way of distinguishing if we are in
the `if' or in the `else' branch..

(when compiled with -fno-crossjumping everything is clear again)

> If the goal is simply to make the compiled code as small as possible,
> this is the way to do it.

That's what the user is telling gcc when he is calling the compiler with
-Os. One great thing of free software is it doesn't try to `patronize' its
users. Please do not let us start with that now..

As statet already, the abort information is pretty useless when the binary
is compiled without debug symbols. And usually the `production binaries'
shipped by distributors are built without debug symbols. So you would need
to rebuild with debug symbols anyways - why not just rebuilding without
optimization too when that is what one actually wants to do?

The fancy_abort() function someone suggested in the other mail always
works. And if the author of the software has developed a personal procedure
for looking into problems where a fancy_abort() isn't very helpfull (and it
looks like you did - but that doesn't mean automatically that everyone is
using this strategy for debugging software) then we are still confronted
with the problems stated above (deactiviating some optimizations doesn't
change anything because of the missing debug symbols).

> So maybe it would be better to treat abort specially in the opposite way:
> to inhibit merging two abort calls even in a situation where calls to
> some unknown function might be merged.

In my oppinion that would be pretty ugly. From the compilers point of view
the abort function is just a normal function with the __noreturn__
attribute. It's not a compiler builtin or something like that. Just
matching for a function name in the compiler and treat a function call
diffrently if it is to a function called "abort" is imo a strict no-do.

It would be possible to add a new attribute for such cases - but because of
the need-to-recompile-for-debug-symbols-anyways reason I don't see any need
for such an attribute.

yours,
 - clifford

--
 _  _   _  Nerds on Air - Radio for Geeks  _  __ ___
| \| |___  /_\   On 1st and 3rd Friday of the month   / |/ /__  / _ |
| .` / _ \/ _ \21:00-22:00 CET on Radio Orange   // _ \/ __ |
|_|\_\___/_/ \_\ http://www.clifford.at/noa//_/|_/\___/_/ |_|
 
To understand recursion, you must first understand recursion.
 


pgpiOq4kxrDKC.pgp
Description: PGP signature


Re: Questions about trampolines

2005-03-16 Thread Clifford Wolf
Hi,

On Wed, Mar 16, 2005 at 01:50:32PM +, Joern RENNECKE wrote:
> These can be provided in a separate module of the static libgcc, together
> with allocation and deallocation of individual trampolines from the pool
> (the latter has to be called from the epilogue of functions that use
> initialize (and thus allocate) trampolines).

I also thought about that already.
It's a good idea, but not good enough.  :-(

what's about longjmp(), gotos from nested functions to their surrounding
functions (with a complex calltree inbetween) and (c++) exceptions?

always preserving frame pointers, unrolling the stack frame by frame and
executing this epilogues might be possible - but I don't think that we
really want to go this way..

yours,
 - clifford

--
  L The SPL Programming Language
SP  P L http://www.clifford.at/spl/
  L 
   S PL A statefull, simple, small, c-like, object oriented,
 P  embeddable, feature rich, dynamic scripting language
 
Opinions expressed here are mine. And if you don't agree with them, you
are racist, sexist, elitist, imperialist, baptist and possibly even right.
 


pgpDVUGEEmaC8.pgp
Description: PGP signature


Re: Questions about trampolines

2005-03-17 Thread Clifford Wolf
hi,

On Wed, Mar 16, 2005 at 02:48:56PM -0500, Robert Dewar wrote:
> Yes, but that avoids the difficulty, that's obvious so far.
> 
> The problem is to know exactly when to pop the stack, and that is
> not trivial (longjmp, exceptions, non local gotos).

hmm.. what's about doing it gc-like. Instead of a stack there simply is a
'pool' of trampolines from which trampolines are allocated and a pointer to
the trampoline is pushed on the stack.

When the last trampoline from the pool is allocated, a 'garbage collector'
is running over it and looking for pointers to trampolines between the
stack pointer and the stack start address. Every trampoline which isn't
possibly referenced is added to a free-list from which new trampolines are
allocated.

When no trampoline can be allocated, abort() is called (with or without
crossjumping ;-).

This may be a dirty hack and guessing a good size for the trampoline pool
is still an issue - but it could be implemented easily and would work...

Instead of adding the trampoline pool to libgcc (as suggested earlier in
this thread) I would suggest that gcc generates a trampoline pool in a
linkonce section every time a source file is compiled which requires
trampolines. That way there wouldn't be any trampoline pool in an
executeable which doesn't need one and a compiler option such as
-ftrampoline-pool-size=32 could be used the specify the size of the
trampoline pool on the command line.

The only issue I see with that is that the trampoline pool will actually
consist of two sections: one for the code and one for the data. Afair there
is a bug with linkonce sections connected to data sections. (triggered e.g.
when a big switch statement in function in a c++ template is compiled using
a jump table. this may lead to code-references in .data to dropped linkonce
code sections.) may this also become an issue here? or is the bug fixed
already?

yours,
 - clifford

--
ocaml graphics.cma <( echo 'open Graphics;;open_graph " 640x480"let
complex_mul(a,b)(c,d)=(a*.c-.b*.d,a*.d+.b*.c)let complex_add(a,b)(c
,d)=(a+.c,b+.d);;let rec mandel c n=if n>0 then let z=mandel c(n-1)
in complex_add(complex_mul z z)c else (0.0,0.0);; for x=0 to 640 do
for y=0 to 480 do let c=((float_of_int(x-450))/.200.0,(float_of_int
(y-240))/.200.0) in let cabs2(a,b)=(a*.a)+.(b*.b)in if cabs2(mandel
c 50)<4.0 then plot x y done done;;read_line()' )
 
M$ is not the answer. M$ is the question. No is the answer!
 


pgpupBLHWsXdb.pgp
Description: PGP signature


Re: Questions about trampolines

2005-03-17 Thread Clifford Wolf
Hi,

On Thu, Mar 17, 2005 at 01:35:29PM +, Joern RENNECKE wrote:
> I.e. you could have libgcc provide one with a size that works most of the
> time

Some applications have recursions which go into a depth of 1000 and more.
Some architectures have only a few k ram. Which "a size that works most of
the time" would you suggest?

It's ugly to have a static pool size. But it's intolerable to not allow the
user to change that pool size easily using an option.

> The mmapped trampoline can be an absolute function call to some helper 
> code that does the

I am pretty sure that all processor architectures with such a strict haward
design that it is impossible to generate dynamic code are MMU-less.

yours,
 - clifford

-- 
bash -c "gcc -o mysdldemo -Wall -O2 -lSDL -lm -pthread -x c <( echo -e '
#include \n#include \nint main(){SDL_Surface*s;SDL_Event
e;int x,y,n;SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(640,480,32,0);for(x=0;
x<640;x++)for(y=0;y<480;y++){float _Complex z=0, c=((x-400)/200.0) + ((y-240)/
200.0)*1.0fi;for(n=1;n<64;n++){z=z*z+c;if(cabsf(z)>2){((Uint32*)s->pixels)[x+y
*640]=n<<3;n=99;}}}SDL_UpdateRect(s,0,0,s->w,s->h);do SDL_WaitEvent(&e); while
(e.type!=SDL_QUIT&&e.type!=SDL_KEYDOWN);SDL_Quit();return 0;}' ); ./mysdldemo"
 
M$ is not the answer. M$ is the question. No is the answer!
 


pgpUWbp1VmpeO.pgp
Description: PGP signature


proposal: explicit context pointers in addition to trampolines in C frontend

2005-04-12 Thread Clifford Wolf
Hi,

I've been thinking about trampolines and nested functions in C the other
day. I really like using trampolines for callback functions, such as in

http://svn.clifford.at/spl/trunk/spl_modules/mod_xml.c

see:

  static struct spl_node *handler_xml2tree(struct spl_task *task, void *data)
  {
[...]

void XMLCALL element_start_hdl(void *data, const char *el, const char 
**attr)
{
[...]
}

[ ... ]

XML_SetElementHandler(p, element_start_hdl, element_end_hdl);
  }

sure - I could also pack all the stuff which should be shared between
handler_xml2tree() and its element_start_hdl() in a struct and pass a
pointer to that struct as first argument to element_start_hdl(). But it
simply is easier (faster to implement) to do that with the trampoline
mechanism.

But, on the other hand, trampolines aren't very portable and require
an executeable stack, which isn't nice. So, it would be cool to be able to
do something like the following:

  static struct spl_node *handler_xml2tree(struct spl_task *task, void *data)
  {
[...]

void XMLCALL element_start_hdl(void *data
__attribute__ (( contextpointer(handler_xml2tree) )),
const char *el, const char **attr)
{
[...]
}

[ ... ]

XML_SetElementHandler(p, element_start_hdl, element_end_hdl);
XML_SetUserData(p, __builtin_contextpointer(handler_xml2tree));
  }

so, because the 1st argument of element_start_hdl() has this new, fancy,
attributute, it is using it to access the stack frame of its
handler_xml2tree(). The __builtin_contextpointer() is used to generate this
context pointers and no trampoline is ever generated when using
element_start_hdl as function pointer.

It's not that I would really _need_ this feature. It just came to my mind
when thinking about the trampoline thread from some time ago and I didn't
want the idea to get lost...

"You can now flame me, I am full of love."  ;-)

yours,
 - clifford

-- 
/"\  ASCII Ribbon Campaign - against html email
\ /- against microsoft office attachments
 X - against text above fullquote below
/ \- against lines longer than 79 characters
 
"The generation of random numbers is too important to be left to chance."
 - Robert R. Coveyou, Oak Ridge National Laboratory.
 


pgp0aBSaSqqwi.pgp
Description: PGP signature


GCC 4.1.0 build error (as doesn't like code produced by xgcc)

2006-03-28 Thread Clifford Wolf
Hi,

I have an interesting problem with compiling gcc 4.1.0 on
i386-unknown-linux-gnu. Building xgcc (with gcc 3.4.3) works fine.
But rebuilding the compiler with xgcc the 2nd time (with -fprofile-use)
fails with an assembler error:

  $ stage1/xgcc -Bstage1/ -B/usr/i386-unknown-linux-gnu/bin/ -c   -O2 -g 
-fomit-frame-pointer -fprofile-use -freorder-blocks-and-partition -DIN_GCC -W 
-Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic 
-Wno-long-long -Wno-variadic-macros -Wold-style-definition 
-Wmissing-format-attribute -DHAVE_CONFIG_H -I. -I. -I../../gcc 
-I../../gcc/. -I../../gcc/../include -I../../gcc/../libcpp/include 
../../gcc/attribs.c -o attribs.o
  
  /tmp/cc9Aywrx.s: Assembler messages:
  /tmp/cc9Aywrx.s:1256: Error: can't resolve `.text.unlikely' {.text.unlikely 
section} - `.LCFI70' {.text section}

The assembler code generated by xgcc can be found here:

  http://www.clifford.at/priv/gcc410-attribs.s.gz

My assembler is a GNU as, version 2.16.91.0.7 (i.e. HJLs linux binutils).
I've also tried it with the bit older 2.16.91.0.3 and got the same error.

It can be easily reproduced by calling `as' directly on the assembler code:

  $ as --traditional-format attribs.s

  attribs.s: Assembler messages:
  attribs.s:1256: Error: can't resolve `.text.unlikely' {.text.unlikely 
section} - `.LCFI70' {.text section}

Is this a known problem? I (better said: google) was unable to find
anything about it.

I also do not really understand the error message. The assembler is trying
to look up a symbol `.text.unlikely' in the .text.unlikely section? Sounds
strange to me and according to the assember code it should try to look up
`.LCFI71' instead. Is this a bug in binutils or gcc? Or am I doing
something wrong?

yours,
 - clifford

--
bash -c "gcc -o mysdldemo -Wall -O2 -lSDL -lm -pthread -x c <( echo -e '
#include \n#include \nint main(){SDL_Surface*s;SDL_Event
e;int x,y,n;SDL_Init(SDL_INIT_VIDEO);s=SDL_SetVideoMode(640,480,32,0);for(x=0;
x<640;x++)for(y=0;y<480;y++){float _Complex z=0, c=((x-400)/200.0) + ((y-240)/
200.0)*1.0fi;for(n=1;n<64;n++){z=z*z+c;if(cabsf(z)>2){((Uint32*)s->pixels)[x+y
*640]=n<<3;n=99;}}}SDL_UpdateRect(s,0,0,s->w,s->h);do SDL_WaitEvent(&e); while
(e.type!=SDL_QUIT&&e.type!=SDL_KEYDOWN);SDL_Quit();return 0;}' ); ./mysdldemo"
 
A: No.
Q: Should I include quotations after my reply?
 


pgpumZfvmaMsZ.pgp
Description: PGP signature


Re: GCC 4.1.0 build error (as doesn't like code produced by xgcc)

2006-03-30 Thread Clifford Wolf
Hi,

On Wed, Mar 29, 2006 at 09:31:26AM -0500, Daniel Jacobowitz wrote:
> On Tue, Mar 28, 2006 at 03:10:30PM +0200, Clifford Wolf wrote:
> >   /tmp/cc9Aywrx.s: Assembler messages:
> >   /tmp/cc9Aywrx.s:1256: Error: can't resolve `.text.unlikely' 
> > {.text.unlikely section} - `.LCFI70' {.text section}
> 
> The assembly is wrong.  File a GCC bug.  Two subtracted symbols should
> generally be in the same section.

bug filed:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26942

yours,
 - clifford

-- 
 _  _   _  Nerds on Air - Radio for Geeks  _  __ ___
| \| |___  /_\   On 1st and 3rd Friday of the month   / |/ /__  / _ |
| .` / _ \/ _ \21:00-22:00 CET on Radio Orange   // _ \/ __ |
|_|\_\___/_/ \_\ http://www.clifford.at/noa//_/|_/\___/_/ |_|
 
[..] If it still doesn't work, re-write it in assembler. This won't fix the
bug, but it will make sure no one else finds it and makes you look bad.
 


[no subject]

2023-10-25 Thread wolf king via Gcc
Hi, please I just want to ask how to get the caribien nationality as a
syrian man and his family and the datiels about it and thanks for your help