ref: a3d9c8a50f2bd94224725e329b1d2482a7b0718d
parent: 40b1fef01b2962896ed4eab1ae7f90eb7f58a73f
author: Mahdi <mahdi.hoseini1381@yahoo.com>
date: Thu Nov 23 12:07:26 EST 2023
Added va_list definition to include/u.h, Added printf.c, scanf.c, strtol.c, strncpy.c and itoa.c prototypes to include/libc.h and Makefile
--- a/Makefile
+++ b/Makefile
@@ -21,10 +21,14 @@
libc/strcmp.o\
libc/strcntok.o\
libc/strccnt.o\
+ libc/strtol.o\
+ libc/strncpy.o\
libc/memcpy.o\
libc/memset.o\
libc/lladd.o\
libc/lldel.o\
+ libc/printf.o\
+ libc/scanf.o\
K = \
pc/boot.o\
--- a/include/libc.h
+++ b/include/libc.h
@@ -9,6 +9,8 @@
char* strtok(char *s, char *b);
char* strcntok(char *src, char token, int n);
int strccnt(char *s, char c);
+long strtol(char *nptr, char **endptr, int base);
+char* strncpy(char *dst, const char *src, size_t num);
void* memset(void* src, char c, unsigned int len);
void* memcpy(void *a1, void *a2, unsigned int len);
@@ -16,3 +18,5 @@
int lladd(ll_t*, void*);
int lldel(ll_t*);
+int printf(const char* restrict format, ...);
+int scanf (char * str, ...);
\ No newline at end of file
--- a/include/u.h
+++ b/include/u.h
@@ -1,5 +1,7 @@
#pragma once
#define nil ((void*)0x0)
+#define LONG_MAX 2147483647L
+#define LONG_MIN -2147483648L
typedef int size_t;
@@ -12,7 +14,9 @@
typedef unsigned long uint32;
typedef long int32;
-typedef char* va_list;
+
+
+typedef __builtin_va_list va_list;
typedef struct
{
void *val;
@@ -24,3 +28,4 @@
char *name;
int (*main)(int argc, char **argv);
}prog_t;
+