Skip to content

Commit

Permalink
AK: Rename printf.cpp to PrintfImplementation.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 7, 2019
1 parent 1d5a350 commit 98eeb8f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
20 changes: 7 additions & 13 deletions AK/printf.cpp → AK/PrintfImplementation.h
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions AK/StringBuilder.cpp
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions Kernel/kprintf.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
20 changes: 10 additions & 10 deletions LibC/stdio.cpp
Original file line number Diff line number Diff line change
@@ -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" {

Expand Down
2 changes: 1 addition & 1 deletion LibCore/CIODevice.cpp
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 98eeb8f

Please sign in to comment.