2009-12-26 14:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/Makefile
  * harbour/include/hbmath.h
  + harbour/include/hbmather.h
  * harbour/include/hbsetup.h
  * harbour/include/hbapi.h
    * moved math error handler definitions and settings separate header file
    * moved hb_random_num() declaration from hbmath.h to hbapi.h

    After above modification hbmath file should be use only by code which
    wants to use math functions declared usually in math.h

  + harbour/include/hbfloat.h
    + added header file with test macros for floating point numbers
      this file should be included before any other files

  * harbour/src/vm/hvmall.c
  * harbour/src/vm/itemapi.c
  * harbour/src/common/hbprintf.c
  * harbour/src/rtl/math.c
    * use new macros from hbfloat.h

  * harbour/src/rtl/math.c
    + include "hbmather.h"

  * harbour/src/rtl/hbrandom.c
  * harbour/src/rdd/dbf1.c
  * harbour/contrib/xhb/hboutdbg.c
    - removed not longer necessary include "hbmath.h"

  * harbour/contrib/hbct/ctmath.h
    - do not include <float.h> and <limits.h>

  * harbour/contrib/hbct/ct.h
    - do not include "hbmath.h" and "ctmath.h"

  * harbour/contrib/hbct/ctmath.c
  * harbour/contrib/hbct/exponent.c
  * harbour/contrib/hbct/ctc.c
    + include "ctmath.h"

  * harbour/contrib/hbct/trig.c
  * harbour/contrib/hbct/finan.c
  * harbour/contrib/hbct/ctmath2.c
    + include "ctmath.h"
    + include "hbmather.h"

  * harbour/contrib/hbct/num1.c
    + include "ctmath.h"
    + include <float.h>

  * harbour/include/hbinit.h
  * harbour/src/rtl/hbsocket.c
    * added patches from Tamas - thanks

  * harbour/bin/hb-func.sh
  * harbour/harbour.spec
    + create /etc/ld.so.conf.d/harbour.conf with Harbour shared lib directory
      if /etc/ld.so.conf.d directory exists and user has sufficient write
      permission or install package is created.
      This modification allows to install Harbour anywhere and in modern
      distros using /etc/ld.so.conf.d/ harbour shared libraries will be
      always available for all programs

   [TOMERGE 2.0]
This commit is contained in:
Przemyslaw Czerpak
2009-12-26 13:13:02 +00:00
parent 2e7a94a814
commit 6b2f6bd054
27 changed files with 546 additions and 320 deletions

View File

@@ -17,6 +17,72 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-26 14:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/Makefile
* harbour/include/hbmath.h
+ harbour/include/hbmather.h
* harbour/include/hbsetup.h
* harbour/include/hbapi.h
* moved math error handler definitions and settings separate header file
* moved hb_random_num() declaration from hbmath.h to hbapi.h
After above modification hbmath file should be use only by code which
wants to use math functions declared usually in math.h
+ harbour/include/hbfloat.h
+ added header file with test macros for floating point numbers
this file should be included before any other files
* harbour/src/vm/hvmall.c
* harbour/src/vm/itemapi.c
* harbour/src/common/hbprintf.c
* harbour/src/rtl/math.c
* use new macros from hbfloat.h
* harbour/src/rtl/math.c
+ include "hbmather.h"
* harbour/src/rtl/hbrandom.c
* harbour/src/rdd/dbf1.c
* harbour/contrib/xhb/hboutdbg.c
- removed not longer necessary include "hbmath.h"
* harbour/contrib/hbct/ctmath.h
- do not include <float.h> and <limits.h>
* harbour/contrib/hbct/ct.h
- do not include "hbmath.h" and "ctmath.h"
* harbour/contrib/hbct/ctmath.c
* harbour/contrib/hbct/exponent.c
* harbour/contrib/hbct/ctc.c
+ include "ctmath.h"
* harbour/contrib/hbct/trig.c
* harbour/contrib/hbct/finan.c
* harbour/contrib/hbct/ctmath2.c
+ include "ctmath.h"
+ include "hbmather.h"
* harbour/contrib/hbct/num1.c
+ include "ctmath.h"
+ include <float.h>
* harbour/include/hbinit.h
* harbour/src/rtl/hbsocket.c
* added patches from Tamas - thanks
* harbour/bin/hb-func.sh
* harbour/harbour.spec
+ create /etc/ld.so.conf.d/harbour.conf with Harbour shared lib directory
if /etc/ld.so.conf.d directory exists and user has sufficient write
permission or install package is created.
This modification allows to install Harbour anywhere and in modern
distros using /etc/ld.so.conf.d/ harbour shared libraries will be
always available for all programs
[TOMERGE 2.0]
2009-12-26 12:17 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* INSTALL
+ Added note that at least QT 4.5.0 is required for Harbour.

View File

