Re: bug#11437: coreutils: Please disable misc/nice test on hurd-i386]
Eric Blake, le Tue 08 May 2012 12:54:08 -0600, a écrit : > On 05/08/2012 12:39 PM, Samuel Thibault wrote: > > The misc/nice test currently fails on hurd-i386 because the nice support > > there is not precise enough: the Mach kernel, which handles scheduling > > priorities, has only 32 priority levels, and not 40, so conversion is > > used, but that becomes not precise enough for the misc/nice test. Apart > > from that, the nice tool works fine. Could you disable that test on > > hurd-i386? > > What is the mapping between the kernel's 32 levels and the > POSIX-mandated minimum of 40 niceness levels (that is, which niceness > levels are rounded to a neighbor)? Can we rewrite the test to use just > niceness levels provided by Hurd? It's a simple factor 2: #define MACH_PRIORITY_TO_NICE(prio) (2 * ((prio) - 12)) #define NICE_TO_MACH_PRIORITY(nice) (12 + ((nice) / 2)) > In fact, > if you could track 64 niceness levels, and just have every pair of > niceness levels map to the kernel priorities, then you would be > POSIX-compliant (POSIX doesn't require that niceness level 0 and 1 have > any difference in scheduling, only that you can have niceness levels > between 0 and 2*NZERO-1). Right, but that'd means that libc has to remember all priorities, to be able to return them, including other processes (it's not only about nice, but also get/setpriority). OTOH, we could as well extend mach's priorities to 40 levels and change the mappping. The only issue with that is that when using a patched libc (using >32 priority values) with a non-patched kernel (refusing them), some nice values will be refused by kernel. Maybe we can consider it's not a problem that people have to upgrade their kernel to fix it. Samuel
[PATCH,HURD] Add TLS support
This adds TLS support to GNU/HURD. Using it to replace threadvar will be part of another patch. I had to separate the thread state with segments from the thread state without segments: each thread has its own gs segment, which needs to be inherited across fork, etc. I also had to fix some initialization order. 2009-07-30 Samuel Thibault * sysdeps/mach/hurd/bits/libc-lock.h [_LIBC - 0]: Include * sysdeps/mach/hurd/tls.h: Include and * include/errno.h (__GNU__): Do not define TLS errno for now. * sysdeps/generic/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New macro. * sysdeps/mach/thread_state.h (MACHINE_THREAD_STATE_FIX_NEW): New macro. * sysdeps/mach/i386/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to i386_THREAD_STATE. (MACHINE_THREAD_STATE_FLAVOR): Define to i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. (MACHINE_THREAD_STATE_FIX_NEW): New macro, reads segments. * sysdeps/mach/powerpc/thread_state.h (MACHINE_NEW_THREAD_STATE_FLAVOR): New macro, defined to PPC_THREAD_STATE. * sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Use i386_REGS_SEGS_STATE instead of i386_THREAD_STATE. * sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Use kern_return_t error type. Use first GDT slot, 0x48. (_hurd_tls_fork): Use kern_return_t error type. Duplicate existing LDT descriptor instead of creating a new one. (_hurd_tls_new): New function, creates a new descriptor and updates tcb. * mach/mach.h (__mach_setup_tls,mach_setup_tls): Add declarations. * mach/setup-thread.c: Include . (__mach_setup_thread): Use MACHINE_NEW_THREAD_STATE_FLAVOR instead of MACHINE_THREAD_STATE_FLAVOR. (__mach_setup_tls): New function. * hurd/hurdfault.c (_hurdsig_fault_init): Call MACHINE_THREAD_STATE_FIX_NEW. * sysdeps/mach/hurd/profil.c (update_waiter): Call __mach_setup_tls. * sysdeps/mach/hurd/setitimer.c (setitimer_locked): Call __mach_setup_tls. * hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls. * sysdeps/mach/hurd/fork.c (__fork): Call _hurd_tls_fork for sigthread. Pass kernel thread to _hurd_tls_fork. * sysdeps/mach/hurd/i386/init-first.c (init): Move ELF header parsing after getting up the environment pointer. Call __pthread_initialize_minimal. * csu/libc-start.c (LIBC_START_MAIN) [__GNU__]: Do not call __pthread_initialize_minimal. --- csu/libc-start.c|2 ++ hurd/hurdfault.c|2 ++ hurd/hurdsig.c |2 ++ include/errno.h | 14 + mach/mach.h |3 ++ mach/setup-thread.c | 30 +- sysdeps/generic/thread_state.h |1 + sysdeps/mach/hurd/bits/libc-lock.h |3 ++ sysdeps/mach/hurd/fork.c|7 - sysdeps/mach/hurd/i386/init-first.c | 59 ++- sysdeps/mach/hurd/i386/tls.h| 53 +-- sysdeps/mach/hurd/i386/trampoline.c |2 +- sysdeps/mach/hurd/profil.c |2 ++ sysdeps/mach/hurd/setitimer.c |3 +- sysdeps/mach/hurd/tls.h |6 +++- sysdeps/mach/i386/thread_state.h| 11 ++- sysdeps/mach/powerpc/thread_state.h |1 + sysdeps/mach/thread_state.h |3 ++ 18 files changed, 160 insertions(+), 44 deletions(-) diff --git a/csu/libc-start.c b/csu/libc-start.c index 0f9bfd7..dcf2bac 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -139,10 +139,12 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), /* Performe IREL{,A} relocations. */ __libc_csu_irel (); +#ifndef __GNU__ /* Initialize the thread library at least a bit since the libgcc functions are using thread functions if these are available and we need to setup errno. */ __pthread_initialize_minimal (); +#endif /* Set up the stack checker's canary. */ uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (_dl_random); diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c index e2891d1..3990f90 100644 --- a/hurd/hurdfault.c +++ b/hurd/hurdfault.c @@ -205,6 +205,8 @@ _hurdsig_fault_init (void) /* This state will be restored when we fault. It runs the function above. */ memset (&state, 0, sizeof state); + + MACHINE_THREAD_STATE_FIX_NEW (&state); MACHINE_THREAD_STATE_SET_PC (&state, faulted); MACHINE_THREAD_STATE_SET_SP (&state, faultstack, sizeof faultstack); diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index e1e0919..9e8485a 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -1267,6 +1267,8 @@ _hurdsig_init (const int *intarray, size_t intarraysize) (vm_address_t *) &__hurd_sigthread_stack_base,
[PATCH,HURD] Add SysV SHM support
2005-07-11 Marcus Brinkmann * hurd/Makefile (routines): Add sysvshm. (distribute): Add sysvshm.h. * hurd/sysvshm.h: New file. * hurd/sysvshm.c: New file. * sysdeps/mach/hurd/bits/stat.h (S_IMMAP0): New macro. (S_ISPARE): Unset the S_IMMAP0 flag. * sysdeps/mach/hurd/ftok.c: New file. * sysdeps/mach/hurd/shmat.c: New file. * sysdeps/mach/hurd/shmctl.c: New file. * sysdeps/mach/hurd/shmdt.c: New file. * sysdeps/mach/hurd/bits/posix_opt.h: Define _XOPEN_SHM to 1. --- hurd/Makefile |3 +- hurd/sysvshm.c | 96 ++ hurd/sysvshm.h | 47 +++ sysdeps/mach/hurd/bits/posix_opt.h |2 + sysdeps/mach/hurd/ftok.c | 43 +++ sysdeps/mach/hurd/shmat.c | 78 sysdeps/mach/hurd/shmctl.c | 132 sysdeps/mach/hurd/shmdt.c | 51 sysdeps/mach/hurd/shmget.c | 242 9 files changed, 693 insertions(+), 1 deletion(-) diff --git a/hurd/Makefile b/hurd/Makefile index bdad4ff..4f74ccc 100644 --- a/hurd/Makefile +++ b/hurd/Makefile @@ -59,6 +59,7 @@ routines = hurdstartup hurdinit \ vpprintf \ ports-get ports-set hurdports hurdmsg \ errno-loc \ + sysvshm \ $(sig) $(dtable) $(inlines) port-cleanup report-wait xattr sig= hurdsig hurdfault siginfo hurd-raise preempt-sig \ trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \ @@ -67,7 +68,7 @@ dtable= dtable port2fd new-fd alloc-fd intern-fd \ getdport openport \ fd-close fd-read fd-write hurdioctl ctty-input ctty-output inlines = $(inline-headers:%.h=%-inlines) -distribute = hurdstartup.h hurdfault.h hurdhost.h \ +distribute = hurdstartup.h hurdfault.h hurdhost.h sysvshm.h \ faultexc.defs intr-rpc.defs intr-rpc.h intr-msg.h Notes # XXX this is a temporary hack; see hurdmalloc.h diff --git a/hurd/sysvshm.c b/hurd/sysvshm.c new file mode 100644 index 000..292cc01 --- /dev/null +++ b/hurd/sysvshm.c @@ -0,0 +1,96 @@ +/* Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Description of an shm attachment. */ +struct sysvshm_attach +{ + /* Linked list. */ + struct sysvshm_attach *next; + + /* Map address. */ + void *addr; + + /* Map size. */ + size_t size; +}; + +/* List of attachments. */ +static struct sysvshm_attach *attach_list; + +/* A lock to protect the linked list of shared memory attachments. */ +static struct mutex sysvshm_lock = MUTEX_INITIALIZER; + + +/* Adds a segment attachment. */ +error_t +__sysvshm_add (void *addr, size_t size) +{ + struct sysvshm_attach *shm; + + shm = malloc (sizeof (*shm)); + if (!shm) +return errno; + + __mutex_lock (&sysvshm_lock); + shm->addr = addr; + shm->size = size; + shm->next = attach_list; + attach_list = shm; + __mutex_unlock (&sysvshm_lock); + + return 0; +} + +/* Removes a segment attachment. Returns its size if found, or EINVAL + otherwise. */ +error_t +__sysvshm_remove (void *addr, size_t *size) +{ + struct sysvshm_attach *shm; + struct sysvshm_attach **pshm = &attach_list; + + __mutex_lock (&sysvshm_lock); + shm = attach_list; + while (shm) +{ + shm = *pshm; + if (shm->addr == addr) + { + *pshm = shm->next; + *size = shm->size; + __mutex_unlock (&sysvshm_lock); + return 0; + } + pshm = &shm->next; + shm = shm->next; +} + __mutex_unlock (&sysvshm_lock); + return EINVAL; +} diff --git a/hurd/sysvshm.h b/hurd/sysvshm.h new file mode 100644 index 000..0c561c8 --- /dev/null +++ b/hurd/sysvshm.h @@ -0,0 +1,47 @@ +/* Copyright (C) 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foun
Re: [PATCH,HURD] Add SysV SHM support
On Sat, 12 May 2012, Samuel Thibault wrote: > 2005-07-11 Marcus Brinkmann > > * hurd/Makefile (routines): Add sysvshm. > (distribute): Add sysvshm.h. We no longer have "distribute" settings in makefiles. Patches submitted for inclusion should be against current glibc (apply cleanly there) > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, write to the Free > + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA > + 02111-1307 USA. */ All glibc files should now use URLs instead of FSF postal addresses, unless they are imported verbatim from another project without glibc-local modifications (in which case they keep the notice in the form it's in in that project). -- Joseph S. Myers jos...@codesourcery.com
Re: nanosleep modifying second parameter on success
Simon Josefsson, le Thu 04 Aug 2011 12:10:43 +0200, a écrit : > As reported as 2) in this mail: > > https://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00027.html > > it seems the nanosleep function modifies the second parameter on > success. > > This behaviour doesn't seem consistent with the specification at > > http://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html > > It seems the second parameter should not be modified unless the call > fails with EINTR, right? As a followup to an very old mail: Pino fixed the issue, patch is pending upload of the debian package. Samuel
Re: link(dir,name) should fail with EPERM
Hello, Eric Blake, le Tue 01 Mar 2011 16:30:04 -0700, a écrit : > POSIX states that this should fail with EPERM, not EISDIR: > > $ mkdir d > $ link d c > > This was detected by the gnulib testsuite; I've since updated that > testsuite to tolerate Hurd's current behavior, but it might be worth > updating link(2) to comply with the standard. Indeed, now fixed upstream, thanks! Samuel