Skip to content

Commit

Permalink
Merge pull request #59 from dscho/rebase-to-v3.4.9
Browse files Browse the repository at this point in the history
Rebase to v3.4.9
  • Loading branch information
dscho authored Sep 7, 2023
2 parents 8ed211a + 3341cab commit be82660
Show file tree
Hide file tree
Showing 25 changed files with 257 additions and 140 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,5 @@ jobs:
make &&
make install &&
(cd */newlib; make info man) &&
(cd */newlib; make install-info install-man) &&
(cd */winsup; make check || true)
(cd */newlib; make install-info install-man)
shell: C:\cygwin\bin\bash.exe --noprofile --norc -eo pipefail '{0}'
40 changes: 20 additions & 20 deletions newlib/libc/include/langinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,26 @@ enum

_NL_LOCALE_EXTENDED_FIRST_ENTRY,

_NL_CTYPE_OUTDIGITS0_MB,
_NL_CTYPE_OUTDIGITS1_MB,
_NL_CTYPE_OUTDIGITS2_MB,
_NL_CTYPE_OUTDIGITS3_MB,
_NL_CTYPE_OUTDIGITS4_MB,
_NL_CTYPE_OUTDIGITS5_MB,
_NL_CTYPE_OUTDIGITS6_MB,
_NL_CTYPE_OUTDIGITS7_MB,
_NL_CTYPE_OUTDIGITS8_MB,
_NL_CTYPE_OUTDIGITS9_MB,
_NL_CTYPE_OUTDIGITS0_WC,
_NL_CTYPE_OUTDIGITS1_WC,
_NL_CTYPE_OUTDIGITS2_WC,
_NL_CTYPE_OUTDIGITS3_WC,
_NL_CTYPE_OUTDIGITS4_WC,
_NL_CTYPE_OUTDIGITS5_WC,
_NL_CTYPE_OUTDIGITS6_WC,
_NL_CTYPE_OUTDIGITS7_WC,
_NL_CTYPE_OUTDIGITS8_WC,
_NL_CTYPE_OUTDIGITS9_WC,
_NL_CTYPE_OUTDIGIT0_MB,
_NL_CTYPE_OUTDIGIT1_MB,
_NL_CTYPE_OUTDIGIT2_MB,
_NL_CTYPE_OUTDIGIT3_MB,
_NL_CTYPE_OUTDIGIT4_MB,
_NL_CTYPE_OUTDIGIT5_MB,
_NL_CTYPE_OUTDIGIT6_MB,
_NL_CTYPE_OUTDIGIT7_MB,
_NL_CTYPE_OUTDIGIT8_MB,
_NL_CTYPE_OUTDIGIT9_MB,
_NL_CTYPE_OUTDIGIT0_WC,
_NL_CTYPE_OUTDIGIT1_WC,
_NL_CTYPE_OUTDIGIT2_WC,
_NL_CTYPE_OUTDIGIT3_WC,
_NL_CTYPE_OUTDIGIT4_WC,
_NL_CTYPE_OUTDIGIT5_WC,
_NL_CTYPE_OUTDIGIT6_WC,
_NL_CTYPE_OUTDIGIT7_WC,
_NL_CTYPE_OUTDIGIT8_WC,
_NL_CTYPE_OUTDIGIT9_WC,

_NL_TIME_CODESET,
_NL_TIME_WMON_1,
Expand Down
23 changes: 13 additions & 10 deletions newlib/libc/stdlib/gdtoa-dmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,28 @@ rv_alloc(ptr, i) struct _reent *ptr, int i;
rv_alloc(struct _reent *ptr, int i)
#endif
{
int j, k, *r;
int j;
char *r;

/* Allocate buffer in a compatible way with legacy _ldtoa_r(). */
j = sizeof(ULong);
for(k = 0;
sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i;
j <<= 1)
k++;
r = (int*)Balloc(ptr, k);
for (_REENT_MP_RESULT_K (ptr) = 0;
sizeof (Bigint) - sizeof (ULong) + j <= i; j <<= 1)
_REENT_MP_RESULT_K (ptr)++;
_REENT_MP_RESULT (ptr) = eBalloc (ptr, _REENT_MP_RESULT_K (ptr));
r = (char *) _REENT_MP_RESULT (ptr);

if (r == NULL)
return (
#ifndef MULTIPLE_THREADS
dtoa_result =
#endif
NULL);
*r = k;
return
#ifndef MULTIPLE_THREADS
dtoa_result =
#endif
(char *)(r+1);
r;
}

