From 29f085b7aa27e4df4baa186f06da54e4fed272ab Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Mon, 6 Aug 2018 21:00:58 +0200 Subject: [PATCH] Add va_list and rename types.h into stdarg.h --- core/exception.h | 2 +- core/idt.h | 2 +- core/interrupt.h | 2 +- core/io.h | 2 +- core/irq.c | 2 +- core/klibc.h | 2 +- core/main.c | 2 +- core/mem.h | 2 +- core/segment.h | 2 +- core/{types.h => stdarg.h} | 5 +++++ drivers/vga.h | 2 +- 11 files changed, 15 insertions(+), 10 deletions(-) rename core/{types.h => stdarg.h} (83%) diff --git a/core/exception.h b/core/exception.h index 465f752..8ff1c20 100644 --- a/core/exception.h +++ b/core/exception.h @@ -1,6 +1,6 @@ #pragma once #include "interrupt.h" -#include "types.h" +#include "stdarg.h" #define EXCEPTION_INTERRUPT_BASE_ADDRESS 0 diff --git a/core/idt.h b/core/idt.h index a87266d..ce8491d 100644 --- a/core/idt.h +++ b/core/idt.h @@ -1,5 +1,5 @@ #pragma once -#include "types.h" +#include "stdarg.h" #define IDT_NUM 256 diff --git a/core/interrupt.h b/core/interrupt.h index 45b7bfc..7edd0bb 100644 --- a/core/interrupt.h +++ b/core/interrupt.h @@ -1,5 +1,5 @@ #pragma once -#include "types.h" +#include "stdarg.h" struct interrupt_frame; diff --git a/core/io.h b/core/io.h index 9f0a62b..9e7b50a 100644 --- a/core/io.h +++ b/core/io.h @@ -1,5 +1,5 @@ #pragma once -#include "types.h" +#include "stdarg.h" // NIH http://wiki.osdev.org/Inline_Assembly/Examples#I.2FO_access static inline void outb(uint16_t port, uint8_t val) diff --git a/core/irq.c b/core/irq.c index 09ee6b2..2809f6d 100644 --- a/core/irq.c +++ b/core/irq.c @@ -1,7 +1,7 @@ #include "irq.h" #include "idt.h" #include "pic.h" -#include "types.h" +#include "stdarg.h" int irqSetup() { diff --git a/core/klibc.h b/core/klibc.h index 02b3479..fa7011e 100644 --- a/core/klibc.h +++ b/core/klibc.h @@ -1,4 +1,4 @@ #pragma once -#include "types.h" +#include "stdarg.h" void *memcpy(void *dest, const void *src, size_t n ); diff --git a/core/main.c b/core/main.c index 46d40f9..2aab0d4 100644 --- a/core/main.c +++ b/core/main.c @@ -7,7 +7,7 @@ #include "mem.h" #include "multiboot.h" #include "pit.h" -#include "types.h" +#include "stdarg.h" #include "vga.h" #define CHECK_FLAG(flags,bit) ((flags) & (1 << (bit))) diff --git a/core/mem.h b/core/mem.h index 9cb8069..9d24821 100644 --- a/core/mem.h +++ b/core/mem.h @@ -1,5 +1,5 @@ #pragma once -#include "types.h" +#include "stdarg.h" #define PAGE_SHIFT 12 diff --git a/core/segment.h b/core/segment.h index f5d5961..570464b 100644 --- a/core/segment.h +++ b/core/segment.h @@ -29,7 +29,7 @@ * @see Intel x86 doc, vol 3 chapter 3. */ -#include "types.h" +#include "stdarg.h" /* * Global segment selectors (GDT) for SOS/x86. diff --git a/core/types.h b/core/stdarg.h similarity index 83% rename from core/types.h rename to core/stdarg.h index f816264..6866c81 100644 --- a/core/types.h +++ b/core/stdarg.h @@ -45,3 +45,8 @@ typedef long ssize_t; typedef unsigned int size_t; typedef int ssize_t; #endif + +typedef void *va_list; +#define va_start(v, l) ((v) = (va_list) & (l) + sizeof(l)) +#define va_end(v) ((v) = NULL) +#define va_arg(v, type) (*(type *)(((v)+=sizeof(type))-sizeof(type))) diff --git a/drivers/vga.h b/drivers/vga.h index a488719..6672c53 100644 --- a/drivers/vga.h +++ b/drivers/vga.h @@ -1,5 +1,5 @@ #pragma once -#include "types.h" +#include "stdarg.h" // https://wiki.osdev.org/Text_UI #define BLACK 0x00