summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-06-07 11:41:11 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-06-07 11:41:11 +0200
commit98eeb8f22df509b2a711de0e4a01660b6646f229 (patch)
tree6da7c07e6edf340287051f7ab86a6adeba00c98f
parent1d5a3507b2deb7d23ba0427aacac6805d7acf5ac (diff)
downloadserenity-98eeb8f22df509b2a711de0e4a01660b6646f229.zip
AK: Rename printf.cpp to PrintfImplementation.h.
-rw-r--r--AK/PrintfImplementation.h (renamed from AK/printf.cpp)20
-rw-r--r--AK/StringBuilder.cpp4
-rw-r--r--Kernel/kprintf.cpp8
-rw-r--r--LibC/stdio.cpp20
-rw-r--r--LibCore/CIODevice.cpp2
5 files changed, 24 insertions, 30 deletions
diff --git a/AK/printf.cpp b/AK/PrintfImplementation.h
index 0b5ee149ad..0088b550ce 100644
--- a/AK/printf.cpp
+++ b/AK/PrintfImplementation.h
@@ -1,17 +1,11 @@
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int dword;
-typedef long long unsigned int qword;
+#pragma once
-[[gnu::always_inline]] inline size_t strlen(const char* str)
-{
- size_t len = 0;
- while (*(str++))
- ++len;
- return len;
-}
+#include <AK/Types.h>
+#include <LibC/stdarg.h>
+
+static constexpr const char* printf_hex_digits = "0123456789abcdef";
-static constexpr const char* h = "0123456789abcdef";
+extern "C" size_t strlen(const char*);
template<typename PutChFunc, typename T>
[[gnu::always_inline]] inline int print_hex(PutChFunc putch, char*& bufptr, T number, byte fields)
@@ -20,7 +14,7 @@ template<typename PutChFunc, typename T>
byte shr_count = fields * 4;
while (shr_count) {
shr_count -= 4;
- putch(bufptr, h[(number >> shr_count) & 0x0F]);
+ putch(bufptr, printf_hex_digits[(number >> shr_count) & 0x0F]);
++ret;
}
return ret;
diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp
index 6f6a86de26..6ba5754c73 100644
--- a/AK/StringBuilder.cpp
+++ b/AK/StringBuilder.cpp
@@ -1,6 +1,6 @@
-#include "StringBuilder.h"
-#include "printf.cpp"
+#include <AK/PrintfImplementation.h>
#include <AK/StdLibExtras.h>
+#include <AK/StringBuilder.h>
#include <LibC/stdarg.h>
namespace AK {
diff --git a/Kernel/kprintf.cpp b/Kernel/kprintf.cpp
index 884dfa9f39..9605d2cfec 100644
--- a/Kernel/kprintf.cpp
+++ b/Kernel/kprintf.cpp
@@ -1,10 +1,10 @@
-#include <Kernel/kstdio.h>
+#include <AK/PrintfImplementation.h>
+#include <AK/Types.h>
#include <Kernel/Console.h>
#include <Kernel/IO.h>
-#include <LibC/stdarg.h>
#include <Kernel/Process.h>
-#include <AK/Types.h>
-#include <AK/printf.cpp>
+#include <Kernel/kstdio.h>
+#include <LibC/stdarg.h>
static void console_putch(char*&, char ch)
{
diff --git a/LibC/stdio.cpp b/LibC/stdio.cpp
index 3aae74ec52..926f67f8f3 100644
--- a/LibC/stdio.cpp
+++ b/LibC/stdio.cpp
@@ -1,17 +1,17 @@
-#include <stdio.h>
+#include <AK/PrintfImplementation.h>
+#include <AK/StdLibExtras.h>
+#include <AK/ValueRestorer.h>
+#include <Kernel/Syscall.h>
+#include <assert.h>
+#include <errno.h>
+#include <fcntl.h>
#include <stdarg.h>
-#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <errno.h>
+#include <sys/types.h>
#include <unistd.h>
-#include <assert.h>
-#include <stdlib.h>
#include <unistd.h>
-#include <fcntl.h>
-#include <AK/printf.cpp>
-#include <AK/StdLibExtras.h>
-#include <AK/ValueRestorer.h>
-#include <Kernel/Syscall.h>
extern "C" {
diff --git a/LibCore/CIODevice.cpp b/LibCore/CIODevice.cpp
index 5171821b39..cc2599c609 100644
--- a/LibCore/CIODevice.cpp
+++ b/LibCore/CIODevice.cpp
@@ -1,9 +1,9 @@
+#include <AK/PrintfImplementation.h>
#include <LibCore/CIODevice.h>
#include <stdio.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
-#include <AK/printf.cpp>
CIODevice::CIODevice(CObject* parent)
: CObject(parent)