Re: ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

2018-12-19 Thread Adhemerval Zanella



On 19/12/2018 15:58, Vineet Gupta wrote:
> On 12/18/18 6:39 PM, Vineet Gupta wrote:
 diff --git a/sysdeps/unix/sysv/linux/arc/sigaction.c 
 b/sysdeps/unix/sysv/linux/arc/sigaction.c
>>> Why do you need this, rather than using the unified version (possibly with 
>>> a few macros defined first)?
>>
>> The only syscall ABI requirement is that we pass our our own SA_RESTORER stub
>> (rather than inject one in kernel, and deal with cache sync etc etc). Indeed 
>> the
>> common code can be used - likely was not the case when I started with ARC 
>> port, or
>> more likely the port that I started ARC port from ;-)
>>
>> I'll update this.
> 
> I took a stab at this but not really happy with taking this approach.
> 
> (1). Common code assumes disparate kernel and userland sigaction struct even
> though there's no reason for a *new* port to be: its not like all glibc code 
> is
> shared/common although I agree it is best to do so as much as possible
> So this requires explicit copy over of 1 struct into other, when it could have
> been avoided altogether for some cases atleast (!SA_RESTORER).
> 
> (2)  Linux kernel asm-generic syscall ABI expects sigset_t to be 2 words
> 
> | kernel: include/uapi/asm-generic/signal.h
> |
> | #define _NSIG   64
> | typedef struct {
> | unsigned long sig[_NSIG_WORDS];
> | } sigset_t;
> 
> And that is what we pretend at the time of syscall itself, e.g. snippet below 
> from
> generic sigaction()
> 
> | /* XXX The size argument hopefully will have to be changed to the
> | real size of the user-level sigset_t.  */
> |   result = INLINE_SYSCALL_CALL (rt_sigaction, sig,
> | act ? &kact : NULL,
> | oact ? &koact : NULL, STUB(act) _NSIG / 8);
> ^
> 
> However glibc assumes sigset_to to be 128 words which is fine, however the 
> memcpy
> for 256 words seems pointless when kernel is not supposed to be even looking 
> at
> beyond 2nd word (although I realize my SA_RESTORE case was doing the implicit 
> copy
> as well)
> 
> (3) Consider me a micro-optimization freak :-) but this memcpy seems waste of
> cycles and will atleast show up LMBench lat_sig  micro-benchmarks.
> 
> 
> I don't have strong feelings either ways, but wanted to express my concerns 
> anyways.
> 

One possibility is to define an arch-specific __sigset_t.h with a custom 
_SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check
if both kernel_sigaction and glibc sigaction share same size and internal
layout to use the struct as-is for syscall instead of copy to a temporary
value (similar to what we used to have on getdents).  ARC would still have
arch-specific code and would be the only ABI to have a different sigset_t
though.

However I *hardly* think sigaction is a hotspot in real world cases, usually
the signal action is defined once or in a very limited number of times.  I am
not considering synthetic benchmarks, specially lmbench which in most cases
does not measure any useful metric. Even for other sigset_t usage case I still
think an arch-specific definition should not make much difference:

  1. setcontext: it would incur just in larger ucontext_t (kernel get/set
 mask is done using kernel expected size).  Also, taking in consideration
 these interfaces were removed from POSIX.1-2008, the inherent performance
 issues (signal set/restore will most likely dominate the overhead), and
 some implementation issues (BZ#18135 for instance), I would say to not
 bother to optimize it.

  2. pselect, ppoll, epoll_pwait, posix_spawn (posix_spawnattr_t), sig*: 
 for functions that accept sigset as an argument it would incur in just
 larger memory utilization without much performance overhead. Again,
 runtime for these calls would be mostly dominate by syscall overhead
 or kernel wait-time for events.

  3. raise, etc: for function that might allocate a sigset_t internally it
 will similar to 2.

Now, if ARC intention is just to follow generic glibc linux ABI definitions,
it could just define its sigaction as (not tested):

* sysdeps/unix/sysv/linux/arc/sigaction.c

---
#define SA_RESTORER 0x0400
#include 

extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;

#define SET_SA_RESTORER(kact, act)  \
  (kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
  (kact)->sa_restorer = &__default_rt_sa_restorer

#define RESET_SA_RESTORER(act, kact)\
  (act)->sa_restorer = (kact)->sa_restorer

static void __default_rt_sa_restorer(void)
{
  INTERNAL_SYSCALL_DECL (err);
  INTERNAL_SYSCALL_CALL (__NR_rt_sigreturn, err);
}

#include 
---


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

2018-12-20 Thread Adhemerval Zanella



On 19/12/2018 20:23, Vineet Gupta wrote:
> On 12/19/18 2:00 PM, Adhemerval Zanella wrote:
>>
>>
>> One possibility is to define an arch-specific __sigset_t.h with a custom 
>> _SIGSET_NWORDS value and add an optimization on Linux sigaction.c to check
>> if both kernel_sigaction and glibc sigaction share same size and internal
>> layout to use the struct as-is for syscall instead of copy to a temporary
>> value (similar to what we used to have on getdents).  ARC would still have
>> arch-specific code and would be the only ABI to have a different sigset_t
>> though.
> 
> I don't like ARC to single out either. But as Joseph suggests could this be
> starting point for arches of future. Assuming it does, would rather see this 
> or
> the approach Joseph alluded to earlier [1]
> 
> [1] 
> http://lists.infradead.org/pipermail/linux-snps-arc/2018-December/005122.html
> 
>>
>> However I *hardly* think sigaction is a hotspot in real world cases, usually
>> the signal action is defined once or in a very limited number of times.  I am
>> not considering synthetic benchmarks, specially lmbench which in most cases
>> does not measure any useful metric. 
> 
> I tend to disagree. Coming from embedded linux background, I've found it 
> immensely
> useful to compare 2 minimal systems: especially when distos, out-of-box 
> packages,
> fancy benchmarks don't even exist.
> 
> At any rate, my disagreement with status quo is not so much of optimize for 
> ARC,
> but rather pointless spending of electrons. When we know that there are 64 
> signals
> at max, which need 64-bits, why bother shuffling around 1k bits, specially 
> when
> one is starting afresh and there's no legacy crap getting in the way.
> 
> The case of adding more signals in future is indeed theoretically possible but
> that will be an ABI change anyways.

The only advantage of using a larger sigset_t from glibc standpoint is if
kernel ever change it maximum number of supported signals it would not be
a ABI change (it would be if glibc provided sigset_t need to be extended).

My point was that this change would hardly help in performance or memory 
utilization due the signal set common utilization in exported and internal
API.  But at the same time the signal set hasn't been changed for a *long* time 
and I don't see indication that it will any time soon. So a new architecture 
might indeed assume it won't change and set its default to follow Linux user 
ABI.

> 
>> Even for other sigset_t usage case I still
>> think an arch-specific definition should not make much difference:
>>
>>   1. setcontext: it would incur just in larger ucontext_t (kernel get/set
>>  mask is done using kernel expected size).  Also, taking in consideration
>>  these interfaces were removed from POSIX.1-2008, the inherent 
>> performance
>>  issues (signal set/restore will most likely dominate the overhead), and
>>  some implementation issues (BZ#18135 for instance), I would say to not
>>  bother to optimize it.
>>
>>   2. pselect, ppoll, epoll_pwait, posix_spawn (posix_spawnattr_t), sig*: 
>>  for functions that accept sigset as an argument it would incur in just
>>  larger memory utilization without much performance overhead. Again,
>>  runtime for these calls would be mostly dominate by syscall overhead
>>  or kernel wait-time for events.
>>
>>   3. raise, etc: for function that might allocate a sigset_t internally it
>>  will similar to 2.
> 
> I agree that that in libc, pretty much anything will be dominated by syscall
> overhead, but still...
> 
> 
>> Now, if ARC intention is just to follow generic glibc linux ABI definitions,
>> it could just define its sigaction as (not tested):
> 
> Indeed the ABI is etched in stone and I have a very similar code now, with 
> slight
> difference.
> 
>> * sysdeps/unix/sysv/linux/arc/sigaction.c
>>
>> ---
>> #define SA_RESTORER 0x0400
>> #include 
>>
>> extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;
>>
>> #define SET_SA_RESTORER(kact, act)  \
>>   (kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
>>   (kact)->sa_restorer = &__default_rt_sa_restorer
> 
> +#define SET_SA_RESTORER(kact, act)   \
> + ({  \
> +   if (!((kact)->sa_flags & SA_RESTORER))\
> + {   \
> +   (kact)->sa_restorer = __default_rt_sa_restorer; 

Re: ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

2018-12-20 Thread Adhemerval Zanella



On 20/12/2018 17:23, Vineet Gupta wrote:
> On 12/20/18 3:19 AM, Adhemerval Zanella wrote:
>>>> #define SET_SA_RESTORER(kact, act)  \
>>>>   (kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
>>>>   (kact)->sa_restorer = &__default_rt_sa_restorer
>>> +#define SET_SA_RESTORER(kact, act) \
>>> + ({\
>>> +   if (!((kact)->sa_flags & SA_RESTORER))  \
>>> + { \
>>> +   (kact)->sa_restorer = __default_rt_sa_restorer; \
>>> +   (kact)->sa_flags |= SA_RESTORER;\
>>> + } \
>>> +   else\
>>> + (kact)->sa_restorer = (act)->sa_restorer; \
>>> + })
>> What is so special about ARC sa_restorer that an application should provide
>> an specialized one?
> 
> Its the other way around. Only if application provides it's own restorer, we 
> honor
> it, otherwise default restorer is used. This logic goes back many many years 
> ago
> to how ARC uClibc did this and likely inherited it from the port it was copied
> from. But I don't know if say POSIX allows apps to provide their own restorer 
> or
> not. We could very well remove it; although per other discussion if we intend 
> to
> use the same struct sigaction for kernel/userland, the placeholder would 
> exist and
> we could choose to just ignore it.
> 

The 'should' should be indeed 'might' in my question. And SA_RESTORER is a Linux
specific ABI not intended to be used by applications, so my question is in fact
what kind of specialized sa_restorer applications might provided that would
require the libc to honour it. 

The placeholder existence is not an issue itself (POSIX states the minimum
fields sigaction should provide, not its specific fields neither their
layout).

> 
>> Can't it follow other abi where they issue __NR_sigreturn
>> for !SA_SIGINFO or __NR_rt_sigreturn otherwise?
> 
> With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about
> restorer ?

Right, so ARC at least is not pulling old compat stuff. Is it safe to just zero
the sa_restorer for sa_flags without SA_RESTORER?

> 
>> As for other architecture I do think we should hide the sa_restorer usage
>> from application.
> 
> As mentioned above, the placeholder could exist, we can choose to ignore it.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: ARC vs. generic sigaction (was Re: [PATCH 08/21] ARC: Linux Syscall Interface)

2018-12-21 Thread Adhemerval Zanella



On 20/12/2018 18:46, Vineet Gupta wrote:
> On 12/20/18 12:06 PM, Adhemerval Zanella wrote:
>>
>>
>> On 20/12/2018 17:23, Vineet Gupta wrote:
>>> On 12/20/18 3:19 AM, Adhemerval Zanella wrote:
>>>>>> #define SET_SA_RESTORER(kact, act)  \
>>>>>>   (kact)->sa_flags = (act)->sa_flags | SA_RESTORER; \
>>>>>>   (kact)->sa_restorer = &__default_rt_sa_restorer
>>>>> +#define SET_SA_RESTORER(kact, act)   \
>>>>> + ({  \
>>>>> +   if (!((kact)->sa_flags & SA_RESTORER))\
>>>>> + {   \
>>>>> +   (kact)->sa_restorer = __default_rt_sa_restorer;   \
>>>>> +   (kact)->sa_flags |= SA_RESTORER;  \
>>>>> + }   \
>>>>> +   else  \
>>>>> + (kact)->sa_restorer = (act)->sa_restorer;   \
>>>>> + })
>>>> What is so special about ARC sa_restorer that an application should provide
>>>> an specialized one?
>>>
>>> Its the other way around. Only if application provides it's own restorer, 
>>> we honor
>>> it, otherwise default restorer is used. This logic goes back many many 
>>> years ago
>>> to how ARC uClibc did this and likely inherited it from the port it was 
>>> copied
>>> from. But I don't know if say POSIX allows apps to provide their own 
>>> restorer or
>>> not. We could very well remove it; although per other discussion if we 
>>> intend to
>>> use the same struct sigaction for kernel/userland, the placeholder would 
>>> exist and
>>> we could choose to just ignore it.
>>>
>>
>> The 'should' should be indeed 'might' in my question. And SA_RESTORER is a 
>> Linux
>> specific ABI not intended to be used by applications, 
> 
> What do u mean here. It is ABI between userspace and kernel, but not 
> necessarily
> between applications and glibc, although the same "carrier" sa_flags is in 
> play ?
> IOW, SA_RESTORER is not intended to be set by applications, but only by glibc 
> ?

AFAIK SA_RESTORER is meant to be used by libc or alike environments to setup
the required code to handle signal handling, it should not be up to programs
to mess up with sa_restorer to provide custom routines.

> 
>> so my question is in fact
>> what kind of specialized sa_restorer applications might provided that would
>> require the libc to honour it. 
> 
> Indeed, applications should not be allowed to change it. The exact signature 
> of
> default sigreturn is hardwired in signal unwinding etc etc and any deviation 
> from
> that is recipe for issues: but like I mentioned I didn't invent that 
> interface for
> ARC.

So my suggestion is not allow user code to mess with sa_restore regardless 
if sa_flags contain SA_RESTORER.  If kernel allows it to be zero in case of
!SA_RESTORER, set it to zero as other architectures.  If it requires an
special routine, add an arch-specific one within glibc.

> 
>> The placeholder existence is not an issue itself (POSIX states the minimum
>> fields sigaction should provide, not its specific fields neither their
>> layout).
> 
> OK !
> 
>>>> Can't it follow other abi where they issue __NR_sigreturn
>>>> for !SA_SIGINFO or __NR_rt_sigreturn otherwise?
>>>
>>> With Linux UAPI ABI, __NR_sigreturn doesn't exist, but your concern is about
>>> restorer ?
>>
>> Right, so ARC at least is not pulling old compat stuff. Is it safe to just 
>> zero
>> the sa_restorer for sa_flags without SA_RESTORER?
> 
> Thing is ARC signal return depends on a restorer. Meaning !SA_RESTORER doesn't
> effectively exist (between libc and kernel). We currently honor user provided
> value, instead we could simply overwrite it with default_rt_restorer and on 
> the
> way out, zero it out to avoid leaking the glibc guts to curious users.
> 

Yes, this is what I suggest ARC should do.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return

2020-02-20 Thread Adhemerval Zanella



On 19/02/2020 18:40, Vineet Gupta wrote:
> On 2/10/20 11:20 AM, Adhemerval Zanella wrote:
>> It changes the nios INTERNAL_SYSCALL_RAW macro to return a negative
>> value instead of 'r2' register value on 'err' macro argument.
>>
>> The macro INTERNAL_SYSCALL_DECL is no longer required, and the
>> INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS.
>>
>> Checked with a build against nios2-linux-gnu.
>> ---
>>  sysdeps/unix/sysv/linux/nios2/sysdep.h | 10 +-
>>  1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep.h 
>> b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> index b02730bd23..eab888df32 100644
>> --- a/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/nios2/sysdep.h
>> @@ -157,13 +157,14 @@
>>   (int) result_var; })
>>  
>>  #undef INTERNAL_SYSCALL_DECL
>> -#define INTERNAL_SYSCALL_DECL(err) unsigned int err __attribute__((unused))
>> +#define INTERNAL_SYSCALL_DECL(err) do { } while (0)
>>  
>>  #undef INTERNAL_SYSCALL_ERROR_P
>> -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (unsigned int) 
>> (err))
>> +#define INTERNAL_SYSCALL_ERROR_P(val, err) \
>> +  ((unsigned long) (val) >= (unsigned long) -4095)
>>  
>>  #undef INTERNAL_SYSCALL_ERRNO
>> -#define INTERNAL_SYSCALL_ERRNO(val, err)   ((void) (err), val)
>> +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
>>  
>>  #undef INTERNAL_SYSCALL_RAW
>>  #define INTERNAL_SYSCALL_RAW(name, err, nr, args...)\
>> @@ -180,8 +181,7 @@
>>   : "+r" (_r2), "=r" (_err)  \
>>   : ASM_ARGS_##nr\
>>   : __SYSCALL_CLOBBERS); \
>> -   _sys_result = _r2;   \
>> -   err = _err;  \
>> +   _sys_result = _err != 0 ? -_r2 : -_r2;   \
> 
> Is there a typo here ? both cases seem to be -ve

It is, thanks for catching it. I have pushed b790c8c2ed to fix and
double checked nios2 syscall handling (arch/nios2/kernel/entry.S:205)
to certify that the modification does follow nios2 kABI.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 08/15] nios2: Use Linux kABI for syscall return

2020-02-27 Thread Adhemerval Zanella



On 20/02/2020 18:04, Vineet Gupta wrote:
> 
> Through a maze of defines this ends up calling INTERNAL_SYSCALL_RAW which 
> seems be
> unconditionally converting !0 value (success) into -ve and returning it. So 
> won't
>  it convert a legit brk address return into a -ve and save in __curbrk.


> On 2/20/20 12:39 PM, Vineet Gupta wrote:
>> Am I not following this correctly ?
> 
> Oh never mind, they use 2 seperate regs to convey syscall result and error, so
> your code is right.
> 

One of my goals is to disentangle the {INTERNAL,INLINE}_SYSCALL macros
to consolidate their definitions and move the arch-specific bits to 
inline functions instead of macros.  Another one is to remove the
requirement to define similar assembly macros to be used by the 
auto-generated one.

The idea is an architecture will just need to define a set of
inline_syscall{0-6} functions.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] semaphore: consolidate arch headers into a generic one

2020-05-08 Thread Adhemerval Zanella



On 05/05/2020 19:59, Vineet Gupta wrote:
> On 5/5/20 12:05 PM, Adhemerval Zanella via Libc-alpha wrote:
>>> diff --git a/sysdeps/s390/nptl/bits/semaphore.h 
>>> b/sysdeps/unix/sysv/linux/bits/semaphore.h
>>> similarity index 100%
>>> rename from sysdeps/s390/nptl/bits/semaphore.h
>>> rename to sysdeps/unix/sysv/linux/bits/semaphore.h
>>
>> Ok, although I think we should handle as a new file: add a online 
>> description and
>> remove any 'Contributed by' line.
> 
> Ok did explicit add/del but still git rename detection triggers, this time
> matching it to x86 version (with 90% similarity). I'm pretty sure in the past
> delete/add used to elide renames, perhaps the heuristics have gotten better. 
> AFAIK
> there is no gitconfig setting to disable the rename detection.
> 
> ...
>  sysdeps/{x86 => unix/sysv/linux}/bits/semaphore.h |  5 ++---
>  sysdeps/unix/sysv/linux/powerpc/bits/semaphore.h  | 40
> 

I use both -C (detect copies as well as renames) and -M (detect renames)
with git format-patch and send-email to try avoid such issues. Sometimes
it is required to change the -M threshold to get the rename right.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-05-29 Thread Adhemerval Zanella



On 28/05/2020 16:43, Vineet Gupta wrote:
> The existing macros are fragile and expect local variables with a
> certain name. Fix this by defining them as functions with defaul
> timplementation in a new header dl-runtime.h which arches can overrid
> eif need be.
> 
> This came up during ARC port review.
> 
> This patch potentially only affects hppa/x86 ports,
> build tested for both those configs and a few more.
> 
> Suggested-by: Adhemerval Zanella 

LGTM, thanks.

Reviewed-by: Adhemerval Zanella 

> ---
>  elf/dl-runtime.c  | 24 +++---
>  elf/dl-runtime.h  | 30 ++
>  sysdeps/hppa/dl-runtime.c |  4 ---
>  sysdeps/hppa/dl-runtime.h | 31 +++
>  sysdeps/x86_64/{dl-runtime.c => dl-runtime.h} | 13 ++--
>  5 files changed, 84 insertions(+), 18 deletions(-)
>  create mode 100644 elf/dl-runtime.h
>  create mode 100644 sysdeps/hppa/dl-runtime.h
>  rename sysdeps/x86_64/{dl-runtime.c => dl-runtime.h} (60%)
> 
> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> index cf5f1d3e82e1..62f90579370b 100644
> --- a/elf/dl-runtime.c
> +++ b/elf/dl-runtime.c
> @@ -27,6 +27,7 @@
>  #include "dynamic-link.h"
>  #include 
>  #include 
> +#include 
>  
>  
>  #if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
> @@ -42,13 +43,6 @@
>  # define ARCH_FIXUP_ATTRIBUTE
>  #endif
>  
> -#ifndef reloc_offset
> -# define reloc_offset reloc_arg
> -# define reloc_index  reloc_arg / sizeof (PLTREL)
> -#endif
> -
> -
> -
>  /* This function is called through a special trampoline from the PLT the
> first time each PLT entry is called.  We must perform the relocation
> specified in the PLT of the given shared object, and return the resolved
> @@ -68,8 +62,11 @@ _dl_fixup (
>  = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> -= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> += (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *refsym = sym;
>void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);

Ok (it should be dead code eliminated by compiler if reloc_offset does not
use the pltgot field, as for default implementation).

> @@ -182,7 +179,8 @@ _dl_profile_fixup (
>  
>/* This is the address in the array where we store the result of previous
>   relocations.  */
> -  struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result
> += &l->l_reloc_result[reloc_index (reloc_arg, sizeof (PLTREL))];
>  
>   /* CONCURRENCY NOTES:
>  
> @@ -219,8 +217,11 @@ _dl_profile_fixup (
>   = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const char *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> - = (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> + = (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *refsym = &symtab[ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *defsym = refsym;
>lookup_t result;
> @@ -489,7 +490,8 @@ _dl_call_pltexit (struct link_map *l, ElfW(Word) 
> reloc_arg,
>   relocations.  */
>// XXX Maybe the bound information must be stored on the stack since
>// XXX with bind_not a new value could have been stored in the meantime.
> -  struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result =
> +&l->l_reloc_result[reloc_index (reloc_arg, sizeof (PLTREL))];
>ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
>   l_info[DT_SYMTAB])
>  + reloc_result->boundndx);

