From b5e59140cbc69a0b5cf70669e01affe1f1b201ed Mon Sep 17 00:00:00 2001 From: Michael Spector Date: Thu, 19 Mar 2020 08:06:04 +0200 Subject: [PATCH] Upgrade Avro to 1.9.2 release (#10380) * Upgrade Avro to 1.9.2 release * Apply CR fixes * Applied CR recommendations --- ports/avro-c/CONTROL | 3 +- ports/avro-c/avro-pr-217.patch | 421 ------------------ ports/avro-c/avro.patch | 174 +++++--- ports/avro-c/fix-build-error.patch | 20 - ports/avro-c/portfile.cmake | 16 +- .../{snappy.patch => snappy-pr-793.patch} | 100 ++--- 6 files changed, 162 insertions(+), 572 deletions(-) delete mode 100644 ports/avro-c/avro-pr-217.patch delete mode 100644 ports/avro-c/fix-build-error.patch rename ports/avro-c/{snappy.patch => snappy-pr-793.patch} (91%) diff --git a/ports/avro-c/CONTROL b/ports/avro-c/CONTROL index 196c8936e56..10cef30fae3 100644 --- a/ports/avro-c/CONTROL +++ b/ports/avro-c/CONTROL @@ -1,5 +1,6 @@ Source: avro-c -Version: 1.8.2-4 +Version: 1.9.2 +Supports: !(uwp|linux|osx) Homepage: https://github.com/apache/avro Description: Apache Avro is a data serialization system Build-Depends: jansson, liblzma, zlib, snappy diff --git a/ports/avro-c/avro-pr-217.patch b/ports/avro-c/avro-pr-217.patch deleted file mode 100644 index 9a5ddd3a855..00000000000 --- a/ports/avro-c/avro-pr-217.patch +++ /dev/null @@ -1,421 +0,0 @@ -diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c -index 3ade1140e..97e3ff354 100644 ---- a/lang/c/src/schema.c -+++ b/lang/c/src/schema.c -@@ -2,17 +2,17 @@ - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. -- * The ASF licenses this file to you under the Apache License, Version 2.0 -+ * The ASF licenses this file to you under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at -- * -+ * - * http://www.apache.org/licenses/LICENSE-2.0 -- * -+ * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied. See the License for the specific language governing -- * permissions and limitations under the License. -+ * permissions and limitations under the License. - */ - - #include "avro/allocation.h" -@@ -61,7 +61,7 @@ static int is_avro_id(const char *name) - } - } - /* -- * starts with [A-Za-z_] subsequent [A-Za-z0-9_] -+ * starts with [A-Za-z_] subsequent [A-Za-z0-9_] - */ - return 1; - } -@@ -199,7 +199,13 @@ static void avro_schema_free(avro_schema_t schema) - case AVRO_LINK:{ - struct avro_link_schema_t *link; - link = avro_schema_to_link(schema); -- avro_schema_decref(link->to); -+ /* Since we didn't increment the -+ * reference count of the target -+ * schema when we created the link, we -+ * should not decrement the reference -+ * count of the target schema when we -+ * free the link. -+ */ - avro_freet(struct avro_link_schema_t, link); - } - break; -@@ -727,7 +733,19 @@ avro_schema_t avro_schema_link(avro_schema_t to) - avro_set_error("Cannot allocate new link schema"); - return NULL; - } -- link->to = avro_schema_incref(to); -+ -+ /* Do not increment the reference count of target schema -+ * pointed to by the AVRO_LINK. AVRO_LINKs are only valid -+ * internal to a schema. The target schema pointed to by a -+ * link will be valid as long as the top-level schema is -+ * valid. Similarly, the link will be valid as long as the -+ * top-level schema is valid. Therefore the validity of the -+ * link ensures the validity of its target, and we don't need -+ * an additional reference count on the target. This mechanism -+ * of an implied validity also breaks reference count cycles -+ * for recursive schemas, which result in memory leaks. -+ */ -+ link->to = to; - avro_schema_init(&link->obj, AVRO_LINK); - return &link->obj; - } -@@ -807,7 +825,7 @@ avro_type_from_json_t(json_t *json, avro_type_t *type, - return EINVAL; - } - /* -- * TODO: gperf/re2c this -+ * TODO: gperf/re2c this - */ - if (strcmp(type_str, "string") == 0) { - *type = AVRO_STRING; -@@ -1259,7 +1277,7 @@ avro_schema_from_json_length(const char *jsontext, size_t length, - return avro_schema_from_json_root(root, schema); - } - --avro_schema_t avro_schema_copy(avro_schema_t schema) -+avro_schema_t avro_schema_copy_root(avro_schema_t schema, st_table *named_schemas) - { - long i; - avro_schema_t new_schema = NULL; -@@ -1276,7 +1294,7 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - case AVRO_BOOLEAN: - case AVRO_NULL: - /* -- * No need to copy primitives since they're static -+ * No need to copy primitives since they're static - */ - new_schema = schema; - break; -@@ -1288,6 +1306,10 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - new_schema = - avro_schema_record(record_schema->name, - record_schema->space); -+ if (save_named_schemas(new_schema, named_schemas)) { -+ avro_set_error("Cannot save enum schema"); -+ return NULL; -+ } - for (i = 0; i < record_schema->fields->num_entries; i++) { - union { - st_data_t data; -@@ -1295,10 +1317,11 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - } val; - st_lookup(record_schema->fields, i, &val.data); - avro_schema_t type_copy = -- avro_schema_copy(val.field->type); -+ avro_schema_copy_root(val.field->type, named_schemas); - avro_schema_record_field_append(new_schema, - val.field->name, - type_copy); -+ avro_schema_decref(type_copy); - } - } - break; -@@ -1309,6 +1332,10 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - avro_schema_to_enum(schema); - new_schema = avro_schema_enum_ns(enum_schema->name, - enum_schema->space); -+ if (save_named_schemas(new_schema, named_schemas)) { -+ avro_set_error("Cannot save enum schema"); -+ return NULL; -+ } - for (i = 0; i < enum_schema->symbols->num_entries; i++) { - union { - st_data_t data; -@@ -1329,6 +1356,10 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - avro_schema_fixed_ns(fixed_schema->name, - fixed_schema->space, - fixed_schema->size); -+ if (save_named_schemas(new_schema, named_schemas)) { -+ avro_set_error("Cannot save fixed schema"); -+ return NULL; -+ } - } - break; - -@@ -1337,11 +1368,12 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - struct avro_map_schema_t *map_schema = - avro_schema_to_map(schema); - avro_schema_t values_copy = -- avro_schema_copy(map_schema->values); -+ avro_schema_copy_root(map_schema->values, named_schemas); - if (!values_copy) { - return NULL; - } - new_schema = avro_schema_map(values_copy); -+ avro_schema_decref(values_copy); - } - break; - -@@ -1350,11 +1382,12 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - struct avro_array_schema_t *array_schema = - avro_schema_to_array(schema); - avro_schema_t items_copy = -- avro_schema_copy(array_schema->items); -+ avro_schema_copy_root(array_schema->items, named_schemas); - if (!items_copy) { - return NULL; - } - new_schema = avro_schema_array(items_copy); -+ avro_schema_decref(items_copy); - } - break; - -@@ -1372,12 +1405,13 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - avro_schema_t schema; - } val; - st_lookup(union_schema->branches, i, &val.data); -- schema_copy = avro_schema_copy(val.schema); -+ schema_copy = avro_schema_copy_root(val.schema, named_schemas); - if (avro_schema_union_append - (new_schema, schema_copy)) { - avro_schema_decref(new_schema); - return NULL; - } -+ avro_schema_decref(schema_copy); - } - } - break; -@@ -1386,12 +1420,12 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - { - struct avro_link_schema_t *link_schema = - avro_schema_to_link(schema); -- /* -- * TODO: use an avro_schema_copy of to instead of pointing to -- * the same reference -- */ -- avro_schema_incref(link_schema->to); -- new_schema = avro_schema_link(link_schema->to); -+ avro_schema_t to; -+ -+ to = find_named_schemas(avro_schema_name(link_schema->to), -+ avro_schema_namespace(link_schema->to), -+ named_schemas); -+ new_schema = avro_schema_link(to); - } - break; - -@@ -1401,6 +1435,23 @@ avro_schema_t avro_schema_copy(avro_schema_t schema) - return new_schema; - } - -+avro_schema_t avro_schema_copy(avro_schema_t schema) -+{ -+ avro_schema_t new_schema; -+ st_table *named_schemas; -+ -+ named_schemas = st_init_strtable_with_size(DEFAULT_TABLE_SIZE); -+ if (!named_schemas) { -+ avro_set_error("Cannot allocate named schema map"); -+ return NULL; -+ } -+ -+ new_schema = avro_schema_copy_root(schema, named_schemas); -+ st_foreach(named_schemas, HASH_FUNCTION_CAST named_schema_free_foreach, 0); -+ st_free_table(named_schemas); -+ return new_schema; -+} -+ - avro_schema_t avro_schema_get_subschema(const avro_schema_t schema, - const char *name) - { -diff --git a/lang/c/tests/CMakeLists.txt b/lang/c/tests/CMakeLists.txt -index 445e689a7..0870ef5ec 100644 ---- a/lang/c/tests/CMakeLists.txt -+++ b/lang/c/tests/CMakeLists.txt -@@ -48,12 +48,14 @@ add_avro_test(test_data_structures) - add_avro_test(test_avro_schema) - add_avro_test(test_avro_schema_names) - add_avro_test(test_avro_values) -+add_avro_test(test_avro_766) - add_avro_test(test_avro_968) - add_avro_test(test_avro_984) - add_avro_test(test_avro_1034) - add_avro_test(test_avro_1084) - add_avro_test(test_avro_1087) - add_avro_test(test_avro_1165) -+add_avro_test(test_avro_1167) - add_avro_test(test_avro_1237) - add_avro_test(test_avro_1238) - add_avro_test(test_avro_1279) -diff --git a/lang/c/tests/test_avro_1167.c b/lang/c/tests/test_avro_1167.c -new file mode 100644 -index 000000000..869b37d17 ---- /dev/null -+++ b/lang/c/tests/test_avro_1167.c -@@ -0,0 +1,84 @@ -+/* -+ * Licensed to the Apache Software Foundation (ASF) under one or more -+ * contributor license agreements. See the NOTICE file distributed with -+ * this work for additional information regarding copyright ownership. -+ * The ASF licenses this file to you under the Apache License, Version 2.0 -+ * (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -+ * implied. See the License for the specific language governing -+ * permissions and limitations under the License. -+ */ -+ -+#include -+#include -+#include -+ -+/* To see the AVRO-1167 memory leak, run this test program through -+ * valgrind. The specific valgrind commandline to use from the -+ * avro-trunk/lang/c/tests directory is: -+ * valgrind -v --track-origins=yes --leak-check=full -+ * --show-reachable = yes ../build/tests/test_avro_1167 -+ */ -+ -+int main(int argc, char **argv) -+{ -+ const char *json = -+ "{" -+ " \"name\": \"repeated_subrecord_array\"," -+ " \"type\": \"record\"," -+ " \"fields\": [" -+ " { \"name\": \"subrecord_one\"," -+ " \"type\": {" -+ " \"name\": \"SubrecordType\"," -+ " \"type\": \"record\"," -+ " \"fields\": [" -+ " { \"name\": \"x\", \"type\": \"int\" }," -+ " { \"name\": \"y\", \"type\": \"int\" }" -+ " ]" -+ " }" -+ " }," -+ " { \"name\": \"subrecord_two\", \"type\": \"SubrecordType\" }," -+ " { \"name\": \"subrecord_array\", \"type\": {" -+ " \"type\":\"array\"," -+ " \"items\": \"SubrecordType\"" -+ " }" -+ " }" -+ " ]" -+ "}"; -+ -+ int rval; -+ avro_schema_t schema = NULL; -+ avro_schema_t schema_copy = NULL; -+ avro_schema_error_t error; -+ -+ (void) argc; -+ (void) argv; -+ -+ rval = avro_schema_from_json(json, strlen(json), &schema, &error); -+ if ( rval ) -+ { -+ printf("Failed to read schema from JSON.\n"); -+ exit(EXIT_FAILURE); -+ } -+ else -+ { -+ printf("Successfully read schema from JSON.\n"); -+ } -+ -+ schema_copy = avro_schema_copy( schema ); -+ if ( ! avro_schema_equal(schema, schema_copy) ) -+ { -+ printf("Failed avro_schema_equal(schema, schema_copy)\n"); -+ exit(EXIT_FAILURE); -+ } -+ -+ avro_schema_decref(schema); -+ avro_schema_decref(schema_copy); -+ return 0; -+} -diff --git a/lang/c/tests/test_avro_766.c b/lang/c/tests/test_avro_766.c -new file mode 100755 -index 000000000..4e21368c4 ---- /dev/null -+++ b/lang/c/tests/test_avro_766.c -@@ -0,0 +1,76 @@ -+/* -+ * Licensed to the Apache Software Foundation (ASF) under one or more -+ * contributor license agreements. See the NOTICE file distributed with -+ * this work for additional information regarding copyright ownership. -+ * The ASF licenses this file to you under the Apache License, Version 2.0 -+ * (the "License"); you may not use this file except in compliance with -+ * the License. You may obtain a copy of the License at -+ * -+ * http://www.apache.org/licenses/LICENSE-2.0 -+ * -+ * Unless required by applicable law or agreed to in writing, software -+ * distributed under the License is distributed on an "AS IS" BASIS, -+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -+ * implied. See the License for the specific language governing -+ * permissions and limitations under the License. -+ */ -+ -+#include -+#include -+#include -+ -+/* To see the AVRO-766 memory leak, run this test program through -+ * valgrind. The specific valgrind commandline to use from the -+ * avro-trunk/lang/c/tests directory is: -+ * valgrind -v --track-origins=yes --leak-check=full -+ * --show-reachable = yes ../build/tests/test_avro_766 -+ */ -+int main(int argc, char **argv) -+{ -+ const char *json = -+ "{" -+ " \"type\": \"record\"," -+ " \"name\": \"list\"," -+ " \"fields\": [" -+ " { \"name\": \"x\", \"type\": \"int\" }," -+ " { \"name\": \"y\", \"type\": \"int\" }," -+ " { \"name\": \"next\", \"type\": [\"null\",\"list\"]}," -+ " { \"name\": \"arraylist\", \"type\": { \"type\":\"array\", \"items\": \"list\" } }" -+ " ]" -+ "}"; -+ -+ int rval; -+ avro_schema_t schema = NULL; -+ avro_schema_error_t error; -+ -+ (void) argc; -+ (void) argv; -+ -+ rval = avro_schema_from_json(json, strlen(json), &schema, &error); -+ if ( rval ) -+ { -+ printf("Failed to read schema from JSON.\n"); -+ exit(EXIT_FAILURE); -+ } -+ else -+ { -+ printf("Successfully read schema from JSON.\n"); -+ } -+ -+#define TEST_AVRO_1167 (1) -+ #if TEST_AVRO_1167 -+ { -+ avro_schema_t schema_copy = NULL; -+ schema_copy = avro_schema_copy( schema ); -+ if ( ! avro_schema_equal(schema, schema_copy) ) -+ { -+ printf("Failed avro_schema_equal(schema, schema_copy)\n"); -+ exit(EXIT_FAILURE); -+ } -+ avro_schema_decref(schema_copy); -+ } -+ #endif -+ -+ avro_schema_decref(schema); -+ return 0; -+} diff --git a/ports/avro-c/avro.patch b/ports/avro-c/avro.patch index 50c32a6d3c4..ffaa93624e0 100644 --- a/ports/avro-c/avro.patch +++ b/ports/avro-c/avro.patch @@ -1,16 +1,8 @@ -diff -ur a/lang/c/CMakeLists.txt b/lang/c/CMakeLists.txt ---- a/lang/c/CMakeLists.txt 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/CMakeLists.txt 2017-11-12 20:03:13.776973800 -0500 -@@ -50,7 +50,7 @@ - else(UNIX) - # Hard code for win32 -- need to figure out how to port version.sh for - # Windows. -- set(LIBAVRO_VERSION "22:0:0") -+ set(LIBAVRO_VERSION "23:0:0") - endif(UNIX) - - -@@ -151,25 +151,24 @@ +diff --git a/lang/c/CMakeLists.txt b/lang/c/CMakeLists.txt +index 11cbf018..1bef3ba2 100644 +--- a/lang/c/CMakeLists.txt ++++ b/lang/c/CMakeLists.txt +@@ -161,27 +161,27 @@ else (SNAPPY_FOUND AND ZLIB_FOUND) message("Disabled snappy codec. libsnappy not found or zlib not found.") endif (SNAPPY_FOUND AND ZLIB_FOUND) @@ -43,10 +35,14 @@ diff -ur a/lang/c/CMakeLists.txt b/lang/c/CMakeLists.txt +find_package(JANSSON REQUIRED) if (JANSSON_FOUND) set(JANSSON_PKG libjansson) - include_directories(${JANSSON_INCLUDE_DIR}) -diff -ur a/lang/c/examples/quickstop.c b/lang/c/examples/quickstop.c ---- a/lang/c/examples/quickstop.c 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/examples/quickstop.c 2017-11-10 12:40:59.151301400 -0500 ++ set(JANSSON_LIBRARIES jansson::jansson) + include_directories(${JANSSON_INCLUDE_DIRS}) + link_directories(${JANSSON_LIBRARY_DIRS}) + else (JANSSON_FOUND) +diff --git a/lang/c/examples/quickstop.c b/lang/c/examples/quickstop.c +index f18225b7..78e2b1b8 100644 +--- a/lang/c/examples/quickstop.c ++++ b/lang/c/examples/quickstop.c @@ -16,6 +16,7 @@ */ @@ -55,7 +51,7 @@ diff -ur a/lang/c/examples/quickstop.c b/lang/c/examples/quickstop.c #include #include -@@ -102,7 +103,7 @@ +@@ -102,7 +103,7 @@ int print_person(avro_file_reader_t db, avro_schema_t reader_schema) if (avro_record_get(person, "ID", &id_datum) == 0) { avro_int64_get(id_datum, &i64); @@ -64,29 +60,32 @@ diff -ur a/lang/c/examples/quickstop.c b/lang/c/examples/quickstop.c } if (avro_record_get(person, "First", &first_datum) == 0) { avro_string_get(first_datum, &p); -diff -ur a/lang/c/src/avro/msinttypes.h b/lang/c/src/avro/msinttypes.h ---- a/lang/c/src/avro/msinttypes.h 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/avro/msinttypes.h 2017-11-10 12:37:30.372271300 -0500 -@@ -54,6 +54,9 @@ +diff --git a/lang/c/src/avro/msinttypes.h b/lang/c/src/avro/msinttypes.h +index 29be14b9..7efc7026 100644 +--- a/lang/c/src/avro/msinttypes.h ++++ b/lang/c/src/avro/msinttypes.h +@@ -54,6 +54,10 @@ // 7.8 Format conversion of integer types +#if (_MSC_VER >= 1900) +# include +#else ++ typedef struct { intmax_t quot; intmax_t rem; -@@ -311,5 +314,6 @@ +@@ -311,5 +315,6 @@ imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom) #define wcstoimax _wcstoi64 #define wcstoumax _wcstoui64 -+#endif ++#endif // (_MSC_VER >= 1900) #endif // _MSC_INTTYPES_H_ ] -diff -ur a/lang/c/src/avro/msstdint.h b/lang/c/src/avro/msstdint.h ---- a/lang/c/src/avro/msstdint.h 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/avro/msstdint.h 2017-11-10 10:44:14.011482500 -0500 +diff --git a/lang/c/src/avro/msstdint.h b/lang/c/src/avro/msstdint.h +index d02608a5..54e8972c 100644 +--- a/lang/c/src/avro/msstdint.h ++++ b/lang/c/src/avro/msstdint.h @@ -42,6 +42,10 @@ #include @@ -98,28 +97,45 @@ diff -ur a/lang/c/src/avro/msstdint.h b/lang/c/src/avro/msstdint.h // For Visual Studio 6 in C++ mode and for many Visual Studio versions when // compiling for ARM we should wrap include with 'extern "C++" {}' // or compiler give many errors like this: -@@ -243,5 +247,6 @@ +@@ -243,5 +247,6 @@ typedef uint64_t uintmax_t; #endif // __STDC_CONSTANT_MACROS ] -+#endif // _MSC_VER < 1900 ++#endif // (_MSC_VER >= 1900) #endif // _MSC_STDINT_H_ ] -diff -ur a/lang/c/src/avro_private.h b/lang/c/src/avro_private.h ---- a/lang/c/src/avro_private.h 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/avro_private.h 2017-11-10 10:32:33.414879700 -0500 -@@ -34,7 +34,7 @@ +diff --git a/lang/c/src/avro/platform.h b/lang/c/src/avro/platform.h +index 92930550..edfe1e05 100644 +--- a/lang/c/src/avro/platform.h ++++ b/lang/c/src/avro/platform.h +@@ -35,8 +35,10 @@ extern "C" { + // Defines for printing size_t. + #if defined(_WIN64) + #define PRIsz PRIu64 ++ typedef __int64 ssize_t; + #elif defined(_WIN32) + #define PRIsz PRIu32 ++ typedef long ssize_t; + #else // GCC + #define PRIsz "zu" + #endif +diff --git a/lang/c/src/avro_private.h b/lang/c/src/avro_private.h +index f97ef6b5..6b291048 100644 +--- a/lang/c/src/avro_private.h ++++ b/lang/c/src/avro_private.h +@@ -34,7 +34,7 @@ extern "C" { #endif #ifdef _WIN32 -#define snprintf _snprintf -+ //#define snprintf _snprintf ++ // #define snprintf _snprintf #endif /* Note that AVRO_PLATFORM_IS_BIG_ENDIAN is *always* defined. It is -diff -ur a/lang/c/src/avroappend.c b/lang/c/src/avroappend.c ---- a/lang/c/src/avroappend.c 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/avroappend.c 2017-11-10 12:15:14.878275800 -0500 +diff --git a/lang/c/src/avroappend.c b/lang/c/src/avroappend.c +index 7243c600..39656ff4 100644 +--- a/lang/c/src/avroappend.c ++++ b/lang/c/src/avroappend.c @@ -20,7 +20,7 @@ #include #include @@ -129,10 +145,11 @@ diff -ur a/lang/c/src/avroappend.c b/lang/c/src/avroappend.c #endif #include "avro.h" -diff -ur a/lang/c/src/codec.c b/lang/c/src/codec.c ---- a/lang/c/src/codec.c 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/codec.c 2017-11-10 11:09:08.033816100 -0500 -@@ -266,7 +266,7 @@ +diff --git a/lang/c/src/codec.c b/lang/c/src/codec.c +index 5b55b351..49789f2b 100644 +--- a/lang/c/src/codec.c ++++ b/lang/c/src/codec.c +@@ -269,7 +269,7 @@ static int encode_deflate(avro_codec_t c, void * data, int64_t len) s->next_in = (Bytef*)data; s->avail_in = (uInt)len; @@ -141,7 +158,7 @@ diff -ur a/lang/c/src/codec.c b/lang/c/src/codec.c s->avail_out = (uInt)c->block_size; s->total_out = 0; -@@ -310,10 +310,10 @@ +@@ -313,10 +313,10 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len) c->used_size = 0; @@ -154,7 +171,7 @@ diff -ur a/lang/c/src/codec.c b/lang/c/src/codec.c s->avail_out = c->block_size; s->total_out = 0; -@@ -334,7 +334,7 @@ +@@ -337,7 +337,7 @@ static int decode_deflate(avro_codec_t c, void * data, int64_t len) if (err == Z_BUF_ERROR) { c->block_data = avro_realloc(c->block_data, c->block_size, c->block_size * 2); @@ -163,30 +180,31 @@ diff -ur a/lang/c/src/codec.c b/lang/c/src/codec.c s->avail_out += c->block_size; c->block_size = c->block_size * 2; } -@@ -437,7 +437,7 @@ +@@ -440,7 +440,7 @@ static int encode_lzma(avro_codec_t codec, void * data, int64_t len) return 1; } - ret = lzma_raw_buffer_encode(filters, NULL, data, len, codec->block_data, &written, codec->block_size); -+ ret = lzma_raw_buffer_encode(filters, NULL, (const uint8_t *)data, len, (uint8_t *)codec->block_data, &written, codec->block_size); ++ ret = lzma_raw_buffer_encode(filters, NULL, (const uint8_t*)data, len, (uint8_t*)codec->block_data, &written, codec->block_size); codec->used_size = written; -@@ -468,8 +468,8 @@ +@@ -471,8 +471,8 @@ static int decode_lzma(avro_codec_t codec, void * data, int64_t len) do { - ret = lzma_raw_buffer_decode(filters, NULL, data, - &read_pos, len, codec->block_data, &write_pos, -+ ret = lzma_raw_buffer_decode(filters, NULL, (const uint8_t *)data, -+ &read_pos, len, (uint8_t *)codec->block_data, &write_pos, ++ ret = lzma_raw_buffer_decode(filters, NULL, (const uint8_t*)data, ++ &read_pos, len, (uint8_t*)codec->block_data, &write_pos, codec->block_size); codec->used_size = write_pos; -diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c ---- a/lang/c/src/schema.c 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/src/schema.c 2017-11-10 11:45:45.268458000 -0500 -@@ -74,7 +74,7 @@ +diff --git a/lang/c/src/schema.c b/lang/c/src/schema.c +index 7b389002..50fa0db6 100644 +--- a/lang/c/src/schema.c ++++ b/lang/c/src/schema.c +@@ -74,7 +74,7 @@ static int is_avro_id(const char *name) * namespace (as a newly allocated buffer using Avro's allocator). */ static char *split_namespace_name(const char *fullname, const char **name_out) { @@ -195,7 +213,7 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c if (last_dot == NULL) { *name_out = fullname; return NULL; -@@ -742,12 +742,12 @@ +@@ -770,12 +770,12 @@ avro_schema_t avro_schema_link_target(avro_schema_t schema) } static const char * @@ -212,7 +230,7 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c } else { full_name = avro_strdup(name); } -@@ -758,20 +758,20 @@ +@@ -786,20 +786,20 @@ static int save_named_schemas(const avro_schema_t schema, st_table *st) { const char *name = avro_schema_name(schema); @@ -237,7 +255,7 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c int rval = st_lookup(st, (st_data_t) full_name, &(val.data)); avro_str_free((char *)full_name); if (rval) { -@@ -784,7 +784,7 @@ +@@ -812,7 +812,7 @@ find_named_schemas(const char *name, const char *namespace, st_table *st) static int avro_type_from_json_t(json_t *json, avro_type_t *type, st_table *named_schemas, avro_schema_t *named_type, @@ -246,7 +264,7 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c { json_t *json_type; const char *type_str; -@@ -835,7 +835,7 @@ +@@ -863,7 +863,7 @@ avro_type_from_json_t(json_t *json, avro_type_t *type, *type = AVRO_MAP; } else if (strcmp(type_str, "fixed") == 0) { *type = AVRO_FIXED; @@ -255,7 +273,7 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c *type = AVRO_LINK; } else { avro_set_error("Unknown Avro \"type\": %s", type_str); -@@ -930,12 +930,12 @@ +@@ -954,15 +954,15 @@ avro_schema_from_json_t(json_t *json, avro_schema_t *schema, } if (strchr(fullname, '.')) { @@ -267,13 +285,18 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c + avro_str_free(namespaceX); } else if (json_is_string(json_namespace)) { - const char *namespace = json_string_value(json_namespace); -- *schema = avro_schema_record(fullname, namespace); +- if (strlen(namespace) == 0) { +- namespace = NULL; + const char *namespaceX = json_string_value(json_namespace); ++ if (strlen(namespaceX) == 0) { ++ namespaceX = NULL; + } +- *schema = avro_schema_record(fullname, namespace); + *schema = avro_schema_record(fullname, namespaceX); } else { *schema = avro_schema_record(fullname, parent_namespace); } -@@ -1026,13 +1026,13 @@ +@@ -1053,16 +1053,16 @@ avro_schema_from_json_t(json_t *json, avro_schema_t *schema, } if (strchr(fullname, '.')) { @@ -282,18 +305,23 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c - *schema = avro_schema_enum_ns(name, namespace); - avro_str_free(namespace); + char *namespaceX; -+ namespaceX = split_namespace_name(fullname, &name); ++ namespaceX = split_namespace_name(fullname, &name); + *schema = avro_schema_enum_ns(name, namespaceX); + avro_str_free(namespaceX); } else if (json_is_string(json_namespace)) { - const char *namespace = json_string_value(json_namespace); -- *schema = avro_schema_enum_ns(fullname, namespace); +- if (strlen(namespace) == 0) { +- namespace = NULL; + const char *namespaceX = json_string_value(json_namespace); ++ if (strlen(namespaceX) == 0) { ++ namespaceX = NULL; + } +- *schema = avro_schema_enum_ns(fullname, namespace); + *schema = avro_schema_enum_ns(fullname, namespaceX); } else { *schema = avro_schema_enum_ns(fullname, parent_namespace); } -@@ -1160,13 +1160,13 @@ +@@ -1190,16 +1190,16 @@ avro_schema_from_json_t(json_t *json, avro_schema_t *schema, fullname = json_string_value(json_name); if (strchr(fullname, '.')) { @@ -302,18 +330,23 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c - *schema = avro_schema_fixed_ns(name, namespace, (int64_t) size); - avro_str_free(namespace); + char *namespaceX; -+ namespaceX = split_namespace_name(fullname, &name); ++ namespaceX = split_namespace_name(fullname, &name); + *schema = avro_schema_fixed_ns(name, namespaceX, (int64_t) size); + avro_str_free(namespaceX); } else if (json_is_string(json_namespace)) { - const char *namespace = json_string_value(json_namespace); -- *schema = avro_schema_fixed_ns(fullname, namespace, (int64_t) size); +- if (strlen(namespace) == 0) { +- namespace = NULL; + const char *namespaceX = json_string_value(json_namespace); ++ if (strlen(namespaceX) == 0) { ++ namespaceX = NULL; + } +- *schema = avro_schema_fixed_ns(fullname, namespace, (int64_t) size); + *schema = avro_schema_fixed_ns(fullname, namespaceX, (int64_t) size); } else { *schema = avro_schema_fixed_ns(fullname, parent_namespace, (int64_t) size); } -@@ -1749,9 +1749,9 @@ +@@ -1821,9 +1821,9 @@ static int write_link(avro_writer_t out, const struct avro_link_schema_t *link, { int rval; check(rval, avro_write_str(out, "\"")); @@ -326,10 +359,11 @@ diff -ur a/lang/c/src/schema.c b/lang/c/src/schema.c check(rval, avro_write_str(out, ".")); } check(rval, avro_write_str(out, avro_schema_name(link->to))); -diff -ur a/lang/c/tests/test_avro_data.c b/lang/c/tests/test_avro_data.c ---- a/lang/c/tests/test_avro_data.c 2017-04-17 19:56:17.000000000 -0400 -+++ b/lang/c/tests/test_avro_data.c 2017-11-10 12:41:29.924190100 -0500 -@@ -112,7 +112,7 @@ +diff --git a/lang/c/tests/test_avro_data.c b/lang/c/tests/test_avro_data.c +index 1da09e6d..7ef26013 100644 +--- a/lang/c/tests/test_avro_data.c ++++ b/lang/c/tests/test_avro_data.c +@@ -112,7 +112,7 @@ write_read_check(avro_schema_t writers_schema, avro_datum_t datum, if (size != avro_writer_tell(writer)) { fprintf(stderr, "Unable to calculate size %s validate=%d " @@ -338,7 +372,7 @@ diff -ur a/lang/c/tests/test_avro_data.c b/lang/c/tests/test_avro_data.c type, validate, size, avro_writer_tell(writer), avro_strerror()); exit(EXIT_FAILURE); -@@ -142,7 +142,7 @@ +@@ -142,7 +142,7 @@ static void test_json(avro_datum_t datum, const char *expected) { char *json = NULL; avro_datum_to_json(datum, 1, &json); diff --git a/ports/avro-c/fix-build-error.patch b/ports/avro-c/fix-build-error.patch deleted file mode 100644 index 6e07310fabb..00000000000 --- a/ports/avro-c/fix-build-error.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/lang/c/src/CMakeLists.txt b/lang/c/src/CMakeLists.txt -index c21f1ce..accb0e3 100644 ---- a/lang/c/src/CMakeLists.txt -+++ b/lang/c/src/CMakeLists.txt -@@ -85,13 +85,13 @@ source_group(Avro FILES ${AVRO_SRC}) - string(REPLACE ":" "." LIBAVRO_DOT_VERSION ${LIBAVRO_VERSION}) - - add_library(avro-static STATIC ${AVRO_SRC}) --target_link_libraries(avro-static ${JANSSON_LIBRARIES} ${CODEC_LIBRARIES} ${THREADS_LIBRARIES}) -+target_link_libraries(avro-static jansson::jansson ${CODEC_LIBRARIES} ${THREADS_LIBRARIES}) - set_target_properties(avro-static PROPERTIES OUTPUT_NAME avro) - - if (NOT WIN32) - # TODO: Create Windows DLLs. See http://www.cmake.org/Wiki/BuildingWinDLL - add_library(avro-shared SHARED ${AVRO_SRC}) --target_link_libraries(avro-shared ${JANSSON_LIBRARIES} ${CODEC_LIBRARIES} ${THREADS_LIBRARIES}) -+target_link_libraries(avro-shared jansson::jansson ${CODEC_LIBRARIES} ${THREADS_LIBRARIES}) - set_target_properties(avro-shared PROPERTIES - OUTPUT_NAME avro - SOVERSION ${LIBAVRO_DOT_VERSION}) diff --git a/ports/avro-c/portfile.cmake b/ports/avro-c/portfile.cmake index 0e74037fa58..8d8d81c6ac0 100644 --- a/ports/avro-c/portfile.cmake +++ b/ports/avro-c/portfile.cmake @@ -1,18 +1,15 @@ -include(vcpkg_common_functions) - vcpkg_buildpath_length_warning(37) +vcpkg_fail_port_install(ON_TARGET "uwp" "linux" "osx") vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO apache/avro - REF release-1.8.2 - SHA512 a48cc353aadd45ad2c8593bf89ec3f1ddb0fcd364b79dd002a60a54d49cab714b46eee8bd6dc47b13588b9eead49c754dfe05f6aff735752fca8d2cd35ae8649 + REF release-1.9.2 + SHA512 6a6980901eea964c050eb3d61fadf28712e2f02c36985bf8e5176b668bba48985f6a666554a1964435448de29b18d790ab86b787d0288a22fd9cba00746a7846 HEAD_REF master PATCHES - avro.patch - avro-pr-217.patch - fix-build-error.patch # Since jansson updated, use jansson::jansson instead of the macro ${JANSSON_LIBRARIES} - snappy.patch # https://github.com/apache/avro/pull/793 + avro.patch # Private vcpkg build fixes + snappy-pr-793.patch # Snappy build fixes for Windows (PR-793) ) vcpkg_configure_cmake( @@ -29,5 +26,4 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(COPY ${SOURCE_PATH}/lang/c/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/avro-c) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/avro-c/LICENSE ${CURRENT_PACKAGES_DIR}/share/avro-c/copyright) +file(INSTALL ${SOURCE_PATH}/lang/c/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/avro-c/snappy.patch b/ports/avro-c/snappy-pr-793.patch similarity index 91% rename from ports/avro-c/snappy.patch rename to ports/avro-c/snappy-pr-793.patch index 60a40e300af..28909318dad 100644 --- a/ports/avro-c/snappy.patch +++ b/ports/avro-c/snappy-pr-793.patch @@ -1,56 +1,56 @@ diff -ru b/c/src/codec.c a/lang/c/src/codec.c --- b/lang/c/src/codec.c 2020-01-23 16:18:15.119970300 +0200 +++ a/lang/c/src/codec.c 2020-01-23 19:31:41.679834300 +0200 -@@ -21,6 +21,9 @@ - # if defined(__APPLE__) - # include - # define __bswap_32 OSSwapInt32 -+# elif defined(_WIN32) -+# include -+# define __bswap_32 _byteswap_ulong - # else - # include - # endif +@@ -24,6 +24,9 @@ + # elif defined(__FreeBSD__) + # include + # define __bswap_32 bswap32 ++# elif defined(_WIN32) ++# include ++# define __bswap_32 _byteswap_ulong + # else + # include + # endif @@ -115,14 +118,14 @@ - return 1; - } - -- if (snappy_compress(data, len, c->block_data, &outlen) != SNAPPY_OK) -+ if (snappy_compress((const char *)data, len, (char*)c->block_data, &outlen) != SNAPPY_OK) - { - avro_set_error("Error compressing block with Snappy"); - return 1; - } - -- crc = __bswap_32(crc32(0, data, len)); -- memcpy(c->block_data+outlen, &crc, 4); -+ crc = __bswap_32(crc32(0, (const Bytef *)data, len)); -+ memcpy((char*)c->block_data+outlen, &crc, 4); - c->used_size = outlen+4; - - return 0; + return 1; + } + +- if (snappy_compress(data, len, c->block_data, &outlen) != SNAPPY_OK) ++ if (snappy_compress((const char *)data, len, (char*)c->block_data, &outlen) != SNAPPY_OK) + { + avro_set_error("Error compressing block with Snappy"); + return 1; + } + +- crc = __bswap_32(crc32(0, data, len)); +- memcpy(c->block_data+outlen, &crc, 4); ++ crc = __bswap_32(crc32(0, (const Bytef *)data, len)); ++ memcpy((char*)c->block_data+outlen, &crc, 4); + c->used_size = outlen+4; + + return 0; @@ -133,7 +136,7 @@ - uint32_t crc; - size_t outlen; - -- if (snappy_uncompressed_length(data, len-4, &outlen) != SNAPPY_OK) { -+ if (snappy_uncompressed_length((const char*)data, len-4, &outlen) != SNAPPY_OK) { - avro_set_error("Uncompressed length error in snappy"); - return 1; - } + uint32_t crc; + size_t outlen; + +- if (snappy_uncompressed_length(data, len-4, &outlen) != SNAPPY_OK) { ++ if (snappy_uncompressed_length((const char*)data, len-4, &outlen) != SNAPPY_OK) { + avro_set_error("Uncompressed length error in snappy"); + return 1; + } @@ -152,13 +155,13 @@ - return 1; - } - -- if (snappy_uncompress(data, len-4, c->block_data, &outlen) != SNAPPY_OK) -+ if (snappy_uncompress((const char*)data, len-4, (char*)c->block_data, &outlen) != SNAPPY_OK) - { - avro_set_error("Error uncompressing block with Snappy"); - return 1; - } - -- crc = __bswap_32(crc32(0, c->block_data, outlen)); -+ crc = __bswap_32(crc32(0, (const Bytef *)c->block_data, outlen)); - if (memcmp(&crc, (char*)data+len-4, 4)) - { - avro_set_error("CRC32 check failure uncompressing block with Snappy"); + return 1; + } + +- if (snappy_uncompress(data, len-4, c->block_data, &outlen) != SNAPPY_OK) ++ if (snappy_uncompress((const char*)data, len-4, (char*)c->block_data, &outlen) != SNAPPY_OK) + { + avro_set_error("Error uncompressing block with Snappy"); + return 1; + } + +- crc = __bswap_32(crc32(0, c->block_data, outlen)); ++ crc = __bswap_32(crc32(0, (const Bytef *)c->block_data, outlen)); + if (memcmp(&crc, (char*)data+len-4, 4)) + { + avro_set_error("CRC32 check failure uncompressing block with Snappy");