4 ms·
I could imagine that perhaps they want the program to work on architectures other than the ones they can provide and test assembly code for.
by beefhash 7y ago
I could imagine that perhaps they want the program to work on architectures other than the ones they can provide and test assembly code for.
- chrisseaton 7y agoIf they don't have a way to test and look at machine code on these architectures... then how can they know their workarounds for compiler optimisations are working?
- megous 7y agoThese are not workarounds. The code looks complicated only because it tries to be portable and fast. Otherwise just the last #else block would be enough. Also they know, because it's what those functions they call are for. man explicit_bzero for example. It says: "The explicit_bzero() function performs the same task as bzero(). It differs from bzero() in that it guarantees that compiler optimizations will not remove the erase operation if the compiler deduces that the operation is "unnecessary"."
- chrisseaton 7y ago> These are not workarounds. What is the purpose of this line? Why do you think it's there if the C code using volatile is enough on its own? https://github.com/jedisct1/libsodium/blob/a26467874a512de304f6e7e25d98af549963de9f/src/libsodium/sodium/utils.c#L131 https://github.com/jedisct1/libsodium/blob/a26467874a512de30... It's a workaround to prevent optimisations because that happens to be how some compilers are implemented today. Will it be implemented like that tomorrow or in a different compiler? Who knows. https://github.com/jedisct1/libsodium/commit/27872ca13c713c90cd5576722a3f672a73d4c9f6 https://github.com/jedisct1/libsodium/commit/27872ca13c713c9...
- megous 7y agoThat line is not present at all if volatile using variant of the function is used.