[erlang-questions] Help! Do I need erl_driver_compat.h

G Bulmer <>
Fri Nov 14 19:27:32 CET 2008


I'm trying to write a Linked-in driver.
My guru's have suggested starting with the stdio buffered FILE i/o  
driver 'bfile' as a good skeleton.

I have two question.

Q1. File FILE_drv.c (conditionally) #includes <erl_driver_compat.h>,  
but I can't find that file anywhere (on my machine, or using google;  
almost a googlewhack).
Briefly, what is it for? Is it 'deprecated', defunct, or does it come  
from some other contributed piece?

This is for Erlang-DTrace, so I don't expect to run on many OS's for a  
while (Solaris/OpenSolaris, Mac OS X, BSD and VXworks for now), though  
I would like the code to build without error, even if it is all null  
functions, on Erlang/OTP platforms.

I prefer to avoid stuff that I can't use, and can't test.
So can I safely throw away the #include <erl_driver_compat.h> ?


Q2. Why is the output done using ErlDrvData.control, and not  
ErlDrvData.output?
I can see that it is well-organised if all I/O goes through the one  
ErlDrvData.control function (and that is a good reason to me), but is  
there a performance difference between the two approaches?


Thanks in Advance for any help advice,
GB


PS. A tiny, irrelevant, point. In FILE_drv.c the macro symbol  
USE_STDIO is defined **always**, and then used to *conditionally*  
include stdio.h.

I can't find any definition of USE_STDIO in the Erlang source, or  
anywhere under /usr, /bin or /etc on Mac OS X.
I am not using stdio, so I'll remove all of this, but I am curious, is  
this necessary on some platform?

// ----
#define USE_STDIO

#ifdef WIN32
#define USE_STDIO
#include <windows.h>

#else

#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#endif /*WIN32*/

#include "erl_driver.h"
#ifndef ERL_DRV_NIL
#include "erl_driver_compat.h"
#endif

#ifdef USE_STDIO		// Always #include <stdio.h>
#  include <stdio.h>		// as it will anyway?
#else					// ----




More information about the erlang-questions mailing list