OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [tcl/] [unix/] [tclMtherr.c] - Diff between revs 578 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 578 Rev 1765
/*
/*
 * tclMatherr.c --
 * tclMatherr.c --
 *
 *
 *      This function provides a default implementation of the
 *      This function provides a default implementation of the
 *      "matherr" function, for SYS-V systems where it's needed.
 *      "matherr" function, for SYS-V systems where it's needed.
 *
 *
 * Copyright (c) 1993-1994 The Regents of the University of California.
 * Copyright (c) 1993-1994 The Regents of the University of California.
 * Copyright (c) 1994 Sun Microsystems, Inc.
 * Copyright (c) 1994 Sun Microsystems, Inc.
 *
 *
 * See the file "license.terms" for information on usage and redistribution
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 *
 * RCS: @(#) $Id: tclMtherr.c,v 1.1.1.1 2002-01-16 10:25:37 markom Exp $
 * RCS: @(#) $Id: tclMtherr.c,v 1.1.1.1 2002-01-16 10:25:37 markom Exp $
 */
 */
 
 
#include "tclInt.h"
#include "tclInt.h"
#include <math.h>
#include <math.h>
 
 
#ifndef TCL_GENERIC_ONLY
#ifndef TCL_GENERIC_ONLY
#include "tclPort.h"
#include "tclPort.h"
#else
#else
#define NO_ERRNO_H
#define NO_ERRNO_H
#endif
#endif
 
 
#ifdef NO_ERRNO_H
#ifdef NO_ERRNO_H
extern int errno;                       /* Use errno from tclExecute.c. */
extern int errno;                       /* Use errno from tclExecute.c. */
#define EDOM 33
#define EDOM 33
#define ERANGE 34
#define ERANGE 34
#endif
#endif
 
 
/*
/*
 * The following variable is secretly shared with Tcl so we can
 * The following variable is secretly shared with Tcl so we can
 * tell if expression evaluation is in progress.  If not, matherr
 * tell if expression evaluation is in progress.  If not, matherr
 * just emulates the default behavior, which includes printing
 * just emulates the default behavior, which includes printing
 * a message.
 * a message.
 */
 */
 
 
extern int tcl_MathInProgress;
extern int tcl_MathInProgress;
 
 
/*
/*
 * The following definitions allow matherr to compile on systems
 * The following definitions allow matherr to compile on systems
 * that don't really support it.  The compiled procedure is bogus,
 * that don't really support it.  The compiled procedure is bogus,
 * but it will never be executed on these systems anyway.
 * but it will never be executed on these systems anyway.
 */
 */
 
 
#ifndef NEED_MATHERR
#ifndef NEED_MATHERR
struct exception {
struct exception {
    int type;
    int type;
};
};
#define DOMAIN 0
#define DOMAIN 0
#define SING 0
#define SING 0
#endif
#endif


/*
/*
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 *
 *
 * matherr --
 * matherr --
 *
 *
 *      This procedure is invoked on Sys-V systems when certain
 *      This procedure is invoked on Sys-V systems when certain
 *      errors occur in mathematical functions.  Type "man matherr"
 *      errors occur in mathematical functions.  Type "man matherr"
 *      for more information on how this function works.
 *      for more information on how this function works.
 *
 *
 * Results:
 * Results:
 *      Returns 1 to indicate that we've handled the error
 *      Returns 1 to indicate that we've handled the error
 *      locally.
 *      locally.
 *
 *
 * Side effects:
 * Side effects:
 *      Sets errno based on what's in xPtr.
 *      Sets errno based on what's in xPtr.
 *
 *
 *----------------------------------------------------------------------
 *----------------------------------------------------------------------
 */
 */
 
 
int
int
matherr(xPtr)
matherr(xPtr)
    struct exception *xPtr;     /* Describes error that occurred. */
    struct exception *xPtr;     /* Describes error that occurred. */
{
{
    if (!tcl_MathInProgress) {
    if (!tcl_MathInProgress) {
        return 0;
        return 0;
    }
    }
    if ((xPtr->type == DOMAIN) || (xPtr->type == SING)) {
    if ((xPtr->type == DOMAIN) || (xPtr->type == SING)) {
        errno = EDOM;
        errno = EDOM;
    } else {
    } else {
        errno = ERANGE;
        errno = ERANGE;
    }
    }
    return 1;
    return 1;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.