Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Sep 95 13:04:17 +0100
From:      cracauer@wavehh.hanse.de (Martin Cracauer)
To:        cstruble@vt.edu
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Objective C
Message-ID:  <9509261204.AA13081@wavehh.hanse.de>
References:  <199509260315.XAA04532@quirk.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In hanse-ml.freebsd.hackers you write:

>Well, I saw a discussion a while ago, but it seemed without
>resolution.  I'm very interested in getting Objective C working on
>FreeBSD, but so far have been unable to get anywhere.

>I compiled gcc 2.7.0 and everything seemed to compile fine. I then
>tried to build libobjects-0.1.14 and the test programs. All the
>test programs fail with a core dump (floating point exception) in
>libobjc.a, the Objective C runtime library. It seems to be a problem
>with __builtin_return(), but my compiler knowledge is a bit lacking
>so I can't figure out exactly what is wrong.

>Has anyone gotten any Objective C programs to work on FreeBSD? If so,
>what magic incantations do I have to perform to get them to run?

The problem is that FreeBSD does not use IEEE exceptions. Division
by zero etc. (that result in NaN or other special IEEE numbers on
other machines) will raise the SIGFPE signal, which by default causes
a core dump.

Linux has the same problem. You can solve it at Linux using
-lieee. NetBSD uses full IEEE semantic as does any workstation I
have.

I don't know the correct FreeBSD solution, since nothing like -lieee
seems to exist. Maybe I overlooked the right way to solve this in
FreeBSD.

Anyway, in the meantime, to run ObjC programs, you can ignore the
signal, ObjC message dispatch works nothingtheless. I don't know why
gcc-2.7.0 partly produces exceptions and earlier versions did not.

At the beginning of your source file:
#ifdef __FreeBSD__
#include <signal.h>
#endif /* __FreeBSD__ */

Somewhere:
#ifdef __FreeBSD__
void signal_dummy(int nix) {};
#endif /* __FreeBSD__ */

At the beginning of the program, before any ObjC message call:
#ifdef __FreeBSD__
signal(SIGFPE,signal_dummy);
#endif /* __FreeBSD__ */

Note that FP exception (division by zero etc.) will not longer cause
your program to terminate, but will result in "0". Since the corrent
behaviour is to produce 'NaN' anyway, I find it unlikely that you'll
find a program that worked on FreeBSD and will no longer work with
this ignored signal.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@wavehh.hanse.de>. No NeXTMail, please.
 Norderstedt/Hamburg, Germany. Fax +49 40 522 85 36. This is a 
 private address. At (netless) work programming in data analysis.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9509261204.AA13081>