aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.h
AgeCommit message (Collapse)Author
2019-02-27Revert "Prepare release"Rickard Green
This reverts commit df130102cdeca8d35fec95a0c926fd1cfec54eab.
2019-02-26Prepare releaseErlang/OTP
2019-01-07erts: Add enif_select_read|write with 'msg_env' argumentSverker Eriksson
2018-11-01erts: Bump erl_nif minor version and ERL_NIF_MIN_ERTS_VERSIONSverker Eriksson
with ticket syntax.
2018-07-20erts: Add ERL_NIF_SELECT_CANCEL flag for enif_selectSverker Eriksson
to deselect read and/or writes without stop callback.
2018-06-18Update copyright yearHenrik Nord
2018-03-23Add enif_make_map_from_arraysJohn Högberg
2018-03-22erts: Improve NIF load incompatibility errorsSverker Eriksson
2018-03-22erts: Add enif_vfprintf and enif_vsnprintfSverker Eriksson
2018-03-22erts: Add enif_*_name functionsSverker Eriksson
2018-02-26Expand ErlNifBinary by another word for future additionsJohn Högberg
When fixing OTP-14931/14932 we had to settle for a solution that decreased performance in a few corner cases like multiple calls to enif_make_binary, as the other options on the table required extra fields which would have broken ABI compatibility. This is ABI-compatible since the fields are unused and at the end.
2018-02-26Unconditionally transfer ownership to the created termJohn Högberg
This fixes two corner-cases: 1) We will no longer return an invalid term when a binary inspected on environment A is used in enif_make_binary on environment B 2) A double-free in this sequence of events: * enif_alloc_binary(size, &bin); * enif_ioq_enq_binary(ioq, &bin, skip); * enif_make_binary(env, &bin); * enif_make_binary(env, &bin); OTP-14931 OTP-14932
2017-11-30Add enif_ioq_peek_headJohn Högberg
This introduces a way to retrieve erlang terms from NIF IO queues without having to resort to copying. OTP-14797
2017-11-15Fix NIF API version for enif_ioqJohn Högberg
2017-09-05erts: Add nif ioqLukas Larsson
2017-05-04Update copyright yearRaimo Niskanen
2017-04-20erts: Refactor enif_phash2 into enif_hashGuilherme Andrade
A more generic hashing function which can also hash terms based on `make_internal_hash'.
2017-02-20Fix enif_select for windowsSverker Eriksson
2017-02-09erts: Change return value for enif_selectSverker Eriksson
to negative int as error and positive as success.
2017-02-09erts: Add enif_monitor_process and enif_demonitor_processSverker Eriksson
2016-12-19Add stop arguments: fd and is_direct_callSverker Eriksson
2016-12-19erts: Add testing + some minor fixesSverker Eriksson
2016-11-30erts: Add enif_select & enif_open_resource_type_xSverker Eriksson
2016-11-23erts: Secure abi backward compat for tracer nifsSverker Eriksson
and simplify the code by handling the compatibility stuff at loading by creating modern struct copies in create_lib().
2016-06-08Replace enif_is_on_dirty_scheduler() with enif_thread_type()Rickard Green
2016-05-13Merge branch 'egil/erts/nif-format_term/OTP-13580'Björn-Egil Dahlberg
* egil/erts/nif-format_term/OTP-13580: runtime_tools: Change erts_snprintf to enif_snprintf erts: Document enif_snprintf erts: Add tests for enif_snprintf erts: Add enif_snprintf Conflicts: erts/emulator/beam/erl_nif_api_funcs.h
2016-05-11erts: Add enif_snprintfBjörn-Egil Dahlberg
* Add the capability to format erlang terms to a char buffer in nifs. * Bump NIF version to 2.11
2016-05-10Remove conditional dirty schedulers APIRickard Green
2016-04-15erts: Implement tracer modulesLukas Larsson
Add the possibility to use modules as trace data receivers. The functions in the module have to be nifs as otherwise complex trace probes will be very hard to handle (complex means trace probes for ports for example). This commit changes the way that the ptab->tracer field works from always being an immediate, to now be NIL if no tracer is present or else be the tuple {TracerModule, TracerState} where TracerModule is an atom that is later used to lookup the appropriate tracer callbacks to call and TracerState is just passed to the tracer callback. The default process and port tracers have been rewritten to use the new API. This commit also changes the order which trace messages are delivered to the potential tracer process. Any enif_send done in a tracer module may be delayed indefinitely because of lock order issues. If a message is delayed any other trace message send from that process is also delayed so that order is preserved for each traced entity. This means that for some trace events (i.e. send/receive) the events may come in an unintuitive order (receive before send) to the trace receiver. Timestamps are taken when the trace message is generated so trace messages from differented processes may arrive with the timestamp out of order. Both the erlang:trace and seq_trace:set_system_tracer accept the new tracer module tracers and also the backwards compatible arguments. OTP-10267
2016-04-15erts: Add erts_nif_get_funcs and erts_nif_call_functionLukas Larsson
These are convinience functions for calling nifs from erts
2016-04-13Merge branch 'henrik/update-copyrightyear'Henrik Nord
* henrik/update-copyrightyear: update copyright-year
2016-03-29erts: Improve enif_binary_to_termSverker Eriksson
* Accept a raw data buffer instead of ErlNifBinary * Accept option ERL_NIF_BIN2TERM_SAFE * Return number of read bytes
2016-03-29erts: Add enif_is_process/port_aliveLukas Larsson
2016-03-29erts: Add enif_cpu/now_time and enif_make_unique_integerLukas Larsson
2016-03-15update copyright-yearHenrik Nord
2016-02-02Merge branch 'maint'Rickard Green
* maint: Introduce time management in native APIs Introduce time warp safe replacement for safe_fixed option Introduce time warp safe trace timestamp formats Conflicts: erts/emulator/beam/erl_bif_trace.c erts/emulator/beam/erl_driver.h erts/emulator/beam/erl_nif.h erts/emulator/beam/erl_trace.c erts/preloaded/ebin/erlang.beam
2016-01-21Introduce time management in native APIsRickard Green
2016-01-08erts: Allow -fvisibility=hidden for NIFs and driversSverker Eriksson
as is strongly recommended by gcc man page. We use __attribute__ ((visibility("default"))) to make sure the init functions are properly exported.
2016-01-08erts: Refactor ERL_NIF_INIT macroSverker Eriksson
2015-11-27Merge branch 'maint'Sverker Eriksson
2015-11-26erts: Refactor alloc_SUITE to use NIFs instead of driversSverker Eriksson
2015-11-26erts: Add enif_getenvSverker Eriksson
to read OS environment variables in a safe and portable way.
2015-06-24erts: Remove halfword in erl_nif.hBjörn-Egil Dahlberg
2015-06-18Change license text to APLv2Bruce Yinhe
2015-05-27erts: Rename ErlNifMapIteratorEntry enumsSverker Eriksson
To differentiate between first/last map entry and head/tail which is before/after first/last map entry.
2015-04-22Merge branch 'sverk/pr632/prevent-illegal-nif-terms/OTP-12655'Sverker Eriksson
* sverk/pr632/prevent-illegal-nif-terms/OTP-12655: erts: Reject non-finite float terms in erl_drv_output_term erts: Remove old docs about experimental NIF versions. erts: Add enif_has_pending_exception erts: Clearify erl_nif documentation about badarg exception erts: Fix compile warning in enif_make_double erts: Fix divide by zero compile error in nif_SUITE.c erts: Fix isfinite for windows Ensure NIF term creation disallows illegal values
2015-04-15erts: Add enif_has_pending_exceptionSverker Eriksson
2015-03-12erts: Fix nif API for hashmapsSverker Eriksson
2014-10-02Fix missing field initializer in ERL_NIF_INIT macroSteve Vinoski
In the ERL_NIF_INIT macro, add a missing static initializer for the new options field which was added to the ErlNifEntry struct for 17.3. This fix prevents compile-time errors in NIFs when the compiler is instructed to treat missing field initializers as errors.
2014-08-28add enif_schedule_nif() to NIF APISteve Vinoski
In the #erlang IRC channel Anthony Ramine once mentioned the idea of allowing a NIF to use an emulator trap, similar to a BIF trap, to schedule another NIF for execution. This is exactly how dirty NIFs were implemented for Erlang/OTP 17.0, so this commit refactors and generalizes that dirty NIF code to support a new enif_schedule_nif() API function. The enif_schedule_nif() function allows a long-running NIF to be broken into separate NIF invocations. The NIF first executes part of the long-running task, then calls enif_schedule_nif() to schedule a NIF for later execution to continue the task. Any number of NIFs can be scheduled in this manner, one after another. Since the emulator regains control between invocations, this helps avoid problems caused by native code tying up scheduler threads for too long. The enif_schedule_nif() function also replaces the original experimental dirty NIF API. The function takes a flags parameter that a caller can use to indicate the NIF should be scheduled onto either a dirty CPU scheduler thread, a dirty I/O scheduler thread, or scheduled as a regular NIF on a regular scheduler thread. With this change, the original experimental enif_schedule_dirty_nif(), enif_schedule_dirty_nif_finalizer() and enif_dirty_nif_finalizer() API functions are no longer needed and have been removed. Explicit scheduling of a dirty NIF finalization function is no longer necessary; if an application wants similar functionality, it can have a dirty NIF just invoke enif_schedule_nif() to schedule a non-dirty NIF to complete its task. Lift the restriction that dirty NIFs can't call enif_make_badarg() to raise an exception. This was a problem with the original dirty NIF API because it forced developers to get and check all incoming arguments in a regular NIF, and then schedule the dirty NIF which then had to get all the arguments again. Now, the argument checking can be done in the dirty NIF and it can call enif_make_badarg() itself to flag incorrect arguments. Extend the ErlNifFunc struct with a new flags field that allows NIFs to be declared as dirty. The default value for this field is 0, indicating a regular NIF, so it's backwards compatible with all existing statically initialized ErlNifFunc struct instances, and so such instances require no code changes. Defining the flags field with a value of ERL_NIF_DIRTY_JOB_CPU_BOUND indicates that the NIF should execute on a dirty CPU scheduler thread, or defining it with a value of ERL_NIF_DIRTY_JOB_IO_BOUND indicates that the NIF should execute on a dirty I/O scheduler thread. Any other flags field value causes a NIF library loading error. Extend the ErlNifEntry struct with a new options field that indicates whether a NIF library was built with support for optional features such as dirty NIFs. When a NIF library is loaded, the runtime checks the options field to ensure compatibility. If a NIF library built with dirty NIF support is loaded into a runtime that does not support dirty NIFs, and the library defines one or more ErlNifFunc entries with non-zero flags fields indicating dirty NIFs, a NIF library loading error results. There is no error if a NIF library built with dirty NIF support is loaded into a runtime that does not support dirty NIFs but the library does not have any dirty NIFs. It is also not an error if a library without dirty NIF support is loaded into a runtime built with dirty NIF support. Add documentation and tests for enif_schedule_nif().