26 September 2022, 00:54 | #1 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 161
|
Please help me decode this macro..
Hi, I'm trying to compile xadmaster.library v13 fro native 68k. My first "success" gave a library that was almost twice as big as the v12.1a from aminet. Seeing that more clients had become internal, I'm trying to make them external again.
I got most to compile, but I'm having trouble with the HA.020 and HA.060 clients, and a macro I can't wrap my head around. The macro from xadClient.h: Code:
/* The defines _M680x0 are done automatically by SAS-C. Do them in makefile for other compilers. */ #ifdef _M68060 #define CPUCHECK if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68060)) return 0; #define CPUCHECKGI if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68060)) return XADERR_FILESYSTEM; #define CPUTEXT " 060" #elif defined (_M68040) #define CPUCHECK if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68040)) return 0; #define CPUCHECKGI if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68040)) return XADERR_FILESYSTEM; #define CPUTEXT " 040" #elif defined (_M68030) #define CPUCHECK if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68030)) return 0; #define CPUCHECKGI if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68030)) return XADERR_FILESYSTEM; #define CPUTEXT " 030" #elif defined (_M68020) #define CPUCHECK if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68020)) return 0; #define CPUCHECKGI if(!(xadMasterBase->xmb_SysBase->AttnFlags & AFF_68020)) return XADERR_FILESYSTEM; #define CPUTEXT " 020" #else #define CPUTEXT #endif #endif /* The macro CPUCHECK is used in xcRecogData() as first command. A inline function is used to encapsulate the real function. For filesystem clients CPUCKECKGI is used in xc_GetInfo(). These macros are security macros only. It is still not very clever to install wrong CPU version, but if this macro is used, the computer does not crash, but this client is skipped always. The string CPUTEXT is used in version string after date. */ #if !defined(XADMASTERFILE) && defined(CPUCHECK) #define XADRECOGDATA(name) INLINE xadBOOL _name##_RecogData( xadSize size, \ const xadUINT8 *data, struct xadMasterBase *xadMasterBase); \ static ASM(xadBOOL) name##_RecogData( \ REG(d0, xadSize size), \ REG(a0, const xadUINT8 *data), \ REG(a6, struct xadMasterBase *xadMasterBase)) \ { CPUCHECK return _name##_RecogData(size,data,xadMasterBase); } \ INLINE xadBOOL _name##_RecogData( xadSize size, \ xadUINT8 *data, struct xadMasterBase *xadMasterBase) #else #define XADRECOGDATA(name) static ASM(xadBOOL) name##_RecogData( \ REG(d0, xadSize size), \ REG(a0, const xadUINT8 *data), \ REG(a6, struct xadMasterBase *xadMasterBase)) #endif relevant part from HA.c Code:
XADRECOGDATA(HA) { if(data[0] == 'H' && data[1] == 'A' && (data[4]>>4) == 2 && (data[4]&0xF) <= HATYPE_SPECIAL && EndGetI32(data+5) <= EndGetI32(data+9)) return 1; return 0; } Code:
sc RESOPT NOSTACKCHECK STRINGMERGE UNSIGNEDCHARS NOCHECKABORT NOICONS MEMSIZE=HUGE DATA=FARONLY PARAM=REGISTERS DEFINE=__NOLIBBASE__ IDIR=//amiga/include/c/ HA.c OBJNAME=//obj/clients/HA.060.o CPU=68060 SAS/C Amiga Compiler 6.59 Copyright (c) 1988-1995 SAS Institute Inc. ==================== { HA.c 109 Error 72: conflict with previous declaration See line 108 file "HA.c" HA.c 1299 Warning 183: inline function "_name_RecogData" declared but not defined See line 109 file "HA.c" sc failed returncode 20 Fore reference I'm using sources downloaded form: https://github.com/ashang/libxad Last edited by hceline; 26 September 2022 at 08:23. Reason: Added note about INLINE |
26 September 2022, 11:14 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,000
|
I guess _name##_RecogData should better be _##name##_RecogData
Otherwise "name" would not be substituted by the name given to the macro. This part probably has never been compiled as external client. It could also be a restriction of SAS/C. The macro first declares a prototype for the inline function, then has the external function calling the inline function and then defines the inline function. I could imagine that the compiler needs the whole inline function to compile the external function, not only a prototype. You might try to omit the inline keyword. |
26 September 2022, 13:29 | #3 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 161
|
Thanks for suggestions.
If I replace all occurrences of _name##_RecogData with _##name##_RecogData in macro i get: Code:
sc RESOPT NOSTACKCHECK STRINGMERGE UNSIGNEDCHARS NOCHECKABORT NOICONS MEMSIZE=HUGE DATA=FARONLY PARAM=REGISTERS DEFINE=__NOLIBBASE__ IDIR=//amiga/include/c/ HA.c OBJNAME=//obj/clients/HA.020.o CPU=68020 SAS/C Amiga Compiler 6.59 Copyright (c) 1988-1995 SAS Institute Inc. ==================== { HA.c 109 Error 72: conflict with previous declaration See line 108 file "HA.c" HA.c 1300 Warning 183: inline function "_HA_RecogData" declared but not defined See line 109 file "HA.c" sc failed returncode 20 And removing the INLINE just changes the output, not the error: Code:
sc RESOPT NOSTACKCHECK STRINGMERGE UNSIGNEDCHARS NOCHECKABORT NOICONS MEMSIZE=HUGE DATA=FARONLY PARAM=REGISTERS DEFINE=__NOLIBBASE__ IDIR=//amiga/include/c/ HA.c OBJNAME=//obj/clients/HA.020.o CPU=68020 SAS/C Amiga Compiler 6.59 Copyright (c) 1988-1995 SAS Institute Inc. ==================== { HA.c 109 Error 72: conflict with previous declaration See line 108 file "HA.c" sc failed returncode 20 Last edited by hceline; 27 September 2022 at 16:45. Reason: Logic illuded me whan writing tha last part, deleted. |
27 September 2022, 17:02 | #4 |
Registered User
Join Date: Nov 2009
Location: Top of the world
Posts: 161
|
Solved it....
Conclusion is that I need to learn how to read/understand macros. Had the sas/c preprocessor translate it to C for me. And after going on a wild rabbit chase trough the source hunting for an non existent #define that explained the difference between HA and TR-DOS, I finally realized it: It was a missing "const" before "xadUINT8 *data" on last line in the macro. @thomas: If I'd read your post twice. And really tried to understand the last part, I'd probably solved it sooner. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Utillity to decode MFM data | mark_k | request.Apps | 5 | 26 August 2017 14:32 |
How to decode ZX Spectrum and C64 fonts | Leandro Jardim | Retrogaming General Discussion | 4 | 04 July 2014 02:05 |
WAITBLIT macro | phx | Coders. Asm / Hardware | 20 | 18 February 2014 14:22 |
Optimising ILBM decode | pmc | Coders. Asm / Hardware | 21 | 12 October 2011 20:24 |
Looking for Macro Paint | mr_a500 | request.Apps | 2 | 28 January 2006 18:20 |
|
|