Skip to content

Commit 4882a56

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
fix: emit negative macro constants as hex literals
GL_TIMEOUT_IGNORED (0xFFFFFFFFFFFFFFFF) was emitted as -1, which overflows uint64 types like GLuint64. Emit negative values as hex to preserve the unsigned bit pattern. Fixes CI: "constant -1 overflows gles3.GLuint64"
1 parent 7bedf2c commit 4882a56

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

egl/constants.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gles2/constants.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gles3/constants.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/pkg/idiomgen/generate.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,15 @@ func generateUntypedMacros(
393393
var b strings.Builder
394394
b.WriteString(generatedHeader + "\n\npackage " + packageName + "\n\nconst (\n")
395395
for _, name := range names {
396-
fmt.Fprintf(&b, "\t%s = %d\n", name, macros[name])
396+
v := macros[name]
397+
// Emit negative values as hex to preserve the unsigned bit pattern.
398+
// E.g. GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFF, not -1, so it
399+
// can be used with both signed and unsigned Go types.
400+
if v < 0 {
401+
fmt.Fprintf(&b, "\t%s = 0x%X\n", name, uint64(v))
402+
} else {
403+
fmt.Fprintf(&b, "\t%s = %d\n", name, v)
404+
}
397405
}
398406
b.WriteString(")\n")
399407
return b.String()

0 commit comments

Comments
 (0)