Commit Graph

11308 Commits

Author SHA1 Message Date
Corinna Vinschen b1f63ce874 Fix typos in comments and debug output in select_stuff::wait
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-08 11:02:50 +02:00
Corinna Vinschen ffac52c1ab Add release message for commit 7239bb7b3d
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 19:02:08 +02:00
Corinna Vinschen 0177f12cf6 Add release message for select(2) changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 17:24:39 +02:00
Corinna Vinschen 7186b657e7 Improve timer handling in select.
Commit a23e6a35d8 introduced a timer
object to the WFMO handling in select_stuff::wait to allow sub-tickcount
timeout values in select.

Problems with this patch: The timer was created and destroyed on every
invocation of select_stuff::wait, thus potentially multiple times per
select.  Also, since the timer was prepended to the WFMO hande list,
the timer handle could shadow actual events on other objects, given that
WFMO checks the objects in the order they have been specified in the
HANDLE array.  The timer was also created/destroyed and added to the
HANDLE array even if it was not required.

This patch drops the local timer HANDLE and recycles the cw_timer HANDLE
in the cygtls area instead.  Thus we typically don't need to create the
timer in select at all, and we never have to destroy it.

The timer HANDLE is now also appended as last object to the HANDLE array,
and it's only added if actually needed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 16:48:38 +02:00
Corinna Vinschen 83834110a0 Fix condition in select which results in busy loop.
The check for current timestamp > start timestamp has an unwelcome
side effect:  The loop is not left as long as the current timestamp
hasn't been incremented.  This leads to busy loops of about one tick
(10 to 16 ms per MSDN).

This fixes https://cygwin.com/ml/cygwin/2016-05/msg00327.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 16:18:53 +02:00
Takashi Yano 7239bb7b3d Return at most one line of input in canonical mode
'man termios' says:
"A read(2) returns at most one line of input" in canonical mode.

On cygwin 2.5.1, read(2) returns all data in buffer if the buffer
size specified is large enough. This behaviour is correct in
noncanonical mode, but is not correct in canonical mode.

While checking this problem, I found a bug of tcflush().  tcflush()
flushes only partial data in the buffer.  The patch also fixes this bug.

The patch has also been tested against the problem reported in
https://cygwin.com/ml/cygwin/2016-05/msg00318.html.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 15:10:25 +02:00
Ken Brown 97349b7870 Allow 'make distclean' to clean winsup/cygwin
But don’t let it remove source files.
2016-06-06 11:52:19 +02:00
Corinna Vinschen 7abe634731 Only regenerate tlsoffsets{64}.h if cygtls.h can be compiled
The rule to make tlsoffset{64}.h has a flaw.  If cygtls.h can't be
built for whatever reason, it *still* regenerates tlsoffsets{64}.h,
just with size 0.  If the bug is not in cygtls.h itself, this behaviour
breaks further building, because fixing the problem won't result in
regenerating tlsoffset{64}.h.  Manual intervention is required.

Fix that by removing tlsoffsets{64}.h if gentls_offsets fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-06 11:44:54 +02:00
Yaakov Selkowitz f4edc7fd6d cygwin: include sys/types.h in sys/xattr.h
Using libattr's <xattr/xattr.h> requires consumers to explicitly include
<sys/types.h> first, but glibc's header in sys/ already contains the include.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-06-03 03:34:11 -05:00
Corinna Vinschen b0b99e39dc sched.cc: Use PROCESS_QUERY_INFORMATION for now
Temporarily revert to use PROCESS_QUERY_INFORMATION instead of
PROCESS_QUERY_LIMITED_INFORMATION to make sure every aspect of the
next release is still XP/2003 compatible.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-03 10:28:44 +02:00
Corinna Vinschen 211a942ad2 Revert "Cygwin hangs up if several keys are typed during outputting a lot of texts."
This reverts commit 252a07b0ad.

This change introduced a hang in certain scenarios, for an example
see https://cygwin.com/ml/cygwin/2016-05/msg00318.html
2016-06-01 17:04:24 +02:00
Corinna Vinschen 8a31aa37bc dlopen: Add dot to filename if no slash is present
We're appending a dot to the filename before calling LoadLibrary to
override ".dll" automagic.  This only worked for paths, not for simple
filenames since it required a slash in the pathname.  Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-01 13:12:22 +02:00
Corinna Vinschen c496a068cf Cygwin: Add release messages for previous two commits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-31 16:37:53 +02:00
Corinna Vinschen 5c759ab2f4 realpath: Handle Win32 and NT long path prefixes
So far drive letter paths have been handled special since path_conv
leaves the incoming path untouched except for converting backslashes
to forward slashes.  However, if the incoming path starts with a
long path prefix, the same problem occurs.  Therefore handle all
paths starting with a backslahs the same way.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-31 16:33:21 +02:00
Corinna Vinschen 030d86d04d TZ: Replace unreliable isupper calls on wchars
In case the TZ variable is empty, Cygwin fetches timezone info from
Windows.  Extracting the timezone short name uses isupper on wide chars.
Replace with explicit check for A <= character <= Z to be independent
of undefined behaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-25 12:13:03 +02:00
Adam Dinwoodie 3b66731698 Git is Git, not GIT
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-24 12:09:10 +02:00
Corinna Vinschen 8d7b9a199c Fix typo and wrong URL in winsup/README
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-24 10:25:18 +02:00
Corinna Vinschen 4e434bf223 Add release message for previous mmap fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 21:50:41 +02:00
Corinna Vinschen 0aa738220b mmap: Fix size restriction of maps due to using 32 bit size type
Throughout mmap, size-related variables and parameters are still using
DWORD as type, which disallows mapping ranges > 4Gigs.  Fix this by
using SIZE_T throughout for those vars and parameters.
Also, drop unused off parameter from 1st variant of mmap_record::map_pages.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 21:48:10 +02:00
Corinna Vinschen 2e62d68ba5 Add release message for scheduler fixes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 18:01:11 +02:00
Corinna Vinschen 4b51e4c142 Fix thread priority handling
So far pthread::postcreate() only sets the thread priority at all, only
if the inherit-scheduler attribute is PTHREAD_EXPLICIT_SCHED.  This
completely ignores the PTHREAD_INHERIT_SCHED case, since in contrast
to POSIX, a thread does not inherit its priority from the creating
thread, but always starts with THREAD_PRIORITY_NORMAL.

pthread_getschedparam() only returns what's stored in the thread attributes,
not the actual thread priority.

This patch fixes both problems.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 17:45:24 +02:00
Corinna Vinschen 450f557fee Rewrite scheduler functions getting and setting process and thread priority
So far the scheduler priority handling is not POSIX compatible.
The priorities use a range of -14 up to +15, which means it's not clear
if the POSIX-required return value of -1 in case of an error is *really*
an error or just the valid priority value -1.  Even more confusing, -14
is the *max* value and 15 is the *min* value.  Last but not least this
range doesn't match the POSIX requirement of at least 32 priority values.

This patch cleans up scheduler priority handling and moves the valid
priority range to 1 (min) - 32 (max).  It also adds a function
sched_get_thread_priority() which will help to make thread priority
more POSIX-like.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-20 17:38:22 +02:00
John Hood 6dd601af66 Miscellaneous style cleanup, whitespace only. 2016-05-20 12:11:18 +02:00
John Hood e5665d8c93 Improve and simplify select().
* select.h: Eliminate redundant select_stuff::select_loop state.
* select.cc (select): Eliminate redundant
  select_stuff::select_loop state.  Eliminate redundant code for
  zero timeout.  Do not return early on early timer return.
  (select_stuff::wait): Eliminate redundant
  select_stuff::select_loop state.
2016-05-20 12:00:58 +02:00
John Hood a23e6a35d8 Use high-resolution timebases for select().
* select.h: Change prototype for select_stuff::wait() for larger
  microsecond timeouts.
* select.cc (pselect): Convert from old cygwin_select().
  Implement microsecond timeouts.
  (cygwin_select): Rewrite as a wrapper on pselect().
  (select): Implement microsecond timeouts.
  (select_stuff::wait): Implement microsecond timeouts with a timer
  object.
2016-05-20 12:00:38 +02:00
Corinna Vinschen f6d9d8a182 Bump Cygwin DLL version to 2.5.2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-05-18 21:27:57 +02:00
Sebastian Huber 51062c856b Always provide register_t via <sys/types.h>
Always provide register_t via <sys/types.h> for glibc and BSD
compatibility.  Define __BIT_TYPES_DEFINED__ to 1 like glibc for legacy
header files.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-21 10:28:13 +02:00
Corinna Vinschen 8cb99e8ba4 Remove cygwin/types.h 2016-04-21 10:12:02 +02:00
Sebastian Huber 9bb91b6c6b Resurrect <machine/types.h> for <sys/types.h>
Resurrect <machine/_user_types.h> for use in <sys/types.h>.  Newlib
targets may provide an own version of <machine/types.h> in their machine
directory to add custom user types for <sys/types.h>.  Check the
_SYS_TYPES_H header guard to prevent a direct include of
<machine/types.h>, since the <machine/types.h> file is a Newlib
speciality.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-21 10:08:19 +02:00
Corinna Vinschen 1f02aa08d1 Add release message for commit 9409c53 2016-04-20 12:34:07 +02:00
Corinna Vinschen 9409c5335b Don't test pthread objects for being already initialized at init time
For all pthread init functions, POSIX says

  Results are undefined if pthread_FOO_init() is called specifying an
  already initialized pthread_FOO object.

So far our pthread init functions tested the incoming object if it's
already an initialized object and, if so, returned EBUSY.  That's ok
*iff* the object was already initialized.  However, as the example in
https://cygwin.com/ml/cygwin/2016-04/msg00473.html shows, an uninitialized
pthread object could also accidentally look like an initialized object
and then returning EBUSY is not ok.

Consequentially, all those tests are dangerous.  Per POSIX, an application
has to know what its doing when calling any of the pthread init functions
anyway, and re-initializing the object is just as well as undefined
behaviour as is returning EBUSY on already initialized objects.

	* thread.cc (pthread_attr_init): Drop check for already initialized
	object.
	(pthread_condattr_init): Ditto.
	(pthread_rwlockattr_init): Ditto.
	(pthread_mutexattr_init): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-20 12:31:45 +02:00
