Darryl Gove's blog

Friday Dec 15, 2006

Define in -fast

There is a #define included in -fast. It's the rather petulantly named MATHERR_ERRNO_DONTCARE. This tells the compiler that some maths library functions don't have side effects (like setting errno), so the compiler can assume that the errno variable is unchanged by the call. Of course the library code is still free to change errno, it's just the that the compiler will assume that the variable hasn't changed.

The documentation contains an example.

Examining the actual header (/usr/include/math.h) file shows that the pragma used are:

  • #pragma does_not_read_global_data(). So global data does not need to be stored back to memory before the function is called.
  • #pragma does_not_write_global_data(). So global data does not need to be reloaded after the function call returns.
  • #pragma no_side_effect(). So the function call can be eliminated if the result of the call is not used.

This only affects the errno variable for the floating point routines, and it basically tells the compiler that the programmer is not interested in whether the errno variable is changed or not.

Comments:

Post a Comment:
Comments are closed for this entry.

Calendar

Search this blog

About

Solaris Application Programming

Book resources

The Developer's Edge

Book resources

OpenSPARC Internals

Book resources

Recent entries

Custom search

Tag cloud

book cmt communityone compiler cooltools cpu2006 dtrace gcc libraries linker multithreading openmp opensolaris opensparc optimisation optimization parallelisation parallelization performance performanceanalyzer programming secondlife solaris solarisapplicationprogramming sparc spot sunstudio ultrasparc ultrasparct2 x86

Links

Webcasts

Articles

Presentations

Interesting docs

Navigation

Referers

Feeds