lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello,

There are a few uses of the 'volatile' keyword in lstrlib.c, and I'm
trying to understand their purpose (lua 5.3).

I care most about the two instances of "volatile Ftypes u;" The other
one is copywithendian.

>From what I understand, most uses of 'volatile' in Lua are protection
in the case of setjmp/longjmp stomping registers. Do those concerns
apply here?

These were introduced with commit
c172a4f7c2d452035f9cbb4285f2e6761ab7a68b, with the comment:
    'dumpint' and related functions replaced by 'string.pack'/'string.unpack'

So, not a lot of info there.

Are there any other concerns in this code that require 'volatile'? Or
maybe it's a workaround for some old compilers, such as mentioned in
the comments for 'aux_close' ?


For the extra-curious, this is a stumbling block for me as I implement
a custom lua_Number type, compiling it as C++ with operator
overloading to make my type behave much like a float. I made a
StackOverflow question with details here, if anyone is interested:
https://stackoverflow.com/questions/64071982/custom-number-class-can-it-be-made-to-work-in-place-of-float-or-other-buil

Thanks
-John