From 0be25cf8220752e3000f10a5c8c38021e7c9085c Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Mon, 26 Sep 2016 14:54:25 +0200 Subject: [PATCH] fixed clock_gettime under MacOS X --- CMakeLists.txt | 27 +++++++++-- README | 84 +++++++++++++++++++++++++++++++++ cmake/test_clock_gettime.c | 9 ++++ lib/CMakeLists.txt | 7 ++- lib/Utilities/clock_gettime.cpp | 60 +++++++++++++++++++++++ 5 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 cmake/test_clock_gettime.c create mode 100644 lib/Utilities/clock_gettime.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 31089fdc52..0336657805 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,6 +105,7 @@ set(BIN_ARANGOVPACK arangovpack) set(TEST_BASICS_SUITE basics_suite) set(TEST_GEO_SUITE geo_suite) set(PACKAGES_LIST) + ################################################################################ ## VERSION FILES ################################################################################ @@ -133,9 +134,10 @@ configure_file( NEWLINE_STYLE UNIX ) - ################################################################################ ## Find the git revision +################################################################################ + find_program (GIT_EXE git) if (DEFINED GIT_EXE AND IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git") execute_process( @@ -328,7 +330,7 @@ if (MSVC) # https://blogs.msdn.microsoft.com/vcblog/2016/04/14/stl-fixes-in-vs-2015-update-2/ # https://connect.microsoft.com/VisualStudio/feedback/details/1892487 - #http://lists.boost.org/boost-users/2016/04/85968.php + # http://lists.boost.org/boost-users/2016/04/85968.php add_definitions("-D_ENABLE_ATOMIC_ALIGNMENT_FIX") set(MSVC_LIBS Shlwapi.lib;crypt32.lib;WINMM.LIB;Ws2_32.lib) @@ -342,6 +344,25 @@ else () ) endif () +# broken clock_gettime on MacOSX +SET(USE_LOCAL_CLOCK_GETTIME FALSE) + +if (APPLE) + TRY_RUN(RUN_CLOCK_GETTIME + COMPILE_CLOCK_GETTIME + ${PROJECT_BINARY_DIR}/test_clock_gettime + ${CMAKE_SOURCE_DIR}/cmake/test_clock_gettime.c + OUTPUT_VARIABLE OUTPUT_CLOCK_GETTIME) + + if (${COMPILE_CLOCK_GETTIME} AND ${RUN_CLOCK_GETTIME} STREQUAL "FAILED_TO_RUN") + set(USE_LOCAL_CLOCK_GETTIME TRUE) + endif () + + if (USE_LOCAL_CLOCK_GETTIME) + message(STATUS "using a home-made clock_gettime") + endif () +endif () + ################################################################################ ## INCLUDE DIRECTORIES ################################################################################ @@ -909,4 +930,4 @@ add_custom_target(packages DEPENDS ${PACKAGES_LIST} ) -message(INFO " Building for git revision: ${ARANGODB_BUILD_REPOSITORY}") +message(STATUS "building for git revision: ${ARANGODB_BUILD_REPOSITORY}") diff --git a/README b/README index e69de29bb2..05a06d8f37 100644 --- a/README +++ b/README @@ -0,0 +1,84 @@ +****** ArangoDB ****** +ArangoDB is a multi-model, open-source database with flexible data models for +documents, graphs, and key-values. Build high performance applications using a +convenient SQL-like query language or JavaScript extensions. Use ACID +transactions if you require them. Scale horizontally with a few mouse clicks. +The supported data models can be mixed in queries and allow ArangoDB to be the +aggregation point for your data. +To get started, try one of our 10 minutes tutorials in your favorite +programming language or try one of our ArangoDB_Cookbook_recipes. +For the impatient: download and install ArangoDB. Start the server arangod and +point your browser to http://127.0.0.1:8529/. +***** Key Features in ArangoDB ***** + * Multi-Model: Documents, graphs and key-value pairs — model your data as + you see fit for your application. + * Joins: Conveniently join what belongs together for flexible ad-hoc + querying, less data redundancy. + * Transactions: Easy application development keeping your data consistent + and safe. No hassle in your client. +Here is an AQL query that makes use of all those features: +[AQL Query Example] +Joins and transactions are key features for flexible, secure data designs, +widely used in relational databases but lacking in many NoSQL products. +However, there is no need to forgo them in ArangoDB. You decide how and when to +use joins and strong consistency guarantees, without sacrificing performance +and scalability. +Furthermore, ArangoDB offers a JavaScript framework called Foxx that is +executed in the database server with direct access to the data. Build your own +data-centric microservices with a few lines of code: +Microservice Example +[Microservice Example] +By extending the HTTP API with user code written in JavaScript, ArangoDB can be +turned into a strict schema-enforcing persistence engine. +Next step, bundle your Foxx application as a docker_container and get it +running in the cloud. +Other features of ArangoDB include: + * Schema-free schemata let you combine the space efficiency of MySQL with + the performance power of NoSQL + * Use a data-centric microservices approach with ArangoDB Foxx and fuse + your application-logic and database together for maximal throughput + * JavaScript for all: no language zoo, you can use one language from your + browser to your back-end + * ArangoDB is multi-threaded - exploit the power of all your cores + * Flexible data modeling: model your data as combination of key-value + pairs, documents or graphs - perfect for social relations + * Free index choice: use the correct index for your problem, be it a skip + list or a fulltext search + * Configurable durability: let the application decide if it needs more + durability or more performance + * Powerful query language (AQL) to retrieve and modify data + * Transactions: run queries on multiple documents or collections with + optional transactional consistency and isolation + * Replication and Sharding: set up the database in a master-slave + configuration or spread bigger datasets across multiple servers + * It is open source (Apache License 2.0) +For more in-depth information read the design_goals_of_ArangoDB +***** Latest Release - ArangoDB 3.0 ***** +The What's_new_in_ArangoDB_3.0 can be found in the documentation. +Key features of the 3.0 release are: + * use of VelocyPack as internal storage format + * AQL improvements + * much better cluster state management + * Synchronous replication (master/master) + * unified APIs for CRUD operations + * persistent indexes + * upgraded version of V8 + * new web admin interface + * Foxx improvements + * Logging improvements + * improved documentation +***** More Information ***** +Please check the Installation_Manual for installation and compilation +instructions. +The User_Manual has an introductory chapter showing the basic operations of +ArangoDB. +***** Stay in Contact ***** +We really appreciate feature requests and bug reports. Please use our Github +issue tracker for reporting them: +https://github.com/arangodb/arangodb/issues +You can use the Google group for improvements, feature requests, comments: +http://www.arangodb.com/community +StackOverflow is great for questions about AQL, usage scenarios etc. +http://stackoverflow.com/questions/tagged/arangodb +To chat with the community and the developers we offer a Slack chat: +http://slack.arangodb.com/ diff --git a/cmake/test_clock_gettime.c b/cmake/test_clock_gettime.c new file mode 100644 index 0000000000..d3f41924ee --- /dev/null +++ b/cmake/test_clock_gettime.c @@ -0,0 +1,9 @@ +#include +#include + +int main() { + printf("-- testing clock_gettime\n"); + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return 0; +} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 436df043b6..611718535a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -97,7 +97,11 @@ else() message("-- Will not compile in hand-optimized assembler code for CRC32.") endif() - +if (USE_LOCAL_CLOCK_GETTIME) + SET(LIB_CLOCK_GETTIME + Utilities/clock_gettime.cpp + ) +endif () add_library(${LIB_ARANGO} STATIC ${LIB_ARANGO_APPLE} @@ -105,6 +109,7 @@ add_library(${LIB_ARANGO} STATIC ${LIB_ARANGO_POSIX} ${LIB_ARANGO_LINENOISE} ${LIB_ARANGO_VPACK} + ${LIB_CLOCK_GETTIME} ${LIB_ASM_SOURCES} ApplicationFeatures/ApplicationFeature.cpp ApplicationFeatures/ApplicationServer.cpp diff --git a/lib/Utilities/clock_gettime.cpp b/lib/Utilities/clock_gettime.cpp new file mode 100644 index 0000000000..8162e2e250 --- /dev/null +++ b/lib/Utilities/clock_gettime.cpp @@ -0,0 +1,60 @@ +/* + * From: https://github.com/tarantool/tarantool/tree/1.7/third_party + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +extern "C" { +int clock_gettime(clockid_t clock_id, struct timespec* tp) { + tp->tv_nsec = 0; + tp->tv_sec = 0; + uint64_t tk; + struct timeval tv; + switch (clock_id) { + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + gettimeofday(&tv, 0); + tp->tv_sec = tv.tv_sec; + tp->tv_nsec = tv.tv_usec * 1000; + break; + case CLOCK_PROCESS_CPUTIME_ID: + case CLOCK_THREAD_CPUTIME_ID: + tk = clock(); + tp->tv_sec = tk / CLOCKS_PER_SEC; + tp->tv_nsec = (tk % CLOCKS_PER_SEC) * (1000000000 / CLOCKS_PER_SEC); + break; + default: + return 0; + } + return 0; +} +}