diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-28 14:27:45 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-13 17:49:51 +0200 |
commit | 7fffea101f878d7040fec4347d52544f6994b042 (patch) | |
tree | c247f970ddb27e39d595461cba3ff68a1c807fac | |
parent | a52ccc23e3c97e752cfabe7edebe05331b0d94e4 (diff) | |
download | sparse-7fffea101f878d7040fec4347d52544f6994b042.tar.gz |
arch: add an option to specify the OS: --os=$OS
This is not needed when doing native 'compilation' but is
quite handy when testing the predefined types & macros.
The supported OSes are: 'linux', 'freebsd', 'openbsd', 'netbsd'
'darwin', 'sunos', 'cygwin' and a generic 'unix'.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | machine.h | 1 | ||||
-rw-r--r-- | options.c | 11 | ||||
-rw-r--r-- | sparse.1 | 10 | ||||
-rw-r--r-- | target.c | 29 | ||||
-rw-r--r-- | target.h | 1 |
5 files changed, 52 insertions, 0 deletions
@@ -94,6 +94,7 @@ enum fp_abi { enum { OS_UNKNOWN, + OS_NONE, OS_UNIX, OS_CYGWIN, OS_DARWIN, @@ -925,6 +925,16 @@ static char **handle_param(char *arg, char **next) return next; } +static char **handle_os(char *arg, char **next) +{ + if (*arg++ != '=') + die("missing argument for --os option"); + + target_os(arg); + + return next; +} + static char **handle_version(char *arg, char **next) { printf("%s\n", SPARSE_VERSION); @@ -941,6 +951,7 @@ static char **handle_long_options(char *arg, char **next) { static struct switches cmd[] = { { "arch", handle_arch, 1 }, + { "os", handle_os, 1 }, { "param", handle_param, 1 }, { "version", handle_version }, { NULL, NULL } @@ -464,6 +464,16 @@ Look for system headers in the multiarch subdirectory \fIdir\fR. The \fIdir\fR name would normally take the form of the target's normalized GNU triplet. (e.g. i386-linux-gnu). . +.TP +.B --os=\fIOS\fR +Specify the target Operating System. +This only makes a few differences with the predefined types. +The accepted values are: linux, unix, freebsd, netbsd, opensd, sunos, darwin +and cygwin. + +The default OS is the one of the machine used to build Sparse if it can be +detected, otherwise some generic settings are used. +. .SH DEBUG OPTIONS .TP .B \-fmem-report @@ -136,6 +136,35 @@ enum machine target_parse(const char *name) return MACH_UNKNOWN; } +void target_os(const char *name) +{ + static const struct os { + const char *name; + int os; + } oses[] = { + { "cygwin", OS_CYGWIN }, + { "darwin", OS_DARWIN }, + { "freebsd", OS_FREEBSD }, + { "linux", OS_LINUX }, + { "native", OS_NATIVE, }, + { "netbsd", OS_NETBSD }, + { "none", OS_NONE }, + { "openbsd", OS_OPENBSD }, + { "sunos", OS_SUNOS }, + { "unix", OS_UNIX }, + { NULL }, + }, *p; + + for (p = &oses[0]; p->name; p++) { + if (!strcmp(p->name, name)) { + arch_os = p->os; + return; + } + } + + die("invalid os: %s", name); +} + void target_config(enum machine mach) { @@ -105,6 +105,7 @@ extern const struct target target_x86_64; extern const struct target *arch_target; enum machine target_parse(const char *name); +void target_os(const char *name); void target_config(enum machine mach); void target_init(void); |