Update dependencies (#333)

This commit is contained in:
tobi 2021-11-27 15:26:58 +01:00 committed by GitHub
commit 182b4eea73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
848 changed files with 377869 additions and 107280 deletions

View file

@ -11,7 +11,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"runtime/debug"
"strconv"
"strings"
@ -29,6 +28,7 @@ import (
"modernc.org/libc/limits"
"modernc.org/libc/netdb"
"modernc.org/libc/netinet/in"
"modernc.org/libc/pthread"
"modernc.org/libc/pwd"
"modernc.org/libc/signal"
"modernc.org/libc/stdio"
@ -138,44 +138,15 @@ func Xgetrusage(t *TLS, who int32, usage uintptr) int32 {
return 0
}
// char *fgets(char *s, int size, FILE *stream);
func Xfgets(t *TLS, s uintptr, size int32, stream uintptr) uintptr {
// int fgetc(FILE *stream);
func Xfgetc(t *TLS, stream uintptr) int32 {
fd := int((*stdio.FILE)(unsafe.Pointer(stream)).F_file)
var b []byte
buf := [1]byte{}
for ; size > 0; size-- {
n, err := unix.Read(fd, buf[:])
if n != 0 {
b = append(b, buf[0])
if buf[0] == '\n' {
b = append(b, 0)
copy((*RawMem)(unsafe.Pointer(s))[:len(b):len(b)], b)
return s
}
continue
}
switch {
case n == 0 && err == nil && len(b) == 0:
return 0
default:
panic(todo(""))
}
// if err == nil {
// panic("internal error")
// }
// if len(b) != 0 {
// b = append(b, 0)
// copy((*RawMem)(unsafe.Pointer(s)[:len(b)]), b)
// return s
// }
// t.setErrno(err)
var buf [1]byte
if n, _ := unix.Read(fd, buf[:]); n != 0 {
return int32(buf[0])
}
panic(todo(""))
return stdio.EOF
}
// int lstat(const char *pathname, struct stat *statbuf);
@ -238,7 +209,7 @@ func Xopen(t *TLS, pathname uintptr, flags int32, args uintptr) int32 {
func Xopen64(t *TLS, pathname uintptr, flags int32, args uintptr) int32 {
var mode types.Mode_t
if args != 0 {
mode = *(*types.Mode_t)(unsafe.Pointer(args))
mode = (types.Mode_t)(VaUint32(&args))
}
fdcwd := fcntl.AT_FDCWD
n, _, err := unix.Syscall6(unix.SYS_OPENAT, uintptr(fdcwd), pathname, uintptr(flags), uintptr(mode), 0, 0)
@ -1742,16 +1713,6 @@ func Xferror(t *TLS, stream uintptr) int32 {
return Bool32(file(stream).err())
}
// int fgetc(FILE *stream);
func Xfgetc(t *TLS, stream uintptr) int32 {
panic(todo(""))
}
// int getc(FILE *stream);
func Xgetc(t *TLS, stream uintptr) int32 {
return Xfgetc(t, stream)
}
// int ungetc(int c, FILE *stream);
func Xungetc(t *TLS, c int32, stream uintptr) int32 {
panic(todo(""))
@ -1762,11 +1723,6 @@ func Xfscanf(t *TLS, stream, format, va uintptr) int32 {
panic(todo(""))
}
// FILE *fdopen(int fd, const char *mode);
func Xfdopen(t *TLS, fd int32, mode uintptr) uintptr {
panic(todo(""))
}
// int fputs(const char *s, FILE *stream);
func Xfputs(t *TLS, s, stream uintptr) int32 {
if _, _, err := unix.Syscall(unix.SYS_WRITE, uintptr(file(stream).fd()), s, uintptr(Xstrlen(t, s))); err != 0 {
@ -1931,11 +1887,6 @@ func X__isoc99_sscanf(t *TLS, str, format, va uintptr) int32 {
return r
}
// int sched_yield(void);
func Xsched_yield(t *TLS) {
runtime.Gosched()
}
var ctimeStaticBuf [32]byte
// char *ctime(const time_t *timep);
@ -2118,3 +2069,76 @@ func Xmmap(t *TLS, addr uintptr, length types.Size_t, prot, flags, fd int32, off
}
return data
}
const PTHREAD_MUTEX_DEFAULT = 0
func X__ccgo_pthreadMutexattrGettype(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:93:5: */
return (int32((*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr & uint32(3)))
}
func X__ccgo_getMutexType(tls *TLS, m uintptr) int32 { /* pthread_mutex_lock.c:3:5: */
return (*(*int32)(unsafe.Pointer((m /* &.__u */ /* &.__i */))) & 15)
}
func X__ccgo_pthreadAttrGetDetachState(tls *TLS, a uintptr) int32 { /* pthread_attr_get.c:3:5: */
return *(*int32)(unsafe.Pointer((a /* &.__u */ /* &.__i */) + 6*4))
}
func Xpthread_attr_init(t *TLS, pAttr uintptr) int32 {
*(*pthread.Pthread_attr_t)(unsafe.Pointer(pAttr)) = pthread.Pthread_attr_t(0)
return 0
}
// The pthread_mutex_init() function shall initialize the mutex referenced by
// mutex with attributes specified by attr. If attr is NULL, the default mutex
// attributes are used; the effect shall be the same as passing the address of
// a default mutex attributes object. Upon successful initialization, the state
// of the mutex becomes initialized and unlocked.
//
// If successful, the pthread_mutex_destroy() and pthread_mutex_init()
// functions shall return zero; otherwise, an error number shall be returned to
// indicate the error.
//
// int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
func Xpthread_mutex_init(t *TLS, pMutex, pAttr uintptr) int32 {
typ := PTHREAD_MUTEX_DEFAULT
if pAttr != 0 {
typ = int(X__ccgo_pthreadMutexattrGettype(t, pAttr))
}
mutexesMu.Lock()
defer mutexesMu.Unlock()
mutexes[pMutex] = newMutex(typ)
return 0
}
func Xpthread_attr_getdetachstate(tls *TLS, a uintptr, state uintptr) int32 { /* pthread_attr_get.c:7:5: */
*(*int32)(unsafe.Pointer(state)) = *(*int32)(unsafe.Pointer((a /* &.__u */ /* &.__i */) + 6*4))
return 0
}
func Xpthread_attr_setdetachstate(tls *TLS, a uintptr, state int32) int32 { /* pthread_attr_setdetachstate.c:3:5: */
if uint32(state) > 1 {
return 22
}
*(*int32)(unsafe.Pointer((a /* &.__u */ /* &.__i */) + 6*4)) = state
return 0
}
func Xpthread_mutexattr_destroy(tls *TLS, a uintptr) int32 { /* pthread_mutexattr_destroy.c:3:5: */
return 0
}
func Xpthread_mutexattr_init(tls *TLS, a uintptr) int32 { /* pthread_mutexattr_init.c:3:5: */
*(*pthread_mutexattr_t)(unsafe.Pointer(a)) = pthread_mutexattr_t{}
return 0
}
func Xpthread_mutexattr_settype(tls *TLS, a uintptr, type1 int32) int32 { /* pthread_mutexattr_settype.c:3:5: */
if uint32(type1) > uint32(2) {
return 22
}
(*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr = (((*pthread_mutexattr_t)(unsafe.Pointer(a)).__attr & Uint32FromInt32(CplInt32(3))) | uint32(type1))
return 0
}