Use system copy of cbrt() if available.

Also move the replacement inline into miarc.c, since that's the only user.
This commit is contained in:
Adam Jackson 2007-05-09 21:49:44 -04:00
parent 8dcc37520d
commit 20c5250e48
5 changed files with 15 additions and 55 deletions

View File

@ -182,6 +182,7 @@ AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the `mmap' function.]))
dnl Find the math libary
AC_CHECK_LIB(m, sqrt)
AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])

View File

@ -102,6 +102,9 @@
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
/* Define to 1 if you have cbrt */
#undef HAVE_CBRT
/* Define to 1 if you have the <dbm.h> header file. */
#undef HAVE_DBM_H

View File

@ -9,7 +9,6 @@ endif
AM_CFLAGS = $(DIX_CFLAGS)
libmi_la_SOURCES = \
cbrt.c \
mi.h \
miarc.c \
mibank.c \

View File

@ -1,46 +0,0 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/* simple cbrt, in case your math library doesn't have a good one */
/*
* Would normally include <math.h> for this, but for the sake of compiler
* warnings, we don't want to get duplicate declarations for cbrt().
*/
double pow(double, double);
double cbrt(double);
double
cbrt(double x)
{
if (x > 0.0)
return pow(x, 1.0/3.0);
else
return -pow(-x, 1.0/3.0);
}

View File

@ -51,14 +51,7 @@ SOFTWARE.
#include <dix-config.h>
#endif
#if defined(_XOPEN_SOURCE) || defined(__QNXNTO__) \
|| (defined(sun) && defined(__SVR4))
#include <math.h>
#else
#define _XOPEN_SOURCE /* to get prototype for hypot on some systems */
#include <math.h>
#undef _XOPEN_SOURCE
#endif
#include <X11/X.h>
#include <X11/Xprotostr.h>
#include "misc.h"
@ -75,7 +68,17 @@ static double miDsin(double a);
static double miDcos(double a);
static double miDasin(double v);
static double miDatan2(double dy, double dx);
double cbrt(double);
#ifndef HAVE_CBRT
static double
cbrt(double x)
{
if (x > 0.0)
return pow(x, 1.0/3.0);
else
return -pow(-x, 1.0/3.0);
}
#endif
/*
* some interesting sematic interpretation of the protocol: