You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2015/11/19 01:12:17 UTC

[04/14] incubator-mynewt-larva git commit: Add libc function implementations to direct printf() and fprintf([stdout|stderr], ) to console.

Add libc function implementations to direct printf() and
fprintf([stdout|stderr],) to console.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/commit/339374ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/339374ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/339374ff

Branch: refs/heads/master
Commit: 339374ffce24bfe9d774bb49aa6d1f2cb47bc804
Parents: d942da3
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Nov 18 15:52:56 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Nov 18 15:52:56 2015 -0800

----------------------------------------------------------------------
 libs/libc/egg.yml       |  4 ++++
 libs/libc/src/fprintf.c | 34 ++++++++++++++++++++++++++++++++++
 libs/libc/src/printf.c  | 30 ++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/339374ff/libs/libc/egg.yml
----------------------------------------------------------------------
diff --git a/libs/libc/egg.yml b/libs/libc/egg.yml
new file mode 100644
index 0000000..4aaf94d
--- /dev/null
+++ b/libs/libc/egg.yml
@@ -0,0 +1,4 @@
+egg.name: libs/libc
+egg.vers: 0.1
+egg.req_caps:
+    - console

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/339374ff/libs/libc/src/fprintf.c
----------------------------------------------------------------------
diff --git a/libs/libc/src/fprintf.c b/libs/libc/src/fprintf.c
new file mode 100644
index 0000000..823e012
--- /dev/null
+++ b/libs/libc/src/fprintf.c
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+
+#include <console/console.h>
+
+int
+fprintf(FILE *stream, const char *fmt, ...)
+{
+    va_list args;
+    int len;
+
+    if (stream == stdout || stream == stderr) {
+        va_start(args, fmt);
+        len = console_vprintf(fmt, args);
+        va_end(args);
+        return len;
+    } else {
+        return -1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/339374ff/libs/libc/src/printf.c
----------------------------------------------------------------------
diff --git a/libs/libc/src/printf.c b/libs/libc/src/printf.c
new file mode 100644
index 0000000..361e225
--- /dev/null
+++ b/libs/libc/src/printf.c
@@ -0,0 +1,30 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <stdio.h>
+
+#include <console/console.h>
+
+int
+printf(const char *fmt, ...)
+{
+    va_list args;
+    int len;
+
+    va_start(args, fmt);
+    len = console_vprintf(fmt, args);
+    va_end(args);
+    return len;
+}