Ok.

> diff --git a/elf/dl-runtime.h b/elf/dl-runtime.h
> new file mode 100644
> index ..ed5db3ba51b7
> --- /dev/null
> +++ b/elf/dl-runtime.h
> @@ -0,0 +1,30 @@
> +/* Helpers for On-demand PLT fixup for shared objects, Generic version.

Maybe period here?

> +   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 redi

Re: [PATCH v6 01/13] ARC: ABI Implementation

2020-05-29 Thread Adhemerval Zanella



On 27/05/2020 19:15, Vineet Gupta wrote:
> On 5/27/20 11:26 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>>> This code deals with the ARC ABI.
>>>
>>> Signed-off-by: Vineet Gupta 
>>
>> We do not use DCO, but rather copyright assignment.
> 
> Right, removed that now.
> 
>> Looks ok in general, with some comments below.
> 
> Thx for taking a look.
> 
>>> +;@ r1 = value that setjmp( ) will return due to this longjmp
>>
>> Since all .S files are processed by gcc assembly implementation usually
>> use C style comment (/* ... */). Same applies to other assembly
>> implementations.
> 
> OK, I can update throughout, although I like the small assembler comments 
> which
> are on the same line.

I don't have a strong preference and I am not sure if there is a strict
code guideline for comment in assembly implementations. It was more a
suggestion, since other assembly implementations tend to use C style
comment as well.


>>> diff --git a/sysdeps/arc/memusage.h b/sysdeps/arc/memusage.h
> 
>>> +
>>> +#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
>>> +
>>> +#define uatomic32_t unsigned int
>>
>> Not sure if this is really required now that we are moving to C11 atomic
>> model withing glibc itself. Maybe we could just use uint32_t on
>> malloc/memusage.c and rely on atomic macros instead.
> 
> But that would be much bigger change, and orthogonal to the port. So perhaps 
> we
> add it for now and then do the bigger/sweeping change.
> 

Indeed, it was more a open note for a future cleanup. The current
definition is fine as is.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 06/13] ARC: hardware floating point support

2020-05-29 Thread Adhemerval Zanella



On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
> Signed-off-by: Vineet Gupta 

As prior patch we do not use DCO, but rather copyright assignment.

Some comments below.

> ---
>  sysdeps/arc/fpu/e_sqrt.c|  27 
>  sysdeps/arc/fpu/e_sqrtf.c   |  27 
>  sysdeps/arc/fpu/fclrexcpt.c |  36 +++
>  sysdeps/arc/fpu/fegetenv.c  |  37 +++
>  sysdeps/arc/fpu/fegetmode.c |  31 ++
>  sysdeps/arc/fpu/fegetround.c|  32 ++
>  sysdeps/arc/fpu/feholdexcpt.c   |  43 +
>  sysdeps/arc/fpu/fesetenv.c  |  48 +++
>  sysdeps/arc/fpu/fesetexcept.c   |  32 ++
>  sysdeps/arc/fpu/fesetmode.c |  40 
>  sysdeps/arc/fpu/fesetround.c|  40 
>  sysdeps/arc/fpu/feupdateenv.c   |  51 +++
>  sysdeps/arc/fpu/fgetexcptflg.c  |  31 ++
>  sysdeps/arc/fpu/fraiseexcpt.c   |  39 
>  sysdeps/arc/fpu/fsetexcptflg.c  |  38 
>  sysdeps/arc/fpu/ftestexcept.c   |  33 ++
>  sysdeps/arc/fpu/s_fma.c |  28 +
>  sysdeps/arc/fpu/s_fmaf.c|  28 +
>  sysdeps/arc/fpu_control.h   | 106 
>  sysdeps/arc/get-rounding-mode.h |  38 
>  sysdeps/arc/math-tests-trap.h   |  27 
>  sysdeps/arc/tininess.h  |   1 +
>  22 files changed, 813 insertions(+)
>  create mode 100644 sysdeps/arc/fpu/e_sqrt.c
>  create mode 100644 sysdeps/arc/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/arc/fpu/fclrexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fegetenv.c
>  create mode 100644 sysdeps/arc/fpu/fegetmode.c
>  create mode 100644 sysdeps/arc/fpu/fegetround.c
>  create mode 100644 sysdeps/arc/fpu/feholdexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fesetenv.c
>  create mode 100644 sysdeps/arc/fpu/fesetexcept.c
>  create mode 100644 sysdeps/arc/fpu/fesetmode.c
>  create mode 100644 sysdeps/arc/fpu/fesetround.c
>  create mode 100644 sysdeps/arc/fpu/feupdateenv.c
>  create mode 100644 sysdeps/arc/fpu/fgetexcptflg.c
>  create mode 100644 sysdeps/arc/fpu/fraiseexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fsetexcptflg.c
>  create mode 100644 sysdeps/arc/fpu/ftestexcept.c
>  create mode 100644 sysdeps/arc/fpu/s_fma.c
>  create mode 100644 sysdeps/arc/fpu/s_fmaf.c
>  create mode 100644 sysdeps/arc/fpu_control.h
>  create mode 100644 sysdeps/arc/get-rounding-mode.h
>  create mode 100644 sysdeps/arc/math-tests-trap.h
>  create mode 100644 sysdeps/arc/tininess.h
> 
> diff --git a/sysdeps/arc/fpu/e_sqrt.c b/sysdeps/arc/fpu/e_sqrt.c
> new file mode 100644
> index ..abb67ef7b061
> --- /dev/null
> +++ b/sysdeps/arc/fpu/e_sqrt.c
> @@ -0,0 +1,27 @@
> +/* Square root of floating point number.
> +   Copyright (C) 2015-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
> +   .  */
> +
> +#include 
> +#include 
> +
> +double
> +__ieee754_sqrt (double d)
> +{
> +  return __builtin_sqrt (d);
> +}
> +libm_alias_finite (__ieee754_sqrt, __sqrt)

I think it is better to extend to math-use-builtins.h for cover 
e_sqrt{f} so we can also adapt to other architecutes.

> diff --git a/sysdeps/arc/fpu/e_sqrtf.c b/sysdeps/arc/fpu/e_sqrtf.c
> new file mode 100644
> index ..13008a4f45d6
> --- /dev/null
> +++ b/sysdeps/arc/fpu/e_sqrtf.c
> @@ -0,0 +1,27 @@
> +/* Single-precision floating point square root.
> +   Copyright (C) 2015-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
> +   .  */
> +
> +#include 
> +#include 
> +
> +float
> +__ieee7

Re: [PATCH v6 07/13] ARC: Linux Syscall Interface

2020-05-29 Thread Adhemerval Zanella



On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
> Signed-off-by: Vineet Gupta 

As prior patches we do not use DCO, but rather copyright assignment.

Some comments below.

> ---
>  sysdeps/unix/sysv/linux/arc/arch-syscall.h| 303 ++
>  sysdeps/unix/sysv/linux/arc/bits/timesize.h   |  21 ++
>  sysdeps/unix/sysv/linux/arc/clone.S   |  98 ++
>  .../unix/sysv/linux/arc/fixup-asm-unistd.h|  41 +++
>  sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
>  sysdeps/unix/sysv/linux/arc/kernel-features.h |  28 ++
>  sysdeps/unix/sysv/linux/arc/kernel_stat.h |  26 ++
>  sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  27 ++
>  sysdeps/unix/sysv/linux/arc/pt-vfork.S|   1 +
>  sysdeps/unix/sysv/linux/arc/sigaction.c   |  31 ++
>  sysdeps/unix/sysv/linux/arc/sigrestorer.S |  29 ++
>  sysdeps/unix/sysv/linux/arc/syscall.S |  33 ++
>  sysdeps/unix/sysv/linux/arc/syscalls.list |   3 +
>  sysdeps/unix/sysv/linux/arc/sysctl.mk |   1 +
>  sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 ++
>  sysdeps/unix/sysv/linux/arc/sysdep.h  | 224 +
>  sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
>  17 files changed, 947 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/arc/arch-syscall.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/bits/timesize.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/syscalls.list
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysctl.mk
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
> b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
> new file mode 100644
> index ..2b017eb5bbaa
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
> @@ -0,0 +1,303 @@
> +/* AUTOGENERATED by update-syscall-lists.py.  */
> +#define __NR_accept 202
> +#define __NR_accept4 242
> +#define __NR_acct 89
> +#define __NR_add_key 217
> +#define __NR_adjtimex 171
> +#define __NR_arc_gettls 246
> +#define __NR_arc_settls 245
> +#define __NR_arc_usr_cmpxchg 248
> +#define __NR_bind 200
> +#define __NR_bpf 280
> +#define __NR_brk 214
> +#define __NR_cacheflush 244
> +#define __NR_capget 90
> +#define __NR_capset 91
> +#define __NR_chdir 49
> +#define __NR_chroot 51
> +#define __NR_clock_adjtime64 405
> +#define __NR_clock_getres_time64 406
> +#define __NR_clock_gettime 113
> +#define __NR_clock_gettime64 403
> +#define __NR_clock_nanosleep 115
> +#define __NR_clock_nanosleep_time64 407
> +#define __NR_clock_settime 112
> +#define __NR_clock_settime64 404
> +#define __NR_clone 220
> +#define __NR_clone3 435
> +#define __NR_close 57
> +#define __NR_connect 203
> +#define __NR_copy_file_range 285
> +#define __NR_delete_module 106
> +#define __NR_dup 23
> +#define __NR_dup3 24
> +#define __NR_epoll_create1 20
> +#define __NR_epoll_ctl 21
> +#define __NR_epoll_pwait 22
> +#define __NR_eventfd2 19
> +#define __NR_execve 221
> +#define __NR_execveat 281
> +#define __NR_exit 93
> +#define __NR_exit_group 94
> +#define __NR_faccessat 48
> +#define __NR_fadvise64_64 223
> +#define __NR_fallocate 47
> +#define __NR_fanotify_init 262
> +#define __NR_fanotify_mark 263
> +#define __NR_fchdir 50
> +#define __NR_fchmod 52
> +#define __NR_fchmodat 53
> +#define __NR_fchown 55
> +#define __NR_fchownat 54
> +#define __NR_fcntl64 25
> +#define __NR_fdatasync 83
> +#define __NR_fgetxattr 10
> +#define __NR_finit_module 273
> +#define __NR_flistxattr 13
> +#define __NR_flock 32
> +#define __NR_fremovexattr 16
> +#define __NR_fsconfig 431
> +#define __NR_fsetxattr 7
> +#define __NR_fsmount 432
> +#define __NR_fsopen 430
> +#define __NR_fspick 433
> +#define __NR_fstatfs64 44
> +#define __NR_fsync 82
> +#define __NR_ftruncate64 46
> +#define __NR_futex_time64 422
> +#define __NR_get_mempolicy 236
> +#define __NR_get_robust_list 100
> +#define __NR_getcpu 168
> +#define __NR_getcwd 17
> +#define __NR_getdents64 61
> +#define __NR_getegid 177
> +#define __NR_geteuid 175
> +#define __NR_getgid 176
> +#define __NR_getgroups 158
> +#define __NR_getitimer 102
> +#define __NR_getpeername 205
> +#define __NR_getpgid 155
> +#define __NR_getpid 172
> +#define __NR_getppid 173
> +#define __NR_getprior

Re: [PATCH] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-05-29 Thread Adhemerval Zanella



On 29/05/2020 14:39, Vineet Gupta wrote:
> On 5/29/20 5:58 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 28/05/2020 16:43, Vineet Gupta wrote:
>>> The existing macros are fragile and expect local variables with a
>>> certain name. Fix this by defining them as functions with defaul
>>> timplementation in a new header dl-runtime.h which arches can overrid
>>> eif need be.
>>>
>>> This came up during ARC port review.
>>>
>>> This patch potentially only affects hppa/x86 ports,
>>> build tested for both those configs and a few more.
>>>
>>> Suggested-by: Adhemerval Zanella 
>>
>> LGTM, thanks.
>>
>> Reviewed-by: Adhemerval Zanella 
> 
> Sorry I didn't think through this before, but ARC port needs pltgot arg 
> (runtime
> address of plt0) in reloc_index not reloc_offset. I'll swap them and repost.

Hum I though I had it covered on my suggestion, but it seems I mixed them
up. Ok, I will review the new version.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/5] iee754: prvoide gcc builtins based generic sqrt functions

2020-06-01 Thread Adhemerval Zanella



On 29/05/2020 23:00, Vineet Gupta wrote:

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  

> ---
>  sysdeps/generic/math-use-builtins.h | 3 +++
>  sysdeps/ieee754/dbl-64/e_sqrt.c | 6 ++
>  sysdeps/ieee754/flt-32/e_sqrtf.c| 6 ++
>  3 files changed, 15 insertions(+)
> 
> diff --git a/sysdeps/generic/math-use-builtins.h 
> b/sysdeps/generic/math-use-builtins.h
> index 8a39ef58bc95..fc724c824a17 100644
> --- a/sysdeps/generic/math-use-builtins.h
> +++ b/sysdeps/generic/math-use-builtins.h
> @@ -60,4 +60,7 @@
>  # define USE_COPYSIGNF128_BUILTIN 0
>  #endif
>  
> +#define USE_SQRT_BUILTIN 0
> +#define USE_SQRTF_BUILTIN 0
> +
>  #endif /* math-use-builtins.h */

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c
> index d42a1a4eb6e9..518a8ae5cdaf 100644
> --- a/sysdeps/ieee754/dbl-64/e_sqrt.c
> +++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*/
>  /* An ultimate sqrt routine. Given an IEEE double machine number x   */

Ok.

> @@ -50,6 +51,10 @@
>  double
>  __ieee754_sqrt (double x)
>  {
> +#if USE_SQRT_BUILTIN
> +  return __builtin_sqrt (x);
> +#else
> +  /* Use generic implementation.  */
>static const double
>  rt0 = 9.859990725855365213134618E-01,
>  rt1 = 4.495955425917856814202739E-01,
> @@ -138,6 +143,7 @@ __ieee754_sqrt (double x)
>   return (x - x) / (x - x); /* sqrt(-ve)=sNaN */
>return 0x1p-256 * __ieee754_sqrt (x * 0x1p512);
>  }
> +#endif /* ! USE_SQRT_BUILTIN  */
>  }
>  #ifndef __ieee754_sqrt
>  libm_alias_finite (__ieee754_sqrt, __sqrt)

Ok.

> diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c 
> b/sysdeps/ieee754/flt-32/e_sqrtf.c
> index b339444301aa..68fc80e1e1ee 100644
> --- a/sysdeps/ieee754/flt-32/e_sqrtf.c
> +++ b/sysdeps/ieee754/flt-32/e_sqrtf.c
> @@ -16,12 +16,17 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  static   const float one = 1.0, tiny=1.0e-30;
>  
>  float
>  __ieee754_sqrtf(float x)
>  {
> +#if USE_SQRTF_BUILTIN
> + return __builtin_sqrtf (x);
> +#else
> + /* Use generic implementation.  */
>   float z;
>   int32_t sign = (int)0x8000;
>   int32_t ix,s,q,m,t,i;
> @@ -83,6 +88,7 @@ __ieee754_sqrtf(float x)
>   ix += (m <<23);
>   SET_FLOAT_WORD(z,ix);
>   return z;
> +#endif /* ! USE_SQRTF_BUILTIN  */
>  }
>  #ifndef __ieee754_sqrtf
>  libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> 

