aboutsummaryrefslogtreecommitdiffstats
path: root/system_cmds/getconf.tproj/progenv.gperf
blob: 4e3245a8cb38ce2ff8e5577ee19454a6e2733bac (plain) (blame)
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
67
68
69
70
%{
/*
 * Copyright is disclaimed as to the contents of this file.
 *
 * $FreeBSD: src/usr.bin/getconf/progenv.gperf,v 1.2 2003/08/22 17:32:07 markm Exp $
 */

#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.)
 */
#if defined(__alpha__) || defined(__sparc64__)
#define	have_LP64_OFF64		NULL
#elif defined(__APPLE__)
#define	have_LP64_OFF64		NULL
#define	have_LPBIG_OFFBIG	NULL
#endif

#if defined(__i386__) || defined(__powerpc__) || defined(__x86_64__)
#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, have_LPBIG_OFFBIG
_POSIX_V6_ILP32_OFF32, notdef
_POSIX_V6_ILP32_OFFBIG, have_ILP32_OFFBIG
_POSIX_V6_LP64_OFF64, have_LP64_OFF64
_POSIX_V6_LPBIG_OFFBIG, have_LPBIG_OFFBIG
%%
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;
}