[med-svn] [Git][med-team/staden-io-lib][master] 5 commits: Fix build for 32 bit systems courtesy a patch from upstream.

Michael R. Crusoe gitlab at salsa.debian.org
Tue Jul 28 11:43:21 BST 2020



Michael R. Crusoe pushed to branch master at Debian Med / staden-io-lib


Commits:
027875ed by Michael R. Crusoe at 2020-07-21T13:45:03+02:00
Fix build for 32 bit systems courtesy a patch from upstream.

- - - - -
2dc82139 by Michael R. Crusoe at 2020-07-28T12:37:54+02:00
Really install io_lib_config.h properly

- - - - -
4fa0c6c9 by Michael R. Crusoe at 2020-07-28T12:37:54+02:00
fix repeated override_dh_install-indep

- - - - -
ee14fd9b by Michael R. Crusoe at 2020-07-28T12:37:54+02:00
Updated symbols file to match upstream's patch

- - - - -
d84b6520 by Michael R. Crusoe at 2020-07-28T12:42:37+02:00
release 1.14.13-4

- - - - -


5 changed files:

- debian/changelog
- debian/libstaden-read14.symbols
- + debian/patches/32-bit.patch
- debian/patches/series
- debian/rules


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,11 @@
+staden-io-lib (1.14.13-4) unstable; urgency=medium
+
+  * Fix build for 32 bit systems courtesy a patch from upstream. Updated
+    symbols file to match.
+  * REALLY install io_lib_config.h to /usr/include/io_lib/
+
+ -- Michael R. Crusoe <crusoe at debian.org>  Tue, 28 Jul 2020 12:42:20 +0200
+
 staden-io-lib (1.14.13-3) unstable; urgency=medium
 
   * Install io_lib_config.h to /usr/include/io_lib/


=====================================
debian/libstaden-read14.symbols
=====================================
@@ -19,6 +19,7 @@ libstaden-read.so.14 libstaden-read14 #MINVER#
  HashJenkins3 at Base 1.14.12
  HashJenkins at Base 1.14.12
  HashTableAdd at Base 1.14.12
+ HashTableAddInt64 at Base 1.14.13
  HashTableCreate at Base 1.14.12
  HashTableDel at Base 1.14.12
  HashTableDestroy at Base 1.14.12
@@ -28,10 +29,13 @@ libstaden-read.so.14 libstaden-read14 #MINVER#
  HashTableIterNext at Base 1.14.12
  HashTableIterReset at Base 1.14.12
  HashTableNext at Base 1.14.12
+ HashTableNextInt64 at Base 1.14.13
  HashTableNextInt at Base 1.14.12
  HashTableRemove at Base 1.14.12
+ HashTableRemoveInt64 at Base 1.14.13
  HashTableResize at Base 1.14.12
  HashTableSearch at Base 1.14.12
+ HashTableSearchInt64 at Base 1.14.13
  HashTableStats at Base 1.14.12
  HashTcl at Base 1.14.12
  MD5_Final at Base 1.14.12