Ok.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 3/5] iee754: prvoide gcc builtins based generic fma functions

2020-06-01 Thread Adhemerval Zanella



On 29/05/2020 23:00, Vineet Gupta wrote:

Ok with the fixes below.

Reviewed-by: Adhemerval Zanella  

> ---
>  sysdeps/generic/math-use-builtins.h | 4 
>  sysdeps/ieee754/dbl-64/s_fma.c  | 6 ++
>  sysdeps/ieee754/dbl-64/s_fmaf.c | 6 ++
>  sysdeps/ieee754/float128/float128_private.h | 2 ++
>  sysdeps/ieee754/ldbl-128/s_fmal.c   | 5 +
>  5 files changed, 23 insertions(+)
> 
> diff --git a/sysdeps/generic/math-use-builtins.h 
> b/sysdeps/generic/math-use-builtins.h
> index fc724c824a17..9e96807a3370 100644
> --- a/sysdeps/generic/math-use-builtins.h
> +++ b/sysdeps/generic/math-use-builtins.h
> @@ -63,4 +63,8 @@
>  #define USE_SQRT_BUILTIN 0
>  #define USE_SQRTF_BUILTIN 0
>  
> +#define USE_FMA_BUILTIN 0
> +#define USE_FMAF_BUILTIN 0
> +#define USE_FMAL_BUILTIN 0
> +
>  #endif /* math-use-builtins.h */

For float128 support it should also contain a:

  #define USE_FMAF128_BUILTIN

> diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
> index 876df6e78bdc..1e4b2da1511d 100644
> --- a/sysdeps/ieee754/dbl-64/s_fma.c
> +++ b/sysdeps/ieee754/dbl-64/s_fma.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation uses rounding to odd to avoid problems with
> double rounding.  See a paper by Boldo and Melquiond:
> @@ -33,6 +34,10 @@
>  double
>  __fma (double x, double y, double z)
>  {
> +#if USE_FMA_BUILTIN
> +  return __builtin_fma (x);

It should be:

  return __builtin_fma (x, y, z);

Same for float and long double variant.

> +#else
> +  /* Use generic implementation.  */
>union ieee754_double u, v, w;
>int adjust = 0;
>u.d = x;
> @@ -292,6 +297,7 @@ __fma (double x, double y, double z)
>v.ieee.mantissa1 |= j;
>return v.d * 0x1p-108;
>  }
> +#endif /* ! USE_FMA_BUILTIN  */
>  }
>  #ifndef __fma
>  libm_alias_double (__fma, fma)> diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c 
> b/sysdeps/ieee754/dbl-64/s_fmaf.c
> index 57329d0a87fe..f15b18262124 100644
> --- a/sysdeps/ieee754/dbl-64/s_fmaf.c
> +++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation relies on double being more than twice as
> precise as float and uses rounding to odd in order to avoid problems
> @@ -33,6 +34,10 @@
>  float
>  __fmaf (float x, float y, float z)
>  {
> +#if USE_FMAF_BUILTIN
> +  return __builtin_fmaf (x);
> +#else
> +  /* Use generic implementation.  */
>fenv_t env;
>  
>/* Multiplication is always exact.  */
> @@ -60,6 +65,7 @@ __fmaf (float x, float y, float z)
>  
>/* And finally truncation with round to nearest.  */
>return (float) u.d;
> +#endif /* ! USE_FMAF_BUILTIN  */
>  }
>  #ifndef __fmaf
>  libm_alias_float (__fma, fma)> diff --git 
> a/sysdeps/ieee754/float128/float128_private.h 
> b/sysdeps/ieee754/float128/float128_private.h
> index f97463d9dc1b..a697a7c29038 100644
> --- a/sysdeps/ieee754/float128/float128_private.h
> +++ b/sysdeps/ieee754/float128/float128_private.h
> @@ -154,6 +154,8 @@
>  #define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN
>  #undef USE_COPYSIGNL_BUILTIN
>  #define USE_COPYSIGNL_BUILTIN USE_COPYSIGNF128_BUILTIN
> +#undef USE_FMAL_BUILTIN
> +#define USE_FMAL_BUILTIN USE_FMA128_BUILTIN
>  
>  /* IEEE function renames.  */
>  #define __ieee754_acoshl __ieee754_acoshf128

Ok.

> diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c 
> b/sysdeps/ieee754/ldbl-128/s_fmal.c
> index 7475015bcec6..1403734a5aeb 100644
> --- a/sysdeps/ieee754/ldbl-128/s_fmal.c
> +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation uses rounding to odd to avoid problems with
> double rounding.  See a paper by Boldo and Melquiond:
> @@ -33,6 +34,9 @@
>  _Float128
>  __fmal (_Float128 x, _Float128 y, _Float128 z)
>  {
> +#if USE_FMAL_BUILTIN
> +  return __builtin_fmal (x);
> +#else
>union ieee854_long_double u, v, w;
>int adjust = 0;
>u.d = x;
> @@ -296,5 +300,6 @@ __fmal (_Float128 x, _Float128 y, _Float128 z)
>v.ieee.mantissa3 |= j;
>return v.d * L(0x1p-228);
>  }
> +#endif /* ! USE_FMAL_BUILTIN  */
>  }
>  libm_alias_ldouble (__fma, fma)
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/5] iee754: prvoide gcc builtins based generic sqrt functions

2020-06-01 Thread Adhemerval Zanella



On 01/06/2020 11:13, Adhemerval Zanella wrote:
> 
> 
> On 29/05/2020 23:00, Vineet Gupta wrote:
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  
> 
>> ---
>>  sysdeps/generic/math-use-builtins.h | 3 +++
>>  sysdeps/ieee754/dbl-64/e_sqrt.c | 6 ++
>>  sysdeps/ieee754/flt-32/e_sqrtf.c| 6 ++
>>  3 files changed, 15 insertions(+)
>>
>> diff --git a/sysdeps/generic/math-use-builtins.h 
>> b/sysdeps/generic/math-use-builtins.h
>> index 8a39ef58bc95..fc724c824a17 100644
>> --- a/sysdeps/generic/math-use-builtins.h
>> +++ b/sysdeps/generic/math-use-builtins.h
>> @@ -60,4 +60,7 @@
>>  # define USE_COPYSIGNF128_BUILTIN 0
>>  #endif
>>  
>> +#define USE_SQRT_BUILTIN 0
>> +#define USE_SQRTF_BUILTIN 0
>> +
>>  #endif /* math-use-builtins.h */
> 
> Ok.
> 
>> diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c 
>> b/sysdeps/ieee754/dbl-64/e_sqrt.c
>> index d42a1a4eb6e9..518a8ae5cdaf 100644
>> --- a/sysdeps/ieee754/dbl-64/e_sqrt.c
>> +++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
>> @@ -41,6 +41,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  /*/
>>  /* An ultimate sqrt routine. Given an IEEE double machine number x   */
> 
> Ok.
> 
>> @@ -50,6 +51,10 @@
>>  double
>>  __ieee754_sqrt (double x)
>>  {
>> +#if USE_SQRT_BUILTIN
>> +  return __builtin_sqrt (x);
>> +#else
>> +  /* Use generic implementation.  */
>>static const double
>>  rt0 = 9.859990725855365213134618E-01,
>>  rt1 = 4.495955425917856814202739E-01,
>> @@ -138,6 +143,7 @@ __ieee754_sqrt (double x)
>>  return (x - x) / (x - x); /* sqrt(-ve)=sNaN */
>>return 0x1p-256 * __ieee754_sqrt (x * 0x1p512);
>>  }
>> +#endif /* ! USE_SQRT_BUILTIN  */
>>  }
>>  #ifndef __ieee754_sqrt
>>  libm_alias_finite (__ieee754_sqrt, __sqrt)
> 
> Ok.
> 
>> diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c 
>> b/sysdeps/ieee754/flt-32/e_sqrtf.c
>> index b339444301aa..68fc80e1e1ee 100644
>> --- a/sysdeps/ieee754/flt-32/e_sqrtf.c
>> +++ b/sysdeps/ieee754/flt-32/e_sqrtf.c
>> @@ -16,12 +16,17 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  
>>  static  const float one = 1.0, tiny=1.0e-30;

You will need to move this definitions inside the !USE_SQRTF_BUILTIN
to avoid defined by not used warnings.  Current practice is to just
open code the constants and let compiler optimize the constant pool:

diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c b/sysdeps/ieee754/flt-32/e_sqrtf.c
index 68fc80e..d85a041 100644
--- a/sysdeps/ieee754/flt-32/e_sqrtf.c
+++ b/sysdeps/ieee754/flt-32/e_sqrtf.c
@@ -18,8 +18,6 @@
 #include 
 #include 
 
-static const float one = 1.0, tiny=1.0e-30;
-
 float
 __ieee754_sqrtf(float x)
 {
@@ -75,10 +73,10 @@ __ieee754_sqrtf(float x)
 
 /* use floating add to find out rounding direction */
if(ix!=0) {
-   z = one-tiny; /* trigger inexact flag */
-   if (z>=one) {
-   z = one+tiny;
-   if (z>one)
+   z = 0x1p0 - 0x1.4484cp-100; /* trigger inexact flag */
+   if (z >= 0x1p0) {
+   z = 0x1p0 + 0x1.4484cp-100;
+   if (z > 0x1p0)
q += 2;
else
q += (q&1);

>>  
>>  float
>>  __ieee754_sqrtf(float x)
>>  {
>> +#if USE_SQRTF_BUILTIN
>> +return __builtin_sqrtf (x);
>> +#else
>> +/* Use generic implementation.  */
>>  float z;
>>  int32_t sign = (int)0x8000;
>>  int32_t ix,s,q,m,t,i;
>> @@ -83,6 +88,7 @@ __ieee754_sqrtf(float x)
>>  ix += (m <<23);
>>  SET_FLOAT_WORD(z,ix);
>>  return z;
>> +#endif /* ! USE_SQRTF_BUILTIN  */
>>  }
>>  #ifndef __ieee754_sqrtf
>>  libm_alias_finite (__ieee754_sqrtf, __sqrtf)
>>
> 
> Ok.
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 4/5] aarch/fpu: use generic sqrt, fma functions

2020-06-01 Thread Adhemerval Zanella



On 29/05/2020 23:00, Vineet Gupta wrote:
> Signed-off-by: Vineet Gupta 

LGTM, some comments below.

> ---
>  sysdeps/aarch64/fpu/e_sqrt.c| 27 --
>  sysdeps/aarch64/fpu/e_sqrtf.c   | 27 --
>  sysdeps/aarch64/fpu/math-use-builtins.h | 70 +
>  sysdeps/aarch64/fpu/s_fma.c | 28 --
>  sysdeps/aarch64/fpu/s_fmaf.c| 28 --
>  5 files changed, 70 insertions(+), 110 deletions(-)
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
>  delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c
> 
> diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c
> deleted file mode 100644
> index abb67ef7b061..
> --- a/sysdeps/aarch64/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Square root of floating point number.
> -   Copyright (C) 2015-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
> -   .  */
> -
> -#include 
> -#include 
> -
> -double
> -__ieee754_sqrt (double d)
> -{
> -  return __builtin_sqrt (d);
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)

Ok.

> diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c
> deleted file mode 100644
> index 13008a4f45d6..
> --- a/sysdeps/aarch64/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Single-precision floating point square root.
> -   Copyright (C) 2015-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
> -   .  */
> -
> -#include 
> -#include 
> -
> -float
> -__ieee754_sqrtf (float s)
> -{
> -  return __builtin_sqrtf (s);
> -}
> -libm_alias_finite (__ieee754_sqrtf, __sqrtf)

Ok.

> diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h 
> b/sysdeps/aarch64/fpu/math-use-builtins.h
> new file mode 100644
> index ..52f0a0dad6dd
> --- /dev/null
> +++ b/sysdeps/aarch64/fpu/math-use-builtins.h
> @@ -0,0 +1,70 @@
> +/* Using math gcc builtins instead of generic implementation.  aarch64 
> version.
> +   Copyright (C) 2019-2020 Free Software Foundation, Inc.

I think it should be just 2020 here.

> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   .  */
> +
> +#ifndef MATH_USE_BUILTINS_H
> +#define MATH_USE_BUILTINS_H  1
> +
> +#include  /* For __GNUC_PREREQ.  */
> +
> +/* Define these macros to 1 to use __builtin_xyz instead of the
> +   generic implementation.  */
> +#define USE_NEARBYINT_BUILTIN 0
> +#define USE_NEARBYINTF_BUILTIN 0
> +#define USE_NEARBYINTL_BUILTIN 0
> +#define USE_NEARBYINTF128_BUILTIN 0

Since we are adding this new file for aarch64, we could also enable it fo
nearbyint{f} and remove sysdeps/aarch64/fpu/s_nearbyint{f}.c as well.

> +
> +#define US

Re: [PATCH 5/5] powerpc/fpu: use generic fma functions

2020-06-01 Thread Adhemerval Zanella



On 29/05/2020 23:00, Vineet Gupta wrote:

LGTM, thanks.

This new addition, along with the aarch64 one, makes me wonder if
it would be better to decompose the USE_* defined in multiple files
so the architecture adds only the required ones (instead of copy/paste
the whole file with the generic ones).

Also for powerpc, maybe a future cleanup would to move the logic
to select the builtin to math-use-builtins.h. Something like:

  #ifdef _ARCH_PWR5X
  #  define USE_FLOOR_BUILTIN 1
  #  define USE_FLOORF_BUILTIN 1
  #else
  #  define USE_FLOOR_BUILTIN 0
  #  define USE_FLOORF_BUILTIN 0
  #endif
  #define USE_FLOORL_BUILTIN 0
  #define USE_FLOORF128_BUILTIN 0

Reviewed-by: Adhemerval Zanella  

> ---
>  sysdeps/powerpc/fpu/math-use-builtins.h | 70 +
>  sysdeps/powerpc/fpu/s_fma.c | 27 --
>  sysdeps/powerpc/fpu/s_fmaf.c| 27 --
>  3 files changed, 70 insertions(+), 54 deletions(-)
>  create mode 100644 sysdeps/powerpc/fpu/math-use-builtins.h
>  delete mode 100644 sysdeps/powerpc/fpu/s_fma.c
>  delete mode 100644 sysdeps/powerpc/fpu/s_fmaf.c
> 
> diff --git a/sysdeps/powerpc/fpu/math-use-builtins.h 
> b/sysdeps/powerpc/fpu/math-use-builtins.h
> new file mode 100644
> index ..9bdde66cf1de
> --- /dev/null
> +++ b/sysdeps/powerpc/fpu/math-use-builtins.h
> @@ -0,0 +1,70 @@
> +/* Using math gcc builtins instead of generic implementation.  PowerPC 
> version.
> +   Copyright (C) 2019-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/>.  */
> +
> +#ifndef MATH_USE_BUILTINS_H
> +#define MATH_USE_BUILTINS_H  1
> +
> +#include  /* For __GNUC_PREREQ.  */
> +
> +/* Define these macros to 1 to use __builtin_xyz instead of the
> +   generic implementation.  */
> +#define USE_NEARBYINT_BUILTIN 0
> +#define USE_NEARBYINTF_BUILTIN 0
> +#define USE_NEARBYINTL_BUILTIN 0
> +#define USE_NEARBYINTF128_BUILTIN 0
> +
> +#define USE_RINT_BUILTIN 0
> +#define USE_RINTF_BUILTIN 0
> +#define USE_RINTL_BUILTIN 0
> +#define USE_RINTF128_BUILTIN 0
> +
> +#define USE_FLOOR_BUILTIN 0
> +#define USE_FLOORF_BUILTIN 0
> +#define USE_FLOORL_BUILTIN 0
> +#define USE_FLOORF128_BUILTIN 0
> +
> +#define USE_CEIL_BUILTIN 0
> +#define USE_CEILF_BUILTIN 0
> +#define USE_CEILL_BUILTIN 0
> +#define USE_CEILF128_BUILTIN 0
> +
> +#define USE_TRUNC_BUILTIN 0
> +#define USE_TRUNCF_BUILTIN 0
> +#define USE_TRUNCL_BUILTIN 0
> +#define USE_TRUNCF128_BUILTIN 0
> +
> +#define USE_ROUND_BUILTIN 0
> +#define USE_ROUNDF_BUILTIN 0
> +#define USE_ROUNDL_BUILTIN 0
> +#define USE_ROUNDF128_BUILTIN 0
> +
> +#define USE_COPYSIGNL_BUILTIN 1
> +#if __GNUC_PREREQ (7, 0)
> +# define USE_COPYSIGNF128_BUILTIN 1
> +#else
> +# define USE_COPYSIGNF128_BUILTIN 0
> +#endif
> +
> +#define USE_SQRT_BUILTIN 0
> +#define USE_SQRTF_BUILTIN 0
> +
> +#define USE_FMA_BUILTIN 1
> +#define USE_FMAF_BUILTIN 1
> +#define USE_FMAL_BUILTIN 0
> +
> +#endif /* math-use-builtins.h */

Ok.

> diff --git a/sysdeps/powerpc/fpu/s_fma.c b/sysdeps/powerpc/fpu/s_fma.c
> deleted file mode 100644
> index 9ddd13253485..
> --- a/sysdeps/powerpc/fpu/s_fma.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Compute x * y + z as ternary operation.  PowerPC version.
> -   Copyright (C) 2019-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 Lesse

Re: [PATCH 2/5] iee754: prvoide gcc builtins based generic sqrt functions

2020-06-01 Thread Adhemerval Zanella



On 01/06/2020 15:12, Vineet Gupta wrote:
> On 6/1/20 7:42 AM, Adhemerval Zanella via Libc-alpha wrote:
>> You will need to move this definitions inside the !USE_SQRTF_BUILTIN
>> to avoid defined by not used warnings.  Current practice is to just
>> open code the constants and let compiler optimize the constant pool:
> 
> Won't it be better to keep the const variable and trust the compiler to 
> subsume it
> instead of open coding in multiple places. Makes it more readable ?

I don't have a strong preference, it is just the recent math optimizations
use the constant directly in the hex format instead of trying to factoring
them out.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 03/13] ARC: Thread Local Storage support

2020-06-01 Thread Adhemerval Zanella



On 27/05/2020 22:36, Vineet Gupta wrote:
> On 5/27/20 12:17 PM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>>> This includes all 4 TLS addressing models
>>>
>>> Signed-off-by: Vineet Gupta 
>>
>> As prior patch we do not use DCO, but rather copyright assignment.
>>
>> Looks ok in general, with some comments below.
> 
>>> +
>>> +register struct pthread *__thread_self __asm__("r25");
>>
>> This is used on other ports, but I am not sure if this is a valid definition
>> for a global variable. 
> 
> Not valid from gcc implementation POV ? The syntax seems to work alright in 
> ARC
> linux kernel where we use r25 to cache the current task pointer.

The gcc documentation [1] does specify register global variables, but it
also states that 

"[...] it is recommended that you choose a register that is normally saved and 
restored by function calls on your machine, so that calls to library routines
will not clobber it."

So I see that the semantic of global register is kind fragile and since
it is usage is solely for asm inline argument I don't see a very compelling
reason to keep using it.

[1] https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html

> 
>> Usually the register specifier is used as an input 
>> for inline assembly.  Do we really need this global on ARC port? Couldn't
>> we replace it with __builtin_thread_pointer where applicable?
> 
> We do use __builtin_thread_pointer and actually __thread_self is not used in 
> ARC
> port :-) so I can just drop it

Ack.

> 
> Many thx for reviewing.
> -Vineet
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 1/4] iee754: provide gcc builtins based generic sqrt functions

