Commit Graph

19815 Commits

Author SHA1 Message Date
Joel Sherrill 0c0f3df224 sys/stat.h: Enable UTIME_NOW and UTIME_OMIT for RTEMS 2021-05-20 10:04:07 +02:00
Corinna Vinschen 9b24fc9505 Cygwin: autoload: fix case in DLL name for sanity
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 10:04:07 +02:00
Corinna Vinschen 23d071229d Cygwin: Add missing IsWow64Process2 declaration
The previous patch is accidentally missing the declaration of
IsWow64Process2.  Add it belatedly.

Fixes: 1865a41cb383 ("Cygwin: suppress FAST_CWD warnings on ARM64")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-20 10:04:07 +02:00
Jeremy Drake 338548f82f Cygwin: suppress FAST_CWD warnings on ARM64
The old check was insufficient: new insider preview builds of Windows
allow running x86_64 process on ARM64.  The IsWow64Process2 function
seems to be the intended way to figure this situation out.
2021-05-19 14:40:51 +02:00
Jeremy Drake c8949d0400 Cygwin: Handle virtual drives as non-symlinks
This avoids MAX_PATH-related problems in native tools in case the
virtual drive points to a deep directory

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-19 14:40:51 +02:00
Corinna Vinschen 7b8edba625 Cygwin: POSIX message queues: simplify sync object creation
Introduce new inline function mq_ipc_init to create all three
required sync objects.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-12 11:04:44 +02:00
Jon Turney 079c3a5587
Cygwin: Use parallel make on AppVeyor
We're bumping up against the 1hr free job duration limit on AppVeyor, so
use 'make -j$(nproc)' to allow things to build slightly faster.

Restructure the way build_script: is written in YAML, so it's slightly less
repetitive and easier to add that.

