From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C1F5813835A for ; Sat, 10 Oct 2020 15:31:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1140BE0882; Sat, 10 Oct 2020 15:31:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DFB6FE0882 for ; Sat, 10 Oct 2020 15:31:32 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 4E28E335D7F for ; Sat, 10 Oct 2020 15:31:31 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B7B9026 for ; Sat, 10 Oct 2020 15:31:29 +0000 (UTC) From: "Conrad Kostecki" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Conrad Kostecki" Message-ID: <1602343586.4ad1abce782d98f32c7ba77d1c59f92f6417b2ff.conikost@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lua/lua-bit32/, dev-lua/lua-bit32/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-lua/lua-bit32/files/lua-bit32-5.3.5-fix-32bit-conversion.patch dev-lua/lua-bit32/lua-bit32-5.3.5-r1.ebuild X-VCS-Directories: dev-lua/lua-bit32/files/ dev-lua/lua-bit32/ X-VCS-Committer: conikost X-VCS-Committer-Name: Conrad Kostecki X-VCS-Revision: 4ad1abce782d98f32c7ba77d1c59f92f6417b2ff X-VCS-Branch: master Date: Sat, 10 Oct 2020 15:31:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 809908ed-bc21-4dd6-9a9a-9c548e9a69b9 X-Archives-Hash: 368126249dea32cb17ec9c188a26438c commit: 4ad1abce782d98f32c7ba77d1c59f92f6417b2ff Author: Conrad Kostecki gentoo org> AuthorDate: Sat Oct 10 15:26:26 2020 +0000 Commit: Conrad Kostecki gentoo org> CommitDate: Sat Oct 10 15:26:26 2020 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4ad1abce dev-lua/lua-bit32: fix 32bit conversion Running bit32 on 32bit systems was broken, so returned value was '-1'. Closes: https://bugs.gentoo.org/746836 Package-Manager: Portage-3.0.8, Repoman-3.0.1 Signed-off-by: Conrad Kostecki gentoo.org> .../lua-bit32-5.3.5-fix-32bit-conversion.patch | 51 ++++++++++++++++++++++ dev-lua/lua-bit32/lua-bit32-5.3.5-r1.ebuild | 51 ++++++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/dev-lua/lua-bit32/files/lua-bit32-5.3.5-fix-32bit-conversion.patch b/dev-lua/lua-bit32/files/lua-bit32-5.3.5-fix-32bit-conversion.patch new file mode 100644 index 00000000000..36c0ef16cec --- /dev/null +++ b/dev-lua/lua-bit32/files/lua-bit32-5.3.5-fix-32bit-conversion.patch @@ -0,0 +1,51 @@ +From e245d3a18957e43ef902a59a72c8902e2e4435b9 Mon Sep 17 00:00:00 2001 +From: Philipp Janda +Date: Sat, 10 Oct 2020 16:43:46 +0200 +Subject: [PATCH] Fix bit32 conversion issues for Lua 5.1 on 32 bit + +The default unsigned conversion procedure from upstream using +`lua_Integer` as an intermediate value fails if `lua_Integer` has only +32 bits (as is the case on 32 bit Lua 5.1). This fix uses a `lua_Number` +(hopefully double) as intermediate value in those cases. +--- + lbitlib.c | 14 ++++++++++++-- + tests/test-bit32.lua | 1 + + 2 files changed, 13 insertions(+), 2 deletions(-) + +diff --git a/lbitlib.c b/lbitlib.c +index 4786c0d..db2652a 100644 +--- a/lbitlib.c ++++ b/lbitlib.c +@@ -19,8 +19,18 @@ + #if defined(LUA_COMPAT_BITLIB) /* { */ + + +-#define pushunsigned(L,n) lua_pushinteger(L, (lua_Integer)(n)) +-#define checkunsigned(L,i) ((lua_Unsigned)luaL_checkinteger(L,i)) ++#define pushunsigned(L,n) (sizeof(lua_Integer) > 4 ? lua_pushinteger(L, (lua_Integer)(n)) : lua_pushnumber(L, (lua_Number)(n))) ++static lua_Unsigned checkunsigned(lua_State *L, int i) { ++ if (sizeof(lua_Integer) > 4) ++ return (lua_Unsigned)luaL_checkinteger(L, i); ++ else { ++ lua_Number d = luaL_checknumber(L, i); ++ if (d < 0) ++ d = (d + 1) + (~(lua_Unsigned)0); ++ luaL_argcheck(L, d >= 0 && d <= (~(lua_Unsigned)0), i, "value out of range"); ++ return (lua_Unsigned)d; ++ } ++} + + + /* number of bits to consider in a number */ +diff --git a/tests/test-bit32.lua b/tests/test-bit32.lua +index cc91e52..a408b7d 100755 +--- a/tests/test-bit32.lua ++++ b/tests/test-bit32.lua +@@ -4,6 +4,7 @@ local bit32 = require("bit32") + + + assert(bit32.bnot(0) == 2^32-1) ++assert(bit32.bnot(-1) == 0) + assert(bit32.band(1, 3, 5) == 1) + assert(bit32.bor(1, 3, 5) == 7) + diff --git a/dev-lua/lua-bit32/lua-bit32-5.3.5-r1.ebuild b/dev-lua/lua-bit32/lua-bit32-5.3.5-r1.ebuild new file mode 100644 index 00000000000..32d81d68f9f --- /dev/null +++ b/dev-lua/lua-bit32/lua-bit32-5.3.5-r1.ebuild @@ -0,0 +1,51 @@ +# Copyright 2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +inherit toolchain-funcs + +# Weird upstream version descisions... +# Result tarball may be reused for future lua-compat53 package +LUA_COMPAT_PN="lua-compat-5.3" +LUA_COMPAT_PV="0.9" + +DESCRIPTION="Backported Lua bit manipulation library" +HOMEPAGE="https://github.com/keplerproject/lua-compat-5.3" +SRC_URI="https://github.com/keplerproject/${LUA_COMPAT_PN}/archive/v${LUA_COMPAT_PV}.tar.gz -> lua-compat53-${LUA_COMPAT_PV}.tar.gz" + +S="${WORKDIR}/${LUA_COMPAT_PN}-${LUA_COMPAT_PV}" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux" +IUSE="test" + +RESTRICT="!test? ( test )" + +DEPEND="dev-lang/lua:0=" +RDEPEND="${DEPEND}" +BDEPEND="virtual/pkgconfig" + +PATCHES=( "${FILESDIR}/${P}-fix-32bit-conversion.patch" ) + +src_compile() { + # TODO maybe sometime there will be luarocks eclass... + compile="$(tc-getCC) ${CFLAGS} ${LDFLAGS} -fPIC -I/usr/include -c lbitlib.c -o lbitlib.o -DLUA_COMPAT_BITLIB -Ic-api" + einfo "${compile}" + eval "${compile}" || die + + link="$(tc-getCC) -shared ${LDFLAGS} -o bit32.so lbitlib.o" + einfo "${link}" + eval "${link}" || die +} + +src_test() { + LUA_CPATH=./?.so lua tests/test-bit32.lua || die +} + +src_install() { + exeinto $($(tc-getPKG_CONFIG) --variable INSTALL_CMOD lua) + doexe bit32.so + dodoc README.md +}