Skip to content

Commit 49f59aa

Browse files
authored
Merge pull request #3 from luoliwoshang/nc/test2
cl/nc:package_test
2 parents a40bf94 + be6035a commit 49f59aa

File tree

3 files changed

+212
-175
lines changed

3 files changed

+212
-175
lines changed

cl/internal/convert/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (p *Converter) Process() {
106106
}
107107
log.Panicln("ConvMacro:", err)
108108
}
109-
ctx.p.SetCurFile(goFile, true)
109+
ctx.SetGoFile(goFile)
110110
ctx.NewMacro(goName, macro)
111111
}
112112

cl/internal/convert/package.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ func (p *Package) SetCurFile(hfile *HeaderFile) {
166166
}
167167
*/
168168

169+
// to keep the unsafe package load to use go:linkname command
170+
func (p *Package) SetGoFile(goFile string) {
171+
p.p.SetCurFile(goFile, true)
172+
// todo(zzy):avoid remark
173+
p.p.Unsafe().MarkForceUsed(p.p)
174+
}
175+
169176
// todo(zzy):refine logic
170177
func (p *Package) linkLib(lib string) error {
171178
if lib == "" {

0 commit comments

Comments
 (0)