How2Code
发现一个很有意思的事情。 我们知道对于std::function或者lambda来说只有没有捕获外层变量才能退化成函数指针,但是在Python对C风格函数指针进行FFI调用的时候却可以随意捕获变量(生成闭包),比如对于 void register_callback(callback_fn callback) 这样的C函数签名,在Python代码里可以传入任意闭包。 对于其中的原因我思考了很久才发现了华点:Python本身自带一个编译器,所以在运行期也可以动态编译闭包,而C++运行期并没有这种可能。动态语言真是太好辣.jpg
Lazymio's Blog
Cast a Closure to a Function Pointer -- How libffi closure works
CallbacksThis post also has a Chinese version: 把闭包变成函数指针——libffi 闭包原理解析. As is often the case, a lib written in C may expose an API which accepts a function pointer as a callback function like: 123typ
How2Code
勘误:Python并不是动态编译闭包,而是 libffi 提供了把闭包变成函数指针的能力。我写了文章和demo验证这点。 英文版 中文版 Demo
Update: 这篇文章居然被libffi作者注意到了。。。尴尬的是我图错了 草
被linker坑傻了,重名符号但是在不同的static lib里,链接的时候不报错。
https://stackoverflow.com/questions/59978787/same-object-file-in-different-static-libraries-when-linking
https://stackoverflow.com/questions/59978787/same-object-file-in-different-static-libraries-when-linking
Stack Overflow
Same object file in different static libraries when linking
clang++ ... foo.cpp ... -o dir1/foo.o
clang++ ... foo.cpp ... -o dir2/foo.o
//The only difference beween the above two clang++ command lines
//is the output directory
llvm-ar ... dir1/lib1.a ... d...
clang++ ... foo.cpp ... -o dir2/foo.o
//The only difference beween the above two clang++ command lines
//is the output directory
llvm-ar ... dir1/lib1.a ... d...
https://github.com/desktop/desktop/issues/12978
Holly shit! Apple 又毁了我一天。
TLDR:Bug Sir以后的macOS,在有MAP_JIT的情况下fork会很慢,具体有多慢呢,Linux上0.0004us而macOS需要0.06us,也就慢150倍吧。使用posix_spawn可以绕开bug,受影响的应用包括libuv,electron等,目前尚未完全修复。
PS:在Intel mac上 hardened runtime 并不是强制的,也就是说可以直接不用 MAP_JIT 绕开,而 M1 mac 目前没有办法。
Holly shit! Apple 又毁了我一天。
TLDR:Bug Sir以后的macOS,在有MAP_JIT的情况下fork会很慢,具体有多慢呢,Linux上0.0004us而macOS需要0.06us,也就慢150倍吧。使用posix_spawn可以绕开bug,受影响的应用包括libuv,electron等,目前尚未完全修复。
PS:在Intel mac上 hardened runtime 并不是强制的,也就是说可以直接不用 MAP_JIT 绕开,而 M1 mac 目前没有办法。
GitHub
Upgrade to Electron v13 · Issue #12978 · desktop/desktop
In an attempt to upgrade GitHub Desktop to Electron v12 and then v13, we ran into a performance issue affecting unsigned builds on Big Sur (and potentially Monterey too). More specifically, using s...
给自己项目打个广告
我们的项目 Qiling 参加了 Google Summer of Code 2022,用人话说就是 Google 掏钱支持你暑期给开源项目做贡献,大概四五月开始报名,报名后需要根据 Idea 提 Proposal 然后跟着 Mentor 写项目,但是一般二三月就开始找Idea了,我们项目目前的 Idea 在这里:https://github.com/qilingframework/qiling/discussions/1083
工资补贴见:https://developers.google.com/open-source/gsoc/help/student-stipends
我们的项目 Qiling 参加了 Google Summer of Code 2022,用人话说就是 Google 掏钱支持你暑期给开源项目做贡献,大概四五月开始报名,报名后需要根据 Idea 提 Proposal 然后跟着 Mentor 写项目,但是一般二三月就开始找Idea了,我们项目目前的 Idea 在这里:https://github.com/qilingframework/qiling/discussions/1083
工资补贴见:https://developers.google.com/open-source/gsoc/help/student-stipends
GitHub
GSoC 2022: Qiling's Debut! · qilingframework/qiling · Discussion #1083
Hello! It is the first time we participate in Google Summer of Code and we are offering interesting ideas and projects for students of all levels. As our README suggests, Qiling is an advanced bina...
https://stackoverflow.com/questions/50605/signed-to-unsigned-conversion-in-c-is-it-always-safe
本身不算什么新鲜的事情,但是真正有趣的是只有g++报了这个warning
本身不算什么新鲜的事情,但是真正有趣的是只有g++报了这个warning
~ > cat /tmp/test.c
#include "stdio.h"
#include "stdlib.h"
inline int test(){
return 1;
}
int main(){
if (test()) {
printf("test\n");
}
}
~ > gcc /tmp/test.c -o /tmp/test
/usr/bin/ld: /tmp/ccwgqM5z.o: in function `main':
test.c:(.text+0xe): undefined reference to `test'
collect2: error: ld returned 1 exit status
这就是C语言吗.jpg
Explanation
Reddit
Inline function undefined reference : r/C_Programming
141K subscribers in the C_Programming community. The subreddit for the C programming language
To incoming English speakers: I don't plan to release any English contents in this channel though you might find equivelant posts in my English blog: https://blog.lazym.io. I appreciate your interests in my channel.
Lazymio's Blog
Hi! I'm Ziqiao Kong, a 2nd year Ph.D. student supervised by [Prof. Liu Yang](https://personal.ntu.edu.sg/yangliu/) at Nanyang Technological University. I obtained my master degree in computer science
2023 年 12 月 45 号更新今年文章!
现在拥有 2 台 64C128T + 1T 的机器了,尽享数框框的乐趣
还有就是小心 System Phd
https://blog.ihomura.cn/2024/01/14/EPYC-%E5%B7%A5%E4%BD%9C%E7%AB%99%E9%80%89%E8%B4%AD%E5%AE%9E%E6%88%98%E4%B8%8E%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/
现在拥有 2 台 64C128T + 1T 的机器了,尽享数框框的乐趣
https://blog.ihomura.cn/2024/01/14/EPYC-%E5%B7%A5%E4%BD%9C%E7%AB%99%E9%80%89%E8%B4%AD%E5%AE%9E%E6%88%98%E4%B8%8E%E7%BB%8F%E9%AA%8C%E5%88%86%E4%BA%AB/
澪同学的博客 - 个人的技术分享
EPYC 服务器选购实战与经验分享
前言 自从开始读 Ph.D. 之后,对算力的要求逐步增长,因此一直想购入强劲的服务器用于科研玩装机,感谢近几年的 AMD 强势,我居然只用了大概 4 万元就拿下了两台 EPYC 7B13 64C128T + 1T 内存的工作站,这篇文章就来简单分享一下整个实战过程和一些经验。
https://blog.lazym.io/2024/07/19/Escaping-from-sync-to-async-world-and-vice-versa/
如何在 rust 的 sync 和 async 反复横跳?
今年的更新指标完成啦
如何在 rust 的 sync 和 async 反复横跳?
Lazymio's Blog
Escaping from sync to async world with tokio, and vice-versa
MotivationWriting rust is a great pleasure when the code is either purely synchronous or asynchronous. However, the awkward thing kicks in if you try to jump between the two worlds. Although there is