步骤

1. 执行configure

2. 将你的bifs加入至erts/emulator/beam/bif.tab

bif re:grep/2 bif re:compile/1

3. 创建一个C代码文件

erts/emulator/beam/erl_bif_re.c

4.将你的C代码文件加入至erts/emulator/<arch>/Makefile里

RUN_OBJS = $(OBJDIR)/erl_bif_re.o \

5. implement your bifs by stealing bits from existing erl_bif_*.c files

參考其余的erl_bif_*.c文件,加入以下这段代码

1
2
3
4
5
BIF_RETTYPE re_grep_2(BIF_ALIST_2){
  Eterm result;
  result = magic_function();
  BIF_RET(result);
}

6. 执行make; make install

重点回想:

步骤0-3仅仅需执行一次,假设你将以下的bif
1
bif re:grep/2

加入至bif.tab时。erl_bif_re.c文件要实现以下这个函数

title=Adding_my_own_BIF#" class="toolbar_item command_help help" style="font-variant: inherit; color: white !important; margin: 0px !important; padding: 1px 0px 0px !important; border: 0px !important; font-size: 1em !important; vertical-align: baseline !important; text-decoration: none !important; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; outline: 0px !important; overflow: visible !important; position: static !important; right: auto !important; text-align: center !important; top: auto !important; width: auto !important; box-sizing: content-box !important; min-height: inherit !important; display: block !important;">?

1
BIF_RETTYPE re_grep_2(BIF_ALIST_2);

[Erlang]怎样加入自己的BIF的更多相关文章

  1. erlang 健壮性

    erlang 提供了简单易用的并发编程模型,基本不需要再考虑多线程并发问题.但实际应用中并不是那么的完美,很多地方需要注意,就算标准库也有不少问题.很多在多线程编程中很多很容易解决的事情,在erlan ...

  2. erlang note

    没有关于erlang interface ,继续寻找吧... --------------------------------------------------------------- erl - ...

  3. Erlang数据类型的表示和实现(5)——binary

    binary 是 Erlang 中一个具有特色的数据结构,用于处理大块的“原始的”字节块.如果没有 binary 这种数据类型,在 Erlang 中处理字节流的话可能还需要像列表或元组这样的数据结构. ...

  4. erlang虚拟机代码执行原理

     转载:http://blog.csdn.NET/mycwq/article/details/45653897 erlang是开源的,很多人都研究过源代码.但是,从erlang代码到c代码,这是个不小 ...

  5. erlang判断模块导出函数问题

    erlang本身提供一个接口,可以用来检查模块是否有导出函数,这个接口是erlang:function_exported/3,但是很多时候这个接口无法正常使用. 下面重现一下这个问题: 1> e ...

  6. erlang学习笔记

    安装 Ubuntu Server上: sudo apt-get install erlang 如果安装时下载 太慢,可手工下载deb包( esl-erlang_16.a-rc1_ubuntu_prec ...

  7. [Erlang 0126] 我们读过的Erlang论文

    我在Erlang Resources 豆瓣小站上发起了一个征集活动 [链接] ,"[征集] 我们读过的Erlang论文",希望大家来参加.发起这样一个活动的目的是因为Erlang相 ...

  8. [Erlang 0119] Erlang OTP 源码阅读指引

      上周Erlang讨论群里面提到lists的++实现,争论大多基于猜测,其实打开代码看一下就都明了.贴出代码截图后有同学问这代码是哪里找的?   "代码去哪里找?",关于Erla ...

  9. [Erlang 0116] 当我们谈论Erlang Maps时,我们谈论什么 Part 1

         Erlang 增加 Maps数据类型并不是很突然,因为这个提议已经进行了2~3年之久,只不过Joe Armstrong老爷子最近一篇文章Big changes to Erlang掀起不小了风 ...

随机推荐

  1. Show username instead of "System Account" in SharePoint 2010

    Problems: When I load my local SharePoint site, the account always show as "System Account" ...

  2. tlplayer,wzplayer支持wince,winphone,windows8 for arm

    tlplayer,wzplayer宣布支持wince,winphone,windows8 for arm,支持http,hls,rtmp,rtsp,mms等媒体流协议. 支持加密视频播放. 目前tlp ...

  3. Oracle EBS 预警系统管理

    本章主要讲述配置和设置Oracle EBS预警系统管理, 它比较方便和及时发用户或系统对数据库操作情况.下面讲一操作步聚: 1.预警系统管理-->系统-->选项 名称"Unix ...

  4. 细说SQL性能优化

    1:在进行多表关联时,多用where语句把单个表的结果集最小化,多用聚合函数汇总结果集后再与其它表做关联,以使结果集数据量最小化2:在两张表进行关联时,应考虑可否使用右连接.以提高查询速度3:使用wh ...

  5. Android启动时间测试方法

    android apk启动时间可以通过下面的命令来完成测试,最终会生成一个mp4的视屏文件,通过播放录制好的视屏来统计app的启动时间精确到ms级别   例如:adb shell screenreco ...

  6. jquery的小插件(按钮抖动)——衍生QQ窗口抖动

    1.抖动的按钮 效果预览:http://runjs.cn/detail/tyx8dbag <script type="text/javascript"> //shake ...

  7. golang安装卸载 linux+windows+raspberryPI 平台

    参考  https://golang.org/doc/install 自ECUG2013洗脑回来,就渴望早点接触Go 听着许式伟和谢孟军的演讲 发现go的网络库的确很强大,高负载利器,语言的一些精简导 ...

  8. 正则表达式(来源http://deerchao.net/tutorials/regex/regex.htm)

    目录 跳过目录 本文目标 如何使用本教程 正则表达式到底是什么东西? 入门 测试正则表达式 元字符 字符转义 重复 字符类 分枝条件 反义 分组 后向引用 零宽断言 负向零宽断言 注释 贪婪与懒惰 处 ...

  9. 关于FP-Growth 算法一个很好的ppt-学习分享

    http://pan.baidu.com/share/link?shareid=1980963149&uk=1594824745

  10. javascript设计模式2

    接口:利 固化一部分代码 弊 丧失js的灵活性 在JavaScript中模仿接口 /* interface Composite{ function add(child); function remov ...