[Self-interest] C preprocessor for asm

Valery Ushakov uwe at stderr.spb.ru
Sun Dec 18 00:30:36 UTC 2022


Asm sources in Self currently use assembler's macro facilities that
differ between clang and gas.  Recent versions of clang asm is gas
compatible, but then as far as I understand apple's clang is special.
llvm's asm behaves differently if "IsDarwin" and the current llvm
macro code in Self is effectively apple-only.

I'm working on a NetBSD port and NetBSD supports both gcc and clang as
system compilers.  I will porbably look at the FreeBSD port too and
FreeBSD is now clang only, afaik.  This makes it a bit painful to work
with the current asm sources.

Would there be any objections to switching Self i386 asm sources to
use the C pre-processor?  NetBSD has been doing that for ages (for a
large zoo of CPUs) and it's quite ok.

Some examples

  https://github.com/NetBSD/src/blob/trunk/sys/arch/i386/include/asm.h
  https://github.com/NetBSD/src/blob/trunk/lib/libc/arch/i386/SYS.h

just to give a general idea of what it looks like.  So, e.g.

    start_exported_function currentFrame

will just become


    start_exported_function(currentFrame)

Or

    MACRO(ret_prim_error, error_code)
        ...

    ret_bad_type: ret_prim_error badTypeOffset


will be

    #define ret_prim_error(error_code) \
	... ; \
        ...

    ret_bad_type: ret_prim_error(badTypeOffset)


-uwe


More information about the Self-interest mailing list