forked from PoliEcho-holding-org/kern
Write vsnprintf() implementation
This commit is contained in:
+10
-4
@@ -2,15 +2,16 @@
|
||||
#define _KERNEL_H
|
||||
|
||||
// Null definition
|
||||
#define NULL ((void*)0)
|
||||
#define NULL ((void*)0)
|
||||
|
||||
/*
|
||||
* Variable arguments
|
||||
*/
|
||||
typedef void* va_list;
|
||||
#define va_start(ap, param) (void)((ap) = (char*)(&(param) + 1))
|
||||
#define va_end(ap) (void)((ap) = 0)
|
||||
#define va_arg(ap, type) (((type*)((ap) = ((ap) + sizeof(type))))[-1])
|
||||
#define __va_align(size) ((size + sizeof(int) - 1) & ~(sizeof(int) - 1))
|
||||
#define va_start(ap, param) (void)((ap) = (char*)(&(param) + 1))
|
||||
#define va_end(ap) (void)((ap) = 0)
|
||||
#define va_arg(ap, type) (*(type*)(((ap) += __va_align(sizeof(type))) - sizeof(type)))
|
||||
|
||||
/*
|
||||
* Utility macros
|
||||
@@ -67,6 +68,11 @@ typedef int32_t intptr_t;
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
/*
|
||||
* Linker defined values
|
||||
*/
|
||||
extern uint32_t __kernel_start, __kernel_end;
|
||||
|
||||
/*
|
||||
* Logging and errors
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _VSNPRINTF_H
|
||||
#define _VSNPRINTF_H
|
||||
|
||||
#include <kernel.h>
|
||||
|
||||
int vsnprintf(char* buf, size_t len, char* fmt, va_list args);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user