-
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
Conversation
a678417
to
a857300
Compare
|
ulib/c_libax/include/ctype.h
Outdated
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?
#define isalpha(a) (((unsigned)(a)|32)-'a') < 26)
// ...
ulib/c_libax/src/stdio.c
Outdated
f = (FILE *)malloc(sizeof(FILE)); | ||
|
||
flags = __fmodeflags(mode); | ||
int fd = ax_open(filename, flags, mode); |
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.
mode
type in ax_open
is not char *
ulib/c_libax/include/time.h
Outdated
#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 comment
The reason will be displayed to describe this comment to others. Learn more.
This definition is useless, use (usec)*1000
in code directly.
ulib/libax/src/cbindings/thread.rs
Outdated
pub unsafe extern "C" fn ax_getpid() -> c_int { | ||
ax_call_body!(ax_getpid, { | ||
let pid = current().id().as_u64() as c_int; | ||
debug!("getpid return {}", pid); |
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.
This debug info is already printed in ax_call_body
ulib/libax/src/cbindings/thread.rs
Outdated
|
||
use crate::debug; | ||
use crate::task::exit; | ||
use axerrno::{LinuxError, LinuxResult}; |
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.
Remove unused imports
ulib/libax/src/cbindings/time.rs
Outdated
unsafe { | ||
*ts = ret; | ||
} | ||
debug!("ax_clock_gettime: {}s, {}ns", now.as_secs(), now.as_nanos()); |
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.
debug!("ax_clock_gettime: {}.{:09}s", ret.tv_sec, ret.tv_nsec);
return Err(LinuxError::EINVAL); | ||
} | ||
|
||
let total_nano = (*req).tv_sec as u64 * NANOS_PER_SEC + (*req).tv_nsec as u64; |
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.
Add debug info for arguments:
debug!("ax_nanosleep <= {}.{:09}s", (*req).tv_sec, (*req).tv_nsec);
@coolyjg Very good! try to make your work better. |
This PR will be clearer in #38 |
syscall: fix fd leak in epoll
* [feat] update allocator version to support alloc_pages_at * [feat] set phys-virt-offset as 0xffff_8000_0000_0000 for x86_64 qemu
Finish some libc implementations.
stdlib.h
calloc
: ax_malloc + memsetrealloc
declaration: Previous code lacks of declarationstrtol
,atoll
,strtoll
,strtoul
,strtoull
: Some type conversion functionsexit
: callax_exit
abs
,llabs
: Get absolution valuestdio.h
stdin
,stdout
,stderr
definition toFILE*
. Accordingly change correspondingprint
-like functions usingstdout->fd
rather than number 1.fopen
: Since libc are responsible for allocatingFILE*
structure infopen
, this function acquires both "fs" and "alloc" feature.fflush
: Change input variable type.vsnprintf
,snprintf
,vsprintf
,vfprintf
,sprintf
: Someprint
-like implementation inspired by previousfprintf
implementation.time.h
clock_gettime
,gmtime
,time
,local_time
,gettimeofday
: Sometime
implementation based onulib/libax/src/time.rs
nanosleep
: Call sleep API in task. TODO: task can be early woken up by some signal and return remained time.unistd.h
usleep
,sleep
: Call sleep API in taskgetpid
: Callcurrent()
if "multitask" feature is on, or return 2 ("main" task Id)Add some
cbindings
syscall implementationax_exit
ax_clock_gettime
ax_nanosleep