KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q37459: "pascal" Attribute for Multi-Thread Functions Returning Double

Article: Q37459
Product(s): See article
Version(s): 5.10
Operating System(s): OS/2
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 22-NOV-1988

Although it is not documented, an important requirement for returning
floating-point values from functions in a multi-thread environment is
defining and prototyping functions with the "pascal" function
attribute as we have done for all functions prototyped to return a
double in \include\mt\math.h.

When you use the pascal attribute on floating-point functions, the
floating-point return value is placed on the calling thread's stack,
providing each thread with its own return value as desired.

When using the default of the C function call/return convention
instead of pascal, we use a global variable __fac (floating-point
accumulator) for returning floating-point values. For multi-thread
applications or DLL's using CRTLIB.DLL, the global variable __fac
could be unintentionally modified by another thread, so it is not
contained in CRTEXE.OBJ, CRTDLL.OBJ, or CRTDLL.LIB. Consequently,
references to __fac will be unresolved at link time.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.