New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

How to trap fpu exceptions on macbook pro?


Post Reply New Thread Subscribe

 
Thread Tools
miggles

 
Member Since: Aug 03, 2004
Posts: 39
miggles is on a distinguished road

miggles is offline
I can't get even a simple C++ code to trap fpu errors, no matter what combination of compile options or signal handling I attempt. Can anyone point me to some definitive documation on this? Thanks.

#include <iostream>
#include <cmath>
#include <signal.h>


int main()
{
signal(SIGFPE, exit);

for (int i=0; i<10; i++) {
double arg = -5 + i;
double recip = 1. / arg;

std::cerr << arg << " " << recip << std::endl;
}
}



And here is the compile command with every possible non-optimization and fpu-related option that I could find, set to its pickiest setting:


% cc junk.C -g -O0 -lc -lstdc++ -Wl,-m -Wl,-w -lm -fsignaling-nans -ftrapping-math -fno-unsafe-math-optimizations
% ./a.out
-5 -0.2
-4 -0.25
-3 -0.333333
-2 -0.5
-1 -1
0 inf
1 1
2 0.5
3 0.333333
4 0.25


The code should exit/crash prior to outputting the 6th line.

Thanks.
QUOTE Thanks
miggles

 
Member Since: Aug 03, 2004
Posts: 39
miggles is on a distinguished road

miggles is offline
Furthermore, I can't get this to work on PowerPC macs either. So any help even getting this to go for non-intel mac would be much appreciated. Thanks.
QUOTE Thanks
miggles

 
Member Since: Aug 03, 2004
Posts: 39
miggles is on a distinguished road

miggles is offline
Okay, I found a code snippet at:

http://developer.apple.com/technotes/tn2002/tn2053.html

which shows how to enable trapping on powerpc architectures. It involves an asm command, so a corresponding version for intel is bound to be different.
QUOTE Thanks

Post Reply New Thread Subscribe


« Localhost | xcode applescript help »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
19 Days with a Macbook Pro b.hicks Switcher Hangout 23 03-01-2010 12:49 AM
MacBook impressions - trip to store kaidomac Schweb's Lounge 24 10-14-2007 01:45 PM
Should I get Macbook or Macbook Pro? markw10 Switcher Hangout 20 10-12-2007 03:43 PM
Macbook or MacBook Pro? markw10 Apple Notebooks 1 08-31-2006 02:37 AM

All times are GMT -4. The time now is 11:16 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?