Sebastian Huber 7d22dc338d Provide in_port_t via <sys/types.h>
Provide in_port_t via <sys/types.h> if __BSD_VISIBLE for BSD
compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 23:40:53 +02:00
Sebastian Huber 3ce1e7901e Provide in_addr_t via <sys/types.h>
Provide in_addr_t via <sys/types.h> if __BSD_VISIBLE for BSD
compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 17:21:38 +02:00
Sebastian Huber e03a7056a6 Introduce __sa_family_t for BSD compatibiliy
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 17:06:49 +02:00
Sebastian Huber cb376b255d Introduce __socklen_t for BSD compatibility
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 16:51:00 +02:00
Sebastian Huber 76a2110b47 BSD compatibility for <machine/endian.h>
Introduce <machine/_endian.h> to let target based customization of
<machine/endian.h> via

 * _LITTLE_ENDIAN,
 * _BIG_ENDIAN,
 * _PDP_ENDIAN, and
 * _BYTE_ORDER.

defines.  Add definitions expected by FreeBSD to
<machine/endian.h> like

 * _QUAD_HIGHWORD,
 * _QUAD_LOWWORD,
 * __bswap16(),
 * __bswap32(),
 * __bswap64(),
 * __htonl(),
 * __htons(),
 * __ntohl(), and
 * __ntohs().

Also, if __BSD_VISIBLE

 * LITTLE_ENDIAN,
 * BIG_ENDIAN,
 * PDP_ENDIAN, and
 * BYTE_ORDER.

Targets that define __machine_host_to_from_network_defined in
<machine/_endian.h> must provide their own implementation of

 * __htonl(),
 * __htons(),
 * __ntohl(), and
 * __ntohs(),

otherwise a default implementation is provided by <machine/endian.h>.
In case of GCC defines to builtins are used.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-19 16:36:51 +02:00
Corinna Vinschen 7a5b452443 Disallow S_ISGID on directories without default ACL entries
We can't handle the S_ISGID bit if the child didn't inherit a NULL SID
ACE with the S_ISGID bit set.  On directories without default ACL
entries we would have to add an inheritable NULL SID ACE and nothing else.
This in turn results in permission problems when calling set_file_sd
from set_created_file_access.  That's fixable, but it would only work
for files created from Cygwin while files created from native Windows
tools end up with really ugly permissions.

