Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 04 Jul 2013 13:58:49 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: Use of size_t and ssize_t in mseek

Am Donnerstag, den 04.07.2013, 13:10 +0200 schrieb Szabolcs Nagy:
> it seems to me that if a qsort_s call sets the tls and then before
> the callee reads that pointer a signal interrupts with a handler that
> calls qsort_s again then the tls is overwritten by another pointer
> 
> so you lose signal-safety with the tls design

this would in fact not be good

in any case I don't think that the tls design is the way to go for
qsort_s, the overhead would be too large

> > > (In P99 I do that with inlining and gcc shows to be able to expand all
> > > comparisons in place and to optimize that smoothly.)
> > 
> > Nice. I'll have to take a look -- I've always wanted to see a fully
> > inlined qsort that could be compared to the C++ template-based sorts
> > to demonstrate that inline functions in C can do just as good or
> > better, inlining the comparison callback... :)
> 
> * Jens Gustedt <jens.gustedt@...ia.fr> [2013-07-04 10:45:47 +0200]:
> > http://gustedt.wordpress.com/2012/12/04/inline-functions-as-good-as-templates/
> 
> good to know that this works now..
> 
> it's not clear from the article how the compiler knew that the
> last arg for qsort_s is supposed to be passed to the comparision
> function: was it lto+static linking or was the internal of
> qsort_s visible in the same translation unit?

it is visible. P99 is all inline, there isn't even a precompiled
libp99 to link to.

> a few years ago i did similar experiments but those failed back then:
> https://groups.google.com/d/msg/comp.lang.c/sO2oYdZGdd8/bqFZ4i81P7AJ

I see. So yes, the situation has substantially improved since
then. gcc and clang are both capable of doing such optimizations
nowadays, if they are presented with clean code.

Jens

-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::



Download attachment "signature.asc" of type "application/pgp-signature" (199 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.