2022-10-26 18:39:04 +02:00
|
|
|
#include <stddef.h>
|
2022-11-04 18:07:18 +01:00
|
|
|
#include <stdio.h>
|
2022-10-26 18:39:04 +02:00
|
|
|
|
2022-11-04 18:07:18 +01:00
|
|
|
typedef void ALooper;
|
|
|
|
|
typedef int (*Looper_callbackFunc)(int fd, int events, void* data);
|
2022-10-26 18:39:04 +02:00
|
|
|
|
2022-11-04 18:07:18 +01:00
|
|
|
void _ZN7android6Looper12getForThreadEv(void **ret); // no clue why itanium ABI does this with return values
|
|
|
|
|
ALooper * ALooper_forThread()
|
2022-10-26 18:39:04 +02:00
|
|
|
{
|
2022-11-04 18:07:18 +01:00
|
|
|
void *ret;
|
|
|
|
|
_ZN7android6Looper12getForThreadEv(&ret);
|
|
|
|
|
return ret;
|
2022-10-26 18:39:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-04 18:07:18 +01:00
|
|
|
void _ZN7android6Looper7prepareEi(void **ret, int opts); // no clue why itanium ABI does this with return values
|
|
|
|
|
ALooper * ALooper_prepare(int opts)
|
2022-10-26 18:39:04 +02:00
|
|
|
{
|
2022-11-04 18:07:18 +01:00
|
|
|
void *ret;
|
|
|
|
|
_ZN7android6Looper7prepareEi(&ret, opts);
|
|
|
|
|
return ret;
|
2022-10-26 18:39:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-04 18:07:18 +01:00
|
|
|
int _ZN7android6Looper7pollAllEiPiS1_PPv(void *this, int timeoutMillis, int* outFd, int* outEvents, void** outData);
|
2022-10-26 18:39:04 +02:00
|
|
|
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
|
|
|
|
|
{
|
2022-11-04 18:07:18 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _ZN7android6Looper5addFdEiiiPFiiiPvES1_(void *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-10-26 18:39:04 +02:00
|
|
|
}
|