=====================================
debian/patches/32-bit.patch
=====================================
@@ -0,0 +1,255 @@
+From: James Bonfield <jkb at sanger.ac.uk>
+Date: Mon, 20 Jul 2020 16:53:58 +0100
+Subject: Added int64 versions of some HashTable functions.
+Forwarded: upstream, https://github.com/jkbonfield/io_lib/commit/3c1d8dfa1f20f59bb32f051be289e8b7fbc82e5b
+
+This is needed for CRAM 4.0 which uses 64-bit integer keys in the hash
+table, which doesn't fit in the char*key parameter on 32-bit systems.
+This does however add a small dependency on a single C11 feature
+(anonymous unions), but we'll see if this causes problems.  Certainly
+fewer problems than changing the API, so it's a starting point.
+
+Fixes #31
+---
+ io_lib/cram_stats.c |  10 ++--
+ io_lib/hash_table.c | 118 ++++++++++++++++++++++++++++++++++++++++++++
+ io_lib/hash_table.h |  21 +++++++-
+ 3 files changed, 143 insertions(+), 6 deletions(-)
+
+--- staden-io-lib.orig/io_lib/cram_stats.c
++++ staden-io-lib/io_lib/cram_stats.c
+@@ -69,12 +69,12 @@
+ 	    st->h = HashTableCreate(2048, HASH_DYNAMIC_SIZE|HASH_NONVOLATILE_KEYS|HASH_INT_KEYS);
+ 	}
+ 
+-	if ((hi = HashTableSearch(st->h, (char *)(size_t)val, 8))) {
++	if ((hi = HashTableSearchInt64(st->h, val))) {
+ 	    hi->data.i++;
+ 	} else {
+ 	    HashData hd;
+ 	    hd.i = 1;
+-	    HashTableAdd(st->h, (char *)(size_t)val, 8, hd, NULL);
++	    HashTableAddInt64(st->h, val, hd, NULL);
+ 	}
+     }
+ }
+@@ -88,7 +88,7 @@
+     } else if (st->h) {
+ 	HashItem *hi;
+ 
+-	if ((hi = HashTableSearch(st->h, (char *)(size_t)val, 8))) {
++	if ((hi = HashTableSearchInt64(st->h, val))) {
+ 	    if (--hi->data.i == 0)
+ 		HashTableDel(st->h, hi, 0);
+ 	} else {
+@@ -114,7 +114,7 @@
+ 	HashItem *hi;
+ 
+ 	while ((hi = HashTableIterNext(st->h, iter))) {
+-	    fprintf(stderr, "\t%d\t%d\n", (int)(size_t)hi->key,
++	    fprintf(stderr, "\t%d\t%d\n", (int)hi->key64,
+ 		    (int)hi->data.i);
+ 	}
+ 	HashTableIterDestroy(iter);
+@@ -171,7 +171,7 @@
+ 		if (!vals || !freqs)
+ 		    return E_HUFFMAN; // Cannot do much else atm
+ 	    }
+-	    i = (size_t)hi->key;
++	    i = hi->key64;
+ 	    vals[nvals]=i;
+ 	    freqs[nvals] = hi->data.i;
+ 	    ntot += freqs[nvals];
+--- staden-io-lib.orig/io_lib/hash_table.c
++++ staden-io-lib/io_lib/hash_table.c
+@@ -581,6 +581,49 @@
+     return hi;
+ }
+ 
++// Custom version of above for option HASH_INT_KEYS | HASH_NONVOLATILE_KEYS.
++// Needed on 32-bit platforms where we cannot shoehorn in a 64-bit integer
++// into a pointer.  The previous interface is still valid for 32-bit integer
++// keys.
++HashItem *HashTableAddInt64(HashTable *h, int64_t key, HashData data,
++			    int *new) {
++    uint64_t hv;
++    HashItem *hi;
++
++    if (!(h->options & HASH_INT_KEYS))
++        return NULL;
++    hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key))
++	& h->mask;
++
++    /* Already exists? */
++    if (!(h->options & HASH_ALLOW_DUP_KEYS)) {
++	for (hi = h->bucket[hv]; hi; hi = hi->next) {
++	    if (hi->key64 == key) {
++		if (new) *new = 0;
++		return hi;
++	    }
++	}
++    }
++
++    /* No, so create a new one and link it in */
++    if (NULL == (hi = HashItemCreate(h)))
++	return NULL;
++
++    hi->key64 = key;
++    hi->key_len = sizeof(key);
++    hi->data = data;
++    hi->next = h->bucket[hv];
++    h->bucket[hv] = hi;
++
++    if ((h->options & HASH_DYNAMIC_SIZE) &&
++	h->nused > HASH_TABLE_RESIZE * h->nbuckets)
++	HashTableResize(h, h->nbuckets*4);
++
++    if (new) *new = 1;
++
++    return hi;
++}
++
+ 
+ /*
+  * Removes a specified HashItem from the HashTable. (To perform this it needs
+@@ -685,6 +728,46 @@
+     return retval;
+ }
+ 
++int HashTableRemoveInt64(HashTable *h, int64_t key, int deallocate_data) {
++    uint64_t hv;
++    HashItem *last, *next, *hi;
++    int retval = -1;
++
++    if (!(h->options & HASH_INT_KEYS))
++	return -1;
++
++    hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key))
++	& h->mask;
++
++    last = NULL;
++    next = h->bucket[hv];
++
++    while (next) {
++	hi = next;
++	if (key == hi->key64) {
++	    /* An item to remove, adjust links and destroy */
++	    if (last)
++		last->next = hi->next;
++	    else
++		h->bucket[hv] = hi->next;
++
++	    next = hi->next;
++	    HashItemDestroy(h, hi, deallocate_data);
++
++	    retval = 0;
++	    if (!(h->options & HASH_ALLOW_DUP_KEYS))
++		break;
++
++	} else {
++	    /* We only update last when it's something we haven't destroyed */
++	    last = hi;
++	    next = hi->next;
++	}
++    }
++
++    return retval;
++}
++
+ /*
+  * Searches the HashTable for the data registered with 'key'.
+  * If HASH_ALLOW_DUP_KEYS is used this will just be the first one found.
+@@ -721,6 +804,29 @@
+     return NULL;
+ }
+ 
++// As per HashTableAddInt64 this is a custom search function for 64-bit
++// integer keys.  Only needed on 32-bit platforms where the char *key is
++// not large enough to hold a 64-bit integer.
++// Note: On 64-bit platforms calling this function still works, so it is
++// the preferred new API.
++HashItem *HashTableSearchInt64(HashTable *h, int64_t key) {
++    uint64_t hv;
++    HashItem *hi;
++
++    if (!(h->options & HASH_INT_KEYS))
++        return NULL;
++
++    hv = hash64(h->options & HASH_FUNC_MASK, (uint8_t *)&key, sizeof(key))
++	& h->mask;
++
++    for (hi = h->bucket[hv]; hi; hi = hi->next) {
++	if (key == hi->key64)
++	    return hi;
++    }
++
++    return NULL;
++}
++
+ /*
+  * Find the next HashItem (starting from 'hi') to also match this key.
+  * This is only valid when the HASH_ALLOW_DUP_KEYS is in use and
+@@ -753,6 +859,18 @@
+ 	    return hi;
+     }
+ 
++    return NULL;
++}
++
++HashItem *HashTableNextInt64(HashItem *hi, int64_t key) {
++    if (!hi)
++	return NULL;
++
++    for (hi = hi->next; hi; hi = hi->next) {
++	if (key == hi->key64)
++	    return hi;
++    }
++
+     return NULL;
+ }
+ 
+--- staden-io-lib.orig/io_lib/hash_table.h
++++ staden-io-lib/io_lib/hash_table.h
+@@ -54,10 +54,24 @@
+     void *p;
+ } HashData;
+ 
++/*
++ * The anonymous union below is strictly a C11 feature, but is supported
++ * by GNU99 and many other compilers.
++ *
++ * Adding an explicit name to the union changes the API.  The alternative
++ * is to have a non-union and explicit key and key64 both present, but
++ * that is costly.  It could be done for sizeof(char*)<64 only via an ifdef,
++ * which severely limits the likelihood of it being needed.  However we'll
++ * try the easy route to start with and see if this causes any problems.
++ */
++
+ /* A hash item with "next" pointer to use in a linked list */
+ typedef struct HashItemStruct {
+     HashData data;        /* user defined data attached to this key */
+-    char    *key;         /* key we hashed on */
++    union {
++      char    *key;       /* key we hashed on */
++      int64_t key64;
++    };
+     int      key_len;     /* and its length */
+     struct HashItemStruct *next;
+ } HashItem;
+@@ -171,11 +185,16 @@
+ int HashTableResize(HashTable *h, int newsize);
+ HashItem *HashTableAdd(HashTable *h, char *key, int key_len,
+ 		       HashData data, int *added);
++HashItem *HashTableAddInt64(HashTable *h, int64_t key,
++			    HashData data, int *added);
+ int HashTableDel(HashTable *h, HashItem *hi, int deallocate_data);
+ int HashTableRemove(HashTable *h, char *key, int key_len, int deallocate_data);
++int HashTableRemoveInt64(HashTable *h, int64_t key, int deallocate_data);
+ HashItem *HashTableSearch(HashTable *h, char *key, int key_len);
++HashItem *HashTableSearchInt64(HashTable *h, int64_t key);
+ HashItem *HashTableNext(HashItem *hi, char *key, int key_len);
+ HashItem *HashTableNextInt(HashItem *hi, char *key, int key_len);
++HashItem *HashTableNextInt64(HashItem *hi, int64_t key);
+ 
+ void HashTableStats(HashTable *h, FILE *fp);
+ void HashTableDump(HashTable *h, FILE *fp, char *prefix);


