Skip to content

Commit

Permalink
Merge pull request git-for-windows#40 from dscho/rebase-to-v3.3.4
Browse files Browse the repository at this point in the history
Rebase to v3.3.4
  • Loading branch information
dscho authored Feb 14, 2022
2 parents b600e8e + 8f03340 commit 00534e8
Show file tree
Hide file tree
Showing 20 changed files with 693 additions and 275 deletions.
54 changes: 42 additions & 12 deletions newlib/libm/common/frexpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,42 @@ POSSIBILITY OF SUCH DAMAGE.
#include "local.h"

/* On platforms where long double is as wide as double. */
#if defined(_LDBL_EQ_DBL) || (LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024)
#if defined(_LDBL_EQ_DBL)
long double
frexpl (long double x, int *eptr)
{
return frexp(x, eptr);
}
#endif
#else /* !_DBL_EQ_DBL */
# if (LDBL_MANT_DIG == 53) /* 64-bit long double */
static const double scale = 0x1p54;

union ldbl {
long double x;
struct {
# ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */
__uint32_t fracl;
__uint32_t frach:20;
__uint32_t exp:11;
__uint32_t sign:1;
# endif
# ifdef __IEEE_BIG_ENDIAN
__uint32_t sign:1;
__uint32_t exp:11;
__uint32_t frach:20;
# ifndef ___IEEE_BYTES_LITTLE_ENDIAN
# else /* ARMEL without __VFP_FP__ */
__uint32_t frach:20;
__uint32_t exp:11;
__uint32_t sign:1;
# endif
__uint32_t fracl;
# endif
} u32;
};
# elif (LDBL_MANT_DIG == 64) /* 80-bit long double */
static const double scale = 0x1p65;

