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.
About

Darryl Gove is a senior engineer in the Solaris Studio team, working on optimising applications and benchmarks for current and future processors. He is also the author of the books:
Multicore Application Programming
Solaris Application Programming
The Developer's Edge

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
5
6
8
9
10
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
The Developer's Edge
Solaris Application Programming
Publications
Webcasts
Presentations
OpenSPARC Book
Multicore Application Programming
Docs