Files
android_translation_layer/src/libandroid/looper.c

61 lines
1.9 KiB
C
Raw Normal View History

#include <stddef.h>
#include <stdio.h>
typedef void ALooper;
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
// dummy strong pointer class
struct sp {
ALooper *ptr;
/* the struct has to be larger then 16 bytes, because on aarch64 the
* calling convention for returning structs larger than 16 bytes is the
* same as the calling convention for returning large C++ objects */
char filler[16];
};
/* --- */
struct sp _ZN7android6Looper12getForThreadEv(void);
ALooper * ALooper_forThread(void)
{
return _ZN7android6Looper12getForThreadEv().ptr;
}
struct sp _ZN7android6Looper7prepareEi(int opts);
ALooper * ALooper_prepare(int opts)
{
return _ZN7android6Looper7prepareEi(opts).ptr;
}
2022-12-27 17:22:49 +01:00
void _ZNK7android7RefBase9incStrongEPKv(ALooper *this, void *unused);
void ALooper_acquire(ALooper* looper) {
_ZNK7android7RefBase9incStrongEPKv(looper, (void*)ALooper_acquire);
}
void _ZNK7android7RefBase9decStrongEPKv(ALooper *this, void *unused);
void ALooper_release(ALooper* looper) {
_ZNK7android7RefBase9decStrongEPKv(looper, (void*)ALooper_acquire);
}
int _ZN7android6Looper7pollAllEiPiS1_PPv(ALooper *this, int timeoutMillis, int* outFd, int* outEvents, void** outData);
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
{
ALooper *looper = ALooper_forThread();
if(!looper) {
fprintf(stderr, "ALooper_pollAll: ALooper_forThread returned NULL\n");
return 0;
}
return _ZN7android6Looper7pollAllEiPiS1_PPv(looper, timeoutMillis, outFd, outEvents, outData);
}
2022-12-27 17:22:49 +01:00
int _ZN7android6Looper5addFdEiiiPFiiiPvES1_(ALooper *this, int fd, int ident, int events, Looper_callbackFunc callback, void* data);
int ALooper_addFd(ALooper* looper, int fd, int ident, int events, Looper_callbackFunc callback, void* data)
{
return _ZN7android6Looper5addFdEiiiPFiiiPvES1_(looper, fd, ident, events, callback, data);
}
2022-12-27 17:22:49 +01:00
void _ZN7android6Looper4wakeEv(ALooper *this);
void ALooper_wake(ALooper* looper) {
_ZN7android6Looper4wakeEv(looper);
}