59be119f56421c3369666ee72b9167e5e39e1b4f
[tpg/acess2.git] / AcessNative / ld-acess_src / common.h
1 /*
2  */
3 #ifndef _COMMON_H_
4 #define _COMMON_H_
5
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <string.h>
10
11 extern int      Binary_GetSymbol(const char *SymbolName, uintptr_t *Value);
12 extern void     *Binary_LoadLibrary(const char *Path);
13 extern void     *Binary_Load(const char *Path, uintptr_t *EntryPoint);
14 extern void     Binary_SetReadyToUse(void *Base);
15
16 // HACKS - So this can share the usermode elf.c
17 static inline void *GetSymbol(const char*sym, size_t*sz)
18 {
19         uintptr_t rv;
20         if( Binary_GetSymbol(sym, &rv) )
21                 return NULL;
22         return (void*)rv;
23 }
24 static inline void *LoadLibrary(const char *Name, const char *SearchPath, char **envp)
25 {
26         return Binary_LoadLibrary(Name);
27 }
28 static inline void AddLoaded(const char *Path, void *Base)
29 {
30         Binary_SetReadyToUse(Base);
31 }
32
33 extern int      AllocateMemory(uintptr_t VirtAddr, size_t ByteCount);
34 extern uintptr_t        FindFreeRange(size_t ByteCount, int MaxBits);
35
36 extern void     Warning(const char *Format, ...);
37 extern void     Notice(const char *Format, ...);
38 extern void     Debug(const char *Format, ...);
39 #define SysDebug        Debug
40
41 #define ACESS_SEEK_CUR  0
42 #define ACESS_SEEK_SET  1
43 #define ACESS_SEEK_END  -1
44
45 #include "exports.h"
46
47 typedef struct sBinFmt {
48         struct sBinFmt  *Next;
49         char    *Name;
50         void    *(*Load)(int fd);
51         uintptr_t       (*Relocate)(void *base);
52          int    (*GetSymbol)(void*,char*,uintptr_t*);
53 }       tBinFmt;
54
55 #endif
56

UCC git Repository :: git.ucc.asn.au