Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #67 from ali-ince/1.7-windows-7-compilation
Browse files Browse the repository at this point in the history
Split platform based functions into seperate source files
  • Loading branch information
ali-ince authored Jan 17, 2019
2 parents 833b621 + 613a8b9 commit 67f59c6
Show file tree
Hide file tree
Showing 28 changed files with 888 additions and 578 deletions.
24 changes: 15 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ project(seabolt
DESCRIPTION "The C Connector library for Neo4j"
LANGUAGES C CXX)

IF(DEFINED ENV{SEABOLT_VERSION})
IF (DEFINED ENV{SEABOLT_VERSION})
set(_SEABOLT_VERSION $ENV{SEABOLT_VERSION})
ELSE()
set(_SEABOLT_VERSION "1.7.1-dev")
ENDIF()
ELSE ()
set(_SEABOLT_VERSION "1.7.2-dev")
ENDIF ()

set(SEABOLT_VERSION ${_SEABOLT_VERSION} CACHE STRING "The version of seabolt being built")

Expand All @@ -30,10 +30,6 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif ()

set(ON_WINDOWS OFF)
set(ON_MACOS OFF)
set(ON_POSIX OFF)
Expand All @@ -43,6 +39,11 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(ON_MACOS ON)
endif ()

set(ON_GCC OFF)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(ON_GCC ON)
endif ()

if (NOT ON_WINDOWS)
include(CheckIncludeFile)
check_include_file("unistd.h" HAVE_UNISTD_H)
Expand Down Expand Up @@ -138,7 +139,12 @@ install(
DESTINATION ${INSTALL_CMAKEDIR}
COMPONENT dev)

INSTALL(
if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
endif ()
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)

