:: Re: [DNG] The D in Systemd stands f…
Kezdőlap
Delete this message
Reply to this message
Szerző: Didier Kryn
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] The D in Systemd stands for 'Dammmmit!'
Le 30/10/2018 à 13:38, Adam Borowski a écrit :
> In that case, memcpy() is strictly better:
> * faster:
>    + no need to compare every byte
>    + can copy longer strings a word at a time
> * safer: you don't get the false impression it'd null-terminate the string
>    for you



    Wether the function is able to group bytes in words is, in
principle, an implementation issue. I thought, naively, that strncpy()
also was able to group the bytes in words. But you're perfectly right,
memcpy() does the job.

>> The two other methods are to use snprintf() or to copy the bytes one by
>> one in a loop.
> Or copy word by word -- or even via a mem-to-mem DMA transfer some folks
> want to add to new machines. Or...


    [OT] DMA engines access physical memory, not virtual; therefore you
need to issue syscalls to a dedicated driver, which implies some
overhead. It could only be valuable for very long strings. If it's
behind the MMU, then, IMHO, it should rather be called a memcpy
instruction than DMA. But I'd really be interested in reading what
people have in mind.

    Didier