@@ -789,7 +789,7 @@ EOF
mk_hblibso()
{
local LIBS LIBSMT l lm ll dir hb_rootdir hb_ver hb_libs full_lib_name full_lib_name_mt linker_options linker_mtoptions gpm lib_ext lib_pref lib_suff
local LIBS LIBSMT l lm ll ld dir hb_rootdir hb_ver hb_libs full_lib_name full_lib_name_mt linker_options linker_mtoptions gpm lib_ext lib_pref lib_suff
dir=`pwd`
name=`get_solibname`
@@ -874,10 +874,10 @@ mk_hblibso()
elif [ "${l}" = gtsln ]; then
linker_options="$linker_options -lslang"
elif [ "${l}" = gtxwc ]; then
[ -d "/usr/X11R6/lib" ] && \
linker_options="$linker_options -L/usr/X11R6/lib"
[ -d "/usr/X11R6/lib64" ] && \
linker_options="$linker_options -L/usr/X11R6/lib64"
[ -d "/usr/X11R6/lib" ] && \
linker_options="$linker_options -L/usr/X11R6/lib"
linker_options="$linker_options -lX11"
fi
if [ -n "${gpm}" ] && ( [ "${l}" = gtcrs ] || \
@@ -937,14 +937,24 @@ mk_hblibso()
ln -sf ${name}/$l ../$ll
ln -sf ${name}/$l ../$l
;;
/usr/local/${name})
mkdir -p ../../lib
ln -sf ../${name}/lib/$l ../../lib/$ll
ln -sf ../${name}/lib/$l ../../lib/$l
/usr/local/${name}/lib)
ld="/usr/lib"
if [ -n "${HB_INST_PKGPREF}" ] || [ -w $ld ]
then
mkdir -p ${HB_INST_PKGPREF}$ld
ln -sf ../local/${name}/lib/$l ${HB_INST_PKGPREF}$ld/$ll
ln -sf ../local/${name}/lib/$l ${HB_INST_PKGPREF}$ld/$l
fi
;;
*)
;;
esac
ld="/etc/ld.so.conf.d"
if [ -d $ld ] && ( [ -n "${HB_INST_PKGPREF}" ] || [ -w $ld ] )
then
mkdir -p ${HB_INST_PKGPREF}$ld
echo "$HB_LIB_INSTALL" > ${HB_INST_PKGPREF}/$ld/${name}.conf
fi
fi
fi
done

View File

@@ -61,10 +61,8 @@
#include "hbapicdp.h"
#include "hbapierr.h"
#include "error.ch"
#include "hbmath.h"
#include "ctstr.h"
#include "ctmath.h"
#include "ctset.h"
#include "cterror.ch"

View File

@@ -54,6 +54,7 @@
#include "ct.h"
#include "ctmath.h"
#include "hbvm.h"
#include "hbstack.h"

View File

@@ -53,6 +53,7 @@
*/
#include "ct.h"
#include "ctmath.h"
/* ---------------- */
/* initialization */

View File

@@ -55,11 +55,13 @@
#define _CTMATH_H
#include "hbmath.h"
#include <float.h>
#include <limits.h>
HB_EXTERN_BEGIN
#define CT_PI 3.14159265358979323846
#define CT_PI_2 1.57079632679489661923
#define CT_PI_RAD 0.0174532925199432957692 /* 3.14159265358979323846 / 180.0 */
/* initialization */
extern int ct_math_init( void );
extern int ct_math_exit( void );
@@ -68,10 +70,6 @@ extern int ct_math_exit( void );
extern void ct_setprecision( int iPrecision );
extern int ct_getprecision( void );
#define CT_PI 3.14159265358979323846
#define CT_PI_2 1.57079632679489661923
#define CT_PI_RAD 0.0174532925199432957692 /* 3.14159265358979323846 / 180.0 */
HB_EXTERN_END
#endif /* CTMATH_H */

View File

@@ -64,6 +64,8 @@
#include "ct.h"
#include "ctmath.h"
#include "hbmather.h"
/* $DOC$

View File

@@ -52,6 +52,7 @@
*/
#include "ct.h"
#include "ctmath.h"
/* undefine the following if you want to evaluate the mantissa and exponent from the doubles' bit representation */
/* #define CT_EXPONENT_MANTISSA_BIT 1 */

View File

