d bare bones
Iain Buclaw
ibuclaw at ubuntu.com
Fri Sep 6 07:09:02 PDT 2013
On 6 September 2013 14:13, Dicebot <public at dicebot.lv> wrote:
> On Friday, 6 September 2013 at 12:25:56 UTC, eles wrote:
>>
>> On Friday, 6 September 2013 at 10:43:38 UTC, Iain Buclaw wrote:
>>>
>>> On 6 September 2013 10:35, eles <eles at eles.com> wrote:
>>> But there's no equivalent to volatile statements other than
>>> implementing your own low level thread library for use in kernel-land
>>> to allow synchronized to work properly.
>>
>>
>> Frankly, but each day D becomes better, it becomes worse for systems
>> programming. I'll have more&more difficulties to defend it as an acceptable
>> solution at my workplace.
>>
>> I am sorry about that, but I cannot do much about it... :(
>
>
> Yes, I feel quite the same way and I have almost abandoned any hopes to use
> it in C domain. Currently D is more like native faster C# - still pretty
> cool in lot of applications but definitely not the breakthrough.
And all I'm saying is that if you want to use it on bare metal then
you have to strip out phobos and re-implement everything from
druntime.
- In a kernel, you don't have the liberty of using malloc, realloc,
free, or any other libc functions. So these allocation routines that
are a part of the GC need to be re-written for use in the kernel.
- The GC that comes with D itself is a bit too heavy for use in a
kernel -> re-write.
- pthread library is also out -> write your own lock system specific
for use in the kernel.
- Using exceptions in a kernel? You are having a laugh...
- The D compiler may generate calls to libc functions, such as memcmp
or fmod or pow -> avoid these like the plague. (Actually this isn't
necessary a bad thing to note upon, as eg: gcc could do the same thing
also, and so Linux devs tend to write in a very peculiar way because
of this anyway).
But lets try to be positive. How would I pragmatically approach this?
Well, we are going to have to build a runtime from ground up either
way you look at it.
1) Minimal D runtime.
Only recent example I can think of is here: http://arsdnet.net/dcode/minimal.zip
Though this is for DMD only.
Older examples of a minimal D runtime are for D1.
https://github.com/xomboverlord/xomb/tree/unborn/runtimes
Ideally you'd want to try and marriage the two together.
2) GDC-specific modules.
Only set of modules you need to worry about are the EH modules
(unwind.d). These are based off of libstdc++ EH functions, there is a
minimal C++ runtime here which is available here:
https://github.com/pathscale/libcxxrt/tree/master/src
Simply convert the EH routines over to D as required.
3) Entrypoint functions.
See Xomb link above for assembly files, etc.
4) glibc/pthread
Write your own replacements. See for example how Linux does this
(kmalloc/kfree, etc).
Regards
--
Iain Buclaw
*(p < e ? p++ : p) = (c & 0x0f) + '0';
More information about the D.gnu
mailing list