This patch only makes sure that the S_ISGID bit is reset for a directory
if it has no inheritable ACEs.  Still having the 's' bit shown in ls or
getfacl output would be misleading.  So, calling `setfacl -k' on a dir
also removes the S_ISGID bit now.

	* sec_acl.cc (set_posix_access): Drop S_ISGID bit on directories
	without inheritable ACEs.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-19 10:23:49 +02:00
Corinna Vinschen 97d0449325 Handle permissions a bit closer to POSIX 1003.1e
So far we tweaked ACL_GROUP_OBJ and ACL_MASK values the same way when
creating a file.  We now do what POSIX requires, namely just change
ACL_MASK if it's present, otherwise ACL_GROUP_OBJ.  Note that we only
do this at creation time.  Chmod still tweaks both to create less
surprising results for the unsuspecting user.

Additionally make sure to take umask only into account if no ACL_MASK
value is present.  That has been missed so far.

	* sec_acl.cc (set_posix_access): Perform check for non-existant
	default	ACEs earlier.  Ignore umask also if ACL_MASK is present.
	Only set owner_eq_group if we're actually handling a user entry.
	Mention chmod in a comment.
	* security.cc (set_created_file_access): Perform group/mask
	permission setting as required by POSIX 1003.1e.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 20:43:00 +02:00
Corinna Vinschen 12cc8290e8 Also create NULL SID ACE if special POSIX bits are set
Commit e2ea143 forgot to take special POSIX bits into account.

	* sec_acl.cc (set_posix_access): Make sure to create NULL SID
	ACE if any special POSIX permission bits are set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 15:36:34 +02:00
Corinna Vinschen c36070f2f6 Add release message for commit e2ea143 2016-04-18 12:09:18 +02:00
Corinna Vinschen e2ea143083 Fix attempt to create ACLs without NULL SID
Commit f75114fc was supposed to drop NULL SIDs in case the permissions
are simple enough not to require mask values or special POSIX bits
(S_ISVTX, etc).  The check was incorrect.  This patch is supposed to
fix the problem.

	* sec_acl.cc (set_posix_access): Fix condition under which we
	write a NULL SID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-18 12:07:04 +02:00
Corinna Vinschen ea58e20c0e Cygwin: Drop definition and usage of _mode_t in favor of __mode_t
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber f3e587d30a Provide POSIX defined fsblkcnt_t and fsfilcnt_t
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber c5d5030aea Provide POSIX defined blksize_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber 57d2718c0e Provide POSIX defined blkcnt_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:40 +02:00
Sebastian Huber eba91a5d0a Define mode_t via __mode_t
Use __uint32_t to avoid the use of GCC-specific _ST_INT32.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber e77040b2bf Add BSD guard for ino_t in <sys/types.h>
Introduce internal type __ino_t.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber eeded3c170 Provide POSIX defined id_t in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Sebastian Huber 8a5af1a184 Use __machine_*_t_defined for internal types
Newlib defines defaults for internal types via <sys/_types.h> and uses
<machine/_types.h> to let targets define their own type if necessary.

Previously for example

	#ifndef __dev_t_defined
	typedef short __dev_t;
	#endif

However, the __*_t_defined pattern conflicts with the glibc type guard
pattern for user types, e.g. dev_t in this example.  Introduce a
__machine_*_t_defined pattern for internal types (defined by
<machine/_types.h>, used by <sys/_types.h>).  For example

	#ifndef __machine_dev_t_defined
	typedef short __dev_t;
	#endif

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-15 14:51:39 +02:00
Corinna Vinschen 7b39124400 Get rid of some special cases for Cygwin in sys/types.h
Remove off_t typedef from cygwin/types.h thus relying on sys/types.h.
Introduce winsup/cygwin/machine/_types.h and move some types shared
with newlib into it.  Get rid of their definition in cygwin/types.h.
Add same handling for __key_t/key_t as for the other types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-13 21:00:17 +02:00
Sebastian Huber 477463a201 Eliminate use of Newlib-specific <machine/types.h>
This change solves a glibc/BSD compatibility problem.

glibc and BSD use double underscore types for internal types.  The Linux
port of Newlib uses some glibc provided internal type definitions which
are not protected by guard defines, e.g. __off_t.  To avoid a conflict
Newlib uses single underscore types for some internal types, e.g.
_off_t.  However, for BSD compatibility we have to define the internal
types with double underscore names in <sys/_types.h>.

The header file <machine/types.h> is Newlib-specific.  It was used
instead of <sys/_types.h> to provide the internal type definitions
_CLOCK_T, _TIME_T_, _CLOCKID_T_, _TIMER_T_, and __suseconds_t.  Move
these definitions to <sys/_types.h> (there exist two instances of this
file, one for Linux and one for all other targets).  This makes the
_HAVE_SYSTYPES configuration define obsolete (could possibly break the
__RDOS__ target).  Use the standard <sys/_types.h> include throughout.

Move __loff_t defintion to default (non-Linux) <sys/_types.h>.  Define
it via _off64_t to avoid a dependency on the compiler.

Provide the __off_t definition via default (non-Linux) <sys/_types.h>
based on _off_t for all systems except Cygwin.  For Cygwin use _off64_t.
Define off_t via __off_t.

Provide the __pid_t definition via default (non-Linux) <sys/_types.h>.
This prevents a potential __pid_t and pid_t incompatibility.  Add BSD
guard defines for pid_t.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-04-13 13:30:27 +02:00
Corinna Vinschen eb6f1d7b77 Add Cygwin 2.5.1 release message file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:26:53 +02:00
Corinna Vinschen 002c9b468d Reformat comments in Cygwin's version.h, remove very outdated info
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:23:41 +02:00
Corinna Vinschen 308de2a1d4 Bump Cygwin DLL version to 2.5.1.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:18:29 +02:00
Corinna Vinschen e185421106 strxfrm/wcsxfrm: Always return length of the transformed string
Cygwin's strxfrm/wcsfrm treated a too short output buffer as an error
condition and always returned the size value provided as third parameter.
This is not as it's documented in POSIX.1-2008.  Rather, the only error
condition is an invalid input string(*).

Other than that, the functions are supposed to return the length of the
resulting sort key, even if the output buffer is too small.  In the latter
case the content of the output array is unspecified, but it's the job
of the application to check that the return value is greater or equal to
the provided buffer size.

(*) We have to make an exception in Cygwin:  strxfrm has to call the
    UNICODE function LCMapStringW for reasons outlined in a source comment.
    If the incoming multibyte string is so large that we fail to malloc
    the space required to convert it to a wchar_t string, we have to
    ser errno as well since we have nothing to call LCMapStringW with.

	* nlsfuncs.cc (wcsxfrm): Fix expression computing offset of
	trailing wchar_t NUL.  Compute correct return value even if
	output buffer is too small.
	(strxfrm): Handle failing malloc.  Compute correct return value
	even if	output buffer is too small.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-12 15:06:05 +02:00
Johannes Schindelin 03ecfb9280 Be truthful about reporting whether readahead is available
In 7346568 (Make requested console reports work, 2016-03-16), code was
introduced to report the current cursor position. It works by using a
pointer that either points to the next byte in the readahead buffer, or
to a NUL byte if the buffer is depleted, or the pointer is NULL.

These conditions are heeded in the fhandler_console::read() method, but
the condition that the pointer can point at the end of the readahead
buffer was not handled properly in the get_cons_readahead_valid()
method.

This poses a problem e.g. in Git for Windows (which uses a slightly
modified MSYS2 runtime which is in turn a slightly modified Cygwin
runtime) when vim queries the cursor position and immediately goes on to
read console input, erroneously thinking that the readahead buffer is
valid when it is already depleted instead. This condition results in an
apparent freeze that can be helped only by pressing keys repeatedly.

The full Git for Windows bug report is here:

	https://github.com/git-for-windows/git/issues/711

Let's just teach the get_cons_readahead_valid() method to handle a
depleted readahead buffer correctly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2016-04-05 19:20:10 +02:00
Corinna Vinschen 8d67708a08 Add latest changes to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-05 10:35:05 +02:00
Corinna Vinschen 41abcc5825 Revert "Refactor to avoid nonnull checks on "this" pointer."
This reverts commit 0008bdea02.

This patch introduced a regression.  Calling FOO=$(...) in zsh hangs
indefinitely and has to be killed forcefully.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-05 10:30:28 +02:00
Yaakov Selkowitz 8502abb674 winsup/utils: port getconf to 64-bit
The available specifications obviously differ on 32-bit and 64-bit, as
already handled in <sys/features.h>.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:39 -05:00
Yaakov Selkowitz 959d58ea7c cygwin: update sysconf for new features
POSIX spawn and thread barriers have since been added.  Also fix a typo in
_POSIX2_C_DEV (result is the same).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:36 -05:00
Yaakov Selkowitz 929be8005c cygwin/math: make isinf functions signed
glibc returns -1 for negative infinity:

http://man7.org/linux/man-pages/man3/isinfl.3.html
https://sourceware.org/bugzilla/show_bug.cgi?id=15367

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:34 -05:00
Yaakov Selkowitz b3acb347c4 Feature test macros overhaul: Cygwin pthread.h
As a Cygwin-specific header, there is no need to guard functions based on
capability macros.  Instead, guard several blocks based on additions or
removals in later versions of POSIX.1, along with a few which are only
XSI or GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-04-04 10:25:32 -05:00
Peter Foley 0008bdea02 Refactor to avoid nonnull checks on "this" pointer.
G++ 6.0 asserts that the "this" pointer is non-null for member
functions.
Refactor methods that check if "this" is non-null to resolve this.

winsup/cygwin/ChangeLog:
external.cc (cygwin_internal): Check for a null pinfo before calling
cmdline.
fhandler_dsp.cc (Audio::blockSize): Make static.
fhandler_dsp.cc (Audio_in): add default_buf_info.
fhandler_dsp.cc (Audio_out): Ditto.
fhandler_dsp.cc (Audio_out::buf_info): Refactor method to call
default_buf_info if dev_ is null.
fhandler_dsp.cc (Audio_in::buf_info): Ditto.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_out::default_buf_info if audio_out_ is null.
fhandler_dsp.cc (fhandler_dev_dsp::_ioctl): Call Audio_in::default_buf_info if audio_in_ is null.
fhandler_process.cc (format_process_fd): Check if pinfo is null.
fhandler_process.cc (format_process_root): Ditto.
fhandler_process.cc (format_process_cwd): Ditto.
fhandler_process.cc (format_process_cmdline): Ditto.
signal.cc (tty_min::kill_pgrp): Ditto.
signal.cc (_pinfo::kill0): Ditto.
sigproc.cc (pid_exists): Ditto.
sigproc.cc (remove_proc): Ditto.
times.cc (clock_gettime): Ditto.
times.cc (clock_getcpuclockid): Ditto.
path.cc (cwdstuff::override_win32_cwd): Check if old_cwd is null.
path.cc (fcwd_access_t::Free): Factor null check of "this" out to
caller(s).
pinfo.cc (_pinfo::exists): Ditto.
pinfo.cc (_pinfo::fd): Ditto.
pinfo.cc (_pinfo::fds): Ditto.
pinfo.cc (_pinfo::root): Ditto.
pinfo.cc (_pinfo::cwd): Ditto.
pinfo.cc (_pinfo::cmdline): Ditto.
signal.cc (_pinfo::kill): Ditto.
pinfo.cc (_pinfo::commune_request): remove non-null check on "this", as
this method is only called from pinfo.cc after null checks
pinfo.cc (_pinfo::pipe_fhandler): remove non-null check on "this", as
this method is only called from pipe.cc (fhandler_pipe::open) after a null check.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-04 16:46:51 +02:00
Peter Foley e7e6119241 Rename without-mingw-progs to with-cross-bootstrap
Rename without-mingw-progs to with-cross-bootstrap, since it now
disables additional checks that are problematic for cross-compilers.

When cross-compiling a toolchain targeting cygwin, building cygwin1.dll
requires libgcc.
However, building libgcc requires the cygwin headers to be
installed.
Configuring cygwin requries the mingw-crt libraries, which require the
cygwin headers to be installed.
Work around this circular dependency by making the
--with-cross-bootstrap configure option skip cygwin's configure checks
for valid mingw-crt libraries. Cygwin will still properly link against
these libraries if they exist, but this allows configure to succeed even
if the libraries have not been built yet.
Since the mingw-crt libraries only require the cygwin headers to be
installed, this allows us to successfully configure cygwin so that we
can only install the headers without trying to build any
libraries.

winsup/ChangeLog
configure.ac: rename without-mingw-progs option to with-cross-bootstrap
configure: regenerate
winsup/cygserver/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate
winsup/cygwin/ChangeLog
configure.ac: don't check AC_WINDOWS_LIBS when using with-cross-bootstrap
configure: regenerate

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-04 16:39:41 +02:00
Peter Foley 44b72b43d6 Update autoconf for doc/lsaauth/utils
Don't use obsolete LIB_AC_PROG_CC.
Run autoupdate.

winsup/ChangeLog:
doc/aclocal.m4: delete
lsaauth/aclocal.m4: ditto
doc/configure.ac: refactor and update
lsaauth/configure.ac: ditto
utils/configure.ac: ditto
doc/configure: regenerate
lsaauth/configure: regenerate
utils/configure: regenerate

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 14:04:41 +02:00
Corinna Vinschen 8e732f7f7f Remove MALLOC_CHECK and calls to it entirely
MALLOC_CHECK got useless with commit b259af5.  Remove it throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-04-01 14:04:09 +02:00
Peter Foley b259af51b8 Remove remnants of never-defined MALLOC_DEBUG and NEWVFORK
MALLOC_DEBUG and NEWVFORK haven't been defined since 2008 (4616253751).
Remove all references to tem.

winsup/cygwin/ChangeLog:
acconfig.h: delete
dcrt0.cc (dll_crt0_1): remove NEWVFORK code.
dcrt0.cc (do_exit): ditto.
debug.h: ditto.
dtable.h: ditto.
winsup.h: ditto.
globals.cc: ditto.
malloc_wrapper.cc: ditto.
malloc_wrapper.cc (malloc_init): ditto.
spawn.cc (spawnve): ditto.
syscalls.cc (setsid): ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:53:25 +02:00
Peter Foley 02cfe00445 Don't use deprecated acconfig.h for DEBUGGING
Use the 3-arg form of AC_DEFINE.

winsup/cygwin/ChangeLog:
acconfig.h: Remove DEBUGGING define.
configure.ac: Add description to DEBUGGING define.
config.h.in: Regenerate.
configure: Ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:46:04 +02:00
Peter Foley 5d89883790 Remove leftover cruft from config.h.in
HAVE_BUILTIN_MEMTEST and AC_ALLOCA were removed in 4bd8eb7d1b.
Cleanup leftover references.

winsup/cygwin/ChangeLog
acconfig.h: remove HAVE_BUILTIN_MEMTEST
config.h.in: regenerate

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-04-01 13:44:11 +02:00
Corinna Vinschen c8022ae3f0 mkvers.sh: Reformatting for better readability
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 17:06:50 +02:00
Peter Foley 4eca5e6a3f Use just-built gcc for windres
When building cygwin in a combined tree with binutils,
the just-built windres cannot find the just-buit gcc automatically.
Parse the CC env variable to use the correct compiler, rather then
falling back to the build-system's gcc which does not define the proper
preprocessor macros.

winsup/cygwin/ChangeLog
mkvers.sh: Manually specify preprocessor based on $CC

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-30 16:52:36 +02:00
Peter Foley 31dfc51a36 fix typo in netinit/ip.h
The type for the ip_tos member was typoed, fix it.

winsup/cygwin/ChangeLog:
include/netinet/ip.h: fix type of ip_tos

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-30 16:51:40 +02:00
Corinna Vinschen d6c651040d Add dependencies to tlsoffsets file
After `make clean', the build can fail because the dependencies don't
require the tlsoffsets file to exist before building obejct files.
This patch fixes it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 14:35:46 +02:00
Corinna Vinschen 6436024c4c Replace AC_CANONICAL_SYSTEM with AC_CANONICAL_TARGET, fix AC_INIT usage
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 14:09:19 +02:00
Peter Foley cf41355aba Add option to not build mingw programs when cross compiling.
Add an option to not require a mingw compiler when bootstrapping a cross toolchain.
Defaults to existing behavior.
Also update some obsolete macros.

winsup/ChangeLog
configure.ac: Add option to skip building programs that require mingw.
configure: Regenerate.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-30 13:50:16 +02:00
Corinna Vinschen 279aaeb5c7 fenv.h: Change fexcept_t to integral type for compatibility
On Linux and in Mingw-w64, fexcept_t is defined as type unsigned short.
There are packages in the wild which rely on the fact that fexcept_t is
an integral type.  We're changing the internal handling to use the bits
just as in GLibc, so only the 6 lowest bits are used to reflect the hw
bits.  We even change the header file guard to reflect GLibc for compatibility.

	* include/fenv.h (_FENV_H): Rename from _FENV_H_ and set to 1 as in
	GLibc's header.
	(fexcept_t): Change to __uint16_t to be an integral type as in GLibc.
	* fenv.cc (fegetexceptflag): Align to the *flagp's type change.
	(fesetexceptflag): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-30 12:55:42 +02:00
Corinna Vinschen 3d90769979 Document implemented functions
* posix.xml (std-susv4): Add newly implemented math SUSv4 math
	functions.  Add missing functions strtold and tcgetsid.  Re-sort.
	(std-gnu): Add clog10l, exp10l, pow10l, sincos{f,l}.
	(std-notimpl): Drop now implemented functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 17:45:01 +02:00
Corinna Vinschen a638b8580b Add missing nanl
* Makefile.in (MATH_OFILES): Add nanl.o.
	* common.din (nanl): Export.
	* math/nanl.c: New file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 17:39:17 +02:00
