mirror of
https://github.com/kenshineto/kern.git
synced 2025-04-16 23:47:25 +00:00
fmt
This commit is contained in:
parent
c5cbf5d747
commit
4c1d03b082
8 changed files with 28 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
|||
-c
|
||||
-std=c11
|
||||
-Ikernel/include
|
||||
-Iuser/include
|
||||
-ffreestanding
|
||||
-fno-builtin
|
||||
-Wall
|
||||
|
|
|
@ -44,7 +44,7 @@ __attribute__((format(printf, 1, 2))) int kprintf(const char *format, ...);
|
|||
* @returns number of bytes written
|
||||
*/
|
||||
__attribute__((format(printf, 2, 3))) int ksprintf(char *restrict s,
|
||||
const char *format, ...);
|
||||
const char *format, ...);
|
||||
|
||||
/**
|
||||
* prints out a formatted string to a buffer with a given max length
|
||||
|
@ -56,9 +56,8 @@ __attribute__((format(printf, 2, 3))) int ksprintf(char *restrict s,
|
|||
* @returns number of bytes written
|
||||
* @returns number of bytes that would of been written (past maxlen)
|
||||
*/
|
||||
__attribute__((format(printf, 3, 4))) int ksnprintf(char *restrict s,
|
||||
size_t maxlen,
|
||||
const char *format, ...);
|
||||
__attribute__((format(printf, 3, 4))) int
|
||||
ksnprintf(char *restrict s, size_t maxlen, const char *format, ...);
|
||||
|
||||
/**
|
||||
* prints out a formatted string
|
||||
|
@ -89,6 +88,6 @@ int kvsprintf(char *restrict s, const char *format, va_list args);
|
|||
* @returns number of bytes that would of been written (past maxlen)
|
||||
*/
|
||||
int kvsnprintf(char *restrict s, size_t maxlen, const char *format,
|
||||
va_list args);
|
||||
va_list args);
|
||||
|
||||
#endif /* kio.h */
|
||||
|
|
|
@ -189,7 +189,12 @@ unsigned int bound(unsigned int min, unsigned int value, unsigned int max);
|
|||
#define __PANIC_STR2(x) #x
|
||||
|
||||
#define panic(...) __panic(__PANIC_STR(__LINE__), __FILE__, __VA_ARGS__)
|
||||
#define assert(val, ...) do { if (!(val)) { panic(__VA_ARGS__); } } while (0)
|
||||
#define assert(val, ...) \
|
||||
do { \
|
||||
if (!(val)) { \
|
||||
panic(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* Abort the kernel with a given message.
|
||||
|
@ -197,8 +202,8 @@ unsigned int bound(unsigned int min, unsigned int value, unsigned int max);
|
|||
* @param format - the format string
|
||||
* @param ... - variable args for the format
|
||||
*/
|
||||
__attribute__((noreturn, format(printf, 3, 4)))
|
||||
void __panic(const char *line, const char *file, const char *format, ...);
|
||||
__attribute__((noreturn, format(printf, 3, 4))) void
|
||||
__panic(const char *line, const char *file, const char *format, ...);
|
||||
|
||||
/**
|
||||
* Fill dst with a stack trace consisting of return addresses in order
|
||||
|
|
|
@ -572,7 +572,7 @@ int kvsprintf(char *restrict s, const char *format, va_list args)
|
|||
}
|
||||
|
||||
int kvsnprintf(char *restrict s, size_t maxlen, const char *format,
|
||||
va_list args)
|
||||
va_list args)
|
||||
{
|
||||
context_t ctx = { 0 };
|
||||
ctx.format = format;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <stdarg.h>
|
||||
#include <comus/asm.h>
|
||||
|
||||
__attribute__((noreturn)) void __panic(const char *line, const char *file, const char *format, ...)
|
||||
__attribute__((noreturn)) void __panic(const char *line, const char *file,
|
||||
const char *format, ...)
|
||||
{
|
||||
cli();
|
||||
va_list list;
|
||||
|
|
|
@ -25,14 +25,16 @@ void *mboot_get_rsdp(void)
|
|||
// acpi 2.0
|
||||
tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_NEW);
|
||||
if (tag != NULL) {
|
||||
struct multiboot_tag_new_acpi *rsdp = (struct multiboot_tag_new_acpi *)tag;
|
||||
struct multiboot_tag_new_acpi *rsdp =
|
||||
(struct multiboot_tag_new_acpi *)tag;
|
||||
return rsdp->rsdp;
|
||||
}
|
||||
|
||||
// acpi 1.0
|
||||
tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_OLD);
|
||||
if (tag != NULL) {
|
||||
struct multiboot_tag_old_acpi *rsdp = (struct multiboot_tag_old_acpi *)tag;
|
||||
struct multiboot_tag_old_acpi *rsdp =
|
||||
(struct multiboot_tag_old_acpi *)tag;
|
||||
return rsdp->rsdp;
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ extern int fputs(const char *str, FILE *stream);
|
|||
* @returns number of bytes written
|
||||
*/
|
||||
__attribute__((format(printf, 1, 2))) extern int printf(const char *format,
|
||||
...);
|
||||
...);
|
||||
|
||||
/**
|
||||
* prints out a formatted string to a buffer
|
||||
|
@ -131,7 +131,7 @@ extern int vsprintf(char *restrict s, const char *format, va_list args);
|
|||
* @returns number of bytes that would of been written (past maxlen)
|
||||
*/
|
||||
extern int vsnprintf(char *restrict s, size_t maxlen, const char *format,
|
||||
va_list args);
|
||||
va_list args);
|
||||
|
||||
/**
|
||||
* prints out a formatted string
|
||||
|
@ -169,7 +169,8 @@ extern FILE *fopen(const char *restrict filename, const char *restrict modes);
|
|||
* @param stream - the stream to replace
|
||||
* @returns the file pointer of success, NULL on error
|
||||
*/
|
||||
extern FILE *freopen(const char *restrict filename, const char *restrict modes, FILE *restrict stream);
|
||||
extern FILE *freopen(const char *restrict filename, const char *restrict modes,
|
||||
FILE *restrict stream);
|
||||
|
||||
/**
|
||||
* closes a opened file
|
||||
|
@ -187,7 +188,8 @@ extern void fclose(FILE *stream);
|
|||
* @param stream - the file stream to read from
|
||||
* @returns the number of blocks read
|
||||
*/
|
||||
extern size_t fread(void *restrict ptr, size_t size, size_t n, FILE *restrict stream);
|
||||
extern size_t fread(void *restrict ptr, size_t size, size_t n,
|
||||
FILE *restrict stream);
|
||||
|
||||
/**
|
||||
* writes data from a pointer into a filename
|
||||
|
@ -198,7 +200,8 @@ extern size_t fread(void *restrict ptr, size_t size, size_t n, FILE *restrict st
|
|||
* @param stream - the file stream to write into
|
||||
* @returns the number of blocks written
|
||||
*/
|
||||
extern size_t fwrite(const void *restrict ptr, size_t size, size_t n, FILE *restrict stream);
|
||||
extern size_t fwrite(const void *restrict ptr, size_t size, size_t n,
|
||||
FILE *restrict stream);
|
||||
|
||||
/**
|
||||
* seek to a certain position on stream
|
||||
|
|
|
@ -574,8 +574,7 @@ int vsprintf(char *restrict s, const char *format, va_list args)
|
|||
return ctx.written_len;
|
||||
}
|
||||
|
||||
int vsnprintf(char *restrict s, size_t maxlen, const char *format,
|
||||
va_list args)
|
||||
int vsnprintf(char *restrict s, size_t maxlen, const char *format, va_list args)
|
||||
{
|
||||
context_t ctx = { 0 };
|
||||
ctx.format = format;
|
||||
|
|
Loading…
Add table
Reference in a new issue