<feed xmlns='http://www.w3.org/2005/Atom'>
<title>musl/src/string, branch v1.1.23</title>
<subtitle>musl - an implementation of the standard library for Linux-based systems</subtitle>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/'/>
<entry>
<title>fix memccpy to not access buffer past given size</title>
<updated>2018-12-02T14:24:15+00:00</updated>
<author>
<name>Quentin Rameau</name>
<email>quinq@fifth.space</email>
</author>
<published>2018-11-11T08:25:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=d9bdfd1644320ab916ea31d95da4bf641042209a'/>
<id>d9bdfd1644320ab916ea31d95da4bf641042209a</id>
<content type='text'>
memccpy would return a pointer over the given size when c is not
found in the source buffer and n reaches 0.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
memccpy would return a pointer over the given size when c is not
found in the source buffer and n reaches 0.
</pre>
</div>
</content>
</entry>
<entry>
<title>optimize two-way strstr and memmem bad character shift</title>
<updated>2018-11-08T20:22:22+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-11-08T20:00:02+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=122d67f846cb0be2c9e1c3880db9eb9545bbe38c'/>
<id>122d67f846cb0be2c9e1c3880db9eb9545bbe38c</id>
<content type='text'>
first, the condition (mem &amp;&amp; k &lt; p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.

second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
first, the condition (mem &amp;&amp; k &lt; p) is redundant, because mem being
nonzero implies the needle is periodic with period exactly p, in which
case any byte that appears in the needle must appear in the last p
bytes of the needle, bounding the shift (k) by p.

second, the whole point of replacing the shift k by mem (=l-p) is to
prevent shifting by less than mem when discarding the memory on shift,
in which case linear time could not be guaranteed. but as written, the
check also replaced shifts greater than mem by mem, reducing the
benefit of the shift. there is no possible benefit to this reduction of
the shift; since mem is being cleared, the full shift is valid and
more optimal. so only replace the shift by mem when it would be less
than mem.
</pre>
</div>
</content>
</entry>
<entry>
<title>remove commented-out debug printf from strstr</title>
<updated>2018-11-02T16:04:41+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-11-02T16:04:41+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=0239cd0681e889a269fb7691f60e81ef8d081e6b'/>
<id>0239cd0681e889a269fb7691f60e81ef8d081e6b</id>
<content type='text'>
this was leftover from before the initial commit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
this was leftover from before the initial commit.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix spuriously slow check in twoway strstr/memmem cores</title>
<updated>2018-11-02T16:02:09+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-11-02T16:01:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=8f5a820d147da36bcdbddd201b35d293699dacd8'/>
<id>8f5a820d147da36bcdbddd201b35d293699dacd8</id>
<content type='text'>
mem0 &amp;&amp; mem &amp;&amp; ... is redundant since mem can only be nonzero when
mem0 is nonzero.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
mem0 &amp;&amp; mem &amp;&amp; ... is redundant since mem can only be nonzero when
mem0 is nonzero.
</pre>
</div>
</content>
</entry>
<entry>
<title>fix aliasing-based undefined behavior in string functions</title>
<updated>2018-09-26T18:39:10+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-26T18:39:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=4d0a82170a25464c39522d7190b9fe302045ddb2'/>
<id>4d0a82170a25464c39522d7190b9fe302045ddb2</id>
<content type='text'>
use the GNU C may_alias attribute if available, and fallback to naive
byte-by-byte loops if __GNUC__ is not defined.

this patch has been written to minimize changes so that history
remains reviewable; it does not attempt to bring the affected code
into a more consistent or elegant form.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
use the GNU C may_alias attribute if available, and fallback to naive
byte-by-byte loops if __GNUC__ is not defined.

this patch has been written to minimize changes so that history
remains reviewable; it does not attempt to bring the affected code
into a more consistent or elegant form.
</pre>
</div>
</content>
</entry>
<entry>
<title>optimize nop case of wmemmove</title>
<updated>2018-09-23T06:51:01+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-23T06:51:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=8cd738bbee3b4e60a99b71599c338bf444070f18'/>
<id>8cd738bbee3b4e60a99b71599c338bf444070f18</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>fix undefined pointer comparison in wmemmove</title>
<updated>2018-09-23T06:48:25+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-23T06:48:25+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=82c41e92320c3f84bd6d24e21c5350a06e2fc831'/>
<id>82c41e92320c3f84bd6d24e21c5350a06e2fc831</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>fix undefined pointer comparison in memmove</title>
<updated>2018-09-23T04:03:08+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-23T04:03:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=debadaa238e90fce897b467a9efefcbbc0155d06'/>
<id>debadaa238e90fce897b467a9efefcbbc0155d06</id>
<content type='text'>
the comparison must take place in the address space model as an
integer type, since comparing pointers that are not pointing into the
same array is undefined.

the subsequent d&lt;s comparison however is valid, because it's only
reached in the case where the source and dest overlap, in which case
they are necessarily pointing to parts of the same array.

to make the comparison, use an unsigned range check for dist(s,d)&gt;=n,
algebraically !(-n&lt;s-d&lt;n). subtracting n yields !(-2*n&lt;s-d-n&lt;0), which
mapped into unsigned modular arithmetic is !(-2*n&lt;s-d-n) or rather
-2*n&gt;=s-d-n.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
the comparison must take place in the address space model as an
integer type, since comparing pointers that are not pointing into the
same array is undefined.

the subsequent d&lt;s comparison however is valid, because it's only
reached in the case where the source and dest overlap, in which case
they are necessarily pointing to parts of the same array.

to make the comparison, use an unsigned range check for dist(s,d)&gt;=n,
algebraically !(-n&lt;s-d&lt;n). subtracting n yields !(-2*n&lt;s-d-n&lt;0), which
mapped into unsigned modular arithmetic is !(-2*n&lt;s-d-n) or rather
-2*n&gt;=s-d-n.
</pre>
</div>
</content>
</entry>
<entry>
<title>reduce spurious inclusion of libc.h</title>
<updated>2018-09-12T18:34:37+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-12T04:08:09+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=5ce3737931bb411a8d167356d4d0287b53b0cbdc'/>
<id>5ce3737931bb411a8d167356d4d0287b53b0cbdc</id>
<content type='text'>
libc.h was intended to be a header for access to global libc state and
related interfaces, but ended up included all over the place because
it was the way to get the weak_alias macro. most of the inclusions
removed here are places where weak_alias was needed. a few were
recently introduced for hidden. some go all the way back to when
libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented)
cancellation points had to include it.

