From dae7f3f4d5e066c945ed8352bf60dee37eb97657 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Tue, 14 Jul 2009 15:21:00 +0000 Subject: nixio: Add Rockspec Add bswap to nixio.bit Fix nixio.bit documentation --- libs/nixio/src/bit.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libs/nixio/src/bit.c') diff --git a/libs/nixio/src/bit.c b/libs/nixio/src/bit.c index 14fdecab13..9991a7ca41 100644 --- a/libs/nixio/src/bit.c +++ b/libs/nixio/src/bit.c @@ -97,6 +97,13 @@ static int nixio_bit_cast(lua_State *L) { return 1; } +static int nixio_bit_swap(lua_State *L) { + uint64_t op = luaL_checknumber(L, 1); + op = (op >> 24) | ((op >> 8) & 0xff00) | ((op & 0xff00) << 8) | (op << 24); + lua_pushnumber(L, op); + return 1; +} + /* module table */ static const luaL_reg R[] = { {"bor", nixio_bit_or}, @@ -111,6 +118,8 @@ static const luaL_reg R[] = { {"div", nixio_bit_div}, {"check", nixio_bit_check}, {"cast", nixio_bit_cast}, + {"tobit", nixio_bit_cast}, + {"bswap", nixio_bit_swap}, {NULL, NULL} }; -- cgit v1.2.3