[arch-commits] Commit in haskell-cryptonite/trunk (PKGBUILD i686.patch)
Felix Yan
fyan at archlinux.org
Wed Jun 8 09:09:22 UTC 2016
Date: Wednesday, June 8, 2016 @ 11:09:22
Author: fyan
Revision: 178595
upgpkg: haskell-cryptonite 0.16-1
add a patch to fix i686 build
Added:
haskell-cryptonite/trunk/i686.patch
Modified:
haskell-cryptonite/trunk/PKGBUILD
------------+
PKGBUILD | 12 +++++++--
i686.patch | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 2 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2016-06-08 09:02:56 UTC (rev 178594)
+++ PKGBUILD 2016-06-08 09:09:22 UTC (rev 178595)
@@ -11,9 +11,17 @@
license=("custom:BSD3")
arch=('i686' 'x86_64')
depends=("ghc=8.0.1" "haskell-memory")
-source=("http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
-sha256sums=('5c3bf190954986ea4af466914eb7a0c55a0b4c1c66552d00341277c89082511a')
+source=("http://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz"
+ i686.patch)
+sha256sums=('5c3bf190954986ea4af466914eb7a0c55a0b4c1c66552d00341277c89082511a'
+ '0bd68b7fd7caa859ca9a5dd7343c45c0dfd22c0c5cd55dec626de2dd9804abec')
+prepare() {
+ cd $_hkgname-$pkgver
+ # https://github.com/haskell-crypto/cryptonite/issues/88
+ patch -p1 -i ../i686.patch
+}
+
build() {
cd "${srcdir}/${_hkgname}-${pkgver}"
Added: i686.patch
===================================================================
--- i686.patch (rev 0)
+++ i686.patch 2016-06-08 09:09:22 UTC (rev 178595)
@@ -0,0 +1,75 @@
+From f5a811e755eee253bc34897f327e096e04ad1286 Mon Sep 17 00:00:00 2001
+From: Vincent Hanquez <vincent at snarc.org>
+Date: Fri, 3 Jun 2016 07:12:38 +0100
+Subject: [PATCH] [rdrand] add an untested workaround for i686 machine
+
+---
+ cbits/cryptonite_rdrand.c | 35 ++++++++++++++++++++++++++++-------
+ 1 file changed, 28 insertions(+), 7 deletions(-)
+
+diff --git a/cbits/cryptonite_rdrand.c b/cbits/cryptonite_rdrand.c
+index 54409fc..66501e5 100644
+--- a/cbits/cryptonite_rdrand.c
++++ b/cbits/cryptonite_rdrand.c
+@@ -65,17 +65,38 @@ static inline int crypto_random_rdrand64_step(uint64_t *buffer)
+ : \
+ : "cc")
+
++/* inline encoding of 'rdrand %eax' to cover old binutils
++ * - no inputs
++ * - 'cc' to the clobber list as we modify condition code.
++ * - output of rdrand in eax and have a 8 bit error condition
++ */
++#define inline_rdrand_eax(val, err) \
++ asm(".byte 0x0f,0xc7,0xf0; setc %1" \
++ : "=a" (val), "=q" (err) \
++ : \
++ : "cc")
++
++#ifdef __x86_64__
++# define RDRAND_SZ 8
++# define RDRAND_T uint64_t
++#define inline_rdrand(val, err) inline_rdrand_rax(val, err)
++#else
++# define RDRAND_SZ 4
++# define RDRAND_T uint32_t
++#define inline_rdrand(val, err) inline_rdrand_eax(val, err)
++#endif
++
+ /* Returns the number of bytes succesfully generated */
+ int cryptonite_get_rand_bytes(uint8_t *buffer, size_t len)
+ {
+- uint64_t tmp;
+- int aligned = (intptr_t) buffer % 8;
++ RDRAND_T tmp;
++ int aligned = (intptr_t) buffer % RDRAND_SZ;
+ int orig_len = len;
+- int to_alignment = 8 - aligned;
++ int to_alignment = RDRAND_SZ - aligned;
+ uint8_t ok;
+
+ if (aligned != 0) {
+- inline_rdrand_rax(tmp, ok);
++ inline_rdrand(tmp, ok);
+ if (!ok)
+ return 0;
+ memcpy(buffer, (uint8_t *) &tmp, to_alignment);
+@@ -83,15 +104,15 @@ int cryptonite_get_rand_bytes(uint8_t *buffer, size_t len)
+ len -= to_alignment;
+ }
+
+- for (; len >= 8; buffer += 8, len -= 8) {
+- inline_rdrand_rax(tmp, ok);
++ for (; len >= RDRAND_SZ; buffer += RDRAND_SZ, len -= RDRAND_SZ) {
++ inline_rdrand(tmp, ok);
+ if (!ok)
+ return (orig_len - len);
+ *((uint64_t *) buffer) = tmp;
+ }
+
+ if (len > 0) {
+- inline_rdrand_rax(tmp, ok);
++ inline_rdrand(tmp, ok);
+ if (!ok)
+ return (orig_len - len);
+ memcpy(buffer, (uint8_t *) &tmp, len);
More information about the arch-commits
mailing list