Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
build:
verbosity: detailed

branches:
only:
- master
- development

platform: x64

environment:
matrix:
- GENERATOR: Visual Studio 16 2019
BUILD_TYPE: Debug
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

build_script:
- mkdir tmp
- cd tmp
- curl -fsSL "https://github.com/microsoft/GSL/archive/v2.0.0.zip" -o gsl.zip
- 7z x gsl.zip
- Xcopy /E /I GSL-2.0.0\include\gsl ..\include\extern\gsl\
- curl -fsSL "https://github.com/Tencent/rapidjson/archive/v1.1.0.zip" -o rapidjson.zip
- 7z x rapidjson.zip
- Xcopy /E /I rapidjson-1.1.0\include\rapidjson ..\include\extern\rapidjson
- cd ..
- mkdir build
- cd build
- cmake .. -G "%GENERATOR%" -A x64 -Dbuild_abi=ON -Dextended_test=ON
- cmake --build . --config %BUILD_TYPE%
- path=%cd%\%BUILD_TYPE%;%PATH%
- ctest --output-on-failure --build-config %BUILD_TYPE%
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ option(gen_coverage "Generate gcov coverage information in support envs" OFF)
option(use_asan "Link tests with address sanitizer" OFF)

# Check which dependencies are installed.
find_path(libgsl gsl/gsl)
find_library(libyaml yaml)
find_path(librj rapidjson/reader.h)
find_path(libgsl gsl/gsl HINTS ${PROJECT_SOURCE_DIR}/include/extern)
find_path(librj rapidjson/reader.h HINTS ${PROJECT_SOURCE_DIR}/include/extern)
if (NOT librj)
CHECK_INCLUDE_FILE_CXX("rapidjson/reader.h" librj)
endif ()
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Dart
==============

[![Build Status](https://travis-ci.com/target/libdart.svg?branch=master)](https://travis-ci.com/target/libdart)
[![Build status](https://ci.appveyor.com/api/projects/status/trv6dpc03nm3d9df?svg=true)](https://ci.appveyor.com/project/Cfretz244/libdart)
[![Coverage Status](https://coveralls.io/repos/github/target/libdart/badge.svg?branch=master)](https://coveralls.io/github/target/libdart?branch=master)
### A High Performance, Network Optimized, JSON Manipulation Library
**Dart** is both a wire-level binary `JSON` protocol, along with a high performance,
Expand Down
14 changes: 14 additions & 0 deletions include/dart/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8118,6 +8118,20 @@ extern "C" {
*/
DART_ABI_EXPORT char const* dart_get_error();

/**
* @brief
* Free a buffer returned from one of the dart_*_dup_bytes functions
*
* @details
* Dart requires its buffer representations to be aligned to a 64-bit
* boundary for internal design reasons (simplifies alignment logic significantly).
* Very easy to do on *nix machines with posix_memalign, which allocates aligned
* memory that can be passed directly to free.
* Windows, on the other hand, has _aligned_malloc and _aligned_free, which MUST
* be paired, so to write portable code this function must exist.
*/
DART_ABI_EXPORT void dart_aligned_free(void* ptr);

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/generic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1644,4 +1644,8 @@ extern "C" {
return dart::detail::errmsg.data();
}

void dart_aligned_free(void* ptr) {
dart::shim::aligned_free(ptr);
}

}
4 changes: 2 additions & 2 deletions test/buffer_abi_unit_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ SCENARIO("finalized buffer objects have unique object representations") {
auto* ownone = dart_buffer_dup_bytes(&finone, &lenone);
auto* owntwo = dart_buffer_dup_bytes(&fintwo, nullptr);
auto guard = make_scope_guard([&] {
free(owntwo);
free(ownone);
dart_aligned_free(owntwo);
dart_aligned_free(ownone);
});
REQUIRE(lenone == lentwo);
REQUIRE(std::memcmp(ownone, owntwo, lenone) == 0);
Expand Down
4 changes: 2 additions & 2 deletions test/generic_abi_unit_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1120,8 +1120,8 @@ SCENARIO("finalized objects have unique object representations") {
auto* ownone = dart_dup_bytes(&finone, &lenone);
auto* owntwo = dart_dup_bytes(&fintwo, &lentwo);
auto guard = make_scope_guard([&] {
free(owntwo);
free(ownone);
dart_aligned_free(owntwo);
dart_aligned_free(ownone);
});
REQUIRE(lenone == lentwo);
REQUIRE(std::memcmp(ownone, owntwo, lenone) == 0);
Expand Down
4 changes: 2 additions & 2 deletions test/heap_abi_unit_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,8 @@ SCENARIO("heap finalized objects have unique object representations") {
auto* ownone = dart_dup_bytes(&finone, &lenone);
auto* owntwo = dart_dup_bytes(&fintwo, &lentwo);
auto guard = make_scope_guard([&] {
free(owntwo);
free(ownone);
dart_aligned_free(owntwo);
dart_aligned_free(ownone);
});
REQUIRE(lenone == lentwo);
REQUIRE(std::memcmp(ownone, owntwo, lenone) == 0);
Expand Down
16 changes: 0 additions & 16 deletions test/json_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,6 @@ TEST_CASE("dart_packet parses JSON via RapidJSON", "[json unit]") {
compare_rj_dart_abi(packet, &bufferthree);
compare_rj_dart_abi(packet, &bufferfour);

// Validate the underlying buffer.
auto pktdup = dart_take_bytes(dart_dup_bytes(&bufferone, nullptr));
auto pktduptwo = dart_take_bytes_rc(dart_dup_bytes(&bufferone, nullptr), DART_RC_SAFE);
auto bufferdup = dart_buffer_take_bytes(dart_buffer_dup_bytes(&bufferone, nullptr));
auto bufferduptwo = dart_buffer_take_bytes_rc(dart_buffer_dup_bytes(&bufferone, nullptr), DART_RC_SAFE);
auto guard_two = make_scope_guard([&] {
dart_destroy(&bufferduptwo);
dart_destroy(&bufferdup);
dart_destroy(&pktduptwo);
dart_destroy(&pktdup);
});
compare_rj_dart_abi(packet, &pktdup);
compare_rj_dart_abi(packet, &pktduptwo);
compare_rj_dart_abi(packet, &bufferdup);
compare_rj_dart_abi(packet, &bufferduptwo);

// Generate JSON, reparse it, and validate it's still the same.
rj::Document rjone, rjtwo, rjthree;
auto* pktjson = dart_to_json(&pktone, nullptr);
Expand Down