diff options
author | Ayke van Laethem <[email protected]> | 2022-08-03 16:24:47 +0200 |
---|---|---|
committer | Ayke <[email protected]> | 2022-08-04 12:18:32 +0200 |
commit | c7a23183e822b9eebb639902414a0e08a09fbba0 (patch) | |
tree | 894a03fe2f4980a728c8401604d8a2c17503fde5 /src/syscall | |
parent | f936125658e8aef885a0e31d8fc343859defe63c (diff) | |
download | tinygo-c7a23183e822b9eebb639902414a0e08a09fbba0.tar.gz tinygo-c7a23183e822b9eebb639902414a0e08a09fbba0.zip |
all: format code according to Go 1.19 rules
Go 1.19 started reformatting code in a way that makes it more obvious
how it will be rendered on pkg.go.dev. It gets it almost right, but not
entirely. Therefore, I had to modify some of the comments so that they
are formatted correctly.
Diffstat (limited to 'src/syscall')
-rw-r--r-- | src/syscall/errno.go | 9 | ||||
-rw-r--r-- | src/syscall/file_hosted.go | 1 | ||||
-rw-r--r-- | src/syscall/proc_hosted.go | 6 | ||||
-rw-r--r-- | src/syscall/syscall_libc.go | 21 | ||||
-rw-r--r-- | src/syscall/syscall_libc_darwin.go | 10 | ||||
-rw-r--r-- | src/syscall/syscall_libc_darwin_amd64.go | 5 | ||||
-rw-r--r-- | src/syscall/syscall_libc_darwin_arm64.go | 5 | ||||
-rw-r--r-- | src/syscall/syscall_libc_wasi.go | 3 |
8 files changed, 52 insertions, 8 deletions
diff --git a/src/syscall/errno.go b/src/syscall/errno.go index ec6cc1fb8..3670a2dc9 100644 --- a/src/syscall/errno.go +++ b/src/syscall/errno.go @@ -13,10 +13,11 @@ import "internal/itoa" // An Errno is an unsigned number describing an error condition. // It implements the error interface. The zero Errno is by convention // a non-error, so code to convert from Errno to error should use: -// err = nil -// if errno != 0 { -// err = errno -// } +// +// err = nil +// if errno != 0 { +// err = errno +// } type Errno uintptr func (e Errno) Error() string { diff --git a/src/syscall/file_hosted.go b/src/syscall/file_hosted.go index f11081c31..86fc62c40 100644 --- a/src/syscall/file_hosted.go +++ b/src/syscall/file_hosted.go @@ -22,5 +22,6 @@ func Getwd() (string, error) { } // char *getcwd(char *buf, size_t size) +// //export getcwd func libc_getcwd(buf *byte, size uint) *byte diff --git a/src/syscall/proc_hosted.go b/src/syscall/proc_hosted.go index 2ec99ac54..dd7c289ca 100644 --- a/src/syscall/proc_hosted.go +++ b/src/syscall/proc_hosted.go @@ -14,25 +14,31 @@ func Getpid() int { return int(libc_getpid()) } func Getppid() int { return int(libc_getppid()) } // uid_t getuid(void) +// //export getuid func libc_getuid() int32 // gid_t getgid(void) +// //export getgid func libc_getgid() int32 // uid_t geteuid(void) +// //export geteuid func libc_geteuid() int32 // gid_t getegid(void) +// //export getegid func libc_getegid() int32 // gid_t getpid(void) +// //export getpid func libc_getpid() int32 // gid_t getppid(void) +// //export getppid func libc_getppid() int32 diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go index a02187b5f..0f10b7fbb 100644 --- a/src/syscall/syscall_libc.go +++ b/src/syscall/syscall_libc.go @@ -317,86 +317,107 @@ func splitSlice(p []byte) (buf *byte, len uintptr) { func libc_strlen(ptr unsafe.Pointer) uintptr // ssize_t write(int fd, const void *buf, size_t count) +// //export write func libc_write(fd int32, buf *byte, count uint) int // char *getenv(const char *name); +// //export getenv func libc_getenv(name *byte) *byte // int setenv(const char *name, const char *val, int replace); +// //export setenv func libc_setenv(name *byte, val *byte, replace int32) int32 // int unsetenv(const char *name); +// //export unsetenv func libc_unsetenv(name *byte) int32 // ssize_t read(int fd, void *buf, size_t count); +// //export read func libc_read(fd int32, buf *byte, count uint) int // ssize_t pread(int fd, void *buf, size_t count, off_t offset); +// //export pread func libc_pread(fd int32, buf *byte, count uint, offset int64) int // ssize_t lseek(int fd, off_t offset, int whence); +// //export lseek func libc_lseek(fd int32, offset int64, whence int) int64 // int open(const char *pathname, int flags, mode_t mode); +// //export open func libc_open(pathname *byte, flags int32, mode uint32) int32 // int close(int fd) +// //export close func libc_close(fd int32) int32 // int dup(int fd) +// //export dup func libc_dup(fd int32) int32 // void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); +// //export mmap func libc_mmap(addr unsafe.Pointer, length uintptr, prot, flags, fd int32, offset uintptr) unsafe.Pointer // int munmap(void *addr, size_t length); +// //export munmap func libc_munmap(addr unsafe.Pointer, length uintptr) int32 // int mprotect(void *addr, size_t len, int prot); +// //export mprotect func libc_mprotect(addr unsafe.Pointer, len uintptr, prot int32) int32 // int chdir(const char *pathname, mode_t mode); +// //export chdir func libc_chdir(pathname *byte) int32 // int chmod(const char *pathname, mode_t mode); +// //export chmod func libc_chmod(pathname *byte, mode uint32) int32 // int mkdir(const char *pathname, mode_t mode); +// //export mkdir func libc_mkdir(pathname *byte, mode uint32) int32 // int rmdir(const char *pathname); +// //export rmdir func libc_rmdir(pathname *byte) int32 // int rename(const char *from, *to); +// //export rename func libc_rename(from, to *byte) int32 // int symlink(const char *from, *to); +// //export symlink func libc_symlink(from, to *byte) int32 // ssize_t readlink(const char *path, void *buf, size_t count); +// //export readlink func libc_readlink(path *byte, buf *byte, count uint) int // int unlink(const char *pathname); +// //export unlink func libc_unlink(pathname *byte) int32 diff --git a/src/syscall/syscall_libc_darwin.go b/src/syscall/syscall_libc_darwin.go index 4b1f1716d..0e1ea087e 100644 --- a/src/syscall/syscall_libc_darwin.go +++ b/src/syscall/syscall_libc_darwin.go @@ -14,10 +14,10 @@ import ( // This function returns the error location in the darwin ABI. // Discovered by compiling the following code using Clang: // -// #include <errno.h> -// int getErrno() { -// return errno; -// } +// #include <errno.h> +// int getErrno() { +// return errno; +// } // //export __error func libc___error() *int32 @@ -272,9 +272,11 @@ func Getpagesize() int { } // int pipe(int32 *fds); +// //export pipe func libc_pipe(fds *int32) int32 // int getpagesize(); +// //export getpagesize func libc_getpagesize() int32 diff --git a/src/syscall/syscall_libc_darwin_amd64.go b/src/syscall/syscall_libc_darwin_amd64.go index 81e06efdd..242aca3f2 100644 --- a/src/syscall/syscall_libc_darwin_amd64.go +++ b/src/syscall/syscall_libc_darwin_amd64.go @@ -14,21 +14,26 @@ import ( // It not needed on arm64. // struct DIR * buf fdopendir(int fd); +// //export fdopendir$INODE64 func libc_fdopendir(fd int32) unsafe.Pointer // int readdir_r(struct DIR * buf, struct dirent *entry, struct dirent **result); +// //export readdir_r$INODE64 func libc_readdir_r(unsafe.Pointer, unsafe.Pointer, unsafe.Pointer) int32 // int stat(const char *path, struct stat * buf); +// //export stat$INODE64 func libc_stat(pathname *byte, ptr unsafe.Pointer) int32 // int fstat(int fd, struct stat * buf); +// //export fstat$INODE64 func libc_fstat(fd int32, ptr unsafe.Pointer) int32 // int lstat(const char *path, struct stat * buf); +// //export lstat$INODE64 func libc_lstat(pathname *byte, ptr unsafe.Pointer) int32 diff --git a/src/syscall/syscall_libc_darwin_arm64.go b/src/syscall/syscall_libc_darwin_arm64.go index 74075000b..815d84f92 100644 --- a/src/syscall/syscall_libc_darwin_arm64.go +++ b/src/syscall/syscall_libc_darwin_arm64.go @@ -8,21 +8,26 @@ import ( ) // struct DIR * buf fdopendir(int fd); +// //export fdopendir func libc_fdopendir(fd int32) unsafe.Pointer // int readdir_r(struct DIR * buf, struct dirent *entry, struct dirent **result); +// //export readdir_r func libc_readdir_r(unsafe.Pointer, unsafe.Pointer, unsafe.Pointer) int32 // int stat(const char *path, struct stat * buf); +// //export stat func libc_stat(pathname *byte, ptr unsafe.Pointer) int32 // int fstat(int fd, struct stat * buf); +// //export fstat func libc_fstat(fd int32, ptr unsafe.Pointer) int32 // int lstat(const char *path, struct stat * buf); +// //export lstat func libc_lstat(pathname *byte, ptr unsafe.Pointer) int32 diff --git a/src/syscall/syscall_libc_wasi.go b/src/syscall/syscall_libc_wasi.go index ec9d2304e..65f11b709 100644 --- a/src/syscall/syscall_libc_wasi.go +++ b/src/syscall/syscall_libc_wasi.go @@ -302,13 +302,16 @@ func Getpagesize() int { } // int stat(const char *path, struct stat * buf); +// //export stat func libc_stat(pathname *byte, ptr unsafe.Pointer) int32 // int fstat(fd int, struct stat * buf); +// //export fstat func libc_fstat(fd int32, ptr unsafe.Pointer) int32 // int lstat(const char *path, struct stat * buf); +// //export lstat func libc_lstat(pathname *byte, ptr unsafe.Pointer) int32 |