You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
syscall: document NewCallback and NewCallbackCDecl limitations
Currently NewCallback and NewCallbackCDecl may only be called a limited
number of times in a single Go process, but this property of the API is
not documented. This change fixes that, but does not document the
precise limit to avoid making that limit part of the API, leaving us
open to increasing or decreasing the limit in the future as needed.
Although the API avoids documenting a limit, it does guarantee a minimum
callback count so users can rely on at least some amount of callbacks
working.
Updates #46184.
Change-Id: I5129bf5fe301efff73ac112ba1f207ab32058833
Reviewed-on: https://go-review.googlesource.com/c/go/+/321133
Trust: Michael Knyszek <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
// NewCallback converts a Go function to a function pointer conforming to the stdcall calling convention.
175
175
// This is useful when interoperating with Windows code requiring callbacks.
176
176
// The argument is expected to be a function with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr.
177
+
// Only a limited number of callbacks may be created in a single Go process, and any memory allocated
178
+
// for these callbacks is never released.
179
+
// Between NewCallback and NewCallbackCDecl, at least 1024 callbacks can always be created.
177
180
funcNewCallback(fninterface{}) uintptr {
178
181
returncompileCallback(fn, true)
179
182
}
180
183
181
184
// NewCallbackCDecl converts a Go function to a function pointer conforming to the cdecl calling convention.
182
185
// This is useful when interoperating with Windows code requiring callbacks.
183
186
// The argument is expected to be a function with one uintptr-sized result. The function must not have arguments with size larger than the size of uintptr.
187
+
// Only a limited number of callbacks may be created in a single Go process, and any memory allocated
188
+
// for these callbacks is never released.
189
+
// Between NewCallback and NewCallbackCDecl, at least 1024 callbacks can always be created.
0 commit comments