4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-02 12:30:24 +08:00

19746 Commits

Author SHA1 Message Date
Ken Brown
816c8dfecd Cygwin: AF_UNIX: update tests
There's now a (successful) test of sending socket descriptors.
2020-11-25 15:32:03 -05:00
Jon Turney
e496754853 Cygwin: Have cygmagic not create output if an error occurs
Improve the 'cygmagic' script, so it doesn't create the output file if
an error occurs, even in one of the backtick-enclosed pipelines it runs.
2020-11-25 15:06:41 -05:00
Jon Turney
4d8bc5e889 Cygwin: Use standard CXXFLAGS when compiling localtime_wrapper.c
This has an separate, explicit compilation rule which omits CXXFLAGS, so
expected flags like '-g -O2' aren't being used.
2020-11-25 15:06:41 -05:00
Jon Turney
aace6db332 Cygwin: Drop libgmon.a build dependency on gcrt0.o
libgmon.a depends on gcrt0.o, but doesn't include it.
2020-11-25 15:06:41 -05:00
Takashi Yano via Cygwin-patches
5e2f9e3d83 Cygwin: pty: Fix minor style issue. 2020-11-25 15:06:41 -05:00
Takashi Yano via Cygwin-patches
fd70323047 Cygwin: pty: Discard "OSC Ps; ? BEL/ST" in pseudo console output.
- If vim is executed in WSL in mintty, some garbage string caused
  by "OSC Ps;? BEL/ST" will be shown in some situations. This patch
  fixes the issue by removing "OSC Ps;? BEL/ST" from pseudo console
  output.
2020-11-25 15:06:41 -05:00
Takashi Yano via Cygwin-patches
43d5338620 Cygwin: pty: Fix a bug in the code removing "CSI > Pm m".
- The code added by 8121b606e843c001d5ca5213d24099e04ebc62ca has a
  bug which fails to remove multiple "CSI > Pm m" sequences. This
  patch fixes the bug.
2020-11-25 15:06:41 -05:00
Ken Brown
3b8be197f7 Cygwin: AF_UNIX: SCM_RIGHTS: support socket descriptors
This requires modifying fhandler_socket_wsock::dup and
fhandler_socket_unix::dup to use the src_pid argument.

First cut.  Not yet tested.
2020-11-22 15:02:39 -05:00
Ken Brown
877427fbaa Cygwin: AF_UNIX: add _pipe_end member and related methods
Use this to keep track of whether our pipe handle is for the server or
client end of the pipe.
2020-11-22 14:17:52 -05:00
Ken Brown
d9bb7965f9 Cygwin: AF_UNIX: code simplification
Add a 'src_pid' argument to dtable::dup_worker.

Use the latter in serialize/deserialize rather than repeating much of
what it does.

Don't duplicate the path_conv handle; it isn't needed.
2020-11-22 14:13:00 -05:00
Ken Brown
81ceb96528 Cygwin: AF_UNIX: create an ack mechanism for SCM_RIGHTS
When a process sends a file descriptor via an SCM_RIGHTS control
message, it creates a temporary copy of the fhandler associated with
that descriptor and sends a serialization of that copy.  The
deserialization done by the receiver involves duplicating handles from
the copy, so the latter must stay alive until the deserialization is
done.  But it must ultimately be closed in order to avoid a memory
leak.

We coordinate all this as follows:

- Introduce a new struct scm_pending_fd that contains information
  about the temporary copy.  For brevity, call such a struct a
  "pending fd" in what follows.

- Maintain a list of pending fds in shared memory.

- Add several methods for manipulating the list to the af_unix_shmem_t
  and fhandler_socket_unix classes.

- Also add a lock, 'scm_fd_lock', to control access to the list.

- When a serialized fhandler is received, the receiver sends an ack
  back to the sender in an administrative packet with a control
  message of a new (Cygwin-specific) type SCM_RIGHTS_ACK.

- grab_admin_pkt is called in various places to process these packets.
  A complication here is that the process that calls grab_admin_pkt
  might not be the process that originally sent the serialized
  fhandler.  (It could be a subprocess of the original process, for
  example.)  This is why we need to maintain the list of pending fds
  in shared memory.

