Module:CTypes

local bit32 = require "bit32" local p = {}

local function unimplemented error("CTypes function not implemented") end

p.uint32_t = {} local uint32_t = p.uint32_t

uint32_t.unm = unimplemented uint32_t.add = function(x, y)	return (x+y) % 4294967296 -- 2^32 end uint32_t.sub = unimplemented uint32_t.mul = function(x, y)	local lo_x = bit32.extract( x, 0, 16 ) local hi_x = bit32.extract( x, 16, 16 ) local lo_y = bit32.extract( y, 0, 16 ) local hi_y = bit32.extract( y, 16, 16 )

local r = lo_x * lo_y local l = hi_x * lo_y + bit32.extract( r, 16, 16 ) + lo_x * hi_y

return bit32.replace(r, l, 16, 16) end uint32_t.div = unimplemented uint32_t.shl = unimplemented uint32_t.shr = unimplemented

return p