Cygwin's strxfrm/wcsfrm treated a too short output buffer as an error
condition and always returned the size value provided as third parameter.
This is not as it's documented in POSIX.1-2008. Rather, the only error
condition is an invalid input string(*).
Other than that, the functions are supposed to return the length of the
resulting sort key, even if the output buffer is too small. In the latter
case the content of the output array is unspecified, but it's the job
of the application to check that the return value is greater or equal to
the provided buffer size.
(*) We have to make an exception in Cygwin: strxfrm has to call the
UNICODE function LCMapStringW for reasons outlined in a source comment.
If the incoming multibyte string is so large that we fail to malloc
the space required to convert it to a wchar_t string, we have to
ser errno as well since we have nothing to call LCMapStringW with.
* nlsfuncs.cc (wcsxfrm): Fix expression computing offset of
trailing wchar_t NUL. Compute correct return value even if
output buffer is too small.
(strxfrm): Handle failing malloc. Compute correct return value
even if output buffer is too small.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Move the kernel dependent parts of <sys/time.h> to new system-specific
header file <machine/_time.h>. Provide an empty default implementation.
Add a specialized implementation for RTEMS.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This include is not present in default Newlib, glibc and FreeBSD
<sys/param.h>. With it there is now a conflict with <sys/libkern.h>
introduced by ecf453f963.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
In 7346568 (Make requested console reports work, 2016-03-16), code was
introduced to report the current cursor position. It works by using a
pointer that either points to the next byte in the readahead buffer, or
to a NUL byte if the buffer is depleted, or the pointer is NULL.
These conditions are heeded in the fhandler_console::read() method, but
the condition that the pointer can point at the end of the readahead
buffer was not handled properly in the get_cons_readahead_valid()
method.
This poses a problem e.g. in Git for Windows (which uses a slightly
modified MSYS2 runtime which is in turn a slightly modified Cygwin
runtime) when vim queries the cursor position and immediately goes on to
read console input, erroneously thinking that the readahead buffer is
valid when it is already depleted instead. This condition results in an
apparent freeze that can be helped only by pressing keys repeatedly.
The full Git for Windows bug report is here:
https://github.com/git-for-windows/git/issues/711
Let's just teach the get_cons_readahead_valid() method to handle a
depleted readahead buffer correctly.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This reverts commit 0008bdea02.
This patch introduced a regression. Calling FOO=$(...) in zsh hangs
indefinitely and has to be killed forcefully.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The available specifications obviously differ on 32-bit and 64-bit, as
already handled in <sys/features.h>.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
POSIX spawn and thread barriers have since been added. Also fix a typo in
_POSIX2_C_DEV (result is the same).
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
As a Cygwin-specific header, there is no need to guard functions based on
capability macros. Instead, guard several blocks based on additions or
removals in later versions of POSIX.1, along with a few which are only
XSI or GNU extensions.
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Each version of SUS specifies a different value for _POSIX_VERSION,
_POSIX2_VERSION, and _XOPEN_VERSION. glibc also changes the value
of the other _POSIX2_ variables but not the _POSIX_* variables.
_POSIX_TIMERS should be set to a version number, not just 1.
The _POSIX_V7_* macros were missing, which was not noticed because
the V6 values were aliased in sysconf (<unistd.h>).
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
G++ 6.0 asserts that the "this" pointer is non-null for member
functions.
Refactor methods that check if "this" is non-null to resolve this.
winsup/cygwin/ChangeLog:
external.cc (cygwin_internal): Check for a null pinfo before calling
cmdline.
fhandler_dsp.cc (Audio::blockSize): Make static.
fhandler_dsp.cc (Audio_in): add default_buf_info.
fhandler_dsp.cc (Audio_out): Ditto.
fhandler_dsp.cc (Audio_out::buf_info): Refactor method to call
default_buf_info if dev_ is null.
fhandler_dsp.cc (Audio_in::buf_info): Ditto.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_out::default_buf_info if audio_out_ is null.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_in::default_buf_info if audio_in_ is null.
fhandler_process.cc (format_process_fd): Check if pinfo is null.
fhandler_process.cc (format_process_root): Ditto.
fhandler_process.cc (format_process_cwd): Ditto.
fhandler_process.cc (format_process_cmdline): Ditto.
signal.cc (tty_min::kill_pgrp): Ditto.
signal.cc (_pinfo::kill0): Ditto.
sigproc.cc (pid_exists): Ditto.
sigproc.cc (remove_proc): Ditto.
times.cc (clock_gettime): Ditto.
times.cc (clock_getcpuclockid): Ditto.
path.cc (cwdstuff::override_win32_cwd): Check if old_cwd is null.
path.cc (fcwd_access_t::Free): Factor null check of "this" out to
caller(s).
pinfo.cc (_pinfo::exists): Ditto.
pinfo.cc (_pinfo::fd): Ditto.
pinfo.cc (_pinfo::fds): Ditto.
pinfo.cc (_pinfo::root): Ditto.
pinfo.cc (_pinfo::cwd): Ditto.
pinfo.cc (_pinfo::cmdline): Ditto.
signal.cc (_pinfo::kill): Ditto.
pinfo.cc (_pinfo::commune_request): remove non-null check on "this", as
this method is only called from pinfo.cc after null checks
pinfo.cc (_pinfo::pipe_fhandler): remove non-null check on "this", as
this method is only called from pipe.cc (fhandler_pipe::open) after a null check.
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
Rename without-mingw-progs to with-cross-bootstrap, since it now
disables additional checks that are problematic for cross-compilers.
When cross-compiling a toolchain targeting cygwin, building cygwin1.dll
requires libgcc.
However, building libgcc requires the cygwin headers to be
installed.
Configuring cygwin requries the mingw-crt libraries, which require the
cygwin headers to be installed.
Work around this circular dependency by making the
--with-cross-bootstrap configure option skip cygwin's configure checks
for valid mingw-crt libraries. Cygwin will still properly link against
these libraries if they exist, but this allows configure to succeed even
if the libraries have not been built yet.
Since the mingw-crt libraries only require the cygwin headers to be
installed, this allows us to successfully configure cygwin so that we
can only install the headers without trying to build any
libraries.
winsup/ChangeLog
configure.ac: rename without-mingw-progs option to with-cross-bootstrap
configure: regenerate
winsup/cygserver/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate
winsup/cygwin/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
Intel MCU System V ABI are incompartible with i386 System V ABI:
o Minimum instruction set is Intel Pentium ISA minus x87 instructions
o No x87 or vector registers
o First three args are passed in %eax, %edx and %ecx
o Full specification available here:
https://github.com/hjl-tools/x86-psABI/wiki/iamcu-psABI-0.7.pdf
newlib/
* configure.host: Add new ix86-*-elfiamcu target
newlib/libc/include/
* setjmp.h: Change _JBLEN for Intel MCU target
newlib/libc/machine/i386/
* memchr.S: (memchr) Target-specific size-optimized version
* memcmp.S: (memcmp) Likewise
* memcpy.S: (memcpy) Likewise
* memmove.S: (memmove) Likewise
* memset.S: (memset) Likewise
* setjmp.S: (setjmp) Likewise
* strchr.S: (strchr) Likewise
* strlen.S: (strlen) Likewise
newlib/libc/stdlib/
* srtold.c: (__flt_rounds) Disable for Intel MCU
Use the 3-arg form of AC_DEFINE.
winsup/cygwin/ChangeLog:
acconfig.h: Remove DEBUGGING define.
configure.ac: Add description to DEBUGGING define.
config.h.in: Regenerate.
configure: Ditto.
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
HAVE_BUILTIN_MEMTEST and AC_ALLOCA were removed in 4bd8eb7d1b.
Cleanup leftover references.
winsup/cygwin/ChangeLog
acconfig.h: remove HAVE_BUILTIN_MEMTEST
config.h.in: regenerate
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
When building cygwin in a combined tree with binutils,
the just-built windres cannot find the just-buit gcc automatically.
Parse the CC env variable to use the correct compiler, rather then
falling back to the build-system's gcc which does not define the proper
preprocessor macros.
winsup/cygwin/ChangeLog
mkvers.sh: Manually specify preprocessor based on $CC
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
The type for the ip_tos member was typoed, fix it.
winsup/cygwin/ChangeLog:
include/netinet/ip.h: fix type of ip_tos
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
After `make clean', the build can fail because the dependencies don't
require the tlsoffsets file to exist before building obejct files.
This patch fixes it.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Add an option to not require a mingw compiler when bootstrapping a cross toolchain.
Defaults to existing behavior.
Also update some obsolete macros.
winsup/ChangeLog
configure.ac: Add option to skip building programs that require mingw.
configure: Regenerate.
Signed-off-by: Peter Foley <pefoley2@pefoley.com>
On Linux and in Mingw-w64, fexcept_t is defined as type unsigned short.
There are packages in the wild which rely on the fact that fexcept_t is
an integral type. We're changing the internal handling to use the bits
just as in GLibc, so only the 6 lowest bits are used to reflect the hw
bits. We even change the header file guard to reflect GLibc for compatibility.
* include/fenv.h (_FENV_H): Rename from _FENV_H_ and set to 1 as in
GLibc's header.
(fexcept_t): Change to __uint16_t to be an integral type as in GLibc.
* fenv.cc (fegetexceptflag): Align to the *flagp's type change.
(fesetexceptflag): Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This patch adds the long double functions missing in newlib to Cygwin.
Apart from some self-written additions (exp10l, finite{f,l}, isinf{f,l},
isnan{f,l}, pow10l) the files are taken from the Mingw-w64 math lib.
Minor changes were required, e.g. substitue _WIN64 with __x86_64__ and
fixing __FLT_RPT_DOMAIN/__FLT_RPT_ERANGE for Cygwin.
Cygwin:
* math: New subdir with math functions.
* Makefile.in (VPATH): Add math subdir.
(MATH_OFILES): List of object files collected from building files in
math subdir.
(DLL_OFILES): Add $(MATH_OFILES).
${CURDIR}/libm.a: Add $(MATH_OFILES) to build.
* common.din: Add new functions from math subdir.
* i686.din: Align to new math subdir. Remove functions now commonly
available.
* x86_64.din: Ditto.
* math.h: math.h wrapper to define mingw structs used in some files in
math subdir.
* include/cygwin/version.h: Bump API minor version.
newlib:
* libc/include/complex.h: Add prototypes for complex long double
functions. Only define for Cygwin.
* libc/include/math.h: Additionally enable prototypes of long double
functions for Cygwin. Add Cygwin-only prototypes for dreml, sincosl,
exp10l and pow10l. Explain why we don't add them to newlib.
* libc/include/tgmath.h: Enable long double handling on Cygwin.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
setstate is supposed to take a char *, not a const char *.
* random.cc (setstate): Unconstify parameter to align to stdlib.h.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The inclusion of <sys/cygwin.h> by <sys/shm.h>, besides causing namespace
pollution, also makes it very difficult to get the WINVER-dependent parts
of the former. This affects code (such as x11vnc -unixpw_nis) which use
both SysV shared memory (e.g. the X11 MIT-SHM extension) and user password
authentication.
getpagesize is the simplest function to retreive this information, but it
is a legacy function and would also pollute the global namespace. The LSB
lists another form which is in the implementation-reserved namespace:
http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib---getpagesize.html
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
Prototypes also added for initstate() and setstate() but they
were not implemented in the shared newlib code.
* newlib/libc/include/cygwin/stdlib.h: Prototypes added.
* winsup/cygwin/include/cygwin/stdlib.h: Prototypes removed.
* newlib/libc/stdlib/random.c: New file.
* newlib/libc/machine/epiphany/machine/stdlib.h: Removed
* newlib/libc/stdlib/Makefile.am: Added random.c.
* newlib/libc/stdlib/stdlib.tex: Added random.def.
* newlib/libc/stdlib/Makefile.in: Regenerated.
GCCs builtin functions are mostly type agnostic and architecture
indepedent. Prefer to use them if available.
* libc/include/math.h (fpclassify, isfinite, isinf, isnan,
isnormal): Use matching GCC builtin functions if built with
GCC 4.4 or later.
(signbit): Use matching GCC builtin functions if built with
GCC 4.0 or later.
(isgreater, isgreaterequal, isless, islessequal, islessgreater,
isunordered): Use matching GCC builtin functions if built with
GCC 2.97 or later.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
__builtin_isinf_sign doesn't reflect the correct return value for NaN
to emulate finite function. Use __builtin_isfinite instead whichg is available
since GCC 4.4 just as __builtin_isinf_sign.
* libm/common/sl_finite.c (finitel): Use __builtin_isfinite.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Infinity returned from strtold is recognized as NaN by GCC builtin
functions. The reason is that ULtox is missing to set a bit.
* libc/stdlib/strtorx.c (ULtox): Set high bit in second word
to create valid Infinity value.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
While running tests on internal systems, we identified an issue in the
startup code for newlib on AArch32 systems with Multiprocessor
Extensions to the architecture.
The issue is we were configuring page table flags to be Inner
cacheable/Outer non-cacheable, while for at least architectures with
Multiprocessor Extension, we'd configure it to Inner/Outer write-back, no
write-allocate, and cacheable.
The attached patch fixes this, and no regression on arm-none-eabi
bare-metal tests.
Adopted suggestion given by Richard offline to avoid using jump.
libgloss/
* arm/cpu-init/rdimon-aem.S: Set TTBR0 to inner/outer
cacheable WB, and no allocate on WB for arch with multiprocessor
extension.
Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers
to the Winsock types. Use u_intN_t in BSD-based sources, unsigned char
where strings are concerned, uintN_t otherwise. Also:
* net.cc: Fix comment, we're not using u_long anymore.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>