Fwd: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Mike Stump
[ dup sorry ] On Aug 13, 2014, at 5:12 AM, Felix Yang wrote: > The qsort library function may have different behavior on > different hosts (say Linux vs MinGW). > OK for trunk? I just have one question. Why if we want to use a stable sort, and we program in C++, would we not want to just us

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Mike Stump
On Aug 13, 2014, at 5:12 AM, Felix Yang wrote: >The qsort library function may have different behavior on > different hosts (say Linux vs MinGW). > OK for trunk? I just have one question. Why if we want to use a stable sort, and we program in C++, would we not want to just use C++: http

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Jeff Law
On 08/13/14 07:55, Felix Yang wrote: Is this possible a Canadian build. I am afread that the qsort then is from the MinGW/Win host? The stability of the sort is independent of the underlying qsort implementation if the comparison routine is fully specified. It's somewhat painful, but I'd reall

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Ian Lance Taylor
On Wed, Aug 13, 2014 at 6:31 AM, Jeff Law wrote: > On 08/13/14 06:12, Felix Yang wrote: >> >> Hi all, >> >> The qsort library function may have different behavior on >> different hosts (say Linux vs MinGW). >> We may have different sorting results with qsort when there are >> elements wi

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Felix Yang
Is this possible a Canadian build. I am afread that the qsort then is from the MinGW/Win host? Cheers, Felix On Wed, Aug 13, 2014 at 9:31 PM, Jeff Law wrote: > On 08/13/14 06:12, Felix Yang wrote: >> >> Hi all, >> >> The qsort library function may have different behavior on >> different hos

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Jeff Law
On 08/13/14 06:12, Felix Yang wrote: Hi all, The qsort library function may have different behavior on different hosts (say Linux vs MinGW). We may have different sorting results with qsort when there are elements with the same key value. GCC uses qsort a lot. And the output of ce

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Felix Yang
Hi Jakub, I got it. I will update the patch after I finished integrating the GLIBC qsort with libiberty. Cheers, Felix On Wed, Aug 13, 2014 at 8:55 PM, Jakub Jelinek wrote: > On Wed, Aug 13, 2014 at 08:48:52PM +0800, Felix Yang wrote: >> I did tried to use the glibc qsort. I compared th

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Jakub Jelinek
On Wed, Aug 13, 2014 at 08:48:52PM +0800, Felix Yang wrote: > I did tried to use the glibc qsort. I compared the source of the > two versions. > I found that the BSD one is more self-contained and easy for > integration with libiberty. Being more self-contained is not what we care about, t

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Felix Yang
Hi Jakub, I did tried to use the glibc qsort. I compared the source of the two versions. I found that the BSD one is more self-contained and easy for integration with libiberty. That's why the BSD one is preferred. And we already have several BSD functions there in libiberty (libib

Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Jakub Jelinek
On Wed, Aug 13, 2014 at 08:12:03PM +0800, Felix Yang wrote: > The qsort library function may have different behavior on > different hosts (say Linux vs MinGW). > We may have different sorting results with qsort when there are > elements with the same key value. > GCC uses qsort a lot. A

[PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Felix Yang
Hi all, The qsort library function may have different behavior on different hosts (say Linux vs MinGW). We may have different sorting results with qsort when there are elements with the same key value. GCC uses qsort a lot. And the output of certain optimizations, such as IRA, relies o