概述
警告:此库仍在积极开发中,API 可能发生变化。
libhandler 在 C 语言中实现了代数效应处理程序。它通过安全且可移植的方式捕获栈。代数效应处理程序可用于以直线方式编写异步代码,我们希望用它使 libuv 编程更加便捷。
本库的详细说明见随附的 技术报告。若需了解代数效应的入门知识,请参阅 koka 手册 中的相关章节。
祝使用愉快!
-- Daan.
构建
构建 libhandler 即生成一个可链接到您自己项目中的静态 C 库。libhandler 力求尽可能可移植,但依赖于栈和 setjmp 实现的一些平台特定假设。在新平台上请仔细测试。目前已测试的平台包括:
-
(
gcc,clang,cl)-x86-pc-windows(32 位,Windows) -
(
gcc,clang,cl)-x64-pc-windows(64 位,Windows) -
(
gcc,clang)-amd64-pc-linux(64 位,Ubuntu 16.04) -
(
gcc,clang)-arm-linux(32 位,ARMv7 (树莓派 3,Raspbian/Debian Jessie)) -
gcc-arm64-linux(64 位,ARMv8 (树莓派 3,Gentoo Linux))
C++ 支持正在开发中。
在 test/libuv 目录(位于 dev 分支)中已有与 libuv 集成的初步测试代码。Microsoft IDE 方案包含一个用于构建 libuv 的项目。
Unix/MacOSX
使用常规的 configure 和 make 构建:
$ ./configure
$ make depend
$ make
使用 VARIANT=release 构建发布版本,并以 tests 为目标运行测试。例如:
$ make tests VARIANT=release
配置选项:
--cc=<cc>: 指定要使用的 C 编译器(如gcc、clang等)--cc-opts=<options>: 指定要使用的额外 C 编译器标志(如-m64)--asm-opts=<options>: 指定要使用的额外汇编器标志(如-m64)--abi=<abi>: 指定调用约定 ABI。例如--abi=amd64或--abi=x64。--os=<os>: 指定目标操作系统,例如--os=windows。--ar=<archiver>: 指定用于创建静态库的归档工具(=ar)--cxx=<c++ compiler>: 指定要使用的 C++ 编译器(=$cc++)--link=<linker>: 指定要使用的链接器(=$cc)
Make 参数:
VARIANT=<debug|testopt|release> : 指定构建变体。testopt构建优化版本但保留断言。VALGRIND=1: 在 valgrind 下运行测试以进行内存泄漏检测。
Make 目标:
staticlib: 构建静态库。tests: 构建并运行测试。bench: 构建并运行基准测试。clean: 清理所有输出。staticlibxx: 为 C++ 构建库(支持异常和析构函数展开)。testsxx: 构建并运行 C++ 测试。
Windows
在 Windows 上有三种构建方式:
-
使用 Microsoft Visual C++ IDE。2015 Community 版 可免费用于非商业用途。 解决方案位于:
-
在 Windows 10 上启用“Linux 子系统”。请参阅 MSDN 获取安装说明。启用后,您可以在命令提示符下运行
bash进入 Windows 下的 Ubuntu Linux。 使用apt安装开发工具:sudo apt-get updatesudo apt install build-essentialsudo apt install clang
之后即可如前所述运行
configure和make。 -
在旧版 Windows 上,可使用
msys2, 下载地址 http://msys2.github.io。请仔细遵循安装说明。安装后,可使用msys2包管理器安装其他工具:pacman -S mingw-w64-x86_64-gcc(C 编译器)pacman -S mingw-w64-x86_64-gdb(调试器)pacman -S make(make)
之后即可如前所述运行
configure和make。
在 Windows 上成功的 bash 配置:
gcc-amd64-pc-linux-gnu
直接使用./configureclang-amd64-pc-linux-gnu
先执行sudo apt install clang,再执行./configure --cc=clang
使用 msys2 在 Windows 上成功的配置:
gcc-x64-w64-mingw32
直接使用./configuregcc-x86-w64-mingw32
使用安装了mingw-w64-i686-toolchain的mingw32shell。clang-x64-pc-windows
使用./configure --cc=/c/programs/llvm/bin/clang。clang-x86-pc-windows(32 位)
使用./configure --cc=/c/programs/llvm/bin/clang --cc-opts=-m32 --asm-opts=-m32。
使用 Visual Studio IDE:
cl-x64-pc-windows选择 64 位构建。cl-x86-pc-windows选择 32 位构建。
Windows 上的 LibUV
已在 Visual Studio 的 x64 构建中启用。您需要在主 libhandler 文件夹下的 libuv 文件夹中放置 libuv 头文件和二进制文件。
Windows 的二进制文件可在 libuv.org 找到。
0 Comments
Log in to join the conversation.No comments yet. Be the first to share your thoughts.