mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
3396c97da9
Now that the new CMake build system is encouraging us to lay out the code like a set of libraries, it seems like a good idea to make them look more _like_ libraries, by putting things into separate modules as far as possible. This fixes several previous annoyances in which you had to link against some object in order to get a function you needed, but that object also contained other functions you didn't need which included link-time symbol references you didn't want to have to deal with. The usual offender was subsidiary supporting programs including misc.c for some innocuous function and then finding they had to deal with the requirements of buildinfo(). This big reorganisation introduces three new subdirectories called 'utils', one at the top level and one in each platform subdir. In each case, the directory contains basically the same files that were previously placed in the 'utils' build-time library, except that the ones that were extremely miscellaneous (misc.c, utils.c, uxmisc.c, winmisc.c, winmiscs.c, winutils.c) have been split up into much smaller pieces.
66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/*
|
|
* Header included only by arm_arch_queries.c.
|
|
*
|
|
* The only reason this is a header file instead of a source file is
|
|
* so that I can define 'static inline' functions which may or may not
|
|
* be used, without provoking a compiler warning when I turn out not
|
|
* to use them in the subsequent source file.
|
|
*/
|
|
|
|
#ifndef PUTTY_ARM_ARCH_QUERIES_H
|
|
#define PUTTY_ARM_ARCH_QUERIES_H
|
|
|
|
#if defined __APPLE__
|
|
#if HAVE_SYS_SYSCTL_H
|
|
#include <sys/sysctl.h>
|
|
#endif
|
|
#endif /* defined __APPLE__ */
|
|
|
|
#if defined __arm__ || defined __aarch64__
|
|
|
|
#if HAVE_SYS_TYPES_H
|
|
#include <sys/types.h>
|
|
#endif
|
|
|
|
#if HAVE_SYS_AUXV_H
|
|
#include <sys/auxv.h>
|
|
#endif
|
|
|
|
#if HAVE_ASM_HWCAP_H
|
|
#include <asm/hwcap.h>
|
|
#endif
|
|
|
|
#if HAVE_GETAUXVAL
|
|
/* No code needed: getauxval has just the API we want already */
|
|
#elif HAVE_ELF_AUX_INFO
|
|
/* Implement the simple getauxval API in terms of FreeBSD elf_aux_info */
|
|
static inline u_long getauxval(int which)
|
|
{
|
|
u_long toret;
|
|
if (elf_aux_info(which, &toret, sizeof(toret)) != 0)
|
|
return 0; /* elf_aux_info didn't work */
|
|
return toret;
|
|
}
|
|
#else
|
|
/* Implement a stub getauxval which returns no capabilities */
|
|
static inline u_long getauxval(int which) { return 0; }
|
|
#endif
|
|
|
|
#endif /* defined __arm__ || defined __aarch64__ */
|
|
|
|
#if defined __APPLE__
|
|
static inline bool test_sysctl_flag(const char *flagname)
|
|
{
|
|
#if HAVE_SYSCTLBYNAME
|
|
int value;
|
|
size_t size = sizeof(value);
|
|
return (sysctlbyname(flagname, &value, &size, NULL, 0) == 0 &&
|
|
size == sizeof(value) && value != 0);
|
|
#else /* HAVE_SYSCTLBYNAME */
|
|
return false;
|
|
#endif /* HAVE_SYSCTLBYNAME */
|
|
}
|
|
#endif /* defined __APPLE__ */
|
|
|
|
#endif /* PUTTY_ARM_ARCH_QUERIES_H */
|