diff options
author | Vijay Kumar Banerjee <vijaykumar9597@gmail.com> | 2019-06-25 12:43:43 +0530 |
---|---|---|
committer | Christian Mauderer <oss@c-mauderer.de> | 2019-06-29 10:31:01 +0200 |
commit | 4ed60d9076b23307cc86da136562cdc741370d50 (patch) | |
tree | 75f806ae4354927037fbb060413dab597ea191d8 /freebsd/usr.sbin/i2c | |
parent | i2c tool : Import from FreeBSD (diff) | |
download | rtems-libbsd-4ed60d9076b23307cc86da136562cdc741370d50.tar.bz2 |
i2c tool : port to RTEMS
Diffstat (limited to '')
-rw-r--r-- | freebsd/usr.sbin/i2c/i2c.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/freebsd/usr.sbin/i2c/i2c.c b/freebsd/usr.sbin/i2c/i2c.c index 084682a1..840f78f6 100644 --- a/freebsd/usr.sbin/i2c/i2c.c +++ b/freebsd/usr.sbin/i2c/i2c.c @@ -28,6 +28,13 @@ * SUCH DAMAGE. */ +#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/cdefs.h> __FBSDID("$FreeBSD$"); @@ -560,6 +567,24 @@ err2: return (1); } +#ifdef __rtems__ +static int main(int argc, char *argv[]); + +int +rtems_bsd_command_i2c(int argc, char *argv[]) +{ + int exit_code; + void *data_begin; + size_t data_size; + + rtems_bsd_program_lock(); + exit_code = rtems_bsd_program_call_main("i2c", main, argc, argv); + rtems_bsd_program_unlock(); + + return exit_code; +} +#endif /* __rtems__ */ + int main(int argc, char** argv) { @@ -568,6 +593,16 @@ main(int argc, char** argv) char *dev, *skip_addr, *i2c_buf; int error, chunk_size, i, j, ch; +#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__ */ + errno = 0; error = 0; |