Hi,

I was able to build linuxsampler on loongarch64 with some minor tweaks and would
like to share them and possibly merge into linuxsampler.
I also successfully ran `make check` with those changes.
All patches applied against 2.4.0

1. Add CreateTimeStamp() implementation for loongarch64

--- a/src/common/RTMath.cpp
+++ b/src/common/RTMath.cpp
@@ -85,6 +85,10 @@ RTMathBase::time_stamp_t RTMathBase::CreateTimeStamp() {
     uint32_t t;
     asm volatile ("mrc p15, 0, %0, c15, c12, 1" : "=r" (t));
     return t;
+    #elif defined(__loongarch__) && __loongarch_grlen == 64
+    uint64_t t;
+    asm volatile ("rdtime.d %0, $zero" : "=r" (t));
+    return t;
     #else // we don't want to use a slow generic solution
     #  error "Sorry, LinuxSampler lacks time stamp code for your system."
     #  error "Please report this error and the CPU you are using to the 
LinuxSampler developers mailing list!"


2. Add generic atomic_sub implementation

--- a/src/common/atomic.h
+++ b/src/common/atomic.h
@@ -1473,6 +1473,11 @@ static __inline__ void atomic_dec(atomic_t *v)
        v->counter--;
 }
 
+static __inline__ void atomic_sub(int i, atomic_t *v)
+{
+       v->counter -= i;
+}
+
 static __inline__ int atomic_dec_and_test(atomic_t *v)
 {
        int res;


For the second patch I don't know if generic implementation should have
atomic_sub but it does not compile without it. Also I guess that it is better to
have loongarch64 specific atomic but I'm not sure if I'll be able to work it out
on my own.

Waiting for feedback!

--
Ilya Sorochan


_______________________________________________
Linuxsampler-devel mailing list
Linuxsampler-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel

Reply via email to