2020-06-02 Thread Adhemerval Zanella



On 01/06/2020 21:35, Vineet Gupta wrote:
> Reviewed-by: Adhemerval Zanella  

LGTM with the small nit below and the s390 fix pointed by Stefan.

Reviewed-by: Adhemerval Zanella 

> ---
>  sysdeps/generic/math-use-builtins.h |  3 +++
>  sysdeps/ieee754/dbl-64/e_sqrt.c |  6 ++
>  sysdeps/ieee754/flt-32/e_sqrtf.c| 16 ++--
>  3 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/sysdeps/generic/math-use-builtins.h 
> b/sysdeps/generic/math-use-builtins.h
> index 8a39ef58bc95..fc724c824a17 100644
> --- a/sysdeps/generic/math-use-builtins.h
> +++ b/sysdeps/generic/math-use-builtins.h
> @@ -60,4 +60,7 @@
>  # define USE_COPYSIGNF128_BUILTIN 0
>  #endif
>  
> +#define USE_SQRT_BUILTIN 0
> +#define USE_SQRTF_BUILTIN 0
> +
>  #endif /* math-use-builtins.h */

Ok.

> diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c
> index d42a1a4eb6e9..518a8ae5cdaf 100644
> --- a/sysdeps/ieee754/dbl-64/e_sqrt.c
> +++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
> @@ -41,6 +41,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /*/
>  /* An ultimate sqrt routine. Given an IEEE double machine number x   */
> @@ -50,6 +51,10 @@
>  double
>  __ieee754_sqrt (double x)
>  {
> +#if USE_SQRT_BUILTIN
> +  return __builtin_sqrt (x);
> +#else
> +  /* Use generic implementation.  */
>static const double
>  rt0 = 9.859990725855365213134618E-01,
>  rt1 = 4.495955425917856814202739E-01,
> @@ -138,6 +143,7 @@ __ieee754_sqrt (double x)
>   return (x - x) / (x - x); /* sqrt(-ve)=sNaN */
>return 0x1p-256 * __ieee754_sqrt (x * 0x1p512);
>  }
> +#endif /* ! USE_SQRT_BUILTIN  */
>  }
>  #ifndef __ieee754_sqrt
>  libm_alias_finite (__ieee754_sqrt, __sqrt)

Ok.

> diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c 
> b/sysdeps/ieee754/flt-32/e_sqrtf.c
> index b339444301aa..d85a04162983 100644
> --- a/sysdeps/ieee754/flt-32/e_sqrtf.c
> +++ b/sysdeps/ieee754/flt-32/e_sqrtf.c
> @@ -16,12 +16,15 @@
>  #include 
>  #include 
>  #include 
> -
> -static   const float one = 1.0, tiny=1.0e-30;
> +#include 
>  
>  float
>  __ieee754_sqrtf(float x)
>  {
> +#if USE_SQRTF_BUILTIN
> + return __builtin_sqrtf (x);
> +#else
> + /* Use generic implementation.  */
>   float z;
>   int32_t sign = (int)0x8000;
>   int32_t ix,s,q,m,t,i;
> @@ -70,10 +73,10 @@ __ieee754_sqrtf(float x)
>  
>  /* use floating add to find out rounding direction */
>   if(ix!=0) {
> - z = one-tiny; /* trigger inexact flag */
> - if (z>=one) {
> - z = one+tiny;
> - if (z>one)
> + z = 0x1p0 - 0x1.4484cp-100; /* trigger inexact flag */

Period and double space before '*/'.

> + if (z >= 0x1p0) {
> + z = 0x1p0 + 0x1.4484cp-100;
> + if (z > 0x1p0)
>   q += 2;
>   else
>   q += (q&1);
> @@ -83,6 +86,7 @@ __ieee754_sqrtf(float x)
>   ix += (m <<23);
>   SET_FLOAT_WORD(z,ix);
>   return z;
> +#endif /* ! USE_SQRTF_BUILTIN  */
>  }
>  #ifndef __ieee754_sqrtf
>  libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> 

Ok.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 2/4] iee754: provide gcc builtins based generic fma functions

2020-06-02 Thread Adhemerval Zanella



On 01/06/2020 21:35, Vineet Gupta wrote:
> ---
>  sysdeps/generic/math-use-builtins.h | 5 +
>  sysdeps/ieee754/dbl-64/s_fma.c  | 6 ++
>  sysdeps/ieee754/dbl-64/s_fmaf.c | 6 ++
>  sysdeps/ieee754/float128/float128_private.h | 2 ++
>  sysdeps/ieee754/ldbl-128/s_fmal.c   | 5 +
>  5 files changed, 24 insertions(+)


LGTM with s390 fix pointed by Stefan.

Reviewed-by: Adhemerval Zanella 

> 
> diff --git a/sysdeps/generic/math-use-builtins.h 
> b/sysdeps/generic/math-use-builtins.h
> index fc724c824a17..cf25ed8a2138 100644
> --- a/sysdeps/generic/math-use-builtins.h
> +++ b/sysdeps/generic/math-use-builtins.h
> @@ -63,4 +63,9 @@
>  #define USE_SQRT_BUILTIN 0
>  #define USE_SQRTF_BUILTIN 0
>  
> +#define USE_FMA_BUILTIN 0
> +#define USE_FMAF_BUILTIN 0
> +#define USE_FMAL_BUILTIN 0
> +#define USE_FMAF128_BUILTIN 0
> +
>  #endif /* math-use-builtins.h */
> diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
> index 876df6e78bdc..9dc5b132b9ee 100644
> --- a/sysdeps/ieee754/dbl-64/s_fma.c
> +++ b/sysdeps/ieee754/dbl-64/s_fma.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation uses rounding to odd to avoid problems with
> double rounding.  See a paper by Boldo and Melquiond:
> @@ -33,6 +34,10 @@
>  double
>  __fma (double x, double y, double z)
>  {
> +#if USE_FMA_BUILTIN
> +  return __builtin_fma (x, y, z);
> +#else
> +  /* Use generic implementation.  */
>union ieee754_double u, v, w;
>int adjust = 0;
>u.d = x;
> @@ -292,6 +297,7 @@ __fma (double x, double y, double z)
>v.ieee.mantissa1 |= j;
>return v.d * 0x1p-108;
>  }
> +#endif /* ! USE_FMA_BUILTIN  */
>  }
>  #ifndef __fma
>  libm_alias_double (__fma, fma)
> diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
> index 57329d0a87fe..93b8660d5242 100644
> --- a/sysdeps/ieee754/dbl-64/s_fmaf.c
> +++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation relies on double being more than twice as
> precise as float and uses rounding to odd in order to avoid problems
> @@ -33,6 +34,10 @@
>  float
>  __fmaf (float x, float y, float z)
>  {
> +#if USE_FMAF_BUILTIN
> +  return __builtin_fmaf (x, y, z);
> +#else
> +  /* Use generic implementation.  */
>fenv_t env;
>  
>/* Multiplication is always exact.  */
> @@ -60,6 +65,7 @@ __fmaf (float x, float y, float z)
>  
>/* And finally truncation with round to nearest.  */
>return (float) u.d;
> +#endif /* ! USE_FMAF_BUILTIN  */
>  }
>  #ifndef __fmaf
>  libm_alias_float (__fma, fma)
> diff --git a/sysdeps/ieee754/float128/float128_private.h 
> b/sysdeps/ieee754/float128/float128_private.h
> index f97463d9dc1b..ab6fc9f3c9cf 100644
> --- a/sysdeps/ieee754/float128/float128_private.h
> +++ b/sysdeps/ieee754/float128/float128_private.h
> @@ -154,6 +154,8 @@
>  #define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN
>  #undef USE_COPYSIGNL_BUILTIN
>  #define USE_COPYSIGNL_BUILTIN USE_COPYSIGNF128_BUILTIN
> +#undef USE_FMAL_BUILTIN
> +#define USE_FMAL_BUILTIN USE_FMAF128_BUILTIN
>  
>  /* IEEE function renames.  */
>  #define __ieee754_acoshl __ieee754_acoshf128
> diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c 
> b/sysdeps/ieee754/ldbl-128/s_fmal.c
> index 7475015bcec6..a610499e47c7 100644
> --- a/sysdeps/ieee754/ldbl-128/s_fmal.c
> +++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
> @@ -25,6 +25,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  /* This implementation uses rounding to odd to avoid problems with
> double rounding.  See a paper by Boldo and Melquiond:
> @@ -33,6 +34,9 @@
>  _Float128
>  __fmal (_Float128 x, _Float128 y, _Float128 z)
>  {
> +#if USE_FMAL_BUILTIN
> +  return __builtin_fmal (x, y, z);
> +#else
>union ieee854_long_double u, v, w;
>int adjust = 0;
>u.d = x;
> @@ -296,5 +300,6 @@ __fmal (_Float128 x, _Float128 y, _Float128 z)
>v.ieee.mantissa3 |= j;
>return v.d * L(0x1p-228);
>  }
> +#endif /* ! USE_FMAL_BUILTIN  */
>  }
>  libm_alias_ldouble (__fma, fma)
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 3/4] aarch/fpu: use generic builtins based math functions

2020-06-02 Thread Adhemerval Zanella



On 01/06/2020 21:35, Vineet Gupta wrote:
> introduce sysdep header math-use-builtins.h to replace aarch64
> impementations with corresponding generic ones

s/impementations/implementations and missing ':'.

> 
>  - newly inroduced generic sqrt{,f}, fma{,f}
>  - existing floor{,f}, nearbyint{,f}, rint{,f}, round{,f}, trunc{,f}
>  - Note that generic copysign was already enabled (via generic
>math-use-builtins.h) now thru sysdep header
> 
> This is supposed to be a non functional change
> Passes build-many for aarch64-linux-gnu

LGTM (just double check if the objects generated by the removed 
implementations did not changed).

Reviewed-by: Adhemerval Zanella 

> ---
>  sysdeps/aarch64/fpu/e_sqrt.c| 27 --
>  sysdeps/aarch64/fpu/e_sqrtf.c   | 27 --
>  sysdeps/aarch64/fpu/math-use-builtins.h | 71 +
>  sysdeps/aarch64/fpu/s_floor.c   | 29 --
>  sysdeps/aarch64/fpu/s_floorf.c  | 29 --
>  sysdeps/aarch64/fpu/s_fma.c | 28 --
>  sysdeps/aarch64/fpu/s_fmaf.c| 28 --
>  sysdeps/aarch64/fpu/s_nearbyint.c   | 28 --
>  sysdeps/aarch64/fpu/s_nearbyintf.c  | 28 --
>  sysdeps/aarch64/fpu/s_rint.c| 29 --
>  sysdeps/aarch64/fpu/s_rintf.c   | 29 --
>  sysdeps/aarch64/fpu/s_round.c   | 29 --
>  sysdeps/aarch64/fpu/s_roundf.c  | 29 --
>  sysdeps/aarch64/fpu/s_trunc.c   | 29 --
>  sysdeps/aarch64/fpu/s_truncf.c  | 29 --
>  15 files changed, 71 insertions(+), 398 deletions(-)
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
>  delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
>  delete mode 100644 sysdeps/aarch64/fpu/s_floor.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_floorf.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_nearbyint.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_nearbyintf.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_rint.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_rintf.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_round.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_roundf.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_trunc.c
>  delete mode 100644 sysdeps/aarch64/fpu/s_truncf.c
> 
> diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c
> deleted file mode 100644
> index abb67ef7b061..
> --- a/sysdeps/aarch64/fpu/e_sqrt.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Square root of floating point number.
> -   Copyright (C) 2015-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/>.  */
> -
> -#include 
> -#include 
> -
> -double
> -__ieee754_sqrt (double d)
> -{
> -  return __builtin_sqrt (d);
> -}
> -libm_alias_finite (__ieee754_sqrt, __sqrt)

Ok.

> diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c
> deleted file mode 100644
> index 13008a4f45d6..
> --- a/sysdeps/aarch64/fpu/e_sqrtf.c
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Single-precision floating point square root.
> -   Copyright (C) 2015-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 Pu

Re: static inline math functions (was Re: [PATCH v6 06/13] ARC: hardware floating point support)

2020-06-02 Thread Adhemerval Zanella



On 02/06/2020 15:13, Joseph Myers wrote:
> On Tue, 2 Jun 2020, Vineet Gupta via Libc-alpha wrote:
> 
>> Thi s approach seems to trip math/check-installed-headers.out
>>
>>
>>  -std=c89
>> In file included from ../include/fpu_control.h:2,
>> from /tmp/cih_test_Nknxdp.c:8:
>> ../sysdeps/arc/fpu_control.h:82:14: error: expected ';' before 'unsigned'
>> 82 | static inline unsigned int arc_fpu_getcw(void)
>>
>>
>> Any tips ?
> 
> Installed headers have to use __inline instead of inline to work in C90 
> mode.
> 

Do we need to export _FPU_{GET,SET}CW macros? Otherwise we remove it and
move the fp hardware control register to an internal definition?

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v3 1/4] iee754: provide gcc builtins based generic sqrt functions

2020-06-03 Thread Adhemerval Zanella



On 03/06/2020 14:06, Vineet Gupta via Libc-alpha wrote:
> On 6/3/20 1:46 AM, Andreas Schwab wrote:
>> s/iee754/ieee754/
> 
> Fixed. Thx
> 

I think this patchset is ok, there is no need to send a v4. Do you 
need someone to push it upstream for you?

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 11/13] ARC: Build Infrastructure

2020-06-03 Thread Adhemerval Zanella



On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
> Signed-off-by: Vineet Gupta 

Some comments below.

> ---
>  config.h.in|   3 +
>  sysdeps/arc/Implies|   3 +
>  sysdeps/arc/Makefile   |  21 +++
>  sysdeps/arc/Versions   |   8 +
>  sysdeps/arc/configure  | 182 +
>  sysdeps/arc/configure.ac   |  26 +++
>  sysdeps/arc/nptl/Makefile  |  22 +++
>  sysdeps/arc/preconfigure   |  14 ++
>  sysdeps/unix/sysv/linux/arc/Implies|   3 +
>  sysdeps/unix/sysv/linux/arc/Makefile   |  29 
>  sysdeps/unix/sysv/linux/arc/Versions   |  16 ++
>  sysdeps/unix/sysv/linux/arc/configure  |   4 +
>  sysdeps/unix/sysv/linux/arc/configure.ac   |   4 +
>  sysdeps/unix/sysv/linux/arc/ldconfig.h |  27 +++
>  sysdeps/unix/sysv/linux/arc/shlib-versions |   7 +
>  15 files changed, 369 insertions(+)
>  create mode 100644 sysdeps/arc/Implies
>  create mode 100644 sysdeps/arc/Makefile
>  create mode 100644 sysdeps/arc/Versions
>  create mode 100644 sysdeps/arc/configure
>  create mode 100644 sysdeps/arc/configure.ac
>  create mode 100644 sysdeps/arc/nptl/Makefile
>  create mode 100644 sysdeps/arc/preconfigure
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
>  create mode 100644 sysdeps/unix/sysv/linux/arc/configure
>  create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
>  create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions
> 
> diff --git a/config.h.in b/config.h.in
> index dea43df438f6..08962dfed075 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -109,6 +109,9 @@
>  /* AArch64 big endian ABI */
>  #undef HAVE_AARCH64_BE
>  
> +/* ARC big endian ABI */
> +#undef HAVE_ARC_BE
> +

Why do you need this define exactly? It is not used anywhere in the code
and for C code if is more straightforwar to use endian.h.

>  /* C-SKY ABI version.  */
>  #undef CSKYABI
>  
> diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies
> new file mode 100644
> index ..780c4e246769
> --- /dev/null
> +++ b/sysdeps/arc/Implies
> @@ -0,0 +1,3 @@
> +wordsize-32
> +ieee754/flt-32
> +ieee754/dbl-64

Ok.

> diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
> new file mode 100644
> index ..56ac503bfe43
> --- /dev/null
> +++ b/sysdeps/arc/Makefile
> @@ -0,0 +1,21 @@
> +# ARC Makefile
> +# Copyright (C) 1993-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
> +# .
> +
> +# We don't support long doubles as a distinct type.  We don't need to set
> +# this variable; it's here mostly for documentational purposes.
> +long-double-fcts = no

Ok.

> diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
> new file mode 100644
> index ..6ac7b8e49505
> --- /dev/null
> +++ b/sysdeps/arc/Versions
> @@ -0,0 +1,8 @@
> +libc {
> +  GLIBC_2.32 {
> +__mcount;
> +  }

Hum, does ARC require a different symbol name than the one provided
by gmon/Versions?

> +  GLIBC_PRIVATE {
> +__syscall_error;
> +  }
> +}
> diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
> new file mode 100644
> index ..5820017d6505
> --- /dev/null
> +++ b/sysdeps/arc/configure
> @@ -0,0 +1,182 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> + # Local configure fragment for sysdeps/arc.
> +
> +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
> +
> +libc_cv_have_sdata_section=no
> +
> +# For ARC, historically ; was used for comments and not newline
> +# Later # also got added to comment list, but ; couldn't be switched to
> +# canonical newline as there's lots of code out there which will break
> +libc_cv_asm_line_sep='`'
> +cat >>confdefs.h <<_ACEOF
> +#define ASM_LINE_SEP $libc_cv_asm_line_sep
> +_ACEOF
> +
> +
> +# For big endian ABI, generate a symbol for selecting right dynamic linker
> +
> +
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long 
> lines and -e" >&5
> +$as_echo_n "checking for grep that handles long lines and -e... "

Re: [PATCH v6 07/13] ARC: Linux Syscall Interface

2020-06-03 Thread Adhemerval Zanella



