[PATCH v3 10/19] RISC-V: Support the 32-bit ABI implementation

Maciej W. Rozycki macro@wdc.com
Thu Jul 16 08:23:20 GMT 2020


On Sun, 12 Jul 2020, Alistair Francis via Libc-alpha wrote:

> This patch adds the ABI implementation for 32-bit RISC-V. It contains
                                                           ^
 Missing space here.

> diff --git a/sysdeps/riscv/bits/wordsize.h b/sysdeps/riscv/bits/wordsize.h
> index faccc71828..6e6677effe 100644
> --- a/sysdeps/riscv/bits/wordsize.h
> +++ b/sysdeps/riscv/bits/wordsize.h
> @@ -22,8 +22,9 @@
>  # error unsupported ABI
>  #endif
>  
> -#if __riscv_xlen == 64
> -# define __WORDSIZE_TIME64_COMPAT32 1
> -#else
> -# error "rv32i-based targets are not supported"
> +#define __WORDSIZE_TIME64_COMPAT32 1
                                     ^
 ... and here (for alignment with the macros below).

> +
> +#if __WORDSIZE == 32
> +# define __WORDSIZE32_SIZE_ULONG    0
> +# define __WORDSIZE32_PTRDIFF_LONG  0
>  #endif
> diff --git a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
> index c3c72d6c10..d03f2bfe5c 100644
> --- a/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
> +++ b/sysdeps/riscv/nptl/bits/pthreadtypes-arch.h
> @@ -21,18 +21,22 @@
>  
>  #include <bits/endian.h>
>  
> -#if __riscv_xlen == 64
> +#define __SIZEOF_PTHREAD_MUTEXATTR_T		4
> +#define __SIZEOF_PTHREAD_COND_T			48
> +#define __SIZEOF_PTHREAD_CONDATTR_T		4
> +#define __SIZEOF_PTHREAD_RWLOCKATTR_T		8
> +#define __SIZEOF_PTHREAD_BARRIERATTR_T		4
> +
> +#if __WORDSIZE == 64
>  # define __SIZEOF_PTHREAD_ATTR_T 		56
>  # define __SIZEOF_PTHREAD_MUTEX_T 		40
> -# define __SIZEOF_PTHREAD_MUTEXATTR_T 		 4
> -# define __SIZEOF_PTHREAD_COND_T 		48
> -# define __SIZEOF_PTHREAD_CONDATTR_T 		 4
>  # define __SIZEOF_PTHREAD_RWLOCK_T 		56
> -# define __SIZEOF_PTHREAD_RWLOCKATTR_T 		 8
>  # define __SIZEOF_PTHREAD_BARRIER_T 		32
> -# define __SIZEOF_PTHREAD_BARRIERATTR_T 	 4
>  #else
> -# error "rv32i-based systems are not supported"
> +# define __SIZEOF_PTHREAD_ATTR_T 		32
                                   ^
> +# define __SIZEOF_PTHREAD_MUTEX_T 		32
                                    ^
> +# define __SIZEOF_PTHREAD_RWLOCK_T 		48
                                     ^
> +# define __SIZEOF_PTHREAD_BARRIER_T 		20
                                      ^
 Extraneous spaces here.

> diff --git a/sysdeps/riscv/sys/asm.h b/sysdeps/riscv/sys/asm.h
> index bd2de17e17..e314133ce4 100644
> --- a/sysdeps/riscv/sys/asm.h
> +++ b/sysdeps/riscv/sys/asm.h
> @@ -26,7 +26,10 @@
>  # define REG_S sd
>  # define REG_L ld
>  #elif __riscv_xlen == 32
> -# error "rv32i-based targets are not supported"
> +# define PTRLOG 2
> +# define SZREG	4
                 ^
 Use two spaces rather than a tab here.

> diff --git a/sysdeps/unix/sysv/linux/riscv/jmp_buf-macros.h b/sysdeps/unix/sysv/linux/riscv/jmp_buf-macros.h
> new file mode 100644
> index 0000000000..73c7ade9c7
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/riscv/jmp_buf-macros.h
> @@ -0,0 +1,53 @@
> +/* The jump buffer constants for RISC-V.
> +   Copyright (C) 2020 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/>.  */
> +
> +/* Produced by this program:
> +
> +  #include <stdio.h>
> +  #include <unistd.h>
> +  #include <setjmp.h>
> +  #include <stddef.h>
> +
> +  int main (int argc, char **argv)
> +    {
> +      printf ("#define JMP_BUF_SIZE %d\n", sizeof (jmp_buf));
> +      printf ("#define JMP_BUF_ALIGN %d\n", __alignof__ (jmp_buf));
> +      printf ("#define SIGJMP_BUF_SIZE %d\n", sizeof (sigjmp_buf));
> +      printf ("#define SIGJMP_BUF_ALIGN %d\n", __alignof__ (sigjmp_buf));
> +      printf ("#define MASK_WAS_SAVED_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __mask_was_saved));
> +      printf ("#define SAVED_MASK_OFFSET %d\n", offsetof (struct __jmp_buf_tag, __saved_mask));

 Wrap the last two lines so that they don't extend past column 79.

  Maciej


More information about the Libc-alpha mailing list