1 add_subdirectory(memory_utils)
8 libc.utils.CPP.standalone_cpp
11 add_entrypoint_object(
22 add_entrypoint_object(
33 add_entrypoint_object(
43 add_entrypoint_object(
51 add_entrypoint_object(
61 add_entrypoint_object(
69 add_entrypoint_object(
77 add_entrypoint_object(
87 add_entrypoint_object(
95 add_entrypoint_object(
103 add_entrypoint_object(
113 add_entrypoint_object(
120 libc.utils.CPP.standalone_cpp
123 add_entrypoint_object(
133 add_entrypoint_object(
143 add_entrypoint_object(
153 # Helper to define a function with multiple implementations
154 # - Computes flags to satisfy required/rejected features and arch,
155 # - Declares an entry point,
156 # - Attach the REQUIRE_CPU_FEATURES property to the target,
157 # - Add the fully qualified target to `${name}_implementations` global property for tests.
158 function(add_implementation name impl_name)
159 cmake_parse_arguments(
161 "" # Optional arguments
162 "MARCH" # Single value arguments
163 "REQUIRE;REJECT;SRCS;HDRS;DEPENDS;COMPILE_OPTIONS" # Multi value arguments
166 MARCH ${ADD_IMPL_MARCH}
167 REQUIRE ${ADD_IMPL_REQUIRE}
168 REJECT ${ADD_IMPL_REJECT}
170 add_entrypoint_object(${impl_name}
172 SRCS ${ADD_IMPL_SRCS}
173 HDRS ${ADD_IMPL_HDRS}
174 DEPENDS ${ADD_IMPL_DEPENDS}
175 COMPILE_OPTIONS ${ADD_IMPL_COMPILE_OPTIONS} ${flags} -O2
177 get_fq_target_name(${impl_name} fq_target_name)
178 set_target_properties(${fq_target_name} PROPERTIES REQUIRE_CPU_FEATURES "${ADD_IMPL_REQUIRE}")
179 set_property(GLOBAL APPEND PROPERTY "${name}_implementations" "${fq_target_name}")
182 # ------------------------------------------------------------------------------
184 # ------------------------------------------------------------------------------
186 # include the relevant architecture specific implementations
187 if(${LIBC_TARGET_MACHINE} STREQUAL "x86_64")
188 set(LIBC_STRING_TARGET_ARCH "x86")
189 set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/x86/memcpy.cpp)
191 set(LIBC_STRING_TARGET_ARCH ${LIBC_TARGET_MACHINE})
192 set(MEMCPY_SRC ${LIBC_SOURCE_DIR}/src/string/memcpy.cpp)
195 function(add_memcpy memcpy_name)
196 add_implementation(memcpy ${memcpy_name}
198 HDRS ${LIBC_SOURCE_DIR}/src/string/memcpy.h
200 .memory_utils.memory_utils
208 if(${LIBC_STRING_TARGET_ARCH} STREQUAL "x86")
209 add_memcpy(memcpy MARCH native)
214 # ------------------------------------------------------------------------------
216 # ------------------------------------------------------------------------------
218 function(add_memset memset_name)
219 add_implementation(memset ${memset_name}
220 SRCS ${LIBC_SOURCE_DIR}/src/string/memset.cpp
221 HDRS ${LIBC_SOURCE_DIR}/src/string/memset.h
223 .memory_utils.memory_utils
231 if(${LIBC_STRING_TARGET_ARCH} STREQUAL "x86")
232 add_memset(memset MARCH native)
237 # ------------------------------------------------------------------------------
239 # ------------------------------------------------------------------------------
241 function(add_bzero bzero_name)
242 add_implementation(bzero ${bzero_name}
243 SRCS ${LIBC_SOURCE_DIR}/src/string/bzero.cpp
244 HDRS ${LIBC_SOURCE_DIR}/src/string/bzero.h
246 .memory_utils.memory_utils
255 if(${LIBC_STRING_TARGET_ARCH} STREQUAL "x86")
256 add_bzero(bzero MARCH native)
261 # ------------------------------------------------------------------------------
262 # Add all other relevant implementations for the native target.
263 # ------------------------------------------------------------------------------
265 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_STRING_TARGET_ARCH})
266 include(${LIBC_STRING_TARGET_ARCH}/CMakeLists.txt)