=====================================
debian/patches/series
=====================================
@@ -1,3 +1,4 @@
+32-bit.patch
 pathmax.patch
 fix_fseeko.patch
 spelling


=====================================
debian/rules
=====================================
@@ -32,12 +32,12 @@ override_dh_install-arch:
 		    --movedev "debian/tmp/usr/include" usr \
 	            --override s/libhtscodecs2-dev/libhtscodecs-dev/ \
 		    debian/tmp/usr/lib/*/$(libpkg).so
-	mkdir -p $(devpkg)/usr/include/io_lib/
-	cp $(CURDIR)/io_lib_config.h $(devpkg)/usr/include/io_lib/
+	mkdir -p $(CURDIR)/debian/$(devpkg)/usr/include/io_lib/
+	cp $(CURDIR)/io_lib_config.h $(CURDIR)/debian/$(devpkg)/usr/include/io_lib/
 	# make sure io_lib-config --libs will not return -pie (see  #825461)
 	find debian/*/usr/bin -name io_lib-config -exec sed -i -e 's/ *-fPIE//' -e 's/ *-pie//' \{\} \;
 
-override_dh_install-indep:
+override_dh_auto_test-indep:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
 	echo "Do not run test suite for architecture independent builds"
 endif



View it on GitLab: https://salsa.debian.org/med-team/staden-io-lib/-/compare/fa0aad23ca50419383469ed5e4b8bbc3c4aed25d...d84b652027d223b115750a7cf1472c93e37ba595

-- 
View it on GitLab: https://salsa.debian.org/med-team/staden-io-lib/-/compare/fa0aad23ca50419383469ed5e4b8bbc3c4aed25d...d84b652027d223b115750a7cf1472c93e37ba595
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20200728/04e22128/attachment-0001.html>


More information about the debian-med-commit mailing list