Skip to content

Commit

Permalink
Merge pull request #7 from linshire/add_some_function
Browse files Browse the repository at this point in the history
添加了一些函数,并在qemu-virt64-riscv上验证
  • Loading branch information
BernardXiong authored Mar 7, 2023
2 parents adba279 + 1079206 commit d136362
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 117 deletions.
29 changes: 0 additions & 29 deletions arch/arm/typedef.h

This file was deleted.

31 changes: 31 additions & 0 deletions arch/riscv64/typedef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef __TYPEDEF_H__
#define __TYPEDEF_H__

#define NULL 0
typedef unsigned long long size_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;

typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;

typedef volatile uint8_t vuint8_t;
typedef volatile uint16_t vuint16_t;
typedef volatile uint32_t vuint32_t;
typedef volatile uint64_t vuint64_t;

typedef volatile int8_t vint8_t;
typedef volatile int16_t vint16_t;
typedef volatile int32_t vint32_t;
typedef volatile int64_t vint64_t;

typedef long _fpos_t;

typedef int64_t intmax_t;
typedef uint64_t uintmax_t;

#endif
11 changes: 5 additions & 6 deletions include/stdarg.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#ifndef __STDARG_H__
#define __STDARG_H__

#define va_list __builtin_va_list
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_copy(d,s) __builtin_va_copy(d,s)

#define va_list __builtin_va_list
#define va_start __builtin_va_start
#define va_end __builtin_va_end
#define va_arg __builtin_va_arg
#define va_copy __builtin_va_copy
#endif
34 changes: 32 additions & 2 deletions include/stdio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
#ifndef __STDIO_H__
#define __STDIO_H__

#include <typedef.h>

#define EOF (-1)

struct __sbuf {
unsigned char *_base;
int _size;
};

typedef struct _iobuf
{
unsigned char *_p; /* current position in (some) buffer */
int _r; /* read space left for getc() */
int _w; /* write space left for putc() */
short _flags; /* flags, below; this FILE is free if 0 */
short _file; /* fileno, if Unix descriptor, else -1 */
struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */
int _lbfsize; /* 0 or -_bf._size, for inline putc */
} FILE;

typedef _fpos_t fpos_t;

#define ZEROPAD (1 << 0) /* pad with zero */
#define SIGN (1 << 1) /* unsigned/signed long */
#define PLUS (1 << 2) /* show plus */
Expand All @@ -9,5 +31,13 @@
#define SPECIAL (1 << 5) /* 0x */
#define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */

extern int print(const char* str, ...);
#endif /*#ifndef _STDIO_H_*/
#define SEEK_CUR 0x01
#define SEEK_END 0x02
#define SEEK_SET 0x03

int printf(const char *format, ...);
int vprintf(const char *format, va_list arg);
int fprintf(FILE *stream, const char *format, ...);
int vfprintf(FILE *stream, const char *format, va_list arg);

#endif /*#ifndef _STDIO_H_*/
15 changes: 15 additions & 0 deletions include/string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef __STRING_H_
#define __STRING_H_

#include <typedef.h>

size_t strlen(const char *s);








#endif
28 changes: 0 additions & 28 deletions include/typedef.h

This file was deleted.

Loading

0 comments on commit d136362

Please sign in to comment.