Also skip 'make check' on x86, since it currently just hangs. :(
2021-05-10 16:57:41 +01:00
Jon Turney 71e8b45007
Get rid of relative include paths in strace.cc 2021-05-10 14:41:41 +01:00
Jon Turney b8bd9d1b01
Move source files used in utils/mingw/ into that subdirectory
Move all the source files used in utils/mingw/ into that subdirectory,
so the built objects are in the expected place.

(path.cc requires some more unpicking, and even then there is genuinely
some shared code, so use a trivial file which includes the real path.cc
so the object file is generated where expected)
2021-05-10 14:41:40 +01:00
Jon Turney 9ce70bf450
Unpick cygpath TESTSUITE
Rather than having testsuite.h do various things, depending on defines,
just have it do one thing, and then explicitly redirect to test stubs in
path.cc when building test.
2021-05-10 14:41:39 +01:00
Corinna Vinschen 44eb416323 Cygwin: fetch Windows directory on all platforms and use throughout
Rather than fetching the system Windows directory at dll init time
only on 32 bit, fetch it on all platforms.  Store as WCHAR and
UNICODE_STRING.  Use where appropriate to simplify code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-07 23:05:24 +02:00
Corinna Vinschen 19d59ce75d Cygwin: path_conv: Rework handling native symlinks as inner path components
commit 456c3a4638 was only going half-way.  It handled symlinks and
junction points as inner path components and made realpath return the
correct path, but it ignored drive letter substitution, i. e., virtual
drives created with, e. g.

  subst X: C:\foo\bar

It was also too simple.  Just returning an error code from
symlink_info::check puts an unnecessary onus on the symlink evaluation
loop in path_conv::check.

Rework the code to use GetFinalPathNameByHandle, and only do this after
checking the current file for being a symlink failed.

If the final path returned by GetFinalPathNameByHandle is not the same
as the incoming path, replace the incoming path with the POSIXified
final path.  This also short-circuits path evaluation, because
path_conv::check doesn't have to recurse over the inner path components
multiple times if all symlinks are of a native type, while still getting
the final path as end result.

Virtual drives are now handled like symlinks.  This is a necessary change
from before to make sure virtual drives are handled identically across
different access methods.  An example is realpath(1) from coreutils.  It
doesn't call readlink(2), but iterates over all path components using
lstat/readlink calls.  Both methods should result in the same real path.

Fixes: 456c3a4638 ("path_conv: Try to handle native symlinks more sanely")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-07 22:52:16 +02:00
Corinna Vinschen 9ea0f37667 Cygwin: revert handwritten tags/ctags target, take 2
Fix accidental checkin of the wrong test version

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-06 13:35:26 +02:00
Corinna Vinschen a5b24cb241 Cygwin: revert handwritten tags/ctags target
Converting to automake dropped the former, handwritten tags/ctags
target.  This leads to a couple of problems:

- For no good reason the tags file gets written to the builddir
  instead of to the srcdir where it's needed.

- `make tags' requires etags to exist, rather than checking if it
  exists and skipping it.

- Adding the extra ctags arguments to AM_CTAGSFLAGS still results
  in a shortened tags file.

(Temporary?) solution: Revert the old tags/ctags rules and silence
the automake warnings.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-06 11:12:46 +02:00
Corinna Vinschen 895f6d2b59 Cygwin: autogen.sh: Allow running from any directory
autogen.sh expects to run from within the winsup dir, so
set CWD accordingly before running autotools.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-05-06 10:56:20 +02:00
Ola Olsson 84d068971d Nano-malloc: Fix for unwanted external heap fragmentation
The only reason why it is tough for us to use nano malloc
is because of the small shortcoming where nano_malloc()
splits a bigger chunk from the free list into two pieces
while handing back the second one (the tail) to the user.
This is error prone and especially bad for smaller heaps,
where nano malloc is supposed to be superior. The normal
malloc doesn't have this issue and we need to use it even
though it costs us ~2k bytes compared to nano-malloc.

The problem arise especially after giving back _every_
malloced memory to the heap and then starting to exercise
the heap again by allocating something small. This small
item might split the whole heap in two equally big parts
depending on how the heap has been exercised before.

I have uploaded the smallest possible application
(only tested on ST and Nordic devices) to show the issue
while the real customer applications are far more complicated:
https://drive.google.com/file/d/1kfSC2KOm3Os3mI7EBd-U0j63qVs8xMbt/view?usp=sharing

The application works like the following pseudo code,
where we assume a heap of 100 bytes
(I haven't taken padding and other nitty and gritty
details into account. Everything to simplify understanding):

void *ptr = malloc(52); // We get 52 bytes and we have
                        // 48 bytes to use.
free(ptr); // Hand back the 52 bytes to nano_malloc
           // This is the magic line that shows the issue of
           // nano_malloc
ptr = malloc(1); // Nano malloc will split the 52 bytes
                 // in the free list and hand you a pointer
                 // somewhere in the
                 // middle of the heap.
ptr2 = malloc(52); // Out of memory...

I have done a fix which hands back the first part of the
splitted chunk. Once this is fixed we obviously
have the 1 byte placed in position 0 of the heap instead
of somewhere in the middle.

However, this won't let us malloc 52 new bytes even though
we potentially have 99 bytes left to use in the heap. The
reason is that when we try to do the allocation,
nano-malloc looks into the free list and sees a 51 byte
chunk to be used.
This is not big enough so nano-malloc decides to call
sbrk for _another_ 52 bytes which is not possible since
there is only 48 bytes left to ask for.

The solution for this problem is to check if the last
item in the free list is adjacent to sbrk(0). If it is,
as it is in this case, we can just ask sbrk for the
remainder of what is needed. In this case 1 byte.

NB! I have only tested the solution on our ST device.
2021-05-03 13:00:33 +02:00
Jon Turney b05b790689 Cygwin: Ensure toollibdir exists before installing a link there
This helps 'make install -j2' work.
2021-04-30 21:06:33 +02:00
Brian Inglis 6914b40c14 format_proc_swaps: ensure space between fields for clarity
page/swap space name >= 40 or size/used >= 8 leaves no space between fields;
ensure a space after name and add extra tabs after size and used fields;
output appears like Linux 5.8 after changes to mm/swapfile(swap_show);

proc-swaps-space-before.log:
==> /proc/swaps <==
Filename				Type		Size	Used	Priority
/mnt/c/pagefile.sys                     file            11567748292920  0
/mnt/d/pagefile.sys                     file            12582912205960  0

proc-swaps-space-after.log:
==> /proc/swaps <==
Filename				Type		Size		Used		Priority
/mnt/c/pagefile.sys			file		11567748	241024		0
/mnt/d/pagefile.sys			file		12582912	182928		0
2021-04-30 21:05:11 +02:00
Corinna Vinschen 715c4208e4 Cygwin: mq_open: set filesize using ftruncate
ftruncate is leaner than lseek/write.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-30 20:32:52 +02:00
Jon Turney 2d34164402
Cygwin: CI configuration update
Install autoconf and automake, and run winsup/autogen.sh, and don't have
it silently ignore failures.

On AppVeyor:
- use latest VM image, to reduce time spent installing updates.
- run the testsuite, but ignore the result, as some tests don't work
correctly.
- hardcode the python-lxml and python-ply packages to install, so we get
ones for the right python.
- install texlive collections now needed to build documentation.

On github:
- Use a copr for cocom, since RPMSphere's package updates don't track
fedora:latest very efficently.
2021-04-30 14:22:07 +01:00
Corinna Vinschen 548a4c3ca4 Cygwin: POSIX mq: avoid double calls to ipc_mutex_unlock
_mq_send as well as _mq_receive call ipc_mutex_unlock twice in case
of success, after having introduced __try/__except blocks.

Fixes: 3f3bd10104 ("* Throughout, use __try/__except/__endtry blocks, rather than myfault handler.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-30 10:30:21 +02:00
Corinna Vinschen 4f89f24fbe Cygwin: POSIX mq: only allo priority up to MQ_PRIO_MAX - 1
POSIX requires that message priorities range from 0 (low) to
sysconf(_SC_MQ_PRIO_MAX) - 1 (high).  Cygwin's mq_send erroneously
allowed a message priority of sysconf(_SC_MQ_PRIO_MAX).  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 20:09:10 +02:00
Corinna Vinschen c66797eef8 Cygwin: FAQ: building-cygwin: accomodate autoconf changes
- also, rephrase slightly for better readability and
  remove questionable old cruft

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 12:14:00 +02:00
Corinna Vinschen cf25b55902 Cygwin: automake: change @INCLUDES@ to @AM_CPPFLAGS@ to avoid warnings
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:28:14 +02:00
Corinna Vinschen 84ffbfeb10 Cygwin: automake: fix warning in terms of the `ps' target
We are building a ps executable, but the rule to build the target
collides with an auto-generated, documentation-related `ps' rule.

Work around that by naming the executable "cygps" at build time
and use a transform rule to rename it at installation time.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:24:53 +02:00
Jon Turney 0bf0cf48ff Cygwin: specify toollibdir toolincludedir in terms of tooldir
Specify toollibdir and toolincludedir in terms of tooldir, so the
install location is correct if tooldir is the default
($(exec_prefix)/$(target_alias)), or explicitly specified on the 'make'
command line.
2021-04-29 11:20:37 +02:00
Corinna Vinschen a26779fae0 Cygwin: drop all generated autotools files
- add autotool files generated under winsup to .gitignore

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:16:38 +02:00
Brian Inglis 5eb232ede7 format_proc_cpuinfo: add v_spec_ctrl, bus_lock_detect
Linux 5.12 Frozen Wasteland added features and changes:
add AMD 0x8000000a EDX:20 v_spec_ctrl virtual speculation control support
add Intel 0x00000007 ECX:24 bus_lock_detect bus lock detect debug exception
2021-04-28 12:26:03 +02:00
Corinna Vinschen a89bd73c5f Cygwin: tty.h: devices.h is a local header, not a system header
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-27 21:25:29 +02:00
Jon Turney 247ce0ca3a
Cygwin: Use automake (v5)
v2:
* Include tzmap.h in BUILT_SOURCES
* Make per-file flags appear after user-supplied CXXFLAGS, so they can
override optimization level.
* Correct .o files used to define symbols exported by libm.a
* Drop gcrt0.o mistakenly included in libgmon.a
* Add missing line continuations in GMON_FILES value

v3:
* use per-file flags for .c compilation
* override C{XX,}FLAGS, as they are set on the command line by top-level make

v4:
* Drop -Wno-error=write-strings from path_testsuite CXXFLAGS

v5:
* Update for changes in master
- Add -fno-threadsafe-statics to CXX flags
- Add hypotl.cc
- Remove fenv.cc (in favour of newlib), add fenv.c stub
- Add proc.5 manpage rules
2021-04-27 16:49:56 +01:00
Ken Brown 3b0ba65352 Cygwin: connect: implement resetting a connected DGRAM socket
Following POSIX and Linux, allow a connected DGRAM socket's connection
to be reset (so that the socket becomes unconnected).  This is done by
calling connect and specifing an address whose family is AF_UNSPEC.
2021-04-27 10:01:45 -04:00
Ken Brown 2be07f7554 Cygwin: connect: set connect state for DGRAM sockets
When connect is called on a DGRAM socket, the call to Winsock's
connect can immediately return successfully rather than failing with
WSAEWOULDBLOCK.  Set the connect state to "connected" in this case.

Previously the connect state remained "connect_pending" after the
successful connection.
2021-04-26 09:19:37 -04:00
Mike Frysinger ae6e6c3526 bfin: add myself as maintainer 2021-04-26 11:38:35 +02:00
Takashi Yano 6d46d85049 Cygwin: pty: Add missing guard for close_pseudoconsole().
- This patch adds a missing mutex guard for close_pseudoconsole()
  call when GDB exits.
2021-04-21 17:42:00 +02:00
Takashi Yano 6004ea977b Cygwin: pty: Fix fallback processing in setup_pseudoconsole().
- Currently, the fallback processing in setup_pseudoconsole()
  when helper process error occurs does not work properly.
  This patch fixes the issue.
2021-04-21 17:42:00 +02:00
Takashi Yano 01387f1ff4 Cygwin: pty: Additional race issue fix regarding pseudo console.
- In commit bb93c6d7, the race issue was not completely fixed. In
  the pseudo console inheritance, if the destination process to
  which the ownership of pseudo console switches, is found but exits
  before switching, the inheritance fails. Currently, this extremely
  rarely happens. This patch fixes the issue.
2021-04-21 17:42:00 +02:00
Corinna Vinschen 13fd26ecf5 Cygwin: skip native symlink check in Windows dir under WOW64
Commit 456c3a4638 added a workaround when handling paths with native
symlinks as inner path components.  This patch introduced a problem for
paths handled by the WOW64 File System Redirector (FSR).

Fix this problem by not performing the new code from commit 456c3a4638
for paths under the Windows directory.  Only do this in WOW64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-21 17:41:08 +02:00
Ties Stuij 282445a10e fix some Arm FP routines not checking if floating point is enabled
A lot of the Arm FP routines check for the availability of floating point by way
of `(__ARM_FP & 0x4)`. However some do not. This patch remedies this.
2021-04-21 16:18:09 +01:00
Corinna Vinschen 8050ef2074 Cygwin: add 3.2.1 release file and add fixes up to this point
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-20 10:46:39 +02:00
Takashi Yano 5176afeb7d Cygwin: pty: Make rlwrap work with cmd.exe.
- After the commit 919dea66, "rlwrap cmd" fails to start pseudo
  console. This patch fixes the issue.
2021-04-20 10:21:45 +02:00
Takashi Yano bb93c6d7c2 Cygwin: pty: Fix race issue in inheritance of pseudo console.
- If multiple non-cygwin processes are started/ended simultaneously,
  inheritance of pseudo console sometimes fails. This patch fixes
  the issue.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html
2021-04-20 10:21:45 +02:00
Takashi Yano b4fc81edcc Cygwin: console: Fix race issue regarding cons_master_thread().
- With this patch, the race issue regarding starting/stopping
  cons_master_thread() introduced by commit ff4440fc is fixed.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html
2021-04-20 10:21:45 +02:00
Corinna Vinschen 9c6c2fb0f6 scanf: allow hex float input per POSIX
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-19 22:00:10 +02:00
Takashi Yano a648c15309 Cygwin: console: Fix a bug in the code to fix tab position.
- With this patch, a bug in the code to fix tab position after
  resizing window is fixed.
2021-04-19 16:17:12 +02:00
Corinna Vinschen 456c3a4638 Cygwin: path_conv: Try to handle native symlinks more sanely
For local paths, add a check if the inner path components contain native
symlinks or junctions.  Compare the incoming path with the path returned
by NtQueryInformationFile(FileNameInformation).  If they differ, there
must be at least one native symlink or junction in the path.  If so,
treat the currently evaluated file as non-existant.  This forces
path_conv::check to backtrack inner path components until we eliminated
all native symlinks or junctions and have a normalized path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-19 14:49:14 +02:00
Corinna Vinschen 183e5f0a15 Cygwin: take hypotl function from Mingw-w64
The simple newlib hypotl for real long double architectures is too
simple at this point.  It's implemented as a real call to sqrtl(x^2+y^2).
This has a fatal tendency to overflow for big input numbers.  Hypotl
isn't supposed to do that if the result would still be valid in range of
long double.

Given the complexity of implementing hypotl for various architectures,
we just take the hypotl function from Mingw-w64, which is in the public
domain.

Even though this hypotl is an architecture-independent implementation,
we can't use it for newlib yet, unfortunately, because it requires logbl
under the hood.  Logbl is yet another function missing in newlib for
real long double architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-19 12:39:30 +02:00
David Macek 7078248485 fenv: fix up stub file comment, drop symlinks from description
also slightly fixed up formatting
2021-04-13 12:55:34 +02:00
Corinna Vinschen 81137c50d1 Cygwin: fix fenv.h includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen cc19109af9 Cygwin: don't export _feinitialise from newlib
Use the more official fesetenv(FE_DFL_ENV) from _dll_crt0, thus
allowing to drop the _feinitialise declaration from fenv.h.

Provide a no-op _feinitialise in Cygwin as exportable symbol for really
old applications when _feinitialise was called from mainCRTStartup in
crt0.o.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen 3b22d72255 fenv: drop Cygwin-specific implementation in favor of newlib code
Drop the Cygwin-specific fenv.cc and fenv.h file and use the equivalent
newlib functionality now, so we have at least one example of a user for
this new mechanism.

fenv.c: allow _feinitialise to be called from Cygwin startup code

fenv.h: add declarations for fegetprec and fesetprec for Cygwin only.
        Fix a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00