Corinna Vinschen 63e4f1291c Add release message for 792e51b
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 14:59:18 +02:00
Corinna Vinschen 792e51b721 Add missing long double functions to Cygwin
This patch adds the long double functions missing in newlib to Cygwin.
Apart from some self-written additions (exp10l, finite{f,l}, isinf{f,l},
isnan{f,l}, pow10l) the files are taken from the Mingw-w64 math lib.
Minor changes were required, e.g. substitue _WIN64 with __x86_64__ and
fixing __FLT_RPT_DOMAIN/__FLT_RPT_ERANGE for Cygwin.

Cygwin:
	* math: New subdir with math functions.
	* Makefile.in (VPATH): Add math subdir.
	(MATH_OFILES): List of object files collected from building files in
	math subdir.
	(DLL_OFILES): Add $(MATH_OFILES).
	${CURDIR}/libm.a: Add $(MATH_OFILES) to build.
	* common.din: Add new functions from math subdir.
	* i686.din: Align to new math subdir.  Remove functions now commonly
	available.
	* x86_64.din: Ditto.
	* math.h: math.h wrapper to define mingw structs used in some files in
	math subdir.
	* include/cygwin/version.h: Bump API minor version.

newlib:
	* libc/include/complex.h: Add prototypes for complex long double
	functions.  Only define for Cygwin.
	* libc/include/math.h: Additionally enable prototypes of long double
	functions for Cygwin.  Add Cygwin-only prototypes for dreml, sincosl,
	exp10l and pow10l.  Explain why we don't add them to newlib.
	* libc/include/tgmath.h: Enable long double handling on Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 14:43:55 +02:00
Corinna Vinschen 087aca6163 Fix Cygwin setstate definition
setstate is supposed to take a char *, not a const char *.

	* random.cc (setstate): Unconstify parameter to align to stdlib.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-29 13:41:11 +02:00
Yaakov Selkowitz 660f84b15b cygwin: export __getpagesize
The inclusion of <sys/cygwin.h> by <sys/shm.h>, besides causing namespace
pollution, also makes it very difficult to get the WINVER-dependent parts
of the former.  This affects code (such as x11vnc -unixpw_nis) which use
both SysV shared memory (e.g. the X11 MIT-SHM extension) and user password
authentication.

getpagesize is the simplest function to retreive this information, but it
is a legacy function and would also pollute the global namespace. The LSB
lists another form which is in the implementation-reserved namespace:

http://refspecs.linuxfoundation.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/baselib---getpagesize.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-29 12:14:18 +02:00
Joel Sherrill ecf453f963 Add simple versions of random() and srandom()
Prototypes also added for initstate() and setstate() but they
were not implemented in the shared newlib code.

	* newlib/libc/include/cygwin/stdlib.h: Prototypes added.
	* winsup/cygwin/include/cygwin/stdlib.h: Prototypes removed.
	* newlib/libc/stdlib/random.c: New file.
	* newlib/libc/machine/epiphany/machine/stdlib.h: Removed
	* newlib/libc/stdlib/Makefile.am: Added random.c.
	* newlib/libc/stdlib/stdlib.tex: Added random.def.
	* newlib/libc/stdlib/Makefile.in: Regenerated.
2016-03-28 22:39:50 -05:00
Corinna Vinschen a0c4772429 Add release text for 373f81d and 3e446e9
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-26 20:38:30 +01:00
Corinna Vinschen acc5f02ce8 Throughout Cygwin, use u_intN_t or uintN_t
Don't use u_char, u_short, u_int or u_long in Cygwin, unless it refers
to the Winsock types.  Use u_intN_t in BSD-based sources, unsigned char
where strings are concerned, uintN_t otherwise.  Also:

	* net.cc: Fix comment, we're not using u_long anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:39:15 +01:00
Corinna Vinschen 6ba2b53c53 Change definition of b64_pton from K&R to ANSI
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:25:00 +01:00
Corinna Vinschen 34adefae7f Fix return type of get_routedst
* net.cc (get_routedst): Correctly return in_addr_t.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:23:50 +01:00
Corinna Vinschen c133a6a3d1 Remove unused function convert_ifr_flags
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:22:30 +01:00
Corinna Vinschen 977912ff93 Fix FIONBIO comments
FIONBIO is defined in sys/termios.h and asm/socket.h.  Align the comments.
Remove unused REAL_FIONBIO.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 16:12:28 +01:00
Corinna Vinschen b1b46d4580 Drop usage of old-age BSD types in generically used Cygwin headers
u_char, u_short, u_int, u_long are BSD-only types.  Remove them from
Cygwin headers which are supposed to be used in a non-BSD scenario.
Drop special Cygwin handling of those types in sys/types.h.

newlib:
	* libc/include/sys/types.h (u_char,u_short,u_int,u_long): Drop
	Cygwin exception.

cygwin:
	* fhandler_socket.cc (fhandler_socket::ioctl): Accommodate change
	in include/asm/socket.h.  Continue using u_long since that's the
	MS type here.
	* include/asm/socket.h: Since the type given in _IOR/_IOW macros
	is only used for its sizeof, replace u_long with equivalent long.
	* netdb.h (getnetbyaddr): Fix prototype.
	* netinet/ip.h: Replace old BSD-only types with generically defined
	old BSD types (u_char -> u_int8_t, etc).
	* netinet/tcp.h: Ditto.
	* netinet/udp.h: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 15:55:25 +01:00
Corinna Vinschen db5bfdbd8a Define BSD u_intN_t types indiscriminately
The u_intN_t types are BSD types but sanctioned by POSIX.  They are
always defined when using Glibc headers so we follow suit.

newlib:
	* libc/include/sys/types.h: Drop outdated __INTTYPES_DEFINED__
	macro.  Always define u_intN_t types.

cygwin:
	* include/cygwin/types.h: Remove definition of u_intN_t types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-24 15:51:14 +01:00
Corinna Vinschen 5b08c1bca1 Add release message for commit 59b3bd2 2016-03-23 18:11:38 +01:00
Corinna Vinschen 59b3bd2aa6 Only allow enabled groups as primary group
So far any group in the user's token could be used as primary group.
Windows doesn't check if the primary group is enabled or not, it just
has no meaning.  From a POSIXy point of view it can lead to weird
results though.

	* uinfo.cc (check_token_membership): New static function.
	(internal_getlogin): Only allow enabled groups as primary group.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:51:03 +01:00
Corinna Vinschen fc504453fd Use 64K buffers for TOKEN_GROUPS
A user token can be up to 64K in size.  Using 32K buffers for TOKEN_GROUPS
may be insufficient.

	* uinfo.cc (get_logon_sid): Use 64K buffers for the TOKEN_GROUPS
	array.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:42:04 +01:00
Corinna Vinschen 155a1ec5fb Allocate temporary TOKEN_GROUP arrays using TLS
A user token can be up to 64K in size.  The group list might take a lot
of that so use tmp_pathbuf allocated space rather than stack space
allocted via alloca.  In create_token the TOKEN_GROUP was allocated via
malloc, but the code is needlessly complicated.  Simplify by using
tmp_pathbuf as well.

	* sec_auth.cc (verify_token): Allocate TOKEN_GROUP via tmp_pathbuf.
	(create_token): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 17:40:24 +01:00
Corinna Vinschen 117737a7fa cxx.cc: Disable C++14 warning for new sized delete operator
As long as we're not building in C++14 mode, the definition of the
sized delete operator results in a compatibility warning.

	* cxx.cc (operator delete): Disable C++14 warning for sized	variant.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 11:58:21 +01:00
Peter Foley 93c13ec6cc Add c++14 sized deallocation operator
When compiling with -std=c++14 (the default for gcc 6.0+), the sized
deallocation operator must be defined to prevent undefined symbols when
linking.

winsup/cygwin/ChangeLog:
cxx.cc (operator delete(void *p, size_t)): Define.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-23 11:51:22 +01:00
Corinna Vinschen 3737bc4e98 Drop Cygwin-only posix_memalign prototype
newlib:
	* libc/include/stdlib.h (posix_memalign): Drop __rtmes__ guards.

cygwin:
	* include/cygwin/stdlib.h (posix_memalign): Drop prototype.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-23 11:50:27 +01:00
Peter Foley fa6a5a3a74 Use DnsFree instead of deprecated DnsRecordListFree
The latest version of the mingw headers have been updated to make
DnsRecordListFree an alias of DnsFree when targeting Windows XP or later.
Use DnsFree directly, avoiding the wrapper function.