char *
Expand Down Expand Up @@ -100,8 +102,9 @@ freedtoa(ptr, s) struct _reent *ptr, char *s;
freedtoa(struct _reent *ptr, char *s)
#endif
{
Bigint *b = (Bigint *)((int *)s - 1);
b->_maxwds = 1 << (b->_k = *(int*)b);
/* Free buffer allocated in a compatible way with legacy _ldtoa_r(). */
Bigint *b = (Bigint *)s;
b->_maxwds = 1 << (b->_k = _REENT_MP_RESULT_K (ptr));
Bfree(ptr, b);
#ifndef MULTIPLE_THREADS
if (s == dtoa_result)
Expand Down
4 changes: 1 addition & 3 deletions newlib/libc/stdlib/gdtoa-ldtoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ _ldtoa_r(struct _reent *ptr,

/* reentrancy addition to use mprec storage pool */
if (_REENT_MP_RESULT (ptr)) {
_REENT_MP_RESULT (ptr)->_k = _REENT_MP_RESULT_K (ptr);
_REENT_MP_RESULT (ptr)->_maxwds = 1 << _REENT_MP_RESULT_K (ptr);
Bfree (ptr, _REENT_MP_RESULT (ptr));
freedtoa (ptr, (char *) _REENT_MP_RESULT (ptr));
_REENT_MP_RESULT (ptr) = 0;
}

Expand Down
13 changes: 10 additions & 3 deletions winsup/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,12 @@ AM_CONDITIONAL(CROSS_BOOTSTRAP, [test "x$with_cross_bootstrap" != "xyes"])

AC_EXEEXT

AC_CHECK_LIB([bfd], [bfd_init], [true],
AC_MSG_WARN([Not building dumper.exe since some required libraries or headers are missing]))
AC_ARG_ENABLE([dumper],
[AS_HELP_STRING([--disable-dumper], [do not build the 'dumper' utility])],
[build_dumper=$enableval],
[build_dumper=yes])

AM_CONDITIONAL(BUILD_DUMPER, [test "x$ac_cv_lib_bfd_bfd_init" = "xyes"])
AM_CONDITIONAL(BUILD_DUMPER, [test "x$build_dumper" = "xyes"])

# libbfd.a doesn't have a pkgconfig file, so we guess what it's dependencies
# are, based on what's present in the build environment
Expand All @@ -161,6 +163,11 @@ AC_CHECK_LIB([sframe], [sframe_decode], [BFD_LIBS="${BFD_LIBS} -lsframe"])
AC_CHECK_LIB([zstd], [ZSTD_isError], [BFD_LIBS="${BFD_LIBS} -lzstd"])
AC_SUBST([BFD_LIBS])

AC_CHECK_LIB([sframe], [sframe_decode],
AC_MSG_NOTICE([Detected libsframe; Assuming that libbfd depends on it]), [true])

AM_CONDITIONAL(HAVE_LIBSFRAME, [test "x$ac_cv_lib_sframe_sframe_decode" = "xyes"])

AC_CONFIG_FILES([
Makefile
cygwin/Makefile
Expand Down
2 changes: 2 additions & 0 deletions winsup/cygwin/cygwin.din
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ __b64_ntop NOSIGFE
__b64_pton NOSIGFE
__bsd_qsort_r NOSIGFE
__chk_fail SIGFE
__cpuset_alloc SIGFE
__cpuset_free SIGFE
__cxa_atexit = cygwin__cxa_atexit SIGFE
__cxa_finalize SIGFE
__dn_comp SIGFE
Expand Down
23 changes: 16 additions & 7 deletions winsup/cygwin/dcrt0.cc
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,22 @@ dll_crt0_1 (void *)
{
/* Create a copy of Cygwin's version of __argv so that, if the user makes
a change to an element of argv[] it does not affect Cygwin's argv.
Changing the the contents of what argv[n] points to will still
affect Cygwin. This is similar (but not exactly like) Linux. */
char *newargv[__argc + 1];
char **nav = newargv;
char **oav = __argv;
while ((*nav++ = *oav++) != NULL)
continue;
Changing the contents of what argv[n] points to will still affect
Cygwin. This is similar (but not exactly like) Linux.
We used to allocate newargv on the stack, but all the rest of the
argument and environment handling does not depend on the stack,
as it does on Linux. In fact, everything is stored by the parent
in the cygheap, so the only reason this may fail is if we're out
of resources in a big way. If this malloc fails, we could either
fail the entire process execution, or we could proceed with the
original argv and potentially affect output of /proc/self/cmdline.
We opt for the latter here because it's the lesser evil. */
char **newargv = (char **) malloc ((__argc + 1) * sizeof (char *));
if (newargv)
memcpy (newargv, __argv, (__argc + 1) * sizeof (char *));
else
newargv = __argv;
/* Handle any signals which may have arrived */
sig_dispatch_pending (false);
_my_tls.call_signal_handler ();
Expand Down
8 changes: 5 additions & 3 deletions winsup/cygwin/fhandler/dsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ fhandler_dev_dsp::fixup_after_exec ()
int
fhandler_dev_dsp::open (int flags, mode_t)
{
int ret = 0, err = 0;
int ret = -1, err = 0;
UINT num_in = 0, num_out = 0;
set_flags ((flags & ~O_TEXT) | O_BINARY);
// Work out initial sample format & frequency, /dev/dsp defaults
Expand Down Expand Up @@ -1095,7 +1095,7 @@ fhandler_dev_dsp::open (int flags, mode_t)

debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d, ret=%d",
flags & O_ACCMODE, num_in, num_out, err, ret);
if (ret)
if (ret >= 0)
being_closed = false;
return ret;
}
Expand Down Expand Up @@ -1188,7 +1188,9 @@ fhandler_dev_dsp::_read (void *ptr, size_t& len)
return;
}

audio_in_->read ((char *)ptr, (int&)len);
int res = len;
audio_in_->read ((char *)ptr, res);
len = (size_t)res;
}

void
Expand Down
25 changes: 16 additions & 9 deletions winsup/cygwin/fhandler/pty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ inline static bool process_alive (DWORD pid);
stub_only: return only stub process's pid of non-cygwin process. */
DWORD
fhandler_pty_common::get_console_process_id (DWORD pid, bool match,
bool cygwin, bool stub_only)
bool cygwin, bool stub_only,
bool nat)
{
tmp_pathbuf tp;
DWORD *list = (DWORD *) tp.c_get ();
Expand All @@ -109,6 +110,8 @@ fhandler_pty_common::get_console_process_id (DWORD pid, bool match,
else
{
pinfo p (cygwin_pid (list[i]));
if (nat && !!p && !ISSTATE(p, PID_NOTCYGWIN))
continue;
if (!!p && p->exec_dwProcessId)
{
res_pri = stub_only ? p->exec_dwProcessId : list[i];
Expand Down Expand Up @@ -436,8 +439,10 @@ static int osi;
void
fhandler_pty_master::flush_to_slave ()
{
WaitForSingleObject (input_mutex, mutex_timeout);
if (get_readahead_valid () && !(get_ttyp ()->ti.c_lflag & ICANON))
accept_input ();
ReleaseMutex (input_mutex);
}

void
Expand Down Expand Up @@ -523,8 +528,6 @@ fhandler_pty_master::accept_input ()
DWORD bytes_left;
int ret = 1;

WaitForSingleObject (input_mutex, mutex_timeout);

char *p = rabuf () + raixget ();
bytes_left = eat_readahead (-1);

Expand Down Expand Up @@ -626,7 +629,6 @@ fhandler_pty_master::accept_input ()
if (write_to == get_output_handle ())
SetEvent (input_available_event); /* Set input_available_event only when
the data is written to cyg pipe. */
ReleaseMutex (input_mutex);
return ret;
}

Expand Down Expand Up @@ -2247,9 +2249,9 @@ fhandler_pty_master::write (const void *ptr, size_t len)
{
/* This accept_input() call is needed in order to transfer input
which is not accepted yet to non-cygwin pipe. */
WaitForSingleObject (input_mutex, mutex_timeout);
if (get_readahead_valid ())
accept_input ();
WaitForSingleObject (input_mutex, mutex_timeout);
acquire_attach_mutex (mutex_timeout);
fhandler_pty_slave::transfer_input (tty::to_nat, from_master,
get_ttyp (),
Expand Down Expand Up @@ -2317,9 +2319,10 @@ fhandler_pty_master::write (const void *ptr, size_t len)
get_ttyp (), input_available_event);
release_attach_mutex ();
}
ReleaseMutex (input_mutex);

line_edit_status status = line_edit (p, len, ti, &ret);
ReleaseMutex (input_mutex);

if (status > line_edit_signalled && status != line_edit_pipe_full)
ret = -1;
return ret;
Expand Down Expand Up @@ -3577,9 +3580,11 @@ fhandler_pty_slave::get_winpid_to_hand_over (tty *ttyp,
{
/* Search another native process which attaches to the same console */
DWORD current_pid = myself->exec_dwProcessId ?: myself->dwProcessId;
switch_to = get_console_process_id (current_pid, false, true, true);
switch_to = get_console_process_id (current_pid,
false, true, true, true);
if (!switch_to)
switch_to = get_console_process_id (current_pid, false, true, false);
switch_to = get_console_process_id (current_pid,
false, true, false, true);
}
return switch_to;
}
Expand Down Expand Up @@ -3902,7 +3907,9 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
to = ttyp->to_slave ();

pinfo p (ttyp->master_pid);
HANDLE pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
HANDLE pty_owner = NULL;
if (p)
pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
if (pty_owner)
{
DuplicateHandle (pty_owner, to, GetCurrentProcess (), &to,
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/include/cygwin/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ details. */
changes to the DLL and is mainly informative in nature. */

#define CYGWIN_VERSION_DLL_MAJOR 3004
#define CYGWIN_VERSION_DLL_MINOR 7
#define CYGWIN_VERSION_DLL_MINOR 9

/* CYGWIN_VERSION_DLL_COMBINED gives us a single number representing the
combined DLL major and minor numbers. */
Expand Down
Loading

0 comments on commit be82660

Please sign in to comment.