a48321cf39300d34d28811451928063b7c12e8fc
33 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
8e70525b66 |
2009-06-05 06:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbclass.ch
+ extended support for xbase++ compatible method declaration:
[SYNC] METHOD <methodName1>[([<params>])] ;
[ , <methodNameN>[([<params>])] ]
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
* harbour/source/vm/classes.c
+ added alternative support for SYNC method which does not use
sync mutexes. The old method is still present. I'll remove it
when xbase++ users confirm that the new one exactly emulates
xbase++ behavior.
* harbour/source/vm/classes.c
* harbour/source/rtl/tthreadx.prg
* switch to alternative SYNC method implementation which seems to be
xbase++ compatible - please test
! fixed missing thread interrupt in recent modification for ::setInterval
|
||
|
|
016078ef85 |
2009-03-09 00:19 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
* emulate POSIX thread conditional variables in Windows builds.
It should fix some possible bad behavior in MS-Windows Harbour
MT programs.
* harbour/source/rtl/hbinet.c
! fixed typo in HB_INETDATAREADY() - the second parameter (timeout)
was ignored.
* harbour/contrib/examples/uhttpd/uhttpdc.c
* fixed typo in conditional iMsec usage.
* harbour/contrib/examples/uhttpd/uhttpd.prg
* set default timeout for socket operations to 3 sec.
* use timeout parameter in HB_INETDATAREADY() and
increased default timeout for accept to 250 millisecs.
Please correct this modification if you prefer different values.
|
||
|
|
844cf0e16b |
2009-02-18 20:00 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
! added support for conditional variables working like in PTHREADS
in OS2 builds - it fixes the problem with possible dead lock or
starvation effect which can also cause dead lock in some cases.
OS2 users please test current code.
|
||
|
|
a05c032678 |
2009-02-13 11:15 UTC+0100 Maurilio Longo (maurilio.longo@libero.it)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
! fixed a bug on OS/2 MT implementation adding a new function,
_hb_cond_timed_wait() because when a semaphore gets posted it has
to be reset, otherwise it does not stop new threads entering it in a wait.
|
||
|
|
a8598c6299 |
2009-02-04 23:23 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* include/hbwince.h
* include/hb_io.h
* include/hbwmain.c
* include/hbthread.h
* include/hbsetup.h
* include/hbmath.h
* include/hbassert.h
* contrib/gtwvg/gtwvg.c
* contrib/gtwvg/gtwvg.h
* contrib/gtwvg/wvggui.c
* contrib/gtwvg/wvggui.h
* contrib/gtwvg/wvgutils.c
* contrib/hbwin/win_prn2.c
* contrib/hbwin/win_dll.c
* contrib/hbwin/win_prn1.c
* contrib/examples/pp/pp.c
* contrib/examples/pp/hbppcore.c
* source/pp/hbpp.c
* source/vm/fm.c
* source/vm/extrap.c
* source/main/harbour.c
* source/common/hbver.c
* source/common/hbwince.c
* source/rtl/diskspac.c
* source/rtl/hbgtcore.c
* source/rtl/gtclip.c
* source/rtl/gtstd/gtstd.c
* source/rtl/disksphb.c
* source/rtl/gtpca/gtpca.c
* source/rtl/seconds.c
* source/rtl/filebuf.c
* source/rtl/hbproces.c
* source/rtl/gtwvt/gtwvt.h
* source/rtl/gtwvt/gtwvt.c
* source/rtl/fssize.c
* source/rtl/hbinet.c
* source/rtl/gtsys.c
* source/rtl/filesys.c
* HB_WINCE -> HB_OS_WIN_CE.
Now all OS branching #defines are in the HB_OS_* namespace.
Please use the new name from now on.
|
||
|
|
1d13959a7b |
2009-02-04 01:09 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* include/extend.api
* include/hbgtcore.h
* include/hbwince.h
* include/hbthread.h
* include/hbdefs.h
* include/hbsetup.h
* include/hbapi.h
* include/clipdefs.h
* include/hbatomic.h
* contrib/hbmysql/mysql.c
* contrib/hbct/ctnet.c
* contrib/hbct/files.c
* contrib/hbct/dattime3.c
* contrib/hbct/disk.c
* contrib/hbodbc/odbc.c
* contrib/xhb/hboutdbg.c
* contrib/xhb/hbsyslog.c
* contrib/xhb/filestat.c
* contrib/hbmsql/msql.c
* contrib/hbole/ole2.c
* contrib/hbmzip/hbmzip.c
* contrib/hbapollo/apollo.c
* contrib/hbfbird/firebird.c
* contrib/hbnf/descendn.c
* contrib/hbnf/getenvrn.c
* contrib/rddsql/sqlmix.c
* contrib/gtwvg/gtwvg.c
* contrib/gtwvg/wvggui.c
* contrib/gtwvg/wvgwin.c
* contrib/gtwvg/wvgutils.c
* contrib/gtwvg/wvgcore.c
* contrib/rddads/adsx.c
* contrib/rddads/rddads.h
* contrib/rddads/adsmgmnt.c
* contrib/rddads/adsfunc.c
* contrib/rddads/ads1.c
* contrib/hbfimage/fi_winfu.c
* contrib/hbfimage/fi_wrp.c
* contrib/hbgd/gd.ch
* contrib/hbgd/gdwrp.c
* contrib/hbgf/hbgfwin/winapi.c
* contrib/hbtip/utils.c
* contrib/hbtip/ChangeLog
* contrib/hbwin/win_prn2.c
* contrib/hbwin/win_osc.c
* contrib/hbwin/win_misc.c
* contrib/hbwin/win_prt.c
* contrib/hbwin/win_dll.c
* contrib/hbwin/win_ole.c
* contrib/hbwin/win_prn1.c
* contrib/hbwin/win_regc.c
* contrib/hbssl/sslsess.c
* contrib/hbssl/sslrand.c
* contrib/hbwhat/whtdate.c
* contrib/hbwhat/whtini.c
* contrib/hbwhat/whtcret.c
* contrib/hbwhat/whthead.c
* contrib/hbwhat/whtilst.c
* contrib/hbwhat/whtreg.c
* contrib/hbwhat/whtclpb.c
* contrib/hbwhat/whtmous.c
* contrib/hbwhat/whtrgn.c
* contrib/hbwhat/whtmeta.c
* contrib/hbwhat/whttbar.c
* contrib/hbwhat/whtrect.c
* contrib/hbwhat/whtbrsh.c
* contrib/hbwhat/whtgdi.c
* contrib/hbwhat/whtdlg.c
* contrib/hbwhat/whtview.c
* contrib/hbwhat/whtsys.c
* contrib/hbwhat/whtmain.c
* contrib/hbwhat/whtwnd.c
* contrib/hbwhat/whtmmcap.c
* contrib/hbwhat/whtfont.c
* contrib/hbwhat/whtdir.c
* contrib/hbwhat/whtbmp.c
* contrib/hbwhat/whtkbrd.c
* contrib/hbwhat/whtpen.c
* contrib/hbwhat/whttext.c
* contrib/hbwhat/whtdc.c
* contrib/hbwhat/whtdraw.c
* contrib/examples/uhttpd/socket.c
* contrib/examples/uhttpd/uhttpdc.c
* source/vm/mainwin.c
* source/vm/maindll.c
* source/vm/maindllh.c
* source/vm/hvm.c
* source/vm/cmdarg.c
* source/vm/maindllp.c
* source/vm/fm.c
* source/vm/extrap.c
* source/vm/thread.c
* source/vm/dynlibhb.c
* source/vm/set.c
* source/common/hbgete.c
* source/common/hbver.c
* source/common/hbfsapi.c
* source/common/hbwince.c
* source/common/hbdate.c
* source/rtl/diskspac.c
* source/rtl/console.c
* source/rtl/gtwin/gtwin.c
* source/rtl/fserror.c
* source/rtl/hbgtcore.c
* source/rtl/gtclip.c
* source/rtl/fstemp.c
* source/rtl/idle.c
* source/rtl/oemansi.c
* source/rtl/disksphb.c
* source/rtl/net.c
* source/rtl/gtgui/gtgui.c
* source/rtl/seconds.c
* source/rtl/gttone.c
* source/rtl/hbproces.c
* source/rtl/gtkeycod.c
* source/rtl/version.c
* source/rtl/gtwvt/gtwvt.c
* source/rtl/hbrandom.c
* source/rtl/hbinet.c
* source/rtl/hbffind.c
* source/rtl/gtsys.c
* source/rtl/filesys.c
* source/rtl/gtkbstat.c
* source/rtl/isprint.c
* source/compiler/cmdcheck.c
* utils/hbmake/hbmlang.c
* #defines renamed to be bitwidth-independent.
- HB_OS_WIN_32_USED -> HB_OS_WIN_USED
- HB_OS_WIN_32 -> HB_OS_WIN
; Please modify your code accordingly.
* include/hbdefs.h
* include/hbsetup.h
+ Added compatibility to still understand HB_OS_WIN_32_USED,
and to #define HB_OS_WIN_32 in addition to HB_OS_WIN.
This means that old code will still work, but these
compatibility features will be removed in the future,
so it's recommended to change the code as above.
|
||
|
|
79fd663a78 |
2009-02-03 00:55 UTC+0100 Maurilio Longo (maurilio.longo@libero.it)
* include/hbdefs.h
* include/hbthread.h
* added HB_OS_SUNOS to be able to build under OpenSolaris 2008.11
using pthreads.
* source/common/hbprintf.c
* include ieeefp.h under OpenSolaris 2008.11
|
||
|
|
fa31aa6f70 |
2008-12-11 19:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
+ added hb_atomic_set(), hb_atomic_get(), hb_atomic_inc() and
hb_atomic_dec() functions which operates on HB_COUNTER or smaller
type if it's necessary for some platforms which can be access/assign
increment/decrement in MT safe atom operations.
hb_atomic_dec() returns true if counter is 0 after decrementation
* harbour/include/hbatomic.h
! fixed compilation in Linux and OpenWatcom
* harbour/include/hbapiitm.h
* harbour/source/rtl/itemseri.c
+ make hb_itemSerialize() and hb_itemDeserialize() public functions
! fixed serialization items with internal item references
* harbour/source/vm/hvm.c
* release memvars after closing RDDs
* harbour/source/debug/dbgentry.c
! fixed buffer overflow reported by Rodrigo
* harbour/source/vm/macro.c
* harbour/source/compiler/hbmain.c
* formatting
* harbour/include/hbexprb.c
! fixed wrongly recognized functions with HB_I18N_ prefix as
HB_I18N_GETTEXT()
* harbour/include/hbapi.h
* harbour/include/hbstack.h
* harbour/include/hbthread.h
* harbour/source/vm/estack.c
* harbour/source/vm/thread.c
* harbour/source/vm/hvm.c
+ added support for I18N in HVM.
Each thread can have it's own i18n set.
When new thread is created then it inherits i18n set from parent
thread and both uses the same set (please remember about it if you
will want to make some direct modifications on active i18n set
internals).
When thread change active i18n set then it effects only this thread
and new threads which will be create later. It does not change i18n
in other existing threads.
+ added functions to set/get pointer to active i18n set in HVM
void * hb_vmI18N( void )
void hb_vmSetI18N( void * )
* harbour/include/hbapi.h
* harbour/source/rtl/hbi18n.c
+ added i18n module. Now only for internal Harbour usage without support
for optional switching to alternative implementations.
I'll add such functionality later when I will work on native gettext
support.
The following public .prg functions has been added:
HB_I18N_GETTEXT[_STRICT]( <cMsgID> [, <cContext> ] )
-> <cTranslatedMsgID> | <cMsgID>
HB_I18N_NGETTEXT[_STRICT]( <nValue>, <cMsgID> | <acMsgID> ;
[, <cContext> ] )
-> <cTranslatedMsgID> | <cMsgID> | <acMsgID>[ <nIndex> ]
This is minimal support necessary for .prg code which has to exists
in each i18n module working with Harbour.
The following functions had been added as public C API:
PHB_ITEM hb_i18n_gettext( PHB_ITEM pMsgID, PHB_ITEM pContext )
PHB_ITEM hb_i18n_ngettext( PHB_ITEM pNum,
PHB_ITEM pMsgID, PHB_ITEM pContext )
The following functions had been added as private HVM C API:
void hb_i18n_init( void )
void hb_i18n_exit( void )
void hb_i18n_release( void * cargo )
void * hb_i18n_alloc( void * cargo )
They have to be supported by alternative i18n modules
The following functions has been added to manage Harbour i18n
translations sets:
HB_I18N_CREATE()
-> <pI18N>
Creates new empty I18N translation set
HB_I18N_CODEPAGE( [<pI18N>,] [<cNewCP>], [<lBase>], [<lTranslate>] )
-> <cOldCP>
Gets or sets Harbour codepage used by translation set
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewCP> - new CP ID. Must be linked with application
<lBase> - when it's .T. then get/set base massages CP instead of
translated massages CP
<lTranslate> - if it's .T. then translate base (<lBase>==.T.) or
final messages in I18N set from previous CP to
given one. Base messages translation in synced
with context ID translation.
HB_I18N_PLURALFORM( [<pI18N>,] [<cNewForm>|<bNewForm>], [<lBase>] )
-> <cOldForm>|<bOldForm>
Gets or sets plural form used for final or base messages
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewForm> - language ID of plural form, f.e.: "EN", "PL", "LT".
Now only three above are supported. Please add rules
for other languages to source/rtl/hbi18n.c.
<bNewForm> - codeblock used to calculate plural form indexes.
can be used instead of character representation but
it's not storred in serialized I18N set
<lBase> - when it's .T. then get/set base massages plural form
instead of translated massages one.
HB_I18N_DESCRIPTION( [<pI18N>,] [<cNewDescription>] )
-> <cOldDescription>
Gets or sets translation set description. After serialization
up to 32 bytes is stored in header which can be easy used to
determinate type of translation file.
<pI18N> - I18N translation set,
if it's not given then currently active I18N set is used
<cNewDescription> - new description
HB_I18N_ADDTEXT( <pI18N>, <cMsgID>, <cTrans> | <acTrans> [, <cContext> ] )
-> NIL
Adds new message with translation to i18n translation set
<pI18N> - I18N translation set
<cMsgID> - original message
<cTrans> - translated message
<acTrans> - array with translated messages used for plural forms
<cContext> - message context
HB_I18N_SET( [ <pI18N> | NIL ] )
-> <lActive>
Sets given I18N translation set as default one used by
HB_I18N_[N]GETTEXT[_STRICT]() functions or remove translation
set for calling thread when passed parameter is NIL
<pI18N> - I18N translation set
Returns logical value which is .T. when i18n set is active
HB_I18N_SAVETABLE( [<pI18N>] )
-> <cTable>
Returns I18N translation as string item which can be stored
in file or database
<pI18N> - I18N translation set, if it's not given then currently
active I18N set is used
HB_I18N_RESTORETABLE( <cTable> )
-> <pI18N> | NIL
Restores I18N translation set from strin item.
<cTable> - I18N translation set in string representation
On success it returns new <pI18N> set otherwise NIL if <cTable>
is not valid item created by HB_I18N_SAVETABLE() or it's corrupted.
HB_I18N_HEADERSIZE()
-> <nHeaderSize>
Returns size of header used by i18n serialized version
HB_I18N_CHEK( <cTable> | <cHeader> [, @<cDescription> ] )
-> <lValid>
<cTable> - i18n translation set serialized by HB_I18N_SAVETABLE
<cHeader> - header of i18n translation set
( LEFT( <cTable>, HB_I18N_HEADERSIZE() )
<cDescription> - optional parameter passed by reference where
will be sored i18n translation set description
extracted from valid header
Returns logical value indicating if given table or header is
valid serialized by HB_I18N_SAVETABLE() data. It does not
decode the table though it validates size and control sums.
These functions are optional and some future alternative implementations
may not support all of them and/or may provide some other functions.
+ added unofficial .prg function __I18N_HASHTABLE() which allows to
access hash table used by i18n translation set or create new translation
set with given hash table. It's helper functions for developers which
will work on Harbour i18n tools and should not be used by Harbour users.
Unlike original gettext Harbour allows to use language with many
plural forms as base one. In such case programmer should activate
at application startup default i18n translation set with base plural
form valid for base application language, f.e. by:
pI18N := hb_i18n_create()
hb_i18n_pluralForm( pI18N, <cLangID> | <bForm>, .t. )
hb_i18n_set( pI18N )
.prg code example:
#xtranslate _( <x,...> ) => hb_i18n_gettext_strict( <x> )
#xtranslate _N( <x,...> ) => hb_i18n_ngettext_strict( <x> )
proc main()
local pI18N, i
pI18N := hb_i18n_create()
hb_i18n_pluralForm( pI18N, "PL", .t. )
hb_i18n_set( pI18N )
for i := 0 to 30
? i, _N( i, {"grosz", "grosze", "groszy"} )
if i > 0 .and. i % 10 == 0
wait
endif
next
return
In .pot files created during compilation by Harbour with -j option
for above code we have the following entries for message with plural
forms:
msgid "grosz"
msgid_plural "grosze"
msgid_plural2 "groszy"
msgstr[0] ""
The msgid_plural2 (and others if language has more plural forms)
is Harbour extension which is not gettext compatible.
The above implementation is base version but should be fully functional.
Now we will need functions to safe/read i18n files and tools to mange
.pot files: merge them, edit translations, create final binary i18n
translation sets. Because we are using gettext compatible .pot files
then for some of such jobs we can use original gettext tools but we
need at least function which will create translation set from one or
more .pot files.
We should also agree some default localization(s) for files containing
translated data, their name convention and environment variable(s)
to set default language. It's not strictly necessary and each user
can have his own implementation but it would help in adding new
translations by final users to any Harbour application which will
respect them. We can use LANG envvar to extract preferred language
and use the same path as executed application looking for files
<appname>-<lang>.hil files though it may create some problems for
OSes which support only 8.3 file names so we can also define that
HB_I18N envvar has higher priority and points to expected translation
file.
* harbour/include/hbextern.ch
- removed old __i18n_*() functions
+ added current i18n functions
|
||
|
|
0142b12622 |
2008-11-04 01:04 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
! fixed typo
* harbour/source/vm/Makefile
* excluded mainpm.c from OS2 builds
* harbour/source/rtl/hbinet.c
* changed the #include order for OS2 OpenWatcom builds and added some
cleanups - please test other builds.
|
||
|
|
cbfce0fc00 |
2008-11-03 17:49 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* include <process.h> in OpenWatcom OS2 builds
|
||
|
|
3fba5f0231 |
2008-11-03 14:08 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
+ added ULONG _hb_gettid( void ) to OS2 builds - thanks to Maurilio
* harbour/source/rtl/hbinet.c
* changed a little bit the order of including header files in OS2 builds
(blink fix for OpenWatcom OS2 builds).
|
||
|
|
520a0a0206 |
2008-10-22 05:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbstack.h
* harbour/include/hbgtcore.h
* harbour/include/hbthread.h
* harbour/include/hbapigt.h
* harbour/source/vm/estack.c
* harbour/source/vm/hvm.c
* harbour/source/vm/thread.c
* harbour/source/rtl/hbgtcore.c
+ added support for optional allocating independent console window by
each thread. By default new thread inherits console Window from
parent thread. But each thread can allocate its own console window
by calling hb_gtReload( <cGtName> ) function, f.e. by:
hb_gtReload( hb_gtVersion() )
If GT driver supports such functionality then new it will allocate
new console windows.
Each console window has reference counter which is increased when
new thread starts and decreased when hb_gtReload() is executed or
thread terminates. When counter reach zero give console window is
destroyed.
* harbour/source/rtl/gtwvt/gtwvt.c
! use SendNotifyMessage() instead of SendMessage() to not block
threads which inherited GT from parent thread. Why non of MS-Win
users reported this problem?
+ added reference counter to window class for multi GT support
+ harbour/tests/mt/mttest10.prg
+ added demonstration/test code for using independent console window
in different threads. It needs GT driver which supports such
functionality, f.e GTXWC in *nixes or GTWVT in MS-Windows
* harbour/tests/mt/mttest09.prg
! fixed typo in comment
|
||
|
|
7d8c51e71a |
2008-10-13 18:01 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/vm/thread.c
+ added small description for hb_threadOnce() .prg function
* harbour/include/hbthread.h
! do not set TLS in POCC and XCC builds when _MSC_VER macro is set
This compilers also have this macro but dllspec( thread) does
not work for them (at least in version 4.50.15)
* harbour/utils/hbtest/rt_hvm.prg
+ added few tests which exploit by DMC bug. Be careful with
this compiler. In some cases it gives buggy final code, f.e.
try this:
#include <stdio.h>
typedef struct
{
double dd;
long long int ll;
} UN;
const char * cmp( UN * pU )
{
return pU->dd >= pU->ll ? "OK" : "ERRROR";
}
int main( void )
{
UN u = { 10.50, 10 };
printf( "%s\n", cmp( &u ) );
return 0;
}
The same bug can be exploited also by final Harbour binaries
compiled by DMC in code like:
? iif( 10.50 >= 10, "OK", "ERROR" )
I used DMC 8.42n. As long as such things will not be fixed by
DMC developers this compiler is not supported by Harbour and
reported problems with DMC Harbour builds will have to be
ignored by us.
|
||
|
|
5d69653985 |
2008-10-12 13:19 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* casting cleanup
* harbour/include/hbapigt.h
* harbour/source/rtl/gtapi.c
* harbour/source/rtl/scroll.c
* harbour/source/rtl/console.c
* harbour/source/rtl/box.c
* changed hb_gtDrawBox() and hb_gtPutText() to operate on color
number (index in some GTs) instead of color string
* use int as color number (index) in hb_gtScrollEx() hb_gtBoxEx()
* harbour/source/rtl/box.c
% changed DISPBOX() with color and frame string to work as one
GT atomic operation
* harbour/source/vm/classes.c
! fixed profiler usage
|
||
|
|
a9ed741e26 |
2008-10-09 00:17 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbtypes.h
* harbour/source/vm/maindllp.c
! updated casting for current SVN code
[TOMERGE 1.0]
* harbour/include/hbthread.h
* harbour/source/vm/hvm.c
* harbour/source/vm/thread.c
+ added .prg function
hb_threadWait( <pThID> | <apThID>, [ <nTimeOut> ] [, <lAll> ] )
=> <nThInd> | <nThCount> | 0
This function wait for <nTimeOut> seconds (default infinite wait)
until one or all (controlled by <lAll> parameter) of given HVM threads
will have finished execution in HVM area. It does not join the threads.
It returns index to 1-st thread which has finished execution (default)
or number of threads which has finished in given time period when lAll
is .T.
|
||
|
|
e1ea6f3cec |
2008-10-07 02:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/Makefile
+ harbour/include/hbatomic.h
* harbour/include/hbthread.h
* harbour/source/vm/garbage.c
* harbour/source/vm/fm.c
* moved atomic and spinlock functions into hbatomic.h
* harbour/include/hbatomic.h
+ added atomic inc/dec for GCC and x86@64 and PPC@32
+ use OSAtomic*() and OSSpin*() functions for atomic inc/dec and
spinlocks in Darwin builds
+ added spinlocks to MS-Win builds
|
||
|
|
3f2735f5e6 |
2008-10-06 22:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbthread.h
! Committed MT fix to make it compile under Darwin.
Thanks Przemek.
|
||
|
|
67cc2f7ebe |
2008-10-06 15:30 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
* harbour/source/vm/hvm.c
+ add numeric HVM thread identifiers to thread structure. Now
HB_THREADID() returns numbers in all OSes
* harbour/include/hbexprop.h
* harbour/include/hbexprb.c
* harbour/source/common/expropt2.c
+ added compile time optimization for MIN() and MAX() functions
* harbour/source/rtl/minmax.c
* removed trailing spaces from source code
|
||
|
|
0316d44e12 |
2008-10-06 00:28 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbthread.h
! Blind fix for WinCE compilation after MT changes.
|
||
|
|
cce3e73961 |
2008-09-29 11:18 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbvm.h
* harbour/include/hbthread.h
* harbour/source/vm/hvm.c
* harbour/source/vm/thread.c
+ added hb_vmThreadRegister() funtion which allows to register new
thread in HVM without HVM stack allocation
+ added hb_vmThreadRelease() which removes registered thread which
does not have allocated HVM stack yet
+ added hb_threadStateNew() which returns new thread control state
which can be used as parameter to hb_vmThreadInit(),
hb_vmThreadRegister(), hb_vmThreadRelease()
* register thread control state also for main thread
Now hb_threadSelf() returns thread pointer also for main thread
! fixed possible race condition in hb_threadWaitForAll() and
hb_threadTerminateAll() by using hb_vmThreadRegister() before
starting thread.
* harbour/source/rtl/idle.c
* interrupt hb_idleSleep() on QUIT or BREAK requests
* harbour/tests/mt/mttest09.prg
* small cleanup
|
||
|
|
26c2a6fd7e |
2008-09-27 09:15 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbthread.h
% Disabled HB_USE_TLS for __BORLAND__ and __MINGW32__ for
best performance.
* contrib/hbwhat/whtmmcap.c
! Fixed some warnings under certain MinGW 4.3.2
installations.
TODO: hbwhat users pls finish this fix.
* utils/hbmake/hbmake.prg
! Fixed hbw32 to hbwin.
* Win32 references changed to Windows.
* make_gcc.sh
* Not accepting CFLAGS anymore as custom C flags envvar.
Pls use C_USR instead.
* make_gcc.mak
+ Added wsock32 lib to Cygwin system liblist.
! Removed setting HB_OS_* macros explicitly.
* make_b32.mak
* make_vc.mak
* Minor formatting.
|
||
|
|
0bc59418eb |
2008-09-25 13:07 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbthread.h
+ Enabled HB_USE_TLS for MinGW >= 4.3.0
|
||
|
|
a1a7c1cb07 | Fix to prev | ||
|
|
e7fdff1641 |
2008-09-23 11:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbthread.h
% Enabled TLS for _MSC_VER compilers.
; Tested with MSVS 2008 32-bit. Someone pls test with
older/other MSVC compilers (especially MSVC6 and WinCE mode)
to refine the default setting if needed.
|
||
|
|
c1c574142e |
2008-09-21 23:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/source/vm/arrays.c
+ added hb_arrayGetPtrGC(), hb_arrayGetSymbol(), hb_arraySetSymbol()
* harbour/include/hbapi.h
* harbour/source/vm/dynsym.c
+ added hb_dynsymProtectEval(). Works like hb_dynsymEval() but
keeps dynamic symbol table locked during whole execution.
It's faster then hb_dynsymEval() but user function may not
access dynamic symbol tbale to not cause recursive locks
+ added protection against possible dynamic symbol table resizing
during hb_dynsymEval() by other threads.
* harbour/include/hbapi.h
* harbour/source/vm/memvars.c
+ added hb_memvarSaveInArray( int iScope, BOOL fCopy ) and
hb_memvarRestoreFromArray( PHB_ITEM pArray )
% use hb_dynsymProtectEval() in places where it's safe
* harbour/include/Makefile
+ harbour/include/hbthread.ch
+ added header file with thread constant definitions:
HB_THREAD_INHERIT_PUBLIC
HB_THREAD_INHERIT_PRIVATE
HB_THREAD_INHERIT_MEMVARS
HB_THREAD_MEMVARS_COPY
* harbour/include/hbthread.h
* harbour/source/vm/hvm.c
* harbour/source/vm/thread.c
+ added support for inheriting visible memvars from current
thread when new thread is created. Memvars in child thread
can be shared with parrent or they can be copied. See HB_THREAD_*
attributes defined in hbthread.ch, f.e.:
hb_threadStart( HB_THREAD_INHERIT_PUBLIC, @thFunc() )
or:
hb_threadStart( HB_BITOR( HB_THREAD_INHERIT_MEMVARS + ;
HB_THREAD_MEMVARS_COPY ), ;
@thFunc() )
Please note that when child thread creates new PUBLIC variable
which didn't existed when thread was started then it's visible
only for this thread and optionally for its child threads but
not for parent thread.
Please also remember that write access to shared memvars have
to be protected by users.
+ harbour/tests/mt/mttest08.prg
+ added test code for thread memvars inheritance
|
||
|
|
7cc11cf5e2 |
2008-09-19 22:27 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/vm/set.c
! fixed casting
* harbour/contrib/xhb/xhbcopyf.c
* replaced TABs with SPACEs
* harbour/include/hbapirdd.h
* harbour/source/rdd/workarea.c
* harbour/source/rdd/wacore.c
* harbour/source/rdd/wafunc.c
+ added support for detaching and attaching workareas
* harbour/source/vm/hvm.c
% minor cleanup in thread return code
* harbour/include/hbthread.h
* harbour/source/vm/thread.c
* unlock HVM stack during thread join operation
* added workaround for DosWaitThread() which seems to fail if thread
terminated before
; added TOFIX note for OS2 and join code
|
||
|
|
86333ba271 |
2008-09-18 07:21 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* use assembler version of atomic inc/dec operation in all x86 based
GCC builds - it should noticeable improve OS2 MT build speed,
please test.
* harbour/include/hbcomp.h
* harbour/include/hbapicdp.h
* harbour/include/hbcompdf.h
* harbour/include/hbgtcore.h
* harbour/include/hbapifs.h
* harbour/include/hbwince.h
* harbour/include/hbexpra.c
* harbour/include/hbexprop.h
* harbour/include/hbmacro.h
* harbour/include/hbapigt.h
* harbour/include/hbapi.h
* harbour/include/hbapiitm.h
* harbour/include/hbexprb.c
* harbour/source/pp/ppcore.c
* harbour/source/pp/hbpp.c
* harbour/source/vm/macro.c
* harbour/source/vm/cmdarg.c
* harbour/source/vm/arrays.c
* harbour/source/vm/extrap.c
* harbour/source/vm/memvars.c
* harbour/source/vm/eval.c
* harbour/source/vm/extend.c
* harbour/source/vm/set.c
* harbour/source/main/harbour.c
* harbour/source/common/hbfsapi.c
* harbour/source/common/reserved.c
* harbour/source/common/expropt1.c
* harbour/source/macro/macro.yyc
* harbour/source/macro/macro.y
* harbour/source/macro/macro.yyh
* harbour/source/macro/macrolex.c
* harbour/source/rtl/gtdos/gtdos.c
* harbour/source/rtl/gtwin/gtwin.c
* harbour/source/rtl/gtxwc/gtxwc.c
* harbour/source/rtl/gtos2/gtos2.c
* harbour/source/rtl/hbgtcore.c
* harbour/source/rtl/cdpapi.c
* harbour/source/rtl/gtcrs/gtcrs.c
* harbour/source/rtl/hbtoken.c
* harbour/source/rtl/gtchrmap.c
* harbour/source/rtl/gtstd/gtstd.c
* harbour/source/rtl/gtsln/mousesln.c
* harbour/source/rtl/gtsln/gtsln.c
* harbour/source/rtl/gtsln/kbsln.c
* harbour/source/rtl/gttrm/gttrm.c
* harbour/source/rtl/gtpca/gtpca.c
* harbour/source/rtl/hbhex.c
* harbour/source/rtl/gtgui/gtgui.c
* harbour/source/rtl/gt_tpl/gt_tpl.c
* harbour/source/rtl/gtcgi/gtcgi.c
* harbour/source/rtl/gtwvt/gtwvt.c
* harbour/source/rtl/strtran.c
* harbour/source/rtl/hbinet.c
* harbour/source/rtl/gtapi.c
* harbour/source/rtl/filesys.c
* harbour/source/rdd/dbfntx/dbfntx1.c
* harbour/source/rdd/dbsql.c
* harbour/source/rdd/dbfcdx/dbfcdx1.c
* harbour/source/rdd/dbffpt/dbffpt1.c
* harbour/source/rdd/hbsix/sxfname.c
* harbour/source/compiler/ppcomp.c
* harbour/source/compiler/hbmain.c
* harbour/source/compiler/cmdcheck.c
* harbour/source/compiler/hbdbginf.c
* harbour/source/compiler/genc.c
* harbour/source/compiler/hbident.c
* harbour/source/compiler/hbusage.c
* harbour/source/compiler/gencc.c
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.y
* harbour/contrib/gtalleg/gtalleg.c
* harbour/contrib/hbct/charlist.c
* harbour/contrib/hbct/charmix.c
* harbour/contrib/hbct/screen1.c
* harbour/contrib/hbct/atrepl.c
* harbour/contrib/xhb/hboutdbg.c
* harbour/contrib/xhb/hbxml.c
* harbour/contrib/xhb/hbxml.h
* harbour/contrib/hbgt/strexpan.c
* harbour/contrib/hbsqlit3/sqlite3/sqlite3.c
* harbour/contrib/gtwvg/gtwvg.c
* harbour/contrib/hbclipsm/status.c
* harbour/contrib/hbclipsm/gauge.c
* harbour/contrib/hbmisc/stringsx.c
* harbour/contrib/hbtip/utils.c
* harbour/contrib/hbgf/hbgfgtk/msginfo.c
* harbour/contrib/hbgf/hbgfgtk/harbgtk.h
* harbour/contrib/hbbmcdx/bmdbfcdx.c
* harbour/utils/hbmake/hbmgauge.c
* use const char * instead of char * in places which should be marked
as const
|
||
|
|
ab02c791d5 |
2008-09-17 18:38 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
+ added macros to disable default native compiler TLS support:
HB_NO_TLS
* harbour/source/vm/set.c
! fixed GPF when set listeners were removed
|
||
|
|
ca5637d31c |
2008-09-16 15:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
* do not use native TLS support in BCC builds when CodeGuard
is enabled
|
||
|
|
61647d6776 |
2008-09-16 14:49 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
+ added DMC to list of compilers which can use __declspec( thread )
+ automatically use TLS for Linux and GLIBC >= 2.6 on x86* machines
* harbour/include/hbthread.h
* harbour/source/vm/estack.c
* harbour/source/vm/thread.c
! clean up typos in OS2 builds
|
||
|
|
04523710aa |
2008-09-15 23:08 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
+ harbour/tests/memtst.prg
+ added some simple tests for memory manager
* harbour/tests/speedtst.prg
* reduced the size of allocated block size to not test C-RTL
memory manager but HVM speed
* harbour/include/hbthread.h
* added for x86@32 PTHREADS builds HB_ATOM_GET() and HB_ATOM_SET()
so they can be used together with HB_ATOM_INC()/HB_ATOM_DEC()
also for x86@64 but with reduced to 32bit reference counter.
|
||
|
|
36ed679f92 |
2008-09-15 17:53 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbthread.h
+ added assembler MT version of HB_ATOM_INC/HB_ATOM_DEC operation
for x86@32
* harbour/source/vm/fm.c
! removed #undef HB_ATOM_INC/HB_ATOM_DEC I left by mistake
|
||
|
|
64f97582d9 |
2008-09-13 18:49 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbpp.h
* harbour/include/hbvm.h
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/include/hbtrace.h
* harbour/include/hbapilng.h
* harbour/include/hbinit.h
* harbour/source/rtl/langapi.c
* harbour/source/pp/ppcore.c
* harbour/source/pp/hbpp.c
* harbour/source/vm/itemapi.c
* harbour/source/vm/hvm.c
* harbour/source/common/hbver.c
* harbour/source/common/hbtrace.c
* harbour/source/common/expropt2.c
* harbour/source/compiler/complex.c
* harbour/source/compiler/hbident.c
* harbour/source/compiler/hbfunchk.c
* changed some declarations from 'char *' to 'const char *' and
fixed casting for some more pedantic compilers
* harbour/source/pp/ppcore.c
! fixed one typo which could cause memory leak and even GPF
* harbour/common.mak
* harbour/source/vm/Makefile
* harbour/source/rtl/Makefile
- harbour/source/rtl/set.c
+ harbour/source/vm/set.c
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* moved from RTL to HVM
* eliminated hb_set global structure
* moved set structure to HVM stack
+ added internal function hb_setClone() which is used to create
copy of SET structure for child threads
* hidden HB_SET_STRUCT declaration - 3-rd part code must not access it
directly. Dedicated hb_set*() functions should be used instead.
+ added new function:
BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem )
which allow to change some set by 3-rd party code.
TODO: not all SETs can be changed yet - if someone have a while
then please add code for missing ones.
* harbour/include/set.ch
* harbour/include/hbset.h
+ added _SET_CODEPAGE which works like _SET_LANGUAGE giving common
interface
* harbour/include/hbsetup.h
+ added HB_CODEPAGE_DEFAULT which works like HB_LANG_DEFAULT
* harbour/source/vm/hvm.c
! fixed builds which uses non EN lang or code page modules
by forcing linking the chosen ones
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* harbour/include/hbapicdp.h
* harbour/source/rtl/cdpapi.c
- removed global code page variable: hb_cdp_page and moved
code page settings to HVM stack
+ added new function hb_cdpID() which returns current code page
character ID
+ added new functions hb_vmCDP() and hb_vmSetCDP() to get/set
active for given thread code page structure
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* harbour/include/hbapilng.h
* harbour/source/rtl/langapi.c
+ moved lang setting to HVM stack
+ added new functions hb_vmLang() and hb_vmSetLang() to get/set
active for given thread language module
* harbour/include/hbvmpub.h
* harbour/include/hbstack.h
* harbour/include/hbapi.h
* harbour/source/vm/estack.c
* harbour/source/vm/dynsym.c
* harbour/source/vm/itemapi.c
* harbour/source/vm/memvars.c
* changed memvar handles for HB_HANDLE to void * which is directly
casted to PHB_ITEM - new memvar references
* changed HB_DYNS declarations for MT mode. In MT mode HB_DYNS does
not contain area and memvar handles which are moved to thread
local HVM stack
+ added array for thread local memvar and area handles to HVM stack
% eliminated global continues array with all memvars and detached locals
% changed HB_IT_MEMVAR to use pointers to HB_ITEM directly - it resolve
synchronization problems in MT mode and should also improve the speed
and reduce memory usage. It should be well visible in applications which
uses lot of detached locals.
- removed hb_memvarsInit() and hb_memvarsFree() - they are not necessary
now because we do not longer use array with all allocated memvars
and detached local and private stack initialization is made
automatically
+ added internal functions hb_dynsymGetMemvar()/hb_dynsymSetMemvar()
+ added hb_memvarGetValueBySym() for debugger
* moved PRIVATE variable stack to HVM stack
* eliminated all static variables in memvars module
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* harbour/source/rtl/fserror.c
* moved IO errors to HVM stack
+ added special IO error handling which works without HVM stack
It allows to use hb_fs*() functions without allocated stack
by 3-rd party threads.
* harbour/source/rtl/filesys.c
* moved hb_fsCurDir() to HVM stack with special handling to work
with HVM stack like IO errors
* harbour/source/rdd/workarea.c
* allocated RDD node array in bigger peaces to reduce later RT
reallocations in MT mode. If user want to add dynamically more
then 64 RDDs then it should synchronize this operation himself.
* harbour/source/rdd/wacore.c
* moved WA list, current WA, default RDD and neteer() flag to HVM stack
* harbour/include/hbdefs.h
- removed HB_HANDLE declaration
* harbour/include/hbapi.h
- removed HB_VALUE structure - it's not longer used due to different
memvar handling
* updated hb_struMemvar to new memvar handling
* replaced hb_vmIsLocalRef() and hb_memvarsIsMemvarRef() with
hb_vmIsStackRef() which respect multiple stack and new memvar
and static structures and location in GC mark pass.
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* harbour/source/vm/hvm.c
+ added support for thread specific data located on HVM stack
Now it's possible to allocate static variables which are
local to thread. Such variables are allocated on HVM stack
and automatically destroyed. To declare new TSD variable use:
HB_TSD_NEW( <name>, <size>, <init>, <destruct> )
<name> - name of variable which holds TSD handler
<size> - size of TSD are which has to be allocated
<init> - init function, executed when new TSD is allocated by thread
(thread access given TSD 1-st time). This function receives
void * pointer to allocated area.
<destruct> - destructor function executed when HVM stack is destroyed
f.e.:
static HB_TSD_NEW( s_scrData, sizeof( HB_SCRDATA ),
NULL, hb_xSaveRestRelease );
To initialize dynamically allocated TSD variable use:
HB_TSD_INIT( <name>, <size>, <init>, <destruct> )
Pointer to TSD can be accessed using hb_stackGetTSD( &<name> )
where <name> is name of variable which holds TSD handler, f.e.:
PHB_SCRDATA pScrData = ( PHB_SCRDATA ) hb_stackGetTSD( &s_scrData );
See source/rtl/xsavescr.c as an example
It's also possible to test if data has been already allocated for
current thread by:
hb_stackTestTSD( &<name> ) => pData
it works like hb_stackGetTSD() but return NULL if current thread data
has not been allocated yet.
* harbour/include/hbstack.h
* harbour/source/vm/estack.c
* changed hb_stack location to thread local storage in MT mode
+ added functions and macros to access/assign new HVM stack members
+ changed garbage collection mark functions to work with multiple
stacks, thread local static and memvar variables
* harbour/source/rtl/xsavescr.c
* use TSD data for screen buffer to make __XSAVESCREEN()/__XRESTSCREEN()
thread independent
* harbour/source/rtl/idle.c
* use TSD data for idle task settings and codeblocks
- removed hb_idleShutDown() - it's not longer necessary
* harbour/source/rtl/setkey.c
* use TSD data for allocated keys to make SETKEY() thread independent
* harbour/source/rtl/math.c
* moved math error handler, math error block, math error mode and
math error structure to TSD
* harbour/source/rtl/errorapi.c
* moved error handler, error block, error launch counter and DOS error
value to TSD
* harbour/source/rtl/inkey.c
* moved inkey "before" and "after" blocks to TSD
* harbour/source/rdd/hsx/hsx.c
* moved HSX handles array to TSD
* harbour/include/hbapigt.h
* harbour/source/rtl/console.c
- removed hb_setkeyInit() and hb_setkeyExit() - they are not longer
necessary, allocated resources will be freed by TSD destructor
function
* harbour/include/hbapi.h
* harbour/source/rtl/console.c
* removed hb_conXSaveRestRelease() - it's not longer necessary,
allocated resources will be freed by TSD destructor function
* harbour/source/vm/macro.c
* moved s_macroFlags to TSD
* harbour/source/rtl/accept.c
* moved accept buffer to TSD
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h
* harbour/include/hbxvm.h
* harbour/source/compiler/hbmain.c
* harbour/source/compiler/hbfix.c
* harbour/source/compiler/hbpcode.c
* harbour/source/compiler/hbdead.c
* harbour/source/compiler/complex.c
* harbour/source/compiler/genc.c
* harbour/source/compiler/gencc.c
* harbour/source/compiler/hbopt.c
* harbour/source/compiler/hblbl.c
* harbour/source/compiler/hbstripl.c
* harbour/source/compiler/harbour.y
* harbour/source/compiler/harbour.yyc
* harbour/source/compiler/harbour.yyh
* harbour/source/vm/hvm.c
+ added new PCODE HB_P_THREADSTATICS
+ added support for static variables which are local to thread:
THREAD STATIC <varname [:= <exp>], ...>
They work like normal static variables but each thread operates
on its own copy.
* added protection against possible double call to hb_xfree()
It can happen due to wrong marking expressions as used by bison
and executing destructors after our free code when syntax error
appear.
* harbour/source/rtl/perfuncs.prg
* harbour/source/rtl/menuto.prg
* harbour/source/rtl/getlist.prg
* harbour/source/rtl/readvar.prg
* harbour/source/rtl/text.prg
* use THREAD STATIC variables to make above code MT safe
* harbour/include/hbgtcore.h
* harbour/source/rtl/hbgtcore.c
+ added hb_gt_BaseFree() which will release current GT pointer
locked by hb_gt_Base() function. This function will be used
to optional automatic GT access synchronization when threads
share the same GT.
* harbour/source/rtl/gtapi.c
* harbour/source/rtl/inkeyapi.c
* harbour/source/rtl/mouseapi.c
* harbour/contrib/hbct/ctwin.c
* free GT pointer by hb_gt_BaseFree()
TODO: CTWIN is not MT safe yet - it will be updated together
with core GT when we add multi window interface for
thread with own console window.
* harbour/bin/hb-func.sh
* harbour/config/linux/gcc.cf
+ added rt lib to Linux builds
* harbour/bin/postinst.sh
* create MT safe version of FM stat library: fmmt
* harbour/bin/pack_src.sh
+ added support for ZIP packing
* harbour/include/hbapi.h
* harbour/include/hbvm.h
* harbour/source/vm/hvm.c
+ added hb_vmThreadInit()/hb_vmThreadQuit() functions - they initialize
HVM for calling thread so it can execute .prg code and call HVM
functions. They can be used by 3-rd party code threads.
+ added hb_vmUnlock()/hb_vmLock() functions which informs that
thread will not operate on HVM structures for some time allowing
to execute single thread only processes like GC.
+ added hb_vmThreadQuitRequest() which sends stop request to given
thread
+ added hb_vmWaitForThreads() which stops main thread execution waiting
for other threads
+ added hb_vmSuspendThreads() and hb_vmResumeThreads() used be GC
to stop all HVM threads before mark/swap scan
+ added linked list of HVM stacks
+ added hb_vmTerminateThreads() used by main HVM thread in QUIT state
* moved EXIT procedures execution from QUIT request to HVM QUIT state
in MT mode. It may effects some non structural code which tries to
access private variables in EXIT functions but it's much cleaner
and understandable for user. Please remember that we guaranties
that ALWAYS code in BEGIN SEQUENCE is _always_ executed even after
HVM QUIT request just like destructs. Personally I think that we
should move EXIT procedures execution also in ST mode.
* changed startup and cleanup code for new internal structures
* changes startup and cleanup code for MT mode
% removed some redundant HB_ITEM type settings
! eliminated non MT safe code which was using reference counters
without protection
* harbour/common.mak
* harbour/source/vm/Makefile
+ harbour/include/hbthread.h
+ harbour/source/vm/thread.c
+ added C level functions to manage threads and synchronization objects
See hbthread.h for detail description. They are based on PTHREAD API
and PTHREAD documentation can be used as reference. I intentionally
keep this list small for easier multiplatform porting.
Now they have been implemented for PTHREADS (POSIX threads supported by
many different OSes), MS-Win32/64 and OS2. The OS2 version is not tested
at all. I do not even know if it can be compiled so please make tests.
I used Internet resources and some part of xHarbour code as documentation
for OS2 MT API. It should be quite easy to add other platforms if necessary.
Harbour core code needs non recursive mutexes, conditional variables and
TLS for one pointer. If platforms does not support conditional variables
(f.e. MS-Win or OS2) then they can be emulated using multistate semaphores.
+ added .prg functions to manage threads and synchronization objects:
hb_threadStart( <@sStart()> | <bStart> [, <params,...> ] ) -> <pThID>
hb_threadJoin( <pThID> [, @<xRetCode> ] ) -> <lOK>
hb_threadDetach( <pThID> ) -> <lOK>
hb_threadQuitRequest( <pThID> ) -> <lOK>
hb_threadWaitForAll() -> NIL
hb_mutexCreate() -> <pMtx>
hb_mutexLock( <pMtx> [, <nTimeOut> ] ) -> <lLocked>
hb_mutexUnlock( <pMtx> ) -> <lOK>
hb_mutexNotify( <pMtx> [, <xVal>] ) -> NIL
hb_mutexNotifyAll( <pMtx> [, <xVal>] ) -> NIL
hb_mutexSubscribe( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> <lSubscribed>
hb_mutexSubscribeNow( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> <lSubscribed>
The function list should give similar to xHarbour API but they are not exactly
the same and except of hb_mutex*() functions which should replicate xHarbour behavior.
+ harbour/source/vm/vmmt
+ harbour/source/vm/vmmt/Makefile
+ added hbvmmt library to GNU make builds.
Non GNU make builds should be updated.
* harbour/contrib/hbct/pos1.c
* harbour/contrib/gtwvg/gtwvg.c
* harbour/contrib/rddads/ads1.c
* harbour/contrib/hbmisc/spd.c
* harbour/contrib/hbbmcdx/bmdbfcdx.c
* harbour/contrib/examples/rdddbt/dbfdbt1.c
* harbour/source/vm/runner.c
* harbour/source/vm/itemapi.c
* harbour/source/vm/hvm.c
* harbour/source/rtl/console.c
* harbour/source/rtl/strcase.c
* harbour/source/rtl/spfiles.c
* harbour/source/rtl/defpath.c
* harbour/source/rtl/hbgtcore.c
* harbour/source/rtl/dateshb.c
* harbour/source/rtl/mlcfunc.c
* harbour/source/rtl/fstemp.c
* harbour/source/rtl/is.c
* harbour/source/rtl/setcolor.c
* harbour/source/rtl/errorint.c
* harbour/source/rtl/transfrm.c
* harbour/source/rtl/dates.c
* harbour/source/rtl/filesys.c
* harbour/source/rtl/gtdos/gtdos.c
* harbour/source/rtl/gtwin/gtwin.c
* harbour/source/rtl/gtwvt/gtwvt.c
* harbour/source/rtl/gtxwc/gtxwc.c
* harbour/source/rtl/gttrm/gttrm.c
* harbour/source/rtl/gtpca/gtpca.c
* harbour/source/rtl/gtcgi/gtcgi.c
* harbour/source/rtl/gtcrs/gtcrs.c
* harbour/source/rtl/gtstd/gtstd.c
* harbour/source/rtl/gtsln/gtsln.c
* harbour/source/rtl/gtsln/gtsln.h
* harbour/source/rdd/dbf1.c
* harbour/source/rdd/sdf1.c
* harbour/source/rdd/delim1.c
* harbour/source/rdd/dbcmd.c
* harbour/source/rdd/hbdbsort.c
* harbour/source/rdd/workarea.c
* harbour/source/rdd/dbffpt/dbffpt1.c
* harbour/source/rdd/dbfcdx/dbfcdx1.c
* harbour/source/rdd/dbfntx/dbfntx1.c
* harbour/source/rdd/hsx/hsx.c
* harbour/source/rdd/hbsix/sxfname.c
* use API functions instead of direct accessing to hb_cdp_page or hb_set
* harbour/source/rtl/fstemp.c
* harbour/source/rtl/fssize.c
* harbour/source/rtl/hbffind.c
* harbour/source/rtl/filesys.c
* encapsulate potentially slow IO operation inside
hb_vmUnlock()/hb_vmLock() calls to allow other thread GC
activation
* harbour/contrib/hbnf/fttext.c
! fixed casting
* harbour/contrib/gtwvg/gtwvg.h
- removed #include <comctl32.h> - my MinGW and MinGW/CE instalations do
not have them. If it exists in some newer ones then it has to be
covered by #if version checking.
* harbour/source/vm/dynsym.c
- removed hb_dynsymLog() and hb_dynsymMemvarHandle()
* modified code to be MT safe and improved speed of some operations
* added MUEXT protection for global dynamic table access
* harbour/include/hbapi.h
* harbour/source/vm/garbage.c
* changed to work with MT HVM
* changed to work with new memvar structures and thread local static and
memvar variables
* added MUEXT protection for linked block lists
+ added parameter to hb_gcCollectAll() which will force GC activation
in MT mode by temporary suspending all executed threads.
+ added logical parameter to HB_GCALL() functions which is passed to
hb_gcCollectAll()
* harbour/source/vm/fm.c
* added MUEXT protection for FM statistic module
* added MT protection for reference counters. For platforms
which supports atomic incrmenetation/decrementation (f.e.
Interlocked*() functions in MS-Win) such operations are
used. For other it's MUTEX protection. It gives MT safe
readonly access for HVM complex variables without user
synchronization. The MUTEX protection can cause some speed
overhead so it's good to define MT safe version of
HB_ATOM_INC()/HB_ATOM_DEC() in hbthread.h if given platform
has them. Now they are defined only for Windows. For other
platforms We can define can define them in assembler for some
most popular CPUs in the future.
* harbour/source/vm/classes.c
* changed class definition array. Now it keeps pointers to class
structures.
* In MT mode allocated at HVM startup big enough array for class
definitions to avoid later RT reallocations. It effectively eliminates
MUTEX synchronization for class structure access.
* protect by MUTEX code for new class creation
* harbour/source/debug/dbgentry.c
* eliminated hbvmopt.h and direct accessing to HVM structures
* harbour/source/rtl/gtclip.c
* protect with MUTEX access to internal clipboard data
* harbour/source/rdd/nulsys/nulsys.c
+ added hb_rddCloseAll()
+ harbour/tests/mt
+ harbour/tests/mt/mttest01.prg
+ harbour/tests/mt/mttest02.prg
+ harbour/tests/mt/mttest03.prg
+ harbour/tests/mt/mttest04.prg
+ harbour/tests/mt/mttest05.prg
+ harbour/tests/mt/mttest06.prg
+ harbour/tests/mt/mttest07.prg
+ added some demonstration/test small MT programs written
using Harbour language. Some of them can be also compiled
by xHarbour but xHarbour does not pass any of my tests in
real multi-CPU machine so do not expect they will work
correctly.
Harbour threads needs OS threads support. Each Harbour thread is directly
mapped to OS thread. It's not very efficient on some older system where
cost of thread creation and/or task switching is very expensive but it
should not be bigger problem for modern OS-es which can support threads
in practice nearly in user space only.
I haven't touched Harbour function calling convention which comes from
Clipper. It means that we do not pass pointer to VM to each functions
like CLIP or xBase++. To resolve the problem I have to use thread local
storage (TLS) where such pointer is kept. If platform does not support
TLS then it can be emulated by us. Anyhow the speed of accessing TLS
data and extracting HB_STACK poitner is critical for performance.
Some compilers depending on used hardware and OS give native support
for TLS (f.e. __thread keyword in GCC/BCC or __declspec( thread ) in MSVC).
This should give optimal performance. On other Harbour uses TLS functions
like TlsGetValue() (MS-WIN) or pthread_getspecific() (PTHREAD) are used.
OS2 gives quite interesting TLS functionality which seems to be quite fast
though it will be interesting to know how it is iplemented internally for
real multi CPU machines (if it depends on CPU exception then the
performance will be bad). We need TLS only for one pointer to HB_STACK
structure.
I haven't added any tricks like HB_THREAD_STUB in xHarbour to reduce
the cost of TLS access. If it will be necessary for some platform the we
can add it.
Except TLS Harbour threads needs OS support for non recursive mutexes or
critical sections and conditional variables. If platforms does not support
conditional variables (f.e. MS-Win or OS2) then they can be emulated using
multistate semaphores. I intentionally didn't create code which may need
recursive mutexes. The non recursive ones are often faster and some
platforms may not support recursive mutexes so they will have to be
emulated by us.
Harbour uses reference counters for complex variables. It means that even
readonly access to complex item causes internal write operations necessary
to increment/decrement its reference counter. To make such readonly access
MT safe we have to make incrementation and decrementation with result
checking atomic. By default it's done by mutex inside vm/fm.c but some
platforms have native support for atomic inc/dec operations, f.e.
Interlocked*() functions in MS-Win. If they are available then such
functions should be used to not reduce the performance by mutex call
very often used functions. For many CPUs it should be quite easy to
implement such atomic inc/dec functionality in assembler. F.e. for
GCC and x86@32 it may looks like:
static __inline__ void hb_atomic_inc32( volatile int * p )
{
__asm__ __volatile__(
"lock incl %0"
:"=m" (*p) :"m" (*p)
);
}
static __inline__ int hb_atomic_dec32( volatile int * p )
{
unsigned char c;
__asm__ __volatile__(
"lock decl %0"
"sete %1"
:"=m" (*p), "=qm" (c) :"m" (*p) : "memory"
);
return c == 0;
}
and then it's enough to define in hbthreads.h:
#define HB_ATOM_INC( p ) hb_atomic_inc32( ( volatile int * ) p )
#define HB_ATOM_DEC( p ) hb_atomic_dec32( ( volatile int * ) p )
Probably I'll make it for some most popular CPUs in the future.
In Harbour each thread which wants to call HVM functions have to allocate
it's own HVM stack. It's done hb_vmThreadInit(). The HVM stack is freed
by calling hb_vmThreadQuit(). This functions can be called also by 3-rd
party threads if they want to call HVM functions or execute .prg code.
Calling HVM functions without allocated stack will cause GPF.
I moved most of static variables to HVM stack to make them thread
local. But some of them like FS errors have their own alternative
copy which is used when thread does not allocate HVM stack. It allows
to use hb_fs*() functions without HVM stack but programmer have to
know that error codes return by hb_fs*Error() functions can be
overwritten by other threads which also didn't allocated HVM stack.
To execute garbage collector scan and mark pass it's necessary to
stop other HVM threads. Otherwise the scan may give false results.
It's also possible to not stop threads but protect with mutex all
operations on GC items but it will probably cause performance reduction
and will force some other modifications. Maybe I'll implement it
in the future.
I didn't use any OS level thread KILL or CANCEL calls. All HVM threads
have to be cleanly removed without any resource leaks.
QUIT command terminate only calling thread. If main (startup) HVM
thread call QUIT then it sends QUIT request to all existing threads.
In QUIT state ALWAYS statements and destructors are executed.
New thread is created by:
hb_threadStart( <@sStart()> | <bStart> [, <params,...> ] ) -> <pThID>
The returned value is a pointer to internal thread structure which
can be used in JOIN or DETACH operations. Each thread should be Joined
or DETACHED to avoid resource leaks. If programmer does not store
<pThID> or all instances of <pThID> are destroyed then thread is
automatically detached. I do not know clear method of thread detaching
in OS2. If some OS2 users knows it then plase update vm/hbthread.c.
When thread terminates then all locked by this thread mutexes are
released.
Each thread uses its own memvars (PRIVATEs and PUBLICs) and work areas.
When new thread is created then it inherits from parent thread:
- code page
- language
- SETs
- default RDD
error block is initialized to default value by calling ERRORSYS()
and PUBLIC variable GetList := {} is created.
The following objects are initialized to default value:
- error block
- math error handler and math error block
- macro compiler features setting (hb_setMacro())
or move them to SETs.
We can think about inheriting them. It's also possible to add
inheriting of all visible memvars but I do not know it's good
idea.
Compilation and linking:
For MT mode HVM library should be compiled with HB_MT_VM macro.
GNU make automatically creates hbvmmt library which should be
linked with Harbour MT programs instead of hbvm.
Non GNU make files should be updated.
If given compiler support TLS then you can try to set HB_USE_TLS
to force using native compiler TLS support. Now it's enabled by
default only for BCC. For Linux and GCC builds it may depend also
on used GLIBC version. In older system there is no TLS support
at all or TLS works only for shared binaries so I haven't enabled
it. If you will test some other compiler then please add default
native TLS support for them in hbthread.h
Users using hb* scripts can simply use -mt switch when they want
to create MT program, f.e.:
hbmk -n -w3 -es2 -mt mttest01.prg
There are still some minor things which should be done but I'll
do them later. Current state seems to be fully functional.
The most important and still missing is our own file lock server
for RDD synchronization in POSIX systems. Kernel internally
recognize POSIX locks by PID and file i-node - not PID and file
handle. It means that the same file open more then once by one
process shares locks. Because POSIX locks can be overwritten
then we do not have any synchronization between aliased workareas
or threads using the same table in *nixes. We have to make
synchronization ourselves. I'll create such lock server ASAP.
Please test and enjoy using Harbour threads.
|