macro rule_compile: remove C++ flags from the C flags.
[AROS.git] / arch / all-unix / battclock / battclock_init.c
blobd0e16627b4d17937d26abc95faa6ee017e19ec29
1 #include <aros/debug.h>
2 #include <aros/libcall.h>
3 #include <aros/symbolsets.h>
4 #include <proto/exec.h>
5 #include <proto/hostlib.h>
7 #include <time.h>
9 #include "battclock_intern.h"
11 #ifdef HOST_OS_linux
12 #ifndef HOST_OS_android
13 #define LIBC_NAME "libc.so.6"
14 #endif
15 #endif
17 #ifdef HOST_OS_darwin
18 #define LIBC_NAME "libSystem.dylib"
19 #endif
21 #ifndef LIBC_NAME
22 #define LIBC_NAME "libc.so"
23 #endif
25 static const char *Symbols[] = {
26 "time",
27 "localtime",
28 NULL
31 /* auto init */
32 static int BattClock_Init(struct BattClockBase *BattClockBase)
34 APTR HostLibBase;
35 ULONG r;
37 HostLibBase = OpenResource("hostlib.resource");
38 D(bug("[battclock] HostLibBase = 0x%08lX\n", HostLibBase));
40 if (HostLibBase)
42 BattClockBase->Lib = HostLib_Open(LIBC_NAME, NULL);
43 if (BattClockBase->Lib)
45 BattClockBase->SysIFace = (struct BattclockInterface *)HostLib_GetInterface(BattClockBase->Lib, Symbols, &r);
46 D(bug("[battclock] SysIFace = 0x%08lX, unresolved: %u\n", BattClockBase->SysIFace, r));
48 if (BattClockBase->SysIFace)
50 if (!r)
51 return 1;
52 HostLib_DropInterface((APTR)BattClockBase->SysIFace);
54 HostLib_Close(BattClockBase->Lib, NULL);
57 return 0;
60 ADD2INITLIB(BattClock_Init, 0)