Commit 8a3b3bb4d7224d419cc1a4af60ccf7e70edc876b changed the guard on
some functions from _POSIX_THREADS to __POSIX_VISIBLE. As a consequence,
some use of siginfo_t and pthread_t became visible under configurations
where _POSIX_THREADS is unset but __POSIX_VISIBLE is. Build then fails
because the definition of those types are still unavailable.
This commit make those type definition visible for __POSIX_VISIBLE
configurations. This requires moving the siginfo_t definition out of the
RTEMS specific definitions in sys/signal.h while still guarding it
against cygwin case.
Erik M. Bray [Thu, 15 Jun 2017 13:30:08 +0000 (15:30 +0200)]
Ensure that send() interrupted by a signal returns sucessfully
When SA_RESTART is not set on a socket, a blocking send() that is
interrupted mid-transition by a signal should return success (and
report just how many bytes were actually transmitted).
The err variable used here was not always guaranteed to be set
correctly in the loop, so better to just remove it and call
WSAGetLastError() explicitly.
Yaakov Selkowitz [Wed, 14 Jun 2017 15:20:05 +0000 (10:20 -0500)]
Export XSI sigpause
There are two common sigpause variants, both of which take an int argument.
If you request _XOPEN_SOURCE or _GNU_SOURCE, you get the System V version,
which removes the given signal from the process's signal mask; otherwise
you get the BSD version, which sets the process's signal mask to the given
value.
Yaakov Selkowitz [Tue, 13 Jun 2017 19:51:18 +0000 (14:51 -0500)]
stdio.h: guard function macros with !__cplusplus
While POSIX allows these functions to also be defined as macros in C, in
C++ this is not allowed, and prevents these names (particularly feof) from
being used in a custom namespace.
Corinna Vinschen [Wed, 14 Jun 2017 11:22:56 +0000 (13:22 +0200)]
cygwin: readdir: don't lookup mount target inodes
So far Cygwin's readdir returned the inode number of a mount target
in d_ino, rather than the actual inode number of the mount point in
the underlying filesystem. This not only results in a performance
hit if the mount target is a remote FS, it is also not done on other
POSIX systems.
Remove the code evaluating the mount target inode number.
Joe Lowe [Tue, 13 Jun 2017 18:12:50 +0000 (11:12 -0700)]
readdir() with mount point dentry, return mount point INO
This patch fixes a minor compatibility issue w/ cygwin mount point handling in
readdir(), compared to equivalent behavior of Linux and MacOS. dentry.d_ino
should indicate the INO of the mount point itself, not the target volume root
folder.
Changed return type from readdir_check_reparse_point to uint8_t, to avoid
unnecessarily being implicitly cast to and from a signed int.
Renamed a related local variable "attr" to "oattr" that was eclipsing a member
variable with the same name.
Sebastian Huber [Mon, 12 Jun 2017 06:38:56 +0000 (08:38 +0200)]
Remove FreeBSD specifics from RTEMS <arpa/inet.h>
For whatever reason FreeBSD renames several functions provided by
<arpa/inet.h> and uses weak references to provide the standard function
names. This causes problems on targets lacking proper support for weak
references. We do not need this function renaming on RTEMS.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Silviu Baranga [Mon, 5 Jun 2017 08:54:42 +0000 (09:54 +0100)]
Don't overread or write memory returned by _DTOA_R
Don't over-read memory returned by _DTOA_R, and never write to it
since the result might be a string literal.
For example, when doing:
swprintf(tt, 20, L"%.*f", 6, 0.0);
we will get back "0".
Instead, write the result returned by _DTOA_R to the output buffer.
After this, write the 0 chars directly to the the output buffer
(if there are any). This also has the (marginal) advantage that
we read/write less memory overall.
cygwin: Fix lrint{f,l} to return a 64 bit long on x86_64
Mingw-w64 (where the code has been taken from) has 4 byte longs
independently of the architecture but x86_64 Cygwin has 64 bit longs.
So use fistpll instead of fistpl on x86_64 Cygwin.
Workaround a bug (or undocumented behaviour) in LCMapStringW:
It's documented(*) that the cchDest parameter is a byte count with
LCMAP_SORTKEY, but a character count otherwise. But the docs don't
state what happens if you combine LCMAP_SORTKEY with LCMAP_BYTEREV.
Tests indicate that LCMAP_SORTKEY treats cchDest as byte count, but
then LCMAP_BYTEREV treats it as char count in the same call. So the
latter swaps twice as much bytes in the destination buffer than the
byte count it returns, which potentially results in writing past the
end of the given output buffer.
Solution: Don't specify LCMAP_BYTEREV in the LCMapStringW(LCMAP_SORTKEY)
call, rather byte swap afterwards.
Sebastian Huber [Mon, 22 May 2017 07:34:31 +0000 (09:34 +0200)]
Move ARM access.c from machine to sys
The implementation of the POSIX access() function is nothing machine
specific like memcpy(), etc. Move it back to the system domain. This
avoids problems due to the include search order of the Newlib/GCC build
which picks up machine includes before system includes.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
When simulating arm code, the target program startup code (crt0) uses
semihosting invocations to get the command line from the simulator. The
simulator returns the command line and its size into the area passed in
parameter. (ARM 32-bit specifications :
http://infocenter.arm.com/help/topic/com.arm.doc.dui0058d/DUI0058.pdf
chapter "5.4.19 SYS_GET_CMDLINE").
The memory area pointed by the semihosting register argument is located
in .text section (usually not writtable (RX)).
If we run this code on a simulator that respects this rights properties
(qemu user-mode for instance), the command line will not be written to
the .text program memory, in particular the length of the string. The
program runs with an empty command line. This problem hasn't been seen
earlier probably because qemu user-mode is not so much used, but this can
happen with another simulator that refuse to write in a read-only segment.
With this modification, the command line can be correctly passed to the
target program.
Changes:
- libgloss/arm/crt0.S : Arguments passed to the AngelSWI_Reason_GetCmdLine
semihosting invocation are placed into .data section instead of .text
- libgloss/aarch64/crt0.S : Idem for aarch64 AngelSVC_Reason_GetCmdLine
semihosting.
cygwin: pinfo: do not wait for setting ppid on a transitional procinfo
This leads to excessive lag when stracing processes if the inferior
process checks the process table. The reason is that ppid isn't set
in the procinfo memory of the dynamically loading strace itself.
cygwin: try unprivileged symlink creation on W10 1703 and later
Add new SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag to
CreateSymbolicLinkW call when running on W10 1703 or later.
Don't do that on older versions to avoid ERROR_INVALID_PARAMETER.
Preliminary, needs testing. There's an off-chance that the
flag results in the same ERROR_INVALID_PARAMETER on 1703 if the
developer settings are not enabled.
RtlGetNtVersionNumbers returns the build number with some upper bits
set for no apparent reason. The fact that RtlGetNtVersionNumbers is
undocumented doesn't exactly help.
Just filter out the upper WORD for now. If build numbers are in
danger to become 6 digit numbers, re-evaluate.
Christian Franke [Sat, 22 Apr 2017 12:50:58 +0000 (14:50 +0200)]
Fix stat.st_blocks for files compressed with CompactOS method
Always retrieve FileCompressionInformation for non-empty
files if FileStandardInformation returns 0 allocated blocks.
This fixes stat.st_blocks for files compressed with CompactOS method.
Signed-off-by: Christian Franke <franke@computer.org>
Daniel Santos [Wed, 19 Apr 2017 16:06:02 +0000 (11:06 -0500)]
strace: Fix "over-optimization" flaw in strace.
Recent versions of gcc are optimizing away the TLS buffer allocated in
main, so we need to tell gcc that it's really used. RtlSecureZeroMemory
accomplishes this while also inlining the memset.
Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
Carlos Santos [Thu, 13 Apr 2017 23:17:37 +0000 (20:17 -0300)]
libgloss/arm: fix discovery of "eabihf" toolchains
ARM EABI toolchains can optionally use the "hf" suffix to identify
hardware floating point support. Use the "*-*-eabi*" pattern to match
these toolchains.
Original patch by Bryan Hundven for the Crosstool-NG project. Improved
by Alexey Neyman.
previous commit 4c90db7bc89e7fa1077025fefdd58269dc71a6ac introduced
a compile time error because libm/common/s_infconst.c used the remove
__fmath, __dmath, and __ldmath union types.
Since this is very old, and unused for a very long time, just drop the
file and thus the __infinity constants entirely.
Exception: Cygwin exports __infinity from the beginning. There's a very,
VERY low probability that any existing executable or lib still uses this
constant, but we just keep it in for backward compat, nevertheless.
Jon Turney [Sat, 8 Apr 2017 12:39:44 +0000 (13:39 +0100)]
Avoid decimal point localization in /proc/loadavg
Explicitly format the contents of /proc/loadavg to avoid the decimal point
getting localized according to LC_NUMERIC. Using anything other than '.' is
wrong and breaks top.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.
Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
Add two new macros, SLIST_CONCAT and LIST_CONCAT. Note in both the
queue.h header file and in the queue.3 manual page that they are O(n) so
should be used only in low-usage paths with short lists (otherwise an
STAILQ or TAILQ should be used).
Make the system queue header file fully usable within C++ programs by
adding macros to define class lists.
This change is backwards compatible for all use within C and C++
programs. Only C++ programs will have added support to use the queue
macros within classes. Previously the queue macros could only be used
within structures.
The queue.3 manual page has been updated to describe the new
functionality and some alphabetic sorting has been done while
at it.
Add new FOREACH_FROM variants of the queue(3) FOREACH macros which can
optionally start the traversal from a previously found element by
passing the element in as "var". Passing a NULL "var" retains the same
semantics as the regular FOREACH macros.
Kudos to phk for suggesting the "FROM" suffix instead of my original
proposal.
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.
Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96
don't use C99 static array indices with older GCC versions
For example, the FreeBSD GCC (4.2.1) has a spotty support for that
feature. If the static keyword is used with an unnamed array parameter
in a function declaration, then the compilation fails with:
error: static or type qualifiers in abstract declarator
The feature does work if the parameter is named.
So, the restriction introduced in this commit can be removed when all
affected function prototypes have the workaround.
This was meant to be used by a future FORTIFY_SOURCE implementation.
Probably for good, FORTIFY_SOURCE and this particular GCCism were never
well supported by clang or other compilers. Furthermore, the technology
has long since been replaced by either static checkers, sanitizers, or
even just the strong stack protector that was enabled by default.
Drop __gnu_inline to avoid cluttering the headers.
Fix C++ includability of crypto headers with static array sizes
C99 allows array function parameters to use the static keyword for their
sizes. This tells the compiler that the parameter will have at least the
specified size, and calling code will fail to compile if that guarantee is
not met. However, this syntax is not legal in C++.
This commit reverts r300824, which worked around the problem for
sys/md5.h only, and introduces a new macro: min_size(). min_size(x) can
be used in headers as a static array size, but will still compile in C++
mode.
dim [Tue, 4 Apr 2017 07:04:53 +0000 (09:04 +0200)]
Stop exposing the C11 _Atomic() macro in <sys/cdefs.h>, when compiling for C++.
It clashes with the one in libc++'s <atomic> header.
(Previously, the _Atomic() macro was defined in <stdatomic.h>, which is
only for use with C11, but for various reasons it was moved to its
current location in r251804.)
Sebastian Huber [Fri, 31 Mar 2017 09:00:42 +0000 (11:00 +0200)]
Use enum __packed in favour of -fshort-enums
Some architectures like ARM encode the short enum option state in the
object file and the linker checks that this option is consistent for all
objects of an executable. In case applications use -fno-short-enums,
then this leads to linker warnings. Use the enum __packed attribute for
the relevent enums to avoid the -fshort-enums compiler option. This
attribute is at least available on GCC, LLVM/clang and the Intel
compiler.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Jon Turney [Tue, 21 Mar 2017 19:17:42 +0000 (19:17 +0000)]
Implement getloadavg()
v2:
autoload PerfDataHelper functions
Keep loadavg in shared memory
Guard loadavg access by a mutex
Initialize loadavg to the current load
v3:
Shared memory version bump isn't needed if we are only extending it
Remove unused autoload
Mark inititalized flags as NO_COPY for correct behaviour in fork child
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
Corinna Vinschen [Fri, 24 Mar 2017 16:26:37 +0000 (17:26 +0100)]
cygserver: Speed up non-debug scenario
_log/_vlog were always called so we always had a function call hit even
if we're not debugging. Expand on the debugging macros so the decision
to call _log/_vlog is done in the caller already. Also, make a log level
difference between syscall_printf and system_printf.