On 03/06/2020 16:46, Vineet Gupta wrote:
> On 5/29/20 9:49 AM, Adhemerval Zanella via Libc-alpha wrote:
>>> +   ; - child starts here -
>>> +
>>> +   ; Setup TP register (only recent kernels v4.19+ do that)
>>> +   and.f   0, r12, CLONE_SETTLS
>>> +   mov.nz  r25, r9
>> Do you still need to set it since the minimum supported kernel
>> for ARC is 5.1 ?
> 
> Right.
> 
>> It should be safe for internal glibc usage, since for both pthread
>> and posix_spawn it blocks all signals including SIGCANCEL and SIGXID.
>> However this is still small race window if this is called directly 
>> with pthread cancellation or g*uid in multithread.
> 
> I'm not sure what you mean above. Do you mean not doing this in glibc and 
> even if
> kernel support didn't exist should be safe internally ?

At least for internal clone usage with CLONE_VM within glibc we explicit
disable all signals (posix_spawn and pthread_create).

> 
> fwiw as mentioned above kernel sets up TP for clone (SETTLS). I detested doing
> that for a long time, give ABI implications but ended up doing it anyways due 
> to
> an actual race hit when running uClibc tst-kill6 [1]

We explicit disable all signals during the create_thread call in pthread_create
(b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8), so it should not happen on glibc
anymore.  However it is still an issue if application calls clone itself.

> 
> [1] 
> http://lists.infradead.org/pipermail/linux-snps-arc/2018-October/004480.html
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 07/13] ARC: Linux Syscall Interface

2020-06-04 Thread Adhemerval Zanella



On 03/06/2020 17:17, Vineet Gupta wrote:
> On 6/3/20 1:04 PM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 03/06/2020 16:46, Vineet Gupta wrote:
>>> On 5/29/20 9:49 AM, Adhemerval Zanella via Libc-alpha wrote:
>>>>> + ; - child starts here -
>>>>> +
>>>>> + ; Setup TP register (only recent kernels v4.19+ do that)
>>>>> + and.f   0, r12, CLONE_SETTLS
>>>>> + mov.nz  r25, r9
>>>> Do you still need to set it since the minimum supported kernel
>>>> for ARC is 5.1 ?
>>>
>>> Right.
>>>
>>>> It should be safe for internal glibc usage, since for both pthread
>>>> and posix_spawn it blocks all signals including SIGCANCEL and SIGXID.
>>>> However this is still small race window if this is called directly 
>>>> with pthread cancellation or g*uid in multithread.
>>>
>>> I'm not sure what you mean above. Do you mean not doing this in glibc and 
>>> even if
>>> kernel support didn't exist should be safe internally ?
>>
>> At least for internal clone usage with CLONE_VM within glibc we explicit
>> disable all signals (posix_spawn and pthread_create).
>>
>>>
>>> fwiw as mentioned above kernel sets up TP for clone (SETTLS). I detested 
>>> doing
>>> that for a long time, give ABI implications but ended up doing it anyways 
>>> due to
>>> an actual race hit when running uClibc tst-kill6 [1]
>>
>> We explicit disable all signals during the create_thread call in 
>> pthread_create
>> (b3cae39dcbfa2432b3f3aa28854d8ac57f0de1b8), so it should not happen on glibc
>> anymore.  However it is still an issue if application calls clone itself.
> 
> The scenario there was pthread_create() and parent getting scheduled before 
> child
> and immediately doing pthread_kill() causing child signal handler to be 
> invoked
> and signal handler doing pthread_self() which was broken as TP was not setup.
> 
> With commit above, parent pthread_kill() will block and will only run when 
> child
> is scheduled and unblocks the signals !

It could happen with other scenarios when signal plus tp accesses were involved 
as
well: pthread_cancel the thread (since the sigcancel_handler acesses the tp
with THREAD_GETMEM macro), setg* functions (since sighandler_setxid), or any
functions with a syscall failure that sets the errno.


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 11/13] ARC: Build Infrastructure

2020-06-04 Thread Adhemerval Zanella



On 04/06/2020 12:25, Vineet Gupta wrote:
> On 6/3/20 12:58 PM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>>
>>> diff --git a/config.h.in b/config.h.in
>>> index dea43df438f6..08962dfed075 100644
>>> --- a/config.h.in
>>> +++ b/config.h.in
>>> @@ -109,6 +109,9 @@
>>>  /* AArch64 big endian ABI */
>>>  #undef HAVE_AARCH64_BE
>>>  
>>> +/* ARC big endian ABI */
>>> +#undef HAVE_ARC_BE
>>> +
>>
>> Why do you need this define exactly? It is not used anywhere in the code
>> and for C code if is more straightforwar to use endian.h.
> 
> It is used in build system as part of "formal" BE ABI support as pointed to 
> in v4
> series review. This specific thing helps choose the right dynamic linker name 
> for
> BE case.

Ack.

> 
> $ git grep HAVE_ARC_BE
> config.h.in:113:#undef HAVE_ARC_BE
> sysdeps/arc/configure:175:  $as_echo "#define HAVE_ARC_BE 1" >>confdefs.h
> sysdeps/arc/configure.ac:22:  AC_DEFINE(HAVE_ARC_BE)
> sysdeps/unix/sysv/linux/arc/shlib-versions:3:%ifdef HAVE_ARC_BE
> 
> I looked at other ports and they seem to follow similar patters: csky for 
> CSKYABI,
> riscv for RISCV_ABI_XLEN etc.

Right, it is the usual way indeed. This is fine.

> 
> But I can rework if there's a simpler/better way.
> 
>>> +++ b/sysdeps/arc/Versions
>>> @@ -0,0 +1,8 @@
>>> +libc {
>>> +  GLIBC_2.32 {
>>> +__mcount;
>>> +  }
>>
>> Hum, does ARC require a different symbol name than the one provided
>> by gmon/Versions?
> 
> ARC gcc generates __mcount and _mcount with different ABIs and we use the 
> newer
> __mcount.

Ack.

> 
>>> +AC_DEFINE(PI_STATIC_AND_HIDDEN)
>>> +libc_cv_have_sdata_section=no
>>
>> The libc_cv_have_sdata_section is done by configure.ac, why do you need
>> to explicit set it here?
> 
> We inhibit small data explicitly which by default kicks in.

Ok, is it some limitation for loader bootstrap or something else?

> 
>>> +if test $libc_cv_arc_be = yes; then
>>> +  # For shlib-versions.
>>> +  AC_DEFINE(HAVE_ARC_BE)
>>> +  LIBC_CONFIG_VAR([default-abi], [ilp32_be])
>>> +else
>>> +  LIBC_CONFIG_VAR([default-abi], [ilp32])
>>> +fi
>>
>> The ilp32 naming is usually set for ILP32 architectures that uses 
>> 64-bit registers type on 32 bit VMA (for instance mips64n32, x32,
>> or aarch64_ilp32).  I don't think this is the case for ARC, so I think
>> this naming might be confusing.
>>> +abi-variants := ilp32 ilp32_be
> 
> arcle arcbe ?

LGTM.

> 
>>> +
>>> +ifeq (,$(filter $(default-abi),$(abi-variants)))
>>> +$(error Unknown ABI $(default-abi), must be one of $(abi-variants))
>>> +endif
>>> +
>>> +abi-ilp32-condition:= !defined __BIG_ENDIAN__
>>> +abi-ilp32_be-condition := defined __BIG_ENDIAN__
>>
>> Ok with the 'ilp32' naming module described above.
> 
> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/Versions 
>>> b/sysdeps/unix/sysv/linux/arc/Versions
>>> new file mode 100644
>>> index ..292f1974b02a
>>> --- /dev/null
>>> +++ b/sysdeps/unix/sysv/linux/arc/Versions
>>> @@ -0,0 +1,16 @@
>>> +ld {
>>> +  GLIBC_PRIVATE {
>>> +# used for loading by static libraries
>>> +_dl_var_init;
>>> +  }
>>> +}
>>> +libc {
>>> +  GLIBC_2.32 {
>>> +_flush_cache;
>>> +cacheflush;
>>> +  }
>>> +  GLIBC_PRIVATE {
>>> +# A copy of sigaction lives in libpthread, and needs these.
>>> +__default_rt_sa_restorer;
>>> +  }
>>> +}
>>
>> Afaik all other ABIs that requires the sa_restores uses a local symbol in
>> libpthread. I don't have a strong preference here.
> 
> Do you mean add following to sysdeps/unix/sysv/linux/arc/Makefile
> 
> ifeq ($(subdir),nptl)
> libpthread-routines += sigrestorer
> libpthread-shared-only-routines += sigrestorer
> endif

Yeap.

> 
> And that is to optimize the reference to restorer as a direct PC relative 
> access
> vs a got reference ?

My understanding is this specific optimization does not really matter: 
sigaction is hardly a hotspot and the symbol will be issue by the 
kernel itself. AFAIU is more a way to optimize the exported symbols
and simplify the GLIBC_PRIVATE namespace (since the sa_restore usually
has small text size).

> 
> It seems even in libc, this is currently not optimal. It seems we need
> libc_hidden_* on restore

Re: [PATCH v6 06/13] ARC: hardware floating point support

2020-06-05 Thread Adhemerval Zanella



On 05/06/2020 01:44, Vineet Gupta wrote:
> On 5/29/20 4:50 PM, Vineet Gupta via Libc-alpha wrote:
 Although this code follow other architectures, I think it woudl be better
 to move forward a macro that emulates function calls and use proper
 static inline function instead for _FPU_* (as for get-rounding-mode.h).
>>> OK. do you have a preference for names, existing upper case names OK ?
>> Something like below ?
>>
>> +# define _FPU_FPSR_FWE  0x8000
>> +
>> -#  define _FPU_GETCW(cw) __asm__ volatile ("lr %0, [0x300]" : "=r" (cw))
>> -#  define _FPU_SETCW(cw) __asm__ volatile ("sr %0, [0x300]" : : "r" (cw))
>> +static inline unsigned int arc_fpu_getcw(void)
>> +{
>> +  unsigned int cw;
>> +  __asm__ volatile ("lr %0, [0x300]" : "=r" (cw));
>> +  return cw;
>> +}
>> +
>> +static inline void arc_fpu_setcw(unsigned int cw)
>> +{
>> +  __asm__ volatile ("sr %0, [0x300]" : : "r" (cw));
>> +}
> 
> It seems there is more discussiosn to be had here. Can we just punt on this
> specific item and keep the status quo macros please. We are heading towards 
> july
> and I'd rather have the port go in this cycle !

I don't have a strong opinion here, it was more a suggestion. It seems
to follow other architectures, although at least alpha does not 
provide the _FPU_GETCW macro.  Another option would to just
move this definition to an internal header as well.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 1/2] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-06-05 Thread Adhemerval Zanella



On 01/06/2020 19:18, Vineet Gupta wrote:
> The existing macros are fragile and expect local variables with a
> certain name. Fix this by defining them as functions with default
> implementation in a new header dl-runtime.h which arches can override
> if need be.
> 
> This came up during ARC port review, hence the need for argument pltgot
> in reloc_index() which is not needed by existing ports.
> 
> This patch potentially only affects hppa/x86 ports,
> build tested for both those configs and a few more.
> 
> Suggested-by: Adhemerval Zanella 

LGTM, thanks.  There are just style nits in the one-line comment
for new files.

Reviewed-by: Adhemerval Zanella 

> ---
>  elf/dl-runtime.c| 28 +---
>  elf/dl-runtime.h| 30 ++
>  sysdeps/hppa/dl-runtime.c   |  4 
>  sysdeps/hppa/dl-runtime.h   | 31 +++
>  sysdeps/x86_64/dl-runtime.c |  9 -
>  sysdeps/x86_64/dl-runtime.h | 35 +++
>  6 files changed, 113 insertions(+), 24 deletions(-)
>  create mode 100644 elf/dl-runtime.h
>  create mode 100644 sysdeps/hppa/dl-runtime.h
>  delete mode 100644 sysdeps/x86_64/dl-runtime.c
>  create mode 100644 sysdeps/x86_64/dl-runtime.h
> 
> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> index cf5f1d3e82e1..85a229f6f019 100644
> --- a/elf/dl-runtime.c
> +++ b/elf/dl-runtime.c
> @@ -27,6 +27,7 @@
>  #include "dynamic-link.h"
>  #include 
>  #include 
> +#include 
>  
>  
>  #if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
> @@ -42,13 +43,6 @@
>  # define ARCH_FIXUP_ATTRIBUTE
>  #endif
>  
> -#ifndef reloc_offset
> -# define reloc_offset reloc_arg
> -# define reloc_index  reloc_arg / sizeof (PLTREL)
> -#endif
> -
> -
> -
>  /* This function is called through a special trampoline from the PLT the
> first time each PLT entry is called.  We must perform the relocation
> specified in the PLT of the given shared object, and return the resolved
> @@ -68,8 +62,11 @@ _dl_fixup (
>  = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> -= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> += (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *refsym = sym;
>void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);

Ok.

> @@ -180,9 +177,12 @@ _dl_profile_fixup (
>   l, reloc_arg);
>  }
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>/* This is the address in the array where we store the result of previous
>   relocations.  */
> -  struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result
> += &l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
>  
>   /* CONCURRENCY NOTES:
>  


Ok.
> @@ -219,8 +219,11 @@ _dl_profile_fixup (
>   = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const char *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> - = (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> + = (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *refsym = &symtab[ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *defsym = refsym;
>lookup_t result;

Ok.

> @@ -485,11 +488,14 @@ _dl_call_pltexit (struct link_map *l, ElfW(Word) 
> reloc_arg,
> const void *inregs, void *outregs)
>  {
>  #ifdef SHARED
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>/* This is the address in the array where we store the result of previous
>   relocations.  */
>// XXX Maybe the bound information must be stored on the stack since
>// XXX with bind_not a new value could have been stored in the meantime.
> -  struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result =
> +&l->l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
>ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
>   l_info[DT_SYMTAB])
> 

Re: [PATCH v2 2/2] ARC/dl-runtime helper macros

2020-06-05 Thread Adhemerval Zanella



On 01/06/2020 19:18, Vineet Gupta wrote:
> This is purely for review purposes to attest the interface defined
> in prior patch

LGTM with some style nits, however I think it should be pushed along with 
the ARC patchset.

Reviewed-by: Adhemerval Zanella 

> ---
>  sysdeps/arc/dl-runtime.h | 42 
>  1 file changed, 42 insertions(+)
>  create mode 100644 sysdeps/arc/dl-runtime.h
> 
> diff --git a/sysdeps/arc/dl-runtime.h b/sysdeps/arc/dl-runtime.h
> new file mode 100644
> index ..529d49f5d0a1
> --- /dev/null
> +++ b/sysdeps/arc/dl-runtime.h
> @@ -0,0 +1,42 @@
> +/* Helpers for On-demand PLT fixup for shared objects. ARC version.

Double space after period.

> +   Copyright (C) 2017-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/>.  */
> +
> +/* PLT jump into resolver passes PC of PLTn, while _dl_fixup expects the
> +   address of corresponding .rela.plt entry.
> +
> +- @plt0: runtime pc of first plt entry (DT_PLTGOT)
> +- @pltn: runtime pc of plt entry being resolved
> +- @size: size of .plt.rela entry (unused).  */
> +static inline uintptr_t
> +reloc_index (uintptr_t plt0, uintptr_t pltn, size_t size)
> +{
> +  unsigned long int idx = (unsigned long)pltn - (unsigned long)plt0;

I don't think the explicit cast is required here.

> +
> +  /* PLT trampoline is 16 bytes. */
> +  idx /= 16;
> +
> +  /* Exclude PLT0 and PLT1.  */
> +  return idx - 2;
> +}
> +
> +static inline uintptr_t
> +reloc_offset (uintptr_t plt0, uintptr_t pltn)
> +{
> +  size_t sz = sizeof (ElfW(Rela));
> +  return reloc_index(plt0, pltn, sz) * sz;

Space before parenthesis.

> +}
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2] ieee754/dbl-64: Reduce the scope of temporary storage variables

2020-06-15 Thread Adhemerval Zanella



On 15/06/2020 16:09, Vineet Gupta via Libc-alpha wrote:
> On 6/4/20 12:08 PM, Vineet Gupta via Libc-alpha wrote:
>> On 6/2/20 1:31 PM, Vineet Gupta via Libc-alpha wrote:
>>> On 6/2/20 11:16 AM, Joseph Myers wrote:
 On Mon, 1 Jun 2020, Vineet Gupta via Libc-alpha wrote:

> Also as suggested by Joseph [1] used --strip and compared the libs with
> and w/o patch and their sizes are exactly same (with gcc 9).

 My suggestion was to compare the *contents* of the libraries, not just 
 their sizes.  Either they should be byte-for-byte identical, or if there 
 are other differences (register allocation, line numbers in assertions, 
 etc.) a more detailed investigation will be needed.

>>>
>>> Here's my diff of the 2 --strip builds
>>>
>>> for i in `find . -name libm-2.31.9000.so`; do echo $i; diff $i
>>> /SCRATCH/vgupta/gnu2/install/glibcs/$i ; echo $?; done
>>>
>>> ./aarch64-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>> ./arm-linux-gnueabi/lib/libm-2.31.9000.so
>>> 0
>>> ./x86_64-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>> ./arm-linux-gnueabihf/lib/libm-2.31.9000.so
>>> 0
>>> ./riscv64-linux-gnu-rv64imac-lp64/lib64/lp64/libm-2.31.9000.so
>>> 0
>>> ./riscv64-linux-gnu-rv64imafdc-lp64/lib64/lp64/libm-2.31.9000.so
>>> 0
>>> ./powerpc-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./microblaze-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./nios2-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./hppa-linux-gnu/lib/libm-2.31.9000.so
>>> 0
>>> ./s390x-linux-gnu/lib64/libm-2.31.9000.so
>>> 0
>>
>> Is this sufficient for comparison ?
> 
> ping !
> 

This analysis looks good me, although I can't voucher for Joseph.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7 00/13] glibc port to ARC processors

2020-06-30 Thread Adhemerval Zanella



On 30/06/2020 21:11, Vineet Gupta wrote:
> On 6/23/20 9:56 AM, Vineet Gupta via Libc-alpha wrote:
>> On 6/15/20 1:14 PM, Vineet Gupta wrote:
>>> Hi,
>>>
>>> This patchset implements glibc port to ARC HS48x processor from Synopsys.
>>
>> ping !
> 
> ping ^2 !
> 
> I've posted the incremental series (v7.1) as a followup to include rebase 
> fixes
> since v7. The changes are minimal and documented in respective patches. Kindly
> review so we can get this in, in this cycle.

Thanks for your patience, I will help wrap this up so we can include in
on 2.32.

>>>
>>> (b) Full testsuite ran in a cross compile setup using buildroot on HSDK 
>>> development
>>> platform. Bulk of failures come from cross testing setup and I
>>> intend to improve things with native testing going forward.
>>>
>>> | Summary of test results:
>>> | 30 FAIL   (-3)
>>> |
>>> | FAIL: csu/test-as-const-tcb-offsets
>>> + FAIL: elf/tst-audit14
>>> + FAIL: elf/tst-audit15
>>> + FAIL: elf/tst-audit16

