Skip to content

Commit 07ba428

Browse files
[cmake][sc-memory] Support arm64 on OSX
1 parent acc578d commit 07ba428

File tree

7 files changed

+29
-14
lines changed

7 files changed

+29
-14
lines changed

CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,34 @@ project (sc-machine)
22
site_name (www.ostis.net)
33
cmake_minimum_required (VERSION 2.8)
44

5-
include(CTest)
5+
include (CTest)
6+
include (CheckCCompilerFlag)
67

7-
set(SC_BIN_PATH "${CMAKE_CURRENT_LIST_DIR}/bin")
8+
set (SC_BIN_PATH "${CMAKE_CURRENT_LIST_DIR}/bin")
89

9-
set(SC_MACHINE_ROOT ${CMAKE_CURRENT_LIST_DIR})
10-
set(SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty")
10+
set (SC_MACHINE_ROOT ${CMAKE_CURRENT_LIST_DIR})
11+
set (SC_MACHINE_THIRDPARTY_PATH "${SC_MACHINE_ROOT}/thirdparty")
1112

1213
option (SC_AUTO_TEST "Flag to build for automation testing" OFF)
1314
option (SC_KPM_SCP "Flag to build SCP module" OFF)
1415
option (SC_BUILD_SCTP "Flag to turn on/off sctp protocol support" OFF)
16+
option (SC_BUILD_ARM64 "Flag to build arm64" OFF)
1517

1618
set(SC_USE_SANITIZER "none" CACHE STRING "Build with specified sanitizer")
1719
set_property(CACHE SC_USE_SANITIZER PROPERTY STRINGS none address memory)
1820

1921
message ("Sanitizer: ${SC_USE_SANITIZER}")
2022

23+
if (${SC_BUILD_ARM64})
24+
check_c_compiler_flag("-arch arm64" IS_ARM64_SUPPORTED)
25+
if (${IS_ARM64_SUPPORTED})
26+
set (CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Used architecture" FORCE)
27+
message ("-- Architecture: arm64")
28+
else()
29+
message (FATAL_ERROR "Arm64 platform is not supported by compiler")
30+
endif()
31+
endif()
32+
2133
# codegen
2234
if (${UNIX})
2335
set(SC_CODEGEN_TOOL "${SC_BIN_PATH}/sc-code-generator")
@@ -91,7 +103,6 @@ if (${APPLE})
91103

92104
set (GLIB2_LIBRARIES ${GLIB_LDFLAGS} ${GLIB2_MODULE_LDFLAGS})
93105

94-
set (LIBCLANG_LLVM_CONFIG_EXECUTABLE "/usr/local/opt/llvm/bin/llvm-config")
95106
if (NOT DEFINED LIBCLANG_LIBRARIES OR NOT DEFINED LIBCLANG_CXXFLAGS OR NOT DEFINED LIBCLANG_LIBDIR)
96107
find_package(LibClang REQUIRED)
97108
endif ()

cmake/FindLibClang.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ if (NOT LIBCLANG_LLVM_CONFIG_EXECUTABLE)
4848
set(llvm_config_names llvm-config)
4949
foreach(minor RANGE 9 0)
5050
list(APPEND llvm_config_names
51+
"llvm-config"
5152
"llvm-config-7"
5253
"llvm-config-6.${minor}"
5354
"llvm-config-5.${minor}"

sc-memory/sc-core/sc-store/sc_element.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct _sc_arc_info
2121
};
2222

2323

24-
#define SC_CHECKSUM_LEN 32//(sizeof(sc_arc_info) - sizeof(sc_uint32))
24+
#define SC_CHECKSUM_LEN 32 //(sizeof(sc_arc_info) - sizeof(sc_uint32))
2525

2626
/*! Structure to store content information
2727
* Data field store checksum for data, that stores in specified sc-link.

sc-memory/sc-core/sc-store/sc_event/sc_event_private.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#define SC_EVENT_REQUEST_DESTROY (1 << 31)
2121
#define SC_EVENT_REF_COUNT_MASK (~SC_EVENT_REQUEST_DESTROY)
2222

23-
#pragma pack(push, 1)
2423
/*! Structure that contains information about event
2524
*/
2625
struct _sc_event
@@ -45,7 +44,6 @@ struct _sc_event
4544
sc_access_levels access_levels;
4645

4746
};
48-
#pragma pack(pop)
4947

5048

5149
//! Function to initialize sc-events module

sc-memory/sc-core/sc-store/sc_event/sc_event_queue.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@
1111
#include "../../sc_memory_private.h"
1212
#include "../../sc_memory.h"
1313

14-
#pragma pack(push, 1)
1514
typedef struct
1615
{
1716
sc_event * evt;
1817
sc_addr edge_addr;
1918
sc_addr other_addr;
2019
} sc_event_pool_worker_data;
21-
#pragma pack(pop)
2220

2321
sc_event_pool_worker_data * sc_event_pool_worker_data_new(sc_event * evt, sc_addr edge_addr, sc_addr other_addr)
2422
{

sc-memory/tests/sc-memory/performance/main.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ void BM_MemoryThreaded(benchmark::State & state)
5252

5353
int constexpr kNodeIters = 10000000;
5454

55+
BENCHMARK_TEMPLATE(BM_MemoryThreaded, TestCreateNode)
56+
->Threads(1)
57+
->Iterations(kNodeIters)
58+
->Unit(benchmark::TimeUnit::kMicrosecond);
59+
5560
BENCHMARK_TEMPLATE(BM_MemoryThreaded, TestCreateNode)
5661
->Threads(2)
5762
->Iterations(kNodeIters / 2)
@@ -72,7 +77,12 @@ BENCHMARK_TEMPLATE(BM_MemoryThreaded, TestCreateNode)
7277
->Iterations(kNodeIters / 16)
7378
->Unit(benchmark::TimeUnit::kMicrosecond);
7479

75-
int constexpr kLinkIters = 25000;
80+
int constexpr kLinkIters = 2500;
81+
82+
BENCHMARK_TEMPLATE(BM_MemoryThreaded, TestCreateLink)
83+
->Threads(1)
84+
->Iterations(kLinkIters)
85+
->Unit(benchmark::TimeUnit::kMicrosecond);
7686

7787
BENCHMARK_TEMPLATE(BM_MemoryThreaded, TestCreateLink)
7888
->Threads(2)

sc-network/sctp_client/sctpClient.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace sctp
2020

2121
#define SCTP_ADDR_SIZE (sizeof(ScRealAddr))
2222

23-
#pragma pack(push,1)
2423
struct RequestHeader
2524
{
2625
sc_uint8 commandType;
@@ -76,8 +75,6 @@ struct ResultHeader
7675
};
7776

7877

79-
#pragma pack(pop)
80-
8178
class Iterator
8279
{
8380
friend class Client;

0 commit comments

Comments
 (0)