From e0dc827bf6e9882e1531905c61a00c83cc91359d Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 2 Feb 2023 00:27:26 +0100 Subject: hurd: Move some i386 bits to x86 As they will actually be usable on x86_64 too. --- sysdeps/mach/hurd/Makefile | 62 +++++++++++++ sysdeps/mach/hurd/i386/Makefile | 79 ---------------- sysdeps/mach/hurd/i386/ioperm.c | 53 ----------- sysdeps/mach/hurd/i386/sys/io.h | 177 ------------------------------------ sysdeps/mach/hurd/x86/Makefile | 16 ++++ sysdeps/mach/hurd/x86/ioperm.c | 53 +++++++++++ sysdeps/mach/hurd/x86/sys/io.h | 177 ++++++++++++++++++++++++++++++++++++ sysdeps/mach/i386/Implies | 1 + sysdeps/mach/i386/bits/mach/param.h | 25 ----- sysdeps/mach/i386/machine-lock.h | 79 ---------------- sysdeps/mach/i386/sysdep.h | 27 +----- sysdeps/mach/x86/bits/mach/param.h | 25 +++++ sysdeps/mach/x86/machine-lock.h | 79 ++++++++++++++++ sysdeps/mach/x86/sysdep.h | 47 ++++++++++ 14 files changed, 461 insertions(+), 439 deletions(-) delete mode 100644 sysdeps/mach/hurd/i386/ioperm.c delete mode 100644 sysdeps/mach/hurd/i386/sys/io.h create mode 100644 sysdeps/mach/hurd/x86/Makefile create mode 100644 sysdeps/mach/hurd/x86/ioperm.c create mode 100644 sysdeps/mach/hurd/x86/sys/io.h create mode 100644 sysdeps/mach/i386/Implies delete mode 100644 sysdeps/mach/i386/bits/mach/param.h delete mode 100644 sysdeps/mach/i386/machine-lock.h create mode 100644 sysdeps/mach/x86/bits/mach/param.h create mode 100644 sysdeps/mach/x86/machine-lock.h create mode 100644 sysdeps/mach/x86/sysdep.h diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index 76c2774ef0..d0e3da03ca 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -227,3 +227,65 @@ LDLIBS-pthread.so += $(objdir)/hurd/libhurduser.so LDLIBS-c_malloc_debug.so += $(link-rpcuserlibs) endif # in-Makerules + +# For bug 23286 +ifeq ($(subdir),hurd) +test-xfail-check-abi-libhurduser = yes +endif +ifeq ($(subdir),mach) +test-xfail-check-abi-libmachuser = yes +endif + +# For bug 25521 +# (setpshared support) +ifeq ($(subdir),malloc) +test-xfail-tst-mallocfork2 = yes +test-xfail-tst-mallocfork2-mcheck = yes +test-xfail-tst-mallocfork2-malloc-check = yes +test-xfail-tst-mallocfork2-malloc-hugetlb1 = yes +test-xfail-tst-mallocfork2-malloc-hugetlb2 = yes +endif +ifeq ($(subdir),htl) +test-xfail-tst-mutex4 = yes +test-xfail-tst-cancel16 = yes +test-xfail-tst-cancelx16 = yes +test-xfail-tst-cond4 = yes +test-xfail-tst-cond6 = yes +test-xfail-tst-cond12 = yes +test-xfail-tst-cond13 = yes +test-xfail-tst-cond23 = yes +test-xfail-tst-rwlock4 = yes +test-xfail-tst-rwlock12 = yes +test-xfail-tst-barrier2 = yes +test-xfail-tst-pututxline-cache = yes +test-xfail-tst-pututxline-lockfail = yes +test-xfail-tst-flock2 = yes +test-xfail-tst-signal1 = yes +test-xfail-tst-signal2 = yes +endif + +ifeq ($(subdir),htl) +# For bug 25522 +# (setprotocol support) +test-xfail-tst-cond24 = yes +test-xfail-tst-cond25 = yes + +# For bug 25563 +# (robust support against dead threads) +test-xfail-tst-robust1 = yes +test-xfail-tst-robust2 = yes +test-xfail-tst-robust3 = yes +test-xfail-tst-robust4 = yes +test-xfail-tst-robust5 = yes +test-xfail-tst-robust6 = yes +test-xfail-tst-robust7 = yes +test-xfail-tst-robust9 = yes +endif + +ifeq ($(subdir),elf) +# We do use nested functions involving creation of trampolines, notably for +# callbacks whose parameters don't permit to get the context parameters. +check-execstack-xfail += ld.so libc.so libpthread.so +# We always create a thread for signals +test-xfail-tst-single_threaded-pthread-static = yes +endif diff --git a/sysdeps/mach/hurd/i386/Makefile b/sysdeps/mach/hurd/i386/Makefile index ec58bb18f6..8fe93ef27a 100644 --- a/sysdeps/mach/hurd/i386/Makefile +++ b/sysdeps/mach/hurd/i386/Makefile @@ -1,16 +1,3 @@ -ifeq ($(subdir),misc) -sysdep_routines += ioperm -sysdep_headers += sys/io.h -endif - -ifeq ($(subdir),debug) -gen-as-const-headers += signal-defines.sym -endif - -ifeq ($(subdir),setjmp) -gen-as-const-headers += signal-defines.sym -endif - ifeq ($(subdir),csu) ifeq (yes,$(build-shared)) sysdep_routines += divdi3 @@ -24,69 +11,3 @@ ifeq ($(subdir),conform) # (type conformance) conformtest-xfail-conds += i386-gnu endif - -# For bug 23286 -ifeq ($(subdir),hurd) -test-xfail-check-abi-libhurduser = yes -endif -ifeq ($(subdir),mach) -test-xfail-check-abi-libmachuser = yes -endif - -# For bug 25521 -# (setpshared support) -ifeq ($(subdir),malloc) -test-xfail-tst-mallocfork2 = yes -test-xfail-tst-mallocfork2-mcheck = yes -test-xfail-tst-mallocfork2-malloc-check = yes -test-xfail-tst-mallocfork2-malloc-hugetlb1 = yes -test-xfail-tst-mallocfork2-malloc-hugetlb2 = yes -endif -ifeq ($(subdir),htl) -test-xfail-tst-mutex4 = yes -test-xfail-tst-cancel16 = yes -test-xfail-tst-cancelx16 = yes -test-xfail-tst-cond4 = yes -test-xfail-tst-cond6 = yes -test-xfail-tst-cond12 = yes -test-xfail-tst-cond13 = yes -test-xfail-tst-cond23 = yes -test-xfail-tst-rwlock4 = yes -test-xfail-tst-rwlock12 = yes -test-xfail-tst-barrier2 = yes -test-xfail-tst-pututxline-cache = yes -test-xfail-tst-pututxline-lockfail = yes -test-xfail-tst-flock2 = yes -test-xfail-tst-signal1 = yes -test-xfail-tst-signal2 = yes -endif - -ifeq ($(subdir),htl) -# For bug 25522 -# (setprotocol support) -test-xfail-tst-cond24 = yes -test-xfail-tst-cond25 = yes - -# For bug 25563 -# (robust support against dead threads) -test-xfail-tst-robust1 = yes -test-xfail-tst-robust2 = yes -test-xfail-tst-robust3 = yes -test-xfail-tst-robust4 = yes -test-xfail-tst-robust5 = yes -test-xfail-tst-robust6 = yes -test-xfail-tst-robust7 = yes -test-xfail-tst-robust9 = yes -endif - -ifeq ($(subdir),elf) -# We do use nested functions involving creation of trampolines, notably for -# callbacks whose parameters don't permit to get the context parameters. -check-execstack-xfail += ld.so libc.so libpthread.so -# We always create a thread for signals -test-xfail-tst-single_threaded-pthread-static = yes -endif - -ifeq ($(subdir),stdlib) -gen-as-const-headers += ucontext_i.sym -endif diff --git a/sysdeps/mach/hurd/i386/ioperm.c b/sysdeps/mach/hurd/i386/ioperm.c deleted file mode 100644 index 73b886b9c9..0000000000 --- a/sysdeps/mach/hurd/i386/ioperm.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Access to hardware i/o ports. Hurd/x86 version. - Copyright (C) 2002-2023 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, see - . */ - -#include -#include -#include - -int -ioperm (unsigned long int from, unsigned long int num, int turn_on) -{ -#if ! HAVE_I386_IO_PERM_MODIFY - return __hurd_fail (ENOSYS); -#else - error_t err; - device_t devmaster; - - /* With the device master port we get a capability that represents - this range of io ports. */ - err = __get_privileged_ports (NULL, &devmaster); - if (! err) - { - io_perm_t perm; - err = __i386_io_perm_create (devmaster, from, from + num - 1, &perm); - __mach_port_deallocate (__mach_task_self (), devmaster); - if (! err) - { - /* Now we add or remove that set from our task's bitmap. */ - err = __i386_io_perm_modify (__mach_task_self (), perm, turn_on); - __mach_port_deallocate (__mach_task_self (), perm); - } - - if (err == MIG_BAD_ID) /* Old kernels don't have these RPCs. */ - err = ENOSYS; - } - - return err ? __hurd_fail (err) : 0; -#endif -} diff --git a/sysdeps/mach/hurd/i386/sys/io.h b/sysdeps/mach/hurd/i386/sys/io.h deleted file mode 100644 index 87b5416cd5..0000000000 --- a/sysdeps/mach/hurd/i386/sys/io.h +++ /dev/null @@ -1,177 +0,0 @@ -/* Access to hardware i/o ports. GNU/x86 version. - Copyright (C) 2002-2023 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, see - . */ - -#ifndef _SYS_IO_H -#define _SYS_IO_H 1 - -#include - -__BEGIN_DECLS - -/* If TURN_ON is TRUE, request for permission to do direct i/o on the - port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O - permission off for that range. This call requires root privileges. */ -extern int ioperm (unsigned long int __from, unsigned long int __num, - int __turn_on) __THROW; - -/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to - access any I/O port is granted. This call requires root - privileges. */ -extern int iopl (int __level) __THROW; - -#if defined __GNUC__ && __GNUC__ >= 2 - -static __inline unsigned char -inb (unsigned short int port) -{ - unsigned char _v; - - __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline unsigned char -inb_p (unsigned short int port) -{ - unsigned char _v; - - __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline unsigned short int -inw (unsigned short int port) -{ - unsigned short _v; - - __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline unsigned short int -inw_p (unsigned short int port) -{ - unsigned short int _v; - - __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline unsigned int -inl (unsigned short int port) -{ - unsigned int _v; - - __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline unsigned int -inl_p (unsigned short int port) -{ - unsigned int _v; - __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); - return _v; -} - -static __inline void -outb (unsigned char value, unsigned short int port) -{ - __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); -} - -static __inline void -outb_p (unsigned char value, unsigned short int port) -{ - __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value), - "Nd" (port)); -} - -static __inline void -outw (unsigned short int value, unsigned short int port) -{ - __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); - -} - -static __inline void -outw_p (unsigned short int value, unsigned short int port) -{ - __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value), - "Nd" (port)); -} - -static __inline void -outl (unsigned int value, unsigned short int port) -{ - __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); -} - -static __inline void -outl_p (unsigned int value, unsigned short int port) -{ - __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value), - "Nd" (port)); -} - -static __inline void -insb (unsigned short int port, void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -static __inline void -insw (unsigned short int port, void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -static __inline void -insl (unsigned short int port, void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -static __inline void -outsb (unsigned short int port, const void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -static __inline void -outsw (unsigned short int port, const void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -static __inline void -outsl (unsigned short int port, const void *addr, unsigned long int count) -{ - __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr), - "=c" (count):"d" (port), "0" (addr), "1" (count)); -} - -#endif /* GNU C */ - -__END_DECLS -#endif /* _SYS_IO_H */ diff --git a/sysdeps/mach/hurd/x86/Makefile b/sysdeps/mach/hurd/x86/Makefile new file mode 100644 index 0000000000..29371f6c9a --- /dev/null +++ b/sysdeps/mach/hurd/x86/Makefile @@ -0,0 +1,16 @@ +ifeq ($(subdir),misc) +sysdep_routines += ioperm +sysdep_headers += sys/io.h +endif + +ifeq ($(subdir),debug) +gen-as-const-headers += signal-defines.sym +endif + +ifeq ($(subdir),setjmp) +gen-as-const-headers += signal-defines.sym +endif + +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif diff --git a/sysdeps/mach/hurd/x86/ioperm.c b/sysdeps/mach/hurd/x86/ioperm.c new file mode 100644 index 0000000000..73b886b9c9 --- /dev/null +++ b/sysdeps/mach/hurd/x86/ioperm.c @@ -0,0 +1,53 @@ +/* Access to hardware i/o ports. Hurd/x86 version. + Copyright (C) 2002-2023 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, see + . */ + +#include +#include +#include + +int +ioperm (unsigned long int from, unsigned long int num, int turn_on) +{ +#if ! HAVE_I386_IO_PERM_MODIFY + return __hurd_fail (ENOSYS); +#else + error_t err; + device_t devmaster; + + /* With the device master port we get a capability that represents + this range of io ports. */ + err = __get_privileged_ports (NULL, &devmaster); + if (! err) + { + io_perm_t perm; + err = __i386_io_perm_create (devmaster, from, from + num - 1, &perm); + __mach_port_deallocate (__mach_task_self (), devmaster); + if (! err) + { + /* Now we add or remove that set from our task's bitmap. */ + err = __i386_io_perm_modify (__mach_task_self (), perm, turn_on); + __mach_port_deallocate (__mach_task_self (), perm); + } + + if (err == MIG_BAD_ID) /* Old kernels don't have these RPCs. */ + err = ENOSYS; + } + + return err ? __hurd_fail (err) : 0; +#endif +} diff --git a/sysdeps/mach/hurd/x86/sys/io.h b/sysdeps/mach/hurd/x86/sys/io.h new file mode 100644 index 0000000000..87b5416cd5 --- /dev/null +++ b/sysdeps/mach/hurd/x86/sys/io.h @@ -0,0 +1,177 @@ +/* Access to hardware i/o ports. GNU/x86 version. + Copyright (C) 2002-2023 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, see + . */ + +#ifndef _SYS_IO_H +#define _SYS_IO_H 1 + +#include + +__BEGIN_DECLS + +/* If TURN_ON is TRUE, request for permission to do direct i/o on the + port numbers in the range [FROM,FROM+NUM-1]. Otherwise, turn I/O + permission off for that range. This call requires root privileges. */ +extern int ioperm (unsigned long int __from, unsigned long int __num, + int __turn_on) __THROW; + +/* Set the I/O privilege level to LEVEL. If LEVEL>3, permission to + access any I/O port is granted. This call requires root + privileges. */ +extern int iopl (int __level) __THROW; + +#if defined __GNUC__ && __GNUC__ >= 2 + +static __inline unsigned char +inb (unsigned short int port) +{ + unsigned char _v; + + __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned char +inb_p (unsigned short int port) +{ + unsigned char _v; + + __asm__ __volatile__ ("inb %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned short int +inw (unsigned short int port) +{ + unsigned short _v; + + __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned short int +inw_p (unsigned short int port) +{ + unsigned short int _v; + + __asm__ __volatile__ ("inw %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned int +inl (unsigned short int port) +{ + unsigned int _v; + + __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline unsigned int +inl_p (unsigned short int port) +{ + unsigned int _v; + __asm__ __volatile__ ("inl %w1,%0\noutb %%al,$0x80":"=a" (_v):"Nd" (port)); + return _v; +} + +static __inline void +outb (unsigned char value, unsigned short int port) +{ + __asm__ __volatile__ ("outb %b0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +outb_p (unsigned char value, unsigned short int port) +{ + __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (value), + "Nd" (port)); +} + +static __inline void +outw (unsigned short int value, unsigned short int port) +{ + __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port)); + +} + +static __inline void +outw_p (unsigned short int value, unsigned short int port) +{ + __asm__ __volatile__ ("outw %w0,%w1\noutb %%al,$0x80": :"a" (value), + "Nd" (port)); +} + +static __inline void +outl (unsigned int value, unsigned short int port) +{ + __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port)); +} + +static __inline void +outl_p (unsigned int value, unsigned short int port) +{ + __asm__ __volatile__ ("outl %0,%w1\noutb %%al,$0x80": :"a" (value), + "Nd" (port)); +} + +static __inline void +insb (unsigned short int port, void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; insb":"=D" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +static __inline void +insw (unsigned short int port, void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; insw":"=D" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +static __inline void +insl (unsigned short int port, void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; insl":"=D" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +static __inline void +outsb (unsigned short int port, const void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; outsb":"=S" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +static __inline void +outsw (unsigned short int port, const void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; outsw":"=S" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +static __inline void +outsl (unsigned short int port, const void *addr, unsigned long int count) +{ + __asm__ __volatile__ ("cld ; rep ; outsl":"=S" (addr), + "=c" (count):"d" (port), "0" (addr), "1" (count)); +} + +#endif /* GNU C */ + +__END_DECLS +#endif /* _SYS_IO_H */ diff --git a/sysdeps/mach/i386/Implies b/sysdeps/mach/i386/Implies new file mode 100644 index 0000000000..da8291f4c8 --- /dev/null +++ b/sysdeps/mach/i386/Implies @@ -0,0 +1 @@ +mach/x86 diff --git a/sysdeps/mach/i386/bits/mach/param.h b/sysdeps/mach/i386/bits/mach/param.h deleted file mode 100644 index 4d3ec5da36..0000000000 --- a/sysdeps/mach/i386/bits/mach/param.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Old-style Unix parameters and limits. i386 Mach version. - Copyright (C) 1993-2023 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, see - . */ - -#ifndef _SYS_PARAM_H -# error "Never use directly; include instead." -#endif - -#ifndef EXEC_PAGESIZE -#define EXEC_PAGESIZE 4096 -#endif diff --git a/sysdeps/mach/i386/machine-lock.h b/sysdeps/mach/i386/machine-lock.h deleted file mode 100644 index 53d2c95c40..0000000000 --- a/sysdeps/mach/i386/machine-lock.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Machine-specific definition for spin locks. i386 version. - Copyright (C) 1994-2023 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, see - . */ - -#ifndef _MACHINE_LOCK_H -#define _MACHINE_LOCK_H - -/* The type of a spin lock variable. */ - -typedef volatile int __spin_lock_t; - -/* Value to initialize `__spin_lock_t' variables to. */ - -#define __SPIN_LOCK_INITIALIZER 0 - - -#ifndef _EXTERN_INLINE -#define _EXTERN_INLINE __extern_inline -#endif - -/* Unlock LOCK. */ - -extern void __spin_unlock (__spin_lock_t *__lock); - -#if defined __USE_EXTERN_INLINES && defined _LIBC -_EXTERN_INLINE void -__spin_unlock (__spin_lock_t *__lock) -{ - register int __unlocked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) - : "memory"); -} -#endif - -/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ - -extern int __spin_try_lock (__spin_lock_t *__lock); - -#if defined __USE_EXTERN_INLINES && defined _LIBC -_EXTERN_INLINE int -__spin_try_lock (__spin_lock_t *__lock) -{ - register int __locked; - __asm__ __volatile ("xchgl %0, %1" - : "=&r" (__locked), "=m" (*__lock) : "0" (1) - : "memory"); - return !__locked; -} -#endif - -/* Return nonzero if LOCK is locked. */ - -extern int __spin_lock_locked (__spin_lock_t *__lock); - -#if defined __USE_EXTERN_INLINES && defined _LIBC -_EXTERN_INLINE int -__spin_lock_locked (__spin_lock_t *__lock) -{ - return *__lock != 0; -} -#endif - - -#endif /* machine-lock.h */ diff --git a/sysdeps/mach/i386/sysdep.h b/sysdeps/mach/i386/sysdep.h index 19eab418a7..33bd5ee402 100644 --- a/sysdeps/mach/i386/sysdep.h +++ b/sysdeps/mach/i386/sysdep.h @@ -19,37 +19,12 @@ #ifndef _MACH_I386_SYSDEP_H #define _MACH_I386_SYSDEP_H 1 -/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ -#include -#include - -#define LOSE asm volatile ("hlt") - -#define SNARF_ARGS(entry_sp, argc, argv, envp) \ - do \ - { \ - char **p; \ - argc = (int) *entry_sp; \ - argv = (char **) (entry_sp + 1); \ - p = argv; \ - while (*p++ != NULL) \ - ; \ - if (p >= (char **) argv[0]) \ - --p; \ - envp = p; \ - } while (0) +#include #define RETURN_TO(sp, pc, retval) \ asm volatile ("movl %0, %%esp; jmp %*%1 # %2" \ : : "g" (sp), "r" (pc), "a" (retval)) - -#define STACK_GROWTH_DOWN - -/* Get the machine-independent Mach definitions. */ -#include - - /* This should be rearranged, but at the moment this file provides the most useful definitions for assembler syntax details. */ #undef ENTRY diff --git a/sysdeps/mach/x86/bits/mach/param.h b/sysdeps/mach/x86/bits/mach/param.h new file mode 100644 index 0000000000..cef2bdb165 --- /dev/null +++ b/sysdeps/mach/x86/bits/mach/param.h @@ -0,0 +1,25 @@ +/* Old-style Unix parameters and limits. x86 Mach version. + Copyright (C) 1993-2023 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, see + . */ + +#ifndef _SYS_PARAM_H +# error "Never use directly; include instead." +#endif + +#ifndef EXEC_PAGESIZE +#define EXEC_PAGESIZE 4096 +#endif diff --git a/sysdeps/mach/x86/machine-lock.h b/sysdeps/mach/x86/machine-lock.h new file mode 100644 index 0000000000..6ce884a8c3 --- /dev/null +++ b/sysdeps/mach/x86/machine-lock.h @@ -0,0 +1,79 @@ +/* Machine-specific definition for spin locks. x86 version. + Copyright (C) 1994-2023 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, see + . */ + +#ifndef _MACHINE_LOCK_H +#define _MACHINE_LOCK_H + +/* The type of a spin lock variable. */ + +typedef volatile int __spin_lock_t; + +/* Value to initialize `__spin_lock_t' variables to. */ + +#define __SPIN_LOCK_INITIALIZER 0 + + +#ifndef _EXTERN_INLINE +#define _EXTERN_INLINE __extern_inline +#endif + +/* Unlock LOCK. */ + +extern void __spin_unlock (__spin_lock_t *__lock); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +_EXTERN_INLINE void +__spin_unlock (__spin_lock_t *__lock) +{ + register int __unlocked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__unlocked), "=m" (*__lock) : "0" (0) + : "memory"); +} +#endif + +/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */ + +extern int __spin_try_lock (__spin_lock_t *__lock); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +_EXTERN_INLINE int +__spin_try_lock (__spin_lock_t *__lock) +{ + register int __locked; + __asm__ __volatile ("xchgl %0, %1" + : "=&r" (__locked), "=m" (*__lock) : "0" (1) + : "memory"); + return !__locked; +} +#endif + +/* Return nonzero if LOCK is locked. */ + +extern int __spin_lock_locked (__spin_lock_t *__lock); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +_EXTERN_INLINE int +__spin_lock_locked (__spin_lock_t *__lock) +{ + return *__lock != 0; +} +#endif + + +#endif /* machine-lock.h */ diff --git a/sysdeps/mach/x86/sysdep.h b/sysdeps/mach/x86/sysdep.h new file mode 100644 index 0000000000..90f295b27d --- /dev/null +++ b/sysdeps/mach/x86/sysdep.h @@ -0,0 +1,47 @@ +/* Copyright (C) 1991-2023 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, see + . */ + +#ifndef _MACH_X86_SYSDEP_H +#define _MACH_X86_SYSDEP_H 1 + +/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ +#include +#include + +#define LOSE asm volatile ("hlt") + +#define SNARF_ARGS(entry_sp, argc, argv, envp) \ + do \ + { \ + char **p; \ + argc = (int) *entry_sp; \ + argv = (char **) (entry_sp + 1); \ + p = argv; \ + while (*p++ != NULL) \ + ; \ + if (p >= (char **) argv[0]) \ + --p; \ + envp = p; \ + } while (0) + +#define STACK_GROWTH_DOWN + +/* Get the machine-independent Mach definitions. */ +#include + +#endif /* mach/x86/sysdep.h */ -- cgit v1.2.1