Any idea what it might the culprit here?

>>> | FAIL: elf/tst-ldconfig-ld_so_conf-update # not true: dlopen
>>> | FAIL: iconv/test-iconvconfig  # Needs gconv installed
>>> - FAIL: iconv/tst-gconv-init-failure
>>> | FAIL: io/ftwtest  # Requires execution by non-root
>>> - FAIL: io/tst-futimesat
>>> | FAIL: io/tst-lockf
>>> | FAIL: libio/tst-wfile-sync

Could it be related to NFS usage as well?

>>> | FAIL: locale/tst-C-locale
>>> | FAIL: locale/tst-duplocale
>>> | FAIL: locale/tst-locale-locpath
>>> | FAIL: locale/tst-locname
>>> | FAIL: localedata/sort-test

Any idea why locale is not being working here (these tests are really
simple, maybe another issue related to the filesystem)?

>>> | FAIL: nptl/test-cond-printers # needs Python3 and target GDB 
>>> on target
>>> | FAIL: nptl/test-condattr-printers #ditto
>>> | FAIL: nptl/test-mutex-printers#ditto
>>> | FAIL: nptl/test-mutexattr-printers#ditto
>>> | FAIL: nptl/test-rwlock-printers   #ditto
>>> | FAIL: nptl/test-rwlockattr-printers   #ditto
>>> | FAIL: nptl/tst-umask1 # passes if run natively on 
>>> target (NFS ACLv3 support needed)
>>> | FAIL: nss/bug-erange
>>> | FAIL: nss/tst-nss-files-hosts-getent  # Timed out
>>> | FAIL: nss/tst-nss-files-hosts-multi   # Timed out
>>> | FAIL: posix/bug-ga2   # DNS issue: google DNS vs. SNPS
>>> | FAIL: posix/globtest  # require same user on target 
>>> and host
>>> | FAIL: posix/tst-getaddrinfo5  # passes outside corporate 
>>> network
>>> - FAIL: resolv/tst-resolv-basic
>>> - FAIL: resolv/tst-resolv-edns
>>> - FAIL: resolv/tst-resolv-rotate
>>> - FAIL: resolv/tst-resolv-search
>>> | FAIL: stdio-common/bug22  # Needs more RAM: 2 GB memory

We might try to enhance this test to avoid require too much memory.

>>> | FAIL: sunrpc/bug20790 # missing cpp on target
>>> | FAIL: timezone/tst-tzset  # passes outside corporate network

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7.1 01/13] ARC: ABI Implementation

2020-07-01 Thread Adhemerval Zanella



On 01/07/2020 16:36, Vineet Gupta wrote:
> On 7/1/20 9:50 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 30/06/2020 21:06, Vineet Gupta via Libc-alpha wrote:
>>> This code deals with the ARC ABI.
>>> ---
>>>Changes since v7:
>>>  - Used void * (iso int *) in tls-macros.h
>>
>> LGTM, with just a couple of syntax nits below.
>>
>> Reviewed-by: Adhemerval Zanella  
> 
> Thx. I suppose the process for new ports is to have a Reviewed-by on all 
> patches,
> squash them and push in 1 go (although in past I was asked to push the ARC elf
> header patch).

I think there is no need to squash them up in one commit, but I think
it would be better to commit them at the same time.

> Also do we need more than 1 Reviewed-by for this to be "push worthy" ?

I don't think so, unless someone raise some questioning on the review
itself.

I plan to finish them up by the end of the week.

> 
>>> +ENTRY (__longjmp)
>>> +
>>> +   LDR (blink, r0,  0)
>>> +   LDR (sp,r0,  1)
>>> +   LDR (fp,r0,  2)
>>> +   LDR (gp,r0,  3)
>>> +
>>> +   LDR (r13,   r0,  4)
>>> +   LDR (r14,   r0,  5)
>>> +   LDR (r15,   r0,  6)
>>> +   LDR (r16,   r0,  7)
>>> +   LDR (r17,   r0,  8)
>>> +   LDR (r18,   r0,  9)
>>> +   LDR (r19,   r0, 10)
>>> +   LDR (r20,   r0, 11)
>>> +   LDR (r21,   r0, 12)
>>> +   LDR (r22,   r0, 13)
>>> +   LDR (r23,   r0, 14)
>>> +   LDR (r24,   r0, 15)
>>> +
>>> +   mov.f  r0, r1
>>> +   j.d[blink]
>>> +   mov.z  r0, 1/* don't return 0 to setjmp callsite from longjmp.  */
>>> +
>>> +END (__longjmp)
>>
>> Ok, you have removed r25 save as pre previous discussion.
> 
> Right, and GP is being saved now.
> 
>>> diff --git a/sysdeps/arc/bits/setjmp.h b/sysdeps/arc/bits/setjmp.h
>>> new file mode 100644
>>> index ..6bba95fafe0f
>>> --- /dev/null
>>> +++ b/sysdeps/arc/bits/setjmp.h
>>> @@ -0,0 +1,26 @@
>>> +/* Define the machine-dependent type `jmp_buf'.  ARC version.
>>
>> I think current trend is to just use apostrophe instead of the grave
>> accent in such cases.
> 
> Ok changed.
> 
>>> +reloc_index (uintptr_t plt0, uintptr_t pltn, size_t size)
>>> +{
>>> +  unsigned long int idx = pltn - plt0;
>>> +
>>> +  /* PLT trampoline is 16 bytes. */
>>
>> Double space after period.
> 
> Fixed.
> 
>>> +#define _JMPBUF_UNWINDS_ADJ(_jmpbuf, _address, _adj) \
>>> +  ((uintptr_t) (_address) - (_adj) < (uintptr_t) (_jmpbuf_sp (_jmpbuf) - 
>>> (_adj)))
>>> +
>>> +/* We use the normal longjmp for unwinding.  */
>>> +#define __libc_unwind_longjmp(buf, val) __libc_longjmp (buf, val)
>>
>> Ok. As a side note teh jmpbuf-unwind.h is candidate for some consolidation
>> (the same macros are replicated in each architecture).
> 
> OK.
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7 11/13] ARC: Build Infrastructure

2020-07-03 Thread Adhemerval Zanella



On 15/06/2020 17:14, Vineet Gupta via Libc-alpha wrote:
> ---
>  config.h.in|   3 +
>  sysdeps/arc/Implies|   3 +
>  sysdeps/arc/Makefile   |  21 +++
>  sysdeps/arc/Versions   |   8 +
>  sysdeps/arc/configure  | 182 +
>  sysdeps/arc/configure.ac   |  26 +++
>  sysdeps/arc/nptl/Makefile  |  22 +++
>  sysdeps/arc/preconfigure   |  14 ++
>  sysdeps/unix/sysv/linux/arc/Implies|   3 +
>  sysdeps/unix/sysv/linux/arc/Makefile   |  29 
>  sysdeps/unix/sysv/linux/arc/Versions   |  16 ++
>  sysdeps/unix/sysv/linux/arc/configure  |   4 +
>  sysdeps/unix/sysv/linux/arc/configure.ac   |   4 +
>  sysdeps/unix/sysv/linux/arc/ldconfig.h |  27 +++
>  sysdeps/unix/sysv/linux/arc/shlib-versions |   7 +

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  


>  15 files changed, 369 insertions(+)
>  create mode 100644 sysdeps/arc/Implies
>  create mode 100644 sysdeps/arc/Makefile
>  create mode 100644 sysdeps/arc/Versions
>  create mode 100644 sysdeps/arc/configure
>  create mode 100644 sysdeps/arc/configure.ac
>  create mode 100644 sysdeps/arc/nptl/Makefile
>  create mode 100644 sysdeps/arc/preconfigure
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Implies
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Makefile
>  create mode 100644 sysdeps/unix/sysv/linux/arc/Versions
>  create mode 100644 sysdeps/unix/sysv/linux/arc/configure
>  create mode 100644 sysdeps/unix/sysv/linux/arc/configure.ac
>  create mode 100644 sysdeps/unix/sysv/linux/arc/ldconfig.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/shlib-versions
> 
> diff --git a/config.h.in b/config.h.in
> index 831eca2fe14e..2ed684b7d4e4 100644
> --- a/config.h.in
> +++ b/config.h.in
> @@ -109,6 +109,9 @@
>  /* AArch64 big endian ABI */
>  #undef HAVE_AARCH64_BE
>  
> +/* ARC big endian ABI */
> +#undef HAVE_ARC_BE
> +
>  /* C-SKY ABI version.  */
>  #undef CSKYABI
>  

Ok.

> diff --git a/sysdeps/arc/Implies b/sysdeps/arc/Implies
> new file mode 100644
> index ..780c4e246769
> --- /dev/null
> +++ b/sysdeps/arc/Implies
> @@ -0,0 +1,3 @@
> +wordsize-32
> +ieee754/flt-32
> +ieee754/dbl-64

Ok.

> diff --git a/sysdeps/arc/Makefile b/sysdeps/arc/Makefile
> new file mode 100644
> index ..d5a702e29e58
> --- /dev/null
> +++ b/sysdeps/arc/Makefile
> @@ -0,0 +1,21 @@
> +# ARC Makefile
> +# 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/>.
> +
> +# We don't support long doubles as a distinct type.  We don't need to set
> +# this variable; it's here mostly for documentational purposes.
> +long-double-fcts = no

Ok.

> diff --git a/sysdeps/arc/Versions b/sysdeps/arc/Versions
> new file mode 100644
> index ..6ac7b8e49505
> --- /dev/null
> +++ b/sysdeps/arc/Versions
> @@ -0,0 +1,8 @@
> +libc {
> +  GLIBC_2.32 {
> +__mcount;
> +  }
> +  GLIBC_PRIVATE {
> +__syscall_error;
> +  }
> +}

Ok.

> diff --git a/sysdeps/arc/configure b/sysdeps/arc/configure
> new file mode 100644
> index ..bce7d3c3773d
> --- /dev/null
> +++ b/sysdeps/arc/configure
> @@ -0,0 +1,182 @@
> +# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
> + # Local configure fragment for sysdeps/arc.
> +
> +$as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
> +
> +libc_cv_have_sdata_section=no
> +
> +# For ARC, historically ; was used for comments and not newline
> +# Later # also got added to comment list, but ; couldn't be switched to
> +# canonical newline as there's lots of code out there which will break
> +libc_cv_asm_line_sep='`'
> +cat >>confdefs.h <<_ACEOF
> +#define ASM_LINE_SEP $libc_cv_asm_line_sep
> +_ACEOF
> +
> +
> +# For big endian ABI, generate a symbol 

Re: [PATCH v7 12/13] build-many-glibcs.py: Enable ARC builds

2020-07-03 Thread Adhemerval Zanella



On 15/06/2020 17:14, Vineet Gupta via Libc-alpha wrote:
> ---
>  scripts/build-many-glibcs.py | 10 ++
>  1 file changed, 10 insertions(+)

LGTM, thanks.

Reviewed-by: Adhemerval Zanella 

> 
> diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py
> index 6c6615b200d9..64f5713530bd 100755
> --- a/scripts/build-many-glibcs.py
> +++ b/scripts/build-many-glibcs.py
> @@ -162,6 +162,15 @@ class Context(object):
> 'cfg': ['--disable-multi-arch']}])
>  self.add_config(arch='aarch64_be',
>  os_name='linux-gnu')
> +self.add_config(arch='arc',
> +os_name='linux-gnu',
> +gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
> +self.add_config(arch='arc',
> +os_name='linux-gnuhf',
> +gcc_cfg=['--disable-multilib', 
> '--with-cpu=hs38_linux'])
> +self.add_config(arch='arceb',
> +os_name='linux-gnu',
> +gcc_cfg=['--disable-multilib', '--with-cpu=hs38'])
>  self.add_config(arch='alpha',
>  os_name='linux-gnu')
>  self.add_config(arch='arm',
> @@ -1224,6 +1233,7 @@ def install_linux_headers(policy, cmdlist):
>  """Install Linux kernel headers."""
>  arch_map = {'aarch64': 'arm64',
>  'alpha': 'alpha',
> +'arc': 'arc',
>  'arm': 'arm',
>  'csky': 'csky',
>  'hppa': 'parisc',
> 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7 13/13] Documentation for ARC port

2020-07-03 Thread Adhemerval Zanella



On 15/06/2020 17:14, Vineet Gupta via Libc-alpha wrote:
> ---
>  NEWS| 11 +++
>  README  |  1 +
>  manual/install.texi |  4 

LGTM, thanks.

Reviewed-by: Adhemerval Zanella 

>  3 files changed, 16 insertions(+)
> 
> diff --git a/NEWS b/NEWS
> index a660fc59a89e..db65fea8b6ec 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -15,6 +15,17 @@ Major new features:
>  
>  * New locale added: ckb_IQ (Kurdish/Sorani spoken in Iraq)
>  
> +* Support for Synopsys ARC HS cores (ARCv2 ISA) running Linux has been
> +  added. This port requires at least binutils-2.32, gcc-8.3 and Linux-5.1.
> +  Three ABIs are supported:
> +
> + - arc-linux-gnu
> + - arc-linux-gnuhf
> + - arceb-linux-gnu
> +
> +  The arc* ABI is little-endian while arceb is big-endian. All ABIs use
> +  64-bit time (y2038 safe) and 64-bit file offsets (LFS default).
> +
>  * The GNU C Library now loads audit modules listed in the DT_AUDIT and
>DT_DEPAUDIT dynamic section entries of the main executable.
>  

Ok.

> diff --git a/README b/README
> index 31c5da0405bd..903f07e4840a 100644
> --- a/README
> +++ b/README
> @@ -24,6 +24,7 @@ The GNU C Library supports these configurations for using 
> Linux kernels:
>  
>   aarch64*-*-linux-gnu
>   alpha*-*-linux-gnu
> + arc*-*-linux-gnu
>   arm-*-linux-gnueabi
>   csky-*-linux-gnuabiv2
>   hppa-*-linux-gnu

Ok.

> diff --git a/manual/install.texi b/manual/install.texi
> index c1e49a94fed3..74cb90a91331 100644
> --- a/manual/install.texi
> +++ b/manual/install.texi
> @@ -522,6 +522,8 @@ Library with support for IEEE long double.
>  @c powerpc64le performs an autoconf test to verify the compiler compiles with
>  @c commands like "$CC -c foo.c -mabi=ibmlongdouble -mlong-double-128".
>  
> +For ARC architecture builds, GCC 8.3 or higher is needed.
> +
>  For multi-arch support it is recommended to use a GCC which has been built 
> with
>  support for GNU indirect functions.  This ensures that correct debugging
>  information is generated for functions selected by IFUNC resolvers.  This
> @@ -547,6 +549,8 @@ For PowerPC 64-bits little-endian (powerpc64le), 
> @command{objcopy} is required
>  to support @option{--update-section}.  This option requires binutils 2.26 or
>  newer.
>  
> +ARC architecture needs @code{binutils} 2.32 or higher for TLS related fixes.
> +
>  @item
>  GNU @code{texinfo} 4.7 or later
>  
> 

Ok.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7.1 07/13] ARC: Linux Syscall Interface

2020-07-06 Thread Adhemerval Zanella



On 04/07/2020 00:54, Vineet Gupta wrote:
> On 7/2/20 7:47 PM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 30/06/2020 21:08, Vineet Gupta via Libc-alpha wrote:
>>> ---
>>>Changes since v7:
>>>  - used long int (iso int) in sysdep.h/syscall_error for handling 
>>> registers
>>
>> Patch looks ok, but I have question on the __NR_* undef/define. 
>>
> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
>>> b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
> ...
>>> +#define __NR_write 64
>>> +#define __NR_writev 66
>>
>> Looks good. As side note I think an improvement would be to add
>> an annotation on update-syscall-lists.py to specify which kernel
>> version it used.
> 
> Very good idea indeed. I've asked myself the very question atleast once.
> 
> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
>>> b/sysdeps/unix/sysv/linux/arc/clone.S
> ..
>>> +
>>> +   ; adjust libc args for syscall
>>
>> Use the C comment style for constency with rest of the file.
> 
> Done.
> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h 
>>> b/sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h
> 
>>> +
>>> +/* Adjustments to ARC asm-generic syscall ABI (3.9 kernel) for 64-bit 
>>> time_t
>>> +   support.  */
>>> +
>>> +/* fstat64 and fstatat64 need to be replaced with statx.  */
>>> +
>>> +#undef __NR_fstat64
>>> +#undef __NR_fstatat64
> 
> This is certainly needed as they are present in ARC arch-syscall.h but we 
> need to
> use statx.
> 
>>> +/* Replace all other 32-bit time syscalls with 64-bit variants.  */
>>> +
>>> +# undef __NR_clock_adjtime
>>> +# undef __NR_clock_getres
>>> +# undef __NR_futex
>>> +# undef __NR_mq_timedreceive
>>> +# undef __NR_mq_timedsend
>>> +# undef __NR_ppoll
>>> +# undef __NR_pselect6
>>> +# undef __NR_recvmmsg
>>> +# undef __NR_rt_sigtimedwait
>>> +# undef __NR_sched_rr_get_interval
>>> +# undef __NR_semtimedop
>>> +# undef __NR_timerfd_settime
>>> +# undef __NR_timerfd_gettime
>>> +# undef __NR_utimensat
>>
>> I am trying to understand why these are required since arc does not define 
>> them in arch-syscall.h.
> 
> arch-syscall.h doesn't define them precisely due to these being here. When
> update-syscalls is run, the 32-bit syscalls are generated for ARC (since 
> kernel
> ABI provides these because that was v3.9 circa 2013). Adding them
> fixup-asm-unistd.h removes them (perhaps I need to add this in changelog to
> clarify - atleast for myself).
> 
>> And the generic implementation should handle the time64 variant.  If they
>> are not this is something we need to handle it.
> 
> At the time we we doing this, arch-syscall.h generation was not yet in place,
> however I tried to undef in generic/sysdep.h for TIMESIZE==64. However I was 
> asked
> me to add this to ARC specific fixup-asm-unistd.h
> https://sourceware.org/pipermail/libc-alpha/2020-March/112395.html
> https://sourceware.org/pipermail/libc-alpha/2020-April/112909.html

My confusion here, I forgot that this header is only used glibcsyscalls.py
to actually generate arch-syscall.h.

You changes does look correct.

> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h 
>>> b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
> ...
>>> +#define STATFS_IS_STATFS64 0
>>
>> Ok.
> 
> This specific one is actually dead code. I did post a patch to this effect and
> followed up with supporting data that enabling it on 64-bit arches doesn't 
> lead to
> any changes in generated code.
> 
> https://sourceware.org/pipermail/libc-alpha/2020-February/111259.html
> https://sourceware.org/pipermail/libc-alpha/2020-June/115217.html
> 

Ack.

> 
>>> diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h 
>>> b/sysdeps/unix/sysv/linux/arc/sysdep.h
> 
> ...
> 
>>> +/* 32-bit time syscalls are not available, but the redefines allow generic
>>> +   wrappers to work.  */
>>> +#define __NR_clock_adjtime __NR_clock_adjtime64
>>> +#define __NR_clock_getres  __NR_clock_getres_time64
>>> +#define __NR_futex __NR_futex_time64
>>> +#define __NR_mq_timedreceive   __NR_mq_timedreceive_time64
>>> +#define __NR_mq_timedsend  __NR_mq_timedsend_time64
>>> +#define __NR_ppoll __NR_ppoll_time64
>>> +#define __NR_pselect6  __NR_pselect6_time64
>>> +#define __NR_recvm

Re: [PATCH v7.1 07/13] ARC: Linux Syscall Interface

2020-07-07 Thread Adhemerval Zanella



On 06/07/2020 22:25, Vineet Gupta wrote:
> On 7/6/20 6:20 AM, Adhemerval Zanella via Libc-alpha wrote:
>>>>> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
>>>>> b/sysdeps/unix/sysv/linux/arc/clone.S
>>>
>>>>> diff --git a/sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h 
>>>>> b/sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h
>>>
>>>>> +
>>>>> +/* Adjustments to ARC asm-generic syscall ABI (3.9 kernel) for 64-bit 
>>>>> time_t
>>>>> +   support.  */
>>>>> +
>>>>> +/* fstat64 and fstatat64 need to be replaced with statx.  */
>>>>> +
>>>>> +#undef __NR_fstat64
>>>>> +#undef __NR_fstatat64
>>>
>>> This is certainly needed as they are present in ARC arch-syscall.h but we 
>>> need to
>>> use statx.
>>>
>>>>> +/* Replace all other 32-bit time syscalls with 64-bit variants.  */
>>>>> +
>>>>> +# undef __NR_clock_adjtime
>>>>> +# undef __NR_clock_getres
>>>>> +# undef __NR_futex
>>>>> +# undef __NR_mq_timedreceive
>>>>> +# undef __NR_mq_timedsend
>>>>> +# undef __NR_ppoll
>>>>> +# undef __NR_pselect6
>>>>> +# undef __NR_recvmmsg
>>>>> +# undef __NR_rt_sigtimedwait
>>>>> +# undef __NR_sched_rr_get_interval
>>>>> +# undef __NR_semtimedop
>>>>> +# undef __NR_timerfd_settime
>>>>> +# undef __NR_timerfd_gettime
>>>>> +# undef __NR_utimensat
>>>>
>>>> I am trying to understand why these are required since arc does not define 
>>>> them in arch-syscall.h.
>>>
>>> arch-syscall.h doesn't define them precisely due to these being here. When
>>> update-syscalls is run, the 32-bit syscalls are generated for ARC (since 
>>> kernel
>>> ABI provides these because that was v3.9 circa 2013). Adding them
>>> fixup-asm-unistd.h removes them (perhaps I need to add this in changelog to
>>> clarify - atleast for myself).
>>>
>>>> And the generic implementation should handle the time64 variant.  If they
>>>> are not this is something we need to handle it.
>>>
>>> At the time we we doing this, arch-syscall.h generation was not yet in 
>>> place,
>>> however I tried to undef in generic/sysdep.h for TIMESIZE==64. However I 
>>> was asked
>>> me to add this to ARC specific fixup-asm-unistd.h
>>> https://sourceware.org/pipermail/libc-alpha/2020-March/112395.html
>>> https://sourceware.org/pipermail/libc-alpha/2020-April/112909.html
>>
>> My confusion here, I forgot that this header is only used glibcsyscalls.py
>> to actually generate arch-syscall.h.
>>
>> You changes does look correct.
> 
> Actually we can add a few more entries here which have 64-bit variants.
> 
> +# undef __NR_clock_gettime
> +# undef __NR_clock_nanosleep
> +# undef __NR_clock_settime
> +# undef __NR_timer_gettime
> +# undef __NR_timer_settime

It should not intefere since ARC also defines __ASSUME_TIME64_SYSCALLS
and the 32-bit fallback syscalls won't be used in this case.

As a side note, now that arch-syscall.h is based on latest kernel version
and all the 32-bit ABIs with old 32-bit time_t have upstream support for 
64-bit time_t we can simplify a bit some implementation by assuming 
the 64-bit time_t is always defined and adding a fallback only for
!define __ASSUME_TIME64_SYSCALLS.


> 
> 
>>>>> diff --git a/sysdeps/unix/sysv/linux/arc/kernel_stat.h 
>>>>> b/sysdeps/unix/sysv/linux/arc/kernel_stat.h
> 
>>> This specific one is actually dead code. I did post a patch to this effect 
>>> and
>>> followed up with supporting data that enabling it on 64-bit arches doesn't 
>>> lead to
>>> any changes in generated code.
>>>
>>> https://sourceware.org/pipermail/libc-alpha/2020-February/111259.html
>>> https://sourceware.org/pipermail/libc-alpha/2020-June/115217.html
>>>
>>
>> Ack.
> 
> Thx. I'll repost this after things settle at bit.
> 
>>>>> diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h 
>>>>> b/sysdeps/unix/sysv/linux/arc/sysdep.h
>>>
>>> ...
>>>
>>>>> +/* 32-bit time syscalls are not available, but the redefines allow 
>>>>> generic
>>>>> +   wrappers to work.  */
>>>>> +#define __NR_clock_adjtime   __NR_clock_adjtime64
>>>>> 

Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface

2020-07-09 Thread Adhemerval Zanella



On 08/07/2020 16:32, Vineet Gupta wrote:
> On 7/8/20 9:31 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>> On 07/07/2020 17:55, Vineet Gupta via Libc-alpha wrote:
>>> ---
>>>Changes since v7.1:
>>>  - Added a few more 32-bit time_t syscalls to fixup-asm-unistd.h
>>>and regen arch-syscall.h to remove them: __NR_timer{g,s}ettime,
>>>__NR_clock_{gettime,nanosleep,settime}
>>>  - minimal/annotated list of 32-bit syscall aliases in ARC sysdeps.h
>>>for 64-bit time_t support
>>>  - Open-coded SYS_ify() but retained the macro as used by common
>>>code
>>>  - No functional changes in generated dsos.
>>>Changes since v7:
>>>  - used long int (iso int) in sysdep.h/syscall_error for handling 
>>> registers
>> LGTM, thanks.
>>
>> Reviewed-by: Adhemerval Zanella  
> 
> Thx a lot. I now have Reviewed-by tags on all ARC patches so we just need the
> sysvipc/semctl y2038 patches to hit upstream before I can commit.

The patches are in, if you could just to a sanity check I will
be grateful. 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v7.2 07/13] ARC: Linux Syscall Interface

