Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add loongarch64-linux-gnusf target support #21499

Merged
merged 5 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified lib/libc/glibc/abilists
Binary file not shown.
11 changes: 11 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/endianness.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _BITS_ENDIANNESS_H
#define _BITS_ENDIANNESS_H 1

#ifndef _BITS_ENDIAN_H
#error "Never use <bits/endianness.h> directly; include <endian.h> instead."
#endif

/* LoongArch is little-endian. */
#define __BYTE_ORDER __LITTLE_ENDIAN

#endif /* bits/endianness.h */
61 changes: 61 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/fcntl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/* O_*, F_*, FD_* bit values for the generic Linux/LoongArch ABI.
Copyright (C) 2022-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */

#ifndef _FCNTL_H
#error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
#endif

#include <bits/wordsize.h>

/* In 64-bit ISA files are always with 64bit off_t and F_*LK64 are the same as
non-64-bit versions. It will need to be revised for 128-bit. */
#if __WORDSIZE == 64
#define __O_LARGEFILE 0

#define F_GETLK64 5 /* Get record locking info. */
#define F_SETLK64 6 /* Set record locking info (non-blocking). */
#define F_SETLKW64 7 /* Set record locking info (blocking). */
#endif

struct flock
{
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
#ifndef __USE_FILE_OFFSET64
__off_t l_start; /* Offset where the lock begins. */
__off_t l_len; /* Size of the locked area; zero means until EOF. */
#else
__off64_t l_start; /* Offset where the lock begins. */
__off64_t l_len; /* Size of the locked area; zero means until EOF. */
#endif
__pid_t l_pid; /* Process holding the lock. */
};

#ifdef __USE_LARGEFILE64
struct flock64
{
short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
__off64_t l_start; /* Offset where the lock begins. */
__off64_t l_len; /* Size of the locked area; zero means until EOF. */
__pid_t l_pid; /* Process holding the lock. */
};
#endif

/* Include generic Linux declarations. */
#include <bits/fcntl-linux.h>
90 changes: 90 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/fenv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/* Floating point environment.
Copyright (C) 2022-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */

#ifndef _FENV_H
#error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
#endif

/* Define bits representing the exception. We use the bit positions
of the appropriate bits in the FPU control word. */
enum
{
FE_INEXACT =
#define FE_INEXACT 0x010000
FE_INEXACT,
FE_UNDERFLOW =
#define FE_UNDERFLOW 0x020000
FE_UNDERFLOW,
FE_OVERFLOW =
#define FE_OVERFLOW 0x040000
FE_OVERFLOW,
FE_DIVBYZERO =
#define FE_DIVBYZERO 0x080000
FE_DIVBYZERO,
FE_INVALID =
#define FE_INVALID 0x100000
FE_INVALID,
};

#define FE_ALL_EXCEPT \
(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)

/* The LoongArch FPU supports all of the four defined rounding modes. We
use again the bit positions in the FPU control word as the values
for the appropriate macros. */
enum
{
FE_TONEAREST =
#define FE_TONEAREST 0x000
FE_TONEAREST,
FE_TOWARDZERO =
#define FE_TOWARDZERO 0x100
FE_TOWARDZERO,
FE_UPWARD =
#define FE_UPWARD 0x200
FE_UPWARD,
FE_DOWNWARD =
#define FE_DOWNWARD 0x300
FE_DOWNWARD
};

/* Type representing exception flags. */
typedef unsigned int fexcept_t;

/* Type representing floating-point environment. This function corresponds
to the layout of the block written by the `fstenv'. */
typedef struct
{
unsigned int __fp_control_register;
} fenv_t;

/* If the default argument is used we use this value. */
#define FE_DFL_ENV ((const fenv_t *) -1)

#ifdef __USE_GNU
/* Floating-point environment where none of the exception is masked. */
#define FE_NOMASK_ENV ((const fenv_t *) -257)
#endif

#if __GLIBC_USE (IEC_60559_BFP_EXT_C23)
/* Type representing floating-point control modes. */
typedef unsigned int femode_t;

/* Default floating-point control modes. */
#define FE_DFL_MODE ((const femode_t *) -1L)
#endif
38 changes: 38 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/hwcap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Defines for bits in AT_HWCAP. LoongArch64 Linux version.
Copyright (C) 2022-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */

#if !defined (_SYS_AUXV_H)
# error "Never include <bits/hwcap.h> directly; use <sys/auxv.h> instead."
#endif

