Update SM4 OpenCL implementation

This commit is contained in:
Zhi Guan
2024-04-12 16:07:30 +08:00
parent 9fd4464980
commit 8e2c4ebd2f
4 changed files with 185 additions and 85 deletions

View File

@@ -327,6 +327,15 @@ if (ENABLE_SM4_CTR_AESNI_AVX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
endif()
if (ENABLE_SM4_CL)
message(STATUS "ENABLE_SM4_CL is ON")
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
add_definitions(-DMACOS) # to include <OpenCL/OpenCL.h>
endif()
list(APPEND src src/sm4_cl.c)
list(APPEND tests sm4_cl)
endif()
if (ENABLE_SM4_ECB)
message(STATUS "ENABLE_SM4_ECB is ON")
add_definitions(-DENABLE_SM4_ECB)
@@ -516,7 +525,10 @@ if (WIN32)
elseif (APPLE)
target_link_libraries(gmssl dl)
target_link_libraries(gmssl "-framework Security")
#target_link_libraries(gmssl "-framework OpenCL")
if (ENABLE_SM4_CL)
# FIXME: different rules for cl and OpenCL framework
target_link_libraries(gmssl "-framework OpenCL")
endif()
#target_link_libraries(gmssl "-framework CoreFoundation") # rand_apple.c CFRelease()
elseif (MINGW)
target_link_libraries(gmssl PRIVATE wsock32)