authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-15 00:22:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-15 14:30:03-07:00
log19ca2415f26b07b399a60fd17a4cf85f290da0fd
treedbbd6affde21ad2a59b2b2e1f4d7948e21133a13
parent1edf8efa4243eb1715ace35b1a99f7eaa0863fdd

update glibc start files to 2.34

This commit introduces tools/update_glibc.zig to update the start files for next time. Some notable changes in recent glibc: * abi-note.S has been changed to abi-note.c but we resist the change to keep it easier to compile the start files. * elf-init.c has been deleted upstream. Further testing should be done to verify that binaries against glibc omitting elf-init.c still run properly on oldel glibc linux systems. Closes #4926

295 files changed, 4070 insertions(+), 8630 deletions(-)

lib/libc/glibc/bits/byteswap.h+1-1
......@@ -1,5 +1,5 @@
11/* Macros and inline functions to swap the order of bytes in integer values.
2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/floatn-common.h+1-1
......@@ -1,6 +1,6 @@
11/* Macros to control TS 18661-3 glibc features where the same
22 definitions are appropriate for all platforms.
3 Copyright (C) 2017-2020 Free Software Foundation, Inc.
3 Copyright (C) 2017-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/libc-header-start.h+27-3
......@@ -1,5 +1,5 @@
11/* Handle feature test macros at the start of a header.
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
2 Copyright (C) 2016-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -44,8 +44,26 @@
4444
4545/* ISO/IEC TS 18661-1:2014 defines the __STDC_WANT_IEC_60559_BFP_EXT__
4646 macro. Most but not all symbols enabled by that macro in TS
47 18661-1 are enabled unconditionally in C2X; the symbols in Annex F
48 still require that macro in C2X. */
47 18661-1 are enabled unconditionally in C2X. In C2X, the symbols in
48 Annex F still require a new feature test macro
49 __STDC_WANT_IEC_60559_EXT__ instead (C2X does not define
50 __STDC_WANT_IEC_60559_BFP_EXT__), while a few features from TS
51 18661-1 are not included in C2X (and thus should depend on
52 __STDC_WANT_IEC_60559_BFP_EXT__ even when C2X features are
53 enabled).
54
55 __GLIBC_USE (IEC_60559_BFP_EXT) controls those features from TS
56 18661-1 not included in C2X.
57
58 __GLIBC_USE (IEC_60559_BFP_EXT_C2X) controls those features from TS
59 18661-1 that are also included in C2X (with no feature test macro
60 required in C2X).
61
62 __GLIBC_USE (IEC_60559_EXT) controls those features from TS 18661-1
63 that are included in C2X but conditional on
64 __STDC_WANT_IEC_60559_EXT__. (There are currently no features
65 conditional on __STDC_WANT_IEC_60559_EXT__ that are not in TS
66 18661-1.) */
4967#undef __GLIBC_USE_IEC_60559_BFP_EXT
5068#if defined __USE_GNU || defined __STDC_WANT_IEC_60559_BFP_EXT__
5169# define __GLIBC_USE_IEC_60559_BFP_EXT 1
......@@ -58,6 +76,12 @@
5876#else
5977# define __GLIBC_USE_IEC_60559_BFP_EXT_C2X 0
6078#endif
79#undef __GLIBC_USE_IEC_60559_EXT
80#if __GLIBC_USE (IEC_60559_BFP_EXT) || defined __STDC_WANT_IEC_60559_EXT__
81# define __GLIBC_USE_IEC_60559_EXT 1
82#else
83# define __GLIBC_USE_IEC_60559_EXT 0
84#endif
6185
6286/* ISO/IEC TS 18661-4:2015 defines the
6387 __STDC_WANT_IEC_60559_FUNCS_EXT__ macro. Other than the reduction
lib/libc/glibc/bits/long-double.h+15-2
......@@ -1,5 +1,5 @@
11/* Properties of long double type.
2 Copyright (C) 2016-2020 Free Software Foundation, Inc.
2 Copyright (C) 2016-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -37,4 +37,17 @@
3737#ifndef __NO_LONG_DOUBLE_MATH
3838# define __NO_LONG_DOUBLE_MATH 1
3939#endif
40#define __LONG_DOUBLE_USES_FLOAT128 0
40
41/* The macro __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI is used to determine the
42 choice of the underlying ABI of long double. It will always assume
43 a constant value for each translation unit.
44
45 If the value is non-zero, any API which is parameterized by the long
46 double type (i.e the scanf/printf family of functions or the explicitly
47 parameterized math.h functions) will be redirected to a compatible
48 implementation using _Float128 ABI via symbols suffixed with ieee128.
49
50 The mechanism this macro uses to acquire may be a function
51 of architecture, or target specific options used to invoke the
52 compiler. */
53#define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0
lib/libc/glibc/bits/select.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/signum-generic.h+4-25
......@@ -1,5 +1,5 @@
11/* Signal number constants. Generic template.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -57,31 +57,9 @@
5757#define SIGQUIT 3 /* Quit. */
5858#define SIGTRAP 5 /* Trace/breakpoint trap. */
5959#define SIGKILL 9 /* Killed. */
60#define SIGBUS 10 /* Bus error. */
61#define SIGSYS 12 /* Bad system call. */
6260#define SIGPIPE 13 /* Broken pipe. */
6361#define SIGALRM 14 /* Alarm clock. */
6462
65/* New(er) POSIX signals (1003.1-2008, 1003.1-2013). */
66#define SIGURG 16 /* Urgent data is available at a socket. */
67#define SIGSTOP 17 /* Stop, unblockable. */
68#define SIGTSTP 18 /* Keyboard stop. */
69#define SIGCONT 19 /* Continue. */
70#define SIGCHLD 20 /* Child terminated or stopped. */
71#define SIGTTIN 21 /* Background read from control terminal. */
72#define SIGTTOU 22 /* Background write to control terminal. */
73#define SIGPOLL 23 /* Pollable event occurred (System V). */
74#define SIGXCPU 24 /* CPU time limit exceeded. */
75#define SIGXFSZ 25 /* File size limit exceeded. */
76#define SIGVTALRM 26 /* Virtual timer expired. */
77#define SIGPROF 27 /* Profiling timer expired. */
78#define SIGUSR1 30 /* User-defined signal 1. */
79#define SIGUSR2 31 /* User-defined signal 2. */
80
81/* Nonstandard signals found in all modern POSIX systems
82 (including both BSD and Linux). */
83#define SIGWINCH 28 /* Window size change (4.3 BSD, Sun). */
84
8563/* Archaic names for compatibility. */
8664#define SIGIO SIGPOLL /* I/O now possible (4.2 BSD). */
8765#define SIGIOT SIGABRT /* IOT instruction, abort() on a PDP-11. */
......@@ -93,8 +71,9 @@
9371 but some real-time signals may be used internally by glibc. Do not
9472 use these constants in application code; use SIGRTMIN and SIGRTMAX
9573 (defined in signal.h) instead. */
96#define __SIGRTMIN 32
97#define __SIGRTMAX __SIGRTMIN
74
75/* Include system specific bits. */
76#include <bits/signum-arch.h>
9877
9978/* Biggest signal number + 1 (including real-time signals). */
10079#define _NSIG (__SIGRTMAX + 1)
lib/libc/glibc/bits/stat.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/stdint-intn.h+1-1
......@@ -1,5 +1,5 @@
11/* Define intN_t types.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/stdlib-bsearch.h+1-1
......@@ -1,5 +1,5 @@
11/* Perform binary search - inline version.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/time64.h+1-1
......@@ -1,5 +1,5 @@
11/* bits/time64.h -- underlying types for __time64_t. Generic version.
2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/timesize.h+1-1
......@@ -1,5 +1,5 @@
11/* Bit size of the time_t type at glibc build time, general case.
2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/types/struct_sched_param.h+1-1
......@@ -1,5 +1,5 @@
11/* Sched parameter structure. Generic version.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/typesizes.h+8-1
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. Generic version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -50,6 +50,7 @@
5050#define __TIME_T_TYPE __SLONGWORD_TYPE
5151#define __USECONDS_T_TYPE __U32_TYPE
5252#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __SUSECONDS64_T_TYPE __SQUAD_TYPE
5354#define __DADDR_T_TYPE __S32_TYPE
5455#define __KEY_T_TYPE __S32_TYPE
5556#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -75,10 +76,16 @@
7576
7677/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
7778# define __STATFS_MATCHES_STATFS64 1
79
80/* And for getitimer, setitimer and rusage */
81# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
7882#else
7983# define __RLIM_T_MATCHES_RLIM64_T 0
8084
8185# define __STATFS_MATCHES_STATFS64 0
86
87/* And for getitimer, setitimer and rusage */
88# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
8289#endif
8390
8491/* Number of descriptors that can fit in an `fd_set'. */
lib/libc/glibc/bits/uintn-identity.h+1-1
......@@ -1,5 +1,5 @@
11/* Inline functions to return unsigned integer values unchanged.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/bits/waitflags.h+9-1
......@@ -1,5 +1,5 @@
11/* Definitions of flag bits for `waitpid' et al.
2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 Copyright (C) 1992-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -24,3 +24,11 @@
2424/* Bits in the third argument to `waitpid'. */
2525#define WNOHANG 1 /* Don't block waiting. */
2626#define WUNTRACED 2 /* Report status of stopped children. */
27
28/* Bits in the fourth argument to `waitid'. */
29#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K8
30# define WSTOPPED WUNTRACED /* Report stopped child. */
31# define WCONTINUED 4 /* Report continued child. */
32# define WNOWAIT 8 /* Don't reap, just poll status. */
33# define WEXITED 16 /* Report dead child. */
34#endif
lib/libc/glibc/bits/waitstatus.h+1-1
......@@ -1,5 +1,5 @@
11/* Definitions of status bits for `wait' et al.
2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 Copyright (C) 1992-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/csu/elf-init.c deleted-106
......@@ -1,106 +0,0 @@
1/* Startup support for ELF initializers/finalizers in the main executable.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36#include <stddef.h>
37
38
39/* These magic symbols are provided by the linker. */
40extern void (*__preinit_array_start []) (int, char **, char **)
41 attribute_hidden;
42extern void (*__preinit_array_end []) (int, char **, char **)
43 attribute_hidden;
44extern void (*__init_array_start []) (int, char **, char **)
45 attribute_hidden;
46extern void (*__init_array_end []) (int, char **, char **)
47 attribute_hidden;
48extern void (*__fini_array_start []) (void) attribute_hidden;
49extern void (*__fini_array_end []) (void) attribute_hidden;
50
51
52#ifndef NO_INITFINI
53/* These function symbols are provided for the .init/.fini section entry
54 points automagically by the linker. */
55extern void _init (void);
56extern void _fini (void);
57#endif
58
59
60/* These functions are passed to __libc_start_main by the startup code.
61 These get statically linked into each program. For dynamically linked
62 programs, this module will come from libc_nonshared.a and differs from
63 the libc.a module in that it doesn't call the preinit array. */
64
65
66void
67__libc_csu_init (int argc, char **argv, char **envp)
68{
69 /* For dynamically linked executables the preinit array is executed by
70 the dynamic linker (before initializing any shared object). */
71
72#ifndef LIBC_NONSHARED
73 /* For static executables, preinit happens right before init. */
74 {
75 const size_t size = __preinit_array_end - __preinit_array_start;
76 size_t i;
77 for (i = 0; i < size; i++)
78 (*__preinit_array_start [i]) (argc, argv, envp);
79 }
80#endif
81
82#ifndef NO_INITFINI
83 _init ();
84#endif
85
86 const size_t size = __init_array_end - __init_array_start;
87 for (size_t i = 0; i < size; i++)
88 (*__init_array_start [i]) (argc, argv, envp);
89}
90
91/* This function should not be used anymore. We run the executable's
92 destructor now just like any other. We cannot remove the function,
93 though. */
94void
95__libc_csu_fini (void)
96{
97#ifndef LIBC_NONSHARED
98 size_t i = __fini_array_end - __fini_array_start;
99 while (i-- > 0)
100 (*__fini_array_start [i]) ();
101
102# ifndef NO_INITFINI
103 _fini ();
104# endif
105#endif
106}
lib/libc/glibc/csu/errno.c created+35
......@@ -0,0 +1,35 @@
1/* Definition of `errno' variable. Canonical version.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <errno.h>
20#include <tls.h>
21#include <dl-sysdep.h>
22#undef errno
23
24#if RTLD_PRIVATE_ERRNO
25
26/* Code compiled for rtld refers only to this name. */
27int rtld_errno attribute_hidden;
28
29#else
30
31__thread int errno;
32extern __thread int __libc_errno __attribute__ ((alias ("errno")))
33 attribute_hidden;
34
35#endif
lib/libc/glibc/debug/stack_chk_fail_local.c+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/elf/elf.h+108-35
......@@ -1,5 +1,5 @@
11/* This file defines standard ELF types, structures, and macros.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -19,10 +19,6 @@
1919#ifndef _ELF_H
2020#define _ELF_H 1
2121
22#include <features.h>
23
24__BEGIN_DECLS
25
2622/* Standard ELF types. */
2723
2824#include <stdint.h>
......@@ -322,7 +318,7 @@ typedef struct
322318 /* reserved 184 */
323319#define EM_AVR32 185 /* Amtel 32-bit microprocessor */
324320#define EM_STM8 186 /* STMicroelectronics STM8 */
325#define EM_TILE64 187 /* Tileta TILE64 */
321#define EM_TILE64 187 /* Tilera TILE64 */
326322#define EM_TILEPRO 188 /* Tilera TILEPro */
327323#define EM_MICROBLAZE 189 /* Xilinx MicroBlaze */
328324#define EM_CUDA 190 /* NVIDIA CUDA */
......@@ -330,7 +326,7 @@ typedef struct
330326#define EM_CLOUDSHIELD 192 /* CloudShield */
331327#define EM_COREA_1ST 193 /* KIPO-KAIST Core-A 1st gen. */
332328#define EM_COREA_2ND 194 /* KIPO-KAIST Core-A 2nd gen. */
333#define EM_ARC_COMPACT2 195 /* Synopsys ARCompact V2 */
329#define EM_ARCV2 195 /* Synopsys ARCv2 ISA. */
334330#define EM_OPEN8 196 /* Open8 RISC */
335331#define EM_RL78 197 /* Renesas RL78 */
336332#define EM_VIDEOCORE5 198 /* Broadcom VideoCore V */
......@@ -340,7 +336,8 @@ typedef struct
340336#define EM_BA2 202 /* Beyond BA2 */
341337#define EM_XCORE 203 /* XMOS xCORE */
342338#define EM_MCHP_PIC 204 /* Microchip 8-bit PIC(r) */
343 /* reserved 205-209 */
339#define EM_INTELGT 205 /* Intel Graphics Technology */
340 /* reserved 206-209 */
344341#define EM_KM32 210 /* KM211 KM32 */
345342#define EM_KMX32 211 /* KM211 KMX32 */
346343#define EM_EMX16 212 /* KM211 KMX16 */
......@@ -445,7 +442,7 @@ typedef struct
445442#define SHT_FINI_ARRAY 15 /* Array of destructors */
446443#define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */
447444#define SHT_GROUP 17 /* Section group */
448#define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */
445#define SHT_SYMTAB_SHNDX 18 /* Extended section indices */
449446#define SHT_NUM 19 /* Number of defined types. */
450447#define SHT_LOOS 0x60000000 /* Start OS-specific. */
451448#define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes. */
......@@ -482,6 +479,7 @@ typedef struct
482479#define SHF_COMPRESSED (1 << 11) /* Section with compressed data. */
483480#define SHF_MASKOS 0x0ff00000 /* OS-specific. */
484481#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
482#define SHF_GNU_RETAIN (1 << 21) /* Not to be GCed by linker. */
485483#define SHF_ORDERED (1 << 30) /* Special ordering requirement
486484 (Solaris). */
487485#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless
......@@ -721,6 +719,7 @@ typedef struct
721719#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
722720#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
723721#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
722#define PT_GNU_PROPERTY 0x6474e553 /* GNU property */
724723#define PT_LOSUNW 0x6ffffffa
725724#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
726725#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
......@@ -815,6 +814,10 @@ typedef struct
815814 address keys. */
816815#define NT_ARM_PACG_KEYS 0x408 /* ARM pointer authentication
817816 generic key. */
817#define NT_ARM_TAGGED_ADDR_CTRL 0x409 /* AArch64 tagged address
818 control. */
819#define NT_ARM_PAC_ENABLED_KEYS 0x40a /* AArch64 pointer authentication
820 enabled keys. */
818821#define NT_VMCOREDD 0x700 /* Vmcore Device Dump Note. */
819822#define NT_MIPS_DSP 0x800 /* MIPS DSP ASE registers. */
820823#define NT_MIPS_FP_MODE 0x801 /* MIPS floating-point mode. */
......@@ -1049,7 +1052,7 @@ typedef struct
10491052#define VER_NDX_LORESERVE 0xff00 /* Beginning of reserved entries. */
10501053#define VER_NDX_ELIMINATE 0xff01 /* Symbol is to be eliminated. */
10511054
1052/* Auxialiary version information. */
1055/* Auxiliary version information. */
10531056
10541057typedef struct
10551058{
......@@ -1318,33 +1321,34 @@ typedef struct
13181321/* Application-specific semantics, hi */
13191322#define GNU_PROPERTY_HIUSER 0xffffffff
13201323
1324/* AArch64 specific GNU properties. */
1325#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
1326
1327#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1U << 0)
1328#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1U << 1)
1329
13211330/* The x86 instruction sets indicated by the corresponding bits are
13221331 used in program. Their support in the hardware is optional. */
1323#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000
1332#define GNU_PROPERTY_X86_ISA_1_USED 0xc0010002
13241333/* The x86 instruction sets indicated by the corresponding bits are
13251334 used in program and they must be supported by the hardware. */
1326#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001
1335#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0008002
13271336/* X86 processor-specific features used in program. */
13281337#define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002
13291338
1330#define GNU_PROPERTY_X86_ISA_1_486 (1U << 0)
1331#define GNU_PROPERTY_X86_ISA_1_586 (1U << 1)
1332#define GNU_PROPERTY_X86_ISA_1_686 (1U << 2)
1333#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 3)
1334#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 4)
1335#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 5)
1336#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 6)
1337#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 7)
1338#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 8)
1339#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 9)
1340#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 10)
1341#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 11)
1342#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 12)
1343#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 13)
1344#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 14)
1345#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 15)
1346#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 16)
1347#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17)
1339/* GNU_PROPERTY_X86_ISA_1_BASELINE: CMOV, CX8 (cmpxchg8b), FPU (fld),
1340 MMX, OSFXSR (fxsave), SCE (syscall), SSE and SSE2. */
1341#define GNU_PROPERTY_X86_ISA_1_BASELINE (1U << 0)
1342/* GNU_PROPERTY_X86_ISA_1_V2: GNU_PROPERTY_X86_ISA_1_BASELINE,
1343 CMPXCHG16B (cmpxchg16b), LAHF-SAHF (lahf), POPCNT (popcnt), SSE3,
1344 SSSE3, SSE4.1 and SSE4.2. */
1345#define GNU_PROPERTY_X86_ISA_1_V2 (1U << 1)
1346/* GNU_PROPERTY_X86_ISA_1_V3: GNU_PROPERTY_X86_ISA_1_V2, AVX, AVX2, BMI1,
1347 BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE. */
1348#define GNU_PROPERTY_X86_ISA_1_V3 (1U << 2)
1349/* GNU_PROPERTY_X86_ISA_1_V4: GNU_PROPERTY_X86_ISA_1_V3, AVX512F,
1350 AVX512BW, AVX512CD, AVX512DQ and AVX512VL. */
1351#define GNU_PROPERTY_X86_ISA_1_V4 (1U << 3)
13481352
13491353/* This indicates that all executable sections are compatible with
13501354 IBT. */
......@@ -2136,9 +2140,9 @@ enum
21362140#define EFA_PARISC_1_1 0x0210 /* PA-RISC 1.1 big-endian. */
21372141#define EFA_PARISC_2_0 0x0214 /* PA-RISC 2.0 big-endian. */
21382142
2139/* Additional section indeces. */
2143/* Additional section indices. */
21402144
2141#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tenatively declared
2145#define SHN_PARISC_ANSI_COMMON 0xff00 /* Section for tentatively declared
21422146 symbols in ANSI C. */
21432147#define SHN_PARISC_HUGE_COMMON 0xff01 /* Common blocks in huge model. */
21442148
......@@ -2868,6 +2872,8 @@ enum
28682872#define R_AARCH64_IRELATIVE 1032 /* STT_GNU_IFUNC relocation. */
28692873
28702874/* AArch64 specific values for the Dyn d_tag field. */
2875#define DT_AARCH64_BTI_PLT (DT_LOPROC + 1)
2876#define DT_AARCH64_PAC_PLT (DT_LOPROC + 3)
28712877#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5)
28722878#define DT_AARCH64_NUM 6
28732879
......@@ -3946,8 +3952,9 @@ enum
39463952#define R_RISCV_SET16 55
39473953#define R_RISCV_SET32 56
39483954#define R_RISCV_32_PCREL 57
3955#define R_RISCV_IRELATIVE 58
39493956
3950#define R_RISCV_NUM 58
3957#define R_RISCV_NUM 59
39513958
39523959/* BPF specific declarations. */
39533960
......@@ -3964,7 +3971,7 @@ enum
39643971#define R_METAG_RELBRANCH 4
39653972#define R_METAG_GETSETOFF 5
39663973
3967/* Backward compatability */
3974/* Backward compatibility */
39683975#define R_METAG_REG32OP1 6
39693976#define R_METAG_REG32OP2 7
39703977#define R_METAG_REG32OP3 8
......@@ -4027,6 +4034,72 @@ enum
40274034#define R_NDS32_TLS_TPOFF 102
40284035#define R_NDS32_TLS_DESC 119
40294036
4030__END_DECLS
4037/* ARCompact/ARCv2 specific relocs. */
4038#define R_ARC_NONE 0x0
4039#define R_ARC_8 0x1
4040#define R_ARC_16 0x2
4041#define R_ARC_24 0x3
4042#define R_ARC_32 0x4
4043#define R_ARC_B26 0x5
4044#define R_ARC_B22_PCREL 0x6
4045#define R_ARC_H30 0x7
4046#define R_ARC_N8 0x8
4047#define R_ARC_N16 0x9
4048#define R_ARC_N24 0xA
4049#define R_ARC_N32 0xB
4050#define R_ARC_SDA 0xC
4051#define R_ARC_SECTOFF 0xD
4052#define R_ARC_S21H_PCREL 0xE
4053#define R_ARC_S21W_PCREL 0xF
4054#define R_ARC_S25H_PCREL 0x10
4055#define R_ARC_S25W_PCREL 0x11
4056#define R_ARC_SDA32 0x12
4057#define R_ARC_SDA_LDST 0x13
4058#define R_ARC_SDA_LDST1 0x14
4059#define R_ARC_SDA_LDST2 0x15
4060#define R_ARC_SDA16_LD 0x16
4061#define R_ARC_SDA16_LD1 0x17
4062#define R_ARC_SDA16_LD2 0x18
4063#define R_ARC_S13_PCREL 0x19
4064#define R_ARC_W 0x1A
4065#define R_ARC_32_ME 0x1B
4066#define R_ARC_N32_ME 0x1C
4067#define R_ARC_SECTOFF_ME 0x1D
4068#define R_ARC_SDA32_ME 0x1E
4069#define R_ARC_W_ME 0x1F
4070#define R_ARC_H30_ME 0x20
4071#define R_ARC_SECTOFF_U8 0x21
4072#define R_ARC_SECTOFF_S9 0x22
4073#define R_AC_SECTOFF_U8 0x23
4074#define R_AC_SECTOFF_U8_1 0x24
4075#define R_AC_SECTOFF_U8_2 0x25
4076#define R_AC_SECTOFF_S9 0x26
4077#define R_AC_SECTOFF_S9_1 0x27
4078#define R_AC_SECTOFF_S9_2 0x28
4079#define R_ARC_SECTOFF_ME_1 0x29
4080#define R_ARC_SECTOFF_ME_2 0x2A
4081#define R_ARC_SECTOFF_1 0x2B
4082#define R_ARC_SECTOFF_2 0x2C
4083#define R_ARC_PC32 0x32
4084#define R_ARC_GOTPC32 0x33
4085#define R_ARC_PLT32 0x34
4086#define R_ARC_COPY 0x35
4087#define R_ARC_GLOB_DAT 0x36
4088#define R_ARC_JUMP_SLOT 0x37
4089#define R_ARC_RELATIVE 0x38
4090#define R_ARC_GOTOFF 0x39
4091#define R_ARC_GOTPC 0x3A
4092#define R_ARC_GOT32 0x3B
4093
4094#define R_ARC_TLS_DTPMOD 0x42
4095#define R_ARC_TLS_DTPOFF 0x43
4096#define R_ARC_TLS_TPOFF 0x44
4097#define R_ARC_TLS_GD_GOT 0x45
4098#define R_ARC_TLS_GD_LD 0x46
4099#define R_ARC_TLS_GD_CALL 0x47
4100#define R_ARC_TLS_IE_GOT 0x48
4101#define R_ARC_TLS_DTPOFF_S9 0x4a
4102#define R_ARC_TLS_LE_S9 0x4a
4103#define R_ARC_TLS_LE_32 0x4b
40314104
40324105#endif /* elf.h */
lib/libc/glibc/include/bits/cpu-set.h+8
......@@ -1 +1,9 @@
1#ifndef _BITS_CPU_SET_H
12#include <posix/bits/cpu-set.h>
3
4#ifndef _ISOMAC
5int __sched_cpucount (size_t __setsize, const cpu_set_t *__setp);
6libc_hidden_proto (__sched_cpucount)
7#endif
8
9#endif /* _BITS_CPU_SET_H */
lib/libc/glibc/include/errno.h created+45
......@@ -0,0 +1,45 @@
1#ifndef _ERRNO_H
2#include <stdlib/errno.h>
3#if !defined _ISOMAC && !defined __ASSEMBLER__
4
5# if IS_IN (rtld)
6# include <dl-sysdep.h>
7# ifndef RTLD_PRIVATE_ERRNO
8# error "dl-sysdep.h must define RTLD_PRIVATE_ERRNO!"
9# endif
10# else
11# define RTLD_PRIVATE_ERRNO 0
12# endif
13
14# if RTLD_PRIVATE_ERRNO
15/* The dynamic linker uses its own private errno variable.
16 All access to errno inside the dynamic linker is serialized,
17 so a single (hidden) global variable is all it needs. */
18
19# undef errno
20# define errno rtld_errno
21extern int rtld_errno attribute_hidden;
22
23# elif IS_IN_LIB && !IS_IN (rtld)
24
25# undef errno
26# if IS_IN (libc)
27# define errno __libc_errno
28# else
29# define errno errno /* For #ifndef errno tests. */
30# endif
31extern __thread int errno attribute_tls_model_ie;
32
33# endif /* IS_IN_LIB */
34
35# define __set_errno(val) (errno = (val))
36
37extern int *__errno_location (void) __THROW __attribute_const__
38# if RTLD_PRIVATE_ERRNO
39 attribute_hidden
40# endif
41;
42libc_hidden_proto (__errno_location)
43
44#endif /* !_ISOMAC && !__ASSEMBLER__ */
45#endif /* !_ERRNO_H */
lib/libc/glibc/include/features.h+25-2
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -33,6 +33,8 @@
3333 Extensions to ISO C11 from TS 18661-4:2015.
3434 __STDC_WANT_IEC_60559_TYPES_EXT__
3535 Extensions to ISO C11 from TS 18661-3:2015.
36 __STDC_WANT_IEC_60559_EXT__
37 ISO C2X interfaces defined only in Annex F.
3638
3739 _POSIX_SOURCE IEEE Std 1003.1.
3840 _POSIX_C_SOURCE If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
......@@ -48,6 +50,8 @@
4850 _LARGEFILE64_SOURCE Additional functionality from LFS for large files.
4951 _FILE_OFFSET_BITS=N Select default filesystem interface.
5052 _ATFILE_SOURCE Additional *at interfaces.
53 _DYNAMIC_STACK_SIZE_SOURCE Select correct (but non compile-time constant)
54 MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
5155 _GNU_SOURCE All of the above, plus GNU extensions.
5256 _DEFAULT_SOURCE The default set of features (taking precedence over
5357 __STRICT_ANSI__).
......@@ -94,6 +98,8 @@
9498 __USE_FILE_OFFSET64 Define 64bit interface as default.
9599 __USE_MISC Define things from 4.3BSD or System V Unix.
96100 __USE_ATFILE Define *at interfaces and AT_* constants for them.
101 __USE_DYNAMIC_STACK_SIZE Define correct (but non compile-time constant)
102 MINSIGSTKSZ, SIGSTKSZ and PTHREAD_STACK_MIN.
97103 __USE_GNU Define GNU extensions.
98104 __USE_FORTIFY_LEVEL Additional security measures used, according to level.
99105
......@@ -137,6 +143,7 @@
137143#undef __USE_FILE_OFFSET64
138144#undef __USE_MISC
139145#undef __USE_ATFILE
146#undef __USE_DYNAMIC_STACK_SIZE
140147#undef __USE_GNU
141148#undef __USE_FORTIFY_LEVEL
142149#undef __KERNEL_STRICT_NAMES
......@@ -213,6 +220,8 @@
213220# define _DEFAULT_SOURCE 1
214221# undef _ATFILE_SOURCE
215222# define _ATFILE_SOURCE 1
223# undef _DYNAMIC_STACK_SIZE_SOURCE
224# define _DYNAMIC_STACK_SIZE_SOURCE 1
216225#endif
217226
218227/* If nothing (other than _GNU_SOURCE and _DEFAULT_SOURCE) is defined,
......@@ -380,6 +389,8 @@
380389# define __USE_FILE_OFFSET64 1
381390#endif
382391
392#include <features-time64.h>
393
383394#if defined _DEFAULT_SOURCE
384395# define __USE_MISC 1
385396#endif
......@@ -388,6 +399,10 @@
388399# define __USE_ATFILE 1
389400#endif
390401
402#ifdef _DYNAMIC_STACK_SIZE_SOURCE
403# define __USE_DYNAMIC_STACK_SIZE 1
404#endif
405
391406#ifdef _GNU_SOURCE
392407# define __USE_GNU 1
393408#endif
......@@ -397,7 +412,15 @@
397412# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
398413# elif !__GNUC_PREREQ (4, 1)
399414# warning _FORTIFY_SOURCE requires GCC 4.1 or later
415# elif _FORTIFY_SOURCE > 2 && __glibc_clang_prereq (9, 0)
416# if _FORTIFY_SOURCE > 3
417# warning _FORTIFY_SOURCE > 3 is treated like 3 on this platform
418# endif
419# define __USE_FORTIFY_LEVEL 3
400420# elif _FORTIFY_SOURCE > 1
421# if _FORTIFY_SOURCE > 2
422# warning _FORTIFY_SOURCE > 2 is treated like 2 on this platform
423# endif
401424# define __USE_FORTIFY_LEVEL 2
402425# else
403426# define __USE_FORTIFY_LEVEL 1
......@@ -454,7 +477,7 @@
454477/* Major and minor version number of the GNU C library package. Use
455478 these macros to test for features in specific releases. */
456479#define __GLIBC__ 2
457#define __GLIBC_MINOR__ 31
480#define __GLIBC_MINOR__ 34
458481
459482#define __GLIBC_PREREQ(maj, min) \
460483 ((__GLIBC__ << 16) + __GLIBC_MINOR__ >= ((maj) << 16) + (min))
lib/libc/glibc/include/libc-pointer-arith.h+4-1
......@@ -1,5 +1,5 @@
11/* Helper macros for pointer arithmetic.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -37,6 +37,9 @@
3737/* Cast an integer or a pointer VAL to integer with proper type. */
3838# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
3939
40/* Cast an integer VAL to void * pointer. */
41# define cast_to_pointer(val) ((void *) (uintptr_t) (val))
42
4043/* Align a value by rounding down to closest size.
4144 e.g. Using size of 4096, we get this behavior:
4245 {4095, 4096, 4097} = {0, 4096, 4096}. */
lib/libc/glibc/include/libc-symbols.h+62-83
......@@ -1,6 +1,6 @@
11/* Support macros for making weak and strong aliases for symbols,
22 and for using symbol sets and linker warnings with GNU ld.
3 Copyright (C) 1995-2020 Free Software Foundation, Inc.
3 Copyright (C) 1995-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -84,6 +84,9 @@
8484
8585#include <config.h>
8686
87/* Obtain the definition of symbol_version_reference. */
88#include <libc-symver.h>
89
8790/* When PIC is defined and SHARED isn't defined, we are building PIE
8891 by default. */
8992#if defined PIC && !defined SHARED
......@@ -307,7 +310,7 @@ for linking")
307310
308311/* Resource freeing functions from libc.so go in this section. */
309312#define __libc_freeres_fn_section \
310 __attribute__ ((section ("__libc_freeres_fn")))
313 __attribute__ ((__used__, section ("__libc_freeres_fn")))
311314
312315/* Resource freeing functions for libc.so. */
313316#define libc_freeres_fn(name) \
......@@ -349,6 +352,12 @@ for linking")
349352
350353*/
351354
355#ifdef HAVE_GNU_RETAIN
356# define attribute_used_retain __attribute__ ((__used__, __retain__))
357#else
358# define attribute_used_retain __attribute__ ((__used__))
359#endif
360
352361/* Symbol set support macros. */
353362
354363/* Make SYMBOL, which is in the text segment, an element of SET. */
......@@ -364,12 +373,12 @@ for linking")
364373/* When building a shared library, make the set section writable,
365374 because it will need to be relocated at run time anyway. */
366375# define _elf_set_element(set, symbol) \
367 static const void *__elf_set_##set##_element_##symbol##__ \
368 __attribute__ ((used, section (#set))) = &(symbol)
376 static const void *__elf_set_##set##_element_##symbol##__ \
377 attribute_used_retain __attribute__ ((section (#set))) = &(symbol)
369378#else
370379# define _elf_set_element(set, symbol) \
371 static const void *const __elf_set_##set##_element_##symbol##__ \
372 __attribute__ ((used, section (#set))) = &(symbol)
380 static const void *const __elf_set_##set##_element_##symbol##__ \
381 attribute_used_retain __attribute__ ((section (#set))) = &(symbol)
373382#endif
374383
375384/* Define SET as a symbol set. This may be required (it is in a.out) to
......@@ -396,32 +405,27 @@ for linking")
396405 past the last element in SET. */
397406#define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set)
398407
399/* Use symbol_version_reference to specify the version a symbol
400 reference should link to. Use symbol_version or
401 default_symbol_version for the definition of a versioned symbol.
402 The difference is that the latter is a no-op in non-shared
403 builds. */
404#ifdef __ASSEMBLER__
405# define symbol_version_reference(real, name, version) \
406 .symver real, name##@##version
407#else /* !__ASSEMBLER__ */
408# define symbol_version_reference(real, name, version) \
409 __asm__ (".symver " #real "," #name "@" #version)
410#endif
411
412408#ifdef SHARED
413409# define symbol_version(real, name, version) \
414410 symbol_version_reference(real, name, version)
415411# define default_symbol_version(real, name, version) \
416412 _default_symbol_version(real, name, version)
413/* See <libc-symver.h>. */
417414# ifdef __ASSEMBLER__
418415# define _default_symbol_version(real, name, version) \
419 .symver real, name##@##@##version
416 _set_symbol_version (real, name@@version)
420417# else
421418# define _default_symbol_version(real, name, version) \
422 __asm__ (".symver " #real "," #name "@@" #version)
419 _set_symbol_version (real, #name "@@" #version)
423420# endif
424#else
421
422/* Evalutes to a string literal for VERSION in LIB. */
423# define symbol_version_string(lib, version) \
424 _symbol_version_stringify_1 (VERSION_##lib##_##version)
425# define _symbol_version_stringify_1(arg) _symbol_version_stringify_2 (arg)
426# define _symbol_version_stringify_2(arg) #arg
427
428#else /* !SHARED */
425429# define symbol_version(real, name, version)
426430# define default_symbol_version(real, name, version) \
427431 strong_alias(real, name)
......@@ -618,12 +622,7 @@ for linking")
618622# define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
619623# define libc_hidden_def(name) hidden_def (name)
620624# define libc_hidden_weak(name) hidden_weak (name)
621# ifdef LINK_OBSOLETE_RPC
622 /* libc_hidden_nolink_sunrpc should only get used in sunrpc code. */
623# define libc_hidden_nolink_sunrpc(name, version) hidden_def (name)
624# else
625# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
626# endif
625# define libc_hidden_nolink_sunrpc(name, version) hidden_nolink (name, libc, version)
627626# define libc_hidden_ver(local, name) hidden_ver (local, name)
628627# define libc_hidden_data_def(name) hidden_data_def (name)
629628# define libc_hidden_tls_def(name) hidden_tls_def (name)
......@@ -641,7 +640,7 @@ for linking")
641640# define libc_hidden_data_ver(local, name)
642641#endif
643642
644#if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
643#if IS_IN (rtld)
645644# define rtld_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
646645# define rtld_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
647646# define rtld_hidden_def(name) hidden_def (name)
......@@ -730,6 +729,29 @@ for linking")
730729# define libresolv_hidden_data_ver(local, name)
731730#endif
732731
732#if IS_IN (libpthread)
733# define libpthread_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
734# define libpthread_hidden_tls_proto(name, attrs...) \
735 hidden_tls_proto (name, ##attrs)
736# define libpthread_hidden_def(name) hidden_def (name)
737# define libpthread_hidden_weak(name) hidden_weak (name)
738# define libpthread_hidden_ver(local, name) hidden_ver (local, name)
739# define libpthread_hidden_data_def(name) hidden_data_def (name)
740# define libpthread_hidden_tls_def(name) hidden_tls_def (name)
741# define libpthread_hidden_data_weak(name) hidden_data_weak (name)
742# define libpthread_hidden_data_ver(local, name) hidden_data_ver (local, name)
743#else
744# define libpthread_hidden_proto(name, attrs...)
745# define libpthread_hidden_tls_proto(name, attrs...)
746# define libpthread_hidden_def(name)
747# define libpthread_hidden_weak(name)
748# define libpthread_hidden_ver(local, name)
749# define libpthread_hidden_data_def(name)
750# define libpthread_hidden_tls_def(name)
751# define libpthread_hidden_data_weak(name)
752# define libpthread_hidden_data_ver(local, name)
753#endif
754
733755#if IS_IN (librt)
734756# define librt_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
735757# define librt_hidden_tls_proto(name, attrs...) \
......@@ -776,40 +798,11 @@ for linking")
776798# define libdl_hidden_data_ver(local, name)
777799#endif
778800
779#if IS_IN (libnss_files)
780# define libnss_files_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
781# define libnss_files_hidden_tls_proto(name, attrs...) \
782 hidden_tls_proto (name, ##attrs)
783# define libnss_files_hidden_def(name) hidden_def (name)
784# define libnss_files_hidden_weak(name) hidden_weak (name)
785# define libnss_files_hidden_ver(local, name) hidden_ver (local, name)
786# define libnss_files_hidden_data_def(name) hidden_data_def (name)
787# define libnss_files_hidden_tls_def(name) hidden_tls_def (name)
788# define libnss_files_hidden_data_weak(name) hidden_data_weak (name)
789# define libnss_files_hidden_data_ver(local, name) hidden_data_ver(local, name)
790#else
791# define libnss_files_hidden_proto(name, attrs...)
792# define libnss_files_hidden_tls_proto(name, attrs...)
793# define libnss_files_hidden_def(name)
794# define libnss_files_hidden_weak(name)
795# define libnss_files_hidden_ver(local, name)
796# define libnss_files_hidden_data_def(name)
797# define libnss_files_hidden_tls_def(name)
798# define libnss_files_hidden_data_weak(name)
799# define libnss_files_hidden_data_ver(local, name)
800#endif
801
802801#if IS_IN (libnsl)
803802# define libnsl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
804803# define libnsl_hidden_tls_proto(name, attrs...) \
805804 hidden_tls_proto (name, ##attrs)
806# ifdef LINK_OBSOLETE_NSL
807 /* libnsl_hidden_nolink should only get used in libnsl code. */
808# define libnsl_hidden_nolink_def(name, version) libnsl_hidden_def (name)
809# else
810# define libnsl_hidden_nolink_def(name, version) hidden_nolink (name, libnsl, version)
811# endif
812# define libnsl_hidden_def(name) hidden_def (name)
805# define libnsl_hidden_nolink_def(name, version) hidden_nolink (name, libnsl, version)
813806# define libnsl_hidden_weak(name) hidden_weak (name)
814807# define libnsl_hidden_ver(local, name) hidden_ver (local, name)
815808# define libnsl_hidden_data_def(name) hidden_data_def (name)
......@@ -819,7 +812,6 @@ for linking")
819812#else
820813# define libnsl_hidden_proto(name, attrs...)
821814# define libnsl_hidden_tls_proto(name, attrs...)
822# define libnsl_hidden_def(name)
823815# define libnsl_hidden_weak(name)
824816# define libnsl_hidden_ver(local, name)
825817# define libnsl_hidden_data_def(name)
......@@ -828,33 +820,12 @@ for linking")
828820# define libnsl_hidden_data_ver(local, name)
829821#endif
830822
831#if IS_IN (libnss_nisplus)
832# define libnss_nisplus_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
833# define libnss_nisplus_hidden_tls_proto(name, attrs...) \
834 hidden_tls_proto (name, ##attrs)
835# define libnss_nisplus_hidden_def(name) hidden_def (name)
836# define libnss_nisplus_hidden_weak(name) hidden_weak (name)
837# define libnss_nisplus_hidden_ver(local, name) hidden_ver (local, name)
838# define libnss_nisplus_hidden_data_def(name) hidden_data_def (name)
839# define libnss_nisplus_hidden_tls_def(name) hidden_tls_def (name)
840# define libnss_nisplus_hidden_data_weak(name) hidden_data_weak (name)
841# define libnss_nisplus_hidden_data_ver(local, name) hidden_data_ver (local, name)
842#else
843# define libnss_nisplus_hidden_proto(name, attrs...)
844# define libnss_nisplus_hidden_tls_proto(name, attrs...)
845# define libnss_nisplus_hidden_def(name)
846# define libnss_nisplus_hidden_weak(name)
847# define libnss_nisplus_hidden_ver(local, name)
848# define libnss_nisplus_hidden_data_def(name)
849# define libnss_nisplus_hidden_tls_def(name)
850# define libnss_nisplus_hidden_data_weak(name)
851# define libnss_nisplus_hidden_data_ver(local, name)
852#endif
853
854823#define libc_hidden_builtin_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
855824#define libc_hidden_builtin_def(name) libc_hidden_def (name)
856825#define libc_hidden_builtin_weak(name) libc_hidden_weak (name)
857826#define libc_hidden_builtin_ver(local, name) libc_hidden_ver (local, name)
827
828#define libc_hidden_ldbl_proto(name, attrs...) libc_hidden_proto (name, ##attrs)
858829#ifdef __ASSEMBLER__
859830# define HIDDEN_BUILTIN_JUMPTARGET(name) HIDDEN_JUMPTARGET(name)
860831#endif
......@@ -882,6 +853,14 @@ for linking")
882853# define libutil_hidden_data_ver(local, name)
883854#endif
884855
856#if IS_IN (libanl)
857# define libanl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
858# define libanl_hidden_def(name) hidden_def (name)
859#else
860# define libanl_hidden_proto(name, attrs...)
861# define libanl_hidden_def(name)
862#endif
863
885864/* Get some dirty hacks. */
886865#include <symbol-hacks.h>
887866
lib/libc/glibc/include/pthread.h+11
......@@ -8,9 +8,20 @@ extern int __pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
88 const pthread_barrierattr_t *__restrict
99 __attr, unsigned int __count)
1010 __THROW __nonnull ((1));
11#if PTHREAD_IN_LIBC
12libc_hidden_proto (__pthread_barrier_init)
13#endif
1114extern int __pthread_barrier_wait (pthread_barrier_t *__barrier)
1215 __THROWNL __nonnull ((1));
16#if PTHREAD_IN_LIBC
17libc_hidden_proto (__pthread_barrier_wait)
18#endif
1319
1420/* This function is called to initialize the pthread library. */
1521extern void __pthread_initialize (void) __attribute__ ((weak));
22
23extern int __pthread_kill (pthread_t threadid, int signo);
24
25extern pthread_t __pthread_self (void);
26
1627#endif
lib/libc/glibc/include/signal.h+15-2
......@@ -2,6 +2,8 @@
22# include <signal/signal.h>
33
44# ifndef _ISOMAC
5# include <sigsetops.h>
6
57libc_hidden_proto (sigemptyset)
68libc_hidden_proto (sigfillset)
79libc_hidden_proto (sigaddset)
......@@ -12,7 +14,10 @@ libc_hidden_proto (__sigpause)
1214libc_hidden_proto (raise)
1315libc_hidden_proto (__libc_current_sigrtmin)
1416libc_hidden_proto (__libc_current_sigrtmax)
15libc_hidden_proto (_sys_siglist)
17extern const char * const __sys_siglist[_NSIG];
18libc_hidden_proto (__sys_siglist)
19extern const char * const __sys_sigabbrev[_NSIG];
20libc_hidden_proto (__sys_sigabbrev)
1621
1722/* Now define the internal interfaces. */
1823extern __sighandler_t __bsd_signal (int __sig, __sighandler_t __handler);
......@@ -33,6 +38,14 @@ extern int __sigwait (const sigset_t *__set, int *__sig);
3338libc_hidden_proto (__sigwait)
3439extern int __sigwaitinfo (const sigset_t *__set, siginfo_t *__info);
3540libc_hidden_proto (__sigwaitinfo)
41#if __TIMESIZE == 64
42# define __sigtimedwait64 __sigtimedwait
43#else
44# include <struct___timespec64.h>
45extern int __sigtimedwait64 (const sigset_t *__set, siginfo_t *__info,
46 const struct __timespec64 *__timeout);
47libc_hidden_proto (__sigtimedwait64)
48#endif
3649extern int __sigtimedwait (const sigset_t *__set, siginfo_t *__info,
3750 const struct timespec *__timeout);
3851libc_hidden_proto (__sigtimedwait)
......@@ -54,7 +67,7 @@ extern int __xpg_sigpause (int sig);
5467/* Allocate real-time signal with highest/lowest available priority. */
5568extern int __libc_allocate_rtsig (int __high);
5669
57# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
70# if IS_IN (rtld)
5871extern __typeof (__sigaction) __sigaction attribute_hidden;
5972extern __typeof (__libc_sigaction) __libc_sigaction attribute_hidden;
6073# endif
lib/libc/glibc/include/stap-probe.h+1-1
......@@ -1,5 +1,5 @@
11/* Macros for defining Systemtap <sys/sdt.h> static probe points.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/include/stdc-predef.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/include/stdlib.h+20-5
......@@ -3,12 +3,23 @@
33#ifndef _ISOMAC
44# include <stddef.h>
55#endif
6
7/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++. */
8#include <bits/floatn.h>
9#if defined __cplusplus && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
10# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
11# pragma GCC system_header
12# endif
13#endif
14
615#include <stdlib/stdlib.h>
716
817/* Now define the internal interfaces. */
918#if !defined _ISOMAC
1019# include <sys/stat.h>
1120
21# include <rtld-malloc.h>
22
1223extern __typeof (strtol_l) __strtol_l;
1324extern __typeof (strtoul_l) __strtoul_l;
1425extern __typeof (strtoll_l) __strtoll_l;
......@@ -80,6 +91,7 @@ extern int __setenv (const char *__name, const char *__value, int __replace)
8091extern int __unsetenv (const char *__name) attribute_hidden;
8192extern int __clearenv (void) attribute_hidden;
8293extern char *__mktemp (char *__template) __THROW __nonnull ((1));
94libc_hidden_proto (__mktemp)
8395extern char *__canonicalize_file_name (const char *__name);
8496extern char *__realpath (const char *__name, char *__resolved);
8597libc_hidden_proto (__realpath)
......@@ -125,6 +137,12 @@ libc_hidden_proto (__libc_reallocarray)
125137
126138extern int __libc_system (const char *line);
127139
140extern __typeof (getpt) __getpt;
141extern __typeof (ptsname_r) __ptsname_r;
142libc_hidden_proto (__getpt)
143libc_hidden_proto (__ptsname_r)
144libc_hidden_proto (grantpt)
145libc_hidden_proto (unlockpt)
128146
129147extern double __strtod_internal (const char *__restrict __nptr,
130148 char **__restrict __endptr, int __group)
......@@ -205,7 +223,7 @@ libc_hidden_proto (____strtoull_l_internal)
205223#include <bits/floatn.h>
206224libc_hidden_proto (strtof)
207225libc_hidden_proto (strtod)
208#if __LONG_DOUBLE_USES_FLOAT128 == 0
226#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0
209227libc_hidden_proto (strtold)
210228#endif
211229libc_hidden_proto (strtol)
......@@ -288,9 +306,6 @@ libc_hidden_proto (__qfcvt_r)
288306# define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX))
289307# endif
290308
291extern void *__default_morecore (ptrdiff_t) __THROW;
292libc_hidden_proto (__default_morecore)
293
294309struct abort_msg_s
295310{
296311 unsigned int size;
......@@ -299,7 +314,7 @@ struct abort_msg_s
299314extern struct abort_msg_s *__abort_msg;
300315libc_hidden_proto (__abort_msg)
301316
302# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
317# if IS_IN (rtld)
303318extern __typeof (unsetenv) unsetenv attribute_hidden;
304319extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
305320# endif
lib/libc/glibc/include/struct___timespec64.h created+27
......@@ -0,0 +1,27 @@
1#ifndef _STRUCT_TIMESPEC64_H
2#define _STRUCT_TIMESPEC64_H
3
4#if __TIMESIZE == 64
5# define __timespec64 timespec
6#else
7#include <endian.h>
8/* The glibc Y2038-proof struct __timespec64 structure for a time value.
9 To keep things Posix-ish, we keep the nanoseconds field a 32-bit
10 signed long, but since the Linux field is a 64-bit signed int, we
11 pad our tv_nsec with a 32-bit unnamed bit-field padding.
12
13 As a general rule the Linux kernel is ignoring upper 32 bits of
14 tv_nsec field. */
15struct __timespec64
16{
17 __time64_t tv_sec; /* Seconds */
18# if BYTE_ORDER == BIG_ENDIAN
19 __int32_t :32; /* Padding */
20 __int32_t tv_nsec; /* Nanoseconds */
21# else
22 __int32_t tv_nsec; /* Nanoseconds */
23 __int32_t :32; /* Padding */
24# endif
25};
26#endif
27#endif /* _STRUCT_TIMESPEC64_H */
lib/libc/glibc/include/struct___timeval64.h created+17
......@@ -0,0 +1,17 @@
1#ifndef _STRUCT_TIMEVAL64_H
2#define _STRUCT_TIMEVAL64_H
3
4#if __TIMESIZE == 64
5# define __timeval64 timeval
6#else
7/* The glibc Y2038-proof struct __timeval64 structure for a time value.
8 This structure is NOT supposed to be passed to the Linux kernel.
9 Instead, it shall be converted to struct __timespec64 and time shall
10 be [sg]et via clock_[sg]ettime (which are now Y2038 safe). */
11struct __timeval64
12{
13 __time64_t tv_sec; /* Seconds */
14 __suseconds64_t tv_usec; /* Microseconds */
15};
16#endif
17#endif /* _STRUCT_TIMEVAL64_H */
lib/libc/glibc/include/sys/cdefs.h+20
......@@ -13,6 +13,26 @@ extern void __chk_fail (void) __attribute__ ((__noreturn__));
1313libc_hidden_proto (__chk_fail)
1414rtld_hidden_proto (__chk_fail)
1515
16/* If we are using redirects internally to support long double,
17 we need to tweak some macros to ensure the PLT bypass tricks
18 continue to work in libc. */
19#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 && IS_IN (libc) && defined SHARED
20
21# undef __LDBL_REDIR_DECL
22# define __LDBL_REDIR_DECL(func) \
23 extern __typeof(func) func __asm (__ASMNAME ("__GI____ieee128_" #func));
24
25# undef libc_hidden_ldbl_proto
26# define libc_hidden_ldbl_proto(func, attrs...) \
27 extern __typeof(func) ___ieee128_ ## func; \
28 libc_hidden_proto (___ieee128_ ## func, ##attrs);
29
30# undef __LDBL_REDIR2_DECL
31# define __LDBL_REDIR2_DECL(func) \
32 extern __typeof(__ ## func) __ ## func __asm (__ASMNAME ("__GI____ieee128___" #func));
33
1634#endif
1735
36#endif /* !defined _ISOMAC */
37
1838#endif
lib/libc/glibc/include/sys/select.h+29
......@@ -3,6 +3,35 @@
33
44#ifndef _ISOMAC
55/* Now define the internal interfaces. */
6# if __TIMESIZE == 64
7# define __pselect64 __pselect
8# define __select64 __select
9#else
10# include <struct___timespec64.h>
11# include <struct___timeval64.h>
12
13extern int __pselect64 (int __nfds, fd_set *__readfds,
14 fd_set *__writefds, fd_set *__exceptfds,
15 const struct __timespec64 *__timeout,
16 const __sigset_t *__sigmask);
17libc_hidden_proto (__pselect64)
18
19extern int __pselect32 (int __nfds, fd_set *__readfds,
20 fd_set *__writefds, fd_set *__exceptfds,
21 const struct __timespec64 *__timeout,
22 const __sigset_t *__sigmask)
23 attribute_hidden;
24extern int __select32 (int __nfds, fd_set *__readfds,
25 fd_set *__writefds, fd_set *__exceptfds,
26 const struct __timespec64 *ts64,
27 struct __timeval64 *timeout)
28 attribute_hidden;
29
30extern int __select64 (int __nfds, fd_set *__readfds,
31 fd_set *__writefds, fd_set *__exceptfds,
32 struct __timeval64 *__timeout);
33libc_hidden_proto (__select64)
34#endif
635extern int __pselect (int __nfds, fd_set *__readfds,
736 fd_set *__writefds, fd_set *__exceptfds,
837 const struct timespec *__timeout,
lib/libc/glibc/include/sys/stat.h+77-43
......@@ -2,63 +2,97 @@
22#include <io/sys/stat.h>
33
44#ifndef _ISOMAC
5# include <xstatver.h>
6# include <struct___timespec64.h>
7# include <struct_stat_time64.h>
8# include <stdbool.h>
9
10static inline bool
11in_ino_t_range (__ino64_t v)
12{
13 __ino_t s = v;
14 return s == v;
15}
16
17static inline bool
18in_off_t_range (__off64_t v)
19{
20 __off_t s = v;
21 return s == v;
22}
23
24static inline bool
25in_blkcnt_t_range (__blkcnt64_t v)
26{
27 __blkcnt_t s = v;
28 return s == v;
29}
30
531/* Now define the internal interfaces. */
632extern int __stat (const char *__file, struct stat *__buf);
33extern int __stat64 (const char *__file, struct stat64 *__buf);
734extern int __fstat (int __fd, struct stat *__buf);
35extern int __fstat64 (int __fd, struct stat64 *__buf);
836extern int __lstat (const char *__file, struct stat *__buf);
37extern int __lstat64 (const char *__file, struct stat64 *__buf);
38extern int __fstatat (int dirfd, const char *pathname, struct stat *buf,
39 int flags);
40extern int __fstatat64 (int dirfd, const char *pathname, struct stat64 *buf,
41 int flags);
42# if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
43hidden_proto (__stat64)
44hidden_proto (__fstat64)
45hidden_proto (__lstat64)
46hidden_proto (__fstatat64)
47# endif
48
49# if __TIMESIZE == 64 || defined NO_RTLD_HIDDEN
50# define __stat64_time64 __stat64
51# define __fstat64_time64 __fstat64
52# define __lstat64_time64 __lstat64
53# define __fstatat64_time64 __fstatat64
54# else
55extern int __stat64_time64 (const char *file, struct __stat64_t64 *buf);
56hidden_proto (__stat64_time64);
57extern int __lstat64_time64 (const char *file, struct __stat64_t64 *buf);
58hidden_proto (__lstat64_time64);
59extern int __fstat64_time64 (int fd, struct __stat64_t64 *buf);
60hidden_proto (__fstat64_time64);
61extern int __fstatat64_time64 (int dirfd, const char *pathname,
62 struct __stat64_t64 *buf, int flags);
63hidden_proto (__fstatat64_time64);
64# endif
65
966extern int __chmod (const char *__file, __mode_t __mode);
1067libc_hidden_proto (__chmod)
1168extern int __fchmod (int __fd, __mode_t __mode);
69libc_hidden_proto (fchmodat)
1270extern __mode_t __umask (__mode_t __mask);
1371extern int __mkdir (const char *__path, __mode_t __mode);
1472libc_hidden_proto (__mkdir)
73
74extern int __mknodat (int fd, const char *path, mode_t mode, dev_t dev);
75libc_hidden_proto (__mknodat);
1576extern int __mknod (const char *__path,
1677 __mode_t __mode, __dev_t __dev);
17#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
18hidden_proto (__fxstat)
19hidden_proto (__fxstat64)
20hidden_proto (__lxstat)
21hidden_proto (__lxstat64)
22hidden_proto (__xstat)
23hidden_proto (__xstat64)
24#endif
25extern __inline__ int __stat (const char *__path, struct stat *__statbuf)
26{
27 return __xstat (_STAT_VER, __path, __statbuf);
28}
29libc_hidden_proto (__xmknod)
30extern __inline__ int __mknod (const char *__path, __mode_t __mode,
31 __dev_t __dev)
32{
33 return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
34}
35libc_hidden_proto (__xmknodat)
78libc_hidden_proto (__mknod);
3679
37libc_hidden_proto (__fxstatat)
38libc_hidden_proto (__fxstatat64)
80extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
81 __dev_t *__dev);
82extern int __xmknodat (int __ver, int __fd, const char *__path,
83 __mode_t __mode, __dev_t *__dev);
3984
40# if IS_IN (rtld) && !defined NO_RTLD_HIDDEN
41extern __typeof (__fxstatat64) __fxstatat64 attribute_hidden;
42# endif
85int __fxstat (int __ver, int __fildes, struct stat *__stat_buf);
86int __xstat (int __ver, const char *__filename,
87 struct stat *__stat_buf);
88int __lxstat (int __ver, const char *__filename, struct stat *__stat_buf);
89int __fxstatat (int __ver, int __fildes, const char *__filename,
90 struct stat *__stat_buf, int __flag);
91int __fxstat64 (int ver, int __fildes, struct stat64 *__stat_buf);
92int __xstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
93int __lxstat64 (int ver, const char *__filename, struct stat64 *__stat_buf);
94int __fxstatat64 (int ver, int __fildes, const char *__filename,
95 struct stat64 *__stat_buf, int __flag);
4396
44/* The `stat', `fstat', `lstat' functions have to be handled special since
45 even while not compiling the library with optimization calls to these
46 functions in the shared library must reference the `xstat' etc functions.
47 We have to use macros but we cannot define them in the normal headers
48 since on user level we must use real functions. */
49#define stat(fname, buf) __xstat (_STAT_VER, fname, buf)
50#define lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
51#define __lstat(fname, buf) __lxstat (_STAT_VER, fname, buf)
52#define lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
53#define __lstat64(fname, buf) __lxstat64 (_STAT_VER, fname, buf)
54#define stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
55#define fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
56#define __fstat64(fd, buf) __fxstat64 (_STAT_VER, fd, buf)
57#define fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
58#define __fstat(fd, buf) __fxstat (_STAT_VER, fd, buf)
59#define __fstatat(dfd, fname, buf, flag) \
60 __fxstatat (_STAT_VER, dfd, fname, buf, flag)
61#define __fstatat64(dfd, fname, buf, flag) \
62 __fxstatat64 (_STAT_VER, dfd, fname, buf, flag)
6397#endif
6498#endif
lib/libc/glibc/io/bits/statx.h+1-1
......@@ -1,5 +1,5 @@
11/* statx-related definitions and declarations. Generic version.
2 Copyright (C) 2018-2020 Free Software Foundation, Inc.
2 Copyright (C) 2018-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/io/fcntl.h created+347
......@@ -0,0 +1,347 @@
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18/*
19 * POSIX Standard: 6.5 File Control Operations <fcntl.h>
20 */
21
22#ifndef _FCNTL_H
23#define _FCNTL_H 1
24
25#include <features.h>
26
27/* This must be early so <bits/fcntl.h> can define types winningly. */
28__BEGIN_DECLS
29
30/* Get __mode_t, __dev_t and __off_t .*/
31#include <bits/types.h>
32
33/* Get the definitions of O_*, F_*, FD_*: all the
34 numbers and flag bits for `open', `fcntl', et al. */
35#include <bits/fcntl.h>
36
37/* Detect if open needs mode as a third argument (or for openat as a fourth
38 argument). */
39#ifdef __O_TMPFILE
40# define __OPEN_NEEDS_MODE(oflag) \
41 (((oflag) & O_CREAT) != 0 || ((oflag) & __O_TMPFILE) == __O_TMPFILE)
42#else
43# define __OPEN_NEEDS_MODE(oflag) (((oflag) & O_CREAT) != 0)
44#endif
45
46/* POSIX.1-2001 specifies that these types are defined by <fcntl.h>.
47 Earlier POSIX standards permitted any type ending in `_t' to be defined
48 by any POSIX header, so we don't conditionalize the definitions here. */
49#ifndef __mode_t_defined
50typedef __mode_t mode_t;
51# define __mode_t_defined
52#endif
53
54#ifndef __off_t_defined
55# ifndef __USE_FILE_OFFSET64
56typedef __off_t off_t;
57# else
58typedef __off64_t off_t;
59# endif
60# define __off_t_defined
61#endif
62
63#if defined __USE_LARGEFILE64 && !defined __off64_t_defined
64typedef __off64_t off64_t;
65# define __off64_t_defined
66#endif
67
68#ifndef __pid_t_defined
69typedef __pid_t pid_t;
70# define __pid_t_defined
71#endif
72
73/* For XPG all symbols from <sys/stat.h> should also be available. */
74#ifdef __USE_XOPEN2K8
75# include <bits/types/struct_timespec.h>
76#endif
77#if defined __USE_XOPEN || defined __USE_XOPEN2K8
78# include <bits/stat.h>
79
80# define S_IFMT __S_IFMT
81# define S_IFDIR __S_IFDIR
82# define S_IFCHR __S_IFCHR
83# define S_IFBLK __S_IFBLK
84# define S_IFREG __S_IFREG
85# ifdef __S_IFIFO
86# define S_IFIFO __S_IFIFO
87# endif
88# ifdef __S_IFLNK
89# define S_IFLNK __S_IFLNK
90# endif
91# if (defined __USE_UNIX98 || defined __USE_XOPEN2K8) && defined __S_IFSOCK
92# define S_IFSOCK __S_IFSOCK
93# endif
94
95/* Protection bits. */
96
97# define S_ISUID __S_ISUID /* Set user ID on execution. */
98# define S_ISGID __S_ISGID /* Set group ID on execution. */
99
100# if defined __USE_MISC || defined __USE_XOPEN
101/* Save swapped text after use (sticky bit). This is pretty well obsolete. */
102# define S_ISVTX __S_ISVTX
103# endif
104
105# define S_IRUSR __S_IREAD /* Read by owner. */
106# define S_IWUSR __S_IWRITE /* Write by owner. */
107# define S_IXUSR __S_IEXEC /* Execute by owner. */
108/* Read, write, and execute by owner. */
109# define S_IRWXU (__S_IREAD|__S_IWRITE|__S_IEXEC)
110
111# define S_IRGRP (S_IRUSR >> 3) /* Read by group. */
112# define S_IWGRP (S_IWUSR >> 3) /* Write by group. */
113# define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */
114/* Read, write, and execute by group. */
115# define S_IRWXG (S_IRWXU >> 3)
116
117# define S_IROTH (S_IRGRP >> 3) /* Read by others. */
118# define S_IWOTH (S_IWGRP >> 3) /* Write by others. */
119# define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */
120/* Read, write, and execute by others. */
121# define S_IRWXO (S_IRWXG >> 3)
122#endif
123
124#ifdef __USE_MISC
125# ifndef R_OK /* Verbatim from <unistd.h>. Ugh. */
126/* Values for the second argument to access.
127 These may be OR'd together. */
128# define R_OK 4 /* Test for read permission. */
129# define W_OK 2 /* Test for write permission. */
130# define X_OK 1 /* Test for execute permission. */
131# define F_OK 0 /* Test for existence. */
132# endif
133#endif /* Use misc. */
134
135/* XPG wants the following symbols. <stdio.h> has the same definitions. */
136#if defined __USE_XOPEN || defined __USE_XOPEN2K8
137# define SEEK_SET 0 /* Seek from beginning of file. */
138# define SEEK_CUR 1 /* Seek from current position. */
139# define SEEK_END 2 /* Seek from end of file. */
140#endif /* XPG */
141
142/* The constants AT_REMOVEDIR and AT_EACCESS have the same value. AT_EACCESS
143 is meaningful only to faccessat, while AT_REMOVEDIR is meaningful only to
144 unlinkat. The two functions do completely different things and therefore,
145 the flags can be allowed to overlap. For example, passing AT_REMOVEDIR to
146 faccessat would be undefined behavior and thus treating it equivalent to
147 AT_EACCESS is valid undefined behavior. */
148#ifdef __USE_ATFILE
149# define AT_FDCWD -100 /* Special value used to indicate
150 the *at functions should use the
151 current working directory. */
152# define AT_SYMLINK_NOFOLLOW 0x100 /* Do not follow symbolic links. */
153# define AT_REMOVEDIR 0x200 /* Remove directory instead of
154 unlinking file. */
155# define AT_SYMLINK_FOLLOW 0x400 /* Follow symbolic links. */
156# ifdef __USE_GNU
157# define AT_NO_AUTOMOUNT 0x800 /* Suppress terminal automount
158 traversal. */
159# define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname. */
160# define AT_STATX_SYNC_TYPE 0x6000
161# define AT_STATX_SYNC_AS_STAT 0x0000
162# define AT_STATX_FORCE_SYNC 0x2000
163# define AT_STATX_DONT_SYNC 0x4000
164# define AT_RECURSIVE 0x8000 /* Apply to the entire subtree. */
165# endif
166# define AT_EACCESS 0x200 /* Test access permitted for
167 effective IDs, not real IDs. */
168#endif
169
170/* Do the file control operation described by CMD on FD.
171 The remaining arguments are interpreted depending on CMD.
172
173 This function is a cancellation point and therefore not marked with
174 __THROW. */
175#ifndef __USE_TIME_BITS64
176# ifndef __USE_FILE_OFFSET64
177extern int fcntl (int __fd, int __cmd, ...);
178# else
179# ifdef __REDIRECT
180extern int __REDIRECT (fcntl, (int __fd, int __cmd, ...), fcntl64);
181# else
182# define fcntl fcntl64
183# endif
184# endif
185# ifdef __USE_LARGEFILE64
186extern int fcntl64 (int __fd, int __cmd, ...);
187# endif
188#else /* __USE_TIME_BITS64 */
189# ifdef __REDIRECT
190extern int __REDIRECT (fcntl, (int __fd, int __request, ...),
191 __fcntl_time64) __THROW;
192extern int __REDIRECT (fcntl64, (int __fd, int __request, ...),
193 __fcntl_time64) __THROW;
194# else
195extern int __fcntl_time64 (int __fd, int __request, ...) __THROW;
196# define fcntl64 __fcntl_time64
197# define fcntl __fcntl_time64
198# endif
199#endif
200
201/* Open FILE and return a new file descriptor for it, or -1 on error.
202 OFLAG determines the type of access used. If O_CREAT or O_TMPFILE is set
203 in OFLAG, the third argument is taken as a `mode_t', the mode of the
204 created file.
205
206 This function is a cancellation point and therefore not marked with
207 __THROW. */
208#ifndef __USE_FILE_OFFSET64
209extern int open (const char *__file, int __oflag, ...) __nonnull ((1));
210#else
211# ifdef __REDIRECT
212extern int __REDIRECT (open, (const char *__file, int __oflag, ...), open64)
213 __nonnull ((1));
214# else
215# define open open64
216# endif
217#endif
218#ifdef __USE_LARGEFILE64
219extern int open64 (const char *__file, int __oflag, ...) __nonnull ((1));
220#endif
221
222#ifdef __USE_ATFILE
223/* Similar to `open' but a relative path name is interpreted relative to
224 the directory for which FD is a descriptor.
225
226 NOTE: some other `openat' implementation support additional functionality
227 through this interface, especially using the O_XATTR flag. This is not
228 yet supported here.
229
230 This function is a cancellation point and therefore not marked with
231 __THROW. */
232# ifndef __USE_FILE_OFFSET64
233extern int openat (int __fd, const char *__file, int __oflag, ...)
234 __nonnull ((2));
235# else
236# ifdef __REDIRECT
237extern int __REDIRECT (openat, (int __fd, const char *__file, int __oflag,
238 ...), openat64) __nonnull ((2));
239# else
240# define openat openat64
241# endif
242# endif
243# ifdef __USE_LARGEFILE64
244extern int openat64 (int __fd, const char *__file, int __oflag, ...)
245 __nonnull ((2));
246# endif
247#endif
248
249/* Create and open FILE, with mode MODE. This takes an `int' MODE
250 argument because that is what `mode_t' will be widened to.
251
252 This function is a cancellation point and therefore not marked with
253 __THROW. */
254#ifndef __USE_FILE_OFFSET64
255extern int creat (const char *__file, mode_t __mode) __nonnull ((1));
256#else
257# ifdef __REDIRECT
258extern int __REDIRECT (creat, (const char *__file, mode_t __mode),
259 creat64) __nonnull ((1));
260# else
261# define creat creat64
262# endif
263#endif
264#ifdef __USE_LARGEFILE64
265extern int creat64 (const char *__file, mode_t __mode) __nonnull ((1));
266#endif
267
268#if !defined F_LOCK && (defined __USE_MISC || (defined __USE_XOPEN_EXTENDED \
269 && !defined __USE_POSIX))
270/* NOTE: These declarations also appear in <unistd.h>; be sure to keep both
271 files consistent. Some systems have them there and some here, and some
272 software depends on the macros being defined without including both. */
273
274/* `lockf' is a simpler interface to the locking facilities of `fcntl'.
275 LEN is always relative to the current file position.
276 The CMD argument is one of the following. */
277
278# define F_ULOCK 0 /* Unlock a previously locked region. */
279# define F_LOCK 1 /* Lock a region for exclusive use. */
280# define F_TLOCK 2 /* Test and lock a region for exclusive use. */
281# define F_TEST 3 /* Test a region for other processes locks. */
282
283# ifndef __USE_FILE_OFFSET64
284extern int lockf (int __fd, int __cmd, off_t __len);
285# else
286# ifdef __REDIRECT
287extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64);
288# else
289# define lockf lockf64
290# endif
291# endif
292# ifdef __USE_LARGEFILE64
293extern int lockf64 (int __fd, int __cmd, off64_t __len);
294# endif
295#endif
296
297#ifdef __USE_XOPEN2K
298/* Advice the system about the expected behaviour of the application with
299 respect to the file associated with FD. */
300# ifndef __USE_FILE_OFFSET64
301extern int posix_fadvise (int __fd, off_t __offset, off_t __len,
302 int __advise) __THROW;
303# else
304 # ifdef __REDIRECT_NTH
305extern int __REDIRECT_NTH (posix_fadvise, (int __fd, __off64_t __offset,
306 __off64_t __len, int __advise),
307 posix_fadvise64);
308# else
309# define posix_fadvise posix_fadvise64
310# endif
311# endif
312# ifdef __USE_LARGEFILE64
313extern int posix_fadvise64 (int __fd, off64_t __offset, off64_t __len,
314 int __advise) __THROW;
315# endif
316
317
318/* Reserve storage for the data of the file associated with FD.
319
320 This function is a possible cancellation point and therefore not
321 marked with __THROW. */
322# ifndef __USE_FILE_OFFSET64
323extern int posix_fallocate (int __fd, off_t __offset, off_t __len);
324# else
325 # ifdef __REDIRECT
326extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
327 __off64_t __len),
328 posix_fallocate64);
329# else
330# define posix_fallocate posix_fallocate64
331# endif
332# endif
333# ifdef __USE_LARGEFILE64
334extern int posix_fallocate64 (int __fd, off64_t __offset, off64_t __len);
335# endif
336#endif
337
338
339/* Define some inlines helping to catch common problems. */
340#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function \
341 && defined __va_arg_pack_len
342# include <bits/fcntl2.h>
343#endif
344
345__END_DECLS
346
347#endif /* fcntl.h */
lib/libc/glibc/io/fstat.c+10-32
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,23 +16,18 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <errno.h>
20#include <fcntl.h>
3621
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstat
47#undef __fstat
4822int
49attribute_hidden
5023__fstat (int fd, struct stat *buf)
5124{
52 return __fxstat (_STAT_VER, fd, buf);
25 if (fd < 0)
26 {
27 __set_errno (EBADF);
28 return -1;
29 }
30 return __fstatat (fd, "", buf, AT_EMPTY_PATH);
5331}
5432
55weak_hidden_alias (__fstat, fstat)
33weak_alias (__fstat, fstat)
lib/libc/glibc/io/fstat64.c+12-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,20 +16,18 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <errno.h>
20#include <fcntl.h>
3621
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstat64
4722int
48attribute_hidden
49fstat64 (int fd, struct stat64 *buf)
23__fstat64 (int fd, struct stat64 *buf)
5024{
51 return __fxstat64 (_STAT_VER, fd, buf);
25 if (fd < 0)
26 {
27 __set_errno (EBADF);
28 return -1;
29 }
30 return __fstatat64 (fd, "", buf, AT_EMPTY_PATH);
5231}
32hidden_def (__fstat64)
33weak_alias (__fstat64, fstat64)
lib/libc/glibc/io/fstatat.c+21-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,20 +16,27 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <errno.h>
20#include <fcntl.h>
3621
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstatat
4722int
48attribute_hidden
49fstatat (int fd, const char *file, struct stat *buf, int flag)
23__fstatat (int fd, const char *file, struct stat *buf, int flag)
5024{
51 return __fxstatat (_STAT_VER, fd, file, buf, flag);
25 if (fd < 0 && fd != AT_FDCWD)
26 {
27 __set_errno (EBADF);
28 return -1;
29 }
30 if (buf == 0 || (flag & ~AT_SYMLINK_NOFOLLOW) != 0)
31 {
32 __set_errno (EINVAL);
33 return -1;
34 }
35
36 __set_errno (ENOSYS);
37 return -1;
5238}
39
40weak_alias (__fstatat, fstatat)
41
42stub_warning (fstatat)
lib/libc/glibc/io/fstatat64.c+21-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,20 +16,27 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <errno.h>
20#include <fcntl.h>
3621
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef fstatat64
4722int
48attribute_hidden
49fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
23__fstatat64 (int fd, const char *file, struct stat64 *buf, int flag)
5024{
51 return __fxstatat64 (_STAT_VER, fd, file, buf, flag);
25 if (fd < 0 && fd != AT_FDCWD)
26 {
27 __set_errno (EBADF);
28 return -1;
29 }
30 if (buf == 0 || (flag & ~AT_SYMLINK_NOFOLLOW) != 0)
31 {
32 __set_errno (EINVAL);
33 return -1;
34 }
35
36 __set_errno (ENOSYS);
37 return -1;
5238}
39hidden_def (__fstatat64)
40weak_alias (__fstatat64, fstatat64)
41
42stub_warning (fstatat64)
lib/libc/glibc/io/lstat.c+4-32
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,23 +16,12 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <fcntl.h>
3620
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef lstat
47#undef __lstat
4821int
49attribute_hidden
5022__lstat (const char *file, struct stat *buf)
5123{
52 return __lxstat (_STAT_VER, file, buf);
24 return __fstatat (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
5325}
5426
55weak_hidden_alias (__lstat, lstat)
27weak_alias (__lstat, lstat)
lib/libc/glibc/io/lstat64.c+6-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,20 +16,12 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <fcntl.h>
3620
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef lstat64
4721int
48attribute_hidden
49lstat64 (const char *file, struct stat64 *buf)
22__lstat64 (const char *file, struct stat64 *buf)
5023{
51 return __lxstat64 (_STAT_VER, file, buf);
24 return __fstatat64 (AT_FDCWD, file, buf, AT_SYMLINK_NOFOLLOW);
5225}
26hidden_def (__lstat64)
27weak_alias (__lstat64, lstat64)
lib/libc/glibc/io/mknod.c+5-33
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -32,24 +15,13 @@
3215 License along with the GNU C Library; if not, see
3316 <https://www.gnu.org/licenses/>. */
3417
35
36#include <sys/types.h>
3718#include <sys/stat.h>
38
39/* This definition is only used if inlining fails for this function; see
40 the last page of <sys/stat.h>. The real work is done by the `x'
41 function which is passed a version number argument. We arrange in the
42 makefile that when not inlined this function is always statically
43 linked; that way a dynamically-linked executable always encodes the
44 version number corresponding to the data structures it uses, so the `x'
45 functions in the shared library can adapt without needing to recompile
46 all callers. */
19#include <fcntl.h>
4720
4821int
49attribute_hidden
5022__mknod (const char *path, mode_t mode, dev_t dev)
5123{
52 return __xmknod (_MKNOD_VER, path, mode, &dev);
24 return __mknodat (AT_FDCWD, path, mode, dev);
5325}
54
55weak_hidden_alias (__mknod, mknod)
26libc_hidden_def (__mknod)
27weak_alias (__mknod, mknod)
lib/libc/glibc/io/mknodat.c+9-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -32,22 +15,17 @@
3215 License along with the GNU C Library; if not, see
3316 <https://www.gnu.org/licenses/>. */
3417
35
3618#include <sys/types.h>
3719#include <sys/stat.h>
38
39/* This definition is only used if inlining fails for this function; see
40 the last page of <sys/stat.h>. The real work is done by the `x'
41 function which is passed a version number argument. We arrange in the
42 makefile that when not inlined this function is always statically
43 linked; that way a dynamically-linked executable always encodes the
44 version number corresponding to the data structures it uses, so the `x'
45 functions in the shared library can adapt without needing to recompile
46 all callers. */
20#include <errno.h>
4721
4822int
49attribute_hidden
50mknodat (int fd, const char *path, mode_t mode, dev_t dev)
23__mknodat (int fd, const char *path, mode_t mode, dev_t dev)
5124{
52 return __xmknodat (_MKNOD_VER, fd, path, mode, &dev);
25 __set_errno (ENOSYS);
26 return -1;
5327}
28libc_hidden_def (__mknodat)
29weak_alias (__mknodat, mknodat)
30
31stub_warning (mknodat)
lib/libc/glibc/io/stat.c+4-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,22 +16,12 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <fcntl.h>
3620
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef stat
4721int
48attribute_hidden
4922__stat (const char *file, struct stat *buf)
5023{
51 return __xstat (_STAT_VER, file, buf);
24 return __fstatat (AT_FDCWD, file, buf, 0);
5225}
5326
54weak_hidden_alias (__stat, stat)
27weak_alias (__stat, stat)
lib/libc/glibc/io/stat64.c+6-31
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -6,23 +6,6 @@
66 License as published by the Free Software Foundation; either
77 version 2.1 of the License, or (at your option) any later version.
88
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
17
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
25
269 The GNU C Library is distributed in the hope that it will be useful,
2710 but WITHOUT ANY WARRANTY; without even the implied warranty of
2811 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
......@@ -33,20 +16,12 @@
3316 <https://www.gnu.org/licenses/>. */
3417
3518#include <sys/stat.h>
19#include <fcntl.h>
3620
37/* This definition is only used if inlining fails for this function; see
38 the last page of <sys/stat.h>. The real work is done by the `x'
39 function which is passed a version number argument. We arrange in the
40 makefile that when not inlined this function is always statically
41 linked; that way a dynamically-linked executable always encodes the
42 version number corresponding to the data structures it uses, so the `x'
43 functions in the shared library can adapt without needing to recompile
44 all callers. */
45
46#undef stat64
4721int
48attribute_hidden
49stat64 (const char *file, struct stat64 *buf)
22__stat64 (const char *file, struct stat64 *buf)
5023{
51 return __xstat64 (_STAT_VER, file, buf);
24 return __fstatat64 (AT_FDCWD, file, buf, 0);
5225}
26hidden_def (__stat64)
27weak_alias (__stat64, stat64)
lib/libc/glibc/io/sys/stat.h+101-167
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -209,21 +209,51 @@ extern int stat (const char *__restrict __file,
209209 that file descriptor FD is open on and put them in BUF. */
210210extern int fstat (int __fd, struct stat *__buf) __THROW __nonnull ((2));
211211#else
212# ifdef __REDIRECT_NTH
212# ifdef __USE_TIME_BITS64
213# ifdef __REDIRECT_NTH
214extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
215 struct stat *__restrict __buf),
216 __stat64_time64)
217 __nonnull ((1, 2));
218extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf),
219 __fstat64_time64)
220 __nonnull ((2));
221# else
222# define stat __stat64_time64
223# define fstat __fstat64_time64
224# endif
225# else
226# ifdef __REDIRECT_NTH
213227extern int __REDIRECT_NTH (stat, (const char *__restrict __file,
214228 struct stat *__restrict __buf), stat64)
215229 __nonnull ((1, 2));
216230extern int __REDIRECT_NTH (fstat, (int __fd, struct stat *__buf), fstat64)
217231 __nonnull ((2));
218# else
219# define stat stat64
220# define fstat fstat64
232# else
233# define stat stat64
234# define fstat fstat64
235# endif
221236# endif
222237#endif
223238#ifdef __USE_LARGEFILE64
239# ifndef __USE_TIME_BITS64
224240extern int stat64 (const char *__restrict __file,
225241 struct stat64 *__restrict __buf) __THROW __nonnull ((1, 2));
226242extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
243# else
244# ifdef __REDIRECT_NTH
245extern int __REDIRECT_NTH (stat64, (const char *__restrict __file,
246 struct stat64 *__restrict __buf),
247 __stat64_time64)
248 __nonnull ((1, 2));
249extern int __REDIRECT_NTH (fstat64, (int __fd, struct stat64 *__buf),
250 __fstat64_time64)
251 __nonnull ((2));
252# else
253# define stat64 __stat64_time64
254# define fstat64 __fstat64_time
255# endif
256# endif
227257#endif
228258
229259#ifdef __USE_ATFILE
......@@ -235,20 +265,44 @@ extern int fstatat (int __fd, const char *__restrict __file,
235265 struct stat *__restrict __buf, int __flag)
236266 __THROW __nonnull ((2, 3));
237267# else
238# ifdef __REDIRECT_NTH
268# ifdef __USE_TIME_BITS64
269# ifdef __REDIRECT_NTH
239270extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
240271 struct stat *__restrict __buf,
241272 int __flag),
242 fstatat64) __nonnull ((2, 3));
273 __fstatat64_time64) __nonnull ((2, 3));
274# else
275# define fstatat __fstatat64_time64
276# endif
243277# else
244# define fstatat fstatat64
278# ifdef __REDIRECT_NTH
279extern int __REDIRECT_NTH (fstatat, (int __fd, const char *__restrict __file,
280 struct stat *__restrict __buf,
281 int __flag),
282 fstatat64) __nonnull ((2, 3));
283# else
284# define fstatat fstatat64
285# endif
245286# endif
246287# endif
247288
248289# ifdef __USE_LARGEFILE64
290# ifndef __USE_TIME_BITS64
249291extern int fstatat64 (int __fd, const char *__restrict __file,
250292 struct stat64 *__restrict __buf, int __flag)
251293 __THROW __nonnull ((2, 3));
294# else
295# ifdef __REDIRECT_NTH
296extern int __REDIRECT_NTH (fstatat64, (int __fd,
297 const char *__restrict __file,
298 struct stat64 *__restrict __buf,
299 int __flag),
300 __fstatat64_time64)
301 __nonnull ((2, 3));
302# else
303# define fstatat64 __fstatat64_time64
304# endif
305# endif
252306# endif
253307#endif
254308
......@@ -259,19 +313,37 @@ extern int fstatat64 (int __fd, const char *__restrict __file,
259313extern int lstat (const char *__restrict __file,
260314 struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
261315# else
262# ifdef __REDIRECT_NTH
316# ifdef __USE_TIME_BITS64
317# ifdef __REDIRECT_NTH
263318extern int __REDIRECT_NTH (lstat,
264319 (const char *__restrict __file,
265 struct stat *__restrict __buf), lstat64)
320 struct stat *__restrict __buf), __lstat64_time64)
266321 __nonnull ((1, 2));
322# else
323# define lstat __lstat64_time64
324# endif
267325# else
268# define lstat lstat64
326# ifdef __REDIRECT_NTH
327extern int __REDIRECT_NTH (lstat,
328 (const char *__restrict __file,
329 struct stat *__restrict __buf), lstat64)
330 __nonnull ((1, 2));
331# else
332# define lstat lstat64
333# endif
269334# endif
270335# endif
271336# ifdef __USE_LARGEFILE64
337# ifndef __USE_TIME_BITS64
272338extern int lstat64 (const char *__restrict __file,
273339 struct stat64 *__restrict __buf)
274340 __THROW __nonnull ((1, 2));
341# else
342extern int __REDIRECT_NTH (lstat64, (const char *__restrict __file,
343 struct stat64 *__restrict __buf),
344 __lstat64_time64)
345 __nonnull ((1, 2));
346# endif
275347# endif
276348#endif
277349
......@@ -355,182 +427,44 @@ extern int mkfifoat (int __fd, const char *__path, __mode_t __mode)
355427#endif
356428
357429#ifdef __USE_ATFILE
430# ifndef __USE_TIME_BITS64
358431/* Set file access and modification times relative to directory file
359432 descriptor. */
360433extern int utimensat (int __fd, const char *__path,
361434 const struct timespec __times[2],
362435 int __flags)
363436 __THROW __nonnull ((2));
437# else
438# ifdef __REDIRECT_NTH
439extern int __REDIRECT_NTH (utimensat, (int fd, const char *__path,
440 const struct timespec __times[2],
441 int flags),
442 __utimensat64) __nonnull ((2));
443# else
444# define utimensat __utimensat64
445# endif
446# endif
364447#endif
365448
366449#ifdef __USE_XOPEN2K8
450# ifndef __USE_TIME_BITS64
367451/* Set file access and modification times of the file associated with FD. */
368452extern int futimens (int __fd, const struct timespec __times[2]) __THROW;
369#endif
370
371/* To allow the `struct stat' structure and the file type `mode_t'
372 bits to vary without changing shared library major version number,
373 the `stat' family of functions and `mknod' are in fact inline
374 wrappers around calls to `xstat', `fxstat', `lxstat', and `xmknod',
375 which all take a leading version-number argument designating the
376 data structure and bits used. <bits/stat.h> defines _STAT_VER with
377 the version number corresponding to `struct stat' as defined in
378 that file; and _MKNOD_VER with the version number corresponding to
379 the S_IF* macros defined therein. It is arranged that when not
380 inlined these function are always statically linked; that way a
381 dynamically-linked executable always encodes the version number
382 corresponding to the data structures it uses, so the `x' functions
383 in the shared library can adapt without needing to recompile all
384 callers. */
385
386#ifndef _STAT_VER
387# define _STAT_VER 0
388#endif
389#ifndef _MKNOD_VER
390# define _MKNOD_VER 0
391#endif
392
393/* Wrappers for stat and mknod system calls. */
394#ifndef __USE_FILE_OFFSET64
395extern int __fxstat (int __ver, int __fildes, struct stat *__stat_buf)
396 __THROW __nonnull ((3));
397extern int __xstat (int __ver, const char *__filename,
398 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
399extern int __lxstat (int __ver, const char *__filename,
400 struct stat *__stat_buf) __THROW __nonnull ((2, 3));
401extern int __fxstatat (int __ver, int __fildes, const char *__filename,
402 struct stat *__stat_buf, int __flag)
403 __THROW __nonnull ((3, 4));
404#else
405# ifdef __REDIRECT_NTH
406extern int __REDIRECT_NTH (__fxstat, (int __ver, int __fildes,
407 struct stat *__stat_buf), __fxstat64)
408 __nonnull ((3));
409extern int __REDIRECT_NTH (__xstat, (int __ver, const char *__filename,
410 struct stat *__stat_buf), __xstat64)
411 __nonnull ((2, 3));
412extern int __REDIRECT_NTH (__lxstat, (int __ver, const char *__filename,
413 struct stat *__stat_buf), __lxstat64)
414 __nonnull ((2, 3));
415extern int __REDIRECT_NTH (__fxstatat, (int __ver, int __fildes,
416 const char *__filename,
417 struct stat *__stat_buf, int __flag),
418 __fxstatat64) __nonnull ((3, 4));
419453
420454# else
421# define __fxstat __fxstat64
422# define __xstat __xstat64
423# define __lxstat __lxstat64
455# ifdef __REDIRECT_NTH
456extern int __REDIRECT_NTH (futimens, (int fd, const struct timespec __times[2]),
457 __futimens64);
458# else
459# define futimens __futimens64
460# endif
424461# endif
425462#endif
426463
427#ifdef __USE_LARGEFILE64
428extern int __fxstat64 (int __ver, int __fildes, struct stat64 *__stat_buf)
429 __THROW __nonnull ((3));
430extern int __xstat64 (int __ver, const char *__filename,
431 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
432extern int __lxstat64 (int __ver, const char *__filename,
433 struct stat64 *__stat_buf) __THROW __nonnull ((2, 3));
434extern int __fxstatat64 (int __ver, int __fildes, const char *__filename,
435 struct stat64 *__stat_buf, int __flag)
436 __THROW __nonnull ((3, 4));
437#endif
438extern int __xmknod (int __ver, const char *__path, __mode_t __mode,
439 __dev_t *__dev) __THROW __nonnull ((2, 4));
440
441extern int __xmknodat (int __ver, int __fd, const char *__path,
442 __mode_t __mode, __dev_t *__dev)
443 __THROW __nonnull ((3, 5));
444
445464#ifdef __USE_GNU
446465# include <bits/statx.h>
447466#endif
448467
449#ifdef __USE_EXTERN_INLINES
450/* Inlined versions of the real stat and mknod functions. */
451
452__extern_inline int
453__NTH (stat (const char *__path, struct stat *__statbuf))
454{
455 return __xstat (_STAT_VER, __path, __statbuf);
456}
457
458# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
459__extern_inline int
460__NTH (lstat (const char *__path, struct stat *__statbuf))
461{
462 return __lxstat (_STAT_VER, __path, __statbuf);
463}
464# endif
465
466__extern_inline int
467__NTH (fstat (int __fd, struct stat *__statbuf))
468{
469 return __fxstat (_STAT_VER, __fd, __statbuf);
470}
471
472# ifdef __USE_ATFILE
473__extern_inline int
474__NTH (fstatat (int __fd, const char *__filename, struct stat *__statbuf,
475 int __flag))
476{
477 return __fxstatat (_STAT_VER, __fd, __filename, __statbuf, __flag);
478}
479# endif
480
481# ifdef __USE_MISC
482__extern_inline int
483__NTH (mknod (const char *__path, __mode_t __mode, __dev_t __dev))
484{
485 return __xmknod (_MKNOD_VER, __path, __mode, &__dev);
486}
487# endif
488
489# ifdef __USE_ATFILE
490__extern_inline int
491__NTH (mknodat (int __fd, const char *__path, __mode_t __mode,
492 __dev_t __dev))
493{
494 return __xmknodat (_MKNOD_VER, __fd, __path, __mode, &__dev);
495}
496# endif
497
498# if defined __USE_LARGEFILE64 \
499 && (! defined __USE_FILE_OFFSET64 \
500 || (defined __REDIRECT_NTH && defined __OPTIMIZE__))
501__extern_inline int
502__NTH (stat64 (const char *__path, struct stat64 *__statbuf))
503{
504 return __xstat64 (_STAT_VER, __path, __statbuf);
505}
506
507# if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
508__extern_inline int
509__NTH (lstat64 (const char *__path, struct stat64 *__statbuf))
510{
511 return __lxstat64 (_STAT_VER, __path, __statbuf);
512}
513# endif
514
515__extern_inline int
516__NTH (fstat64 (int __fd, struct stat64 *__statbuf))
517{
518 return __fxstat64 (_STAT_VER, __fd, __statbuf);
519}
520
521# ifdef __USE_ATFILE
522__extern_inline int
523__NTH (fstatat64 (int __fd, const char *__filename, struct stat64 *__statbuf,
524 int __flag))
525{
526 return __fxstatat64 (_STAT_VER, __fd, __filename, __statbuf, __flag);
527}
528# endif
529
530# endif
531
532#endif
533
534468__END_DECLS
535469
536470
lib/libc/glibc/locale/bits/types/__locale_t.h+1-1
......@@ -1,5 +1,5 @@
11/* Definition of struct __locale_struct and __locale_t.
2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
55
lib/libc/glibc/locale/bits/types/locale_t.h+1-1
......@@ -1,5 +1,5 @@
11/* Definition of locale_t.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/misc/sys/cdefs.h+187-69
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -25,7 +25,7 @@
2525
2626/* The GNU libc does not support any K&R compilers or the traditional mode
2727 of ISO C compilers anymore. Check for some of the combinations not
28 anymore supported. */
28 supported anymore. */
2929#if defined __GNUC__ && !defined __STDC__
3030# error "You need a ISO C conforming compiler to use the glibc headers"
3131#endif
......@@ -34,7 +34,29 @@
3434#undef __P
3535#undef __PMT
3636
37#ifdef __GNUC__
37/* Compilers that lack __has_attribute may object to
38 #if defined __has_attribute && __has_attribute (...)
39 even though they do not need to evaluate the right-hand side of the &&.
40 Similarly for __has_builtin, etc. */
41#if (defined __has_attribute \
42 && (!defined __clang_minor__ \
43 || 3 < __clang_major__ + (5 <= __clang_minor__)))
44# define __glibc_has_attribute(attr) __has_attribute (attr)
45#else
46# define __glibc_has_attribute(attr) 0
47#endif
48#ifdef __has_builtin
49# define __glibc_has_builtin(name) __has_builtin (name)
50#else
51# define __glibc_has_builtin(name) 0
52#endif
53#ifdef __has_extension
54# define __glibc_has_extension(ext) __has_extension (ext)
55#else
56# define __glibc_has_extension(ext) 0
57#endif
58
59#if defined __GNUC__ || defined __clang__
3860
3961/* All functions, except those with callbacks or those that
4062 synchronize memory, are leaf functions. */
......@@ -47,21 +69,26 @@
4769# endif
4870
4971/* GCC can always grok prototypes. For C++ programs we add throw()
50 to help it optimize the function calls. But this works only with
51 gcc 2.8.x and egcs. For gcc 3.2 and up we even mark C functions
72 to help it optimize the function calls. But this only works with
73 gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
5274 as non-throwing using a function attribute since programs can use
5375 the -fexceptions options for C code as well. */
54# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
76# if !defined __cplusplus \
77 && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
5578# define __THROW __attribute__ ((__nothrow__ __LEAF))
5679# define __THROWNL __attribute__ ((__nothrow__))
5780# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
5881# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
5982# else
60# if defined __cplusplus && __GNUC_PREREQ (2,8)
61# define __THROW throw ()
62# define __THROWNL throw ()
63# define __NTH(fct) __LEAF_ATTR fct throw ()
64# define __NTHNL(fct) fct throw ()
83# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
84# if __cplusplus >= 201103L
85# define __THROW noexcept (true)
86# else
87# define __THROW throw ()
88# endif
89# define __THROWNL __THROW
90# define __NTH(fct) __LEAF_ATTR fct __THROW
91# define __NTHNL(fct) fct __THROW
6592# else
6693# define __THROW
6794# define __THROWNL
......@@ -70,7 +97,7 @@
7097# endif
7198# endif
7299
73#else /* Not GCC. */
100#else /* Not GCC or clang. */
74101
75102# if (defined __cplusplus \
76103 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
......@@ -83,16 +110,7 @@
83110# define __THROWNL
84111# define __NTH(fct) fct
85112
86#endif /* GCC. */
87
88/* Compilers that are not clang may object to
89 #if defined __clang__ && __has_extension(...)
90 even though they do not need to evaluate the right-hand side of the &&. */
91#if defined __clang__ && defined __has_extension
92# define __glibc_clang_has_extension(ext) __has_extension (ext)
93#else
94# define __glibc_clang_has_extension(ext) 0
95#endif
113#endif /* GCC || clang. */
96114
97115/* These two macros are not used in glibc anymore. They are kept here
98116 only because some other projects expect the macros to be defined. */
......@@ -123,14 +141,20 @@
123141#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
124142#define __bos0(ptr) __builtin_object_size (ptr, 0)
125143
144/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
145#if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
146# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
147# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
148#else
149# define __glibc_objsize0(__o) __bos0 (__o)
150# define __glibc_objsize(__o) __bos (__o)
151#endif
152
126153#if __GNUC_PREREQ (4,3)
127# define __warndecl(name, msg) \
128 extern void name (void) __attribute__((__warning__ (msg)))
129154# define __warnattr(msg) __attribute__((__warning__ (msg)))
130155# define __errordecl(name, msg) \
131156 extern void name (void) __attribute__((__error__ (msg)))
132157#else
133# define __warndecl(name, msg) extern void name (void)
134158# define __warnattr(msg)
135159# define __errordecl(name, msg) extern void name (void)
136160#endif
......@@ -139,11 +163,11 @@
139163 Headers that should use flexible arrays only if they're "real"
140164 (e.g. only if they won't affect sizeof()) should test
141165 #if __glibc_c99_flexarr_available. */
142#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
166#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
143167# define __flexarr []
144168# define __glibc_c99_flexarr_available 1
145#elif __GNUC_PREREQ (2,97)
146/* GCC 2.97 supports C99 flexible array members as an extension,
169#elif __GNUC_PREREQ (2,97) || defined __clang__
170/* GCC 2.97 and clang support C99 flexible array members as an extension,
147171 even when in C89 mode or compiling C++ (any version). */
148172# define __flexarr []
149173# define __glibc_c99_flexarr_available 1
......@@ -169,7 +193,7 @@
169193 Example:
170194 int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
171195
172#if defined __GNUC__ && __GNUC__ >= 2
196#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
173197
174198# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
175199# ifdef __cplusplus
......@@ -194,17 +218,17 @@
194218*/
195219#endif
196220
197/* GCC has various useful declarations that can be made with the
198 `__attribute__' syntax. All of the ways we use this do fine if
199 they are omitted for compilers that don't understand it. */
200#if !defined __GNUC__ || __GNUC__ < 2
221/* GCC and clang have various useful declarations that can be made with
222 the '__attribute__' syntax. All of the ways we use this do fine if
223 they are omitted for compilers that don't understand it. */
224#if !(defined __GNUC__ || defined __clang__)
201225# define __attribute__(xyz) /* Ignore */
202226#endif
203227
204228/* At some point during the gcc 2.96 development the `malloc' attribute
205229 for functions was introduced. We don't want to use it unconditionally
206230 (although this would be possible) since it generates warnings. */
207#if __GNUC_PREREQ (2,96)
231#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
208232# define __attribute_malloc__ __attribute__ ((__malloc__))
209233#else
210234# define __attribute_malloc__ /* Ignore */
......@@ -222,23 +246,29 @@
222246/* At some point during the gcc 2.96 development the `pure' attribute
223247 for functions was introduced. We don't want to use it unconditionally
224248 (although this would be possible) since it generates warnings. */
225#if __GNUC_PREREQ (2,96)
249#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
226250# define __attribute_pure__ __attribute__ ((__pure__))
227251#else
228252# define __attribute_pure__ /* Ignore */
229253#endif
230254
231255/* This declaration tells the compiler that the value is constant. */
232#if __GNUC_PREREQ (2,5)
256#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
233257# define __attribute_const__ __attribute__ ((__const__))
234258#else
235259# define __attribute_const__ /* Ignore */
236260#endif
237261
262#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
263# define __attribute_maybe_unused__ __attribute__ ((__unused__))
264#else
265# define __attribute_maybe_unused__ /* Ignore */
266#endif
267
238268/* At some point during the gcc 3.1 development the `used' attribute
239269 for functions was introduced. We don't want to use it unconditionally
240270 (although this would be possible) since it generates warnings. */
241#if __GNUC_PREREQ (3,1)
271#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
242272# define __attribute_used__ __attribute__ ((__used__))
243273# define __attribute_noinline__ __attribute__ ((__noinline__))
244274#else
......@@ -247,7 +277,7 @@
247277#endif
248278
249279/* Since version 3.2, gcc allows marking deprecated functions. */
250#if __GNUC_PREREQ (3,2)
280#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
251281# define __attribute_deprecated__ __attribute__ ((__deprecated__))
252282#else
253283# define __attribute_deprecated__ /* Ignore */
......@@ -257,7 +287,7 @@
257287 when a deprecated function is used. clang claims to be gcc 4.2, but
258288 may also support this feature. */
259289#if __GNUC_PREREQ (4,5) \
260 || __glibc_clang_has_extension (__attribute_deprecated_with_message__)
290 || __glibc_has_extension (__attribute_deprecated_with_message__)
261291# define __attribute_deprecated_msg__(msg) \
262292 __attribute__ ((__deprecated__ (msg)))
263293#else
......@@ -270,7 +300,7 @@
270300 If several `format_arg' attributes are given for the same function, in
271301 gcc-3.0 and older, all but the last one are ignored. In newer gccs,
272302 all designated arguments are considered. */
273#if __GNUC_PREREQ (2,8)
303#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
274304# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
275305#else
276306# define __attribute_format_arg__(x) /* Ignore */
......@@ -280,27 +310,42 @@
280310 attribute for functions was introduced. We don't want to use it
281311 unconditionally (although this would be possible) since it
282312 generates warnings. */
283#if __GNUC_PREREQ (2,97)
313#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
284314# define __attribute_format_strfmon__(a,b) \
285315 __attribute__ ((__format__ (__strfmon__, a, b)))
286316#else
287317# define __attribute_format_strfmon__(a,b) /* Ignore */
288318#endif
289319
290/* The nonull function attribute allows to mark pointer parameters which
320/* The nonnull function attribute marks pointer parameters that
291321 must not be NULL. */
292#if __GNUC_PREREQ (3,3)
293# define __nonnull(params) __attribute__ ((__nonnull__ params))
294#else
295# define __nonnull(params)
322#ifndef __nonnull
323# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
324# define __nonnull(params) __attribute__ ((__nonnull__ params))
325# else
326# define __nonnull(params)
327# endif
328#elif !defined __GLIBC__
329# undef __nonnull
330# define __nonnull(params) _GL_ATTRIBUTE_NONNULL (params)
331#endif
332
333/* The returns_nonnull function attribute marks the return type of the function
334 as always being non-null. */
335#ifndef __returns_nonnull
336# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
337# define __returns_nonnull __attribute__ ((__returns_nonnull__))
338# else
339# define __returns_nonnull
340# endif
296341#endif
297342
298343/* If fortification mode, we warn about unused results of certain
299344 function calls which can lead to problems. */
300#if __GNUC_PREREQ (3,4)
345#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
301346# define __attribute_warn_unused_result__ \
302347 __attribute__ ((__warn_unused_result__))
303# if __USE_FORTIFY_LEVEL > 0
348# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
304349# define __wur __attribute_warn_unused_result__
305350# endif
306351#else
......@@ -311,7 +356,7 @@
311356#endif
312357
313358/* Forces a function to be always inlined. */
314#if __GNUC_PREREQ (3,2)
359#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
315360/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
316361 it conflicts with this definition. Therefore undefine it first to
317362 allow either header to be included first. */
......@@ -324,7 +369,7 @@
324369
325370/* Associate error messages with the source location of the call site rather
326371 than with the source location inside the function. */
327#if __GNUC_PREREQ (4,3)
372#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
328373# define __attribute_artificial__ __attribute__ ((__artificial__))
329374#else
330375# define __attribute_artificial__ /* Ignore */
......@@ -367,12 +412,14 @@
367412 run in pedantic mode if the uses are carefully marked using the
368413 `__extension__' keyword. But this is not generally available before
369414 version 2.8. */
370#if !__GNUC_PREREQ (2,8)
415#if !(__GNUC_PREREQ (2,8) || defined __clang__)
371416# define __extension__ /* Ignore */
372417#endif
373418
374/* __restrict is known in EGCS 1.2 and above. */
375#if !__GNUC_PREREQ (2,92)
419/* __restrict is known in EGCS 1.2 and above, and in clang.
420 It works also in C++ mode (outside of arrays), but only when spelled
421 as '__restrict', not 'restrict'. */
422#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
376423# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
377424# define __restrict restrict
378425# else
......@@ -382,8 +429,9 @@
382429
383430/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
384431 array_name[restrict]
385 GCC 3.1 supports this. */
386#if __GNUC_PREREQ (3,1) && !defined __GNUG__
432 GCC 3.1 and clang support this.
433 This syntax is not usable in C++ mode. */
434#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
387435# define __restrict_arr __restrict
388436#else
389437# ifdef __GNUC__
......@@ -398,7 +446,7 @@
398446# endif
399447#endif
400448
401#if __GNUC__ >= 3
449#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
402450# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
403451# define __glibc_likely(cond) __builtin_expect ((cond), 1)
404452#else
......@@ -406,15 +454,10 @@
406454# define __glibc_likely(cond) (cond)
407455#endif
408456
409#ifdef __has_attribute
410# define __glibc_has_attribute(attr) __has_attribute (attr)
411#else
412# define __glibc_has_attribute(attr) 0
413#endif
414
415457#if (!defined _Noreturn \
416458 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
417 && !__GNUC_PREREQ (4,7))
459 && !(__GNUC_PREREQ (4,7) \
460 || (3 < __clang_major__ + (5 <= __clang_minor__))))
418461# if __GNUC_PREREQ (2,8)
419462# define _Noreturn __attribute__ ((__noreturn__))
420463# else
......@@ -443,16 +486,51 @@
443486
444487#if (!defined _Static_assert && !defined __cplusplus \
445488 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
446 && (!__GNUC_PREREQ (4, 6) || defined __STRICT_ANSI__))
489 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
490 || defined __STRICT_ANSI__))
447491# define _Static_assert(expr, diagnostic) \
448492 extern int (*__Static_assert_function (void)) \
449493 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
450494#endif
451495
452#include <bits/wordsize.h>
453#include <bits/long-double.h>
496/* The #ifndef lets Gnulib avoid including these on non-glibc
497 platforms, where the includes typically do not exist. */
498#ifdef __GLIBC__
499# include <bits/wordsize.h>
500# include <bits/long-double.h>
501#endif
502
503#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
504# ifdef __REDIRECT
505
506/* Alias name defined automatically. */
507# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
508# define __LDBL_REDIR_DECL(name) \
509 extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
510
511/* Alias name defined automatically, with leading underscores. */
512# define __LDBL_REDIR2_DECL(name) \
513 extern __typeof (__##name) __##name \
514 __asm (__ASMNAME ("__" #name "ieee128"));
515
516/* Alias name defined manually. */
517# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
518# define __LDBL_REDIR1_DECL(name, alias) \
519 extern __typeof (name) name __asm (__ASMNAME (#alias));
520
521# define __LDBL_REDIR1_NTH(name, proto, alias) \
522 __REDIRECT_NTH (name, proto, alias)
523# define __REDIRECT_NTH_LDBL(name, proto, alias) \
524 __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
525
526/* Unused. */
527# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
528# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
454529
455#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
530# else
531_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
532# endif
533#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
456534# define __LDBL_COMPAT 1
457535# ifdef __REDIRECT
458536# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
......@@ -461,6 +539,8 @@
461539# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
462540# define __LDBL_REDIR_NTH(name, proto) \
463541 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
542# define __LDBL_REDIR2_DECL(name) \
543 extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
464544# define __LDBL_REDIR1_DECL(name, alias) \
465545 extern __typeof (name) name __asm (__ASMNAME (#alias));
466546# define __LDBL_REDIR_DECL(name) \
......@@ -471,11 +551,13 @@
471551 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
472552# endif
473553#endif
474#if !defined __LDBL_COMPAT || !defined __REDIRECT
554#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
555 || !defined __REDIRECT
475556# define __LDBL_REDIR1(name, proto, alias) name proto
476557# define __LDBL_REDIR(name, proto) name proto
477558# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
478559# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
560# define __LDBL_REDIR2_DECL(name)
479561# define __LDBL_REDIR_DECL(name)
480562# ifdef __REDIRECT
481563# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
......@@ -506,7 +588,7 @@
506588 check is required to enable the use of generic selection. */
507589#if !defined __cplusplus \
508590 && (__GNUC_PREREQ (4, 9) \
509 || __glibc_clang_has_extension (c_generic_selections) \
591 || __glibc_has_extension (c_generic_selections) \
510592 || (!defined __GNUC__ && defined __STDC_VERSION__ \
511593 && __STDC_VERSION__ >= 201112L))
512594# define __HAVE_GENERIC_SELECTION 1
......@@ -514,4 +596,40 @@
514596# define __HAVE_GENERIC_SELECTION 0
515597#endif
516598
599#if __GNUC_PREREQ (10, 0)
600/* Designates a 1-based positional argument ref-index of pointer type
601 that can be used to access size-index elements of the pointed-to
602 array according to access mode, or at least one element when
603 size-index is not provided:
604 access (access-mode, <ref-index> [, <size-index>]) */
605# define __attr_access(x) __attribute__ ((__access__ x))
606# if __GNUC_PREREQ (11, 0)
607# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
608# else
609# define __attr_access_none(argno)
610# endif
611#else
612# define __attr_access(x)
613# define __attr_access_none(argno)
614#endif
615
616#if __GNUC_PREREQ (11, 0)
617/* Designates dealloc as a function to call to deallocate objects
618 allocated by the declared function. */
619# define __attr_dealloc(dealloc, argno) \
620 __attribute__ ((__malloc__ (dealloc, argno)))
621# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
622#else
623# define __attr_dealloc(dealloc, argno)
624# define __attr_dealloc_free
625#endif
626
627/* Specify that a function such as setjmp or vfork may return
628 twice. */
629#if __GNUC_PREREQ (4, 1)
630# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
631#else
632# define __attribute_returns_twice__ /* Ignore. */
633#endif
634
517635#endif /* sys/cdefs.h */
lib/libc/glibc/misc/sys/select.h+28-1
......@@ -1,5 +1,5 @@
11/* `fd_set' type and related macros, and `select'/`pselect' declarations.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -98,10 +98,23 @@ __BEGIN_DECLS
9898
9999 This function is a cancellation point and therefore not marked with
100100 __THROW. */
101#ifndef __USE_TIME_BITS64
101102extern int select (int __nfds, fd_set *__restrict __readfds,
102103 fd_set *__restrict __writefds,
103104 fd_set *__restrict __exceptfds,
104105 struct timeval *__restrict __timeout);
106#else
107# ifdef __REDIRECT
108extern int __REDIRECT (select,
109 (int __nfds, fd_set *__restrict __readfds,
110 fd_set *__restrict __writefds,
111 fd_set *__restrict __exceptfds,
112 struct timeval *__restrict __timeout),
113 __select64);
114# else
115# define select __select64
116# endif
117#endif
105118
106119#ifdef __USE_XOPEN2K
107120/* Same as above only that the TIMEOUT value is given with higher
......@@ -110,11 +123,25 @@ extern int select (int __nfds, fd_set *__restrict __readfds,
110123
111124 This function is a cancellation point and therefore not marked with
112125 __THROW. */
126# ifndef __USE_TIME_BITS64
113127extern int pselect (int __nfds, fd_set *__restrict __readfds,
114128 fd_set *__restrict __writefds,
115129 fd_set *__restrict __exceptfds,
116130 const struct timespec *__restrict __timeout,
117131 const __sigset_t *__restrict __sigmask);
132# else
133# ifdef __REDIRECT
134extern int __REDIRECT (pselect,
135 (int __nfds, fd_set *__restrict __readfds,
136 fd_set *__restrict __writefds,
137 fd_set *__restrict __exceptfds,
138 const struct timespec *__restrict __timeout,
139 const __sigset_t *__restrict __sigmask),
140 __pselect64);
141# else
142# define pselect __pselect64
143# endif
144# endif
118145#endif
119146
120147
lib/libc/glibc/nptl/pthread_atfork.c deleted-61
......@@ -1,61 +0,0 @@
1/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
37 void (*child) (void));
38extern int __register_atfork (void (*__prepare) (void),
39 void (*__parent) (void),
40 void (*__child) (void),
41 void *dso_handle);
42libc_hidden_proto (__register_atfork)
43extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
44
45/* Hide the symbol so that no definition but the one locally in the
46 executable or DSO is used. */
47int
48#ifndef __pthread_atfork
49/* Don't mark the compatibility function as hidden. */
50attribute_hidden
51#endif
52__pthread_atfork (void (*prepare) (void), void (*parent) (void),
53 void (*child) (void))
54{
55 return __register_atfork (prepare, parent, child, __dso_handle);
56}
57#ifndef __pthread_atfork
58extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
59 void (*child) (void)) attribute_hidden;
60weak_alias (__pthread_atfork, pthread_atfork)
61#endif
lib/libc/glibc/posix/bits/cpu-set.h+1-1
......@@ -1,6 +1,6 @@
11/* Definition of the cpu_set_t structure used by the POSIX 1003.1b-1993
22 scheduling interface.
3 Copyright (C) 1996-2020 Free Software Foundation, Inc.
3 Copyright (C) 1996-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/posix/bits/types.h+2-1
......@@ -1,5 +1,5 @@
11/* bits/types.h -- definitions of __*_t types underlying *_t types.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -160,6 +160,7 @@ __STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
160160__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
161161__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
162162__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
163__STD_TYPE __SUSECONDS64_T_TYPE __suseconds64_t;
163164
164165__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
165166__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */
lib/libc/glibc/posix/sys/types.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/signal/signal.h+32-15
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -27,7 +27,7 @@
2727__BEGIN_DECLS
2828
2929#include <bits/types.h>
30#include <bits/signum.h>
30#include <bits/signum-generic.h>
3131
3232#include <bits/types/sig_atomic_t.h>
3333
......@@ -148,7 +148,8 @@ extern void psiginfo (const siginfo_t *__pinfo, const char *__s);
148148
149149#ifdef __USE_XOPEN_EXTENDED
150150# ifdef __GNUC__
151extern int sigpause (int __sig) __asm__ ("__xpg_sigpause");
151extern int sigpause (int __sig) __asm__ ("__xpg_sigpause")
152 __attribute_deprecated_msg__ ("Use the sigsuspend function instead");
152153# else
153154extern int __sigpause (int __sig_or_mask, int __is_sig);
154155/* Remove a signal from the signal mask and suspend the process. */
......@@ -164,7 +165,9 @@ extern int __sigpause (int __sig_or_mask, int __is_sig);
164165 simply do not work in many situations. Use `sigprocmask' instead. */
165166
166167/* Compute mask for signal SIG. */
167# define sigmask(sig) ((int)(1u << ((sig) - 1)))
168# define sigmask(sig) \
169 __glibc_macro_warning ("sigmask is deprecated") \
170 ((int)(1u << ((sig) - 1)))
168171
169172/* Block signals in MASK, returning the old mask. */
170173extern int sigblock (int __mask) __THROW __attribute_deprecated__;
......@@ -266,10 +269,23 @@ extern int sigwaitinfo (const sigset_t *__restrict __set,
266269
267270 This function is a cancellation point and therefore not marked with
268271 __THROW. */
272# ifndef __USE_TIME_BITS64
269273extern int sigtimedwait (const sigset_t *__restrict __set,
270274 siginfo_t *__restrict __info,
271275 const struct timespec *__restrict __timeout)
272276 __nonnull ((1));
277# else
278# ifdef __REDIRECT
279extern int __REDIRECT (sigtimedwait,
280 (const sigset_t *__restrict __set,
281 siginfo_t *__restrict __info,
282 const struct timespec *__restrict __timeout),
283 __sigtimedwait64)
284 __nonnull ((1));
285# else
286# define sigtimedwait __sigtimedwait64
287# endif
288# endif
273289
274290/* Send signal SIG to the process PID. Associate data in VAL with the
275291 signal. */
......@@ -281,12 +297,6 @@ extern int sigqueue (__pid_t __pid, int __sig, const union sigval __val)
281297
282298#ifdef __USE_MISC
283299
284/* Names of the signals. This variable exists only for compatibility.
285 Use `strsignal' instead (see <string.h>). */
286extern const char *const _sys_siglist[_NSIG];
287extern const char *const sys_siglist[_NSIG];
288
289
290300/* Get machine-dependent `struct sigcontext' and signal subcodes. */
291301# include <bits/sigcontext.h>
292302
......@@ -311,9 +321,11 @@ extern int sigreturn (struct sigcontext *__scp) __THROW;
311321/* If INTERRUPT is nonzero, make signal SIG interrupt system calls
312322 (causing them to fail with EINTR); if INTERRUPT is zero, make system
313323 calls be restarted after signal SIG. */
314extern int siginterrupt (int __sig, int __interrupt) __THROW;
324extern int siginterrupt (int __sig, int __interrupt) __THROW
325 __attribute_deprecated_msg__ ("Use sigaction with SA_RESTART instead");
315326
316327# include <bits/sigstack.h>
328# include <bits/sigstksz.h>
317329# include <bits/ss_flags.h>
318330
319331/* Alternate signal handler stack interface.
......@@ -340,16 +352,21 @@ extern int sigstack (struct sigstack *__ss, struct sigstack *__oss)
340352/* Simplified interface for signal management. */
341353
342354/* Add SIG to the calling process' signal mask. */
343extern int sighold (int __sig) __THROW;
355extern int sighold (int __sig) __THROW
356 __attribute_deprecated_msg__ ("Use the sigprocmask function instead");
344357
345358/* Remove SIG from the calling process' signal mask. */
346extern int sigrelse (int __sig) __THROW;
359extern int sigrelse (int __sig) __THROW
360 __attribute_deprecated_msg__ ("Use the sigprocmask function instead");
347361
348362/* Set the disposition of SIG to SIG_IGN. */
349extern int sigignore (int __sig) __THROW;
363extern int sigignore (int __sig) __THROW
364 __attribute_deprecated_msg__ ("Use the signal function instead");
350365
351366/* Set the disposition of SIG. */
352extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW;
367extern __sighandler_t sigset (int __sig, __sighandler_t __disp) __THROW
368 __attribute_deprecated_msg__
369 ("Use the signal and sigprocmask functions instead");
353370#endif
354371
355372#if defined __USE_POSIX199506 || defined __USE_UNIX98
lib/libc/glibc/stdlib/alloca.h+2-2
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -25,7 +25,7 @@
2525
2626__BEGIN_DECLS
2727
28/* Remove any previous definitions. */
28/* Remove any previous definition. */
2929#undef alloca
3030
3131/* Allocate a block that will be freed when the calling function exits. */
lib/libc/glibc/stdlib/at_quick_exit.c+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/stdlib/atexit.c+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/stdlib/bits/stdlib-float.h+1-1
......@@ -1,5 +1,5 @@
11/* Floating-point inline functions for stdlib.h.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/stdlib/errno.h created+55
......@@ -0,0 +1,55 @@
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18/*
19 * ISO C99 Standard: 7.5 Errors <errno.h>
20 */
21
22#ifndef _ERRNO_H
23#define _ERRNO_H 1
24
25#include <features.h>
26
27/* The system-specific definitions of the E* constants, as macros. */
28#include <bits/errno.h>
29
30/* When included from assembly language, this header only provides the
31 E* constants. */
32#ifndef __ASSEMBLER__
33
34__BEGIN_DECLS
35
36/* The error code set by various library functions. */
37extern int *__errno_location (void) __THROW __attribute_const__;
38# define errno (*__errno_location ())
39
40# ifdef __USE_GNU
41
42/* The full and simple forms of the name with which the program was
43 invoked. These variables are set up automatically at startup based on
44 the value of argv[0]. */
45extern char *program_invocation_name;
46extern char *program_invocation_short_name;
47
48#include <bits/types/error_t.h>
49
50# endif /* __USE_GNU */
51
52__END_DECLS
53
54#endif /* !__ASSEMBLER__ */
55#endif /* errno.h */
lib/libc/glibc/stdlib/exit.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/stdlib/stdlib.h+21-12
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -397,7 +397,7 @@ extern long int a64l (const char *__s)
397397 `initstate' and `setstate' functions are those from BSD Unices.
398398 The `rand' and `srand' functions are required by the ANSI standard.
399399 We provide both interfaces to the same random number generator. */
400/* Return a random long integer between 0 and RAND_MAX inclusive. */
400/* Return a random long integer between 0 and 2^31-1 inclusive. */
401401extern long int random (void) __THROW;
402402
403403/* Seed the random number generator with the given number. */
......@@ -550,6 +550,9 @@ extern void *calloc (size_t __nmemb, size_t __size)
550550extern void *realloc (void *__ptr, size_t __size)
551551 __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
552552
553/* Free a block allocated by `malloc', `realloc' or `calloc'. */
554extern void free (void *__ptr) __THROW;
555
553556#ifdef __USE_MISC
554557/* Re-allocate the previously allocated block in PTR, making the new
555558 block large enough for NMEMB elements of SIZE bytes each. */
......@@ -558,11 +561,13 @@ extern void *realloc (void *__ptr, size_t __size)
558561 between objects pointed by the old and new pointers. */
559562extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
560563 __THROW __attribute_warn_unused_result__
561 __attribute_alloc_size__ ((2, 3));
562#endif
564 __attribute_alloc_size__ ((2, 3))
565 __attr_dealloc_free;
563566
564/* Free a block allocated by `malloc', `realloc' or `calloc'. */
565extern void free (void *__ptr) __THROW;
567/* Add reallocarray as its own deallocator. */
568extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
569 __THROW __attr_dealloc (reallocarray, 1);
570#endif
566571
567572#ifdef __USE_MISC
568573# include <alloca.h>
......@@ -788,7 +793,8 @@ extern int system (const char *__command) __wur;
788793/* Return a malloc'd string containing the canonical absolute name of the
789794 existing named file. */
790795extern char *canonicalize_file_name (const char *__name)
791 __THROW __nonnull ((1)) __wur;
796 __THROW __nonnull ((1)) __attribute_malloc__
797 __attr_dealloc_free __wur;
792798#endif
793799
794800#if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
......@@ -931,12 +937,13 @@ extern int wctomb (char *__s, wchar_t __wchar) __THROW;
931937
932938/* Convert a multibyte string to a wide char string. */
933939extern size_t mbstowcs (wchar_t *__restrict __pwcs,
934 const char *__restrict __s, size_t __n) __THROW;
940 const char *__restrict __s, size_t __n) __THROW
941 __attr_access ((__read_only__, 2));
935942/* Convert a wide char string to multibyte string. */
936943extern size_t wcstombs (char *__restrict __s,
937944 const wchar_t *__restrict __pwcs, size_t __n)
938 __THROW;
939
945 __THROW
946 __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
940947
941948#ifdef __USE_MISC
942949/* Determine whether the string value of RESPONSE matches the affirmation
......@@ -990,7 +997,7 @@ extern char *ptsname (int __fd) __THROW __wur;
990997 terminal associated with the master FD is open on in BUF.
991998 Return 0 on success, otherwise an error number. */
992999extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
993 __THROW __nonnull ((2));
1000 __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
9941001
9951002/* Open a master pseudo terminal and return its file descriptor. */
9961003extern int getpt (void);
......@@ -1016,7 +1023,9 @@ extern int ttyslot (void) __THROW;
10161023#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
10171024# include <bits/stdlib.h>
10181025#endif
1019#ifdef __LDBL_COMPAT
1026
1027#include <bits/floatn.h>
1028#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
10201029# include <bits/stdlib-ldbl.h>
10211030#endif
10221031
lib/libc/glibc/string/bits/endian.h+1-1
......@@ -1,5 +1,5 @@
11/* Endian macros for string.h functions
2 Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 Copyright (C) 1992-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/string/endian.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/aarch64/crti.S+11-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33
44 This file is part of the GNU C Library.
55
......@@ -75,6 +75,11 @@ call_weak_fn:
7575 .hidden _init
7676 .type _init, %function
7777_init:
78#if HAVE_AARCH64_PAC_RET
79 PACIASP
80#else
81 BTI_C
82#endif
7883 stp x29, x30, [sp, -16]!
7984 mov x29, sp
8085#if PREINIT_FUNCTION_WEAK
......@@ -89,5 +94,10 @@ _init:
8994 .hidden _fini
9095 .type _fini, %function
9196_fini:
97#if HAVE_AARCH64_PAC_RET
98 PACIASP
99#else
100 BTI_C
101#endif
92102 stp x29, x30, [sp, -16]!
93103 mov x29, sp
lib/libc/glibc/sysdeps/aarch64/crtn.S+9-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for AArch64.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33
44 This file is part of the GNU C Library.
55
......@@ -37,10 +37,18 @@
3737/* crtn.S puts function epilogues in the .init and .fini sections
3838 corresponding to the prologues in crti.S. */
3939
40#include <sysdep.h>
41
4042 .section .init,"ax",%progbits
4143 ldp x29, x30, [sp], 16
44#if HAVE_AARCH64_PAC_RET
45 AUTIASP
46#endif
4247 RET
4348
4449 .section .fini,"ax",%progbits
4550 ldp x29, x30, [sp], 16
51#if HAVE_AARCH64_PAC_RET
52 AUTIASP
53#endif
4654 RET
lib/libc/glibc/sysdeps/aarch64/dl-sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
lib/libc/glibc/sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
lib/libc/glibc/sysdeps/aarch64/start.S+7-16
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -43,10 +43,9 @@
4343 */
4444
4545 .text
46 .globl _start
47 .type _start,#function
48_start:
46ENTRY(_start)
4947 /* Create an initial frame with 0 LR and FP */
48 cfi_undefined (x30)
5049 mov x29, #0
5150 mov x30, #0
5251
......@@ -64,26 +63,16 @@ _start:
6463# ifdef SHARED
6564 adrp x0, :got:main
6665 ldr PTR_REG (0), [x0, #:got_lo12:main]
67
68 adrp x3, :got:__libc_csu_init
69 ldr PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
70
71 adrp x4, :got:__libc_csu_fini
72 ldr PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
7366# else
7467 adrp x0, __wrap_main
7568 add x0, x0, :lo12:__wrap_main
76 adrp x3, __libc_csu_init
77 add x3, x3, :lo12:__libc_csu_init
78 adrp x4, __libc_csu_fini
79 add x4, x4, :lo12:__libc_csu_fini
8069# endif
8170#else
8271 /* Set up the other arguments in registers */
8372 MOVL (0, main)
84 MOVL (3, __libc_csu_init)
85 MOVL (4, __libc_csu_fini)
8673#endif
74 mov x3, #0 /* Used to be init. */
75 mov x4, #0 /* Used to be fini. */
8776
8877 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
8978 stack_end) */
......@@ -100,8 +89,10 @@ _start:
10089 because crt1.o and rcrt1.o share code and the later must avoid the
10190 use of GOT relocations before __libc_start_main is called. */
10291__wrap_main:
92 BTI_C
10393 b main
10494#endif
95END(_start)
10596
10697 /* Define a symbol for the first piece of initialized data. */
10798 .data
lib/libc/glibc/sysdeps/aarch64/sysdep.h+68-5
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -25,29 +25,90 @@
2525# define AARCH64_R(NAME) R_AARCH64_ ## NAME
2626# define PTR_REG(n) x##n
2727# define PTR_LOG_SIZE 3
28# define DELOUSE(n)
28# define PTR_ARG(n)
29# define SIZE_ARG(n)
2930#else
3031# define AARCH64_R(NAME) R_AARCH64_P32_ ## NAME
3132# define PTR_REG(n) w##n
3233# define PTR_LOG_SIZE 2
33# define DELOUSE(n) mov w##n, w##n
34# define PTR_ARG(n) mov w##n, w##n
35# define SIZE_ARG(n) mov w##n, w##n
3436#endif
3537
3638#define PTR_SIZE (1<<PTR_LOG_SIZE)
3739
40#ifndef __ASSEMBLER__
41/* Strip pointer authentication code from pointer p. */
42static inline void *
43strip_pac (void *p)
44{
45 register void *ra asm ("x30") = (p);
46 asm ("hint 7 // xpaclri" : "+r"(ra));
47 return ra;
48}
49
50/* This is needed when glibc is built with -mbranch-protection=pac-ret
51 with a gcc that is affected by PR target/94891. */
52# if HAVE_AARCH64_PAC_RET
53# undef RETURN_ADDRESS
54# define RETURN_ADDRESS(n) strip_pac (__builtin_return_address (n))
55# endif
56#endif
57
3858#ifdef __ASSEMBLER__
3959
4060/* Syntactic details of assembler. */
4161
4262#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
4363
64/* Branch Target Identitication support. */
65#if HAVE_AARCH64_BTI
66# define BTI_C hint 34
67# define BTI_J hint 36
68#else
69# define BTI_C nop
70# define BTI_J nop
71#endif
72
73/* Return address signing support (pac-ret). */
74#define PACIASP hint 25
75#define AUTIASP hint 29
76
77/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
78#define FEATURE_1_AND 0xc0000000
79#define FEATURE_1_BTI 1
80#define FEATURE_1_PAC 2
81
82/* Add a NT_GNU_PROPERTY_TYPE_0 note. */
83#define GNU_PROPERTY(type, value) \
84 .section .note.gnu.property, "a"; \
85 .p2align 3; \
86 .word 4; \
87 .word 16; \
88 .word 5; \
89 .asciz "GNU"; \
90 .word type; \
91 .word 4; \
92 .word value; \
93 .word 0; \
94 .text
95
96/* Add GNU property note with the supported features to all asm code
97 where sysdep.h is included. */
98#if HAVE_AARCH64_BTI && HAVE_AARCH64_PAC_RET
99GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI|FEATURE_1_PAC)
100#elif HAVE_AARCH64_BTI
101GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI)
102#endif
103
44104/* Define an entry point visible from C. */
45105#define ENTRY(name) \
46106 .globl C_SYMBOL_NAME(name); \
47107 .type C_SYMBOL_NAME(name),%function; \
48 .align 4; \
108 .p2align 6; \
49109 C_LABEL(name) \
50110 cfi_startproc; \
111 BTI_C; \
51112 CALL_MCOUNT
52113
53114/* Define an entry point visible from C. */
......@@ -57,6 +118,7 @@
57118 .p2align align; \
58119 C_LABEL(name) \
59120 cfi_startproc; \
121 BTI_C; \
60122 CALL_MCOUNT
61123
62124/* Define an entry point visible from C with a specified alignment and
......@@ -68,11 +130,12 @@
68130 .globl C_SYMBOL_NAME(name); \
69131 .type C_SYMBOL_NAME(name),%function; \
70132 .p2align align; \
71 .rep padding; \
133 .rep padding - 1; /* -1 for bti c. */ \
72134 nop; \
73135 .endr; \
74136 C_LABEL(name) \
75137 cfi_startproc; \
138 BTI_C; \
76139 CALL_MCOUNT
77140
78141#undef END
lib/libc/glibc/sysdeps/alpha/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/alpha/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for Alpha.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/alpha/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. Alpha version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/alpha/nptl/bits/pthreadtypes-arch.h deleted-61
......@@ -1,61 +0,0 @@
1/* Machine-specific pthread type layouts. Alpha version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#define __SIZEOF_PTHREAD_ATTR_T 56
23#define __SIZEOF_PTHREAD_MUTEX_T 40
24#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
25#define __SIZEOF_PTHREAD_COND_T 48
26#define __SIZEOF_PTHREAD_CONDATTR_T 4
27#define __SIZEOF_PTHREAD_RWLOCK_T 56
28#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
29#define __SIZEOF_PTHREAD_BARRIER_T 32
30#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
31
32/* Definitions for internal mutex struct. */
33#define __PTHREAD_COMPAT_PADDING_MID
34#define __PTHREAD_COMPAT_PADDING_END
35#define __PTHREAD_MUTEX_LOCK_ELISION 0
36#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
37#define __PTHREAD_MUTEX_USE_UNION 0
38
39#define __LOCK_ALIGNMENT
40#define __ONCE_ALIGNMENT
41
42struct __pthread_rwlock_arch_t
43{
44 unsigned int __readers;
45 unsigned int __writers;
46 unsigned int __wrphase_futex;
47 unsigned int __writers_futex;
48 unsigned int __pad3;
49 unsigned int __pad4;
50 int __cur_writer;
51 int __shared;
52 unsigned long int __pad1;
53 unsigned long int __pad2;
54 /* FLAGS must stay at this position in the structure to maintain
55 binary compatibility. */
56 unsigned int __flags;
57};
58
59#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
60
61#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/alpha/start.S+3-4
......@@ -1,5 +1,5 @@
11/* Startup code for Alpha/ELF.
2 Copyright (C) 1993-2020 Free Software Foundation, Inc.
2 Copyright (C) 1993-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Richard Henderson <rth@tamu.edu>
55
......@@ -55,9 +55,8 @@ _start:
5555 ldl a1, 16(sp) /* get argc */
5656 lda a2, 24(sp) /* get argv */
5757
58 /* Load address of our own entry points to .fini and .init. */
59 lda a3, __libc_csu_init
60 lda a4, __libc_csu_fini
58 mov $r31, a3 /* Used to be init. */
59 mov $r31, a4 /* Used to be fini. */
6160
6261 /* Store address of the shared library termination function. */
6362 mov v0, a5
lib/libc/glibc/sysdeps/arm/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/arm/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for ARM.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/arm/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. Alpha version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/arm/nptl/bits/pthreadtypes-arch.h deleted-71
......@@ -1,71 +0,0 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <endian.h>
22
23#define __SIZEOF_PTHREAD_ATTR_T 36
24#define __SIZEOF_PTHREAD_MUTEX_T 24
25#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
26#define __SIZEOF_PTHREAD_COND_T 48
27#define __SIZEOF_PTHREAD_CONDATTR_T 4
28#define __SIZEOF_PTHREAD_RWLOCK_T 32
29#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
30#define __SIZEOF_PTHREAD_BARRIER_T 20
31#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32
33/* Data structure for mutex handling. */
34#define __PTHREAD_COMPAT_PADDING_MID
35#define __PTHREAD_COMPAT_PADDING_END
36#define __PTHREAD_MUTEX_LOCK_ELISION 0
37#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
38#define __PTHREAD_MUTEX_USE_UNION 1
39
40#define __LOCK_ALIGNMENT
41#define __ONCE_ALIGNMENT
42
43struct __pthread_rwlock_arch_t
44{
45 unsigned int __readers;
46 unsigned int __writers;
47 unsigned int __wrphase_futex;
48 unsigned int __writers_futex;
49 unsigned int __pad3;
50 unsigned int __pad4;
51#if __BYTE_ORDER == __BIG_ENDIAN
52 unsigned char __pad1;
53 unsigned char __pad2;
54 unsigned char __shared;
55 /* FLAGS must stay at this position in the structure to maintain
56 binary compatibility. */
57 unsigned char __flags;
58#else
59 /* FLAGS must stay at this position in the structure to maintain
60 binary compatibility. */
61 unsigned char __flags;
62 unsigned char __shared;
63 unsigned char __pad1;
64 unsigned char __pad2;
65#endif
66 int __cur_writer;
67};
68
69#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
70
71#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/arm/start.S+6-18
......@@ -1,5 +1,5 @@
11/* Startup code for ARM & ELF
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -94,30 +94,20 @@ _start:
9494 adr a4, .L_GOT
9595 add sl, sl, a4
9696
97 ldr ip, .L_GOT+4 /* __libc_csu_fini */
98 ldr ip, [sl, ip]
97 mov a4, #0 /* Used to be init. */
98 push { a4 } /* Used to be fini. */
9999
100 push { ip } /* Push __libc_csu_fini */
101
102 ldr a4, .L_GOT+8 /* __libc_csu_init */
103 ldr a4, [sl, a4]
104
105 ldr a1, .L_GOT+12 /* main */
100 ldr a1, .L_GOT+4 /* main */
106101 ldr a1, [sl, a1]
107102
108103 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
109104 /* Let the libc call main and exit with its return code. */
110105 bl __libc_start_main(PLT)
111106#else
112 /* Fetch address of __libc_csu_fini */
113 ldr ip, =__libc_csu_fini
114
115 /* Push __libc_csu_fini */
116 push { ip }
117107
118 /* Set up the other arguments in registers */
108 mov a4, #0 /* Used to init. */
109 push { a4 } /* Used to fini. */
119110 ldr a1, =main
120 ldr a4, =__libc_csu_init
121111
122112 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
123113 /* Let the libc call main and exit with its return code. */
......@@ -131,8 +121,6 @@ _start:
131121 .align 2
132122.L_GOT:
133123 .word _GLOBAL_OFFSET_TABLE_ - .L_GOT
134 .word __libc_csu_fini(GOT)
135 .word __libc_csu_init(GOT)
136124 .word main(GOT)
137125#endif
138126
lib/libc/glibc/sysdeps/arm/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for ARM.
2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/dl-dtprocnum.h+1-1
......@@ -1,5 +1,5 @@
11/* Configuration of lookup functions.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. Generic version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/dwarf2.h+1-1
......@@ -1,6 +1,6 @@
11/* Declarations and definitions of codes relating to the DWARF2 symbolic
22 debugging information format.
3 Copyright (C) 1992-2020 Free Software Foundation, Inc.
3 Copyright (C) 1992-2021 Free Software Foundation, Inc.
44 Contributed by Gary Funck (gary@intrepid.com). Derived from the
55 DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com).
66
lib/libc/glibc/sysdeps/generic/libc-lock.h+1-13
......@@ -1,5 +1,5 @@
11/* libc-internal interface for mutex locks. Stub version.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -125,16 +125,4 @@
125125/* We need portable names for some of the functions. */
126126#define __libc_mutex_unlock
127127
128/* Type for key of thread specific data. */
129typedef int __libc_key_t;
130
131/* Create key for thread specific data. */
132#define __libc_key_create(KEY,DEST) ((void) (KEY), (void) (DEST), -1)
133
134/* Set thread-specific data associated with KEY to VAL. */
135#define __libc_setspecific(KEY,VAL) ((void) (KEY), (void) (VAL))
136
137/* Get thread-specific data associated with KEY. */
138#define __libc_getspecific(KEY) ((void) (KEY), (void *) 0)
139
140128#endif /* libc-lock.h */
lib/libc/glibc/sysdeps/generic/libc-symver.h created+88
......@@ -0,0 +1,88 @@
1/* Symbol version management.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* This file is included from <libc-symbols.h> for !_ISOMAC, and
20 unconditionally from <shlib-compat.h>. */
21
22#ifndef _LIBC_SYMVER_H
23#define _LIBC_SYMVER_H 1
24
25#include <config.h>
26
27/* Use symbol_version_reference to specify the version a symbol
28 reference should link to. Use symbol_version or
29 default_symbol_version for the definition of a versioned symbol.
30 The difference is that the latter is a no-op in non-shared
31 builds.
32
33 _set_symbol_version is similar to symbol_version_reference, except
34 that this macro expects the name and symbol version as a single
35 string or token sequence, with an @ or @@ separator. (A string is
36 used in C mode and a token sequence in assembler mode.)
37 _set_symbol_version only be used for definitions because it may
38 introduce an alias symbol that would not be globally unique for
39 mere references. The _set_symbol_version macro is used to define
40 default_symbol_version and compat_symbol. */
41
42#ifdef __ASSEMBLER__
43# define symbol_version_reference(real, name, version) \
44 .symver real, name##@##version
45#else
46# define symbol_version_reference(real, name, version) \
47 __asm__ (".symver " #real "," #name "@" #version)
48#endif /* !__ASSEMBLER__ */
49
50#if SYMVER_NEEDS_ALIAS
51/* If the assembler cannot support multiple versions for the same
52 symbol, introduce __SInnn_ aliases to which the symbol version is
53 attached. */
54# define __symbol_version_unique_concat(x, y) __SI ## x ## _ ## y
55# define _symbol_version_unique_concat(x, y) \
56 __symbol_version_unique_concat (x, y)
57# define _symbol_version_unique_alias(name) \
58 _symbol_version_unique_concat (name, __COUNTER__)
59# ifdef __ASSEMBLER__
60# define _set_symbol_version_2(real, alias, name_version) \
61 .globl alias ASM_LINE_SEP \
62 .equiv alias, real ASM_LINE_SEP \
63 .symver alias, name_version
64# else
65# define _set_symbol_version_2(real, alias, name_version) \
66 __asm__ (".globl " #alias "\n\t" \
67 ".equiv " #alias ", " #real "\n\t" \
68 ".symver " #alias "," name_version)
69# endif
70# define _set_symbol_version_1(real, alias, name_version) \
71 _set_symbol_version_2 (real, alias, name_version)
72/* REAL must be globally unique, so that the counter also produces
73 globally unique symbols. */
74# define _set_symbol_version(real, name_version) \
75 _set_symbol_version_1 (real, _symbol_version_unique_alias (real), \
76 name_version)
77# else /* !SYMVER_NEEDS_ALIAS */
78# ifdef __ASSEMBLER__
79# define _set_symbol_version(real, name_version) \
80 .symver real, name_version
81# else
82# define _set_symbol_version(real, name_version) \
83 __asm__ (".symver " #real "," name_version)
84# endif
85#endif /* !SYMVER_NEEDS_ALIAS */
86
87
88#endif /* _LIBC_SYMVER_H */
lib/libc/glibc/sysdeps/generic/single-thread.h+1-1
......@@ -1,5 +1,5 @@
11/* Single thread optimization, generic version.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/struct_stat_time64.h created+6
......@@ -0,0 +1,6 @@
1#ifndef _BITS_STRUCT_STAT_TIME64_H
2#define _BITS_STRUCT_STAT_TIME64_H 1
3
4#define __stat64_t64 stat64
5
6#endif
lib/libc/glibc/sysdeps/generic/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Generic asm macros used on many machines.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/tls.h+1-1
......@@ -1,5 +1,5 @@
11/* Definition for thread-local data handling. Generic version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/generic/xstatver.h created+4
......@@ -0,0 +1,4 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER 0
4#define _MKNOD_VER 0
lib/libc/glibc/sysdeps/hppa/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/hppa/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for HPPA
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/hppa/nptl/bits/pthreadtypes-arch.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/hppa/start.S+5-23
......@@ -1,5 +1,5 @@
11/* ELF startup code for HPPA.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -36,8 +36,6 @@
3636 .import main, code
3737 .import $global$, data
3838 .import __libc_start_main, code
39 .import __libc_csu_fini, code
40 .import __libc_csu_init, code
4139
4240 /* Have the linker create plabel words so we get PLABEL32
4341 relocs and not 21/14. The use of 21/14 relocs is only
......@@ -52,10 +50,6 @@
5250 .word P%main
5351.Lp__libc_start_main:
5452 .word P%__libc_start_main
55.Lp__libc_csu_fini:
56 .word P%__libc_csu_fini
57.Lp__libc_csu_init:
58 .word P%__libc_csu_init
5953
6054 .text
6155 .align 4
......@@ -77,8 +71,8 @@ _start:
7771 1. r26 - Application main
7872 2. r25 - argc
7973 3. r24 - argv
80 4. r23 - __libc_csu_init
81 5. sp-52 - __libc_csu_fini
74 4. r23 - init (unused)
75 5. sp-52 - fini (unused)
8276 6. sp-56 - rtld_fini
8377 7. sp-60 - stackend */
8478
......@@ -108,14 +102,6 @@ _start:
108102 addil LT'.Lpmain, %r19
109103 ldw RT'.Lpmain(%r1), %r26
110104 ldw 0(%r26),%r26
111 /* void (*init) (void) (4th argument) */
112 addil LT'.Lp__libc_csu_init, %r19
113 ldw RT'.Lp__libc_csu_init(%r1), %r23
114 ldw 0(%r23), %r23
115 /* void (*fini) (void) (5th argument) */
116 addil LT'.Lp__libc_csu_fini, %r19
117 ldw RT'.Lp__libc_csu_fini(%r1), %r22
118 ldw 0(%r22), %r22
119105#else
120106 /* Load $global$ address into %dp */
121107 ldil L%$global$, %dp
......@@ -124,13 +110,9 @@ _start:
124110 /* load main (1st argument) */
125111 ldil LR'.Lpmain, %r26
126112 ldw RR'.Lpmain(%r26), %r26
127 /* void (*init) (void) (4th argument) */
128 ldil LR'.Lp__libc_csu_init, %r23
129 ldw RR'.Lp__libc_csu_init(%r23), %r23
130 /* void (*fini) (void) (5th argument) */
131 ldil LR'.Lp__libc_csu_fini, %r22
132 ldw RR'.Lp__libc_csu_fini(%r22), %r22
133113#endif
114 ldi 0,%r23 /* Used to be init. */
115 ldi 0,%r22 /* Used to be fini. */
134116 /* Store 5th argument */
135117 stw %r22, -52(%sp)
136118 /* void *stack_end (7th argument) */
lib/libc/glibc/sysdeps/hppa/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for HP/PA.
2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
55
lib/libc/glibc/sysdeps/htl/bits/pthread.h+1-1
......@@ -1,5 +1,5 @@
11/* Pthread data structures. Generic version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/htl/bits/thread-shared-types.h+14-1
......@@ -1,5 +1,5 @@
11/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -20,5 +20,18 @@
2020#define _THREAD_SHARED_TYPES_H 1
2121
2222#include <bits/pthreadtypes-arch.h>
23#include <bits/types/struct___pthread_once.h>
24
25typedef int __tss_t;
26typedef int __thrd_t;
27
28typedef union
29{
30 struct __pthread_once __data;
31 int __align __ONCE_ALIGNMENT;
32 char __size[__SIZEOF_PTHREAD_ONCE_T];
33} __once_flag;
34
35#define __ONCE_FLAG_INIT { { __PTHREAD_ONCE_INIT } }
2336
2437#endif /* _THREAD_SHARED_TYPES_H */
lib/libc/glibc/sysdeps/htl/libc-lockP.h+1-14
......@@ -1,5 +1,5 @@
11/* Private libc-internal interface for mutex locks.
2 Copyright (C) 2015-2020 Free Software Foundation, Inc.
2 Copyright (C) 2015-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -22,9 +22,6 @@
2222#include <pthread.h>
2323#include <pthread-functions.h>
2424
25/* Type for key to thread-specific data. */
26typedef pthread_key_t __libc_key_t;
27
2825/* If we check for a weakly referenced symbol and then perform a
2926 normal jump to it te code generated for some platforms in case of
3027 PIC is unnecessarily slow. What would happen is that the function
......@@ -109,16 +106,6 @@ extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
109106
110107extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
111108
112extern int __pthread_key_create (pthread_key_t *__key,
113 void (*__destr_function) (void *));
114
115extern int __pthread_key_delete (pthread_key_t __key);
116
117extern int __pthread_setspecific (pthread_key_t __key,
118 const void *__pointer);
119
120extern void *__pthread_getspecific (pthread_key_t __key);
121
122109extern int __pthread_once (pthread_once_t *__once_control,
123110 void (*__init_routine) (void));
124111
lib/libc/glibc/sysdeps/htl/pthread.h+66-39
......@@ -1,5 +1,5 @@
11/* Posix threads. Hurd version.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -222,6 +222,32 @@ extern void pthread_exit (void *__status) __attribute__ ((__noreturn__));
222222 the exit status of the thread in *STATUS. */
223223extern int pthread_join (pthread_t __threadp, void **__status);
224224
225#ifdef __USE_GNU
226/* Check whether thread TH has terminated. If yes return the status of
227 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
228extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
229
230/* Make calling thread wait for termination of the thread TH, but only
231 until TIMEOUT. The exit status of the thread is stored in
232 *THREAD_RETURN, if THREAD_RETURN is not NULL.
233
234 This function is a cancellation point and therefore not marked with
235 __THROW. */
236extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
237 const struct timespec *__abstime);
238
239/* Make calling thread wait for termination of the thread TH, but only
240 until TIMEOUT measured against the clock specified by CLOCKID. The
241 exit status of the thread is stored in *THREAD_RETURN, if
242 THREAD_RETURN is not NULL.
243
244 This function is a cancellation point and therefore not marked with
245 __THROW. */
246extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return,
247 clockid_t __clockid,
248 const struct timespec *__abstime);
249#endif
250
225251/* Indicate that the storage for THREAD can be reclaimed when it
226252 terminates. */
227253extern int pthread_detach (pthread_t __threadp);
......@@ -273,6 +299,7 @@ extern pthread_t pthread_self (void) __THROW;
273299#ifdef __USE_XOPEN2K
274300# define PTHREAD_MUTEX_STALLED __PTHREAD_MUTEX_STALLED
275301# define PTHREAD_MUTEX_ROBUST __PTHREAD_MUTEX_ROBUST
302# define PTHREAD_MUTEX_ROBUST_NP __PTHREAD_MUTEX_ROBUST
276303#endif
277304
278305#include <bits/types/struct___pthread_mutexattr.h>
......@@ -400,6 +427,13 @@ extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict __mutex,
400427 __THROWNL __nonnull ((1, 2));
401428#endif
402429
430#ifdef __USE_GNU
431extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
432 clockid_t __clockid,
433 const struct timespec *__restrict
434 __abstime) __THROWNL __nonnull ((1, 3));
435#endif
436
403437/* Unlock MUTEX. */
404438extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
405439 __THROWNL __nonnull ((1));
......@@ -516,6 +550,21 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
516550 pthread_mutex_t *__restrict __mutex,
517551 __const struct timespec *__restrict __abstime)
518552 __nonnull ((1, 2, 3));
553
554# ifdef __USE_GNU
555/* Wait for condition variable COND to be signaled or broadcast until
556 ABSTIME measured by the specified clock. MUTEX is assumed to be
557 locked before. CLOCK is the clock to use. ABSTIME is an absolute
558 time specification against CLOCK's epoch.
559
560 This function is a cancellation point and therefore not marked with
561 __THROW. */
562extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
563 pthread_mutex_t *__restrict __mutex,
564 __clockid_t __clock_id,
565 const struct timespec *__restrict __abstime)
566 __nonnull ((1, 2, 4));
567# endif
519568
520569
521570/* Spin locks. */
......@@ -549,42 +598,6 @@ extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
549598extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
550599 __nonnull ((1));
551600
552# if defined __USE_EXTERN_INLINES && defined _LIBC
553
554# include <bits/spin-lock-inline.h>
555
556__extern_inline int
557pthread_spin_destroy (pthread_spinlock_t *__lock)
558{
559 return __pthread_spin_destroy (__lock);
560}
561
562__extern_inline int
563pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
564{
565 return __pthread_spin_init (__lock, __pshared);
566}
567
568__extern_inline int
569pthread_spin_lock (pthread_spinlock_t *__lock)
570{
571 return __pthread_spin_lock (__lock);
572}
573
574__extern_inline int
575pthread_spin_trylock (pthread_spinlock_t *__lock)
576{
577 return __pthread_spin_trylock (__lock);
578}
579
580__extern_inline int
581pthread_spin_unlock (pthread_spinlock_t *__lock)
582{
583 return __pthread_spin_unlock (__lock);
584}
585
586# endif /* Use extern inlines. */
587
588601#endif /* XPG6. */
589602
590603
......@@ -658,6 +671,13 @@ extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict __rwl
658671 __THROWNL __nonnull ((1, 2));
659672# endif
660673
674# ifdef __USE_GNU
675extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
676 clockid_t __clockid,
677 const struct timespec *__restrict
678 __abstime) __THROWNL __nonnull ((1, 3));
679# endif
680
661681/* Acquire the rwlock *RWLOCK for writing. */
662682extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
663683 __THROWNL __nonnull ((1));
......@@ -674,6 +694,13 @@ extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict __rwl
674694 __THROWNL __nonnull ((1, 2));
675695# endif
676696
697# ifdef __USE_GNU
698extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
699 clockid_t __clockid,
700 const struct timespec *__restrict
701 __abstime) __THROWNL __nonnull ((1, 3));
702# endif
703
677704/* Release the lock held by the current thread on *RWLOCK. */
678705extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
679706 __THROWNL __nonnull ((1));
......@@ -795,14 +822,14 @@ extern void *pthread_getspecific (pthread_key_t __key) __THROW;
795822
796823/* Set the caller thread's thread specific value of KEY to VALUE. */
797824extern int pthread_setspecific (pthread_key_t __key, const void *__value)
798 __THROW;
825 __THROW __attr_access_none (2);
799826
800827
801828/* Dynamic package initialization. */
802829
803830#include <bits/types/struct___pthread_once.h>
804831
805#define PTHREAD_ONCE_INIT __PTHREAD_ONCE_INIT
832#define PTHREAD_ONCE_INIT (struct __pthread_once) { __PTHREAD_ONCE_INIT }
806833
807834/* Call INIT_ROUTINE if this function has never been called with
808835 *ONCE_CONTROL, otherwise do nothing. */
lib/libc/glibc/sysdeps/i386/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/i386/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for x86.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/i386/htl/bits/pthreadtypes-arch.h+1-1
......@@ -1,5 +1,5 @@
11/* Machine-specific pthread type layouts. Hurd i386 version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/i386/start.S+7-9
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF i386 ABI.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -87,11 +87,9 @@ ENTRY (_start)
8787 call 1f
8888 addl $_GLOBAL_OFFSET_TABLE_, %ebx
8989
90 /* Push address of our own entry points to .fini and .init. */
91 leal __libc_csu_fini@GOTOFF(%ebx), %eax
92 pushl %eax
93 leal __libc_csu_init@GOTOFF(%ebx), %eax
94 pushl %eax
90 /* This used to be the addresses of .fini and .init. */
91 pushl $0
92 pushl $0
9593
9694 pushl %ecx /* Push second argument: argv. */
9795 pushl %esi /* Push first argument: argc. */
......@@ -112,9 +110,9 @@ ENTRY (_start)
112110 But let the libc call main. */
113111 call __libc_start_main@PLT
114112#else
115 /* Push address of our own entry points to .fini and .init. */
116 pushl $__libc_csu_fini
117 pushl $__libc_csu_init
113 /* This used to be the addresses of .fini and .init. */
114 pushl $0
115 pushl $0
118116
119117 pushl %ecx /* Push second argument: argv. */
120118 pushl %esi /* Push first argument: argc. */
lib/libc/glibc/sysdeps/i386/symbol-hacks.h+1-1
......@@ -1,5 +1,5 @@
11/* Hacks needed for symbol manipulation. i386 version.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/i386/sysdep.h+3-5
......@@ -1,5 +1,5 @@
11/* Assembler macros for i386.
2 Copyright (C) 1991-2020 Free Software Foundation, Inc.
2 Copyright (C) 1991-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -18,8 +18,6 @@
1818
1919#include <sysdeps/x86/sysdep.h>
2020
21#include <features.h> /* For __GNUC_PREREQ. */
22
2321/* It is desirable that the names of PIC thunks match those used by
2422 GCC so that multiple copies are eliminated by the linker. Because
2523 GCC 4.6 and earlier use __i686 in the names, it is necessary to
......@@ -97,9 +95,9 @@ GET_PC_THUNK(reg): \
9795
9896# define SETUP_PIC_REG_STR(reg) \
9997 ".ifndef " GET_PC_THUNK_STR (reg) "\n" \
100 "section .text." GET_PC_THUNK_STR (reg) ",\"axG\",@progbits," \
98 ".section .text." GET_PC_THUNK_STR (reg) ",\"axG\",@progbits," \
99 GET_PC_THUNK_STR (reg) ",comdat\n" \
101100 ".globl " GET_PC_THUNK_STR (reg) "\n" \
102 GET_PC_THUNK_STR (reg) ",comdat\n" \
103101 ".hidden " GET_PC_THUNK_STR (reg) "\n" \
104102 ".p2align 4\n" \
105103 ".type " GET_PC_THUNK_STR (reg) ",@function\n" \
lib/libc/glibc/sysdeps/ia64/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for IA64.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/ia64/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for ARM.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/ia64/dl-dtprocnum.h+1-1
......@@ -1,5 +1,5 @@
11/* Configuration of lookup functions. IA-64 version.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/ia64/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. IA-64 version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/ia64/nptl/bits/pthreadtypes-arch.h deleted-63
......@@ -1,63 +0,0 @@
1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Jakub Jelinek <jakub@redhat.com>, 2003.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#define __SIZEOF_PTHREAD_ATTR_T 56
23#define __SIZEOF_PTHREAD_MUTEX_T 40
24#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
25#define __SIZEOF_PTHREAD_COND_T 48
26#define __SIZEOF_PTHREAD_CONDATTR_T 4
27#define __SIZEOF_PTHREAD_RWLOCK_T 56
28#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
29#define __SIZEOF_PTHREAD_BARRIER_T 32
30#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
31
32/* Definitions for internal mutex struct. */
33#define __PTHREAD_COMPAT_PADDING_MID
34#define __PTHREAD_COMPAT_PADDING_END
35#define __PTHREAD_MUTEX_LOCK_ELISION 0
36#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 0
37#define __PTHREAD_MUTEX_USE_UNION 0
38
39#define __LOCK_ALIGNMENT
40#define __ONCE_ALIGNMENT
41
42/* Data structure for reader-write lock variable handling. The
43 structure of the attribute type is not exposed on purpose. */
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers;
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52 int __cur_writer;
53 int __shared;
54 unsigned long int __pad1;
55 unsigned long int __pad2;
56 /* FLAGS must stay at this position in the structure to maintain
57 binary compatibility. */
58 unsigned int __flags;
59};
60
61#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
62
63#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/ia64/start.S+3-8
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
44
......@@ -82,20 +82,15 @@ _start:
8282 {
8383 addl r11 = @ltoff(__libc_ia64_register_backing_store_base), gp
8484 addl out0 = @ltoff(@fptr(main)), gp
85 addl out3 = @ltoff(@fptr(__libc_csu_init)), gp
85 mov out3 = r0 /* Used to be init. */
8686 ;;
8787 }
8888 { .mmi
8989 ld8 r3 = [r11] /* pointer to __libc_ia64_register_backing_store_base */
9090 ld8 out0 = [out0] /* pointer to `main' function descriptor */
91 addl out4 = @ltoff(@fptr(__libc_csu_fini)), gp
91 mov out4 = r0 /* Used to be fini. */
9292 ;;
9393 }
94 { .mmi
95 ld8 out3 = [out3] /* pointer to `init' function descriptor */
96 ld8 out4 = [out4] /* pointer to `fini' function descriptor */
97 nop 0
98 }
9994 .body
10095 { .mib
10196 st8 [r3] = r10
lib/libc/glibc/sysdeps/ia64/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
44
lib/libc/glibc/sysdeps/init_array/crti.S deleted-27
......@@ -1,27 +0,0 @@
1/* Dummy crti file.
2
3 In this configuration, crti.o and crtn.o are both empty because the
4 .init_array/.fini_array sections are used exclusively.
5
6 Older ports cannot use this because even if the linker used to
7 build libc itself has .init_array support, we don't want to produce
8 a crt[in].o that presume a linker that new will be used to link
9 other things later.
10
11 But new configurations without compatibility concerns for
12 toolchains without .init_array support can use this to avoid the
13 superfluous .init and .fini boilerplate code. */
14
15#ifdef PREINIT_FUNCTION
16
17#if PREINIT_FUNCTION_WEAK
18# error PREINIT_FUNCTION_WEAK is unsupported
19#endif
20
21/* This arranges for PREINIT_FUNCTION to be called upon loading a library that
22 contains crti.o. */
23
24 .section .init_array,"a",%init_array
25 .dc.a PREINIT_FUNCTION
26
27#endif
lib/libc/glibc/sysdeps/init_array/crtn.S deleted-13
......@@ -1,13 +0,0 @@
1/* Dummy crtn file.
2
3 In this configuration, crti.o and crtn.o are both empty because the
4 .init_array/.fini_array sections are used exclusively.
5
6 Older ports cannot use this because even if the linker used to
7 build libc itself has .init_array support, we don't want to produce
8 a crt[in].o that presume a linker that new will be used to link
9 other things later.
10
11 But new configurations without compatibility concerns for
12 toolchains without .init_array support can use this to avoid the
13 superfluous .init and .fini boilerplate code. */
lib/libc/glibc/sysdeps/m68k/coldfire/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for Coldfire.
2 Copyright (C) 1998-2020 Free Software Foundation, Inc.
2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/m68k/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/m68k/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for m68k.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/m68k/m680x0/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for m680x0.
2 Copyright (C) 2010-2020 Free Software Foundation, Inc.
2 Copyright (C) 2010-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/m68k/nptl/bits/pthreadtypes-arch.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2010-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2010-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
44
lib/libc/glibc/sysdeps/m68k/start.S+5-10
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF m68k ABI.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -76,15 +76,14 @@ _start:
7676 pea (%a1) /* Push address of the shared library
7777 termination function. */
7878
79 /* These used to be addresses of the .fini and .init entry points. */
80 clr.l -(%sp)
81 clr.l -(%sp)
82
7983#ifdef PIC
8084 /* Load PIC register. */
8185 LOAD_GOT (%a5)
8286
83 /* Push the address of our own entry points to `.fini' and
84 `.init'. */
85 move.l __libc_csu_fini@GOT(%a5), -(%sp)
86 move.l __libc_csu_init@GOT(%a5), -(%sp)
87
8887 pea (%a0) /* Push second argument: argv. */
8988 move.l %d0, -(%sp) /* Push first argument: argc. */
9089
......@@ -94,10 +93,6 @@ _start:
9493 let the libc call main. */
9594 jbsr __libc_start_main@PLTPC
9695#else
97 /* Push the address of our own entry points to `.fini' and
98 `.init'. */
99 pea __libc_csu_fini
100 pea __libc_csu_init
10196
10297 pea (%a0) /* Push second argument: argv. */
10398 move.l %d0, -(%sp) /* Push first argument: argc. */
lib/libc/glibc/sysdeps/m68k/symbol-hacks.h+1-1
......@@ -1,5 +1,5 @@
11/* Hacks needed for symbol manipulation. m68k version.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/m68k/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for m68k.
2 Copyright (C) 1998-2020 Free Software Foundation, Inc.
2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mach/hurd/bits/stat.h deleted-263
......@@ -1,263 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/types.h>
26
27/* NOTE: The size of this structure (32 ints) is known in
28 <hurd/hurd_types.defs>, since it is used in the `io_stat' RPC. MiG
29 does not cope at all well with the passed C structure not being of
30 the expected size. There are some filler words at the end to allow
31 for future expansion. To increase the size of the structure used
32 in the RPC and retain binary compatibility, we would need to assign
33 a new message number. */
34
35struct stat
36 {
37 int st_fstype; /* File system type. */
38 __fsid_t st_fsid; /* File system ID. */
39#define st_dev st_fsid
40
41#ifndef __USE_FILE_OFFSET64
42 __ino_t st_ino; /* File number. */
43#else
44 __ino64_t st_ino; /* File number. */
45#endif
46 unsigned int st_gen; /* To detect reuse of file numbers. */
47 __dev_t st_rdev; /* Device if special file. */
48 __mode_t st_mode; /* File mode. */
49 __nlink_t st_nlink; /* Number of links. */
50
51 __uid_t st_uid; /* Owner. */
52 __gid_t st_gid; /* Owning group. */
53
54#ifndef __USE_FILE_OFFSET64
55 __off_t st_size; /* Size in bytes. */
56#else
57 __off64_t st_size; /* Size in bytes. */
58#endif
59
60#ifdef __USE_XOPEN2K8
61 /* Nanosecond resolution timestamps are stored in a format
62 equivalent to 'struct timespec'. This is the type used
63 whenever possible but the Unix namespace rules do not allow the
64 identifier 'timespec' to appear in the <sys/stat.h> header.
65 Therefore we have to handle the use of this header in strictly
66 standard-compliant sources special. */
67 struct timespec st_atim; /* Time of last access. */
68 struct timespec st_mtim; /* Time of last modification. */
69 struct timespec st_ctim; /* Time of last status change. */
70# define st_atime st_atim.tv_sec /* Backward compatibility. */
71# define st_mtime st_mtim.tv_sec
72# define st_ctime st_ctim.tv_sec
73#else
74 __time_t st_atime; /* Time of last access. */
75 unsigned long int st_atimensec; /* Nscecs of last access. */
76 __time_t st_mtime; /* Time of last modification. */
77 unsigned long int st_mtimensec; /* Nsecs of last modification. */
78 __time_t st_ctime; /* Time of last status change. */
79 unsigned long int st_ctimensec; /* Nsecs of last status change. */
80#endif
81
82 __blksize_t st_blksize; /* Optimal size for I/O. */
83
84#ifndef __USE_FILE_OFFSET64
85 __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated.
86 Not related to `st_blksize'. */
87#else
88 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
89 Not related to `st_blksize'. */
90#endif
91
92 __uid_t st_author; /* File author. */
93
94 unsigned int st_flags; /* User-defined flags.
95 High 16 bits can be set only by root. */
96
97#ifndef __USE_FILE_OFFSET64
98# define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 12 : 11)
99#else
100# define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
101#endif
102 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
103#undef _SPARE_SIZE
104 };
105
106#ifdef __USE_LARGEFILE64
107struct stat64
108 {
109 int st_fstype; /* File system type. */
110 __fsid_t st_fsid; /* File system ID. */
111# define st_dev st_fsid
112
113 __ino64_t st_ino; /* File number. */
114 unsigned int st_gen; /* To detect reuse of file numbers. */
115 __dev_t st_rdev; /* Device if special file. */
116 __mode_t st_mode; /* File mode. */
117 __nlink_t st_nlink; /* Number of links. */
118
119 __uid_t st_uid; /* Owner. */
120 __gid_t st_gid; /* Owning group. */
121
122 __off64_t st_size; /* Size in bytes. */
123
124#ifdef __USE_XOPEN2K8
125 /* Nanosecond resolution timestamps are stored in a format
126 equivalent to 'struct timespec'. This is the type used
127 whenever possible but the Unix namespace rules do not allow the
128 identifier 'timespec' to appear in the <sys/stat.h> header.
129 Therefore we have to handle the use of this header in strictly
130 standard-compliant sources special. */
131 struct timespec st_atim; /* Time of last access. */
132 struct timespec st_mtim; /* Time of last modification. */
133 struct timespec st_ctim; /* Time of last status change. */
134#else
135 __time_t st_atime; /* Time of last access. */
136 unsigned long int st_atimensec; /* Nscecs of last access. */
137 __time_t st_mtime; /* Time of last modification. */
138 unsigned long int st_mtimensec; /* Nsecs of last modification. */
139 __time_t st_ctime; /* Time of last status change. */
140 unsigned long int st_ctimensec; /* Nsecs of last status change. */
141#endif
142
143 __blksize_t st_blksize; /* Optimal size for I/O. */
144
145 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated.
146 Not related to `st_blksize'. */
147
148 __uid_t st_author; /* File author. */
149
150 unsigned int st_flags; /* User-defined flags.
151 High 16 bits can be set only by root. */
152
153#define _SPARE_SIZE ((sizeof (__fsid_t) == sizeof (int)) ? 9 : 8)
154 int st_spare[_SPARE_SIZE]; /* Room for future expansion. */
155#undef _SPARE_SIZE
156 };
157#endif
158
159/* Tell code we have these members. */
160#define _STATBUF_ST_BLKSIZE
161/* Nanosecond resolution time values are supported. */
162#define _STATBUF_ST_NSEC
163
164/* Encoding of the file mode. */
165
166#define __S_IFMT 0170000 /* These bits determine file type. */
167
168/* File types. */
169#define __S_IFDIR 0040000 /* Directory. */
170#define __S_IFCHR 0020000 /* Character device. */
171#define __S_IFBLK 0060000 /* Block device. */
172#define __S_IFREG 0100000 /* Regular file. */
173#define __S_IFLNK 0120000 /* Symbolic link. */
174#define __S_IFSOCK 0140000 /* Socket. */
175#define __S_IFIFO 0010000 /* FIFO. */
176
177/* POSIX.1b objects. */
178#define __S_TYPEISMQ(buf) (0)
179#define __S_TYPEISSEM(buf) (0)
180#define __S_TYPEISSHM(buf) (0)
181
182/* Protection bits. */
183
184#define __S_ISUID 04000 /* Set user ID on execution. */
185#define __S_ISGID 02000 /* Set group ID on execution. */
186#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
187#define __S_IREAD 00400 /* Read by owner. */
188#define __S_IWRITE 00200 /* Write by owner. */
189#define __S_IEXEC 00100 /* Execute by owner. */
190
191
192#ifdef __USE_GNU
193/* If set, there is no benefit in caching the contents of this file. */
194#define S_INOCACHE 000000200000
195
196/* If the S_IUSEUNK bit is set, then the S_IUNKNOWN bits (see below)
197 control access for unknown users. If S_IUSEUNK is clear, then unknown
198 users are treated as "others" for purposes of access control. */
199#define S_IUSEUNK 000000400000
200/* Mask of protection bits for unknown users (no effective IDs at all). */
201#define S_IUNKNOWN 000007000000
202/* Shift S_IREAD, S_IWRITE, S_IEXEC left this many bits to produce the
203 protection bits for unknown users. */
204#define S_IUNKSHIFT 12
205
206/* Read only bits: */
207
208/* There is a passive translator set for this file */
209#define S_IPTRANS 000010000000
210/* There is an active translator running on this file */
211#define S_IATRANS 000020000000
212/* This is the root of a filesystem (or single node translator) */
213#define S_IROOT 000040000000
214/* All the bits relevant to translators */
215#define S_ITRANS 000070000000
216
217/* Definitely no mmaps to this. */
218#define S_IMMAP0 000100000000
219
220/* ALL the unused bits. */
221#define S_ISPARE (~(S_IFMT|S_ITRANS|S_INOCACHE|S_IMMAP0 \
222 |S_IUSEUNK|S_IUNKNOWN|07777))
223#endif
224
225#ifdef __USE_MISC
226/* Default file creation mask (umask). */
227# define CMASK 0022
228
229/* Definitions of flags stored in file flags word. */
230
231/* Super-user and owner changeable flags. */
232# define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
233# define UF_NODUMP 0x00000001 /* do not dump file */
234# define UF_IMMUTABLE 0x00000002 /* file may not be changed */
235# define UF_APPEND 0x00000004 /* writes to file may only append */
236# define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
237# define UF_NOUNLINK 0x00000010 /* file may not be removed or renamed */
238
239/* Super-user changeable flags. */
240# define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
241# define SF_ARCHIVED 0x00010000 /* file is archived */
242# define SF_IMMUTABLE 0x00020000 /* file may not be changed */
243# define SF_APPEND 0x00040000 /* writes to file may only append */
244# define SF_NOUNLINK 0x00100000 /* file may not be removed or renamed */
245# define SF_SNAPSHOT 0x00200000 /* snapshot inode */
246
247__BEGIN_DECLS
248
249/* Set file flags for FILE to FLAGS. */
250extern int chflags (__const char *__file, unsigned long int __flags) __THROW;
251
252/* Set file flags of the file referred to by FD to FLAGS. */
253extern int fchflags (int __fd, unsigned long int __flags) __THROW;
254
255__END_DECLS
256#endif
257
258#ifdef __USE_ATFILE
259# define UTIME_NOW -1 /* corresponds to the current time */
260# define UTIME_OMIT -2 /* target time is omitted */
261#endif
262
263#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/mach/hurd/bits/typesizes.h deleted-72
......@@ -1,72 +0,0 @@
1/* bits/typesizes.h -- underlying types for *_t. Hurd version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_TYPES_H
20# error "Never include <bits/typesizes.h> directly; use <sys/types.h> instead."
21#endif
22
23#ifndef _BITS_TYPESIZES_H
24#define _BITS_TYPESIZES_H 1
25
26/* See <bits/types.h> for the meaning of these macros. This file exists so
27 that <bits/types.h> need not vary across different GNU platforms. */
28
29#define __DEV_T_TYPE __U32_TYPE
30#define __UID_T_TYPE __U32_TYPE
31#define __GID_T_TYPE __U32_TYPE
32#define __INO_T_TYPE __ULONGWORD_TYPE
33#define __INO64_T_TYPE __UQUAD_TYPE
34#define __MODE_T_TYPE __U32_TYPE
35#define __NLINK_T_TYPE __UWORD_TYPE
36#define __OFF_T_TYPE __SLONGWORD_TYPE
37#define __OFF64_T_TYPE __SQUAD_TYPE
38#define __PID_T_TYPE __S32_TYPE
39#define __RLIM_T_TYPE __ULONGWORD_TYPE
40#define __RLIM64_T_TYPE __UQUAD_TYPE
41#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
42#define __BLKCNT64_T_TYPE __SQUAD_TYPE
43#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
44#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
45#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
46#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
47#define __FSWORD_T_TYPE __SWORD_TYPE
48#define __ID_T_TYPE __U32_TYPE
49#define __CLOCK_T_TYPE __SLONGWORD_TYPE
50#define __TIME_T_TYPE __SLONGWORD_TYPE
51#define __USECONDS_T_TYPE __U32_TYPE
52#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __DADDR_T_TYPE __S32_TYPE
54#define __KEY_T_TYPE __S32_TYPE
55#define __CLOCKID_T_TYPE __S32_TYPE
56#define __TIMER_T_TYPE __S32_TYPE
57#define __BLKSIZE_T_TYPE __SLONGWORD_TYPE
58#define __FSID_T_TYPE __UQUAD_TYPE
59#define __SSIZE_T_TYPE __SWORD_TYPE
60#define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE
61#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
62#define __CPU_MASK_TYPE __ULONGWORD_TYPE
63
64/* Number of descriptors that can fit in an `fd_set'. */
65#define __FD_SETSIZE 256
66
67/* Tell the libc code that fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and
68 fsfilcnt64_t are not the same type for all ABI purposes. */
69# define __STATFS_MATCHES_STATFS64 0
70
71
72#endif /* bits/typesizes.h */
lib/libc/glibc/sysdeps/mach/hurd/dl-sysdep.h deleted-31
......@@ -1,31 +0,0 @@
1/* System-specific settings for dynamic linker code. Hurd version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* The private errno doesn't make sense on the Hurd. errno is always the
20 thread-local slot shared with libc, and it matters to share the cell
21 with libc because after startup we use libc functions that set errno
22 (open, mmap, etc). */
23
24#define RTLD_PRIVATE_ERRNO 0
25
26#ifdef SHARED
27/* _dl_argv and __libc_stack_end cannot be attribute_relro, because the stack-switching
28 libc initializer for using cthreads might write into it. */
29# define DL_ARGV_NOT_RELRO 1
30# define LIBC_STACK_END_NOT_RELRO 1
31#endif
lib/libc/glibc/sysdeps/mach/hurd/kernel-features.h deleted-21
......@@ -1,21 +0,0 @@
1/* Set flags signalling availability of certain operating system features.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* This file can define __ASSUME_* macros checked by certain source files.
20 Almost none of these are used outside of sysdeps/unix/sysv/linux code.
21 But those referring to POSIX-level features like O_* flags can be. */
lib/libc/glibc/sysdeps/mach/i386/sysdep.h+1-11
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -39,16 +39,6 @@
3939 envp = p; \
4040 } while (0)
4141
42#define CALL_WITH_SP(fn, info, sp) \
43 do { \
44 void **ptr = (void **) sp; \
45 *--(__typeof (info) *) ptr = info; \
46 ptr[-1] = ptr; \
47 --ptr; \
48 asm volatile ("movl %0, %%esp; call %1" : : \
49 "g" (ptr), "m" (*(long int *) (fn)) : "%esp"); \
50 } while (0)
51
5242#define RETURN_TO(sp, pc, retval) \
5343 asm volatile ("movl %0, %%esp; jmp %*%1 # %2" \
5444 : : "g" (sp), "r" (pc), "a" (retval))
lib/libc/glibc/sysdeps/mach/libc-lock.h+11-14
......@@ -1,5 +1,5 @@
11/* libc-internal interface for mutex locks. Mach cthreads version.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -24,9 +24,6 @@
2424#include <tls.h>
2525#include <lowlevellock.h>
2626
27/* The locking here is very inexpensive, even for inlining. */
28#define _IO_lock_inexpensive 1
29
3027typedef unsigned int __libc_lock_t;
3128typedef struct
3229{
......@@ -57,13 +54,13 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
5754 CLASS __libc_lock_t NAME;
5855
5956/* Define an initialized lock variable NAME with storage class CLASS. */
60#define _LIBC_LOCK_INITIALIZER LLL_INITIALIZER
57#define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER
6158#define __libc_lock_define_initialized(CLASS,NAME) \
62 CLASS __libc_lock_t NAME = LLL_INITIALIZER;
59 CLASS __libc_lock_t NAME = LLL_LOCK_INITIALIZER;
6360
6461/* Initialize the named lock variable, leaving it in a consistent, unlocked
6562 state. */
66#define __libc_lock_init(NAME) (NAME) = LLL_INITIALIZER
63#define __libc_lock_init(NAME) (NAME) = LLL_LOCK_INITIALIZER
6764
6865/* Finalize the named lock variable, which must be locked. It cannot be
6966 used again until __libc_lock_init is called again on it. This must be
......@@ -74,19 +71,19 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
7471
7572/* Lock the named lock variable. */
7673#define __libc_lock_lock(NAME) \
77 ({ lll_lock (&(NAME), 0); 0; })
74 ({ lll_lock ((NAME), 0); 0; })
7875
7976/* Lock the named lock variable. */
80#define __libc_lock_trylock(NAME) lll_trylock (&(NAME))
77#define __libc_lock_trylock(NAME) lll_trylock (NAME)
8178
8279/* Unlock the named lock variable. */
8380#define __libc_lock_unlock(NAME) \
84 ({ lll_unlock (&(NAME), 0); 0; })
81 ({ lll_unlock ((NAME), 0); 0; })
8582
8683#define __libc_lock_define_recursive(CLASS,NAME) \
8784 CLASS __libc_lock_recursive_t NAME;
8885
89#define _LIBC_LOCK_RECURSIVE_INITIALIZER { LLL_INITIALIZER, 0, 0 }
86#define _LIBC_LOCK_RECURSIVE_INITIALIZER { LLL_LOCK_INITIALIZER, 0, 0 }
9087
9188#define __libc_lock_define_initialized_recursive(CLASS,NAME) \
9289 CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
......@@ -111,7 +108,7 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
111108 int __r = 0; \
112109 if (__self == __lock->owner) \
113110 ++__lock->cnt; \
114 else if ((__r = lll_trylock (&__lock->lock)) == 0) \
111 else if ((__r = lll_trylock (__lock->lock)) == 0) \
115112 __lock->owner = __self, __lock->cnt = 1; \
116113 __r; \
117114 })
......@@ -122,7 +119,7 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
122119 void *__self = __libc_lock_owner_self (); \
123120 if (__self != __lock->owner) \
124121 { \
125 lll_lock (&__lock->lock, 0); \
122 lll_lock (__lock->lock, 0); \
126123 __lock->owner = __self; \
127124 } \
128125 ++__lock->cnt; \
......@@ -135,7 +132,7 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
135132 if (--__lock->cnt == 0) \
136133 { \
137134 __lock->owner = 0; \
138 lll_unlock (&__lock->lock, 0); \
135 lll_unlock (__lock->lock, 0); \
139136 } \
140137 })
141138
lib/libc/glibc/sysdeps/mach/sysdep.h+1-9
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1994-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -62,14 +62,6 @@
6262#error SNARF_ARGS not defined by sysdeps/mach/MACHINE/sysdep.h
6363#endif
6464
65/* Call the C function FN with no arguments,
66 on a stack starting at SP (as returned by *_cthread_init_routine).
67 You don't need to deal with FN returning; it shouldn't. */
68#ifndef CALL_WITH_SP
69#define CALL_WITH_SP(fn, sp)
70#error CALL_WITH_SP not defined by sysdeps/mach/MACHINE/sysdep.h
71#endif
72
7365/* LOSE can be defined as the `halt' instruction or something
7466 similar which will cause the process to die in a characteristic
7567 way suggesting a bug. */
lib/libc/glibc/sysdeps/microblaze/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/microblaze/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MicroBlaze.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h deleted-72
......@@ -1,72 +0,0 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20# define _BITS_PTHREADTYPES_ARCH_H 1
21
22# include <endian.h>
23
24# define __SIZEOF_PTHREAD_ATTR_T 36
25# define __SIZEOF_PTHREAD_MUTEX_T 24
26# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
27# define __SIZEOF_PTHREAD_COND_T 48
28# define __SIZEOF_PTHREAD_CONDATTR_T 4
29# define __SIZEOF_PTHREAD_RWLOCK_T 32
30# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
31# define __SIZEOF_PTHREAD_BARRIER_T 20
32# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
33
34/* Definitions for internal mutex struct. */
35#define __PTHREAD_COMPAT_PADDING_MID
36#define __PTHREAD_COMPAT_PADDING_END
37#define __PTHREAD_MUTEX_LOCK_ELISION 0
38#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
39#define __PTHREAD_MUTEX_USE_UNION 1
40
41#define __LOCK_ALIGNMENT
42#define __ONCE_ALIGNMENT
43
44struct __pthread_rwlock_arch_t
45{
46 unsigned int __readers;
47 unsigned int __writers;
48 unsigned int __wrphase_futex;
49 unsigned int __writers_futex;
50 unsigned int __pad3;
51 unsigned int __pad4;
52# if __BYTE_ORDER == __BIG_ENDIAN
53 unsigned char __pad1;
54 unsigned char __pad2;
55 unsigned char __shared;
56 /* FLAGS must stay at this position in the structure to maintain
57 binary compatibility. */
58 unsigned char __flags;
59# else
60 /* FLAGS must stay at this position in the structure to maintain
61 binary compatibility. */
62 unsigned char __flags;
63 unsigned char __shared;
64 unsigned char __pad1;
65 unsigned char __pad2;
66# endif
67 int __cur_writer;
68};
69
70# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
71
72#endif /* bits/pthreadtypes.h. */
lib/libc/glibc/sysdeps/microblaze/start.S+5-5
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -63,14 +63,14 @@ _start:
6363 mfs r20,rpc
6464 addik r20,r20,_GLOBAL_OFFSET_TABLE_+8
6565 lwi r5,r20,main@GOT
66 lwi r8,r20,__libc_csu_init@GOT
67 lwi r9,r20,__libc_csu_fini@GOT
66 addk r8,r0,r0 /* Used to be init. */
67 addk r9,r0,r0 /* Used to be fini. */
6868 brid __libc_start_main@PLT
6969 addk r10,r0,r0
7070#else
7171 addik r5,r0,main
72 addik r8,r0,__libc_csu_init
73 addik r9,r0,__libc_csu_fini
72 addk r8,r0,r0 /* Used to be init. */
73 addk r9,r0,r0 /* Used to be fini. */
7474 brid __libc_start_main
7575 addk r10,r0,r0
7676#endif
lib/libc/glibc/sysdeps/microblaze/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
lib/libc/glibc/sysdeps/mips/dl-dtprocnum.h+1-1
......@@ -1,5 +1,5 @@
11/* Configuration of lookup functions. MIPS version.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips32/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips32/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (o32).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips64/n32/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips64/n32/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (n32).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips64/n64/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/mips64/n64/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for MIPS (n64).
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/nptl/bits/pthreadtypes-arch.h+1-1
......@@ -1,5 +1,5 @@
11/* Machine-specific pthread type layouts. MIPS version.
2 Copyright (C) 2005-2020 Free Software Foundation, Inc.
2 Copyright (C) 2005-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/mips/start.S+8-12
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF Mips ABI.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -96,13 +96,13 @@ ENTRY_POINT:
9696# if _MIPS_SIM == _ABIO32
9797 PTR_SUBIU $29, 32
9898# endif
99 PTR_LA $7, __libc_csu_init /* init */
100 PTR_LA $8, __libc_csu_fini
99 move $7, $0 /* Used to be init. */
101100# if _MIPS_SIM == _ABIO32
102 PTR_S $8, 16($29) /* fini */
101 PTR_S $0, 16($29) /* Used to be fini. */
103102 PTR_S $2, 20($29) /* rtld_fini */
104103 PTR_S $29, 24($29) /* stack_end */
105104# else
105 move $8, $0 /* Used to be fini. */
106106 move $9, $2 /* rtld_fini */
107107 move $10, $29 /* stack_end */
108108# endif
......@@ -143,19 +143,17 @@ ENTRY_POINT:
143143 /* Lay out last arguments, and call __libc_start_main(). */
144144# ifdef __PIC__
145145 sw $7, 24($sp) /* stack_end */
146 lw $4, %got(__libc_csu_fini)($3)
147 lw $7, %got(__libc_csu_init)($3) /* init */
148 sw $4, 16($sp) /* fini */
146 move $4, $0 /* Used to be ini. */
147 sw $0, 16($sp) /* Used to be fini. */
149148 lw $4, %got(main)($3) /* main */
150149 lw $3, %call16(__libc_start_main)($3)
151150 sw $2, 20($sp) /* rtld_fini */
152151 move $25, $3
153152 jalr $3
154153# else
155 lw $4, 1f
156154 sw $7, 24($sp) /* stack_end */
157 lw $7, 2f /* init */
158 sw $4, 16($sp) /* fini */
155 move $7, $0 /* Used to be init. */
156 sw $0, 16($sp) /* Used to be fini. */
159157 lw $4, 3f /* main */
160158 sw $2, 20($sp) /* rtld_fini */
161159 /* Load and call __libc_start_main(). */
......@@ -165,8 +163,6 @@ ENTRY_POINT:
165163hlt: b hlt /* Crash if somehow it does return. */
166164# ifndef __PIC__
167165 .align 2
1681: .word __libc_csu_fini
1692: .word __libc_csu_init
1701663: .word main
1711674: .word __libc_start_main
172168# endif
lib/libc/glibc/sysdeps/nptl/bits/pthreadtypes.h+1-1
......@@ -1,5 +1,5 @@
11/* Declaration of common pthread types for all architectures.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/nptl/bits/thread-shared-types.h+11-1
......@@ -1,5 +1,5 @@
11/* Common threading primitives definitions for both POSIX and C11.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -116,4 +116,14 @@ struct __pthread_cond_s
116116 unsigned int __g_signals[2];
117117};
118118
119typedef unsigned int __tss_t;
120typedef unsigned long int __thrd_t;
121
122typedef struct
123{
124 int __data __ONCE_ALIGNMENT;
125} __once_flag;
126
127#define __ONCE_FLAG_INIT { 0 }
128
119129#endif /* _THREAD_SHARED_TYPES_H */
lib/libc/glibc/sysdeps/nptl/libc-lock.h+31-30
......@@ -1,5 +1,5 @@
11/* libc-internal interface for mutex locks. NPTL version.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -143,39 +143,40 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
143143 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
144144#endif
145145
146/* Note that for I/O cleanup handling we are using the old-style
147 cancel handling. It does not have to be integrated with C++ since
148 no C++ code is called in the middle. The old-style handling is
149 faster and the support is not going away. */
150extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
151 void (*routine) (void *), void *arg);
152extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
153 int execute);
146/* Put the unwind buffer BUFFER on the per-thread callback stack. The
147 caller must fill BUFFER->__routine and BUFFER->__arg before calling
148 this function. */
149void __libc_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer);
150libc_hidden_proto (__libc_cleanup_push_defer)
151/* Remove BUFFER from the unwind callback stack. The caller must invoke
152 the callback if desired. */
153void __libc_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer);
154libc_hidden_proto (__libc_cleanup_pop_restore)
154155
155156/* Start critical region with cleanup. */
156#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
157 { struct _pthread_cleanup_buffer _buffer; \
158 int _avail; \
159 if (DOIT) { \
160 _avail = PTFAVAIL (_pthread_cleanup_push_defer); \
161 if (_avail) { \
162 __libc_ptf_call_always (_pthread_cleanup_push_defer, (&_buffer, FCT, \
163 ARG)); \
164 } else { \
165 _buffer.__routine = (FCT); \
166 _buffer.__arg = (ARG); \
167 } \
168 } else { \
169 _avail = 0; \
170 }
157#define __libc_cleanup_region_start(DOIT, FCT, ARG) \
158 { bool _cleanup_start_doit; \
159 struct _pthread_cleanup_buffer _buffer; \
160 /* Non-addressable copy of FCT, so that we avoid indirect calls on \
161 the non-unwinding path. */ \
162 void (*_cleanup_routine) (void *) = (FCT); \
163 _buffer.__arg = (ARG); \
164 if (DOIT) \
165 { \
166 _cleanup_start_doit = true; \
167 _buffer.__routine = _cleanup_routine; \
168 __libc_cleanup_push_defer (&_buffer); \
169 } \
170 else \
171 _cleanup_start_doit = false;
171172
172173/* End critical region with cleanup. */
173#define __libc_cleanup_region_end(DOIT) \
174 if (_avail) { \
175 __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
176 } else if (DOIT) \
177 _buffer.__routine (_buffer.__arg); \
178 }
174#define __libc_cleanup_region_end(DOIT) \
175 if (_cleanup_start_doit) \
176 __libc_cleanup_pop_restore (&_buffer); \
177 if (DOIT) \
178 _cleanup_routine (_buffer.__arg); \
179 } /* matches __libc_cleanup_region_start */
179180
180181
181182/* Hide the definitions which are only supposed to be used inside libc in
lib/libc/glibc/sysdeps/nptl/libc-lockP.h+49-224
......@@ -1,5 +1,5 @@
11/* Private libc-internal interface for mutex locks. NPTL version.
2 Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 Copyright (C) 1996-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -32,26 +32,12 @@
3232 ld.so might be used on old kernels with a different libc.so. */
3333#include <lowlevellock.h>
3434#include <tls.h>
35#include <pthread-functions.h>
36
37#if IS_IN (libpthread)
38/* This gets us the declarations of the __pthread_* internal names,
39 and hidden_proto for them. */
40# include <nptl/pthreadP.h>
41#endif
4235
4336/* Mutex type. */
44#if !IS_IN (libc) && !IS_IN (libpthread)
45typedef pthread_mutex_t __libc_lock_t;
46#else
4737typedef int __libc_lock_t;
48#endif
4938typedef struct { pthread_mutex_t mutex; } __rtld_lock_recursive_t;
5039typedef pthread_rwlock_t __libc_rwlock_t;
5140
52/* Type for key to thread-specific data. */
53typedef pthread_key_t __libc_key_t;
54
5541/* Define a lock variable NAME with storage class CLASS. The lock must be
5642 initialized with __libc_lock_init before it can be used (or define it
5743 with __libc_lock_define_initialized, below). Use `extern' for CLASS to
......@@ -103,126 +89,48 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0");
10389 (FUNC != NULL ? FUNC ARGS : ELSE)
10490#endif
10591
106/* Call thread functions through the function pointer table. */
107#if defined SHARED && IS_IN (libc)
108# define PTFAVAIL(NAME) __libc_pthread_functions_init
109# define __libc_ptf_call(FUNC, ARGS, ELSE) \
110 (__libc_pthread_functions_init ? PTHFCT_CALL (ptr_##FUNC, ARGS) : ELSE)
111# define __libc_ptf_call_always(FUNC, ARGS) \
112 PTHFCT_CALL (ptr_##FUNC, ARGS)
113#elif IS_IN (libpthread)
114# define PTFAVAIL(NAME) 1
115# define __libc_ptf_call(FUNC, ARGS, ELSE) \
116 FUNC ARGS
117# define __libc_ptf_call_always(FUNC, ARGS) \
118 FUNC ARGS
119#else
120# define PTFAVAIL(NAME) (NAME != NULL)
121# define __libc_ptf_call(FUNC, ARGS, ELSE) \
122 __libc_maybe_call (FUNC, ARGS, ELSE)
123# define __libc_ptf_call_always(FUNC, ARGS) \
124 FUNC ARGS
125#endif
126
92/* All previously forwarded functions are now called directly (either
93 via local call in libc, or through a __export), but __libc_ptf_call
94 is still used in generic code shared with Hurd. */
95#define PTFAVAIL(NAME) 1
96#define __libc_ptf_call(FUNC, ARGS, ELSE) FUNC ARGS
97#define __libc_ptf_call_always(FUNC, ARGS) FUNC ARGS
12798
12899/* Initialize the named lock variable, leaving it in a consistent, unlocked
129100 state. */
130#if IS_IN (libc) || IS_IN (libpthread)
131# define __libc_lock_init(NAME) \
132 ((void) ((NAME) = LLL_LOCK_INITIALIZER))
133#else
134# define __libc_lock_init(NAME) \
135 __libc_maybe_call (__pthread_mutex_init, (&(NAME), NULL), 0)
136#endif
137#if defined SHARED && IS_IN (libc)
138/* ((NAME) = (__libc_rwlock_t) PTHREAD_RWLOCK_INITIALIZER) is inefficient. */
139# define __libc_rwlock_init(NAME) \
140 ((void) __builtin_memset (&(NAME), '\0', sizeof (NAME)))
141#else
142# define __libc_rwlock_init(NAME) \
143 __libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0)
144#endif
101#define __libc_lock_init(NAME) ((void) ((NAME) = LLL_LOCK_INITIALIZER))
102#define __libc_rwlock_init(NAME) __pthread_rwlock_init (&(NAME), NULL)
145103
146104/* Finalize the named lock variable, which must be locked. It cannot be
147105 used again until __libc_lock_init is called again on it. This must be
148106 called on a lock variable before the containing storage is reused. */
149#if IS_IN (libc) || IS_IN (libpthread)
150# define __libc_lock_fini(NAME) ((void) 0)
151#else
152# define __libc_lock_fini(NAME) \
153 __libc_maybe_call (__pthread_mutex_destroy, (&(NAME)), 0)
154#endif
155#if defined SHARED && IS_IN (libc)
156# define __libc_rwlock_fini(NAME) ((void) 0)
157#else
158# define __libc_rwlock_fini(NAME) \
159 __libc_maybe_call (__pthread_rwlock_destroy, (&(NAME)), 0)
160#endif
107#define __libc_lock_fini(NAME) ((void) 0)
108#define __libc_rwlock_fini(NAME) ((void) 0)
161109
162110/* Lock the named lock variable. */
163#if IS_IN (libc) || IS_IN (libpthread)
164# ifndef __libc_lock_lock
165# define __libc_lock_lock(NAME) \
166 ({ lll_lock (NAME, LLL_PRIVATE); 0; })
167# endif
168#else
169# undef __libc_lock_lock
170# define __libc_lock_lock(NAME) \
171 __libc_maybe_call (__pthread_mutex_lock, (&(NAME)), 0)
172#endif
173#define __libc_rwlock_rdlock(NAME) \
174 __libc_ptf_call (__pthread_rwlock_rdlock, (&(NAME)), 0)
175#define __libc_rwlock_wrlock(NAME) \
176 __libc_ptf_call (__pthread_rwlock_wrlock, (&(NAME)), 0)
111#define __libc_lock_lock(NAME) ({ lll_lock (NAME, LLL_PRIVATE); 0; })
112#define __libc_rwlock_rdlock(NAME) __pthread_rwlock_rdlock (&(NAME))
113#define __libc_rwlock_wrlock(NAME) __pthread_rwlock_wrlock (&(NAME))
177114
178115/* Try to lock the named lock variable. */
179#if IS_IN (libc) || IS_IN (libpthread)
180# ifndef __libc_lock_trylock
181# define __libc_lock_trylock(NAME) \
182 lll_trylock (NAME)
183# endif
184#else
185# undef __libc_lock_trylock
186# define __libc_lock_trylock(NAME) \
187 __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
188#endif
189#define __libc_rwlock_tryrdlock(NAME) \
190 __libc_maybe_call (__pthread_rwlock_tryrdlock, (&(NAME)), 0)
191#define __libc_rwlock_trywrlock(NAME) \
192 __libc_maybe_call (__pthread_rwlock_trywrlock, (&(NAME)), 0)
193
194#define __rtld_lock_trylock_recursive(NAME) \
195 __libc_maybe_call (__pthread_mutex_trylock, (&(NAME).mutex), 0)
116#define __libc_lock_trylock(NAME) lll_trylock (NAME)
196117
197118/* Unlock the named lock variable. */
198#if IS_IN (libc) || IS_IN (libpthread)
199# define __libc_lock_unlock(NAME) \
200 lll_unlock (NAME, LLL_PRIVATE)
201#else
202# define __libc_lock_unlock(NAME) \
203 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
204#endif
205#define __libc_rwlock_unlock(NAME) \
206 __libc_ptf_call (__pthread_rwlock_unlock, (&(NAME)), 0)
207
208#ifdef SHARED
209# define __rtld_lock_default_lock_recursive(lock) \
210 ++((pthread_mutex_t *)(lock))->__data.__count;
211
212# define __rtld_lock_default_unlock_recursive(lock) \
213 --((pthread_mutex_t *)(lock))->__data.__count;
119#define __libc_lock_unlock(NAME) lll_unlock (NAME, LLL_PRIVATE)
120#define __libc_rwlock_unlock(NAME) __pthread_rwlock_unlock (&(NAME))
214121
122#if IS_IN (rtld)
215123# define __rtld_lock_lock_recursive(NAME) \
216 GL(dl_rtld_lock_recursive) (&(NAME).mutex)
124 ___rtld_mutex_lock (&(NAME).mutex)
217125
218126# define __rtld_lock_unlock_recursive(NAME) \
219 GL(dl_rtld_unlock_recursive) (&(NAME).mutex)
220#else
127 ___rtld_mutex_unlock (&(NAME).mutex)
128#else /* Not in the dynamic loader. */
221129# define __rtld_lock_lock_recursive(NAME) \
222 __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
130 __pthread_mutex_lock (&(NAME).mutex)
223131
224132# define __rtld_lock_unlock_recursive(NAME) \
225 __libc_maybe_call (__pthread_mutex_unlock, (&(NAME).mutex), 0)
133 __pthread_mutex_unlock (&(NAME).mutex)
226134#endif
227135
228136/* Define once control variable. */
......@@ -236,74 +144,42 @@ _Static_assert (LLL_LOCK_INITIALIZER == 0, "LLL_LOCK_INITIALIZER != 0");
236144 CLASS pthread_once_t NAME = PTHREAD_ONCE_INIT
237145#endif
238146
239/* Call handler iff the first call. */
240#define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
241 do { \
242 if (PTFAVAIL (__pthread_once)) \
243 __libc_ptf_call_always (__pthread_once, (&(ONCE_CONTROL), \
244 INIT_FUNCTION)); \
245 else if ((ONCE_CONTROL) == PTHREAD_ONCE_INIT) { \
246 INIT_FUNCTION (); \
247 (ONCE_CONTROL) |= 2; \
248 } \
249 } while (0)
147/* Call handler iff the first call. Use a local call in libc, but the
148 global pthread_once symbol elsewhere. */
149#if IS_IN (libc)
150# define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
151 __pthread_once (&(ONCE_CONTROL), INIT_FUNCTION)
152#else
153# define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
154 pthread_once (&(ONCE_CONTROL), INIT_FUNCTION)
155#endif
250156
251157/* Get once control variable. */
252158#define __libc_once_get(ONCE_CONTROL) ((ONCE_CONTROL) != PTHREAD_ONCE_INIT)
253159
254/* Note that for I/O cleanup handling we are using the old-style
255 cancel handling. It does not have to be integrated with C++ snce
256 no C++ code is called in the middle. The old-style handling is
257 faster and the support is not going away. */
258extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
259 void (*routine) (void *), void *arg);
260extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
261 int execute);
262extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
263 void (*routine) (void *), void *arg);
264extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
265 int execute);
266
267/* Sometimes we have to exit the block in the middle. */
268#define __libc_cleanup_end(DOIT) \
269 if (_avail) { \
270 __libc_ptf_call_always (_pthread_cleanup_pop_restore, (&_buffer, DOIT));\
271 } else if (DOIT) \
272 _buffer.__routine (_buffer.__arg)
273
160/* __libc_cleanup_push and __libc_cleanup_pop depend on exception
161 handling and stack unwinding. */
162#ifdef __EXCEPTIONS
274163
275164/* Normal cleanup handling, based on C cleanup attribute. */
276__extern_inline void
165static __always_inline void
277166__libc_cleanup_routine (struct __pthread_cleanup_frame *f)
278167{
279168 if (f->__do_it)
280169 f->__cancel_routine (f->__cancel_arg);
281170}
282171
283#define __libc_cleanup_push(fct, arg) \
172# define __libc_cleanup_push(fct, arg) \
284173 do { \
285174 struct __pthread_cleanup_frame __clframe \
286175 __attribute__ ((__cleanup__ (__libc_cleanup_routine))) \
287176 = { .__cancel_routine = (fct), .__cancel_arg = (arg), \
288177 .__do_it = 1 };
289178
290#define __libc_cleanup_pop(execute) \
179# define __libc_cleanup_pop(execute) \
291180 __clframe.__do_it = (execute); \
292181 } while (0)
293
294
295/* Create thread-specific key. */
296#define __libc_key_create(KEY, DESTRUCTOR) \
297 __libc_ptf_call (__pthread_key_create, (KEY, DESTRUCTOR), 1)
298
299/* Get thread-specific data. */
300#define __libc_getspecific(KEY) \
301 __libc_ptf_call (__pthread_getspecific, (KEY), NULL)
302
303/* Set thread-specific data. */
304#define __libc_setspecific(KEY, VALUE) \
305 __libc_ptf_call (__pthread_setspecific, (KEY, VALUE), 0)
306
182#endif /* __EXCEPTIONS */
307183
308184/* Register handlers to execute before and after `fork'. Note that the
309185 last parameter is NULL. The handlers registered by the libc are
......@@ -318,107 +194,56 @@ extern int __register_atfork (void (*__prepare) (void),
318194
319195extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
320196 const pthread_mutexattr_t *__mutex_attr);
321
197libc_hidden_proto (__pthread_mutex_init)
322198extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
323
199libc_hidden_proto (__pthread_mutex_destroy)
324200extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
325201
326202extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
327
203libc_hidden_proto (__pthread_mutex_lock)
328204extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
329
330extern int __pthread_mutexattr_init (pthread_mutexattr_t *__attr);
205libc_hidden_proto (__pthread_mutex_unlock)
331206
332207extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *__attr);
333208
334extern int __pthread_mutexattr_settype (pthread_mutexattr_t *__attr,
335 int __kind);
336
337209extern int __pthread_rwlock_init (pthread_rwlock_t *__rwlock,
338210 const pthread_rwlockattr_t *__attr);
211libc_hidden_proto (__pthread_rwlock_init)
339212
340213extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
341214
342215extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
343
344extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
216libc_hidden_proto (__pthread_rwlock_rdlock)
345217
346218extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
347
348extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
219libc_hidden_proto (__pthread_rwlock_wrlock)
349220
350221extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
351
352extern int __pthread_key_create (pthread_key_t *__key,
353 void (*__destr_function) (void *));
354
355extern int __pthread_setspecific (pthread_key_t __key,
356 const void *__pointer);
357
358extern void *__pthread_getspecific (pthread_key_t __key);
359
222libc_hidden_proto (__pthread_rwlock_unlock)
360223extern int __pthread_once (pthread_once_t *__once_control,
361224 void (*__init_routine) (void));
225libc_hidden_proto (__pthread_once)
362226
363227extern int __pthread_atfork (void (*__prepare) (void),
364228 void (*__parent) (void),
365229 void (*__child) (void));
366230
367231extern int __pthread_setcancelstate (int state, int *oldstate);
368
232libc_hidden_proto (__pthread_setcancelstate)
369233
370234/* Make the pthread functions weak so that we can elide them from
371235 single-threaded processes. */
372236#ifndef __NO_WEAK_PTHREAD_ALIASES
373237# ifdef weak_extern
374weak_extern (__pthread_mutex_init)
375weak_extern (__pthread_mutex_destroy)
376weak_extern (__pthread_mutex_lock)
377238weak_extern (__pthread_mutex_trylock)
378weak_extern (__pthread_mutex_unlock)
379weak_extern (__pthread_mutexattr_init)
380239weak_extern (__pthread_mutexattr_destroy)
381weak_extern (__pthread_mutexattr_settype)
382weak_extern (__pthread_rwlock_init)
383weak_extern (__pthread_rwlock_destroy)
384weak_extern (__pthread_rwlock_rdlock)
385weak_extern (__pthread_rwlock_tryrdlock)
386weak_extern (__pthread_rwlock_wrlock)
387weak_extern (__pthread_rwlock_trywrlock)
388weak_extern (__pthread_rwlock_unlock)
389weak_extern (__pthread_key_create)
390weak_extern (__pthread_setspecific)
391weak_extern (__pthread_getspecific)
392weak_extern (__pthread_once)
393240weak_extern (__pthread_initialize)
394241weak_extern (__pthread_atfork)
395weak_extern (__pthread_setcancelstate)
396weak_extern (_pthread_cleanup_push_defer)
397weak_extern (_pthread_cleanup_pop_restore)
398242# else
399# pragma weak __pthread_mutex_init
400# pragma weak __pthread_mutex_destroy
401# pragma weak __pthread_mutex_lock
402243# pragma weak __pthread_mutex_trylock
403# pragma weak __pthread_mutex_unlock
404# pragma weak __pthread_mutexattr_init
405244# pragma weak __pthread_mutexattr_destroy
406# pragma weak __pthread_mutexattr_settype
407# pragma weak __pthread_rwlock_destroy
408# pragma weak __pthread_rwlock_rdlock
409# pragma weak __pthread_rwlock_tryrdlock
410# pragma weak __pthread_rwlock_wrlock
411# pragma weak __pthread_rwlock_trywrlock
412# pragma weak __pthread_rwlock_unlock
413# pragma weak __pthread_key_create
414# pragma weak __pthread_setspecific
415# pragma weak __pthread_getspecific
416# pragma weak __pthread_once
417245# pragma weak __pthread_initialize
418246# pragma weak __pthread_atfork
419# pragma weak __pthread_setcancelstate
420# pragma weak _pthread_cleanup_push_defer
421# pragma weak _pthread_cleanup_pop_restore
422247# endif
423248#endif
424249
lib/libc/glibc/sysdeps/nptl/pthread.h+203-28
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -27,7 +27,11 @@
2727#include <bits/setjmp.h>
2828#include <bits/wordsize.h>
2929#include <bits/types/struct_timespec.h>
30
30#include <bits/types/__sigset_t.h>
31#include <bits/types/struct___jmp_buf_tag.h>
32#ifdef __USE_MISC
33# include <bits/pthread_stack_min-dynamic.h>
34#endif
3135
3236/* Detach state. */
3337enum
......@@ -219,6 +223,7 @@ extern int pthread_join (pthread_t __th, void **__thread_return);
219223 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
220224extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
221225
226# ifndef __USE_TIME_BITS64
222227/* Make calling thread wait for termination of the thread TH, but only
223228 until TIMEOUT. The exit status of the thread is stored in
224229 *THREAD_RETURN, if THREAD_RETURN is not NULL.
......@@ -238,6 +243,23 @@ extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
238243extern int pthread_clockjoin_np (pthread_t __th, void **__thread_return,
239244 clockid_t __clockid,
240245 const struct timespec *__abstime);
246# else
247# ifdef __REDIRECT
248extern int __REDIRECT (pthread_timedjoin_np,
249 (pthread_t __th, void **__thread_return,
250 const struct timespec *__abstime),
251 __pthread_timedjoin_np64);
252
253extern int __REDIRECT (pthread_clockjoin_np,
254 (pthread_t __th, void **__thread_return,
255 clockid_t __clockid,
256 const struct timespec *__abstime),
257 __pthread_clockjoin_np64);
258# else
259# define pthread_timedjoin_np __pthread_timedjoin_np64
260# define pthread_clockjoin_np __pthread_clockjoin_np64
261# endif
262# endif
241263#endif
242264
243265/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
......@@ -385,6 +407,20 @@ extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
385407extern int pthread_getattr_default_np (pthread_attr_t *__attr)
386408 __THROW __nonnull ((1));
387409
410/* Store *SIGMASK as the signal mask for the new thread in *ATTR. */
411extern int pthread_attr_setsigmask_np (pthread_attr_t *__attr,
412 const __sigset_t *sigmask);
413
414/* Store the signal mask of *ATTR in *SIGMASK. If there is no signal
415 mask stored, return PTHREAD_ATTR_NOSIGMASK_NP. Return zero on
416 success. */
417extern int pthread_attr_getsigmask_np (const pthread_attr_t *__attr,
418 __sigset_t *sigmask);
419
420/* Special return value from pthread_attr_getsigmask_np if the signal
421 mask has not been set. */
422#define PTHREAD_ATTR_NO_SIGMASK_NP (-1)
423
388424/* Set the default attributes to be used by pthread_create in this
389425 process. */
390426extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
......@@ -438,11 +474,14 @@ extern int pthread_setconcurrency (int __level) __THROW;
438474#endif
439475
440476#ifdef __USE_GNU
441/* Yield the processor to another thread or process.
442 This function is similar to the POSIX `sched_yield' function but
443 might be differently implemented in the case of a m-on-n thread
444 implementation. */
445477extern int pthread_yield (void) __THROW;
478# ifdef __REDIRECT_NTH
479extern int __REDIRECT_NTH (pthread_yield, (void), sched_yield)
480 __attribute_deprecated_msg__ ("\
481pthread_yield is deprecated, use sched_yield instead");
482# else
483# define pthread_yield sched_yield
484# endif
446485
447486
448487/* Limit specified thread TH to run only on the processors represented
......@@ -496,13 +535,15 @@ extern void pthread_testcancel (void);
496535
497536/* Cancellation handling with integration into exception handling. */
498537
538struct __cancel_jmp_buf_tag
539{
540 __jmp_buf __cancel_jmp_buf;
541 int __mask_was_saved;
542};
543
499544typedef struct
500545{
501 struct
502 {
503 __jmp_buf __cancel_jmp_buf;
504 int __mask_was_saved;
505 } __cancel_jmp_buf[1];
546 struct __cancel_jmp_buf_tag __cancel_jmp_buf[1];
506547 void *__pad[4];
507548} __pthread_unwind_buf_t __attribute__ ((__aligned__));
508549
......@@ -642,8 +683,8 @@ __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
642683 __pthread_unwind_buf_t __cancel_buf; \
643684 void (*__cancel_routine) (void *) = (routine); \
644685 void *__cancel_arg = (arg); \
645 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
646 __cancel_buf.__cancel_jmp_buf, 0); \
686 int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \
687 0); \
647688 if (__glibc_unlikely (__not_first_call)) \
648689 { \
649690 __cancel_routine (__cancel_arg); \
......@@ -677,8 +718,8 @@ extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
677718 __pthread_unwind_buf_t __cancel_buf; \
678719 void (*__cancel_routine) (void *) = (routine); \
679720 void *__cancel_arg = (arg); \
680 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
681 __cancel_buf.__cancel_jmp_buf, 0); \
721 int __not_first_call = __sigsetjmp_cancel (__cancel_buf.__cancel_jmp_buf, \
722 0); \
682723 if (__glibc_unlikely (__not_first_call)) \
683724 { \
684725 __cancel_routine (__cancel_arg); \
......@@ -714,9 +755,24 @@ extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
714755 ;
715756#endif
716757
717/* Function used in the macros. */
718struct __jmp_buf_tag;
719extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
758/* Function used in the macros. Calling __sigsetjmp, with its first
759 argument declared as an array, results in a -Wstringop-overflow
760 warning from GCC 11 because struct pthread_unwind_buf is smaller
761 than jmp_buf. The calls from the macros have __SAVEMASK set to 0,
762 so nothing beyond the common prefix is used and this warning is a
763 false positive. Use an alias with its first argument declared to
764 use the type in the macros if possible to avoid this warning. */
765#if __GNUC_PREREQ (11, 0)
766extern int __REDIRECT_NTHNL (__sigsetjmp_cancel,
767 (struct __cancel_jmp_buf_tag __env[1],
768 int __savemask),
769 __sigsetjmp) __attribute_returns_twice__;
770#else
771# define __sigsetjmp_cancel(env, savemask) \
772 __sigsetjmp ((struct __jmp_buf_tag *) (void *) (env), (savemask))
773extern int __sigsetjmp (struct __jmp_buf_tag __env[1],
774 int __savemask) __THROWNL;
775#endif
720776
721777
722778/* Mutex handling. */
......@@ -740,16 +796,39 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
740796
741797#ifdef __USE_XOPEN2K
742798/* Wait until lock becomes available, or specified time passes. */
799# ifndef __USE_TIME_BITS64
743800extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
744801 const struct timespec *__restrict
745802 __abstime) __THROWNL __nonnull ((1, 2));
803# else
804# ifdef __REDIRECT_NTHNL
805extern int __REDIRECT_NTHNL (pthread_mutex_timedlock,
806 (pthread_mutex_t *__restrict __mutex,
807 const struct timespec *__restrict __abstime),
808 __pthread_mutex_timedlock64) __nonnull ((1, 2));
809# else
810# define pthread_mutex_timedlock __pthread_mutex_timedlock64
811# endif
812# endif
746813#endif
747814
748815#ifdef __USE_GNU
816# ifndef __USE_TIME_BITS64
749817extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
750818 clockid_t __clockid,
751819 const struct timespec *__restrict
752820 __abstime) __THROWNL __nonnull ((1, 3));
821# else
822# ifdef __REDIRECT_NTHNL
823extern int __REDIRECT_NTHNL (pthread_mutex_clocklock,
824 (pthread_mutex_t *__restrict __mutex,
825 clockid_t __clockid,
826 const struct timespec *__restrict __abstime),
827 __pthread_mutex_clocklock64) __nonnull ((1, 3));
828# else
829# define pthread_mutex_clocklock __pthread_mutex_clocklock64
830# endif
831# endif
753832#endif
754833
755834/* Unlock a mutex. */
......@@ -776,8 +855,14 @@ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
776855extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
777856 __THROW __nonnull ((1));
778857# ifdef __USE_GNU
779extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
780 __THROW __nonnull ((1));
858# ifdef __REDIRECT_NTH
859extern int __REDIRECT_NTH (pthread_mutex_consistent_np, (pthread_mutex_t *),
860 pthread_mutex_consistent) __nonnull ((1))
861 __attribute_deprecated_msg__ ("\
862pthread_mutex_consistent_np is deprecated, use pthread_mutex_consistent");
863# else
864# define pthread_mutex_consistent_np pthread_mutex_consistent
865# endif
781866# endif
782867#endif
783868
......@@ -846,9 +931,15 @@ extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
846931 int *__robustness)
847932 __THROW __nonnull ((1, 2));
848933# ifdef __USE_GNU
849extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
850 int *__robustness)
851 __THROW __nonnull ((1, 2));
934# ifdef __REDIRECT_NTH
935extern int __REDIRECT_NTH (pthread_mutexattr_getrobust_np,
936 (pthread_mutex_t *, int *),
937 pthread_mutexattr_getrobust) __nonnull ((1))
938 __attribute_deprecated_msg__ ("\
939pthread_mutexattr_getrobust_np is deprecated, use pthread_mutexattr_getrobust");
940# else
941# define pthread_mutexattr_getrobust_np pthread_mutexattr_getrobust
942# endif
852943# endif
853944
854945/* Set the robustness flag of the mutex attribute ATTR. */
......@@ -856,13 +947,18 @@ extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
856947 int __robustness)
857948 __THROW __nonnull ((1));
858949# ifdef __USE_GNU
859extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
860 int __robustness)
861 __THROW __nonnull ((1));
950# ifdef __REDIRECT_NTH
951extern int __REDIRECT_NTH (pthread_mutexattr_setrobust_np,
952 (pthread_mutex_t *, int),
953 pthread_mutexattr_setrobust) __nonnull ((1))
954 __attribute_deprecated_msg__ ("\
955pthread_mutexattr_setrobust_np is deprecated, use pthread_mutexattr_setrobust");
956# else
957# define pthread_mutexattr_setrobust_np pthread_mutexattr_setrobust
958# endif
862959# endif
863960#endif
864961
865
866962#if defined __USE_UNIX98 || defined __USE_XOPEN2K
867963/* Functions for handling read-write locks. */
868964
......@@ -886,16 +982,41 @@ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
886982
887983# ifdef __USE_XOPEN2K
888984/* Try to acquire read lock for RWLOCK or return after specfied time. */
985# ifndef __USE_TIME_BITS64
889986extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
890987 const struct timespec *__restrict
891988 __abstime) __THROWNL __nonnull ((1, 2));
989# else
990# ifdef __REDIRECT_NTHNL
991extern int __REDIRECT_NTHNL (pthread_rwlock_timedrdlock,
992 (pthread_rwlock_t *__restrict __rwlock,
993 const struct timespec *__restrict __abstime),
994 __pthread_rwlock_timedrdlock64)
995 __nonnull ((1, 2));
996# else
997# define pthread_rwlock_timedrdlock __pthread_rwlock_timedrdlock64
998# endif
999# endif
8921000# endif
8931001
8941002# ifdef __USE_GNU
1003# ifndef __USE_TIME_BITS64
8951004extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
8961005 clockid_t __clockid,
8971006 const struct timespec *__restrict
8981007 __abstime) __THROWNL __nonnull ((1, 3));
1008# else
1009# ifdef __REDIRECT_NTHNL
1010extern int __REDIRECT_NTHNL (pthread_rwlock_clockrdlock,
1011 (pthread_rwlock_t *__restrict __rwlock,
1012 clockid_t __clockid,
1013 const struct timespec *__restrict __abstime),
1014 __pthread_rwlock_clockrdlock64)
1015 __nonnull ((1, 3));
1016# else
1017# define pthread_rwlock_clockrdlock __pthread_rwlock_clockrdlock64
1018# endif
1019# endif
8991020# endif
9001021
9011022/* Acquire write lock for RWLOCK. */
......@@ -908,16 +1029,42 @@ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
9081029
9091030# ifdef __USE_XOPEN2K
9101031/* Try to acquire write lock for RWLOCK or return after specfied time. */
1032# ifndef __USE_TIME_BITS64
9111033extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
9121034 const struct timespec *__restrict
9131035 __abstime) __THROWNL __nonnull ((1, 2));
1036# else
1037# ifdef __REDIRECT_NTHNL
1038extern int __REDIRECT_NTHNL (pthread_rwlock_timedwrlock,
1039 (pthread_rwlock_t *__restrict __rwlock,
1040 const struct timespec *__restrict __abstime),
1041 __pthread_rwlock_timedwrlock64)
1042 __nonnull ((1, 2));
1043# else
1044# define pthread_rwlock_timedwrlock __pthread_rwlock_timedwrlock64
1045# endif
1046# endif
9141047# endif
9151048
9161049# ifdef __USE_GNU
1050# ifndef __USE_TIME_BITS64
9171051extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
9181052 clockid_t __clockid,
9191053 const struct timespec *__restrict
9201054 __abstime) __THROWNL __nonnull ((1, 3));
1055
1056# else
1057# ifdef __REDIRECT_NTHNL
1058extern int __REDIRECT_NTHNL (pthread_rwlock_clockwrlock,
1059 (pthread_rwlock_t *__restrict __rwlock,
1060 clockid_t __clockid,
1061 const struct timespec *__restrict __abstime),
1062 __pthread_rwlock_clockwrlock64)
1063 __nonnull ((1, 3));
1064# else
1065# define pthread_rwlock_clockwrlock __pthread_rwlock_clockwrlock64
1066# endif
1067# endif
9211068# endif
9221069
9231070/* Unlock RWLOCK. */
......@@ -994,10 +1141,23 @@ extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
9941141
9951142 This function is a cancellation point and therefore not marked with
9961143 __THROW. */
1144# ifndef __USE_TIME_BITS64
9971145extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
9981146 pthread_mutex_t *__restrict __mutex,
9991147 const struct timespec *__restrict __abstime)
10001148 __nonnull ((1, 2, 3));
1149# else
1150# ifdef __REDIRECT
1151extern int __REDIRECT (pthread_cond_timedwait,
1152 (pthread_cond_t *__restrict __cond,
1153 pthread_mutex_t *__restrict __mutex,
1154 const struct timespec *__restrict __abstime),
1155 __pthread_cond_timedwait64)
1156 __nonnull ((1, 2, 3));
1157# else
1158# define pthread_cond_timedwait __pthread_cond_timedwait64
1159# endif
1160# endif
10011161
10021162# ifdef __USE_GNU
10031163/* Wait for condition variable COND to be signaled or broadcast until
......@@ -1007,11 +1167,25 @@ extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
10071167
10081168 This function is a cancellation point and therefore not marked with
10091169 __THROW. */
1170# ifndef __USE_TIME_BITS64
10101171extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
10111172 pthread_mutex_t *__restrict __mutex,
10121173 __clockid_t __clock_id,
10131174 const struct timespec *__restrict __abstime)
10141175 __nonnull ((1, 2, 4));
1176# else
1177# ifdef __REDIRECT
1178extern int __REDIRECT (pthread_cond_clockwait,
1179 (pthread_cond_t *__restrict __cond,
1180 pthread_mutex_t *__restrict __mutex,
1181 __clockid_t __clock_id,
1182 const struct timespec *__restrict __abstime),
1183 __pthread_cond_clockwait64)
1184 __nonnull ((1, 2, 4));
1185# else
1186# define pthread_cond_clockwait __pthread_cond_clockwait64
1187# endif
1188# endif
10151189# endif
10161190
10171191/* Functions for handling condition variable attributes. */
......@@ -1132,7 +1306,8 @@ extern void *pthread_getspecific (pthread_key_t __key) __THROW;
11321306
11331307/* Store POINTER in the thread-specific data slot identified by KEY. */
11341308extern int pthread_setspecific (pthread_key_t __key,
1135 const void *__pointer) __THROW ;
1309 const void *__pointer)
1310 __THROW __attr_access_none (2);
11361311
11371312
11381313#ifdef __USE_XOPEN2K
lib/libc/glibc/sysdeps/powerpc/nptl/bits/pthreadtypes-arch.h deleted-81
......@@ -1,81 +0,0 @@
1/* Machine-specific pthread type layouts. PowerPC version.
2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_PTHREADTYPES_ARCH_H
20#define _BITS_PTHREADTYPES_ARCH_H 1
21
22#include <bits/wordsize.h>
23
24#if __WORDSIZE == 64
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_ATTR_T 56
27# define __SIZEOF_PTHREAD_RWLOCK_T 56
28# define __SIZEOF_PTHREAD_BARRIER_T 32
29#else
30# define __SIZEOF_PTHREAD_MUTEX_T 24
31# define __SIZEOF_PTHREAD_ATTR_T 36
32# define __SIZEOF_PTHREAD_RWLOCK_T 32
33# define __SIZEOF_PTHREAD_BARRIER_T 20
34#endif
35#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
36#define __SIZEOF_PTHREAD_COND_T 48
37#define __SIZEOF_PTHREAD_CONDATTR_T 4
38#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
39#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
40
41/* Definitions for internal mutex struct. */
42#define __PTHREAD_COMPAT_PADDING_MID
43#define __PTHREAD_COMPAT_PADDING_END
44#define __PTHREAD_MUTEX_LOCK_ELISION 1
45#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64)
46#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64)
47
48#define __LOCK_ALIGNMENT
49#define __ONCE_ALIGNMENT
50
51struct __pthread_rwlock_arch_t
52{
53 unsigned int __readers;
54 unsigned int __writers;
55 unsigned int __wrphase_futex;
56 unsigned int __writers_futex;
57 unsigned int __pad3;
58 unsigned int __pad4;
59#if __WORDSIZE == 64
60 int __cur_writer;
61 int __shared;
62 unsigned char __rwelision;
63 unsigned char __pad1[7];
64 unsigned long int __pad2;
65 /* FLAGS must stay at this position in the structure to maintain
66 binary compatibility. */
67 unsigned int __flags;
68# define __PTHREAD_RWLOCK_ELISION_EXTRA 0, {0, 0, 0, 0, 0, 0, 0 }
69#else
70 unsigned char __rwelision;
71 unsigned char __pad2;
72 unsigned char __shared;
73 /* FLAGS must stay at this position in the structure to maintain
74 binary compatibility. */
75 unsigned char __flags;
76 int __cur_writer;
77# define __PTHREAD_RWLOCK_ELISION_EXTRA 0
78#endif
79};
80
81#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/powerpc/powerpc32/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc32/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for PowerPC.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc32/start.S+3-3
......@@ -1,5 +1,5 @@
11/* Startup code for programs linked with GNU libc.
2 Copyright (C) 1998-2020 Free Software Foundation, Inc.
2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -52,8 +52,8 @@
5252L(start_addresses):
5353 .long _SDA_BASE_
5454 .long main
55 .long __libc_csu_init
56 .long __libc_csu_fini
55 .long 0 /* Used to be init. */
56 .long 0 /* Used to be fini. */
5757 ASM_SIZE_DIRECTIVE(L(start_addresses))
5858
5959 .section ".text"
lib/libc/glibc/sysdeps/powerpc/powerpc32/symbol-hacks.h+1-1
......@@ -1,5 +1,5 @@
11/* Hacks needed for symbol manipulation. powerpc version.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc32/sysdep.h+15-6
......@@ -1,5 +1,5 @@
11/* Assembly macros for 32-bit PowerPC.
2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -92,7 +92,10 @@ GOT_LABEL: ; \
9292
9393#define DO_CALL(syscall) \
9494 li 0,syscall; \
95 sc
95 DO_CALL_SC
96
97#define DO_CALL_SC \
98 sc
9699
97100#undef JUMPTARGET
98101#ifdef PIC
......@@ -106,14 +109,20 @@ GOT_LABEL: ; \
106109# define HIDDEN_JUMPTARGET(name) __GI_##name##@local
107110#endif
108111
112#define TAIL_CALL_SYSCALL_ERROR \
113 b __syscall_error@local
114
109115#define PSEUDO(name, syscall_name, args) \
110116 .section ".text"; \
111117 ENTRY (name) \
112118 DO_CALL (SYS_ify (syscall_name));
113119
120#define RET_SC \
121 bnslr+;
122
114123#define PSEUDO_RET \
115 bnslr+; \
116 b __syscall_error@local
124 RET_SC; \
125 TAIL_CALL_SYSCALL_ERROR
117126#define ret PSEUDO_RET
118127
119128#undef PSEUDO_END
......@@ -179,8 +188,8 @@ GOT_LABEL: ; \
179188#else
180189/* Position-dependent code does not require access to the GOT. */
181190# define __GLRO(rOUT, rGOT, member, offset) \
182 lis rOUT,(member+LOWORD)@ha; \
183 lwz rOUT,(member+LOWORD)@l(rOUT)
191 lis rOUT,(member)@ha; \
192 lwz rOUT,(member)@l(rOUT)
184193#endif /* PIC */
185194
186195#endif /* __ASSEMBLER__ */
lib/libc/glibc/sysdeps/powerpc/powerpc64/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc64/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for PowerPC64.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc64/dl-dtprocnum.h+1-1
......@@ -1,5 +1,5 @@
11/* Configuration of lookup functions. PowerPC64 version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/powerpc/powerpc64/start.S+3-3
......@@ -1,5 +1,5 @@
11/* Startup code for programs linked with GNU libc. PowerPC64 version.
2 Copyright (C) 1998-2020 Free Software Foundation, Inc.
2 Copyright (C) 1998-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -53,8 +53,8 @@ L(start_addresses):
5353 .quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
5454/* function descriptors so don't need JUMPTARGET */
5555 .quad main
56 .quad __libc_csu_init
57 .quad __libc_csu_fini
56 .quad 0 /* Used to be init. */
57 .quad 0 /* Used to be fini. */
5858
5959 ASM_SIZE_DIRECTIVE(L(start_addresses))
6060
lib/libc/glibc/sysdeps/powerpc/powerpc64/sysdep.h+126-8
......@@ -1,5 +1,5 @@
11/* Assembly macros for 64-bit PowerPC.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -17,6 +17,7 @@
1717 <https://www.gnu.org/licenses/>. */
1818
1919#include <sysdeps/powerpc/sysdep.h>
20#include <tls.h>
2021
2122#ifdef __ASSEMBLER__
2223
......@@ -263,10 +264,83 @@ LT_LABELSUFFIX(name,_name_end): ; \
263264 TRACEBACK_MASK(name,mask); \
264265 END_2(name)
265266
266#define DO_CALL(syscall) \
267 li 0,syscall; \
267/* We will allocate a new frame to save LR and the non-volatile register used to
268 read the TCB when checking for scv support on syscall code. We actually just
269 need the minimum frame size plus room for 1 reg (8 bytes). But the ABI
270 mandates stack frames should be aligned at 16 Bytes, so we end up allocating
271 a bit more space then what will actually be used. */
272#define SCV_FRAME_SIZE (FRAME_MIN_SIZE+16)
273#define SCV_FRAME_NVOLREG_SAVE FRAME_MIN_SIZE
274
275/* Allocate frame and save register */
276#define NVOLREG_SAVE \
277 stdu r1,-SCV_FRAME_SIZE(r1); \
278 std r31,SCV_FRAME_NVOLREG_SAVE(r1); \
279 cfi_adjust_cfa_offset(SCV_FRAME_SIZE);
280
281/* Restore register and destroy frame */
282#define NVOLREG_RESTORE \
283 ld r31,SCV_FRAME_NVOLREG_SAVE(r1); \
284 addi r1,r1,SCV_FRAME_SIZE; \
285 cfi_adjust_cfa_offset(-SCV_FRAME_SIZE);
286
287/* Check PPC_FEATURE2_SCV bit from hwcap2 in the TCB. If it is not set, scv is
288 not available, then go to JUMPFALSE (label given by the macro's caller). We
289 save the value we read from the TCB in a non-volatile register so we can
290 reuse it later when exiting from the syscall in PSEUDO_RET. Note that for
291 the static case we need an extra check to guarantee the thread pointer has
292 already been initialized, otherwise we may try to access an invalid address
293 if a syscall is called before the TLS has been setup. */
294 .macro CHECK_SCV_SUPPORT REG JUMPFALSE
295
296#ifndef SHARED
297 /* Check if thread pointer has already been setup. */
298 cmpdi r13,0
299 beq \JUMPFALSE
300#endif
301
302 /* Read PPC_FEATURE2_SCV from TCB and store it in REG */
303 ld \REG,TCB_HWCAP(PT_THREAD_POINTER)
304 andis. \REG,\REG,PPC_FEATURE2_SCV>>16
305
306 beq \JUMPFALSE
307 .endm
308
309#if !defined(USE_PPC_SCV) || IS_IN(rtld)
310# define DO_CALL(syscall) \
311 li r0,syscall; \
312 DO_CALL_SC
313#else
314/* Before doing the syscall, check if we can use scv. scv is supported by P9
315 and later with Linux v5.9 and later. If so, use it. Otherwise, fallback to
316 sc. We use a non-volatile register to save hwcap2 from the TCB, so we need
317 to save its content beforehand. */
318# define DO_CALL(syscall) \
319 li r0,syscall; \
320 NVOLREG_SAVE; \
321 CHECK_SCV_SUPPORT r31 0f; \
322 DO_CALL_SCV; \
323 b 1f; \
3240: DO_CALL_SC; \
3251:
326#endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
327
328/* DO_CALL_SC and DO_CALL_SCV expect the syscall number to be in r0. */
329#define DO_CALL_SC \
268330 sc
269331
332#define DO_CALL_SCV \
333 mflr r9; \
334 std r9,FRAME_LR_SAVE(r1); \
335 cfi_offset(lr,FRAME_LR_SAVE); \
336 .machine "push"; \
337 .machine "power9"; \
338 scv 0; \
339 .machine "pop"; \
340 ld r9,FRAME_LR_SAVE(r1); \
341 mtlr r9; \
342 cfi_restore(lr);
343
270344/* ppc64 is always PIC */
271345#undef JUMPTARGET
272346#define JUMPTARGET(name) FUNC_LABEL(name)
......@@ -278,7 +352,7 @@ LT_LABELSUFFIX(name,_name_end): ; \
278352
279353#ifdef SHARED
280354#define TAIL_CALL_SYSCALL_ERROR \
281 b JUMPTARGET(__syscall_error)
355 b JUMPTARGET (NOTOC (__syscall_error))
282356#else
283357/* Static version might be linked into a large app with a toc exceeding
284358 64k. We can't put a toc adjusting stub on a plain branch, so can't
......@@ -304,9 +378,33 @@ LT_LABELSUFFIX(name,_name_end): ; \
304378 .endif
305379#endif
306380
307#define PSEUDO_RET \
308 bnslr+; \
381#if !defined(USE_PPC_SCV) || IS_IN(rtld)
382# define PSEUDO_RET \
383 RET_SC; \
309384 TAIL_CALL_SYSCALL_ERROR
385#else
386/* This should only be called after a DO_CALL. In such cases, r31 contains the
387 value of PPC_FEATURE2_SCV read from hwcap2 by CHECK_SCV_SUPPORT. If it is
388 set, we know we have entered the kernel using scv, so handle the return code
389 accordingly. */
390# define PSEUDO_RET \
391 cmpdi cr5,r31,0; \
392 NVOLREG_RESTORE; \
393 beq cr5,0f; \
394 RET_SCV; \
395 b 1f; \
3960: RET_SC; \
3971: TAIL_CALL_SYSCALL_ERROR
398#endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
399
400#define RET_SCV \
401 li r9,-4095; \
402 cmpld r3,r9; \
403 bltlr+; \
404 neg r3,r3;
405
406#define RET_SC \
407 bnslr+;
310408
311409#define ret PSEUDO_RET
312410
......@@ -319,8 +417,15 @@ LT_LABELSUFFIX(name,_name_end): ; \
319417 ENTRY (name); \
320418 DO_CALL (SYS_ify (syscall_name))
321419
322#define PSEUDO_RET_NOERRNO \
420#if !defined(USE_PPC_SCV) || IS_IN(rtld)
421# define PSEUDO_RET_NOERRNO \
422 blr
423#else
424/* This should only be called after a DO_CALL. */
425# define PSEUDO_RET_NOERRNO \
426 NVOLREG_RESTORE; \
323427 blr
428#endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
324429
325430#define ret_NOERRNO PSEUDO_RET_NOERRNO
326431
......@@ -333,8 +438,15 @@ LT_LABELSUFFIX(name,_name_end): ; \
333438 ENTRY (name); \
334439 DO_CALL (SYS_ify (syscall_name))
335440
336#define PSEUDO_RET_ERRVAL \
441#if !defined(USE_PPC_SCV) || IS_IN(rtld)
442# define PSEUDO_RET_ERRVAL \
443 blr
444#else
445/* This should only be called after a DO_CALL. */
446# define PSEUDO_RET_ERRVAL \
447 NVOLREG_RESTORE; \
337448 blr
449#endif /* !defined(USE_PPC_SCV) || IS_IN(rtld) */
338450
339451#define ret_ERRVAL PSEUDO_RET_ERRVAL
340452
......@@ -366,6 +478,12 @@ LT_LABELSUFFIX(name,_name_end): ; \
366478 lwz rOUT,0(rOUT)
367479#endif
368480
481#ifdef USE_PPC64_NOTOC
482# define NOTOC(l) l@notoc
483#else
484# define NOTOC(l) l
485#endif
486
369487#else /* !__ASSEMBLER__ */
370488
371489#if _CALL_ELF != 2
lib/libc/glibc/sysdeps/powerpc/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/pthread/pthread_atfork.c created+61
......@@ -0,0 +1,61 @@
1/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 In addition to the permissions in the GNU Lesser General Public
11 License, the Free Software Foundation gives you unlimited
12 permission to link the compiled version of this file with other
13 programs, and to distribute those programs without any restriction
14 coming from the use of this file. (The GNU Lesser General Public
15 License restrictions do apply in other respects; for example, they
16 cover modification of the file, and distribution when not linked
17 into another program.)
18
19 Note that people who make modified versions of this file are not
20 obligated to grant this special exception for their modified
21 versions; it is their choice whether to do so. The GNU Lesser
22 General Public License gives permission to release a modified
23 version without this exception; this exception also makes it
24 possible to release a modified version which carries forward this
25 exception.
26
27 The GNU C Library is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 Lesser General Public License for more details.
31
32 You should have received a copy of the GNU Lesser General Public
33 License along with the GNU C Library; if not, see
34 <https://www.gnu.org/licenses/>. */
35
36extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
37 void (*child) (void));
38extern int __register_atfork (void (*__prepare) (void),
39 void (*__parent) (void),
40 void (*__child) (void),
41 void *dso_handle);
42libc_hidden_proto (__register_atfork)
43extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
44
45/* Hide the symbol so that no definition but the one locally in the
46 executable or DSO is used. */
47int
48#ifndef __pthread_atfork
49/* Don't mark the compatibility function as hidden. */
50attribute_hidden
51#endif
52__pthread_atfork (void (*prepare) (void), void (*parent) (void),
53 void (*child) (void))
54{
55 return __register_atfork (prepare, parent, child, __dso_handle);
56}
57#ifndef __pthread_atfork
58extern int pthread_atfork (void (*prepare) (void), void (*parent) (void),
59 void (*child) (void)) attribute_hidden;
60weak_alias (__pthread_atfork, pthread_atfork)
61#endif
lib/libc/glibc/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h+16-12
......@@ -1,5 +1,5 @@
11/* Machine-specific pthread type layouts. RISC-V version.
2 Copyright (C) 2011-2020 Free Software Foundation, Inc.
2 Copyright (C) 2011-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -21,18 +21,22 @@
2121
2222#include <bits/endian.h>
2323
24#if __riscv_xlen == 64
25# define __SIZEOF_PTHREAD_ATTR_T 56
26# define __SIZEOF_PTHREAD_MUTEX_T 40
27# define __SIZEOF_PTHREAD_MUTEXATTR_T 4
28# define __SIZEOF_PTHREAD_COND_T 48
29# define __SIZEOF_PTHREAD_CONDATTR_T 4
30# define __SIZEOF_PTHREAD_RWLOCK_T 56
31# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
32# define __SIZEOF_PTHREAD_BARRIER_T 32
33# define __SIZEOF_PTHREAD_BARRIERATTR_T 4
24#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
25#define __SIZEOF_PTHREAD_COND_T 48
26#define __SIZEOF_PTHREAD_CONDATTR_T 4
27#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
28#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
29
30#if __WORDSIZE == 64
31# define __SIZEOF_PTHREAD_ATTR_T 56
32# define __SIZEOF_PTHREAD_MUTEX_T 40
33# define __SIZEOF_PTHREAD_RWLOCK_T 56
34# define __SIZEOF_PTHREAD_BARRIER_T 32
3435#else
35# error "rv32i-based systems are not supported"
36# define __SIZEOF_PTHREAD_ATTR_T 32
37# define __SIZEOF_PTHREAD_MUTEX_T 32
38# define __SIZEOF_PTHREAD_RWLOCK_T 48
39# define __SIZEOF_PTHREAD_BARRIER_T 20
3640#endif
3741
3842#define __LOCK_ALIGNMENT
lib/libc/glibc/sysdeps/riscv/start.S+3-3
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF RISC-V ABI.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -54,8 +54,8 @@ ENTRY (ENTRY_POINT)
5454 REG_L a1, 0(sp) /* argc. */
5555 addi a2, sp, SZREG /* argv. */
5656 andi sp, sp, ALMASK /* Align stack. */
57 lla a3, __libc_csu_init
58 lla a4, __libc_csu_fini
57 li a3, 0 /* Used to be init. */
58 li a4, 0 /* Used to be fini. */
5959 mv a6, sp /* stack_end. */
6060
6161 call __libc_start_main@plt
lib/libc/glibc/sysdeps/s390/nptl/bits/pthreadtypes-arch.h deleted-79
......@@ -1,79 +0,0 @@
1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <bits/wordsize.h>
22
23#if __WORDSIZE == 64
24# define __SIZEOF_PTHREAD_ATTR_T 56
25# define __SIZEOF_PTHREAD_MUTEX_T 40
26# define __SIZEOF_PTHREAD_RWLOCK_T 56
27# define __SIZEOF_PTHREAD_BARRIER_T 32
28#else
29# define __SIZEOF_PTHREAD_ATTR_T 36
30# define __SIZEOF_PTHREAD_MUTEX_T 24
31# define __SIZEOF_PTHREAD_RWLOCK_T 32
32# define __SIZEOF_PTHREAD_BARRIER_T 20
33#endif
34#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
35#define __SIZEOF_PTHREAD_CONDATTR_T 4
36#define __SIZEOF_PTHREAD_COND_T 48
37#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
38#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
39
40/* Definitions for internal mutex struct. */
41#define __PTHREAD_COMPAT_PADDING_MID
42#define __PTHREAD_COMPAT_PADDING_END
43#define __PTHREAD_MUTEX_LOCK_ELISION 1
44#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND (__WORDSIZE != 64)
45#define __PTHREAD_MUTEX_USE_UNION (__WORDSIZE != 64)
46
47#define __LOCK_ALIGNMENT
48#define __ONCE_ALIGNMENT
49
50struct __pthread_rwlock_arch_t
51{
52 unsigned int __readers;
53 unsigned int __writers;
54 unsigned int __wrphase_futex;
55 unsigned int __writers_futex;
56 unsigned int __pad3;
57 unsigned int __pad4;
58#if __WORDSIZE == 64
59 int __cur_writer;
60 int __shared;
61 unsigned long int __pad1;
62 unsigned long int __pad2;
63 /* FLAGS must stay at this position in the structure to maintain
64 binary compatibility. */
65 unsigned int __flags;
66# else
67 unsigned char __pad1;
68 unsigned char __pad2;
69 unsigned char __shared;
70 /* FLAGS must stay at this position in the structure to maintain
71 binary compatibility. */
72 unsigned char __flags;
73 int __cur_writer;
74#endif
75};
76
77#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
78
79#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/s390/s390-32/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/s390/s390-32/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for S/390.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/s390/s390-32/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. S/390 version.
2 Copyright (C) 2014-2020 Free Software Foundation, Inc.
2 Copyright (C) 2014-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/s390/s390-32/start.S+3-9
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF s390 ABI.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
......@@ -175,18 +175,16 @@ _start:
175175 */
176176 stm %r14,%r15,96(%r15) # store rtld_fini/stack_end to parameter area
177177 la %r7,96(%r15)
178 l %r6,.L2-.Llit(%r13) # load pointer to __libc_csu_fini
179 l %r5,.L1-.Llit(%r13) # load pointer to __libc_csu_init
180178 l %r2,.L3-.Llit(%r13) # load pointer to main
181179 l %r1,.L4-.Llit(%r13) # load pointer to __libc_start_main
182180#ifdef PIC
183181 l %r12,.L5-.Llit(%r13) # load .got pointer
184 la %r6,0(%r13,%r6)
185 la %r5,0(%r13,%r5)
186182 la %r12,0(%r13,%r12)
187183 l %r2,0(%r12,%r2)
188184 la %r1,0(%r13,%r1)
189185#endif
186 lhi %r6, 0 # Used to fini.
187 lhi %r5, 0 # Used to init.
190188
191189 /* ok, now branch to the libc main routine */
192190 basr %r14,%r1
......@@ -197,13 +195,9 @@ _start:
197195 cfi_endproc
198196.Llit:
199197#ifndef PIC
200.L1: .long __libc_csu_init
201.L2: .long __libc_csu_fini
202198.L3: .long main
203199.L4: .long __libc_start_main
204200#else
205.L1: .long __libc_csu_init-.Llit
206.L2: .long __libc_csu_fini-.Llit
207201.L3: .long main@GOT
208202.L4: .long __libc_start_main@plt-.Llit
209203.L5: .long _GLOBAL_OFFSET_TABLE_-.Llit
lib/libc/glibc/sysdeps/s390/s390-32/symbol-hacks.h+1-1
......@@ -1,5 +1,5 @@
11/* Hacks needed for symbol manipulation. s390 version.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/s390/s390-32/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for s390.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
lib/libc/glibc/sysdeps/s390/s390-64/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
lib/libc/glibc/sysdeps/s390/s390-64/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for 64 bit S/390.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
lib/libc/glibc/sysdeps/s390/s390-64/start.S+3-3
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the 64 bit S/390 ELF ABI.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
......@@ -80,8 +80,8 @@ _start:
8080 */
8181 stmg %r14,%r15,160(%r15) # store rtld_fini/stack_end to parameter area
8282 la %r7,160(%r15)
83 larl %r6,__libc_csu_fini # load pointer to __libc_csu_fini
84 larl %r5,__libc_csu_init # load pointer to __libc_csu_init
83 lghi %r6,0 # Used to be fini.
84 lghi %r5,0 # Used to be init.
8585
8686 /* Ok, now branch to the libc main routine. */
8787#ifdef PIC
lib/libc/glibc/sysdeps/s390/s390-64/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
lib/libc/glibc/sysdeps/sh/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sh/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for SH.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sh/nptl/bits/pthreadtypes-arch.h deleted-71
......@@ -1,71 +0,0 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_PTHREADTYPES_ARCH_H
19#define _BITS_PTHREADTYPES_ARCH_H 1
20
21#include <endian.h>
22
23#define __SIZEOF_PTHREAD_ATTR_T 36
24#define __SIZEOF_PTHREAD_MUTEX_T 24
25#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
26#define __SIZEOF_PTHREAD_COND_T 48
27#define __SIZEOF_PTHREAD_CONDATTR_T 4
28#define __SIZEOF_PTHREAD_RWLOCK_T 32
29#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
30#define __SIZEOF_PTHREAD_BARRIER_T 20
31#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
32
33/* Definitions for internal mutex struct. */
34#define __PTHREAD_COMPAT_PADDING_MID
35#define __PTHREAD_COMPAT_PADDING_END
36#define __PTHREAD_MUTEX_LOCK_ELISION 0
37#define __PTHREAD_MUTEX_NUSERS_AFTER_KIND 1
38#define __PTHREAD_MUTEX_USE_UNION 1
39
40#define __LOCK_ALIGNMENT
41#define __ONCE_ALIGNMENT
42
43struct __pthread_rwlock_arch_t
44{
45 unsigned int __readers;
46 unsigned int __writers;
47 unsigned int __wrphase_futex;
48 unsigned int __writers_futex;
49 unsigned int __pad3;
50 unsigned int __pad4;
51#if __BYTE_ORDER == __BIG_ENDIAN
52 unsigned char __pad1;
53 unsigned char __pad2;
54 unsigned char __shared;
55 /* FLAGS must stay at this position in the structure to maintain
56 binary compatibility. */
57 unsigned char __flags;
58#else
59 /* FLAGS must stay at this position in the structure to maintain
60 binary compatibility. */
61 unsigned char __flags;
62 unsigned char __shared;
63 unsigned char __pad1;
64 unsigned char __pad2;
65#endif
66 unsigned long int __cur_writer;
67};
68
69#define __PTHREAD_RWLOCK_ELISION_EXTRA 0
70
71#endif /* bits/pthreadtypes.h */
lib/libc/glibc/sysdeps/sh/start.S+3-8
......@@ -1,5 +1,5 @@
11/* Startup code for SH & ELF.
2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -70,12 +70,11 @@ _start:
7070
7171 /* Push the last arguments to main() onto the stack */
7272 mov.l r4,@-r15
73 mov.l L_fini,r0
74 mov.l r0,@-r15
73 mov.l r14,@-r15 /* Used to be fini. */
7574
7675 /* Set up the other arguments for main() that go in registers */
7776 mov.l L_main,r4
78 mov.l L_init,r7
77 mov #0,r7 /* Used to be init. */
7978
8079 /* __libc_start_main (main, argc, argv, init, fini, rtld_fini) */
8180
......@@ -90,10 +89,6 @@ _start:
9089 .align 2
9190L_main:
9291 .long main
93L_init:
94 .long __libc_csu_init
95L_fini:
96 .long __libc_csu_fini
9792L_libc_start_main:
9893 .long __libc_start_main
9994L_abort:
lib/libc/glibc/sysdeps/sh/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for SH.
2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sparc/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sparc/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for sparc.
2 Copyright (C) 1995-2020 Free Software Foundation, Inc.
2 Copyright (C) 1995-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sparc/dl-dtprocnum.h+1-1
......@@ -1,5 +1,5 @@
11/* Configuration of lookup functions. SPARC version.
2 Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sparc/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. SPARC version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/sparc/sparc32/start.S+3-11
......@@ -1,5 +1,5 @@
11/* Startup code for elf32-sparc
2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
55
......@@ -59,22 +59,14 @@ _start:
5959 /* Load the addresses of the user entry points. */
6060#ifndef PIC
6161 sethi %hi(main), %o0
62 sethi %hi(__libc_csu_init), %o3
63 sethi %hi(__libc_csu_fini), %o4
6462 or %o0, %lo(main), %o0
65 or %o3, %lo(__libc_csu_init), %o3
66 or %o4, %lo(__libc_csu_fini), %o4
6763#else
6864 sethi %gdop_hix22(main), %o0
69 sethi %gdop_hix22(__libc_csu_init), %o3
70 sethi %gdop_hix22(__libc_csu_fini), %o4
7165 xor %o0, %gdop_lox10(main), %o0
72 xor %o3, %gdop_lox10(__libc_csu_init), %o3
73 xor %o4, %gdop_lox10(__libc_csu_fini), %o4
7466 ld [%l7 + %o0], %o0, %gdop(main)
75 ld [%l7 + %o3], %o3, %gdop(__libc_csu_init)
76 ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
7767#endif
68 mov 0, %o3 /* Used to be init. */
69 mov 0, %o4 /* Used to be fini. */
7870
7971 /* When starting a binary via the dynamic linker, %g1 contains the
8072 address of the shared library termination function, which will be
lib/libc/glibc/sysdeps/sparc/sparc64/start.S+3-11
......@@ -1,5 +1,5 @@
11/* Startup code for elf64-sparc
2 Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 Copyright (C) 1997-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
55
......@@ -60,22 +60,14 @@ _start:
6060 /* Load the addresses of the user entry points. */
6161#ifndef PIC
6262 sethi %hi(main), %o0
63 sethi %hi(__libc_csu_init), %o3
64 sethi %hi(__libc_csu_fini), %o4
6563 or %o0, %lo(main), %o0
66 or %o3, %lo(__libc_csu_init), %o3
67 or %o4, %lo(__libc_csu_fini), %o4
6864#else
6965 sethi %gdop_hix22(main), %o0
70 sethi %gdop_hix22(__libc_csu_init), %o3
71 sethi %gdop_hix22(__libc_csu_fini), %o4
7266 xor %o0, %gdop_lox10(main), %o0
73 xor %o3, %gdop_lox10(__libc_csu_init), %o3
74 xor %o4, %gdop_lox10(__libc_csu_fini), %o4
7567 ldx [%l7 + %o0], %o0, %gdop(main)
76 ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init)
77 ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini)
7868#endif
69 mov 0, %o3 /* Used to be init. */
70 mov 0, %o4 /* Used to be fini. */
7971
8072 /* When starting a binary via the dynamic linker, %g1 contains the
8173 address of the shared library termination function, which will be
lib/libc/glibc/sysdeps/sparc/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/alpha/sysdep.h deleted-382
......@@ -1,382 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Brendan Kehoe (brendan@zen.org).
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/sysdep.h>
20#include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
21
22#ifdef __ASSEMBLER__
23
24#ifdef __linux__
25# include <alpha/regdef.h>
26#else
27# include <regdef.h>
28#endif
29
30#define __LABEL(x) x##:
31
32#define LEAF(name, framesize) \
33 .globl name; \
34 .align 4; \
35 .ent name, 0; \
36 __LABEL(name) \
37 .frame sp, framesize, ra
38
39#define ENTRY(name) \
40 .globl name; \
41 .align 4; \
42 .ent name, 0; \
43 __LABEL(name) \
44 .frame sp, 0, ra
45
46/* Mark the end of function SYM. */
47#undef END
48#define END(sym) .end sym
49
50#ifdef PROF
51# define PSEUDO_PROF \
52 .set noat; \
53 lda AT, _mcount; \
54 jsr AT, (AT), _mcount; \
55 .set at
56#else
57# define PSEUDO_PROF
58#endif
59
60#ifdef PROF
61# define PSEUDO_PROLOGUE \
62 .frame sp, 0, ra; \
63 ldgp gp,0(pv); \
64 PSEUDO_PROF; \
65 .prologue 1
66#elif defined PIC
67# define PSEUDO_PROLOGUE \
68 .frame sp, 0, ra; \
69 .prologue 0
70#else
71# define PSEUDO_PROLOGUE \
72 .frame sp, 0, ra; \
73 ldgp gp,0(pv); \
74 .prologue 1
75#endif /* PROF */
76
77#ifdef PROF
78# define USEPV_PROF std
79#else
80# define USEPV_PROF no
81#endif
82
83#if RTLD_PRIVATE_ERRNO
84# define SYSCALL_ERROR_LABEL $syscall_error
85# define SYSCALL_ERROR_HANDLER \
86$syscall_error: \
87 stl v0, rtld_errno(gp) !gprel; \
88 lda v0, -1; \
89 ret
90# define SYSCALL_ERROR_FALLTHRU
91#elif defined(PIC)
92# define SYSCALL_ERROR_LABEL __syscall_error !samegp
93# define SYSCALL_ERROR_HANDLER
94# define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL
95#else
96# define SYSCALL_ERROR_LABEL $syscall_error
97# define SYSCALL_ERROR_HANDLER \
98$syscall_error: \
99 jmp $31, __syscall_error
100# define SYSCALL_ERROR_FALLTHRU
101#endif /* RTLD_PRIVATE_ERRNO */
102
103/* Overridden by specific syscalls. */
104#undef PSEUDO_PREPARE_ARGS
105#define PSEUDO_PREPARE_ARGS /* Nothing. */
106
107#define PSEUDO(name, syscall_name, args) \
108 .globl name; \
109 .align 4; \
110 .ent name,0; \
111__LABEL(name) \
112 PSEUDO_PROLOGUE; \
113 PSEUDO_PREPARE_ARGS \
114 lda v0, SYS_ify(syscall_name); \
115 call_pal PAL_callsys; \
116 bne a3, SYSCALL_ERROR_LABEL
117
118#undef PSEUDO_END
119#define PSEUDO_END(sym) \
120 SYSCALL_ERROR_HANDLER; \
121 END(sym)
122
123#define PSEUDO_NOERRNO(name, syscall_name, args) \
124 .globl name; \
125 .align 4; \
126 .ent name,0; \
127__LABEL(name) \
128 PSEUDO_PROLOGUE; \
129 PSEUDO_PREPARE_ARGS \
130 lda v0, SYS_ify(syscall_name); \
131 call_pal PAL_callsys;
132
133#undef PSEUDO_END_NOERRNO
134#define PSEUDO_END_NOERRNO(sym) END(sym)
135
136#define ret_NOERRNO ret
137
138#define PSEUDO_ERRVAL(name, syscall_name, args) \
139 .globl name; \
140 .align 4; \
141 .ent name,0; \
142__LABEL(name) \
143 PSEUDO_PROLOGUE; \
144 PSEUDO_PREPARE_ARGS \
145 lda v0, SYS_ify(syscall_name); \
146 call_pal PAL_callsys;
147
148#undef PSEUDO_END_ERRVAL
149#define PSEUDO_END_ERRVAL(sym) END(sym)
150
151#define ret_ERRVAL ret
152
153#define r0 v0
154#define r1 a4
155
156#define MOVE(x,y) mov x,y
157
158#else /* !ASSEMBLER */
159
160/* In order to get __set_errno() definition in INLINE_SYSCALL. */
161#include <errno.h>
162
163/* ??? Linux needs to be able to override INLINE_SYSCALL for one
164 particular special case. Make this easy. */
165
166#undef INLINE_SYSCALL
167#define INLINE_SYSCALL(name, nr, args...) \
168 INLINE_SYSCALL1(name, nr, args)
169
170#define INLINE_SYSCALL1(name, nr, args...) \
171({ \
172 long _sc_ret, _sc_err; \
173 inline_syscall##nr(__NR_##name, args); \
174 if (__builtin_expect (_sc_err, 0)) \
175 { \
176 __set_errno (_sc_ret); \
177 _sc_ret = -1L; \
178 } \
179 _sc_ret; \
180})
181
182#define INTERNAL_SYSCALL(name, err_out, nr, args...) \
183 INTERNAL_SYSCALL1(name, err_out, nr, args)
184
185#define INTERNAL_SYSCALL1(name, err_out, nr, args...) \
186 INTERNAL_SYSCALL_NCS(__NR_##name, err_out, nr, args)
187
188#define INTERNAL_SYSCALL_NCS(name, err_out, nr, args...) \
189({ \
190 long _sc_ret, _sc_err; \
191 inline_syscall##nr(name, args); \
192 err_out = _sc_err; \
193 _sc_ret; \
194})
195
196#define INTERNAL_SYSCALL_DECL(err) \
197 long int err __attribute__((unused))
198
199/* The normal Alpha calling convention sign-extends 32-bit quantties
200 no matter what the "real" sign of the 32-bit type. We want to
201 preserve that when filling in values for the kernel. */
202#define syscall_promote(arg) \
203 (sizeof (arg) == 4 ? (long)(int)(long)(arg) : (long)(arg))
204
205/* Make sure and "use" the variable that we're not returning,
206 in order to suppress unused variable warnings. */
207#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void)val, err)
208#define INTERNAL_SYSCALL_ERRNO(val, err) ((void)err, val)
209
210#define inline_syscall_clobbers \
211 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
212 "$22", "$23", "$24", "$25", "$27", "$28", "memory"
213
214/* It is moderately important optimization-wise to limit the lifetime
215 of the hard-register variables as much as possible. Thus we copy
216 in/out as close to the asm as possible. */
217
218#define inline_syscall0(name, args...) \
219{ \
220 register long _sc_19 __asm__("$19"); \
221 register long _sc_0 = name; \
222 __asm__ __volatile__ \
223 ("callsys # %0 %1 <= %2" \
224 : "+v"(_sc_0), "=r"(_sc_19) \
225 : : inline_syscall_clobbers, \
226 "$16", "$17", "$18", "$20", "$21"); \
227 _sc_ret = _sc_0, _sc_err = _sc_19; \
228}
229
230#define inline_syscall1(name,arg1) \
231{ \
232 register long _tmp_16 = syscall_promote (arg1); \
233 register long _sc_0 = name; \
234 register long _sc_16 __asm__("$16") = _tmp_16; \
235 register long _sc_19 __asm__("$19"); \
236 __asm__ __volatile__ \
237 ("callsys # %0 %1 <= %2 %3" \
238 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16) \
239 : : inline_syscall_clobbers, \
240 "$17", "$18", "$20", "$21"); \
241 _sc_ret = _sc_0, _sc_err = _sc_19; \
242}
243
244#define inline_syscall2(name,arg1,arg2) \
245{ \
246 register long _tmp_16 = syscall_promote (arg1); \
247 register long _tmp_17 = syscall_promote (arg2); \
248 register long _sc_0 = name; \
249 register long _sc_16 __asm__("$16") = _tmp_16; \
250 register long _sc_17 __asm__("$17") = _tmp_17; \
251 register long _sc_19 __asm__("$19"); \
252 __asm__ __volatile__ \
253 ("callsys # %0 %1 <= %2 %3 %4" \
254 : "+v"(_sc_0), "=r"(_sc_19), \
255 "+r"(_sc_16), "+r"(_sc_17) \
256 : : inline_syscall_clobbers, \
257 "$18", "$20", "$21"); \
258 _sc_ret = _sc_0, _sc_err = _sc_19; \
259}
260
261#define inline_syscall3(name,arg1,arg2,arg3) \
262{ \
263 register long _tmp_16 = syscall_promote (arg1); \
264 register long _tmp_17 = syscall_promote (arg2); \
265 register long _tmp_18 = syscall_promote (arg3); \
266 register long _sc_0 = name; \
267 register long _sc_16 __asm__("$16") = _tmp_16; \
268 register long _sc_17 __asm__("$17") = _tmp_17; \
269 register long _sc_18 __asm__("$18") = _tmp_18; \
270 register long _sc_19 __asm__("$19"); \
271 __asm__ __volatile__ \
272 ("callsys # %0 %1 <= %2 %3 %4 %5" \
273 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16), \
274 "+r"(_sc_17), "+r"(_sc_18) \
275 : : inline_syscall_clobbers, "$20", "$21"); \
276 _sc_ret = _sc_0, _sc_err = _sc_19; \
277}
278
279#define inline_syscall4(name,arg1,arg2,arg3,arg4) \
280{ \
281 register long _tmp_16 = syscall_promote (arg1); \
282 register long _tmp_17 = syscall_promote (arg2); \
283 register long _tmp_18 = syscall_promote (arg3); \
284 register long _tmp_19 = syscall_promote (arg4); \
285 register long _sc_0 = name; \
286 register long _sc_16 __asm__("$16") = _tmp_16; \
287 register long _sc_17 __asm__("$17") = _tmp_17; \
288 register long _sc_18 __asm__("$18") = _tmp_18; \
289 register long _sc_19 __asm__("$19") = _tmp_19; \
290 __asm__ __volatile__ \
291 ("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
292 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
293 "+r"(_sc_17), "+r"(_sc_18) \
294 : : inline_syscall_clobbers, "$20", "$21"); \
295 _sc_ret = _sc_0, _sc_err = _sc_19; \
296}
297
298#define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
299{ \
300 register long _tmp_16 = syscall_promote (arg1); \
301 register long _tmp_17 = syscall_promote (arg2); \
302 register long _tmp_18 = syscall_promote (arg3); \
303 register long _tmp_19 = syscall_promote (arg4); \
304 register long _tmp_20 = syscall_promote (arg5); \
305 register long _sc_0 = name; \
306 register long _sc_16 __asm__("$16") = _tmp_16; \
307 register long _sc_17 __asm__("$17") = _tmp_17; \
308 register long _sc_18 __asm__("$18") = _tmp_18; \
309 register long _sc_19 __asm__("$19") = _tmp_19; \
310 register long _sc_20 __asm__("$20") = _tmp_20; \
311 __asm__ __volatile__ \
312 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
313 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
314 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20) \
315 : : inline_syscall_clobbers, "$21"); \
316 _sc_ret = _sc_0, _sc_err = _sc_19; \
317}
318
319#define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
320{ \
321 register long _tmp_16 = syscall_promote (arg1); \
322 register long _tmp_17 = syscall_promote (arg2); \
323 register long _tmp_18 = syscall_promote (arg3); \
324 register long _tmp_19 = syscall_promote (arg4); \
325 register long _tmp_20 = syscall_promote (arg5); \
326 register long _tmp_21 = syscall_promote (arg6); \
327 register long _sc_0 = name; \
328 register long _sc_16 __asm__("$16") = _tmp_16; \
329 register long _sc_17 __asm__("$17") = _tmp_17; \
330 register long _sc_18 __asm__("$18") = _tmp_18; \
331 register long _sc_19 __asm__("$19") = _tmp_19; \
332 register long _sc_20 __asm__("$20") = _tmp_20; \
333 register long _sc_21 __asm__("$21") = _tmp_21; \
334 __asm__ __volatile__ \
335 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
336 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
337 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20), \
338 "+r"(_sc_21) \
339 : : inline_syscall_clobbers); \
340 _sc_ret = _sc_0, _sc_err = _sc_19; \
341}
342#endif /* ASSEMBLER */
343
344/* Pointer mangling support. Note that tls access is slow enough that
345 we don't deoptimize things by placing the pointer check value there. */
346
347#ifdef __ASSEMBLER__
348# if IS_IN (rtld)
349# define PTR_MANGLE(dst, src, tmp) \
350 ldah tmp, __pointer_chk_guard_local($29) !gprelhigh; \
351 ldq tmp, __pointer_chk_guard_local(tmp) !gprellow; \
352 xor src, tmp, dst
353# define PTR_MANGLE2(dst, src, tmp) \
354 xor src, tmp, dst
355# elif defined SHARED
356# define PTR_MANGLE(dst, src, tmp) \
357 ldq tmp, __pointer_chk_guard; \
358 xor src, tmp, dst
359# else
360# define PTR_MANGLE(dst, src, tmp) \
361 ldq tmp, __pointer_chk_guard_local; \
362 xor src, tmp, dst
363# endif
364# define PTR_MANGLE2(dst, src, tmp) \
365 xor src, tmp, dst
366# define PTR_DEMANGLE(dst, tmp) PTR_MANGLE(dst, dst, tmp)
367# define PTR_DEMANGLE2(dst, tmp) PTR_MANGLE2(dst, dst, tmp)
368#else
369# include <stdint.h>
370# if (IS_IN (rtld) \
371 || (!defined SHARED && (IS_IN (libc) \
372 || IS_IN (libpthread))))
373extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
374# define PTR_MANGLE(var) \
375 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
376# else
377extern uintptr_t __pointer_chk_guard attribute_relro;
378# define PTR_MANGLE(var) \
379 (var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
380# endif
381# define PTR_DEMANGLE(var) PTR_MANGLE(var)
382#endif /* ASSEMBLER */
lib/libc/glibc/sysdeps/unix/arm/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/i386/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/mips/mips32/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Brendan Kehoe (brendan@zen.org).
44
lib/libc/glibc/sysdeps/unix/mips/mips64/n32/sysdep.h deleted-64
......@@ -1,64 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/mips/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Note that while it's better structurally, going back to call __syscall_error
24 can make things confusing if you're debugging---it looks like it's jumping
25 backwards into the previous fn. */
26#ifdef __PIC__
27#define PSEUDO(name, syscall_name, args) \
28 .align 2; \
29 .set nomips16; \
30 cfi_startproc; \
31 99:; \
32 .set noat; \
33 .cpsetup t9, $1, name; \
34 cfi_register (gp, $1); \
35 .set at; \
36 la t9,__syscall_error; \
37 .cpreturn; \
38 cfi_restore (gp); \
39 jr t9; \
40 cfi_endproc; \
41 ENTRY(name) \
42 li v0, SYS_ify(syscall_name); \
43 syscall; \
44 bne a3, zero, 99b; \
45L(syse1):
46#else
47#define PSEUDO(name, syscall_name, args) \
48 .set noreorder; \
49 .align 2; \
50 .set nomips16; \
51 cfi_startproc; \
52 99: j __syscall_error; \
53 nop; \
54 cfi_endproc; \
55 ENTRY(name) \
56 .set noreorder; \
57 li v0, SYS_ify(syscall_name); \
58 syscall; \
59 .set reorder; \
60 bne a3, zero, 99b; \
61L(syse1):
62#endif
63
64#endif
lib/libc/glibc/sysdeps/unix/mips/mips64/n64/sysdep.h deleted-64
......@@ -1,64 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Alexandre Oliva <aoliva@redhat.com>.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <sysdeps/unix/mips/sysdep.h>
20
21#ifdef __ASSEMBLER__
22
23/* Note that while it's better structurally, going back to call __syscall_error
24 can make things confusing if you're debugging---it looks like it's jumping
25 backwards into the previous fn. */
26#ifdef __PIC__
27#define PSEUDO(name, syscall_name, args) \
28 .align 2; \
29 .set nomips16; \
30 cfi_startproc; \
31 99:; \
32 .set noat; \
33 .cpsetup t9, $1, name; \
34 cfi_register (gp, $1); \
35 .set at; \
36 dla t9,__syscall_error; \
37 .cpreturn; \
38 cfi_restore (gp); \
39 jr t9; \
40 cfi_endproc; \
41 ENTRY(name) \
42 li v0, SYS_ify(syscall_name); \
43 syscall; \
44 bne a3, zero, 99b; \
45L(syse1):
46#else
47#define PSEUDO(name, syscall_name, args) \
48 .set noreorder; \
49 .align 2; \
50 .set nomips16; \
51 cfi_startproc; \
52 99: j __syscall_error; \
53 nop; \
54 cfi_endproc; \
55 ENTRY(name) \
56 .set noreorder; \
57 li v0, SYS_ify(syscall_name); \
58 syscall; \
59 .set reorder; \
60 bne a3, zero, 99b; \
61L(syse1):
62#endif
63
64#endif
lib/libc/glibc/sysdeps/unix/mips/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Brendan Kehoe (brendan@zen.org).
44
lib/libc/glibc/sysdeps/unix/powerpc/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sh/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysdep.h+28-21
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -28,24 +28,24 @@
2828#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X (a, b)
2929
3030
31#define __INTERNAL_SYSCALL0(name, err) \
32 INTERNAL_SYSCALL (name, err, 0)
33#define __INTERNAL_SYSCALL1(name, err, a1) \
34 INTERNAL_SYSCALL (name, err, 1, a1)
35#define __INTERNAL_SYSCALL2(name, err, a1, a2) \
36 INTERNAL_SYSCALL (name, err, 2, a1, a2)
37#define __INTERNAL_SYSCALL3(name, err, a1, a2, a3) \
38 INTERNAL_SYSCALL (name, err, 3, a1, a2, a3)
39#define __INTERNAL_SYSCALL4(name, err, a1, a2, a3, a4) \
40 INTERNAL_SYSCALL (name, err, 4, a1, a2, a3, a4)
41#define __INTERNAL_SYSCALL5(name, err, a1, a2, a3, a4, a5) \
42 INTERNAL_SYSCALL (name, err, 5, a1, a2, a3, a4, a5)
43#define __INTERNAL_SYSCALL6(name, err, a1, a2, a3, a4, a5, a6) \
44 INTERNAL_SYSCALL (name, err, 6, a1, a2, a3, a4, a5, a6)
45#define __INTERNAL_SYSCALL7(name, err, a1, a2, a3, a4, a5, a6, a7) \
46 INTERNAL_SYSCALL (name, err, 7, a1, a2, a3, a4, a5, a6, a7)
47
48#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,o,...) o
31#define __INTERNAL_SYSCALL0(name) \
32 INTERNAL_SYSCALL (name, 0)
33#define __INTERNAL_SYSCALL1(name, a1) \
34 INTERNAL_SYSCALL (name, 1, a1)
35#define __INTERNAL_SYSCALL2(name, a1, a2) \
36 INTERNAL_SYSCALL (name, 2, a1, a2)
37#define __INTERNAL_SYSCALL3(name, a1, a2, a3) \
38 INTERNAL_SYSCALL (name, 3, a1, a2, a3)
39#define __INTERNAL_SYSCALL4(name, a1, a2, a3, a4) \
40 INTERNAL_SYSCALL (name, 4, a1, a2, a3, a4)
41#define __INTERNAL_SYSCALL5(name, a1, a2, a3, a4, a5) \
42 INTERNAL_SYSCALL (name, 5, a1, a2, a3, a4, a5)
43#define __INTERNAL_SYSCALL6(name, a1, a2, a3, a4, a5, a6) \
44 INTERNAL_SYSCALL (name, 6, a1, a2, a3, a4, a5, a6)
45#define __INTERNAL_SYSCALL7(name, a1, a2, a3, a4, a5, a6, a7) \
46 INTERNAL_SYSCALL (name, 7, a1, a2, a3, a4, a5, a6, a7)
47
48#define __INTERNAL_SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
4949#define __INTERNAL_SYSCALL_NARGS(...) \
5050 __INTERNAL_SYSCALL_NARGS_X (__VA_ARGS__,7,6,5,4,3,2,1,0,)
5151#define __INTERNAL_SYSCALL_DISP(b,...) \
......@@ -88,10 +88,17 @@
8888#define INLINE_SYSCALL_CALL(...) \
8989 __INLINE_SYSCALL_DISP (__INLINE_SYSCALL, __VA_ARGS__)
9090
91#if IS_IN (rtld)
92/* All cancellation points are compiled out in the dynamic loader. */
93# define NO_SYSCALL_CANCEL_CHECKING 1
94#else
95# define NO_SYSCALL_CANCEL_CHECKING SINGLE_THREAD_P
96#endif
97
9198#define SYSCALL_CANCEL(...) \
9299 ({ \
93100 long int sc_ret; \
94 if (SINGLE_THREAD_P) \
101 if (NO_SYSCALL_CANCEL_CHECKING) \
95102 sc_ret = INLINE_SYSCALL_CALL (__VA_ARGS__); \
96103 else \
97104 { \
......@@ -107,7 +114,7 @@
107114#define INTERNAL_SYSCALL_CANCEL(...) \
108115 ({ \
109116 long int sc_ret; \
110 if (SINGLE_THREAD_P) \
117 if (NO_SYSCALL_CANCEL_CHECKING) \
111118 sc_ret = INTERNAL_SYSCALL_CALL (__VA_ARGS__); \
112119 else \
113120 { \
lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. AArch64 version.
3 Copyright (C) 2018-2020 Free Software Foundation, Inc.
3 Copyright (C) 2018-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sys/elf.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
lib/libc/glibc/sysdeps/unix/sysv/linux/aarch64/sysdep.h+11-34
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2005-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -164,29 +164,10 @@
164164# define HAVE_CLOCK_GETTIME64_VSYSCALL "__kernel_clock_gettime"
165165# define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday"
166166
167/* Previously AArch64 used the generic version without the libc_hidden_def
168 which lead in a non existent __send symbol in libc.so. */
169# undef HAVE_INTERNAL_SEND_SYMBOL
170
171167# define SINGLE_THREAD_BY_GLOBAL 1
172168
173/* Define a macro which expands into the inline wrapper code for a system
174 call. */
175# undef INLINE_SYSCALL
176# define INLINE_SYSCALL(name, nr, args...) \
177 ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
178 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
179 { \
180 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
181 _sys_result = (unsigned long) -1; \
182 } \
183 (long) _sys_result; })
184
185# undef INTERNAL_SYSCALL_DECL
186# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
187
188169# undef INTERNAL_SYSCALL_RAW
189# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
170# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
190171 ({ long _sys_result; \
191172 { \
192173 LOAD_ARGS_##nr (args) \
......@@ -198,19 +179,12 @@
198179 _sys_result; })
199180
200181# undef INTERNAL_SYSCALL
201# define INTERNAL_SYSCALL(name, err, nr, args...) \
202 INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
182# define INTERNAL_SYSCALL(name, nr, args...) \
183 INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
203184
204185# undef INTERNAL_SYSCALL_AARCH64
205# define INTERNAL_SYSCALL_AARCH64(name, err, nr, args...) \
206 INTERNAL_SYSCALL_RAW(__ARM_NR_##name, err, nr, args)
207
208# undef INTERNAL_SYSCALL_ERROR_P
209# define INTERNAL_SYSCALL_ERROR_P(val, err) \
210 ((unsigned long) (val) >= (unsigned long) -4095)
211
212# undef INTERNAL_SYSCALL_ERRNO
213# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
186# define INTERNAL_SYSCALL_AARCH64(name, nr, args...) \
187 INTERNAL_SYSCALL_RAW(__ARM_NR_##name, nr, args)
214188
215189# define LOAD_ARGS_0() \
216190 register long _x0 asm ("x0");
......@@ -253,8 +227,11 @@
253227# define ASM_ARGS_7 ASM_ARGS_6, "r" (_x6)
254228
255229# undef INTERNAL_SYSCALL_NCS
256# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
257 INTERNAL_SYSCALL_RAW (number, err, nr, args)
230# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
231 INTERNAL_SYSCALL_RAW (number, nr, args)
232
233#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
234#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
258235
259236#endif /* __ASSEMBLER__ */
260237
lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/bits/stat.h deleted-160
......@@ -1,160 +0,0 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_KERNEL 0
27#define _STAT_VER_GLIBC2 1
28#define _STAT_VER_GLIBC2_1 2
29#define _STAT_VER_KERNEL64 3
30#define _STAT_VER_GLIBC2_3_4 3
31#define _STAT_VER_LINUX 3
32#define _STAT_VER _STAT_VER_LINUX
33
34/* Versions of the `xmknod' interface. */
35#define _MKNOD_VER_LINUX 0
36
37
38/* Nanosecond resolution timestamps are stored in a format equivalent to
39 'struct timespec'. This is the type used whenever possible but the
40 Unix namespace rules do not allow the identifier 'timespec' to appear
41 in the <sys/stat.h> header. Therefore we have to handle the use of
42 this header in strictly standard-compliant sources special.
43
44 Use neat tidy anonymous unions and structures when possible. */
45
46#ifdef __USE_XOPEN2K8
47# if __GNUC_PREREQ(3,3)
48# define __ST_TIME(X) \
49 __extension__ union { \
50 struct timespec st_##X##tim; \
51 struct { \
52 __time_t st_##X##time; \
53 unsigned long st_##X##timensec; \
54 }; \
55 }
56# else
57# define __ST_TIME(X) struct timespec st_##X##tim
58# define st_atime st_atim.tv_sec
59# define st_mtime st_mtim.tv_sec
60# define st_ctime st_ctim.tv_sec
61# endif
62#else
63# define __ST_TIME(X) \
64 __time_t st_##X##time; \
65 unsigned long st_##X##timensec
66#endif
67
68
69struct stat
70 {
71 __dev_t st_dev; /* Device. */
72#ifdef __USE_FILE_OFFSET64
73 __ino64_t st_ino; /* File serial number. */
74#else
75 __ino_t st_ino; /* File serial number. */
76 int __pad0; /* 64-bit st_ino. */
77#endif
78 __dev_t st_rdev; /* Device number, if device. */
79 __off_t st_size; /* Size of file, in bytes. */
80#ifdef __USE_FILE_OFFSET64
81 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
82#else
83 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
84 int __pad1; /* 64-bit st_blocks. */
85#endif
86 __mode_t st_mode; /* File mode. */
87 __uid_t st_uid; /* User ID of the file's owner. */
88 __gid_t st_gid; /* Group ID of the file's group.*/
89 __blksize_t st_blksize; /* Optimal block size for I/O. */
90 __nlink_t st_nlink; /* Link count. */
91 int __pad2; /* Real padding. */
92 __ST_TIME(a); /* Time of last access. */
93 __ST_TIME(m); /* Time of last modification. */
94 __ST_TIME(c); /* Time of last status change. */
95 long __glibc_reserved[3];
96 };
97
98#ifdef __USE_LARGEFILE64
99/* Note stat64 is the same shape as stat. */
100struct stat64
101 {
102 __dev_t st_dev; /* Device. */
103 __ino64_t st_ino; /* File serial number. */
104 __dev_t st_rdev; /* Device number, if device. */
105 __off_t st_size; /* Size of file, in bytes. */
106 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
107 __mode_t st_mode; /* File mode. */
108 __uid_t st_uid; /* User ID of the file's owner. */
109 __gid_t st_gid; /* Group ID of the file's group.*/
110 __blksize_t st_blksize; /* Optimal block size for I/O. */
111 __nlink_t st_nlink; /* Link count. */
112 int __pad0; /* Real padding. */
113 __ST_TIME(a); /* Time of last access. */
114 __ST_TIME(m); /* Time of last modification. */
115 __ST_TIME(c); /* Time of last status change. */
116 long __glibc_reserved[3];
117 };
118#endif
119
120#undef __ST_TIME
121
122/* Tell code we have these members. */
123#define _STATBUF_ST_BLKSIZE
124#define _STATBUF_ST_RDEV
125#define _STATBUF_ST_NSEC
126
127/* Encoding of the file mode. */
128
129#define __S_IFMT 0170000 /* These bits determine file type. */
130
131/* File types. */
132#define __S_IFDIR 0040000 /* Directory. */
133#define __S_IFCHR 0020000 /* Character device. */
134#define __S_IFBLK 0060000 /* Block device. */
135#define __S_IFREG 0100000 /* Regular file. */
136#define __S_IFIFO 0010000 /* FIFO. */
137#define __S_IFLNK 0120000 /* Symbolic link. */
138#define __S_IFSOCK 0140000 /* Socket. */
139
140/* POSIX.1b objects. Note that these macros always evaluate to zero. But
141 they do it by enforcing the correct use of the macros. */
142#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
143#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
144#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
145
146/* Protection bits. */
147
148#define __S_ISUID 04000 /* Set user ID on execution. */
149#define __S_ISGID 02000 /* Set group ID on execution. */
150#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
151#define __S_IREAD 0400 /* Read by owner. */
152#define __S_IWRITE 0200 /* Write by owner. */
153#define __S_IEXEC 0100 /* Execute by owner. */
154
155#ifdef __USE_ATFILE
156# define UTIME_NOW ((1l << 30) - 1l)
157# define UTIME_OMIT ((1l << 30) - 2l)
158#endif
159
160#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h+5-1
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. Linux/Alpha version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -49,6 +49,7 @@
4949#define __TIME_T_TYPE __SLONGWORD_TYPE
5050#define __USECONDS_T_TYPE __U32_TYPE
5151#define __SUSECONDS_T_TYPE __S64_TYPE
52#define __SUSECONDS64_T_TYPE __S64_TYPE
5253#define __DADDR_T_TYPE __S32_TYPE
5354#define __KEY_T_TYPE __S32_TYPE
5455#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -72,6 +73,9 @@
7273/* Not for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
7374# define __STATFS_MATCHES_STATFS64 0
7475
76/* And for getitimer, setitimer and rusage */
77#define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
78
7579/* Number of descriptors that can fit in an `fd_set'. */
7680#define __FD_SETSIZE 1024
7781
lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 2010-2020 Free Software Foundation, Inc.
3 Copyright (C) 2010-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/sysdep.h+325-8
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
44
......@@ -19,14 +19,10 @@
1919#ifndef _LINUX_ALPHA_SYSDEP_H
2020#define _LINUX_ALPHA_SYSDEP_H 1
2121
22#ifdef __ASSEMBLER__
23#include <asm/pal.h>
24#include <alpha/regdef.h>
25#endif
26
2722/* There is some commonality. */
2823#include <sysdeps/unix/sysv/linux/sysdep.h>
29#include <sysdeps/unix/alpha/sysdep.h>
24#include <sysdeps/unix/sysdep.h>
25#include <dl-sysdep.h> /* Defines RTLD_PRIVATE_ERRNO. */
3026
3127#include <tls.h>
3228
......@@ -39,4 +35,325 @@
3935
4036#define SINGLE_THREAD_BY_GLOBAL 1
4137
42#endif /* _LINUX_ALPHA_SYSDEP_H */
38#ifdef __ASSEMBLER__
39#include <asm/pal.h>
40#include <alpha/regdef.h>
41
42#define __LABEL(x) x##:
43
44#define LEAF(name, framesize) \
45 .globl name; \
46 .align 4; \
47 .ent name, 0; \
48 __LABEL(name) \
49 .frame sp, framesize, ra
50
51#define ENTRY(name) \
52 .globl name; \
53 .align 4; \
54 .ent name, 0; \
55 __LABEL(name) \
56 .frame sp, 0, ra
57
58/* Mark the end of function SYM. */
59#undef END
60#define END(sym) .end sym
61
62#ifdef PROF
63# define PSEUDO_PROF \
64 .set noat; \
65 lda AT, _mcount; \
66 jsr AT, (AT), _mcount; \
67 .set at
68#else
69# define PSEUDO_PROF
70#endif
71
72#ifdef PROF
73# define PSEUDO_PROLOGUE \
74 .frame sp, 0, ra; \
75 ldgp gp,0(pv); \
76 PSEUDO_PROF; \
77 .prologue 1
78#elif defined PIC
79# define PSEUDO_PROLOGUE \
80 .frame sp, 0, ra; \
81 .prologue 0
82#else
83# define PSEUDO_PROLOGUE \
84 .frame sp, 0, ra; \
85 ldgp gp,0(pv); \
86 .prologue 1
87#endif /* PROF */
88
89#ifdef PROF
90# define USEPV_PROF std
91#else
92# define USEPV_PROF no
93#endif
94
95#undef SYSCALL_ERROR_LABEL
96#if RTLD_PRIVATE_ERRNO
97# define SYSCALL_ERROR_LABEL $syscall_error
98# define SYSCALL_ERROR_HANDLER \
99$syscall_error: \
100 stl v0, rtld_errno(gp) !gprel; \
101 lda v0, -1; \
102 ret
103# define SYSCALL_ERROR_FALLTHRU
104#elif defined(PIC)
105# define SYSCALL_ERROR_LABEL __syscall_error !samegp
106# define SYSCALL_ERROR_HANDLER
107# define SYSCALL_ERROR_FALLTHRU br SYSCALL_ERROR_LABEL
108#else
109# define SYSCALL_ERROR_LABEL $syscall_error
110# define SYSCALL_ERROR_HANDLER \
111$syscall_error: \
112 jmp $31, __syscall_error
113# define SYSCALL_ERROR_FALLTHRU
114#endif /* RTLD_PRIVATE_ERRNO */
115
116/* Overridden by specific syscalls. */
117#undef PSEUDO_PREPARE_ARGS
118#define PSEUDO_PREPARE_ARGS /* Nothing. */
119
120#define PSEUDO(name, syscall_name, args) \
121 .globl name; \
122 .align 4; \
123 .ent name,0; \
124__LABEL(name) \
125 PSEUDO_PROLOGUE; \
126 PSEUDO_PREPARE_ARGS \
127 lda v0, SYS_ify(syscall_name); \
128 call_pal PAL_callsys; \
129 bne a3, SYSCALL_ERROR_LABEL
130
131#undef PSEUDO_END
132#define PSEUDO_END(sym) \
133 SYSCALL_ERROR_HANDLER; \
134 END(sym)
135
136#define PSEUDO_NOERRNO(name, syscall_name, args) \
137 .globl name; \
138 .align 4; \
139 .ent name,0; \
140__LABEL(name) \
141 PSEUDO_PROLOGUE; \
142 PSEUDO_PREPARE_ARGS \
143 lda v0, SYS_ify(syscall_name); \
144 call_pal PAL_callsys;
145
146#undef PSEUDO_END_NOERRNO
147#define PSEUDO_END_NOERRNO(sym) END(sym)
148
149#define ret_NOERRNO ret
150
151#define PSEUDO_ERRVAL(name, syscall_name, args) \
152 .globl name; \
153 .align 4; \
154 .ent name,0; \
155__LABEL(name) \
156 PSEUDO_PROLOGUE; \
157 PSEUDO_PREPARE_ARGS \
158 lda v0, SYS_ify(syscall_name); \
159 call_pal PAL_callsys;
160
161#undef PSEUDO_END_ERRVAL
162#define PSEUDO_END_ERRVAL(sym) END(sym)
163
164#define ret_ERRVAL ret
165
166#define r0 v0
167#define r1 a4
168
169#define MOVE(x,y) mov x,y
170
171#else /* !ASSEMBLER */
172
173#define INTERNAL_SYSCALL(name, nr, args...) \
174 internal_syscall##nr(__NR_##name, args)
175
176#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
177 internal_syscall##nr(name, args)
178
179/* The normal Alpha calling convention sign-extends 32-bit quantties
180 no matter what the "real" sign of the 32-bit type. We want to
181 preserve that when filling in values for the kernel. */
182#define syscall_promote(arg) \
183 (sizeof (arg) == 4 ? (long int)(int)(long int)(arg) : (long int)(arg))
184
185#define internal_syscall_clobbers \
186 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
187 "$22", "$23", "$24", "$25", "$27", "$28", "memory"
188
189/* It is moderately important optimization-wise to limit the lifetime
190 of the hard-register variables as much as possible. Thus we copy
191 in/out as close to the asm as possible. */
192
193#define internal_syscall0(name, args...) \
194({ \
195 register long int _sc_19 __asm__("$19"); \
196 register long int _sc_0 = name; \
197 __asm__ __volatile__ \
198 ("callsys # %0 %1 <= %2" \
199 : "+v"(_sc_0), "=r"(_sc_19) \
200 : : internal_syscall_clobbers, \
201 "$16", "$17", "$18", "$20", "$21"); \
202 _sc_19 != 0 ? -_sc_0 : _sc_0; \
203})
204
205#define internal_syscall1(name,arg1) \
206({ \
207 register long int _tmp_16 = syscall_promote (arg1); \
208 register long int _sc_0 = name; \
209 register long int _sc_16 __asm__("$16") = _tmp_16; \
210 register long int _sc_19 __asm__("$19"); \
211 __asm__ __volatile__ \
212 ("callsys # %0 %1 <= %2 %3" \
213 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16) \
214 : : internal_syscall_clobbers, \
215 "$17", "$18", "$20", "$21"); \
216 _sc_19 != 0 ? -_sc_0 : _sc_0; \
217})
218
219#define internal_syscall2(name,arg1,arg2) \
220({ \
221 register long int _tmp_16 = syscall_promote (arg1); \
222 register long int _tmp_17 = syscall_promote (arg2); \
223 register long int _sc_0 = name; \
224 register long int _sc_16 __asm__("$16") = _tmp_16; \
225 register long int _sc_17 __asm__("$17") = _tmp_17; \
226 register long int _sc_19 __asm__("$19"); \
227 __asm__ __volatile__ \
228 ("callsys # %0 %1 <= %2 %3 %4" \
229 : "+v"(_sc_0), "=r"(_sc_19), \
230 "+r"(_sc_16), "+r"(_sc_17) \
231 : : internal_syscall_clobbers, \
232 "$18", "$20", "$21"); \
233 _sc_19 != 0 ? -_sc_0 : _sc_0; \
234})
235
236#define internal_syscall3(name,arg1,arg2,arg3) \
237({ \
238 register long int _tmp_16 = syscall_promote (arg1); \
239 register long int _tmp_17 = syscall_promote (arg2); \
240 register long int _tmp_18 = syscall_promote (arg3); \
241 register long int _sc_0 = name; \
242 register long int _sc_16 __asm__("$16") = _tmp_16; \
243 register long int _sc_17 __asm__("$17") = _tmp_17; \
244 register long int _sc_18 __asm__("$18") = _tmp_18; \
245 register long int _sc_19 __asm__("$19"); \
246 __asm__ __volatile__ \
247 ("callsys # %0 %1 <= %2 %3 %4 %5" \
248 : "+v"(_sc_0), "=r"(_sc_19), "+r"(_sc_16), \
249 "+r"(_sc_17), "+r"(_sc_18) \
250 : : internal_syscall_clobbers, "$20", "$21"); \
251 _sc_19 != 0 ? -_sc_0 : _sc_0; \
252})
253
254#define internal_syscall4(name,arg1,arg2,arg3,arg4) \
255({ \
256 register long int _tmp_16 = syscall_promote (arg1); \
257 register long int _tmp_17 = syscall_promote (arg2); \
258 register long int _tmp_18 = syscall_promote (arg3); \
259 register long int _tmp_19 = syscall_promote (arg4); \
260 register long int _sc_0 = name; \
261 register long int _sc_16 __asm__("$16") = _tmp_16; \
262 register long int _sc_17 __asm__("$17") = _tmp_17; \
263 register long int _sc_18 __asm__("$18") = _tmp_18; \
264 register long int _sc_19 __asm__("$19") = _tmp_19; \
265 __asm__ __volatile__ \
266 ("callsys # %0 %1 <= %2 %3 %4 %5 %6" \
267 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
268 "+r"(_sc_17), "+r"(_sc_18) \
269 : : internal_syscall_clobbers, "$20", "$21"); \
270 _sc_19 != 0 ? -_sc_0 : _sc_0; \
271})
272
273#define internal_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
274({ \
275 register long int _tmp_16 = syscall_promote (arg1); \
276 register long int _tmp_17 = syscall_promote (arg2); \
277 register long int _tmp_18 = syscall_promote (arg3); \
278 register long int _tmp_19 = syscall_promote (arg4); \
279 register long int _tmp_20 = syscall_promote (arg5); \
280 register long int _sc_0 = name; \
281 register long int _sc_16 __asm__("$16") = _tmp_16; \
282 register long int _sc_17 __asm__("$17") = _tmp_17; \
283 register long int _sc_18 __asm__("$18") = _tmp_18; \
284 register long int _sc_19 __asm__("$19") = _tmp_19; \
285 register long int _sc_20 __asm__("$20") = _tmp_20; \
286 __asm__ __volatile__ \
287 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7" \
288 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
289 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20) \
290 : : internal_syscall_clobbers, "$21"); \
291 _sc_19 != 0 ? -_sc_0 : _sc_0; \
292})
293
294#define internal_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
295({ \
296 register long int _tmp_16 = syscall_promote (arg1); \
297 register long int _tmp_17 = syscall_promote (arg2); \
298 register long int _tmp_18 = syscall_promote (arg3); \
299 register long int _tmp_19 = syscall_promote (arg4); \
300 register long int _tmp_20 = syscall_promote (arg5); \
301 register long int _tmp_21 = syscall_promote (arg6); \
302 register long int _sc_0 = name; \
303 register long int _sc_16 __asm__("$16") = _tmp_16; \
304 register long int _sc_17 __asm__("$17") = _tmp_17; \
305 register long int _sc_18 __asm__("$18") = _tmp_18; \
306 register long int _sc_19 __asm__("$19") = _tmp_19; \
307 register long int _sc_20 __asm__("$20") = _tmp_20; \
308 register long int _sc_21 __asm__("$21") = _tmp_21; \
309 __asm__ __volatile__ \
310 ("callsys # %0 %1 <= %2 %3 %4 %5 %6 %7 %8" \
311 : "+v"(_sc_0), "+r"(_sc_19), "+r"(_sc_16), \
312 "+r"(_sc_17), "+r"(_sc_18), "+r"(_sc_20), \
313 "+r"(_sc_21) \
314 : : internal_syscall_clobbers); \
315 _sc_19 != 0 ? -_sc_0 : _sc_0; \
316})
317#endif /* ASSEMBLER */
318
319/* Pointer mangling support. Note that tls access is slow enough that
320 we don't deoptimize things by placing the pointer check value there. */
321
322#ifdef __ASSEMBLER__
323# if IS_IN (rtld)
324# define PTR_MANGLE(dst, src, tmp) \
325 ldah tmp, __pointer_chk_guard_local($29) !gprelhigh; \
326 ldq tmp, __pointer_chk_guard_local(tmp) !gprellow; \
327 xor src, tmp, dst
328# define PTR_MANGLE2(dst, src, tmp) \
329 xor src, tmp, dst
330# elif defined SHARED
331# define PTR_MANGLE(dst, src, tmp) \
332 ldq tmp, __pointer_chk_guard; \
333 xor src, tmp, dst
334# else
335# define PTR_MANGLE(dst, src, tmp) \
336 ldq tmp, __pointer_chk_guard_local; \
337 xor src, tmp, dst
338# endif
339# define PTR_MANGLE2(dst, src, tmp) \
340 xor src, tmp, dst
341# define PTR_DEMANGLE(dst, tmp) PTR_MANGLE(dst, dst, tmp)
342# define PTR_DEMANGLE2(dst, tmp) PTR_MANGLE2(dst, dst, tmp)
343#else
344# include <stdint.h>
345# if (IS_IN (rtld) \
346 || (!defined SHARED && (IS_IN (libc) \
347 || IS_IN (libpthread))))
348extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
349# define PTR_MANGLE(var) \
350 (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
351# else
352extern uintptr_t __pointer_chk_guard attribute_relro;
353# define PTR_MANGLE(var) \
354 (var) = (__typeof(var)) ((uintptr_t) (var) ^ __pointer_chk_guard)
355# endif
356# define PTR_DEMANGLE(var) PTR_MANGLE(var)
357#endif /* ASSEMBLER */
358
359#endif /* _LINUX_ALPHA_SYSDEP_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/arm/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 2006-2020 Free Software Foundation, Inc.
3 Copyright (C) 2006-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/arm/sys/elf.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/arm/sysdep.h+7-34
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
44 ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
......@@ -29,11 +29,6 @@
2929
3030#include <tls.h>
3131
32/* In order to get __set_errno() definition in INLINE_SYSCALL. */
33#ifndef __ASSEMBLER__
34#include <errno.h>
35#endif
36
3732/* For Linux we can use the system call table in the header file
3833 /usr/include/asm/unistd.h
3934 of the kernel. But these symbols do not follow the SYS_* syntax
......@@ -317,21 +312,6 @@ __local_syscall_error: \
317312
318313#else /* not __ASSEMBLER__ */
319314
320/* Define a macro which expands into the inline wrapper code for a system
321 call. */
322#undef INLINE_SYSCALL
323#define INLINE_SYSCALL(name, nr, args...) \
324 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
325 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0)) \
326 { \
327 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
328 _sys_result = (unsigned int) -1; \
329 } \
330 (int) _sys_result; })
331
332#undef INTERNAL_SYSCALL_DECL
333#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
334
335315#if defined(__thumb__)
336316/* We can not expose the use of r7 to the compiler. GCC (as
337317 of 4.5) uses r7 as the hard frame pointer for Thumb - although
......@@ -348,7 +328,7 @@ __local_syscall_error: \
348328 then unwinding will fail higher up the stack. So we move the
349329 syscall out of line and provide its own unwind information. */
350330# undef INTERNAL_SYSCALL_RAW
351# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
331# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
352332 ({ \
353333 register int _a1 asm ("a1"); \
354334 int _nametmp = name; \
......@@ -361,7 +341,7 @@ __local_syscall_error: \
361341 _a1; })
362342#else /* ARM */
363343# undef INTERNAL_SYSCALL_RAW
364# define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \
344# define INTERNAL_SYSCALL_RAW(name, nr, args...) \
365345 ({ \
366346 register int _a1 asm ("r0"), _nr asm ("r7"); \
367347 LOAD_ARGS_##nr (args) \
......@@ -374,15 +354,8 @@ __local_syscall_error: \
374354#endif
375355
376356#undef INTERNAL_SYSCALL
377#define INTERNAL_SYSCALL(name, err, nr, args...) \
378 INTERNAL_SYSCALL_RAW(SYS_ify(name), err, nr, args)
379
380#undef INTERNAL_SYSCALL_ERROR_P
381#define INTERNAL_SYSCALL_ERROR_P(val, err) \
382 ((unsigned int) (val) >= 0xfffff001u)
383
384#undef INTERNAL_SYSCALL_ERRNO
385#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
357#define INTERNAL_SYSCALL(name, nr, args...) \
358 INTERNAL_SYSCALL_RAW(SYS_ify(name), nr, args)
386359
387360#define VDSO_NAME "LINUX_2.6"
388361#define VDSO_HASH 61765110
......@@ -434,8 +407,8 @@ __local_syscall_error: \
434407
435408/* For EABI, non-constant syscalls are actually pretty easy... */
436409#undef INTERNAL_SYSCALL_NCS
437#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
438 INTERNAL_SYSCALL_RAW (number, err, nr, args)
410#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
411 INTERNAL_SYSCALL_RAW (number, nr, args)
439412
440413#define SINGLE_THREAD_BY_GLOBAL 1
441414
lib/libc/glibc/sysdeps/unix/sysv/linux/bits/stat.h+2-114
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -22,119 +22,7 @@
2222#ifndef _BITS_STAT_H
2323#define _BITS_STAT_H 1
2424
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_LINUX_OLD 1
27#define _STAT_VER_KERNEL 1
28#define _STAT_VER_SVR4 2
29#define _STAT_VER_LINUX 3
30#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
31
32/* Versions of the `xmknod' interface. */
33#define _MKNOD_VER_LINUX 1
34#define _MKNOD_VER_SVR4 2
35#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36
37
38struct stat
39 {
40 __dev_t st_dev; /* Device. */
41 unsigned short int __pad1;
42#ifndef __USE_FILE_OFFSET64
43 __ino_t st_ino; /* File serial number. */
44#else
45 __ino_t __st_ino; /* 32bit file serial number. */
46#endif
47 __mode_t st_mode; /* File mode. */
48 __nlink_t st_nlink; /* Link count. */
49 __uid_t st_uid; /* User ID of the file's owner. */
50 __gid_t st_gid; /* Group ID of the file's group.*/
51 __dev_t st_rdev; /* Device number, if device. */
52 unsigned short int __pad2;
53#ifndef __USE_FILE_OFFSET64
54 __off_t st_size; /* Size of file, in bytes. */
55#else
56 __off64_t st_size; /* Size of file, in bytes. */
57#endif
58 __blksize_t st_blksize; /* Optimal block size for I/O. */
59
60#ifndef __USE_FILE_OFFSET64
61 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
62#else
63 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86#ifndef __USE_FILE_OFFSET64
87 unsigned long int __glibc_reserved4;
88 unsigned long int __glibc_reserved5;
89#else
90 __ino64_t st_ino; /* File serial number. */
91#endif
92 };
93
94#ifdef __USE_LARGEFILE64
95struct stat64
96 {
97 __dev_t st_dev; /* Device. */
98 unsigned int __pad1;
99
100 __ino_t __st_ino; /* 32bit file serial number. */
101 __mode_t st_mode; /* File mode. */
102 __nlink_t st_nlink; /* Link count. */
103 __uid_t st_uid; /* User ID of the file's owner. */
104 __gid_t st_gid; /* Group ID of the file's group.*/
105 __dev_t st_rdev; /* Device number, if device. */
106 unsigned int __pad2;
107 __off64_t st_size; /* Size of file, in bytes. */
108 __blksize_t st_blksize; /* Optimal block size for I/O. */
109
110 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
111# ifdef __USE_XOPEN2K8
112 /* Nanosecond resolution timestamps are stored in a format
113 equivalent to 'struct timespec'. This is the type used
114 whenever possible but the Unix namespace rules do not allow the
115 identifier 'timespec' to appear in the <sys/stat.h> header.
116 Therefore we have to handle the use of this header in strictly
117 standard-compliant sources special. */
118 struct timespec st_atim; /* Time of last access. */
119 struct timespec st_mtim; /* Time of last modification. */
120 struct timespec st_ctim; /* Time of last status change. */
121# else
122 __time_t st_atime; /* Time of last access. */
123 unsigned long int st_atimensec; /* Nscecs of last access. */
124 __time_t st_mtime; /* Time of last modification. */
125 unsigned long int st_mtimensec; /* Nsecs of last modification. */
126 __time_t st_ctime; /* Time of last status change. */
127 unsigned long int st_ctimensec; /* Nsecs of last status change. */
128# endif
129 __ino64_t st_ino; /* File serial number. */
130 };
131#endif
132
133/* Tell code we have these members. */
134#define _STATBUF_ST_BLKSIZE
135#define _STATBUF_ST_RDEV
136/* Nanosecond resolution time values are supported. */
137#define _STATBUF_ST_NSEC
25#include <bits/struct_stat.h>
13826
13927/* Encoding of the file mode. */
14028
lib/libc/glibc/sysdeps/unix/sysv/linux/bits/timex.h+32-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -25,6 +25,36 @@
2525
2626struct timex
2727{
28# ifdef __USE_TIME_BITS64
29 unsigned int modes; /* mode selector */
30 int :32; /* pad */
31 long long offset; /* time offset (usec) */
32 long long freq; /* frequency offset (scaled ppm) */
33 long long maxerror; /* maximum error (usec) */
34 long long esterror; /* estimated error (usec) */
35 int status; /* clock command/status */
36 int :32; /* pad */
37 long long constant; /* pll time constant */
38 long long precision; /* clock precision (usec) (read only) */
39 long long tolerance; /* clock frequency tolerance (ppm) (ro) */
40 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
41 long long tick; /* (modified) usecs between clock ticks */
42 long long ppsfreq; /* pps frequency (scaled ppm) (ro) */
43 long long jitter; /* pps jitter (us) (ro) */
44 int shift; /* interval duration (s) (shift) (ro) */
45 int :32; /* pad */
46 long long stabil; /* pps stability (scaled ppm) (ro) */
47 long long jitcnt; /* jitter limit exceeded (ro) */
48 long long calcnt; /* calibration intervals (ro) */
49 long long errcnt; /* calibration errors (ro) */
50 long long stbcnt; /* stability limit exceeded (ro) */
51
52 int tai; /* TAI offset (ro) */
53
54 int :32; int :32; int :32; int :32;
55 int :32; int :32; int :32; int :32;
56 int :32; int :32; int :32;
57# else
2858 unsigned int modes; /* mode selector */
2959 __syscall_slong_t offset; /* time offset (usec) */
3060 __syscall_slong_t freq; /* frequency offset (scaled ppm) */
......@@ -51,6 +81,7 @@ struct timex
5181 int :32; int :32; int :32; int :32;
5282 int :32; int :32; int :32; int :32;
5383 int :32; int :32; int :32;
84# endif
5485};
5586
5687/* Mode codes (timex.mode) */
lib/libc/glibc/sysdeps/unix/sysv/linux/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. Linux version.
2 Copyright (C) 2005-2020 Free Software Foundation, Inc.
2 Copyright (C) 2005-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/generic/bits/stat.h deleted-174
......@@ -1,174 +0,0 @@
1/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <https://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_STAT_H && !defined _FCNTL_H
20# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
21#endif
22
23#ifndef _BITS_STAT_H
24#define _BITS_STAT_H 1
25
26#include <bits/endian.h>
27#include <bits/wordsize.h>
28
29/* 64-bit libc uses the kernel's 'struct stat', accessed via the
30 stat() syscall; 32-bit libc uses the kernel's 'struct stat64'
31 and accesses it via the stat64() syscall. All the various
32 APIs offered by libc use the kernel shape for their struct stat
33 structure; the only difference is that 32-bit programs not
34 using __USE_FILE_OFFSET64 only see the low 32 bits of some
35 of the fields (specifically st_ino, st_size, and st_blocks). */
36#define _STAT_VER_KERNEL 0
37#define _STAT_VER_LINUX 0
38#define _STAT_VER _STAT_VER_KERNEL
39
40/* Versions of the `xmknod' interface. */
41#define _MKNOD_VER_LINUX 0
42
43#if defined __USE_FILE_OFFSET64
44# define __field64(type, type64, name) type64 name
45#elif __WORDSIZE == 64 || defined __INO_T_MATCHES_INO64_T
46# if defined __INO_T_MATCHES_INO64_T && !defined __OFF_T_MATCHES_OFF64_T
47# error "ino_t and off_t must both be the same type"
48# endif
49# define __field64(type, type64, name) type name
50#elif __BYTE_ORDER == __LITTLE_ENDIAN
51# define __field64(type, type64, name) \
52 type name __attribute__((__aligned__ (__alignof__ (type64)))); int __##name##_pad
53#else
54# define __field64(type, type64, name) \
55 int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
56#endif
57
58struct stat
59 {
60 __dev_t st_dev; /* Device. */
61 __field64(__ino_t, __ino64_t, st_ino); /* File serial number. */
62 __mode_t st_mode; /* File mode. */
63 __nlink_t st_nlink; /* Link count. */
64 __uid_t st_uid; /* User ID of the file's owner. */
65 __gid_t st_gid; /* Group ID of the file's group.*/
66 __dev_t st_rdev; /* Device number, if device. */
67 __dev_t __pad1;
68 __field64(__off_t, __off64_t, st_size); /* Size of file, in bytes. */
69 __blksize_t st_blksize; /* Optimal block size for I/O. */
70 int __pad2;
71 __field64(__blkcnt_t, __blkcnt64_t, st_blocks); /* 512-byte blocks */
72#ifdef __USE_XOPEN2K8
73 /* Nanosecond resolution timestamps are stored in a format
74 equivalent to 'struct timespec'. This is the type used
75 whenever possible but the Unix namespace rules do not allow the
76 identifier 'timespec' to appear in the <sys/stat.h> header.
77 Therefore we have to handle the use of this header in strictly
78 standard-compliant sources special. */
79 struct timespec st_atim; /* Time of last access. */
80 struct timespec st_mtim; /* Time of last modification. */
81 struct timespec st_ctim; /* Time of last status change. */
82# define st_atime st_atim.tv_sec /* Backward compatibility. */
83# define st_mtime st_mtim.tv_sec
84# define st_ctime st_ctim.tv_sec
85#else
86 __time_t st_atime; /* Time of last access. */
87 unsigned long int st_atimensec; /* Nscecs of last access. */
88 __time_t st_mtime; /* Time of last modification. */
89 unsigned long int st_mtimensec; /* Nsecs of last modification. */
90 __time_t st_ctime; /* Time of last status change. */
91 unsigned long int st_ctimensec; /* Nsecs of last status change. */
92#endif
93 int __glibc_reserved[2];
94 };
95
96#undef __field64
97
98#ifdef __USE_LARGEFILE64
99struct stat64
100 {
101 __dev_t st_dev; /* Device. */
102 __ino64_t st_ino; /* File serial number. */
103 __mode_t st_mode; /* File mode. */
104 __nlink_t st_nlink; /* Link count. */
105 __uid_t st_uid; /* User ID of the file's owner. */
106 __gid_t st_gid; /* Group ID of the file's group.*/
107 __dev_t st_rdev; /* Device number, if device. */
108 __dev_t __pad1;
109 __off64_t st_size; /* Size of file, in bytes. */
110 __blksize_t st_blksize; /* Optimal block size for I/O. */
111 int __pad2;
112 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
113#ifdef __USE_XOPEN2K8
114 /* Nanosecond resolution timestamps are stored in a format
115 equivalent to 'struct timespec'. This is the type used
116 whenever possible but the Unix namespace rules do not allow the
117 identifier 'timespec' to appear in the <sys/stat.h> header.
118 Therefore we have to handle the use of this header in strictly
119 standard-compliant sources special. */
120 struct timespec st_atim; /* Time of last access. */
121 struct timespec st_mtim; /* Time of last modification. */
122 struct timespec st_ctim; /* Time of last status change. */
123#else
124 __time_t st_atime; /* Time of last access. */
125 unsigned long int st_atimensec; /* Nscecs of last access. */
126 __time_t st_mtime; /* Time of last modification. */
127 unsigned long int st_mtimensec; /* Nsecs of last modification. */
128 __time_t st_ctime; /* Time of last status change. */
129 unsigned long int st_ctimensec; /* Nsecs of last status change. */
130#endif
131 int __glibc_reserved[2];
132 };
133#endif
134
135/* Tell code we have these members. */
136#define _STATBUF_ST_BLKSIZE
137#define _STATBUF_ST_RDEV
138/* Nanosecond resolution time values are supported. */
139#define _STATBUF_ST_NSEC
140
141/* Encoding of the file mode. */
142
143#define __S_IFMT 0170000 /* These bits determine file type. */
144
145/* File types. */
146#define __S_IFDIR 0040000 /* Directory. */
147#define __S_IFCHR 0020000 /* Character device. */
148#define __S_IFBLK 0060000 /* Block device. */
149#define __S_IFREG 0100000 /* Regular file. */
150#define __S_IFIFO 0010000 /* FIFO. */
151#define __S_IFLNK 0120000 /* Symbolic link. */
152#define __S_IFSOCK 0140000 /* Socket. */
153
154/* POSIX.1b objects. Note that these macros always evaluate to zero. But
155 they do it by enforcing the correct use of the macros. */
156#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
157#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
158#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
159
160/* Protection bits. */
161
162#define __S_ISUID 04000 /* Set user ID on execution. */
163#define __S_ISGID 02000 /* Set group ID on execution. */
164#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
165#define __S_IREAD 0400 /* Read by owner. */
166#define __S_IWRITE 0200 /* Write by owner. */
167#define __S_IEXEC 0100 /* Execute by owner. */
168
169#ifdef __USE_ATFILE
170# define UTIME_NOW ((1l << 30) - 1l)
171# define UTIME_OMIT ((1l << 30) - 2l)
172#endif
173
174#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/generic/bits/typesizes.h+30-10
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. For the generic Linux ABI.
2 Copyright (C) 2011-2020 Free Software Foundation, Inc.
2 Copyright (C) 2011-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
55
......@@ -26,31 +26,45 @@
2626
2727/* See <bits/types.h> for the meaning of these macros. This file exists so
2828 that <bits/types.h> need not vary across different GNU platforms. */
29#if __TIMESIZE == 64 && __WORDSIZE == 32
30/* These are the "new" y2038 types defined for architectures added after
31 the 5.1 kernel. */
32# define __INO_T_TYPE __UQUAD_TYPE
33# define __OFF_T_TYPE __SQUAD_TYPE
34# define __RLIM_T_TYPE __UQUAD_TYPE
35# define __BLKCNT_T_TYPE __SQUAD_TYPE
36# define __FSBLKCNT_T_TYPE __UQUAD_TYPE
37# define __FSFILCNT_T_TYPE __UQUAD_TYPE
38# define __TIME_T_TYPE __SQUAD_TYPE
39# define __SUSECONDS_T_TYPE __SQUAD_TYPE
40#else
41# define __INO_T_TYPE __ULONGWORD_TYPE
42# define __OFF_T_TYPE __SLONGWORD_TYPE
43# define __RLIM_T_TYPE __ULONGWORD_TYPE
44# define __BLKCNT_T_TYPE __SLONGWORD_TYPE
45# define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
46# define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
47# define __TIME_T_TYPE __SLONGWORD_TYPE
48# define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
49#endif
2950
3051#define __DEV_T_TYPE __UQUAD_TYPE
3152#define __UID_T_TYPE __U32_TYPE
3253#define __GID_T_TYPE __U32_TYPE
33#define __INO_T_TYPE __ULONGWORD_TYPE
3454#define __INO64_T_TYPE __UQUAD_TYPE
3555#define __MODE_T_TYPE __U32_TYPE
3656#define __NLINK_T_TYPE __U32_TYPE
37#define __OFF_T_TYPE __SLONGWORD_TYPE
3857#define __OFF64_T_TYPE __SQUAD_TYPE
3958#define __PID_T_TYPE __S32_TYPE
40#define __RLIM_T_TYPE __ULONGWORD_TYPE
4159#define __RLIM64_T_TYPE __UQUAD_TYPE
42#define __BLKCNT_T_TYPE __SLONGWORD_TYPE
4360#define __BLKCNT64_T_TYPE __SQUAD_TYPE
44#define __FSBLKCNT_T_TYPE __ULONGWORD_TYPE
4561#define __FSBLKCNT64_T_TYPE __UQUAD_TYPE
46#define __FSFILCNT_T_TYPE __ULONGWORD_TYPE
4762#define __FSFILCNT64_T_TYPE __UQUAD_TYPE
4863#define __FSWORD_T_TYPE __SWORD_TYPE
4964#define __ID_T_TYPE __U32_TYPE
5065#define __CLOCK_T_TYPE __SLONGWORD_TYPE
51#define __TIME_T_TYPE __SLONGWORD_TYPE
5266#define __USECONDS_T_TYPE __U32_TYPE
53#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
67#define __SUSECONDS64_T_TYPE __SQUAD_TYPE
5468#define __DADDR_T_TYPE __S32_TYPE
5569#define __KEY_T_TYPE __S32_TYPE
5670#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -62,7 +76,7 @@
6276#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
6377#define __CPU_MASK_TYPE __ULONGWORD_TYPE
6478
65#ifdef __LP64__
79#if defined __LP64__ || (__TIMESIZE == 64 && __WORDSIZE == 32)
6680/* Tell the libc code that off_t and off64_t are actually the same type
6781 for all ABI purposes, even if possibly expressed as different base types
6882 for C type-checking purposes. */
......@@ -76,11 +90,17 @@
7690
7791/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
7892# define __STATFS_MATCHES_STATFS64 1
93
94/* And for getitimer, setitimer and rusage */
95# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 (__WORDSIZE == 64)
7996#else
8097# define __RLIM_T_MATCHES_RLIM64_T 0
8198
8299# define __STATFS_MATCHES_STATFS64 0
100
101# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
83102#endif
103
84104/* Number of descriptors that can fit in an `fd_set'. */
85105#define __FD_SETSIZE 1024
86106
lib/libc/glibc/sysdeps/unix/sysv/linux/generic/sysdep.h+1-9
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
44
......@@ -25,11 +25,3 @@
2525#ifdef __NR_llseek
2626# define __NR__llseek __NR_llseek
2727#endif
28
29#if __WORDSIZE == 64
30/* By defining the older names, glibc will build syscall wrappers for
31 both pread and pread64; sysdeps/unix/sysv/linux/wordsize-64/pread64.c
32 will suppress generating any separate code for pread64.c. */
33#define __NR_pread __NR_pread64
34#define __NR_pwrite __NR_pwrite64
35#endif
lib/libc/glibc/sysdeps/unix/sysv/linux/generic/xstatver.h created+10
......@@ -0,0 +1,10 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_KERNEL 0
4#define _STAT_VER_LINUX 0
5#define _STAT_VER _STAT_VER_KERNEL
6
7/* Versions of the 'xmknod' interface used in compatibility xmknod
8 functions. */
9#define _MKNOD_VER_LINUX 0
10#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/kernel-features.h+1-6
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 2006-2020 Free Software Foundation, Inc.
3 Copyright (C) 2006-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -18,11 +18,6 @@
1818 <https://www.gnu.org/licenses/>. */
1919
2020
21/* Support for the utimes syscall was added in 3.14. */
22#if __LINUX_KERNEL_VERSION >= 0x030e00
23# define __ASSUME_UTIMES 1
24#endif
25
2621#include_next <kernel-features.h>
2722
2823#define __ASSUME_RECV_SYSCALL 1
lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/pthread.h deleted-1174
......@@ -1,1174 +0,0 @@
1/* Copyright (C) 2002-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _PTHREAD_H
19#define _PTHREAD_H 1
20
21#include <features.h>
22#include <endian.h>
23#include <sched.h>
24#include <time.h>
25
26#include <bits/pthreadtypes.h>
27#include <bits/setjmp.h>
28#include <bits/wordsize.h>
29#include <bits/types/struct_timespec.h>
30
31
32/* Detach state. */
33enum
34{
35 PTHREAD_CREATE_JOINABLE,
36#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
37 PTHREAD_CREATE_DETACHED
38#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
39};
40
41
42/* Mutex types. */
43enum
44{
45 PTHREAD_MUTEX_TIMED_NP,
46 PTHREAD_MUTEX_RECURSIVE_NP,
47 PTHREAD_MUTEX_ERRORCHECK_NP,
48 PTHREAD_MUTEX_ADAPTIVE_NP
49#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
50 ,
51 PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
52 PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
53 PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
54 PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
55#endif
56#ifdef __USE_GNU
57 /* For compatibility. */
58 , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
59#endif
60};
61
62
63#ifdef __USE_XOPEN2K
64/* Robust mutex or not flags. */
65enum
66{
67 PTHREAD_MUTEX_STALLED,
68 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
69 PTHREAD_MUTEX_ROBUST,
70 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
71};
72#endif
73
74
75#if defined __USE_POSIX199506 || defined __USE_UNIX98
76/* Mutex protocols. */
77enum
78{
79 PTHREAD_PRIO_NONE,
80 PTHREAD_PRIO_INHERIT,
81 PTHREAD_PRIO_PROTECT
82};
83#endif
84
85
86#define PTHREAD_MUTEX_INITIALIZER \
87 { { 0, 0, 0, 0, { 0, 0, 0, 0 }, 0, { __PTHREAD_SPINS }, { 0, 0 } } }
88#ifdef __USE_GNU
89# define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
90 { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, { 0, 0, 0, 0 }, 0, \
91 { __PTHREAD_SPINS }, { 0, 0 } } }
92# define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
93 { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, { 0, 0, 0, 0 }, 0, \
94 { __PTHREAD_SPINS }, { 0, 0 } } }
95# define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
96 { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, { 0, 0, 0, 0 }, 0, \
97 { __PTHREAD_SPINS }, { 0, 0 } } }
98#endif
99
100
101/* Read-write lock types. */
102#if defined __USE_UNIX98 || defined __USE_XOPEN2K
103enum
104{
105 PTHREAD_RWLOCK_PREFER_READER_NP,
106 PTHREAD_RWLOCK_PREFER_WRITER_NP,
107 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
108 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
109};
110
111/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
112 has the shared field. All 64-bit architectures have the shared field
113 in pthread_rwlock_t. */
114#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
115# if __WORDSIZE == 64
116# define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
117# endif
118#endif
119
120
121/* Read-write lock initializers. */
122# define PTHREAD_RWLOCK_INITIALIZER \
123 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
124# ifdef __USE_GNU
125# define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
126 { { { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
127 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, 0, 0, 0 } }
128# endif
129#endif /* Unix98 or XOpen2K */
130
131
132/* Scheduler inheritance. */
133enum
134{
135 PTHREAD_INHERIT_SCHED,
136#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
137 PTHREAD_EXPLICIT_SCHED
138#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
139};
140
141
142/* Scope handling. */
143enum
144{
145 PTHREAD_SCOPE_SYSTEM,
146#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
147 PTHREAD_SCOPE_PROCESS
148#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
149};
150
151
152/* Process shared or private flag. */
153enum
154{
155 PTHREAD_PROCESS_PRIVATE,
156#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
157 PTHREAD_PROCESS_SHARED
158#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
159};
160
161
162/* Conditional variable handling. */
163#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
164
165
166/* Cleanup buffers */
167struct _pthread_cleanup_buffer
168{
169 void (*__routine) (void *); /* Function to call. */
170 void *__arg; /* Its argument. */
171 int __canceltype; /* Saved cancellation type. */
172 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
173};
174
175/* Cancellation */
176enum
177{
178 PTHREAD_CANCEL_ENABLE,
179#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
180 PTHREAD_CANCEL_DISABLE
181#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
182};
183enum
184{
185 PTHREAD_CANCEL_DEFERRED,
186#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
187 PTHREAD_CANCEL_ASYNCHRONOUS
188#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
189};
190#define PTHREAD_CANCELED ((void *) -1)
191
192
193/* Single execution handling. */
194#define PTHREAD_ONCE_INIT 0
195
196
197#ifdef __USE_XOPEN2K
198/* Value returned by 'pthread_barrier_wait' for one of the threads after
199 the required number of threads have called this function.
200 -1 is distinct from 0 and all errno constants */
201# define PTHREAD_BARRIER_SERIAL_THREAD -1
202#endif
203
204
205__BEGIN_DECLS
206
207/* Create a new thread, starting with execution of START-ROUTINE
208 getting passed ARG. Creation attributed come from ATTR. The new
209 handle is stored in *NEWTHREAD. */
210extern int pthread_create (pthread_t *__restrict __newthread,
211 const pthread_attr_t *__restrict __attr,
212 void *(*__start_routine) (void *),
213 void *__restrict __arg) __THROWNL __nonnull ((1, 3));
214
215/* Terminate calling thread.
216
217 The registered cleanup handlers are called via exception handling
218 so we cannot mark this function with __THROW.*/
219extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
220
221/* Make calling thread wait for termination of the thread TH. The
222 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
223 is not NULL.
224
225 This function is a cancellation point and therefore not marked with
226 __THROW. */
227extern int pthread_join (pthread_t __th, void **__thread_return);
228
229#ifdef __USE_GNU
230/* Check whether thread TH has terminated. If yes return the status of
231 the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL. */
232extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
233
234/* Make calling thread wait for termination of the thread TH, but only
235 until TIMEOUT. The exit status of the thread is stored in
236 *THREAD_RETURN, if THREAD_RETURN is not NULL.
237
238 This function is a cancellation point and therefore not marked with
239 __THROW. */
240extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
241 const struct timespec *__abstime);
242#endif
243
244/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
245 The resources of TH will therefore be freed immediately when it
246 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
247 on it. */
248extern int pthread_detach (pthread_t __th) __THROW;
249
250
251/* Obtain the identifier of the current thread. */
252extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
253
254/* Compare two thread identifiers. */
255extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
256 __THROW __attribute__ ((__const__));
257
258
259/* Thread attribute handling. */
260
261/* Initialize thread attribute *ATTR with default attributes
262 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
263 no user-provided stack). */
264extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
265
266/* Destroy thread attribute *ATTR. */
267extern int pthread_attr_destroy (pthread_attr_t *__attr)
268 __THROW __nonnull ((1));
269
270/* Get detach state attribute. */
271extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
272 int *__detachstate)
273 __THROW __nonnull ((1, 2));
274
275/* Set detach state attribute. */
276extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
277 int __detachstate)
278 __THROW __nonnull ((1));
279
280
281/* Get the size of the guard area created for stack overflow protection. */
282extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
283 size_t *__guardsize)
284 __THROW __nonnull ((1, 2));
285
286/* Set the size of the guard area created for stack overflow protection. */
287extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
288 size_t __guardsize)
289 __THROW __nonnull ((1));
290
291
292/* Return in *PARAM the scheduling parameters of *ATTR. */
293extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
294 struct sched_param *__restrict __param)
295 __THROW __nonnull ((1, 2));
296
297/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
298extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
299 const struct sched_param *__restrict
300 __param) __THROW __nonnull ((1, 2));
301
302/* Return in *POLICY the scheduling policy of *ATTR. */
303extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
304 __attr, int *__restrict __policy)
305 __THROW __nonnull ((1, 2));
306
307/* Set scheduling policy in *ATTR according to POLICY. */
308extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
309 __THROW __nonnull ((1));
310
311/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
312extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
313 __attr, int *__restrict __inherit)
314 __THROW __nonnull ((1, 2));
315
316/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
317extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
318 int __inherit)
319 __THROW __nonnull ((1));
320
321
322/* Return in *SCOPE the scheduling contention scope of *ATTR. */
323extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
324 int *__restrict __scope)
325 __THROW __nonnull ((1, 2));
326
327/* Set scheduling contention scope in *ATTR according to SCOPE. */
328extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
329 __THROW __nonnull ((1));
330
331/* Return the previously set address for the stack. */
332extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
333 __attr, void **__restrict __stackaddr)
334 __THROW __nonnull ((1, 2)) __attribute_deprecated__;
335
336/* Set the starting address of the stack of the thread to be created.
337 Depending on whether the stack grows up or down the value must either
338 be higher or lower than all the address in the memory block. The
339 minimal size of the block must be PTHREAD_STACK_MIN. */
340extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
341 void *__stackaddr)
342 __THROW __nonnull ((1)) __attribute_deprecated__;
343
344/* Return the currently used minimal stack size. */
345extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
346 __attr, size_t *__restrict __stacksize)
347 __THROW __nonnull ((1, 2));
348
349/* Add information about the minimum stack size needed for the thread
350 to be started. This size must never be less than PTHREAD_STACK_MIN
351 and must also not exceed the system limits. */
352extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
353 size_t __stacksize)
354 __THROW __nonnull ((1));
355
356#ifdef __USE_XOPEN2K
357/* Return the previously set address for the stack. */
358extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
359 void **__restrict __stackaddr,
360 size_t *__restrict __stacksize)
361 __THROW __nonnull ((1, 2, 3));
362
363/* The following two interfaces are intended to replace the last two. They
364 require setting the address as well as the size since only setting the
365 address will make the implementation on some architectures impossible. */
366extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
367 size_t __stacksize) __THROW __nonnull ((1));
368#endif
369
370#ifdef __USE_GNU
371/* Thread created with attribute ATTR will be limited to run only on
372 the processors represented in CPUSET. */
373extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
374 size_t __cpusetsize,
375 const cpu_set_t *__cpuset)
376 __THROW __nonnull ((1, 3));
377
378/* Get bit set in CPUSET representing the processors threads created with
379 ATTR can run on. */
380extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
381 size_t __cpusetsize,
382 cpu_set_t *__cpuset)
383 __THROW __nonnull ((1, 3));
384
385/* Get the default attributes used by pthread_create in this process. */
386extern int pthread_getattr_default_np (pthread_attr_t *__attr)
387 __THROW __nonnull ((1));
388
389/* Set the default attributes to be used by pthread_create in this
390 process. */
391extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
392 __THROW __nonnull ((1));
393
394/* Initialize thread attribute *ATTR with attributes corresponding to the
395 already running thread TH. It shall be called on uninitialized ATTR
396 and destroyed with pthread_attr_destroy when no longer needed. */
397extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
398 __THROW __nonnull ((2));
399#endif
400
401
402/* Functions for scheduling control. */
403
404/* Set the scheduling parameters for TARGET_THREAD according to POLICY
405 and *PARAM. */
406extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
407 const struct sched_param *__param)
408 __THROW __nonnull ((3));
409
410/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
411extern int pthread_getschedparam (pthread_t __target_thread,
412 int *__restrict __policy,
413 struct sched_param *__restrict __param)
414 __THROW __nonnull ((2, 3));
415
416/* Set the scheduling priority for TARGET_THREAD. */
417extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
418 __THROW;
419
420
421#ifdef __USE_GNU
422/* Get thread name visible in the kernel and its interfaces. */
423extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
424 size_t __buflen)
425 __THROW __nonnull ((2));
426
427/* Set thread name visible in the kernel and its interfaces. */
428extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
429 __THROW __nonnull ((2));
430#endif
431
432
433#ifdef __USE_UNIX98
434/* Determine level of concurrency. */
435extern int pthread_getconcurrency (void) __THROW;
436
437/* Set new concurrency level to LEVEL. */
438extern int pthread_setconcurrency (int __level) __THROW;
439#endif
440
441#ifdef __USE_GNU
442/* Yield the processor to another thread or process.
443 This function is similar to the POSIX `sched_yield' function but
444 might be differently implemented in the case of a m-on-n thread
445 implementation. */
446extern int pthread_yield (void) __THROW;
447
448
449/* Limit specified thread TH to run only on the processors represented
450 in CPUSET. */
451extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
452 const cpu_set_t *__cpuset)
453 __THROW __nonnull ((3));
454
455/* Get bit set in CPUSET representing the processors TH can run on. */
456extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
457 cpu_set_t *__cpuset)
458 __THROW __nonnull ((3));
459#endif
460
461
462/* Functions for handling initialization. */
463
464/* Guarantee that the initialization function INIT_ROUTINE will be called
465 only once, even if pthread_once is executed several times with the
466 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
467 extern variable initialized to PTHREAD_ONCE_INIT.
468
469 The initialization functions might throw exception which is why
470 this function is not marked with __THROW. */
471extern int pthread_once (pthread_once_t *__once_control,
472 void (*__init_routine) (void)) __nonnull ((1, 2));
473
474
475/* Functions for handling cancellation.
476
477 Note that these functions are explicitly not marked to not throw an
478 exception in C++ code. If cancellation is implemented by unwinding
479 this is necessary to have the compiler generate the unwind information. */
480
481/* Set cancelability state of current thread to STATE, returning old
482 state in *OLDSTATE if OLDSTATE is not NULL. */
483extern int pthread_setcancelstate (int __state, int *__oldstate);
484
485/* Set cancellation state of current thread to TYPE, returning the old
486 type in *OLDTYPE if OLDTYPE is not NULL. */
487extern int pthread_setcanceltype (int __type, int *__oldtype);
488
489/* Cancel THREAD immediately or at the next possibility. */
490extern int pthread_cancel (pthread_t __th);
491
492/* Test for pending cancellation for the current thread and terminate
493 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
494 cancelled. */
495extern void pthread_testcancel (void);
496
497
498/* Cancellation handling with integration into exception handling. */
499
500typedef struct
501{
502 struct
503 {
504 __jmp_buf __cancel_jmp_buf;
505 int __mask_was_saved;
506 } __cancel_jmp_buf[1];
507 void *__pad[4];
508} __pthread_unwind_buf_t __attribute__ ((__aligned__));
509
510/* No special attributes by default. */
511#ifndef __cleanup_fct_attribute
512# define __cleanup_fct_attribute
513#endif
514
515
516/* Structure to hold the cleanup handler information. */
517struct __pthread_cleanup_frame
518{
519 void (*__cancel_routine) (void *);
520 void *__cancel_arg;
521 int __do_it;
522 int __cancel_type;
523};
524
525#if defined __GNUC__ && defined __EXCEPTIONS
526# ifdef __cplusplus
527/* Class to handle cancellation handler invocation. */
528class __pthread_cleanup_class
529{
530 void (*__cancel_routine) (void *);
531 void *__cancel_arg;
532 int __do_it;
533 int __cancel_type;
534
535 public:
536 __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
537 : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
538 ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
539 void __setdoit (int __newval) { __do_it = __newval; }
540 void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
541 &__cancel_type); }
542 void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
543};
544
545/* Install a cleanup handler: ROUTINE will be called with arguments ARG
546 when the thread is canceled or calls pthread_exit. ROUTINE will also
547 be called with arguments ARG when the matching pthread_cleanup_pop
548 is executed with non-zero EXECUTE argument.
549
550 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
551 be used in matching pairs at the same nesting level of braces. */
552# define pthread_cleanup_push(routine, arg) \
553 do { \
554 __pthread_cleanup_class __clframe (routine, arg)
555
556/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
557 If EXECUTE is non-zero, the handler function is called. */
558# define pthread_cleanup_pop(execute) \
559 __clframe.__setdoit (execute); \
560 } while (0)
561
562# ifdef __USE_GNU
563/* Install a cleanup handler as pthread_cleanup_push does, but also
564 saves the current cancellation type and sets it to deferred
565 cancellation. */
566# define pthread_cleanup_push_defer_np(routine, arg) \
567 do { \
568 __pthread_cleanup_class __clframe (routine, arg); \
569 __clframe.__defer ()
570
571/* Remove a cleanup handler as pthread_cleanup_pop does, but also
572 restores the cancellation type that was in effect when the matching
573 pthread_cleanup_push_defer was called. */
574# define pthread_cleanup_pop_restore_np(execute) \
575 __clframe.__restore (); \
576 __clframe.__setdoit (execute); \
577 } while (0)
578# endif
579# else
580/* Function called to call the cleanup handler. As an extern inline
581 function the compiler is free to decide inlining the change when
582 needed or fall back on the copy which must exist somewhere
583 else. */
584__extern_inline void
585__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
586{
587 if (__frame->__do_it)
588 __frame->__cancel_routine (__frame->__cancel_arg);
589}
590
591/* Install a cleanup handler: ROUTINE will be called with arguments ARG
592 when the thread is canceled or calls pthread_exit. ROUTINE will also
593 be called with arguments ARG when the matching pthread_cleanup_pop
594 is executed with non-zero EXECUTE argument.
595
596 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
597 be used in matching pairs at the same nesting level of braces. */
598# define pthread_cleanup_push(routine, arg) \
599 do { \
600 struct __pthread_cleanup_frame __clframe \
601 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
602 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
603 .__do_it = 1 };
604
605/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
606 If EXECUTE is non-zero, the handler function is called. */
607# define pthread_cleanup_pop(execute) \
608 __clframe.__do_it = (execute); \
609 } while (0)
610
611# ifdef __USE_GNU
612/* Install a cleanup handler as pthread_cleanup_push does, but also
613 saves the current cancellation type and sets it to deferred
614 cancellation. */
615# define pthread_cleanup_push_defer_np(routine, arg) \
616 do { \
617 struct __pthread_cleanup_frame __clframe \
618 __attribute__ ((__cleanup__ (__pthread_cleanup_routine))) \
619 = { .__cancel_routine = (routine), .__cancel_arg = (arg), \
620 .__do_it = 1 }; \
621 (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, \
622 &__clframe.__cancel_type)
623
624/* Remove a cleanup handler as pthread_cleanup_pop does, but also
625 restores the cancellation type that was in effect when the matching
626 pthread_cleanup_push_defer was called. */
627# define pthread_cleanup_pop_restore_np(execute) \
628 (void) pthread_setcanceltype (__clframe.__cancel_type, NULL); \
629 __clframe.__do_it = (execute); \
630 } while (0)
631# endif
632# endif
633#else
634/* Install a cleanup handler: ROUTINE will be called with arguments ARG
635 when the thread is canceled or calls pthread_exit. ROUTINE will also
636 be called with arguments ARG when the matching pthread_cleanup_pop
637 is executed with non-zero EXECUTE argument.
638
639 pthread_cleanup_push and pthread_cleanup_pop are macros and must always
640 be used in matching pairs at the same nesting level of braces. */
641# define pthread_cleanup_push(routine, arg) \
642 do { \
643 __pthread_unwind_buf_t __cancel_buf; \
644 void (*__cancel_routine) (void *) = (routine); \
645 void *__cancel_arg = (arg); \
646 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
647 __cancel_buf.__cancel_jmp_buf, 0); \
648 if (__glibc_unlikely (__not_first_call)) \
649 { \
650 __cancel_routine (__cancel_arg); \
651 __pthread_unwind_next (&__cancel_buf); \
652 /* NOTREACHED */ \
653 } \
654 \
655 __pthread_register_cancel (&__cancel_buf); \
656 do {
657extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
658 __cleanup_fct_attribute;
659
660/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
661 If EXECUTE is non-zero, the handler function is called. */
662# define pthread_cleanup_pop(execute) \
663 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
664 } while (0); \
665 __pthread_unregister_cancel (&__cancel_buf); \
666 if (execute) \
667 __cancel_routine (__cancel_arg); \
668 } while (0)
669extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
670 __cleanup_fct_attribute;
671
672# ifdef __USE_GNU
673/* Install a cleanup handler as pthread_cleanup_push does, but also
674 saves the current cancellation type and sets it to deferred
675 cancellation. */
676# define pthread_cleanup_push_defer_np(routine, arg) \
677 do { \
678 __pthread_unwind_buf_t __cancel_buf; \
679 void (*__cancel_routine) (void *) = (routine); \
680 void *__cancel_arg = (arg); \
681 int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \
682 __cancel_buf.__cancel_jmp_buf, 0); \
683 if (__glibc_unlikely (__not_first_call)) \
684 { \
685 __cancel_routine (__cancel_arg); \
686 __pthread_unwind_next (&__cancel_buf); \
687 /* NOTREACHED */ \
688 } \
689 \
690 __pthread_register_cancel_defer (&__cancel_buf); \
691 do {
692extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
693 __cleanup_fct_attribute;
694
695/* Remove a cleanup handler as pthread_cleanup_pop does, but also
696 restores the cancellation type that was in effect when the matching
697 pthread_cleanup_push_defer was called. */
698# define pthread_cleanup_pop_restore_np(execute) \
699 do { } while (0);/* Empty to allow label before pthread_cleanup_pop. */\
700 } while (0); \
701 __pthread_unregister_cancel_restore (&__cancel_buf); \
702 if (execute) \
703 __cancel_routine (__cancel_arg); \
704 } while (0)
705extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
706 __cleanup_fct_attribute;
707# endif
708
709/* Internal interface to initiate cleanup. */
710extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
711 __cleanup_fct_attribute __attribute__ ((__noreturn__))
712# ifndef SHARED
713 __attribute__ ((__weak__))
714# endif
715 ;
716#endif
717
718/* Function used in the macros. */
719struct __jmp_buf_tag;
720extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
721
722
723/* Mutex handling. */
724
725/* Initialize a mutex. */
726extern int pthread_mutex_init (pthread_mutex_t *__mutex,
727 const pthread_mutexattr_t *__mutexattr)
728 __THROW __nonnull ((1));
729
730/* Destroy a mutex. */
731extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
732 __THROW __nonnull ((1));
733
734/* Try locking a mutex. */
735extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
736 __THROWNL __nonnull ((1));
737
738/* Lock a mutex. */
739extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
740 __THROWNL __nonnull ((1));
741
742#ifdef __USE_XOPEN2K
743/* Wait until lock becomes available, or specified time passes. */
744extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
745 const struct timespec *__restrict
746 __abstime) __THROWNL __nonnull ((1, 2));
747#endif
748
749#ifdef __USE_GNU
750extern int pthread_mutex_clocklock (pthread_mutex_t *__restrict __mutex,
751 clockid_t __clockid,
752 const struct timespec *__restrict
753 __abstime) __THROWNL __nonnull ((1, 3));
754#endif
755
756/* Unlock a mutex. */
757extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
758 __THROWNL __nonnull ((1));
759
760
761/* Get the priority ceiling of MUTEX. */
762extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
763 __restrict __mutex,
764 int *__restrict __prioceiling)
765 __THROW __nonnull ((1, 2));
766
767/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
768 priority ceiling value in *OLD_CEILING. */
769extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
770 int __prioceiling,
771 int *__restrict __old_ceiling)
772 __THROW __nonnull ((1, 3));
773
774
775#ifdef __USE_XOPEN2K8
776/* Declare the state protected by MUTEX as consistent. */
777extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
778 __THROW __nonnull ((1));
779# ifdef __USE_GNU
780extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
781 __THROW __nonnull ((1));
782# endif
783#endif
784
785
786/* Functions for handling mutex attributes. */
787
788/* Initialize mutex attribute object ATTR with default attributes
789 (kind is PTHREAD_MUTEX_TIMED_NP). */
790extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
791 __THROW __nonnull ((1));
792
793/* Destroy mutex attribute object ATTR. */
794extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
795 __THROW __nonnull ((1));
796
797/* Get the process-shared flag of the mutex attribute ATTR. */
798extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
799 __restrict __attr,
800 int *__restrict __pshared)
801 __THROW __nonnull ((1, 2));
802
803/* Set the process-shared flag of the mutex attribute ATTR. */
804extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
805 int __pshared)
806 __THROW __nonnull ((1));
807
808#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
809/* Return in *KIND the mutex kind attribute in *ATTR. */
810extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
811 __attr, int *__restrict __kind)
812 __THROW __nonnull ((1, 2));
813
814/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
815 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
816 PTHREAD_MUTEX_DEFAULT). */
817extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
818 __THROW __nonnull ((1));
819#endif
820
821/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
822extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
823 __restrict __attr,
824 int *__restrict __protocol)
825 __THROW __nonnull ((1, 2));
826
827/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
828 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
829extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
830 int __protocol)
831 __THROW __nonnull ((1));
832
833/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
834extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
835 __restrict __attr,
836 int *__restrict __prioceiling)
837 __THROW __nonnull ((1, 2));
838
839/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
840extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
841 int __prioceiling)
842 __THROW __nonnull ((1));
843
844#ifdef __USE_XOPEN2K
845/* Get the robustness flag of the mutex attribute ATTR. */
846extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
847 int *__robustness)
848 __THROW __nonnull ((1, 2));
849# ifdef __USE_GNU
850extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
851 int *__robustness)
852 __THROW __nonnull ((1, 2));
853# endif
854
855/* Set the robustness flag of the mutex attribute ATTR. */
856extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
857 int __robustness)
858 __THROW __nonnull ((1));
859# ifdef __USE_GNU
860extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
861 int __robustness)
862 __THROW __nonnull ((1));
863# endif
864#endif
865
866
867#if defined __USE_UNIX98 || defined __USE_XOPEN2K
868/* Functions for handling read-write locks. */
869
870/* Initialize read-write lock RWLOCK using attributes ATTR, or use
871 the default values if later is NULL. */
872extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
873 const pthread_rwlockattr_t *__restrict
874 __attr) __THROW __nonnull ((1));
875
876/* Destroy read-write lock RWLOCK. */
877extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
878 __THROW __nonnull ((1));
879
880/* Acquire read lock for RWLOCK. */
881extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
882 __THROWNL __nonnull ((1));
883
884/* Try to acquire read lock for RWLOCK. */
885extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
886 __THROWNL __nonnull ((1));
887
888# ifdef __USE_XOPEN2K
889/* Try to acquire read lock for RWLOCK or return after specfied time. */
890extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
891 const struct timespec *__restrict
892 __abstime) __THROWNL __nonnull ((1, 2));
893# endif
894
895# ifdef __USE_GNU
896extern int pthread_rwlock_clockrdlock (pthread_rwlock_t *__restrict __rwlock,
897 clockid_t __clockid,
898 const struct timespec *__restrict
899 __abstime) __THROWNL __nonnull ((1, 3));
900# endif
901
902/* Acquire write lock for RWLOCK. */
903extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
904 __THROWNL __nonnull ((1));
905
906/* Try to acquire write lock for RWLOCK. */
907extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
908 __THROWNL __nonnull ((1));
909
910# ifdef __USE_XOPEN2K
911/* Try to acquire write lock for RWLOCK or return after specfied time. */
912extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
913 const struct timespec *__restrict
914 __abstime) __THROWNL __nonnull ((1, 2));
915# endif
916
917# ifdef __USE_GNU
918extern int pthread_rwlock_clockwrlock (pthread_rwlock_t *__restrict __rwlock,
919 clockid_t __clockid,
920 const struct timespec *__restrict
921 __abstime) __THROWNL __nonnull ((1, 3));
922# endif
923
924/* Unlock RWLOCK. */
925extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
926 __THROWNL __nonnull ((1));
927
928
929/* Functions for handling read-write lock attributes. */
930
931/* Initialize attribute object ATTR with default values. */
932extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
933 __THROW __nonnull ((1));
934
935/* Destroy attribute object ATTR. */
936extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
937 __THROW __nonnull ((1));
938
939/* Return current setting of process-shared attribute of ATTR in PSHARED. */
940extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
941 __restrict __attr,
942 int *__restrict __pshared)
943 __THROW __nonnull ((1, 2));
944
945/* Set process-shared attribute of ATTR to PSHARED. */
946extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
947 int __pshared)
948 __THROW __nonnull ((1));
949
950/* Return current setting of reader/writer preference. */
951extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
952 __restrict __attr,
953 int *__restrict __pref)
954 __THROW __nonnull ((1, 2));
955
956/* Set reader/write preference. */
957extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
958 int __pref) __THROW __nonnull ((1));
959#endif
960
961
962/* Functions for handling conditional variables. */
963
964/* Initialize condition variable COND using attributes ATTR, or use
965 the default values if later is NULL. */
966extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
967 const pthread_condattr_t *__restrict __cond_attr)
968 __THROW __nonnull ((1));
969
970/* Destroy condition variable COND. */
971extern int pthread_cond_destroy (pthread_cond_t *__cond)
972 __THROW __nonnull ((1));
973
974/* Wake up one thread waiting for condition variable COND. */
975extern int pthread_cond_signal (pthread_cond_t *__cond)
976 __THROWNL __nonnull ((1));
977
978/* Wake up all threads waiting for condition variables COND. */
979extern int pthread_cond_broadcast (pthread_cond_t *__cond)
980 __THROWNL __nonnull ((1));
981
982/* Wait for condition variable COND to be signaled or broadcast.
983 MUTEX is assumed to be locked before.
984
985 This function is a cancellation point and therefore not marked with
986 __THROW. */
987extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
988 pthread_mutex_t *__restrict __mutex)
989 __nonnull ((1, 2));
990
991/* Wait for condition variable COND to be signaled or broadcast until
992 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
993 absolute time specification; zero is the beginning of the epoch
994 (00:00:00 GMT, January 1, 1970).
995
996 This function is a cancellation point and therefore not marked with
997 __THROW. */
998extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
999 pthread_mutex_t *__restrict __mutex,
1000 const struct timespec *__restrict __abstime)
1001 __nonnull ((1, 2, 3));
1002
1003# ifdef __USE_GNU
1004/* Wait for condition variable COND to be signaled or broadcast until
1005 ABSTIME measured by the specified clock. MUTEX is assumed to be
1006 locked before. CLOCK is the clock to use. ABSTIME is an absolute
1007 time specification against CLOCK's epoch.
1008
1009 This function is a cancellation point and therefore not marked with
1010 __THROW. */
1011extern int pthread_cond_clockwait (pthread_cond_t *__restrict __cond,
1012 pthread_mutex_t *__restrict __mutex,
1013 __clockid_t __clock_id,
1014 const struct timespec *__restrict __abstime)
1015 __nonnull ((1, 2, 4));
1016# endif
1017
1018/* Functions for handling condition variable attributes. */
1019
1020/* Initialize condition variable attribute ATTR. */
1021extern int pthread_condattr_init (pthread_condattr_t *__attr)
1022 __THROW __nonnull ((1));
1023
1024/* Destroy condition variable attribute ATTR. */
1025extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
1026 __THROW __nonnull ((1));
1027
1028/* Get the process-shared flag of the condition variable attribute ATTR. */
1029extern int pthread_condattr_getpshared (const pthread_condattr_t *
1030 __restrict __attr,
1031 int *__restrict __pshared)
1032 __THROW __nonnull ((1, 2));
1033
1034/* Set the process-shared flag of the condition variable attribute ATTR. */
1035extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
1036 int __pshared) __THROW __nonnull ((1));
1037
1038#ifdef __USE_XOPEN2K
1039/* Get the clock selected for the condition variable attribute ATTR. */
1040extern int pthread_condattr_getclock (const pthread_condattr_t *
1041 __restrict __attr,
1042 __clockid_t *__restrict __clock_id)
1043 __THROW __nonnull ((1, 2));
1044
1045/* Set the clock selected for the condition variable attribute ATTR. */
1046extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
1047 __clockid_t __clock_id)
1048 __THROW __nonnull ((1));
1049#endif
1050
1051
1052#ifdef __USE_XOPEN2K
1053/* Functions to handle spinlocks. */
1054
1055/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
1056 be shared between different processes. */
1057extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
1058 __THROW __nonnull ((1));
1059
1060/* Destroy the spinlock LOCK. */
1061extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
1062 __THROW __nonnull ((1));
1063
1064/* Wait until spinlock LOCK is retrieved. */
1065extern int pthread_spin_lock (pthread_spinlock_t *__lock)
1066 __THROWNL __nonnull ((1));
1067
1068/* Try to lock spinlock LOCK. */
1069extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
1070 __THROWNL __nonnull ((1));
1071
1072/* Release spinlock LOCK. */
1073extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
1074 __THROWNL __nonnull ((1));
1075
1076
1077/* Functions to handle barriers. */
1078
1079/* Initialize BARRIER with the attributes in ATTR. The barrier is
1080 opened when COUNT waiters arrived. */
1081extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
1082 const pthread_barrierattr_t *__restrict
1083 __attr, unsigned int __count)
1084 __THROW __nonnull ((1));
1085
1086/* Destroy a previously dynamically initialized barrier BARRIER. */
1087extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
1088 __THROW __nonnull ((1));
1089
1090/* Wait on barrier BARRIER. */
1091extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
1092 __THROWNL __nonnull ((1));
1093
1094
1095/* Initialize barrier attribute ATTR. */
1096extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
1097 __THROW __nonnull ((1));
1098
1099/* Destroy previously dynamically initialized barrier attribute ATTR. */
1100extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
1101 __THROW __nonnull ((1));
1102
1103/* Get the process-shared flag of the barrier attribute ATTR. */
1104extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
1105 __restrict __attr,
1106 int *__restrict __pshared)
1107 __THROW __nonnull ((1, 2));
1108
1109/* Set the process-shared flag of the barrier attribute ATTR. */
1110extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
1111 int __pshared)
1112 __THROW __nonnull ((1));
1113#endif
1114
1115
1116/* Functions for handling thread-specific data. */
1117
1118/* Create a key value identifying a location in the thread-specific
1119 data area. Each thread maintains a distinct thread-specific data
1120 area. DESTR_FUNCTION, if non-NULL, is called with the value
1121 associated to that key when the key is destroyed.
1122 DESTR_FUNCTION is not called if the value associated is NULL when
1123 the key is destroyed. */
1124extern int pthread_key_create (pthread_key_t *__key,
1125 void (*__destr_function) (void *))
1126 __THROW __nonnull ((1));
1127
1128/* Destroy KEY. */
1129extern int pthread_key_delete (pthread_key_t __key) __THROW;
1130
1131/* Return current value of the thread-specific data slot identified by KEY. */
1132extern void *pthread_getspecific (pthread_key_t __key) __THROW;
1133
1134/* Store POINTER in the thread-specific data slot identified by KEY. */
1135extern int pthread_setspecific (pthread_key_t __key,
1136 const void *__pointer) __THROW ;
1137
1138
1139#ifdef __USE_XOPEN2K
1140/* Get ID of CPU-time clock for thread THREAD_ID. */
1141extern int pthread_getcpuclockid (pthread_t __thread_id,
1142 __clockid_t *__clock_id)
1143 __THROW __nonnull ((2));
1144#endif
1145
1146
1147/* Install handlers to be called when a new process is created with FORK.
1148 The PREPARE handler is called in the parent process just before performing
1149 FORK. The PARENT handler is called in the parent process just after FORK.
1150 The CHILD handler is called in the child process. Each of the three
1151 handlers can be NULL, meaning that no handler needs to be called at that
1152 point.
1153 PTHREAD_ATFORK can be called several times, in which case the PREPARE
1154 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
1155 first called before FORK), and the PARENT and CHILD handlers are called
1156 in FIFO (first added, first called). */
1157
1158extern int pthread_atfork (void (*__prepare) (void),
1159 void (*__parent) (void),
1160 void (*__child) (void)) __THROW;
1161
1162
1163#ifdef __USE_EXTERN_INLINES
1164/* Optimizations. */
1165__extern_inline int
1166__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
1167{
1168 return __thread1 == __thread2;
1169}
1170#endif
1171
1172__END_DECLS
1173
1174#endif /* pthread.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/sysdep.h+5-33
......@@ -1,5 +1,5 @@
11/* Assembler macros for PA-RISC.
2 Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 Copyright (C) 1999-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
55 Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
......@@ -28,6 +28,8 @@
2828/* Defines RTLD_PRIVATE_ERRNO. */
2929#include <dl-sysdep.h>
3030
31#include <tls.h>
32
3133/* In order to get __set_errno() definition in INLINE_SYSCALL. */
3234#ifndef __ASSEMBLER__
3335#include <errno.h>
......@@ -360,39 +362,9 @@ L(pre_end): ASM_LINE_SEP \
360362#define CALL_CLOB_REGS "%r1", "%r2", CLOB_TREG \
361363 "%r20", "%r29", "%r31"
362364
363#undef INLINE_SYSCALL
364#define INLINE_SYSCALL(name, nr, args...) \
365({ \
366 long __sys_res = INTERNAL_SYSCALL (name, , nr, args); \
367 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_res, ))) \
368 { \
369 __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_res, )); \
370 __sys_res = -1; \
371 } \
372 __sys_res; \
373})
374
375/* INTERNAL_SYSCALL_DECL - Allows us to setup some function static
376 value to use within the context of the syscall
377 INTERNAL_SYSCALL_ERROR_P - Returns 0 if it wasn't an error, 1 otherwise
378 You are allowed to use the syscall result (val) and the DECL error
379 variable to determine what went wrong.
380 INTERLAL_SYSCALL_ERRNO - Munges the val/err pair into the error number.
381 In our case we just flip the sign. */
382
383#undef INTERNAL_SYSCALL_DECL
384#define INTERNAL_SYSCALL_DECL(err)
385
386#undef INTERNAL_SYSCALL_ERROR_P
387#define INTERNAL_SYSCALL_ERROR_P(val, err) \
388 ((val < 0) && (val > -4095))
389
390#undef INTERNAL_SYSCALL_ERRNO
391#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
392
393365/* Similar to INLINE_SYSCALL but we don't set errno */
394366#undef INTERNAL_SYSCALL
395#define INTERNAL_SYSCALL(name, err, nr, args...) \
367#define INTERNAL_SYSCALL(name, nr, args...) \
396368({ \
397369 long __sys_res; \
398370 { \
......@@ -418,7 +390,7 @@ L(pre_end): ASM_LINE_SEP \
418390
419391/* The _NCS variant allows non-constant syscall numbers. */
420392#undef INTERNAL_SYSCALL_NCS
421#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
393#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
422394({ \
423395 long __sys_res; \
424396 { \
lib/libc/glibc/sysdeps/unix/sysv/linux/i386/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. i386 version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/i386/kernel-features.h+3-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. i386 version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -23,8 +23,6 @@
2323# define __ASSUME_SOCKETPAIR_SYSCALL 1
2424# define __ASSUME_BIND_SYSCALL 1
2525# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
2826# define __ASSUME_GETSOCKNAME_SYSCALL 1
2927# define __ASSUME_GETPEERNAME_SYSCALL 1
3028# define __ASSUME_SHUTDOWN_SYSCALL 1
......@@ -41,6 +39,8 @@
4139# undef __ASSUME_CONNECT_SYSCALL
4240# undef __ASSUME_RECVFROM_SYSCALL
4341# undef __ASSUME_SENDTO_SYSCALL
42# undef __ASSUME_GETSOCKOPT_SYSCALL
43# undef __ASSUME_SETSOCKOPT_SYSCALL
4444#endif
4545
4646/* i686 only supports ipc syscall before 5.1. */
lib/libc/glibc/sysdeps/unix/sysv/linux/i386/sysdep.h+85-108
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995.
44
......@@ -48,7 +48,7 @@
4848 to compile glibc. Disable GCC 5 optimization when compiling for
4949 profiling or when -fno-omit-frame-pointer is used since asm ("ebp")
5050 can't be used to put the 6th argument in %ebp for syscall. */
51#if __GNUC_PREREQ (5,0) && !defined PROF && CAN_USE_REGISTER_ASM_EBP
51#if !defined PROF && CAN_USE_REGISTER_ASM_EBP
5252# define OPTIMIZE_FOR_GCC_5
5353#endif
5454
......@@ -67,6 +67,7 @@
6767
6868/* We don't want the label for the error handle to be global when we define
6969 it here. */
70#undef SYSCALL_ERROR_LABEL
7071#define SYSCALL_ERROR_LABEL __syscall_error
7172
7273#undef PSEUDO
......@@ -280,35 +281,6 @@ struct libc_do_syscall_args
280281};
281282#endif
282283
283/* Define a macro which expands inline into the wrapper code for a system
284 call. */
285#undef INLINE_SYSCALL
286#if IS_IN (libc)
287# define INLINE_SYSCALL(name, nr, args...) \
288 ({ \
289 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
290 __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, )) \
291 ? __syscall_error (-INTERNAL_SYSCALL_ERRNO (resultvar, )) \
292 : (int) resultvar; })
293#else
294# define INLINE_SYSCALL(name, nr, args...) \
295 ({ \
296 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
297 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
298 { \
299 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
300 resultvar = 0xffffffff; \
301 } \
302 (int) resultvar; })
303#endif
304
305/* Set error number and return -1. Return the internal function,
306 __syscall_error, which sets errno from the negative error number
307 and returns -1, to avoid PIC. */
308#undef INLINE_SYSCALL_ERROR_RETURN_VALUE
309#define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
310 __syscall_error (-(resultvar))
311
312284# define VDSO_NAME "LINUX_2.6"
313285# define VDSO_HASH 61765110
314286
......@@ -319,6 +291,11 @@ struct libc_do_syscall_args
319291# define HAVE_TIME_VSYSCALL "__vdso_time"
320292# define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres"
321293
294# define HAVE_CLONE3_WRAPPER 1
295
296# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
297# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
298
322299/* Define a macro which expands inline into the wrapper code for a system
323300 call. This use is for internal calls that do not need to handle errors
324301 normally. It will never touch errno. This returns just what the kernel
......@@ -327,25 +304,41 @@ struct libc_do_syscall_args
327304 The _NCS variant allows non-constant syscall numbers but it is not
328305 possible to use more than four parameters. */
329306#undef INTERNAL_SYSCALL
330#define INTERNAL_SYSCALL_MAIN_0(name, err, args...) \
331 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 0, args)
332#define INTERNAL_SYSCALL_MAIN_1(name, err, args...) \
333 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 1, args)
334#define INTERNAL_SYSCALL_MAIN_2(name, err, args...) \
335 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 2, args)
336#define INTERNAL_SYSCALL_MAIN_3(name, err, args...) \
337 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 3, args)
338#define INTERNAL_SYSCALL_MAIN_4(name, err, args...) \
339 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 4, args)
340#define INTERNAL_SYSCALL_MAIN_5(name, err, args...) \
341 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
307#define INTERNAL_SYSCALL_MAIN_0(name, args...) \
308 INTERNAL_SYSCALL_MAIN_INLINE(name, 0, args)
309#define INTERNAL_SYSCALL_MAIN_1(name, args...) \
310 INTERNAL_SYSCALL_MAIN_INLINE(name, 1, args)
311#define INTERNAL_SYSCALL_MAIN_2(name, args...) \
312 INTERNAL_SYSCALL_MAIN_INLINE(name, 2, args)
313#define INTERNAL_SYSCALL_MAIN_3(name, args...) \
314 INTERNAL_SYSCALL_MAIN_INLINE(name, 3, args)
315#define INTERNAL_SYSCALL_MAIN_4(name, args...) \
316 INTERNAL_SYSCALL_MAIN_INLINE(name, 4, args)
317#define INTERNAL_SYSCALL_MAIN_5(name, args...) \
318 INTERNAL_SYSCALL_MAIN_INLINE(name, 5, args)
319
320#define INTERNAL_SYSCALL_MAIN_NCS_0(name, args...) \
321 INTERNAL_SYSCALL_MAIN_NCS(name, 0, args)
322#define INTERNAL_SYSCALL_MAIN_NCS_1(name, args...) \
323 INTERNAL_SYSCALL_MAIN_NCS(name, 1, args)
324#define INTERNAL_SYSCALL_MAIN_NCS_2(name, args...) \
325 INTERNAL_SYSCALL_MAIN_NCS(name, 2, args)
326#define INTERNAL_SYSCALL_MAIN_NCS_3(name, args...) \
327 INTERNAL_SYSCALL_MAIN_NCS(name, 3, args)
328#define INTERNAL_SYSCALL_MAIN_NCS_4(name, args...) \
329 INTERNAL_SYSCALL_MAIN_NCS(name, 4, args)
330#define INTERNAL_SYSCALL_MAIN_NCS_5(name, args...) \
331 INTERNAL_SYSCALL_MAIN_NCS(name, 5, args)
332
342333/* Each object using 6-argument inline syscalls must include a
343334 definition of __libc_do_syscall. */
344335#ifdef OPTIMIZE_FOR_GCC_5
345# define INTERNAL_SYSCALL_MAIN_6(name, err, args...) \
346 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 6, args)
336# define INTERNAL_SYSCALL_MAIN_6(name, args...) \
337 INTERNAL_SYSCALL_MAIN_INLINE(name, 6, args)
338# define INTERNAL_SYSCALL_MAIN_NCS_6(name, args...) \
339 INTERNAL_SYSCALL_MAIN_NCS(name, 6, args)
347340#else /* GCC 5 */
348# define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3, \
341# define INTERNAL_SYSCALL_MAIN_6(name, arg1, arg2, arg3, \
349342 arg4, arg5, arg6) \
350343 struct libc_do_syscall_args _xv = \
351344 { \
......@@ -359,52 +352,67 @@ struct libc_do_syscall_args
359352 : "=a" (resultvar) \
360353 : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
361354 : "memory", "cc")
355# define INTERNAL_SYSCALL_MAIN_NCS_6(name, arg1, arg2, arg3, \
356 arg4, arg5, arg6) \
357 struct libc_do_syscall_args _xv = \
358 { \
359 (int) (arg1), \
360 (int) (arg5), \
361 (int) (arg6) \
362 }; \
363 asm volatile ( \
364 "movl %1, %%eax\n\t" \
365 "call __libc_do_syscall" \
366 : "=a" (resultvar) \
367 : "a" (name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
368 : "memory", "cc")
362369#endif /* GCC 5 */
363#define INTERNAL_SYSCALL(name, err, nr, args...) \
370
371#define INTERNAL_SYSCALL(name, nr, args...) \
364372 ({ \
365373 register unsigned int resultvar; \
366 INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \
374 INTERNAL_SYSCALL_MAIN_##nr (name, args); \
367375 (int) resultvar; })
376#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
377 ({ \
378 register unsigned int resultvar; \
379 INTERNAL_SYSCALL_MAIN_NCS_##nr (name, args); \
380 (int) resultvar; })
381
368382#if I386_USE_SYSENTER
369383# ifdef OPTIMIZE_FOR_GCC_5
370384# ifdef PIC
371# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
385# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
372386 LOADREGS_##nr(args) \
373387 asm volatile ( \
374388 "call *%%gs:%P2" \
375389 : "=a" (resultvar) \
376390 : "a" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
377391 ASMARGS_##nr(args) : "memory", "cc")
378# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
379 ({ \
380 register unsigned int resultvar; \
392# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
381393 LOADREGS_##nr(args) \
382394 asm volatile ( \
383395 "call *%%gs:%P2" \
384396 : "=a" (resultvar) \
385397 : "a" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
386 ASMARGS_##nr(args) : "memory", "cc"); \
387 (int) resultvar; })
398 ASMARGS_##nr(args) : "memory", "cc")
388399# else
389# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
400# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
390401 LOADREGS_##nr(args) \
391402 asm volatile ( \
392403 "call *_dl_sysinfo" \
393404 : "=a" (resultvar) \
394405 : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
395# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
396 ({ \
397 register unsigned int resultvar; \
406# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
398407 LOADREGS_##nr(args) \
399408 asm volatile ( \
400409 "call *_dl_sysinfo" \
401410 : "=a" (resultvar) \
402 : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
403 (int) resultvar; })
411 : "a" (name) ASMARGS_##nr(args) : "memory", "cc")
404412# endif
405413# else /* GCC 5 */
406414# ifdef PIC
407# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
415# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
408416 EXTRAVAR_##nr \
409417 asm volatile ( \
410418 LOADARGS_##nr \
......@@ -414,9 +422,7 @@ struct libc_do_syscall_args
414422 : "=a" (resultvar) \
415423 : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
416424 ASMFMT_##nr(args) : "memory", "cc")
417# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
418 ({ \
419 register unsigned int resultvar; \
425# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
420426 EXTRAVAR_##nr \
421427 asm volatile ( \
422428 LOADARGS_##nr \
......@@ -424,10 +430,9 @@ struct libc_do_syscall_args
424430 RESTOREARGS_##nr \
425431 : "=a" (resultvar) \
426432 : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
427 ASMFMT_##nr(args) : "memory", "cc"); \
428 (int) resultvar; })
433 ASMFMT_##nr(args) : "memory", "cc")
429434# else
430# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
435# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
431436 EXTRAVAR_##nr \
432437 asm volatile ( \
433438 LOADARGS_##nr \
......@@ -436,38 +441,32 @@ struct libc_do_syscall_args
436441 RESTOREARGS_##nr \
437442 : "=a" (resultvar) \
438443 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
439# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
440 ({ \
441 register unsigned int resultvar; \
444# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
442445 EXTRAVAR_##nr \
443446 asm volatile ( \
444447 LOADARGS_##nr \
445448 "call *_dl_sysinfo\n\t" \
446449 RESTOREARGS_##nr \
447450 : "=a" (resultvar) \
448 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
449 (int) resultvar; })
451 : "0" (name) ASMFMT_##nr(args) : "memory", "cc")
450452# endif
451453# endif /* GCC 5 */
452454#else
453455# ifdef OPTIMIZE_FOR_GCC_5
454# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
456# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
455457 LOADREGS_##nr(args) \
456458 asm volatile ( \
457459 "int $0x80" \
458460 : "=a" (resultvar) \
459461 : "a" (__NR_##name) ASMARGS_##nr(args) : "memory", "cc")
460# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
461 ({ \
462 register unsigned int resultvar; \
462# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
463463 LOADREGS_##nr(args) \
464464 asm volatile ( \
465465 "int $0x80" \
466466 : "=a" (resultvar) \
467 : "a" (name) ASMARGS_##nr(args) : "memory", "cc"); \
468 (int) resultvar; })
467 : "a" (name) ASMARGS_##nr(args) : "memory", "cc")
469468# else /* GCC 5 */
470# define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
469# define INTERNAL_SYSCALL_MAIN_INLINE(name, nr, args...) \
471470 EXTRAVAR_##nr \
472471 asm volatile ( \
473472 LOADARGS_##nr \
......@@ -476,30 +475,17 @@ struct libc_do_syscall_args
476475 RESTOREARGS_##nr \
477476 : "=a" (resultvar) \
478477 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
479# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
480 ({ \
481 register unsigned int resultvar; \
478# define INTERNAL_SYSCALL_MAIN_NCS(name, nr, args...) \
482479 EXTRAVAR_##nr \
483480 asm volatile ( \
484481 LOADARGS_##nr \
485482 "int $0x80\n\t" \
486483 RESTOREARGS_##nr \
487484 : "=a" (resultvar) \
488 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
489 (int) resultvar; })
485 : "0" (name) ASMFMT_##nr(args) : "memory", "cc")
490486# endif /* GCC 5 */
491487#endif
492488
493#undef INTERNAL_SYSCALL_DECL
494#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
495
496#undef INTERNAL_SYSCALL_ERROR_P
497#define INTERNAL_SYSCALL_ERROR_P(val, err) \
498 ((unsigned int) (val) >= 0xfffff001u)
499
500#undef INTERNAL_SYSCALL_ERRNO
501#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
502
503489#define LOADARGS_0
504490#ifdef __PIC__
505491# if I386_USE_SYSENTER && defined PIC
......@@ -618,20 +604,6 @@ struct libc_do_syscall_args
618604# define EXTRAVAR_5
619605#endif
620606
621/* Consistency check for position-independent code. */
622#if defined __PIC__ && !defined OPTIMIZE_FOR_GCC_5
623# define check_consistency() \
624 ({ int __res; \
625 __asm__ __volatile__ \
626 (LOAD_PIC_REG_STR (cx) ";" \
627 "subl %%ebx, %%ecx;" \
628 "je 1f;" \
629 "ud2;" \
630 "1:\n" \
631 : "=c" (__res)); \
632 __res; })
633#endif
634
635607#endif /* __ASSEMBLER__ */
636608
637609
......@@ -662,4 +634,9 @@ struct libc_do_syscall_args
662634# endif
663635#endif
664636
637/* Each shadow stack slot takes 4 bytes. Assuming that each stack
638 frame takes 128 bytes, this is used to compute shadow stack size
639 from stack size. */
640#define STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT 5
641
665642#endif /* linux/i386/sysdep.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/bits/stat.h deleted-149
......@@ -1,149 +0,0 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_KERNEL 0
27#define _STAT_VER_LINUX 1
28#define _STAT_VER _STAT_VER_LINUX
29
30/* Versions of the `xmknod' interface. */
31#define _MKNOD_VER_LINUX 0
32
33struct stat
34 {
35 __dev_t st_dev; /* Device. */
36 __ino_t st_ino; /* File serial number. */
37 __nlink_t st_nlink; /* Link count. */
38 __mode_t st_mode; /* File mode. */
39 __uid_t st_uid; /* User ID of the file's owner. */
40 __gid_t st_gid; /* Group ID of the file's group.*/
41 int __glibc_reserved0;
42 __dev_t st_rdev; /* Device number, if device. */
43 __off_t st_size; /* Size of file, in bytes. */
44#ifdef __USE_XOPEN2K8
45 /* Nanosecond resolution timestamps are stored in a format
46 equivalent to 'struct timespec'. This is the type used
47 whenever possible but the Unix namespace rules do not allow the
48 identifier 'timespec' to appear in the <sys/stat.h> header.
49 Therefore we have to handle the use of this header in strictly
50 standard-compliant sources special. */
51 struct timespec st_atim; /* Time of last access. */
52 struct timespec st_mtim; /* Time of last modification. */
53 struct timespec st_ctim; /* Time of last status change. */
54# define st_atime st_atim.tv_sec /* Backward compatibility. */
55# define st_mtime st_mtim.tv_sec
56# define st_ctime st_ctim.tv_sec
57#else
58 __time_t st_atime; /* Time of last access. */
59 unsigned long int st_atimensec; /* Nscecs of last access. */
60 __time_t st_mtime; /* Time of last modification. */
61 unsigned long int st_mtimensec; /* Nsecs of last modification. */
62 __time_t st_ctime; /* Time of last status change. */
63 unsigned long int st_ctimensec; /* Nsecs of last status change. */
64#endif
65 __blksize_t st_blksize; /* Optimal block size for I/O. */
66 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
67 long int __glibc_reserved[3];
68 };
69
70#ifdef __USE_LARGEFILE64
71/* Note stat64 is the same shape as stat. */
72struct stat64
73 {
74 __dev_t st_dev; /* Device. */
75 __ino64_t st_ino; /* File serial number. */
76 __nlink_t st_nlink; /* Link count. */
77 __mode_t st_mode; /* File mode. */
78 __uid_t st_uid; /* User ID of the file's owner. */
79 __gid_t st_gid; /* Group ID of the file's group.*/
80 int __glibc_reserved0;
81 __dev_t st_rdev; /* Device number, if device. */
82 __off_t st_size; /* Size of file, in bytes. */
83#ifdef __USE_XOPEN2K8
84 /* Nanosecond resolution timestamps are stored in a format
85 equivalent to 'struct timespec'. This is the type used
86 whenever possible but the Unix namespace rules do not allow the
87 identifier 'timespec' to appear in the <sys/stat.h> header.
88 Therefore we have to handle the use of this header in strictly
89 standard-compliant sources special. */
90 struct timespec st_atim; /* Time of last access. */
91 struct timespec st_mtim; /* Time of last modification. */
92 struct timespec st_ctim; /* Time of last status change. */
93# define st_atime st_atim.tv_sec /* Backward compatibility. */
94# define st_mtime st_mtim.tv_sec
95# define st_ctime st_ctim.tv_sec
96#else
97 __time_t st_atime; /* Time of last access. */
98 unsigned long int st_atimensec; /* Nscecs of last access. */
99 __time_t st_mtime; /* Time of last modification. */
100 unsigned long int st_mtimensec; /* Nsecs of last modification. */
101 __time_t st_ctime; /* Time of last status change. */
102 unsigned long int st_ctimensec; /* Nsecs of last status change. */
103#endif
104 __blksize_t st_blksize; /* Optimal block size for I/O. */
105 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
106 long int __glibc_reserved[3];
107 };
108#endif
109
110/* Tell code we have these members. */
111#define _STATBUF_ST_BLKSIZE
112#define _STATBUF_ST_RDEV
113/* Nanosecond resolution time values are supported. */
114#define _STATBUF_ST_NSEC
115
116/* Encoding of the file mode. */
117
118#define __S_IFMT 0170000 /* These bits determine file type. */
119
120/* File types. */
121#define __S_IFDIR 0040000 /* Directory. */
122#define __S_IFCHR 0020000 /* Character device. */
123#define __S_IFBLK 0060000 /* Block device. */
124#define __S_IFREG 0100000 /* Regular file. */
125#define __S_IFIFO 0010000 /* FIFO. */
126#define __S_IFLNK 0120000 /* Symbolic link. */
127#define __S_IFSOCK 0140000 /* Socket. */
128
129/* POSIX.1b objects. Note that these macros always evaluate to zero. But
130 they do it by enforcing the correct use of the macros. */
131#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
132#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
133#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
134
135/* Protection bits. */
136
137#define __S_ISUID 04000 /* Set user ID on execution. */
138#define __S_ISGID 02000 /* Set group ID on execution. */
139#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
140#define __S_IREAD 0400 /* Read by owner. */
141#define __S_IWRITE 0200 /* Write by owner. */
142#define __S_IEXEC 0100 /* Execute by owner. */
143
144#ifdef __USE_ATFILE
145# define UTIME_NOW ((1l << 30) - 1l)
146# define UTIME_OMIT ((1l << 30) - 2l)
147#endif
148
149#endif /* bits//stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* System-specific settings for dynamic linker code. IA-64 version.
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
2 Copyright (C) 2003-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 2010-2020 Free Software Foundation, Inc.
3 Copyright (C) 2010-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/ia64/sysdep.h+15-47
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Written by Jes Sorensen, <Jes.Sorensen@cern.ch>, April 1999.
44 Based on code originally written by David Mosberger-Tang
......@@ -46,12 +46,6 @@
4646#undef SYS_ify
4747#define SYS_ify(syscall_name) __NR_##syscall_name
4848
49/* This is to help the old kernel headers where __NR_semtimedop is not
50 available. */
51#ifndef __NR_semtimedop
52# define __NR_semtimedop 1247
53#endif
54
5549#if defined USE_DL_SYSINFO \
5650 && (IS_IN (libc) \
5751 || IS_IN (libpthread) || IS_IN (librt))
......@@ -95,6 +89,7 @@
9589
9690/* We don't want the label for the error handler to be visible in the symbol
9791 table when we define it here. */
92#undef SYSCALL_ERROR_LABEL
9893#define SYSCALL_ERROR_LABEL __syscall_error
9994
10095#undef PSEUDO
......@@ -177,6 +172,9 @@
177172
178173#else /* not __ASSEMBLER__ */
179174
175#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
176#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
177
180178#define BREAK_INSN_1(num) "break " #num ";;\n\t"
181179#define BREAK_INSN(num) BREAK_INSN_1(num)
182180
......@@ -191,13 +189,13 @@
191189
192190#ifdef IA64_USE_NEW_STUB
193191
194# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
192# define INTERNAL_SYSCALL_NCS(name, nr, args...) \
193({ \
195194 LOAD_ARGS_##nr (args) \
196195 register long _r8 __asm ("r8"); \
197196 register long _r10 __asm ("r10"); \
198197 register long _r15 __asm ("r15") = name; \
199198 register void *_b7 __asm ("b7") = ((tcbhead_t *)__thread_self)->__private;\
200 long _retval; \
201199 LOAD_REGS_##nr \
202200 /* \
203201 * Don't specify any unwind info here. We mark ar.pfs as \
......@@ -209,60 +207,30 @@
209207 ASM_OUTARGS_##nr \
210208 : "0" (_b7), "3" (_r15) ASM_ARGS_##nr \
211209 : "memory", "ar.pfs" ASM_CLOBBERS_##nr); \
212 _retval = _r8;
210 _r10 == -1 ? -_r8 : _r8; \
211})
213212
214213#else /* !IA64_USE_NEW_STUB */
215214
216# define DO_INLINE_SYSCALL_NCS(name, nr, args...) \
215# define INTERNAL_SYSCALL_NCS(name, nr, args...) \
216({ \
217217 LOAD_ARGS_##nr (args) \
218218 register long _r8 asm ("r8"); \
219219 register long _r10 asm ("r10"); \
220220 register long _r15 asm ("r15") = name; \
221 long _retval; \
222221 LOAD_REGS_##nr \
223222 __asm __volatile (BREAK_INSN (__IA64_BREAK_SYSCALL) \
224223 : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
225224 ASM_OUTARGS_##nr \
226225 : "2" (_r15) ASM_ARGS_##nr \
227226 : "memory" ASM_CLOBBERS_##nr); \
228 _retval = _r8;
227 _r10 == -1 ? -_r8 : _r8; \
228})
229229
230230#endif /* !IA64_USE_NEW_STUB */
231231
232#define DO_INLINE_SYSCALL(name, nr, args...) \
233 DO_INLINE_SYSCALL_NCS (__NR_##name, nr, ##args)
234
235#undef INLINE_SYSCALL
236#define INLINE_SYSCALL(name, nr, args...) \
237 ({ \
238 DO_INLINE_SYSCALL_NCS (__NR_##name, nr, args) \
239 if (_r10 == -1) \
240 { \
241 __set_errno (_retval); \
242 _retval = -1; \
243 } \
244 _retval; })
245
246#undef INTERNAL_SYSCALL_DECL
247#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
248
249#undef INTERNAL_SYSCALL
250#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
251 ({ \
252 DO_INLINE_SYSCALL_NCS (name, nr, args) \
253 err = _r10; \
254 _retval; })
255#define INTERNAL_SYSCALL(name, err, nr, args...) \
256 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
257
258#undef INTERNAL_SYSCALL_ERROR_P
259#define INTERNAL_SYSCALL_ERROR_P(val, err) \
260 ({ (void) (val); \
261 (err == -1); \
262 })
263
264#undef INTERNAL_SYSCALL_ERRNO
265#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
232#define INTERNAL_SYSCALL(name, nr, args...) \
233 INTERNAL_SYSCALL_NCS (__NR_##name, nr, ##args)
266234
267235#define LOAD_ARGS_0()
268236#define LOAD_REGS_0
lib/libc/glibc/sysdeps/unix/sysv/linux/include/sys/timex.h+172-1
......@@ -1,5 +1,5 @@
11/* Internal declarations for sys/timex.h.
2 Copyright (C) 2014-2020 Free Software Foundation, Inc.
2 Copyright (C) 2014-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -23,7 +23,178 @@
2323
2424# ifndef _ISOMAC
2525
26extern int __adjtimex (struct timex *__ntx);
2627libc_hidden_proto (__adjtimex)
2728
29# include <time.h>
30# include <struct___timeval64.h>
31/* Local definition of 64 bit time supporting timex struct */
32# if __TIMESIZE == 64
33# define __timex64 timex
34# define __clock_adjtime64 __clock_adjtime
35# define ___adjtimex64 ___adjtimex
36# define __ntptimeval64 ntptimeval
37# define __ntp_gettime64 __ntp_gettime
38# define __ntp_gettimex64 __ntp_gettimex
39# else
40
41struct __timex64
42{
43 unsigned int modes; /* mode selector */
44 int :32; /* pad */
45 long long int offset; /* time offset (usec) */
46 long long int freq; /* frequency offset (scaled ppm) */
47 long long int maxerror; /* maximum error (usec) */
48 long long int esterror; /* estimated error (usec) */
49 int status; /* clock command/status */
50 int :32; /* pad */
51 long long int constant; /* pll time constant */
52 long long int precision; /* clock precision (usec) (read only) */
53 long long int tolerance; /* clock frequency tolerance (ppm) (ro) */
54 struct __timeval64 time; /* (read only, except for ADJ_SETOFFSET) */
55 long long int tick; /* (modified) usecs between clock ticks */
56 long long int ppsfreq; /* pps frequency (scaled ppm) (ro) */
57 long long int jitter; /* pps jitter (us) (ro) */
58 int shift; /* interval duration (s) (shift) (ro) */
59 int :32; /* pad */
60 long long int stabil; /* pps stability (scaled ppm) (ro) */
61 long long int jitcnt; /* jitter limit exceeded (ro) */
62 long long int calcnt; /* calibration intervals (ro) */
63 long long int errcnt; /* calibration errors (ro) */
64 long long int stbcnt; /* stability limit exceeded (ro) */
65
66 int tai; /* TAI offset (ro) */
67
68 int :32;
69 int :32;
70 int :32;
71 int :32;
72 int :32;
73 int :32;
74 int :32;
75 int :32;
76 int :32;
77 int :32;
78 int :32;
79};
80extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
81libc_hidden_proto (__clock_adjtime64);
82extern int ___adjtimex64 (struct __timex64 *tx64);
83libc_hidden_proto (___adjtimex64)
84
85struct __ntptimeval64
86{
87 struct __timeval64 time; /* current time (ro) */
88 long int maxerror; /* maximum error (us) (ro) */
89 long int esterror; /* estimated error (us) (ro) */
90 long int tai; /* TAI offset (ro) */
91
92 long int __glibc_reserved1;
93 long int __glibc_reserved2;
94 long int __glibc_reserved3;
95 long int __glibc_reserved4;
96};
97extern int __ntp_gettime64 (struct __ntptimeval64 *ntv);
98libc_hidden_proto (__ntp_gettime64)
99extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv);
100libc_hidden_proto (__ntp_gettimex64)
101
102# endif
103
104/* Convert a known valid struct timex into a struct __timex64. */
105static inline struct __timex64
106valid_timex_to_timex64 (const struct timex tx)
107{
108 struct __timex64 tx64;
109
110 tx64.modes = tx.modes;
111 tx64.offset = tx.offset;
112 tx64.freq = tx.freq;
113 tx64.maxerror = tx.maxerror;
114 tx64.esterror = tx.esterror;
115 tx64.status = tx.status;
116 tx64.constant = tx.constant;
117 tx64.precision = tx.precision;
118 tx64.tolerance = tx.tolerance;
119 tx64.time = valid_timeval_to_timeval64 (tx.time);
120 tx64.tick = tx.tick;
121 tx64.ppsfreq = tx.ppsfreq;
122 tx64.jitter = tx.jitter;
123 tx64.shift = tx.shift;
124 tx64.stabil = tx.stabil;
125 tx64.jitcnt = tx.jitcnt;
126 tx64.calcnt = tx.calcnt;
127 tx64.errcnt = tx.errcnt;
128 tx64.stbcnt = tx.stbcnt;
129 tx64.tai = tx.tai;
130
131 return tx64;
132}
133
134/* Convert a known valid struct __timex64 into a struct timex. */
135static inline struct timex
136valid_timex64_to_timex (const struct __timex64 tx64)
137{
138 struct timex tx;
139
140 tx.modes = tx64.modes;
141 tx.offset = tx64.offset;
142 tx.freq = tx64.freq;
143 tx.maxerror = tx64.maxerror;
144 tx.esterror = tx64.esterror;
145 tx.status = tx64.status;
146 tx.constant = tx64.constant;
147 tx.precision = tx64.precision;
148 tx.tolerance = tx64.tolerance;
149 tx.time = valid_timeval64_to_timeval (tx64.time);
150 tx.tick = tx64.tick;
151 tx.ppsfreq = tx64.ppsfreq;
152 tx.jitter = tx64.jitter;
153 tx.shift = tx64.shift;
154 tx.stabil = tx64.stabil;
155 tx.jitcnt = tx64.jitcnt;
156 tx.calcnt = tx64.calcnt;
157 tx.errcnt = tx64.errcnt;
158 tx.stbcnt = tx64.stbcnt;
159 tx.tai = tx64.tai;
160
161 return tx;
162}
163
164/* Convert a known valid struct ntptimeval into a struct __ntptimeval64. */
165static inline struct __ntptimeval64
166valid_ntptimeval_to_ntptimeval64 (const struct ntptimeval ntv)
167{
168 struct __ntptimeval64 ntv64;
169
170 ntv64.time = valid_timeval_to_timeval64 (ntv.time);
171 ntv64.maxerror = ntv.maxerror;
172 ntv64.esterror = ntv.esterror;
173 ntv64.tai = ntv.tai;
174 ntv64.__glibc_reserved1 = 0;
175 ntv64.__glibc_reserved2 = 0;
176 ntv64.__glibc_reserved3 = 0;
177 ntv64.__glibc_reserved4 = 0;
178
179 return ntv64;
180}
181
182/* Convert a known valid struct __ntptimeval64 into a struct ntptimeval. */
183static inline struct ntptimeval
184valid_ntptimeval64_to_ntptimeval (const struct __ntptimeval64 ntp64)
185{
186 struct ntptimeval ntp;
187
188 ntp.time = valid_timeval64_to_timeval (ntp64.time);
189 ntp.maxerror = ntp64.maxerror;
190 ntp.esterror = ntp64.esterror;
191 ntp.tai = ntp64.tai;
192 ntp.__glibc_reserved1 = 0;
193 ntp.__glibc_reserved2 = 0;
194 ntp.__glibc_reserved3 = 0;
195 ntp.__glibc_reserved4 = 0;
196
197 return ntp;
198}
28199# endif /* _ISOMAC */
29200#endif /* sys/timex.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/kernel-features.h+11-5
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -49,10 +49,6 @@
4949 SH this appeared first in 2.6.19-rc1, on ia64 in 2.6.22-rc1. */
5050#define __ASSUME_PSELECT 1
5151
52/* The *at syscalls were introduced just after 2.6.16-rc1. On PPC
53 they were introduced in 2.6.17-rc1, on SH in 2.6.19-rc1. */
54#define __ASSUME_ATFCTS 1
55
5652/* Support for inter-process robust mutexes was added in 2.6.17 (but
5753 some architectures lack futex_atomic_cmpxchg_inatomic in some
5854 configurations). */
......@@ -81,6 +77,8 @@
8177#define __ASSUME_ACCEPT4_SYSCALL 1
8278#define __ASSUME_RECVMMSG_SYSCALL 1
8379#define __ASSUME_SENDMMSG_SYSCALL 1
80#define __ASSUME_GETSOCKOPT_SYSCALL 1
81#define __ASSUME_SETSOCKOPT_SYSCALL 1
8482
8583/* Support for SysV IPC through wired syscalls. All supported architectures
8684 either support ipc syscall and/or all the ipc correspondent syscalls. */
......@@ -214,4 +212,12 @@
214212# define __ASSUME_WAITID_PID0_P_PGID
215213#endif
216214
215/* The faccessat2 system call was introduced across all architectures
216 in Linux 5.8. */
217#if __LINUX_KERNEL_VERSION >= 0x050800
218# define __ASSUME_FACCESSAT2 1
219#else
220# define __ASSUME_FACCESSAT2 0
221#endif
222
217223#endif /* kernel-features.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/bits/stat.h deleted-172
......@@ -1,172 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_LINUX_OLD 1
27#define _STAT_VER_KERNEL 1
28#define _STAT_VER_SVR4 2
29#define _STAT_VER_LINUX 3
30#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
31
32/* Versions of the `xmknod' interface. */
33#define _MKNOD_VER_LINUX 1
34#define _MKNOD_VER_SVR4 2
35#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36
37
38struct stat
39 {
40 __dev_t st_dev; /* Device. */
41 unsigned short int __pad1;
42#ifndef __USE_FILE_OFFSET64
43 __ino_t st_ino; /* File serial number. */
44#else
45 __ino_t __st_ino; /* 32bit file serial number. */
46#endif
47 __mode_t st_mode; /* File mode. */
48 __nlink_t st_nlink; /* Link count. */
49 __uid_t st_uid; /* User ID of the file's owner. */
50 __gid_t st_gid; /* Group ID of the file's group.*/
51 __dev_t st_rdev; /* Device number, if device. */
52 unsigned short int __pad2;
53#ifndef __USE_FILE_OFFSET64
54 __off_t st_size; /* Size of file, in bytes. */
55#else
56 __off64_t st_size; /* Size of file, in bytes. */
57#endif
58 __blksize_t st_blksize; /* Optimal block size for I/O. */
59
60#ifndef __USE_FILE_OFFSET64
61 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
62#else
63 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86#ifndef __USE_FILE_OFFSET64
87 unsigned long int __glibc_reserved4;
88 unsigned long int __glibc_reserved5;
89#else
90 __ino64_t st_ino; /* File serial number. */
91#endif
92 };
93
94#ifdef __USE_LARGEFILE64
95struct stat64
96 {
97 __dev_t st_dev; /* Device. */
98 unsigned short int __pad1;
99
100 __ino_t __st_ino; /* 32bit file serial number. */
101 __mode_t st_mode; /* File mode. */
102 __nlink_t st_nlink; /* Link count. */
103 __uid_t st_uid; /* User ID of the file's owner. */
104 __gid_t st_gid; /* Group ID of the file's group.*/
105 __dev_t st_rdev; /* Device number, if device. */
106 unsigned short int __pad2;
107 __off64_t st_size; /* Size of file, in bytes. */
108 __blksize_t st_blksize; /* Optimal block size for I/O. */
109
110 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
111# ifdef __USE_XOPEN2K8
112 /* Nanosecond resolution timestamps are stored in a format
113 equivalent to 'struct timespec'. This is the type used
114 whenever possible but the Unix namespace rules do not allow the
115 identifier 'timespec' to appear in the <sys/stat.h> header.
116 Therefore we have to handle the use of this header in strictly
117 standard-compliant sources special. */
118 struct timespec st_atim; /* Time of last access. */
119 struct timespec st_mtim; /* Time of last modification. */
120 struct timespec st_ctim; /* Time of last status change. */
121# else
122 __time_t st_atime; /* Time of last access. */
123 unsigned long int st_atimensec; /* Nscecs of last access. */
124 __time_t st_mtime; /* Time of last modification. */
125 unsigned long int st_mtimensec; /* Nsecs of last modification. */
126 __time_t st_ctime; /* Time of last status change. */
127 unsigned long int st_ctimensec; /* Nsecs of last status change. */
128# endif
129 __ino64_t st_ino; /* File serial number. */
130 };
131#endif
132
133/* Tell code we have these members. */
134#define _STATBUF_ST_BLKSIZE
135#define _STATBUF_ST_RDEV
136/* Nanosecond resolution time values are supported. */
137#define _STATBUF_ST_NSEC
138
139/* Encoding of the file mode. */
140
141#define __S_IFMT 0170000 /* These bits determine file type. */
142
143/* File types. */
144#define __S_IFDIR 0040000 /* Directory. */
145#define __S_IFCHR 0020000 /* Character device. */
146#define __S_IFBLK 0060000 /* Block device. */
147#define __S_IFREG 0100000 /* Regular file. */
148#define __S_IFIFO 0010000 /* FIFO. */
149#define __S_IFLNK 0120000 /* Symbolic link. */
150#define __S_IFSOCK 0140000 /* Socket. */
151
152/* POSIX.1b objects. Note that these macros always evaluate to zero. But
153 they do it by enforcing the correct use of the macros. */
154#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
155#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
156#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
157
158/* Protection bits. */
159
160#define __S_ISUID 04000 /* Set user ID on execution. */
161#define __S_ISGID 02000 /* Set group ID on execution. */
162#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
163#define __S_IREAD 0400 /* Read by owner. */
164#define __S_IWRITE 0200 /* Write by owner. */
165#define __S_IEXEC 0100 /* Execute by owner. */
166
167#ifdef __USE_ATFILE
168# define UTIME_NOW ((1l << 30) - 1l)
169# define UTIME_OMIT ((1l << 30) - 2l)
170#endif
171
172#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/coldfire/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2010-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2010-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/kernel-features.h+3-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 2008-2020 Free Software Foundation, Inc.
3 Copyright (C) 2008-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -23,8 +23,6 @@
2323# define __ASSUME_SOCKETPAIR_SYSCALL 1
2424# define __ASSUME_BIND_SYSCALL 1
2525# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
2826# define __ASSUME_GETSOCKNAME_SYSCALL 1
2927# define __ASSUME_GETPEERNAME_SYSCALL 1
3028# define __ASSUME_SHUTDOWN_SYSCALL 1
......@@ -43,6 +41,8 @@
4341# undef __ASSUME_CONNECT_SYSCALL
4442# undef __ASSUME_RECVFROM_SYSCALL
4543# undef __ASSUME_SENDTO_SYSCALL
44# undef __ASSUME_GETSOCKOPT_SYSCALL
45# undef __ASSUME_SETSOCKOPT_SYSCALL
4646#endif
4747
4848/* No support for PI futexes or robust mutexes before 3.10 for m68k. */
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/m680x0/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2010-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2010-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/sysdep.h+8-26
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1996-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Written by Andreas Schwab, <schwab@issan.informatik.uni-dortmund.de>,
44 December 1995.
......@@ -44,6 +44,7 @@
4444
4545/* We don't want the label for the error handler to be visible in the symbol
4646 table when we define it here. */
47#undef SYSCALL_ERROR_LABEL
4748#ifdef PIC
4849#define SYSCALL_ERROR_LABEL .Lsyscall_error
4950#else
......@@ -221,27 +222,12 @@ SYSCALL_ERROR_LABEL: \
221222
222223#else /* not __ASSEMBLER__ */
223224
224/* Define a macro which expands into the inline wrapper code for a system
225 call. */
226#undef INLINE_SYSCALL
227#define INLINE_SYSCALL(name, nr, args...) \
228 ({ unsigned int _sys_result = INTERNAL_SYSCALL (name, , nr, args); \
229 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\
230 { \
231 __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \
232 _sys_result = (unsigned int) -1; \
233 } \
234 (int) _sys_result; })
235
236#undef INTERNAL_SYSCALL_DECL
237#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
238
239225/* Define a macro which expands inline into the wrapper code for a system
240226 call. This use is for internal calls that do not need to handle errors
241227 normally. It will never touch errno. This returns just what the kernel
242228 gave back. */
243229#undef INTERNAL_SYSCALL
244#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
230#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
245231 ({ unsigned int _sys_result; \
246232 { \
247233 /* Load argument values in temporary variables
......@@ -257,15 +243,8 @@ SYSCALL_ERROR_LABEL: \
257243 _sys_result = _d0; \
258244 } \
259245 (int) _sys_result; })
260#define INTERNAL_SYSCALL(name, err, nr, args...) \
261 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
262
263#undef INTERNAL_SYSCALL_ERROR_P
264#define INTERNAL_SYSCALL_ERROR_P(val, err) \
265 ((unsigned int) (val) >= -4095U)
266
267#undef INTERNAL_SYSCALL_ERRNO
268#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
246#define INTERNAL_SYSCALL(name, nr, args...) \
247 INTERNAL_SYSCALL_NCS (__NR_##name, nr, ##args)
269248
270249#define LOAD_ARGS_0()
271250#define LOAD_REGS_0
......@@ -313,6 +292,9 @@ SYSCALL_ERROR_LABEL: \
313292 LOAD_REGS_5
314293#define ASM_ARGS_6 ASM_ARGS_5, "a" (_a0)
315294
295#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
296#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
297
316298#endif /* not __ASSEMBLER__ */
317299
318300/* Pointer mangling is not yet supported for M68K. */
lib/libc/glibc/sysdeps/unix/sysv/linux/m68k/xstatver.h created+13
......@@ -0,0 +1,13 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_LINUX_OLD 1
4#define _STAT_VER_KERNEL 1
5#define _STAT_VER_SVR4 2
6#define _STAT_VER_LINUX 3
7#define _STAT_VER _STAT_VER_LINUX
8
9/* Versions of the 'xmknod' interface used in compatibility xmknod
10 functions. */
11#define _MKNOD_VER_LINUX 1
12#define _MKNOD_VER_SVR4 2
13#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/bits/stat.h deleted-203
......@@ -1,203 +0,0 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
2
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#if !defined _SYS_STAT_H && !defined _FCNTL_H
20# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
21#endif
22
23#ifndef _BITS_STAT_H
24#define _BITS_STAT_H 1
25
26/* Versions of the `struct stat' data structure. */
27#define _STAT_VER_LINUX_OLD 1
28#define _STAT_VER_KERNEL 1
29#define _STAT_VER_SVR4 2
30#define _STAT_VER_LINUX 3
31#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
32
33/* Versions of the `xmknod' interface. */
34#define _MKNOD_VER_LINUX 1
35#define _MKNOD_VER_SVR4 2
36#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
37
38#ifndef __USE_FILE_OFFSET64
39struct stat
40{
41 __dev_t st_dev; /* Device. */
42 __ino_t st_ino; /* File serial number. */
43 __mode_t st_mode; /* File mode. */
44 __nlink_t st_nlink; /* Link count. */
45 __uid_t st_uid; /* User ID of the file's owner. */
46 __gid_t st_gid; /* Group ID of the file's group. */
47 __dev_t st_rdev; /* Device number, if device. */
48 unsigned long __pad2;
49 __off_t st_size; /* Size of file, in bytes. */
50 __blksize_t st_blksize; /* Optimal block size for I/O. */
51 int __pad3;
52 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
53#ifdef __USE_XOPEN2K8
54 /* Nanosecond resolution timestamps are stored in a format
55 * equivalent to 'struct timespec'. This is the type used
56 * whenever possible but the Unix namespace rules do not allow the
57 * identifier 'timespec' to appear in the <sys/stat.h> header.
58 * Therefore we have to handle the use of this header in strictly
59 * standard-compliant sources special. */
60 struct timespec st_atim; /* Time of last access. */
61 struct timespec st_mtim; /* Time of last modification. */
62 struct timespec st_ctim; /* Time of last status change. */
63# define st_atime st_atim.tv_sec /* Backward compatibility. */
64# define st_mtime st_mtim.tv_sec
65# define st_ctime st_ctim.tv_sec
66#else
67 __time_t st_atime; /* Time of last access. */
68 unsigned long int st_atimensec; /* Nscecs of last access. */
69 __time_t st_mtime; /* Time of last modification. */
70 unsigned long int st_mtimensec; /* Nsecs of last modification. */
71 __time_t st_ctime; /* Time of last status change. */
72 unsigned long int st_ctimensec; /* Nsecs of last status change. */
73#endif
74 unsigned int __glibc_reserved4;
75 unsigned int __glibc_reserved5;
76};
77#else /* __USE_FILE_OFFSET64 */
78/* MS: If __USE_FILE_OFFSET64 is setup then struct stat should match stat64
79 * structure. Glibc has no type __dev64_t that's why I had to use standard
80 * type for st_dev and st_rdev. Several architectures uses pads after st_dev
81 * but this approach covers BIG and LITTLE endian. I think it is better to
82 * create one ifdef to separate stats structures. */
83struct stat
84{
85 unsigned long long st_dev; /* Device. */
86 __ino64_t st_ino; /* 32bit file serial number. */
87 __mode_t st_mode; /* File mode. */
88 __nlink_t st_nlink; /* Link count. */
89 __uid_t st_uid; /* User ID of the file's owner. */
90 __gid_t st_gid; /* Group ID of the file's group. */
91 unsigned long long st_rdev; /* Device number, if device. */
92 unsigned long long __pad2;
93 __off64_t st_size; /* Size of file, in bytes. */
94 __blksize_t st_blksize; /* Optimal block size for I/O. */
95 int __pad3;
96 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
97#ifdef __USE_MISC
98 /* Nanosecond resolution timestamps are stored in a format
99 * equivalent to 'struct timespec'. This is the type used
100 * whenever possible but the Unix namespace rules do not allow the
101 * identifier 'timespec' to appear in the <sys/stat.h> header.
102 * Therefore we have to handle the use of this header in strictly
103 * standard-compliant sources special. */
104 struct timespec st_atim; /* Time of last access. */
105 struct timespec st_mtim; /* Time of last modification. */
106 struct timespec st_ctim; /* Time of last status change. */
107# define st_atime st_atim.tv_sec /* Backward compatibility. */
108# define st_mtime st_mtim.tv_sec
109# define st_ctime st_ctim.tv_sec
110#else
111 __time_t st_atime; /* Time of last access. */
112 unsigned long int st_atimensec; /* Nscecs of last access. */
113 __time_t st_mtime; /* Time of last modification. */
114 unsigned long int st_mtimensec; /* Nsecs of last modification. */
115 __time_t st_ctime; /* Time of last status change. */
116 unsigned long int st_ctimensec; /* Nsecs of last status change. */
117#endif
118 unsigned int __glibc_reserved4;
119 unsigned int __glibc_reserved5;
120};
121#endif /* __USE_FILE_OFFSET64 */
122
123#ifdef __USE_LARGEFILE64
124struct stat64
125{
126 unsigned long long st_dev; /* Device. */
127 __ino64_t st_ino; /* 32bit file serial number. */
128 __mode_t st_mode; /* File mode. */
129 __nlink_t st_nlink; /* Link count. */
130 __uid_t st_uid; /* User ID of the file's owner. */
131 __gid_t st_gid; /* Group ID of the file's group. */
132 unsigned long long st_rdev; /* Device number, if device. */
133 unsigned long long __pad2;
134 __off64_t st_size; /* Size of file, in bytes. */
135 __blksize_t st_blksize; /* Optimal block size for I/O. */
136 int __pad3;
137 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
138#ifdef __USE_XOPEN2K8
139 /* Nanosecond resolution timestamps are stored in a format
140 * equivalent to 'struct timespec'. This is the type used
141 * whenever possible but the Unix namespace rules do not allow the
142 * identifier 'timespec' to appear in the <sys/stat.h> header.
143 * Therefore we have to handle the use of this header in strictly
144 * standard-compliant sources special. */
145 struct timespec st_atim; /* Time of last access. */
146 struct timespec st_mtim; /* Time of last modification. */
147 struct timespec st_ctim; /* Time of last status change. */
148# define st_atime st_atim.tv_sec /* Backward compatibility. */
149# define st_mtime st_mtim.tv_sec
150# define st_ctime st_ctim.tv_sec
151#else
152 __time_t st_atime; /* Time of last access. */
153 unsigned long int st_atimensec; /* Nscecs of last access. */
154 __time_t st_mtime; /* Time of last modification. */
155 unsigned long int st_mtimensec; /* Nsecs of last modification. */
156 __time_t st_ctime; /* Time of last status change. */
157 unsigned long int st_ctimensec; /* Nsecs of last status change. */
158#endif
159 unsigned int __glibc_reserved4;
160 unsigned int __glibc_reserved5;
161};
162#endif
163
164/* Tell code we have these members. */
165#define _STATBUF_ST_BLKSIZE
166#define _STATBUF_ST_RDEV
167/* Nanosecond resolution time values are supported. */
168#define _STATBUF_ST_NSEC
169
170/* Encoding of the file mode. */
171
172#define __S_IFMT 0170000 /* These bits determine file type. */
173
174/* File types. */
175#define __S_IFDIR 0040000 /* Directory. */
176#define __S_IFCHR 0020000 /* Character device. */
177#define __S_IFBLK 0060000 /* Block device. */
178#define __S_IFREG 0100000 /* Regular file. */
179#define __S_IFIFO 0010000 /* FIFO. */
180#define __S_IFLNK 0120000 /* Symbolic link. */
181#define __S_IFSOCK 0140000 /* Socket. */
182
183/* POSIX.1b objects. Note that these macros always evaluate to zero. But
184 they do it by enforcing the correct use of the macros. */
185#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
186#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
187#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
188
189/* Protection bits. */
190
191#define __S_ISUID 04000 /* Set user ID on execution. */
192#define __S_ISGID 02000 /* Set group ID on execution. */
193#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
194#define __S_IREAD 0400 /* Read by owner. */
195#define __S_IWRITE 0200 /* Write by owner. */
196#define __S_IEXEC 0100 /* Execute by owner. */
197
198#ifdef __USE_ATFILE
199# define UTIME_NOW ((1l << 30) - 1l)
200# define UTIME_OMIT ((1l << 30) - 2l)
201#endif
202
203#endif /* bits/stat.h. */
lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/kernel-features.h+1-3
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2011-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -28,8 +28,6 @@
2828#define __ASSUME_SEND_SYSCALL 1
2929#define __ASSUME_RECV_SYSCALL 1
3030#define __ASSUME_SHUTDOWN_SYSCALL 1
31#define __ASSUME_GETSOCKOPT_SYSCALL 1
32#define __ASSUME_SETSOCKOPT_SYSCALL 1
3331
3432#include_next <kernel-features.h>
3533
lib/libc/glibc/sysdeps/unix/sysv/linux/microblaze/sysdep.h+65-62
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22
33 This file is part of the GNU C Library.
44
......@@ -26,6 +26,8 @@
2626/* Defines RTLD_PRIVATE_ERRNO. */
2727#include <dl-sysdep.h>
2828
29#include <tls.h>
30
2931/* In order to get __set_errno() definition in INLINE_SYSCALL. */
3032#ifndef __ASSEMBLER__
3133# include <errno.h>
......@@ -60,6 +62,7 @@
6062
6163/* We don't want the label for the error handler to be visible in the symbol
6264 table when we define it here. */
65# undef SYSCALL_ERROR_LABEL
6366# ifdef PIC
6467# define SYSCALL_ERROR_LABEL 0f
6568# else
......@@ -163,42 +166,18 @@ SYSCALL_ERROR_LABEL_DCL: \
163166
164167#else /* not __ASSEMBLER__ */
165168
166/* Define a macro which expands into the inline wrapper code for a system
167 call. */
168# undef INLINE_SYSCALL
169# define INLINE_SYSCALL(name, nr, args...) \
170({ INTERNAL_SYSCALL_DECL(err); \
171 unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args); \
172 if (INTERNAL_SYSCALL_ERROR_P (resultvar, err)) \
173 { \
174 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \
175 resultvar = (unsigned long) -1; \
176 } \
177 (long) resultvar; \
178})
179
180# undef INTERNAL_SYSCALL_DECL
181# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
182
183169/* Define a macro which expands inline into the wrapper code for a system
184170 call. This use is for internal calls that do not need to handle errors
185171 normally. It will never touch errno. This returns just what the kernel
186172 gave back. */
187173# undef INTERNAL_SYSCALL
188# define INTERNAL_SYSCALL(name, err, nr, args...) \
174# define INTERNAL_SYSCALL(name, nr, args...) \
189175 inline_syscall##nr(SYS_ify(name), args)
190176
191177# undef INTERNAL_SYSCALL_NCS
192# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
178# define INTERNAL_SYSCALL_NCS(name, nr, args...) \
193179 inline_syscall##nr(name, args)
194180
195# undef INTERNAL_SYSCALL_ERROR_P
196# define INTERNAL_SYSCALL_ERROR_P(val, err) \
197 ((unsigned int) (val) >= -4095U)
198
199# undef INTERNAL_SYSCALL_ERRNO
200# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
201
202181# define SYSCALL_CLOBBERS_6 "r11", "r4", "memory"
203182# define SYSCALL_CLOBBERS_5 "r10", SYSCALL_CLOBBERS_6
204183# define SYSCALL_CLOBBERS_4 "r9", SYSCALL_CLOBBERS_5
......@@ -209,8 +188,8 @@ SYSCALL_ERROR_LABEL_DCL: \
209188
210189# define inline_syscall0(name,dummy) \
211190 ({ \
212 register long __ret __asm__("r3"); \
213 register long __r12 __asm__("r12") = name; \
191 register long int __ret __asm__("r3"); \
192 register long int __r12 __asm__("r12") = name; \
214193 __asm__ __volatile__( "brki r14,8; nop;" \
215194 : "=r"(__ret) \
216195 : "r"(__r12) \
......@@ -219,9 +198,10 @@ SYSCALL_ERROR_LABEL_DCL: \
219198
220199# define inline_syscall1(name,arg1) \
221200 ({ \
222 register long __ret __asm__("r3"); \
223 register long __r12 __asm__("r12") = name; \
224 register long __r5 __asm__("r5") = (long)(arg1); \
201 long int __arg1 = (long int) (arg1); \
202 register long int __ret __asm__("r3"); \
203 register long int __r12 __asm__("r12") = name; \
204 register long int __r5 __asm__("r5") = __arg1; \
225205 __asm__ __volatile__( "brki r14,8; nop;" \
226206 : "=r"(__ret) \
227207 : "r"(__r5), "r"(__r12) \
......@@ -230,10 +210,12 @@ SYSCALL_ERROR_LABEL_DCL: \
230210
231211# define inline_syscall2(name,arg1,arg2) \
232212 ({ \
233 register long __ret __asm__("r3"); \
234 register long __r12 __asm__("r12") = name; \
235 register long __r5 __asm__("r5") = (long)(arg1); \
236 register long __r6 __asm__("r6") = (long)(arg2); \
213 long int __arg1 = (long int) (arg1); \
214 long int __arg2 = (long int) (arg2); \
215 register long int __ret __asm__("r3"); \
216 register long int __r12 __asm__("r12") = name; \
217 register long int __r5 __asm__("r5") = __arg1; \
218 register long int __r6 __asm__("r6") = __arg2; \
237219 __asm__ __volatile__( "brki r14,8; nop;" \
238220 : "=r"(__ret) \
239221 : "r"(__r5), "r"(__r6), "r"(__r12) \
......@@ -243,11 +225,14 @@ SYSCALL_ERROR_LABEL_DCL: \
243225
244226# define inline_syscall3(name,arg1,arg2,arg3) \
245227 ({ \
246 register long __ret __asm__("r3"); \
247 register long __r12 __asm__("r12") = name; \
248 register long __r5 __asm__("r5") = (long)(arg1); \
249 register long __r6 __asm__("r6") = (long)(arg2); \
250 register long __r7 __asm__("r7") = (long)(arg3); \
228 long int __arg1 = (long int) (arg1); \
229 long int __arg2 = (long int) (arg2); \
230 long int __arg3 = (long int) (arg3); \
231 register long int __ret __asm__("r3"); \
232 register long int __r12 __asm__("r12") = name; \
233 register long int __r5 __asm__("r5") = __arg1; \
234 register long int __r6 __asm__("r6") = __arg2; \
235 register long int __r7 __asm__("r7") = __arg3; \
251236 __asm__ __volatile__( "brki r14,8; nop;" \
252237 : "=r"(__ret) \
253238 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r12) \
......@@ -257,12 +242,16 @@ SYSCALL_ERROR_LABEL_DCL: \
257242
258243# define inline_syscall4(name,arg1,arg2,arg3,arg4) \
259244 ({ \
260 register long __ret __asm__("r3"); \
261 register long __r12 __asm__("r12") = name; \
262 register long __r5 __asm__("r5") = (long)(arg1); \
263 register long __r6 __asm__("r6") = (long)(arg2); \
264 register long __r7 __asm__("r7") = (long)(arg3); \
265 register long __r8 __asm__("r8") = (long)(arg4); \
245 long int __arg1 = (long int) (arg1); \
246 long int __arg2 = (long int) (arg2); \
247 long int __arg3 = (long int) (arg3); \
248 long int __arg4 = (long int) (arg4); \
249 register long int __ret __asm__("r3"); \
250 register long int __r12 __asm__("r12") = name; \
251 register long int __r5 __asm__("r5") = __arg1; \
252 register long int __r6 __asm__("r6") = __arg2; \
253 register long int __r7 __asm__("r7") = __arg3; \
254 register long int __r8 __asm__("r8") = __arg4; \
266255 __asm__ __volatile__( "brki r14,8; nop;" \
267256 : "=r"(__ret) \
268257 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r12) \
......@@ -272,13 +261,18 @@ SYSCALL_ERROR_LABEL_DCL: \
272261
273262# define inline_syscall5(name,arg1,arg2,arg3,arg4,arg5) \
274263 ({ \
275 register long __ret __asm__("r3"); \
276 register long __r12 __asm__("r12") = name; \
277 register long __r5 __asm__("r5") = (long)(arg1); \
278 register long __r6 __asm__("r6") = (long)(arg2); \
279 register long __r7 __asm__("r7") = (long)(arg3); \
280 register long __r8 __asm__("r8") = (long)(arg4); \
281 register long __r9 __asm__("r9") = (long)(arg5); \
264 long int __arg1 = (long int) (arg1); \
265 long int __arg2 = (long int) (arg2); \
266 long int __arg3 = (long int) (arg3); \
267 long int __arg4 = (long int) (arg4); \
268 long int __arg5 = (long int) (arg5); \
269 register long int __ret __asm__("r3"); \
270 register long int __r12 __asm__("r12") = name; \
271 register long int __r5 __asm__("r5") = __arg1; \
272 register long int __r6 __asm__("r6") = __arg2; \
273 register long int __r7 __asm__("r7") = __arg3; \
274 register long int __r8 __asm__("r8") = __arg4; \
275 register long int __r9 __asm__("r9") = __arg5; \
282276 __asm__ __volatile__( "brki r14,8; nop;" \
283277 : "=r"(__ret) \
284278 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r12) \
......@@ -288,14 +282,20 @@ SYSCALL_ERROR_LABEL_DCL: \
288282
289283# define inline_syscall6(name,arg1,arg2,arg3,arg4,arg5,arg6) \
290284 ({ \
291 register long __ret __asm__("r3"); \
292 register long __r12 __asm__("r12") = name; \
293 register long __r5 __asm__("r5") = (long)(arg1); \
294 register long __r6 __asm__("r6") = (long)(arg2); \
295 register long __r7 __asm__("r7") = (long)(arg3); \
296 register long __r8 __asm__("r8") = (long)(arg4); \
297 register long __r9 __asm__("r9") = (long)(arg5); \
298 register long __r10 __asm__("r10") = (long)(arg6); \
285 long int __arg1 = (long int) (arg1); \
286 long int __arg2 = (long int) (arg2); \
287 long int __arg3 = (long int) (arg3); \
288 long int __arg4 = (long int) (arg4); \
289 long int __arg5 = (long int) (arg5); \
290 long int __arg6 = (long int) (arg6); \
291 register long int __ret __asm__("r3"); \
292 register long int __r12 __asm__("r12") = name; \
293 register long int __r5 __asm__("r5") = __arg1; \
294 register long int __r6 __asm__("r6") = __arg2; \
295 register long int __r7 __asm__("r7") = __arg3; \
296 register long int __r8 __asm__("r8") = __arg4; \
297 register long int __r9 __asm__("r9") = __arg5; \
298 register long int __r10 __asm__("r10") = __arg6; \
299299 __asm__ __volatile__( "brki r14,8; nop;" \
300300 : "=r"(__ret) \
301301 : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r10), \
......@@ -310,6 +310,9 @@ SYSCALL_ERROR_LABEL_DCL: \
310310
311311# define SINGLE_THREAD_BY_GLOBAL 1
312312
313#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
314#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
315
313316#endif /* not __ASSEMBLER__ */
314317
315318#endif /* _LINUX_MICROBLAZE_SYSDEP_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/bits/stat.h deleted-263
......@@ -1,263 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <sgidefs.h>
26
27/* Versions of the `struct stat' data structure. */
28#define _STAT_VER_LINUX_OLD 1
29#define _STAT_VER_KERNEL 1
30#define _STAT_VER_SVR4 2
31#define _STAT_VER_LINUX 3
32#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
33
34/* Versions of the `xmknod' interface. */
35#define _MKNOD_VER_LINUX 1
36#define _MKNOD_VER_SVR4 2
37#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
38
39
40#if _MIPS_SIM == _ABIO32
41/* Structure describing file characteristics. */
42struct stat
43 {
44 unsigned long int st_dev;
45 long int st_pad1[3];
46#ifndef __USE_FILE_OFFSET64
47 __ino_t st_ino; /* File serial number. */
48#else
49 __ino64_t st_ino; /* File serial number. */
50#endif
51 __mode_t st_mode; /* File mode. */
52 __nlink_t st_nlink; /* Link count. */
53 __uid_t st_uid; /* User ID of the file's owner. */
54 __gid_t st_gid; /* Group ID of the file's group.*/
55 unsigned long int st_rdev; /* Device number, if device. */
56#ifndef __USE_FILE_OFFSET64
57 long int st_pad2[2];
58 __off_t st_size; /* Size of file, in bytes. */
59 /* SVR4 added this extra long to allow for expansion of off_t. */
60 long int st_pad3;
61#else
62 long int st_pad2[3];
63 __off64_t st_size; /* Size of file, in bytes. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86 __blksize_t st_blksize; /* Optimal block size for I/O. */
87#ifndef __USE_FILE_OFFSET64
88 __blkcnt_t st_blocks; /* Number of 512-byte blocks allocated. */
89#else
90 long int st_pad4;
91 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
92#endif
93 long int st_pad5[14];
94 };
95
96#ifdef __USE_LARGEFILE64
97struct stat64
98 {
99 unsigned long int st_dev;
100 long int st_pad1[3];
101 __ino64_t st_ino; /* File serial number. */
102 __mode_t st_mode; /* File mode. */
103 __nlink_t st_nlink; /* Link count. */
104 __uid_t st_uid; /* User ID of the file's owner. */
105 __gid_t st_gid; /* Group ID of the file's group.*/
106 unsigned long int st_rdev; /* Device number, if device. */
107 long int st_pad2[3];
108 __off64_t st_size; /* Size of file, in bytes. */
109# ifdef __USE_XOPEN2K8
110 /* Nanosecond resolution timestamps are stored in a format
111 equivalent to 'struct timespec'. This is the type used
112 whenever possible but the Unix namespace rules do not allow the
113 identifier 'timespec' to appear in the <sys/stat.h> header.
114 Therefore we have to handle the use of this header in strictly
115 standard-compliant sources special. */
116 struct timespec st_atim; /* Time of last access. */
117 struct timespec st_mtim; /* Time of last modification. */
118 struct timespec st_ctim; /* Time of last status change. */
119# else
120 __time_t st_atime; /* Time of last access. */
121 unsigned long int st_atimensec; /* Nscecs of last access. */
122 __time_t st_mtime; /* Time of last modification. */
123 unsigned long int st_mtimensec; /* Nsecs of last modification. */
124 __time_t st_ctime; /* Time of last status change. */
125 unsigned long int st_ctimensec; /* Nsecs of last status change. */
126# endif
127 __blksize_t st_blksize; /* Optimal block size for I/O. */
128 long int st_pad3;
129 __blkcnt64_t st_blocks; /* Number of 512-byte blocks allocated. */
130 long int st_pad4[14];
131 };
132#endif
133#else
134struct stat
135 {
136 __dev_t st_dev;
137 int st_pad1[3]; /* Reserved for st_dev expansion */
138#ifndef __USE_FILE_OFFSET64
139 __ino_t st_ino;
140#else
141 __ino64_t st_ino;
142#endif
143 __mode_t st_mode;
144 __nlink_t st_nlink;
145 __uid_t st_uid;
146 __gid_t st_gid;
147 __dev_t st_rdev;
148#if !defined __USE_FILE_OFFSET64
149 unsigned int st_pad2[2]; /* Reserved for st_rdev expansion */
150 __off_t st_size;
151 int st_pad3;
152#else
153 unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
154 __off64_t st_size;
155#endif
156#ifdef __USE_XOPEN2K8
157 /* Nanosecond resolution timestamps are stored in a format
158 equivalent to 'struct timespec'. This is the type used
159 whenever possible but the Unix namespace rules do not allow the
160 identifier 'timespec' to appear in the <sys/stat.h> header.
161 Therefore we have to handle the use of this header in strictly
162 standard-compliant sources special. */
163 struct timespec st_atim; /* Time of last access. */
164 struct timespec st_mtim; /* Time of last modification. */
165 struct timespec st_ctim; /* Time of last status change. */
166# define st_atime st_atim.tv_sec /* Backward compatibility. */
167# define st_mtime st_mtim.tv_sec
168# define st_ctime st_ctim.tv_sec
169#else
170 __time_t st_atime; /* Time of last access. */
171 unsigned long int st_atimensec; /* Nscecs of last access. */
172 __time_t st_mtime; /* Time of last modification. */
173 unsigned long int st_mtimensec; /* Nsecs of last modification. */
174 __time_t st_ctime; /* Time of last status change. */
175 unsigned long int st_ctimensec; /* Nsecs of last status change. */
176#endif
177 __blksize_t st_blksize;
178 unsigned int st_pad4;
179#ifndef __USE_FILE_OFFSET64
180 __blkcnt_t st_blocks;
181#else
182 __blkcnt64_t st_blocks;
183#endif
184 int st_pad5[14];
185 };
186
187#ifdef __USE_LARGEFILE64
188struct stat64
189 {
190 __dev_t st_dev;
191 unsigned int st_pad1[3]; /* Reserved for st_dev expansion */
192 __ino64_t st_ino;
193 __mode_t st_mode;
194 __nlink_t st_nlink;
195 __uid_t st_uid;
196 __gid_t st_gid;
197 __dev_t st_rdev;
198 unsigned int st_pad2[3]; /* Reserved for st_rdev expansion */
199 __off64_t st_size;
200# ifdef __USE_XOPEN2K8
201 /* Nanosecond resolution timestamps are stored in a format
202 equivalent to 'struct timespec'. This is the type used
203 whenever possible but the Unix namespace rules do not allow the
204 identifier 'timespec' to appear in the <sys/stat.h> header.
205 Therefore we have to handle the use of this header in strictly
206 standard-compliant sources special. */
207 struct timespec st_atim; /* Time of last access. */
208 struct timespec st_mtim; /* Time of last modification. */
209 struct timespec st_ctim; /* Time of last status change. */
210# else
211 __time_t st_atime; /* Time of last access. */
212 unsigned long int st_atimensec; /* Nscecs of last access. */
213 __time_t st_mtime; /* Time of last modification. */
214 unsigned long int st_mtimensec; /* Nsecs of last modification. */
215 __time_t st_ctime; /* Time of last status change. */
216 unsigned long int st_ctimensec; /* Nsecs of last status change. */
217# endif
218 __blksize_t st_blksize;
219 unsigned int st_pad3;
220 __blkcnt64_t st_blocks;
221 int st_pad4[14];
222};
223#endif
224#endif
225
226/* Tell code we have these members. */
227#define _STATBUF_ST_BLKSIZE
228#define _STATBUF_ST_RDEV
229
230/* Encoding of the file mode. */
231
232#define __S_IFMT 0170000 /* These bits determine file type. */
233
234/* File types. */
235#define __S_IFDIR 0040000 /* Directory. */
236#define __S_IFCHR 0020000 /* Character device. */
237#define __S_IFBLK 0060000 /* Block device. */
238#define __S_IFREG 0100000 /* Regular file. */
239#define __S_IFIFO 0010000 /* FIFO. */
240#define __S_IFLNK 0120000 /* Symbolic link. */
241#define __S_IFSOCK 0140000 /* Socket. */
242
243/* POSIX.1b objects. Note that these macros always evaluate to zero. But
244 they do it by enforcing the correct use of the macros. */
245#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
246#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
247#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
248
249/* Protection bits. */
250
251#define __S_ISUID 04000 /* Set user ID on execution. */
252#define __S_ISGID 02000 /* Set group ID on execution. */
253#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
254#define __S_IREAD 0400 /* Read by owner. */
255#define __S_IWRITE 0200 /* Write by owner. */
256#define __S_IEXEC 0100 /* Execute by owner. */
257
258#ifdef __USE_ATFILE
259# define UTIME_NOW ((1l << 30) - 1l)
260# define UTIME_OMIT ((1l << 30) - 2l)
261#endif
262
263#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h+93-112
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -25,11 +25,6 @@
2525
2626#include <tls.h>
2727
28/* In order to get __set_errno() definition in INLINE_SYSCALL. */
29#ifndef __ASSEMBLER__
30#include <errno.h>
31#endif
32
3328/* For Linux we can use the system call table in the header file
3429 /usr/include/asm/unistd.h
3530 of the kernel. But these symbols do not follow the SYS_* syntax
......@@ -42,32 +37,14 @@
4237/* We don't want the label for the error handler to be visible in the symbol
4338 table when we define it here. */
4439#ifdef __PIC__
40# undef SYSCALL_ERROR_LABEL
4541# define SYSCALL_ERROR_LABEL 99b
4642#endif
4743
4844#else /* ! __ASSEMBLER__ */
4945
50/* Define a macro which expands into the inline wrapper code for a system
51 call. */
52#undef INLINE_SYSCALL
53#define INLINE_SYSCALL(name, nr, args...) \
54 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
55 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
56 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
57 { \
58 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
59 result_var = -1L; \
60 } \
61 result_var; })
62
63#undef INTERNAL_SYSCALL_DECL
64#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
65
66#undef INTERNAL_SYSCALL_ERROR_P
67#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
68
69#undef INTERNAL_SYSCALL_ERRNO
70#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
46#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
47#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
7148
7249/* Note that the original Linux syscall restart convention required the
7350 instruction immediately preceding SYSCALL to initialize $v0 with the
......@@ -103,11 +80,11 @@
10380
10481union __mips_syscall_return
10582 {
106 long long val;
83 long long int val;
10784 struct
10885 {
109 long v0;
110 long v1;
86 long int v0;
87 long int v1;
11188 }
11289 reg;
11390 };
......@@ -121,14 +98,13 @@ union __mips_syscall_return
12198
12299# include <mips16-syscall.h>
123100
124# define INTERNAL_SYSCALL(name, err, nr, args...) \
125 INTERNAL_SYSCALL_NCS (SYS_ify (name), err, nr, args)
101# define INTERNAL_SYSCALL(name, nr, args...) \
102 INTERNAL_SYSCALL_NCS (SYS_ify (name), nr, args)
126103
127# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
104# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
128105({ \
129106 union __mips_syscall_return _sc_ret; \
130107 _sc_ret.val = __mips16_syscall##nr (args, number); \
131 err = _sc_ret.reg.v1; \
132108 _sc_ret.reg.v0; \
133109})
134110
......@@ -138,12 +114,12 @@ union __mips_syscall_return
138114 number, err, args)
139115
140116#else /* !__mips16 */
141# define INTERNAL_SYSCALL(name, err, nr, args...) \
117# define INTERNAL_SYSCALL(name, nr, args...) \
142118 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
143119 "IK" (SYS_ify (name)), \
144120 SYS_ify (name), err, args)
145121
146# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
122# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
147123 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
148124 "r" (__s0), \
149125 number, err, args)
......@@ -152,13 +128,13 @@ union __mips_syscall_return
152128
153129#define internal_syscall0(v0_init, input, number, err, dummy...) \
154130({ \
155 long _sys_result; \
131 long int _sys_result; \
156132 \
157133 { \
158 register long __s0 asm ("$16") __attribute__ ((unused)) \
134 register long int __s0 asm ("$16") __attribute__ ((unused)) \
159135 = (number); \
160 register long __v0 asm ("$2"); \
161 register long __a3 asm ("$7"); \
136 register long int __v0 asm ("$2"); \
137 register long int __a3 asm ("$7"); \
162138 __asm__ volatile ( \
163139 ".set\tnoreorder\n\t" \
164140 v0_init \
......@@ -167,22 +143,22 @@ union __mips_syscall_return
167143 : "=r" (__v0), "=r" (__a3) \
168144 : input \
169145 : __SYSCALL_CLOBBERS); \
170 err = __a3; \
171 _sys_result = __v0; \
146 _sys_result = __a3 != 0 ? -__v0 : __v0; \
172147 } \
173148 _sys_result; \
174149})
175150
176151#define internal_syscall1(v0_init, input, number, err, arg1) \
177152({ \
178 long _sys_result; \
153 long int _sys_result; \
179154 \
180155 { \
181 register long __s0 asm ("$16") __attribute__ ((unused)) \
156 long int _arg1 = (long int) (arg1); \
157 register long int __s0 asm ("$16") __attribute__ ((unused)) \
182158 = (number); \
183 register long __v0 asm ("$2"); \
184 register long __a0 asm ("$4") = (long) (arg1); \
185 register long __a3 asm ("$7"); \
159 register long int __v0 asm ("$2"); \
160 register long int __a0 asm ("$4") = _arg1; \
161 register long int __a3 asm ("$7"); \
186162 __asm__ volatile ( \
187163 ".set\tnoreorder\n\t" \
188164 v0_init \
......@@ -191,23 +167,24 @@ union __mips_syscall_return
191167 : "=r" (__v0), "=r" (__a3) \
192168 : input, "r" (__a0) \
193169 : __SYSCALL_CLOBBERS); \
194 err = __a3; \
195 _sys_result = __v0; \
170 _sys_result = __a3 != 0 ? -__v0 : __v0; \
196171 } \
197172 _sys_result; \
198173})
199174
200175#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
201176({ \
202 long _sys_result; \
177 long int _sys_result; \
203178 \
204179 { \
205 register long __s0 asm ("$16") __attribute__ ((unused)) \
180 long int _arg1 = (long int) (arg1); \
181 long int _arg2 = (long int) (arg2); \
182 register long int __s0 asm ("$16") __attribute__ ((unused)) \
206183 = (number); \
207 register long __v0 asm ("$2"); \
208 register long __a0 asm ("$4") = (long) (arg1); \
209 register long __a1 asm ("$5") = (long) (arg2); \
210 register long __a3 asm ("$7"); \
184 register long int __v0 asm ("$2"); \
185 register long int __a0 asm ("$4") = _arg1; \
186 register long int __a1 asm ("$5") = _arg2; \
187 register long int __a3 asm ("$7"); \
211188 __asm__ volatile ( \
212189 ".set\tnoreorder\n\t" \
213190 v0_init \
......@@ -216,8 +193,7 @@ union __mips_syscall_return
216193 : "=r" (__v0), "=r" (__a3) \
217194 : input, "r" (__a0), "r" (__a1) \
218195 : __SYSCALL_CLOBBERS); \
219 err = __a3; \
220 _sys_result = __v0; \
196 _sys_result = __a3 != 0 ? -__v0 : __v0; \
221197 } \
222198 _sys_result; \
223199})
......@@ -225,16 +201,19 @@ union __mips_syscall_return
225201#define internal_syscall3(v0_init, input, number, err, \
226202 arg1, arg2, arg3) \
227203({ \
228 long _sys_result; \
204 long int _sys_result; \
229205 \
230206 { \
231 register long __s0 asm ("$16") __attribute__ ((unused)) \
207 long int _arg1 = (long int) (arg1); \
208 long int _arg2 = (long int) (arg2); \
209 long int _arg3 = (long int) (arg3); \
210 register long int __s0 asm ("$16") __attribute__ ((unused)) \
232211 = (number); \
233 register long __v0 asm ("$2"); \
234 register long __a0 asm ("$4") = (long) (arg1); \
235 register long __a1 asm ("$5") = (long) (arg2); \
236 register long __a2 asm ("$6") = (long) (arg3); \
237 register long __a3 asm ("$7"); \
212 register long int __v0 asm ("$2"); \
213 register long int __a0 asm ("$4") = _arg1; \
214 register long int __a1 asm ("$5") = _arg2; \
215 register long int __a2 asm ("$6") = _arg3; \
216 register long int __a3 asm ("$7"); \
238217 __asm__ volatile ( \
239218 ".set\tnoreorder\n\t" \
240219 v0_init \
......@@ -243,8 +222,7 @@ union __mips_syscall_return
243222 : "=r" (__v0), "=r" (__a3) \
244223 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
245224 : __SYSCALL_CLOBBERS); \
246 err = __a3; \
247 _sys_result = __v0; \
225 _sys_result = __a3 != 0 ? -__v0 : __v0; \
248226 } \
249227 _sys_result; \
250228})
......@@ -252,16 +230,20 @@ union __mips_syscall_return
252230#define internal_syscall4(v0_init, input, number, err, \
253231 arg1, arg2, arg3, arg4) \
254232({ \
255 long _sys_result; \
233 long int _sys_result; \
256234 \
257235 { \
258 register long __s0 asm ("$16") __attribute__ ((unused)) \
236 long int _arg1 = (long int) (arg1); \
237 long int _arg2 = (long int) (arg2); \
238 long int _arg3 = (long int) (arg3); \
239 long int _arg4 = (long int) (arg4); \
240 register long int __s0 asm ("$16") __attribute__ ((unused)) \
259241 = (number); \
260 register long __v0 asm ("$2"); \
261 register long __a0 asm ("$4") = (long) (arg1); \
262 register long __a1 asm ("$5") = (long) (arg2); \
263 register long __a2 asm ("$6") = (long) (arg3); \
264 register long __a3 asm ("$7") = (long) (arg4); \
242 register long int __v0 asm ("$2"); \
243 register long int __a0 asm ("$4") = _arg1; \
244 register long int __a1 asm ("$5") = _arg2; \
245 register long int __a2 asm ("$6") = _arg3; \
246 register long int __a3 asm ("$7") = _arg4; \
265247 __asm__ volatile ( \
266248 ".set\tnoreorder\n\t" \
267249 v0_init \
......@@ -270,8 +252,7 @@ union __mips_syscall_return
270252 : "=r" (__v0), "+r" (__a3) \
271253 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
272254 : __SYSCALL_CLOBBERS); \
273 err = __a3; \
274 _sys_result = __v0; \
255 _sys_result = __a3 != 0 ? -__v0 : __v0; \
275256 } \
276257 _sys_result; \
277258})
......@@ -285,65 +266,65 @@ union __mips_syscall_return
285266 compiler specifics required for the stack arguments to be pushed,
286267 which would be the case if these syscalls were inlined. */
287268
288long long __nomips16 __mips_syscall5 (long arg1, long arg2, long arg3,
289 long arg4, long arg5,
290 long number);
269long long int __nomips16 __mips_syscall5 (long int arg1, long int arg2,
270 long int arg3, long int arg4,
271 long int arg5,
272 long int number);
291273libc_hidden_proto (__mips_syscall5, nomips16)
292274
293275#define internal_syscall5(v0_init, input, number, err, \
294276 arg1, arg2, arg3, arg4, arg5) \
295277({ \
296278 union __mips_syscall_return _sc_ret; \
297 _sc_ret.val = __mips_syscall5 ((long) (arg1), \
298 (long) (arg2), \
299 (long) (arg3), \
300 (long) (arg4), \
301 (long) (arg5), \
302 (long) (number)); \
303 err = _sc_ret.reg.v1; \
304 _sc_ret.reg.v0; \
279 _sc_ret.val = __mips_syscall5 ((long int) (arg1), \
280 (long int) (arg2), \
281 (long int) (arg3), \
282 (long int) (arg4), \
283 (long int) (arg5), \
284 (long int) (number)); \
285 _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \
305286})
306287
307long long __nomips16 __mips_syscall6 (long arg1, long arg2, long arg3,
308 long arg4, long arg5, long arg6,
309 long number);
288long long int __nomips16 __mips_syscall6 (long int arg1, long int arg2,
289 long int arg3, long int arg4,
290 long int arg5, long int arg6,
291 long int number);
310292libc_hidden_proto (__mips_syscall6, nomips16)
311293
312294#define internal_syscall6(v0_init, input, number, err, \
313295 arg1, arg2, arg3, arg4, arg5, arg6) \
314296({ \
315297 union __mips_syscall_return _sc_ret; \
316 _sc_ret.val = __mips_syscall6 ((long) (arg1), \
317 (long) (arg2), \
318 (long) (arg3), \
319 (long) (arg4), \
320 (long) (arg5), \
321 (long) (arg6), \
322 (long) (number)); \
323 err = _sc_ret.reg.v1; \
324 _sc_ret.reg.v0; \
298 _sc_ret.val = __mips_syscall6 ((long int) (arg1), \
299 (long int) (arg2), \
300 (long int) (arg3), \
301 (long int) (arg4), \
302 (long int) (arg5), \
303 (long int) (arg6), \
304 (long int) (number)); \
305 _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \
325306})
326307
327long long __nomips16 __mips_syscall7 (long arg1, long arg2, long arg3,
328 long arg4, long arg5, long arg6,
329 long arg7,
330 long number);
308long long int __nomips16 __mips_syscall7 (long int arg1, long int arg2,
309 long int arg3, long int arg4,
310 long int arg5, long int arg6,
311 long int arg7,
312 long int number);
331313libc_hidden_proto (__mips_syscall7, nomips16)
332314
333315#define internal_syscall7(v0_init, input, number, err, \
334316 arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
335317({ \
336318 union __mips_syscall_return _sc_ret; \
337 _sc_ret.val = __mips_syscall7 ((long) (arg1), \
338 (long) (arg2), \
339 (long) (arg3), \
340 (long) (arg4), \
341 (long) (arg5), \
342 (long) (arg6), \
343 (long) (arg7), \
344 (long) (number)); \
345 err = _sc_ret.reg.v1; \
346 _sc_ret.reg.v0; \
319 _sc_ret.val = __mips_syscall7 ((long int) (arg1), \
320 (long int) (arg2), \
321 (long int) (arg3), \
322 (long int) (arg4), \
323 (long int) (arg5), \
324 (long int) (arg6), \
325 (long int) (arg7), \
326 (long int) (number)); \
327 _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \
347328})
348329
349330#if __mips_isa_rev >= 6
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h deleted-311
......@@ -1,311 +0,0 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_MIPS_SYSDEP_H
19#define _LINUX_MIPS_SYSDEP_H 1
20
21/* There is some commonality. */
22#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
23#include <sysdeps/unix/sysv/linux/sysdep.h>
24#include <sysdeps/unix/mips/mips64/n32/sysdep.h>
25
26#include <tls.h>
27
28/* In order to get __set_errno() definition in INLINE_SYSCALL. */
29#ifndef __ASSEMBLER__
30#include <errno.h>
31#endif
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37#undef SYS_ify
38#define SYS_ify(syscall_name) __NR_##syscall_name
39
40#ifdef __ASSEMBLER__
41
42/* We don't want the label for the error handler to be visible in the symbol
43 table when we define it here. */
44# define SYSCALL_ERROR_LABEL 99b
45
46#else /* ! __ASSEMBLER__ */
47
48/* Convert X to a long long, without losing any bits if it is one
49 already or warning if it is a 32-bit pointer. */
50#define ARGIFY(X) ((long long) (__typeof__ ((X) - (X))) (X))
51
52/* Define a macro which expands into the inline wrapper code for a system
53 call. */
54#undef INLINE_SYSCALL
55#define INLINE_SYSCALL(name, nr, args...) \
56 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
57 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
58 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
59 { \
60 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
61 result_var = -1L; \
62 } \
63 result_var; })
64
65#undef INTERNAL_SYSCALL_DECL
66#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
67
68#undef INTERNAL_SYSCALL_ERROR_P
69#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
70
71#undef INTERNAL_SYSCALL_ERRNO
72#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
73
74/* Note that the original Linux syscall restart convention required the
75 instruction immediately preceding SYSCALL to initialize $v0 with the
76 syscall number. Then if a restart triggered, $v0 would have been
77 clobbered by the syscall interrupted, and needed to be reinititalized.
78 The kernel would decrement the PC by 4 before switching back to the
79 user mode so that $v0 had been reloaded before SYSCALL was executed
80 again. This implied the place $v0 was loaded from must have been
81 preserved across a syscall, e.g. an immediate, static register, stack
82 slot, etc.
83
84 The convention was relaxed in Linux with a change applied to the kernel
85 GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
86 first appeared in the 2.6.36 release. Since then the kernel has had
87 code that reloads $v0 upon syscall restart and resumes right at the
88 SYSCALL instruction, so no special arrangement is needed anymore.
89
90 For backwards compatibility with existing kernel binaries we support
91 the old convention by choosing the instruction preceding SYSCALL
92 carefully. This also means we have to force a 32-bit encoding of the
93 microMIPS MOVE instruction if one is used. */
94
95#ifdef __mips_micromips
96# define MOVE32 "move32"
97#else
98# define MOVE32 "move"
99#endif
100
101#undef INTERNAL_SYSCALL
102#define INTERNAL_SYSCALL(name, err, nr, args...) \
103 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
104 "IK" (SYS_ify (name)), \
105 0, err, args)
106
107#undef INTERNAL_SYSCALL_NCS
108#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
109 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
110 "r" (__s0), \
111 number, err, args)
112
113#define internal_syscall0(v0_init, input, number, err, dummy...) \
114({ \
115 long _sys_result; \
116 \
117 { \
118 register long long __s0 asm ("$16") __attribute__ ((unused)) \
119 = (number); \
120 register long long __v0 asm ("$2"); \
121 register long long __a3 asm ("$7"); \
122 __asm__ volatile ( \
123 ".set\tnoreorder\n\t" \
124 v0_init \
125 "syscall\n\t" \
126 ".set reorder" \
127 : "=r" (__v0), "=r" (__a3) \
128 : input \
129 : __SYSCALL_CLOBBERS); \
130 err = __a3; \
131 _sys_result = __v0; \
132 } \
133 _sys_result; \
134})
135
136#define internal_syscall1(v0_init, input, number, err, arg1) \
137({ \
138 long _sys_result; \
139 \
140 { \
141 register long long __s0 asm ("$16") __attribute__ ((unused)) \
142 = (number); \
143 register long long __v0 asm ("$2"); \
144 register long long __a0 asm ("$4") = ARGIFY (arg1); \
145 register long long __a3 asm ("$7"); \
146 __asm__ volatile ( \
147 ".set\tnoreorder\n\t" \
148 v0_init \
149 "syscall\n\t" \
150 ".set reorder" \
151 : "=r" (__v0), "=r" (__a3) \
152 : input, "r" (__a0) \
153 : __SYSCALL_CLOBBERS); \
154 err = __a3; \
155 _sys_result = __v0; \
156 } \
157 _sys_result; \
158})
159
160#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
161({ \
162 long _sys_result; \
163 \
164 { \
165 register long long __s0 asm ("$16") __attribute__ ((unused)) \
166 = (number); \
167 register long long __v0 asm ("$2"); \
168 register long long __a0 asm ("$4") = ARGIFY (arg1); \
169 register long long __a1 asm ("$5") = ARGIFY (arg2); \
170 register long long __a3 asm ("$7"); \
171 __asm__ volatile ( \
172 ".set\tnoreorder\n\t" \
173 v0_init \
174 "syscall\n\t" \
175 ".set\treorder" \
176 : "=r" (__v0), "=r" (__a3) \
177 : input, "r" (__a0), "r" (__a1) \
178 : __SYSCALL_CLOBBERS); \
179 err = __a3; \
180 _sys_result = __v0; \
181 } \
182 _sys_result; \
183})
184
185#define internal_syscall3(v0_init, input, number, err, \
186 arg1, arg2, arg3) \
187({ \
188 long _sys_result; \
189 \
190 { \
191 register long long __s0 asm ("$16") __attribute__ ((unused)) \
192 = (number); \
193 register long long __v0 asm ("$2"); \
194 register long long __a0 asm ("$4") = ARGIFY (arg1); \
195 register long long __a1 asm ("$5") = ARGIFY (arg2); \
196 register long long __a2 asm ("$6") = ARGIFY (arg3); \
197 register long long __a3 asm ("$7"); \
198 __asm__ volatile ( \
199 ".set\tnoreorder\n\t" \
200 v0_init \
201 "syscall\n\t" \
202 ".set\treorder" \
203 : "=r" (__v0), "=r" (__a3) \
204 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
205 : __SYSCALL_CLOBBERS); \
206 err = __a3; \
207 _sys_result = __v0; \
208 } \
209 _sys_result; \
210})
211
212#define internal_syscall4(v0_init, input, number, err, \
213 arg1, arg2, arg3, arg4) \
214({ \
215 long _sys_result; \
216 \
217 { \
218 register long long __s0 asm ("$16") __attribute__ ((unused)) \
219 = (number); \
220 register long long __v0 asm ("$2"); \
221 register long long __a0 asm ("$4") = ARGIFY (arg1); \
222 register long long __a1 asm ("$5") = ARGIFY (arg2); \
223 register long long __a2 asm ("$6") = ARGIFY (arg3); \
224 register long long __a3 asm ("$7") = ARGIFY (arg4); \
225 __asm__ volatile ( \
226 ".set\tnoreorder\n\t" \
227 v0_init \
228 "syscall\n\t" \
229 ".set\treorder" \
230 : "=r" (__v0), "+r" (__a3) \
231 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
232 : __SYSCALL_CLOBBERS); \
233 err = __a3; \
234 _sys_result = __v0; \
235 } \
236 _sys_result; \
237})
238
239#define internal_syscall5(v0_init, input, number, err, \
240 arg1, arg2, arg3, arg4, arg5) \
241({ \
242 long _sys_result; \
243 \
244 { \
245 register long long __s0 asm ("$16") __attribute__ ((unused)) \
246 = (number); \
247 register long long __v0 asm ("$2"); \
248 register long long __a0 asm ("$4") = ARGIFY (arg1); \
249 register long long __a1 asm ("$5") = ARGIFY (arg2); \
250 register long long __a2 asm ("$6") = ARGIFY (arg3); \
251 register long long __a3 asm ("$7") = ARGIFY (arg4); \
252 register long long __a4 asm ("$8") = ARGIFY (arg5); \
253 __asm__ volatile ( \
254 ".set\tnoreorder\n\t" \
255 v0_init \
256 "syscall\n\t" \
257 ".set\treorder" \
258 : "=r" (__v0), "+r" (__a3) \
259 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
260 : __SYSCALL_CLOBBERS); \
261 err = __a3; \
262 _sys_result = __v0; \
263 } \
264 _sys_result; \
265})
266
267#define internal_syscall6(v0_init, input, number, err, \
268 arg1, arg2, arg3, arg4, arg5, arg6) \
269({ \
270 long _sys_result; \
271 \
272 { \
273 register long long __s0 asm ("$16") __attribute__ ((unused)) \
274 = (number); \
275 register long long __v0 asm ("$2"); \
276 register long long __a0 asm ("$4") = ARGIFY (arg1); \
277 register long long __a1 asm ("$5") = ARGIFY (arg2); \
278 register long long __a2 asm ("$6") = ARGIFY (arg3); \
279 register long long __a3 asm ("$7") = ARGIFY (arg4); \
280 register long long __a4 asm ("$8") = ARGIFY (arg5); \
281 register long long __a5 asm ("$9") = ARGIFY (arg6); \
282 __asm__ volatile ( \
283 ".set\tnoreorder\n\t" \
284 v0_init \
285 "syscall\n\t" \
286 ".set\treorder" \
287 : "=r" (__v0), "+r" (__a3) \
288 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
289 "r" (__a5) \
290 : __SYSCALL_CLOBBERS); \
291 err = __a3; \
292 _sys_result = __v0; \
293 } \
294 _sys_result; \
295})
296
297#if __mips_isa_rev >= 6
298# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
299 "$14", "$15", "$24", "$25", "memory"
300#else
301# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
302 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
303#endif
304
305#endif /* __ASSEMBLER__ */
306
307/* Pointer mangling is not yet supported for MIPS. */
308#define PTR_MANGLE(var) (void) (var)
309#define PTR_DEMANGLE(var) (void) (var)
310
311#endif /* linux/mips/sysdep.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h deleted-307
......@@ -1,307 +0,0 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library. If not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_MIPS_SYSDEP_H
19#define _LINUX_MIPS_SYSDEP_H 1
20
21/* There is some commonality. */
22#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
23#include <sysdeps/unix/sysv/linux/sysdep.h>
24#include <sysdeps/unix/mips/mips64/n64/sysdep.h>
25
26#include <tls.h>
27
28/* In order to get __set_errno() definition in INLINE_SYSCALL. */
29#ifndef __ASSEMBLER__
30#include <errno.h>
31#endif
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37#undef SYS_ify
38#define SYS_ify(syscall_name) __NR_##syscall_name
39
40#ifdef __ASSEMBLER__
41
42/* We don't want the label for the error handler to be visible in the symbol
43 table when we define it here. */
44# define SYSCALL_ERROR_LABEL 99b
45
46#else /* ! __ASSEMBLER__ */
47
48/* Define a macro which expands into the inline wrapper code for a system
49 call. */
50#undef INLINE_SYSCALL
51#define INLINE_SYSCALL(name, nr, args...) \
52 ({ INTERNAL_SYSCALL_DECL (_sc_err); \
53 long result_var = INTERNAL_SYSCALL (name, _sc_err, nr, args); \
54 if ( INTERNAL_SYSCALL_ERROR_P (result_var, _sc_err) ) \
55 { \
56 __set_errno (INTERNAL_SYSCALL_ERRNO (result_var, _sc_err)); \
57 result_var = -1L; \
58 } \
59 result_var; })
60
61#undef INTERNAL_SYSCALL_DECL
62#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused))
63
64#undef INTERNAL_SYSCALL_ERROR_P
65#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err))
66
67#undef INTERNAL_SYSCALL_ERRNO
68#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val)
69
70/* Note that the original Linux syscall restart convention required the
71 instruction immediately preceding SYSCALL to initialize $v0 with the
72 syscall number. Then if a restart triggered, $v0 would have been
73 clobbered by the syscall interrupted, and needed to be reinititalized.
74 The kernel would decrement the PC by 4 before switching back to the
75 user mode so that $v0 had been reloaded before SYSCALL was executed
76 again. This implied the place $v0 was loaded from must have been
77 preserved across a syscall, e.g. an immediate, static register, stack
78 slot, etc.
79
80 The convention was relaxed in Linux with a change applied to the kernel
81 GIT repository as commit 96187fb0bc30cd7919759d371d810e928048249d, that
82 first appeared in the 2.6.36 release. Since then the kernel has had
83 code that reloads $v0 upon syscall restart and resumes right at the
84 SYSCALL instruction, so no special arrangement is needed anymore.
85
86 For backwards compatibility with existing kernel binaries we support
87 the old convention by choosing the instruction preceding SYSCALL
88 carefully. This also means we have to force a 32-bit encoding of the
89 microMIPS MOVE instruction if one is used. */
90
91#ifdef __mips_micromips
92# define MOVE32 "move32"
93#else
94# define MOVE32 "move"
95#endif
96
97#undef INTERNAL_SYSCALL
98#define INTERNAL_SYSCALL(name, err, nr, args...) \
99 internal_syscall##nr ("li\t%0, %2\t\t\t# " #name "\n\t", \
100 "IK" (SYS_ify (name)), \
101 0, err, args)
102
103#undef INTERNAL_SYSCALL_NCS
104#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
105 internal_syscall##nr (MOVE32 "\t%0, %2\n\t", \
106 "r" (__s0), \
107 number, err, args)
108
109#define internal_syscall0(v0_init, input, number, err, dummy...) \
110({ \
111 long _sys_result; \
112 \
113 { \
114 register long __s0 asm ("$16") __attribute__ ((unused)) \
115 = (number); \
116 register long __v0 asm ("$2"); \
117 register long __a3 asm ("$7"); \
118 __asm__ volatile ( \
119 ".set\tnoreorder\n\t" \
120 v0_init \
121 "syscall\n\t" \
122 ".set reorder" \
123 : "=r" (__v0), "=r" (__a3) \
124 : input \
125 : __SYSCALL_CLOBBERS); \
126 err = __a3; \
127 _sys_result = __v0; \
128 } \
129 _sys_result; \
130})
131
132#define internal_syscall1(v0_init, input, number, err, arg1) \
133({ \
134 long _sys_result; \
135 \
136 { \
137 register long __s0 asm ("$16") __attribute__ ((unused)) \
138 = (number); \
139 register long __v0 asm ("$2"); \
140 register long __a0 asm ("$4") = (long) (arg1); \
141 register long __a3 asm ("$7"); \
142 __asm__ volatile ( \
143 ".set\tnoreorder\n\t" \
144 v0_init \
145 "syscall\n\t" \
146 ".set reorder" \
147 : "=r" (__v0), "=r" (__a3) \
148 : input, "r" (__a0) \
149 : __SYSCALL_CLOBBERS); \
150 err = __a3; \
151 _sys_result = __v0; \
152 } \
153 _sys_result; \
154})
155
156#define internal_syscall2(v0_init, input, number, err, arg1, arg2) \
157({ \
158 long _sys_result; \
159 \
160 { \
161 register long __s0 asm ("$16") __attribute__ ((unused)) \
162 = (number); \
163 register long __v0 asm ("$2"); \
164 register long __a0 asm ("$4") = (long) (arg1); \
165 register long __a1 asm ("$5") = (long) (arg2); \
166 register long __a3 asm ("$7"); \
167 __asm__ volatile ( \
168 ".set\tnoreorder\n\t" \
169 v0_init \
170 "syscall\n\t" \
171 ".set\treorder" \
172 : "=r" (__v0), "=r" (__a3) \
173 : input, "r" (__a0), "r" (__a1) \
174 : __SYSCALL_CLOBBERS); \
175 err = __a3; \
176 _sys_result = __v0; \
177 } \
178 _sys_result; \
179})
180
181#define internal_syscall3(v0_init, input, number, err, \
182 arg1, arg2, arg3) \
183({ \
184 long _sys_result; \
185 \
186 { \
187 register long __s0 asm ("$16") __attribute__ ((unused)) \
188 = (number); \
189 register long __v0 asm ("$2"); \
190 register long __a0 asm ("$4") = (long) (arg1); \
191 register long __a1 asm ("$5") = (long) (arg2); \
192 register long __a2 asm ("$6") = (long) (arg3); \
193 register long __a3 asm ("$7"); \
194 __asm__ volatile ( \
195 ".set\tnoreorder\n\t" \
196 v0_init \
197 "syscall\n\t" \
198 ".set\treorder" \
199 : "=r" (__v0), "=r" (__a3) \
200 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
201 : __SYSCALL_CLOBBERS); \
202 err = __a3; \
203 _sys_result = __v0; \
204 } \
205 _sys_result; \
206})
207
208#define internal_syscall4(v0_init, input, number, err, \
209 arg1, arg2, arg3, arg4) \
210({ \
211 long _sys_result; \
212 \
213 { \
214 register long __s0 asm ("$16") __attribute__ ((unused)) \
215 = (number); \
216 register long __v0 asm ("$2"); \
217 register long __a0 asm ("$4") = (long) (arg1); \
218 register long __a1 asm ("$5") = (long) (arg2); \
219 register long __a2 asm ("$6") = (long) (arg3); \
220 register long __a3 asm ("$7") = (long) (arg4); \
221 __asm__ volatile ( \
222 ".set\tnoreorder\n\t" \
223 v0_init \
224 "syscall\n\t" \
225 ".set\treorder" \
226 : "=r" (__v0), "+r" (__a3) \
227 : input, "r" (__a0), "r" (__a1), "r" (__a2) \
228 : __SYSCALL_CLOBBERS); \
229 err = __a3; \
230 _sys_result = __v0; \
231 } \
232 _sys_result; \
233})
234
235#define internal_syscall5(v0_init, input, number, err, \
236 arg1, arg2, arg3, arg4, arg5) \
237({ \
238 long _sys_result; \
239 \
240 { \
241 register long __s0 asm ("$16") __attribute__ ((unused)) \
242 = (number); \
243 register long __v0 asm ("$2"); \
244 register long __a0 asm ("$4") = (long) (arg1); \
245 register long __a1 asm ("$5") = (long) (arg2); \
246 register long __a2 asm ("$6") = (long) (arg3); \
247 register long __a3 asm ("$7") = (long) (arg4); \
248 register long __a4 asm ("$8") = (long) (arg5); \
249 __asm__ volatile ( \
250 ".set\tnoreorder\n\t" \
251 v0_init \
252 "syscall\n\t" \
253 ".set\treorder" \
254 : "=r" (__v0), "+r" (__a3) \
255 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \
256 : __SYSCALL_CLOBBERS); \
257 err = __a3; \
258 _sys_result = __v0; \
259 } \
260 _sys_result; \
261})
262
263#define internal_syscall6(v0_init, input, number, err, \
264 arg1, arg2, arg3, arg4, arg5, arg6) \
265({ \
266 long _sys_result; \
267 \
268 { \
269 register long __s0 asm ("$16") __attribute__ ((unused)) \
270 = (number); \
271 register long __v0 asm ("$2"); \
272 register long __a0 asm ("$4") = (long) (arg1); \
273 register long __a1 asm ("$5") = (long) (arg2); \
274 register long __a2 asm ("$6") = (long) (arg3); \
275 register long __a3 asm ("$7") = (long) (arg4); \
276 register long __a4 asm ("$8") = (long) (arg5); \
277 register long __a5 asm ("$9") = (long) (arg6); \
278 __asm__ volatile ( \
279 ".set\tnoreorder\n\t" \
280 v0_init \
281 "syscall\n\t" \
282 ".set\treorder" \
283 : "=r" (__v0), "+r" (__a3) \
284 : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \
285 "r" (__a5) \
286 : __SYSCALL_CLOBBERS); \
287 err = __a3; \
288 _sys_result = __v0; \
289 } \
290 _sys_result; \
291})
292
293#if __mips_isa_rev >= 6
294# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
295 "$14", "$15", "$24", "$25", "memory"
296#else
297# define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
298 "$14", "$15", "$24", "$25", "hi", "lo", "memory"
299#endif
300
301#endif /* __ASSEMBLER__ */
302
303/* Pointer mangling is not yet supported for MIPS. */
304#define PTR_MANGLE(var) (void) (var)
305#define PTR_DEMANGLE(var) (void) (var)
306
307#endif /* linux/mips/sysdep.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/mips/xstatver.h created+13
......@@ -0,0 +1,13 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_LINUX_OLD 1
4#define _STAT_VER_KERNEL 1
5#define _STAT_VER_SVR4 2
6#define _STAT_VER_LINUX 3
7#define _STAT_VER _STAT_VER_LINUX
8
9/* Versions of the 'xmknod' interface used in compatibility xmknod
10 functions. */
11#define _MKNOD_VER_LINUX 1
12#define _MKNOD_VER_SVR4 2
13#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/bits/stat.h deleted-275
......@@ -1,275 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/wordsize.h>
26
27/* Versions of the `struct stat' data structure. */
28#define _STAT_VER_LINUX_OLD 1
29#define _STAT_VER_KERNEL 1
30#define _STAT_VER_SVR4 2
31#define _STAT_VER_LINUX 3
32#if __WORDSIZE == 32
33# define _STAT_VER _STAT_VER_LINUX
34#else
35# define _STAT_VER _STAT_VER_KERNEL
36#endif
37
38/* Versions of the `xmknod' interface. */
39#define _MKNOD_VER_LINUX 1
40#define _MKNOD_VER_SVR4 2
41#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
42
43
44#if __WORDSIZE == 32
45
46struct stat
47 {
48 __dev_t st_dev; /* Device. */
49# ifndef __USE_FILE_OFFSET64
50 unsigned short int __pad1;
51 __ino_t st_ino; /* File serial number. */
52# else
53 __ino64_t st_ino; /* File serial number. */
54# endif
55 __mode_t st_mode; /* File mode. */
56 __nlink_t st_nlink; /* Link count. */
57 __uid_t st_uid; /* User ID of the file's owner. */
58 __gid_t st_gid; /* Group ID of the file's group.*/
59 __dev_t st_rdev; /* Device number, if device. */
60 unsigned short int __pad2;
61# ifndef __USE_FILE_OFFSET64
62 __off_t st_size; /* Size of file, in bytes. */
63# else
64 __off64_t st_size; /* Size of file, in bytes. */
65# endif
66 __blksize_t st_blksize; /* Optimal block size for I/O. */
67
68# ifndef __USE_FILE_OFFSET64
69 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
70# else
71 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
72# endif
73# ifdef __USE_XOPEN2K8
74 /* Nanosecond resolution timestamps are stored in a format
75 equivalent to 'struct timespec'. This is the type used
76 whenever possible but the Unix namespace rules do not allow the
77 identifier 'timespec' to appear in the <sys/stat.h> header.
78 Therefore we have to handle the use of this header in strictly
79 standard-compliant sources special. */
80 struct timespec st_atim; /* Time of last access. */
81 struct timespec st_mtim; /* Time of last modification. */
82 struct timespec st_ctim; /* Time of last status change. */
83# define st_atime st_atim.tv_sec /* Backward compatibility. */
84# define st_mtime st_mtim.tv_sec
85# define st_ctime st_ctim.tv_sec
86# else
87 __time_t st_atime; /* Time of last access. */
88 unsigned long int st_atimensec; /* Nscecs of last access. */
89 __time_t st_mtime; /* Time of last modification. */
90 unsigned long int st_mtimensec; /* Nsecs of last modification. */
91 __time_t st_ctime; /* Time of last status change. */
92 unsigned long int st_ctimensec; /* Nsecs of last status change. */
93# endif
94 unsigned long int __glibc_reserved4;
95 unsigned long int __glibc_reserved5;
96 };
97
98
99# ifdef __USE_LARGEFILE64
100struct stat64
101 {
102 __dev_t st_dev; /* Device. */
103 __ino64_t st_ino; /* File serial number. */
104 __mode_t st_mode; /* File mode. */
105 __nlink_t st_nlink; /* Link count. */
106 __uid_t st_uid; /* User ID of the file's owner. */
107 __gid_t st_gid; /* Group ID of the file's group.*/
108 __dev_t st_rdev; /* Device number, if device. */
109 unsigned short int __pad2;
110 __off64_t st_size; /* Size of file, in bytes. */
111 __blksize_t st_blksize; /* Optimal block size for I/O. */
112 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
113# ifdef __USE_XOPEN2K8
114 /* Nanosecond resolution timestamps are stored in a format
115 equivalent to 'struct timespec'. This is the type used
116 whenever possible but the Unix namespace rules do not allow the
117 identifier 'timespec' to appear in the <sys/stat.h> header.
118 Therefore we have to handle the use of this header in strictly
119 standard-compliant sources special. */
120 struct timespec st_atim; /* Time of last access. */
121 struct timespec st_mtim; /* Time of last modification. */
122 struct timespec st_ctim; /* Time of last status change. */
123# define st_atime st_atim.tv_sec /* Backward compatibility. */
124# define st_mtime st_mtim.tv_sec
125# define st_ctime st_ctim.tv_sec
126# else
127 __time_t st_atime; /* Time of last access. */
128 unsigned long int st_atimensec; /* Nscecs of last access. */
129 __time_t st_mtime; /* Time of last modification. */
130 unsigned long int st_mtimensec; /* Nsecs of last modification. */
131 __time_t st_ctime; /* Time of last status change. */
132 unsigned long int st_ctimensec; /* Nsecs of last status change. */
133# endif
134 unsigned long int __glibc_reserved4;
135 unsigned long int __glibc_reserved5;
136 };
137# endif /* __USE_LARGEFILE64 */
138
139#else /* __WORDSIZE == 32 */
140
141struct stat
142 {
143 __dev_t st_dev; /* Device. */
144# ifndef __USE_FILE_OFFSET64
145 __ino_t st_ino; /* File serial number. */
146# else
147 __ino64_t st_ino; /* File serial number. */
148# endif
149 __nlink_t st_nlink; /* Link count. */
150 __mode_t st_mode; /* File mode. */
151 __uid_t st_uid; /* User ID of the file's owner. */
152 __gid_t st_gid; /* Group ID of the file's group.*/
153 int __pad2;
154 __dev_t st_rdev; /* Device number, if device. */
155# ifndef __USE_FILE_OFFSET64
156 __off_t st_size; /* Size of file, in bytes. */
157# else
158 __off64_t st_size; /* Size of file, in bytes. */
159# endif
160 __blksize_t st_blksize; /* Optimal block size for I/O. */
161
162# ifndef __USE_FILE_OFFSET64
163 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
164# else
165 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
166# endif
167# ifdef __USE_XOPEN2K8
168 /* Nanosecond resolution timestamps are stored in a format
169 equivalent to 'struct timespec'. This is the type used
170 whenever possible but the Unix namespace rules do not allow the
171 identifier 'timespec' to appear in the <sys/stat.h> header.
172 Therefore we have to handle the use of this header in strictly
173 standard-compliant sources special. */
174 struct timespec st_atim; /* Time of last access. */
175 struct timespec st_mtim; /* Time of last modification. */
176 struct timespec st_ctim; /* Time of last status change. */
177# define st_atime st_atim.tv_sec /* Backward compatibility. */
178# define st_mtime st_mtim.tv_sec
179# define st_ctime st_ctim.tv_sec
180# else
181 __time_t st_atime; /* Time of last access. */
182 unsigned long int st_atimensec; /* Nscecs of last access. */
183 __time_t st_mtime; /* Time of last modification. */
184 unsigned long int st_mtimensec; /* Nsecs of last modification. */
185 __time_t st_ctime; /* Time of last status change. */
186 unsigned long int st_ctimensec; /* Nsecs of last status change. */
187# endif
188 unsigned long int __glibc_reserved4;
189 unsigned long int __glibc_reserved5;
190 unsigned long int __glibc_reserved6;
191 };
192
193# ifdef __USE_LARGEFILE64
194struct stat64
195 {
196 __dev_t st_dev; /* Device. */
197 __ino64_t st_ino; /* File serial number. */
198 __nlink_t st_nlink; /* Link count. */
199 __mode_t st_mode; /* File mode. */
200 __uid_t st_uid; /* User ID of the file's owner. */
201 __gid_t st_gid; /* Group ID of the file's group.*/
202 int __pad2;
203 __dev_t st_rdev; /* Device number, if device. */
204 __off64_t st_size; /* Size of file, in bytes. */
205 __blksize_t st_blksize; /* Optimal block size for I/O. */
206 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
207# ifdef __USE_XOPEN2K8
208 /* Nanosecond resolution timestamps are stored in a format
209 equivalent to 'struct timespec'. This is the type used
210 whenever possible but the Unix namespace rules do not allow the
211 identifier 'timespec' to appear in the <sys/stat.h> header.
212 Therefore we have to handle the use of this header in strictly
213 standard-compliant sources special. */
214 struct timespec st_atim; /* Time of last access. */
215 struct timespec st_mtim; /* Time of last modification. */
216 struct timespec st_ctim; /* Time of last status change. */
217# define st_atime st_atim.tv_sec /* Backward compatibility. */
218# define st_mtime st_mtim.tv_sec
219# define st_ctime st_ctim.tv_sec
220# else
221 __time_t st_atime; /* Time of last access. */
222 unsigned long int st_atimensec; /* Nscecs of last access. */
223 __time_t st_mtime; /* Time of last modification. */
224 unsigned long int st_mtimensec; /* Nsecs of last modification. */
225 __time_t st_ctime; /* Time of last status change. */
226 unsigned long int st_ctimensec; /* Nsecs of last status change. */
227# endif
228 unsigned long int __glibc_reserved4;
229 unsigned long int __glibc_reserved5;
230 unsigned long int __glibc_reserved6;
231 };
232# endif /* __USE_LARGEFILE64 */
233#endif
234
235
236/* Tell code we have these members. */
237#define _STATBUF_ST_BLKSIZE
238#define _STATBUF_ST_RDEV
239/* Nanosecond resolution time values are supported. */
240#define _STATBUF_ST_NSEC
241
242/* Encoding of the file mode. */
243
244#define __S_IFMT 0170000 /* These bits determine file type. */
245
246/* File types. */
247#define __S_IFDIR 0040000 /* Directory. */
248#define __S_IFCHR 0020000 /* Character device. */
249#define __S_IFBLK 0060000 /* Block device. */
250#define __S_IFREG 0100000 /* Regular file. */
251#define __S_IFIFO 0010000 /* FIFO. */
252#define __S_IFLNK 0120000 /* Symbolic link. */
253#define __S_IFSOCK 0140000 /* Socket. */
254
255/* POSIX.1b objects. Note that these macros always evaluate to zero. But
256 they do it by enforcing the correct use of the macros. */
257#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
258#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
259#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
260
261/* Protection bits. */
262
263#define __S_ISUID 04000 /* Set user ID on execution. */
264#define __S_ISGID 02000 /* Set group ID on execution. */
265#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
266#define __S_IREAD 0400 /* Read by owner. */
267#define __S_IWRITE 0200 /* Write by owner. */
268#define __S_IEXEC 0100 /* Execute by owner. */
269
270#ifdef __USE_ATFILE
271# define UTIME_NOW ((1l << 30) - 1l)
272# define UTIME_OMIT ((1l << 30) - 2l)
273#endif
274
275#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/kernel-features.h+1-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. PowerPC version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -28,8 +28,6 @@
2828#define __ASSUME_SEND_SYSCALL 1
2929#define __ASSUME_RECV_SYSCALL 1
3030#define __ASSUME_SHUTDOWN_SYSCALL 1
31#define __ASSUME_GETSOCKOPT_SYSCALL 1
32#define __ASSUME_SETSOCKOPT_SYSCALL 1
3331
3432/* Define this if your 32-bit syscall API requires 64-bit register
3533 pairs to start with an even-number register. */
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h deleted-214
......@@ -1,214 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef _LINUX_POWERPC_SYSDEP_H
19#define _LINUX_POWERPC_SYSDEP_H 1
20
21#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
22#include <sysdeps/unix/sysv/linux/sysdep.h>
23#include <sysdeps/unix/powerpc/sysdep.h>
24#include <tls.h>
25
26/* For Linux we can use the system call table in the header file
27 /usr/include/asm/unistd.h
28 of the kernel. But these symbols do not follow the SYS_* syntax
29 so we have to redefine the `SYS_ify' macro here. */
30#undef SYS_ify
31#define SYS_ify(syscall_name) __NR_##syscall_name
32
33#ifndef __ASSEMBLER__
34
35# include <errno.h>
36
37/* Define a macro which expands inline into the wrapper code for a VDSO
38 call. This use is for internal calls that do not need to handle errors
39 normally. It will never touch errno.
40 On powerpc a system call basically clobbers the same registers like a
41 function call, with the exception of LR (which is needed for the
42 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
43 an error return status). */
44# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...) \
45 ({ \
46 register void *r0 __asm__ ("r0"); \
47 register long int r3 __asm__ ("r3"); \
48 register long int r4 __asm__ ("r4"); \
49 register long int r5 __asm__ ("r5"); \
50 register long int r6 __asm__ ("r6"); \
51 register long int r7 __asm__ ("r7"); \
52 register long int r8 __asm__ ("r8"); \
53 register long int r9 __asm__ ("r9"); \
54 register long int r10 __asm__ ("r10"); \
55 register long int r11 __asm__ ("r11"); \
56 register long int r12 __asm__ ("r12"); \
57 register type rval __asm__ ("r3"); \
58 LOADARGS_##nr (funcptr, args); \
59 __asm__ __volatile__ \
60 ("mtctr %0\n\t" \
61 "bctrl\n\t" \
62 "mfcr %0" \
63 : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), "+r" (r7), \
64 "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12) \
65 : : "cr0", "ctr", "lr", "memory"); \
66 err = (long int) r0; \
67 __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4)); \
68 rval; \
69 })
70
71#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
72 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
73
74# undef INLINE_SYSCALL
75# define INLINE_SYSCALL(name, nr, args...) \
76 ({ \
77 INTERNAL_SYSCALL_DECL (sc_err); \
78 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
79 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
80 { \
81 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
82 sc_ret = -1L; \
83 } \
84 sc_ret; \
85 })
86
87/* Define a macro which expands inline into the wrapper code for a system
88 call. This use is for internal calls that do not need to handle errors
89 normally. It will never touch errno.
90 On powerpc a system call basically clobbers the same registers like a
91 function call, with the exception of LR (which is needed for the
92 "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
93 an error return status). */
94
95# undef INTERNAL_SYSCALL_DECL
96# define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
97
98# undef INTERNAL_SYSCALL
99# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
100 ({ \
101 register long int r0 __asm__ ("r0"); \
102 register long int r3 __asm__ ("r3"); \
103 register long int r4 __asm__ ("r4"); \
104 register long int r5 __asm__ ("r5"); \
105 register long int r6 __asm__ ("r6"); \
106 register long int r7 __asm__ ("r7"); \
107 register long int r8 __asm__ ("r8"); \
108 register long int r9 __asm__ ("r9"); \
109 register long int r10 __asm__ ("r10"); \
110 register long int r11 __asm__ ("r11"); \
111 register long int r12 __asm__ ("r12"); \
112 LOADARGS_##nr(name, args); \
113 __asm__ __volatile__ \
114 ("sc \n\t" \
115 "mfcr %0" \
116 : "=&r" (r0), \
117 "=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
118 "=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
119 : ASM_INPUT_##nr \
120 : "cr0", "ctr", "memory"); \
121 err = r0; \
122 (int) r3; \
123 })
124# define INTERNAL_SYSCALL(name, err, nr, args...) \
125 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
126
127# undef INTERNAL_SYSCALL_ERROR_P
128# define INTERNAL_SYSCALL_ERROR_P(val, err) \
129 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
130
131# undef INTERNAL_SYSCALL_ERRNO
132# define INTERNAL_SYSCALL_ERRNO(val, err) (val)
133
134# define LOADARGS_0(name, dummy) \
135 r0 = name
136# define LOADARGS_1(name, __arg1) \
137 long int arg1 = (long int) (__arg1); \
138 LOADARGS_0(name, 0); \
139 extern void __illegally_sized_syscall_arg1 (void); \
140 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
141 __illegally_sized_syscall_arg1 (); \
142 r3 = arg1
143# define LOADARGS_2(name, __arg1, __arg2) \
144 long int arg2 = (long int) (__arg2); \
145 LOADARGS_1(name, __arg1); \
146 extern void __illegally_sized_syscall_arg2 (void); \
147 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
148 __illegally_sized_syscall_arg2 (); \
149 r4 = arg2
150# define LOADARGS_3(name, __arg1, __arg2, __arg3) \
151 long int arg3 = (long int) (__arg3); \
152 LOADARGS_2(name, __arg1, __arg2); \
153 extern void __illegally_sized_syscall_arg3 (void); \
154 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
155 __illegally_sized_syscall_arg3 (); \
156 r5 = arg3
157# define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
158 long int arg4 = (long int) (__arg4); \
159 LOADARGS_3(name, __arg1, __arg2, __arg3); \
160 extern void __illegally_sized_syscall_arg4 (void); \
161 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
162 __illegally_sized_syscall_arg4 (); \
163 r6 = arg4
164# define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
165 long int arg5 = (long int) (__arg5); \
166 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
167 extern void __illegally_sized_syscall_arg5 (void); \
168 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
169 __illegally_sized_syscall_arg5 (); \
170 r7 = arg5
171# define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
172 long int arg6 = (long int) (__arg6); \
173 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
174 extern void __illegally_sized_syscall_arg6 (void); \
175 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
176 __illegally_sized_syscall_arg6 (); \
177 r8 = arg6
178
179# define ASM_INPUT_0 "0" (r0)
180# define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
181# define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
182# define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
183# define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
184# define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
185# define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
186
187#endif /* __ASSEMBLER__ */
188
189
190/* Pointer mangling support. */
191#if IS_IN (rtld)
192/* We cannot use the thread descriptor because in ld.so we use setjmp
193 earlier than the descriptor is initialized. */
194#else
195# ifdef __ASSEMBLER__
196# define PTR_MANGLE(reg, tmpreg) \
197 lwz tmpreg,POINTER_GUARD(r2); \
198 xor reg,tmpreg,reg
199# define PTR_MANGLE2(reg, tmpreg) \
200 xor reg,tmpreg,reg
201# define PTR_MANGLE3(destreg, reg, tmpreg) \
202 lwz tmpreg,POINTER_GUARD(r2); \
203 xor destreg,tmpreg,reg
204# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
205# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
206# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
207# else
208# define PTR_MANGLE(var) \
209 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
210# define PTR_DEMANGLE(var) PTR_MANGLE (var)
211# endif
212#endif
213
214#endif /* linux/powerpc/powerpc32/sysdep.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h+3-195
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -17,202 +17,10 @@
1717
1818/* Alan Modra <amodra@bigpond.net.au> rewrote the INLINE_SYSCALL macro */
1919
20#ifndef _LINUX_POWERPC_SYSDEP_H
21#define _LINUX_POWERPC_SYSDEP_H 1
20#ifndef _LINUX_POWERPC64_SYSDEP_H
21#define _LINUX_POWERPC64_SYSDEP_H 1
2222
2323#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
24#include <sysdeps/unix/sysv/linux/sysdep.h>
25#include <sysdeps/unix/powerpc/sysdep.h>
26#include <tls.h>
27
28/* Define __set_errno() for INLINE_SYSCALL macro below. */
29#ifndef __ASSEMBLER__
30#include <errno.h>
31#endif
32
33/* For Linux we can use the system call table in the header file
34 /usr/include/asm/unistd.h
35 of the kernel. But these symbols do not follow the SYS_* syntax
36 so we have to redefine the `SYS_ify' macro here. */
37#undef SYS_ify
38#define SYS_ify(syscall_name) __NR_##syscall_name
39
40#ifdef __ASSEMBLER__
41
42/* This seems to always be the case on PPC. */
43# define ALIGNARG(log2) log2
44# define ASM_SIZE_DIRECTIVE(name) .size name,.-name
45
46#endif /* __ASSEMBLER__ */
47
48/* Define a macro which expands inline into the wrapper code for a system
49 call. This use is for internal calls that do not need to handle errors
50 normally. It will never touch errno. This returns just what the kernel
51 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
52 the negation of the return value in the kernel gets reverted. */
53
54#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...) \
55 ({ \
56 register void *r0 __asm__ ("r0"); \
57 register long int r3 __asm__ ("r3"); \
58 register long int r4 __asm__ ("r4"); \
59 register long int r5 __asm__ ("r5"); \
60 register long int r6 __asm__ ("r6"); \
61 register long int r7 __asm__ ("r7"); \
62 register long int r8 __asm__ ("r8"); \
63 register type rval __asm__ ("r3"); \
64 LOADARGS_##nr (funcptr, args); \
65 __asm__ __volatile__ \
66 ("mtctr %0\n\t" \
67 "bctrl\n\t" \
68 "mfcr %0\n\t" \
69 "0:" \
70 : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5), "+r" (r6), \
71 "+r" (r7), "+r" (r8) \
72 : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory"); \
73 err = (long int) r0; \
74 __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3)); \
75 rval; \
76 })
77
78#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
79 INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
80
81/* This version is for kernels that implement system calls that
82 behave like function calls as far as register saving. */
83#undef INLINE_SYSCALL
84#define INLINE_SYSCALL(name, nr, args...) \
85 ({ \
86 INTERNAL_SYSCALL_DECL (sc_err); \
87 long int sc_ret = INTERNAL_SYSCALL (name, sc_err, nr, args); \
88 if (INTERNAL_SYSCALL_ERROR_P (sc_ret, sc_err)) \
89 { \
90 __set_errno (INTERNAL_SYSCALL_ERRNO (sc_ret, sc_err)); \
91 sc_ret = -1L; \
92 } \
93 sc_ret; \
94 })
95
96/* Define a macro which expands inline into the wrapper code for a system
97 call. This use is for internal calls that do not need to handle errors
98 normally. It will never touch errno. This returns just what the kernel
99 gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
100 the negation of the return value in the kernel gets reverted. */
101
102#undef INTERNAL_SYSCALL
103#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
104 ({ \
105 register long int r0 __asm__ ("r0"); \
106 register long int r3 __asm__ ("r3"); \
107 register long int r4 __asm__ ("r4"); \
108 register long int r5 __asm__ ("r5"); \
109 register long int r6 __asm__ ("r6"); \
110 register long int r7 __asm__ ("r7"); \
111 register long int r8 __asm__ ("r8"); \
112 LOADARGS_##nr (name, ##args); \
113 __asm__ __volatile__ \
114 ("sc\n\t" \
115 "mfcr %0\n\t" \
116 "0:" \
117 : "=&r" (r0), \
118 "=&r" (r3), "=&r" (r4), "=&r" (r5), \
119 "=&r" (r6), "=&r" (r7), "=&r" (r8) \
120 : ASM_INPUT_##nr \
121 : "r9", "r10", "r11", "r12", \
122 "cr0", "ctr", "memory"); \
123 err = r0; \
124 r3; \
125 })
126#define INTERNAL_SYSCALL(name, err, nr, args...) \
127 INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
128
129#undef INTERNAL_SYSCALL_DECL
130#define INTERNAL_SYSCALL_DECL(err) long int err __attribute__ ((unused))
131
132#undef INTERNAL_SYSCALL_ERROR_P
133#define INTERNAL_SYSCALL_ERROR_P(val, err) \
134 ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
135
136#undef INTERNAL_SYSCALL_ERRNO
137#define INTERNAL_SYSCALL_ERRNO(val, err) (val)
138
139#define LOADARGS_0(name, dummy) \
140 r0 = name
141#define LOADARGS_1(name, __arg1) \
142 long int arg1 = (long int) (__arg1); \
143 LOADARGS_0(name, 0); \
144 extern void __illegally_sized_syscall_arg1 (void); \
145 if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 8) \
146 __illegally_sized_syscall_arg1 (); \
147 r3 = arg1
148#define LOADARGS_2(name, __arg1, __arg2) \
149 long int arg2 = (long int) (__arg2); \
150 LOADARGS_1(name, __arg1); \
151 extern void __illegally_sized_syscall_arg2 (void); \
152 if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 8) \
153 __illegally_sized_syscall_arg2 (); \
154 r4 = arg2
155#define LOADARGS_3(name, __arg1, __arg2, __arg3) \
156 long int arg3 = (long int) (__arg3); \
157 LOADARGS_2(name, __arg1, __arg2); \
158 extern void __illegally_sized_syscall_arg3 (void); \
159 if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 8) \
160 __illegally_sized_syscall_arg3 (); \
161 r5 = arg3
162#define LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4) \
163 long int arg4 = (long int) (__arg4); \
164 LOADARGS_3(name, __arg1, __arg2, __arg3); \
165 extern void __illegally_sized_syscall_arg4 (void); \
166 if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 8) \
167 __illegally_sized_syscall_arg4 (); \
168 r6 = arg4
169#define LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
170 long int arg5 = (long int) (__arg5); \
171 LOADARGS_4(name, __arg1, __arg2, __arg3, __arg4); \
172 extern void __illegally_sized_syscall_arg5 (void); \
173 if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 8) \
174 __illegally_sized_syscall_arg5 (); \
175 r7 = arg5
176#define LOADARGS_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
177 long int arg6 = (long int) (__arg6); \
178 LOADARGS_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
179 extern void __illegally_sized_syscall_arg6 (void); \
180 if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 8) \
181 __illegally_sized_syscall_arg6 (); \
182 r8 = arg6
183
184#define ASM_INPUT_0 "0" (r0)
185#define ASM_INPUT_1 ASM_INPUT_0, "1" (r3)
186#define ASM_INPUT_2 ASM_INPUT_1, "2" (r4)
187#define ASM_INPUT_3 ASM_INPUT_2, "3" (r5)
188#define ASM_INPUT_4 ASM_INPUT_3, "4" (r6)
189#define ASM_INPUT_5 ASM_INPUT_4, "5" (r7)
190#define ASM_INPUT_6 ASM_INPUT_5, "6" (r8)
191
192
193/* Pointer mangling support. */
194#if IS_IN (rtld)
195/* We cannot use the thread descriptor because in ld.so we use setjmp
196 earlier than the descriptor is initialized. */
197#else
198# ifdef __ASSEMBLER__
199# define PTR_MANGLE(reg, tmpreg) \
200 ld tmpreg,POINTER_GUARD(r13); \
201 xor reg,tmpreg,reg
202# define PTR_MANGLE2(reg, tmpreg) \
203 xor reg,tmpreg,reg
204# define PTR_MANGLE3(destreg, reg, tmpreg) \
205 ld tmpreg,POINTER_GUARD(r13); \
206 xor destreg,tmpreg,reg
207# define PTR_DEMANGLE(reg, tmpreg) PTR_MANGLE (reg, tmpreg)
208# define PTR_DEMANGLE2(reg, tmpreg) PTR_MANGLE2 (reg, tmpreg)
209# define PTR_DEMANGLE3(destreg, reg, tmpreg) PTR_MANGLE3 (destreg, reg, tmpreg)
210# else
211# define PTR_MANGLE(var) \
212 (var) = (__typeof (var)) ((uintptr_t) (var) ^ THREAD_GET_POINTER_GUARD ())
213# define PTR_DEMANGLE(var) PTR_MANGLE (var)
214# endif
215#endif
21624
21725/* In the PowerPC64 ABI, the unadorned F_GETLK* opcodes should be used
21826 even by largefile64 code. */
lib/libc/glibc/sysdeps/unix/sysv/linux/powerpc/xstatver.h created+17
......@@ -0,0 +1,17 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_LINUX_OLD 1
4#define _STAT_VER_KERNEL 1
5#define _STAT_VER_SVR4 2
6#define _STAT_VER_LINUX 3
7#if __WORDSIZE == 32
8# define _STAT_VER _STAT_VER_LINUX
9#else
10# define _STAT_VER _STAT_VER_KERNEL
11#endif
12
13/* Versions of the 'xmknod' interface used in compatibility xmknod
14 functions. */
15#define _MKNOD_VER_LINUX 1
16#define _MKNOD_VER_SVR4 2
17#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. RISC-V version.
3 Copyright (C) 2018-2020 Free Software Foundation, Inc.
3 Copyright (C) 2018-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/riscv/sysdep.h+112-76
......@@ -22,6 +22,32 @@
2222#include <sysdeps/unix/sysv/linux/generic/sysdep.h>
2323#include <tls.h>
2424
25#undef SYS_ify
26#define SYS_ify(syscall_name) __NR_##syscall_name
27
28#if __WORDSIZE == 32
29
30/* Workarounds for generic code needing to handle 64-bit time_t. */
31
32/* Fix sysdeps/unix/sysv/linux/clock_getcpuclockid.c. */
33#define __NR_clock_getres __NR_clock_getres_time64
34/* Fix sysdeps/nptl/lowlevellock-futex.h. */
35#define __NR_futex __NR_futex_time64
36/* Fix sysdeps/unix/sysv/linux/pause.c. */
37#define __NR_ppoll __NR_ppoll_time64
38/* Fix sysdeps/unix/sysv/linux/select.c. */
39#define __NR_pselect6 __NR_pselect6_time64
40/* Fix sysdeps/unix/sysv/linux/recvmmsg.c. */
41#define __NR_recvmmsg __NR_recvmmsg_time64
42/* Fix sysdeps/unix/sysv/linux/sigtimedwait.c. */
43#define __NR_rt_sigtimedwait __NR_rt_sigtimedwait_time64
44/* Fix sysdeps/unix/sysv/linux/semtimedop.c. */
45#define __NR_semtimedop __NR_semtimedop_time64
46/* Hack sysdeps/unix/sysv/linux/generic/utimes.c. */
47#define __NR_utimensat __NR_utimensat_time64
48
49#endif /* __WORDSIZE == 32 */
50
2551#ifdef __ASSEMBLER__
2652
2753# include <sys/asm.h>
......@@ -107,56 +133,38 @@
107133# undef ret_ERRVAL
108134# define ret_ERRVAL ret
109135
110#endif /* __ASSEMBLER__ */
136#else /* !__ASSEMBLER__ */
111137
112/* In order to get __set_errno() definition in INLINE_SYSCALL. */
113#ifndef __ASSEMBLER__
114# include <errno.h>
115#endif
138# if __WORDSIZE == 64
139# define VDSO_NAME "LINUX_4.15"
140# define VDSO_HASH 182943605
116141
117#include <sysdeps/unix/sysdep.h>
118
119#undef SYS_ify
120#define SYS_ify(syscall_name) __NR_##syscall_name
121
122#ifndef __ASSEMBLER__
142/* List of system calls which are supported as vsyscalls only
143 for RV64. */
144# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
145# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
146# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
147# else
148# define VDSO_NAME "LINUX_5.4"
149# define VDSO_HASH 61765876
123150
124# define VDSO_NAME "LINUX_4.15"
125# define VDSO_HASH 182943605
151/* RV32 does not support the gettime VDSO syscalls. */
152# endif
126153
127/* List of system calls which are supported as vsyscalls. */
128# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
129# define HAVE_CLOCK_GETTIME64_VSYSCALL "__vdso_clock_gettime"
130# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
154/* List of system calls which are supported as vsyscalls (for RV32 and
155 RV64). */
131156# define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
132157
133/* Define a macro which expands into the inline wrapper code for a system
134 call. */
135# undef INLINE_SYSCALL
136# define INLINE_SYSCALL(name, nr, args...) \
137 ({ INTERNAL_SYSCALL_DECL (err); \
138 long int __sys_result = INTERNAL_SYSCALL (name, err, nr, args); \
139 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__sys_result, ))) \
140 { \
141 __set_errno (INTERNAL_SYSCALL_ERRNO (__sys_result, )); \
142 __sys_result = (unsigned long) -1; \
143 } \
144 __sys_result; })
145
146# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
147
148# define INTERNAL_SYSCALL_ERROR_P(val, err) \
149 ((unsigned long int) (val) > -4096UL)
150
151# define INTERNAL_SYSCALL_ERRNO(val, err) (-val)
158# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
159# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
152160
153# define INTERNAL_SYSCALL(name, err, nr, args...) \
154 internal_syscall##nr (SYS_ify (name), err, args)
161# define INTERNAL_SYSCALL(name, nr, args...) \
162 internal_syscall##nr (SYS_ify (name), args)
155163
156# define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
157 internal_syscall##nr (number, err, args)
164# define INTERNAL_SYSCALL_NCS(number, nr, args...) \
165 internal_syscall##nr (number, args)
158166
159# define internal_syscall0(number, err, dummy...) \
167# define internal_syscall0(number, dummy...) \
160168({ \
161169 long int _sys_result; \
162170 \
......@@ -173,13 +181,14 @@
173181 _sys_result; \
174182})
175183
176# define internal_syscall1(number, err, arg0) \
184# define internal_syscall1(number, arg0) \
177185({ \
178186 long int _sys_result; \
187 long int _arg0 = (long int) (arg0); \
179188 \
180189 { \
181190 register long int __a7 asm ("a7") = number; \
182 register long int __a0 asm ("a0") = (long int) (arg0); \
191 register long int __a0 asm ("a0") = _arg0; \
183192 __asm__ volatile ( \
184193 "scall\n\t" \
185194 : "+r" (__a0) \
......@@ -190,14 +199,16 @@
190199 _sys_result; \
191200})
192201
193# define internal_syscall2(number, err, arg0, arg1) \
202# define internal_syscall2(number, arg0, arg1) \
194203({ \
195204 long int _sys_result; \
205 long int _arg0 = (long int) (arg0); \
206 long int _arg1 = (long int) (arg1); \
196207 \
197208 { \
198209 register long int __a7 asm ("a7") = number; \
199 register long int __a0 asm ("a0") = (long int) (arg0); \
200 register long int __a1 asm ("a1") = (long int) (arg1); \
210 register long int __a0 asm ("a0") = _arg0; \
211 register long int __a1 asm ("a1") = _arg1; \
201212 __asm__ volatile ( \
202213 "scall\n\t" \
203214 : "+r" (__a0) \
......@@ -208,15 +219,18 @@
208219 _sys_result; \
209220})
210221
211# define internal_syscall3(number, err, arg0, arg1, arg2) \
222# define internal_syscall3(number, arg0, arg1, arg2) \
212223({ \
213224 long int _sys_result; \
225 long int _arg0 = (long int) (arg0); \
226 long int _arg1 = (long int) (arg1); \
227 long int _arg2 = (long int) (arg2); \
214228 \
215229 { \
216230 register long int __a7 asm ("a7") = number; \
217 register long int __a0 asm ("a0") = (long int) (arg0); \
218 register long int __a1 asm ("a1") = (long int) (arg1); \
219 register long int __a2 asm ("a2") = (long int) (arg2); \
231 register long int __a0 asm ("a0") = _arg0; \
232 register long int __a1 asm ("a1") = _arg1; \
233 register long int __a2 asm ("a2") = _arg2; \
220234 __asm__ volatile ( \
221235 "scall\n\t" \
222236 : "+r" (__a0) \
......@@ -227,16 +241,20 @@
227241 _sys_result; \
228242})
229243
230# define internal_syscall4(number, err, arg0, arg1, arg2, arg3) \
244# define internal_syscall4(number, arg0, arg1, arg2, arg3) \
231245({ \
232246 long int _sys_result; \
247 long int _arg0 = (long int) (arg0); \
248 long int _arg1 = (long int) (arg1); \
249 long int _arg2 = (long int) (arg2); \
250 long int _arg3 = (long int) (arg3); \
233251 \
234252 { \
235253 register long int __a7 asm ("a7") = number; \
236 register long int __a0 asm ("a0") = (long int) (arg0); \
237 register long int __a1 asm ("a1") = (long int) (arg1); \
238 register long int __a2 asm ("a2") = (long int) (arg2); \
239 register long int __a3 asm ("a3") = (long int) (arg3); \
254 register long int __a0 asm ("a0") = _arg0; \
255 register long int __a1 asm ("a1") = _arg1; \
256 register long int __a2 asm ("a2") = _arg2; \
257 register long int __a3 asm ("a3") = _arg3; \
240258 __asm__ volatile ( \
241259 "scall\n\t" \
242260 : "+r" (__a0) \
......@@ -247,17 +265,22 @@
247265 _sys_result; \
248266})
249267
250# define internal_syscall5(number, err, arg0, arg1, arg2, arg3, arg4) \
268# define internal_syscall5(number, arg0, arg1, arg2, arg3, arg4) \
251269({ \
252270 long int _sys_result; \
271 long int _arg0 = (long int) (arg0); \
272 long int _arg1 = (long int) (arg1); \
273 long int _arg2 = (long int) (arg2); \
274 long int _arg3 = (long int) (arg3); \
275 long int _arg4 = (long int) (arg4); \
253276 \
254277 { \
255278 register long int __a7 asm ("a7") = number; \
256 register long int __a0 asm ("a0") = (long int) (arg0); \
257 register long int __a1 asm ("a1") = (long int) (arg1); \
258 register long int __a2 asm ("a2") = (long int) (arg2); \
259 register long int __a3 asm ("a3") = (long int) (arg3); \
260 register long int __a4 asm ("a4") = (long int) (arg4); \
279 register long int __a0 asm ("a0") = _arg0; \
280 register long int __a1 asm ("a1") = _arg1; \
281 register long int __a2 asm ("a2") = _arg2; \
282 register long int __a3 asm ("a3") = _arg3; \
283 register long int __a4 asm ("a4") = _arg4; \
261284 __asm__ volatile ( \
262285 "scall\n\t" \
263286 : "+r" (__a0) \
......@@ -268,18 +291,24 @@
268291 _sys_result; \
269292})
270293
271# define internal_syscall6(number, err, arg0, arg1, arg2, arg3, arg4, arg5) \
294# define internal_syscall6(number, arg0, arg1, arg2, arg3, arg4, arg5) \
272295({ \
273296 long int _sys_result; \
297 long int _arg0 = (long int) (arg0); \
298 long int _arg1 = (long int) (arg1); \
299 long int _arg2 = (long int) (arg2); \
300 long int _arg3 = (long int) (arg3); \
301 long int _arg4 = (long int) (arg4); \
302 long int _arg5 = (long int) (arg5); \
274303 \
275304 { \
276305 register long int __a7 asm ("a7") = number; \
277 register long int __a0 asm ("a0") = (long int) (arg0); \
278 register long int __a1 asm ("a1") = (long int) (arg1); \
279 register long int __a2 asm ("a2") = (long int) (arg2); \
280 register long int __a3 asm ("a3") = (long int) (arg3); \
281 register long int __a4 asm ("a4") = (long int) (arg4); \
282 register long int __a5 asm ("a5") = (long int) (arg5); \
306 register long int __a0 asm ("a0") = _arg0; \
307 register long int __a1 asm ("a1") = _arg1; \
308 register long int __a2 asm ("a2") = _arg2; \
309 register long int __a3 asm ("a3") = _arg3; \
310 register long int __a4 asm ("a4") = _arg4; \
311 register long int __a5 asm ("a5") = _arg5; \
283312 __asm__ volatile ( \
284313 "scall\n\t" \
285314 : "+r" (__a0) \
......@@ -291,19 +320,26 @@
291320 _sys_result; \
292321})
293322
294# define internal_syscall7(number, err, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
323# define internal_syscall7(number, arg0, arg1, arg2, arg3, arg4, arg5, arg6) \
295324({ \
296325 long int _sys_result; \
326 long int _arg0 = (long int) (arg0); \
327 long int _arg1 = (long int) (arg1); \
328 long int _arg2 = (long int) (arg2); \
329 long int _arg3 = (long int) (arg3); \
330 long int _arg4 = (long int) (arg4); \
331 long int _arg5 = (long int) (arg5); \
332 long int _arg6 = (long int) (arg6); \
297333 \
298334 { \
299335 register long int __a7 asm ("a7") = number; \
300 register long int __a0 asm ("a0") = (long int) (arg0); \
301 register long int __a1 asm ("a1") = (long int) (arg1); \
302 register long int __a2 asm ("a2") = (long int) (arg2); \
303 register long int __a3 asm ("a3") = (long int) (arg3); \
304 register long int __a4 asm ("a4") = (long int) (arg4); \
305 register long int __a5 asm ("a5") = (long int) (arg5); \
306 register long int __a6 asm ("a6") = (long int) (arg6); \
336 register long int __a0 asm ("a0") = _arg0; \
337 register long int __a1 asm ("a1") = _arg1; \
338 register long int __a2 asm ("a2") = _arg2; \
339 register long int __a3 asm ("a3") = _arg3; \
340 register long int __a4 asm ("a4") = _arg4; \
341 register long int __a5 asm ("a5") = _arg5; \
342 register long int __a6 asm ("a6") = _arg6; \
307343 __asm__ volatile ( \
308344 "scall\n\t" \
309345 : "+r" (__a0) \
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/bits/stat.h deleted-265
......@@ -1,265 +0,0 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25#include <bits/wordsize.h>
26
27#if __WORDSIZE == 64
28/* Versions of the `struct stat' data structure. */
29# define _STAT_VER_KERNEL 0
30# define _STAT_VER_LINUX 1
31# define _STAT_VER _STAT_VER_LINUX
32
33/* Versions of the `xmknod' interface. */
34#define _MKNOD_VER_LINUX 0
35#else
36/* Versions of the `struct stat' data structure. */
37# define _STAT_VER_LINUX_OLD 1
38# define _STAT_VER_KERNEL 1
39# define _STAT_VER_SVR4 2
40# define _STAT_VER_LINUX 3
41# define _STAT_VER _STAT_VER_LINUX
42
43/* Versions of the `xmknod' interface. */
44# define _MKNOD_VER_LINUX 1
45# define _MKNOD_VER_SVR4 2
46# define _MKNOD_VER _MKNOD_VER_LINUX
47#endif
48
49#if __WORDSIZE == 64
50struct stat
51 {
52 __dev_t st_dev; /* Device. */
53 __ino_t st_ino; /* File serial number. */
54 __nlink_t st_nlink; /* Link count. */
55 __mode_t st_mode; /* File mode. */
56 __uid_t st_uid; /* User ID of the file's owner. */
57 __gid_t st_gid; /* Group ID of the file's group.*/
58 int __glibc_reserved0;
59 __dev_t st_rdev; /* Device number, if device. */
60 __off_t st_size; /* Size of file, in bytes. */
61#ifdef __USE_XOPEN2K8
62 /* Nanosecond resolution timestamps are stored in a format
63 equivalent to 'struct timespec'. This is the type used
64 whenever possible but the Unix namespace rules do not allow the
65 identifier 'timespec' to appear in the <sys/stat.h> header.
66 Therefore we have to handle the use of this header in strictly
67 standard-compliant sources special. */
68 struct timespec st_atim; /* Time of last access. */
69 struct timespec st_mtim; /* Time of last modification. */
70 struct timespec st_ctim; /* Time of last status change. */
71# define st_atime st_atim.tv_sec /* Backward compatibility. */
72# define st_mtime st_mtim.tv_sec
73# define st_ctime st_ctim.tv_sec
74#else
75 __time_t st_atime; /* Time of last access. */
76 unsigned long int st_atimensec; /* Nscecs of last access. */
77 __time_t st_mtime; /* Time of last modification. */
78 unsigned long int st_mtimensec; /* Nsecs of last modification. */
79 __time_t st_ctime; /* Time of last status change. */
80 unsigned long int st_ctimensec; /* Nsecs of last status change. */
81#endif
82 __blksize_t st_blksize; /* Optimal block size for I/O. */
83 __blkcnt_t st_blocks; /* Nr. 512-byte blocks allocated. */
84 long int __glibc_reserved[3];
85 };
86#else
87struct stat
88 {
89 __dev_t st_dev; /* Device. */
90 unsigned int __pad1;
91# ifndef __USE_FILE_OFFSET64
92 __ino_t st_ino; /* File serial number. */
93# else
94 __ino_t __st_ino; /* 32bit file serial number. */
95# endif
96 __mode_t st_mode; /* File mode. */
97 __nlink_t st_nlink; /* Link count. */
98 __uid_t st_uid; /* User ID of the file's owner. */
99 __gid_t st_gid; /* Group ID of the file's group.*/
100 __dev_t st_rdev; /* Device number, if device. */
101 unsigned int __pad2;
102# ifndef __USE_FILE_OFFSET64
103 __off_t st_size; /* Size of file, in bytes. */
104# else
105 __off64_t st_size; /* Size of file, in bytes. */
106# endif
107 __blksize_t st_blksize; /* Optimal block size for I/O. */
108
109# ifndef __USE_FILE_OFFSET64
110 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
111# else
112 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
113# endif
114# ifdef __USE_XOPEN2K8
115 /* Nanosecond resolution timestamps are stored in a format
116 equivalent to 'struct timespec'. This is the type used
117 whenever possible but the Unix namespace rules do not allow the
118 identifier 'timespec' to appear in the <sys/stat.h> header.
119 Therefore we have to handle the use of this header in strictly
120 standard-compliant sources special. */
121 struct timespec st_atim; /* Time of last access. */
122 struct timespec st_mtim; /* Time of last modification. */
123 struct timespec st_ctim; /* Time of last status change. */
124# define st_atime st_atim.tv_sec /* Backward compatibility. */
125# define st_mtime st_mtim.tv_sec
126# define st_ctime st_ctim.tv_sec
127# else
128 __time_t st_atime; /* Time of last access. */
129 unsigned long int st_atimensec; /* Nscecs of last access. */
130 __time_t st_mtime; /* Time of last modification. */
131 unsigned long int st_mtimensec; /* Nsecs of last modification. */
132 __time_t st_ctime; /* Time of last status change. */
133 unsigned long int st_ctimensec; /* Nsecs of last status change. */
134# endif
135# ifndef __USE_FILE_OFFSET64
136 unsigned long int __glibc_reserved4;
137 unsigned long int __glibc_reserved5;
138# else
139 __ino64_t st_ino; /* File serial number. */
140# endif
141 };
142#endif
143
144#ifdef __USE_LARGEFILE64
145# if __WORDSIZE == 64
146/* Note stat64 is the same shape as stat. */
147struct stat64
148 {
149 __dev_t st_dev; /* Device. */
150 __ino64_t st_ino; /* File serial number. */
151 __nlink_t st_nlink; /* Link count. */
152 __mode_t st_mode; /* File mode. */
153 __uid_t st_uid; /* User ID of the file's owner. */
154 __gid_t st_gid; /* Group ID of the file's group.*/
155 int __glibc_reserved0;
156 __dev_t st_rdev; /* Device number, if device. */
157 __off_t st_size; /* Size of file, in bytes. */
158# ifdef __USE_XOPEN2K8
159 /* Nanosecond resolution timestamps are stored in a format
160 equivalent to 'struct timespec'. This is the type used
161 whenever possible but the Unix namespace rules do not allow the
162 identifier 'timespec' to appear in the <sys/stat.h> header.
163 Therefore we have to handle the use of this header in strictly
164 standard-compliant sources special. */
165 struct timespec st_atim; /* Time of last access. */
166 struct timespec st_mtim; /* Time of last modification. */
167 struct timespec st_ctim; /* Time of last status change. */
168# define st_atime st_atim.tv_sec /* Backward compatibility. */
169# define st_mtime st_mtim.tv_sec
170# define st_ctime st_ctim.tv_sec
171# else
172 __time_t st_atime; /* Time of last access. */
173 unsigned long int st_atimensec; /* Nscecs of last access. */
174 __time_t st_mtime; /* Time of last modification. */
175 unsigned long int st_mtimensec; /* Nsecs of last modification. */
176 __time_t st_ctime; /* Time of last status change. */
177 unsigned long int st_ctimensec; /* Nsecs of last status change. */
178# endif
179 __blksize_t st_blksize; /* Optimal block size for I/O. */
180 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
181 long int __glibc_reserved[3];
182 };
183# else
184struct stat64
185 {
186 __dev_t st_dev; /* Device. */
187 unsigned int __pad1;
188
189 __ino_t __st_ino; /* 32bit file serial number. */
190 __mode_t st_mode; /* File mode. */
191 __nlink_t st_nlink; /* Link count. */
192 __uid_t st_uid; /* User ID of the file's owner. */
193 __gid_t st_gid; /* Group ID of the file's group.*/
194 __dev_t st_rdev; /* Device number, if device. */
195 unsigned int __pad2;
196 __off64_t st_size; /* Size of file, in bytes. */
197 __blksize_t st_blksize; /* Optimal block size for I/O. */
198
199 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
200# ifdef __USE_XOPEN2K8
201 /* Nanosecond resolution timestamps are stored in a format
202 equivalent to 'struct timespec'. This is the type used
203 whenever possible but the Unix namespace rules do not allow the
204 identifier 'timespec' to appear in the <sys/stat.h> header.
205 Therefore we have to handle the use of this header in strictly
206 standard-compliant sources special. */
207 struct timespec st_atim; /* Time of last access. */
208 struct timespec st_mtim; /* Time of last modification. */
209 struct timespec st_ctim; /* Time of last status change. */
210# define st_atime st_atim.tv_sec /* Backward compatibility. */
211# define st_mtime st_mtim.tv_sec
212# define st_ctime st_ctim.tv_sec
213# else
214 __time_t st_atime; /* Time of last access. */
215 unsigned long int st_atimensec; /* Nscecs of last access. */
216 __time_t st_mtime; /* Time of last modification. */
217 unsigned long int st_mtimensec; /* Nsecs of last modification. */
218 __time_t st_ctime; /* Time of last status change. */
219 unsigned long int st_ctimensec; /* Nsecs of last status change. */
220# endif
221 __ino64_t st_ino; /* File serial number. */
222 };
223# endif
224#endif
225
226/* Tell code we have these members. */
227#define _STATBUF_ST_BLKSIZE
228#define _STATBUF_ST_RDEV
229/* Nanosecond resolution time values are supported. */
230#define _STATBUF_ST_NSEC
231
232/* Encoding of the file mode. */
233
234#define __S_IFMT 0170000 /* These bits determine file type. */
235
236/* File types. */
237#define __S_IFDIR 0040000 /* Directory. */
238#define __S_IFCHR 0020000 /* Character device. */
239#define __S_IFBLK 0060000 /* Block device. */
240#define __S_IFREG 0100000 /* Regular file. */
241#define __S_IFIFO 0010000 /* FIFO. */
242#define __S_IFLNK 0120000 /* Symbolic link. */
243#define __S_IFSOCK 0140000 /* Socket. */
244
245/* POSIX.1b objects. Note that these macros always evaluate to zero. But
246 they do it by enforcing the correct use of the macros. */
247#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
248#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
249#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
250
251/* Protection bits. */
252
253#define __S_ISUID 04000 /* Set user ID on execution. */
254#define __S_ISGID 02000 /* Set group ID on execution. */
255#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
256#define __S_IREAD 0400 /* Read by owner. */
257#define __S_IWRITE 0200 /* Write by owner. */
258#define __S_IEXEC 0100 /* Execute by owner. */
259
260#ifdef __USE_ATFILE
261# define UTIME_NOW ((1l << 30) - 1l)
262# define UTIME_OMIT ((1l << 30) - 2l)
263#endif
264
265#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/bits/typesizes.h+8-1
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. Linux/s390 version.
2 Copyright (C) 2003-2020 Free Software Foundation, Inc.
2 Copyright (C) 2003-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -50,6 +50,7 @@
5050#define __TIME_T_TYPE __SLONGWORD_TYPE
5151#define __USECONDS_T_TYPE __U32_TYPE
5252#define __SUSECONDS_T_TYPE __SLONGWORD_TYPE
53#define __SUSECONDS64_T_TYPE __SQUAD_TYPE
5354#define __DADDR_T_TYPE __S32_TYPE
5455#define __KEY_T_TYPE __S32_TYPE
5556#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -81,10 +82,16 @@
8182
8283/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
8384# define __STATFS_MATCHES_STATFS64 1
85
86/* And for getitimer, setitimer and rusage */
87# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
8488#else
8589# define __RLIM_T_MATCHES_RLIM64_T 0
8690
8791# define __STATFS_MATCHES_STATFS64 0
92
93/* And for getitimer, setitimer and rusage */
94# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
8895#endif
8996
9097/* Number of descriptors that can fit in an `fd_set'. */
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/kernel-features.h+3-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. S/390 version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -23,8 +23,6 @@
2323# define __ASSUME_SOCKETPAIR_SYSCALL 1
2424# define __ASSUME_BIND_SYSCALL 1
2525# define __ASSUME_LISTEN_SYSCALL 1
26# define __ASSUME_GETSOCKOPT_SYSCALL 1
27# define __ASSUME_SETSOCKOPT_SYSCALL 1
2826# define __ASSUME_GETSOCKNAME_SYSCALL 1
2927# define __ASSUME_GETPEERNAME_SYSCALL 1
3028# define __ASSUME_SHUTDOWN_SYSCALL 1
......@@ -43,6 +41,8 @@
4341# undef __ASSUME_CONNECT_SYSCALL
4442# undef __ASSUME_RECVFROM_SYSCALL
4543# undef __ASSUME_SENDTO_SYSCALL
44# undef __ASSUME_GETSOCKOPT_SYSCALL
45# undef __ASSUME_SETSOCKOPT_SYSCALL
4646#endif
4747
4848/* s390 only supports ipc syscall before 5.1. */
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h+10-100
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
33 This file is part of the GNU C Library.
44
......@@ -26,11 +26,6 @@
2626#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
2727#include <tls.h>
2828
29/* Define __set_errno() for INLINE_SYSCALL macro below. */
30#ifndef __ASSEMBLER__
31#include <errno.h>
32#endif
33
3429/* For Linux we can use the system call table in the header file
3530 /usr/include/asm/unistd.h
3631 of the kernel. But these symbols do not follow the SYS_* syntax
......@@ -38,9 +33,6 @@
3833/* in newer 2.1 kernels __NR_syscall is missing so we define it here */
3934#define __NR_syscall 0
4035
41#undef SYS_ify
42#define SYS_ify(syscall_name) __NR_##syscall_name
43
4436#ifdef __ASSEMBLER__
4537
4638/* Linux uses a negative return value to indicate syscall errors, unlike
......@@ -88,7 +80,9 @@
8880#define PSEUDO_END_ERRVAL(name) \
8981 END (name)
9082
83#undef SYSCALL_ERROR_LABEL
9184#ifndef PIC
85# undef SYSCALL_ERROR_LABEL
9286# define SYSCALL_ERROR_LABEL 0f
9387# define SYSCALL_ERROR_HANDLER \
94880: basr %r1,0; \
......@@ -97,6 +91,7 @@
97912: .long syscall_error
9892#else
9993# if RTLD_PRIVATE_ERRNO
94# undef SYSCALL_ERROR_LABEL
10095# define SYSCALL_ERROR_LABEL 0f
10196# define SYSCALL_ERROR_HANDLER \
102970: basr %r1,0; \
......@@ -112,6 +107,7 @@
112107# else
113108# define SYSCALL_ERROR_ERRNO errno
114109# endif
110# undef SYSCALL_ERROR_LABEL
115111# define SYSCALL_ERROR_LABEL 0f
116112# define SYSCALL_ERROR_HANDLER \
1171130: lcr %r0,%r2; \
......@@ -124,6 +120,7 @@
124120 br %r14; \
1251212: .long _GLOBAL_OFFSET_TABLE_-1b
126122# else
123# undef SYSCALL_ERROR_LABEL
127124# define SYSCALL_ERROR_LABEL 0f
128125# define SYSCALL_ERROR_HANDLER \
1291260: basr %r1,0; \
......@@ -178,99 +175,12 @@
178175#define ret_ERRVAL \
179176 br 14
180177
181#endif /* __ASSEMBLER__ */
182
183#undef INLINE_SYSCALL
184#define INLINE_SYSCALL(name, nr, args...) \
185 ({ \
186 unsigned int _ret = INTERNAL_SYSCALL (name, , nr, args); \
187 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \
188 { \
189 __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \
190 _ret = 0xffffffff; \
191 } \
192 (int) _ret; })
193
194#undef INTERNAL_SYSCALL_DECL
195#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
196
197#undef INTERNAL_SYSCALL_DIRECT
198#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \
199 ({ \
200 DECLARGS_##nr(args) \
201 register int _ret __asm__("2"); \
202 __asm__ __volatile__ ( \
203 "svc %b1\n\t" \
204 : "=d" (_ret) \
205 : "i" (__NR_##name) ASMFMT_##nr \
206 : "memory" ); \
207 _ret; })
208
209#undef INTERNAL_SYSCALL_SVC0
210#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \
211 ({ \
212 DECLARGS_##nr(args) \
213 register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name); \
214 register int _ret __asm__("2"); \
215 __asm__ __volatile__ ( \
216 "svc 0\n\t" \
217 : "=d" (_ret) \
218 : "d" (_nr) ASMFMT_##nr \
219 : "memory" ); \
220 _ret; })
221
222#undef INTERNAL_SYSCALL_NCS
223#define INTERNAL_SYSCALL_NCS(no, err, nr, args...) \
224 ({ \
225 DECLARGS_##nr(args) \
226 register unsigned long _nr __asm__("1") = (unsigned long)(no); \
227 register int _ret __asm__("2"); \
228 __asm__ __volatile__ ( \
229 "svc 0\n\t" \
230 : "=d" (_ret) \
231 : "d" (_nr) ASMFMT_##nr \
232 : "memory" ); \
233 _ret; })
234
235#undef INTERNAL_SYSCALL
236#define INTERNAL_SYSCALL(name, err, nr, args...) \
237 (((__NR_##name) < 256) \
238 ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args) \
239 : INTERNAL_SYSCALL_SVC0(name, err,nr, args))
240
241#undef INTERNAL_SYSCALL_ERROR_P
242#define INTERNAL_SYSCALL_ERROR_P(val, err) \
243 ((unsigned int) (val) >= 0xfffff001u)
244
245#undef INTERNAL_SYSCALL_ERRNO
246#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
178#else
247179
248#define DECLARGS_0()
249#define DECLARGS_1(arg1) \
250 register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
251#define DECLARGS_2(arg1, arg2) \
252 DECLARGS_1(arg1) \
253 register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
254#define DECLARGS_3(arg1, arg2, arg3) \
255 DECLARGS_2(arg1, arg2) \
256 register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
257#define DECLARGS_4(arg1, arg2, arg3, arg4) \
258 DECLARGS_3(arg1, arg2, arg3) \
259 register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
260#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
261 DECLARGS_4(arg1, arg2, arg3, arg4) \
262 register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
263#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
264 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
265 register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
180# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
181# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
266182
267#define ASMFMT_0
268#define ASMFMT_1 , "0" (gpr2)
269#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
270#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
271#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
272#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
273#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
183#endif /* __ASSEMBLER__ */
274184
275185/* Pointer mangling support. */
276186#if IS_IN (rtld)
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h+10-110
......@@ -1,5 +1,5 @@
11/* Assembler macros for 64 bit S/390.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
44 This file is part of the GNU C Library.
55
......@@ -27,11 +27,6 @@
2727#include <dl-sysdep.h> /* For RTLD_PRIVATE_ERRNO. */
2828#include <tls.h>
2929
30/* Define __set_errno() for INLINE_SYSCALL macro below. */
31#ifndef __ASSEMBLER__
32#include <errno.h>
33#endif
34
3530/* For Linux we can use the system call table in the header file
3631 /usr/include/asm/unistd.h
3732 of the kernel. But these symbols do not follow the SYS_* syntax
......@@ -39,17 +34,6 @@
3934/* In newer 2.1 kernels __NR_syscall is missing so we define it here. */
4035#define __NR_syscall 0
4136
42/*
43 * Newer kernel versions redefined __NR_pread and __NR_pwrite to
44 * __NR_pread64 and __NR_pwrite64.
45 */
46#ifndef __NR_pread
47# define __NR_pread __NR_pread64
48#endif
49#ifndef __NR_pwrite
50# define __NR_pwrite __NR_pwrite64
51#endif
52
5337#undef SYS_ify
5438#define SYS_ify(syscall_name) __NR_##syscall_name
5539
......@@ -102,11 +86,14 @@
10286 SYSCALL_ERROR_HANDLER; \
10387 END (name)
10488
89#undef SYSCALL_ERROR_LABEL
10590#ifndef PIC
91# undef SYSCALL_ERROR_LABEL
10692# define SYSCALL_ERROR_LABEL syscall_error
10793# define SYSCALL_ERROR_HANDLER
10894#else
10995# if RTLD_PRIVATE_ERRNO
96# undef SYSCALL_ERROR_LABEL
11097# define SYSCALL_ERROR_LABEL 0f
11198# define SYSCALL_ERROR_HANDLER \
112990: larl %r1,rtld_errno; \
......@@ -120,6 +107,7 @@
120107# else
121108# define SYSCALL_ERROR_ERRNO errno
122109# endif
110# undef SYSCALL_ERROR_LABEL
123111# define SYSCALL_ERROR_LABEL 0f
124112# define SYSCALL_ERROR_HANDLER \
1251130: lcr %r0,%r2; \
......@@ -132,6 +120,7 @@
132120 lghi %r2,-1; \
133121 br %r14
134122# else
123# undef SYSCALL_ERROR_LABEL
135124# define SYSCALL_ERROR_LABEL 0f
136125# define SYSCALL_ERROR_HANDLER \
1371260: larl %r1,_GLOBAL_OFFSET_TABLE_; \
......@@ -184,101 +173,12 @@
184173#define ret_ERRVAL \
185174 br 14
186175
187#endif /* __ASSEMBLER__ */
188
189#undef INLINE_SYSCALL
190#define INLINE_SYSCALL(name, nr, args...) \
191 ({ \
192 long _ret = INTERNAL_SYSCALL (name, , nr, args); \
193 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (_ret, ))) \
194 { \
195 __set_errno (INTERNAL_SYSCALL_ERRNO (_ret, )); \
196 _ret = -1; \
197 } \
198 _ret; })
199
200#undef INTERNAL_SYSCALL_DECL
201#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
202
203#undef INTERNAL_SYSCALL_DIRECT
204#define INTERNAL_SYSCALL_DIRECT(name, err, nr, args...) \
205 ({ \
206 DECLARGS_##nr(args) \
207 register long _ret __asm__("2"); \
208 __asm__ __volatile__ ( \
209 "svc %b1\n\t" \
210 : "=d" (_ret) \
211 : "i" (__NR_##name) ASMFMT_##nr \
212 : "memory" ); \
213 _ret; })
214
215#undef INTERNAL_SYSCALL_SVC0
216#define INTERNAL_SYSCALL_SVC0(name, err, nr, args...) \
217 ({ \
218 DECLARGS_##nr(args) \
219 register unsigned long _nr __asm__("1") = (unsigned long)(__NR_##name); \
220 register long _ret __asm__("2"); \
221 __asm__ __volatile__ ( \
222 "svc 0\n\t" \
223 : "=d" (_ret) \
224 : "d" (_nr) ASMFMT_##nr \
225 : "memory" ); \
226 _ret; })
227
228#undef INTERNAL_SYSCALL_NCS
229#define INTERNAL_SYSCALL_NCS(no, err, nr, args...) \
230 ({ \
231 DECLARGS_##nr(args) \
232 register unsigned long _nr __asm__("1") = (unsigned long)(no); \
233 register long _ret __asm__("2"); \
234 __asm__ __volatile__ ( \
235 "svc 0\n\t" \
236 : "=d" (_ret) \
237 : "d" (_nr) ASMFMT_##nr \
238 : "memory" ); \
239 _ret; })
240
241#undef INTERNAL_SYSCALL
242#define INTERNAL_SYSCALL(name, err, nr, args...) \
243 (((__NR_##name) < 256) \
244 ? INTERNAL_SYSCALL_DIRECT(name, err, nr, args) \
245 : INTERNAL_SYSCALL_SVC0(name, err,nr, args))
246
247#undef INTERNAL_SYSCALL_ERROR_P
248#define INTERNAL_SYSCALL_ERROR_P(val, err) \
249 ((unsigned long) (val) >= -4095UL)
250
251#undef INTERNAL_SYSCALL_ERRNO
252#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
253
254#define DECLARGS_0()
255#define DECLARGS_1(arg1) \
256 register unsigned long gpr2 __asm__ ("2") = (unsigned long)(arg1);
257#define DECLARGS_2(arg1, arg2) \
258 DECLARGS_1(arg1) \
259 register unsigned long gpr3 __asm__ ("3") = (unsigned long)(arg2);
260#define DECLARGS_3(arg1, arg2, arg3) \
261 DECLARGS_2(arg1, arg2) \
262 register unsigned long gpr4 __asm__ ("4") = (unsigned long)(arg3);
263#define DECLARGS_4(arg1, arg2, arg3, arg4) \
264 DECLARGS_3(arg1, arg2, arg3) \
265 register unsigned long gpr5 __asm__ ("5") = (unsigned long)(arg4);
266#define DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
267 DECLARGS_4(arg1, arg2, arg3, arg4) \
268 register unsigned long gpr6 __asm__ ("6") = (unsigned long)(arg5);
269#define DECLARGS_6(arg1, arg2, arg3, arg4, arg5, arg6) \
270 DECLARGS_5(arg1, arg2, arg3, arg4, arg5) \
271 register unsigned long gpr7 __asm__ ("7") = (unsigned long)(arg6);
176#else
272177
273#define ASMFMT_0
274#define ASMFMT_1 , "0" (gpr2)
275#define ASMFMT_2 , "0" (gpr2), "d" (gpr3)
276#define ASMFMT_3 , "0" (gpr2), "d" (gpr3), "d" (gpr4)
277#define ASMFMT_4 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
278#define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
279#define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
178# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
179# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
280180
281#define SINGLE_THREAD_BY_GLOBAL 1
181#endif /* __ASSEMBLER__ */
282182
283183/* Pointer mangling support. */
284184#if IS_IN (rtld)
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/sys/elf.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/s390/xstatver.h created+19
......@@ -0,0 +1,19 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3
4#include <bits/wordsize.h>
5
6#if __WORDSIZE == 64
7# define _STAT_VER_KERNEL 0
8# define _STAT_VER_LINUX 1
9# define _MKNOD_VER_LINUX 0
10#else
11# define _STAT_VER_LINUX_OLD 1
12# define _STAT_VER_KERNEL 1
13# define _STAT_VER_SVR4 2
14# define _STAT_VER_LINUX 3
15# define _MKNOD_VER_LINUX 1
16# define _MKNOD_VER_SVR4 2
17#endif
18#define _STAT_VER _STAT_VER_LINUX
19#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/sh/kernel-features.h+1-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. SH version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -33,8 +33,6 @@
3333#define __ASSUME_SEND_SYSCALL 1
3434#define __ASSUME_RECV_SYSCALL 1
3535#define __ASSUME_SHUTDOWN_SYSCALL 1
36#define __ASSUME_GETSOCKOPT_SYSCALL 1
37#define __ASSUME_SETSOCKOPT_SYSCALL 1
3836
3937#include_next <kernel-features.h>
4038
lib/libc/glibc/sysdeps/unix/sysv/linux/sh/sysdep.h+3-24
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1992-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
44 Changed by Kaz Kojima, <kkojima@rr.iij4u.or.jp>.
......@@ -287,19 +287,8 @@
287287 register long int r1 asm ("%r1") = (long int) (_arg6); \
288288 register long int r2 asm ("%r2") = (long int) (_arg7)
289289
290#undef INLINE_SYSCALL
291#define INLINE_SYSCALL(name, nr, args...) \
292 ({ \
293 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
294 if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (resultvar, ), 0)) \
295 { \
296 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
297 resultvar = 0xffffffff; \
298 } \
299 (int) resultvar; })
300
301290#undef INTERNAL_SYSCALL
302#define INTERNAL_SYSCALL(name, err, nr, args...) \
291#define INTERNAL_SYSCALL(name, nr, args...) \
303292 ({ \
304293 unsigned long int resultvar; \
305294 register long int r3 asm ("%r3") = SYS_ify (name); \
......@@ -313,7 +302,7 @@
313302 (int) resultvar; })
314303
315304/* The _NCS variant allows non-constant syscall numbers. */
316#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
305#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
317306 ({ \
318307 unsigned long int resultvar; \
319308 register long int r3 asm ("%r3") = (name); \
......@@ -326,16 +315,6 @@
326315 \
327316 (int) resultvar; })
328317
329#undef INTERNAL_SYSCALL_DECL
330#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
331
332#undef INTERNAL_SYSCALL_ERROR_P
333#define INTERNAL_SYSCALL_ERROR_P(val, err) \
334 ((unsigned int) (val) >= 0xfffff001u)
335
336#undef INTERNAL_SYSCALL_ERRNO
337#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
338
339318#endif /* __ASSEMBLER__ */
340319
341320/* Pointer mangling support. */
lib/libc/glibc/sysdeps/unix/sysv/linux/single-thread.h+13-31
......@@ -1,5 +1,5 @@
11/* Single thread optimization, Linux version.
2 Copyright (C) 2019-2020 Free Software Foundation, Inc.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -27,36 +27,18 @@
2727 The ABI might define SINGLE_THREAD_BY_GLOBAL to enable the single thread
2828 check to use global variables instead of the pthread_t field. */
2929
30#ifdef SINGLE_THREAD_BY_GLOBAL
31# if IS_IN (libc)
30#ifndef __ASSEMBLER__
3231extern int __libc_multiple_threads;
33# define SINGLE_THREAD_P \
34 __glibc_likely (__libc_multiple_threads == 0)
35# elif IS_IN (libpthread)
36extern int __pthread_multiple_threads;
37# define SINGLE_THREAD_P \
38 __glibc_likely (__pthread_multiple_threads == 0)
39# elif IS_IN (librt)
40# define SINGLE_THREAD_P \
41 __glibc_likely (THREAD_GETMEM (THREAD_SELF, \
42 header.multiple_threads) == 0)
43# else
44/* For rtld, et cetera. */
45# define SINGLE_THREAD_P (1)
46# endif
47#else /* SINGLE_THREAD_BY_GLOBAL */
48# if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
49# define SINGLE_THREAD_P \
50 __glibc_likely (THREAD_GETMEM (THREAD_SELF, \
51 header.multiple_threads) == 0)
52# else
53/* For rtld, et cetera. */
54# define SINGLE_THREAD_P (1)
55# endif
56#endif /* SINGLE_THREAD_BY_GLOBAL */
57
58#define RTLD_SINGLE_THREAD_P \
59 __glibc_likely (THREAD_GETMEM (THREAD_SELF, \
60 header.multiple_threads) == 0)
32libc_hidden_proto (__libc_multiple_threads)
33#endif
34
35#if !defined SINGLE_THREAD_BY_GLOBAL || IS_IN (rtld)
36# define SINGLE_THREAD_P \
37 (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0)
38#else
39# define SINGLE_THREAD_P (__libc_multiple_threads == 0)
40#endif
41
42#define RTLD_SINGLE_THREAD_P SINGLE_THREAD_P
6143
6244#endif /* _SINGLE_THREAD_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/bits/stat.h deleted-173
......@@ -1,173 +0,0 @@
1/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#define _STAT_VER_LINUX_OLD 1
27#define _STAT_VER_KERNEL 1
28#define _STAT_VER_SVR4 2
29#define _STAT_VER_LINUX 3
30#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
31
32/* Versions of the `xmknod' interface. */
33#define _MKNOD_VER_LINUX 1
34#define _MKNOD_VER_SVR4 2
35#define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36
37
38struct stat
39 {
40 __dev_t st_dev; /* Device. */
41#if __WORDSIZE == 64 || !defined __USE_FILE_OFFSET64
42 unsigned short int __pad1;
43 __ino_t st_ino; /* File serial number. */
44#else
45 __ino64_t st_ino; /* File serial number. */
46#endif
47 __mode_t st_mode; /* File mode. */
48 __nlink_t st_nlink; /* Link count. */
49 __uid_t st_uid; /* User ID of the file's owner. */
50 __gid_t st_gid; /* Group ID of the file's group.*/
51 __dev_t st_rdev; /* Device number, if device. */
52 unsigned short int __pad2;
53#ifndef __USE_FILE_OFFSET64
54 __off_t st_size; /* Size of file, in bytes. */
55#else
56 __off64_t st_size; /* Size of file, in bytes. */
57#endif
58 __blksize_t st_blksize; /* Optimal block size for I/O. */
59
60#ifndef __USE_FILE_OFFSET64
61 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
62#else
63 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
64#endif
65#ifdef __USE_XOPEN2K8
66 /* Nanosecond resolution timestamps are stored in a format
67 equivalent to 'struct timespec'. This is the type used
68 whenever possible but the Unix namespace rules do not allow the
69 identifier 'timespec' to appear in the <sys/stat.h> header.
70 Therefore we have to handle the use of this header in strictly
71 standard-compliant sources special. */
72 struct timespec st_atim; /* Time of last access. */
73 struct timespec st_mtim; /* Time of last modification. */
74 struct timespec st_ctim; /* Time of last status change. */
75# define st_atime st_atim.tv_sec /* Backward compatibility. */
76# define st_mtime st_mtim.tv_sec
77# define st_ctime st_ctim.tv_sec
78#else
79 __time_t st_atime; /* Time of last access. */
80 unsigned long int st_atimensec; /* Nscecs of last access. */
81 __time_t st_mtime; /* Time of last modification. */
82 unsigned long int st_mtimensec; /* Nsecs of last modification. */
83 __time_t st_ctime; /* Time of last status change. */
84 unsigned long int st_ctimensec; /* Nsecs of last status change. */
85#endif
86 unsigned long int __glibc_reserved4;
87 unsigned long int __glibc_reserved5;
88 };
89
90#ifdef __USE_LARGEFILE64
91struct stat64
92 {
93 __dev_t st_dev; /* Device. */
94# if __WORDSIZE == 64
95 unsigned short int __pad1;
96# endif
97 __ino64_t st_ino; /* File serial number. */
98 __mode_t st_mode; /* File mode. */
99 __nlink_t st_nlink; /* Link count. */
100 __uid_t st_uid; /* User ID of the file's owner. */
101 __gid_t st_gid; /* Group ID of the file's group.*/
102 __dev_t st_rdev; /* Device number, if device. */
103 unsigned short int __pad2;
104 __off64_t st_size; /* Size of file, in bytes. */
105 __blksize_t st_blksize; /* Optimal block size for I/O. */
106
107 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
108# ifdef __USE_XOPEN2K8
109 /* Nanosecond resolution timestamps are stored in a format
110 equivalent to 'struct timespec'. This is the type used
111 whenever possible but the Unix namespace rules do not allow the
112 identifier 'timespec' to appear in the <sys/stat.h> header.
113 Therefore we have to handle the use of this header in strictly
114 standard-compliant sources special. */
115 struct timespec st_atim; /* Time of last access. */
116 struct timespec st_mtim; /* Time of last modification. */
117 struct timespec st_ctim; /* Time of last status change. */
118# define st_atime st_atim.tv_sec /* Backward compatibility. */
119# define st_mtime st_mtim.tv_sec
120# define st_ctime st_ctim.tv_sec
121# else
122 __time_t st_atime; /* Time of last access. */
123 unsigned long int st_atimensec; /* Nscecs of last access. */
124 __time_t st_mtime; /* Time of last modification. */
125 unsigned long int st_mtimensec; /* Nsecs of last modification. */
126 __time_t st_ctime; /* Time of last status change. */
127 unsigned long int st_ctimensec; /* Nsecs of last status change. */
128# endif
129 unsigned long int __glibc_reserved4;
130 unsigned long int __glibc_reserved5;
131 };
132#endif
133
134/* Tell code we have these members. */
135#define _STATBUF_ST_BLKSIZE
136#define _STATBUF_ST_RDEV
137/* Nanosecond resolution time values are supported. */
138#define _STATBUF_ST_NSEC
139
140/* Encoding of the file mode. */
141
142#define __S_IFMT 0170000 /* These bits determine file type. */
143
144/* File types. */
145#define __S_IFDIR 0040000 /* Directory. */
146#define __S_IFCHR 0020000 /* Character device. */
147#define __S_IFBLK 0060000 /* Block device. */
148#define __S_IFREG 0100000 /* Regular file. */
149#define __S_IFIFO 0010000 /* FIFO. */
150#define __S_IFLNK 0120000 /* Symbolic link. */
151#define __S_IFSOCK 0140000 /* Socket. */
152
153/* POSIX.1b objects. Note that these macros always evaluate to zero. But
154 they do it by enforcing the correct use of the macros. */
155#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
156#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
157#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
158
159/* Protection bits. */
160
161#define __S_ISUID 04000 /* Set user ID on execution. */
162#define __S_ISGID 02000 /* Set group ID on execution. */
163#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
164#define __S_IREAD 0400 /* Read by owner. */
165#define __S_IWRITE 0200 /* Write by owner. */
166#define __S_IEXEC 0100 /* Execute by owner. */
167
168#ifdef __USE_ATFILE
169# define UTIME_NOW ((1l << 30) - 1l)
170# define UTIME_OMIT ((1l << 30) - 2l)
171#endif
172
173#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h+8-1
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. Linux/SPARC version.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
2 Copyright (C) 2002-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -50,6 +50,7 @@
5050#define __TIME_T_TYPE __SLONGWORD_TYPE
5151#define __USECONDS_T_TYPE __U32_TYPE
5252#define __SUSECONDS_T_TYPE __S32_TYPE
53#define __SUSECONDS64_T_TYPE __SQUAD_TYPE
5354#define __DADDR_T_TYPE __S32_TYPE
5455#define __KEY_T_TYPE __S32_TYPE
5556#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -75,10 +76,16 @@
7576
7677/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
7778# define __STATFS_MATCHES_STATFS64 1
79
80/* And for getitimer, setitimer and rusage */
81# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
7882#else
7983# define __RLIM_T_MATCHES_RLIM64_T 0
8084
8185# define __STATFS_MATCHES_STATFS64 0
86
87/* And for getitimer, setitimer and rusage */
88# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
8289#endif
8390
8491/* Number of descriptors that can fit in an `fd_set'. */
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/kernel-features.h+3-3
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. SPARC version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
......@@ -38,10 +38,11 @@
3838# undef __ASSUME_CONNECT_SYSCALL
3939# undef __ASSUME_RECVFROM_SYSCALL
4040# undef __ASSUME_SENDTO_SYSCALL
41# undef __ASSUME_GETSOCKOPT_SYSCALL
42# undef __ASSUME_SETSOCKOPT_SYSCALL
4143#else
4244# define __ASSUME_SOCKET_SYSCALL 1
4345# define __ASSUME_SOCKETPAIR_SYSCALL 1
44# define __ASSUME_GETSOCKOPT_SYSCALL 1
4546# define __ASSUME_SHUTDOWN_SYSCALL 1
4647#endif
4748
......@@ -49,7 +50,6 @@
4950#if __LINUX_KERNEL_VERSION >= 0x040400
5051# define __ASSUME_BIND_SYSCALL 1
5152# define __ASSUME_LISTEN_SYSCALL 1
52# define __ASSUME_SETSOCKOPT_SYSCALL 1
5353#endif
5454
5555#ifdef __arch64__
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h+5-3
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Miguel de Icaza <miguel@gnu.ai.mit.edu>, January 1997.
44
......@@ -110,9 +110,8 @@ ENTRY(name); \
110110#define __SYSCALL_STRING \
111111 "ta 0x10;" \
112112 "bcc 1f;" \
113 " mov 0, %%g1;" \
113 " nop;" \
114114 "sub %%g0, %%o0, %%o0;" \
115 "mov 1, %%g1;" \
116115 "1:"
117116
118117#define __SYSCALL_CLOBBERS \
......@@ -122,6 +121,9 @@ ENTRY(name); \
122121 "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \
123122 "cc", "memory"
124123
124#undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
125#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
126
125127#endif /* __ASSEMBLER__ */
126128
127129/* Pointer mangling support. */
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h+2-3
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1997-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Richard Henderson <richard@gnu.ai.mit.edu>, 1997.
44
......@@ -109,9 +109,8 @@ ENTRY(name); \
109109#define __SYSCALL_STRING \
110110 "ta 0x6d;" \
111111 "bcc,pt %%xcc, 1f;" \
112 " mov 0, %%g1;" \
112 " nop;" \
113113 "sub %%g0, %%o0, %%o0;" \
114 "mov 1, %%g1;" \
115114 "1:"
116115
117116#define __SYSCALL_CLOBBERS \
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/sysdep.h+90-94
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2000-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33 Contributed by Jakub Jelinek <jakub@redhat.com>, 2000.
44
......@@ -34,13 +34,6 @@
3434
3535#else /* __ASSEMBLER__ */
3636
37#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
38 ({ \
39 long _ret = funcptr (args); \
40 err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \
41 _ret; \
42 })
43
4437# define VDSO_NAME "LINUX_2.6"
4538# define VDSO_HASH 61765110
4639
......@@ -52,121 +45,119 @@
5245# endif
5346# define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday"
5447
55#undef INLINE_SYSCALL
56#define INLINE_SYSCALL(name, nr, args...) \
57({ INTERNAL_SYSCALL_DECL(err); \
58 unsigned long resultvar = INTERNAL_SYSCALL(name, err, nr, args);\
59 if (INTERNAL_SYSCALL_ERROR_P (resultvar, err)) \
60 { \
61 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, err)); \
62 resultvar = (unsigned long) -1; \
63 } \
64 (long) resultvar; \
65})
66
67#undef INTERNAL_SYSCALL_DECL
68#define INTERNAL_SYSCALL_DECL(err) \
69 register long err __asm__("g1");
70
7148#undef INTERNAL_SYSCALL
72#define INTERNAL_SYSCALL(name, err, nr, args...) \
73 inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args)
49#define INTERNAL_SYSCALL(name, nr, args...) \
50 internal_syscall##nr(__SYSCALL_STRING, __NR_##name, args)
7451
7552#undef INTERNAL_SYSCALL_NCS
76#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
77 inline_syscall##nr(__SYSCALL_STRING, err, name, args)
78
79#undef INTERNAL_SYSCALL_ERROR_P
80#define INTERNAL_SYSCALL_ERROR_P(val, err) \
81 ((void) (val), __builtin_expect((err) != 0, 0))
82
83#undef INTERNAL_SYSCALL_ERRNO
84#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
53#define INTERNAL_SYSCALL_NCS(name, nr, args...) \
54 internal_syscall##nr(__SYSCALL_STRING, name, args)
8555
86#define inline_syscall0(string,err,name,dummy...) \
56#define internal_syscall0(string,name,dummy...) \
8757({ \
58 register long int __g1 __asm__ ("g1") = (name); \
8859 register long __o0 __asm__ ("o0"); \
89 err = name; \
90 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
91 "0" (err) : \
60 __asm __volatile (string : "=r" (__o0) : \
61 "r" (__g1) : \
9262 __SYSCALL_CLOBBERS); \
9363 __o0; \
9464})
9565
96#define inline_syscall1(string,err,name,arg1) \
66#define internal_syscall1(string,name,arg1) \
9767({ \
98 register long __o0 __asm__ ("o0") = (long)(arg1); \
99 err = name; \
100 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
101 "0" (err), "1" (__o0) : \
68 long int _arg1 = (long int) (arg1); \
69 register long int __g1 __asm__("g1") = (name); \
70 register long int __o0 __asm__ ("o0") = _arg1; \
71 __asm __volatile (string : "=r" (__o0) : \
72 "r" (__g1), "0" (__o0) : \
10273 __SYSCALL_CLOBBERS); \
10374 __o0; \
10475})
10576
106#define inline_syscall2(string,err,name,arg1,arg2) \
77#define internal_syscall2(string,name,arg1,arg2) \
10778({ \
108 register long __o0 __asm__ ("o0") = (long)(arg1); \
109 register long __o1 __asm__ ("o1") = (long)(arg2); \
110 err = name; \
111 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
112 "0" (err), "1" (__o0), "r" (__o1) : \
79 long int _arg1 = (long int) (arg1); \
80 long int _arg2 = (long int) (arg2); \
81 register long int __g1 __asm__("g1") = (name); \
82 register long int __o0 __asm__ ("o0") = _arg1; \
83 register long int __o1 __asm__ ("o1") = _arg2; \
84 __asm __volatile (string : "=r" (__o0) : \
85 "r" (__g1), "0" (__o0), "r" (__o1) : \
11386 __SYSCALL_CLOBBERS); \
11487 __o0; \
11588})
11689
117#define inline_syscall3(string,err,name,arg1,arg2,arg3) \
90#define internal_syscall3(string,name,arg1,arg2,arg3) \
11891({ \
119 register long __o0 __asm__ ("o0") = (long)(arg1); \
120 register long __o1 __asm__ ("o1") = (long)(arg2); \
121 register long __o2 __asm__ ("o2") = (long)(arg3); \
122 err = name; \
123 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
124 "0" (err), "1" (__o0), "r" (__o1), \
92 long int _arg1 = (long int) (arg1); \
93 long int _arg2 = (long int) (arg2); \
94 long int _arg3 = (long int) (arg3); \
95 register long int __g1 __asm__("g1") = (name); \
96 register long int __o0 __asm__ ("o0") = _arg1; \
97 register long int __o1 __asm__ ("o1") = _arg2; \
98 register long int __o2 __asm__ ("o2") = _arg3; \
99 __asm __volatile (string : "=r" (__o0) : \
100 "r" (__g1), "0" (__o0), "r" (__o1), \
125101 "r" (__o2) : \
126102 __SYSCALL_CLOBBERS); \
127103 __o0; \
128104})
129105
130#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4) \
106#define internal_syscall4(string,name,arg1,arg2,arg3,arg4) \
131107({ \
132 register long __o0 __asm__ ("o0") = (long)(arg1); \
133 register long __o1 __asm__ ("o1") = (long)(arg2); \
134 register long __o2 __asm__ ("o2") = (long)(arg3); \
135 register long __o3 __asm__ ("o3") = (long)(arg4); \
136 err = name; \
137 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
138 "0" (err), "1" (__o0), "r" (__o1), \
108 long int _arg1 = (long int) (arg1); \
109 long int _arg2 = (long int) (arg2); \
110 long int _arg3 = (long int) (arg3); \
111 long int _arg4 = (long int) (arg4); \
112 register long int __g1 __asm__("g1") = (name); \
113 register long int __o0 __asm__ ("o0") = _arg1; \
114 register long int __o1 __asm__ ("o1") = _arg2; \
115 register long int __o2 __asm__ ("o2") = _arg3; \
116 register long int __o3 __asm__ ("o3") = _arg4; \
117 __asm __volatile (string : "=r" (__o0) : \
118 "r" (__g1), "0" (__o0), "r" (__o1), \
139119 "r" (__o2), "r" (__o3) : \
140120 __SYSCALL_CLOBBERS); \
141121 __o0; \
142122})
143123
144#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \
124#define internal_syscall5(string,name,arg1,arg2,arg3,arg4,arg5) \
145125({ \
146 register long __o0 __asm__ ("o0") = (long)(arg1); \
147 register long __o1 __asm__ ("o1") = (long)(arg2); \
148 register long __o2 __asm__ ("o2") = (long)(arg3); \
149 register long __o3 __asm__ ("o3") = (long)(arg4); \
150 register long __o4 __asm__ ("o4") = (long)(arg5); \
151 err = name; \
152 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
153 "0" (err), "1" (__o0), "r" (__o1), \
126 long int _arg1 = (long int) (arg1); \
127 long int _arg2 = (long int) (arg2); \
128 long int _arg3 = (long int) (arg3); \
129 long int _arg4 = (long int) (arg4); \
130 long int _arg5 = (long int) (arg5); \
131 register long int __g1 __asm__("g1") = (name); \
132 register long int __o0 __asm__ ("o0") = _arg1; \
133 register long int __o1 __asm__ ("o1") = _arg2; \
134 register long int __o2 __asm__ ("o2") = _arg3; \
135 register long int __o3 __asm__ ("o3") = _arg4; \
136 register long int __o4 __asm__ ("o4") = _arg5; \
137 __asm __volatile (string : "=r" (__o0) : \
138 "r" (__g1), "0" (__o0), "r" (__o1), \
154139 "r" (__o2), "r" (__o3), "r" (__o4) : \
155140 __SYSCALL_CLOBBERS); \
156141 __o0; \
157142})
158143
159#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6) \
144#define internal_syscall6(string,name,arg1,arg2,arg3,arg4,arg5,arg6) \
160145({ \
161 register long __o0 __asm__ ("o0") = (long)(arg1); \
162 register long __o1 __asm__ ("o1") = (long)(arg2); \
163 register long __o2 __asm__ ("o2") = (long)(arg3); \
164 register long __o3 __asm__ ("o3") = (long)(arg4); \
165 register long __o4 __asm__ ("o4") = (long)(arg5); \
166 register long __o5 __asm__ ("o5") = (long)(arg6); \
167 err = name; \
168 __asm __volatile (string : "=r" (err), "=r" (__o0) : \
169 "0" (err), "1" (__o0), "r" (__o1), \
146 long int _arg1 = (long int) (arg1); \
147 long int _arg2 = (long int) (arg2); \
148 long int _arg3 = (long int) (arg3); \
149 long int _arg4 = (long int) (arg4); \
150 long int _arg5 = (long int) (arg5); \
151 long int _arg6 = (long int) (arg6); \
152 register long int __g1 __asm__("g1") = (name); \
153 register long int __o0 __asm__ ("o0") = _arg1; \
154 register long int __o1 __asm__ ("o1") = _arg2; \
155 register long int __o2 __asm__ ("o2") = _arg3; \
156 register long int __o3 __asm__ ("o3") = _arg4; \
157 register long int __o4 __asm__ ("o4") = _arg5; \
158 register long int __o5 __asm__ ("o5") = _arg6; \
159 __asm __volatile (string : "=r" (__o0) : \
160 "r" (__g1), "0" (__o0), "r" (__o1), \
170161 "r" (__o2), "r" (__o3), "r" (__o4), \
171162 "r" (__o5) : \
172163 __SYSCALL_CLOBBERS); \
......@@ -175,20 +166,25 @@
175166
176167#define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \
177168({ \
178 register long __o0 __asm__ ("o0") = (long)(arg1); \
179 register long __o1 __asm__ ("o1") = (long)(arg2); \
180 register long __o2 __asm__ ("o2") = (long)(arg3); \
181 register long __o3 __asm__ ("o3") = (long)(arg4); \
182 register long __o4 __asm__ ("o4") = (long)(arg5); \
183 register long __g1 __asm__ ("g1") = __NR_clone; \
169 long int _arg1 = (long int) (arg1); \
170 long int _arg2 = (long int) (arg2); \
171 long int _arg3 = (long int) (arg3); \
172 long int _arg4 = (long int) (arg4); \
173 long int _arg5 = (long int) (arg5); \
174 register long int __o0 __asm__ ("o0") = _arg1; \
175 register long int __o1 __asm__ ("o1") = _arg2; \
176 register long int __o2 __asm__ ("o2") = _arg3; \
177 register long int __o3 __asm__ ("o3") = _arg4; \
178 register long int __o4 __asm__ ("o4") = _arg5; \
179 register long int __g1 __asm__ ("g1") = __NR_clone; \
184180 __asm __volatile (__SYSCALL_STRING : \
185 "=r" (__g1), "=r" (__o0), "=r" (__o1) : \
186 "0" (__g1), "1" (__o0), "2" (__o1), \
181 "=r" (__o0), "=r" (__o1) : \
182 "r" (__g1), "0" (__o0), "1" (__o1), \
187183 "r" (__o2), "r" (__o3), "r" (__o4) : \
188184 __SYSCALL_CLOBBERS); \
189 if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1)) \
185 if (__glibc_unlikely ((unsigned long int) (__o0) > -4096UL)) \
190186 { \
191 __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1)); \
187 __set_errno (-__o0); \
192188 __o0 = -1L; \
193189 } \
194190 else \
lib/libc/glibc/sysdeps/unix/sysv/linux/sparc/xstatver.h created+13
......@@ -0,0 +1,13 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_LINUX_OLD 1
4#define _STAT_VER_KERNEL 1
5#define _STAT_VER_SVR4 2
6#define _STAT_VER_LINUX 3
7#define _STAT_VER _STAT_VER_LINUX /* The one defined below. */
8
9/* Versions of the 'xmknod' interface used in compatibility xmknod
10 functions. */
11#define _MKNOD_VER_LINUX 1
12#define _MKNOD_VER_SVR4 2
13#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/struct_stat_time64.h created+34
......@@ -0,0 +1,34 @@
1/* Struct stat with 64-bit time support.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _BITS_STRUCT_STAT_TIME64_H
20#define _BITS_STRUCT_STAT_TIME64_H 1
21
22#if __TIMESIZE == 64
23# define __stat64_t64 stat64
24#else
25# include <struct___timespec64.h>
26
27struct __stat64_t64
28 {
29# define __struct_timespec struct __timespec64
30# include <bits/struct_stat_time64_helper.h>
31 };
32#endif /* __TIMESIZE == 64 */
33
34#endif /* _BITS_STRUCT_STAT_TIME64_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/sys/syscall.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/sys/timex.h+24-7
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1995-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1995-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -54,17 +54,34 @@ struct ntptimeval
5454
5555__BEGIN_DECLS
5656
57extern int __adjtimex (struct timex *__ntx) __THROW;
57#ifndef __USE_TIME_BITS64
5858extern int adjtimex (struct timex *__ntx) __THROW;
59extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
5960
60#ifdef __REDIRECT_NTH
61# ifdef __REDIRECT_NTH
6162extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
62 ntp_gettimex);
63 ntp_gettimex);
64# else
65# define ntp_gettime ntp_gettimex
66# endif
67extern int ntp_adjtime (struct timex *__tntx) __THROW;
6368#else
64extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
65# define ntp_gettime ntp_gettimex
69# ifdef __REDIRECT_NTH
70extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
71 ___adjtimex64);
72extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
73 __ntp_gettime64);
74extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
75 __ntp_gettimex64);
76extern int __REDIRECT_NTH (ntp_adjtime, (struct timex *__ntx),
77 ___adjtimex64);
78# else
79# define adjtimex ___adjtimex64
80# define ntp_adjtime ___adjtimex64
81# define ntp_gettime __ntp_gettime64
82# define ntp_gettimex __ntp_gettimex64
83# endif
6684#endif
67extern int ntp_adjtime (struct timex *__tntx) __THROW;
6885
6986__END_DECLS
7087
lib/libc/glibc/sysdeps/unix/sysv/linux/sysdep.h+38-4
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2015-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2015-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -15,8 +15,40 @@
1515 License along with the GNU C Library; if not, see
1616 <https://www.gnu.org/licenses/>. */
1717
18#ifndef _SYSDEP_LINUX_H
19#define _SYSDEP_LINUX_H
20
1821#include <bits/wordsize.h>
1922#include <kernel-features.h>
23#include <endian.h>
24#include <errno.h>
25
26#undef INTERNAL_SYSCALL_ERROR_P
27#define INTERNAL_SYSCALL_ERROR_P(val) \
28 ((unsigned long int) (val) > -4096UL)
29
30#ifndef SYSCALL_ERROR_LABEL
31# define SYSCALL_ERROR_LABEL(sc_err) \
32 ({ \
33 __set_errno (sc_err); \
34 -1L; \
35 })
36#endif
37
38/* Define a macro which expands into the inline wrapper code for a system
39 call. It sets the errno and returns -1 on a failure, or the syscall
40 return value otherwise. */
41#undef INLINE_SYSCALL
42#define INLINE_SYSCALL(name, nr, args...) \
43 ({ \
44 long int sc_ret = INTERNAL_SYSCALL (name, nr, args); \
45 __glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (sc_ret)) \
46 ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (sc_ret)) \
47 : sc_ret; \
48 })
49
50#undef INTERNAL_SYSCALL_ERRNO
51#define INTERNAL_SYSCALL_ERRNO(val) (-(val))
2052
2153/* Set error number and return -1. A target may choose to return the
2254 internal function, __syscall_error, which sets errno and returns -1.
......@@ -63,6 +95,8 @@
6395 (long) (val), \
6496 (long) (((uint64_t) (val)) >> 32)
6597
66/* Exports the __send symbol on send.c linux implementation (some ABI have
67 it missing due the usage of a old generic version without it). */
68#define HAVE_INTERNAL_SEND_SYMBOL 1
98/* Export the ___brk_addr symbol on brk.c implementation (some ABIs export
99 it due and old crtstuff.c code). */
100#define HAVE_INTERNAL_BRK_ADDR_SYMBOL 0
101
102#endif /* _SYSDEP_LINUX_H */
lib/libc/glibc/sysdeps/unix/sysv/linux/x86/bits/stat.h deleted-210
......@@ -1,210 +0,0 @@
1/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#if !defined _SYS_STAT_H && !defined _FCNTL_H
19# error "Never include <bits/stat.h> directly; use <sys/stat.h> instead."
20#endif
21
22#ifndef _BITS_STAT_H
23#define _BITS_STAT_H 1
24
25/* Versions of the `struct stat' data structure. */
26#ifndef __x86_64__
27# define _STAT_VER_LINUX_OLD 1
28# define _STAT_VER_KERNEL 1
29# define _STAT_VER_SVR4 2
30# define _STAT_VER_LINUX 3
31
32/* i386 versions of the `xmknod' interface. */
33# define _MKNOD_VER_LINUX 1
34# define _MKNOD_VER_SVR4 2
35# define _MKNOD_VER _MKNOD_VER_LINUX /* The bits defined below. */
36#else
37# define _STAT_VER_KERNEL 0
38# define _STAT_VER_LINUX 1
39
40/* x86-64 versions of the `xmknod' interface. */
41# define _MKNOD_VER_LINUX 0
42#endif
43
44#define _STAT_VER _STAT_VER_LINUX
45
46struct stat
47 {
48 __dev_t st_dev; /* Device. */
49#ifndef __x86_64__
50 unsigned short int __pad1;
51#endif
52#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
53 __ino_t st_ino; /* File serial number. */
54#else
55 __ino_t __st_ino; /* 32bit file serial number. */
56#endif
57#ifndef __x86_64__
58 __mode_t st_mode; /* File mode. */
59 __nlink_t st_nlink; /* Link count. */
60#else
61 __nlink_t st_nlink; /* Link count. */
62 __mode_t st_mode; /* File mode. */
63#endif
64 __uid_t st_uid; /* User ID of the file's owner. */
65 __gid_t st_gid; /* Group ID of the file's group.*/
66#ifdef __x86_64__
67 int __pad0;
68#endif
69 __dev_t st_rdev; /* Device number, if device. */
70#ifndef __x86_64__
71 unsigned short int __pad2;
72#endif
73#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
74 __off_t st_size; /* Size of file, in bytes. */
75#else
76 __off64_t st_size; /* Size of file, in bytes. */
77#endif
78 __blksize_t st_blksize; /* Optimal block size for I/O. */
79#if defined __x86_64__ || !defined __USE_FILE_OFFSET64
80 __blkcnt_t st_blocks; /* Number 512-byte blocks allocated. */
81#else
82 __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */
83#endif
84#ifdef __USE_XOPEN2K8
85 /* Nanosecond resolution timestamps are stored in a format
86 equivalent to 'struct timespec'. This is the type used
87 whenever possible but the Unix namespace rules do not allow the
88 identifier 'timespec' to appear in the <sys/stat.h> header.
89 Therefore we have to handle the use of this header in strictly
90 standard-compliant sources special. */
91 struct timespec st_atim; /* Time of last access. */
92 struct timespec st_mtim; /* Time of last modification. */
93 struct timespec st_ctim; /* Time of last status change. */
94# define st_atime st_atim.tv_sec /* Backward compatibility. */
95# define st_mtime st_mtim.tv_sec
96# define st_ctime st_ctim.tv_sec
97#else
98 __time_t st_atime; /* Time of last access. */
99 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
100 __time_t st_mtime; /* Time of last modification. */
101 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
102 __time_t st_ctime; /* Time of last status change. */
103 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
104#endif
105#ifdef __x86_64__
106 __syscall_slong_t __glibc_reserved[3];
107#else
108# ifndef __USE_FILE_OFFSET64
109 unsigned long int __glibc_reserved4;
110 unsigned long int __glibc_reserved5;
111# else
112 __ino64_t st_ino; /* File serial number. */
113# endif
114#endif
115 };
116
117#ifdef __USE_LARGEFILE64
118/* Note stat64 has the same shape as stat for x86-64. */
119struct stat64
120 {
121 __dev_t st_dev; /* Device. */
122# ifdef __x86_64__
123 __ino64_t st_ino; /* File serial number. */
124 __nlink_t st_nlink; /* Link count. */
125 __mode_t st_mode; /* File mode. */
126# else
127 unsigned int __pad1;
128 __ino_t __st_ino; /* 32bit file serial number. */
129 __mode_t st_mode; /* File mode. */
130 __nlink_t st_nlink; /* Link count. */
131# endif
132 __uid_t st_uid; /* User ID of the file's owner. */
133 __gid_t st_gid; /* Group ID of the file's group.*/
134# ifdef __x86_64__
135 int __pad0;
136 __dev_t st_rdev; /* Device number, if device. */
137 __off_t st_size; /* Size of file, in bytes. */
138# else
139 __dev_t st_rdev; /* Device number, if device. */
140 unsigned int __pad2;
141 __off64_t st_size; /* Size of file, in bytes. */
142# endif
143 __blksize_t st_blksize; /* Optimal block size for I/O. */
144 __blkcnt64_t st_blocks; /* Nr. 512-byte blocks allocated. */
145# ifdef __USE_XOPEN2K8
146 /* Nanosecond resolution timestamps are stored in a format
147 equivalent to 'struct timespec'. This is the type used
148 whenever possible but the Unix namespace rules do not allow the
149 identifier 'timespec' to appear in the <sys/stat.h> header.
150 Therefore we have to handle the use of this header in strictly
151 standard-compliant sources special. */
152 struct timespec st_atim; /* Time of last access. */
153 struct timespec st_mtim; /* Time of last modification. */
154 struct timespec st_ctim; /* Time of last status change. */
155# else
156 __time_t st_atime; /* Time of last access. */
157 __syscall_ulong_t st_atimensec; /* Nscecs of last access. */
158 __time_t st_mtime; /* Time of last modification. */
159 __syscall_ulong_t st_mtimensec; /* Nsecs of last modification. */
160 __time_t st_ctime; /* Time of last status change. */
161 __syscall_ulong_t st_ctimensec; /* Nsecs of last status change. */
162# endif
163# ifdef __x86_64__
164 __syscall_slong_t __glibc_reserved[3];
165# else
166 __ino64_t st_ino; /* File serial number. */
167# endif
168 };
169#endif
170
171/* Tell code we have these members. */
172#define _STATBUF_ST_BLKSIZE
173#define _STATBUF_ST_RDEV
174/* Nanosecond resolution time values are supported. */
175#define _STATBUF_ST_NSEC
176
177/* Encoding of the file mode. */
178
179#define __S_IFMT 0170000 /* These bits determine file type. */
180
181/* File types. */
182#define __S_IFDIR 0040000 /* Directory. */
183#define __S_IFCHR 0020000 /* Character device. */
184#define __S_IFBLK 0060000 /* Block device. */
185#define __S_IFREG 0100000 /* Regular file. */
186#define __S_IFIFO 0010000 /* FIFO. */
187#define __S_IFLNK 0120000 /* Symbolic link. */
188#define __S_IFSOCK 0140000 /* Socket. */
189
190/* POSIX.1b objects. Note that these macros always evaluate to zero. But
191 they do it by enforcing the correct use of the macros. */
192#define __S_TYPEISMQ(buf) ((buf)->st_mode - (buf)->st_mode)
193#define __S_TYPEISSEM(buf) ((buf)->st_mode - (buf)->st_mode)
194#define __S_TYPEISSHM(buf) ((buf)->st_mode - (buf)->st_mode)
195
196/* Protection bits. */
197
198#define __S_ISUID 04000 /* Set user ID on execution. */
199#define __S_ISGID 02000 /* Set group ID on execution. */
200#define __S_ISVTX 01000 /* Save swapped text after use (sticky). */
201#define __S_IREAD 0400 /* Read by owner. */
202#define __S_IWRITE 0200 /* Write by owner. */
203#define __S_IEXEC 0100 /* Execute by owner. */
204
205#ifdef __USE_ATFILE
206# define UTIME_NOW ((1l << 30) - 1l)
207# define UTIME_OMIT ((1l << 30) - 2l)
208#endif
209
210#endif /* bits/stat.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/x86/bits/typesizes.h+7-1
......@@ -1,5 +1,5 @@
11/* bits/typesizes.h -- underlying types for *_t. Linux/x86-64 version.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -64,6 +64,7 @@
6464#define __TIME_T_TYPE __SYSCALL_SLONG_TYPE
6565#define __USECONDS_T_TYPE __U32_TYPE
6666#define __SUSECONDS_T_TYPE __SYSCALL_SLONG_TYPE
67#define __SUSECONDS64_T_TYPE __SQUAD_TYPE
6768#define __DADDR_T_TYPE __S32_TYPE
6869#define __KEY_T_TYPE __S32_TYPE
6970#define __CLOCKID_T_TYPE __S32_TYPE
......@@ -87,10 +88,15 @@
8788
8889/* And for fsblkcnt_t, fsblkcnt64_t, fsfilcnt_t and fsfilcnt64_t. */
8990# define __STATFS_MATCHES_STATFS64 1
91
92/* And for getitimer, setitimer and rusage */
93# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 1
9094#else
9195# define __RLIM_T_MATCHES_RLIM64_T 0
9296
9397# define __STATFS_MATCHES_STATFS64 0
98
99# define __KERNEL_OLD_TIMEVAL_MATCHES_TIMEVAL64 0
94100#endif
95101
96102/* Number of descriptors that can fit in an `fd_set'. */
lib/libc/glibc/sysdeps/unix/sysv/linux/x86/sys/elf.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1998-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1998-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/x86/xstatver.h created+16
......@@ -0,0 +1,16 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#ifndef __x86_64__
4# define _STAT_VER_LINUX_OLD 1
5# define _STAT_VER_KERNEL 1
6# define _STAT_VER_SVR4 2
7# define _STAT_VER_LINUX 3
8# define _MKNOD_VER_LINUX 1
9# define _MKNOD_VER_SVR4 2
10#else
11# define _STAT_VER_KERNEL 0
12# define _STAT_VER_LINUX 1
13# define _MKNOD_VER_LINUX 0
14#endif
15#define _STAT_VER _STAT_VER_LINUX
16#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/sysv/linux/x86_64/kernel-features.h+1-1
......@@ -1,6 +1,6 @@
11/* Set flags signalling availability of kernel features based on given
22 kernel version number. x86-64 version.
3 Copyright (C) 1999-2020 Free Software Foundation, Inc.
3 Copyright (C) 1999-2021 Free Software Foundation, Inc.
44 This file is part of the GNU C Library.
55
66 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/unix/sysv/linux/x86_64/sysdep.h+83-74
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -33,13 +33,6 @@
3333#undef SYS_ify
3434#define SYS_ify(syscall_name) __NR_##syscall_name
3535
36/* This is to help the old kernel headers where __NR_semtimedop is not
37 available. */
38#ifndef __NR_semtimedop
39# define __NR_semtimedop 220
40#endif
41
42
4336#ifdef __ASSEMBLER__
4437
4538/* Linux uses a negative return value to indicate syscall errors,
......@@ -55,19 +48,40 @@
5548
5649/* We don't want the label for the error handle to be global when we define
5750 it here. */
51# undef SYSCALL_ERROR_LABEL
5852# ifdef PIC
53# undef SYSCALL_ERROR_LABEL
5954# define SYSCALL_ERROR_LABEL 0f
6055# else
56# undef SYSCALL_ERROR_LABEL
6157# define SYSCALL_ERROR_LABEL syscall_error
6258# endif
6359
60/* PSEUDO and T_PSEUDO macros have 2 extra arguments for unsigned long
61 int arguments. */
62# define PSEUDOS_HAVE_ULONG_INDICES 1
63
64# ifndef SYSCALL_ULONG_ARG_1
65# define SYSCALL_ULONG_ARG_1 0
66# define SYSCALL_ULONG_ARG_2 0
67# endif
68
6469# undef PSEUDO
65# define PSEUDO(name, syscall_name, args) \
66 .text; \
67 ENTRY (name) \
68 DO_CALL (syscall_name, args); \
69 cmpq $-4095, %rax; \
70# if SYSCALL_ULONG_ARG_1
71# define PSEUDO(name, syscall_name, args, ulong_arg_1, ulong_arg_2) \
72 .text; \
73 ENTRY (name) \
74 DO_CALL (syscall_name, args, ulong_arg_1, ulong_arg_2); \
75 cmpq $-4095, %rax; \
76 jae SYSCALL_ERROR_LABEL
77# else
78# define PSEUDO(name, syscall_name, args) \
79 .text; \
80 ENTRY (name) \
81 DO_CALL (syscall_name, args, 0, 0); \
82 cmpq $-4095, %rax; \
7083 jae SYSCALL_ERROR_LABEL
84# endif
7185
7286# undef PSEUDO_END
7387# define PSEUDO_END(name) \
......@@ -75,10 +89,17 @@
7589 END (name)
7690
7791# undef PSEUDO_NOERRNO
78# define PSEUDO_NOERRNO(name, syscall_name, args) \
79 .text; \
80 ENTRY (name) \
81 DO_CALL (syscall_name, args)
92# if SYSCALL_ULONG_ARG_1
93# define PSEUDO_NOERRNO(name, syscall_name, args, ulong_arg_1, ulong_arg_2) \
94 .text; \
95 ENTRY (name) \
96 DO_CALL (syscall_name, args, ulong_arg_1, ulong_arg_2)
97# else
98# define PSEUDO_NOERRNO(name, syscall_name, args) \
99 .text; \
100 ENTRY (name) \
101 DO_CALL (syscall_name, args, 0, 0)
102# endif
82103
83104# undef PSEUDO_END_NOERRNO
84105# define PSEUDO_END_NOERRNO(name) \
......@@ -87,11 +108,19 @@
87108# define ret_NOERRNO ret
88109
89110# undef PSEUDO_ERRVAL
90# define PSEUDO_ERRVAL(name, syscall_name, args) \
91 .text; \
92 ENTRY (name) \
93 DO_CALL (syscall_name, args); \
111# if SYSCALL_ULONG_ARG_1
112# define PSEUDO_ERRVAL(name, syscall_name, args, ulong_arg_1, ulong_arg_2) \
113 .text; \
114 ENTRY (name) \
115 DO_CALL (syscall_name, args, ulong_arg_1, ulong_arg_2); \
116 negq %rax
117# else
118# define PSEUDO_ERRVAL(name, syscall_name, args) \
119 .text; \
120 ENTRY (name) \
121 DO_CALL (syscall_name, args, 0, 0); \
94122 negq %rax
123# endif
95124
96125# undef PSEUDO_END_ERRVAL
97126# define PSEUDO_END_ERRVAL(name) \
......@@ -163,8 +192,10 @@
163192 Syscalls of more than 6 arguments are not supported. */
164193
165194# undef DO_CALL
166# define DO_CALL(syscall_name, args) \
195# define DO_CALL(syscall_name, args, ulong_arg_1, ulong_arg_2) \
167196 DOARGS_##args \
197 ZERO_EXTEND_##ulong_arg_1 \
198 ZERO_EXTEND_##ulong_arg_2 \
168199 movl $SYS_ify (syscall_name), %eax; \
169200 syscall;
170201
......@@ -176,57 +207,39 @@
176207# define DOARGS_5 DOARGS_4
177208# define DOARGS_6 DOARGS_5
178209
210# define ZERO_EXTEND_0 /* nothing */
211# define ZERO_EXTEND_1 /* nothing */
212# define ZERO_EXTEND_2 /* nothing */
213# define ZERO_EXTEND_3 /* nothing */
214# define ZERO_EXTEND_4 /* nothing */
215# define ZERO_EXTEND_5 /* nothing */
216# define ZERO_EXTEND_6 /* nothing */
217
179218#else /* !__ASSEMBLER__ */
180/* Define a macro which expands inline into the wrapper code for a system
181 call. */
182# undef INLINE_SYSCALL
183# define INLINE_SYSCALL(name, nr, args...) \
184 ({ \
185 unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
186 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
187 { \
188 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
189 resultvar = (unsigned long int) -1; \
190 } \
191 (long int) resultvar; })
192
193/* Define a macro with explicit types for arguments, which expands inline
194 into the wrapper code for a system call. It should be used when size
195 of any argument > size of long int. */
196# undef INLINE_SYSCALL_TYPES
197# define INLINE_SYSCALL_TYPES(name, nr, args...) \
198 ({ \
199 unsigned long int resultvar = INTERNAL_SYSCALL_TYPES (name, , nr, args); \
200 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
201 { \
202 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
203 resultvar = (unsigned long int) -1; \
204 } \
205 (long int) resultvar; })
206
207# undef INTERNAL_SYSCALL_DECL
208# define INTERNAL_SYSCALL_DECL(err) do { } while (0)
209219
210220/* Registers clobbered by syscall. */
211221# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
212222
213/* Create a variable 'name' based on type 'X' to avoid explicit types.
214 This is mainly used set use 64-bits arguments in x32. */
215#define TYPEFY(X, name) __typeof__ ((X) - (X)) name
216/* Explicit cast the argument to avoid integer from pointer warning on
217 x32. */
218#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))
223/* NB: This also works when X is an array. For an array X, type of
224 (X) - (X) is ptrdiff_t, which is signed, since size of ptrdiff_t
225 == size of pointer, cast is a NOP. */
226#define TYPEFY1(X) __typeof__ ((X) - (X))
227/* Explicit cast the argument. */
228#define ARGIFY(X) ((TYPEFY1 (X)) (X))
229/* Create a variable 'name' based on type of variable 'X' to avoid
230 explicit types. */
231#define TYPEFY(X, name) __typeof__ (ARGIFY (X)) name
219232
220233#undef INTERNAL_SYSCALL
221#define INTERNAL_SYSCALL(name, err, nr, args...) \
222 internal_syscall##nr (SYS_ify (name), err, args)
234#define INTERNAL_SYSCALL(name, nr, args...) \
235 internal_syscall##nr (SYS_ify (name), args)
223236
224237#undef INTERNAL_SYSCALL_NCS
225#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
226 internal_syscall##nr (number, err, args)
238#define INTERNAL_SYSCALL_NCS(number, nr, args...) \
239 internal_syscall##nr (number, args)
227240
228241#undef internal_syscall0
229#define internal_syscall0(number, err, dummy...) \
242#define internal_syscall0(number, dummy...) \
230243({ \
231244 unsigned long int resultvar; \
232245 asm volatile ( \
......@@ -238,7 +251,7 @@
238251})
239252
240253#undef internal_syscall1
241#define internal_syscall1(number, err, arg1) \
254#define internal_syscall1(number, arg1) \
242255({ \
243256 unsigned long int resultvar; \
244257 TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
......@@ -252,7 +265,7 @@
252265})
253266
254267#undef internal_syscall2
255#define internal_syscall2(number, err, arg1, arg2) \
268#define internal_syscall2(number, arg1, arg2) \
256269({ \
257270 unsigned long int resultvar; \
258271 TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
......@@ -268,7 +281,7 @@
268281})
269282
270283#undef internal_syscall3
271#define internal_syscall3(number, err, arg1, arg2, arg3) \
284#define internal_syscall3(number, arg1, arg2, arg3) \
272285({ \
273286 unsigned long int resultvar; \
274287 TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
......@@ -286,7 +299,7 @@
286299})
287300
288301#undef internal_syscall4
289#define internal_syscall4(number, err, arg1, arg2, arg3, arg4) \
302#define internal_syscall4(number, arg1, arg2, arg3, arg4) \
290303({ \
291304 unsigned long int resultvar; \
292305 TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
......@@ -306,7 +319,7 @@
306319})
307320
308321#undef internal_syscall5
309#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5) \
322#define internal_syscall5(number, arg1, arg2, arg3, arg4, arg5) \
310323({ \
311324 unsigned long int resultvar; \
312325 TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
......@@ -329,7 +342,7 @@
329342})
330343
331344#undef internal_syscall6
332#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \
345#define internal_syscall6(number, arg1, arg2, arg3, arg4, arg5, arg6) \
333346({ \
334347 unsigned long int resultvar; \
335348 TYPEFY (arg6, __arg6) = ARGIFY (arg6); \
......@@ -353,12 +366,6 @@
353366 (long int) resultvar; \
354367})
355368
356# undef INTERNAL_SYSCALL_ERROR_P
357# define INTERNAL_SYSCALL_ERROR_P(val, err) \
358 ((unsigned long int) (long int) (val) >= -4095L)
359
360# undef INTERNAL_SYSCALL_ERRNO
361# define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
362369
363370# define VDSO_NAME "LINUX_2.6"
364371# define VDSO_HASH 61765110
......@@ -370,6 +377,8 @@
370377# define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
371378# define HAVE_CLOCK_GETRES64_VSYSCALL "__vdso_clock_getres"
372379
380# define HAVE_CLONE3_WRAPPER 1
381
373382# define SINGLE_THREAD_BY_GLOBAL 1
374383
375384#endif /* __ASSEMBLER__ */
lib/libc/glibc/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h+36-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2012-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2012-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
......@@ -26,4 +26,39 @@
2626#undef LO_HI_LONG
2727#define LO_HI_LONG(val) (val)
2828
29#ifdef __ASSEMBLER__
30/* Zero-extend 32-bit unsigned long int arguments to 64 bits. */
31# undef ZERO_EXTEND_1
32# define ZERO_EXTEND_1 movl %edi, %edi;
33# undef ZERO_EXTEND_2
34# define ZERO_EXTEND_2 movl %esi, %esi;
35# undef ZERO_EXTEND_3
36# define ZERO_EXTEND_3 movl %edx, %edx;
37# if SYSCALL_ULONG_ARG_1 == 4 || SYSCALL_ULONG_ARG_2 == 4
38# undef DOARGS_4
39# define DOARGS_4 movl %ecx, %r10d;
40# else
41# undef ZERO_EXTEND_4
42# define ZERO_EXTEND_4 movl %r10d, %r10d;
43# endif
44# undef ZERO_EXTEND_5
45# define ZERO_EXTEND_5 movl %r8d, %r8d;
46# undef ZERO_EXTEND_6
47# define ZERO_EXTEND_6 movl %r9d, %r9d;
48#else /* !__ASSEMBLER__ */
49# undef ARGIFY
50/* Enforce zero-extension for pointers and array system call arguments.
51 For integer types, extend to int64_t (the full register) using a
52 regular cast, resulting in zero or sign extension based on the
53 signedness of the original type. */
54# define ARGIFY(X) \
55 ({ \
56 _Pragma ("GCC diagnostic push"); \
57 _Pragma ("GCC diagnostic ignored \"-Wpointer-to-int-cast\""); \
58 (__builtin_classify_type (X) == 5 \
59 ? (uintptr_t) (X) : (int64_t) (X)); \
60 _Pragma ("GCC diagnostic pop"); \
61 })
62#endif /* __ASSEMBLER__ */
63
2964#endif /* linux/x86_64/x32/sysdep.h */
lib/libc/glibc/sysdeps/unix/sysv/linux/xstatver.h created+13
......@@ -0,0 +1,13 @@
1/* Versions of the 'struct stat' data structure used in compatibility xstat
2 functions. */
3#define _STAT_VER_LINUX_OLD 1
4#define _STAT_VER_KERNEL 1
5#define _STAT_VER_SVR4 2
6#define _STAT_VER_LINUX 3
7#define _STAT_VER _STAT_VER_LINUX
8
9/* Versions of the 'xmknod' interface used in compatibility xmknod
10 functions. */
11#define _MKNOD_VER_LINUX 1
12#define _MKNOD_VER_SVR4 2
13#define _MKNOD_VER _MKNOD_VER_LINUX
lib/libc/glibc/sysdeps/unix/x86_64/sysdep.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
1/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/wordsize-32/divdi3-symbol-hacks.h+1-1
......@@ -1,5 +1,5 @@
11/* Hacks needed for divdi3 symbol manipulation.
2 Copyright (C) 2004-2020 Free Software Foundation, Inc.
2 Copyright (C) 2004-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/x86/bits/select.h deleted-63
......@@ -1,63 +0,0 @@
1/* Copyright (C) 1997-2020 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <https://www.gnu.org/licenses/>. */
17
18#ifndef _SYS_SELECT_H
19# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
20#endif
21
22#include <bits/wordsize.h>
23
24
25#if defined __GNUC__ && __GNUC__ >= 2
26
27# if __WORDSIZE == 64
28# define __FD_ZERO_STOS "stosq"
29# else
30# define __FD_ZERO_STOS "stosl"
31# endif
32
33# define __FD_ZERO(fdsp) \
34 do { \
35 int __d0, __d1; \
36 __asm__ __volatile__ ("cld; rep; " __FD_ZERO_STOS \
37 : "=c" (__d0), "=D" (__d1) \
38 : "a" (0), "0" (sizeof (fd_set) \
39 / sizeof (__fd_mask)), \
40 "1" (&__FDS_BITS (fdsp)[0]) \
41 : "memory"); \
42 } while (0)
43
44#else /* ! GNU CC */
45
46/* We don't use `memset' because this would require a prototype and
47 the array isn't too big. */
48# define __FD_ZERO(set) \
49 do { \
50 unsigned int __i; \
51 fd_set *__arr = (set); \
52 for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
53 __FDS_BITS (__arr)[__i] = 0; \
54 } while (0)
55
56#endif /* GNU CC */
57
58#define __FD_SET(d, set) \
59 ((void) (__FDS_BITS (set)[__FD_ELT (d)] |= __FD_MASK (d)))
60#define __FD_CLR(d, set) \
61 ((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
62#define __FD_ISSET(d, set) \
63 ((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
lib/libc/glibc/sysdeps/x86/nptl/bits/pthreadtypes-arch.h+1-1
......@@ -1,4 +1,4 @@
1/* Copyright (C) 2002-2020 Free Software Foundation, Inc.
1/* Copyright (C) 2002-2021 Free Software Foundation, Inc.
22 This file is part of the GNU C Library.
33
44 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/x86/sysdep.h+6-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for x86.
2 Copyright (C) 2017-2020 Free Software Foundation, Inc.
2 Copyright (C) 2017-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -57,6 +57,11 @@ enum cf_protection_level
5757#define STATE_SAVE_MASK \
5858 ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | (1 << 7))
5959
60/* Constants for bits in __x86_string_control: */
61
62/* Avoid short distance REP MOVSB. */
63#define X86_STRING_CONTROL_AVOID_SHORT_DISTANCE_REP_MOVSB (1 << 0)
64
6065#ifdef __ASSEMBLER__
6166
6267/* Syntactic details of assembler. */
lib/libc/glibc/sysdeps/x86_64/crti.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/x86_64/crtn.S+1-1
......@@ -1,5 +1,5 @@
11/* Special .init and .fini section support for x86-64.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/sysdeps/x86_64/start.S+5-9
......@@ -1,5 +1,5 @@
11/* Startup code compliant to the ELF x86-64 ABI.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44 Contributed by Andreas Jaeger <aj@suse.de>, 2001.
55
......@@ -96,17 +96,13 @@ ENTRY (_start)
9696 which grow downwards). */
9797 pushq %rsp
9898
99#ifdef PIC
100 /* Pass address of our own entry points to .fini and .init. */
101 mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
102 mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
99 /* These used to be the addresses of .fini and .init. */
100 xorl %r8d, %r8d
101 xorl %ecx, %ecx
103102
103#ifdef PIC
104104 mov main@GOTPCREL(%rip), %RDI_LP
105105#else
106 /* Pass address of our own entry points to .fini and .init. */
107 mov $__libc_csu_fini, %R8_LP
108 mov $__libc_csu_init, %RCX_LP
109
110106 mov $main, %RDI_LP
111107#endif
112108
lib/libc/glibc/sysdeps/x86_64/sysdep.h+23-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for x86-64.
2 Copyright (C) 2001-2020 Free Software Foundation, Inc.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
......@@ -95,6 +95,28 @@ lose: \
9595#define R14_LP r14
9696#define R15_LP r15
9797
98/* Zero upper vector registers and return with xtest. NB: Use VZEROALL
99 to avoid RTM abort triggered by VZEROUPPER inside transactionally. */
100#define ZERO_UPPER_VEC_REGISTERS_RETURN_XTEST \
101 xtest; \
102 jz 1f; \
103 vzeroall; \
104 ret; \
1051: \
106 vzeroupper; \
107 ret
108
109/* Zero upper vector registers and return. */
110#ifndef ZERO_UPPER_VEC_REGISTERS_RETURN
111# define ZERO_UPPER_VEC_REGISTERS_RETURN \
112 VZEROUPPER; \
113 ret
114#endif
115
116#ifndef VZEROUPPER_RETURN
117# define VZEROUPPER_RETURN VZEROUPPER; ret
118#endif
119
98120#else /* __ASSEMBLER__ */
99121
100122/* Long and pointer size in bytes. */
lib/libc/glibc/sysdeps/x86_64/x32/sysdep.h+1-1
......@@ -1,5 +1,5 @@
11/* Assembler macros for x32.
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
2 Copyright (C) 2012-2021 Free Software Foundation, Inc.
33 This file is part of the GNU C Library.
44
55 The GNU C Library is free software; you can redistribute it and/or
lib/libc/glibc/time/bits/types/struct_timespec.h+6-1
......@@ -4,15 +4,20 @@
44
55#include <bits/types.h>
66#include <bits/endian.h>
7#include <bits/types/time_t.h>
78
89/* POSIX.1b structure for a time value. This is like a `struct timeval' but
910 has nanoseconds instead of microseconds. */
1011struct timespec
1112{
13#ifdef __USE_TIME_BITS64
14 __time64_t tv_sec; /* Seconds. */
15#else
1216 __time_t tv_sec; /* Seconds. */
17#endif
1318#if __WORDSIZE == 64 \
1419 || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
15 || __TIMESIZE == 32
20 || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
1621 __syscall_slong_t tv_nsec; /* Nanoseconds. */
1722#else
1823# if __BYTE_ORDER == __BIG_ENDIAN
lib/libc/glibc/time/bits/types/struct_timeval.h+5
......@@ -7,7 +7,12 @@
77 microsecond but also has a range of years. */
88struct timeval
99{
10#ifdef __USE_TIME_BITS64
11 __time64_t tv_sec; /* Seconds. */
12 __suseconds64_t tv_usec; /* Microseconds. */
13#else
1014 __time_t tv_sec; /* Seconds. */
1115 __suseconds_t tv_usec; /* Microseconds. */
16#endif
1217};
1318#endif
lib/libc/glibc/time/bits/types/time_t.h+4
......@@ -4,6 +4,10 @@
44#include <bits/types.h>
55
66/* Returned by `time'. */
7#ifdef __USE_TIME_BITS64
8typedef __time64_t time_t;
9#else
710typedef __time_t time_t;
11#endif
812
913#endif
src/glibc.zig+5-38
......@@ -282,46 +282,13 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
282282 lib_libc_glibc ++ "io" ++ path.sep_str ++ "fstatat64.c",
283283 lib_libc_glibc ++ "io" ++ path.sep_str ++ "mknod.c",
284284 lib_libc_glibc ++ "io" ++ path.sep_str ++ "mknodat.c",
285 lib_libc_glibc ++ "nptl" ++ path.sep_str ++ "pthread_atfork.c",
285 lib_libc_glibc ++ "sysdeps" ++ path.sep_str ++ "pthread" ++ path.sep_str ++
286 "pthread_atfork.c",
286287 lib_libc_glibc ++ "debug" ++ path.sep_str ++ "stack_chk_fail_local.c",
288 lib_libc_glibc ++ "csu" ++ path.sep_str ++ "errno.c",
287289 };
288290
289 var c_source_files: [deps.len + 1]Compilation.CSourceFile = undefined;
290
291 c_source_files[0] = blk: {
292 var args = std.ArrayList([]const u8).init(arena);
293 try args.appendSlice(&[_][]const u8{
294 "-std=gnu11",
295 "-fgnu89-inline",
296 "-fmerge-all-constants",
297 "-fno-stack-protector",
298 "-fmath-errno",
299 "-fno-stack-protector",
300 "-I",
301 try lib_path(comp, arena, lib_libc_glibc ++ "csu"),
302 });
303 try add_include_dirs(comp, arena, &args);
304 try args.appendSlice(&[_][]const u8{
305 "-DSTACK_PROTECTOR_LEVEL=0",
306 "-fPIC",
307 "-fno-stack-protector",
308 "-ftls-model=initial-exec",
309 "-D_LIBC_REENTRANT",
310 "-include",
311 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-modules.h"),
312 "-DMODULE_NAME=libc",
313 "-Wno-nonportable-include-path",
314 "-include",
315 try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"),
316 "-DPIC",
317 "-DLIBC_NONSHARED=1",
318 "-DTOP_NAMESPACE=glibc",
319 });
320 break :blk .{
321 .src_path = try lib_path(comp, arena, lib_libc_glibc ++ "csu" ++ path.sep_str ++ "elf-init.c"),
322 .extra_flags = args.items,
323 };
324 };
291 var c_source_files: [deps.len]Compilation.CSourceFile = undefined;
325292
326293 for (deps) |dep, i| {
327294 var args = std.ArrayList([]const u8).init(arena);
......@@ -347,7 +314,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
347314 "-DLIBC_NONSHARED=1",
348315 "-DTOP_NAMESPACE=glibc",
349316 });
350 c_source_files[i + 1] = .{
317 c_source_files[i] = .{
351318 .src_path = try lib_path(comp, arena, dep),
352319 .extra_flags = args.items,
353320 };
test/standalone.zig+1
......@@ -84,5 +84,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
8484 cases.add("tools/gen_stubs.zig");
8585 cases.add("tools/update_clang_options.zig");
8686 cases.add("tools/update_cpu_features.zig");
87 cases.add("tools/update_glibc.zig");
8788 cases.add("tools/update_spirv_features.zig");
8889}
tools/update_glibc.zig created+71
......@@ -0,0 +1,71 @@
1//! This script updates the .c, .h, .s, and .S files that make up the start
2//! files such as crt1.o. Not to be confused with
3//! https://github.com/ziglang/glibc-abi-tool/ which updates the `abilists`
4//! file.
5//!
6//! Example usage:
7//! `zig run ../tools/update_glibc.zig -- ~/Downloads/glibc ..`
8
9const std = @import("std");
10const mem = std.mem;
11const log = std.log;
12const fs = std.fs;
13
14const exempt_files = [_][]const u8{
15 "abilists",
16 "include/libc-modules.h",
17 "include/config.h",
18 // These are easier to maintain like this, without updating to the abi-note.c
19 // that glibc did upstream.
20 "csu/abi-tag.h",
21 "csu/abi-note.S",
22};
23
24pub fn main() !void {
25 var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator);
26 defer arena_instance.deinit();
27 const arena = arena_instance.allocator();
28
29 const args = try std.process.argsAlloc(arena);
30 const glibc_src_path = args[1];
31 const zig_src_path = args[2];
32
33 const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/glibc", .{zig_src_path});
34
35 var dest_dir = fs.cwd().openDir(dest_dir_path, .{ .iterate = true }) catch |err| {
36 fatal("unable to open destination directory '{s}': {s}", .{
37 dest_dir_path, @errorName(err),
38 });
39 };
40 defer dest_dir.close();
41
42 var glibc_src_dir = try fs.cwd().openDir(glibc_src_path, .{});
43 defer glibc_src_dir.close();
44
45 var walker = try dest_dir.walk(arena);
46 defer walker.deinit();
47
48 walk: while (try walker.next()) |entry| {
49 if (entry.kind != .File) continue;
50 if (mem.startsWith(u8, entry.basename, ".")) continue;
51 for (exempt_files) |p| {
52 if (mem.eql(u8, entry.path, p)) continue :walk;
53 }
54
55 glibc_src_dir.copyFile(entry.path, dest_dir, entry.path, .{}) catch |err| {
56 log.warn("unable to copy '{s}/{s}' to '{s}/{s}': {s}", .{
57 glibc_src_path, entry.path,
58 dest_dir_path, entry.path,
59 @errorName(err),
60 });
61 if (err == error.FileNotFound) {
62 try dest_dir.deleteFile(entry.path);
63 }
64 };
65 }
66}
67
68fn fatal(comptime format: []const u8, args: anytype) noreturn {
69 log.err(format, args);
70 std.process.exit(1);
71}