aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/openssl/CMakeLists.txt7
-rw-r--r--crypto/compat/getprogname_linux.c25
2 files changed, 32 insertions, 0 deletions
diff --git a/apps/openssl/CMakeLists.txt b/apps/openssl/CMakeLists.txt
index db63ecf..6d89c06 100644
--- a/apps/openssl/CMakeLists.txt
+++ b/apps/openssl/CMakeLists.txt
@@ -67,6 +67,13 @@ else()
67 set(OPENSSL_SRC ${OPENSSL_SRC} compat/strtonum.c) 67 set(OPENSSL_SRC ${OPENSSL_SRC} compat/strtonum.c)
68endif() 68endif()
69 69
70if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
71 check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
72 if(NOT HAVE_CLOCK_GETTIME)
73 set(OPENSSL_SRC ${OPENSSL_SRC} compat/clock_gettime_osx.c)
74 endif()
75endif()
76
70add_executable(openssl ${OPENSSL_SRC}) 77add_executable(openssl ${OPENSSL_SRC})
71target_include_directories(openssl PRIVATE . ../../include/compat) 78target_include_directories(openssl PRIVATE . ../../include/compat)
72target_link_libraries(openssl ${OPENSSL_LIBS}) 79target_link_libraries(openssl ${OPENSSL_LIBS})
diff --git a/crypto/compat/getprogname_linux.c b/crypto/compat/getprogname_linux.c
index fefe5ea..2c89743 100644
--- a/crypto/compat/getprogname_linux.c
+++ b/crypto/compat/getprogname_linux.c
@@ -5,5 +5,30 @@
5const char * 5const char *
6getprogname(void) 6getprogname(void)
7{ 7{
8 /*
9 * Android added getprogname with API 21 [0]. We should not end up here
10 * with APIs bigger than 21. Still write a precise check.
11 *
12 * Since Android is using portions of OpenBSD libc, it should have
13 * a symbol called __progname [1].
14 *
15 * Regarding program_invocation_short_name, it is a GNU libc ext [2] and
16 * so make it conditional to __GLIBC__ [3].
17 *
18 * .. [0] https://github.com/aosp-mirror/platform_bionic/blob/1eb6d3/libc/include/stdlib.h#L160
19 *
20 * .. [1] https://github.com/aosp-mirror/platform_bionic/commit/692207
21 *
22 * .. [2] https://linux.die.net/man/3/program_invocation_short_name
23 *
24 * .. [3] https://android.googlesource.com/platform/system/core/+/2819c0/base/logging.cpp#65
25 */
26#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
27 extern const char *__progname;
28 return __progname;
29#elif defined(__GLIBC__)
8 return program_invocation_short_name; 30 return program_invocation_short_name;
31#else
32#error "Cannot emulate getprogname"
33#endif
9} 34}