Restore EXP2 and LOG2 functions, by providing mathematical identify functions, when the underlying C functions are not available.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73911 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2007-07-08 21:01:28 +00:00
parent cf6ee48b5b
commit 935bd057f8
6 changed files with 2631 additions and 139 deletions

2348
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -375,8 +375,14 @@ if test "x${host_os}" = "xlinux-gnu" ; then
fi
# BSD might not have exp2, and/or log2
AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
AST_EXT_LIB_CHECK([LOG2], [m], [log2])
AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
AST_EXT_LIB_CHECK([LOG10], [m], [log10])
GSM_INTERNAL="yes"
AC_SUBST(GSM_INTERNAL)

View File

@@ -105,9 +105,27 @@
/* Define to 1 if you have the `endpwent' function. */
#undef HAVE_ENDPWENT
/* Define this to indicate the ${EXP10_DESCRIP} library */
#undef HAVE_EXP10
/* Define this to indicate the ${EXP10L_DESCRIP} library */
#undef HAVE_EXP10L
/* Define to indicate the ${EXP10L_DESCRIP} library version */
#undef HAVE_EXP10L_VERSION
/* Define to indicate the ${EXP10_DESCRIP} library version */
#undef HAVE_EXP10_VERSION
/* Define this to indicate the ${EXP2_DESCRIP} library */
#undef HAVE_EXP2
/* Define this to indicate the ${EXP2L_DESCRIP} library */
#undef HAVE_EXP2L
/* Define to indicate the ${EXP2L_DESCRIP} library version */
#undef HAVE_EXP2L_VERSION
/* Define to indicate the ${EXP2_DESCRIP} library version */
#undef HAVE_EXP2_VERSION
@@ -232,9 +250,27 @@
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define this to indicate the ${LOG10_DESCRIP} library */
#undef HAVE_LOG10
/* Define this to indicate the ${LOG10L_DESCRIP} library */
#undef HAVE_LOG10L
/* Define to indicate the ${LOG10L_DESCRIP} library version */
#undef HAVE_LOG10L_VERSION
/* Define to indicate the ${LOG10_DESCRIP} library version */
#undef HAVE_LOG10_VERSION
/* Define this to indicate the ${LOG2_DESCRIP} library */
#undef HAVE_LOG2
/* Define this to indicate the ${LOG2L_DESCRIP} library */
#undef HAVE_LOG2L
/* Define to indicate the ${LOG2L_DESCRIP} library version */
#undef HAVE_LOG2L_VERSION
/* Define to indicate the ${LOG2_DESCRIP} library version */
#undef HAVE_LOG2_VERSION
@@ -711,12 +747,12 @@
release 3. */
#undef SETVBUF_REVERSED
/* The size of a `int', as computed by sizeof. */
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
automatically deduced at run-time.
automatically deduced at runtime.
STACK_DIRECTION > 0 => grows toward higher addresses
STACK_DIRECTION < 0 => grows toward lower addresses
STACK_DIRECTION = 0 => direction of growth unknown */
@@ -731,6 +767,13 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
#undef TM_IN_SYS_TIME
/* Define to 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
@@ -745,6 +788,27 @@
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Enable extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
@@ -763,13 +827,13 @@
/* Define to `int' if <sys/types.h> does not define. */
#undef mode_t
/* Define to `long' if <sys/types.h> does not define. */
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> doesn't define. */

View File

