Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from xushiwei/q
Browse files Browse the repository at this point in the history
support ./src/unistd/*.c
  • Loading branch information
xushiwei authored Aug 2, 2022
2 parents 9ba4266 + 1ce3c8c commit f0bbb6e
Show file tree
Hide file tree
Showing 78 changed files with 888 additions and 496 deletions.
7 changes: 7 additions & 0 deletions access.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package libc

import unsafe "unsafe"

func access(filename *int8, amode int32) int32 {
return int32(__syscall2_r1(int64(33), int64(uintptr(unsafe.Pointer(filename))), int64(amode)))
}
7 changes: 7 additions & 0 deletions acct.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package libc

import unsafe "unsafe"

func acct(filename *int8) int32 {
return int32(__syscall1_r1(int64(51), int64(uintptr(unsafe.Pointer(filename)))))
}
14 changes: 14 additions & 0 deletions alarm.c.i.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package libc

func alarm(seconds uint32) uint32 {
var it struct_itimerval = struct_itimerval{Struct_timeval{}, Struct_timeval{int64(seconds), 0}}
var old struct_itimerval = struct_itimerval{Struct_timeval{int64(0), 0}, Struct_timeval{}}
setitimer(int32(0), &it, &old)
return uint32(old.it_value.Tv_sec + func() int64 {
if !!(old.it_value.Tv_usec != 0) {
return 1
} else {
return 0
}
}())
}
27 changes: 24 additions & 3 deletions c2go.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"./include/stdlib.h",
"./include/string.h",
"./include/ctype.h",
"./c2go/include/unistd.h",
"./c2go/include/bits/alltypes.h"
]
},
Expand All @@ -30,11 +31,31 @@
"__pthread_self"
],
"files": [
"./src/unistd/dup3.c",
"./src/unistd/faccessat.c",
"./src/unistd/ftruncate.c",
"./src/unistd/getcwd.c",
"./src/unistd/pause.c",
"./src/unistd/pipe2.c",
"./src/unistd/pread.c",
"./src/unistd/pwrite.c",
"./src/unistd/setegid.c",
"./src/unistd/seteuid.c",
"./src/unistd/setpgrp.c",
"./src/unistd/setregid.c",
"./src/unistd/setresgid.c",
"./src/unistd/setresuid.c",
"./src/unistd/sleep.c",
"./src/unistd/truncate.c",
"./src/unistd/ttyname.c",
"./src/unistd/ttyname_r.c",
"./src/unistd/usleep.c",
"./src/misc/syscall.c",
"./src/misc/getresgid.c",
"./src/misc/getresuid.c",
"./src/misc/getrlimit.c",
"./src/misc/ioctl.c",
"./src/misc/getdomainname.c",
"./src/misc/setdomainname.c",
"./src/misc/setrlimit.c",
"./src/misc/syslog.c",
Expand All @@ -46,11 +67,13 @@
"./src/stdio/vfwprintf.c",
"./src/stdio/freopen.c",
"./src/stdio/ftrylockfile.c",
"./src/stdio/popen.c",
"./src/stdio/open_memstream.c",
"./src/stdio/open_wmemstream.c"
]
},
"dirs": [
"./src/unistd",
"./src/misc",
"./src/math",
"./src/stdio",
Expand Down Expand Up @@ -78,9 +101,7 @@
"./src/locale/__mo_lookup.c",
"./src/locale/__lctrans.c",
"./src/locale/c_locale.c",
"./src/locale/locale_map.c",
"./src/unistd/lseek.c",
"./src/unistd/write.c"
"./src/locale/locale_map.c"
]
},
"include": [
Expand Down
1 change: 1 addition & 0 deletions c2go.pub
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ __signbit
__signbitl
__FLOAT_BITS
__DOUBLE_BITS
sync
basename
initstate
setstate
Expand Down
7 changes: 7 additions & 0 deletions c2go/include/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@
#define SEEK_CUR 1
#define SEEK_END 2

char *getlogin(void);

off_t __lseek(int, off_t, int);

pid_t fork(void);

int execl(const char *path, const char *argv0, ...);

pid_t getpid(void);
// int setpgid(pid_t pid, pid_t pgid);

pid_t setsid(void);
pid_t setpgrp(void);

_Noreturn void _exit(int status);

Expand All @@ -38,6 +43,8 @@ ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);

int ioctl(int fd, int req, ...);
int dup2(int old, int new);

int pipe(int fd[2]);
int pipe2(int fd[2], int flag);

ssize_t read(int fd, void *buf, size_t count);
Expand Down
72 changes: 27 additions & 45 deletions c2go_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,45 @@ import unsafe "unsafe"
type struct___dirstream struct {
}

func Execl(path *int8, argv0 *int8, __cgo_args ...interface {
}) int32 {
panic("notimpl")
}
func Fdopen(int32, *int8) *Struct__IO_FILE {
panic("notimpl")
}
func Fork() int32 {
panic("notimpl")
}
func Ftrylockfile(*Struct__IO_FILE) int32 {
panic("notimpl")
}
func Getcwd(buf *int8, size uint64) *int8 {
panic("notimpl")
}
func Ioctl(fd int32, req int32, __cgo_args ...interface {
}) int32 {
panic("notimpl")
}
func Mblen(*int8, uint64) int32 {
panic("notimpl")
}
func Mbtowc(*uint32, *int8, uint64) int32 {
panic("notimpl")
}
func Pipe2(fd *int32, flag int32) int32 {
panic("notimpl")
}
func Vfscanf(*Struct__IO_FILE, *int8, []interface {
}) int32 {
panic("notimpl")
}
func Wctomb(*int8, uint32) int32 {
panic("notimpl")
}
func X_Exit(int32) {
panic("notimpl")
}
func __aio_close(int32) int32 {
panic("notimpl")
}
Expand All @@ -33,6 +53,9 @@ func __block_all_sigs(unsafe.Pointer) {
func __futexwait(addr unsafe.Pointer, val int32, priv int32) {
panic("notimpl")
}
func __procfdname(*int8, uint32) {
panic("notimpl")
}
func __randname(*int8) *int8 {
panic("notimpl")
}
Expand All @@ -42,6 +65,9 @@ func __register_locked_file(*Struct__IO_FILE, *Struct___pthread) {
func __restore_sigs(unsafe.Pointer) {
panic("notimpl")
}
func __synccall(func(unsafe.Pointer), unsafe.Pointer) {
panic("notimpl")
}
func __unlist_locked_file(*Struct__IO_FILE) {
panic("notimpl")
}
Expand All @@ -51,48 +77,22 @@ func __vm_wait() {
func __wake(addr unsafe.Pointer, cnt int32, priv int32) {
panic("notimpl")
}
func _exit(status int32) {
panic("notimpl")
}
func close(fd int32) int32 {
panic("notimpl")
}
func closedir(*struct___dirstream) int32 {
panic("notimpl")
}
func dup2(old int32, new int32) int32 {
panic("notimpl")
}
func execl(path *int8, argv0 *int8, __cgo_args ...interface {
}) int32 {
panic("notimpl")
}
func fcntl(int32, int32, ...interface {
}) int32 {
panic("notimpl")
}
func fdopendir(int32) *struct___dirstream {
panic("notimpl")
}
func fork() int32 {
panic("notimpl")
}
func getcwd(buf *int8, size uint64) *int8 {
panic("notimpl")
}
func getgrouplist(*int8, uint32, *uint32, *int32) int32 {
panic("notimpl")
}
func getpid() int32 {
panic("notimpl")
}
func getrandom(unsafe.Pointer, uint64, uint32) int64 {
panic("notimpl")
}
func ioctl(int32, int32, ...interface {
}) int32 {
panic("notimpl")
}
func kill(int32, int32) int32 {
panic("notimpl")
}
Expand All @@ -106,37 +106,19 @@ func open(*int8, int32, ...interface {
}) int32 {
panic("notimpl")
}
func pipe2(fd *int32, flag int32) int32 {
panic("notimpl")
}
func posix_spawn(*int32, *int8, *_cgoa_19_popen, *_cgoa_18_popen, **int8, **int8) int32 {
panic("notimpl")
}
func posix_spawn_file_actions_adddup2(*_cgoa_19_popen, int32, int32) int32 {
panic("notimpl")
}
func posix_spawn_file_actions_destroy(*_cgoa_19_popen) int32 {
panic("notimpl")
}
func posix_spawn_file_actions_init(*_cgoa_19_popen) int32 {
panic("notimpl")
}
func pthread_setcancelstate(int32, *int32) int32 {
panic("notimpl")
}
func pthread_sigmask(int32, *Struct___sigset_t, *Struct___sigset_t) int32 {
panic("notimpl")
}
func read(fd int32, buf unsafe.Pointer, count uint64) int64 {
panic("notimpl")
}
func readdir(*struct___dirstream) *struct_dirent {
panic("notimpl")
}
func setgroups(uint64, *uint32) int32 {
panic("notimpl")
}
func setsid() int32 {
func setitimer(int32, *struct_itimerval, *struct_itimerval) int32 {
panic("notimpl")
}
func sigfillset(*Struct___sigset_t) int32 {
Expand Down
Loading

0 comments on commit f0bbb6e

Please sign in to comment.