Compare commits

..

No commits in common. "0e1fbc94a2bc25b8be75b3c8762b2f264381728b" and "06952f41ff4897c615fa838c5daf571aacb55d0f" have entirely different histories.

24 changed files with 105 additions and 201 deletions

2
config.sub vendored
View file

@ -1749,7 +1749,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
| fiwix* | xenon* ) | fiwix* )
;; ;;
# This one is extra strict with allowed versions # This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*) sco3.2v2 | sco3.2v[4-9]* | sco5v6*)

View file

@ -35,10 +35,10 @@ void or1k_interrupt_handler_add(uint32_t id,
{ {
#ifdef __OR1K_MULTICORE__ #ifdef __OR1K_MULTICORE__
_or1k_interrupt_handler_table[or1k_coreid()][id] = handler; _or1k_interrupt_handler_table[or1k_coreid()][id] = handler;
_or1k_interrupt_handler_data_ptr_table[or1k_coreid()][id] = data_ptr; _or1k_interrupt_handler_data_ptr_table[or1k_coreid()][id] = (uint32_t) data_ptr;
#else #else
_or1k_interrupt_handler_table[id] = handler; _or1k_interrupt_handler_table[id] = handler;
_or1k_interrupt_handler_data_ptr_table[id] = data_ptr; _or1k_interrupt_handler_data_ptr_table[id] = (uint32_t) data_ptr;
#endif #endif
} }

View file

@ -90,7 +90,7 @@ void (*_or1k_uart_read_cb)(char c);
* This is the interrupt handler that is registered for the callback * This is the interrupt handler that is registered for the callback
* function. * function.
*/ */
void _or1k_uart_interrupt_handler(void *data) void _or1k_uart_interrupt_handler(uint32_t data)
{ {
uint8_t iir = REG8(IIR); uint8_t iir = REG8(IIR);

View file

@ -30,7 +30,7 @@ extern void (*_or1k_uart_read_cb)(char c);
/** /**
* The UART interrupt handler * The UART interrupt handler
*/ */
void _or1k_uart_interrupt_handler(void *data); void _or1k_uart_interrupt_handler(uint32_t data);
/** /**
* Initialize UART * Initialize UART

View file

@ -20,7 +20,7 @@
#include "include/or1k-support.h" #include "include/or1k-support.h"
extern uint32_t end; /* Set by linker. */ extern uint32_t end; /* Set by linker. */
uint32_t _or1k_heap_start = (uint32_t) &end; uint32_t _or1k_heap_start = &end;
uint32_t _or1k_heap_end; uint32_t _or1k_heap_end;
void * void *

View file

@ -1,19 +1,3 @@
*** Major changes in newlib version 4.5.0:
- major clean-up of libgloss build including merging a number of platforms
into top-level Makefile (moxie, v850, i960, msp430, frv, i386, ...) and
removal of dead platforms such as xc16x
- strverscmp fixed for comparison of digit sequence with non-digits
- proper locking added from amdgcn
- numerous improvements to arc support including support of 16-entry
register file
- long double complex functions are now skipped if long double != double
- support for POSIX.1-2024 added to features.h
- arc64: port added for Synopsys Designware ARCv3 ISA
- sys/xtensa removed and replaced by machine/xtensa and libgloss
- fixes to powf
- fixes for building with gcc-15
*** Major changes in newlib version 4.4.0: *** Major changes in newlib version 4.4.0:
- long double support for i386, aarch64, and x86_64 added from FreeBSD - long double support for i386, aarch64, and x86_64 added from FreeBSD

View file

@ -1,4 +1,4 @@
README for newlib-4.5.0 release README for newlib-4.2.0 release
(mostly cribbed from the README in the gdb-4.13 release) (mostly cribbed from the README in the gdb-4.13 release)
This is `newlib', a simple ANSI C library, math library, and collection This is `newlib', a simple ANSI C library, math library, and collection
@ -20,8 +20,8 @@ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Unpacking and Installation -- quick overview Unpacking and Installation -- quick overview
========================== ==========================
When you unpack the newlib-4.5.0.tar.gz file, you'll find a directory When you unpack the newlib-4.2.0.tar.gz file, you'll find a directory
called `newlib-4.5.0', which contains many files. Interesting ones: called `newlib-4.2.0', which contains many files. Interesting ones:
COPYING* - License files for the sources COPYING* - License files for the sources
README - A common overview of all GNU development projects README - A common overview of all GNU development projects
configure - The build script for configuring the source tree configure - The build script for configuring the source tree
@ -94,13 +94,13 @@ directory. If the path to `configure' would be the same as the
argument to `--srcdir', you can leave out the `--srcdir' option; it argument to `--srcdir', you can leave out the `--srcdir' option; it
will be assumed.) will be assumed.)
For example, with version 4.5.0, you can build NEWLIB in a separate For example, with version 4.2.0, you can build NEWLIB in a separate
directory for a Sun 4 cross m68k-aout environment like this: directory for a Sun 4 cross m68k-aout environment like this:
cd newlib-4.5.0 cd newlib-4.2.0
mkdir ../newlib-m68k-aout mkdir ../newlib-m68k-aout
cd ../newlib-m68k-aout cd ../newlib-m68k-aout
../newlib-4.5.0/configure --host=sun4 --target=m68k-aout ../newlib-4.2.0/configure --host=sun4 --target=m68k-aout
make make
When `configure' builds a configuration using a remote source When `configure' builds a configuration using a remote source
@ -116,8 +116,8 @@ called `configure' (or one of its subdirectories).
The `Makefile' that `configure' generates in each source directory The `Makefile' that `configure' generates in each source directory
also runs recursively. If you type `make' in a source directory such also runs recursively. If you type `make' in a source directory such
as `newlib-4.5.0' (or in a separate configured directory configured with as `newlib-4.2.0' (or in a separate configured directory configured with
`--srcdir=PATH/newlib-4.5.0'), you will build all the required libraries. `--srcdir=PATH/newlib-4.2.0'), you will build all the required libraries.
When you have multiple hosts or targets configured in separate When you have multiple hosts or targets configured in separate
directories, you can run `make' on them in parallel (for example, if directories, you can run `make' on them in parallel (for example, if
@ -530,7 +530,7 @@ Reporting Bugs
The correct address for reporting bugs found in NEWLIB is The correct address for reporting bugs found in NEWLIB is
"newlib@sourceware.org". Please email all bug reports to that "newlib@sourceware.org". Please email all bug reports to that
address. Please include the NEWLIB version number (e.g., newlib-4.5.0), address. Please include the NEWLIB version number (e.g., newlib-4.2.0),
and how you configured it (e.g., "sun4 host and m68k-aout target"). and how you configured it (e.g., "sun4 host and m68k-aout target").
Since NEWLIB supports many different configurations, it is important Since NEWLIB supports many different configurations, it is important
that you be precise about this. that you be precise about this.

View file

@ -2,7 +2,7 @@ dnl This provides configure definitions used by all the newlib
dnl configure.in files. dnl configure.in files.
AC_DEFUN([DEF_NEWLIB_MAJOR_VERSION],m4_define([NEWLIB_MAJOR_VERSION],[4])) AC_DEFUN([DEF_NEWLIB_MAJOR_VERSION],m4_define([NEWLIB_MAJOR_VERSION],[4]))
AC_DEFUN([DEF_NEWLIB_MINOR_VERSION],m4_define([NEWLIB_MINOR_VERSION],[5])) AC_DEFUN([DEF_NEWLIB_MINOR_VERSION],m4_define([NEWLIB_MINOR_VERSION],[4]))
AC_DEFUN([DEF_NEWLIB_PATCHLEVEL_VERSION],m4_define([NEWLIB_PATCHLEVEL_VERSION],[0])) AC_DEFUN([DEF_NEWLIB_PATCHLEVEL_VERSION],m4_define([NEWLIB_PATCHLEVEL_VERSION],[0]))
AC_DEFUN([DEF_NEWLIB_VERSION],m4_define([NEWLIB_VERSION],[NEWLIB_MAJOR_VERSION.NEWLIB_MINOR_VERSION.NEWLIB_PATCHLEVEL_VERSION])) AC_DEFUN([DEF_NEWLIB_VERSION],m4_define([NEWLIB_VERSION],[NEWLIB_MAJOR_VERSION.NEWLIB_MINOR_VERSION.NEWLIB_PATCHLEVEL_VERSION]))

24
newlib/configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for newlib 4.5.0. # Generated by GNU Autoconf 2.69 for newlib 4.4.0.
# #
# #
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@ -576,8 +576,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='newlib' PACKAGE_NAME='newlib'
PACKAGE_TARNAME='newlib' PACKAGE_TARNAME='newlib'
PACKAGE_VERSION='4.5.0' PACKAGE_VERSION='4.4.0'
PACKAGE_STRING='newlib 4.5.0' PACKAGE_STRING='newlib 4.4.0'
PACKAGE_BUGREPORT='' PACKAGE_BUGREPORT=''
PACKAGE_URL='' PACKAGE_URL=''
@ -1563,7 +1563,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures newlib 4.5.0 to adapt to many kinds of systems. \`configure' configures newlib 4.4.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1633,7 +1633,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of newlib 4.5.0:";; short | recursive ) echo "Configuration of newlib 4.4.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1765,7 +1765,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
newlib configure 4.5.0 newlib configure 4.4.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1857,7 +1857,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by newlib $as_me 4.5.0, which was It was created by newlib $as_me 4.4.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -4870,7 +4870,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='newlib' PACKAGE='newlib'
VERSION='4.5.0' VERSION='4.4.0'
# Some tools Automake needs. # Some tools Automake needs.
@ -6501,13 +6501,13 @@ fi
$as_echo "#define _NEWLIB_VERSION \"4.5.0\"" >>confdefs.h $as_echo "#define _NEWLIB_VERSION \"4.4.0\"" >>confdefs.h
$as_echo "#define __NEWLIB__ 4" >>confdefs.h $as_echo "#define __NEWLIB__ 4" >>confdefs.h
$as_echo "#define __NEWLIB_MINOR__ 5" >>confdefs.h $as_echo "#define __NEWLIB_MINOR__ 4" >>confdefs.h
$as_echo "#define __NEWLIB_PATCHLEVEL__ 0" >>confdefs.h $as_echo "#define __NEWLIB_PATCHLEVEL__ 0" >>confdefs.h
@ -8460,7 +8460,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by newlib $as_me 4.5.0, which was This file was extended by newlib $as_me 4.4.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -8526,7 +8526,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
newlib config.status 4.5.0 newlib config.status 4.4.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View file

@ -455,9 +455,6 @@ case "${host}" in
newlib_cflags="${newlib_cflags} -DHAVE_FCNTL -DHAVE_BLKSIZE -DHAVE_OPENDIR -DHAVE_RENAME" newlib_cflags="${newlib_cflags} -DHAVE_FCNTL -DHAVE_BLKSIZE -DHAVE_OPENDIR -DHAVE_RENAME"
newlib_cflags="${newlib_cflags} -DGETREENT_PROVIDED -DSIGNAL_PROVIDED" newlib_cflags="${newlib_cflags} -DGETREENT_PROVIDED -DSIGNAL_PROVIDED"
;; ;;
*-fcx-*)
sys_dir=amdgcn # Just use a random one for now, we don't use this yet.
;;
a29k-*-*) a29k-*-*)
sys_dir=a29khif sys_dir=a29khif
signal_dir= signal_dir=

View file

@ -69,8 +69,8 @@ into another language, under the above conditions for modified versions.
@title The Red Hat newlib C Library @title The Red Hat newlib C Library
@subtitle Full Configuration @subtitle Full Configuration
@sp 1 @sp 1
@subtitle @code{libc} 4.5.0 @subtitle @code{libc} 4.4.0
@subtitle December 2024 @subtitle December 2023
@author Steve Chamberlain @author Steve Chamberlain
@author Roland Pesch @author Roland Pesch
@author Red Hat Support @author Red Hat Support

View file

@ -38,9 +38,6 @@ volatile uint32_t _or1k_malloc_lock_restore;
extern uint32_t or1k_sync_cas(void *address, uint32_t compare, uint32_t swap); extern uint32_t or1k_sync_cas(void *address, uint32_t compare, uint32_t swap);
extern uint32_t or1k_critical_begin();
extern void or1k_critical_end(uint32_t restore);
/** /**
* Recursive lock of the malloc * Recursive lock of the malloc
*/ */

View file

@ -46,8 +46,8 @@ into another language, under the above conditions for modified versions.
@titlepage @titlepage
@title The Red Hat newlib C Math Library @title The Red Hat newlib C Math Library
@sp 1 @sp 1
@subtitle @code{libm} 4.5.0 @subtitle @code{libm} 4.4.0
@subtitle December 2024 @subtitle December 2023
@author Steve Chamberlain @author Steve Chamberlain
@author Roland Pesch @author Roland Pesch
@author Red Hat Support @author Red Hat Support

View file

@ -1098,6 +1098,7 @@ format_process_stat (void *data, char *&destbuf)
unsigned long fault_count = 0UL, unsigned long fault_count = 0UL,
vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL; vmsize = 0UL, vmrss = 0UL, vmmaxrss = 0UL;
uint64_t utime = 0ULL, stime = 0ULL, start_time = 0ULL; uint64_t utime = 0ULL, stime = 0ULL, start_time = 0ULL;
int nice = 0;
/* ctty maj is 31:16, min is 15:0; tty_nr s/b maj 15:8, min 31:20, 7:0; /* ctty maj is 31:16, min is 15:0; tty_nr s/b maj 15:8, min 31:20, 7:0;
maj is 31:16 >> 16 & fff << 8; min is 15:0 >> 8 & ff << 20 | & ff */ maj is 31:16 >> 16 & fff << 8; min is 15:0 >> 8 & ff << 20 | & ff */
int tty_nr = 0; int tty_nr = 0;
@ -1130,8 +1131,6 @@ format_process_stat (void *data, char *&destbuf)
else else
state = get_process_state (p->dwProcessId); state = get_process_state (p->dwProcessId);
int nice = 0, prio = 0;
NTSTATUS status; NTSTATUS status;
HANDLE hProcess; HANDLE hProcess;
VM_COUNTERS vmc = { 0 }; VM_COUNTERS vmc = { 0 };
@ -1169,26 +1168,7 @@ format_process_stat (void *data, char *&destbuf)
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (status))
debug_printf ("NtQueryInformationProcess(ProcessQuotaLimits): " debug_printf ("NtQueryInformationProcess(ProcessQuotaLimits): "
"status %y", status); "status %y", status);
nice = winprio_to_nice (GetPriorityClass (hProcess));
nice = p->nice;
DWORD winprio = GetPriorityClass (hProcess);
if (p->sched_policy == SCHED_FIFO || p->sched_policy == SCHED_RR)
/* Linux proc_pid_stat(5): (18) priority - For processes running a
real-time scheduling policy ..., this is the negated scheduling
priority, minus one. */
prio = - winprio_to_schedprio (winprio) - 1; /* -33(high)...-2(low) */
else if (p->sched_policy == SCHED_IDLE)
/* Return the lowest priority unless no longer consistent. */
prio = NZERO + (winprio == IDLE_PRIORITY_CLASS ? NZERO - 1 :
winprio_to_nice (winprio));
else
{
/* Use originally requested nice value unless no longer consistent. */
bool batch = (p->sched_policy == SCHED_BATCH);
if (winprio != nice_to_winprio (nice, batch))
nice = winprio_to_nice (winprio, batch);
prio = NZERO + nice; /* 0(high)...39(low) */
}
CloseHandle (hProcess); CloseHandle (hProcess);
} }
status = NtQuerySystemInformation (SystemTimeOfDayInformation, status = NtQuerySystemInformation (SystemTimeOfDayInformation,
@ -1221,7 +1201,7 @@ format_process_stat (void *data, char *&destbuf)
p->ppid, p->pgid, p->sid, tty_nr, p->ppid, p->pgid, p->sid, tty_nr,
-1, 0, fault_count, fault_count, 0, 0, -1, 0, fault_count, fault_count, 0, 0,
utime, stime, utime, stime, utime, stime, utime, stime,
prio, nice, 0, 0, NZERO + nice, nice, 0, 0,
start_time, start_time,
vmsize, vmrss, vmmaxrss vmsize, vmrss, vmmaxrss
); );

View file

@ -46,8 +46,6 @@ is_alt_numpad_event (PINPUT_RECORD pirec)
int winprio_to_nice (DWORD prio, bool batch = false); int winprio_to_nice (DWORD prio, bool batch = false);
DWORD nice_to_winprio (int &nice, bool batch = false); DWORD nice_to_winprio (int &nice, bool batch = false);
int winprio_to_schedprio (DWORD prio);
DWORD schedprio_to_winprio (int schedprio);
bool set_and_check_winprio (HANDLE proc, DWORD prio, bool set = true); bool set_and_check_winprio (HANDLE proc, DWORD prio, bool set = true);
bool create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD); bool create_pipe (PHANDLE, PHANDLE, LPSECURITY_ATTRIBUTES, DWORD);

View file

@ -223,7 +223,7 @@ private:
DWORD status_exit (DWORD); DWORD status_exit (DWORD);
}; };
#define MAX_PID 4194304 #define MAX_PID 65536
#define ISSTATE(p, f) (!!((p)->process_state & f)) #define ISSTATE(p, f) (!!((p)->process_state & f))
#define NOTSTATE(p, f) (!((p)->process_state & f)) #define NOTSTATE(p, f) (!((p)->process_state & f))

View file

@ -104,7 +104,7 @@ yield ()
} }
/* /*
Mapping of nice value or sched_priority from/to Windows priority Mapping of nice value from/to Windows priority
('batch' is used for SCHED_BATCH policy). ('batch' is used for SCHED_BATCH policy).
nice_to_winprio() winprio_to_nice() nice_to_winprio() winprio_to_nice()
@ -115,14 +115,6 @@ yield ()
-12...-5 -13..-19 3 ABOVE_NORMAL_PRIORITY_CLASS -8 -16 -12...-5 -13..-19 3 ABOVE_NORMAL_PRIORITY_CLASS -8 -16
-13..-19 -20 4 HIGH_PRIORITY_CLASS -16 -20 -13..-19 -20 4 HIGH_PRIORITY_CLASS -16 -20
-20 - 5 REALTIME_PRIORITY_CLASS -20 -20 -20 - 5 REALTIME_PRIORITY_CLASS -20 -20
schedprio_to_winprio() winprio_to_schedprio()
1....6 0 IDLE_PRIORITY_CLASS 3
7...12 1 BELOW_NORMAL_PRIORITY_CLASS 9
13...18 2 NORMAL_PRIORITY_CLASS 15
19...24 3 ABOVE_NORMAL_PRIORITY_CLASS 21
25...30 4 HIGH_PRIORITY_CLASS 27
31...32 5 REALTIME_PRIORITY_CLASS 32
*/ */
/* *_PRIORITY_CLASS -> 0...5 */ /* *_PRIORITY_CLASS -> 0...5 */
@ -175,25 +167,9 @@ nice_to_winprio_impl (int nice, bool batch = false)
return level_to_winprio (level); return level_to_winprio (level);
} }
/* *_PRIORITY_CLASS -> sched_priority */
constexpr int
winprio_to_schedprio_impl (DWORD prio)
{
int level = winprio_to_level (prio);
return (level < 5 ? 3 + level * 6 : 32);
}
/* sched_priority -> *_PRIORITY_CLASS */
constexpr DWORD
schedprio_to_winprio_impl (int schedprio)
{
int level = (schedprio <= 1 ? 0 : (schedprio < 32 ? (schedprio - 1) / 6 : 5));
return level_to_winprio (level);
}
/* Check consistency at compile time. */ /* Check consistency at compile time. */
constexpr bool constexpr bool
check_nice_schedprio_winprio_mapping () check_nice_winprio_mapping ()
{ {
for (int nice = -NZERO; nice < NZERO; nice++) for (int nice = -NZERO; nice < NZERO; nice++)
for (int batch = 0; batch <= 1; batch++) { for (int batch = 0; batch <= 1; batch++) {
@ -203,28 +179,16 @@ check_nice_schedprio_winprio_mapping ()
if (prio != prio2) if (prio != prio2)
return false; return false;
} }
for (int schedprio = 1; schedprio <= 32; schedprio++)
{
DWORD prio = schedprio_to_winprio_impl (schedprio);
int schedprio2 = winprio_to_schedprio_impl (prio);
DWORD prio2 = schedprio_to_winprio_impl (schedprio2);
if (prio != prio2)
return false;
}
return true; return true;
} }
static_assert (check_nice_schedprio_winprio_mapping()); static_assert (check_nice_winprio_mapping());
static_assert (nice_to_winprio_impl(NZERO-1, false) == IDLE_PRIORITY_CLASS); static_assert (nice_to_winprio_impl(NZERO-1, false) == IDLE_PRIORITY_CLASS);
static_assert (nice_to_winprio_impl(0, true) == BELOW_NORMAL_PRIORITY_CLASS); static_assert (nice_to_winprio_impl(0, true) == BELOW_NORMAL_PRIORITY_CLASS);
static_assert (winprio_to_nice_impl(BELOW_NORMAL_PRIORITY_CLASS, true) == 0); static_assert (winprio_to_nice_impl(BELOW_NORMAL_PRIORITY_CLASS, true) == 0);
static_assert (nice_to_winprio_impl(0, false) == NORMAL_PRIORITY_CLASS); static_assert (nice_to_winprio_impl(0, false) == NORMAL_PRIORITY_CLASS);
static_assert (winprio_to_nice_impl(NORMAL_PRIORITY_CLASS, false) == 0); static_assert (winprio_to_nice_impl(NORMAL_PRIORITY_CLASS, false) == 0);
static_assert (nice_to_winprio_impl(-NZERO, false) == REALTIME_PRIORITY_CLASS); static_assert (nice_to_winprio_impl(-NZERO, false) == REALTIME_PRIORITY_CLASS);
static_assert (schedprio_to_winprio_impl(1) == IDLE_PRIORITY_CLASS);
static_assert (schedprio_to_winprio_impl(15) == NORMAL_PRIORITY_CLASS);
static_assert (winprio_to_schedprio_impl(NORMAL_PRIORITY_CLASS) == 15);
static_assert (schedprio_to_winprio_impl(32) == REALTIME_PRIORITY_CLASS);
/* Get a default value for the nice factor. */ /* Get a default value for the nice factor. */
int int
@ -246,20 +210,6 @@ nice_to_winprio (int &nice, bool batch /* = false */)
return nice_to_winprio_impl (nice, batch); return nice_to_winprio_impl (nice, batch);
} }
/* Get a default sched_priority from a Win32 priority. */
int
winprio_to_schedprio (DWORD prio)
{
return winprio_to_schedprio_impl (prio);
}
/* Get a Win32 priority matching the sched_priority. */
DWORD
schedprio_to_winprio (int schedprio)
{
return schedprio_to_winprio_impl (schedprio);
}
/* Set Win32 priority or return false on failure. Also return /* Set Win32 priority or return false on failure. Also return
false and revert to the original priority if a different (lower) false and revert to the original priority if a different (lower)
priority is set instead. Always revert to original priority if priority is set instead. Always revert to original priority if

View file

@ -339,8 +339,8 @@ class mmap_record
SIZE_T find_unused_pages (SIZE_T pages) const; SIZE_T find_unused_pages (SIZE_T pages) const;
bool match (caddr_t addr, SIZE_T len, caddr_t &m_addr, SIZE_T &m_len); bool match (caddr_t addr, SIZE_T len, caddr_t &m_addr, SIZE_T &m_len);
off_t map_pages (SIZE_T len, int new_prot); off_t map_pages (SIZE_T len);
bool map_pages (caddr_t addr, SIZE_T len, int new_prot); bool map_pages (caddr_t addr, SIZE_T len);
bool unmap_pages (caddr_t addr, SIZE_T len); bool unmap_pages (caddr_t addr, SIZE_T len);
int access (caddr_t address); int access (caddr_t address);
@ -373,8 +373,7 @@ class mmap_list
void set (int nfd, struct stat *st); void set (int nfd, struct stat *st);
mmap_record *add_record (mmap_record &r); mmap_record *add_record (mmap_record &r);
bool del_record (mmap_record *rec); bool del_record (mmap_record *rec);
caddr_t try_map (void *addr, size_t len, int new_prot, int flags, caddr_t try_map (void *addr, size_t len, int flags, off_t off);
off_t off);
}; };
class mmap_areas class mmap_areas
@ -456,15 +455,14 @@ mmap_record::init_page_map (mmap_record &r)
} }
off_t off_t
mmap_record::map_pages (SIZE_T len, int new_prot) mmap_record::map_pages (SIZE_T len)
{ {
/* Used ONLY if this mapping matches into the chunk of another already /* Used ONLY if this mapping matches into the chunk of another already
performed mapping in a special case of MAP_ANON|MAP_PRIVATE. performed mapping in a special case of MAP_ANON|MAP_PRIVATE.
Otherwise it's job is now done by init_page_map(). */ Otherwise it's job is now done by init_page_map(). */
DWORD old_prot; DWORD old_prot;
debug_printf ("map_pages (fd=%d, len=%lu, new_prot=%y)", get_fd (), len, debug_printf ("map_pages (fd=%d, len=%lu)", get_fd (), len);
new_prot);
len = PAGE_CNT (len); len = PAGE_CNT (len);
off_t off = find_unused_pages (len); off_t off = find_unused_pages (len);
@ -472,8 +470,7 @@ mmap_record::map_pages (SIZE_T len, int new_prot)
return (off_t) 0; return (off_t) 0;
if (!noreserve () if (!noreserve ()
&& !VirtualProtect (get_address () + off * wincap.page_size (), && !VirtualProtect (get_address () + off * wincap.page_size (),
len * wincap.page_size (), len * wincap.page_size (), gen_protect (),
::gen_protect (new_prot, get_flags ()),
&old_prot)) &old_prot))
{ {
__seterrno (); __seterrno ();
@ -486,10 +483,9 @@ mmap_record::map_pages (SIZE_T len, int new_prot)
} }
bool bool
mmap_record::map_pages (caddr_t addr, SIZE_T len, int new_prot) mmap_record::map_pages (caddr_t addr, SIZE_T len)
{ {
debug_printf ("map_pages (addr=%p, len=%lu, new_prot=%y)", addr, len, debug_printf ("map_pages (addr=%p, len=%lu)", addr, len);
new_prot);
DWORD old_prot; DWORD old_prot;
off_t off = addr - get_address (); off_t off = addr - get_address ();
off /= wincap.page_size (); off /= wincap.page_size ();
@ -503,8 +499,7 @@ mmap_record::map_pages (caddr_t addr, SIZE_T len, int new_prot)
} }
if (!noreserve () if (!noreserve ()
&& !VirtualProtect (get_address () + off * wincap.page_size (), && !VirtualProtect (get_address () + off * wincap.page_size (),
len * wincap.page_size (), len * wincap.page_size (), gen_protect (),
::gen_protect (new_prot, get_flags ()),
&old_prot)) &old_prot))
{ {
__seterrno (); __seterrno ();
@ -619,7 +614,7 @@ mmap_list::del_record (mmap_record *rec)
} }
caddr_t caddr_t
mmap_list::try_map (void *addr, size_t len, int new_prot, int flags, off_t off) mmap_list::try_map (void *addr, size_t len, int flags, off_t off)
{ {
mmap_record *rec; mmap_record *rec;
@ -633,7 +628,7 @@ mmap_list::try_map (void *addr, size_t len, int new_prot, int flags, off_t off)
break; break;
if (rec && rec->compatible_flags (flags)) if (rec && rec->compatible_flags (flags))
{ {
if ((off = rec->map_pages (len, new_prot)) == (off_t) -1) if ((off = rec->map_pages (len)) == (off_t) -1)
return (caddr_t) MAP_FAILED; return (caddr_t) MAP_FAILED;
return (caddr_t) rec->get_address () + off; return (caddr_t) rec->get_address () + off;
} }
@ -651,7 +646,7 @@ mmap_list::try_map (void *addr, size_t len, int new_prot, int flags, off_t off)
break; break;
if (rec) if (rec)
{ {
if (u_addr > (caddr_t) addr || u_addr + u_len < (caddr_t) addr + len if (u_addr > (caddr_t) addr || u_addr + len < (caddr_t) addr + len
|| !rec->compatible_flags (flags)) || !rec->compatible_flags (flags))
{ {
/* Partial match only, or access mode doesn't match. */ /* Partial match only, or access mode doesn't match. */
@ -660,7 +655,7 @@ mmap_list::try_map (void *addr, size_t len, int new_prot, int flags, off_t off)
set_errno (EINVAL); set_errno (EINVAL);
return (caddr_t) MAP_FAILED; return (caddr_t) MAP_FAILED;
} }
if (!rec->map_pages ((caddr_t) addr, len, new_prot)) if (!rec->map_pages ((caddr_t) addr, len))
return (caddr_t) MAP_FAILED; return (caddr_t) MAP_FAILED;
return (caddr_t) addr; return (caddr_t) addr;
} }
@ -1056,7 +1051,7 @@ go_ahead:
/* Test if an existing anonymous mapping can be recycled. */ /* Test if an existing anonymous mapping can be recycled. */
if (map_list && anonymous (flags)) if (map_list && anonymous (flags))
{ {
caddr_t tried = map_list->try_map (addr, len, prot, flags, off); caddr_t tried = map_list->try_map (addr, len, flags, off);
/* try_map returns NULL if no map matched, otherwise it returns /* try_map returns NULL if no map matched, otherwise it returns
a valid address, or MAP_FAILED in case of a fatal error. */ a valid address, or MAP_FAILED in case of a fatal error. */
if (tried) if (tried)

View file

@ -239,7 +239,7 @@ pinfo::exit (DWORD n)
} }
# undef self # undef self
/* Return next free Cygwin PID between 2 and MAX_PID, round-robin. Each new /* Return next free Cygwin PID between 2 and 65535, round-robin. Each new
PID is checked that it doesn't collide with an existing PID. For that, PID is checked that it doesn't collide with an existing PID. For that,
just check if the "cygpid.PID" section exists. */ just check if the "cygpid.PID" section exists. */
pid_t pid_t

View file

@ -61,6 +61,3 @@ Fixes:
- Fix several problems triggered when a lot of SIGSTOP/SIGCONT signals - Fix several problems triggered when a lot of SIGSTOP/SIGCONT signals
are received rapidly. are received rapidly.
Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
- Fix the protection when mmap(2) recycles unused pages.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256911.html

View file

@ -69,12 +69,3 @@ What changed:
each child process created with fork(2). each child process created with fork(2).
Note: Windows does not offer alternative scheduling policies so Note: Windows does not offer alternative scheduling policies so
this could only emulate API behavior. this could only emulate API behavior.
- If SCHED_FIFO or SCHED_RR is selected, the /proc/<PID>/stat field
'(18) priority' is now set to the negated sched_policy minus one.
If SCHED_IDLE is selected, this field is set to 39. The '(19) nice'
field is now set to the originally requested nice value.
- Raise maximum pid from 65536 to 4194304 to account for scenarios
with lots of CPUs and lots of tasks.
Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256927.html

View file

@ -120,7 +120,29 @@ sched_getparam (pid_t pid, struct sched_param *param)
return -1; return -1;
} }
/* calculate the unix priority. */ /* calculate the unix priority. */
param->sched_priority = winprio_to_schedprio (pclass); switch (pclass)
{
case IDLE_PRIORITY_CLASS:
param->sched_priority = 3;
break;
case BELOW_NORMAL_PRIORITY_CLASS:
param->sched_priority = 9;
break;
case NORMAL_PRIORITY_CLASS:
default:
param->sched_priority = 15;
break;
case ABOVE_NORMAL_PRIORITY_CLASS:
param->sched_priority = 21;
break;
case HIGH_PRIORITY_CLASS:
param->sched_priority = 27;
break;
case REALTIME_PRIORITY_CLASS:
param->sched_priority = 32;
break;
}
return 0; return 0;
} }
@ -222,10 +244,18 @@ sched_setparam_pinfo (pinfo & p, const struct sched_param *param)
else if (p->sched_policy == SCHED_IDLE && pri == 0) else if (p->sched_policy == SCHED_IDLE && pri == 0)
/* Idle policy, ignore the nice value. */ /* Idle policy, ignore the nice value. */
pclass = IDLE_PRIORITY_CLASS; pclass = IDLE_PRIORITY_CLASS;
else if ((p->sched_policy == SCHED_FIFO || p->sched_policy == SCHED_RR) else if (1 <= pri && pri <= 6)
&& valid_sched_parameters (param)) pclass = IDLE_PRIORITY_CLASS;
/* Realtime policy, apply requested priority. */ else if (pri <= 12)
pclass = schedprio_to_winprio (param->sched_priority); pclass = BELOW_NORMAL_PRIORITY_CLASS;
else if (pri <= 18)
pclass = NORMAL_PRIORITY_CLASS;
else if (pri <= 24)
pclass = ABOVE_NORMAL_PRIORITY_CLASS;
else if (pri <= 30)
pclass = HIGH_PRIORITY_CLASS;
else if (pri <= 32)
pclass = REALTIME_PRIORITY_CLASS;
else else
{ {
set_errno (EINVAL); set_errno (EINVAL);

View file

@ -1345,12 +1345,6 @@ wait_sig (VOID *)
hntdll = GetModuleHandle ("ntdll.dll"); hntdll = GetModuleHandle ("ntdll.dll");
/* GetTickCount() here is enough because GetTickCount() - t0 does
not overflow until 49 days psss. Even if GetTickCount() overflows,
GetTickCount() - t0 returns correct value, since underflow in
unsigned wraps correctly. Pending a signal for more than 49
days makes no sense. */
DWORD t0 = GetTickCount ();
for (;;) for (;;)
{ {
DWORD nb; DWORD nb;
@ -1360,7 +1354,7 @@ wait_sig (VOID *)
else if (sigq.start.next else if (sigq.start.next
&& PeekNamedPipe (my_readsig, NULL, 0, NULL, &nb, NULL) && !nb) && PeekNamedPipe (my_readsig, NULL, 0, NULL, &nb, NULL) && !nb)
{ {
Sleep (GetTickCount () - t0 > 10 ? 1 : 0); yield ();
pack.si.si_signo = __SIGFLUSH; pack.si.si_signo = __SIGFLUSH;
} }
else if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL)) else if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL))
@ -1370,8 +1364,6 @@ wait_sig (VOID *)
system_printf ("garbled signal pipe data nb %u, sig %d", nb, pack.si.si_signo); system_printf ("garbled signal pipe data nb %u, sig %d", nb, pack.si.si_signo);
continue; continue;
} }
if (pack.si.si_signo != __SIGFLUSH)
t0 = GetTickCount ();
sigq.retry = false; sigq.retry = false;
/* Don't process signals when we start exiting */ /* Don't process signals when we start exiting */

View file

@ -1771,32 +1771,25 @@ Over-allocation on sparse files is entirely ignored on Windows.</para>
<para><function>sched_setpolicy</function> only emulates API behavior <para><function>sched_setpolicy</function> only emulates API behavior
because Windows does not offer alternative scheduling policies. because Windows does not offer alternative scheduling policies.
If <literal>SCHED_OTHER</literal> or <literal>SCHED_BATCH</literal> is If <literal>SCHED_OTHER</literal> is selected, the Windows priority is
selected, the Windows priority is set according to the nice value. set according to the nice value. If <literal>SCHED_FIFO</literal>
If <literal>SCHED_IDLE</literal> is selected, the Windows priority is or <literal>SCHED_RR</literal> is selected, the nice value is preserved
set to <literal>IDLE_PRIORITY_CLASS</literal>. and the Windows priority is set according to the
If <literal>SCHED_FIFO</literal> or <literal>SCHED_RR</literal> is <literal>sched_priority</literal> value.</para>
selected, the nice value is preserved and the Windows priority is set
according to the <literal>sched_priority</literal> value.
If the <literal>SCHED_RESET_ON_FORK</literal> flag is set, realtime
policies and negative nice values are dropped on
<function>fork</function>.</para>
<para><function>nice</function>, <function>setpriority</function>, <para><function>nice</function>, <function>setpriority</function>,
<function>sched_setparam</function> and <function>sched_setpolicy</function> <function>sched_setparam</function> and <function>sched_setpolicy</function>
map the nice value (<literal>SCHED_OTHER</literal>, map the nice value (<literal>SCHED_OTHER</literal>) or the
<literal>SCHED_BATCH</literal>) or the <literal>sched_priority</literal> <literal>sched_priority</literal> (<literal>SCHED_FIFO</literal>,
(<literal>SCHED_FIFO</literal>, <literal>SCHED_RR</literal>) to Windows <literal>SCHED_RR</literal>) to Windows priority classes as follows:</para>
priority classes as follows:</para>
<screen> <screen>
SCHED_OTHER SCHED_BATCH SCHED_FIFO/RR nice value sched_priority Windows priority class
nice value nice value sched_priority Windows priority class 12...19 1....6 IDLE_PRIORITY_CLASS
12...19 4...19 1....6 IDLE_PRIORITY_CLASS 4...11 7...12 BELOW_NORMAL_PRIORITY_CLASS
4...11 -4....3 7...12 BELOW_NORMAL_PRIORITY_CLASS -4....3 13...18 NORMAL_PRIORITY_CLASS
-4....3 -12...-5 13...18 NORMAL_PRIORITY_CLASS -12...-5 19...24 ABOVE_NORMAL_PRIORITY_CLASS
-12...-5 -13..-19 19...24 ABOVE_NORMAL_PRIORITY_CLASS -13..-19 25...30 HIGH_PRIORITY_CLASS
-13..-19 -20 25...30 HIGH_PRIORITY_CLASS -20 31...32 REALTIME_PRIORITY_CLASS
-20 - 31...32 REALTIME_PRIORITY_CLASS
</screen> </screen>
The use of values which are mapped to the The use of values which are mapped to the
<literal>REALTIME_PRIORITY_CLASS</literal> require administrative <literal>REALTIME_PRIORITY_CLASS</literal> require administrative