Commit Graph

16591 Commits

Author SHA1 Message Date
Jeff Johnston 31cf34f849 or1k: Allow exception nesting
Allow exceptions to be nested, which is especially useful with urgent
    interrupts while processing an exception.

    The implementation counts up the nesting level with each call to an
    exception. In the outer exception (level 1), the exception stack is
    started. All nested exceptions just reserve the redzone (scratch
    memory that may be used by compiler) and exception context on the
    stack, but then process on the same scratch.

    Restriction: Impure pointers are shared among all exceptions. This may
    be solved by creating an impure data structure in the stack frame with
    each nested exception.

       * or1k/crt0.S: Add exception nesting
       * or1k/exceptions-asm.S: ditto
       * or1k/util.c: ditto
2015-08-07 15:02:03 -04:00
Jeff Johnston 4098f69c43 or1k: Fix critical handling in malloc locks
Only on first call to the recursive malloc lock the restore value of
    exception enable fields is stored.

    	  * libc/sys/or1k/mlock.c: Fix exception enable saving
2015-08-07 15:01:58 -04:00
Jeff Johnston 0d04c03829 or1k: Make heap end globally visible
Boards may change the initial value from _end to another value.

           * or1k/sbrk.c: Make heap end globally visible
2015-08-07 15:01:50 -04:00
Jon TURNEY 49380b7ee3 Improve FAQ answer on debugging Cygwin
Improve FAQ answer on debugging Cygwin to mention the cygwin-debuginfo package
and the gdb command 'set cygwin-exceptions on'.

2015-08-03  Jon Turney  <jon.turney@dronecode.org.uk>

	* faq-programming.xml: Improve debugging-cygwin answer.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-08-05 20:17:55 +01:00
Nick Clifton 9698cc0f33 This is part of a larger fix for RL78 complex relocs - they need an absolute symbol at address 0 that is not part of the *ABS* section.
* rl78/rl78-sim.ld: Provide a value for __rl78_abs__.
	* rl78/rl78.ld: Likewise.
2015-08-04 13:38:27 +01:00
Shoichi Sakon 001ef5af39 Fix wscanf family positional parameter handling in %lc, %ls, %l[]
* libc/stdio/vfwscanf.c (__SVFWSCANF_R): Convert wrong usage of va_arg
        to GET_ARG in %lc, %ls nad %l[] cases.  Fix unterminated string in %l[]
        case.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-03 21:51:35 +02:00
Corinna Vinschen 09d458b5c7 Bump Cygwin DLL minor number.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-03 21:46:55 +02:00
Corinna Vinschen fe24411770 strace: Handle ofile descriptor more carefully.
Fix coverity CIDs 128250 - 128252

        * strace.cc (main2): Don't call setvbuf on NULL descriptor.
        Explicitely fclose ofile.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-03 12:02:17 +02:00
Jon TURNEY 6fc911071f Don't include stdio64 functions in reentrant syscalls menu when not bulding stdio64.
Fix documentation build since 6c2b1842 by not including stdio64 functions in the
reent syscalls menu if the node itself isn't going to be included because it's
under the STDIO64 flag.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-08-03 09:54:33 +01:00
Sebastian Huber b7ca25162a Fix typo in <sys/lock.h>
Sorry, there was a typo in <sys/lock.h> which leads to memory corruption
since not enough space is reserved for the lock object.

newlib/ChangeLog
2015-07-30  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* libc/sys/rtems/include/sys/lock.h (__LOCK_INIT_RECURSIVE): Use
	proper type.
2015-07-31 06:21:04 -07:00
Wilco Dijkstra 127c38bd44 [AArch64] Rewrite optimized memset.
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.
2015-07-30 12:51:34 +01:00
Corinna Vinschen 7666b3634b Cygwin: Fix x86_64 memcpy/memset for n > 2GB
https://cygwin.com/ml/cygwin/2015-07/msg00344.html:

	RtlFillMemory and RtlCopyMemory only work for size values
	up to 2GB.  Fix this problem by using NetBSD code for
	memset and memcpy.  Add entry points for memmove, wmemset,
	wmemmove, wmemcpy.  Thanks to Roman Petrovski
	<RPetrovski@illumina.com> for pointing this out.

        * miscfuncs.cc (memset): x86_64 only: Implement in assembler.
        (memmove,memcpy): x86_64 only: Ditto.
        (wmemmove,wmemcpy): x86_64 only: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 22:09:34 +02:00
Sebastian Huber f04e46b141 Move header files
During libgcc build the first include search path for <...> is
"../newlib/libc/sys/rtems/include".  Move all RTEMS specific header
files to "libc/sys/rtems/include" so that they can be found.  Later
during libc build the header files in the previous location were somehow
present, but for libgcc build they were invisible.  This change is
necessary to use <pthread.h> for the GCC thread model implementation.

