Skip to content

Commit

Permalink
Merge pull request #62 from dscho/msys2-runtime-v3.4.10
Browse files Browse the repository at this point in the history
Update to MSYS2 runtime v3.4.10
  • Loading branch information
dscho authored Nov 29, 2023
2 parents 9638e0a + b7ef037 commit b7b5f3a
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 82 deletions.
8 changes: 4 additions & 4 deletions newlib/libc/locale/nl_langinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static struct _nl_item_t
_NLITEM (ctype, woutdigits[8]),
_NLITEM (ctype, woutdigits[9]),
_NLITEM (time, codeset),
_NLITEM (time, wmon[0]),
_NLITEM (time, wmon[1]),
_NLITEM (time, wmon[2]),
_NLITEM (time, wmon[3]),
Expand All @@ -89,7 +90,7 @@ static struct _nl_item_t
_NLITEM (time, wmon[9]),
_NLITEM (time, wmon[10]),
_NLITEM (time, wmon[11]),
_NLITEM (time, wmon[12]),
_NLITEM (time, wmonth[0]),
_NLITEM (time, wmonth[1]),
_NLITEM (time, wmonth[2]),
_NLITEM (time, wmonth[3]),
Expand All @@ -101,21 +102,20 @@ static struct _nl_item_t
_NLITEM (time, wmonth[9]),
_NLITEM (time, wmonth[10]),
_NLITEM (time, wmonth[11]),
_NLITEM (time, wmonth[12]),
_NLITEM (time, wwday[0]),
_NLITEM (time, wwday[1]),
_NLITEM (time, wwday[2]),
_NLITEM (time, wwday[3]),
_NLITEM (time, wwday[4]),
_NLITEM (time, wwday[5]),
_NLITEM (time, wwday[6]),
_NLITEM (time, wwday[7]),
_NLITEM (time, wweekday[0]),
_NLITEM (time, wweekday[1]),
_NLITEM (time, wweekday[2]),
_NLITEM (time, wweekday[3]),
_NLITEM (time, wweekday[4]),
_NLITEM (time, wweekday[5]),
_NLITEM (time, wweekday[6]),
_NLITEM (time, wweekday[7]),
_NLITEM (time, wX_fmt),
_NLITEM (time, wx_fmt),
_NLITEM (time, wc_fmt),
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/cygwin.din
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ fegetround NOSIGFE
feholdexcept SIGFE
feof SIGFE
feof_unlocked SIGFE
feraiseexcept SIGFE
feraiseexcept NOSIGFE
ferror SIGFE
ferror_unlocked SIGFE
fesetenv SIGFE
Expand Down
11 changes: 10 additions & 1 deletion winsup/cygwin/fhandler/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,15 @@ fhandler_base::open (int flags, mode_t mode)
NtClose (fh);
goto done;
}
/* Drop sparseness */
if (pc.file_attributes () & FILE_ATTRIBUTE_SPARSE_FILE)
{
FILE_SET_SPARSE_BUFFER fssb = { SetSparse: FALSE };
status = NtFsControlFile (fh, NULL, NULL, NULL, &io,
FSCTL_SET_SPARSE, &fssb, sizeof fssb, NULL, 0);
if (NT_SUCCESS (status))
pc.file_attributes (pc.file_attributes () & ~FILE_ATTRIBUTE_SPARSE_FILE);
}
}

set_handle (fh);
Expand Down Expand Up @@ -1705,7 +1714,7 @@ fhandler_base::fadvise (off_t offset, off_t length, int advice)
int
fhandler_base::ftruncate (off_t length, bool allow_truncate)
{
return EINVAL;
return ENODEV;
}

int
Expand Down
3 changes: 2 additions & 1 deletion winsup/cygwin/fhandler/dsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,8 @@ fhandler_dev_dsp::Audio_out::waitforallsent ()
while (Qisr2app_->query () != MAX_BLOCKS)
{
debug_printf ("%d blocks in Qisr2app", Qisr2app_->query ());
Sleep (100);
cygwait (1);
sendcurrent ();
}
}

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 9
#define CYGWIN_VERSION_DLL_MINOR 10

