| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Thunking, I Think... |
On Wednesday, 1994-07-27 Stacy Smith wrote to Eric Erickson about "Thunking, I Think..." as follows: SS> EE| No thunking is the process of converting between 16:16 (selector:offset) SS> | and 32 bit flat pointers. This is required under OS/2 2.x since some SS> | function calls want 16 Bit Pointers and others need 32 bit. SS> SS> Ah...that makes sense. Are there functions/macros in OS/2 SS> compilers to do this, or do I need to calculate it myself? --- Hi Stacy, Actually, thunking is a more general process that has been around for over 30 years. It was first used in public by a number of ALGOL 60 compilers that implemented the full, 1960 standard for the IFIP Algorithmic Language (ALGOL). A thunk is a compiler-generated (as opposed to programmer-written) subroutine that provides parameter values to a programmer-written subroutine when the parameter supplied by the calling program or subroutine does not match the specifications of the formal parameter in the called subroutine's definition. It is theoretically a two-way mechanism, unlike (say) FORTRAN 77 that would automatically pass a converted value -- typically an INTEGER passed as a REAL -- but would not update the original variable if the parameter were updated. Thus, the input parameter would be 'thunked' in and the result 'thunked' out. This concept is used extensively under OS/2 to provide pointer values when a subroutine expects a segmented-model pointer and is passed a flat-model pointer, or vice-versa. But thunking is not limited to this. Also, conversion of pointers other than in the parameter passing mechanism is NOT correctly called 'thunking'; this is a misuse of the word. If you want to call subroutines that use segmented-model pointers from programs that use the flat memory model, you can do so quite liberally and a good compiler will take care of the conversion for you. However, there are 2 API calls, DosFlatToSel() and DosSelToFlat(), that will allow you to convert pointers almost-manually; note that these API calls use Optlink calling convention. Regards Dave ___ X KWQ/2 1.2e X I thunk therefore I am ..... 32-bit compiler --- Maximus/2 2.01wb* Origin: OS/2 Shareware BBS, Fairfax, VA: 703-385-4325 (1:109/347) SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 413 430 SEEN-BY: 711/807 808 809 934 942 712/353 623 713/888 800/1 @PATH: 109/347 2 1 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.