Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/klibc/kerrno.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define __RT_KERRNO_H__

#include <rtconfig.h>
#include <rttypes.h>

#ifdef __cplusplus
extern "C" {
Expand Down
5 changes: 5 additions & 0 deletions include/klibc/kstdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#ifndef __RT_KSTDIO_H__
#define __RT_KSTDIO_H__

#include <rttypes.h>
#include <stdarg.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -19,6 +22,8 @@ int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
int rt_sprintf(char *buf, const char *format, ...);
int rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
int rt_vsscanf(const char *buffer, const char *format, va_list ap);
int rt_sscanf(const char *str, const char *format, ...);

#ifdef __cplusplus
}
Expand Down
3 changes: 3 additions & 0 deletions include/klibc/kstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#ifndef __RT_KSTRING_H__
#define __RT_KSTRING_H__

#include <rttypes.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -19,6 +21,7 @@ void *rt_memset(void *src, int c, rt_ubase_t n);
void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
void *rt_memmove(void *dest, const void *src, rt_size_t n);
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_size_t count);

char *rt_strdup(const char *s);
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen);
char *rt_strstr(const char *str1, const char *str2);
Expand Down
6 changes: 5 additions & 1 deletion src/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ from building import *
import os

src = Glob('*.c')
src += Glob('klibc/*.c')
cwd = GetCurrentDir()
inc = [os.path.join(cwd, '..', 'include')]

Expand Down Expand Up @@ -49,4 +48,9 @@ group = DefineGroup('Kernel', src, depend=[''], CPPPATH=inc,
LINKFLAGS=LINKFLAGS, LOCAL_CFLAGS=LOCAL_CFLAGS,
CPPDEFINES=['__RTTHREAD__'], LOCAL_CPPDEFINES=['__RT_KERNEL_SOURCE__'])

list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))

Return('group')
14 changes: 14 additions & 0 deletions src/klibc/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from building import *
import os

cwd = GetCurrentDir()
src = Glob('*.c')

group = DefineGroup('klibc', src, depend = [''])

list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))

Return('group')
22 changes: 22 additions & 0 deletions src/klibc/kstdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,25 @@ int rt_sprintf(char *buf, const char *format, ...)
return n;
}
RTM_EXPORT(rt_sprintf);

/**
* @brief This function parses a formatted string from the input string.
*
* @param str the input string to be parsed.
*
* @param format the format string that specifies how to interpret the input.
*
* @return The number of input items successfully matched and assigned.
*/
int rt_sscanf(const char *str, const char *format, ...)
{
va_list ap;
int rv;

va_start(ap, format);
rv = rt_vsscanf(str, format, ap);
va_end(ap);

return rv;
}
RTM_EXPORT(rt_sscanf);
2 changes: 1 addition & 1 deletion src/klibc/rt_vsnprintf_std.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Change Logs:
* Date Author Notes
* 2021-11-27 Meco Man porting for rt_vsnprintf as the fully functional version
* 2024-11-19 Meco Man move into rtklibc
* 2024-11-19 Meco Man move to klibc
*/

/**
Expand Down
Loading
Loading