/* CYGWIN_VERSION_DLL_COMBINED gives us a single number representing the
combined DLL major and minor numbers. */
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/include/sys/cpuset.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void __cpuset_free (cpu_set_t *);

/* These _S macros operate on dynamically-sized cpu sets of size 'siz' bytes */
#define CPU_ZERO_S(siz, set) __cpuset_zero_s (siz, set)
static __inline
static __inline void
__cpuset_zero_s (__size_t siz, cpu_set_t *set)
{
#if __GNUC_PREREQ (2, 91)
Expand Down
3 changes: 1 addition & 2 deletions winsup/cygwin/path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5197,10 +5197,9 @@ cwdstuff::set (path_conv *nat_cwd, const char *posix_cwd)
peb.ProcessParameters->CurrentDirectoryHandle,
GetCurrentProcess (), &h, 0, TRUE, 0))
{
release_write ();
if (peb.ProcessParameters->CurrentDirectoryHandle)
debug_printf ("...and DuplicateHandle failed with %E.");
dir = NULL;
h = NULL;
}
}
}
Expand Down
91 changes: 45 additions & 46 deletions winsup/cygwin/random.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,22 @@

#define __INSIDE_CYGWIN__

#include "winsup.h"

SRWLOCK NO_COPY rndlock = SRWLOCK_INIT;
# define __random_lock() { if (__isthreaded) \
AcquireSRWLockExclusive (&rndlock); }
# define __random_unlock() { if (__isthreaded) \
ReleaseSRWLockExclusive (&rndlock); }

extern "C" {
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.25 2007/01/09 00:28:10 imp Exp $");

#include <sys/time.h> /* for srandomdev() */
#include <fcntl.h> /* for srandomdev() */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> /* for srandomdev() */

/*
* random.c:
Expand Down Expand Up @@ -248,6 +252,8 @@ static inline uint32_t good_rand (int32_t x)
#endif /* !USE_WEAK_SEEDING */
}

static long __random_unlocked();

/*
* srandom:
*
Expand All @@ -260,8 +266,8 @@ static inline uint32_t good_rand (int32_t x)
* introduced by the L.C.R.N.G. Note that the initialization of randtbl[]
* for default usage relies on values produced by this routine.
*/
void
srandom(unsigned x)
static void
__srandom_unlocked(unsigned x)
{
int i, lim;

Expand All @@ -276,49 +282,19 @@ srandom(unsigned x)
lim = 10 * rand_deg;
}
for (i = 0; i < lim; i++)
(void)random();
(void)__random_unlocked();
}

/*
* srandomdev:
*
* Many programs choose the seed value in a totally predictable manner.
* This often causes problems. We seed the generator using the much more
* secure random(4) interface. Note that this particular seeding
* procedure can generate states which are impossible to reproduce by
* calling srandom() with any value, since the succeeding terms in the
* state buffer are no longer derived from the LC algorithm applied to
* a fixed seed.
*/
void
srandomdev()
srandom(unsigned x)
{
size_t len;

if (rand_type == TYPE_0)
len = sizeof state[0];
else
len = rand_deg * sizeof state[0];

if (getentropy ((void *) state, len)) {
struct timeval tv;
unsigned long junk;

gettimeofday(&tv, NULL);
/* Avoid a compiler warning when we really want to get at the
junk in an uninitialized variable. */
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk);
#pragma GCC diagnostic pop
return;
}

if (rand_type != TYPE_0) {
fptr = &state[rand_sep];
rptr = &state[0];
}
__random_lock();
__srandom_unlocked(x);
__random_unlock();
}

EXPORT_ALIAS (srandom, srand)

/*
* initstate:
*
Expand Down Expand Up @@ -350,6 +326,7 @@ initstate(unsigned seed, /* seed for R.N.G. */
char *ostate = (char *)(&state[-1]);
uint32_t *int_arg_state = (uint32_t *)arg_state;

__random_lock();
if (rand_type == TYPE_0)
state[-1] = rand_type;
else
Expand All @@ -358,6 +335,7 @@ initstate(unsigned seed, /* seed for R.N.G. */
(void)fprintf(stderr,
"random: not enough state (%lu bytes); ignored.\n",
(unsigned long) n);
__random_unlock();
return(0);
}
if (n < BREAK_1) {
Expand All @@ -383,11 +361,12 @@ initstate(unsigned seed, /* seed for R.N.G. */
}
state = int_arg_state + 1; /* first location */
end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */
srandom(seed);
__srandom_unlocked(seed);
if (rand_type == TYPE_0)
int_arg_state[0] = rand_type;
else
int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type;
__random_unlock();
return(ostate);
}