2020-07-09 Thread Adhemerval Zanella



On 09/07/2020 13:24, Vineet Gupta wrote:
> On 7/9/20 9:03 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 08/07/2020 16:32, Vineet Gupta wrote:
>>> On 7/8/20 9:31 AM, Adhemerval Zanella via Libc-alpha wrote:
>>>>
>>>> On 07/07/2020 17:55, Vineet Gupta via Libc-alpha wrote:
>>>>> ---
>>>>>Changes since v7.1:
>>>>>  - Added a few more 32-bit time_t syscalls to fixup-asm-unistd.h
>>>>>and regen arch-syscall.h to remove them: __NR_timer{g,s}ettime,
>>>>>__NR_clock_{gettime,nanosleep,settime}
>>>>>  - minimal/annotated list of 32-bit syscall aliases in ARC sysdeps.h
>>>>>for 64-bit time_t support
>>>>>  - Open-coded SYS_ify() but retained the macro as used by common
>>>>>code
>>>>>  - No functional changes in generated dsos.
>>>>>Changes since v7:
>>>>>  - used long int (iso int) in sysdep.h/syscall_error for handling 
>>>>> registers
>>>> LGTM, thanks.
>>>>
>>>> Reviewed-by: Adhemerval Zanella  
>>>
>>> Thx a lot. I now have Reviewed-by tags on all ARC patches so we just need 
>>> the
>>> sysvipc/semctl y2038 patches to hit upstream before I can commit.
>>
>> The patches are in, if you could just to a sanity check I will
>> be grateful. 
> 
> Thx.
> 
> Rebased ARC port on master and fired a build-many-glibcs  now (expect 
> some
> abilist updates). Will do a full testsuite run and if thats same as before, 
> I'm
> good to push ARC port ?
> 

I think it should suffice, just to avoid some issue with recent
traffic on repository recently.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] Remove STATFS_IS_STATFS64 conditional as it is zero in all ports

2020-09-09 Thread Adhemerval Zanella



On 08/09/2020 23:48, Vineet Gupta via Libc-alpha wrote:
> From: Vineet Gupta 
> 
> This seems to be dead code, so remove it.

It could be useful for a possible statfs/statfs64 consolidation, but indeed
it is dead code now.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  


> ---
>  sysdeps/unix/sysv/linux/alpha/kernel_stat.h   |  1 -
>  sysdeps/unix/sysv/linux/fstatfs64.c   | 14 --
>  sysdeps/unix/sysv/linux/generic/kernel_stat.h |  2 --
>  .../unix/sysv/linux/generic/wordsize-32/fstatfs.c |  2 --
>  .../unix/sysv/linux/generic/wordsize-32/statfs.c  |  2 --
>  sysdeps/unix/sysv/linux/hppa/kernel_stat.h|  1 -
>  sysdeps/unix/sysv/linux/ia64/kernel_stat.h|  1 -
>  sysdeps/unix/sysv/linux/kernel_stat.h |  1 -
>  sysdeps/unix/sysv/linux/microblaze/kernel_stat.h  |  1 -
>  sysdeps/unix/sysv/linux/mips/kernel_stat.h|  1 -
>  .../sysv/linux/powerpc/powerpc32/kernel_stat.h|  1 -
>  .../sysv/linux/powerpc/powerpc64/kernel_stat.h|  1 -
>  .../unix/sysv/linux/s390/s390-64/kernel_stat.h|  1 -
>  .../unix/sysv/linux/sparc/sparc32/kernel_stat.h   |  1 -
>  .../unix/sysv/linux/sparc/sparc64/kernel_stat.h   |  1 -
>  sysdeps/unix/sysv/linux/statfs64.c| 15 ---
>  sysdeps/unix/sysv/linux/x86_64/kernel_stat.h  |  1 -
>  17 files changed, 47 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h 
> b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
> index d637e099cfe4..670841140765 100644
> --- a/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/alpha/kernel_stat.h
> @@ -86,4 +86,3 @@ struct glibc21_stat
>};
>  
>  #define XSTAT_IS_XSTAT64 1
> -#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/fstatfs64.c 
> b/sysdeps/unix/sysv/linux/fstatfs64.c
> index 9d22fa228fa5..4a339b548aa7 100644
> --- a/sysdeps/unix/sysv/linux/fstatfs64.c
> +++ b/sysdeps/unix/sysv/linux/fstatfs64.c
> @@ -22,15 +22,6 @@
>  #include 
>  #include 
>  
> -/* Hide the prototypes for __fstatfs and fstatfs so that GCC will not
> -   complain about the different function signatures if they are aliased
> -   to  __fstat64.  If STATFS_IS_STATFS64 is not zero then the statfs and
> -   statfs64 structures have an identical layout but different type names.  */
> -
> -#if STATFS_IS_STATFS64
> -# define __fstatfs __fstatfs_disable
> -# define fstatfs fstatfs_disable
> -#endif
>  #include 
>  
>  #include 
> @@ -85,8 +76,3 @@ weak_alias (__fstatfs64, fstatfs64)
>  
>  #undef __fstatfs
>  #undef fstatfs
> -
> -#if STATFS_IS_STATFS64
> -weak_alias (__fstatfs64, __fstatfs)
> -weak_alias (__fstatfs64, fstatfs)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/kernel_stat.h 
> b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
> index 2eed3596c0ed..5a600f188320 100644
> --- a/sysdeps/unix/sysv/linux/generic/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/generic/kernel_stat.h
> @@ -26,5 +26,3 @@
>  #else
>  # define XSTAT_IS_XSTAT64 0
>  #endif
> -
> -#define STATFS_IS_STATFS64 0
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c 
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
> index 93d9d94a0a61..bacc1543013a 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
> +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c
> @@ -21,7 +21,6 @@
>  #include 
>  #include 
>  
> -#if !STATFS_IS_STATFS64
>  #include "overflow.h"
>  
>  /* Return information about the filesystem on which FD resides.  */
> @@ -32,4 +31,3 @@ __fstatfs (int fd, struct statfs *buf)
>return rc ?: statfs_overflow (buf);
>  }
>  weak_alias (__fstatfs, fstatfs)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c 
> b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
> index 7421501b4a40..a678e96058ce 100644
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
> +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c
> @@ -21,7 +21,6 @@
>  #include 
>  #include 
>  
> -#if !STATFS_IS_STATFS64
>  #include "overflow.h"
>  
>  /* Return information about the filesystem on which FILE resides.  */
> @@ -33,4 +32,3 @@ __statfs (const char *file, struct statfs *buf)
>  }
>  libc_hidden_def (__statfs)
>  weak_alias (__statfs, statfs)
> -#endif
> diff --git a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h 
> b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
> index a3ac53a1ef2f..9ffa3ba638ea 100644
> --- a/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
> +++ b/sysdeps/unix/sysv/linux/hppa/kernel_stat.h
> @@ -31,4 +31,3 @@ struct kernel_stat {
>  #define _HAVE_STAT64_NSEC
>  
> 

Re: [PATCH v2] ARC: update definitions in elf/elf.h

2022-11-21 Thread Adhemerval Zanella Netto



On 21/11/22 10:06, Shahab Vahedi via Libc-alpha wrote:
> While porting ARCv2 to elfutils [1], it was brought up that the
> necessary changes to the project's libelf/elf.h must come from
> glibc, because they sync it from glibc [2].  Therefore, this patch
> is to update ARC entries in elf/elf.h.
> 
> The majority of the update is about adding new definitions,
> specially for the relocations.  However, there is one rename, one
> deletion, and one change:
> 
> - R_ARC_JUMP_SLOT renamed to R_ARC_JMP_SLOT to match binutils.
> - R_ARC_B26 removed because it is unused and deprecated.
> - R_ARC_TLS_DTPOFF_S9 changed from 0x4a to the correct value 0x49.
> 
> [1]
> https://sourceware.org/pipermail/elfutils-devel/2022q4/005530.html
> 
> [2]
> https://sourceware.org/pipermail/elfutils-devel/2022q4/005548.html
> 
> Signed-off-by: Shahab Vahedi 

We discussed this briefly on glibc patchwork review meeting [1],
and if does not trigger any regression it ok to arch maintainers
to handle such changes.

[1] https://sourceware.org/glibc/wiki/PatchworkReviewMeetings

> ---
> Chagelog:
> v2:
>   - Rename instances of R_ARC_JUMP_SLOT to R_ARC_JMP_SLOT.
>   - Remove an unnecessary extra empty line introduced in elf/elf.h.
> 
>  elf/elf.h| 29 -
>  sysdeps/arc/dl-machine.h |  8 
>  2 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/elf/elf.h b/elf/elf.h
> index 920e6891e6..da41bad34b 100644
> --- a/elf/elf.h
> +++ b/elf/elf.h
> @@ -4159,6 +4159,15 @@ enum
>  #define R_LARCH_GNU_VTINHERIT  57
>  #define R_LARCH_GNU_VTENTRY  58
>  
> +/* ARC specific declarations.  */
> +
> +/* Processor specific flags for the Ehdr e_flags field.  */
> +#define EF_ARC_MACH_MSK  0x00ff
> +#define EF_ARC_OSABI_MSK0x0f00
> +#define EF_ARC_ALL_MSK   (EF_ARC_MACH_MSK | EF_ARC_OSABI_MSK)
> +
> +/* Processor specific values for the Shdr sh_type field.  */
> +#define SHT_ARC_ATTRIBUTES   (SHT_LOPROC + 1) /* ARC attributes section.  */
>  
>  /* ARCompact/ARCv2 specific relocs.  */
>  #define R_ARC_NONE   0x0
> @@ -4166,7 +4175,7 @@ enum
>  #define R_ARC_16 0x2
>  #define R_ARC_24 0x3
>  #define R_ARC_32 0x4
> -#define R_ARC_B260x5
> +
>  #define R_ARC_B22_PCREL  0x6
>  #define R_ARC_H300x7
>  #define R_ARC_N8 0x8
> @@ -4206,16 +4215,23 @@ enum
>  #define R_ARC_SECTOFF_ME_2   0x2A
>  #define R_ARC_SECTOFF_1  0x2B
>  #define R_ARC_SECTOFF_2  0x2C
> +#define R_ARC_SDA_12 0x2D
> +#define R_ARC_SDA16_ST2  0x30
> +#define R_ARC_32_PCREL   0x31
>  #define R_ARC_PC32   0x32
>  #define R_ARC_GOTPC320x33
>  #define R_ARC_PLT32  0x34
>  #define R_ARC_COPY   0x35
>  #define R_ARC_GLOB_DAT   0x36
> -#define R_ARC_JUMP_SLOT  0x37
> +#define R_ARC_JMP_SLOT   0x37
>  #define R_ARC_RELATIVE   0x38
>  #define R_ARC_GOTOFF 0x39
>  #define R_ARC_GOTPC  0x3A
>  #define R_ARC_GOT32  0x3B
> +#define R_ARC_S21W_PCREL_PLT 0x3C
> +#define R_ARC_S25H_PCREL_PLT 0x3D
> +
> +#define R_ARC_JLI_SECTOFF0x3F
>  
>  #define R_ARC_TLS_DTPMOD 0x42
>  #define R_ARC_TLS_DTPOFF 0x43
> @@ -4224,9 +4240,12 @@ enum
>  #define R_ARC_TLS_GD_LD  0x46
>  #define R_ARC_TLS_GD_CALL0x47
>  #define R_ARC_TLS_IE_GOT 0x48
> -#define R_ARC_TLS_DTPOFF_S9  0x4a
> -#define R_ARC_TLS_LE_S9  0x4a
> -#define R_ARC_TLS_LE_32  0x4b
> +#define R_ARC_TLS_DTPOFF_S9  0x49
> +#define R_ARC_TLS_LE_S9  0x4A
> +#define R_ARC_TLS_LE_32  0x4B
> +#define R_ARC_S25W_PCREL_PLT 0x4C
> +#define R_ARC_S21H_PCREL_PLT 0x4D
> +#define R_ARC_NPS_CMEM16 0x4E
>  
>  /* OpenRISC 1000 specific relocs.  */
>  #define R_OR1K_NONE  0
> diff --git a/sysdeps/arc/dl-machine.h b/sysdeps/arc/dl-machine.h
> index c6ad232384..8420cd0006 100644
> --- a/sysdeps/arc/dl-machine.h
> +++ b/sysdeps/arc/dl-machine.h
> @@ -183,14 +183,14 @@ __start:
> \n\
> ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
> of the main executable's symbols, as for a COPY reloc.  */
>  #define elf_machine_type_class(type) \
> -  type) == R_ARC_JUMP_SLOT   \
> +  type) == R_ARC_JMP_SLOT\
>   || (type) == R_ARC_TLS_DTPMOD   \
>   || (type) == R_ARC_TLS_DTPOFF   \
>   || (type) == R_ARC_TLS_TPOFF) * ELF_RTYPE_CLASS_PLT)\
> | (((type) == R_ARC_COPY) * ELF_RTYPE_CLASS_COPY))
>  
>  /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
> -#define ELF_MACHINE_JMP_SLOT  R_ARC_JUMP_SLOT
> +#define ELF_MACHINE_JMP_SLOT  R_ARC_JMP_SLOT
>  
>  /* Fixup a PLT

Re: [PATCH] ARC: align child stack in clone

2023-01-16 Thread Adhemerval Zanella Netto



On 21/12/22 13:19, Pavel.Kozlov--- via Libc-alpha wrote:
> From: Pavel Kozlov 
> 
> The ARCv2 ABI requires 4 byte stack pointer alignment. Don't allow to
> use unaligned child stack in clone. As the stack grows down,
> align it down.
> 
> This was pointed by misc/tst-misalign-clone-internal and
> misc/tst-misalign-clone tests. Stack alignmet fixes these tests
> fails.

LGTM, although I can't really test it since the Synopsys qemu tree does not
have qemu-user support [1].

Reviewed-by: Adhemerval Zanella  

[1] https://github.com/foss-for-synopsys-dwc-arc-processors/qemu

> ---
>  sysdeps/unix/sysv/linux/arc/clone.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
> b/sysdeps/unix/sysv/linux/arc/clone.S
> index bd924890844a..f32c83f17a65 100644
> --- a/sysdeps/unix/sysv/linux/arc/clone.S
> +++ b/sysdeps/unix/sysv/linux/arc/clone.S
> @@ -41,6 +41,7 @@
>  
>  ENTRY (__clone)
>   cmp r0, 0   /* @fn can't be NULL.  */
> + and r1,r1,-4/* @child_stack be 4 bytes aligned per ABI.  */
>   cmp.ne  r1, 0   /* @child_stack can't be NULL.  */
>   bz  L (__sys_err)
>  

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] ARC:fpu: add extra capability check before use of sqrt and fma builtins

