Corinna Vinschen [Wed, 10 Aug 2022 15:40:06 +0000 (17:40 +0200)]
Cygwin: rename CygwinCreateThread to create_posix_thread
Rename CygwinCreateThread to create_posix_thread and move
from miscfuncs.cc to create_posix_thread.cc, inbcluding all
related functions. Analogue for the prototypes.
Ken Brown [Tue, 9 Aug 2022 19:14:07 +0000 (15:14 -0400)]
Cygwin: fix return value of symlink_info::check
Currently it is possible for symlink_info::check to return -1 in case
we're searching for foo and find foo.lnk that is not a Cygwin symlink.
This contradicts the new meaning attached to a negative return value
in commit 19d59ce75d. Fix this by setting "res" to 0 at the beginning
of the main loop and not seting it to -1 later.
Also fix the commentary preceding the function definition to reflect
the current behavior.
provide entire internal and external pthread API from inside the
same file.
While I dislike to have another even larger file, this is basically
cleaning up the source and grouping the external API into useful
chunks. Splitting the file cleanly is tricky due to usage of inline
methods is_good_object and verifyable_object_isvalid.
- DevDocs: doc files
- fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc
- local_includes: local include files
- scripts: scripts called during build
- sec: security sources
Cygwin: use locale-aware conversion to UNICODE_STRING checking mount points
mount_info::get_mounts_here used RtlCreateUnicodeStringFromAsciiz
which translates bytes into wide chars verbatim.
Create a new function sys_mbstouni_alloc which can be used from
mount_info::get_mounts_here to convert multibyte mount point
strings to UNICODE_STRINGS in a locale-aware way.
For symmetry, create a function mount_info::free_mounts_here,
so the knwoledge how to free the UNICODE_STRING buffers is
encapsulated in the same class.
Ken Brown [Wed, 3 Aug 2022 20:45:23 +0000 (16:45 -0400)]
Cygwin: syscalls.cc: remove ".dll" from blessed_executable_suffixes
This reverts commit d9e9c7b5a7. The latter added ".dll" to the
blessed_executable_suffixes array because on 32-bit Windows, the
GetBinaryType function would report that a 64-bit DLL is an
executable, contrary to the documentation of that function.
That anomaly does not exist on 64-bit Windows, so we can remove ".dll"
from the list. Reverting the commit does, however, change the
behavior of the rename(2) syscall in the following unlikely situation:
Suppose we have an executable foo.exe and we make the call
rename ("foo", "bar.dll");
Previously, foo.exe would be renamed to bar.dll. So bar.dll would
then be an executable without the .exe extension. The new behavior is
that foo.exe will be renamed to bar.dll.exe. [Exception: If there
already existed an executable (not a DLL!) with the name bar.dll, then
.exe will not be appended.]
Cygwin: syscalls.cc: drop masking macros for standard IO functions
The actual reason for these wrappers are lost in time, there's no
hint even in the pre-2000 ChangeLog files. Apparently they were
masking the prototypes or, alternatively, macros from newlib to
clash with the definitions in syscalls.cc.
They are not needed anymore, so just drop them.
This uncovered that the buffer pointer to pwrite is erronously
non-const. Fix this on the way out.
To avoid linear searches for error codes, autogenerate errmap as
simple array of errno values indexed by Windows error codes.
Restrict to the first 9000 Windows error codes, we don't care for
most of them anyway.
Define errmap in its own file errmap.h to clean up errno.cc.
Cygwin: drop requirement to build newlib's stdio64
Given that 64 bit Cygwin defines all file access types (off_t,
fpos_t, and derived types) as 64 bit anyway, there's no reason
left to rely on the stdio64 part of newlib. Use base functions
and base types.
Takashi Yano [Mon, 1 Aug 2022 00:02:23 +0000 (09:02 +0900)]
Cygwin: path: Make some symlinks to /cygdrive/* work.
- Previously, some symbolic links to /cygdrive/* (e.g. /cygdrive/C,
/cygdrive/./c, /cygdrive//c, etc.) did not work. This patch fixes
the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251994.html
- Previously, LoadLibraryA() is hooked for ConEmu cygwin connector.
With this patch, GetProcAddress() for "RequestTermConnector" is
hooked instead which is more essential for ConEmu cygwin connector.
Cygwin: console: Avoid accessing NULL pointer via cygheap->ctty.
- Recent commit "Cygwin: console: Add missing input_mutex guard."
has a problem that causes NULL pointer access if cygheap->ctty
is NULL. This patch fixes the issue.
Jon Turney [Thu, 19 May 2022 16:27:39 +0000 (17:27 +0100)]
Cygwin: Set threadnames with SetThreadDescription()
gdb master recently learnt how to use GetThreadDescription() [1], so set
threadnames using SetThreadDescription() [available since Windows 10
1607] as well.
This is superior to using a special exception to indicate the thread
name to the debugger, because the thread name isn't missed if you don't
have a debugger attached at the time it's set.
It's not clear what the encoding of a thread name string is, we assume
UTF8 for the moment.
For the moment, continue to use the old method as well, for the benefit
of older gdb versions etc.
Cygwin: rename __cygwin_environ and drop env redirection via cur_environ()
Back in early Cygwin development a function based access to the
environment was exported, the internal environ in Cygwin was called
__cygwin_environ and cur_environ() was used to access the environment
indirectly . The history of that necessity is not documented,
but kept in i686 for backward compatibility.
The x86_64 port eventually used __cygwin_environ directly and exported
it as DATA under the usual name environ.
We don't need the i686 workaround anymore, so just rename
__cygwin_environ to environ, drop the cur_environ() macro and
simply export environ under its own name.
- rename "is64bit" to "is_x86_64"
- Always set sym_prefix to empty string and add a FIXME
- speclib: rename uscore to sym_prefix and fix bug in string handling
Cygwin: console: Add workaround for ConEmu cygwin connector.
- ConEmu cygwin connector conflicts with cons_master_thread since
it does not use read() to read console input. With this patch,
cons_master_thread is disabled in ConEmu cygwin connector.
Matt Joyce [Mon, 16 May 2022 09:51:54 +0000 (11:51 +0200)]
Add --enable-newlib-reent-thread-local option
By default, Newlib uses a huge object of type struct _reent to store
thread-specific data. This object is returned by __getreent() if the
__DYNAMIC_REENT__ Newlib configuration option is defined.
The reentrancy structure contains for example errno and the standard input,
output, and error file streams. This means that if an application only uses
errno it has a dependency on the file stream support even if it does not use
it. This is an issue for lower end targets and applications which need to
qualify the software according to safety standards (for example ECSS-E-ST-40C,
ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333).
If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct
_reent is replaced by dedicated thread-local objects for each struct _reent
member. The thread-local objects are defined in translation units which use
the corresponding object.
Matt Joyce [Mon, 23 May 2022 09:29:57 +0000 (11:29 +0200)]
Add _REENT_IS_NULL()
In a follow up patch, struct _reent is optionally replaced by dedicated
thread-local objects. In this case,_REENT is optionally defined to NULL. Add
the _REENT_IS_NULL() macro to disable this check on demand.
Matt Joyce [Fri, 4 Feb 2022 10:47:18 +0000 (11:47 +0100)]
Add _REENT_SIG_FUNC(ptr)
Add a _REENT_SIG_FUNC() macro to encapsulate access to the
_sig_func member of struct reent. This will help to replace the
struct member with a thread-local storage object in a follow up
patch.
Matt Joyce [Thu, 3 Feb 2022 11:24:26 +0000 (12:24 +0100)]
Add _REENT_CVTBUF(ptr)
Add a _REENT_CVTBUF() macro to encapsulate access to the _cvtbuf
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow up patch.
Matt Joyce [Thu, 3 Feb 2022 10:19:14 +0000 (11:19 +0100)]
Add _REENT_CVTLEN(ptr)
Add a _REENT_CVTLEN() macro to encapsulate access to the _cvtlen
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow-up patch.
Matt Joyce [Thu, 3 Feb 2022 09:18:53 +0000 (10:18 +0100)]
Add _REENT_CLEANUP(ptr)
Add a _REENT_CLEANUP() macro to encapsulate access to the
__cleanup member of struct reent. This will help to replace the
struct member with a thread-local storage object in a follow up
patch.
Matt Joyce [Wed, 2 Feb 2022 11:47:30 +0000 (12:47 +0100)]
Add _REENT_LOCALE(ptr)
Add a _REENT_LOCALE() macro to encapsulate access to the _locale
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow up patch.
Matt Joyce [Wed, 2 Feb 2022 08:49:00 +0000 (09:49 +0100)]
Add _REENT_INC(ptr)
Add a _REENT_INC() macro to encapsulate access to the _inc member
of struct reent. This will help to replace the struct member with
a thread-local storage object in a follow up patch.
Matt Joyce [Tue, 1 Feb 2022 12:05:53 +0000 (13:05 +0100)]
Add _REENT_STDERR(ptr)
Add a _REENT_STDERR() macro to encapsulate access to the _stderr
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow up patch.
Matt Joyce [Tue, 1 Feb 2022 11:37:46 +0000 (12:37 +0100)]
Add _REENT_STDOUT(ptr)
Add a _REENT_STDOUT() macro to encapsulate access to the _stdout
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow up patch.
Matt Joyce [Fri, 28 Jan 2022 09:58:36 +0000 (10:58 +0100)]
Add _REENT_STDIN(ptr)
Add a _REENT_STDIN() macro to encapsulate access to the _stdin
member of struct reent. This will help to replace the struct
member with a thread-local storage object in a follow up patch.
Matt Joyce [Tue, 18 Jan 2022 09:13:04 +0000 (10:13 +0100)]
Add _REENT_ERRNO(ptr)
Add a _REENT_ERRNO() macro to encapsulate the access to the
_errno member of struct reent. This will help to replace the
structure member with a thread-local storage object in a follow
up patch.
Replace uses of __errno_r() with _REENT_ERRNO(). Keep __errno_r() macro for
potential users outside of Newlib.
Matt Joyce [Mon, 16 May 2022 08:54:31 +0000 (10:54 +0200)]
Define _REENT_EMERGENCY(ptr) only once
Use this macro to access the _emergency member of struct _reent. This macro
will help to replace the _emergency member of struct _reent with a thread-local
storage object in a follow up patch.
Cygwin: clipboard: Add workaround for setting clipboard failure.
- OpenClipboard() just after CloseClipboard() sometimes fails. Due
to this, /dev/clipboard sometimes fails to set CF_UNICODETEXT
data. This patch add a workaround for this issue.
Gleb Smirnoff [Fri, 24 Jun 2022 16:09:11 +0000 (09:09 -0700)]
libc/syslog: fully deprecate and don't try to open "/dev/log"
The "/dev/log" socket existed in pre-FreeBSD times. Later it was
substituted to a compatibility symlink. The symlink creation was
deprecated in FreeBSD 10.2 and 9-STABLE.
Provide sticky ARP flag for network interface which marks it as the
"sticky" one similarly to what we have for bridges. Once interface is
marked sticky, any address resolved using the ARP will be saved as a
static one in the ARP table. Such functionality may be used to prevent
ARP spoofing or to decrease latencies in Ethernet networks.
The drawbacks include potential limitations in usage of ARP-based
load-balancers and high-availability solutions such as carp(4).
The implemented option is disabled by default, therefore should not
impact the default behaviour of the networking stack.
Alan Somers [Thu, 5 May 2022 21:35:23 +0000 (15:35 -0600)]
Correctly measure system load averages > 1024
The old fixed-point arithmetic used for calculating load averages had an
overflow at 1024. So on systems with extremely high load, the observed
load average would actually fall back to 0 and shoot up again, creating
a kind of sawtooth graph.
Fix this by using 64-bit math internally, while still reporting the load
average to userspace as a 32-bit number.
tcp: LRO code to deal with all 12 TCP header flags
TCP per RFC793 has 4 reserved flag bits for future use. One
of those bits may be used for Accurate ECN.
This patch is to include these bits in the LRO code to ease
the extensibility if/when these bits are used.
Mike Karels [Wed, 27 Oct 2021 03:01:09 +0000 (22:01 -0500)]
kernel: deprecate Internet Class A/B/C
Hide historical Class A/B/C macros unless IN_HISTORICAL_NETS is defined;
define it for user level. Define IN_MULTICAST separately from IN_CLASSD,
and use it in pf instead of IN_CLASSD. Stop using class for setting
default masks when not specified; instead, define new default mask
(24 bits). Warn when an Internet address is set without a mask.
Peter Lei [Tue, 26 Oct 2021 03:08:54 +0000 (20:08 -0700)]
tcp: socket option to get stack alias name
TCP stack sysctl nodes are currently inserted using the stack
name alias. Allow the user to get the current stack's alias to
allow for programatic sysctl access.