1 /* Copyright (c) 2001 Matej Pfajfar.
2 * Copyright (c) 2001-2004, Roger Dingledine.
3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
9 * @brief Functions to get the name and version of the system libc.
13 #include "lib/osinfo/libc.h"
16 #ifdef HAVE_GNU_LIBC_VERSION_H
17 #include <gnu/libc-version.h>
20 #ifdef HAVE_GNU_LIBC_VERSION_H
21 #ifdef HAVE_GNU_GET_LIBC_VERSION
22 #define CHECK_LIBC_VERSION
26 #define STR_IMPL(x) #x
27 #define STR(x) STR_IMPL(x)
29 /** Return the name of the compile time libc. Returns NULL if we
30 * cannot identify the libc. */
32 tor_libc_get_name(void)
36 #else /* !defined(__GLIBC__) */
38 #endif /* defined(__GLIBC__) */
41 /** Return a string representation of the version of the currently running
42 * version of Glibc. */
44 tor_libc_get_version_str(void)
46 #ifdef CHECK_LIBC_VERSION
47 const char *version
= gnu_get_libc_version();
51 #else /* !defined(CHECK_LIBC_VERSION) */
53 #endif /* defined(CHECK_LIBC_VERSION) */
56 /** Return a string representation of the version of Glibc that was used at
57 * compilation time. */
59 tor_libc_get_header_version_str(void)
62 return STR(__GLIBC__
) "." STR(__GLIBC_MINOR__
);
65 #endif /* defined(__GLIBC__) */