aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2012-11-16 09:37:24 +0100
committerPatrik Nyblom <[email protected]>2012-11-16 09:37:24 +0100
commitd51f75af306975ba59e5eee1d86bf10ea00135ff (patch)
tree1a90166c9cd1a238d7684a99b9f6521a63970fda
parent15f3cb7cb7074d507f70e778862e285e844b8546 (diff)
parent4e0cca34aaf815f7320370ee42ddbd0d772fd806 (diff)
downloadotp-d51f75af306975ba59e5eee1d86bf10ea00135ff.tar.gz
otp-d51f75af306975ba59e5eee1d86bf10ea00135ff.tar.bz2
otp-d51f75af306975ba59e5eee1d86bf10ea00135ff.zip
Merge branch 'pan/port_driver_tutorial/OTP-10573' into maint
* pan/port_driver_tutorial/OTP-10573: Bring driver tutorial up to date.
-rw-r--r--system/doc/tutorial/port_driver.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/system/doc/tutorial/port_driver.c b/system/doc/tutorial/port_driver.c
index d428d08ff3..37de67310f 100644
--- a/system/doc/tutorial/port_driver.c
+++ b/system/doc/tutorial/port_driver.c
@@ -19,7 +19,8 @@ static void example_drv_stop(ErlDrvData handle)
driver_free((char*)handle);
}
-static void example_drv_output(ErlDrvData handle, char *buff, int bufflen)
+static void example_drv_output(ErlDrvData handle, char *buff,
+ ErlDrvSizeT bufflen)
{
example_data* d = (example_data*)handle;
char fn = buff[0], arg = buff[1], res;
@@ -32,7 +33,7 @@ static void example_drv_output(ErlDrvData handle, char *buff, int bufflen)
}
ErlDrvEntry example_driver_entry = {
- NULL, /* F_PTR init, N/A */
+ NULL, /* F_PTR init, called when driver is loaded */
example_drv_start, /* L_PTR start, called when port is opened */
example_drv_stop, /* F_PTR stop, called when port is closed */
example_drv_output, /* F_PTR output, called when erlang has sent */
@@ -40,9 +41,30 @@ ErlDrvEntry example_driver_entry = {
NULL, /* F_PTR ready_output, called when output descriptor ready */
"example_drv", /* char *driver_name, the argument to open_port */
NULL, /* F_PTR finish, called when unloaded */
+ NULL, /* void *handle, Reserved by VM */
NULL, /* F_PTR control, port_command callback */
NULL, /* F_PTR timeout, reserved */
- NULL /* F_PTR outputv, reserved */
+ NULL, /* F_PTR outputv, reserved */
+ NULL, /* F_PTR ready_async, only for async drivers */
+ NULL, /* F_PTR flush, called when port is about
+ to be closed, but there is data in driver
+ queue */
+ NULL, /* F_PTR call, much like control, sync call
+ to driver */
+ NULL, /* F_PTR event, called when an event selected
+ by driver_event() occurs. */
+ ERL_DRV_EXTENDED_MARKER, /* int extended marker, Should always be
+ set to indicate driver versioning */
+ ERL_DRV_EXTENDED_MAJOR_VERSION, /* int major_version, should always be
+ set to this value */
+ ERL_DRV_EXTENDED_MINOR_VERSION, /* int minor_version, should always be
+ set to this value */
+ 0, /* int driver_flags, see documentation */
+ NULL, /* void *handle2, reserved for VM use */
+ NULL, /* F_PTR process_exit, called when a
+ monitored process dies */
+ NULL /* F_PTR stop_select, called to close an
+ event object */
};
DRIVER_INIT(example_drv) /* must match name in driver_entry */