lkml.org 
[lkml]   [2002]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: floating point exception
    On 15 Jan 2002, Christian Thalinger wrote:

    > On Tue, 2002-01-15 at 15:34, Zwane Mwaikambo wrote:
    > > On 14 Jan 2002, Christian Thalinger wrote:
    [SNIPPED...]

    >
    > Tried this:
    >
    > #define _GNU_SOURCE 1
    > #include <fenv.h>
    >
    > main() {
    > double zero=0.0;
    > double one=1.0;
    >
    > feenableexcept(FE_ALL_EXCEPT);
    >
    > one /=zero;
    > }
    >
    Well, that won't even link. The source I showed previously
    compiles and link fine. It also shows a FPU exception when
    one divides by zero:

    Script started on Tue Jan 15 13:27:05 2002
    # gcc -o zzz zzz.c -lm
    /tmp/ccjhyGHj.o: In function `main':
    /tmp/ccjhyGHj.o(.text+0x25): undefined reference to `feenableexcept'
    collect2: ld returned 1 exit status
    # gcc -o zzz fpu.c
    # zzz
    Floating point exception (core dumped)
    # cat fpu.c
    /*
    * Note FPU control only exists per process. Therefore, you have
    * to set up the FPU before you use it in any program.
    */
    #include <i386/fpu_control.h>

    #define FPU_MASK (_FPU_MASK_IM |\
    _FPU_MASK_DM |\
    _FPU_MASK_ZM |\
    _FPU_MASK_OM |\
    _FPU_MASK_UM |\
    _FPU_MASK_PM)

    void fpu()
    {
    __setfpucw(_FPU_DEFAULT & ~FPU_MASK);
    }


    main() {
    double zero=0.0;
    double one=1.0;
    fpu();

    one /=zero;
    }

    # cat zzz.c

    #define _GNU_SOURCE 1
    #include <fenv.h>

    main() {
    double zero=0.0;
    double one=1.0;

    feenableexcept(FE_ALL_EXCEPT);

    one /=zero;
    }


    You have new mail in /var/spool/mail/root
    # exit
    exit

    Script done on Tue Jan 15 13:28:32 2002



    Cheers,
    Dick Johnson

    Penguin : Linux version 2.4.1 on an i686 machine (797.90 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:23    [W:0.028 / U:31.920 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site