This is an optimized memset for AArch64. Memset is split into 4 main
cases: small sets of up to 16 bytes, medium of 16..96 bytes which are
fully unrolled. Large memsets of more than 96 bytes align the
destination and use an unrolled loop processing 64 bytes per
iteration. Memsets of zero of more than 256 use the dc zva
instruction, and there are faster versions for the common ZVA sizes 64
or 128. STP of Q registers is used to reduce codesize without loss of
performance.
This is an optimized memcpy for AArch64. Copies are split into 3 main
cases: small copies of up to 16 bytes, medium copies of 17..96 bytes
which are fully unrolled. Large copies of more than 96 bytes align
the destination and use an unrolled loop processing 64 bytes per
iteration. In order to share code with memmove, small and medium
copies read all data before writing, allowing any kind of overlap. On
a random copy test memcpy is 40.8% faster on A57 and 28.4% on A53.
This is an optimized memmove for AArch64. All copies of up to 96
bytes and all backward copies are done by the new memcpy. The only
remaining case is large forward copies which are done in the same way
as the memcpy loop, but copying from the end rather than the start.
x86_64: Handle myfault exceptions when running on alternate signal stack
x86_64 only:
* cygtls.cc (san::leave): Restore _my_tls.andreas.
* cygtls.h (class san): Add _clemente as in 32 bit case. Add ret and
frame members.
(san::san): Handle _my_tls.andreas as on 32 bit. Take parameter and
write it to new member ret. Store current stack pointer in frame.
(san::~san): New destructor to restore _my_tls.andreas.
(__try): Use __l_except address as parameter to san::san.
* dcrt0.cc (dll_crt0_0): Add myfault_altstack_handler as vectored
continuation handler.
* exception.h (myfault_altstack_handler): Declare.
* exceptions.cc (myfault_altstack_handler): New function. Explain what
it's good for.
Simplify stack allocation code in child after fork
* child_info.h (CURR_CHILD_INFO_MAGIC): Update.
(child_info_fork::alloc_stack_hard_way): Drop declaration.
* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fold into
child_info_fork::alloc_stack.
(getstack): Remove.
(child_info_fork::alloc_stack): Simplify check for application-provided
stack in "hard way" code. Don't call getstack for each page, just
reallocate stack immediately as required.
As a commonly-included header, the #define basename in <string.h> can
affect code which uses "basename" for its own purposes (e.g. struct
members or C++ namespaced functions). When such cases occur and some
code includes <string.h> and some not, then errors result. OTOH,
<libgen.h> is rarely used, and that's where the renaming occurs in
glibc, so code using <libgen.h> should already be safe.
* libc/include/libgen.h (basename): Define as __xpg_basename
for source compatibility with glibc.
Declare with __ASMNAME("basename") for ABI compatibility.
* libc/include/string.h (basename): Define as basename for
source compatibility with glibc.
Declare with __ASMNAME("__gnu_basename") for ABI compatibility.
Fix sys/time.h build problem due to inconsistent macro usage
https://sourceware.org/ml/newlib/2015/msg00520.html describes
how sys/time.h uses __BSD_VISIBLE while the types used in the
affected inline functions are guarded with !_POSIX_SOURCE.
Fix that by guarding the type with __BSD_VISIBLE as well.
* libc/include/sys/time.h: Explicitely include sys/cdefs.h.
* libc/include/sys/types.h: Ditto. Guard BSD convenience base types
with __BSD_VISIBLE rather than !_POSIX_SOURCE.
* miscfuncs.cc (struct pthread_wrapper_arg): Add member guardsize.
(pthread_wrapper): Set thread stack guarantee according to guardsize.
Tweak assembler code so that $rax/$eax is not required by GCC to
prepare the wrapper_arg value.
(CygwinCreateThread): Fix deadzone handling. Drop setting a "POSIX"
guardpage (aka page w/ PAGE_NOACCESS). Always use Windows guard
pages instead. On post-XP systems (providing SetThreadStackGuarantee)
always set up stack Windows like with reserved/commited areas and
movable guard pages. Only on XP set up stack fully commited if the
guardpage size is not the default system guardpage size.
Fill out pthread_wrapper_arg::guardsize. Improve comments.
* resource.cc: Implement RSTACK_LIMIT Linux-like.
(DEFAULT_STACKSIZE): New macro.
(DEFAULT_STACKGUARD): Ditto.
(rlimit_stack_guard): New muto.
(rlimit_stack): New global variable holding current RSTACK_LIMIT values.
(__set_rlimit_stack): Set rlimit_stack under lock.
(__get_rlimit_stack): Initialize rlimit_stack from executable header
and return rlimit_stack values under lock.
(get_rlimit_stack): Filtering function to return useful default
stacksize from rlimit_stack.rlim_cur value.
(getrlimit): Call __get_rlimit_stack in RLIMIT_STACK case.
(setrlimit): Call __set_rlimit_stack in RLIMIT_STACK case.
* thread.cc (pthread::create): Fetch default stacksize calling
get_rlimit_stack.
(pthread_attr::pthread_attr): Fetch default guardsize calling
wincap.def_guard_page_size.
(pthread_attr_getstacksize): Fetch default stacksize calling
get_rlimit_stack.
* thread.h (PTHREAD_DEFAULT_STACKSIZE): Remove.
(PTHREAD_DEFAULT_GUARDSIZE): Remove.
(get_rlimit_stack): Declare.
* fhandler_process.cc (heap_info::heap_info): Disable fetching heap info
on 64 bit XP/2003. Explain why.
* wincap.h (wincaps::has_broken_rtl_query_process_debug_information):
New element.
* wincap.cc: Implement above element throughout.
Fix original stack when running signal handler on alternate stack
* autoload.cc (SetThreadStackGuarantee): Import.
* cygtls.h (struct _cygtls): Replace thread_context with a ucontext_t
called context.
* exceptions.cc (exception::handle): Exit from process via signal_exit
in case sig_send returns from handling a stack overflow SIGSEGV.
Explain why.
(dumpstack_overflow_wrapper): Thread wrapper to create a stackdump
from another thread.
(signal_exit): Fix argument list to reflect three-arg signal handler.
In case we have to create a stackdump for a stack overflow condition,
do so from a separate thread. Explain why.
(sigpacket::process): Don't run signal_exit on alternate stack.
(altstack_wrapper): Wrapper function to do stack correction when
calling the signal handler on an alternate stack to handle a stack
overflow. Make sure to have lots of comments.
(_cygtls::call_signal_handler): Drop local context variable to reduce
stack pressure. Use this->context instead. Change inline assembler
to call altstack_wrapper.
(_cygtls::signal_debugger): Accommodate aforementioned change to
struct _cygtls.
* tlsoffset.h: Regenerate.
* tlsoffset64.h: Regenerate.
Sebastian Huber [Wed, 1 Jul 2015 13:35:00 +0000 (15:35 +0200)]
Prevent use of uninitialized file lock
The CHECK_INIT() is necessary before the _newlib_flockfile_start() since
this would use otherwise acquire an uninitialized lock which gets
initialized after this leading to a corrupt release.
newlib/ChangeLog
2015-07-01 Sebastian Huber <sebastian.huber@embedded-brains.de>
libc/stdio/fputs.c (_puts_r): Add missing CHECK_INIT().
libc/stdio/gets.c (_gets_r): Add missing _REENT_SMALL_CHECK_INIT() and
CHECK_INIT(). Use _stdin_r() to get the file pointer instead of stdin.
Corinna Vinschen [Sat, 27 Jun 2015 10:08:07 +0000 (12:08 +0200)]
Handle ss_flags value longjmp safe.
* exceptions.cc (_cygtls::call_signal_handler): Drop manipulating
thread's ss_flags here. It's not safe against longjmp.
* signal.cc (sigaltstack): Check if we're running on the alternate
stack and set ss_flags returned in oss to SS_ONSTACK.
Corinna Vinschen [Fri, 26 Jun 2015 19:41:26 +0000 (21:41 +0200)]
Define larger MINSIGSTKSZ and SIGSTKSZ values for Cygwin
* include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ
here with bigger values to allow _cygtls to reside on signal stack,
should it turn out to be required at one point.
Jon TURNEY [Tue, 23 Jun 2015 13:35:00 +0000 (14:35 +0100)]
Use source files which have makedoc markup, but aren't processed or included.
These source files have makedoc markup, but aren't listed to be chewed by
makedoc. I am assuming that is accidental.
Future work: Note that stdio/fseeko.c, stdio/ftello.c and common/s_isnand.c have
makedoc markup, but duplicate stdio/fseek.c, stdio/ftell.c and common/s_isnan.c
respectively.
2015-06-23 Jon Turney <jon.turney@dronecode.org.uk>
* libc/ctype/Makefile.am (CHEWOUT_FILES): Add isblank.def.
* libc/ctype/ctype.tex: Include isblank and add to menu.
* libc/posix/Makefile.am (CHEWOUT_FILES): Add posix_spawn.def.
* libc/posix/posix.tex: Include posix_spawn and add to menu.
* libc/stdio64/Makefile.am (CHEWOUT_FILES): Add fdopen.def.
* libc/stdio64/stdio64.tex: Include fdopen64 and add to menu.
* libc/stdio64/fdopen64.c: Improve one-line description.
* libc/string/Makefile.am (CHEWOUT_FILES): Add strchrnul.def.
* libc/string/strings.tex: Include strchrnul and add to menu.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Tue, 23 Jun 2015 13:10:14 +0000 (14:10 +0100)]
Use makedoc output files which are generated but aren't included
I think these are accidental omissions, as these source files are listed to be
chewed by makedoc, but the result is not included by any texinfo source file.
Future work: Nothing in libc/reent/ which is processed by makedoc is included by
reent.tex
2015-06-23 Jon Turney <jon.turney@dronecode.org.uk>
* libc/stdlib/stdlib.tex: Include itoa and utoa, and add to menu.
* libc/string/strings.tex: Include memrchr and rawmemchr, and add
to menu.
* libm/math/math.tex: Include exp10 and pow10, and add to menu.
* libm/common/s_exp10.c: Improve one-line description.
* libm/common/s_exp10.c: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Tue, 23 Jun 2015 12:00:57 +0000 (13:00 +0100)]
Fix SYNOPSIS prototypes without marked up parameter names
2015-06-23 Jon Turney <jon.turney@dronecode.org.uk>
* libc/stdlib/llabs.c: Mark up parameter name in ANSI_SYNOPSIS.
* libc/time/tzset.c: Add and mark up parameter in SYNOPSIS.
* libm/common/s_nan.c: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Wed, 11 Mar 2015 13:50:51 +0000 (13:50 +0000)]
winsup/doc: Create info pages from cygwin documentation
v2:
Updated to use docbook2x-texi not docbook2texi, since source is now docbook XML.
Tweak DocBook XML so info directory entry has a description.
v3:
Use a custom charmap to handle ®
v4:
Proper build avoidance
texinfo node references may not contain ':', so provide alternate text for a few
xref targets
2015-06-22 Jon Turney <jon.turney@dronecode.org.uk>
* Makefile.in (install-info, cygwin-ug-net.info)
(cygwin-api.info): Add.
* cygwin-ug-net.xml: Add texinfo-node.
* cygwin-api.xml: Ditto.
* ntsec.xml (db_home): Add texinfo-node for titles containing a
':' which are the targets of an xref.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Corinna Vinschen [Mon, 22 Jun 2015 11:09:55 +0000 (13:09 +0200)]
Don't push on original stack during alternate signal stack setup
* exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register
on the original stack, it confuses GCC. Rearrange the assembler code
so that $rax/$eax is not used by GCC to prepare an argument value.
Use $rax/$eax without saving. Drop clearing $rbp/$epb.
Corinna Vinschen [Sun, 21 Jun 2015 11:58:57 +0000 (13:58 +0200)]
Safe all clobbered volatile registers when using alternate stack
* exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16
bytes from the alternate stack, it's not necessary. Safe all clobbered
registers. Safe one on the orignal stack, the others on the alternate
stack on both platforms.
Corinna Vinschen [Fri, 19 Jun 2015 13:58:23 +0000 (15:58 +0200)]
Preliminary infrastructure to implement alternate stack
* libc/include/sys/signal.h: Define SS_ONSTACK and SS_DISABLE
unconditionally.
(sigaltstack): Enable prototype on Cygwin.
* common.din (sigaltstack): Export.
* cygtls.cc (_cygtls::init_thread): Initialize altstack.
* cygtls.h (__tlsstack_t): Rename from __stack_t to distinguish
more clearly from stack_t. Accommodate throughout.
(_cygtls): Add altstack member.
* exceptions.cc (exception::handle): Set SIGSEGV handler to SIG_DFL
if we encounter a stack overflow, and no alternate stack has been
defined.
* include/cygwin/signal.h (MINSIGSTKSZ): Define
(SIGSTKSZ): Define.
(SA_ONSTACK): Define.
* signal.cc (sigaltstack): New function.
* tlsoffset.h: Regenerate.
* tlsoffset64.h: Ditto.
Jon TURNEY [Tue, 16 Jun 2015 17:52:37 +0000 (18:52 +0100)]
winsup/doc: Convert cygwin-api function documentation to refentry elements
Convert cygwin-api from using a sect2 element to using a refentry element for
each function. This makes it possible to generate manpage-style output for
those elements.
Note that the chunked html now generates a page for each function, rather than
one containing all functions.
Also:
Remove pointless and incorrect date
Move introductory paragraph from the first section to the start of the chapter
Add a funcsynopsisinfo element with the header file to be included to each
function prototype
Remove extern "C" which doesn't process into all formats successfully
2015-06-17 Jon Turney <jon.turney@dronecode.org.uk>
* cygwin-api.xml: Move introductory paragraph here.
* logon-funcs.xml: Convert from using a sect2 element to using a
refentry element for each function.
* misc-funcs.xml: Ditto.
* path.xml: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Tue, 16 Jun 2015 17:40:29 +0000 (18:40 +0100)]
winsup/doc: Generate ANSI rather than K&R style function prototypes
Since K&R style prototypes appear to be the default for HTML and FO, customize
the stylesheets rendering of funcsynopsis elements to generate ANSI style
prototypes instead.
2015-06-17 Jon Turney <jon.turney@dronecode.org.uk>
* fo.xsl: Render funcsynopsis elements as ANSI style function
prototypes.
* html.xsl: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Corinna Vinschen [Wed, 17 Jun 2015 09:11:02 +0000 (11:11 +0200)]
Add sethostname
* net.cc (sethostname): New function.
* common.din (sethostname): Export
* include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001.
(CYGWIN_VERSION_DLL_MINOR): Set to 0.
* new-features.xml (ov-new): Rename from ov-new1.7.
(ov-new2.1): Add new section. Document sethostname.
Jon TURNEY [Fri, 12 Jun 2015 12:33:13 +0000 (13:33 +0100)]
winsup/doc: Make and install manpages for utils
Use 'xmlto man' to make manpages for utils
(docbook2x-man could also be used, but since we already use xmlto...)
This will generate multiple .1 files as an output, but we don't know what they
will be called, so use a timestamp file for build avoidance when the
dependencies haven't changed.
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
* Makefile.in (install-man, utils2man.stamp): Add rules to build
and install manpages for utils.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Fri, 12 Jun 2015 13:51:00 +0000 (14:51 +0100)]
winsup/doc: Convert utils.xml to using refentry elements
Convert utils.xml from using a sect2 element to using a refentry element for
each utility program. This makes it possible to generate manpage-style output
for those elements.
Note that the chunked html now generates a page for each utility, rather than
one containing all utilities.
A small customization to TOC generation for HTML and PDF is needed to ensure
that it appears as before, containing an entry for each utility command.
Future work: synopsis and options sections could use more detailed markup than
just wrapping the whole thing in <screen>
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
* utils.xml : Convert from using a sect2 element to using a
refentry element for each utility program.
* cygwin.xsl: Customize autotoc to include refentries.
* fo.xsl: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Fri, 12 Jun 2015 13:18:07 +0000 (14:18 +0100)]
winsup/doc: Fix an issue with parallel make
The cygwin-ug-net-nochunks.html.gz target does not ensure that the
cygwin-ug-net/ directory exists, so it can fail if run on it's own, or if the
cygwin-ug-net/cygwin-ug-net.html target has not yet created it in a parallel
make.
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
Jon TURNEY [Fri, 12 Jun 2015 12:30:50 +0000 (13:30 +0100)]
winsup/doc: Make it easier to extend xidepend to more targets
Change xidepend to create a variable containing all the XIncluded sources, which
can be used as a dependency, rather than writing the dependency target itself.
Future work: Makefile.dep should depend on xidepend, but xidepend should not be
passed to itself.
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
* xidepend: Write a Makefile fragment defining variables
containing all the XIncluded sources, rather than a dependency on
those sources.
* Makefile.in: Use that variable to express the dependency.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Tue, 16 Jun 2015 09:17:19 +0000 (10:17 +0100)]
winsup/doc: Some preparatory XML fixes
Remove the inconsistent .exe suffix in strace and umount usage lines.
Tidy up some trailing whitespace.
Tabs inside <screen> are not consistently formatted by all formatters, replace
with spaces.
Remove pointlesss and incorrect date
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
* cygwin-ug-net.xml: Remove incorrect unused date.
* utils.xml : Remove .exe suffix inconsistently added in a few
places. Tidy up some trailing whitespace.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Fri, 12 Jun 2015 09:56:55 +0000 (10:56 +0100)]
winsup/doc: Fix xidepend to handle relative pathnames
It seems that xidepend doesn't work correctly if we are ./configure'd using a
relative pathname to the srcdir:
$ make
cd ../../../../src/winsup/doc && ./xidepend ../../../../src/winsup/doc/cygwin-ug-net.xml ../../../../src/winsup/doc/cygwin-api.xml >"/wip/cygwin/build/x86_64-unknown-cygwin/winsup/doc/Makefile.dep"
grep: ../../../../src/winsup/doc/cygwin-ug-net.xml: No such file or directory
grep: ../../../../src/winsup/doc/cygwin-api.xml: No such file or directory
Although it might be better to fix this by making xidepend use pathnames, rather
than ignoring them and assuming everything is in the current directory...
2015-06-12 Jon Turney <jon.turney@dronecode.org.uk>
* xidepend: Fix to handle relative pathnames.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Corinna Vinschen [Mon, 15 Jun 2015 16:29:56 +0000 (18:29 +0200)]
Try to handle concurrent close on socket more gracefully
* fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with
invalid mutex handle since then socket has been closed.
(UNLOCK_EVENTS): Close critical section.
(fhandler_socket::evaluate_events): Handle calling connect on shutdown
socket.
(fhandler_socket::wait_for_events): Try for pthread_testcancel in case
of WAIT_FAILED. Try to come up with a better errno in case we waited
on an invalid handle.
(fhandler_socket::release_events): Change wsock_mtx and wsock_evt to
NULL under lock to avoid accessing invalid handle.
Jon TURNEY [Sat, 16 May 2015 14:19:59 +0000 (15:19 +0100)]
Improve strace to log most Windows debug events
Not sure if this is wanted, but on a couple of occasions recently I have been
presented with strace output which contains an exception at an address in an
unknown module (i.e. not in the cygwin DLL or the main executable), so here is a
patch which adds some more information, including DLL load addresses, to help
interpret such straces.
v2:
Use NtQueryObject() for HANDLE -> filename conversion
Add new '-e' option to toggle this additional logging
2015-06-07 Jon Turney <jon.turney@dronecode.org.uk>
* strace.cc (proc_child): Log process and thread create and exit,
and DLL load and unload.
(GetFileNameFromHandle): New function.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Corinna Vinschen [Wed, 10 Jun 2015 09:07:27 +0000 (11:07 +0200)]
Drop Windows 2000 considerations in ps, fix uid field length
* ps.cc (main): Widen UID field in long format to accommodate longer
UIDs since Cygwin 1.7.34. Remove Windows 2000 considerations. Fix
comments accordingly.
Evaluate /proc/$PID/{root,cwd,cmdline} for native processes
* pinfo.cc (_pinfo::root): Fake default root for native processes.
(open_commune_proc_parms): New helper function to access process
parameter block.
(_pinfo::cwd): Fetch missing cwd for native processes from processes
parameter block.
(_pinfo::cmdline): Ditto for command line.
Jon TURNEY [Wed, 11 Mar 2015 13:52:01 +0000 (13:52 +0000)]
winsup/doc: Remove ancient unused Makefile rules to make documentation tarball
This used to be used by cygwin-doc to make a tarball which would be used with a
ssh script to run docbook tools on a linux host since they weren't available on
Cygwin or something crazy like that...
2015-06-04 Jon Turney <jon.turney@dronecode.org.uk>
* Makefile.in: Remove ancient unused rules to make a documentation
tarball.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Jon TURNEY [Thu, 21 May 2015 16:34:41 +0000 (17:34 +0100)]
Remove mention of installing everything
An estimate of the size of installing of "hundreds of megabytes" is wildly out
of date. Just remove mention of installing everything, since it is nearly
always not a good idea.
2015-06-01 Jon Turney <jon.turney@dronecode.org.uk>
* ov-ex-unix.xml: Remove unhelpful mention of and inaccurate size
estimate for installing everything.
* ov-ex-win.xml: Ditto.
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Szabolcs Nagy [Mon, 1 Jun 2015 08:17:34 +0000 (10:17 +0200)]
aarch64: fabs and sqrt implementation with inline asm
* libm/machine/aarch64/e_sqrt.c: New file.
* libm/machine/aarch64/ef_sqrt.c: New file.
* libm/machine/aarch64/s_fabs.c: New file.
* libm/machine/aarch64/sf_fabs.c: New file.
* libm/machine/aarch64/Makefile.in: Add new source files.
* libm/machine/aarch64/Makefile.am: Regenerate.