newlib/ChangeLog
2015-07-27  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	libc/sys/rtems/machine/_types.h: Move to ...
	libc/sys/rtems/include/machine/_types.h: ... here.
	libc/sys/rtems/machine/limits.h: Move to ...
	libc/sys/rtems/include/machine/limits.h: ... here.
	libc/sys/rtems/machine/param.h: Move to ...
	libc/sys/rtems/include/machine/param.h: ... here.
	libc/sys/rtems/sys/cpuset.h: Move to ...
	libc/sys/rtems/include/sys/cpuset.h: ... here.
	libc/sys/rtems/sys/dirent.h: Move to ...
	libc/sys/rtems/include/sys/dirent.h: ... here.
	libc/sys/rtems/sys/param.h: Move to ...
	libc/sys/rtems/include/sys/param.h: ... here.
	libc/sys/rtems/sys/syslimits.h: Move to ...
	libc/sys/rtems/include/sys/syslimits.h: ... here.
	libc/sys/rtems/sys/utime.h: Move to ...
	libc/sys/rtems/include/sys/utime.h: ... here.
2015-07-29 12:53:53 -07:00
Joel Sherrill 763e0b7baf newlib/ChangeLog: Left out of previous commit. 2015-07-29 12:48:07 -07:00
Sebastian Huber ecaef05f66 Add <sys/lock.h>
Provide self-contained synchronization objects for RTEMS.  The API was
designed to be able to use it for the Newlib internal locks, the C11
threads support, the GCC thread model support and the libgomp operating
system configuration in combination with <pthread.h>.

References:

https://lists.rtems.org/pipermail/devel/2015-July/011989.html
https://lists.rtems.org/pipermail/devel/2015-July/012000.html

Tickets:

https://devel.rtems.org/ticket/1247
https://devel.rtems.org/ticket/2274.

v2: Fix typo in _Condition_Wait_recursive_timed() declaration.

newlib/ChangeLog
2015-07-28  Sebastian Huber  <sebastian.huber@embedded-brains.de>

	* libc/sys/rtems/include/sys/lock.h: New.
2015-07-29 11:30:05 -07:00
Corinna Vinschen d32ea61ae4 cygwin: Fix copyright dates
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 13:45:46 +02:00
Corinna Vinschen 6ab56bdd3f cygwin: Fix crashes under AllocationPreference=0x100000 condition
* cygtls.h: Include cygtls_padsize.h and define CYGTLS_PADSIZE there.
        * cygtls_padsize.h: New file.  Define CYGTLS_PADSIZE.
        * environ.cc (parse_options): Fix NULL pointer access.
        * init.cc (threadfunc_fe): Do not force stack align on x86_64.

        * strace.cc (main2): Rename from main.
        (main): Make room for _cygtls area on stack and just call main2.  Add
        comment to explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 13:32:29 +02:00
Jon TURNEY 9753bc3333 Remove workaround for texinfo bug with underscores in filenames from mothballed mathfp/
This got removed everywhere else in commit 139f923b, so I'm assuming whatever
ancient bug this was has been fixed long since.

There are plenty of other uses of texinfo with a filename containing an
underscore now.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:11 +01:00
Jon TURNEY 556a3ef544 Remove a stray sentence fragment in iconv.tex
I can't work out any meaning for this random sentence fragment, so remove it.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:09 +01:00
Jon TURNEY fde9684b52 Fix a typo in iconv.tex
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:07 +01:00
Jon TURNEY fdb73a8e43 Fix SYNPOSIS prototypes for iconv functions
Terminate all protoypes with a semicolon.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:05 +01:00
Jon TURNEY 6c2b184277 Use makedoc generated texinfo documentation for reentrant syscalls
We use texinfo nodes beginning with an underscore in several other places, so
revert this ancient workaround for a no longer existing bug, and use the makedoc
generated texinfo for reentrant versions of syscalls, rather than handwritten
documentation.

Also alphabetically sort these functions.

Also add documentation for _execve_r, _getpid_r, _kill_r and _times_r functions,
whose non-reentrant versions are documented as stubs

v2:
Keep _open64_r, _lseek64_r and _fstat64_r functions under texinfo conditional STDIO64
Add _stat64_r function likewise.

Notes:

1. The handwritten prototypes give the reentrancy structure pointer as of type
void *, rather than the presumably more correct struct __reent *