- Each fhandler_socket_unix keeps a count of the pending fds that it
  has created but not yet processed; this count is in a new data
  member 'my_npending_fd'.

- fhandler_socket_unix::close tries to process any remaining pending
  fds before closing, but it gives up after a short timeout and
  forcibly deletes them if necessary.
2020-11-21 08:01:10 -05:00
Ken Brown
ee4f7ec67e Cygwin: AF_UNIX: add a unique id to struct fh_ser 2020-11-21 08:01:10 -05:00
Ken Brown
5a98fbb4f8 Cygwin: AF_UNIX: tweak serialize/deserialize
Make them member functions of the fhandler_socket_unix class.

Make them use void * instead of fh_ser * so that fhandler.h doesn't
need to know about fh_ser.
2020-11-21 08:01:10 -05:00
Ken Brown
0dac3caaf5 Cygwin: AF_UNIX: update tests 2020-11-21 08:01:10 -05:00
Ken Brown
9e6f77d4ef Cygwin: AF_UNIX: peek_pipe_poll: fix thinko
The variable 'sleep_time' was being reset to 0 on every loop
iteration.
2020-11-21 08:01:10 -05:00
Jon Turney
2547ad3807 Cygwin: Remove surplus autoconf auxiliary files
Since we are now only configuring once, in winsup, with
AC_CONFIG_AUX_DIR(..), the auxiliary files are taken from the top-level.

(Previously we had a random assorment of AC_CONFIG_AUX_DIR(..) and
AC_CONFIG_AUX_DIR(../..) in winsup subdirectories, so auxiliary files
would be taken from winsup or the top-level.)
2020-11-21 08:01:10 -05:00
Jon Turney
e707b18446 Cygwin: Remove recursive configure
There's doesn't seem to be much use in independently distributing these
subdirectories, so allowing them to be independently configured seems
pointless and overcomplicated.

The order in which the subdirectories are built is still a little odd,
as cygwin is linked with libcygserver, and cygserver is then linked with
cygwin. So, we build the cygwin directory first, which invokes a build
of libcygserver in the cygserver directory, and then build in the
cygserver directory to build the cygserver executable.

Drop AC_CONFIGURE_ARGS, since we don't need to recursively call
configure with the same arguments anymore.

Slightly refine when we build utils: Previously we didn't build any
utils if MinGW compiler use was avoided, now we just avoid building
those utils which require that compiler.

Greatly simplify how winsup_srcdir and target_builddir are set, since
we're only configuring from one directory.  (These are still kept
absolute, since we don't adjust them where used for being used in a
subdirectory).

Remove configure.cygwin and put it's (greatly reduced) contents inline
in the one place it's used now.

Remove generated configure and aclocal.m4 in subdirectories.
2020-11-21 08:01:09 -05:00
Ken Brown
1395b4ea2c Cygwin: fhandler_fifo::cleanup_handlers: improve efficiency
Traverse the fifo_client_handler list from the top down to try to
avoid copying.
2020-11-21 08:01:09 -05:00
Jon Turney
0cd9136981 Cygwin: Testsuite Makefile cleanup
Drop unused variables CC_FOR_TARGET, GCC_INCLUDE, ALL_CFLAGS
Stop exporting CC, CFLAGS
Drop unused, empty targets force, dll_ofiles, all_target
2020-11-18 14:18:28 -05:00
Jon Turney
601e9ba8c2 Cygwin: Fix 'make check' in utils
This has a test of the path translation code used in various utilities
(mount, cygpath, strace).

MOUNT_BINARY is replaced with the absence of MOUNT_TEXT since 26e0b37e.
The issys member of mnt_t struct was removed in b677a99b.

> $ make check
[...]
> total tests: 63
> pass       : 63 (100.0%)
> fail       : 0 (0.0%)
2020-11-18 14:18:28 -05:00
Jon Turney
ba964d5379 Cygwin: Drop duplicate C++ flags used to build utils
'-fno-exceptions -fno-rtti' are already present in the compile command
COMPILE.cc set by Makefile.common, so we don't need to add them to
CXXFLAGS as well.
2020-11-18 14:18:28 -05:00
Jon Turney
953afd22ed Cygwin: Use grep in text mode to look for version strings
Invoke grep in text mode when looking for version strings inside the
cygwin DLL, so it outputs something more informative than:

  Binary file ../cygwin/cygwin0.dll matches
