Files
harbour-core/harbour/include/hbdefs.h
Przemyslaw Czerpak a290c984e7 2006-02-04 17:05 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/harbour.spec
  * harbour/make_bsd.sh
  * harbour/make_drw.sh
  * harbour/make_gnu.sh
  * harbour/make_rpm.sh
  * harbour/make_tgz.sh
  * harbour/bin/hb-func.sh
  * harbour/bin/pack_src.sh
  * harbour/config/c.cf
  * harbour/config/global.cf
  * harbour/config/rules.cf
  * harbour/config/darwin/gcc.cf
  * harbour/config/darwin/global.cf
  * harbour/config/dos/djgpp.cf
  * harbour/config/dos/global.cf
  * harbour/config/dos/install.cf
  * harbour/config/dos/owatcom.cf
  * harbour/config/hpux/gcc.cf
  * harbour/config/hpux/global.cf
  * harbour/config/linux/gcc.cf
  * harbour/config/linux/global.cf
  * harbour/config/linux/owatcom.cf
  * harbour/config/sunos/gcc.cf
  * harbour/config/w32/watcom.cf
    * include ADSRDD by default in RPMs
    * updated for new RPM which does not accept some old tags
    * set -fPIC on 64bit platforms
    + added /etc/harbour/hb-charmap.def
    * updated for new GT system and drivers

  * harbour/contrib/dot/pp.prg
  * harbour/contrib/dot/pp_harb.ch
    * use _APMAIN as startup function
    * cleaned direct access to item internals

  * harbour/contrib/libct/Makefile
  + harbour/contrib/libct/ctwfunc.c
  + harbour/contrib/libct/ctwin.c
  + harbour/contrib/libct/ctwin.h
    * added CT3 like Window System - it's a GT driver which inherits
      from the existing one and adds CTW functionality

  * harbour/contrib/libct/screen1.c
    * updated for GTAPI modifications

  * harbour/contrib/libnf/Makefile
  * harbour/contrib/libnf/chdir.c
  * harbour/contrib/libnf/mkdir.c
  * harbour/contrib/libnf/rmdir.c
    * use hb_fs*() API functions instead of calling DOS interrupts
      Now NF dir functions works on all platforms - it will be nice
      to update other functions too.

  * harbour/contrib/libnf/dispc.c
  * harbour/contrib/libnf/ftattr.c
    * updated for GT API modifications, some of this code still depends
      on EGA/VGA video buffer so will work only if user will force in GT
      using it - it will be nice to rewrite them

  * harbour/contrib/odbc/odbc.c
  * harbour/contrib/ole/ole2.c
    * casting and cleaning direct access to item internals

  * harbour/contrib/rdd_ads/ads1.c
  * harbour/contrib/rdd_ads/adsfunc.c
  * harbour/contrib/rdd_ads/adsmgmnt.c
    * synced with xHarbour

  * harbour/include/Makefile
    * added new header files

  + harbour/include/hbgtinfo.ch
    + added GTI_* defintions for hb_gtInfo() function.
      This function works in similar way to dbInfo() in RDD.
      The GTI_* definitions are taken from xHarbour "as is" and
      they should be cleaned - not all functionality are supported
      in Harbour and some others should be implemented in differ
      way then in xHarbour.

  + harbour/include/hbgtcore.h
  * harbour/include/hbapigt.h
    * new GTAPI
      hbgtcore.h file should not be included by user code
      it's only for internal use in GT drivers
    * HB_inkey_enum changed to int - this is bit field not enumerated type.
      Many of C/C++ compilers forbid bit operations on enum types and
      forcing it by casting which finally exceeds the enum range is defined
      as bug because it may badly interacts with some compiler optimizations

  * harbour/include/hbapi.h
  * harbour/include/hbapicdp.h
  * harbour/include/hbapierr.h
  * harbour/include/hbapifs.h
  * harbour/include/hbapiitm.h
  * harbour/include/hbapilng.h
  * harbour/include/hbapirdd.h
  * harbour/include/hbdate.h
  * harbour/include/hbdefs.h
  * harbour/include/hbinit.h
  * harbour/include/hbpcode.h
  * harbour/include/hbrdddbf.h
  * harbour/include/hbset.h
  * harbour/include/hbstack.h
  * harbour/include/hbvm.h
  * harbour/include/hbvmopt.h
  * harbour/include/hbvmpub.h
    * separated internal and external API. Now the definitions for
      internal HVM structures and functions are excluded by default
      they could be enabled if user include hbvmopt.h before other
      header files. Such operation should be done _ONLY_ by core
      code - if 3-rd party developers make sth like that then it's
      for their own risk and such code may stop to work with next
      Harbour versions. Without hbvmopt.h the internal structures
      like HB_ITEM, HB_DYNS, ... are  mapped to 'void' so there is
      no way to access their members so we can modify them in the
      future without afford for 3-rd party code.
      There is one small exception 'type' should be the first member
      for HB_ITEM structure because I used a small ugly hack in
      HB_IS_*() macros with castin PHB_ITEM to HB_TYPE* - it works
      without speed overhead but if you think that it will be
      better/cleaner to not use such tricks then it's enough to
      change HB_ITEM_TYPE() definitions in hbvmpub.h - see note.
    * cleared the usage of HB_EXPORT - to avoid problems with some C/C++
      compilers we agreed that the only one common way of using HB_EXPORT
      is adding it ad begining of declaration - please keep this convention
      in the future.
    + added new functions:
      hb_extIsObject(), hb_codeblockId(), hb_idleSleep(),
      hb_fsGetOsHandle(),
      hb_dynsymFindSymbol(), hb_dynsymGetSymbol(),
      hb_dynsymSymbol(), hb_dynsymName(),
      hb_dynsymMemvarHandle(), hb_dynsymAreaHandle(), hb_dynsymSetAreaHandle()
    * changed hb_arrayClone() declaration to:
         PHB_ITEM hb_arrayClone( PHB_ITEM pArray )
    * changed hb_arrayFromParams() declaration to:
         PHB_ITEM hb_arrayFromParams( int iLevel )
      The previous version needed a pointer to stack relocatable area
      so any stack resizing could cause GPF.

  * harbour/include/inkey.ch
    * added definitions for extended mouse keys/events and some key
      combinations

  * harbour/source/codepage/uc1250.c
  * harbour/source/codepage/uc1251.c
  * harbour/source/codepage/uc1253.c
  * harbour/source/codepage/uc1257.c
  * harbour/source/codepage/uc737.c
  * harbour/source/codepage/uc850.c
  * harbour/source/codepage/uc852.c
  * harbour/source/codepage/uc866.c
  * harbour/source/codepage/uc88591b.c
  * harbour/source/codepage/uc8859_1.c
  * harbour/source/codepage/uc8859_2.c
  * harbour/source/codepage/uc8859_5.c
  * harbour/source/codepage/uckoi8.c
  * harbour/source/codepage/uckoi8u.c
  * harbour/source/codepage/ucmaz.c
    * updated unicode values for characters in rabge 1-31 to keep
      DOS compatibility

  * harbour/source/common/expropt1.c
  * harbour/source/common/hbarch.c
  * harbour/source/common/hbdate.c
  * harbour/source/common/hbstr.c
  * harbour/source/common/hbver.c
    * keep HB_EXPORT at the beginning of function declaration

  * harbour/include/hbpcode.h
  * harbour/include/hbcomp.h
  * harbour/source/compiler/harbour.c
  * harbour/source/compiler/harbour.y
  * harbour/source/compiler/hbfix.c
  + harbour/source/compiler/hbdead.c
  * harbour/source/compiler/hbpcode.c
  + harbour/source/compiler/hbstripl.c
    % rewritten jump optimization
      ! fixed some minor problems
      * do not optimize jumps and local variable access by shorter
        PCODE version and HB_P_NOOP when jump optimization is
        disabled, this is a note I left in source code in few places:
         /*
          * optimizing jumps here by shorting them and setting HB_P_NOOPs
          * only slow down the compilation process for three reasons:
          * 1. When it's dummy jump to next instruction we need two passes
          *    in hb_compOptimizeJumps() to fully remove it
          * 2. hb_compOptimizeJumps() also make jump shortcutting in each pass
          * 3. When Jump Optimization is disabled (-kJ) then it cause slowness
          *    at runtime because we will have more HVM loops: first  for the
          *    shorter jump and next for the HB_P_NOOP PCODE(s)
          * [druzuz]
          */

      + added support for multi passes in jump/dead code elimination
        (hb_compOptimizeJumps())
        By default is set upto three passes.
        Now hb_compOptimizeJumps() keeps all compiler internal data clean
        on exist and can be called any times and does not change other
        compiler's functions behaviors
      + added dummy jumps elimination
      + added optimization for:
            IF .T.
            IF .F.
            WHILE .T.
            WHILE .F.
         etc.
      * restored empty BEGIN/RECOVER sequence block elimination
        if Jump Optimization is enabled then it marks the block
        with HB_P_NOOPS else it cut the generated PCODE
      + added dead code eliminator (new functions hb_compCodeTraceMarkDead()/
        hb_compPCodeTrace() - it works only when Jump Optimization is
        not disabled)
      As a result of the above we have smaller and faster PCODE.

      I do not think that we will have meta code support in the reasonable
      time and because I need some valid compiler data/structures like
      updated table of all jumps for real C code (not PCODE in .c files)
      generation then I decide to make some modifications and the above
      is in practice a side effect of this work.

  * harbour/source/rdd/dbcmd.c
  * harbour/source/rdd/dbf1.c
  * harbour/source/rdd/rddord.prg
  * harbour/source/rdd/workarea.c
  * harbour/source/rdd/dbfcdx/dbfcdx1.c
  * harbour/source/rdd/dbffpt/dbffpt1.c
  * harbour/source/rdd/dbfntx/dbfntx1.c
  * harbour/source/rdd/nulsys/nulsys.c
    * synced with my modifications in xHarbour
    * updated for API modifications

  * harbour/source/rtl/Makefile
    + added gtsys.c, gtfunc.c, hbgtcore.c

  * harbour/source/rtl/accept.c
  * harbour/source/rtl/alert.prg
  * harbour/source/rtl/cdpapi.c
  * harbour/source/rtl/console.c
  * harbour/source/rtl/dates.c
  * harbour/source/rtl/do.c
  * harbour/source/rtl/errorapi.c
  * harbour/source/rtl/errorsys.prg
  * harbour/source/rtl/file.c
  * harbour/source/rtl/fserror.c
  * harbour/source/rtl/fstemp.c
  * harbour/source/rtl/hbffind.c
  * harbour/source/rtl/idle.c
  * harbour/source/rtl/math.c
  * harbour/source/rtl/oldclear.c
  * harbour/source/rtl/strmatch.c
  * harbour/source/rtl/strpeek.c
  * harbour/source/rtl/valtype.c
  * harbour/source/rtl/xsavescr.c
    * updated for API modifications
    * cleaned some compiler warnings

  * harbour/source/rtl/filesys.c
    + added hb_fsGetOsHandle()
    * updated for API modifications

  * harbour/source/rtl/gt.c
  * harbour/source/rtl/gtapi.c
  * harbour/source/rtl/gtapiu.c
  + harbour/source/rtl/gtfunc.c
  + harbour/source/rtl/gtsys.c
  + harbour/source/rtl/hbgtcore.c
  * harbour/source/rtl/inkey.c
  * harbour/source/rtl/maxrow.c
  * harbour/source/rtl/mouseapi.c
  * harbour/source/rtl/setcolor.c
  * harbour/source/rtl/setposbs.c
  * harbour/source/rtl/shadow.c
    * new GT API code

  * harbour/source/rtl/saverest.c
    * changed default behavior in SEVESCREEN/RESTSCREEN with parameters
      out of screen range to be Clipper compatible. Added last logical
      parameter to keep previous behavior for programs which begins to
      use it.

  * harbour/source/rtl/seconds.c
    * include missing header file to fix C++ compilation
    * make hb_secondsCPU global function

  * harbour/source/rtl/set.c
    * make HB_SET_TYPEAHEAD Clipper compatible

  * harbour/source/rtl/gtcgi/Makefile
  * harbour/source/rtl/gtcgi/gtcgi.c
  - harbour/source/rtl/gtcgi/mousecgi.c
    * rewritten for new GT API
      some detail behaviors has been changed but I think the current
      implementation is better for CGI programs output - please check
      and fix me if necessary

  * harbour/source/rtl/gtcrs/Makefile
  - harbour/source/rtl/gtcrs/charmap.prg
  + harbour/source/rtl/gtcrs/chrmap.c
  - harbour/source/rtl/gtcrs/debug.map
  - harbour/source/rtl/gtcrs/eterm.map
  * harbour/source/rtl/gtcrs/gtcrs.c
  + harbour/source/rtl/gtcrs/gtcrs.h
  + harbour/source/rtl/gtcrs/hb-charmap.def
  - harbour/source/rtl/gtcrs/kbdcrs.c
  - harbour/source/rtl/gtcrs/keymap.prg
  - harbour/source/rtl/gtcrs/linux.map
  - harbour/source/rtl/gtcrs/mousecrs.c
    * new GTCRS based on my xHarbour and Flagship curses code
      Please not that at runtime it looks for a file
      /etc/harbour/hb-charmap.def where user can fully tune output
      for his terminal. This file is included with proper path in
      binaries created by make_rpm.sh and make_tgz.sh
      Ryszard I've removed some of your extensions which are no longer
      necessary and some other (keyboard sequence redefinition) should
      be done in a little bit differ way. I would like to talk about it
      when you test current code.
      Added support for extended mouse keys (middle button and wheel).

  * harbour/source/rtl/gtdos/Makefile
  * harbour/source/rtl/gtdos/gtdos.c
  - harbour/source/rtl/gtdos/mousedos.c
    * rewritten for new GT API
      Fixed some small problems, finished mouse code which for DJGPP
      is fully Clipper compatible with real mouse SAVE/RESTORE code.
      For other compilers it should be updated depending on memory
      model and used DPMI driver (if any).

  * harbour/source/rtl/gtos2/Makefile
  * harbour/source/rtl/gtos2/gtos2.c
  - harbour/source/rtl/gtos2/mouseos2.c
    * rewritten for new GT API
      Fixed some problems and finished the mouse code.
      Please test it - I made all modifications without OS2 and
      I was not able to make any test. I'm interesting in information
      if it works and the speed difference - f.e. results from
      tests/vidtest.prg run with previous and current version.

  * harbour/source/rtl/gtpca/Makefile
  * harbour/source/rtl/gtpca/gtpca.c
  - harbour/source/rtl/gtpca/kbdos2.gcc
  - harbour/source/rtl/gtpca/mousepca.c
    * rewritten for new GT API
      and finished so now it's full functional GT driver
      I'm interesting in keyboard sequences used by PC-ANSI drivers
      in DOS so it will be possible to implement also support for
      extended keys input.

  * harbour/source/rtl/gtsln/Makefile
  * harbour/source/rtl/gtsln/gtsln.c
  + harbour/source/rtl/gtsln/gtsln.h
  * harbour/source/rtl/gtsln/kbsln.c
  * harbour/source/rtl/gtsln/keytrans.c
  * harbour/source/rtl/gtsln/mousesln.c
    * rewritten for new GT API basing on current xHarbour code
      added support for slang 1.4x patched for UNICODE (Debian
      patches used by most of current Linux distributions) and
      slang 2.x - It's unicode ready, tries to detect terminal mode
      (utf-8/iso) at startup and switch the internal logic to
      iso/unicode mode. When compiled with slang 1.4x or 2.x
      and terminal is in UTF-8 it can display all characters like
      in DOS if only used font have them or good fall-back table is
      loaded (f.e. the one created by QRCZAK)
      Added support for extended mouse keys (middle button and wheel).

  * harbour/source/rtl/gtstd/Makefile
  * harbour/source/rtl/gtstd/gtstd.c
  - harbour/source/rtl/gtstd/mousestd.c
    * rewritten for new GT API
      Now it can work as full screen GT driver redrawing the previous
      screen contents from internal GT core buffers. I run with this
      GT some of my programs and they work quite well ;-) of course
      without colors.

  * harbour/source/rtl/gtwin/Makefile
  * harbour/source/rtl/gtwin/gtwin.c
  - harbour/source/rtl/gtwin/mousewin.c
    * updated for new GT API

  + harbour/source/rtl/gtxwc/Makefile
  + harbour/source/rtl/gtxwc/gtxwc.c
  + harbour/source/rtl/gtxwc/gtxwc.h
    * new XWindow Console GT driver based on my and Giancarlo Niccolai
      code form xHarbour - this GT can work in XWindow environment only
      and create its own window for  console output. It delays the
      initialization to the moment when user try to display anything on
      the screen so even without X Window system programs which uses this
      GT can work as long as use only outstd/outerr output.

  * harbour/source/vm/arrays.c
    * updated for API modifications
    + added hb_arrayId(),
    * changed hb_arrayClone() declaration to:
         HB_EXPORT PHB_ITEM hb_arrayClone( PHB_ITEM pSrcArray )
    * changed hb_arrayFromParams() declaration to:
         PHB_ITEM hb_arrayFromParams( int iLevel )

  * harbour/source/vm/arrayshb.c
    * updated for API modifications
    + added new parameter iLevel to function HB_APARAMS()

  * harbour/source/vm/classes.c
  * harbour/source/vm/cmdarg.c
  * harbour/source/vm/dynlibhb.c
  * harbour/source/vm/estack.c
  * harbour/source/vm/fm.c
  * harbour/source/vm/garbage.c
  * harbour/source/vm/maindll.c
  * harbour/source/vm/maindllh.c
  * harbour/source/vm/maindllp.c
  * harbour/source/vm/mainstd.c
  * harbour/source/vm/mainwin.c
  * harbour/source/vm/memvars.c
  * harbour/source/vm/pcount.c
  * harbour/source/vm/proc.c
    * updated for API modifications

  * harbour/source/vm/codebloc.c
    * updated for API modifications
    + added hb_codeblockId()

  * harbour/source/vm/dynsym.c
    * updated for API modifications
    + added new functions:
      hb_dynsymFindSymbol(), hb_dynsymGetSymbol(),
      hb_dynsymSymbol(), hb_dynsymName(),
      hb_dynsymMemvarHandle(), hb_dynsymAreaHandle(), hb_dynsymSetAreaHandle()

  * harbour/source/vm/eval.c
    * updated for API modifications
    * call hb_vmPushState()/hb_vmPopState() in hb_itemDo()/hb_itemDoC()
      functions - it's necessary to make HVM reentrant safe.

  * harbour/source/vm/extend.c
    * updated for API modifications
    + added hb_extIsObject() similar to existing hb_extIsArray()

  * harbour/source/vm/hvm.c
    * updated for API modifications
    + added new functions: hb_vmPushState(), hb_vmPopState()
      which save/restore HVM state (the top stack value which can be
      processed and return item and maybe sth else in the future) making
      HVM ready for reentrant.

  * harbour/source/vm/itemapi.c
    * updated for API modifications
    + added new function:
         HB_EXPORT PHB_SYMB hb_itemGetSymbol( PHB_ITEM pItem );
    ! fixed bug in hb_itemPutNInt()

  * harbour/tests/Makefile
  * harbour/utils/hbdoc/Makefile
  * harbour/utils/hbextern/Makefile
  * harbour/utils/hbmake/Makefile
  * harbour/utils/hbrun/Makefile
  * harbour/utils/hbtest/Makefile
    - removed badly added: dbfntx, dbfcdx, dbffpt, hbsix libraries.
      what broke GNU make compilation for some compilers
      This libraries should be included automatically when RDD lib
      is included by *.cf files

   Summary:
      The whole patch (cvs diff -uN) is ~1.5MB length and I cannot describe
      everything in details - sorry but it was too much modifications in
      one commit so now just some of general notes.
      The header files included as is does not have any information about
      internal HVM structures and some functions. In practice only HB_SYMB
      is public and it has to be public for .c files generated from .prg
      so I force the fixed size of this structure (alignment independent)
      by redefining some members to union with void * - it's a little bit
      ugly trick but it effectively eliminates the problem of linking
      binaries compiled with differ alignment C compiler switches.
      The structures like HB_ITEM, HB_CODEBLOCK, HB_STACK, HB_DYNS are not
      longer defined and pointers to the defined as void * - like in Clipper
      the ITEM structure. It caused that I had to add some new functions
      to make some operation still possible to implement. If I missed sth
      and any of you will have a problem with your code then please inform
      me about it and after a small discussion on Harbour developers list
      we can decide if other functions should be added.
      The internal API is still accessible. It's enough to include "hbvmopt.h"
      file before other header files to enable it. Now only files in
      source/vm directory include it.
      The 3-rd party code which does not include hbvmopt.h (or tries to
      set some internals macros) should be safe for future HVM modifications
      and will work also with new binaries so 3-rd party library developers
      should remember about it. If they won't then it's only their and
      their clients problem not Harbour developers.
      With this modifications I also create new GT model which is similar
      to the one used by RDD with multi inheritance. It can be quite easy
      extended to simultaneously load more then one GT subsystem (sth like
      work areas in RDD) but I left it for the future when someone may
      need it. hbapigt.h file now contains only information about public
      functions and does not have any code which depends on current
      internal implementation - it should be backword compatible as long
      as somone did not try to use internal GT functions.
      The internal GT system use hbgtcore.h file which should not be
      included by 3-rd party code as long as someone will not make new
      GT driver. The internal GT code is new so I expect that it will
      be changed yet in the nearest future (I'm waiting for other developers
      feedback) and in such case any 3-rd party GTs will have to be updated.
      How it works:
         The base GT driver (GTNUL) is fully functional GT driver which
         makes all operations on memory buffer. After each screen write
         Flush() method is called which check for dispcount() and if
         it's 0 then call Refresh() method to update modified area by
         Redraw() method. This method is dummy in GTNUL and external
         output with this GT can be reached by outstd()/outerr() which
         are now redirected to GT methods. A simple GT driver may overload
         only Refresh() method to give full screen output.
         Application can use only this GT driver and it seems to be very
         good choice for GUI and background daemon/service programs.
         This GT is loaded at startup then all other GTs can be loaded
         later and inherit from the previously loaded GT drivers.
         The new GT driver can overload as much method as wants/needs.
         Now all GT operations are implemented as GT method so GT driver
         can easy change their default behavior, f.e. it may fully overload
         color parsing methods and use differ or extended to Clipper color
         definitions.
         I rewrote all existing GTs to work with new GT model.
         OS2 users - please test GTOS2 which I was not able to test and
         see the note in Redraw() method. If possible please make some
         speed tests.
         In fact now there is much more internal operations then it was
         before but because they are done on memory only then current
         code is much faster in this GT drivers which so far makes all
         operations on real video area. I made some tests with GTNUL
         and tests/vidtest.prg and the total overhead is minimal. Now
         dipbegin()/dispend() in practice does not cost anything so it
         gives additional speed improvement in application which extensively
         use it.
         More then one GT driver can be linked with final binaries and
         chose on application startup by //GT<NAME> switch and/or environment
         variable HB_GT=<name>
         In the RTL is new GT function GTSYS() which works in similar way
         to RDDSYS() in RDD subsystem and for linking default GT driver
         for given platform. When RTL is compiled the default GT driver
         is set to HB_GT_DEFAULT envvar and if not exist to HB_GT_LIB
         envvar and if it also does not exist to hard coded platfom GTs
         (see source/rtl/gtsys.c and source/rtl/Makefile for rules)
         Adding to source code:
            ANNOUNCE GTSYS
         disable linking the default GT driver and:
            REQUEST HB_GT_<name>
         for linking given (<name>) GT driver, f.e.: REQUEST HB_GT_WIN
         If you are working in SH environment (Linux and other *nixes users,
         DJGPP bash, MinGW shell then it's possible to use -gt<name> switch
         in hblnk / hbmk scripts to force linking GT drivers (it could be
         repeated with different <name>) and the first one becomes the default
         one. F.e.:
            xhbmk -m -n -w -es2 -gtcrs -gtsln -gtstd -gtpca vidtest.prg
         Usually the GT driver are loaded at HVM startup but it's possible
         to load it later. I created new GT driver CTW which gives full
         CT3 like Window system. The CT3 extended driver change the behavior
         of some function in Clipper extended driver, f.e WRITECON() or
         SETPOS() with parameters out of screen range. So I implemented it
         CTW as RT GTs which is loaded when some of CTWIN function is used
         (f.e. WOPEN()/WBOARD()) and inherits from any existing GT driver.
         This is full CT3 WIN implementation with all detail behaviors I
         found (with some CT3 bug fixes). It does not have any CT3 limitations
         and can be used for any virtual screen/window size though I hardcoded
         CT3 limitation for backword compatibility. If somone will want to
         remove it then it will be enough to delete few lines from ctwin.c
         file. I'm not CTWIN Clipper user so maybe I missed some side effects
         in this driver and was not able to well test it so if you will find
         any incompatibilities then please inform me.
         THe default GT buffer uses 32bit character cell internally but
         in savescreen/restscreen it uses VGA compatible two bytes character
         cell. Some GT drivers may want to use differ character cell.
         Now GTCRS and GTSLN use 32bit character cell by default. They
         need additional information about character set (box/normal) to
         properly display box characters. It is possible to force in this
         GT drivers using Clipper compatible character cell by calling:
            hb_gtInfo( GTI_COMPATBUFFER, <lCompat> ) -> <lPreviousSeting>
         but in may cause that box drawing characters will be lost in
         some countries after RESTSCREEN(). It will depend on used code
         page.
         HB_GTINFO() is new function which works in similar way to DBINFO()
         in RDD. It allows to retrieve/change some of GT driver settings.
         GTI_* actions are defined in hbgtinfo.ch - it has all GTI_*
         definitions used in xHarbour. Now in Harbour only few of them
         are implemented.
         The new three .prg functions:
            HB_SETKEYCP( <cTermCP> [,<cHostCP>] )
            HB_SETDISPCP( <cTermCP> [,<cHostCP>] [,<lBoxChar>] )
            HB_SETTERMCP( <cTermCP> [,<cHostCP>] [,<lBoxChar>] )
         have been added. They set automatic input (HB_SETKEYCP)
         and output (HB_SETDISPCP) (or both: HB_SETTERMCP) character
         translation. They are also important for some GTs which
         informing them about used internal code page for unicode
         translation (GTXWC, GTSLN) and/or chosing proper character
         set (standard/alternate) for letters and other (f.e. box
         drawing characters) (GTCRS, GTSLN),
            <cTermCP> is encoding used on external (terminal) side
            <cHostCP> is encoding used internally, if not given then
                      current code page set HB_SETCODEPAGE() is used.
                      some of GTs which uses unicode output may
                      ignore <cTermCP>
            <lBoxChar> is optional parameter which interacts with dispbox()
                       output disabling switching to alternate character
                       set in some GTs. It effectively causes that if internal
                       (host) code page contains some letters on the box char
                       positions then they will be shown also by box drawing
                       functions like dispbox() instead of CP437 characters.
                       In some cases it could be useful. By default lBoxChar
                       is not set and GTs which can switch between standard
                       and alternate character set (GTCRS, GTSLN) will try to
                       use alternate character set for box drawing functions.

      Victor: I removed some of your functions. They can be very easy
      implemented with hb_gt_GetChar()/hb_gt_PutChar() but I do not want to
      make them part of documented external API because some GT drivers may
      want to use absolutely differ color definitions and they will stop to
      work so I do not want to make this functions documented external API.

      Ryszard: Setting alternative debug keys does not longer work.
      I like such possibilities but it should be implemented in differ
      way to f.e. using HB_GTINFO interface to allow low level GT driver
      extensions, f.e. in *nixes using CTRL+[A-Z] and SIGINT, SIGQUIT,
      SIGTSTP signals for real asynchronous setting of debug/cancel flag
      without keyboard polling from main HVM loop. I would like to discus
      about such more general solution.

   *** Please updated non GNU make files ***
2006-02-04 16:16:48 +00:00

1137 lines
46 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Header file for compiler and runtime basic type declarations
*
* Copyright 1999 {list of individual authors and e-mail addresses}
* 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_DEFS_H_
#define HB_DEFS_H_
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hbsetup.h"
#include "hbtrace.h"
/*
#define HB_CLIPPER_INT_ITEMS
#define HB_LONG_LONG_OFF
*/
#if defined( HB_OS_WIN_32 ) || defined( _WIN64 )
#if defined( _WIN64 )
#undef HB_LONG_LONG_OFF
#define HB_STRICT_ALIGNMENT
#if !defined( HB_OS_WIN_32 )
#define HB_OS_WIN_32
#endif
#endif
#if !defined( HB_WIN32_IO_OFF )
#define HB_WIN32_IO
#endif
#if defined( HB_WIN32_IO ) && !defined( HB_OS_WIN_32_USED )
/* disabled to avoid problems with windows.h */
/* #define HB_OS_WIN_32_USED */
#endif
#else
#undef HB_WIN32_IO
#undef HB_OS_WIN_32_USED
#endif
/* Include windows.h if applicable and requested */
#if defined( HB_OS_WIN_32_USED ) && defined( HB_OS_WIN_32 )
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#if defined( __GNUC__ )
#define HB_DONT_DEFINE_BASIC_TYPES
#endif
#elif defined( HB_OS_OS2 )
/* With the exception of WORD, the IBM Visual Age C++ compiler has
its own definitions of the Harbour types most of which conflict with the
Harbour #undefs, due to typedef being the prevalent method of
defining the types in IBMCPP, whereas Harbour assumes that the
definitions that it is replacing have been defined using
#define. Therefore, it is necessary to skip the Harbour
definition section when using the IBMCPP compiiler, include
the IBMCPP type definitions, and then add the definition for WORD
NOTE: This only applies to the common types that most C compilers
define. Any new types, particulary those that start with
HB_, must be placed AFTER the #endif __IBMCPP__ line!
*/
/* 28/03/2000 - maurilio.longo@libero.it
The same holds true when using GCC under OS/2
*/
#define INCL_TYPES
#define INCL_DOSEXCEPTIONS /* DOS exception values */
#define INCL_ERRORS /* DOS error values */
#include <os2.h>
#undef INT
#undef UINT
#define HB_DONT_DEFINE_BASIC_TYPES
#elif defined( HB_OS_DOS )
#include <dos.h>
#if defined(__WATCOMC__) && defined(__386__) && !defined(__WINDOWS_386__)
#define HB_DOS_INT86 int386
#define HB_DOS_INT86X int386x
#define HB_XREGS w
#elif defined(__RSX32__)
#define HB_DOS_INT86 _int86
#define HB_DOS_INT86X _int86x
#define HB_XREGS x
#elif defined( __DJGPP__ )
#define HB_DOS_INT86 int86
#define HB_DOS_INT86X int86x
#define HB_XREGS w
#else
#define HB_DOS_INT86 int86
#define HB_DOS_INT86X int86x
#define HB_XREGS x
#endif
#elif defined( HB_OS_DARWIN )
/* Detect if it is Darwin < 6.x */
#include <pthread.h>
#ifndef PTHREAD_MUTEX_RECURSIVE
#define HB_OS_DARWIN_5
#endif
#endif
#if ! defined( HB_DONT_DEFINE_BASIC_TYPES )
#undef BOOL /* boolean */
typedef int BOOL;
#undef UINT /* varies with platform */
typedef unsigned int UINT;
#undef BYTE /* 1 byte unsigned */
typedef unsigned char BYTE;
#undef SHORT /* 2 bytes signed */
typedef short int SHORT;
#undef USHORT /* 2 bytes unsigned */
typedef unsigned short int USHORT;
#undef LONG /* 4 or 8 bytes signed */
typedef long LONG;
#undef ULONG /* 4 or 8 bytes unsigned */
typedef unsigned long ULONG;
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE (!0)
#ifndef HB_LONG_LONG_OFF
#if ! defined(_WINNT_H)
#if !defined(LONGLONG)
#if defined(__GNUC__)
typedef long long LONGLONG;
#else
typedef __int64 LONGLONG;
#endif
#endif
#if !defined(ULONGLONG)
#if defined(__GNUC__)
typedef unsigned long long ULONGLONG;
#else
typedef unsigned __int64 ULONGLONG;
#endif
#endif
#endif
#if !defined(ULONGLONG_MAX)
#if defined(_UI64_MAX)
#define ULONGLONG_MAX _UI64_MAX
#elif defined(ULLONG_MAX)
#define ULONGLONG_MAX ULLONG_MAX
#elif defined(ULONG_LONG_MAX)
#define ULONGLONG_MAX ULONG_LONG_MAX
#else
#define ULONGLONG_MAX 18446744073709551615ULL
#endif
#endif
#if !defined(LONGLONG_MAX)
#if defined(_I64_MAX)
#define LONGLONG_MAX _I64_MAX
#elif defined(LLONG_MAX)
#define LONGLONG_MAX LLONG_MAX
#elif defined(LONG_LONG_MAX)
#define LONGLONG_MAX LONG_LONG_MAX
#else
#define LONGLONG_MAX 9223372036854775807LL
#endif
#endif
#if !defined(LONGLONG_MIN)
#if defined(_I64_MIN)
#define LONGLONG_MIN _I64_MIN
#elif defined(LLONG_MIN)
#define LONGLONG_MIN LLONG_MIN
#elif defined(LONG_LONG_MIN)
#define LONGLONG_MIN LONG_LONG_MIN
#else
#define LONGLONG_MIN (-LONGLONG_MAX - 1LL)
#endif
#endif
#endif /* HB_LONG_LONG_OFF */
#endif /* HB_DONT_DEFINE_BASIC_TYPES */
/*
* below are some hacks which don't have to be true on some machines
* please update it if necessary
*/
#if defined( _WIN64 )
# define HB_ARCH_64BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX > USHRT_MAX
# define HB_ARCH_64BIT
#elif ULONG_MAX == UINT_MAX && UINT_MAX > USHRT_MAX
# define HB_ARCH_32BIT
#elif ULONG_MAX > UINT_MAX && UINT_MAX == USHRT_MAX
# define HB_ARCH_16BIT
#endif
#if USHRT_MAX == 0xffff
# if !defined( UINT16 )
typedef USHORT UINT16;
# endif
# if !defined( INT16 )
typedef SHORT INT16;
# endif
# if !defined( UINT16_MAX )
# define UINT16_MAX USHRT_MAX
# endif
# if !defined( INT16_MAX )
# define INT16_MAX SHRT_MAX
# endif
# if !defined( INT16_MIN )
# define INT16_MIN SHRT_MIN
# endif
#endif
#if UINT_MAX == 0xffffffff
# if !defined( UINT32 )
typedef UINT UINT32;
# endif
# if !defined( INT32 )
typedef int INT32;
# endif
# if !defined( UINT32_MAX )
# define UINT32_MAX UINT_MAX
# endif
# if !defined( INT32_MAX )
# define INT32_MAX INT_MAX
# endif
# if !defined( INT32_MIN )
# define INT32_MIN INT_MIN
# endif
#elif ULONG_MAX == 0xffffffff
# if !defined( UINT32 )
typedef ULONG UINT32;
# endif
# if !defined( INT32 )
typedef LONG INT32;
# endif
# if !defined( UINT32_MAX )
# define UINT32_MAX ULONG_MAX
# endif
# if !defined( INT32_MAX )
# define INT32_MAX LONG_MAX
# endif
# if !defined( INT32_MIN )
# define INT32_MIN LONG_MIN
# endif
#endif
#if defined( HB_ARCH_64BIT ) && !defined( _WIN64 )
# if !defined( UINT64 )
typedef ULONG UINT64;
# endif
# if !defined( INT64 )
typedef LONG INT64;
# endif
# if !defined( UINT64_MAX )
# define UINT64_MAX ULONG_MAX
# endif
# if !defined( INT64_MAX )
# define INT64_MAX LONG_MAX
# endif
# if !defined( INT64_MIN )
# define INT64_MIN LONG_MIN
# endif
#elif !defined( HB_LONG_LONG_OFF )
# if !defined( UINT64 )
typedef ULONGLONG UINT64;
# endif
# if !defined( INT64 )
typedef LONGLONG INT64;
# endif
# if !defined( UINT64_MAX )
# define UINT64_MAX ULONGLONG_MAX
# endif
# if !defined( INT64_MAX )
# define INT64_MAX LONGLONG_MAX
# endif
# if !defined( INT64_MIN )
# define INT64_MIN LONGLONG_MIN
# endif
#endif
#ifndef HB_LONG_DOUBLE_OFF
typedef long double HB_MAXDBL;
#else
typedef double HB_MAXDBL;
#endif
#if defined( HB_CLIPPER_INT_ITEMS )
# define HB_INT_MAX SHRT_MAX
# define HB_INT_MIN SHRT_MIN
# define HB_LONG_MAX LONG_MAX
# define HB_LONG_MIN LONG_MIN
# define HB_ULONG_MAX ULONG_MAX
typedef LONG HB_LONG;
typedef ULONG HB_ULONG;
# define PFHL "l"
#elif !defined( HB_LONG_LONG_OFF ) && ULONG_MAX == UINT_MAX
# define HB_INT_MAX INT_MAX
# define HB_INT_MIN INT_MIN
# define HB_LONG_MAX LONGLONG_MAX
# define HB_LONG_MIN LONGLONG_MIN
# define HB_ULONG_MAX ULONGLONG_MAX
typedef LONGLONG HB_LONG;
typedef ULONGLONG HB_ULONG;
#else
# define HB_INT_MAX INT_MAX
# define HB_INT_MIN INT_MIN
# define HB_LONG_MAX LONG_MAX
# define HB_LONG_MIN LONG_MIN
# define HB_ULONG_MAX ULONG_MAX
typedef LONG HB_LONG;
typedef ULONG HB_ULONG;
# define PFHL "l"
#endif
#define HB_DBL_LIM_INT(d) ( HB_INT_MIN <= (d) && (d) <= HB_INT_MAX )
#define HB_DBL_LIM_LONG(d) ( (HB_MAXDBL) HB_LONG_MIN <= (HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= (HB_MAXDBL) HB_LONG_MAX )
#define HB_LIM_INT(l) ( HB_INT_MIN <= (l) && (l) <= HB_INT_MAX )
#define HB_LIM_LONG(l) ( HB_LONG_MIN <= (l) && (l) <= HB_LONG_MAX )
#define HB_DBL_LIM_INT8(d) ( -128 <= (d) && (d) <= 127 )
#define HB_DBL_LIM_INT16(d) ( INT16_MIN <= (d) && (d) <= INT16_MAX )
#define HB_DBL_LIM_INT24(d) ( -8388608.0 <= (d) && (d) <= 8388607.0 )
#define HB_DBL_LIM_INT32(d) ( INT32_MIN <= (d) && (d) <= INT32_MAX )
#define HB_DBL_LIM_INT64(d) ( (HB_MAXDBL) INT64_MIN <= (HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= (HB_MAXDBL) INT64_MAX )
#define HB_LIM_INT8(l) ( -128 <= (l) && (l) <= 127 )
#define HB_LIM_INT16(l) ( INT16_MIN <= (l) && (l) <= INT16_MAX )
#define HB_LIM_INT24(l) ( -8388608L <= (l) && (l) <= 8388607L )
#define HB_LIM_INT32(l) ( INT32_MIN <= (l) && (l) <= INT32_MAX )
#define HB_LIM_INT64(l) ( INT64_MIN <= (l) && (l) <= INT64_MAX )
/*
* It's a hack for MSC which doesn't support LL suffix for LONGLONG
* numeric constant. This suffix is necessary for some compilers -
* without it they cut the number to LONG
*/
#if ( defined( _MSC_VER ) || defined( __BORLANDC__ ) ) && !defined(__DMC__)
# define HB_LL( num ) num
#else
# define HB_LL( num ) num##LL
#endif
#if HB_LONG_MAX > HB_LL( 10000000000 )
# define HB_LONG_LENGTH( l ) ( ( (l) <= -1000000000 || (l) >= HB_LL( 10000000000 ) ) ? 20 : 10 )
#else
# define HB_LONG_LENGTH( l ) ( ( (l) <= -1000000000 ) ? 20 : 10 )
#endif
#if HB_INT_MIN <= -1000000000
# define HB_INT_LENGTH( i ) ( ( (i) <= -1000000000 ) ? 20 : 10 )
#else
# define HB_INT_LENGTH( i ) 10
#endif
/* NOTE: Yes, -999999999.0 is right instead of -1000000000.0 [vszakats] */
/* This comment is from hb_vmNeg() - if it's true only in this case then
the limit should be changed and this function fixed */
#define HB_DBL_LENGTH( d ) ( ( (d) >= 10000000000.0 || (d) <= -999999999.0 ) ? 20 : 10 )
/* uncomment this if you need strict Clipper compatibility */
/* #define PCODE_LONG_LIM(l) HB_LIM_INT32( l ) */
/* #define PCODE_LONG_LIM(l) HB_LIM_LONG( l ) */
/* type of HB_ITEM */
/* typedef USHORT HB_TYPE; */
typedef UINT32 HB_TYPE;
/* type of reference counter */
typedef unsigned long HB_COUNTER;
/* type for memory pointer diff */
#if defined( _WIN64 )
typedef LONGLONG HB_PTRDIFF;
#else
typedef long HB_PTRDIFF;
#endif
#ifdef HB_LONG_LONG_OFF
typedef LONG HB_FOFFSET;
/* we can add hack with double as work around what should
effectively give 52bit file size limit */
#else
typedef LONGLONG HB_FOFFSET;
#endif
#if defined( HB_WIN32_IO )
typedef long FHANDLE;
#else
typedef int FHANDLE;
#endif
/* maximum length of double number in decimal representation:
log10(2^1024) ~ 308.25 */
#define HB_MAX_DOUBLE_LENGTH 320
/* This value is used to hack the double FL value in round/int
operation - similar thing is done by CL5.3 - I do not know
only the exact factor value but it should be close to this one.
When HB_C52_STRICT is set this macro is not used.
*/
#define HB_DBLFL_PREC_FACTOR 1.0000000000000002;
/* try to detect byte order if not explicitly set */
#if !defined( HB_PDP_ENDIAN ) && !defined( HB_BIG_ENDIAN ) && \
!defined( HB_LITTLE_ENDIAN )
/* I intentionaly move the first two #if/#elif to the begining
to avoid compiler error when this macro will be defined as
empty statement in next conditions, F.e. SunOS
*/
# if ( defined( __LITTLE_ENDIAN__ ) && ! defined( __BIG_ENDIAN__ ) ) || \
( defined( __LITTLE_ENDIAN ) && ! defined( __BIG_ENDIAN ) ) || \
( defined( _LITTLE_ENDIAN ) && ! defined( _BIG_ENDIAN ) ) || \
( defined( LITTLE_ENDIAN ) && ! defined( BIG_ENDIAN ) )
# define HB_LITTLE_ENDIAN
# elif ( ! defined( __LITTLE_ENDIAN__ ) && defined( __BIG_ENDIAN__ ) ) || \
( ! defined( __LITTLE_ENDIAN ) && defined( __BIG_ENDIAN ) ) || \
( ! defined( _LITTLE_ENDIAN ) && defined( _BIG_ENDIAN ) ) || \
( ! defined( LITTLE_ENDIAN ) && defined( BIG_ENDIAN ) )
# define HB_BIG_ENDIAN
# elif ( defined( __BYTE_ORDER ) && defined( __LITTLE_ENDIAN ) && __BYTE_ORDER == __LITTLE_ENDIAN ) || \
( defined( _BYTE_ORDER ) && defined( _LITTLE_ENDIAN ) && _BYTE_ORDER == _LITTLE_ENDIAN ) || \
( defined( BYTE_ORDER ) && defined( LITTLE_ENDIAN ) && BYTE_ORDER == LITTLE_ENDIAN )
# define HB_LITTLE_ENDIAN
# elif ( defined( __BYTE_ORDER ) && defined( __BIG_ENDIAN ) && __BYTE_ORDER == __BIG_ENDIAN ) || \
( defined( _BYTE_ORDER ) && defined( _BIG_ENDIAN ) && _BYTE_ORDER == _BIG_ENDIAN ) || \
( defined( BYTE_ORDER ) && defined( BIG_ENDIAN ) && BYTE_ORDER == BIG_ENDIAN )
# define HB_BIG_ENDIAN
# elif ( defined( __BYTE_ORDER ) && defined( __PDP_ENDIAN ) && __BYTE_ORDER == __PDP_ENDIAN ) || \
( defined( _BYTE_ORDER ) && defined( _PDP_ENDIAN ) && _BYTE_ORDER == _PDP_ENDIAN ) || \
( defined( BYTE_ORDER ) && defined( PDP_ENDIAN ) && BYTE_ORDER == PDP_ENDIAN )
# define HB_PDP_ENDIAN
# else /* We cannot detect byte order, we will have to guess */
# if defined( HB_OS_DARWIN ) || defined( HB_OS_SUNOS ) || defined( HB_OS_HPUX )
# define HB_BIG_ENDIAN
# else
# define HB_LITTLE_ENDIAN
# endif
# endif
#endif
#define HB_MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
#define HB_MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#define HB_LOBYTE( w ) ( ( BYTE ) ( w ) )
#define HB_HIBYTE( w ) ( ( BYTE ) ( ( ( w ) >> 8 ) & 0xFF ) )
#define HB_LOWORD( l ) ( ( UINT16 ) ( l ) )
#define HB_HIWORD( l ) ( ( UINT16 ) ( ( ( l ) >> 16 ) & 0xFFFF ) )
#define HB_MKSHORT( lo, hi ) ( ( SHORT ) ( ( ( INT16 ) ( hi ) ) << 8 ) | ( lo ) )
#define HB_MKUSHORT( lo, hi ) ( ( USHORT ) ( ( ( UINT16 ) ( hi ) ) << 8 ) | ( lo ) )
#define HB_MKLONG( b1, b2, b3, b4 ) ( ( LONG ) \
( ( ( ( INT32 ) ( b4 ) ) << 24 ) | \
( ( ( INT32 ) ( b3 ) ) << 16 ) | \
( ( ( INT32 ) ( b2 ) ) << 8 ) | \
( ( ( INT32 ) ( b1 ) ) ) ) )
#define HB_MKULONG( b1, b2, b3, b4 ) ( ( ULONG ) \
( ( ( ( UINT32 ) ( b4 ) ) << 24 ) | \
( ( ( UINT32 ) ( b3 ) ) << 16 ) | \
( ( ( UINT32 ) ( b2 ) ) << 8 ) | \
( ( ( UINT32 ) ( b1 ) ) ) ) )
#define HB_SWAP_UINT16( w ) ( ( UINT16 ) ( ( ( ( UINT16 ) ( w ) & 0xFF00 ) >> 8 ) | \
( ( ( UINT16 ) ( w ) & 0x00FF ) << 8 ) ) )
#define HB_SWAP_UINT32( w ) ( ( UINT32 ) ( ( ( ( UINT32 ) ( w ) & 0x000000FF ) << 24 ) | \
( ( ( UINT32 ) ( w ) & 0x0000FF00 ) << 8 ) | \
( ( ( UINT32 ) ( w ) & 0x00FF0000 ) >> 8 ) | \
( ( ( UINT32 ) ( w ) & 0xFF000000 ) >> 24 ) ) )
#ifndef PFLL
# if defined( __BORLANDC__ ) || defined( _MSC_VER )
# define PFLL "I64"
# elif defined( __LCC__ )
# define PFLL "ll"
# else
# define PFLL "L"
# endif
#endif
#ifndef PFHL
# define PFHL PFLL
#endif
#define HB_SWAP_UINT64( w ) ( ( UINT64 ) ( ( ( ( UINT64 ) ( w ) & HB_LL( 0x00000000000000FF ) ) << 56 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x000000000000FF00 ) ) << 40 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x0000000000FF0000 ) ) >> 24 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x00000000FF000000 ) ) >> 8 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x000000FF00000000 ) ) >> 8 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x0000FF0000000000 ) ) >> 24 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0x00FF000000000000 ) ) >> 40 ) | \
( ( ( UINT64 ) ( w ) & HB_LL( 0xFF00000000000000 ) ) >> 56 ) ) )
/*
* on some machines it's not safe to directly access pointers stored
* at byte buffer they have to be stored at odd (or other alignment)
* addresses.
* For example SPARC which needs 4 byte alignment for pointers
* and 8 byte alignment for doubles and structures (when GCC is used)
* IMHO need HB_ARCH_<arch> macro yet - the same OS can be used with
* different architectures - SPARC + LINUX, ALPHA + LINUX
*/
#if defined( HB_OS_SUNOS ) || defined( HB_OS_HPUX )
# if !defined( HB_STRICT_ALIGNMENT )
# define HB_STRICT_ALIGNMENT
# endif
# if !defined( HB_ALLOC_ALIGNMENT ) || ( HB_ALLOC_ALIGNMENT + 1 == 1 )
# define HB_ALLOC_ALIGNMENT 8
# endif
#endif
/*
* These macros are necessary for architectures which need
* strict alignment for pointers.
*/
#if defined( HB_BIG_ENDIAN )
# if defined( HB_ARCH_64BIT )
# define HB_PUT_LONG( p, v ) HB_PUT_BE_UINT64( p, ( UINT64 ) ( v ) )
# define HB_GET_LONG( p ) HB_GET_BE_UINT64( p )
# else
# define HB_PUT_LONG( p, v ) HB_PUT_BE_UINT32( p, ( UINT32 ) ( v ) )
# define HB_GET_LONG( p ) HB_GET_BE_UINT32( p )
# endif
#else
# if defined( HB_ARCH_64BIT )
# define HB_PUT_LONG( p, v ) HB_PUT_LE_UINT64( p, ( UINT64 ) ( v ) )
# define HB_GET_LONG( p ) HB_GET_LE_UINT64( p )
# else
# define HB_PUT_LONG( p, v ) HB_PUT_LE_UINT32( p, ( UINT32 ) ( v ) )
# define HB_GET_LONG( p ) HB_GET_LE_UINT32( p )
# endif
#endif
#if !defined( HB_STRICT_ALIGNMENT )
# define HB_PUT_PTR( p, v ) do { *( void ** ) ( p ) = ( void * ) ( v ); } while ( 0 )
# define HB_GET_PTR( p ) ( *( void ** ) ( p ) )
#else
# define HB_PUT_PTR( p, v ) HB_PUT_LONG( p, v )
# define HB_GET_PTR( p ) ( ( void * ) HB_GET_LONG( p ) )
#endif
/* Macros to store/retrive double value */
#if defined( __GNUC__ )
# define HB_GET_REV_DOUBLE( p ) \
( { \
union { \
double dbl; \
BYTE buffer[ 8 ]; \
} u; \
u.buffer[ 0 ] = (( BYTE * )( p ))[ 7 ]; \
u.buffer[ 1 ] = (( BYTE * )( p ))[ 6 ]; \
u.buffer[ 2 ] = (( BYTE * )( p ))[ 5 ]; \
u.buffer[ 3 ] = (( BYTE * )( p ))[ 4 ]; \
u.buffer[ 4 ] = (( BYTE * )( p ))[ 3 ]; \
u.buffer[ 5 ] = (( BYTE * )( p ))[ 2 ]; \
u.buffer[ 6 ] = (( BYTE * )( p ))[ 1 ]; \
u.buffer[ 7 ] = (( BYTE * )( p ))[ 0 ]; \
u.dbl; \
} )
# define HB_GET_STD_DOUBLE( p ) \
( { \
union { \
double dbl; \
BYTE buffer[ 8 ]; \
} u; \
u.buffer[ 0 ] = (( BYTE * )( p ))[ 0 ]; \
u.buffer[ 1 ] = (( BYTE * )( p ))[ 1 ]; \
u.buffer[ 2 ] = (( BYTE * )( p ))[ 2 ]; \
u.buffer[ 3 ] = (( BYTE * )( p ))[ 3 ]; \
u.buffer[ 4 ] = (( BYTE * )( p ))[ 4 ]; \
u.buffer[ 5 ] = (( BYTE * )( p ))[ 5 ]; \
u.buffer[ 6 ] = (( BYTE * )( p ))[ 6 ]; \
u.buffer[ 7 ] = (( BYTE * )( p ))[ 7 ]; \
u.dbl; \
} )
#else
# define HB_GET_REV_DOUBLE( p ) hb_get_rev_double( ( BYTE * ) ( p ) )
# define HB_GET_STD_DOUBLE( p ) hb_get_std_double( ( BYTE * ) ( p ) )
#endif
#define HB_PUT_REV_DOUBLE( p, d ) \
do { \
union { \
double dbl; \
BYTE buffer[ 8 ]; \
} u; \
u.dbl = ( d ); \
(( BYTE * )( p ))[ 7 ] = u.buffer[ 0 ]; \
(( BYTE * )( p ))[ 6 ] = u.buffer[ 1 ]; \
(( BYTE * )( p ))[ 5 ] = u.buffer[ 2 ]; \
(( BYTE * )( p ))[ 4 ] = u.buffer[ 3 ]; \
(( BYTE * )( p ))[ 3 ] = u.buffer[ 4 ]; \
(( BYTE * )( p ))[ 2 ] = u.buffer[ 5 ]; \
(( BYTE * )( p ))[ 1 ] = u.buffer[ 6 ]; \
(( BYTE * )( p ))[ 0 ] = u.buffer[ 7 ]; \
} while ( 0 )
#define HB_PUT_STD_DOUBLE( p, d ) \
do { \
union { \
double dbl; \
BYTE buffer[ 8 ]; \
} u; \
u.dbl = ( d ); \
(( BYTE * )( p ))[ 0 ] = u.buffer[ 0 ]; \
(( BYTE * )( p ))[ 1 ] = u.buffer[ 1 ]; \
(( BYTE * )( p ))[ 2 ] = u.buffer[ 2 ]; \
(( BYTE * )( p ))[ 3 ] = u.buffer[ 3 ]; \
(( BYTE * )( p ))[ 4 ] = u.buffer[ 4 ]; \
(( BYTE * )( p ))[ 5 ] = u.buffer[ 5 ]; \
(( BYTE * )( p ))[ 6 ] = u.buffer[ 6 ]; \
(( BYTE * )( p ))[ 7 ] = u.buffer[ 7 ]; \
} while ( 0 )
/*
* HB_FORCE_IEEE754_DOUBLE will can be used on platforms which use differ
* double format and we want to force storing double number as IEEE754
* double value for sharing binary data (f.e. PCODE in .hrb files or CDX
* indexes or DBFs with "B" fields.
*/
#if defined( HB_FORCE_IEEE754_DOUBLE )
# define HB_GET_LE_DOUBLE( p ) hb_get_ieee754( ( BYTE * ) ( p ) )
# define HB_PUT_LE_DOUBLE( p, d ) hb_put_ieee754( ( BYTE * ) ( p ), ( d ) )
# define HB_DBL2ORD( d, o ) hb_put_ord_ieee754( ( o ), *( d ) )
# define HB_ORD2DBL( o, d ) do { \
*d = hb_get_ord_ieee754( ( BYTE * ) ( o ) ); \
} while( 0 )
#elif defined( HB_STRICT_ALIGNMENT )
# if defined( HB_LITTLE_ENDIAN )
# define HB_GET_LE_DOUBLE( p ) HB_GET_STD_DOUBLE( ( p ) )
# define HB_PUT_LE_DOUBLE( p, d ) HB_PUT_STD_DOUBLE( ( p ), ( d ) )
# elif defined( HB_BIG_ENDIAN )
# define HB_GET_LE_DOUBLE( p ) HB_GET_REV_DOUBLE( ( p ) )
# define HB_PUT_LE_DOUBLE( p, d ) HB_PUT_REV_DOUBLE( ( p ), ( d ) )
# endif
#else
# if defined( HB_LITTLE_ENDIAN )
# define HB_GET_LE_DOUBLE( p ) ( *( double * )( p ) )
# define HB_PUT_LE_DOUBLE( p, d ) ( *( double * )( p ) = ( double ) ( d ) )
# elif defined( HB_BIG_ENDIAN )
# define HB_GET_LE_DOUBLE( p ) HB_GET_REV_DOUBLE( ( p ) )
# define HB_PUT_LE_DOUBLE( p, d ) HB_PUT_REV_DOUBLE( ( p ), ( d ) )
# endif
#endif
/* Now the rest of endian macros */
#if defined( HB_STRICT_ALIGNMENT ) || !defined( HB_LITTLE_ENDIAN )
#define HB_GET_LE_UINT16( p ) ( ( UINT16 ) \
( ( ( UINT16 ) (( BYTE * )( p ))[0] ) | \
( ( UINT16 ) (( BYTE * )( p ))[1] << 8 ) ) )
#define HB_GET_LE_UINT32( p ) ( ( UINT32 ) \
( ( ( UINT32 ) (( BYTE * )( p ))[0] ) | \
( ( UINT32 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( UINT32 ) (( BYTE * )( p ))[2] << 16 ) | \
( ( UINT32 ) (( BYTE * )( p ))[3] << 24 ) ) )
#define HB_GET_LE_UINT64( p ) ( ( UINT64 ) \
( ( ( UINT64 ) (( BYTE * )( p ))[0] ) | \
( ( UINT64 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( UINT64 ) (( BYTE * )( p ))[2] << 16 ) | \
( ( UINT64 ) (( BYTE * )( p ))[3] << 24 ) | \
( ( UINT64 ) (( BYTE * )( p ))[4] << 32 ) | \
( ( UINT64 ) (( BYTE * )( p ))[5] << 40 ) | \
( ( UINT64 ) (( BYTE * )( p ))[6] << 48 ) | \
( ( UINT64 ) (( BYTE * )( p ))[7] << 56 ) ) )
#define HB_PUT_LE_UINT16( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( w ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 8 ); \
} while ( 0 )
#define HB_PUT_LE_UINT32( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( w ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
(( BYTE * )( p ))[3] = ( BYTE )( (w) >> 24 ); \
} while ( 0 )
#define HB_PUT_LE_UINT64( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( w ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
(( BYTE * )( p ))[3] = ( BYTE )( (w) >> 24 ); \
(( BYTE * )( p ))[4] = ( BYTE )( (w) >> 32 ); \
(( BYTE * )( p ))[5] = ( BYTE )( (w) >> 40 ); \
(( BYTE * )( p ))[6] = ( BYTE )( (w) >> 48 ); \
(( BYTE * )( p ))[7] = ( BYTE )( (w) >> 56 ); \
} while ( 0 )
#endif
#if defined( HB_STRICT_ALIGNMENT ) || !defined( HB_BIG_ENDIAN )
#define HB_GET_BE_UINT16( p ) ( ( UINT16 ) \
( ( ( UINT16 ) (( BYTE * )( p ))[0] << 8 ) | \
( ( UINT16 ) (( BYTE * )( p ))[1] ) ) )
#define HB_GET_BE_UINT32( p ) ( ( UINT32 ) \
( ( ( UINT32 ) (( BYTE * )( p ))[0] << 24 ) | \
( ( UINT32 ) (( BYTE * )( p ))[1] << 16 ) | \
( ( UINT32 ) (( BYTE * )( p ))[2] << 8 ) | \
( ( UINT32 ) (( BYTE * )( p ))[3] ) ) )
#define HB_GET_BE_UINT64( p ) ( ( UINT64 ) \
( ( ( UINT64 ) (( BYTE * )( p ))[0] << 56 ) | \
( ( UINT64 ) (( BYTE * )( p ))[1] << 48 ) | \
( ( UINT64 ) (( BYTE * )( p ))[2] << 40 ) | \
( ( UINT64 ) (( BYTE * )( p ))[3] << 32 ) | \
( ( UINT64 ) (( BYTE * )( p ))[4] << 24 ) | \
( ( UINT64 ) (( BYTE * )( p ))[5] << 16 ) | \
( ( UINT64 ) (( BYTE * )( p ))[6] << 8 ) | \
( ( UINT64 ) (( BYTE * )( p ))[7] ) ) )
#define HB_PUT_BE_UINT16( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[1] = ( BYTE )( w ); \
} while ( 0 )
#define HB_PUT_BE_UINT32( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( (w) >> 24 ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 16 ); \
(( BYTE * )( p ))[2] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[3] = ( BYTE )( w ); \
} while ( 0 )
#define HB_PUT_BE_UINT64( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( (w) >> 56 ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 48 ); \
(( BYTE * )( p ))[2] = ( BYTE )( (w) >> 40 ); \
(( BYTE * )( p ))[3] = ( BYTE )( (w) >> 32 ); \
(( BYTE * )( p ))[4] = ( BYTE )( (w) >> 24 ); \
(( BYTE * )( p ))[5] = ( BYTE )( (w) >> 16 ); \
(( BYTE * )( p ))[6] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[7] = ( BYTE )( w ); \
} while ( 0 )
#endif
/*
* 24 bit integers are not directly supported by any processor we used so far
* so we always have to build them from BYTEs and cannot use C casting
*/
#define HB_GET_LE_INT24( p ) ( ( INT32 ) \
( ( ( INT32 ) (( BYTE * )( p ))[0] ) | \
( ( INT32 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( INT32 ) (( BYTE * )( p ))[2] << 16 ) | \
( ( INT32 ) ((( BYTE * )( p ))[2] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) )
#define HB_GET_LE_UINT24( p ) ( ( UINT32 ) \
( ( ( UINT32 ) (( BYTE * )( p ))[0] ) | \
( ( UINT32 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( UINT32 ) (( BYTE * )( p ))[2] << 16 ) ) )
#define HB_PUT_LE_UINT24( p, w ) do { \
(( BYTE * )( p ))[0] = ( BYTE )( w ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[2] = ( BYTE )( (w) >> 16 ); \
} while ( 0 )
#define HB_GET_BE_INT24( p ) ( ( INT32 ) \
( ( ( INT32 ) (( BYTE * )( p ))[2] ) | \
( ( INT32 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( INT32 ) (( BYTE * )( p ))[0] << 16 ) | \
( ( INT32 ) ((( BYTE * )( p ))[0] & 0x80 ? 0xFF : 0x00 ) << 24 ) ) )
#define HB_GET_BE_UINT24( p ) ( ( UINT32 ) \
( ( ( UINT32 ) (( BYTE * )( p ))[2] ) | \
( ( UINT32 ) (( BYTE * )( p ))[1] << 8 ) | \
( ( UINT32 ) (( BYTE * )( p ))[0] << 16 ) ) )
#define HB_PUT_BE_UINT24( p, w ) do { \
(( BYTE * )( p ))[2] = ( BYTE )( w ); \
(( BYTE * )( p ))[1] = ( BYTE )( (w) >> 8 ); \
(( BYTE * )( p ))[0] = ( BYTE )( (w) >> 16 ); \
} while ( 0 )
#if defined( HB_PDP_ENDIAN )
#error PDP-Endian support unimplemented. If you have such machine do it yourself.
#elif defined( HB_BIG_ENDIAN )
/* We use Big-Endian here */
# ifndef HB_STRICT_ALIGNMENT
#define HB_GET_BE_UINT16( p ) ( *( UINT16 * )( p ) )
#define HB_PUT_BE_UINT16( p, w ) ( *( UINT16 * )( p ) = ( UINT16 ) ( w ) )
#define HB_GET_BE_UINT32( p ) ( *( UINT32 * )( p ) )
#define HB_PUT_BE_UINT32( p, l ) ( *( UINT32 * )( p ) = ( UINT32 ) ( l ) )
#define HB_GET_BE_UINT64( p ) ( *( UINT64 * )( p ) )
#define HB_PUT_BE_UINT64( p, l ) ( *( UINT64 * )( p ) = ( UINT64 ) ( l ) )
# endif
#define HB_USHORT_FROM_LE( w ) HB_MKUSHORT( HB_HIBYTE( w ), HB_LOBYTE( w ) )
#define HB_ULONG_FROM_LE( l ) HB_MKULONG( HB_HIBYTE( HB_HIWORD( l ) ), HB_LOBYTE( HB_HIWORD( l ) ), HB_HIBYTE( l ), HB_LOBYTE( l ) )
#define HB_USHORT_TO_LE( w ) HB_USHORT_FROM_LE( w )
#define HB_ULONG_TO_LE( l ) HB_ULONG_FROM_LE( l )
# ifndef HB_FORCE_IEEE754_DOUBLE
#define HB_ORD2DBL( o, d ) do { \
if ( ( ( BYTE * ) ( o ) )[ 0 ] & 0x80 ) { \
( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 0 ]; \
( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 1 ]; \
( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 2 ]; \
( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 3 ]; \
( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 4 ]; \
( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 5 ]; \
( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 6 ]; \
( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0x80; \
} else { \
( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 1 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 2 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 3 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 4 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 5 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 6 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0xFF; \
} } while ( 0 )
#define HB_DBL2ORD( d, o ) do { \
if ( *( double * )( d ) >= 0.0 ) { \
if( *( double * )( d ) == -0.0 ) *( double * )( d ) = 0.0; \
( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0x80; \
( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 1 ]; \
( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 2 ]; \
( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 3 ]; \
( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 4 ]; \
( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 5 ]; \
( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 6 ]; \
( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 7 ]; \
} else { \
( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 1 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 2 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 3 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 4 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 5 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 6 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0xFF; \
} } while ( 0 )
# endif
#else /* HB_LITTLE_ENDIAN */
/* We use Little-Endian here */
# ifndef HB_STRICT_ALIGNMENT
#define HB_GET_LE_UINT16( p ) ( *( UINT16 * )( p ) )
#define HB_PUT_LE_UINT16( p, w ) ( *( UINT16 * )( p ) = ( UINT16 ) ( w ) )
#define HB_GET_LE_UINT32( p ) ( *( UINT32 * )( p ) )
#define HB_PUT_LE_UINT32( p, l ) ( *( UINT32 * )( p ) = ( UINT32 ) ( l ) )
#define HB_GET_LE_UINT64( p ) ( *( UINT64 * )( p ) )
#define HB_PUT_LE_UINT64( p, l ) ( *( UINT64 * )( p ) = ( UINT64 ) ( l ) )
# endif
#define HB_USHORT_FROM_LE( w ) ( ( USHORT )( w ) )
#define HB_ULONG_FROM_LE( l ) ( ( ULONG )( l ) )
#define HB_USHORT_TO_LE( w ) ( ( USHORT )( w ) )
#define HB_ULONG_TO_LE( l ) ( ( ULONG )( l ) )
# ifndef HB_FORCE_IEEE754_DOUBLE
#define HB_ORD2DBL( o, d ) do { \
if ( ( ( BYTE * ) ( o ) )[ 0 ] & 0x80 ) { \
( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 7 ]; \
( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 6 ]; \
( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 5 ]; \
( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 4 ]; \
( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 3 ]; \
( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 2 ]; \
( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 1 ]; \
( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0x80; \
} else { \
( ( BYTE * ) ( d ) )[ 0 ] = ( ( BYTE * ) ( o ) )[ 7 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 1 ] = ( ( BYTE * ) ( o ) )[ 6 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 2 ] = ( ( BYTE * ) ( o ) )[ 5 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 3 ] = ( ( BYTE * ) ( o ) )[ 4 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 4 ] = ( ( BYTE * ) ( o ) )[ 3 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 5 ] = ( ( BYTE * ) ( o ) )[ 2 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 6 ] = ( ( BYTE * ) ( o ) )[ 1 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( d ) )[ 7 ] = ( ( BYTE * ) ( o ) )[ 0 ] ^ ( BYTE ) 0xFF; \
} } while ( 0 )
#define HB_DBL2ORD( d, o ) do { \
if ( *( double * )( d ) >= 0.0 ) { \
if( *( double * )( d ) == -0.0 ) *( double * )( d ) = 0.0; \
( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0x80; \
( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 6 ]; \
( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 5 ]; \
( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 4 ]; \
( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 3 ]; \
( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 2 ]; \
( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 1 ]; \
( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 0 ]; \
} else { \
( ( BYTE * ) ( o ) )[ 0 ] = ( ( BYTE * ) ( d ) )[ 7 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 1 ] = ( ( BYTE * ) ( d ) )[ 6 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 2 ] = ( ( BYTE * ) ( d ) )[ 5 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 3 ] = ( ( BYTE * ) ( d ) )[ 4 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 4 ] = ( ( BYTE * ) ( d ) )[ 3 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 5 ] = ( ( BYTE * ) ( d ) )[ 2 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 6 ] = ( ( BYTE * ) ( d ) )[ 1 ] ^ ( BYTE ) 0xFF; \
( ( BYTE * ) ( o ) )[ 7 ] = ( ( BYTE * ) ( d ) )[ 0 ] ^ ( BYTE ) 0xFF; \
} } while ( 0 )
# endif
#endif
#define HB_GET_LE_INT16( p ) (( INT16 ) HB_GET_LE_UINT16( p ))
#define HB_GET_LE_INT32( p ) (( INT32 ) HB_GET_LE_UINT32( p ))
#define HB_GET_LE_INT64( p ) (( INT64 ) HB_GET_LE_UINT64( p ))
#define HB_PCODE_MKSHORT( p ) (( SHORT ) HB_GET_LE_INT16( p ))
#define HB_PCODE_MKUSHORT( p ) (( USHORT ) HB_GET_LE_UINT16( p ))
#define HB_PCODE_MKLONG( p ) (( LONG ) HB_GET_LE_INT32( p ))
#define HB_PCODE_MKULONG( p ) (( ULONG ) HB_GET_LE_UINT32( p ))
#define HB_PCODE_MKLONGLONG( p ) (( LONGLONG ) HB_GET_LE_INT64( p ))
#define HB_PCODE_MKULONGLONG( p ) (( ULONGLONG ) HB_GET_LE_UINT64( p ))
#define HB_PCODE_MKDOUBLE( p ) (( double ) HB_GET_LE_DOUBLE( p ))
#define HB_PCODE_MKINT24( p ) (( LONG ) HB_GET_LE_INT24( p ))
#define HB_PCODE_MKUINT24( p ) (( ULONG ) HB_GET_LE_UINT24( p ))
/*
* Below are hacked version of INT64 macros which operates on double
* when INT64 is not supported - they are necessary for PCODE and
* database access
*/
#if defined( HB_LONG_LONG_OFF ) && !defined( HB_ARCH_64BIT )
#undef HB_GET_LE_INT64
#undef HB_GET_LE_UINT64
#undef HB_PUT_LE_UINT64
#undef HB_PCODE_MKLONGLONG
#undef HB_PCODE_MKULONGLONG
#undef HB_DBL_LIM_INT64
#define UINT64_MAXDBL ( (( double ) UINT32_MAX + 1.0) * \
(( double ) UINT32_MAX + 1.0) - 1.0 )
#define HB_GET_LE_INT64( p ) hb_get_le_int64( ( BYTE * ) ( p ) )
#define HB_GET_LE_UINT64( p ) hb_get_le_uint64( ( BYTE * ) ( p ) )
#define HB_PUT_LE_UINT64( p, d ) hb_put_le_uint64( ( BYTE * ) ( p ), \
( double ) ( d ) )
#define HB_PCODE_MKLONGLONG( p ) (( double ) HB_GET_LE_INT64( p ))
#define HB_PCODE_MKULONGLONG( p ) (( double ) HB_GET_LE_UINT64( p ))
#define HB_DBL_LIM_INT64(d) ( (HB_MAXDBL) -UINT64_MAXDBL / 2 - 1 <= \
(HB_MAXDBL) (d) && (HB_MAXDBL) (d) <= \
(HB_MAXDBL) UINT64_MAXDBL / 2 )
#endif
#define HB_MACRO2STRING( macro ) HB_MACRO2STRING_( macro )
#define HB_MACRO2STRING_( macro ) #macro
#define HB_SYMBOL_UNUSED( symbol ) ( void ) symbol
/* ***********************************************************************
* The name of starting procedure
* Note: You have to define it in case when Harbour cannot find the proper
* starting procedure (due to incorrect order of static data initialization)
*
* The list of compilers that require it:
* - Watcom C/C++ 10.0
* - GCC on Linux
*
* By default we are using automatic lookup (symbol not defined)
*/
#if defined(__WATCOMC__) || ( defined(__GNUC__) && !defined(__DJGPP__) && !defined(HARBOUR_GCC_OS2) )
#define HARBOUR_START_PROCEDURE "MAIN"
#endif
#if defined(HB_FUNC_CALLCONV)
#define HARBOUR void HB_FUNC_CALLCONV
#else
#define HARBOUR void
#endif
#if ! defined(__HARBOUR__)
#define __HARBOUR__
#endif
typedef HARBOUR ( * PHB_FUNC )( void );
typedef PHB_FUNC HB_FUNC_PTR;
#if defined( __EXPORT__ )
#if defined( __RSXNT__ )
/* RSXNT does not support any type of export keyword.
Exported (i.e., public) names can be obtained via
the emxexp utility and the output can be used for
input to a module definition file. See emxdev.doc
in the RSXNT doc/ directory for more information. */
#define HB_EXPORT
#elif defined( __GNUC__ ) && defined( HB_OS_WIN_32 )
#define HB_EXPORT __attribute__ (( dllexport ))
#elif defined( __GNUC__ ) && defined( HB_OS_LINUX )
#define HB_EXPORT __attribute__ ((visibility ("default")))
#elif defined( __BORLANDC__ )
#define HB_EXPORT _declspec( dllexport )
#elif defined( __WATCOMC__ )
#define HB_EXPORT __declspec( dllexport )
#elif defined( ASANLM ) || defined( ASANT )
#define HB_EXPORT
#elif defined( WIN32 )
#define HB_EXPORT _declspec( dllexport )
#else
#define HB_EXPORT
#endif
#else
#define HB_EXPORT
#endif
/* Function declaration macros */
/* NOTE: The prefix is "HB_FUN_" currently, this is needed to
avoid collision with any other declared symbol.
Note that "HB_" is not enough, since the Harbour internals
are also prefixed with HB_. [vszakats] */
#define HB_FUNCNAME( funcname ) HB_FUN_##funcname
#define HB_INIT_FUNCNAME( funcname ) HB_FUN_init_##funcname
#define HB_EXIT_FUNCNAME( funcname ) HB_FUN_exit_##funcname
#if ( defined( _MSC_VER ) || defined( __WATCOMC__ ) ) && defined( HB_FUNC_NO_DECORATION )
#define HB_EXTERN_C_ extern "C"
#else
#define HB_EXTERN_C_
#endif
#define HB_FUNC_EXEC( funcname ) HB_FUN_##funcname();
#define HB_FUNC( funcname ) HB_EXTERN_C_ HB_EXPORT HARBOUR HB_FUN_##funcname ( void )
#define HB_FUNC_STATIC( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_##funcname ( void )
#define HB_FUNC_EXTERN( funcname ) HB_EXTERN_C_ extern HARBOUR HB_FUN_##funcname ( void )
#define HB_FUNC_INIT( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_init_##funcname ( void )
#define HB_FUNC_EXIT( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_exit_##funcname ( void )
typedef ULONG HB_HANDLE; /* handle to memvar value */
typedef SHORT HB_SYMBOLSCOPE; /* stores symbol's scope */
typedef BYTE HB_CHAR;
typedef BYTE HB_ATTR;
/* Some common character constants */
#define HB_CHAR_NUL '\0' /* 0 - NUL */
#define HB_CHAR_EOS HB_CHAR_NUL
#define HB_CHAR_BEL '\a' /* 7 - Bell */
#define HB_CHAR_BS '\b' /* 8 - Backspace */
#define HB_CHAR_HT '\t' /* 9 - Tab horizontal */
#define HB_CHAR_LF '\n' /* 10 - Linefeed */
#define HB_CHAR_VT '\v' /* 11 - Tab vertical */
#define HB_CHAR_FF '\f' /* 12 - Formfeed */
#define HB_CHAR_CR '\r' /* 13 - Carriage return */
#define HB_CHAR_EOF '\x1A' /* 26 - End of file marker */
/* Harbour specific character constants */
#define HB_CHAR_HARD1 ( ( char ) HB_CHAR_CR )
#define HB_CHAR_HARD2 ( ( char ) HB_CHAR_LF )
#define HB_CHAR_SOFT1 ( ( char ) 141 )
#define HB_CHAR_SOFT2 ( ( char ) HB_CHAR_LF )
#endif /* HB_DEFS_H_ */