2023-01-16 Thread Adhemerval Zanella Netto



On 21/12/22 13:28, Pavel.Kozlov--- via Libc-alpha wrote:
> From: Pavel Kozlov 
> 
> Add extra check for compiler definitions to ensure that compiler provides
> sqrt and fma hw fpu instructions else use software implementation.
> 
> As divide/sqrt and FMA hw support from CPU side is optional,
> the compiler can be configured by options to generate hw FPU instructions,
> but without use of FDDIV, FDSQRT, FSDIV, FSSQRT, FDMADD and FSMADD
> instructions. In this case __builtin_sqrt and __builtin_sqrtf provided by
> compiler can't be used inside the glibc code, as these builtins are used
> in implementations of sqrt() and sqrtf() functions but at the same time
> these builtins unfold to sqrt() and sqrtf(). So it is possible to receive
> code like that:
> 
> 0001c4b4 <__ieee754_sqrtf>:
>1c4b4:0001   b 0 ;1c4b4 <__ieee754_sqrtf>
> 
> The same is also true for __builtin_fma and __builtin_fmaf.
> ---
>  sysdeps/arc/fpu/math-use-builtins-fma.h  | 14 --
>  sysdeps/arc/fpu/math-use-builtins-sqrt.h | 14 --
>  2 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/arc/fpu/math-use-builtins-fma.h 
> b/sysdeps/arc/fpu/math-use-builtins-fma.h
> index eede75aa41be..082badf48201 100644
> --- a/sysdeps/arc/fpu/math-use-builtins-fma.h
> +++ b/sysdeps/arc/fpu/math-use-builtins-fma.h
> @@ -1,4 +1,14 @@
> -#define USE_FMA_BUILTIN 1
> -#define USE_FMAF_BUILTIN 1
> +#if defined __ARC_FPU_DP_DIV__
> +# define USE_SQRT_BUILTIN 1
> +#else
> +# define USE_SQRT_BUILTIN 0
> +#endif
> +
> +#if defined __ARC_FPU_SP_DIV__
> +# define USE_SQRTF_BUILTIN 1
> +#else
> +# define USE_SQRTF_BUILTIN 0
> +#endif
> +
>  #define USE_FMAL_BUILTIN 0
>  #define USE_FMAF128_BUILTIN 0

This is wrong, sqrt use macro do not belong for the fma switch file.

> diff --git a/sysdeps/arc/fpu/math-use-builtins-sqrt.h 
> b/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> index e94c915ba66a..a449bc609295 100644
> --- a/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> +++ b/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> @@ -1,4 +1,14 @@
> -#define USE_SQRT_BUILTIN 1
> -#define USE_SQRTF_BUILTIN 1
> +#if defined __ARC_FPU_DP_DIV__
> +# define USE_SQRT_BUILTIN 1
> +#else
> +# define USE_SQRT_BUILTIN 0
> +#endif
> +
> +#if defined __ARC_FPU_SP_DIV__
> +# define USE_SQRTF_BUILTIN 1
> +#else
> +# define USE_SQRTF_BUILTIN 0
> +#endif
> +
>  #define USE_SQRTL_BUILTIN 0
>  #define USE_SQRTF128_BUILTIN 0

This is ok.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2] ARC:fpu: add extra capability check before use of sqrt and fma builtins

2023-01-17 Thread Adhemerval Zanella Netto



On 17/01/23 09:12, Pavel.Kozlov--- via Libc-alpha wrote:
> From: Pavel Kozlov 
> 
> Add extra check for compiler definitions to ensure that compiler provides
> sqrt and fma hw fpu instructions else use software implementation.
> 
> As divide/sqrt and FMA hw support from CPU side is optional,
> the compiler can be configured by options to generate hw FPU instructions,
> but without use of FDDIV, FDSQRT, FSDIV, FSSQRT, FDMADD and FSMADD
> instructions. In this case __builtin_sqrt and __builtin_sqrtf provided by
> compiler can't be used inside the glibc code, as these builtins are used
> in implementations of sqrt() and sqrtf() functions but at the same time
> these builtins unfold to sqrt() and sqrtf(). So it is possible to receive
> code like that:
> 
> 0001c4b4 <__ieee754_sqrtf>:
>1c4b4:0001   b 0 ;1c4b4 <__ieee754_sqrtf>
> 
> The same is also true for __builtin_fma and __builtin_fmaf.

LGTM, thanks.  You might need to check with Carlos O'Donnel to see it you
could install this for 2.36.

Reviewed-by: Adhemerval Zanella  

> 
> ---
> Changes in v2:
>  - Fixed macros definitions for FMA
> 
>  sysdeps/arc/fpu/math-use-builtins-fma.h  | 14 --
>  sysdeps/arc/fpu/math-use-builtins-sqrt.h | 14 --
>  2 files changed, 24 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/arc/fpu/math-use-builtins-fma.h 
> b/sysdeps/arc/fpu/math-use-builtins-fma.h
> index eede75aa41be..2acd8113ce2c 100644
> --- a/sysdeps/arc/fpu/math-use-builtins-fma.h
> +++ b/sysdeps/arc/fpu/math-use-builtins-fma.h
> @@ -1,4 +1,14 @@
> -#define USE_FMA_BUILTIN 1
> -#define USE_FMAF_BUILTIN 1
> +#if defined __ARC_FPU_DP_FMA__
> +# define USE_FMA_BUILTIN 1
> +#else
> +# define USE_FMA_BUILTIN 0
> +#endif
> +
> +#if defined __ARC_FPU_SP_FMA__
> +# define USE_FMAF_BUILTIN 1
> +#else
> +# define USE_FMAF_BUILTIN 0
> +#endif
> +
>  #define USE_FMAL_BUILTIN 0
>  #define USE_FMAF128_BUILTIN 0
> diff --git a/sysdeps/arc/fpu/math-use-builtins-sqrt.h 
> b/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> index e94c915ba66a..a449bc609295 100644
> --- a/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> +++ b/sysdeps/arc/fpu/math-use-builtins-sqrt.h
> @@ -1,4 +1,14 @@
> -#define USE_SQRT_BUILTIN 1
> -#define USE_SQRTF_BUILTIN 1
> +#if defined __ARC_FPU_DP_DIV__
> +# define USE_SQRT_BUILTIN 1
> +#else
> +# define USE_SQRT_BUILTIN 0
> +#endif
> +
> +#if defined __ARC_FPU_SP_DIV__
> +# define USE_SQRTF_BUILTIN 1
> +#else
> +# define USE_SQRTF_BUILTIN 0
> +#endif
> +
>  #define USE_SQRTL_BUILTIN 0
>  #define USE_SQRTF128_BUILTIN 0

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: Pavel new maintainer of ARC port

2023-02-21 Thread Adhemerval Zanella Netto



On 21/02/23 10:55, Pavel Kozlov via Libc-alpha wrote:
> Hi all,
> 
> I'm excited to introduce myself and become a part of the community. 
> 
> I'm a software engineer in Synopsys and member of a team working to enhance 
> support for ARC CPUs in the GNU Linux ecosystem.
> 
> I would appreciate any guidance or advice on how I can get involved and 
> contribute to the community. I'm always looking for opportunities to connect 
> with other developers and learn from their experiences.
> 
> As a final step of setup, I've updated wiki and added myself as ARC 
> maintainer. Also, thanks Carlos, for help with my setup.
> 
> Best regards,
> Pavel Kozlov

Hi Pavel,

Carlos might already brought to your attention, but we have a weekly
call [1] where we discuss the current patchwork status [2], any blocker
someone might have, future work, or to discuss bug report or any other
issue.  So fell free to hop in if you have anything to discuss.

[1] https://sourceware.org/glibc/wiki/PatchworkReviewMeetings
[2] https://patchwork.sourceware.org/project/glibc/list/

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: Pavel new maintainer of ARC port

2023-02-22 Thread Adhemerval Zanella Netto



On 21/02/23 15:59, Adhemerval Zanella Netto wrote:
> 
> 
> On 21/02/23 10:55, Pavel Kozlov via Libc-alpha wrote:
>> Hi all,
>>
>> I'm excited to introduce myself and become a part of the community. 
>>
>> I'm a software engineer in Synopsys and member of a team working to enhance 
>> support for ARC CPUs in the GNU Linux ecosystem.
>>
>> I would appreciate any guidance or advice on how I can get involved and 
>> contribute to the community. I'm always looking for opportunities to connect 
>> with other developers and learn from their experiences.
>>
>> As a final step of setup, I've updated wiki and added myself as ARC 
>> maintainer. Also, thanks Carlos, for help with my setup.
>>
>> Best regards,
>> Pavel Kozlov
> 
> Hi Pavel,
> 
> Carlos might already brought to your attention, but we have a weekly
> call [1] where we discuss the current patchwork status [2], any blocker
> someone might have, future work, or to discuss bug report or any other
> issue.  So fell free to hop in if you have anything to discuss.
> 
> [1] https://sourceware.org/glibc/wiki/PatchworkReviewMeetings
> [2] https://patchwork.sourceware.org/project/glibc/list/

Another thing you might want to check is to do some triage on the
ARC failures reported by on the 2.37 release page. Some might be
just due timeout issues (test taking to long), however some might
require some work (the test-float64-trunc for instance).

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/2] ARC: run child from the separate start block in __clone

2023-03-07 Thread Adhemerval Zanella Netto



On 02/03/23 13:10, Pavel Kozlov via Libc-alpha wrote:
> From: Pavel Kozlov 
> 
> For better debug experience use separate code block with extra
> cfi_* directives to run child (same as in __clone3).

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  

> ---
>  sysdeps/unix/sysv/linux/arc/clone.S | 40 ++---
>  1 file changed, 25 insertions(+), 15 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
> b/sysdeps/unix/sysv/linux/arc/clone.S
> index 766649625658..0029aaeb8170 100644
> --- a/sysdeps/unix/sysv/linux/arc/clone.S
> +++ b/sysdeps/unix/sysv/linux/arc/clone.S
> @@ -20,9 +20,6 @@
>  #include 
>  #define _ERRNO_H 1
>  #include 
> -#include 
> -
> -#define CLONE_SETTLS 0x0008
>  
>  /* int clone(int (*fn)(void *), void *child_stack,
> int flags, void *arg, ...
> @@ -63,19 +60,9 @@ ENTRY (__clone)
>   ARC_TRAP_INSN
>  
>   cmp r0, 0   /* return code : 0 new process, !0 parent.  */
> + beq thread_start_clone
>   blt L (__sys_err2)  /* < 0 (signed) error.  */
> - jnz [blink] /* Parent returns.  */
> -
> - /* child jumps off to @fn with @arg as argument
> -   TP register already set by kernel.  */
> - jl.d[r10]
> - mov r0, r11
> -
> - /* exit() with result from @fn (already in r0).  */
> - mov r8, __NR_exit
> - ARC_TRAP_INSN
> - /* In case it ever came back.  */
> - flag1
> + j   [blink] /* Parent returns.  */
>  
>  L (__sys_err):
>   mov r0, -EINVAL
> @@ -89,5 +76,28 @@ L (__sys_err2):
>  position independent.  */
>   b   __syscall_error
>  PSEUDO_END (__clone)
> +
> +
> + .align 4
> + .type thread_start_clone, %function
> +thread_start_clone:
> + cfi_startproc
> + /* Terminate call stack by noting ra is undefined.  */
> + cfi_undefined (blink)
> +
> + /* Child jumps off to @fn with @arg as argument.  */
> + jl.d[r10]
> + mov r0, r11
> +
> + /* exit() with result from @fn (already in r0).  */
> + mov r8, __NR_exit
> + ARC_TRAP_INSN
> +
> + /* In case it ever came back.  */
> + flag1
> +
> + cfi_endproc
> + .size thread_start_clone, .-thread_start_clone
> +
>  libc_hidden_def (__clone)
>  weak_alias (__clone, clone)

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/2] ARC: Add the clone3 wrapper

2023-03-07 Thread Adhemerval Zanella Netto



On 02/03/23 13:10, Pavel Kozlov via Libc-alpha wrote:
> From: Pavel Kozlov 
> 
> Use the clone3 wrapper on ARC. It doesn't care about stack alignment.
> All callers should provide an aligned stack.
> It follows the internal signature:
> 
> extern int clone3 (struct clone_args *__cl_args, size_t __size,
>  int (*__func) (void *__arg), void *__arg);

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  

> ---
> Checked on arc-linux-gnu. Previously observed tst-misaling-clone-internal
> test fail was because I used outdated master branch.
> Full testsuite runs without regressions.
> But I also see fail of the new tst-spawn7, as already repoted at [1].
> 
> [1]
> https://sourceware.org/pipermail/libc-alpha/2023-February/145937.html
> 
>  sysdeps/unix/sysv/linux/arc/clone3.S | 90 
>  sysdeps/unix/sysv/linux/arc/sysdep.h |  2 +
>  2 files changed, 92 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/arc/clone3.S
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/clone3.S 
> b/sysdeps/unix/sysv/linux/arc/clone3.S
> new file mode 100644
> index ..87a8272a3977
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arc/clone3.S
> @@ -0,0 +1,90 @@
> +/* The clone3 syscall wrapper.  Linux/arc version.
> +   Copyright (C) 2023 Free Software Foundation, Inc.
> +
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include 
> +#define _ERRNO_H 1
> +#include 
> +
> +/* The userland implementation is:
> +   int clone3 (struct clone_args *cl_args, size_t size,
> +   int (*func)(void *arg), void *arg);
> +
> +   the kernel entry is:
> +   int clone3 (struct clone_args *cl_args, size_t size);
> +
> +   The parameters are passed in registers from userland:
> +   r0: cl_args
> +   r1: size
> +   r2: func
> +   r3: arg  */
> +
> +ENTRY(__clone3)
> +
> + /* Save args for the child.  */
> + mov r10, r0 /* cl_args  */
> + mov r11, r2 /* func  */
> + mov r12, r3 /* args  */
> +
> + /* Sanity check args.  */
> + breqr10, 0, L (__sys_err)   /* No NULL cl_args pointer.  */
> + breqr11, 0, L (__sys_err)   /* No NULL function pointer.  */
> +
> + /* Do the system call, the kernel expects:
> +r8: system call number
> +r0: cl_args
> +r1: size  */
> + mov r0, r10
> + mov r8, __NR_clone3
> + ARC_TRAP_INSN
> +
> + cmp r0, 0
> + beq thread_start_clone3 /* Child returns.  */
> + blt L (__sys_err2)
> + j   [blink] /* Parent returns.  */
> +
> +L (__sys_err):
> + mov r0, -EINVAL
> +L (__sys_err2):
> + b   __syscall_error
> +PSEUDO_END (__clone3)
> +
> +
> + .align 4
> + .type thread_start_clone3, %function
> +thread_start_clone3:
> + cfi_startproc
> + /* Terminate call stack by noting ra is undefined.  */
> + cfi_undefined (blink)
> +
> + /* Child jumps off to @fn with @arg as argument.  */
> + jl.d[r11]
> + mov r0, r12
> +
> + /* exit() with result from @fn (already in r0).  */
> + mov r8, __NR_exit
> + ARC_TRAP_INSN
> +
> + /* In case it ever came back.  */
> + flag1
> +
> + cfi_endproc
> + .size thread_start_clone3, .-thread_start_clone3
> +
> +libc_hidden_def (__clone3)
> +weak_alias (__clone3, clone3)
> diff --git a/sysdeps/unix/sysv/linux/arc/sysdep.h 
> b/sysdeps/unix/sysv/linux/arc/sysdep.h
> index dd6fe73445f9..88dc1dff017f 100644
> --- a/sysdeps/unix/sysv/linux/arc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/arc/sysdep.h
> @@ -141,6 +141,8 @@ hidden_proto (__syscall_error)
>  
>  # define ARC_TRAP_INSN   "trap_s 0   \n\t"
>  
> +# define HAVE_CLONE3_WRAPPER 1
> +
>  # undef INTERNAL_SYSCALL_NCS
>  # define INTERNAL_SYSCALL_NCS(number, nr_args, args...)  \
>({ \

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc