diff --git a/src/core/hle/libraries/libc/libc.cpp b/src/core/hle/libraries/libc/libc.cpp index bc55f822..ec7796a9 100644 --- a/src/core/hle/libraries/libc/libc.cpp +++ b/src/core/hle/libraries/libc/libc.cpp @@ -115,6 +115,7 @@ void libcSymbolsRegister(Loader::SymbolsResolver* sym) { LIB_FUNCTION("DfivPArhucg", "libc", 1, "libc", 1, 1, memcmp); LIB_FUNCTION("Q3VBxCXhUHs", "libc", 1, "libc", 1, 1, memcpy); LIB_FUNCTION("8zTFvBIAIN8", "libc", 1, "libc", 1, 1, memset); + LIB_FUNCTION("viiwFMaNamA", "libc", 1, "libc", 1, 1, strstr); // stdio functions LIB_FUNCTION("hcuQgD53UxM", "libc", 1, "libc", 1, 1, printf); diff --git a/src/core/hle/libraries/libc/libc_string.cpp b/src/core/hle/libraries/libc/libc_string.cpp index 3effa7bf..5e1b6a5e 100644 --- a/src/core/hle/libraries/libc/libc_string.cpp +++ b/src/core/hle/libraries/libc/libc_string.cpp @@ -1,42 +1,37 @@ -#include #include "core/hle/libraries/libc/libc_string.h" +#include +#include + namespace Core::Libraries::LibC { -int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { - return std::memcmp(s1, s2, n); +constexpr bool log_file_libc = true; // disable it to disable logging + +int PS4_SYSV_ABI memcmp(const void* s1, const void* s2, size_t n) { return std::memcmp(s1, s2, n); } + +void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { return std::memcpy(dest, src, n); } + +void* PS4_SYSV_ABI memset(void* s, int c, size_t n) { return std::memset(s, c, n); } + +int PS4_SYSV_ABI strcmp(const char* str1, const char* str2) { return std::strcmp(str1, str2); } + +char* PS4_SYSV_ABI strncpy(char* dest, const char* src, size_t count) { return std::strncpy(dest, src, count); } + +void* PS4_SYSV_ABI memmove(void* dest, const void* src, std::size_t count) { return std::memmove(dest, src, count); } + +char* PS4_SYSV_ABI strcpy(char* dest, const char* src) { + LOG_TRACE_IF(log_file_libc, "strcpy dest ={} src ={}", dest, src); + return std::strcpy(dest, src); } -void* PS4_SYSV_ABI memcpy(void* dest, const void* src, size_t n) { - return std::memcpy(dest, src, n); +char* PS4_SYSV_ABI strcat(char* dest, const char* src) { + LOG_TRACE_IF(log_file_libc, "strcat dest ={} src ={}", dest, src); + return std::strcat(dest, src); } -void* PS4_SYSV_ABI memset(void* s, int c, size_t n) { - return std::memset(s, c, n); +size_t PS4_SYSV_ABI strlen(const char* str) { return std::strlen(str); } +char* PS4_SYSV_ABI strstr(const char* haystack, const char* needle) { + LOG_TRACE_IF(log_file_libc, "strstr haystack ={} needle ={}", haystack, needle); + return (char*)std::strstr(haystack, needle); } - -int PS4_SYSV_ABI strcmp(const char* str1, const char* str2) { - return std::strcmp(str1, str2); -} - -char* PS4_SYSV_ABI strncpy(char* dest, const char* src, size_t count) { - return std::strncpy(dest, src, count); -} - -void* PS4_SYSV_ABI memmove(void* dest, const void* src, std::size_t count) { - return std::memmove(dest, src, count); -} - -char* PS4_SYSV_ABI strcpy(char* dest, const char* src) { - return std::strcpy(dest, src); -} - -char* PS4_SYSV_ABI strcat(char* dest, const char* src) { - return std::strcat(dest, src); -} - -size_t PS4_SYSV_ABI strlen(const char* str) { - return std::strlen(str); -} - -} // namespace Core::Libraries::LibC +} // namespace Core::Libraries::LibC diff --git a/src/core/hle/libraries/libc/libc_string.h b/src/core/hle/libraries/libc/libc_string.h index b5c29e23..8cecb9a3 100644 --- a/src/core/hle/libraries/libc/libc_string.h +++ b/src/core/hle/libraries/libc/libc_string.h @@ -14,5 +14,5 @@ void* PS4_SYSV_ABI memmove(void* dest, const void* src, std::size_t count); char* PS4_SYSV_ABI strcpy(char* destination, const char* source); char* PS4_SYSV_ABI strcat(char* dest, const char* src); size_t PS4_SYSV_ABI strlen(const char* str); - +char* PS4_SYSV_ABI strstr(const char* haystack, const char* needle); } // namespace Core::Libraries::LibC