forked from osmocom/wireshark
Move some routines into ws_version_info.c.
The routines to get compiler, GLib version, CPU, and memory info are used only in routines in ws_version_info.c; move them into ws_version_info.c and make them static. Change-Id: I58edd18da3301095012d2c7a3c5198e5a7073964 Reviewed-on: https://code.wireshark.org/review/6183 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
ce9ca9df77
commit
cb7c949091
|
@ -51,18 +51,14 @@ libwsutil.so.0 libwsutil0 #MINVER#
|
|||
format_size@Base 1.10.0
|
||||
get_basename@Base 1.12.0~rc1
|
||||
get_compiled_version_info@Base 1.99.2
|
||||
get_compiler_info@Base 1.99.0
|
||||
get_copyright_info@Base 1.99.0
|
||||
get_cpu_info@Base 1.99.0
|
||||
get_cur_groupname@Base 1.10.0
|
||||
get_cur_username@Base 1.10.0
|
||||
get_datafile_dir@Base 1.12.0~rc1
|
||||
get_datafile_path@Base 1.12.0~rc1
|
||||
get_dirname@Base 1.12.0~rc1
|
||||
get_extcap_dir@Base 1.99.0
|
||||
get_glib_version_info@Base 1.99.0
|
||||
get_global_profiles_dir@Base 1.12.0~rc1
|
||||
get_mem_info@Base 1.99.0
|
||||
get_natural_int@Base 1.99.0
|
||||
get_os_version_info@Base 1.99.0
|
||||
get_persconffile_path@Base 1.12.0~rc1
|
||||
|
|
|
@ -39,9 +39,7 @@ set(WSUTIL_FILES
|
|||
cfutils.c
|
||||
clopts_common.c
|
||||
cmdarg_err.c
|
||||
compiler_info.c
|
||||
copyright_info.c
|
||||
cpu_info.c
|
||||
crash_info.c
|
||||
crc10.c
|
||||
crc16.c
|
||||
|
@ -55,10 +53,8 @@ set(WSUTIL_FILES
|
|||
eax.c
|
||||
filesystem.c
|
||||
g711.c
|
||||
glib_version_info.c
|
||||
md4.c
|
||||
md5.c
|
||||
mem_info.c
|
||||
mpeg-audio.c
|
||||
nstime.c
|
||||
os_version_info.c
|
||||
|
|
|
@ -36,9 +36,7 @@ LIBWSUTIL_SRC = \
|
|||
cfutils.c \
|
||||
clopts_common.c \
|
||||
cmdarg_err.c \
|
||||
compiler_info.c \
|
||||
copyright_info.c \
|
||||
cpu_info.c \
|
||||
crash_info.c \
|
||||
crc6.c \
|
||||
crc7.c \
|
||||
|
@ -52,10 +50,8 @@ LIBWSUTIL_SRC = \
|
|||
eax.c \
|
||||
filesystem.c \
|
||||
g711.c \
|
||||
glib_version_info.c \
|
||||
md4.c \
|
||||
md5.c \
|
||||
mem_info.c \
|
||||
mpeg-audio.c \
|
||||
nstime.c \
|
||||
os_version_info.c \
|
||||
|
@ -88,9 +84,7 @@ libwsutil_nonrepl_INCLUDES = \
|
|||
cfutils.h \
|
||||
clopts_common.h \
|
||||
cmdarg_err.h \
|
||||
compiler_info.h \
|
||||
copyright_info.h \
|
||||
cpu_info.h \
|
||||
crash_info.h \
|
||||
crc6.h \
|
||||
crc7.h \
|
||||
|
@ -104,10 +98,8 @@ libwsutil_nonrepl_INCLUDES = \
|
|||
eax.h \
|
||||
filesystem.h \
|
||||
g711.h \
|
||||
glib_version_info.h \
|
||||
md4.h \
|
||||
md5.h \
|
||||
mem_info.h \
|
||||
mpeg-audio.h \
|
||||
nstime.h \
|
||||
os_version_info.h \
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
/* compiler_info.c
|
||||
* Routines to report information about the compiler used to compile
|
||||
* Wireshark
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/compiler_info.h>
|
||||
|
||||
/*
|
||||
* Get compiler information, and append it to the GString.
|
||||
*/
|
||||
void
|
||||
get_compiler_info(GString *str)
|
||||
{
|
||||
/*
|
||||
* See https://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
|
||||
* information on various defined strings.
|
||||
*
|
||||
* GCC's __VERSION__ is a nice text string for humans to
|
||||
* read. The page at sourceforge.net largely describes
|
||||
* numeric #defines that encode the version; if the compiler
|
||||
* doesn't also offer a nice printable string, we try prettifying
|
||||
* the number somehow.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__VERSION__)
|
||||
/*
|
||||
* Clang and llvm-gcc also define __GNUC__ and __VERSION__;
|
||||
* distinguish between them.
|
||||
*/
|
||||
#if defined(__clang__)
|
||||
g_string_append_printf(str, "\n\nBuilt using clang %s.\n", __VERSION__);
|
||||
#elif defined(__llvm__)
|
||||
g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
|
||||
#else /* boring old GCC */
|
||||
g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
|
||||
#endif /* llvm */
|
||||
#elif defined(__HP_aCC)
|
||||
g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
|
||||
#elif defined(__xlC__)
|
||||
g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
|
||||
(__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
|
||||
#ifdef __IBMC__
|
||||
if ((__IBMC__ % 10) != 0)
|
||||
g_string_append_printf(str, " patch %d", __IBMC__ % 10);
|
||||
#endif /* __IBMC__ */
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
|
||||
__INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
|
||||
if ((__INTEL_COMPILER % 10) != 0)
|
||||
g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
|
||||
#ifdef __INTEL_COMPILER_BUILD_DATE
|
||||
g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
|
||||
__INTEL_COMPILER_BUILD_DATE / 10000,
|
||||
(__INTEL_COMPILER_BUILD_DATE / 100) % 100,
|
||||
__INTEL_COMPILER_BUILD_DATE % 100);
|
||||
#endif /* __INTEL_COMPILER_BUILD_DATE */
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(_MSC_FULL_VER)
|
||||
# if _MSC_FULL_VER > 99999999
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
|
||||
(_MSC_FULL_VER / 10000000) - 6,
|
||||
(_MSC_FULL_VER / 100000) % 100);
|
||||
# if (_MSC_FULL_VER % 100000) != 0
|
||||
g_string_append_printf(str, " build %d",
|
||||
_MSC_FULL_VER % 100000);
|
||||
# endif
|
||||
# else
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
|
||||
(_MSC_FULL_VER / 1000000) - 6,
|
||||
(_MSC_FULL_VER / 10000) % 100);
|
||||
# if (_MSC_FULL_VER % 10000) != 0
|
||||
g_string_append_printf(str, " build %d",
|
||||
_MSC_FULL_VER % 10000);
|
||||
# endif
|
||||
# endif
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(_MSC_VER)
|
||||
/* _MSC_FULL_VER not defined, but _MSC_VER defined */
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
|
||||
(_MSC_VER / 100) - 6, _MSC_VER % 100);
|
||||
#elif defined(__SUNPRO_C)
|
||||
g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
|
||||
(__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
|
||||
if ((__SUNPRO_C & 0xF) != 0)
|
||||
g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
|
||||
g_string_append_printf(str, "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,39 +0,0 @@
|
|||
/* compiler_info.h
|
||||
* Declarations of outines to report information about the compiler used
|
||||
* to compile Wireshark
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __WSUTIL_COMPILER_INFO_H__
|
||||
#define __WSUTIL_COMPILER_INFO_H__
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
WS_DLL_PUBLIC void get_compiler_info(GString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __WSUTIL_COMPILER_INFO_H__ */
|
|
@ -1,80 +0,0 @@
|
|||
/* cpu_info.c
|
||||
* Routines to report information about the CPU on which we're running
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/ws_cpuid.h>
|
||||
|
||||
#include <wsutil/cpu_info.h>
|
||||
|
||||
/*
|
||||
* Get the CPU info, and append it to the GString
|
||||
*/
|
||||
void
|
||||
get_cpu_info(GString *str _U_)
|
||||
{
|
||||
guint32 CPUInfo[4];
|
||||
char CPUBrandString[0x40];
|
||||
unsigned nExIds;
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.100).aspx */
|
||||
|
||||
/* Calling __cpuid with 0x80000000 as the InfoType argument*/
|
||||
/* gets the number of valid extended IDs.*/
|
||||
if (!ws_cpuid(CPUInfo, 0x80000000))
|
||||
return;
|
||||
nExIds = CPUInfo[0];
|
||||
|
||||
if( nExIds<0x80000005)
|
||||
return;
|
||||
memset(CPUBrandString, 0, sizeof(CPUBrandString));
|
||||
|
||||
/* Interpret CPU brand string.*/
|
||||
ws_cpuid(CPUInfo, 0x80000002);
|
||||
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||
ws_cpuid(CPUInfo, 0x80000003);
|
||||
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
|
||||
ws_cpuid(CPUInfo, 0x80000004);
|
||||
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
|
||||
|
||||
g_string_append_printf(str, "\n%s", CPUBrandString);
|
||||
|
||||
if (ws_cpuid_sse42())
|
||||
g_string_append(str, " (with SSE4.2)");
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,39 +0,0 @@
|
|||
/* cpu_info.h
|
||||
* Declarations of outines to report information about the CPU on which
|
||||
* we're running
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __WSUTIL_CPU_INFO_H__
|
||||
#define __WSUTIL_CPU_INFO_H__
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
WS_DLL_PUBLIC void get_cpu_info(GString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __WSUTIL_CPU_INFO_H__ */
|
|
@ -1,56 +0,0 @@
|
|||
/* glib_version_info.c
|
||||
* Routines to report GLib version information
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <wsutil/glib_version_info.h>
|
||||
|
||||
/*
|
||||
* Get the GLib version, and append it to the GString
|
||||
*/
|
||||
void
|
||||
get_glib_version_info(GString *str)
|
||||
{
|
||||
/* GLIB */
|
||||
g_string_append(str, "with ");
|
||||
g_string_append_printf(str,
|
||||
#ifdef GLIB_MAJOR_VERSION
|
||||
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
|
||||
GLIB_MICRO_VERSION);
|
||||
#else
|
||||
"GLib (version unknown)");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,42 +0,0 @@
|
|||
/* glib_version_info.h
|
||||
* Declarations of outines to report GLib version information
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __WSUTIL_GLIB_VERSION_INFO_H__
|
||||
#define __WSUTIL_GLIB_VERSION_INFO_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Get the GLib version, and append it to a GString.
|
||||
*/
|
||||
WS_DLL_PUBLIC void get_glib_version_info(GString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __WSUTIL_GLIB_VERSION_INFO_H__ */
|
|
@ -1,58 +0,0 @@
|
|||
/* mem_info.c
|
||||
* Routines to report version information about how much memory the
|
||||
* machine on which we're running has
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/mem_info.h>
|
||||
|
||||
void
|
||||
get_mem_info(GString *str _U_)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MEMORYSTATUSEX statex;
|
||||
|
||||
statex.dwLength = sizeof (statex);
|
||||
|
||||
if (GlobalMemoryStatusEx(&statex))
|
||||
g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local variables:
|
||||
* c-basic-offset: 8
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
||||
* :indentSize=8:tabSize=8:noTabs=false:
|
||||
*/
|
|
@ -1,39 +0,0 @@
|
|||
/* mem_info.h
|
||||
* Declarations of outines to report information about how much memory
|
||||
* the machine on which we're running has
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef __WSUTIL_MEM_INFO_H__
|
||||
#define __WSUTIL_MEM_INFO_H__
|
||||
|
||||
#include "ws_symbol_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
WS_DLL_PUBLIC void get_mem_info(GString *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __WSUTIL_MEM_INFO_H__ */
|
|
@ -26,16 +26,17 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <wsutil/ws_version_info.h>
|
||||
|
||||
#include <wsutil/ws_cpuid.h>
|
||||
#include <wsutil/copyright_info.h>
|
||||
#include <wsutil/glib_version_info.h>
|
||||
#include <wsutil/os_version_info.h>
|
||||
#include <wsutil/compiler_info.h>
|
||||
#include <wsutil/cpu_info.h>
|
||||
#include <wsutil/mem_info.h>
|
||||
|
||||
/*
|
||||
* If the string doesn't end with a newline, append one.
|
||||
|
@ -67,6 +68,23 @@ end_string(GString *str)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the GLib version, and append it to the GString
|
||||
*/
|
||||
void
|
||||
get_glib_version_info(GString *str)
|
||||
{
|
||||
/* GLIB */
|
||||
g_string_append(str, "with ");
|
||||
g_string_append_printf(str,
|
||||
#ifdef GLIB_MAJOR_VERSION
|
||||
"GLib %d.%d.%d", GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION,
|
||||
GLIB_MICRO_VERSION);
|
||||
#else
|
||||
"GLib (version unknown)");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Get various library compile-time versions, put them in a GString,
|
||||
* and return the GString.
|
||||
|
@ -110,6 +128,137 @@ get_compiled_version_info(void (*prepend_info)(GString *),
|
|||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the CPU info, and append it to the GString
|
||||
*/
|
||||
static void
|
||||
get_cpu_info(GString *str _U_)
|
||||
{
|
||||
guint32 CPUInfo[4];
|
||||
char CPUBrandString[0x40];
|
||||
unsigned nExIds;
|
||||
|
||||
/* http://msdn.microsoft.com/en-us/library/hskdteyh(v=vs.100).aspx */
|
||||
|
||||
/* Calling __cpuid with 0x80000000 as the InfoType argument*/
|
||||
/* gets the number of valid extended IDs.*/
|
||||
if (!ws_cpuid(CPUInfo, 0x80000000))
|
||||
return;
|
||||
nExIds = CPUInfo[0];
|
||||
|
||||
if( nExIds<0x80000005)
|
||||
return;
|
||||
memset(CPUBrandString, 0, sizeof(CPUBrandString));
|
||||
|
||||
/* Interpret CPU brand string.*/
|
||||
ws_cpuid(CPUInfo, 0x80000002);
|
||||
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
|
||||
ws_cpuid(CPUInfo, 0x80000003);
|
||||
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
|
||||
ws_cpuid(CPUInfo, 0x80000004);
|
||||
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
|
||||
|
||||
g_string_append_printf(str, "\n%s", CPUBrandString);
|
||||
|
||||
if (ws_cpuid_sse42())
|
||||
g_string_append(str, " (with SSE4.2)");
|
||||
}
|
||||
|
||||
static void
|
||||
get_mem_info(GString *str _U_)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
MEMORYSTATUSEX statex;
|
||||
|
||||
statex.dwLength = sizeof (statex);
|
||||
|
||||
if (GlobalMemoryStatusEx(&statex))
|
||||
g_string_append_printf(str, ", with ""%" G_GINT64_MODIFIER "d" "MB of physical memory.\n", statex.ullTotalPhys/(1024*1024));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Get compiler information, and append it to the GString.
|
||||
*/
|
||||
static void
|
||||
get_compiler_info(GString *str)
|
||||
{
|
||||
/*
|
||||
* See https://sourceforge.net/apps/mediawiki/predef/index.php?title=Compilers
|
||||
* information on various defined strings.
|
||||
*
|
||||
* GCC's __VERSION__ is a nice text string for humans to
|
||||
* read. The page at sourceforge.net largely describes
|
||||
* numeric #defines that encode the version; if the compiler
|
||||
* doesn't also offer a nice printable string, we try prettifying
|
||||
* the number somehow.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__VERSION__)
|
||||
/*
|
||||
* Clang and llvm-gcc also define __GNUC__ and __VERSION__;
|
||||
* distinguish between them.
|
||||
*/
|
||||
#if defined(__clang__)
|
||||
g_string_append_printf(str, "\n\nBuilt using clang %s.\n", __VERSION__);
|
||||
#elif defined(__llvm__)
|
||||
g_string_append_printf(str, "\n\nBuilt using llvm-gcc %s.\n", __VERSION__);
|
||||
#else /* boring old GCC */
|
||||
g_string_append_printf(str, "\n\nBuilt using gcc %s.\n", __VERSION__);
|
||||
#endif /* llvm */
|
||||
#elif defined(__HP_aCC)
|
||||
g_string_append_printf(str, "\n\nBuilt using HP aCC %d.\n", __HP_aCC);
|
||||
#elif defined(__xlC__)
|
||||
g_string_append_printf(str, "\n\nBuilt using IBM XL C %d.%d\n",
|
||||
(__xlC__ >> 8) & 0xFF, __xlC__ & 0xFF);
|
||||
#ifdef __IBMC__
|
||||
if ((__IBMC__ % 10) != 0)
|
||||
g_string_append_printf(str, " patch %d", __IBMC__ % 10);
|
||||
#endif /* __IBMC__ */
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
g_string_append_printf(str, "\n\nBuilt using Intel C %d.%d",
|
||||
__INTEL_COMPILER / 100, (__INTEL_COMPILER / 10) % 10);
|
||||
if ((__INTEL_COMPILER % 10) != 0)
|
||||
g_string_append_printf(str, " patch %d", __INTEL_COMPILER % 10);
|
||||
#ifdef __INTEL_COMPILER_BUILD_DATE
|
||||
g_string_sprinta(str, ", compiler built %04d-%02d-%02d",
|
||||
__INTEL_COMPILER_BUILD_DATE / 10000,
|
||||
(__INTEL_COMPILER_BUILD_DATE / 100) % 100,
|
||||
__INTEL_COMPILER_BUILD_DATE % 100);
|
||||
#endif /* __INTEL_COMPILER_BUILD_DATE */
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(_MSC_FULL_VER)
|
||||
# if _MSC_FULL_VER > 99999999
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
|
||||
(_MSC_FULL_VER / 10000000) - 6,
|
||||
(_MSC_FULL_VER / 100000) % 100);
|
||||
# if (_MSC_FULL_VER % 100000) != 0
|
||||
g_string_append_printf(str, " build %d",
|
||||
_MSC_FULL_VER % 100000);
|
||||
# endif
|
||||
# else
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d",
|
||||
(_MSC_FULL_VER / 1000000) - 6,
|
||||
(_MSC_FULL_VER / 10000) % 100);
|
||||
# if (_MSC_FULL_VER % 10000) != 0
|
||||
g_string_append_printf(str, " build %d",
|
||||
_MSC_FULL_VER % 10000);
|
||||
# endif
|
||||
# endif
|
||||
g_string_append_printf(str, "\n");
|
||||
#elif defined(_MSC_VER)
|
||||
/* _MSC_FULL_VER not defined, but _MSC_VER defined */
|
||||
g_string_append_printf(str, "\n\nBuilt using Microsoft Visual C++ %d.%d\n",
|
||||
(_MSC_VER / 100) - 6, _MSC_VER % 100);
|
||||
#elif defined(__SUNPRO_C)
|
||||
g_string_append_printf(str, "\n\nBuilt using Sun C %d.%d",
|
||||
(__SUNPRO_C >> 8) & 0xF, (__SUNPRO_C >> 4) & 0xF);
|
||||
if ((__SUNPRO_C & 0xF) != 0)
|
||||
g_string_append_printf(str, " patch %d", __SUNPRO_C & 0xF);
|
||||
g_string_append_printf(str, "\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Get various library run-time versions, and the OS version, and append
|
||||
* them to the specified GString.
|
||||
|
|
Loading…
Reference in New Issue