From 169f4f295d955471fdbac5ce91916d9f67fc5b97 Mon Sep 17 00:00:00 2001 From: Sunpoet Po-Chuan Hsieh Date: Sat, 19 Sep 2020 15:35:11 +0000 Subject: [PATCH] Use local patch file instead of PATCHFILES --- science/eccodes/Makefile | 3 - science/eccodes/distinfo | 4 +- science/eccodes/files/patch-src-grib_bits.c | 17 ++++ .../patch-src-grib_bits_fast_big_endian.c | 97 +++++++++++++++++++ 4 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 science/eccodes/files/patch-src-grib_bits.c create mode 100644 science/eccodes/files/patch-src-grib_bits_fast_big_endian.c diff --git a/science/eccodes/Makefile b/science/eccodes/Makefile index 7b9e602506f1..45acb4baed5f 100644 --- a/science/eccodes/Makefile +++ b/science/eccodes/Makefile @@ -8,9 +8,6 @@ CATEGORIES= science MASTER_SITES= https://confluence.ecmwf.int/download/attachments/45757960/ \ LOCAL/sunpoet -PATCH_SITES= https://github.com/ecmwf/eccodes/commit/ -PATCHFILES= 7a618fa90aaafa3a28cacae130939c3268e15876.patch:-p1 - MAINTAINER= sunpoet@FreeBSD.org COMMENT= ECMWF API for WMO FM-92 GRIB and FM-94 BUFR messages diff --git a/science/eccodes/distinfo b/science/eccodes/distinfo index b4656b7a8a0d..963c29fe64a8 100644 --- a/science/eccodes/distinfo +++ b/science/eccodes/distinfo @@ -1,5 +1,3 @@ -TIMESTAMP = 1599505171 +TIMESTAMP = 1600177154 SHA256 (eccodes-2.18.0-Source.tar.gz) = d88943df0f246843a1a062796edbf709ef911de7269648eef864be259e9704e3 SIZE (eccodes-2.18.0-Source.tar.gz) = 11525701 -SHA256 (7a618fa90aaafa3a28cacae130939c3268e15876.patch) = ec04900f721353aa5e1c02e6a2405e6fe9386c95dd5b18325c8865733a2f01d7 -SIZE (7a618fa90aaafa3a28cacae130939c3268e15876.patch) = 4301 diff --git a/science/eccodes/files/patch-src-grib_bits.c b/science/eccodes/files/patch-src-grib_bits.c new file mode 100644 index 000000000000..e4766a798558 --- /dev/null +++ b/science/eccodes/files/patch-src-grib_bits.c @@ -0,0 +1,17 @@ +Obtained from: https://github.com/ecmwf/eccodes/commit/7a618fa90aaafa3a28cacae130939c3268e15876 + +--- src/grib_bits.c.orig 2020-06-24 09:11:27 UTC ++++ src/grib_bits.c +@@ -30,6 +30,12 @@ long GRIB_MASK = -1; /* Mask of sword bits */ + ((b) == max_nbits ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits - ((q) + (b))))) + + ++#define VALUE_SIZE_T(p, q, b) \ ++ (((b) == max_nbits_size_t ? GRIB_MASK : ~(GRIB_MASK << (b))) & ((p) >> (max_nbits_size_t - ((q) + (b))))) ++ ++#define MASKVALUE_SIZE_T(q, b) \ ++ ((b) == max_nbits_size_t ? GRIB_MASK : (~(GRIB_MASK << (b)) << (max_nbits_size_t - ((q) + (b))))) ++ + static const unsigned long dmasks[] = { + 0xFF, + 0xFE, diff --git a/science/eccodes/files/patch-src-grib_bits_fast_big_endian.c b/science/eccodes/files/patch-src-grib_bits_fast_big_endian.c new file mode 100644 index 000000000000..8b79c3ad66b2 --- /dev/null +++ b/science/eccodes/files/patch-src-grib_bits_fast_big_endian.c @@ -0,0 +1,97 @@ +Obtained from: https://github.com/ecmwf/eccodes/commit/7a618fa90aaafa3a28cacae130939c3268e15876 + +--- src/grib_bits_fast_big_endian.c.orig 2020-06-24 09:11:27 UTC ++++ src/grib_bits_fast_big_endian.c +@@ -114,7 +114,6 @@ char* grib_decode_string(const unsigned char* bitStrea + return string; + } + +- + unsigned long grib_decode_unsigned_long(const unsigned char* p, long* bitp, long nbits) + { + long countOfLeftmostBits = 0, leftmostBits = 0; +@@ -146,6 +145,37 @@ unsigned long grib_decode_unsigned_long(const unsigned + return val; + } + ++size_t grib_decode_size_t(const unsigned char* p, long* bitp, long nbits) ++{ ++ long countOfLeftmostBits = 0, leftmostBits = 0; ++ long startBit = *bitp; ++ long remainingBits = nbits; ++ long* pp = (long*)p; ++ size_t val = 0; ++ ++ if (startBit >= max_nbits_size_t) { ++ pp += startBit / max_nbits_size_t; ++ startBit %= max_nbits_size_t; ++ } ++ ++ countOfLeftmostBits = startBit + remainingBits; ++ if (countOfLeftmostBits > max_nbits_size_t) { ++ countOfLeftmostBits = max_nbits_size_t - startBit; ++ remainingBits -= countOfLeftmostBits; ++ leftmostBits = (VALUE_SIZE_T(*pp, startBit, countOfLeftmostBits)) << remainingBits; ++ startBit = 0; ++ pp++; ++ } ++ else ++ leftmostBits = 0; ++ ++ val = leftmostBits + (VALUE_SIZE_T(*pp, startBit, remainingBits)); ++ ++ *bitp += nbits; ++ ++ return val; ++} ++ + int grib_encode_unsigned_long(unsigned char* p, unsigned long val, long* bitp, long nbits) + { + long* destination = (long*)p; +@@ -184,6 +214,46 @@ int grib_encode_unsigned_longb(unsigned char* p, unsig + { + return grib_encode_unsigned_long(p, val, bitp, nbits); + } ++ ++int grib_encode_size_t(unsigned char* p, size_t val, long* bitp, long nbits) ++{ ++ long* destination = (long*)p; ++ long countOfLeftmostBits = 0, nextWord = 0, startBit = 0, remainingBits = 0, rightmostBits = 0; ++ ++ startBit = *bitp; ++ remainingBits = nbits; ++ ++ if (startBit >= max_nbits_size_t) { ++ nextWord = startBit / max_nbits_size_t; ++ startBit %= max_nbits_size_t; ++ } ++ else ++ nextWord = 0; ++ ++ countOfLeftmostBits = startBit + remainingBits; ++ if (countOfLeftmostBits > max_nbits_size_t) { ++ countOfLeftmostBits = max_nbits_size_t - startBit; ++ startBit = max_nbits_size_t - remainingBits; ++ remainingBits -= countOfLeftmostBits; ++ destination[nextWord] = ++ ((destination[nextWord] >> countOfLeftmostBits) << countOfLeftmostBits) + (VALUE_SIZE_T(val, startBit, countOfLeftmostBits)); ++ startBit = 0; ++ nextWord++; ++ } ++ ++ rightmostBits = VALUE_SIZE_T(val, max_nbits_size_t - remainingBits, remainingBits); ++ destination[nextWord] = ++ (destination[nextWord] & ~MASKVALUE_SIZE_T(startBit, remainingBits)) + (rightmostBits << max_nbits_size_t - (remainingBits + startBit)); ++ ++ *bitp += nbits; ++ return GRIB_SUCCESS; ++} ++ ++int grib_encode_size_tb(unsigned char* p, size_t val, long* bitp, long nbits) ++{ ++ return grib_encode_size_t(p, val, bitp, nbits); ++} ++ + + #if VECTOR + #include "grib_bits_fast_big_endian_vector.c" /* Experimental */