Adding my own BIF
From Erlang Community
(Difference between revisions)
| Revision as of 15:54, 31 July 2006 (edit) Massemanet (Talk | contribs) ← Previous diff |
Revision as of 16:56, 31 July 2006 (edit) (undo) Massemanet (Talk | contribs) Next diff → |
||
| Line 1: | Line 1: | ||
| - | + | :1. run configure | |
| - | + | :2. add your bifs to erts/emulator/beam/bif.tab | |
| - | + | <tt> | |
| - | < | + | |
| bif re:grep/2 | bif re:grep/2 | ||
| bif re:compile/1 | bif re:compile/1 | ||
| - | </ | + | </tt> |
| - | + | :3. create a C file | |
| - | + | <tt> | |
| - | < | + | |
| erts/emulator/beam/erl_bif_re.c | erts/emulator/beam/erl_bif_re.c | ||
| - | </ | + | </tt> |
| - | + | :4. add your C file to erts/emulator/<arch>/Makefile | |
| - | < | + | <tt> |
| RUN_OBJS = $(OBJDIR)/erl_bif_re.o \ | RUN_OBJS = $(OBJDIR)/erl_bif_re.o \ | ||
| - | </ | + | </tt> |
| - | + | :5. implement your bifs by stealing bits from existing erl_bif_*.c files | |
| - | < | + | <tt> |
| BIF_RETTYPE re_grep_2(BIF_ALIST_2){ | BIF_RETTYPE re_grep_2(BIF_ALIST_2){ | ||
| - | + | Eterm result; | |
| - | + | result = magic_function(); | |
| - | + | BIF_RET(result); | |
| } | } | ||
| - | </ | + | </tt> |
| - | + | :6. run make; make install | |
| steps 0-3 need only be done once. | steps 0-3 need only be done once. | ||
| note that if you add | note that if you add | ||
| - | < | + | <tt> |
| bif re:grep/2 | bif re:grep/2 | ||
| - | </ | + | </tt> |
| to bif.tab there should be a | to bif.tab there should be a | ||
| - | < | + | <tt> |
| erl_bif_re.c | erl_bif_re.c | ||
| - | </ | + | </tt> |
| that implements | that implements | ||
| - | < | + | <tt> |
| BIF_RETTYPE re_grep_2(BIF_ALIST_2); | BIF_RETTYPE re_grep_2(BIF_ALIST_2); | ||
| - | </ | + | </tt> |
| [[Category:HowTo]] | [[Category:HowTo]] | ||
Revision as of 16:56, 31 July 2006
- 1. run configure
- 2. add your bifs to erts/emulator/beam/bif.tab
bif re:grep/2 bif re:compile/1
- 3. create a C file
erts/emulator/beam/erl_bif_re.c
- 4. add your C file to erts/emulator/<arch>/Makefile
RUN_OBJS = $(OBJDIR)/erl_bif_re.o \
- 5. implement your bifs by stealing bits from existing erl_bif_*.c files
BIF_RETTYPE re_grep_2(BIF_ALIST_2){ Eterm result; result = magic_function(); BIF_RET(result); }
- 6. run make; make install
steps 0-3 need only be done once.
note that if you add bif re:grep/2 to bif.tab there should be a erl_bif_re.c that implements BIF_RETTYPE re_grep_2(BIF_ALIST_2);

Digg It
Del.icio.us
Reddit
Facebook
Stumble Upon
Technorati

