Update dependencies
This commit is contained in:
42
vendor/modernc.org/ccgo/v3/lib/ccgo.go
generated
vendored
42
vendor/modernc.org/ccgo/v3/lib/ccgo.go
generated
vendored
@ -32,17 +32,20 @@ import (
|
||||
"github.com/kballard/go-shellquote"
|
||||
"golang.org/x/tools/go/packages"
|
||||
"modernc.org/cc/v3"
|
||||
"modernc.org/libc"
|
||||
"modernc.org/opt"
|
||||
)
|
||||
|
||||
const (
|
||||
Version = "3.9.2-20210323171250"
|
||||
Version = "3.12.6-20210922111124"
|
||||
|
||||
experimentsEnvVar = "CCGO_EXPERIMENT"
|
||||
maxSourceLine = 1 << 20
|
||||
)
|
||||
|
||||
var (
|
||||
_ = libc.Xstdin
|
||||
|
||||
coverExperiment bool
|
||||
)
|
||||
|
||||
@ -201,9 +204,11 @@ char *__builtin___strncpy_chk(char *dest, char *src, size_t n, size_t os);
|
||||
char *__builtin_strchr(const char *s, int c);
|
||||
char *__builtin_strcpy(char *dest, const char *src);
|
||||
double __builtin_copysign ( double x, double y );
|
||||
double __builtin_copysignl (long double x, long double y );
|
||||
double __builtin_fabs(double x);
|
||||
double __builtin_huge_val (void);
|
||||
double __builtin_inf (void);
|
||||
double __builtin_nan (const char *str);
|
||||
float __builtin_copysignf ( float x, float y );
|
||||
float __builtin_huge_valf (void);
|
||||
float __builtin_inff (void);
|
||||
@ -226,6 +231,7 @@ int __builtin_sprintf(char *str, const char *format, ...);
|
||||
int __builtin_strcmp(const char *s1, const char *s2);
|
||||
int __builtin_sub_overflow();
|
||||
long __builtin_expect (long exp, long c);
|
||||
long double __builtin_nanl (const char *str);
|
||||
long long __builtin_llabs(long long j);
|
||||
size_t __builtin_object_size (void * ptr, int type);
|
||||
size_t __builtin_strlen(const char *s);
|
||||
@ -243,6 +249,7 @@ void __builtin_free(void *ptr);
|
||||
void __builtin_prefetch (const void *addr, ...);
|
||||
void __builtin_trap (void);
|
||||
void __builtin_unreachable (void);
|
||||
void __ccgo_dmesg(char*, ...);
|
||||
void __ccgo_va_end(__builtin_va_list ap);
|
||||
void __ccgo_va_start(__builtin_va_list ap);
|
||||
|
||||
@ -370,6 +377,7 @@ type Task struct {
|
||||
exportStructsValid bool // -export-structs present
|
||||
exportTypedefsValid bool // -export-typedefs present
|
||||
fullPathComments bool // -full-path-comments
|
||||
funcSig bool // -func-sig
|
||||
header bool // -header
|
||||
isScripted bool
|
||||
mingw bool
|
||||
@ -627,12 +635,13 @@ func (t *Task) Main() (err error) {
|
||||
opts.Opt("cover-instrumentation-c", func(opt string) error { t.coverC = true; return nil })
|
||||
opts.Opt("err-trace", func(opt string) error { t.errTrace = true; return nil })
|
||||
opts.Opt("full-path-comments", func(opt string) error { t.fullPathComments = true; return nil })
|
||||
opts.Opt("func-sig", func(opt string) error { t.funcSig = true; return nil })
|
||||
opts.Opt("header", func(opt string) error { t.header = true; return nil })
|
||||
opts.Opt("nocapi", func(opt string) error { t.noCapi = true; return nil })
|
||||
opts.Opt("nostdinc", func(opt string) error { t.nostdinc = true; return nil })
|
||||
opts.Opt("panic-stubs", func(opt string) error { t.panicStubs = true; return nil })
|
||||
opts.Opt("trace-translation-units", func(opt string) error { t.traceTranslationUnits = true; return nil })
|
||||
opts.Opt("trace-pinning", func(opt string) error { t.tracePinning = true; return nil })
|
||||
opts.Opt("trace-translation-units", func(opt string) error { t.traceTranslationUnits = true; return nil })
|
||||
opts.Opt("unexported-by-default", func(opt string) error { t.defaultUnExport = true; return nil })
|
||||
opts.Opt("verify-structs", func(opt string) error { t.verifyStructs = true; return nil })
|
||||
opts.Opt("version", func(opt string) error { t.version = true; return nil })
|
||||
@ -719,6 +728,20 @@ func (t *Task) Main() (err error) {
|
||||
}
|
||||
|
||||
if t.version {
|
||||
gobin, err := exec.LookPath("go")
|
||||
var b []byte
|
||||
if err == nil {
|
||||
var bin string
|
||||
bin, err = exec.LookPath(os.Args[0])
|
||||
if err == nil {
|
||||
b, err = exec.Command(gobin, "version", "-m", bin).CombinedOutput()
|
||||
}
|
||||
}
|
||||
if err == nil {
|
||||
fmt.Fprintf(t.stdout, "%s", b)
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Fprintf(t.stdout, "%s\n", Version)
|
||||
return nil
|
||||
}
|
||||
@ -745,6 +768,7 @@ func (t *Task) Main() (err error) {
|
||||
t.imported[len(t.imported)-1].used = true // crt is always imported
|
||||
}
|
||||
abi, err := cc.NewABI(t.goos, t.goarch)
|
||||
abi.Types[cc.LongDouble] = abi.Types[cc.Double]
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1210,8 +1234,8 @@ func (t *Task) createCompileDB(command []string) (rerr error) {
|
||||
var cmd *exec.Cmd
|
||||
var parser func(s string) ([]string, error)
|
||||
out:
|
||||
switch {
|
||||
case t.goos == "darwin":
|
||||
switch t.goos {
|
||||
case "darwin", "freebsd", "netbsd":
|
||||
if command[0] != "make" {
|
||||
return fmt.Errorf("usupported build command: %s", command[0])
|
||||
}
|
||||
@ -1224,7 +1248,7 @@ out:
|
||||
command = append([]string{sh, "-c"}, join(" ", command[0], "SHELL='sh -x'", command[1:]))
|
||||
cmd = exec.Command(command[0], command[1:]...)
|
||||
parser = makeXParser
|
||||
case t.goos == "windows":
|
||||
case "windows":
|
||||
if command[0] != "make" {
|
||||
return fmt.Errorf("usupported build command: %s", command[0])
|
||||
}
|
||||
@ -1397,6 +1421,7 @@ func (it *cdbItem) ccgoArgs(cc string) (r []string, err error) {
|
||||
set.Opt("pedantic", func(opt string) error { return nil })
|
||||
set.Opt("pipe", func(opt string) error { return nil })
|
||||
set.Opt("pthread", func(opt string) error { return nil })
|
||||
set.Opt("s", func(opt string) error { return nil })
|
||||
if err := set.Parse(it.Arguments[1:], func(arg string) error {
|
||||
switch {
|
||||
case strings.HasSuffix(arg, ".c"):
|
||||
@ -1564,6 +1589,7 @@ func (w *cdbMakeWriter) Write(b []byte) (int, error) {
|
||||
w.fail(err)
|
||||
continue
|
||||
}
|
||||
|
||||
if len(args) == 0 {
|
||||
continue
|
||||
}
|
||||
@ -1575,15 +1601,15 @@ func (w *cdbMakeWriter) Write(b []byte) (int, error) {
|
||||
err = nil
|
||||
switch args[0] {
|
||||
case w.cc:
|
||||
fmt.Println(args)
|
||||
fmt.Printf("CCGO CC: %q\n", args)
|
||||
err = w.handleGCC(args)
|
||||
case w.ar:
|
||||
if isCreateArchive(args[1]) {
|
||||
fmt.Println(args)
|
||||
fmt.Printf("CCGO AR: %q\n", args)
|
||||
err = w.handleAR(args)
|
||||
}
|
||||
case "libtool":
|
||||
fmt.Println(args)
|
||||
fmt.Printf("CCGO LIBTOOL: %q\n", args)
|
||||
err = w.handleLibtool(args)
|
||||
}
|
||||
if err != nil {
|
||||
|
1
vendor/modernc.org/ccgo/v3/lib/dmesg.go
generated
vendored
1
vendor/modernc.org/ccgo/v3/lib/dmesg.go
generated
vendored
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ccgo.dmesg
|
||||
// +build ccgo.dmesg
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
193
vendor/modernc.org/ccgo/v3/lib/go.go
generated
vendored
193
vendor/modernc.org/ccgo/v3/lib/go.go
generated
vendored
@ -6,7 +6,6 @@ package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"go/scanner"
|
||||
"go/token"
|
||||
@ -700,9 +699,9 @@ func (f *function) staticAllocsAndPinned(n *cc.CompoundStatement) {
|
||||
}
|
||||
}
|
||||
if need != 0 {
|
||||
if f.project.task.mingw {
|
||||
need += 8 // On windows the va list is prefixed with its length
|
||||
}
|
||||
//TODO- if f.project.task.mingw {
|
||||
//TODO- need += 8 // On windows the va list is prefixed with its length
|
||||
//TODO- }
|
||||
va := roundup(f.off, 8)
|
||||
f.vaLists[x] = va
|
||||
f.off = va + need
|
||||
@ -1221,6 +1220,7 @@ type project struct {
|
||||
structs map[cc.StringID]*taggedStruct // key: C tag
|
||||
symtab map[string]interface{} // *tld or *imported
|
||||
task *Task
|
||||
tldScope scope
|
||||
tlds map[*cc.Declarator]*tld
|
||||
ts bytes.Buffer // Text segment
|
||||
tsName string
|
||||
@ -1289,6 +1289,7 @@ func newProject(t *Task) (*project, error) {
|
||||
wanted: map[*cc.Declarator]struct{}{},
|
||||
wcharSize: t.asts[0].WideCharType.Size(),
|
||||
}
|
||||
p.tldScope = p.scope
|
||||
p.scope.take(idCAPI)
|
||||
for _, v := range t.imported {
|
||||
var err error
|
||||
@ -4255,6 +4256,18 @@ func (p *project) tld(f *function, n *cc.InitDeclarator, sep string, staticLocal
|
||||
}
|
||||
|
||||
if _, ok := p.wanted[d]; !ok && !staticLocal {
|
||||
isFn := d.Type().Kind() == cc.Function
|
||||
if isFn && p.task.header && p.task.funcSig {
|
||||
if nm := d.Name().String(); !strings.HasPrefix(nm, "__") {
|
||||
p.w("\n\n")
|
||||
t := p.tlds[d]
|
||||
if t == nil {
|
||||
t = &tld{}
|
||||
t.name = p.tldScope.take(d.Name())
|
||||
}
|
||||
p.functionSignature2(nil, d.Type(), t.name)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -4303,7 +4316,7 @@ func (p *project) tld(f *function, n *cc.InitDeclarator, sep string, staticLocal
|
||||
|
||||
func (p *project) functionDefinition(n *cc.FunctionDefinition) {
|
||||
// DeclarationSpecifiers Declarator DeclarationList CompoundStatement
|
||||
if p.task.header {
|
||||
if p.task.header && !p.task.funcSig {
|
||||
return
|
||||
}
|
||||
|
||||
@ -4362,6 +4375,10 @@ func (p *project) functionDefinition(n *cc.FunctionDefinition) {
|
||||
p.pass1 = false
|
||||
p.w("\n\n")
|
||||
p.functionDefinitionSignature(f, tld)
|
||||
if p.task.header && p.task.funcSig {
|
||||
return
|
||||
}
|
||||
|
||||
p.w(" ")
|
||||
comment := fmt.Sprintf("/* %v: */", p.pos(d))
|
||||
if p.task.panicStubs {
|
||||
@ -5167,30 +5184,11 @@ func (p *project) assignmentExpressionValueAssignBitfield(f *function, n *cc.Ass
|
||||
lt := lhs.Operand.Type()
|
||||
bf := lt.BitField()
|
||||
defer p.w("%s", p.convertType(n, lt, t, flags))
|
||||
switch {
|
||||
case bf.Type().IsSignedType():
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
break
|
||||
}
|
||||
|
||||
p.w("%sAssignBitFieldPtr%d%s(", p.task.crt, bf.BitFieldBlockWidth(), p.bfHelperType(lt))
|
||||
p.unaryExpression(f, lhs, lt, exprAddrOf, flags)
|
||||
p.w(", ")
|
||||
p.assignmentExpression(f, n.AssignmentExpression, lt, exprValue, flags|fOutermost)
|
||||
p.w(", %d, %d, %#x)", bf.BitFieldWidth(), bf.BitFieldOffset(), bf.Mask())
|
||||
default:
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
break
|
||||
}
|
||||
|
||||
p.w("%sAssignBitFieldPtr%d%s(", p.task.crt, bf.BitFieldBlockWidth(), p.bfHelperType(lt))
|
||||
p.unaryExpression(f, lhs, lt, exprAddrOf, flags)
|
||||
p.w(", ")
|
||||
p.assignmentExpression(f, n.AssignmentExpression, lt, exprValue, flags|fOutermost)
|
||||
p.w(", %d, %d, %#x)", bf.BitFieldWidth(), bf.BitFieldOffset(), bf.Mask())
|
||||
}
|
||||
p.w("%sAssignBitFieldPtr%d%s(", p.task.crt, bf.BitFieldBlockWidth(), p.bfHelperType(lt))
|
||||
p.unaryExpression(f, lhs, lt, exprAddrOf, flags)
|
||||
p.w(", ")
|
||||
p.assignmentExpression(f, n.AssignmentExpression, lt, exprValue, flags|fOutermost)
|
||||
p.w(", %d, %d, %#x)", bf.BitFieldWidth(), bf.BitFieldOffset(), bf.Mask())
|
||||
}
|
||||
|
||||
func (p *project) assignmentExpressionValueAssignNormal(f *function, n *cc.AssignmentExpression, t cc.Type, mode exprMode, flags flags) {
|
||||
@ -5260,11 +5258,6 @@ func (p *project) assignmentExpressionVoid(f *function, n *cc.AssignmentExpressi
|
||||
p.assignmentExpression(f, n.AssignmentExpression, lt, mode, flags|fOutermost)
|
||||
}
|
||||
case opBitfield:
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
break
|
||||
}
|
||||
|
||||
bf := lt.BitField()
|
||||
p.w("%sSetBitFieldPtr%d%s(", p.task.crt, bf.BitFieldBlockWidth(), p.bfHelperType(lt))
|
||||
p.unaryExpression(f, lhs, lt, exprAddrOf, flags)
|
||||
@ -7111,16 +7104,11 @@ func (p *project) binaryShiftExpressionBool(f *function, n *cc.ShiftExpression,
|
||||
defer p.w("%s", p.artithmeticBinaryExpression(n, n.Operand, n.Operand.Type(), &mode, flags))
|
||||
switch {
|
||||
case n.ShiftExpression.Operand.Type().IsBitFieldType():
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
return
|
||||
}
|
||||
|
||||
p.w("(")
|
||||
p.shiftExpression(f, n.ShiftExpression, n.Operand.Type(), exprValue, flags)
|
||||
p.w(" %s%s", oper, tidyComment(" ", &n.Token))
|
||||
p.additiveExpression(f, n.AdditiveExpression, n.Promote(), exprValue, flags)
|
||||
p.w(")&%#x", n.ShiftExpression.Operand.Type().BitField().Mask())
|
||||
p.w(")&%#x", bfValueMask(n.ShiftExpression.Operand.Type().BitField()))
|
||||
case shiftOverflows(n, n.ShiftExpression.Operand, n.AdditiveExpression.Operand, oper, n.Operand.Type()):
|
||||
p.shiftExpression(f, n.ShiftExpression, n.Operand.Type(), exprValue, flags|fForceRuntimeConv)
|
||||
p.w(" %s%s", oper, tidyComment(" ", &n.Token))
|
||||
@ -7148,6 +7136,10 @@ func shiftOp(s string) string {
|
||||
}
|
||||
}
|
||||
|
||||
func bfValueMask(bf cc.Field) uint64 {
|
||||
return uint64(1)<<bf.BitFieldWidth() - 1
|
||||
}
|
||||
|
||||
func (p *project) binaryShiftExpressionValue(f *function, n *cc.ShiftExpression, oper string, t cc.Type, mode exprMode, flags flags) {
|
||||
// ShiftExpression "<<" AdditiveExpression
|
||||
flags &^= fOutermost
|
||||
@ -7160,16 +7152,11 @@ func (p *project) binaryShiftExpressionValue(f *function, n *cc.ShiftExpression,
|
||||
p.additiveExpression(f, n.AdditiveExpression, p.intType, exprValue, flags|fOutermost)
|
||||
p.w(")")
|
||||
case n.ShiftExpression.Operand.Type().IsBitFieldType():
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
return
|
||||
}
|
||||
|
||||
p.w("(")
|
||||
p.shiftExpression(f, n.ShiftExpression, n.Operand.Type(), exprValue, flags)
|
||||
p.w(" %s%s", oper, tidyComment(" ", &n.Token))
|
||||
p.additiveExpression(f, n.AdditiveExpression, n.Promote(), exprValue, flags)
|
||||
p.w(")&%#x", n.ShiftExpression.Operand.Type().BitField().Mask())
|
||||
p.w(")&%#x", bfValueMask(n.ShiftExpression.Operand.Type().BitField()))
|
||||
case shiftOverflows(n, n.ShiftExpression.Operand, n.AdditiveExpression.Operand, oper, n.Operand.Type()):
|
||||
p.shiftExpression(f, n.ShiftExpression, n.Operand.Type(), exprValue, flags|fForceRuntimeConv)
|
||||
p.w(" %s%s", oper, tidyComment(" ", &n.Token))
|
||||
@ -8156,7 +8143,7 @@ func (p *project) castExpressionValueNormal(f *function, n *cc.CastExpression, t
|
||||
case cc.Void:
|
||||
p.castExpression(f, n.CastExpression, tn, exprVoid, flags)
|
||||
default:
|
||||
panic(todo("", n.Position(), t, t.Kind()))
|
||||
panic(todo("%s: %s %s -> %s %s -> %s %s", n.Position(), op.Type(), op.Type().Kind(), tn, tn.Kind(), t, t.Kind()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9947,11 +9934,6 @@ func (p *project) postfixExpressionValuePSelectStruct(f *function, n *cc.Postfix
|
||||
defer p.w("%s", p.convertType(n, fld.Promote(), t, flags))
|
||||
switch pe.Kind() {
|
||||
case cc.Array:
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
return
|
||||
}
|
||||
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
p.w("*(*uint%d)(unsafe.Pointer(", fld.BitFieldBlockWidth())
|
||||
p.postfixExpression(f, n.PostfixExpression, pe, exprDecay, flags)
|
||||
@ -9963,18 +9945,6 @@ func (p *project) postfixExpressionValuePSelectStruct(f *function, n *cc.Postfix
|
||||
p.w("<<%d>>%[1]d", int(fld.Promote().Size()*8)-fld.BitFieldWidth())
|
||||
}
|
||||
default:
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
p.w("*(*uint%d)(unsafe.Pointer(", fld.BitFieldBlockWidth())
|
||||
p.postfixExpression(f, n.PostfixExpression, pe, exprValue, flags)
|
||||
p.bitFldOff(pe.Elem(), n.Token2)
|
||||
p.w("))>>%d&%#x%s", fld.BitFieldBlockWidth()-fld.BitFieldOffset()-fld.BitFieldWidth(), uint64(1)<<fld.BitFieldWidth()-1, x)
|
||||
if fld.Type().IsSignedType() {
|
||||
p.w("<<%d>>%[1]d", int(fld.Promote().Size()*8)-fld.BitFieldWidth())
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
p.w("*(*uint%d)(unsafe.Pointer(", fld.BitFieldBlockWidth())
|
||||
p.postfixExpression(f, n.PostfixExpression, pe, exprValue, flags)
|
||||
@ -10141,11 +10111,6 @@ func (p *project) postfixExpressionValueSelectUnion(f *function, n *cc.PostfixEx
|
||||
}
|
||||
switch {
|
||||
case n.Operand.Type().IsBitFieldType():
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.todo(n, t)
|
||||
return
|
||||
}
|
||||
|
||||
p.w("(")
|
||||
defer p.w("%s)", p.convertType(n, fld.Promote(), t, flags))
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
@ -10175,20 +10140,6 @@ func (p *project) postfixExpressionValueSelectStruct(f *function, n *cc.PostfixE
|
||||
fld := n.Field
|
||||
switch {
|
||||
case n.Operand.Type().IsBitFieldType():
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
p.w("(")
|
||||
defer p.w("%s)", p.convertType(n, fld.Promote(), t, flags))
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
p.w("*(*uint%d)(unsafe.Pointer(", fld.BitFieldBlockWidth())
|
||||
p.postfixExpression(f, n.PostfixExpression, pe, exprAddrOf, flags)
|
||||
p.bitFldOff(pe, n.Token2)
|
||||
p.w("))>>%d&%#x%s", fld.BitFieldBlockWidth()-fld.BitFieldOffset()-fld.BitFieldWidth(), uint64(1)<<fld.BitFieldWidth()-1, x)
|
||||
if fld.Type().IsSignedType() {
|
||||
p.w("<<%d>>%[1]d", int(fld.Promote().Size()*8)-fld.BitFieldWidth())
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
p.w("(")
|
||||
defer p.w("%s)", p.convertType(n, fld.Promote(), t, flags))
|
||||
x := p.convertType(n, nil, fld.Promote(), flags)
|
||||
@ -10491,10 +10442,6 @@ func (p *project) postfixExpressionIncDecValueArrayParameter(f *function, n *cc.
|
||||
}
|
||||
|
||||
func (p *project) postfixExpressionIncDecValueBitfield(f *function, n *cc.PostfixExpression, oper, oper2 string, t cc.Type, mode exprMode, flags flags) {
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
panic(todo("", n.Position()))
|
||||
}
|
||||
|
||||
// PostfixExpression "++"
|
||||
pe := n.PostfixExpression.Operand.Type()
|
||||
defer p.w("%s", p.convert(n, n.PostfixExpression.Operand, t, flags))
|
||||
@ -10671,6 +10618,9 @@ func (p *project) bitFldOff(t cc.Type, tok cc.Token) {
|
||||
}
|
||||
|
||||
func (p *project) fldOff(t cc.Type, tok cc.Token) {
|
||||
if t.Kind() == cc.Ptr {
|
||||
t = t.Elem()
|
||||
}
|
||||
var off uintptr
|
||||
fld, ok := t.FieldByName(tok.Value)
|
||||
switch {
|
||||
@ -10729,8 +10679,12 @@ func (p *project) postfixExpressionCallBool(f *function, n *cc.PostfixExpression
|
||||
}
|
||||
}
|
||||
|
||||
var va uintptr
|
||||
if f != nil {
|
||||
va = f.vaLists[n]
|
||||
}
|
||||
p.postfixExpression(f, n.PostfixExpression, n.PostfixExpression.Operand.Type(), exprFunc, flags&^fOutermost)
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, f.vaLists[n])
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, va)
|
||||
}
|
||||
|
||||
func (p *project) postfixExpressionCallValue(f *function, n *cc.PostfixExpression, t cc.Type, mode exprMode, flags flags) {
|
||||
@ -10775,8 +10729,12 @@ func (p *project) postfixExpressionCallValue(f *function, n *cc.PostfixExpressio
|
||||
return
|
||||
}
|
||||
}
|
||||
var va uintptr
|
||||
if f != nil {
|
||||
va = f.vaLists[n]
|
||||
}
|
||||
p.postfixExpression(f, n.PostfixExpression, n.PostfixExpression.Operand.Type(), exprFunc, flags&^fOutermost)
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, f.vaLists[n])
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, va)
|
||||
}
|
||||
|
||||
// bool __builtin_mul_overflow (type1 a, type2 b, type3 *res)
|
||||
@ -10970,8 +10928,12 @@ func (p *project) postfixExpressionCallVoid(f *function, n *cc.PostfixExpression
|
||||
return
|
||||
}
|
||||
}
|
||||
var va uintptr
|
||||
if f != nil {
|
||||
va = f.vaLists[n]
|
||||
}
|
||||
p.postfixExpression(f, n.PostfixExpression, n.PostfixExpression.Operand.Type(), exprFunc, flags&^fOutermost)
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, f.vaLists[n])
|
||||
p.argumentExpressionList(f, n.PostfixExpression, n.ArgumentExpressionList, va)
|
||||
}
|
||||
|
||||
// void __atomic_store_n (type *ptr, type val, int memorder)
|
||||
@ -11036,7 +10998,12 @@ func (p *project) argList(n *cc.ArgumentExpressionList) (r []*cc.AssignmentExpre
|
||||
}
|
||||
|
||||
func (p *project) argumentExpressionList(f *function, pe *cc.PostfixExpression, n *cc.ArgumentExpressionList, bpOff uintptr) {
|
||||
p.w("(%s", f.tlsName)
|
||||
switch {
|
||||
case f == nil:
|
||||
p.w("(nil")
|
||||
default:
|
||||
p.w("(%s", f.tlsName)
|
||||
}
|
||||
ft := funcType(pe.Operand.Type())
|
||||
isVariadic := ft.IsVariadic()
|
||||
params := ft.Parameters()
|
||||
@ -11347,7 +11314,7 @@ func (p *project) primaryExpressionBool(f *function, n *cc.PrimaryExpression, t
|
||||
case cc.PrimaryExpressionChar: // CHARCONST
|
||||
panic(todo("", p.pos(n)))
|
||||
case cc.PrimaryExpressionLChar: // LONGCHARCONST
|
||||
panic(todo("", p.pos(n)))
|
||||
p.charConst(n, n.Token.Src.String(), n.Operand, t, flags)
|
||||
case cc.PrimaryExpressionString: // STRINGLITERAL
|
||||
p.w(" 1 ")
|
||||
case cc.PrimaryExpressionLString: // LONGSTRINGLITERAL
|
||||
@ -11457,7 +11424,7 @@ func (p *project) primaryExpressionAddrOf(f *function, n *cc.PrimaryExpression,
|
||||
case cc.PrimaryExpressionString: // STRINGLITERAL
|
||||
p.w("%s", p.stringLiteral(n.Operand.Value()))
|
||||
case cc.PrimaryExpressionLString: // LONGSTRINGLITERAL
|
||||
panic(todo("", p.pos(n)))
|
||||
p.w("%s", p.wideStringLiteral(n.Operand.Value(), 0))
|
||||
case cc.PrimaryExpressionExpr: // '(' Expression ')'
|
||||
p.expression(f, n.Expression, t, mode, flags)
|
||||
case cc.PrimaryExpressionStmt: // '(' CompoundStatement ')'
|
||||
@ -12045,10 +12012,6 @@ func (p *project) assignOpValueBitfield(f *function, n *cc.AssignmentExpression,
|
||||
panic(todo(""))
|
||||
}
|
||||
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
panic(todo("", n.Position()))
|
||||
}
|
||||
|
||||
ot := n.Operand.Type()
|
||||
lhs := n.UnaryExpression
|
||||
bf := lhs.Operand.Type().BitField()
|
||||
@ -12078,10 +12041,6 @@ func (p *project) assignOpValueBitfield(f *function, n *cc.AssignmentExpression,
|
||||
}
|
||||
|
||||
func (p *project) readBitfield(n cc.Node, ptr string, bf cc.Field, promote cc.Type) {
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
panic(todo("", n.Position()))
|
||||
}
|
||||
|
||||
bw := bf.BitFieldBlockWidth()
|
||||
m := bf.Mask()
|
||||
o := bf.BitFieldOffset()
|
||||
@ -12213,10 +12172,6 @@ func (p *project) assignOpVoidArrayParameter(f *function, n *cc.AssignmentExpres
|
||||
}
|
||||
|
||||
func (p *project) assignOpVoidBitfield(f *function, n *cc.AssignmentExpression, t cc.Type, oper, oper2 string, mode exprMode, flags flags) {
|
||||
if p.task.cfg.ABI.ByteOrder == binary.BigEndian {
|
||||
panic(todo("", n.Position()))
|
||||
}
|
||||
|
||||
// UnaryExpression "*=" AssignmentExpression etc.
|
||||
lhs := n.UnaryExpression
|
||||
lt := lhs.Operand.Type()
|
||||
@ -12793,6 +12748,34 @@ func (p *project) functionDefinitionSignature(f *function, tld *tld) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *project) functionSignature2(f *function, t cc.Type, nm string) {
|
||||
p.w("func %s", nm)
|
||||
p.w("(_ *%sTLS", p.task.crt)
|
||||
suffix := 1
|
||||
for _, v := range t.Parameters() {
|
||||
if v.Type().Kind() == cc.Void {
|
||||
break
|
||||
}
|
||||
|
||||
pn := "_"
|
||||
if d := v.Declarator(); d != nil {
|
||||
pn = d.Name().String()
|
||||
if _, ok := reservedNames[pn]; ok {
|
||||
pn += strconv.Itoa(suffix)
|
||||
suffix++
|
||||
}
|
||||
}
|
||||
p.w(", %s %s", pn, p.paramTyp(v.Declarator(), v.Type()))
|
||||
}
|
||||
if t.IsVariadic() {
|
||||
p.w(", _ /* va_list */ uintptr")
|
||||
}
|
||||
p.w(")")
|
||||
if rt := t.Result(); rt != nil && rt.Kind() != cc.Void {
|
||||
p.w(" %s", p.typ(nil, rt))
|
||||
}
|
||||
}
|
||||
|
||||
func (p *project) functionSignature(f *function, t cc.Type, nm string) {
|
||||
p.w("func")
|
||||
if nm != "" {
|
||||
|
6
vendor/modernc.org/ccgo/v3/lib/init.go
generated
vendored
6
vendor/modernc.org/ccgo/v3/lib/init.go
generated
vendored
@ -38,7 +38,7 @@ func (p *project) initializer(f *function, n *cc.Initializer, t cc.Type, sc cc.S
|
||||
}
|
||||
|
||||
if a.Field == nil || b.Field == nil || !a.Field.IsBitField() || !b.Field.IsBitField() {
|
||||
panic(todo("%v: internal error: %#x, %v: %#x", a.Position(), a.Offset, b.Position(), b.Offset))
|
||||
panic(todo("%v: internal error: off %#x, %v: off %#x, t %v", a.Position(), a.Offset, b.Position(), b.Offset, t))
|
||||
}
|
||||
|
||||
return a.Field.BitFieldOffset() < b.Field.BitFieldOffset()
|
||||
@ -292,10 +292,6 @@ func (p *project) initializerStructField(off uintptr, s []*cc.Initializer, t cc.
|
||||
bits := false
|
||||
for i := []int{0}; i[0] < nf; i[0]++ {
|
||||
fld2 := t.FieldByIndex(i)
|
||||
if fld2.Name() == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if fld == nil {
|
||||
fld = fld2
|
||||
}
|
||||
|
1
vendor/modernc.org/ccgo/v3/lib/mem.go
generated
vendored
1
vendor/modernc.org/ccgo/v3/lib/mem.go
generated
vendored
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !linux
|
||||
// +build !linux
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
1
vendor/modernc.org/ccgo/v3/lib/nodmesg.go
generated
vendored
1
vendor/modernc.org/ccgo/v3/lib/nodmesg.go
generated
vendored
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !ccgo.dmesg
|
||||
// +build !ccgo.dmesg
|
||||
|
||||
package ccgo // import "modernc.org/ccgo/v3/lib"
|
||||
|
Reference in New Issue
Block a user