aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/time.c
Commit message (Collapse)AuthorAge
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* build: enable IWYU on macdundargoc2023-11-27
|
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|
* docs: small fixesdundargoc2023-05-13
| | | | | | | | | Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: HiPhish <hiphish@posteo.de> Co-authored-by: Julio B <julio.bacel@gmail.com> Co-authored-by: T727 <74924917+T-727@users.noreply.github.com> Co-authored-by: camoz <camoz@users.noreply.github.com> Co-authored-by: champignoom <66909116+champignoom@users.noreply.github.com>
* refactor(time): refactor delay with input checkingbfredl2023-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, there were three low-level delay entry points - os_delay(ms, ignoreinput=true): sleep for ms, only break on got_int - os_delay(ms, ignoreinput=false): sleep for ms, break on any key input os_microdelay(us, false): equivalent, but in μs (not directly called) - os_microdelay(us, true): sleep for μs, never break. The implementation of the latter two both used uv_cond_timedwait() This could have been for two reasons: 1. allow another thread to "interrupt" the wait 2. uv_cond_timedwait() has higher resolution than uv_sleep() However we (1) never used the first, even when TUI was a thread, and (2) nowhere in the codebase are we using μs resolution, it is always a ms multiplied with 1000. In addition, os_delay(ms, false) would completely block the thread for 100ms intervals and in between check for input. This is not how event handling is done alound here. Therefore: Replace the implementation of os_delay(ms, false) to use LOOP_PROCESS_EVENTS_UNTIL which does a proper epoll wait with a timeout, instead of the 100ms timer panic. Replace os_microdelay(us, false) with a direct wrapper of uv_sleep.
* vim-patch:8.1.1313: warnings for using localtime() and ctime() (#21229)zeertzjq2022-11-29
| | | | | | | | Problem: Warnings for using localtime() and ctime(). Solution: Use localtime_r() if available. Avoid using ctime(). https://github.com/vim/vim/commit/63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.0733: use of strftime() is not safe (#21228)zeertzjq2022-11-29
| | | | | | | | | | Problem: Use of strftime() is not safe. Solution: Check the return value of strftime(). Use a larger buffer and correctly pass the available space. (Dominique Pellé, closes vim/vim#11348) https://github.com/vim/vim/commit/84d14ccdb50dc9f362066a2c83bfaf331314e5ea Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com>
* vim-patch:8.2.4155: translating strftime() argument results in check errorzeertzjq2022-11-25
| | | | | | | | | Problem: Translating strftime() argument results in check error. Solution: Add gettext comment. https://github.com/vim/vim/commit/7e93577a957e4f402bb690c4c8629fd831e24a9d Co-authored-by: Bram Moolenaar <Bram@vim.org>
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* refactor: clang-tidy fixes to silence clangd warning (#20683)dundargoc2022-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | * refactor: readability-uppercase-literal-suffix * refactor: readability-named-parameter * refactor: bugprone-suspicious-string-compare * refactor: google-readability-casting * refactor: readability-redundant-control-flow * refactor: bugprone-too-small-loop-variable * refactor: readability-non-const-parameter * refactor: readability-avoid-const-params-in-decls * refactor: google-readability-todo * refactor: readability-inconsistent-declaration-parameter-name * refactor: bugprone-suspicious-missing-comma * refactor: remove noisy or slow warnings
* refactor(uncrustify): set maximum number of consecutive newlines to 2 (#18695)dundargoc2022-05-25
|
* refactor: format files with uncrustify #15663dundargoc2021-09-14
|
* vim-patch:8.1.2313: debugging where a delay comes from is not easyJan Edmund Lazo2021-04-15
| | | | | | Problem: Debugging where a delay comes from is not easy. Solution: Use different values when calling ui_delay(). https://github.com/vim/vim/commit/eda1da0c9a8db1400649629117e7d248c07735f7
* vim-patch:8.1.2326: cannot parse a date/time stringJan Edmund Lazo2021-03-27
| | | | | | | | | | | | | | | Problem: Cannot parse a date/time string. Solution: Add strptime(). (Stephen Wall, closes #) https://github.com/vim/vim/commit/10455d43fef041309ce0613fa792c635dd71e3a8 N/A patches for version.c: vim-patch:8.1.2344: Cygwin: warning for using strptime() Problem: Cygwin: warning for using strptime(). Solution: Move defining _XOPEN_SOURCE and __USE_XOPEN to vim.h. (Ken Takata, closes vim/vim#5265) Use 700 for _XOPEN_SOURCE for mkdtemp(). https://github.com/vim/vim/commit/6a228c6463935a73c8f21142cb7368545cfee317
* Use abort() instead of assert(false) for things that should never happenJames McCoy2021-01-31
| | | | | | | | assert() is compiled out for release builds, but we don't want to continue running in these impossible situations. This also resolves the "implicit fallthrough" warnings for the asserts in switch cases.
* Merge pull request #12804 from janlazo/vim-8.1.1725Jan Edmund Lazo2020-08-31
|\ | | | | [RDY]vim-patch:8.1.{1694,1725,1776,1804,1806,1831,2041,2198,2206},8.2.{1033,1315,1548}
| * vim-patch:8.1.1725: MS-Windows: E325 message may use incorrect date formatJan Edmund Lazo2020-08-30
| | | | | | | | | | | | | | Problem: MS-Windows: E325 message may use incorrect date format. Solution: Convert strftime() result to 'encoding'. Also make the message translatable. (Ken Takata, closes vim/vim#4685, closes vim/vim#4681) https://github.com/vim/vim/commit/663bbc09babea1ff8dfa7ccd58801ac9219fc2b2
* | docs, remove 'guifontset' #11708Justin M. Keyes2020-08-31
|/ | | | | | | | | | | | | - remove redundant autocmd list This "grouped" list is useless, it only gets in the way when searching for event names. - intro.txt: cleanup - starting.txt: update, revisit - doc: `:help bisect` - mbyte.txt: update aliases 1656367b90bd. closes #11960 - options: remove 'guifontset'. Why: - It is complicated and is used by almost no one. - It is unlikely to be implemented by Nvim GUIs (complicated to parse, specific to Xorg...).
* vim-patch:8.1.1567: localtime_r() does not respond to $TZ changesJan Edmund Lazo2020-03-29
| | | | | | Problem: Localtime_r() does not respond to $TZ changes. Solution: If $TZ changes then call tzset(). (Tom Ryder) https://github.com/vim/vim/commit/db51730df1817fc4b6ecf5a065c69fac518ad821
* vim-patch:8.1.1313: warnings for using localtime() and ctime()Jan Edmund Lazo2020-03-29
| | | | | | Problem: Warnings for using localtime() and ctime(). Solution: Use localtime_r() if available. Avoid using ctime(). https://github.com/vim/vim/commit/63d2555c9cefbbeeca3ec87fdd5d241e9488f9dd
* viml/profile: revert gettimeofday() #10488Justin M. Keyes2019-07-13
| | | | | | | e2ce5ff9d616 was proven to be bogus, so revert it. close #10328 ref #10356 ref #10452
* viml/reltime(): allow negative result #10453Justin M. Keyes2019-07-09
| | | | | | - define proftime_T as signed integer - profile_sub(): allow negative result closes #10452
* viml/profile: switch to uv_gettimeofday() #10356Justin M. Keyes2019-06-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Performance of high-resolution time (clock_gettime via uv_hrtime) is expensive on some systems. For profiling VimL, syntax, etc., we don't care about nanosecond-precision and monotonicity edge-cases, so avoid uv_hrtime(). closes #10328 From the uv__hrtime() source: https://github.com/libuv/libuv/blob/0cdb4a5b4b706d0e09413d9270da28f9a88dc083/src/unix/linux-core.c#L442-L462 /* Prefer CLOCK_MONOTONIC_COARSE if available but only when it has * millisecond granularity or better. CLOCK_MONOTONIC_COARSE is * serviced entirely from the vDSO, whereas CLOCK_MONOTONIC may * decide to make a costly system call. */ This micro-benchmark (Debug build) shows negligible differences on my system: #include <sys/time.h> ... proftime_T tm = profile_start(); int trials = 999999; int64_t t = 0; struct timeval tv; for (int i = 0; i < trials; i++) { t += gettimeofday(&tv,NULL); } tm = profile_end(tm); ILOG("%d trials of gettimeofday: %s", trials, profile_msg(tm)); tm = profile_start(); for (int i = 0; i < trials; i++) { t += os_hrtime(); } tm = profile_end(tm); ILOG("%d trials of os_hrtime: %s", trials, profile_msg(tm)); tm = profile_start(); for (int i = 0; i < trials; i++) { t += os_utime(); } tm = profile_end(tm); ILOG("%d trials of os_utime: %s", trials, profile_msg(tm)); ILOG("%zu", t);
* rename: os_get_localtime => os_localtimeJustin M. Keyes2018-07-24
|
* lint, minor cleanupJustin M. Keyes2018-02-07
|
* *: Add comment to all C filesZyX2017-04-19
|
* time.c: os_microdelay(): Let input cancel the delay. #5830Michael Schupikov2017-01-06
| | | | Closes #5397
* *: Rename main loop variable from loop to main_loopZyX2016-05-30
| | | | | | | | | | | | | | | | Current name is inappropriate for the following reasons: 1. It is often masked by local `loop` variables. 2. It cannot be searched for. There are many `loop` variables where `loop` is some local variable. There are many cases when “loop” word is used in a comment. 3. It is in any case bad idea to use a generic name as a name of the global variable. Best if global has module prefix: this is why it is in `main.h`: `main_loop` both stands for “a main loop” and “a loop defined in `main.*`”. Since I have no idea how to list every occurrence of this variable method used to rename it is “remove it from globals.h, try to compile, fix errors”. Thus if some occurrence was hidden under false `#if` branch it was not replaced.
* misc: UNIX => Unix #4022Seth Jackson2016-01-16
| | | | | | | | | | Although UNIX is a registered trademark of The Open Group, it doesn't really matter whether we refer to these systems as UNIX, Unix, or Unix-like. So, for consistency, refer to them collectively as Unix. Related: http://www.greens.org/about/unix.html http://www.unixica.com/html/unixunix.html
* viminfo: First version of ShaDa file dumpingZyX2015-10-08
| | | | | | | | | | | | | | | | | | | | What works: 1. ShaDa file dumping: header, registers, jump list, history, search patterns, substitute strings, variables. 2. ShaDa file reading: registers, global marks, variables. Most was not tested. TODO: 1. Merging. 2. Reading history, local marks, jump and buffer lists. 3. Documentation update. 4. Converting some data from &encoding. 5. Safer variant of dumping viminfo (dump to temporary file then rename). 6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for reference).
* event: Refactor async event processingThiago de Arruda2015-08-13
| | | | | | | | | | - Improve the implementation of deferred/immediate events. - Use the new queue module to change how/when events are queued/processed by giving a private queue to each emitter. - Immediate events(which only exist to break uv_run recursion) are now represented in the `loop->fast_events` queue. - Events pushed to child queues are propagated to the event loop main queue and processed as K_EVENT keys.
* event loop: New abstraction layer with refactored time/signal APIThiago de Arruda2015-07-17
| | | | | | | | | | - Add event loop abstraction module under src/nvim/event. The src/nvim/event/loop module replaces src/nvim/os/event - Remove direct dependency on libuv signal/timer API and use the new abstraction instead. - Replace all references to uv_default_loop() by &loop.uv, a new global variable that wraps libuv main event loop but allows the event loop functions to be reused in other contexts.
* illumos requires the use of limits.h for things like INT_MAX #2049Mike Zeller2015-02-26
|
* refactor: Remove term modules and termcap optionsThiago de Arruda2015-02-21
| | | | | | | | | | | | | | | - Removed term.c, term.h and term_defs.h - Tests for T_* values were removed. screen.c was simplified as a consequence(the best strategy for drawing is implemented in the UI layer) - Redraw functions now call ui.c functions directly. Updates are flushed with `ui_flush()` - Removed all termcap options(they now return empty strings for compatibility) - &term/&ttybuiltin options return a constant value(nvim) - &t_Co is still available, but it mirrors t_colors directly - Remove cursor tracking from screen.c and the `screen_start` function. Now the UI is expected to maintain cursor state across any call, and reset it when resized. - Remove unused code
* Linting: Recommend os_* instead of POSIX functions.Florian Walch2015-01-11
|
* time: Inline microdelay into os_microdelayThiago de Arruda2014-12-03
|
* term: Remove most calls to settmodeThiago de Arruda2014-12-02
| | | | | | Nvim now relies much less on setting terminal mode to cooked mode, remove most calls to settmode, except for those that happen on startup or when suspending. Eventually even those will be handled by the UI layer.
* compilation: Add -Wconversion to more files and validate CONV_SOURCESThiago de Arruda2014-10-21
| | | | | | All files under the os, api and msgpack_rpc directories have -Wconversion automatically applied. CONV_SOURCES is also checked for missing files(when renaming, for example)
* os/time: fix os_localtime_r on win + add func_attrNicolas Hillegeer2014-07-20
| | | | | | - it makes no sense for these functions to take NULL pointers - if `localtime()` on Windows returns a NULL pointer, the old code would try to dereference it.
* os/time: make os_get_localtime more portableNicolas Hillegeer2014-07-20
| | | | | | gettimeofday() doesn't exist on Windows, as reported by @equalsraf. It seems a call to time() would be sufficient here, as only the seconds since the UNIX epoch are needed.
* os: implement os_hrtimeNicolas Hillegeer2014-07-16
| | | | Just an alias to uv_hrtime. Provides a high-resolution timer.
* Use strict function prototypes #945Pavel Platto2014-07-14
| | | | | | | | | | | | | | | | | | | `-Wstrict-prototypes` warn if a function is declared or defined without specifying the argument types. This warning disallow function prototypes with empty parameter list. In C, a function declared with an empty parameter list accepts an arbitrary number of arguments when being called. This is for historic reasons; originally, C functions didn't have prototypes, as C evolved from B, a typeless language. When prototypes were added, the original typeless declarations were left in the language for backwards compatibility. Instead we should provide `void` in argument list to state that function doesn't have arguments. Also this warning disallow declaring type of the parameters after the parentheses because Neovim header generator produce no declarations for old-stlyle prototypes: it expects to find `{` after prototype.
* Add automatic generation of headersZyX2014-06-02
| | | | | | | | | | | | | | | | | - The 'stripdecls.py' script replaces declarations in all headers by includes to generated headers. `ag '#\s*if(?!ndef NEOVIM_).*((?!#\s*endif).*\n)*#ifdef INCLUDE_GENERATED'` was used for this. - Add and integrate gendeclarations.lua into the build system to generate the required includes. - Add -Wno-unused-function - Made a bunch of old-style definitions ANSI This adds a requirement: all type and structure definitions must be present before INCLUDE_GENERATED_DECLARATIONS-protected include. Warning: mch_expandpath (path.h.generated.h) was moved manually. So far it is the only exception.
* Move documentation from function declarations to definitionsZyX2014-06-02
| | | | Uses a perl script to move it (scripts/movedocs.pl)
* Introduce nvim namespace: Fix project-local includes.Eliseo Martínez2014-05-15
| | | | Prepend 'nvim/' in all project-local (non-system) includes.
* Introduce nvim namespace: Move files.Eliseo Martínez2014-05-15
Move files from src/ to src/nvim/. - src/nvim/ becomes the new root dir for nvim executable sources. - src/libnvim/ is planned to become root dir of the neovim library.