install(
FILES
${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}
DESTINATION ${INSTALL_BINDIR}
Expand Down
2 changes: 1 addition & 1 deletion make.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Mkdir %BUILDDIR%
Pushd %BUILDDIR%

cmake.exe -G "%CMAKE_GENERATOR%" -DCMAKE_BUILD_TYPE=%CMAKE_BUILD% -DCMAKE_INSTALL_PREFIX=dist .. || Goto :Failure
cmake.exe --build . --target install || Goto :Failure
cmake.exe --build . --target install --config %CMAKE_BUILD% || Goto :Failure

Popd
Exit /b 0
Expand Down
22 changes: 11 additions & 11 deletions src/seabolt-cli/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <inttypes.h>

#include "bolt/bolt.h"
#include "bolt/platform.h"
#include "bolt/time.h"

#ifdef WIN32

Expand Down Expand Up @@ -219,7 +219,7 @@ void app_destroy(struct Application* app)
void app_connect(struct Application* app)
{
struct timespec t[2];
BoltUtil_get_time(&t[0]);
BoltTime_get_time(&t[0]);
BoltStatus* status = BoltStatus_create();
BoltConnection* connection = BoltConnector_acquire(app->connector, app->access_mode, status);
if (connection==NULL) {
Expand All @@ -229,19 +229,19 @@ void app_connect(struct Application* app)
}
BoltStatus_destroy(status);
app->connection = connection;
BoltUtil_get_time(&t[1]);
BoltTime_get_time(&t[1]);
timespec_diff(&app->stats.connect_time, &t[1], &t[0]);
}

int app_debug(struct Application* app, const char* cypher)
{
struct timespec t[7];

BoltUtil_get_time(&t[1]); // Checkpoint 1 - right at the start
BoltTime_get_time(&t[1]); // Checkpoint 1 - right at the start

app_connect(app);

BoltUtil_get_time(&t[2]); // Checkpoint 2 - after handshake and initialisation
BoltTime_get_time(&t[2]); // Checkpoint 2 - after handshake and initialisation

//BoltConnection_load_bookmark(bolt->connection, "tx:1234");
BoltConnection_load_begin_request(app->connection);
Expand All @@ -255,25 +255,25 @@ int app_debug(struct Application* app, const char* cypher)

BoltConnection_send(app->connection);

BoltUtil_get_time(&t[3]); // Checkpoint 3 - after query transmission
BoltTime_get_time(&t[3]); // Checkpoint 3 - after query transmission

long record_count = 0;

BoltConnection_fetch_summary(app->connection, run);

BoltUtil_get_time(&t[4]); // Checkpoint 4 - receipt of header
BoltTime_get_time(&t[4]); // Checkpoint 4 - receipt of header

while (BoltConnection_fetch(app->connection, pull)) {
record_count += 1;
}

BoltConnection_fetch_summary(app->connection, commit);

BoltUtil_get_time(&t[5]); // Checkpoint 5 - receipt of footer
BoltTime_get_time(&t[5]); // Checkpoint 5 - receipt of footer

BoltConnector_release(app->connector, app->connection);

BoltUtil_get_time(&t[6]); // Checkpoint 6 - after close
BoltTime_get_time(&t[6]); // Checkpoint 6 - after close

///////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -388,12 +388,12 @@ int app_perf(struct Application* app, long warmup_times, long actual_times, cons
run_fetch(app, cypher);
}

BoltUtil_get_time(&t[1]); // Checkpoint 1 - before run
BoltTime_get_time(&t[1]); // Checkpoint 1 - before run
long record_count = 0;
for (int i = 0; i<actual_times; i++) {
record_count += run_fetch(app, cypher);
}
BoltUtil_get_time(&t[2]); // Checkpoint 2 - after run
BoltTime_get_time(&t[2]); // Checkpoint 2 - after run

BoltConnector_release(app->connector, app->connection);

Expand Down
49 changes: 46 additions & 3 deletions src/seabolt/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(CheckSymbolExists)

set_target_properties(${SEABOLT_SHARED}
PROPERTIES
SOVERSION 1
Expand All @@ -23,20 +25,61 @@ list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/log.c
${CMAKE_CURRENT_LIST_DIR}/bolt/mem.c
${CMAKE_CURRENT_LIST_DIR}/bolt/packstream.c
${CMAKE_CURRENT_LIST_DIR}/bolt/platform.c
${CMAKE_CURRENT_LIST_DIR}/bolt/protocol.c
${CMAKE_CURRENT_LIST_DIR}/bolt/routing-pool.c
${CMAKE_CURRENT_LIST_DIR}/bolt/routing-table.c
${CMAKE_CURRENT_LIST_DIR}/bolt/stats.c
${CMAKE_CURRENT_LIST_DIR}/bolt/status.c
${CMAKE_CURRENT_LIST_DIR}/bolt/string-builder.c
${CMAKE_CURRENT_LIST_DIR}/bolt/time.c
${CMAKE_CURRENT_LIST_DIR}/bolt/tls.c
${CMAKE_CURRENT_LIST_DIR}/bolt/utils.c
${CMAKE_CURRENT_LIST_DIR}/bolt/v1.c
${CMAKE_CURRENT_LIST_DIR}/bolt/v2.c
${CMAKE_CURRENT_LIST_DIR}/bolt/v3.c
${CMAKE_CURRENT_LIST_DIR}/bolt/values.c)

check_symbol_exists(timespec_get "time.h" HAVE_TIMESPEC_GET)

if (ON_POSIX)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/sync-pthread.c)
endif ()

if (ON_WINDOWS)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/sync-win32.c)
endif ()

if (HAVE_TIMESPEC_GET)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/time-timespec.c)
else ()
if (ON_WINDOWS)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/time-win32.c)
endif ()

if (ON_MACOS)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/time-macos.c)
endif ()
endif ()

if (ON_GCC)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/atomic-gcc.c)
else ()
if (ON_WINDOWS)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/atomic-win32.c)
endif ()

if (ON_MACOS)
list(APPEND private_source_files
${CMAKE_CURRENT_LIST_DIR}/bolt/atomic-macos.c)
endif ()
endif ()

