Re: MIPS-specific porting issue

YunQiang Su <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <CAKcpw6XAwQuvkNOoZv_-1D_1RRJEcGO=-xFtDD-0a0hTh=Ta8g@mail.gmail.com>
FROM:jiaxun yang

Hi Stéphane.



MIPS do have a way to access count register from user space.

Unfortunately there is no GCC intrinsic function for it, you may try
following inline assembly.



static inline unsigned long get_count() {

    unsigned long count;

    asm volatile ("rdhwr %[rt], $2" : [rt] "=d" (count));

    return count;

}



return Val_long (get_count());



Thanks.



- Jiaxun

Mathieu Malaterre <[email protected]> 于 2021年12月3日周五 下午5:34写道:

> Salut Stéphane,
>
> On Fri, Dec 3, 2021 at 10:19 AM Stéphane Glondu <[email protected]> wrote:
> >
> > Dear MIPS porters,
> >
> > I am debugging ocaml-mirage-crypto build on mipsel.
> >
> > It uses the following code:
> >
> > > #if defined (__i386__) || defined (__x86_64__)
> > >   return Val_long (__rdtsc ());
> > > #elif defined (__arm__) || defined (__aarch64__)
> > >   return Val_long (read_virtual_count ());
> > > #elif defined(__powerpc64__)
> > >   return Val_long (read_cycle_counter ());
> > > #elif defined(__riscv) && (64 == __riscv_xlen)
> > >   return Val_long (rdcycle64 ());
> > > #elif defined (__s390x__)
> > >   return Val_long (getticks ());
> > > #else
> > > #error ("No known cycle-counting instruction.")
> > > #endif
> >
> > I have trouble finding a suitable implementation for this on mipsel.
> > Would you have a hint?
>
> All I could find is this code (untested):
>
>
> https://salsa.debian.org/science-team/nfft/-/blob/debian/master/include/cycle.h#L485-507
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.