aboutsummaryrefslogtreecommitdiff
path: root/jim-eventloop.c
AgeCommit message (Collapse)AuthorFilesLines
2023-04-19vwait: Fix an arg problem with -signalSteve Bennett1-1/+1
'vwait -signal done' should wait for variable 'done' to change but instead waits for a variable '-signal' to changed. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-13clock millis, time: now use monotonic raw time if possibleSteve Bennett1-30/+4
Instead of using all time, these commands now use a monotonically increasing system timer so that they are not affected by time (e.g. ntp) adjustments. (But not on Windows since it doesn't work reliably) Fixes #240 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-13vwait: add support for vwait -signalSteve Bennett1-3/+20
To break vwait if a handled signal is received. In this case, the handled signal(s) can be returned by signal check ?-clear? Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-06eventloop: remove timeBaseSteve Bennett1-3/+3
It isn't used (always zero) and isn't needed. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-01-10package: add ABI version checkingSteve Bennett1-2/+1
jim.h now includes JIM_ABI_VERSION that should be incremented whenever the ABI changes. Then all loadable modules should call Jim_CheckAbiVersion() to make sure they are loaded against the correct version. Add Jim_PackageProvideCheck() that does both Jim_CheckAbiVersion() and Jim_PackageProvide() to simplify the implementation of loadable extensions. Also rename the "big" sqlite3 extension to just sqlite to avoid a naming conflict with the smaller jim-sqlite3 extension. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-15eventloop: Add convenience functions for adding script file handlersSteve Bennett1-0/+49
Add Jim_CreateScriptFileHandler() to create a standard script filehandler event that evaluates the given script with Jim_EvalObjBackground() when the event occurs. Also add Jim_FindFileHandler() to find a registered event handler. Simplify aio by using these. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-10-16after: Need to initialise 'ms'Steve Bennett1-1/+3
Also fix a warning on Windows Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-10-16eventloop: remove leftover debuggingSteve Bennett1-2/+0
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-10-16eventloop: support sub-millisecond timer resolutionSteve Bennett1-32/+47
Timeouts may now be specified in fractions of milliseconds. e.g. after 0.5 This can be useful on faster systems where 1ms resolution is too coarse. Also, use clock_gettime(CLOCK_MONOTONIC_RAW) for timers, if available. This clock is insensitive to system clock changes and ntp adjustments. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2017-09-15eventloop: return from callback is not an errorSteve Bennett1-2/+3
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-10-06eventloop: Don't assume unistd.h and sys/time.hSteve Bennett1-4/+8
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2016-08-17eventloop: Switch to using fd for eventloopSteve Bennett1-15/+14
eventloop doesn't need a filehandle, so so simplify the interface by using file descriptors instead Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-21many comment changes, some small code changesSteve Bennett1-10/+6
Sweep through and clean up all (most) of the comments in the code. While there, adjust some variable and function names to be more consistent, and make a few small code changes - again, mostly for consistency. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2014-01-15eventloop: various minor code cleanupsSteve Bennett1-60/+41
warn at compile time if subsecond sleep in [after] is not supported Simplify time handling by keeping all times in milliseconds since initialisation. No need for any sleep on -ve time Use memset() in initialisation of eventLoop Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-12-21Fix a couple of minor build issuesSteve Bennett1-0/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-08-02Minor code cleanupsSteve Bennett1-5/+2
Prefer Jim_String() and Jim_Length() over Jim_GetString() where it makes sense. Use Jim_ListGetIndex() where success is guaranteed. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-08-02Correct file handler should be deletedSteve Bennett1-10/+13
Previously, Jim_DeleteFileHandler() would indiscriminately delete the first matching file handler in the list. Instead, it should delete the file handler matching the event mask. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2013-07-22Ensure that signals can break vwaitSteve Bennett1-3/+6
The following should break when a handled signal is caught. catch -signal { vwait forever } Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-11-24Create build-jim-ext for building extensionsSteve Bennett1-2/+2
Simplifies the process of building loadable extensions Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-09-24Cleanup in jim-eventloopSteve Bennett1-13/+8
"eof" event no longer exists Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-09-12Remove all trailing whitespace in sourceSteve Bennett1-6/+6
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-08-14On mingw32, use Sleep() if usleep() is unavailableSteve Bennett1-0/+3
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-06-28Fix support for 64-bit mingwSteve Bennett1-31/+30
- Check for mkdir with one arg at configure time - mingw can't really do select(), so support only time events in eventloop - Declare dlerror() to be compatible with mingw Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-06-01Add Jim_String() macroSteve Bennett1-1/+1
It is very common to get the string value without the length. Jim_String() is a macro which does that. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-05-31Remove unused variableSteve Bennett1-2/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2011-04-05Better support for eventloop on mingw32Steve Bennett1-47/+66
Which doesn't support select() with no fds. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-19tv_usec is in usec, not msecSteve Bennett1-1/+1
The consequence is an excessive amount of calls to select Reported-By: Patrick WEBER <patrick.weber@live.com> Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-17Add UTF-8 support to JimSteve Bennett1-2/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-11-09Allow jim to be used as an autoconf subdirSteve Bennett1-0/+1
Ensure that no public headers include the autoconf header, jimautoconf.h, as it leads to problems with redefined symbols. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-20Declare some internal functions staticSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Licence wording updates.Steve Bennett1-2/+0
Per v0.51, don't refer to the FreeBSD licence Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Fix -Wshadow warningsSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Portability fixesSteve Bennett1-4/+17
Especially for eCos, mingw32 and cygwin Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Remove dependence of jim core on stderrSteve Bennett1-2/+4
Remove Jim_PrintErrorMessage() and create Jim_MakeErrorMessage() instead. Move errorInfo to stdlib since it is now required. Also move lassign from tclcompat to stdlib as a core command. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Make jim more reentrantSteve Bennett1-2/+2
Make the exec wait table allocated and per-interpeter Use reentrant variants of some libc calls Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Ensure that Tcl extensions can be built-in or externalSteve Bennett1-0/+3
All C extensions must call Jim_PackageProvide() make-c-ext ensures that Tcl extensions call Jim_PackageProvide() if compiled in. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Minor cleanups and fixesSteve Bennett1-9/+0
array get for odd length list now returns an error comment fixes and small code rearrangement Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15eventloop improvements and enhancementsSteve Bennett1-60/+252
Move Jim_EvalObjBackground() out of the core to eventloop Time events are now kept and triggered in time order Time handlers are removed before execution Add 'update' Add 'after info' and 'after idle' Include time events in the return from Jim_ProcessEvents() Add Tcl eventloop tests Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Fix some eventloop bugsSteve Bennett1-9/+21
bgerror is supposed to be suppressed subsequently if it returns break vwait should error on invalid array element vwait should return an empty result Don't accept 'after info' since it isn't supported Also add some eventloop tests Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Implement 'after ms'Steve Bennett1-2/+8
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Fix some eventloop problemsSteve Bennett1-4/+15
File handlers now pass through the error code and the handler is deleted on error. If there is nothing to do, vwait returns. If bgerror doesn't exist, print the original error to stderr. Also remove the 'eof' event handler since it isn't needed. Can just call [eof $f]. This also fixes source locations within 'readable' scripts. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Clean up the indentation messSteve Bennett1-85/+90
Use 'indent'. Not perfect, but at least consistent. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Fix some build problems and add lost featuresSteve Bennett1-7/+3
Add some missing files needed for autoconf Make jim build standalone and without host jimsh Use (FILE *) for eventloop file handle Don't expect to support dynlib if no mmu Re-add nvp and win32 support (untested) Signed-off-by: Steve Bennett <steveb@workware.net.au>
2010-10-15Documentation, build system updatesSteve Bennett1-1/+2
Document reference-related commands *: ref, getref, setref, finalize, lambda were missing Build system updates *: Add check for long long to configure *: Change -Dwith_jim_ext_... to -Djim_ext_... *: Fix jim-eventloop when compiling with no long long
2010-10-15Various general fixes and cleanupsSteve Bennett1-76/+51
Add lsearch -command, update case to use lsearch Rename tcl6.tcl to tclcompat.tcl Remove // style comments Expand some tabs to spaces Fix some compiler warnings Remove some unused functions Don't close fd=-1 in exec
2010-10-15Build improvements, bug fixes and compiler warningsSteve Bennett1-3/+3
Remove unimplemented 'after restart|expire' from eventloop Allow libjim to be build as a shared library On some platforms, regex.h needs stdlib.h first Use ualarm() only for times < 1 second Fix warnings found by clang static analyser *: printf/syslog %m isn't portable *: some variables set but never read *: some possible null pointer references (although mostly impossible) *: also minor fixes to jim unit tests Fix 'syslog -options <n>' Must null terminate readlink() result
2010-10-15Simplify use of eventloopSteve Bennett1-8/+1
Just assume direct static linking for now
2010-10-15Fix eCos compatiblity problems with autotools.oyvind1-3/+2
2010-10-152009-10-08 Øyvind Harboeoharboe1-7/+14
* jim.c/h: bring in changes from OpenOCD. Warnings and some bug fixes. Copyright list updated in jim.c
2010-10-15Convert jim-aio.c to use subcmdSteve Bennett1-6/+6
Also: - make stream.server set SO_REUSEADDR - do object reference properly for callbacks - white space cleanup in jim-eventloop.c - fix the pwd command - add support for JIM_MODFLAG_FULLARGV to subcmd - make verbose runtests easier to read - bio might not be available