New tool to convert sfd to clib, pragma, stubs etc in the works
I've started a new open source project LibDescConverter that takes .sfd files (very similar to .fd) and output a
slew of include files, but also hopefully also files to connect from other programming libraries.
The intention is to use this new tool when releasing new versions of the NDK, but also for all other to use when making your own library.
The source is available at https://gitlab.com/boemann/libdescconverter
If you plan to support GCC 2.95.3.
There are two ways of generating inlines for this compiler. One uses feature of placing function arguments in specified processor registers. The second one uses feature of placing local variables in specified processor registers. Current NDK uses the first one.
The first method does not work with C++ compiler. The second one works with C and C++. An example for AllocMem()
:
static inline APTR _AllocMem (struct Library* _base, ULONG byteSize, ULONG requirements)
{
register struct Library* b __asm("a6") = _base;
register ULONG p0 __asm("d0") = byteSize;
register ULONG p1 __asm("d1") = requirements;
register APTR r __asm("d0");
__asm volatile ("jsr -198(%0);" : "+r"(b), "=r"(r) : "r"(p0), "r"(p1) : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory");
return r;
}
#define AllocMem(byteSize, requirements) _AllocMem(SysBase, byteSize, requirements)
Thanks, I very much plan to support gcc2.95 and VBCC and the newer gcc too for that matter
Krashan Could you please paste a similar example for a vararg function
Sure. An example for AslRequest() and AslRequestTags():
static inline BOOL _AslRequest (struct Library* _base, APTR requester, CONST struct TagItem* tagList)
{
register struct Library* b __asm("a6") = _base;
register APTR p0 __asm("a0") = requester;
register CONST struct TagItem* p1 __asm("a1") = tagList;
register BOOL r __asm("d0");
__asm volatile ("jsr -60(%0);" : "+r"(b), "=r"(r) : "r"(p0), "r"(p1) : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory");
return r;
}
#define AslRequest(requester, tagList) _AslRequest(AslBase, requester, tagList)
static inline BOOL _AslRequestTags(struct Library* _base, APTR requester, ULONG tag0, ...)
{
return _AslRequest(_base, requester, (const struct TagItem*)&tag0);
}
#define AslRequestTags(requester...) _AslRequestTags(AslBase, requester)
Ha funny those are the exact same functions I've been using for testing. Thank you very much - the tool is almost ready. It creates clib, pragma,pragmas, inline for gcc and vbcc as well the combining proto file. And for assembler it creates lvo and for E it creates emodules.
I will incorporate your suggestion right away
#define AllocAslRequest(reqType, tagList) \
({ \
register void *b __asm("a6") = AslBase; \
register ULONG p0 __asm("d0") = (reqType); \
register CONST struct TagItem *p1 __asm("a0") = (tagList); \
register APTR r __asm("d0"); \
__asm volatile ("jsr a6@(-48:W);" : "+r"(b), "=r"(r) : "r"(p0), "r"(p1) : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); \
r; \
})
#ifndef NO_INLINE_STDARG
#define AllocAslRequestTags(reqType, tags...) \
({ \
ULONG _tags[] = {tags}; \
AllocAslRequest((reqType), _tags); \
r; \
})
#endif
Online Status
It now outputs to clib as well as pragma. Frank Wille made it build on VBCC.
People should not that it requires the opensource but yet unreleased containerkit.library. Contact me if you want an advance copy so you can build LibDescConverter.