[PATCH v2 3/7] Updating STTY command for use in RTEMS shell
Kevin Kirspel
kevin-kirspel at idexx.com
Fri Apr 7 16:49:56 UTC 2017
---
freebsd/bin/stty/cchar.c | 9 ++++++
freebsd/bin/stty/gfmt.c | 6 ++++
freebsd/bin/stty/key.c | 9 ++++++
freebsd/bin/stty/modes.c | 9 ++++++
freebsd/bin/stty/print.c | 9 ++++++
freebsd/bin/stty/rtems-bsd-stty-cchar-data.h | 4 +++
freebsd/bin/stty/rtems-bsd-stty-data.h | 11 +++++++
freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h | 4 +++
freebsd/bin/stty/rtems-bsd-stty-key-data.h | 5 +++
freebsd/bin/stty/rtems-bsd-stty-modes-data.h | 4 +++
freebsd/bin/stty/rtems-bsd-stty-namespace.h | 34 ++++++++++++++++++++
freebsd/bin/stty/rtems-bsd-stty-print-data.h | 6 ++++
freebsd/bin/stty/rtems-bsd-stty-stty-data.h | 4 +++
freebsd/bin/stty/rtems-bsd-stty-util-data.h | 4 +++
freebsd/bin/stty/stty.c | 48 ++++++++++++++++++++++++++++
freebsd/bin/stty/util.c | 9 ++++++
16 files changed, 175 insertions(+)
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-cchar-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-key-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-modes-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-namespace.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-print-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-stty-data.h
create mode 100644 freebsd/bin/stty/rtems-bsd-stty-util-data.h
diff --git a/freebsd/bin/stty/cchar.c b/freebsd/bin/stty/cchar.c
index 4a925da..7335cc3 100644
--- a/freebsd/bin/stty/cchar.c
+++ b/freebsd/bin/stty/cchar.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,6 +40,9 @@ static char sccsid[] = "@(#)cchar.c 8.5 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>
@@ -47,6 +53,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-cchar-data.h"
+#endif /* __rtems__ */
static int c_cchar(const void *, const void *);
diff --git a/freebsd/bin/stty/gfmt.c b/freebsd/bin/stty/gfmt.c
index 57adc1e..7ffaf95 100644
--- a/freebsd/bin/stty/gfmt.c
+++ b/freebsd/bin/stty/gfmt.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,6 +40,9 @@ static char sccsid[] = "@(#)gfmt.c 8.6 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>
diff --git a/freebsd/bin/stty/key.c b/freebsd/bin/stty/key.c
index 1023fa6..cae0433 100644
--- a/freebsd/bin/stty/key.c
+++ b/freebsd/bin/stty/key.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,6 +40,9 @@ static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <err.h>
@@ -96,6 +102,9 @@ static struct key {
{ "speed", f_speed, 0 },
{ "tty", f_tty, 0 },
};
+#ifdef __rtems__
+#include "rtems-bsd-stty-key-data.h"
+#endif /* __rtems__ */
static int
c_key(const void *a, const void *b)
diff --git a/freebsd/bin/stty/modes.c b/freebsd/bin/stty/modes.c
index 79a0ed8..e1536d5 100644
--- a/freebsd/bin/stty/modes.c
+++ b/freebsd/bin/stty/modes.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,10 +40,16 @@ static char sccsid[] = "@(#)modes.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <stddef.h>
#include <string.h>
#include "stty.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-modes-data.h"
+#endif /* __rtems__ */
int msearch(char ***, struct info *);
diff --git a/freebsd/bin/stty/print.c b/freebsd/bin/stty/print.c
index 770c5b5..d60f4ea 100644
--- a/freebsd/bin/stty/print.c
+++ b/freebsd/bin/stty/print.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,6 +40,9 @@ static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <stddef.h>
@@ -45,6 +51,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-print-data.h"
+#endif /* __rtems__ */
static void binit(const char *);
static void bput(const char *);
diff --git a/freebsd/bin/stty/rtems-bsd-stty-cchar-data.h b/freebsd/bin/stty/rtems-bsd-stty-cchar-data.h
new file mode 100644
index 0000000..19661a7
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-cchar-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* cchar.c */
diff --git a/freebsd/bin/stty/rtems-bsd-stty-data.h b/freebsd/bin/stty/rtems-bsd-stty-data.h
new file mode 100644
index 0000000..8bad70a
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-data.h
@@ -0,0 +1,11 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+/* cchar.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars1[]);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, extern struct cchar cchars2[]);
+/* gfmt.c */
+/* key.c */
+/* modes.c */
+/* print.c */
+/* stty.c */
+/* util.c */
diff --git a/freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h b/freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h
new file mode 100644
index 0000000..f2c1358
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-gfmt-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* gfmt.c */
diff --git a/freebsd/bin/stty/rtems-bsd-stty-key-data.h b/freebsd/bin/stty/rtems-bsd-stty-key-data.h
new file mode 100644
index 0000000..848ee78
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-key-data.h
@@ -0,0 +1,5 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* key.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static struct key keys[20]);
diff --git a/freebsd/bin/stty/rtems-bsd-stty-modes-data.h b/freebsd/bin/stty/rtems-bsd-stty-modes-data.h
new file mode 100644
index 0000000..29762ce
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-modes-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* modes.c */
diff --git a/freebsd/bin/stty/rtems-bsd-stty-namespace.h b/freebsd/bin/stty/rtems-bsd-stty-namespace.h
new file mode 100644
index 0000000..c927248
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-namespace.h
@@ -0,0 +1,34 @@
+/* generated by userspace-header-gen.py */
+/* cchar.c */
+#define cchars1 _bsd_stty_cchars1
+#define cchars2 _bsd_stty_cchars2
+#define csearch _bsd_stty_csearch
+/* gfmt.c */
+#define gread _bsd_stty_gread
+#define gprint _bsd_stty_gprint
+/* key.c */
+#define f_tty _bsd_stty_f_tty
+#define f_speed _bsd_stty_f_speed
+#define f_size _bsd_stty_f_size
+#define f_sane _bsd_stty_f_sane
+#define f_rows _bsd_stty_f_rows
+#define f_raw _bsd_stty_f_raw
+#define f_ospeed _bsd_stty_f_ospeed
+#define f_nl _bsd_stty_f_nl
+#define f_ispeed _bsd_stty_f_ispeed
+#define f_extproc _bsd_stty_f_extproc
+#define f_everything _bsd_stty_f_everything
+#define f_ek _bsd_stty_f_ek
+#define f_dec _bsd_stty_f_dec
+#define f_columns _bsd_stty_f_columns
+#define f_cbreak _bsd_stty_f_cbreak
+#define f_all _bsd_stty_f_all
+#define ksearch _bsd_stty_ksearch
+/* modes.c */
+#define msearch _bsd_stty_msearch
+/* print.c */
+#define print _bsd_stty_print
+/* stty.c */
+#define usage _bsd_stty_usage
+/* util.c */
+#define checkredirect _bsd_stty_checkredirect
diff --git a/freebsd/bin/stty/rtems-bsd-stty-print-data.h b/freebsd/bin/stty/rtems-bsd-stty-print-data.h
new file mode 100644
index 0000000..fb6d0e6
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-print-data.h
@@ -0,0 +1,6 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* print.c */
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static int col);
+RTEMS_LINKER_RWSET_CONTENT(bsd_prog_stty, static char const *label);
diff --git a/freebsd/bin/stty/rtems-bsd-stty-stty-data.h b/freebsd/bin/stty/rtems-bsd-stty-stty-data.h
new file mode 100644
index 0000000..c325685
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-stty-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* stty.c */
diff --git a/freebsd/bin/stty/rtems-bsd-stty-util-data.h b/freebsd/bin/stty/rtems-bsd-stty-util-data.h
new file mode 100644
index 0000000..146095b
--- /dev/null
+++ b/freebsd/bin/stty/rtems-bsd-stty-util-data.h
@@ -0,0 +1,4 @@
+/* generated by userspace-header-gen.py */
+#include <rtems/linkersets.h>
+#include "rtems-bsd-stty-data.h"
+/* util.c */
diff --git a/freebsd/bin/stty/stty.c b/freebsd/bin/stty/stty.c
index f7b9ab5..5cf8e56 100644
--- a/freebsd/bin/stty/stty.c
+++ b/freebsd/bin/stty/stty.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1989, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -43,6 +46,12 @@ static char sccsid[] = "@(#)stty.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#define __need_getopt_newlib
+#include <getopt.h>
+#include <machine/rtems-bsd-program.h>
+#include <machine/rtems-bsd-commands.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <ctype.h>
@@ -57,7 +66,33 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-stty-data.h"
+#endif /* __rtems__ */
+#ifdef __rtems__
+static int main(int argc, char *argv[]);
+
+RTEMS_LINKER_RWSET(bsd_prog_stty, char);
+
+int
+rtems_bsd_command_stty(int argc, char *argv[])
+{
+ int exit_code;
+ void *data_begin;
+ size_t data_size;
+
+ data_begin = RTEMS_LINKER_SET_BEGIN(bsd_prog_stty);
+ data_size = RTEMS_LINKER_SET_SIZE(bsd_prog_stty);
+
+ rtems_bsd_program_lock();
+ exit_code = rtems_bsd_program_call_main_with_data_restore("stty",
+ main, argc, argv, data_begin, data_size);
+ rtems_bsd_program_unlock();
+
+ return exit_code;
+}
+#endif /* __rtems__ */
int
main(int argc, char *argv[])
{
@@ -65,6 +100,15 @@ main(int argc, char *argv[])
enum FMT fmt;
int ch;
const char *file, *errstr = NULL;
+#ifdef __rtems__
+ struct getopt_data getopt_data;
+ memset(&getopt_data, 0, sizeof(getopt_data));
+#define optind getopt_data.optind
+#define optarg getopt_data.optarg
+#define opterr getopt_data.opterr
+#define optopt getopt_data.optopt
+#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
+#endif /* __rtems__ */
fmt = NOTSET;
i.fd = STDIN_FILENO;
@@ -72,7 +116,11 @@ main(int argc, char *argv[])
opterr = 0;
while (optind < argc &&
+#ifndef __rtems__
strspn(argv[optind], "-aefg") == strlen(argv[optind]) &&
+#else /* __rtems__ */
+ strspn(argv[optind == 0 ? 1 : optind], "-aefg") == strlen(argv[optind == 0 ? 1 : optind]) &&
+#endif /* __rtems__ */
(ch = getopt(argc, argv, "aef:g")) != -1)
switch(ch) {
case 'a': /* undocumented: POSIX compatibility */
diff --git a/freebsd/bin/stty/util.c b/freebsd/bin/stty/util.c
index 2cdc7d9..4fd1897 100644
--- a/freebsd/bin/stty/util.c
+++ b/freebsd/bin/stty/util.c
@@ -1,5 +1,8 @@
#include <machine/rtems-bsd-user-space.h>
+#ifdef __rtems__
+#include "rtems-bsd-stty-namespace.h"
+#endif /* __rtems__ */
/*-
* Copyright (c) 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
@@ -37,6 +40,9 @@ static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#ifdef __rtems__
+#include <machine/rtems-bsd-program.h>
+#endif /* __rtems__ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -47,6 +53,9 @@ __FBSDID("$FreeBSD$");
#include "stty.h"
#include "extern.h"
+#ifdef __rtems__
+#include "rtems-bsd-stty-util-data.h"
+#endif /* __rtems__ */
/*
* Gross, but since we're changing the control descriptor from 1 to 0, most
--
1.9.1
More information about the devel
mailing list