freebsd-dev/usr.bin/getconf/progenv.gperf
Enji Cooper 7250a09527 Expose the ILP32/LP64 programming environments based on
__ILP32__/__LP64__ instead of by architecture.

The list was incomplete (previous commits purged invalid architectures,
like __alpha__, but failed to add new ones). It's best to base the symbol
presence on whether or not the architecture is ILP32 / LP64 capable, per
the compiler.

This fixes the ILP32/LP64 program environments on some architectures like
arm64, and by proxy fixes the tests on those architectures.

MFC after:	1 month
Reviewed by:	no one (timed out on feedback from imp)
Differential Revision:	D10787
2017-07-17 18:12:08 +00:00

68 lines
1.4 KiB
Plaintext

%{
/*
* Copyright is disclaimed as to the contents of this file.
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <string.h>
#include <unistd.h>
#include "getconf.h"
/*
* Override gperf's built-in external scope.
*/
static const struct map *in_word_set(const char *str);
/*
* The Standard seems a bit ambiguous over whether the POSIX_V6_*
* are specified with or without a leading underscore, so we just
* use both.
*/
/*
* The alt_path member gives the path containing another `getconf'
* executable which was compiled using the specified programming
* environment. If it is NULL, the current executable is good enough.
* If we ever support multiple environments, this table will need to
* be updated. (We cheat here and define the supported environments
* statically.)
*/
#ifdef __LP64__
#define have_LP64_OFF64 NULL
#endif
#ifdef __ILP32__
#define have_ILP32_OFFBIG NULL
#endif
%}
struct map { const char *name; const char *alt_path; int valid; };
%%
POSIX_V6_ILP32_OFF32, notdef
POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
POSIX_V6_LP64_OFF64, have_LP64_OFF64
POSIX_V6_LPBIG_OFFBIG, notdef
_POSIX_V6_ILP32_OFF32, notdef
_POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
_POSIX_V6_LP64_OFF64, have_LP64_OFF64
_POSIX_V6_LPBIG_OFFBIG, notdef
%%
int
find_progenv(const char *name, const char **alt_path)
{
const struct map *rv;
rv = in_word_set(name);
if (rv != NULL) {
if (rv->valid) {
*alt_path = rv->alt_path;
return 1;
}
return -1;
}
return 0;
}