@@ -1,7 +1,9 @@
/* A Bison parser, made by GNU Bison 2.1a. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
/* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,10 +20,18 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */
@@ -37,7 +47,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.1a"
#define YYBISON_VERSION "2.3"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -116,7 +126,7 @@
/* Copy the first part of user declarations. */
#line 1 "ast_expr2.y"
#line 1 "../main/ast_expr2.y"
/* Written by Pace Willisson (pace@blitz.com)
* and placed in the public domain.
@@ -160,14 +170,27 @@
#define FUNC_RINT rintl
#define FUNC_TRUNC truncl
#define FUNC_EXP expl
#ifdef HAVE_EXP2
#ifdef HAVE_EXP2L
#define FUNC_EXP2 exp2l
#else
#define FUNC_EXP2(x) expl((x) * logl(2))
#endif
#ifdef HAVE_EXP10L
#define FUNC_EXP10 exp10l
#else
#define FUNC_EXP10(x) expl((x) * logl(10))
#endif
#define FUNC_LOG logl
#ifdef HAVE_LOG2
#ifdef HAVE_LOG2L
#define FUNC_LOG2 log2l
#else
#define FUNC_LOG2(x) (logl(x) / logl(2))
#endif
#ifdef HAVE_LOG10L
#define FUNC_LOG10 log10l
#else
#define FUNC_LOG10(x) (logl(x) / logl(10))
#endif
#define FUNC_REMAINDER remainderl
#else
#define FP___PRINTF "%.16g"
@@ -191,12 +214,25 @@
#define FUNC_EXP exp
#ifdef HAVE_EXP2
#define FUNC_EXP2 exp2
#else
#define FUNC_EXP2(x) exp((x) * log(2))
#endif
#ifdef HAVE_EXP10
#define FUNC_EXP10 exp10
#else
#define FUNC_EXP10(x) exp((x) * log(10))
#endif
#define FUNC_LOG log
#ifdef HAVE_LOG2
#define FUNC_LOG2 log2
#else
#define FUNC_LOG2(x) (log(x) / log(2))
#endif
#ifdef HAVE_LOG10
#define FUNC_LOG10 log10
#else
#define FUNC_LOG10(x) (log(x) / log(10))
#endif
#define FUNC_REMAINDER remainder
#endif
@@ -363,13 +399,13 @@ int ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 226 "ast_expr2.y"
#line 260 "../main/ast_expr2.y"
{
struct val *val;
struct expr_node *arglist;
}
/* Line 198 of yacc.c. */
#line 365 "ast_expr2.c"
/* Line 187 of yacc.c. */
#line 409 "../main/ast_expr2.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -391,13 +427,13 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
#line 231 "ast_expr2.y"
#line 265 "../main/ast_expr2.y"
extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
/* Line 221 of yacc.c. */
#line 393 "ast_expr2.c"
/* Line 216 of yacc.c. */
#line 437 "../main/ast_expr2.c"
#ifdef short
# undef short
@@ -527,8 +563,13 @@ YYID (i)
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# ifdef __cplusplus
extern "C" {
# if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
@@ -544,9 +585,6 @@ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
# ifdef __cplusplus
}
# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
@@ -691,9 +729,9 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 257, 257, 265, 272, 273, 282, 288, 289, 293,
297, 301, 305, 309, 313, 317, 321, 325, 329, 333,
337, 341, 345, 349, 353, 357, 361
0, 291, 291, 299, 306, 307, 316, 322, 323, 327,
331, 335, 339, 343, 347, 351, 355, 359, 363, 367,
371, 375, 379, 383, 387, 391, 395
};
#endif
@@ -956,14 +994,14 @@ do { \
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep, const YYLTYPE * const yylocationp)
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
FILE *yyoutput;
int yytype;
const YYSTYPE * const yyvaluep;
const YYLTYPE * const yylocationp;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
#endif
{
if (!yyvaluep)
@@ -990,14 +1028,14 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep, const YYLTYPE * const yylocationp)
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
FILE *yyoutput;
int yytype;
const YYSTYPE * const yyvaluep;
const YYLTYPE * const yylocationp;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
#endif
{
if (yytype < YYNTOKENS)
@@ -1050,8 +1088,7 @@ static void
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
#else
static void
yy_reduce_print (yyvsp, yylsp, yyrule
)
yy_reduce_print (yyvsp, yylsp, yyrule)
YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyrule;
@@ -1174,7 +1211,7 @@ yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
size_t yyn = 0;
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
@@ -1221,7 +1258,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
{
int yyn = yypact[yystate];
if (! (YYPACT_NINF < yyn && yyn < YYLAST))
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 0;
else
{
@@ -1259,7 +1296,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn;
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1;
@@ -1347,114 +1384,114 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
switch (yytype)
{
case 4: /* "TOK_COLONCOLON" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1345 "ast_expr2.c"
#line 1390 "../main/ast_expr2.c"
break;
case 5: /* "TOK_COND" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1350 "ast_expr2.c"
#line 1395 "../main/ast_expr2.c"
break;
case 6: /* "TOK_OR" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1355 "ast_expr2.c"
#line 1400 "../main/ast_expr2.c"
break;
case 7: /* "TOK_AND" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1360 "ast_expr2.c"
#line 1405 "../main/ast_expr2.c"
break;
case 8: /* "TOK_NE" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1365 "ast_expr2.c"
#line 1410 "../main/ast_expr2.c"
break;
case 9: /* "TOK_LE" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1370 "ast_expr2.c"
#line 1415 "../main/ast_expr2.c"
break;
case 10: /* "TOK_GE" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1375 "ast_expr2.c"
#line 1420 "../main/ast_expr2.c"
break;
case 11: /* "TOK_LT" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1380 "ast_expr2.c"
#line 1425 "../main/ast_expr2.c"
break;
case 12: /* "TOK_GT" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1385 "ast_expr2.c"
#line 1430 "../main/ast_expr2.c"
break;
case 13: /* "TOK_EQ" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1390 "ast_expr2.c"
#line 1435 "../main/ast_expr2.c"
break;
case 14: /* "TOK_MINUS" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1395 "ast_expr2.c"
#line 1440 "../main/ast_expr2.c"
break;
case 15: /* "TOK_PLUS" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1400 "ast_expr2.c"
#line 1445 "../main/ast_expr2.c"
break;
case 16: /* "TOK_MOD" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1405 "ast_expr2.c"
#line 1450 "../main/ast_expr2.c"
break;
case 17: /* "TOK_DIV" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1410 "ast_expr2.c"
#line 1455 "../main/ast_expr2.c"
break;
case 18: /* "TOK_MULT" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1415 "ast_expr2.c"
#line 1460 "../main/ast_expr2.c"
break;
case 19: /* "TOK_COMPL" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1420 "ast_expr2.c"
#line 1465 "../main/ast_expr2.c"
break;
case 20: /* "TOK_EQTILDE" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1425 "ast_expr2.c"
#line 1470 "../main/ast_expr2.c"
break;
case 21: /* "TOK_COLON" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1430 "ast_expr2.c"
#line 1475 "../main/ast_expr2.c"
break;
case 22: /* "TOK_LP" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1435 "ast_expr2.c"
#line 1480 "../main/ast_expr2.c"
break;
case 23: /* "TOK_RP" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1440 "ast_expr2.c"
#line 1485 "../main/ast_expr2.c"
break;
case 24: /* "TOKEN" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1445 "ast_expr2.c"
#line 1490 "../main/ast_expr2.c"
break;
case 28: /* "expr" */
#line 251 "ast_expr2.y"
#line 285 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1450 "ast_expr2.c"
#line 1495 "../main/ast_expr2.c"
break;
default:
@@ -1777,7 +1814,7 @@ yyreduce:
switch (yyn)
{
case 2:
#line 257 "ast_expr2.y"
#line 291 "../main/ast_expr2.y"
{ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
@@ -1789,7 +1826,7 @@ yyreduce:
break;
case 3:
#line 265 "ast_expr2.y"
#line 299 "../main/ast_expr2.y"
{/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
((struct parse_io *)parseio)->val->type = AST_EXPR_string;
((struct parse_io *)parseio)->val->u.s = strdup("");
@@ -1797,12 +1834,12 @@ yyreduce:
break;
case 4:
#line 272 "ast_expr2.y"
#line 306 "../main/ast_expr2.y"
{ (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
break;
case 5:
#line 273 "ast_expr2.y"
#line 307 "../main/ast_expr2.y"
{struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
struct expr_node *t;
DESTROY((yyvsp[(2) - (3)].val));
@@ -1812,7 +1849,7 @@ yyreduce:
break;
case 6:
#line 282 "ast_expr2.y"
#line 316 "../main/ast_expr2.y"
{ (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
DESTROY((yyvsp[(2) - (4)].val));
DESTROY((yyvsp[(4) - (4)].val));
@@ -1822,12 +1859,12 @@ yyreduce:
break;
case 7:
#line 288 "ast_expr2.y"
#line 322 "../main/ast_expr2.y"
{(yyval.val) = (yyvsp[(1) - (1)].val);;}
break;
case 8:
#line 289 "ast_expr2.y"
#line 323 "../main/ast_expr2.y"
{ (yyval.val) = (yyvsp[(2) - (3)].val);
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;
@@ -1835,7 +1872,7 @@ yyreduce:
break;
case 9:
#line 293 "ast_expr2.y"
#line 327 "../main/ast_expr2.y"
{ (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1843,7 +1880,7 @@ yyreduce:
break;
case 10:
#line 297 "ast_expr2.y"
#line 331 "../main/ast_expr2.y"
{ (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1851,7 +1888,7 @@ yyreduce:
break;
case 11:
#line 301 "ast_expr2.y"
#line 335 "../main/ast_expr2.y"
{ (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1859,7 +1896,7 @@ yyreduce:
break;
case 12:
#line 305 "ast_expr2.y"
#line 339 "../main/ast_expr2.y"
{ (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1867,7 +1904,7 @@ yyreduce:
break;
case 13:
#line 309 "ast_expr2.y"
#line 343 "../main/ast_expr2.y"
{ (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1875,7 +1912,7 @@ yyreduce:
break;
case 14:
#line 313 "ast_expr2.y"
#line 347 "../main/ast_expr2.y"
{ (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1883,7 +1920,7 @@ yyreduce:
break;
case 15:
#line 317 "ast_expr2.y"
#line 351 "../main/ast_expr2.y"
{ (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1891,7 +1928,7 @@ yyreduce:
break;
case 16:
#line 321 "ast_expr2.y"
#line 355 "../main/ast_expr2.y"
{ (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1899,7 +1936,7 @@ yyreduce:
break;
case 17:
#line 325 "ast_expr2.y"
#line 359 "../main/ast_expr2.y"
{ (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1907,7 +1944,7 @@ yyreduce:
break;
case 18:
#line 329 "ast_expr2.y"
#line 363 "../main/ast_expr2.y"
{ (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1915,7 +1952,7 @@ yyreduce:
break;
case 19:
#line 333 "ast_expr2.y"
#line 367 "../main/ast_expr2.y"
{ (yyval.val) = op_negate ((yyvsp[(2) - (2)].val));
DESTROY((yyvsp[(1) - (2)].val));
(yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
@@ -1923,7 +1960,7 @@ yyreduce:
break;
case 20:
#line 337 "ast_expr2.y"
#line 371 "../main/ast_expr2.y"
{ (yyval.val) = op_compl ((yyvsp[(2) - (2)].val));
DESTROY((yyvsp[(1) - (2)].val));
(yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
@@ -1931,7 +1968,7 @@ yyreduce:
break;
case 21:
#line 341 "ast_expr2.y"
#line 375 "../main/ast_expr2.y"
{ (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1939,7 +1976,7 @@ yyreduce:
break;
case 22:
#line 345 "ast_expr2.y"
#line 379 "../main/ast_expr2.y"
{ (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1947,7 +1984,7 @@ yyreduce:
break;
case 23:
#line 349 "ast_expr2.y"
#line 383 "../main/ast_expr2.y"
{ (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1955,7 +1992,7 @@ yyreduce:
break;
case 24:
#line 353 "ast_expr2.y"
#line 387 "../main/ast_expr2.y"
{ (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1963,7 +2000,7 @@ yyreduce:
break;
case 25:
#line 357 "ast_expr2.y"
#line 391 "../main/ast_expr2.y"
{ (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1971,7 +2008,7 @@ yyreduce:
break;
case 26:
#line 361 "ast_expr2.y"
#line 395 "../main/ast_expr2.y"
{ (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val));
DESTROY((yyvsp[(2) - (5)].val));
DESTROY((yyvsp[(4) - (5)].val));
@@ -1980,8 +2017,8 @@ yyreduce:
break;
/* Line 1270 of yacc.c. */
#line 1977 "ast_expr2.c"
/* Line 1267 of yacc.c. */
#line 2022 "../main/ast_expr2.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2196,11 +2233,12 @@ yyreturn:
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return yyresult;
/* Make sure YYID is used. */
return YYID (yyresult);
}
#line 368 "ast_expr2.y"
#line 402 "../main/ast_expr2.y"
static struct expr_node *alloc_expr_node(enum node_type nt)
@@ -2639,7 +2677,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#ifdef HAVE_EXP2
} else if (strcmp(funcname->u.s,"EXP2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2649,7 +2686,15 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else if (strcmp(funcname->u.s,"EXP10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
result = make_number(FUNC_EXP10(arglist->val->u.i));
return result;
} else {
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
} else if (strcmp(funcname->u.s,"LOG") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2659,7 +2704,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#ifdef HAVE_LOG2
} else if (strcmp(funcname->u.s,"LOG2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2669,7 +2713,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else if (strcmp(funcname->u.s,"LOG10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);

View File

@@ -1,7 +1,9 @@
/* A Bison parser, made by GNU Bison 2.1a. */
/* A Bison parser, made by GNU Bison 2.3. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
/* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,10 +20,18 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, when this file is copied by Bison into a
Bison output file, you may use that output file without restriction.
This special exception was added by the Free Software Foundation
in version 1.24 of Bison. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -82,13 +92,13 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 226 "ast_expr2.y"
#line 260 "../main/ast_expr2.y"
{
struct val *val;
struct expr_node *arglist;
}
/* Line 1536 of yacc.c. */
#line 92 "ast_expr2.h"
/* Line 1489 of yacc.c. */
#line 102 "../main/ast_expr2.h"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -111,5 +121,3 @@ typedef struct YYLTYPE
#endif

View File

@@ -41,14 +41,27 @@
#define FUNC_RINT rintl
#define FUNC_TRUNC truncl
#define FUNC_EXP expl
#ifdef HAVE_EXP2
#ifdef HAVE_EXP2L
#define FUNC_EXP2 exp2l
#else
#define FUNC_EXP2(x) expl((x) * logl(2))
#endif
#ifdef HAVE_EXP10L
#define FUNC_EXP10 exp10l
#else
#define FUNC_EXP10(x) expl((x) * logl(10))
#endif
#define FUNC_LOG logl
#ifdef HAVE_LOG2
#ifdef HAVE_LOG2L
#define FUNC_LOG2 log2l
#else
#define FUNC_LOG2(x) (logl(x) / logl(2))
#endif
#ifdef HAVE_LOG10L
#define FUNC_LOG10 log10l
#else
#define FUNC_LOG10(x) (logl(x) / logl(10))
#endif
#define FUNC_REMAINDER remainderl
#else
#define FP___PRINTF "%.16g"
@@ -72,12 +85,25 @@
#define FUNC_EXP exp
#ifdef HAVE_EXP2
#define FUNC_EXP2 exp2
#else
#define FUNC_EXP2(x) exp((x) * log(2))
#endif
#ifdef HAVE_EXP10
#define FUNC_EXP10 exp10
#else
#define FUNC_EXP10(x) exp((x) * log(10))
#endif
#define FUNC_LOG log
#ifdef HAVE_LOG2
#define FUNC_LOG2 log2
#else
#define FUNC_LOG2(x) (log(x) / log(2))
#endif
#ifdef HAVE_LOG10
#define FUNC_LOG10 log10
#else
#define FUNC_LOG10(x) (log(x) / log(10))
#endif
#define FUNC_REMAINDER remainder
#endif
@@ -811,7 +837,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#ifdef HAVE_EXP2
} else if (strcmp(funcname->u.s,"EXP2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -821,7 +846,15 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else if (strcmp(funcname->u.s,"EXP10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
result = make_number(FUNC_EXP10(arglist->val->u.i));
return result;
} else {
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
} else if (strcmp(funcname->u.s,"LOG") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -831,7 +864,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#ifdef HAVE_LOG2
} else if (strcmp(funcname->u.s,"LOG2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -841,7 +873,6 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else if (strcmp(funcname->u.s,"LOG10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);