[rtems-libbsd commit] subr_prf.c: Port to RTEMS.
Sebastian Huber
sebh at rtems.org
Wed Aug 3 12:44:14 UTC 2016
Module: rtems-libbsd
Branch: 4.11
Commit: 48cac54035d10b1d6bca47b9b4600fe001f76ecf
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=48cac54035d10b1d6bca47b9b4600fe001f76ecf
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed May 4 13:04:42 2016 +0200
subr_prf.c: Port to RTEMS.
Note: Only the XXsYYprintf functions have been back ported from 4.12.
---
freebsd/sys/kern/subr_prf.c | 16 ++++++++++++++++
freebsd/sys/libkern/bcd.c | 40 ++++++++++++++++++++++++++++++++++++++++
libbsd.py | 2 ++
wscript | 2 ++
4 files changed, 60 insertions(+)
diff --git a/freebsd/sys/kern/subr_prf.c b/freebsd/sys/kern/subr_prf.c
index 0df816e..dfbf24c 100644
--- a/freebsd/sys/kern/subr_prf.c
+++ b/freebsd/sys/kern/subr_prf.c
@@ -49,15 +49,21 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/sx.h>
#include <sys/kernel.h>
+#ifndef __rtems__
#include <sys/msgbuf.h>
+#endif /* __rtems__ */
#include <sys/malloc.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/stddef.h>
#include <sys/sysctl.h>
+#ifndef __rtems__
#include <sys/tty.h>
+#endif /* __rtems__ */
#include <sys/syslog.h>
+#ifndef __rtems__
#include <sys/cons.h>
+#endif /* __rtems__ */
#include <sys/uio.h>
#include <sys/ctype.h>
@@ -71,13 +77,16 @@ __FBSDID("$FreeBSD$");
*/
#include <machine/stdarg.h>
+#ifndef __rtems__
#define TOCONS 0x01
#define TOTTY 0x02
#define TOLOG 0x04
+#endif /* __rtems__ */
/* Max number conversion buffer length: a u_quad_t in base 2, plus NUL byte. */
#define MAXNBUF (sizeof(intmax_t) * NBBY + 1)
+#ifndef __rtems__
struct putchar_arg {
int flags;
int pri;
@@ -87,20 +96,24 @@ struct putchar_arg {
char *p_next;
size_t remain;
};
+#endif /* __rtems__ */
struct snprintf_arg {
char *str;
size_t remain;
};
+#ifndef __rtems__
extern int log_open;
static void msglogchar(int c, int pri);
static void msglogstr(char *str, int pri, int filter_cr);
static void putchar(int ch, void *arg);
+#endif /* __rtems__ */
static char *ksprintn(char *nbuf, uintmax_t num, int base, int *len, int upper);
static void snprintf_func(int ch, void *arg);
+#ifndef __rtems__
static int msgbufmapped; /* Set when safe to use msgbuf */
int msgbuftrigger;
@@ -474,6 +487,7 @@ putchar(int c, void *arg)
putbuf(c, ap);
}
}
+#endif /* __rtems__ */
/*
* Scaled down version of sprintf(3).
@@ -927,6 +941,7 @@ number:
#undef PCHAR
}
+#ifndef __rtems__
/*
* Put character in log buffer with a particular priority.
*/
@@ -1124,3 +1139,4 @@ hexdump(const void *ptr, int length, const char *hdr, int flags)
}
}
+#endif /* __rtems__ */
diff --git a/freebsd/sys/libkern/bcd.c b/freebsd/sys/libkern/bcd.c
new file mode 100644
index 0000000..df4abad
--- /dev/null
+++ b/freebsd/sys/libkern/bcd.c
@@ -0,0 +1,40 @@
+#include <machine/rtems-bsd-kernel-space.h>
+
+/*-
+ * Some data-tables that are often used.
+ * Cannot be copyrighted.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/libkern.h>
+
+u_char const bcd2bin_data[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, 0,
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0,
+ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, 0, 0, 0, 0, 0,
+ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 0, 0, 0, 0, 0,
+ 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 0, 0, 0, 0, 0, 0,
+ 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 0, 0, 0, 0, 0, 0,
+ 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 0, 0, 0, 0, 0,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0,
+ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99
+};
+
+u_char const bin2bcd_data[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
+ 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
+ 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
+ 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89,
+ 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99
+};
+
+/* This is actually used with radix [2..36] */
+char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
diff --git a/libbsd.py b/libbsd.py
index ebbdc98..b4ac37e 100755
--- a/libbsd.py
+++ b/libbsd.py
@@ -309,6 +309,7 @@ def base(mm):
'sys/kern/subr_kobj.c',
'sys/kern/subr_lock.c',
'sys/kern/subr_module.c',
+ 'sys/kern/subr_prf.c',
'sys/kern/subr_rman.c',
'sys/kern/subr_sbuf.c',
'sys/kern/subr_sleepqueue.c',
@@ -323,6 +324,7 @@ def base(mm):
'sys/kern/uipc_sockbuf.c',
'sys/kern/uipc_socket.c',
'sys/kern/uipc_usrreq.c',
+ 'sys/libkern/bcd.c',
'sys/libkern/arc4random.c',
'sys/libkern/fls.c',
'sys/libkern/inet_ntoa.c',
diff --git a/wscript b/wscript
index afe02a1..a7ed7c5 100644
--- a/wscript
+++ b/wscript
@@ -757,6 +757,7 @@ def build(bld):
'freebsd/sys/kern/subr_kobj.c',
'freebsd/sys/kern/subr_lock.c',
'freebsd/sys/kern/subr_module.c',
+ 'freebsd/sys/kern/subr_prf.c',
'freebsd/sys/kern/subr_rman.c',
'freebsd/sys/kern/subr_sbuf.c',
'freebsd/sys/kern/subr_sleepqueue.c',
@@ -774,6 +775,7 @@ def build(bld):
'freebsd/sys/kern/uipc_syscalls.c',
'freebsd/sys/kern/uipc_usrreq.c',
'freebsd/sys/libkern/arc4random.c',
+ 'freebsd/sys/libkern/bcd.c',
'freebsd/sys/libkern/fls.c',
'freebsd/sys/libkern/inet_ntoa.c',
'freebsd/sys/libkern/random.c',
More information about the vc
mailing list