2. The fcntl, gettimeofday, mkdir and rename functions are not documented as
stubs, so I haven't added the reentrant versions either

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:03 +01:00
Jon TURNEY 1c19a13fd1 Add missing NEWPAGE commands to makedoc markup in reent/
makedoc requires a NEWPAGE command to preceed the second and subsequent FUNCTION
commands in a file in order to produce the correct texinfo output.

Add missing NEWPAGE commands needed in reent/execr.c. and reent/signalr.c, which
contain makedoc markup for multiple functions.

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
2015-07-24 15:50:00 +01:00
Corinna Vinschen 03c8afda17 Improve cygwin 2.2.0 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 21:19:43 +02:00
Corinna Vinschen be8183701a Fix potential buffer overflow in makecontext trampoline
glibc's tst-makecontext2 testcase uncovered a bug in
	__cont_link_context.  If the function misses to reserve
	shadow space for the calls to setcontext/cygwin_exit,
	both functions could overwrite memory beyond the stack
	configured in uc_stack.

        * exceptions.cc (__cont_link_context): x86_64: align stack and reserve
        shadow space for subsequent function calls, otherwise suffer potential
        buffer overflow.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 20:25:22 +02:00
Corinna Vinschen 1e80973f28 Ignore non-absolute $HOME when started from native process
* uinfo.cc (cygheap_user::ontherange): Ignore $HOME if it's not
	starting with a slash (aka, absolute POSIX Path).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-23 17:42:07 +02:00
Corinna Vinschen 7c96ab0b43 Cygwin: Implement siglongjmp and sigsetjmp functions.
* libc/include/machine/setjmp.h (siglongjmp): Declare as function on
	Cygwin.
	(sigsetjmp): Ditto.
	(_longjmp): Mark as noreturn function on Cygwin.

	* common.din (siglongjmp): Export.
	(sigsetjmp): Export.
	* gendef: Change formatting of some comments.
	(sigsetjmp): Implement.
	(siglongjmp): Implement.
	(__setjmpex): x86_64 only: Drop entry point.
	(setjmp): x86_64 only: Store tls stackptr in Frame now, store MXCSR
	and FPUCW registers in Spare, as MSVCRT does.
	(longjmp): x86_64 only: Restore tls stackptr from Frame now, restore
	MXCSR and FPUCW registers from Spare.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

	* new-features.xml (ov-new2.2): Document sigsetjmp, siglongjmp.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-21 17:31:02 +02:00
Corinna Vinschen b723ec272e Add previous ldd fix to release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-20 18:43:16 +02:00
Corinna Vinschen 23ad79d7de Fix potential hang in ldd if DLL encounters missing entry point
* ldd.cc (STATUS_DLL_NOT_FOUND): Drop definition.
        (report): Handle STATUS_ENTRYPOINT_NOT_FOUND exception.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-20 18:32:24 +02:00
Corinna Vinschen e437a7d826 Lower Cygwin's MINSIGSTKSZ and SIGSTKSZ
* include/cygwin/signal.h (MINSIGSTKSZ): Define as 8K, unconditionally.
        (SIGSTKSZ): Define as 32K, unconditionally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-19 22:40:29 +02:00
Corinna Vinschen 4889f730c1 Reduce stack pressure throughout Cygwin
* dcrt0.cc (initial_env): Reduce size of local path buffers to
        PATH_MAX.  Allocate debugger_command from process heap.
        (init_windows_system_directory): Very early initialize new global
        variable global_progname.
        * dll_init.cc (dll_list::alloc): Make path buffer static.  Explain why.
        (dll_list::populate_deps): Use tmp_pathbuf for local path buffer.
        * exceptions.cc (debugger_command): Convert to PWCHAR.
        (error_start_init): Allocate debugger_command and fill with wide char
        strings.  Only allocate if NULL.
        (try_to_debug): Just check if debugger_command is a NULL pointer to
        return.  Drop conversion from char to WCHAR and drop local variable
        dbg_cmd.
        * globals.cc (global_progname): New global variable to store Windows
        application path.
        * pinfo.cc (pinfo_basic::pinfo_basic): Just copy progname over from
        global_progname.
        (pinfo::status_exit): Let path_conv create the POSIX path to
        avoid local buffer.
        * pseudo_reloc.cc (__report_error): Utilize global_progname, drop local
        buffer.
        * smallprint.cc (__small_vsprintf): Just utilize global_progname for
        %P format specifier.
        (__small_vswprintf): Ditto.
        * strace.cc (PROTECT): Change to reflect x being a pointer.  Reformat.
        (CHECK): Ditto.  Reformat.
        (strace::activate): Utilize global_progname, drop local buffer.
        Fix formatting.
        (strace::vsprntf): Reduce size of local progname buffer to NAME_MAX.
        Copy and, if necessary, convert only the last path component to
        progname.
        (strace_buf_guard): New muto.
        (buf): New static pointer.
        (strace::vprntf): Use buf under strace_buf_guard lock only.  Allocate
        buffer space for buf on Windows heap.
        * wow64.cc (wow64_respawn_process): Utilize global_progname, drop
        local path buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-19 22:38:30 +02:00