2020-11-18 14:18:28 -05:00
Kito Cheng
a005d8e7ff RISC-V: Add machine-specific implementation for lrint[f], lround[f], llrint[f] and llround[f]. 2020-11-18 14:18:28 -05:00
Kito Cheng
cc8a2d577d RISC-V: Add machine-specific implementation for isnan[f] and copysign[f] 2020-11-18 14:18:28 -05:00
Kito Cheng
ffa6fd6352 RISC-V: Add missing compile rule for s_finite.c, sf_finite.c, s_isinf.c and sf_isinf.c 2020-11-18 14:18:28 -05:00
Corinna Vinschen
b1dfff7b01 malloc/nano-malloc: correctly check for out-of-bounds allocation reqs
The overflow check in mEMALIGn erroneously checks for INT_MAX,
albeit the input parameter is size_t.  Fix this to check for
__SIZE_MAX__ instead.  Also, it misses to check the req against
adding the alignment before calling mALLOc.

While at it, add out-of-bounds checks to pvALLOc, nano_memalign,
nano_valloc, and Cygwin's (unused) dlpvalloc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-11-18 14:18:28 -05:00
Ken Brown
05d40cdef3 Cygwin: AF_UNIX: implement sending/receiving SCM_RIGHTS ancillary data
First cut.  This is currently implemented only for disk files, and
many things still need to be fixed.  But it works in limited testing
with the programs scm_rights_{recv,send} in
winsup/cygwin/socket_tests.
2020-11-17 14:42:04 -05:00
Ken Brown
e8b866676f Cygwin: AF_UNIX: add serialization/deserialization for fhandlers
Define static helper functions serialize/deserialize in
fhandler_socket_unix.cc.  These will be used to support sending file
descriptors via SCM_RIGHTS control messages.

The serialize function creates an 'fh_ser' structure that contains a
copy of the fhandler associated with the file descriptor, with all
allocated memory freed.  The structure also contains the Windows pid
of the current process, which deserialize can use for duplicating
handles.

The deserialize function reconstructs an fhandler from an fh_ser
structure, with the handles duplicated into its own process.

For now, serialization and deserialization are fully implemented only
for disk files, and even in that case there are many FIXMEs that need
attention.
2020-11-17 14:42:01 -05:00
Ken Brown
0c98e9f6a0 Cygwin: path_conv::set_conv_handle(): new method 2020-11-17 09:22:32 -05:00
Ken Brown
5465d2dc75 Cygwin: device::free_strings(): new method
This is extracted from the destructor ~device().
2020-11-17 09:22:32 -05:00
Ken Brown
b9feec71ff Cygwin: fhandler_base::set_name_from _handle: new method
This is based on a new static member function dtable::handle_to_fn,
which was previously a static function in dtable.cc.
2020-11-17 09:21:57 -05:00
Ken Brown
91ce3d3fd7 Cygwin: fhandler_*::dup: add a 'src_pid' argument
This allows duplication of handles from an fhandler created in a
different process.  For now, this is implemented only for
fhandler_base and fhandler_disk_file.
2020-11-17 09:21:56 -05:00
Ken Brown
cf1034bd38 Cygwin: fhandler_base::get_size(): new method
Override this in each derived class to give the size of each fhandler
class so that the size can be computed dynamically from an
fhandler_base pointer.
2020-11-17 09:21:12 -05:00
Ken Brown
426976b01a Update tests 2020-11-17 09:21:05 -05:00
Sebastian Huber
32016ebf6f Fix return type of __locale_ctype_ptr_l()
This prevents warnings like this:

ctype.h:118:9: warning: return discards 'const' qualifier from pointer
  target type
2020-11-16 14:46:15 -05:00
Corinna Vinschen
b300092e4b Cygwin: testsuite: fix insecure usage of printf in libltp
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-11-16 14:46:15 -05:00
Joel Sherrill
862bdb3880 libc/include/newlib.h: Fix C++ compilation issue 2020-11-16 14:46:15 -05:00
Ken Brown
84836642f9 Cygwin: path_conv::eq_worker: add NULL pointer checks
Don't call cstrdup on NULL pointers.

