pcre, bifs, drivers and ports

Ernie Makris <>
Mon Jul 31 17:28:17 CEST 2006


Hi Mats,

Excellent, that process description will help!

Thanks
Ernie

Mats Cronqvist wrote:
> Ernie Makris wrote:
>> Hi Mats,
>>
>> I'd definitely be interested in seeing the code, 
>
>   i'll ask istvan (the author, i just came up with the idea and the
> API :>) if he'll post the code.
>
>   forgot to post an example in the previous post;
> > re:grep("foofoo",["fo","of([a-z])"]).
> [{0,2,[]},{2,5,["o"]}]
>
>> or even an overview of
>> the process to properly add a bif.
>
>
>   the (probably non-proper) process to add a bif is like this;
>
> 0) run configure
>
> 1) add your bifs to erts/emulator/beam/bif.tab
>
> e.g.
> bif re:grep/2
> bif re:compile/1
>
> 2) create a C file
>
> e.g.
> erts/emulator/beam/erl_bif_re.c
>
> 3) implement your bifs by stealing bits from existing erl_bif_*.c files
>
> e.g.
> BIF_RETTYPE re_grep_2(BIF_ALIST_2){
>  Eterm result;
>  result = magic_function();
>  BIF_RET(result);
> }
>
> 4) add your C file to erts/emulator/<arch>/Makefile
>
> e.g.
> RUN_OBJS = $(OBJDIR)/erl_bif_re.o \
>
> 5) run make; make install
>
>
>   note that if you add
> bif ernie:makris/1
>   to bif.tab
> there should be a erl_bif_ernie.c
>   that implements
> BIF_RETTYPE ernie_makris_1(BIF_ALIST_1);
>
>
>   note that i'm not really an expert on this. consider it an educated
> guess :>
>
>   mats
>



More information about the erlang-questions mailing list