Expand Down Expand Up @@ -418,6 +397,7 @@ setstate(char *arg_state /* pointer to state array */)
uint32_t rear = new_state[0] / MAX_TYPES;
char *ostate = (char *)(&state[-1]);

__random_lock();
if (rand_type == TYPE_0)
state[-1] = rand_type;
else
Expand All @@ -442,6 +422,7 @@ setstate(char *arg_state /* pointer to state array */)
fptr = &state[(rear + rand_sep) % rand_deg];
}
end_ptr = &state[rand_deg]; /* set end_ptr too */
__random_unlock();
return(ostate);
}

Expand All @@ -462,8 +443,8 @@ setstate(char *arg_state /* pointer to state array */)
*
* Returns a 31-bit random number.
*/
long
random()
static long
__random_unlocked()
{
uint32_t i;
uint32_t *f, *r;
Expand All @@ -490,4 +471,22 @@ random()
}
return((long)i);
}

long
random()
{
long r;

__random_lock();
r = __random_unlocked();
__random_unlock();
return (r);
}

int
rand()
{
return ((int) random());
}

}
26 changes: 26 additions & 0 deletions winsup/cygwin/release/3.4.10
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Bug Fixes
---------

- Fix missing term in __cpuset_zero_s() prototoype in sys/cpuset.h.
Addresses: https://cygwin.com/pipermail/cygwin/2023-September/254423.html

- Fix hang in process initialization if cwd is unreadable.
Addresses: https://cygwin.com/pipermail/cygwin/2023-October/254604.html

- Let feraiseexcept actually raise an exception.
Addresses: https://cygwin.com/pipermail/cygwin/2023-October/254667.html

- Make random(3) family of functions thread-safe.
Addresses: https://cygwin.com/pipermail/cygwin/2023-November/254734.html

- Updates to profiler and gmondump: error display mechanics, buffer sizing,
and output formatting.

- Align behaviour of rand(3) to ISO C.
Adresses: https://cygwin.com/pipermail/cygwin/2023-November/254735.html

- Fix posix_fallocate(3) return value in case of being called on
other than regular files.

- Reset sparseness in case open(2) has been called with O_CREAT|O_TRUNC on
sparse files.
4 changes: 4 additions & 0 deletions winsup/cygwin/syscalls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2998,6 +2998,8 @@ posix_fallocate (int fd, off_t offset, off_t len)
res = cfd->ftruncate (offset + len, false);
else
res = EBADF;
if (res == EISDIR)
res = ENODEV;
}
syscall_printf ("%R = posix_fallocate(%d, %D, %D)", res, fd, offset, len);
return res;
Expand All @@ -3013,6 +3015,8 @@ ftruncate (int fd, off_t length)
res = cfd->ftruncate (length, true);
if (res)
{
if (res == ENODEV)
res = EINVAL;
set_errno (res);
res = -1;
}
Expand Down
8 changes: 5 additions & 3 deletions winsup/utils/gmondump.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void
note (const char *fmt, ...)
{
va_list args;
char buf[4096];
char buf[BUFSIZ];

va_start (args, fmt);
vsprintf (buf, fmt, args);
Expand All @@ -72,7 +72,7 @@ void
warn (int geterrno, const char *fmt, ...)
{
va_list args;
char buf[4096];
char buf[BUFSIZ];

va_start (args, fmt);
sprintf (buf, "%s: ", pgm);
Expand All @@ -92,10 +92,12 @@ void __attribute__ ((noreturn))
error (int geterrno, const char *fmt, ...)
{
va_list args;
char buf[BUFSIZ];

va_start (args, fmt);
warn (geterrno, fmt, args);
vsprintf (buf, fmt, args);
va_end (args);
warn (geterrno, "%s", buf);

exit (1);
}
Expand Down
Loading

0 comments on commit b7b5f3a

Please sign in to comment.