This fixes a crash that was observed when cloning an fhandler whose
path_conv member had freed its strings.
2020-11-16 14:46:15 -05:00
Jon Turney
8de6b180c8 Cygwin: Fix testsuite tmpdir creation with non-default cygdrive prefix 2020-11-14 13:50:55 -05:00
Ken Brown
7deff41e89 Cygwin: fhandler_fifo: reduce size
Replace the 'WCHAR pipe_name_buf[48]' class member by 'PWCHAR
pipe_name_buf', and allocate space for the latter as needed.

Change the default constructor to accommodate this change, and add a
destructor that frees the allocated space.

Also change get_pipe_name and clone to accommodate this change.
2020-11-09 08:50:08 -05:00
Jon Turney
83d3e454c7 Cygwin: Ensure temporary directory used by tests exists
By default, libltp tests will create temporary files in a subdirectory
of /tmp, which will (nowadays) be located relative to the test DLL (by
assuming that it is in /bin).  This will evaluate to the directory
$target_builddir/winsup/tmp, which doesn't exist.

The location used for these temporary files can be explicitly controlled
by setting the TDIRECTORY env var.  Arrange to set that env var to the
/cygdrive path of a tmp subdirectory of the build directory.

Unfortunately, libltp doesn't clean the temporary directory if
TDIRECTORY is set, and some tests assume they are started in a clean
directory, so we need to do that in tcl.
2020-11-09 08:50:08 -05:00
Jon Turney
09a7bf22cd Cygwin: Set PATH for tests to pick up cygwin0.dll
Set the PATH so that tests can pick up cygwin0.dll.  Looks like this was
dropped by accident in 2e488e95 ("Don't rely on in-build tools"), so
restore it as it was prior to 9d89f634.
2020-11-09 08:50:08 -05:00
Jon Turney
cfb3e51ea7 Cygwin: Check exit code of a test, rather than stdout
In winsup.exp, don't consider a command failed if it produced any output
(e.g. if the compiler produced warnings).  Instead check the exit code.
2020-11-09 08:50:07 -05:00
Jon Turney
fbff9f73b5 Cygwin: Use absolute path to libltp includes
Use an absolute path to libltp includes, to allow for the fact that
we'll be compiling tests in a subdirectory.
2020-11-09 08:50:07 -05:00
Jon Turney
70a8dca5b0 Cygiwn: Detect and use MinGW compilers for testsuite wrappers
Drop MINGW_FE, which I can't find any trace of, and instead detect and
use MinGW compilers.

This requires adding AC_CANONICAL_TARGET, to set $target_cpu.
2020-11-09 08:50:07 -05:00
Jon Turney
75b2397b62 Cygwin: Define target_builddir autoconf and Makefile variables
This is now required as cygwin_build is defined in terms of
target_builddir.

(Note that in other subdirectories, the autoconf variable
target_builddir is AC_SUBST-ed as a side-effect of using a macro from
winsup/acinclude.m4, which is perhaps less than ideal)
2020-11-09 08:50:07 -05:00
Jon Turney
89c5b2144f Cygwin: Move adding libltp to VPATH after Makefile.common
Move adding libltp to the VPATH after Makefile.common, which sets VPATH.
2020-11-09 08:50:07 -05:00
Jon Turney
bc15d0677e Cygwin: Avoid 'Makefile.in seems to ignore the --datarootdir setting' warning
Avoid a 'Makefile.in seems to ignore the --datarootdir setting' warning
when configuring in testsuite directory.
2020-11-09 08:50:07 -05:00
Jon Turney
39575cb8f9 Cygwin: Add rule to testsuite Makefile to regenerate it when needed 2020-11-09 08:50:07 -05:00
Jon Turney
4ec848904e Cygwin: Always configure in testsuite subdirectory
Doing this properly using AC_CONFIG_SUBDIRS is necessary to get the
correct paths in flags given to the compiler specified in CC/CXX.
2020-11-09 08:50:07 -05:00