utiliD: A library with absolutely no dependencies for bare-metal programming and bootstrapping other D libraries

Eugene Wissner belka at caraus.de
Fri May 10 05:20:59 UTC 2019


- Memcmp, memcpy, memmove and memset are named equal, copy, 
copyBackward and fill respectively. I just wanted to create 
native implementations that are bit safer than their C 
counterparts. So they do the same job, but accept void[] instead 
of pointers. There are also templated functions with the same 
names, that work with ranges.

I‘m not very comfortable with GCC‘s inline asm and it doesn‘t 
support naked asm as DMD does, so I put asm in the .S files and 
compile them separately. But I‘m fine with inline asm too. A 
problem with the inline asm is that it should be written in 
several versions since DMD uses different calling conventions 
(unless we use extern(C)) and GDC and LDC use different asm 
syntax.

Tanya contains pretty much stuff now and I‘m just thinking to 
split it in a smaller parts (of a reasonable size), that are 
probably interesting for other people, who is ready to 
contribute, so I don‘t have to maintain everything myself. I 
don‘t know exactly what goes into this more „low-level“ library, 
we can always talk about it.

- OS API

Not sure if it belongs to the scope of utilD. Some time ago it 
became clear to me, that while C has functions for dynamic memory 
management, it uses them internally very seldom. Instead it lets 
the user to allocate the memory. So there functions like:

char *if_indextoname(unsigned int ifindex, char *ifname);

that take an output buffer as the last argument. The same can be 
done with output ranges in D, so these system functions can be 
rewritten in D with a better interface. Whereby I should say that 
tanya‘s range definitions differ from Phobos.

- meta

Another thing probably interesting for utilD library is 
meta-programming. Tanya has „tanya.meta“ package which contains 
templates similar to to std.traits and std.meta + some nice 
extras like Union/Intersection/Difference working on sets of 
types, that are inspired by Boost Hana. This part is completely 
independent (from Phobos and the rest of tanya) and can even be a 
separate library.


More information about the Digitalmars-d-announce mailing list