Re: FFI: FFI-Kernel-eem.233.mcz
Christoph Thiede via Squeak-dev <[email protected]> Fri, 12 Jun 2026 02:43:58 +0200
| Newsgroups | gmane.comp.lang.smalltalk.squeak.general |
|---|---|
| Message-ID | <01825bf3-cd04-4426-9fe3-d875cd789495@MX2025-DAG1.hpi.uni-potsdam.de> |
FYIO, I have little idea of how FFI is working, but I noticed by accident that the logic and documentation for accessing the error reporting mode is duplicated in ExternalFunction class>>#getFFIExceptionHandlingMode and FFIConstants class>>#getFFIExceptionHandling (plus setters). :-) Best, Christoph -- Sent from Squeak Inbox Talk On 2024-07-05T16:27:12+00:00, [email protected] wrote: > Eliot Miranda uploaded a new version of FFI-Kernel to project FFI: > http://source.squeak.org/FFI/FFI-Kernel-eem.233.mcz > > ==================== Summary ==================== > > Name: FFI-Kernel-eem.233 > Author: eem > Time: 5 July 2024, 9:27:10.149586 am > UUID: 672d32d5-d783-4ef4-9815-f743b6b1bcb6 > Ancestors: FFI-Kernel-mt.232 > > Add the methods to control the exception handling modes for FFI calls. > > Add an error code to loadSymbol:module:. > > Fix an immutability/under-the-covers-code-change issue with checkFFI > > =============== Diff against FFI-Kernel-mt.232 =============== > > Item was changed: > ----- Method: ExternalAddress class>>loadSymbol:module: (in category 'instance creation') ----- > loadSymbol: moduleSymbol module: module > + <primitive: #primitiveLoadSymbolFromModule module: #SqueakFFIPrims error: ec> > + ^ self primitiveFailed > + > + "self loadSymbol: 'primitiveLoadSymbolFromModule' module: #SqueakFFIPrims"! > - <primitive: #primitiveLoadSymbolFromModule module: #SqueakFFIPrims> > - ^ self primitiveFailed! > > Item was added: > + ----- Method: ExternalFunction class>>getFFIExceptionHandlingMode (in category 'system control') ----- > + getFFIExceptionHandlingMode > + "Answer the VM's FFI exception handling mode. > + The results are the following: > + -1: the VM is not catching, or cannot catch exceptions in FFI calls > + 0: the VM will catch exceptions in FFI calls which include an error code, and will throw such exceptions as a primitive failure whose code will contain informaiton about the exception (pc & code) > + 1: the VM will catch exceptions in any and all FFI calls, and will throw such exceptions as a primitive failure" > + <primitive: 220> > + self primitiveFailed > + > + "self getFFIExceptionHandlingMode"! > > Item was added: > + ----- Method: ExternalFunction class>>setFFIExceptionHandlingMode: (in category 'system control') ----- > + setFFIExceptionHandlingMode: integerCode > + "Set the VM's FFI exception handling mode: > + -1: the VM should not catch exceptions in FFI calls > + 0: the VM should catch exceptions in FFI calls which include an error code (and will throw such exceptions as a primitive failure whose code will contain information about the exception: pc & code) > + 1: the VM should catch exceptions in any and all FFI calls, and throw such exceptions as a primitive failure > + This primitive will fail if > + - the VM is too old to implement it > + - the VM cannot implement the catching of FFI errors on the current OS platform." > + <primitive: 220 error: ec> > + self primitiveFailed > + > + "self setFFIExceptionHandlingMode: -1" > + "self setFFIExceptionHandlingMode: 0" > + "self setFFIExceptionHandlingMode: 1"! > > Item was changed: > ----- Method: FFIPlatformDescription class>>checkFFI (in category 'system startup') ----- > checkFFI > "Try to load the FFI module. Warn if not possible." > > [ [ExternalType int32_t > + handle: #[ 0 0 0 0 ] shallowCopy > - handle: #[ 0 0 0 0 ] > at: 1 > put: 42] ifError: [:msg | > self notify: 'FFI plugin not available.', String cr, String cr, msg] > ] fork. "Do not interrupt the startup list."! Squeak-dev mailing list -- [email protected] To unsubscribe send an email to [email protected]