#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
# if (LDBL_MANT_DIG == 64) /* 80-bit long double */
union ldbl {
long double x;
struct {
Expand All @@ -68,7 +94,9 @@ union ldbl {
# endif
} u32;
};
# else /* LDBL_MANT_DIG == 113, 128-bit long double */
# elif (LDBL_MANT_DIG == 113) /* 128-bit long double */
static const double scale = 0x1p114;

union ldbl {
long double x;
struct {
Expand Down Expand Up @@ -96,9 +124,11 @@ union ldbl {
# endif
} u32;
};
# else
# error Unsupported long double format.
# endif

static const double two114 = 0x1p114;
static const int scale_exp = LDBL_MANT_DIG + 1;

long double
frexpl (long double x, int *eptr)
Expand All @@ -107,16 +137,16 @@ frexpl (long double x, int *eptr)
u.x = x;
int e = u.u32.exp;
*eptr = 0;
if (e == 0x7fff || x == 0)
if (e == (LDBL_MAX_EXP*2 - 1) || x == 0)
return x; /* inf,nan,0 */
if (e == 0) /* subnormal */
{
u.x *= two114;
u.x *= scale;
e = u.u32.exp;
*eptr -= 114;
*eptr -= scale_exp;
}
*eptr += e - 16382;
u.u32.exp = 0x3ffe; /* 0 */
*eptr += e - (LDBL_MAX_EXP - 2);
u.u32.exp = LDBL_MAX_EXP - 2; /* -1 */
return u.x;
}
#endif /* End of 80-bit or 128-bit long double */
#endif /* !_LDBL_EQ_DBL */
3 changes: 2 additions & 1 deletion winsup/cygwin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ $(LDSCRIPT): $(LDSCRIPT).in
$(CC) -E - -P < $^ -o $@

# msys-2.0 dll
$(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg libdll.a $(VERSION_OFILES) $(LIBSERVER)
$(TEST_DLL_NAME): $(LDSCRIPT) dllfixdbg libdll.a $(VERSION_OFILES) $(LIBSERVER)\
$(newlib_build)/libm/libm.a $(newlib_build)/libc/libc.a
$(CXX) $(CXXFLAGS) \
-mno-use-libstdc-wrappers \
-Wl,--gc-sections -nostdlib -Wl,-T$(LDSCRIPT) -static \
Expand Down
10 changes: 4 additions & 6 deletions winsup/cygwin/fhandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ fhandler_base::open_with_arch (int flags, mode_t mode)
if (!(res = (archetype && archetype->io_handle)
|| open (flags, mode & 07777)))
{
if (archetype)
delete archetype;
if (archetype && archetype->usecount == 0)
cygheap->fdtab.delete_archetype (archetype);
}
else if (archetype)
{
Expand Down Expand Up @@ -561,12 +561,10 @@ fhandler_base::open (int flags, mode_t mode)
access = READ_CONTROL | FILE_READ_ATTRIBUTES;
break;
case query_write_control:
access = READ_CONTROL | WRITE_OWNER | WRITE_DAC
| (pc.fs_is_samba () ? 0 : FILE_WRITE_ATTRIBUTES);
access = READ_CONTROL | WRITE_OWNER | WRITE_DAC | FILE_WRITE_ATTRIBUTES;
break;
case query_write_dac:
access = READ_CONTROL | WRITE_DAC
| (pc.fs_is_samba () ? 0 : FILE_WRITE_ATTRIBUTES);
access = READ_CONTROL | WRITE_DAC | FILE_WRITE_ATTRIBUTES;
break;
case query_write_attributes:
access = READ_CONTROL | FILE_WRITE_ATTRIBUTES;
Expand Down
9 changes: 8 additions & 1 deletion winsup/cygwin/fhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,9 @@ class fhandler_serial: public fhandler_base
#define release_output_mutex() \
__release_output_mutex (__PRETTY_FUNCTION__, __LINE__)

DWORD acquire_attach_mutex (DWORD t);
void release_attach_mutex (void);

class tty;
class tty_min;
class fhandler_termios: public fhandler_base
Expand Down Expand Up @@ -1938,6 +1941,8 @@ class fhandler_termios: public fhandler_base
fh->copy_from (this);
return fh;
}
static bool path_iscygexec_a (LPCSTR n, LPSTR c);
static bool path_iscygexec_w (LPCWSTR n, LPWSTR c);
};

enum ansi_intensity
Expand Down Expand Up @@ -2206,9 +2211,11 @@ class fhandler_console: public fhandler_termios
void acquire_input_mutex_if_necessary (DWORD ms)
{
acquire_input_mutex (ms);
acquire_attach_mutex (ms);
}
void release_input_mutex_if_necessary (void)
{
release_attach_mutex ();
release_input_mutex ();
}

Expand Down Expand Up @@ -2280,6 +2287,7 @@ class fhandler_pty_common: public fhandler_termios
static DWORD get_console_process_id (DWORD pid, bool match,
bool cygwin = false,
bool stub_only = false);
bool to_be_read_from_pcon (void);

protected:
static BOOL process_opost_output (HANDLE h, const void *ptr, ssize_t& len,
Expand Down Expand Up @@ -2446,7 +2454,6 @@ class fhandler_pty_master: public fhandler_pty_common
fh->copy_from (this);
return fh;
}
bool to_be_read_from_pcon (void);
void get_master_thread_param (master_thread_param_t *p);
void get_master_fwd_thread_param (master_fwd_thread_param_t *p);
void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho = m; }
Expand Down
2 changes: 1 addition & 1 deletion winsup/cygwin/fhandler_clipboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ fhandler_dev_clipboard::read (void *ptr, size_t& len)
if (pos < (off_t) clipbuf->cb_size)
{
ret = (len > (clipbuf->cb_size - pos)) ? clipbuf->cb_size - pos : len;
memcpy (ptr, &clipbuf[1] + pos , ret);
memcpy (ptr, (char *) (clipbuf + 1) + pos, ret);
pos += ret;
}
}
Expand Down
Loading

0 comments on commit 00534e8

Please sign in to comment.