@@ -63,6 +63,8 @@
#include "ct.h"
#include "ctmath.h"
#include "hbmather.h"
/* $DOC$

View File

@@ -63,7 +63,8 @@
#include "ct.h"
#include "ctmath.h"
#include <float.h>
/* $DOC$
* $FUNCNAME$

View File

@@ -71,6 +71,8 @@
*/
#include "ct.h"
#include "ctmath.h"
#include "hbmather.h"
/* $DOC$

View File

@@ -64,8 +64,6 @@
#if defined( HB_OS_UNIX )
#include "hbmath.h"
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>

View File

@@ -43,31 +43,32 @@
%endif
%endif
%define hb_ldconf %([ -d /etc/ld.so.conf.d ] && echo /etc/ld.so.conf.d)
%define name harbour
%define dname Harbour
%define version 2.0.1
%define releasen dev
%define hb_pref hb
%define name harbour
%define dname Harbour
%define version 2.0.1
%define releasen dev
%define hb_pref hb
%define hb_etcdir /etc/%{name}
%define hb_plat export HB_PLATFORM=linux
%define hb_cc export HB_COMPILER=gcc
%define hb_cflag export HB_USER_CFLAGS=
%define hb_lflag export HB_USER_LDFLAGS="${CC_HB_USER_LDFLAGS} %{?_with_static:-static}"
%define hb_gpm export HB_WITH_GPM=%{!?_without_gpm:yes}%{?_without_gpm:no}
%define hb_crs export HB_WITH_CURSES=%{!?_without_curses:yes}%{?_without_curses:no}
%define hb_sln export HB_WITH_SLANG=%{!?_without_slang:yes}%{?_without_slang:no}
%define hb_x11 export HB_WITH_X11=%{!?_without_x11:yes}%{?_without_x11:no}
%define hb_local export HB_WITH_ZLIB=%{?_with_localzlib:local} ; export HB_WITH_PCRE=%{?_with_localpcre:local}
%define hb_bdir export HB_BIN_INSTALL=%{_bindir}
%define hb_idir export HB_INC_INSTALL=%{_includedir}/%{name}
%define hb_ldir export HB_LIB_INSTALL=%{_libdir}/%{name}
%define hb_edir export HB_ETC_INSTALL=%{hb_etcdir}
%define hb_cmrc export HB_BUILD_NOGPLLIB=%{?_without_gpllib:yes}
%define hb_ctrb export HB_CONTRIBLIBS="hbbmcdx hbbtree hbclipsm hbct hbgt hbmisc hbmzip hbnetio hbtip hbtpathy hbhpdf hbsms hbziparc xhb rddsql hbnf %{?_with_odbc:hbodbc} %{?_with_curl:hbcurl} %{?_with_ads:rddads} %{?_with_gd:hbgd} %{?_with_pgsql:hbpgsql} %{?_with_mysql:hbmysql} %{?_with_firebird:hbfbird} %{?_with_allegro:gtalleg} %{?_with_qt:hbqt hbxbp}"
%define hb_env %{hb_plat} ; %{hb_cc} ; %{hb_cflag} ; %{hb_lflag} ; %{hb_gpm} ; %{hb_crs} ; %{hb_sln} ; %{hb_x11} ; %{hb_local} ; %{hb_bdir} ; %{hb_idir} ; %{hb_ldir} ; %{hb_edir} ; %{hb_ctrb} ; %{hb_cmrc}
%define hb_host www.harbour-project.org
%define readme README.RPM
%define hb_plat export HB_PLATFORM=linux
%define hb_cc export HB_COMPILER=gcc
%define hb_cflag export HB_USER_CFLAGS=
%define hb_lflag export HB_USER_LDFLAGS="${CC_HB_USER_LDFLAGS} %{?_with_static:-static}"
%define hb_gpm export HB_WITH_GPM=%{!?_without_gpm:yes}%{?_without_gpm:no}
%define hb_crs export HB_WITH_CURSES=%{!?_without_curses:yes}%{?_without_curses:no}
%define hb_sln export HB_WITH_SLANG=%{!?_without_slang:yes}%{?_without_slang:no}
%define hb_x11 export HB_WITH_X11=%{!?_without_x11:yes}%{?_without_x11:no}
%define hb_local export HB_WITH_ZLIB=%{?_with_localzlib:local} ; export HB_WITH_PCRE=%{?_with_localpcre:local}
%define hb_bdir export HB_BIN_INSTALL=%{_bindir}
%define hb_idir export HB_INC_INSTALL=%{_includedir}/%{name}
%define hb_ldir export HB_LIB_INSTALL=%{_libdir}/%{name}
%define hb_edir export HB_ETC_INSTALL=%{hb_etcdir}
%define hb_cmrc export HB_BUILD_NOGPLLIB=%{?_without_gpllib:yes}
%define hb_ctrb export HB_CONTRIBLIBS="hbbmcdx hbbtree hbclipsm hbct hbgt hbmisc hbmzip hbnetio hbtip hbtpathy hbhpdf hbsms hbziparc xhb rddsql hbnf %{?_with_odbc:hbodbc} %{?_with_curl:hbcurl} %{?_with_ads:rddads} %{?_with_gd:hbgd} %{?_with_pgsql:hbpgsql} %{?_with_mysql:hbmysql} %{?_with_firebird:hbfbird} %{?_with_allegro:gtalleg} %{?_with_qt:hbqt hbxbp}"
%define hb_env %{hb_plat} ; %{hb_cc} ; %{hb_cflag} ; %{hb_lflag} ; %{hb_gpm} ; %{hb_crs} ; %{hb_sln} ; %{hb_x11} ; %{hb_local} ; %{hb_bdir} ; %{hb_idir} ; %{hb_ldir} ; %{hb_edir} ; %{hb_ctrb} ; %{hb_cmrc}
%define hb_host www.harbour-project.org
%define readme README.RPM
######################################################################
## Preamble.
######################################################################
@@ -616,6 +617,7 @@ rm -rf $RPM_BUILD_ROOT
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*.so
%{_libdir}/*.so
%{?hb_ldconf:%{hb_ldconf}/%{name}.conf}
%{?_with_curl:%files curl}
%{?_with_curl:%defattr(644,root,root,755)}

View File

@@ -21,6 +21,7 @@ C_HEADERS := \
hbassert.h \
hbatomic.h \
hbbfish.h \
hbfloat.h \
hbcdpreg.h \
hbchksum.h \
hbcomp.h \
@@ -39,6 +40,7 @@ C_HEADERS := \
hbinit.h \
hbmacro.h \
hbmath.h \
hbmather.h \
hbmsgreg.h \
hbpcode.h \
hbpp.h \

View File

@@ -966,6 +966,7 @@ extern HB_EXPORT char * hb_strRemEscSeq( char * szText, ULONG * ulLen ); /* r
extern HB_EXPORT char * hb_numToStr( char * szBuf, ULONG ulSize, HB_LONG lNumber );
extern HB_EXPORT double hb_numRound( double dResult, int iDec ); /* round a number to a specific number of digits */
extern HB_EXPORT double hb_numInt( double dNum ); /* take the integer part of the number */
extern HB_EXPORT double hb_random_num( void );
extern HB_EXPORT double hb_numDecConv( double dNum, int iDec );
extern HB_EXPORT void hb_strtohex( const char * pSource, ULONG size, char * pDest );

233
harbour/include/hbfloat.h Normal file
View File