/* The following must match the kernel's <asm/hwcap.h>. */
/* HWCAP flags */
#define HWCAP_LOONGARCH_CPUCFG (1 << 0)
#define HWCAP_LOONGARCH_LAM (1 << 1)
#define HWCAP_LOONGARCH_UAL (1 << 2)
#define HWCAP_LOONGARCH_FPU (1 << 3)
#define HWCAP_LOONGARCH_LSX (1 << 4)
#define HWCAP_LOONGARCH_LASX (1 << 5)
#define HWCAP_LOONGARCH_CRC32 (1 << 6)
#define HWCAP_LOONGARCH_COMPLEX (1 << 7)
#define HWCAP_LOONGARCH_CRYPTO (1 << 8)
#define HWCAP_LOONGARCH_LVZ (1 << 9)
#define HWCAP_LOONGARCH_LBT_X86 (1 << 10)
#define HWCAP_LOONGARCH_LBT_ARM (1 << 11)
#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12)
#define HWCAP_LOONGARCH_PTW (1 << 13)
76 changes: 76 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/link.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/* Machine-specific declarations for dynamic linker interface.
Copyright (C) 2022-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */

#ifndef _LINK_H
#error "Never include <bits/link.h> directly; use <link.h> instead."
#endif

#ifndef __loongarch_soft_float
typedef float La_loongarch_vr
__attribute__ ((__vector_size__ (16), __aligned__ (16)));
typedef float La_loongarch_xr
__attribute__ ((__vector_size__ (32), __aligned__ (16)));

typedef union
{
double fpreg[4];
La_loongarch_vr vr[2];
La_loongarch_xr xr[1];
} La_loongarch_vector __attribute__ ((__aligned__ (16)));
#endif

typedef struct La_loongarch_regs
{
unsigned long int lr_reg[8]; /* a0 - a7 */
#ifndef __loongarch_soft_float
La_loongarch_vector lr_vec[8]; /* fa0 - fa7 or vr0 - vr7 or xr0 - xr7*/
#endif
unsigned long int lr_ra;
unsigned long int lr_sp;
} La_loongarch_regs;

/* Return values for calls from PLT on LoongArch. */
typedef struct La_loongarch_retval
{
unsigned long int lrv_a0;
unsigned long int lrv_a1;
#ifndef __loongarch_soft_float
La_loongarch_vector lrv_vec0;
La_loongarch_vector lrv_vec1;
#endif
} La_loongarch_retval;

__BEGIN_DECLS

extern ElfW (Addr) la_loongarch_gnu_pltenter (ElfW (Sym) *__sym,
unsigned int __ndx,
uintptr_t *__refcook,
uintptr_t *__defcook,
La_loongarch_regs *__regs,
unsigned int *__flags,
const char *__symname,
long int *__framesizep);
extern unsigned int la_loongarch_gnu_pltexit (ElfW (Sym) *__sym,
unsigned int __ndx,
uintptr_t *__refcook,
uintptr_t *__defcook,
const La_loongarch_regs *__inregs,
La_loongarch_retval *__outregs,
const char *__symname);

__END_DECLS
25 changes: 25 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/link_lavcurrent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* Data structure for communication from the run-time dynamic linker for
loaded ELF shared objects. LAV_CURRENT definition.
Copyright (C) 2023-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

#ifndef _LINK_H
# error "Never include <bits/link_lavcurrent.h> directly; use <link.h> instead."
#endif

/* Version numbers for la_version handshake interface. */
#define LAV_CURRENT 3
21 changes: 21 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/long-double.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* Properties of long double type. ldbl-128 version.
Copyright (C) 2016-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

/* long double is distinct from double, so there is nothing to
define here. */
#define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0
52 changes: 52 additions & 0 deletions lib/libc/include/loongarch64-linux-gnusf/bits/procfs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* Types for registers for sys/procfs.h.
Copyright (C) 2022-2024 Free Software Foundation, Inc.

This file is part of the GNU C Library.

The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */

#ifndef _SYS_PROCFS_H
# error "Never include <bits/procfs.h> directly; use <sys/procfs.h> instead."
#endif

/* Type for a general-purpose register. */
typedef __uint64_t elf_greg_t;

/* And the whole bunch of them. We could have used `struct
pt_regs' directly in the typedef, but tradition says that
the register set is an array, which does have some peculiar
semantics, so leave it that way. */
#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof (elf_greg_t))
typedef elf_greg_t elf_gregset_t[ELF_NGREG];

#define ELF_NFPREG 34 /* 32 FPRs + 8-byte byte-vec for fcc + 4-byte FCR */
typedef union
{
double d;
float f;
} elf_fpreg_t;
typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];

typedef union
{
double d[2];
float f[4];
} __attribute__ ((__aligned__ (16))) elf_lsxregset_t[32];

typedef union
{
double d[4];
float f[8];
} __attribute__ ((__aligned__ (32))) elf_lasxregset_t[32];
Loading