зеркало из https://github.com/Azure/c-pal.git
Made it build
This commit is contained in:
Родитель
1bd037b694
Коммит
0d61b3e234
|
@ -120,8 +120,8 @@ if (
|
|||
set(PREV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
if(WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4100 /wd4127 /wd4459 /wd4201 /wd4456 /wd4457 /wd4702 /wd4244 /wd4701 /wd4706 /wd4703 /wd4189 /wd4267 /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DDLLEXPORT")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100 /wd4127 /wd4459 /wd4201 /wd4456 /wd4457 /wd4702 /wd4244 /wd4701 /wd4706 /wd4703 /wd4189 /wd4267 /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DDLLEXPORT")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4100 /wd4127 /wd4459 /wd4201 /wd4456 /wd4457 /wd4702 /wd4244 /wd4701 /wd4706 /wd4703 /wd4189 /wd4267 /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DJEMALLOC_EXPORT= /D_LIB")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100 /wd4127 /wd4459 /wd4201 /wd4456 /wd4457 /wd4702 /wd4244 /wd4701 /wd4706 /wd4703 /wd4189 /wd4267 /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DJEMALLOC_EXPORT= /D_LIB")
|
||||
endif()
|
||||
|
||||
add_subdirectory(jemalloc_build)
|
||||
|
@ -129,6 +129,9 @@ if (
|
|||
set(CMAKE_C_FLAGS ${PREV_CMAKE_C_FLAGS})
|
||||
set(CMAKE_CXX_FLAGS ${PREV_CMAKE_CXX_FLAGS})
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DJEMALLOC_EXPORT= /D_LIB")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DJEMALLOC_NO_PRIVATE_NAMESPACE /D_REENTRANT /DJEMALLOC_EXPORT= /D_LIB")
|
||||
|
||||
endif()
|
||||
|
||||
set(run_e2e_tests ${original_run_e2e_tests})
|
||||
|
|
|
@ -63,4 +63,4 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/include/msvc_compat)
|
|||
|
||||
add_library(jemalloc ${jemalloc_h_files} ${jemalloc_c_files})
|
||||
|
||||
target_include_directories(jemalloc PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../deps/jemalloc/include)
|
||||
target_include_directories(jemalloc PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../deps/jemalloc/include ${CMAKE_CURRENT_LIST_DIR}/include ${CMAKE_CURRENT_LIST_DIR}/include/msvc_compat)
|
||||
|
|
|
@ -56,6 +56,10 @@ if(${GBALLOC_LL_TYPE} STREQUAL "MIMALLOC")
|
|||
target_link_libraries(pal_win32 mimalloc-obj)
|
||||
endif()
|
||||
|
||||
if(${GBALLOC_LL_TYPE} STREQUAL "JEMALLOC")
|
||||
target_link_libraries(pal_win32 jemalloc)
|
||||
endif()
|
||||
|
||||
target_include_directories(pal_win32 PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc ${CMAKE_CURRENT_LIST_DIR}/src)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#include "real_gballoc_ll_renames.h"
|
||||
|
||||
#include "../src/gballoc_ll_jemalloc.c"
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "azure_c_logging/xlogging.h"
|
||||
#include "azure_c_pal/gballoc_ll.h"
|
||||
|
||||
#include "jemalloc/jemalloc.h"
|
||||
|
||||
int gballoc_ll_init(void* params)
|
||||
{
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_001: [ gballoc_ll_init shall return 0. ]*/
|
||||
(void)params;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gballoc_ll_deinit(void)
|
||||
{
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_002: [ gballoc_ll_deinit shall return. ] */
|
||||
}
|
||||
|
||||
void* gballoc_ll_malloc(size_t size)
|
||||
{
|
||||
void* result;
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_003: [ gballoc_ll_malloc shall call je_malloc and returns what je_malloc returned. ]*/
|
||||
if ((result = je_malloc(size)) == NULL)
|
||||
{
|
||||
LogError("failure in je_malloc(size=%zu)", size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void gballoc_ll_free(void* ptr)
|
||||
{
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_004: [ gballoc_ll_free shall call je_free(ptr). ]*/
|
||||
je_free(ptr);
|
||||
}
|
||||
|
||||
void* gballoc_ll_calloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void* result;
|
||||
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_005: [ gballoc_ll_calloc shall call je_calloc(nmemb, size) and return what je_calloc returned. ]*/
|
||||
if ((result = je_calloc(nmemb, size)) == NULL)
|
||||
{
|
||||
LogError("failure in je_calloc(nmemb=%zu, size=%zu)", nmemb, size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void* gballoc_ll_realloc(void* ptr, size_t size)
|
||||
{
|
||||
void* result;
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_006: [ gballoc_ll_realloc calls je_realloc(ptr, size) and returns what je_realloc returned. ]*/
|
||||
if ((result = je_realloc(ptr, size)) == NULL)
|
||||
{
|
||||
LogError("failure in je_realloc(ptr=%p, size=%zu)", ptr, size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t gballoc_ll_size(void* ptr)
|
||||
{
|
||||
size_t result;
|
||||
|
||||
/*Codes_SRS_GBALLOC_LL_MIMALLOC_02_007: [ gballoc_ll_size shall call je_usable_size and return what je_usable_size returned. ]*/
|
||||
result = je_malloc_usable_size(ptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -32,6 +32,8 @@ set(${theseTestsName}_h_files
|
|||
|
||||
if(${GBALOC_LL_IMPL} STREQUAL "MIMALLOC")
|
||||
build_test_artifacts(${theseTestsName} ON "tests/azure_c_pal/common" ADDITIONAL_LIBS pal_interfaces synchronization mimalloc-obj)
|
||||
elseif(${GBALOC_LL_IMPL} STREQUAL "JEMALLOC")
|
||||
build_test_artifacts(${theseTestsName} ON "tests/azure_c_pal/common" ADDITIONAL_LIBS pal_interfaces synchronization jemalloc)
|
||||
else()
|
||||
build_test_artifacts(${theseTestsName} ON "tests/azure_c_pal/common" ADDITIONAL_LIBS pal_interfaces synchronization)
|
||||
endif()
|
||||
|
|
Загрузка…
Ссылка в новой задаче