/home/peter/cross/src/cygwin/winsup/cygwin/libc/minires-os-if.c:289:
undefined reference to `DnsFree'

winsup/cygwin/ChangeLog
autoload.cc: Load DnsFree rather then DnsRecordListFree
libc/minires-os-if.cc (cygwin_query): Use DnsFree rather then DnsRecordListFree

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-23 11:41:26 +01:00
Corinna Vinschen 445036bb98 Remove Mingw.org from FAQ, or replace with Mingw-w64.
* faq-api.xml: Change MingW to Mingw-w64.
	* faq-programming.xml: Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-21 21:09:23 +01:00
Peter Foley 3ba2c39fb2 Add nonnull annotation to posix_memalign.
GCC 6.0+ asserts that the memptr argument to the builtin function
posix_memalign is nonnull.
Add the necessary annotation to the prototype and
remove the now unnecessary check to fix a warning.

newlib/Changelog
newlib/libc/include/stdlib.h: Annotate arg to posix_memalign as
non-null.

winsup/cygwin/ChangeLog
malloc_wrapper.cc (posix_memalign): Remove always true nonnull check.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-21 20:27:16 +01:00
Peter Foley 6699e21ffb Remove misleading indentation
GCC 6.0+ warns on misleading indentation, so fix it.

winsup/cygserver/ChangeLog
* sysv_msg.cc (msgsnd): Fix misleading indentation.
* sysv_msg.cc (msgrcv): Ditto.
* sysv_sem.cc (semop): Ditto.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-21 20:16:01 +01:00
Sebastian Huber 08537d88f6 Move arc4random Cygwin only code to Cygwin
Keep the Newlib arc4random.c identical to the OpenBSD upstream version.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>.
2016-03-21 11:12:19 +01:00
Corinna Vinschen 2519f0ef0c srandom: Replace accessing /dev/random by equivalent getentropy call
/dev/random calls getentropy.  So there's no good reason to go out of
our way to open /dev/random just to call getentropy anyway.

	* random.cc (srandomdev): Drop opening /dev/random in favor of
	calling getentropy.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-20 22:29:03 +01:00
Corinna Vinschen 58988463cc Revert "Use high-resolution timebases for select()."
This reverts commit 6e70fd315a.

Revert accidental push
2016-03-20 21:59:47 +01:00
Corinna Vinschen bf0f4baf95 Revert "Debug printfs."
This reverts commit 9f82de59a0.

Revert accidental push
2016-03-20 21:59:43 +01:00
Corinna Vinschen 66dc7d731a Revert "Improve and simplify select()."
This reverts commit 472d0a228c.

Revert accidental push
2016-03-20 21:59:27 +01:00
Corinna Vinschen 1cca343e47 Drop redundant arc4random prototypes from cygwin/stdlib.h
Newlib's default stdlib.h now defines these functions so we can
drop them from the Cygwin-specific header.  Remove the arc4random_stir
and arc4random_uniform prototypes entirely.  They shouldn't be used
by applications anymore.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-20 21:30:58 +01:00
Corinna Vinschen f7f26f65ab Allow machine-dependent arc4 locking
newlib:
	* libc/stdlib/arc4random.h: Remove Cygwin-specific locking code.
	Conditionalize arc4 locking.  Check for _ARC4_LOCK_INIT being
	undefined to fall back to default implementation.

cygwin:
	* include/machine/_arc4random.h: New file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-20 21:30:08 +01:00
John Hood 472d0a228c Improve and simplify select().
* cygwait.h (cygwait_us) Remove; this reverts previous changes.
	* select.h: Eliminate redundant select_stuff::select_loop state.
	* select.cc (select): Eliminate redundant
	select_stuff::select_loop state.  Eliminate redundant code for
	zero timeout.  Do not return early on early timer return.
	(select_stuff::wait): Eliminate redundant
	select_stuff::select_loop state.
2016-03-20 15:26:32 +01:00
John Hood 9f82de59a0 Debug printfs.
* fhandler.cc (fhandler_base::get_readahead): Add debug code.
	* fhandler_console.cc (fhandler_console::read): Add debug code.
	* select.cc (pselect): Add debug code.
	(peek_console): Add debug code.
2016-03-20 15:26:31 +01:00
John Hood 6e70fd315a Use high-resolution timebases for select().
* cygwait.h: Add cygwait_us() methods.
	* select.h: Change prototype for select_stuff::wait() for larger
	microsecond timeouts.
	* select.cc (pselect): Convert from old cygwin_select().
	Implement microsecond timeouts.
	(cygwin_select): Rewrite as a wrapper on pselect().
	(select): Implement microsecond timeouts.
	(select_stuff::wait): Implement microsecond timeouts with a timer
	object.
2016-03-20 15:26:31 +01:00
John Hood 313fcaf1bc * winsup/testsuite/configure: chmod a+x 2016-03-20 15:21:24 +01:00
John Hood b92b47b7bc Move get_nonascii_key into fhandler_console.
* fhandler.h (fhandler_console): Move get_nonascii_key() from
	select.c into this class.
	* select.cc (peek_console): Move get_nonascii_key() into
	fhandler_console class.
2016-03-20 14:14:27 +01:00
Peter Foley 3bc912c02b respect datarootdir
Recent versions of autoconf define datadir/infodir in terms of
datarootdir. Add it.

winsup/ChangeLog
* Makefile.in: define datarootdir

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 12:36:40 +01:00
Peter Foley 5bc753c5a2 Fix strict aliasing
Fix a strict aliasing error detected by gcc 6.0+

winsup/cygwin/ChangeLog
* pinfo.cc (winpids::enum_process): Fix strict aliasing.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 12:31:42 +01:00
Peter Foley 0611132f04 Fix typoed comparison
winsup/cygwin/ChangeLog
* thread.cc (semaphore::open): Fix mistaken conditional.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 12:19:35 +01:00
Peter Foley 1eb7cb2553 The address of an class always evaluates to true
winsup/cygwin/pinfo.cc:465:14: error: the compiler can assume that the
address of 'tc' will always evaluate to 'true' [-Werror=address]

winsup/cygwin/ChangeLog
* pinfo.cc (_pinfo::set_ctty): remove always true check.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 12:16:42 +01:00
Peter Foley 2f310e44c4 Remove misleading indentation
* syscalls.cc (getpriority): Fix misleading indentation.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 11:58:57 +01:00
Peter Foley dc85a189a4 Add necessary braces to if statements
The missing braces cause only the first expression to be guarded by the
else clause.

winsup/cygwin/ChangeLog
* fhandler_disk_file.cc (facl): Add missing braces to if statement.
* mount.cc (dos_drive_mappings): Add missing braces to if statement.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 11:55:08 +01:00
Peter Foley 922e21a3ea Remove dead code from fhandler_console.
This if is unconditionally false, so remove it.

winsup/cygwin/fhandler_console.cc: In member function 'bool dev_console::fillin(HANDLE)':
winsup/cygwin/fhandler_console.cc:740:22: error: self-comparison always evaluates to false [-Werror=tautological-compare]
       if (b.dwSize.Y != b.dwSize.Y || b.dwSize.X != b.dwSize.X)
           ~~~~~~~~~~~^~~~~~~~~~~~~
winsup/cygwin/fhandler_console.cc:740:50: error: self-comparison always evaluates to false [-Werror=tautological-compare]
       if (b.dwSize.Y != b.dwSize.Y || b.dwSize.X != b.dwSize.X)
                                       ~~~~~~~~~~~^~~~~~~~~~~~~

winsup/cygwin/ChangeLog
* fhandle_console.cc (fillin): remove dead code

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 11:54:49 +01:00
Peter Foley c0b6fc54b1 Remove unused and unsafe call to __builtin_frame_address
initial_sp has been unused since commit fbf23e3 back in 2000.
Keep the value, so as to avoid changing the offset of magic_biscuit.

winsup/cygwin/lib/_cygwin_crt0_common.cc:140:52:
error: calling 'void* __builtin_frame_address(unsigned int)' with a
nonzero argument is unsafe [-Werror=frame-address]
   u->initial_sp = (char *) __builtin_frame_address (1);

winsup/cygwin/ChangeLog
lib/_cygwin_crt0_common.cc (_cygwin_crt0_common): Initialize initial_sp
with nullptr.

Signed-off-by: Peter Foley <pefoley2@pefoley.com>
2016-03-20 11:51:43 +01:00
Corinna Vinschen 3df400dc83 winsup: Move all old CVS Changelogs into CVSChangeLogs.old dir 2016-03-19 13:59:52 +01:00
Corinna Vinschen e42f66d00f Remove ill-advised cygwin_props
Cygwin_props have been invented to allow switching off the unique
installation keys in the first place, supposedly for debugging.
This never really was a good idea, after all we *want* the installations
to be independent and there's no good reason to break that, not even
for debugging purposes.

Other than that, cygwin_props were meant to be used for some other global
settings which never took place.  There's just no good reason to tweak
the DLL binary invisibly where a setting could be done in a file or the
environment.

This patch removes the cygwin_props entirely, including the related
settings in cygcheck.

cygwin:
	* cygprops.h: Remove file.
	* globals.cc (cygwin_props): Remove.
	* cygheap.cc (init_cygheap::init_installation_root): Drop removing
	installation key.

utils:
	* cygcheck.cc: Drop including cygprops.h.  Remove now unused option
	values.
	(unique_object_name_opt): Remove.
	(handle_unique_object_name): Remove function.
	(usage): Remove text for unique-object-names options.
	(longopts): Remove unique-object-names options.
	(main): Drop handling unique-object-names options.

doc:
	* utils.xml (cygcheck): Remove text for unique-object-names options.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-19 13:21:18 +01:00
Corinna Vinschen 83029bb69e Remove references to older Cygwin releases from documentation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 22:52:04 +01:00
Corinna Vinschen dcf31cdc99 Implement getentropy for Cygwin
* miscfuncs.cc (getentropy): Move fhandler_dev_random::crypt_gen_random
	here and rename to getentropy.  Fix type and return values to match
	getentropy requirements.
	* miscfuncs.h (getentropy): Add prototype.
	* fhandler.h (fhandler_dev_random::crypt_gen_random): Remove prototype.
	* fhandler_random.cc (fhandler_dev_random::crypt_gen_random): Drop.
	(fhandler_dev_random::write): Use getentropy instead.
	(fhandler_dev_random::read): Ditto.
	* fhandler_socket.cc (fhandler_socket::af_local_set_secret): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:46:20 +01:00
Corinna Vinschen e0fc33322d Delete Cygwin's arc4random in favor of new Newlib implementation
* Makefile.in (DLL_OFILES): Remove arc4random.o.
	* libc/arc4random.c: Remove file.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-18 14:41:33 +01:00
Yaakov Selkowitz 00d2fe1959 Cygwin: define byteswap.h inlines as macros
The bswap_* "functions" are macros in glibc, so they may be tested for
by the preprocessor (e.g. #ifdef bswap_16).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:23 -05:00
Yaakov Selkowitz 3237fb31b3 Feature test macros overhaul: Cygwin headers
Use proper internal macros for BSD and GNU.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:22 -05:00
Yaakov Selkowitz 43e5ee83fe Feature test macros overhaul: time.h
Throughout, replace __STRICT_ANSI__ with the proper internal macros.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:10 -05:00
Yaakov Selkowitz 84ba25226c Feature test macros overhaul: stdlib.h
Throughout, simplify the C99/C11 conditionals, and replace
__STRICT_ANSI__ with the proper internal POSIX macros.  The _*_r
reentrant functions need not be guarded (and most haven't been) because
such names in the global scope are reserved to the implementation.

atoff is unique to newlib.

dtoa is not actually exported (_dtoa_r is used internally), is
nonstandard, and the declaration conflicts with the code included in
MySQL, NSPR, and SpiderMonkey.

mktemp was removed in POSIX.1-2001.

The qsort_r declarations are reordered so that the GNU version retains
precedence.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:09:06 -05:00
Yaakov Selkowitz 86a724b8c0 Feature test macros overhaul: limits.h
Simplify the C99 conditional, and use the internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:57 -05:00
Yaakov Selkowitz d94d983d1b Feature test macros overhaul: fnmatch.h
Use the proper internal macro for GNU extensions.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:54 -05:00
Yaakov Selkowitz d2937299fa Feature test macros overhaul: dirent.h
MAXNAMLEN is a BSDism.

Use the proper internal macros instead of !_POSIX_SOURCE.  telldir and
seekdir are XSI, scandir and alphasort are POSIX.1-2008, and scandirat
is GNU.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-03-17 21:08:51 -05:00
Corinna Vinschen 446d0d355f add release message for commit 4c9bb3e
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-17 17:58:43 +01:00
Corinna Vinschen 4c9bb3e0f9 Propagate correct Windows error if executable can't be opened
* spawn.cc (av::setup): Set last Win32 error if NtOpenFile fails.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-17 17:46:11 +01:00
Thomas Wolff aa2d448093 Add release message for commit 7346568 2016-03-17 08:59:17 +01:00
Thomas Wolff 734656818a Make requested console reports work
cf https://cygwin.com/ml/cygwin-patches/2012-q3/msg00019.html

This enables the following ESC sequences:
ESC[c sends primary device attributes
ESC[>c sends secondary device attributes
ESC[6n sends cursor position report

    * fhandler.h (class dev_console): Add console read-ahead buffer.
    (class fhandler_console): Add peek function for it (for select).
    * fhandler_console.cc (fhandler_console::setup): Init buffer.
    (fhandler_console::read): Check console read-aheader buffer.
    (fhandler_console::char_command): Put responses to terminal
    requests (device status and cursor position reports) into
    common console buffer (shared between CONOUT/CONIN)
    instead of fhandler buffer (separated).
    * select.cc (peek_console): Check console read-ahead buffer.
2016-03-16 10:25:34 +01:00
Jon Turney e8e379ff1d Attempt to fix Coverity issues in ssp
* ssp.c (lookup_thread_id): Consistently check if tix is a null
	pointer.
	(run_program): Annotate that STATUS_BREAKPOINT falls-through to
	STATUS_SINGLE_STEP case.
	(main): Guard against high_pc-low_pc overflow and malloc failure.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-03-15 13:25:57 +00:00
Corinna Vinschen 7176a85cd4 cygwin_getaddrinfo: workaround Winsock getaddrinfo issue with broken DNS
Add experimental code to workaround the issue described in the thread
starting at

  https://cygwin.com/ml/cygwin/2015-07/msg00350.html

There's a hint in https://communities.vmware.com/message/2577858#2577858
that this problem is related to using the AI_ALL flag.

This patch checks if GetAddrInfoW returned with WSANO_RECOVERY and if
the AI_ALL flag was set, it retries GetAddrInfo without the AI_ALL flag.

	* net.cc (cygwin_getaddrinfo): Add experimental code to retry
	GetAddrInfoW without AI_ALL flag if it returned with WSANO_RECOVERY.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-14 17:57:22 +01:00
Corinna Vinschen f75114fc59 Don't write NULL SID ACE if it's not necessary.
If the ACL is supposed to reflect only standard POSIX permissions,
and if the permissions are so that user has more perms than group
and group has more perms than other, we don't really need the NULL
SID ACE.  If the permissions are that simple, get_posix_access will
not call AuthZ.

	* sec_acl.cc (set_posix_perms): Don't write NULL SID ACE if it's
	not required.  Explain why.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-13 16:02:55 +01:00
Corinna Vinschen ddc91e5b2b Update Cygwin release message text with latest bugfixes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-13 00:20:39 +01:00
Corinna Vinschen fcd8a0d4f4 Fix typo which might break permission evaluation
* sec_acl.cc (get_posix_access): Fix a typo checking for a_id
	rather than a_type.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 17:57:34 +01:00
Corinna Vinschen fc180edcf4 Fix reading/writing Samba ACLs using RFC2307 mapping
When using RFC2307 uid/gid-mapping on Samba shares, the POSIX ACL contains
the Windows SIDs.  When writing back such an ACL we have to map the
Windows SIDs back to the corresponding Samba SIDs representing the UNIX
uid/gid value.  When reading Samba SIDs, make sure never to evaluate a
UNIX user account as group.

	* sec_acl.cc (set_posix_access): Convert Windows SIDs to
	RFC2307-mapped Sambe UNIX SIDs.
	* sec_helper.cc (cygpsid::get_id): Skip UNIX user accounts when
	trying to evaluate a SID as group.  Skip UNIX group accounts when
	trying to evaluate a SID as user.
	* cygheap.h (cygheap_ugid_cache::reverse_get): New method to
	get nfs id from cygwin id.
	(cygheap_ugid_cache::reverse_get_uid): Wrapper for uids.
	(cygheap_ugid_cache::reverse_get_gid): Wrapper for gids.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 17:56:21 +01:00
Corinna Vinschen 018fa93e2b Add cygsid methods to create SIDs from scratch
So far creating cygsids requires to generate an "S-1-..." string
which is then converted to a SID by cygsid::getfromstr.

Add two new methods:

- cygsid::create (DWORD auth, DWORD subauth_count, ...)

    ... is a variable length list of subauth_count DWORD values being
    the actual subauths.

- cygsid::append (DWORD rid)

    allows to append a single RID to an alreaday constituted SID.

	* security.h (cygsid::create): Declare public.
	(cygsid::append): Ditto.
	* sec_helper.cc (cygsid::create): Implement.
	(cygsid::append): Implement.
	* uinfo.cc (pwdgrp::fetch_account_from_windows): Use both new
	methods as appropriate.  Drop setting csid from string.  Create
	SID strings for printing SIDs only.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-12 16:39:19 +01:00
Corinna Vinschen 5b972d5b29 gmon.h: Fix type of gmonparam state member
gmonparam::state is used in calls to Win32 Interlocked functions.
Having this defined as int breaks the build on i686.  Redefine as
LONG (same size and correct type on all platforms) to make gcc happy.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-11 22:50:24 +01:00
Václav Haisman b5476c81d2 Spinlock spin with pause instruction
Hi.

I have noticed that Cygwin's spinlock goes into heavy sleeping code
for each spin. It seems it would be a good idea to actually try to
spin a bit first. There is this 'pause' instruction which let's the
CPU make such busy loops be less busy. Here is a patch to do this.

--
VH
2016-03-11 14:01:25 +01:00
Mark Geisert d0cf3b7c02 Documentation covering profiling Cygwin programs. 2016-03-11 11:08:01 +01:00
Corinna Vinschen bf81f082cd Add release message for commit 8b1ede3ce1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:48:04 +01:00
Corinna Vinschen 2b174636e5 Add commit 5807ba83e release message to documentation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:47:33 +01:00
Corinna Vinschen 60fd26a4df Add release message for commit 5807ba83e4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:42:42 +01:00
Mark Geisert 5807ba83e4 Support profiling of multi-threaded apps.
This patch set modifies Cygwin's profiling support to sample PC values
of all an app's threads, not just the main thread. There is no change
to how profiling is requested: just compile and link the app with "-pg"
as usual. The profiling info is dumped into file gmon.out as always.

A new facility enabled via the environment variable GMON_OUT_PREFIX.
This facility is intended to match an undocumented Linux glibc feature.
Exporting the variable with a non-empty value such as "foo" causes the
profiling info to go to a file named foo.$pid instead of the default.
With that, both resulting processes of a fork() can have their profiling
data captured in separate files. gprof already knows how to accumulate
data from multiple files if they all pertain to the same app.

There is no change to the normal Cygwin execution paths if profiling is
not enabled. And when it is enabled, only the one profiling thread per
profiled app is doing more work than it used to.

	* include/sys/cygwin.h: Add CW_CYGHEAP_PROFTHR_ALL.
	* cygheap.cc (cygheap_profthr_all): New C-callable function that
	runs cygheap's threadlist handing each pthread's thread handle in
	turn to profthr_byhandle().
	* external.cc (cygwin_internal): Add case CW_CYGHEAP_PROFTHR_ALL.
	* gmon.c (_mcleanup): Add support for multiple simultaneous
	gmon.out* files named via environment variable GMON_OUT_PREFIX.
	* gmon.h (struct gmonparam): Make state decl volatile.
	* mcount.c (_MCOUNT_DECL): Change stores into gmonparam.state to use
	Interlocked operations. Add #include "winsup.h", update commentary.
	* profil.c (profthr_byhandle): New function abstracting out the
	updating of profile counters based on a thread handle.
	(profthr_func): Update to call profthr_byhandle() to sample the main
	thread then call cygheap_profthr_all() indirectly through
	cygwin_internal(CW_CYGHEAP_PROFTHR_ALL) to sample all other threads.
	(profile_off): Zero targthr to indicate profiling was turned off.
	(profile_on): Fix handle leak on failure path.
	(profile_child): New callback func to restart profiling in child
	process after a fork if the parent was being profiled.
	(profile_ctl): Call pthread_atfork() to set profile_child callback.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 20:39:46 +01:00
Corinna Vinschen 65231f415a getifaddrs: Return pointer to extended interface info in ifa_data member
According to https://cygwin.com/ml/cygwin/2016-03/msg00124.html it's a
problem to collect friendlyname info using AF_INET6 sockets.  Fix problem
by exposing additional hardware info for all collected interfaces via the
pointer in the ifaddrs::ifa_data member.

	* include/ifaddrs.h (struct ifaddrs_hwdata): Define as struct of
	not yet exposed members of struct ifall, defined in net.cc.
	* net.cc (struct ifall): Replace hardware dta members with struct
	ifaddrs_hwdata.  Accommodate throughout.
	(get_ifs): Let ifaddrs ifa_data member point to ifall::ifa_hwdata
	member.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 18:00:00 +01:00
Corinna Vinschen f368589492 Revamp acl_extended_fd/acl_extended_file to avoid open(2) call
Calling open from acl_extended_file{_nofollow} indiscriminately may hang
if the file is a FIFO.  Ultimately the FIFO implementation needs a thorough
rewrite, but for the time being we better do what stat(2) and friends do:
Just create an fhandler directly.

	* sec_posixacl.cc (__acl_extended_fh): New static function calling
	fhandler::facl.
	(acl_extended_fd): Just call __acl_extended_fh.
	(__acl_extended_file): Take just a path_conv as parameter and
	create temporary fhandler to call __acl_extended_fh.
	(acl_extended_file): Create path_conv from incoming path and
	call __acl_extended_file on it.
	(acl_extended_file_nofollow): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-10 10:36:00 +01:00
Corinna Vinschen 48511f3d38 Overwite potentially faked kernel version with correct values
* ntdll.h (RtlGetNtVersionNumbers): Declare.
	* wincap.cc (wincapc::init): Overwrite kernel version info
	returned by RtlGetVersion with correct info returnd by
	RtlGetNtVersionNumbers.  Add comment.

Originally, using RtlGetVersion instead of GetVersionEx was supposed to
fix the fact that GetVersionInfo returns the wrong kernel version if the
executable has been built with an old manifest (or none at all), starting
with Windows 8.1.  Either this never really worked as desired and our
testing was flawed, or this has been changed again with Windows 10, so
that RtlGetVersion does the kernel faking twist as well.  Since we're
only reading the value in the first process in a process tree. the entire
process tree is running with a wrong OS version information in that case.

Fortunately, the (undocumented) RtlGetNtVersionNumbers function is not
affected by this nonsense, so we simply override the OS version info
fields with the correct values now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-09 23:10:17 +01:00
Corinna Vinschen 264b5e137e Move definition of wsadata into wsock_init
The problem this patch fixes showed up after updating to gcc-5.3.0.  The
cuplrit is a change in gcc when emitting section attributes.  It only
shows up when building without optimization.  Effect in Cygwin: ws2_32
functions failed to load.

In the original code the definition of "NO_COPY wsadata" was preceeding
an __asm__ block (the definition of the _wsock_init wrapper), while the
definition of "NO_COPY here" immediately follows the same assembler
block.  When gcc-5.3.0 emits assembler code for the wsadata definition,
it emits the .data_cygwin_nocopy section attribute.

Next it emits the assembler output for the __asm_ block, entirely ignoring
its content.  The __asm__ block adds a .text section definition.

Eventually gcc emits assembler code for the here definition.  However,
apparently gcc still "knows" that it just emitted the .data_cygwin_nocopy
section attribute and so doesn't redefine it.  Remember the __asm__?  It
changed the section to .text.

So with gcc-4.9.3 we got:

    .section .data_cygwin_nocopy,"w"
  wsadata:

  __asm__ block:
    .text

    .section .data_cygwin_nocopy,"w"
  here:

With gcc 5.3.0 we now get:

    .section .data_cygwin_nocopy,"w"
  wsadata:

  __asm__ block:
    .text

  here:

So "here" is now in the .text segment which is read-only.  Hilarity ensues.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-09 22:55:28 +01:00
Corinna Vinschen c09e96fda0 Cygwin: Document new POSIX ACL API
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 17:33:08 +01:00
Jon Turney 930474058e faq: Sort BLODA list and update advice on fixing fork failures
* faq-using.xml (bloda): Alphabetically sort BLODA list for ease
	of finding things in it.
	(fixing-fork-failures): Update to suggest rebase-trigger rather
	than running rebaseall via dash yourself.  Mention detect_bloda
	CYGWIN token.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-03-08 14:39:41 +00:00
Corinna Vinschen e4ecb5b96a acl_create_entry: Don't invalidate existing entry_d and permset_d.
* sec_posixacl .cc (__acl_dup): Remove.
	(acl_dup): Fold __acl_dup functionality into this function.
	(acl_create_entry): Don't create new acl_t.  Just realloc
	acl->entry to make room for new aclent_t.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen 3d88f10983 __acltotext: Always append NUL
* sec_acl.cc (__acltotext): Append NUL unconditionally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen 9ddf063921 Implement POSIX.1e ACL functions
* Makefile.in (DLL_OFILES): Add sec_posixacl.o.
	(SUBLIBS): Add libacl.a
	(libacl.a): New rule to create libacl.a.
	* common.din: Export POSIX ACL functions as well as most libacl.a
	extensions.
	* fhandler.h (fhander_base::acl_get): New prototype.
	(fhander_base::acl_set): Ditto.
	(fhandler_disk_file::acl_get): Ditto.
	(fhandler_disk_file::acl_set): Ditto.
	* include/acl/libacl.h: New file.
	* include/cygwin/version.h: Bump API minor version.
	* include/sys/acl.h: Drop including cygwin/acl.h.  Accommodate
	throughout Cygwin.  Add POSIX ACL definitions.
	* sec_acl.cc: Include sec_posixacl.h.  Replace ILLEGAL_UID and
	ILLEGAL_GID with ACL_UNDEFINED_ID where sensible.
	(__aclcheck): New internal acl check function to be used for
	Solaris and POSIX ACLs.
	(aclcheck32): Call __aclcheck.
	(__aclcalcmask): New function to compute ACL_MASK value.
	(__aclsort): New internal acl sort function to be used for Solaris
	and POSIX ACLs.
	(aclsort32): Call __aclsort.
	(permtostr): Work directly on provided buffer.
	(__acltotext): New internal acltotext function to be used for
	Solaris and POSIX ACLs.
	(acltotext32): Call __acltotext.
	(__aclfromtext): New internal aclfromtext function to be used for
	Solaris and POSIX ACLs.
	(aclfromtext32): Call __aclfromtext.
	* sec_posixacl.cc: New file implemeting POSIX ACL functions.
	* sec_posixacl.h: New internal header.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Corinna Vinschen edd7d93484 cygwin/acl.h: Don't clutter namespace
include/cygwin/acl.h: Change comments to /**/ style.  Reformat
	declarations.  Use underscores in argument names.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-08 13:56:40 +01:00
Alexey Sokolov bf45e12fb6 Mention 64-bit Cygwin as another remedy for fork() failures. 2016-03-04 22:02:35 +01:00
Patrick Bendorf 2cd76694e1 ccwrap: fix build with non-english locale set (v2)
after some discussion on irc and the list i'm resubmitting a simpler
version of the patch.
setting the locale on cygwin to 'C.UTF-8' is not needed, so i'm always
setting it to 'C' which is sufficient for the build process and the
most simple fix.
2016-02-29 14:44:23 +01:00
Patrick Bendorf 5b88b62562 ccwrap: fix build with non-english locale set
short explanation: after setting up cygwin on my systems the default
locale is set to "de_DE.UTF-8". this leads to ccwrap not picking up
certain "-isystem" arguments, which in turn leads to "stddef.h: no such
file or directory". this breaks the build process for systems having non
english locale.

ccwrap scans the output of the first compiler invocation (line 21) for
some specific english output on and around line 43.

i changed the patch to check uname -o for cygwin string and set the
locale to either C or C.UTF-8
2016-02-29 13:56:03 +01:00
Yaakov Selkowitz 8b1ede3ce1 cygwin: Export clog10, clog10f
winsup/cygwin/
	* common.din: Add clog10, clog10f.
	* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.

	winsup/doc/
	* new-features.xml (ov-new2.5): Mention clog10, clog10f.
	* posix.xml (std-gnu): Add clog10, clog10f.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-22 14:45:37 -06:00
Corinna Vinschen b89d317cdc Fix comments in sec_acl.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-22 10:54:13 +01:00
Jon Turney 658caa7640 ssp: Fixes for 64-bit
Fix various 32/64-bit portability issues in ssp, the single-step profiler, and
also build it for 64-bit.

This didn't turn out to actually be very useful for what I wanted to use it for,
so it's only been lightly tested.

It appears that on x86_64, single-step exceptions occur for much more of the
code in system DLLs, unlike x86, so ssp may take much, much longer to profile
some programs.  There is existing code to use breakpoints to mitigate this, but
that is currently disabled.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-02-20 11:26:50 +00:00
Corinna Vinschen 609feee9e5 Update Cygwin release notes.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 15:56:51 +01:00
Yaakov Selkowitz 7503575f1d cygwin: accept SIGIOT as alias of SIGABRT
winsup/cygwin/
	* include/cygwin/signal.h (SIGIOT): Define SIGIOT in terms of SIGABRT.
	* strsig.cc (struct sigdesc): Ditto.

	winsup/doc/
	* utils.xml (kill): Document SIGIOT.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-18 08:20:03 -06:00
Corinna Vinschen 2ceb202bc1 Drop temporary declaration of GetSystemTimePreciseAsFileTime.
* times.cc (GetSystemTimePreciseAsFileTime): Remove declaration
	and accompanying comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 12:38:24 +01:00
Corinna Vinschen 205862ed08 setuid: Create token from scratch without credentials of caller
* sec_auth.cc (get_token_group_sidlist): Drop auth_luid and
	auth_pos parameter.  Remove code adding a logon SID.
	(get_initgroups_sidlist): Drop auth_luid and auth_pos parameter.
	Drop in call to get_token_group_sidlist. Accommodate in callers.
	(get_setgroups_sidlist): Ditto.
	(create_token): Explicitely set auth_luid to ANONYMOUS_LOGON_LUID
	or LOCALSERVICE_LUID depending on OS.  Explain why.
	Remove handling of logon SID since we don't generate one anymore.
	(lsaauth): Drop now unused local variable auth_luid and auth_pos.
	* wincap.h (wincaps::has_broken_whoami): New element.
	* wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 11:22:12 +01:00
Corinna Vinschen b76de0deaa cyglsa: Drop code handling Windows 2000 and earlier
* cyglsa.c (must_create_logon_sid): Remove.
	(LsaApInitializePackage): Drop checking version and setting
	must_create_logon_sid accordingly.
	(LsaApLogonUserEx): Drop code setting login SID only required on
	Windows 2000 and earlier.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-17 16:08:59 +01:00
Mark Geisert 70e7f94e9f Silent relocation truncations considered harmful
This follows up from my msg re GMP-ECM failing its 'make check' on the
main list https://cygwin.com/ml/cygwin/2016-02/msg00147.html .

There's an error that ought to be reported during dynamic linking if the
linked-to address is too far from the relocation site.  However the error
is not reported if __OPTIMIZE__ was #defined when building the Cygwin DLL.
I can't see why optimization settings should affect this.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-17 10:55:28 +01:00
Corinna Vinschen 4c59f62ef9 cygwin_conv_path: Really always preserve trailing slash in conversion to POSIX path
* mount.cc (mount_info::conv_to_posix_path): Account for scenarios
	where the path is identical to a mount point in terms of preserving
	the trailing slash in the output.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-15 16:25:10 +01:00
John Hood 7eb13b33e4 Make buffered console characters visible to select(). 2016-02-15 13:28:56 +01:00
Corinna Vinschen 10e0db58e4 Document pthread_barrier* functions as implemented
posix.xml (std-susv4): Add pthread_barrier* functions.
	(std-notimpl): Remove here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 17:03:36 +01:00
Corinna Vinschen c76954517f Remove local winbase.h (again).
Mingw32-w64 supports all required inline Interlocked functions in the
meantime.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 16:56:12 +01:00
Corinna Vinschen 9a25a76e7b Bump Cygwin version to 2.5.0
Add a release file.  Add release text to documentation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-13 16:55:00 +01:00
Václav Haisman 813da84442 POSIX barrier implementation, take 3
The attached patch should address all of the review comments.

Modifed change log:

Newlib:

	* libc/include/sys/features.h (_POSIX_BARRIERS): Define for Cygwin.
	* libc/include/sys/types.h (pthread_barrier_t)
	(pthread_barrierattr_t): Do not define for Cygwin.

Cygwin:

	* common.din (pthread_barrierattr_init)
	(pthread_barrierattr_setpshared, pthread_barrierattr_getpshared)
	(pthread_barrierattr_destroy, pthread_barrier_init)
	(pthread_barrier_destroy, pthread_barrier_wait): Export.
	* include/cygwin/types.h (pthread_barrierattr_t)
	(pthread_barrier_t): Declare.
	* include/pthread.h (PTHREAD_BARRIER_SERIAL_THREAD)
	(pthread_barrierattr_init, pthread_barrierattr_setpshared)
	(pthread_barrierattr_getpshared, pthread_barrierattr_destroy)
	(pthread_barrier_init, pthread_barrier_destroy)
	(pthread_barrier_wait): Declare.
	* thread.h (PTHREAD_BARRIER_MAGIC)
	(PTHREAD_BARRIERATTR_MAGIC): Define.
	(class pthread_barrierattr, class pthread_barrier): Declare.
	* thread.cc (delete_and_clear): New local helper function.
	(class pthread_barrierattr, class pthread_barrier): Implement.
	* miscfuncs.h (likely, unlikely): New macros.

--
VH
2016-02-13 16:03:15 +01:00
Yaakov Selkowitz ef64aa4940 cygwin: work around GCC 5 preprocessor changes
GCC 5 adds #line directives (and hence extra newlines) for macros
expansions, which confuses cygmagic.  Using the -P flag avoids
them entirely.

https://cygwin.com/ml/cygwin-patches/2016-q1/msg00016.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-13 15:59:55 +01:00
Corinna Vinschen 919137b3d8 Bump Cygwin version to 2.4.2.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-12 21:23:20 +01:00
Yaakov Selkowitz c5f03820fc cygwin: fix errors with GCC 5
GCC 5 switched from C89 to C11 by default. This implies a change from
GNU to C99 inline by default, which have very different meanings of
extern inline vs. static inline:

https://gcc.gnu.org/onlinedocs/gcc/Inline.html

Marking these as gnu_inline retains the previous behaviour.

	winsup/cygwin/
	* exceptions.cc (exception::handle): Change debugging to int to fix
	an always-true boolean comparison warning.
	* include/cygwin/config.h (__getreent): Mark gnu_inline.
	* winbase.h (ilockcmpexch, ilockcmpexch64): Ditto.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-02-12 12:08:40 -06:00
Corinna Vinschen 8b83da2d55 cygwin_conv_path: Always preserve trailing backslashes in conversion to POSIX paths
* include/sys/cygwin.h (CCP_CONVFLAGS_MASK): Define.
	* mount.h (__CCP_APP_SLASH): Define.
	* mount.cc (mount_info::conv_to_posix_path): Handle __CCP_APP_SLASH
	flag.
	* path.cc (cygwin_conv_path): Use CCP_CONVFLAGS_MASK to evaluate
	"how" flag values.  Always add __CCP_APP_SLASH flag when calling
	mount_info::conv_to_posix_path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-09 15:00:30 +01:00
Corinna Vinschen ac4648c13e Treat ACLs with extra ACEs for Admins and SYSTEM like a trivial ACL
POSIX.1e requires that chmod changes the MASK rather than the
	GROUP_OBJ value if the ACL is non-trivial.

	On Windows, especially on home machines, a standard ACL often
	consists of entries for the user, maybe the group, and additional
	entries for SYSTEM and the Administrators group.  A user calling
	chmod on a file with bog standard Windows perms usually expects
	that chmod changes the GROUP_OBJ perms, but given the rules from
	POSIX.1e we can't do that.

	However, since we already treat Admins and SYSTEM special in a
	ACL (they are not used in MASK computations) we go a step in the
	Windows direction to follow user expectations.  If an ACL only
	consists of the three POSIX permissions, plus entries for Admins
	and SYSTEM *only*, then we change the permissions of the GROUP_OBJ
	entry *and* the MASK entry.

	* fhandler_disk_file.cc (fhandler_disk_file::chmod): Drop unused
	code.  Add special handling for a "standard" Windows ACL.  Add
	comment to explain.
	* sec_acl.cc (get_posix_access): Allow to return "standard-ness"
	of an ACL to the caller.  Add preceeding comment to explain a bit.
	* security.h (get_posix_access): Align prototype.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-28 22:05:49 +01:00
Corinna Vinschen a16ab1751c get_posix_access: Fix primary group handing when multiple ACEs exist
Handle additional ACE for primary group only as another GROUP
	entry if it's an allow ACE.  Deny ACEs don't qualify.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-28 14:34:11 +01:00
Corinna Vinschen fcda8810a2 Don't use LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32). It hangs
Observed running hexchat under X.  For some reason the call to
	LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32) in dll_load
	hangs when trying to autoload MsgWaitForMultipleObjectsEx in
	select.cc after hexchat forks to run DNS calls.  Dropping the
	call and just using full paths as in 2.3.1 fixes the issue.

	* autoload.cc (dll_load): Drop call to LoadLibraryEx with
	LOAD_LIBRARY_SEARCH_SYSTEM32 flag.
	* wincap.h (wincaps::has_load_lib_search_flags): Remove.
	* wincap.cc (wincaps::has_load_lib_search_flags): Drop handling
	this flag.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:43:15 +01:00
Corinna Vinschen 78549742de Drop has_broken_fnoi flag
* mount.cc (fs_info::update): Don't set has_broken_fnoi.  It's
	unused anyway.
	* mount.h (class fs_info): Remove has_broken_fnoi status flag.
	* path.h (class path_conv): Remove has_broken_fnoi method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:39:11 +01:00
Corinna Vinschen d9accb0079 Make select wait state more readable
Rename "res" to "wait_state" and change its type to
	select_stuff::wait_states.  Use select_stuff::wait_states
	values instead of ints throughout. 	Rearrange a few comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:37:53 +01:00
Corinna Vinschen 11a37290c6 Fix missing 'user' in usertemp docs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:37:46 +01:00
Corinna Vinschen 69f98f5f18 Add 2.4.1 release message file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-23 22:33:31 +01:00
Corinna Vinschen 79b1b77b1f cygpath: Avoid returning SysWOW64
On Cygwin 32 running under WOW64:

	When case-correcting the path fetched with -S, the underlying
	Windows function fetching the normalized path returns the real
	path C:\Windows\SysWOW64 instead of the path redirection
	enabled C:\Windows\System32 path.  This breaks using the result
	of `cygpath -S' to fetch the POSIX path of the network related
	files under SYSTEMROOT\drivers\etc.  This path is in fact under
	the *real* C:\Windows\System32 and only mapped into the 32 bit
	C:\Windows\System32 (aka C:\Windows\SysWOW64) via path redirection.
	Sounds messy?

	This patch checks if we're running under WOW64.  If so, it
	changes the path returned by GetSystemDirectoryW from "system32"
	to "Sysnative".  This in turn is changed to "System32" by
	NtQueryInformationFile, so we're back to what we need.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:40:30 +01:00
