Skip to content

Commit 23c89dd

Browse files
committed
android mt.c support wip
1 parent 5b3661c commit 23c89dd

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

jsrc/Android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif
3737
LOCAL_LDLIBS := -ldl -llog
3838

3939
LOCAL_SRC_FILES := a.c ab.c aes-c.c aes-arm.c aes-sse2.c af.c ai.c am.c am1.c amn.c ao.c ap.c ar.c as.c au.c c.c ca.c cc.c cd.c cf.c cg.c ch.c cip.c cl.c cp.c cpdtsp.c cpuinfo.c cr.c crs.c \
40-
ct.c cu.c cv.c cx.c d.c dc.c dss.c dstop.c dsusp.c dtoa.c f.c f2.c fbu.c gemm.c i.c io.c j.c jdlllic.c k.c m.c mbx.c p.c pv.c px.c r.c rl.c rt.c s.c sc.c sl.c \
40+
ct.c cu.c cv.c cx.c d.c dc.c dss.c dstop.c dsusp.c dtoa.c f.c f2.c fbu.c gemm.c i.c io.c j.c jdlllic.c k.c m.c mbx.c mt.c p.c pv.c px.c r.c rl.c rt.c s.c sc.c sl.c \
4141
sn.c t.c u.c v.c v0.c v1.c v2.c va1.c va1ss.c va2.c va2s.c va2ss.c vamultsp.c vb.c vbang.c vbit.c vcant.c vchar.c vcat.c vcatsp.c vcomp.c vcompsc.c vd.c vdx.c ve.c \
4242
vf.c vfft.c vfrom.c vfromsp.c vg.c vgauss.c vgcomp.c vgranking.c vgsort.c vgsp.c vi.c viavx.c viix.c visp.c vm.c vo.c vp.c vq.c vrand.c vrep.c vs.c vsb.c \
4343
vt.c vu.c vx.c vz.c w.c wc.c wn.c ws.c x.c x15.c xa.c xaes.c xb.c xc.c xcrc.c xd.c xf.c xfmt.c xh.c xi.c xl.c xo.c xs.c xsha.c xt.c xu.c crc32c.c str.c \

jsrc/mt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ I jtmdif(struct jtimespec w){
3030
R (w.tv_sec-t.tv_sec)*1000000000ull+w.tv_nsec-t.tv_nsec;}
3131

3232
#if PYXES
33-
#ifdef __APPLE__
33+
#if defined(__APPLE__)
3434
void jfutex_wake1(UI4 *p){__ulock_wake(UL_COMPARE_AND_WAIT|ULF_NO_ERRNO,p,0);}
3535
void jfutex_wakea(UI4 *p){__ulock_wake(UL_COMPARE_AND_WAIT|ULF_NO_ERRNO|ULF_WAKE_ALL,p,0);}
3636
C jfutex_wait(UI4 *p,UI4 v){
3737
I r=__ulock_wait(UL_COMPARE_AND_WAIT|ULF_NO_ERRNO,p,v,0);
3838
if(r>=0)R 0;
3939
if(r==-EINTR||r==-EFAULT)R 0; //EFAULT means the address needed to be paged in, not that it wasn't mapped?
4040
R EVFACE;} //should never happen?
41-
#if __arm64__
41+
#if defined(__arm64__)||defined(__aarch64__)
4242
// wait2 takes an ns timeout, but it's only available from macos 11 onward; coincidentally, arm macs only support macos 11+
4343
// so we can count on having this
4444
I jfutex_waitn(UI4 *p,UI4 v,UI ns){
@@ -65,8 +65,10 @@ I jfutex_waitn(UI4 *p,UI4 v,UI ns){I r;
6565
if(r==-ENOMEM)R EVWSFULL;
6666
R EVFACE;}
6767
#endif
68-
#elif defined(__linux__)
68+
#elif defined(__linux__)&&!defined(ANDROID)
6969
//glibc 'syscall': stupid errno
70+
// ??? asm applicable to arm64
71+
// #if defined(__x86_64__)||defined(__i386__)||defined(_M_X64)||defined(_M_IX86)
7072
void jfutex_wake1(UI4 *p){
7173
__asm__ volatile("syscall" :: "a" (SYS_futex), //eax: syscall#
7274
"D" (p), //rdi: ptr
@@ -102,6 +104,8 @@ I jfutex_waitn(UI4 *p,UI4 v,UI ns){
102104
if(r==-ETIMEDOUT)R -1;
103105
if(r==-EAGAIN||r==-EINTR)R 0;
104106
R EVFACE;}
107+
#elif defined(ANDROID)
108+
// TODO
105109
#elif defined(_WIN32)
106110
// defined in cd.c to avoid name collisions between j.h and windows.h
107111
#endif

jsrc/mt.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ I jtpthread_mutex_trylock(jtpthread_mutex_t*,I self); //0=success -1=failure pos
2525
C jtpthread_mutex_unlock(jtpthread_mutex_t*,I self); //0 or error code
2626
//note: self must be non-zero
2727

28-
#if defined(__linux__)
28+
#if defined(__linux__)&&!defined(ANDROID)
2929
#include <linux/futex.h>
3030
#include <sys/syscall.h>
31+
#elif defined(ANDORID)
32+
#error no futex support for your platform
3133
#elif defined(__APPLE__)
3234
// ulock (~futex) junk from xnu. timeout=0 means wait forever
3335
extern int __ulock_wait(uint32_t operation, void *addr, uint64_t value, uint32_t timeout); // timeout in us

0 commit comments

Comments
 (0)