remaining spurious users are mostly callers of the LOCK/UNLOCK macros
and files that use the LFS64 macro to define the awful *64 aliases.

in a few places, new inclusion of libc.h is added because several
internal headers no longer implicitly include libc.h.

declarations for __lockfile and __unlockfile are moved from libc.h to
stdio_impl.h so that the latter does not need libc.h. putting them in
libc.h made no sense at all, since the macros in stdio_impl.h are
needed to use them correctly anyway.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
libc.h was intended to be a header for access to global libc state and
related interfaces, but ended up included all over the place because
it was the way to get the weak_alias macro. most of the inclusions
removed here are places where weak_alias was needed. a few were
recently introduced for hidden. some go all the way back to when
libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented)
cancellation points had to include it.

remaining spurious users are mostly callers of the LOCK/UNLOCK macros
and files that use the LFS64 macro to define the awful *64 aliases.

in a few places, new inclusion of libc.h is added because several
internal headers no longer implicitly include libc.h.

declarations for __lockfile and __unlockfile are moved from libc.h to
stdio_impl.h so that the latter does not need libc.h. putting them in
libc.h made no sense at all, since the macros in stdio_impl.h are
needed to use them correctly anyway.
</pre>
</div>
</content>
</entry>
<entry>
<title>remove or make static various unused __-prefixed symbols</title>
<updated>2018-09-12T18:34:35+00:00</updated>
<author>
<name>Rich Felker</name>
<email>dalias@aerifal.cx</email>
</author>
<published>2018-09-11T18:02:58+00:00</published>
<link rel='alternate' type='text/html' href='http://git.musl-libc.org/cgit/musl/commit/?id=3fe595de83e398dbc3cdbe303cacaf8485c9ae08'/>
<id>3fe595de83e398dbc3cdbe303cacaf8485c9ae08</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
