Programmer's Reference

Pascal16 and cdecl16 pointer conversion

IBM Smalltalk pointers are normally addressed using the linear (0:32) memory model. Pascal16 and cdecl16 pointers use the selector:offset (16:16) model. When a pointer, safePointer, object, or struct value is used as a parameter to a pascal16 or cdecl16 function, it is automatically converted from 0:32 to 16:16. If a pointer, safePointer, or object value is returned from a pascal16 or cdecl16 function, it is automatically converted from 16:16 to 0:32. Immediate object values and the NULL pointer (value 0) are not converted (that is, their value is the same as 0:32 or 16:16).

Two internal PlatformFunctions have been provided so that users can perform these conversions manually, if required. They can be accessed as follows:

EsSelectorOffsetToLinear := "convert 16:16 to 0:32"
   PlatformFunction
      callingConvention: 'c'
      function: 'EsSelectorOffsetToLinear'
      library: nil
      parameterTypes: #(uint32)
      returnType: #uint32.
EsLinearToSelectorOffset := "convert 0:32 to 16:16"
   PlatformFunction
      callingConvention: 'c'
      function: 'EsLinearToSelectorOffset'
      library: nil
      parameterTypes: #(uint32)
      returnType: #uint32.
Note:If a pointer value is converted from 16:16 to 0:32 and then back to 16:16 (either automatically or manually), the final value will not necessarily be the same as the original 16:16 value. It will, however, point to the same physical memory location. Also, the functions do not assume that their argument is an IBM Smalltalk object pointer, so they will erroneously convert immediate object values.

These functions are also available from within user primitives. They are defined as follows:

They are available only on OS/2.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]