list(APPEND public_header_files
${CMAKE_CURRENT_LIST_DIR}/bolt/bolt.h
${CMAKE_CURRENT_LIST_DIR}/bolt/address.h
Expand Down Expand Up @@ -173,7 +216,7 @@ if (WITH_TLS_SUPPORT AND WITH_TLS_OPENSSL)
endif ()

if (CMAKE_C_COMPILER_ID MATCHES AppleClang)
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/bolt/platform.c
set_source_files_properties(${CMAKE_CURRENT_LIST_DIR}/bolt/atomic-macos.c
PROPERTIES
COMPILE_FLAGS -Wno-deprecated-declarations)
endif ()
Expand Down
14 changes: 7 additions & 7 deletions src/seabolt/src/bolt/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "address-private.h"
#include "log-private.h"
#include "mem.h"
#include "platform.h"
#include "sync.h"

#define DEFAULT_BOLT_PORT "7687"
#define DEFAULT_BOLT_HOST "localhost"
Expand All @@ -46,7 +46,7 @@ BoltAddress* BoltAddress_create(const char* host, const char* port)
address->n_resolved_hosts = 0;
address->resolved_hosts = NULL;
address->resolved_port = 0;
BoltUtil_mutex_create(&address->lock);
BoltSync_mutex_create(&address->lock);
return address;
}

Expand Down Expand Up @@ -83,7 +83,7 @@ BoltAddress* BoltAddress_create_from_string(const char* endpoint_str, uint64_t e

int32_t BoltAddress_resolve(BoltAddress* address, int32_t* n_resolved, BoltLog* log)
{
BoltUtil_mutex_lock(&address->lock);
BoltSync_mutex_lock(&address->lock);

if (strchr(address->host, ':')==NULL) {
BoltLog_info(log, "[addr]: Resolving address %s:%s", address->host, address->port);
Expand Down Expand Up @@ -151,16 +151,16 @@ int32_t BoltAddress_resolve(BoltAddress* address, int32_t* n_resolved, BoltLog*
if (address->n_resolved_hosts>0) {
struct sockaddr_storage* resolved = &address->resolved_hosts[0];
const uint16_t resolved_port = resolved->ss_family==AF_INET ?
((struct sockaddr_in*) (resolved))->sin_port
: ((struct sockaddr_in6*) (resolved))->sin6_port;
((struct sockaddr_in*) (resolved))->sin_port
: ((struct sockaddr_in6*) (resolved))->sin6_port;
address->resolved_port = ntohs(resolved_port);
}

if (gai_status==0 && n_resolved!=NULL) {
*n_resolved = address->n_resolved_hosts;
}

BoltUtil_mutex_unlock(&address->lock);
BoltSync_mutex_unlock(&address->lock);

return gai_status;
}
Expand Down Expand Up @@ -190,7 +190,7 @@ void BoltAddress_destroy(BoltAddress* address)
address->n_resolved_hosts = 0;
}

BoltUtil_mutex_destroy(&address->lock);
BoltSync_mutex_destroy(&address->lock);
BoltMem_deallocate((char*) address->host, strlen(address->host)+1);
BoltMem_deallocate((char*) address->port, strlen(address->port)+1);
BoltMem_deallocate(address, sizeof(BoltAddress));
Expand Down
38 changes: 38 additions & 0 deletions src/seabolt/src/bolt/atomic-gcc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2002-2019 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed 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 "bolt-private.h"
#include "atomic.h"

int64_t BoltAtomic_increment(volatile int64_t* ref)
{
return __sync_add_and_fetch(ref, 1);
}

int64_t BoltAtomic_decrement(volatile int64_t* ref)
{
return __sync_add_and_fetch(ref, -1);
}

int64_t BoltAtomic_add(volatile int64_t* ref, int64_t by)
{
return __sync_add_and_fetch(ref, by);
}


40 changes: 40 additions & 0 deletions src/seabolt/src/bolt/atomic-macos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2002-2019 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed 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 "bolt-private.h"
#include "atomic.h"

#include <libkern/OSAtomic.h>

int64_t BoltAtomic_increment(volatile int64_t* ref)
{
return OSAtomicIncrement64(ref);
}

int64_t BoltAtomic_decrement(volatile int64_t* ref)
{
return OSAtomicDecrement64(ref);
}

int64_t BoltAtomic_add(volatile int64_t* ref, int64_t by)
{
return OSAtomicAdd64(by, ref);
}


Loading

0 comments on commit 67f59c6

Please sign in to comment.