diff options
author | joerg <joerg@pkgsrc.org> | 2014-10-06 14:57:53 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2014-10-06 14:57:53 +0000 |
commit | be4dd9e88e099d27ec3024c7533e53ccb5148436 (patch) | |
tree | 522d1dfd3bb6855c5a114d99e33c8b1920f0877f /pkgtools/cwrappers | |
parent | fdd5b93c532fd60074acb9d0952c098de17b7d6f (diff) | |
download | pkgsrc-be4dd9e88e099d27ec3024c7533e53ccb5148436.tar.gz |
OSX 9 lacks getline, so add it to the list. Use custom version of
le32toh.
Diffstat (limited to 'pkgtools/cwrappers')
-rw-r--r-- | pkgtools/cwrappers/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/cwrappers/files/bin/mi_vector_hash.c | 30 |
2 files changed, 21 insertions, 13 deletions
diff --git a/pkgtools/cwrappers/Makefile b/pkgtools/cwrappers/Makefile index e71fabe8f79..06176ea2433 100644 --- a/pkgtools/cwrappers/Makefile +++ b/pkgtools/cwrappers/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.1 2014/09/17 12:40:56 joerg Exp $ +# $NetBSD: Makefile,v 1.2 2014/10/06 14:57:53 joerg Exp $ PKGNAME= cwrappers-20100308 CATEGORIES= pkgtools sysutils @@ -18,7 +18,7 @@ INSTALLATION_DIRS= libexec/cwrappers .if ${OPSYS} != "NetBSD" || !empty(MACHINE_PLATFORM:MNetBSD-[0-5].*) MAKE_ENV+= NEED_MI_VECTOR_HASH=1 .endif -.if !empty(MACHINE_PLATFORM:MDarwin-10.*) +.if !empty(MACHINE_PLATFORM:MDarwin-9.*) || !empty(MACHINE_PLATFORM:MDarwin-10.*) MAKE_ENV+= NEED_GETLINE=1 .endif diff --git a/pkgtools/cwrappers/files/bin/mi_vector_hash.c b/pkgtools/cwrappers/files/bin/mi_vector_hash.c index 12886ab4cc6..33c9bab1ec5 100644 --- a/pkgtools/cwrappers/files/bin/mi_vector_hash.c +++ b/pkgtools/cwrappers/files/bin/mi_vector_hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: mi_vector_hash.c,v 1.1 2014/09/17 12:40:56 joerg Exp $ */ +/* $NetBSD: mi_vector_hash.c,v 1.2 2014/10/06 14:57:53 joerg Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,7 +40,7 @@ #include <nbcompat.h> #include <nbcompat/cdefs.h> -__RCSID("$NetBSD: mi_vector_hash.c,v 1.1 2014/09/17 12:40:56 joerg Exp $"); +__RCSID("$NetBSD: mi_vector_hash.c,v 1.2 2014/10/06 14:57:53 joerg Exp $"); #include <nbcompat/endian.h> #include <stdint.h> @@ -64,6 +64,14 @@ my_le32dec(const void *buf) return (my_le16dec(p) | ((uint32_t)my_le16dec(p + 2) << 16)); } +static uint32_t +my_le32toh(uint32_t val) +{ + uint8_t buf[4]; + memcpy(buf, &val, sizeof(buf)); + return my_le32dec(buf); +} + #define mix(a, b, c) do { \ a -= b; a -= c; a ^= (c >> 13); \ b -= c; b -= a; b ^= (a << 8); \ @@ -153,9 +161,9 @@ mi_vector_hash(const void *key, size_t len, uint32_t seed, uint32_t hashes[3]) } else { const uint32_t *key32 = key; while (len >= 12) { - a += le32toh(key32[0]); - b += le32toh(key32[1]); - c += le32toh(key32[2]); + a += my_le32toh(key32[0]); + b += my_le32toh(key32[1]); + c += my_le32toh(key32[2]); mix(a, b, c); key32 += 3; len -= 12; @@ -163,14 +171,14 @@ mi_vector_hash(const void *key, size_t len, uint32_t seed, uint32_t hashes[3]) c += orig_len; if (len > 8) { - c += (le32toh(key32[2]) & mask[len - 9]) << 8; - b += le32toh(key32[1]); - a += le32toh(key32[0]); + c += (my_le32toh(key32[2]) & mask[len - 9]) << 8; + b += my_le32toh(key32[1]); + a += my_le32toh(key32[0]); } else if (len > 4) { - b += le32toh(key32[1]) & mask[len - 5]; - a += le32toh(key32[0]); + b += my_le32toh(key32[1]) & mask[len - 5]; + a += my_le32toh(key32[0]); } else if (len) - a += le32toh(key32[0]) & mask[len - 1]; + a += my_le32toh(key32[0]) & mask[len - 1]; } mix(a, b, c); hashes[0] = a; |