Corinna Vinschen 93a8435f82 Remove x86_64 __sjfault/__ljfault
* gendef: Remove unused 64 bit versions of __sjfault and __ljfault.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-18 14:48:32 +02:00
Corinna Vinschen 877b02be08 Rearrange makecontext and add lots of comments
* exceptions.cc (makecontext): Rearrange order of initialization and
        document at great length.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-18 12:35:23 +02:00
Corinna Vinschen b2df1577c7 Fix ucontext creation in call_signal handler
* exceptions.cc (__unwind_single_frame): Define empty macro on i686.
        (_cygtls::call_signal_handler): Try to make sure signal context makes
        sense in case we're generating context here.  Add comment to explain.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 18:29:52 +02:00
Corinna Vinschen 16d2d9f131 Comment fixup
* exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext.
        (swapcontext/x86_64): Fix comment yet again.
        (getcontext/i686): Move comment from x86_64 getcontext, slightly
        rearranged, to preceeding comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 16:47:14 +02:00
Corinna Vinschen b3ccf998cc Reuse __unwind_single_frame where appropriate
* exceptions.cc (__unwind_single_frame): Move up in file to be
        accessible from other places.  Move comment to getcontext.
        (stack_info::walk): Call __unwind_single_frame in 64 bit case.  Fix
        preceeding comment.
        (myfault_altstack_handler): Call __unwind_single_frame.
        (getcontext): Give comment from __unwind_single_frame a new home.
        (swapcontext): Fix comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 16:29:41 +02:00
Corinna Vinschen 1020bb292a Implement getcontext, setcontext, makecontext, swapcontext
* common.din (getcontext): Export.
        (makecontext): Export.
        (setcontext): Export.
        (swapcontext): Export.
        * exceptions.cc (__unwind_single_frame): New static functions, 64 bit
        only.
        (setcontext): New function.
        (getcontext): New function.
        (swapcontext): New function.
        (__cont_link_context): New function.
        (makecontext): New function.
        * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2002.
        (CYGWIN_VERSION_API_MINOR): Bump.
        * include/ucontext.h (getcontext): Add prototype.
        (setcontext): Ditto.
        (swapcontext): Ditto.
        (makecontext): Ditto.
        * ntdll.h (NtContinue): Ditto.

        * new-features.xml (ov-new2.2): Add new section.  Document getcontext,
        setcontext, makecontext, swapcontext.
        * posix.xml (std-deprec): Add getcontext, setcontext, makecontext,
        swapcontext.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 14:31:12 +02:00
Corinna Vinschen 9a69aac0ed Document the fact that we forgot to bump for sigaltstack and sethostname
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-17 14:02:43 +02:00
Marcus Shawcroft c7806ef76a [AArch64] Reverting recent optimized memset(). 2015-07-15 13:34:58 +01:00
Andre Simoes Dias Vieira c028685518 Change to nano.specs to add nano's include dir
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-14 15:55:18 +02:00
Corinna Vinschen 211cd495c4 exceptions.cc: Reenable code only disabled for debug purposes
* exceptions.cc (exception::handle): Reenable code only disabled for
	debug purposes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-13 16:08:29 +02:00
Wilco Dijkstra 3263f90ef7 [AArch64] Optimized memset.
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.
2015-07-13 13:17:16 +01:00
Marcus Shawcroft 8e6a9ad74d Fix ChangeLog entry for previous two commits. 2015-07-13 13:17:04 +01:00
Wilco Dijkstra b295f6ba44 [AArch64] Optimized memcpy.
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.
2015-07-13 13:09:02 +01:00
Wilco Dijkstra 9503c7f275 [AArch64] Optimized memmove.
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.
2015-07-13 13:03:02 +01:00
Jeff Johnston a505f607be Fix typo in README. 2015-07-10 16:49:40 -04:00
Corinna Vinschen b90a91a618 tzset: Check timezone and country case-insensitive
* tzset.c (main): Check timezone and country case-insensitive.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-08 10:25:49 +02:00
Corinna Vinschen e6b882b957 Add accidentally missing ChangeLog entry for previous patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 20:49:02 +02:00
Corinna Vinschen 60f10c64aa 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 20:45:06 +02:00
Corinna Vinschen 29a1263227 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.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-07 17:24:49 +02:00