-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some libc function #34
Closed
Closed
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
69419b8
complete some libc function
coolyjg a8fe8f1
apply cfs.patch
githubmomoko 6a3fe3c
Fix CI
equation314 cba3011
x86: start to port to x86_64
equation314 b286d4f
x86: add exception handling
equation314 f052264
x86: enable LAPIC timer interrupts
equation314 6cf28d8
x86: add support of multicore
equation314 9eb0a00
Update README
equation314 737c349
Publish crate_interface to crates.io
equation314 771615d
Rename: doc/arceos-arch.md -> doc/README.md
equation314 fcd6eab
update build&run C apps info in README.md
chyyuu-tsinghua-cs 4737680
CI: increase app test timeout to 60s
equation314 bb5f055
merge main and optimize code
coolyjg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef _CTYPE_H | ||
#define _CTYPE_H | ||
|
||
int tolower(int __c); | ||
int toupper(int __c); | ||
|
||
int isprint(int); | ||
int isalpha(int c); | ||
int isalnum(int); | ||
int isupper(int c); | ||
int islower(int c); | ||
|
||
int isxdigit(int); | ||
int isgraph(int); | ||
int iscntrl(int); | ||
int ispunct(int); | ||
|
||
int isascii(int); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef __LIMITS__ | ||
#define __LIMITS__ | ||
|
||
#define __LONG_MAX 0x7fffffffffffffffL | ||
#define CHAR_BIT 8 | ||
#define SCHAR_MIN (-128) | ||
#define SCHAR_MAX 127 | ||
#define UCHAR_MAX 255 | ||
#define SHRT_MIN (-1 - 0x7fff) | ||
#define SHRT_MAX 0x7fff | ||
#define USHRT_MAX 0xffff | ||
#define INT_MIN (-1 - 0x7fffffff) | ||
#define INT_MAX 0x7fffffff | ||
#define UINT_MAX 0xffffffffU | ||
#define LONG_MIN (-LONG_MAX - 1) | ||
#define LONG_MAX __LONG_MAX | ||
#define ULONG_MAX (2UL * LONG_MAX + 1) | ||
#define LLONG_MIN (-LLONG_MAX - 1) | ||
#define LLONG_MAX 0x7fffffffffffffffLL | ||
#define ULLONG_MAX (2ULL * LLONG_MAX + 1) | ||
|
||
#define PTHREAD_STACK_MIN 2048 | ||
|
||
#define LOGIN_NAME_MAX 256 | ||
#ifndef NAME_MAX | ||
#define NAME_MAX 255 | ||
#endif | ||
#define TZNAME_MAX 6 | ||
|
||
#define PATH_MAX 4096 | ||
#define SSIZE_MAX LONG_MAX | ||
#define CHAR_MAX 127 | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef _LOCALE_H | ||
#define _LOCALE_H | ||
|
||
#define LC_CTYPE 0 | ||
#define LC_NUMERIC 1 | ||
#define LC_TIME 2 | ||
#define LC_COLLATE 3 | ||
#define LC_MONETARY 4 | ||
#define LC_MESSAGES 5 | ||
#define LC_ALL 6 | ||
#define LOCALE_NAME_MAX 23 | ||
|
||
#include <stddef.h> | ||
|
||
struct lconv { | ||
char *decimal_point; | ||
char *thousands_sep; | ||
char *grouping; | ||
|
||
char *int_curr_symbol; | ||
char *currency_symbol; | ||
char *mon_decimal_point; | ||
char *mon_thousands_sep; | ||
char *mon_grouping; | ||
char *positive_sign; | ||
char *negative_sign; | ||
char int_frac_digits; | ||
char frac_digits; | ||
char p_cs_precedes; | ||
char p_sep_by_space; | ||
char n_cs_precedes; | ||
char n_sep_by_space; | ||
char p_sign_posn; | ||
char n_sign_posn; | ||
char int_p_cs_precedes; | ||
char int_p_sep_by_space; | ||
char int_n_cs_precedes; | ||
char int_n_sep_by_space; | ||
char int_p_sign_posn; | ||
char int_n_sign_posn; | ||
}; | ||
|
||
struct __locale_map { | ||
const void *map; | ||
size_t map_size; | ||
char name[LOCALE_NAME_MAX + 1]; | ||
const struct __locale_map *next; | ||
}; | ||
|
||
struct __locale_struct { | ||
const struct __locale_map *cat[6]; | ||
}; | ||
|
||
typedef struct __locale_struct *locale_t; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,59 @@ | ||
#ifndef __STDIO_H__ | ||
#define __STDIO_H__ | ||
|
||
#define stdin 0 | ||
#define stdout 1 | ||
#define stderr 2 | ||
#include <stdarg.h> | ||
#include <stddef.h> | ||
|
||
int getchar(); | ||
int putchar(int); | ||
int puts(const char *s); | ||
void fprintf(int f, const char *fmt, ...); | ||
int fflush(int); | ||
// TODO: complete this struct | ||
struct IO_FILE { | ||
int fd; | ||
}; | ||
|
||
typedef struct IO_FILE FILE; | ||
|
||
extern FILE *const stdin; | ||
extern FILE *const stdout; | ||
extern FILE *const stderr; | ||
|
||
#define stdin (stdin) | ||
#define stdout (stdout) | ||
#define stderr (stderr) | ||
|
||
#define EOF (-1) | ||
|
||
#define printf(...) fprintf(stdout, __VA_ARGS__) | ||
#define printf(...) fprintf(stdout->fd, __VA_ARGS__) | ||
|
||
#define unimplemented(fmt, ...) \ | ||
printf("\x1b[33m%s%s:\x1b[0m " fmt "\n", "WARN: no ax_call implementation for ", __func__, \ | ||
##__VA_ARGS__) | ||
|
||
struct _IO_FILE { | ||
int fd; | ||
}; | ||
|
||
typedef struct _IO_FILE FILE; | ||
|
||
#define SEEK_SET 0 | ||
#define SEEK_CUR 1 | ||
#define SEEK_END 2 | ||
|
||
#define F_EOF 16 | ||
#define F_ERR 32 | ||
#define F_SVB 64 | ||
#define F_NORD 4 | ||
#define UNGET 8 | ||
|
||
#define FILENAME_MAX 4096 | ||
|
||
int getchar(); | ||
int putchar(int); | ||
int puts(const char *s); | ||
void fprintf(int f, const char *fmt, ...); | ||
|
||
#if defined(AX_CONFIG_ALLOC) && defined(AX_CONFIG_FS) | ||
FILE *fopen(const char *filename, const char *mode); | ||
#endif | ||
|
||
int fflush(FILE *); | ||
|
||
int vsnprintf(char *__restrict, size_t, const char *__restrict, va_list); | ||
int snprintf(char *__restrict, size_t, const char *__restrict, ...); | ||
int vsprintf(char *__restrict, const char *__restrict, va_list); | ||
int vfprintf(FILE *__restrict, const char *__restrict, va_list); | ||
int sprintf(char *__restrict, const char *__restrict, ...); | ||
|
||
#endif // __STDIO_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,16 @@ | |
#define __TIME_H__ | ||
|
||
#include <stddef.h> | ||
#include <sys/time.h> | ||
|
||
typedef long time_t; | ||
|
||
#define CLOCK_REALTIME 0 | ||
#define CLOCK_MONOTONIC 1 | ||
#define CLOCKS_PER_SEC 1000000L | ||
|
||
#define ax_time_usec_to_nsec(usec) ((usec)*1000UL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This definition is useless, use |
||
|
||
struct tm { | ||
int tm_sec; /* seconds of minute */ | ||
int tm_min; /* minutes of hour */ | ||
|
@@ -26,5 +33,7 @@ struct tm *gmtime(const time_t *timer); | |
|
||
struct tm *localtime(const time_t *timep); | ||
time_t time(time_t *t); | ||
int clock_gettime(clockid_t _clk, struct timespec *ts); | ||
int nanosleep(const struct timespec *requested_time, struct timespec *remaining); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include <ctype.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int isupper(int c) | ||
{ | ||
return (unsigned)c - 'A' < 26; | ||
} | ||
|
||
int tolower(int c) | ||
{ | ||
if (isupper(c)) | ||
return c | 32; | ||
return c; | ||
} | ||
|
||
int islower(int c) | ||
{ | ||
return (unsigned)c - 'a' < 26; | ||
} | ||
|
||
int toupper(int c) | ||
{ | ||
if (islower(c)) | ||
return c & 0x5f; | ||
return c; | ||
} | ||
|
||
int isgraph(int c) | ||
{ | ||
return (unsigned)c - 0x21 < 0x5e; | ||
} | ||
|
||
int isalpha(int c) | ||
{ | ||
return ((unsigned)c | 32) - 'a' < 26; | ||
} | ||
|
||
int isprint(int c) | ||
{ | ||
return (unsigned)c - 0x20 < 0x5f; | ||
} | ||
|
||
int isalnum(int c) | ||
{ | ||
return isalpha(c) || isdigit(c); | ||
} | ||
|
||
int iscntrl(int c) | ||
{ | ||
return (unsigned)c < 0x20 || c == 0x7f; | ||
} | ||
|
||
int ispunct(int c) | ||
{ | ||
return isgraph(c) && !isalnum(c); | ||
} | ||
|
||
int isxdigit(int c) | ||
{ | ||
return isdigit(c) || ((unsigned)c | 32) - 'a' < 6; | ||
} | ||
|
||
int isascii(int c) | ||
{ | ||
return !(c & ~0x7f); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
#define
for simple functions?