Corinna Vinschen b5c80f5a59 cygwin_logon_user: Return non-privileged token as well
If the calling process doesn't have sufficient privileges to
	fetch the linked token of an admin-user token, cygwin_logon_user
	fails.  This patch changes that by returning the original,
	unprivileged token of the admin user to allow authentication
	and calling setuid for the current process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:32:16 +01:00
Corinna Vinschen d44ec01ea1 Fix formatting in sec_auth.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-21 18:27:05 +01:00
Corinna Vinschen 3a720bf3f0 Bump cygwin version to 2.4.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-16 12:57:53 +01:00
Jon Turney 9c8a6e5646 faq: Update FAQ question and answer about gdb and signals
* faq-programming.xml: Update question and answer about gdb and signals.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-01-15 14:59:07 +00:00
Corinna Vinschen d2216272f5 get_posix_access: Fix group deny bits leaking into file type attribute bits
* sec_acl.cc (get_posix_access): Fix bracketing in expression
	constructing POSIX group permissions so as not leaking deny bits
	into POSIX file type bits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-15 15:13:11 +01:00
Corinna Vinschen fc449e1c1f Initialize handle in dll_load to avoid compiler warning
* autoload.cc (dll_load): Initialize h to NULL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:45:17 +01:00
Corinna Vinschen 8cd1ff7a45 Use MAKEWORD macro in WSAStartup call per documentation
* autoload.cc (wsock_init): Use MAKEWORD macro to create requested
	version rather than handcrafted expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:25:15 +01:00
Corinna Vinschen 15d6f564cd Try loading with safe path using LOAD_LIBRARY_SEARCH_SYSTEM32 first
* autoload.cc (dll_load): Move safe loading from std_dll_init here.
	Add code to handle systems supporting LOAD_LIBRARY_SEARCH flags.
	Add comments to explain what the code is doing.  Fix up comment
	preceeding this function.
	(std_dll_init): Move safe loading code to dll_load.
	* wincap.h (wincaps::has_load_lib_search_flags): New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:23:14 +01:00