blob: f52dea41aacca910dfbe45696c50c194779f63b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2021, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* @file libc.c
* @brief Functions to get the name and version of the system libc.
**/
#include "orconfig.h"
#include "lib/osinfo/libc.h"
#include <stdlib.h>
#ifdef HAVE_GNU_LIBC_VERSION_H
#include <gnu/libc-version.h>
#endif
#ifdef HAVE_GNU_LIBC_VERSION_H
#ifdef HAVE_GNU_GET_LIBC_VERSION
#define CHECK_LIBC_VERSION
#endif
#endif
#define STR_IMPL(x) #x
#define STR(x) STR_IMPL(x)
/** Return the name of the compile time libc. Returns NULL if we
* cannot identify the libc. */
const char *
tor_libc_get_name(void)
{
#ifdef __GLIBC__
return "Glibc";
#else /* !defined(__GLIBC__) */
return NULL;
#endif /* defined(__GLIBC__) */
}
/** Return a string representation of the version of the currently running
* version of Glibc. */
const char *
tor_libc_get_version_str(void)
{
#ifdef CHECK_LIBC_VERSION
const char *version = gnu_get_libc_version();
if (version == NULL)
return "N/A";
return version;
#else /* !defined(CHECK_LIBC_VERSION) */
return "N/A";
#endif /* defined(CHECK_LIBC_VERSION) */
}
/** Return a string representation of the version of Glibc that was used at
* compilation time. */
const char *
tor_libc_get_header_version_str(void)
{
#ifdef __GLIBC__
return STR(__GLIBC__) "." STR(__GLIBC_MINOR__);
#else
return "N/A";
#endif /* defined(__GLIBC__) */
}
|