Commit Graph

1464 Commits

Author SHA1 Message Date
Nicolas Hillegeer
1cfc468e5c test/helpers: allow interning Pascal strings
os_system() returns a Pascal string, for example (it also NUL-terminates the
string, but that's neither here nor there).
2014-07-27 14:00:45 -03:00
Nicolas Hillegeer
ad4c1e1954 test/formatc: improve standalone usage
Easier testing.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
10479fd233 test/formatc: improve 'inline' function handling
Apple seems to define some functions as `inline` but not `static` in
headers. The ghetto parser wasn't unbelievably happy with this.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
115b165bfa rstream: remove 'reading' struct member
Not necessary, as discussed in #980.

From the libuv mailing list:
https://groups.google.com/forum/#!topic/libuv/OD38PeGeVgQ

E.g. this could happen (red: on Windows):

> > alloc_cb(handle1);
> > alloc_cb(handle2);
> > read_cb(handle1);
> > read_cb(handle2);

But this couldn't:

> > alloc_cb(handle1);
> > alloc_cb(handle1);
> > read_cb(handle1);
> > read_cb(handle1);

Because each stream has a 1-to-1 correspondance with a libuv handle. The
code removed was never executed.

Closes #980.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
8bd1fe9523 job: increase JOB_BUFFER_SIZE to 0xFFFF
It used to be 1024 bytes, which is very tiny and slows down some operations
(imaging `cat`-ing a large file). Benchmarks show a large speedup for such
cases. ref #978.

For modern systems 0xFFFF bytes (65535 B = 64 KB = 0.0625 MB) per job
shouldn't be a big problem.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
6f30b25f45 eval: reimplement f_system() on top of os_system()
This evades the tempfile problem (unless of course one manually adds
redirects to the shell commandline, which some plugins seem to do, e.g.:
vim-easytags).
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
3d3b233df8 os/shell: implement os_system
With the goal to support pipe-only system() calls.

Notes on the second (vim) argument to f_system() (i.e.: redirected input)
and its implications:

- When calling system('cat -', ['some', 'list']), vanilla vim (before a
  recent patch that added support for passing lists) just passes an empty
  file to the process. This is the same as immediately closing the pipe,
  which os_system does when no input is given. If we wouldn't close the
  pipe, the process will linger forever (as is the case with `cat -`).

As of now, it's not allowed to pass a non-NULL pointer as the `output`
parameter. In other words, it's not possible to signal disinterst in the
process output. That may change in the future.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
5e0931241d job: add in-pipe notification and closing support
- One can now manually close the in-pipe, without having to tear down the
  job.
- One can be notified of write success/failure.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
891b4b9d2b wstream: allow empty release wbuffer cb
Sometimes a wbuffer is not supposed to be free()'d (such as when it comes
from a constant (possibly static) string, for example.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
06cc046e30 wstream: write completion callback
Now modules using the wstream can find out what's happening to their writes.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
9f624f0937 job: implement job_wait()
Used to wait synchronously for a job to end.
2014-07-27 14:00:44 -03:00
Nicolas Hillegeer
6af15f706a os/shell: constify arguments
Minor fixes
2014-07-27 14:00:44 -03:00
Wayne Rowcliffe
0761142246 Minor buffer.c style cleanups 2014-07-26 16:43:29 -05:00
Justin M. Keyes
9550beda61 Merge pull request #975 from aktau/remove-gettimeofday
remove gettimeofday() usage
2014-07-25 17:44:23 -04:00
ZyX
4dadadd001 build: Compile static luajit lib with -fPIC #996
Should fix the following travis error:

    /usr/bin/ld: /opt/neovim-deps/lib/libluajit-5.1.a(lj_err.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
    /opt/neovim-deps/lib/libluajit-5.1.a: could not read symbols: Bad value
2014-07-25 21:13:44 +02:00
Andrew Chin
d203c37e21 message: add missing stdarg.h include #993
Fixes up gcc 4.1 (not specifically a supported compiler but it's standard
for varargs anyway so it's good to have it included and depend less on
implicit includes).
2014-07-25 19:49:20 +02:00
Justin M. Keyes
d5a7947e8b Merge pull request #986 from aktau/func-attr-enable-more-clang
func_attr: clang/icc support NONNULL_* attr
2014-07-24 10:45:37 -04:00
Justin M. Keyes
cbe1864ab4 Merge pull request #987 from oni-link/fix_some_memory_leaks
Fix some memory leaks in job.c and provider.c
2014-07-24 10:39:43 -04:00
oni-link
e9e4cdb3d4 Fix memory leaks for jobs.
Free the data memory of process and pipe handles in the close callback
for a job.
2014-07-23 15:15:21 +02:00
oni-link
bb1f08f6e8 Fix memory leak in provider_call.
If no channel can be found for a method, free argument arg before
returning.
2014-07-23 15:13:28 +02:00
Nicolas Hillegeer
f430ec5c50 func_attr: clang/icc support NONNULL_* attr
Both clang and (apparently) icc support the nonnull attribute. So I'm not
sure why it wasn't enabled in the first place.

- clang: http://clang-analyzer.llvm.org/annotations.html#attr_nonnull
- icc: https://software.intel.com/en-us/forums/topic/280290 (not conclusive
  evidence, but the best I could find, lacking docs)
2014-07-23 14:37:48 +02:00
Justin M. Keyes
ba04a1c306 Merge pull request #904 from war1025/dev/buffer_tests
Add unit tests for buffer.c and fileio.c
2014-07-22 15:24:56 -04:00
Wayne Rowcliffe
7a2ea275eb Add tests for buffer.c and fileio.c 2014-07-22 05:28:17 -05:00
Wayne Rowcliffe
5941ccab76 Change buffer.h #defines to enums so they can be used in tests 2014-07-22 05:28:17 -05:00
Wayne Rowcliffe
9453b7230b Statically allocate NameBuff 2014-07-22 05:28:17 -05:00
Nicolas Hillegeer
7b1d46f39d cmake: remove check for gettimeofday
There are no more uses of gettimeofday, so remove the check in CMake.
2014-07-21 19:30:00 +02:00
Nicolas Hillegeer
fb5a786bdb term: replace gettimeofday()
gettimeofday() is not portable, replace with os_hrtime() wherever possible.
The new code should behave equivalently to the old implementation.

Because of this, HAVE_GETTIMEOFDAY is no longer necessary To be able to
handle double clicks.
2014-07-21 19:29:29 +02:00
Nicolas Hillegeer
8ec0aef307 sha256: replace gettimeofday()
gettimeofday() is not portable. I suspect os_hrtime() is also better as a
seed than gettimeofday() or time() were.
2014-07-21 19:29:29 +02:00
Nicolas Hillegeer
6cbda2cbf6 viml: re-add sha256() function
Was removed in #699 but actually doesn't have anything to do with security.
2014-07-21 19:29:29 +02:00
Justin M. Keyes
845d1bfa90 Merge #965 'Make os_get_localtime() portable + fix bug on win' 2014-07-20 18:27:49 -04:00
Nicolas Hillegeer
636ddd075c os/time: fix os_localtime_r on win + add func_attr
- 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.
2014-07-20 18:27:45 -04:00
Nicolas Hillegeer
6610b002ef os/time: make os_get_localtime more portable
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.
2014-07-20 18:27:45 -04:00
Nicolas Hillegeer
8d44e36b1a os/time: include time.h in os/time.h
Include what you use, also in the positive direction.
2014-07-20 18:27:45 -04:00
Justin M. Keyes
a9d679b1d7 Merge #962 'Implement startuptime functions on top of profiling functions' 2014-07-20 18:12:45 -04:00
Nicolas Hillegeer
2fcfee39ce startuptime: print vim -> nvim 2014-07-20 16:59:58 -04:00
Nicolas Hillegeer
fb15cbbaea startuptime: always enable startuptime
Removes the STARTUPTIME define.
2014-07-20 16:59:57 -04:00
Nicolas Hillegeer
ab1eec10a1 globals.h: decouple vim.h and globals.h
Allow globals.h to be included without including vim.h. Another small piece
of the puzzle of dismantling vim.h.

Moving some extra `#define`'s to globals.h is no better than having them in
vim.h. We should, in a later PR, move them to the file where they belong or
to a separate `constants.h` or something.
2014-07-20 16:59:57 -04:00
Nicolas Hillegeer
d19712f233 garray: add necessary includes
The upcoming decoupling of vim.h and globals.h needs this to compile.
2014-07-20 16:59:57 -04:00
Nicolas Hillegeer
47815fc6f4 startuptime: implement on top of profiling fns
Reuse the profiling functions to implement the startuptime functions.
Decreases our dependency on `gettimeofday()` and thus gets us a little bit
closer to a clean port to Windows.
2014-07-20 16:59:57 -04:00
Nicolas Hillegeer
a001510382 startuptime: move code to profile.{c,h} + doc
It's a better place to put it. Also slightly documented and reformatted, but
not changed.
2014-07-20 16:59:57 -04:00
Wesley Wiser
c7eb8c5cd7 coverity/62610: Remove dead code from setfname() 2014-07-20 04:49:38 -04:00
Nicolas Hillegeer
1b932cbfec types: typedef long_u as uintptr_t #961
As discussed here: https://github.com/neovim/neovim/pull/941/files#r15026398
2014-07-20 04:47:17 -04:00
Thiago de Arruda
953d61cbf8 Merge PR #895 'Core service providers...' 2014-07-17 12:06:31 -03:00
Thiago de Arruda
4dc642aa62 api tests: set 'initpython' in BeforeEachTest
This is required to run some tests of the python client
2014-07-17 11:37:42 -03:00
Thiago de Arruda
2e4ea29d2c events: Refactor how event deferral is handled
- Remove all *_set_defer methods and the 'defer' flag from rstream/jobs
- Added {signal,rstream,job}_event_source functions. Each return a pointer that
  represent the event source for the object in question(For signals, a static
  pointer is returned)
- Added a 'source' field to the Event struct, which is set to the appropriate
  value by the code that created the event.
- Added a 'sources' parameter to `event_poll`. It should point to a
  NULL-terminated array of event sources that will be used to decide which
  events should be processed immediately
- Added a 'source_override' parameter to `rstream_new`. This was required to use
  jobs as event sources of RStream instances(When "focusing" on a job, for
  example).
- Extracted `process_from` static function from `event_process`.
- Remove 'defer' parameter from `event_process`, which now operates only on
  deferred events.
- Refactor `channel_send_call` to use the new lock mechanism

What changed in a single sentence: Code that calls `event_poll` have to specify
which event sources should NOT be deferred. This change was necessary for a
number of reasons:

- To fix a bug where due to race conditions, a client request
  could end in the deferred queue in the middle of a `channel_send_call`
  invocation, resulting in a deadlock since the client process would never
  receive a response, and channel_send_call would never return because
  the client would still be waiting for the response.
- To handle "event locking" correctly in recursive `channel_send_call`
  invocations when the frames are waiting for responses from different
  clients. Not much of an issue now since there's only a python client, but
  could break things later.
- To simplify the process of implementing synchronous functions that depend on
  asynchronous events.
2014-07-17 11:37:42 -03:00
Thiago de Arruda
cf30837951 api/events/msgpack: Insert log statements to improve debugging
Also changed the default log level to INFO so developers won't end up with big
log files without asking explicitly(DLOG statements were placed in really "hot"
code)
2014-07-17 11:37:41 -03:00
Thiago de Arruda
f180f6fdeb getchar: fix infinite loop due to pending events
The `inchar` function could enter an infinite loop if there are events pending
to be processed when an interrupt is received.
2014-07-17 11:37:41 -03:00
Thiago de Arruda
83cad98d5d api: make buffer_{get,set}_slice automatically assume include_end
This is for compatibility with python-vim interface: When passing an end index
with a value higher than the last index, assume the `include_end` flag
2014-07-17 11:37:41 -03:00
Thiago de Arruda
fba1d3b50f provider: Add support for clipboard registers.
This reimplements the '+'/'*' clipboard registers(both are aliases to the same
register, no dedicated storage for the X11 selection) on top of the provider
infrastructure.

This adds two new 'unnamedclip' option, has the same effect of setting
'clipboard' to 'unnamed/unnamedplus' in vim

The 'clipboard' option was not reused because all values(except 'unnamedplus')
seem to be useless for Neovim, and the code to parse the option was relatively
big. The option remains for vim compatibility but it's silently ignored.
2014-07-17 11:37:41 -03:00
Thiago de Arruda
486c8e37c1 provider: Add support for python commands/functions
This uses the provider/scripting infrastructure to reintroduce python support
through the msgpack-rpc API.

A new 'initpython' option was added, and it must be set to a command that will
bootstrap the python provider the first time it's needed.
2014-07-17 11:37:41 -03:00