@@ -0,0 +1,233 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour floating point math macros
*
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#ifndef HB_FLOAT_H_
#define HB_FLOAT_H_
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#ifndef __EXTENSIONS__
# define __EXTENSIONS__
#endif
/* workaround for some missing C99 math macros in SunOS GCC
* used in C++ mode
*/
#if !defined( __C99FEATURES__ ) && defined( __GNUC__ ) && defined( __sun__ )
# define __C99FEATURES__
#endif
#include "hbapi.h"
#if defined( __DJGPP__ )
# include <libm/math.h>
/* _LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_; */
#else
# include <math.h>
# if defined( __BORLANDC__ ) || defined( __WATCOMC__ ) || defined( _MSC_VER )
# include <float.h>
# elif defined( HB_OS_SUNOS )
# include <ieeefp.h> /* for finite() */
# endif
#endif
#if defined( HB_LONG_DOUBLE_OFF ) && !defined( __NO_LONGDOUBLE__ )
# define __NO_LONGDOUBLE__
#endif
#define _HB_NUM_NAN 1
#define _HB_NUM_PINF 2
#define _HB_NUM_NINF 4
#if defined( __BORLANDC__ ) && 0
/* do not use Borland C _fpclass[l]() function.
* it switches internal logic used for floating point calculation
* in this compiler reducing the precision to 'float' type.
*/
# ifdef __NO_LONGDOUBLE__
# define hb_fpclassify( d ) _fpclass( d )
# else
# define hb_fpclassify( d ) ( sizeof( d ) == sizeof( double ) ? \
_fpclass( d ) : _fpclassl( d ) )
# endif
#endif
/* on some platforms signbit() needs _GNU_SOURCE defined.
* If it's not available on given platform then it can be replaced by
* 'value < 0' but in such case -0.0 will be shown as 0.0
*/
#if defined( _ISOC99_SOURCE ) || defined( _STDC_C99 ) || defined( signbit )
# define hb_signbit( d ) signbit( d )
#elif defined( __BORLANDC__ ) && defined( hb_fpclassify )
# define hb_signbit( d ) ( ( hb_fpclassify( d ) & ( _FPCLASS_NINF | _FPCLASS_NZ ) ) != 0 )
#elif 0 /* TODO: add other C compilers here (check their version number) */
#else
# define hb_signbit( d ) ( d < 0 )
#endif
#if defined( _ISOC99_SOURCE ) || defined( _STDC_C99 ) || \
( defined( isfinite ) && defined( isnan ) && defined( isinf ) )
/* use C99 macros */
# define hb_isfinite( d ) isfinite( d )
# define HB_NUMTYPE( v, d ) do { \
v = ( isfinite( d ) ? 0 : \
( isnan( d ) ? _HB_NUM_NAN : \
( isinf( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
#elif ( defined( __GNUC__ ) || \
defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) ) && \
( defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) || \
defined( _XOPEN_SOURCE ) )
/* use BSD floating point functions */
# define hb_isfinite( d ) finite( d )
# define HB_NUMTYPE( v, d ) do { \
v = ( finite( d ) ? 0 : \
( isnan( d ) ? _HB_NUM_NAN : \
( isinf( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
# if !defined( __NO_LONGDOUBLE__ ) && !defined( HB_OS_SUNOS )
# define HB_NUMTYPEL( v, d ) do { \
v = ( finitel( d ) ? 0 : \
( isnanl( d ) ? _HB_NUM_NAN : \
( isinfl( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
# endif
#elif defined( __BORLANDC__ )
# define hb_isfinite( d ) _finite( d )
# if defined( hb_fpclassify )
# define HB_NUMTYPE( v, d ) do { \
int t = hb_fpclassify( d ); \
v = ( ( t & ( _FPCLASS_UNSUP | _FPCLASS_SNAN | _FPCLASS_QNAN ) ) ? _HB_NUM_NAN : \
( ( t & _FPCLASS_NINF ) ? _HB_NUM_NINF : \
( ( t & _FPCLASS_PINF ) ? _HB_NUM_PINF : 0 ) ) ); \
} while( 0 )
# else
# define HB_NUMTYPE( v, d ) do { \
v = ( _finite( d ) ? 0 : \
( _isnan( d ) ? _HB_NUM_NAN : \
_HB_NUM_PINF ) ); \
} while( 0 )
# if !defined( __NO_LONGDOUBLE__ )
# define HB_NUMTYPEL( v, d ) do { \
v = ( _finitel( d ) ? 0 : \
( _isnanl( d ) ? _HB_NUM_NAN : \
_HB_NUM_PINF ) ); \
} while( 0 )
# endif
# endif
#elif 0 /* TODO: add other C compilers here (check their version number) */
#else
# if defined( __RSXNT__ ) || defined( __EMX__ ) || \
defined( __XCC__ ) || defined( __POCC__ ) || \
defined( __MINGW32__ ) || defined( HB_OS_HPUX )
# define hb_isfinite( d ) isfinite( d )
# elif defined( _MSC_VER )
# define hb_isfinite( d ) _finite( ( double ) d )
# elif defined( __BORLANDC__ ) || defined( __WATCOMC__ )
# define hb_isfinite( d ) _finite( d )
# elif defined( __GNUC__ ) || defined( __DJGPP__ ) || defined( __LCC__ ) || \
defined( HB_OS_SUNOS )
# define hb_isfinite( d ) finite( d )
# endif
# if defined( hb_isfinite )
# define HB_NUMTYPE( v, d ) do { \
v = hb_isfinite( d ) ? 0 : _HB_NUM_NAN ; \
} while( 0 )
# else
# define hb_isfinite( d ) TRUE
# define HB_NUMTYPE( v, d ) do { \
int iTODO; \
v = hb_isfinite( d ) ? 0 : _HB_NUM_NAN ; \
} while( 0 )
# endif
#endif
#if !defined( HB_NUMTYPEL )
# define HB_NUMTYPEL( v, d ) HB_NUMTYPE( v, d )
#endif
/* NOTE: Workaround for Pellec C 5.00 not having an 'inf' (HUGE_VAL)
in '-Tarm-coff' mode. [vszakats] */
#if defined( __POCC__ ) && defined( HB_OS_WIN_CE )
#undef HUGE_VAL
#define HUGE_VAL ( 1.0 / ( 1.0, 0.0 ) )
#endif
#endif /* HB_FLOAT_H_ */

View File

@@ -121,6 +121,12 @@ extern HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbo
#error Wrong macros set for startup code - clean your make/env settings.
#endif
#if defined( _M_COFF )
#define HB_STARTUP_INITSEGMENT ".init, \"x\""
#else
#define HB_STARTUP_INITSEGMENT ".init"
#endif
#define HB_INIT_SYMBOLS_BEGIN( func ) \
static HB_SYMB symbols_table[] = {
@@ -140,9 +146,13 @@ extern HB_EXPORT PHB_SYMB hb_vmProcessSymbols( PHB_SYMB pSymbols, USHORT uiSymbo
} \
HB_INIT_FUNCTION_REF( func ) \
HB_EXTERN_END \
asm ( ".section .init\n\tcall " HB_MACRO2STRING( func ) "\n\t.section .text\n\t" );
asm ( ".section " HB_STARTUP_INITSEGMENT \
"\n\tcall " HB_MACRO2STRING( func ) \
"\n\t.section .text\n\t" );
/* TODO: if possible use other way without public symbols to mark function
* as used so it's not removed by C compiler optimization logic
*/
#define HB_INIT_FUNCTION_REF( func ) \
extern void * func##_ref_( void ); \
void * func##_ref_( void ) \

View File

@@ -54,89 +54,17 @@
#ifndef HB_MATH_H_
#define HB_MATH_H_
#include "hbapi.h"
#if defined( __DJGPP__ )
#include <libm/math.h>
#else
#include <math.h>
#endif
HB_EXTERN_BEGIN
#if defined( __WATCOMC__ )
#define HB_MATH_HANDLER
#if ( __WATCOMC__ > 1000 ) /* && defined( __cplusplus ) */
#define exception _exception
#endif
#elif defined( __BORLANDC__ )
#if ( __BORLANDC__ == 1328 ) && defined( __cplusplus )
/* NOTE: There seem to be a bug in Borland C++ 5.3 C++ mode which prevents
the redefinition of matherr, because nor "_exception" neither
"exception" will work. [vszakats] */
#else
#define HB_MATH_HANDLER
#define matherr _matherr
/* NOTE: This is needed for Borland C++ 5.5 in C++/STDC mode. [vszakats] */
#if ( __BORLANDC__ >= 1360 )
#define exception _exception
#endif
#endif
#elif defined( __MINGW32CE__ )
#define HB_MATH_HANDLER
#define matherr _matherr
#define exception _exception
/* it seems that MinGW has some problem with MATH HANDLER
use HB_MATH_ERRNO instead */
#elif defined( __MINGW32__ ) && 0
#define HB_MATH_HANDLER
#define matherr _matherr
#define exception _exception
#elif defined( __DJGPP__ )
#if !defined( __cplusplus )
#define HB_MATH_HANDLER
#endif
#elif defined( HB_OS_WIN_CE ) && defined( __POCC__ )
/* NOTE: Workaround for Pellec C 5.00 not having an 'inf' (HUGE_VAL)
in '-Tarm-coff' mode. [vszakats] */
/* NOTE: Workaround for Pellec C 5.00 not having an 'inf' (HUGE_VAL)
in '-Tarm-coff' mode. [vszakats] */
#if defined( __POCC__ ) && defined( HB_OS_WIN_CE )
#undef HUGE_VAL
#define HUGE_VAL ( 1.0 / ( 1.0, 0.0 ) )
#endif
#if !defined( HB_MATH_HANDLER ) && \
( defined( __GNUC__ ) || defined( HB_OS_UNIX ) )
#define HB_MATH_ERRNO
#endif
typedef struct _HB_MATH_EXCEPTION
{
int type;
const char * funcname;
const char * error;
double arg1;
double arg2;
double retval;
int retvalwidth;
int retvaldec;
int handled;
} HB_MATH_EXCEPTION;
typedef int ( * HB_MATH_HANDLERPROC )( HB_MATH_EXCEPTION * err );
extern HB_EXPORT void hb_mathResetError( HB_MATH_EXCEPTION * phb_exc );
extern HB_EXPORT BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc, double arg1, double arg2, double dResult );
extern HB_EXPORT int hb_mathSetErrMode( int imode );
extern HB_EXPORT int hb_mathGetErrMode( void );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathGetHandler( void );
extern HB_EXPORT double hb_random_num( void );
/* include defines from hbmath.ch */
#include "hbmath.ch"
HB_EXTERN_END
#endif /* HB_MATH_H_ */

129
harbour/include/hbmather.h Normal file
View File

@@ -0,0 +1,129 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour math functions and API
*
* Copyright 2001 IntTec GmbH, Neunlindenstr 32, 79106 Freiburg, Germany
* Author: Martin Vogel <vogel@inttec.de>
* www - http://www.harbour-project.org
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#ifndef HB_MATHER_H_
#define HB_MATHER_H_
#include "hbmath.h"
HB_EXTERN_BEGIN
#if defined( __WATCOMC__ )
#define HB_MATH_HANDLER
#if ( __WATCOMC__ > 1000 ) /* && defined( __cplusplus ) */
#define exception _exception
#endif
#elif defined( __BORLANDC__ )
#if ( __BORLANDC__ == 1328 ) && defined( __cplusplus )
/* NOTE: There seem to be a bug in Borland C++ 5.3 C++ mode which prevents
the redefinition of matherr, because nor "_exception" neither
"exception" will work. [vszakats] */
#else
#define HB_MATH_HANDLER
#define matherr _matherr
/* NOTE: This is needed for Borland C++ 5.5 in C++/STDC mode. [vszakats] */
#if ( __BORLANDC__ >= 1360 )
#define exception _exception
#endif
#endif
#elif defined( __MINGW32CE__ )
#define HB_MATH_HANDLER
#define matherr _matherr
#define exception _exception
/* it seems that MinGW has some problem with MATH HANDLER
use HB_MATH_ERRNO instead */
#elif defined( __MINGW32__ ) && 0
#define HB_MATH_HANDLER
#define matherr _matherr
#define exception _exception
#elif defined( __DJGPP__ )
#if !defined( __cplusplus )
#define HB_MATH_HANDLER
#endif
#endif
#if !defined( HB_MATH_HANDLER ) && \
( defined( __GNUC__ ) || defined( HB_OS_UNIX ) )
#define HB_MATH_ERRNO
#endif
typedef struct _HB_MATH_EXCEPTION
{
int type;
const char * funcname;
const char * error;
double arg1;
double arg2;
double retval;
int retvalwidth;
int retvaldec;
int handled;
} HB_MATH_EXCEPTION;
typedef int ( * HB_MATH_HANDLERPROC )( HB_MATH_EXCEPTION * err );
extern HB_EXPORT void hb_mathResetError( HB_MATH_EXCEPTION * phb_exc );
extern HB_EXPORT BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc, double arg1, double arg2, double dResult );
extern HB_EXPORT int hb_mathSetErrMode( int imode );
extern HB_EXPORT int hb_mathGetErrMode( void );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc );
extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathGetHandler( void );
/* include defines from hbmath.ch */
#include "hbmath.ch"
HB_EXTERN_END
#endif /* HB_MATHER_H_ */

View File

@@ -469,7 +469,7 @@
/* ***********************************************************************
* See also the following files for task specific definitions/settings
*
* hbmath.h - math errors handling
* hbmather.h - math errors handling
*/
/* ***********************************************************************

View File

@@ -86,41 +86,17 @@ allocations or stack size is not a problem then some parts can be easy
optimized.
*/
/* #define __NO_DOUBLE__ */
/* #define __NO_LONGDOUBLE__ */
/* #define __NO_LONGLONG__ */
/* #define __NO_ARGPOS__ */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#ifndef __EXTENSIONS__
# define __EXTENSIONS__
#endif
/* workaround for some missing C99 math macros in SunOS GCC
* used in C++ mode
*/
#if !defined( __C99FEATURES__ ) && defined( __GNUC__ ) && defined( __sun__ )
# define __C99FEATURES__
#endif
/* hbfloat.h have to be included first */
#include "hbfloat.h"
#include <stddef.h>
#include "hbapi.h"
#include "hbmath.h"
#if ! defined( HB_USE_CRTL_SNPRINTF )
#if defined( __BORLANDC__ ) || defined( __WATCOMC__ ) || defined( _MSC_VER )
# include <float.h>
#elif defined( __DJGPP__ )
/* _LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_; */
#elif defined( HB_OS_SUNOS )
# include <ieeefp.h> /* for finite() */
#endif
#if defined( HB_LONG_DOUBLE_OFF ) && !defined( __NO_LONGDOUBLE__ )
# define __NO_LONGDOUBLE__
#endif
@@ -129,32 +105,11 @@ optimized.
# define __NO_LONGLONG__
#endif
#ifndef va_copy
# ifdef __va_copy
# define va_copy( dst, src ) __va_copy( dst, src )
# else
# define va_copy( dst, src ) ( (dst) = (src) )
# endif
#endif
#if ! defined( HB_USE_CRTL_SNPRINTF )
/* few macros for some platform dependent floating point functions/macros */
#define _HB_NUM_NAN 1
#define _HB_NUM_PINF 2
#define _HB_NUM_NINF 4
#if defined( __BORLANDC__ ) && 0
/* do not use Borland C _fpclass[l]() function.
* it switches internal logic used for floating point calculation
* in this compiler reducing the precision to 'float' type.
*/
# ifdef __NO_LONGDOUBLE__
# define hb_fpclassify( d ) _fpclass( d )
# else
# define hb_fpclassify( d ) _fpclassl( d )
# endif
#endif
#if ( defined( __BORLANDC__ ) && __BORLANDC__ < 1410 ) || \
( defined( __WATCOMC__ ) && __WATCOMC__ < 1270 ) || \
( defined( __DJGPP__ ) && \
@@ -170,89 +125,13 @@ optimized.
# define uintmax_t _x_ulonglong
#endif
/* signbit() needs _GNU_SOURCE defined. If it's not available on given
* platform then it can be replaced by 'value < 0' but in such case
* -0.0 will be shown as 0.0
*/
#if defined( _ISOC99_SOURCE ) || defined( _STDC_C99 )
/* use C99 macros */
# define hb_signbit( d ) signbit( d )
#elif defined( __BORLANDC__ ) && defined( hb_fpclassify )
# define hb_signbit( d ) ( ( hb_fpclassify( d ) & ( _FPCLASS_NINF | _FPCLASS_NZ ) ) != 0 )
#elif 0 /* TODO: add other C compilers here (check their version number) */
#else
# define hb_signbit( d ) ( d < 0 )
#endif
#if defined( _ISOC99_SOURCE ) || defined( _STDC_C99 ) || defined( __MINGW32__ )
/* use C99 macros */
# define HB_NUMTYPE( v, d ) do { \
v = ( isfinite( d ) ? 0 : \
( isnan( d ) ? _HB_NUM_NAN : \
( isinf( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
#elif ( defined( __GNUC__ ) || \
defined( __SUNPRO_C ) || defined( __SUNPRO_CC ) ) && \
( defined( _BSD_SOURCE ) || defined( _SVID_SOURCE ) || \
defined( _XOPEN_SOURCE ) )
/* use BSD floating point functions */
# if defined( __NO_LONGDOUBLE__ ) || defined( HB_OS_SUNOS )
# define HB_NUMTYPE( v, d ) do { \
v = ( finite( d ) ? 0 : \
( isnan( d ) ? _HB_NUM_NAN : \
( isinf( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
#ifndef va_copy
# ifdef __va_copy
# define va_copy( dst, src ) __va_copy( dst, src )
# else
# define HB_NUMTYPE( v, d ) do { \
v = ( finitel( d ) ? 0 : \
( isnanl( d ) ? _HB_NUM_NAN : \
( isinfl( d ) < 0 ? _HB_NUM_NINF : \
_HB_NUM_PINF ) ) ); \
} while( 0 )
# define va_copy( dst, src ) ( (dst) = (src) )
# endif
#elif defined( __BORLANDC__ ) && defined( hb_fpclassify )
# define HB_NUMTYPE( v, d ) do { \
int t = hb_fpclassify( d ); \
v = ( ( t & ( _FPCLASS_UNSUP | _FPCLASS_SNAN | _FPCLASS_QNAN ) ) ? _HB_NUM_NAN : \
( ( t & _FPCLASS_NINF ) ? _HB_NUM_NINF : \
( ( t & _FPCLASS_PINF ) ? _HB_NUM_PINF : 0 ) ) ); \
} while( 0 )
#elif 0 /* TODO: add other C compilers here (check their version number) */
#else
# if defined( __RSXNT__ ) || defined( __EMX__ ) || \
defined( __XCC__ ) || defined( __POCC__ ) || \
defined( __MINGW32__ ) || defined( HB_OS_HPUX )
# define hb_isfinite( d ) isfinite( d )
# elif !defined( __NO_LONGDOUBLE__ ) && defined( __BORLANDC__ )
# define hb_isfinite( d ) _finitel( d )
# elif defined( _MSC_VER )
# define hb_isfinite( d ) _finite( ( double ) d )
# elif defined( __BORLANDC__ ) || defined( __WATCOMC__ )
# define hb_isfinite( d ) _finite( d )
# elif defined( __GNUC__ ) || defined( __DJGPP__ ) || defined( __LCC__ )
# define hb_isfinite( d ) finite( d )
# else
# define hb_isfinite( d ) FALSE
# endif
# define HB_NUMTYPE( v, d ) do { \
v = hb_isfinite( d ) ? 0 : _HB_NUM_NAN ; \
} while( 0 )
#endif
@@ -1073,10 +952,17 @@ int hb_vsnprintf( char * buffer, size_t bufsize, const char * format, va_list ap
case 'f': /* double decimal notation */
case 'F': /* double decimal notation */
if( length == _L_LONGDOUBLE_ )
{
argval.value.as_x_long_dbl = va_arg_n( args, _x_long_dbl, param );
HB_NUMTYPEL( value, argval.value.as_x_long_dbl );
}
else
argval.value.as_x_long_dbl = va_arg_n( args, _x_double, param );
HB_NUMTYPE( value, argval.value.as_x_long_dbl );
{
double d = va_arg_n( args, _x_double, param );
HB_NUMTYPE( value, d );
argval.value.as_x_long_dbl =
( value & ( _HB_NUM_NAN | _HB_NUM_PINF | _HB_NUM_NINF ) ) == 0 ? d : 0;
}
if( value & _HB_NUM_NAN )
size = put_str( buffer, bufsize, size,
c == 'f' ?

View File

@@ -59,7 +59,6 @@
#include "hbapilng.h"
#include "hbset.h"
#include "hbdate.h"
#include "hbmath.h"
#include "hbsxfunc.h"
#include "hbstack.h"
#include "hbvm.h"

View File

@@ -50,12 +50,11 @@
*
*/
#include "hbmath.h"
#include "hbapi.h"
#include "hbdate.h"
#include <stdlib.h>
#if !defined( HB_OS_WIN )
#if !defined( HB_OS_WIN ) /* for DBL_EPSILON */
#include <float.h>
#endif
@@ -141,6 +140,7 @@ double hb_random_num()
d1 = ( double ) rand();
d2 = ( double ) RAND_MAX;
#if defined( HB_OS_WIN )
/* TOFIX: it breaks the range of random values */
/* It seems that on Windows platform there some weirdness about EPSILON value so
that a float division using an epsilon smaller than 1e-10 may be rounded.
Must dig if it's a borland lib bug or a windows problem.

View File

@@ -2484,6 +2484,9 @@ int hb_socketSetMulticast( HB_SOCKET sd, int af, const char * szAddr )
if( err > 0 )
{
mreq.ipv6mr_interface = 0;
#if !defined( IPV6_JOIN_GROUP ) && defined( IPV6_ADD_MEMBERSHIP )
# define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
#endif
ret = setsockopt( sd, IPPROTO_IPV6, IPV6_JOIN_GROUP, ( const char * ) &mreq, sizeof( mreq ) );
hb_socketSetOsError( ret != -1 ? 0 : HB_SOCK_GETERROR() );
return ret;

View File

@@ -55,26 +55,21 @@
*
*/
#if defined( __DJGPP__ )
# include <libm/math.h>
_LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_;
#else
# include <math.h>
#endif
#include "hbapi.h"
/* hbfloat.h have to be included first */
#include "hbfloat.h"
#include "hbmather.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbmath.h"
#if defined( __DJGPP__ )
_LIB_VERSION_TYPE _LIB_VERSION = _XOPEN_;
#endif
#if defined( HB_MATH_ERRNO )
# include <errno.h>
#endif
#if defined( HB_OS_SUNOS )
# include <ieeefp.h>
#endif
typedef struct
{
@@ -312,7 +307,7 @@ BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc,
{
#if defined( HB_MATH_ERRNO )
int errCode;
int errCode, v;
HB_TRACE( HB_TR_DEBUG, ( "hb_mathGetError(%p,%s,%lf,%lf,%lf)", phb_exc, szFunc, arg1, arg2, dResult ) );
@@ -329,15 +324,10 @@ BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char *szFunc,
break;
default:
if( isnan( dResult ) )
HB_NUMTYPE( v, dResult );
if( ( v & _HB_NUM_NAN ) != 0 )
errCode = EDOM;
# if defined( HB_OS_SUNOS )
else if( !finite( dResult ) )
# elif defined( HB_OS_OS2 )
else if( !isfinite( dResult ) )
# else
else if( isinf( dResult ) )
# endif
else if( ( v & ( _HB_NUM_NINF | _HB_NUM_PINF ) ) != 0 )
errCode = ERANGE;
else
errCode = errno;

View File

@@ -79,6 +79,9 @@
* due to macros used to overload some functions
*/
#include "hbvmopt.h"
#include "hbfloat.h"
#include "hvm.c"
#include "itemapi.c"
#include "hashes.c"

View File

@@ -86,7 +86,9 @@
*/
#include "hbvmopt.h"
#include "hbapi.h"
/* hbfloat.h have to be included before other header files */
#include "hbfloat.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapicls.h"
@@ -95,16 +97,8 @@
#include "hbapierr.h"
#include "hbdate.h"
#include "hbset.h"
#include "hbmath.h"
#include "hbapicdp.h"
#if defined( HB_OS_SUNOS )
# include <ieeefp.h>
#elif defined( _MSC_VER ) || defined( __BORLANDC__ ) || \
defined( __WATCOMC__ ) || defined( __IBMCPP__ )
# include <float.h> /* for _finite() and _isnan() */
#endif
PHB_ITEM hb_itemNew( PHB_ITEM pNull )
{
HB_TRACE(HB_TR_DEBUG, ("hb_itemNew(%p)", pNull));
@@ -2244,41 +2238,7 @@ BOOL hb_itemStrBuf( char *szResult, PHB_ITEM pNumber, int iSize, int iDec )
{
double dNumber = hb_itemGetND( pNumber );
/* TODO: look if finite()/_finite() or isinf()/_isinf and isnan()/_isnan
does exist for your compiler and add this to the check below */
#if defined( __RSXNT__ ) || defined( __EMX__ ) || \
defined( __XCC__ ) || defined( __POCC__ ) || \
defined( __MINGW32__ ) || defined( HB_OS_HPUX )
# define HB_FINITE_DBL(d) ( isfinite(d)!=0 )
#elif defined( __WATCOMC__ ) || defined( __BORLANDC__ ) || defined( _MSC_VER )
# define HB_FINITE_DBL(d) ( _finite(d)!=0 )
#elif defined( __GNUC__ ) || defined( __DJGPP__ ) || defined( __LCC__ ) || \
defined( HB_OS_SUNOS )
# define HB_FINITE_DBL(d) ( finite(d)!=0 )
#else
int iTODO;
/* added infinity check for Borland C [martin vogel] */
/* Borland C 5.5 has _finite() function, if it's necessary
we can reenable this code for older DOS BCC versions
Now this code is for generic C compilers undefined above
[druzus] */
static BOOL s_bInfinityInit = FALSE;
static double s_dInfinity = 0;
if( ! s_bInfinityInit )
{
/* set math handler to NULL for evaluating log(0),
to avoid error messages [martin vogel]*/
HB_MATH_HANDLERPROC fOldMathHandler = hb_mathSetHandler (NULL);
s_dInfinity = -log( ( double ) 0 );
hb_mathSetHandler (fOldMathHandler);
s_bInfinityInit = TRUE;
}
# define HB_FINITE_DBL(d) ( (d) != s_dInfinity && (d) != -s_dInfinity )
#endif
if( pNumber->item.asDouble.length == 99 || !HB_FINITE_DBL( dNumber ) )
if( pNumber->item.asDouble.length == 99 || !hb_isfinite( dNumber ) )
{
/* Numeric overflow */
iPos = -1;