diff options
Diffstat (limited to 'ports/sysdeps/tile/bits')
-rw-r--r-- | ports/sysdeps/tile/bits/atomic.h | 86 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/byteswap.h | 35 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/endian.h | 13 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/fenv.h | 44 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/link.h | 57 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/mathdef.h | 48 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/mathinline.h | 44 | ||||
-rw-r--r-- | ports/sysdeps/tile/bits/setjmp.h | 36 |
8 files changed, 363 insertions, 0 deletions
diff --git a/ports/sysdeps/tile/bits/atomic.h b/ports/sysdeps/tile/bits/atomic.h new file mode 100644 index 0000000000..cb96004fc8 --- /dev/null +++ b/ports/sysdeps/tile/bits/atomic.h @@ -0,0 +1,86 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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/>. */ + +/* The sub-architecture headers provide definitions for these macros + that work for "int" and "long" size values only: + + atomic_compare_and_exchange_val_acq() + atomic_exchange_acq() + atomic_exchange_and_add() + atomic_and_val() + atomic_or_val() + atomic_decrement_if_positive() [tilegx only] + + Here we provide generic definitions true for all Tilera chips. */ + +#include <stdint.h> +#include <features.h> + +typedef int32_t atomic32_t; +typedef uint32_t uatomic32_t; +typedef int_fast32_t atomic_fast32_t; +typedef uint_fast32_t uatomic_fast32_t; + +typedef int64_t atomic64_t; +typedef uint64_t uatomic64_t; +typedef int_fast64_t atomic_fast64_t; +typedef uint_fast64_t uatomic_fast64_t; + +typedef intptr_t atomicptr_t; +typedef uintptr_t uatomicptr_t; +typedef intmax_t atomic_max_t; +typedef uintmax_t uatomic_max_t; + +/* Barrier macro. */ +#define atomic_full_barrier() __sync_synchronize() + +/* APIs with "release" semantics. */ +#define atomic_compare_and_exchange_val_rel(mem, n, o) \ + ({ \ + atomic_full_barrier (); \ + atomic_compare_and_exchange_val_acq ((mem), (n), (o)); \ + }) +#define atomic_compare_and_exchange_bool_rel(mem, n, o) \ + ({ \ + atomic_full_barrier (); \ + atomic_compare_and_exchange_bool_acq ((mem), (n), (o)); \ + }) +#define atomic_exchange_rel(mem, n) \ + ({ \ + atomic_full_barrier (); \ + atomic_exchange_acq ((mem), (n)); \ + }) + +/* Various macros that should just be synonyms. */ +#define catomic_exchange_and_add atomic_exchange_and_add +#define atomic_and(mem, mask) ((void) atomic_and_val ((mem), (mask))) +#define catomic_and atomic_and +#define atomic_or(mem, mask) ((void) atomic_or_val ((mem), (mask))) +#define catomic_or atomic_or + +/* atomic_bit_test_set in terms of atomic_or_val. */ +#define atomic_bit_test_set(mem, bit) \ + ({ __typeof (*(mem)) __att0_mask = ((__typeof (*(mem))) 1 << (bit)); \ + atomic_or_val ((mem), __att0_mask) & __att0_mask; }) + +/* + * This non-existent symbol is called for unsupporrted sizes, + * indicating a bug in the caller. + */ +extern int __atomic_error_bad_argument_size(void) + __attribute__ ((warning ("bad sizeof atomic argument"))); diff --git a/ports/sysdeps/tile/bits/byteswap.h b/ports/sysdeps/tile/bits/byteswap.h new file mode 100644 index 0000000000..8e610c6fc8 --- /dev/null +++ b/ports/sysdeps/tile/bits/byteswap.h @@ -0,0 +1,35 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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 _BYTESWAP_H && !defined _NETINET_IN_H && !defined _ENDIAN_H +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead." +#endif + +#ifndef _BITS_BYTESWAP_H +#define _BITS_BYTESWAP_H 1 + +/* gcc __builtin_bswap64() can constant-fold, etc, so always use it. */ +#define __bswap_16(x) ((unsigned short)(__builtin_bswap32(x) >> 16)) +#define __bswap_32(x) ((unsigned int)__builtin_bswap32(x)) +#define __bswap_64(x) ((unsigned long long)__builtin_bswap64(x)) + +#define __bswap_constant_16(x) __bswap_16(x) +#define __bswap_constant_32(x) __bswap_32(x) +#define __bswap_constant_64(x) __bswap_64(x) + +#endif /* _BITS_BYTESWAP_H */ diff --git a/ports/sysdeps/tile/bits/endian.h b/ports/sysdeps/tile/bits/endian.h new file mode 100644 index 0000000000..43d94bb7a7 --- /dev/null +++ b/ports/sysdeps/tile/bits/endian.h @@ -0,0 +1,13 @@ +/* Set endianness for tile. */ + +#ifndef _ENDIAN_H +# error "Never use <bits/endian.h> directly; include <endian.h> instead." +#endif + +#if defined __BIG_ENDIAN__ +# define __BYTE_ORDER __BIG_ENDIAN +#elif defined __LITTLE_ENDIAN__ +# define __BYTE_ORDER __LITTLE_ENDIAN +#else +# error "Endianness not declared!!" +#endif diff --git a/ports/sysdeps/tile/bits/fenv.h b/ports/sysdeps/tile/bits/fenv.h new file mode 100644 index 0000000000..7638e8cc50 --- /dev/null +++ b/ports/sysdeps/tile/bits/fenv.h @@ -0,0 +1,44 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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/>. */ + +#ifndef _FENV_H +# error "Never use <bits/fenv.h> directly; include <fenv.h> instead." +#endif + +/* The TILE-Gx hardware does not provide floating-point exception + handling, and TILEPro does not support any floating-point operations. */ +#define FE_ALL_EXCEPT 0 + +/* TILE-Gx supports only round-to-nearest. The software + floating-point support also acts this way. */ +enum + { + __FE_UNDEFINED = 0, + + FE_TONEAREST = 1, +#define FE_TONEAREST FE_TONEAREST + }; + +/* Type representing exception flags (if there were any). */ +typedef unsigned int fexcept_t; + +/* Type representing floating-point environment. */ +typedef unsigned int fenv_t; + +/* If the default argument is used we use this value. */ +#define FE_DFL_ENV ((const fenv_t *) -1l) diff --git a/ports/sysdeps/tile/bits/link.h b/ports/sysdeps/tile/bits/link.h new file mode 100644 index 0000000000..3cc8c1e837 --- /dev/null +++ b/ports/sysdeps/tile/bits/link.h @@ -0,0 +1,57 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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/>. */ + +#ifndef _LINK_H +# error "Never include <bits/link.h> directly; use <link.h> instead." +#endif + +#define __need_int_reg_t +#include <arch/abi.h> + + +/* Registers for entry into PLT. */ +typedef struct La_tile_regs +{ + __uint_reg_t lr_reg[10]; +} La_tile_regs; + +/* Return values for calls from PLT. */ +typedef struct La_tile_retval +{ + /* Up to ten registers can be used for a return value (e.g. small struct). */ + __uint_reg_t lrv_reg[10]; +} La_tile_retval; + + +__BEGIN_DECLS + +extern ElfW(Addr) la_tile_gnu_pltenter (ElfW(Sym) *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + La_tile_regs *__regs, + unsigned int *__flags, + const char *__symname, + long int *__framesizep); +extern unsigned int la_tile_gnu_pltexit (ElfW(Sym) *__sym, unsigned int __ndx, + uintptr_t *__refcook, + uintptr_t *__defcook, + const La_tile_regs *__inregs, + La_tile_retval *__outregs, + const char *__symname); + +__END_DECLS diff --git a/ports/sysdeps/tile/bits/mathdef.h b/ports/sysdeps/tile/bits/mathdef.h new file mode 100644 index 0000000000..bf0da5e438 --- /dev/null +++ b/ports/sysdeps/tile/bits/mathdef.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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 _MATH_H && !defined _COMPLEX_H +# error "Never use <bits/mathdef.h> directly; include <math.h> instead" +#endif + +#if defined __USE_ISOC99 && defined _MATH_H && !defined _MATH_H_MATHDEF +# define _MATH_H_MATHDEF 1 + +/* "float" and "double" expressions evaluated as "float" and "double". */ +typedef float float_t; +typedef double double_t; + +/* The values returned by `ilogb' for 0 and NaN respectively. */ +# define FP_ILOGB0 (-2147483647) +# define FP_ILOGBNAN (2147483647) + +/* The GCC 4.6 compiler will define __FP_FAST_FMA{,F,L} if the fma{,f,l} + builtins are supported. */ +# if __FP_FAST_FMA +# define FP_FAST_FMA 1 +# endif + +# if __FP_FAST_FMAF +# define FP_FAST_FMAF 1 +# endif + +# if __FP_FAST_FMAL +# define FP_FAST_FMAL 1 +# endif + +#endif /* ISO C99 */ diff --git a/ports/sysdeps/tile/bits/mathinline.h b/ports/sysdeps/tile/bits/mathinline.h new file mode 100644 index 0000000000..4c021f7757 --- /dev/null +++ b/ports/sysdeps/tile/bits/mathinline.h @@ -0,0 +1,44 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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/>. */ + +#ifndef _MATH_H +# error "Never use <bits/mathinline.h> directly; include <math.h> instead." +#endif + +#ifndef __extern_always_inline +# define __MATH_INLINE __inline +#else +# define __MATH_INLINE __extern_always_inline +#endif + + +#if defined __USE_ISOC99 && defined __GNUC__ + +/* Test for negative number. Used in the signbit() macro. */ +__MATH_INLINE int +__NTH (__signbitf (float __x)) +{ + return __builtin_signbitf (__x); +} +__MATH_INLINE int +__NTH (__signbit (double __x)) +{ + return __builtin_signbit (__x); +} + +#endif diff --git a/ports/sysdeps/tile/bits/setjmp.h b/ports/sysdeps/tile/bits/setjmp.h new file mode 100644 index 0000000000..513c73474c --- /dev/null +++ b/ports/sysdeps/tile/bits/setjmp.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011. + + 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/>. */ + +/* Define the machine-dependent type `jmp_buf'. TILE version. */ +#ifndef _BITS_SETJMP_H +#define _BITS_SETJMP_H 1 + +#if !defined _SETJMP_H && !defined _PTHREAD_H +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead." +#endif + +#ifndef _ASM + +#define __need_int_reg_t +#include <arch/abi.h> + +typedef __uint_reg_t __jmp_buf[32]; + +#endif + +#endif /* bits/setjmp.h */ |