Myrddin: Partial C ABI compatibility
[Thread Prev] | [Thread Next]
- Subject: Myrddin: Partial C ABI compatibility
- From: Ori Bernstein <ori@xxxxxxxxxxxxxx>
- Date: Fri, 21 Aug 2015 20:02:01 -0700
- To: myrddin-dev@xxxxxxxxxxxxxx
C ABI compatibility on Linux is partly done. Floats, ints, pointers, and anything else in that class of types is likely to work. Passing structs or unions will not work, although passing pointers to them should be ok. Doing anything interesting in C will involve adding a call to initialize libc. Making this work on Plan 9 shouldn't be too far off, and I believe that it will be easier to make it 100% ABI compatible. Integrating it into the build system is another task, and I'm not sure how that would be best done at the moment. Example: === Myrddin === use std type s = struct a : int b : int c : byte[:] ;; extern const frob : (a : int, b : int, c : uint64, d : s#, str : byte[:]# -> int) const main = { var s = [.a = 1000, .b = 2000, .c = "abc"] var str = "abcd" std.put("{}\n", frob(1, 2, 3, &s, &str)) } === C === #include <stdlib.h> #include <stdint.h> typedef struct Myrsl Myrsl; typedef struct S S; struct Myrsl { void *p; size_t len; }; struct S { int a; int b; Myrsl c; }; int frob(int a, int b, uint64_t c, S *d, Myrsl *str) { return a + b + c + d->a + d->b + d->c.len + str->len; } === To compile === 6m myrcode.myr cc -c ccode.c ld -o mixed $prefix/lib/myr/_myrrt.o myrcode.o ccode.o -L$prefix/lib/myr -lstd -lsys $ ./mixed 3013 -- Ori Bernstein
Re: Myrddin: Partial C ABI compatibility | Ryan Gonzalez <rymg19@xxxxxxxxx> |
- Prev by Date: Re: Parser Generator: Demo Exists.
- Next by Date: Re: Myrddin: Partial C ABI compatibility
- Previous by thread: Re: Parser Generator: Demo Exists.
- Next by thread: Re: Myrddin: Partial C ABI compatibility
- Index(es):