C++/Rust Interop: Using Bridges in Practice
1 - New Rust Extends a C++ Project 5Large existing C++ Library New Plugin Existing Plugins 6C++ Header Class with Methods C++ Source Uses extern “C” from Rust Unsafe Rust C ABI Safe Rust hpp cpp std::unique_ptr<rust::Joint, deleter_from_fn> robot_joint_; }; } // namespace robot_joint hpp 10namespace robot_joint::rust { struct Joint; } // namespace robot_joint::rust extern "C" "C" { extern void robot_joint_free(robot_joint::rust::Joint*); } template struct deleter_from_fn { template constexpr void operator()(T* arg) const { fn(arg); } }; hpp 0 码力 | 45 页 | 724.12 KB | 5 月前3Shared Libraries
auto* pf = &f; lib1 .dynsym f: .plt_exe+8C++ Implication #4: Comparing Func Ptrs • Not comprehensive: • Different for –fpie • Different for comparison between pointers both taken at shared libs Fedore) configure compilers to build with –z relro : “relocate+read only” • Other languages (zig, rust) do too. • Could consider –no-plt too • Not always possible: https://gcc.gnu.org/bugzilla/show_bug0 码力 | 69 页 | 1.40 MB | 5 月前3So You Think You Can Hash
@ciura_victor Victor Ciura Principal Engineer Rust Tooling @ Microsoft 🐘 @ciura_victor@hachyderm.io 🦋 @ciuravictor.bsky.social 🦀 So You Think You Can Hash CppCon September 20242024 Victor Visual C++ @ciura_victor 🐘 @ciura_victor@hachyderm.io 🦋 @ciuravictor.bsky.social Oxidizer SDK 🦀 Rust Tooling 🦀2024 Victor Ciura | @ciura_victor - Unleashing 🦀 The Ferris Within 4 Motivation Title I'm not here to: convert anyone to 🦀 Rust start any language wars "sell the Rust snake oil" tell you to RiiR So, don't throw 🍅 Rust ❤ C++2024 Victor Ciura | @ciura_victor - Unleashing0 码力 | 119 页 | 6.54 MB | 5 月前3C++ Exceptions for Smaller Firmware
func3() -> Result{ return Ok(13); } Using Rust rustc --target thumbv7em-none-eabi -C opt-level="s" --emit=obj rust.rs 18400000000 <rust::combined::h7a7b0cc556a62e18>: 0: b5f0 push 2c: e00b b 0x46 2e: 4668 mov r0, sp Return Rust: Disassembled! objdump --disassemble --demangle rust.o > rust.S 30: f7ff fffe bl 0x30 34: e9dd 0100 ldrd r0, r1, [sp] fn func3() -> Result { Ok(13) } Using Rust (u64) rustc --target thumbv7em-none-eabi -C opt-level="s" --emit=obj rust.rs 18600000000 <rust::combined::hece36e1d2889c9fd>: 0: b5f0 0 码力 | 237 页 | 6.74 MB | 5 月前3Lifetime Safety in C++: Past, Present and Future
issues | ZDNET • Memory safety (chromium.org) • Implications of Rewriting a Browser Component in Rust - Mozilla Hacks - the Web developer blog • Google Online Security Blog: Memory Safe Languages in Profile Crubit: Adopting Rust’s Type System P2771: Thomas Neumann’s Dependency AnnotationsFuture of C++? C++ Core Guidelines’ Lifetime Safety Profile Crubit: Adopting Rust’s Type System P2771: Value SemanticsFuture of C++? C++ Core Guidelines’ Lifetime Safety Profile Crubit: Adopting Rust’s Type System P2771: Thomas Neumann’s Dependency Annotations Vale: Generational References +0 码力 | 124 页 | 2.03 MB | 5 月前3C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串
这个特殊的名字空间里包含了所有的 operator“” 函数。 小彭老师锐评:何谓“键盘压力” • 高情商:键盘压力,指的是程序员敲击键盘时产生的心理压力。 • 低情商:键盘压力,指的是 rust 键盘侠对 cpp 标准委员会的压力。 • rust 键盘侠曰:我们有 233_i32 , cpp 做得到吗? • cpp 标准委员会:谢邀,人在 cpp14 ,已经在 operator“”_i32 了。 • 其实 cpp namespace ,不会存在强迫别人接受你的那一套后缀名规范。 • 甚至可以自定义一个 class int32 具有成员函数,然后就可以快乐地 233_i32 .some_method() 了。而 rust 这种预先规定好一些后缀,就只能是他们标准库的那 个 int32 ,不能自己定义了。 • 所以 cpp 之父曾经说,他设计 cpp11 的时候,是考虑“如何在对语言本身改动最小的情况下 ,尽量只 }; • void cihou_array(FatPtr fptr); • 这就是 rust 炫耀已久的数组胖指针。 C++20 中的 span 也是这个思想。 • 他提倡把 ptr 和 len 这两个逻辑上相关的参数绑在一起,避免程序员犯错。 用胖指针表示字符串 • 其实胖指针的思想既不是 rust 原创的,也不是 C++20 以后才出现的。 • 为了表示动态长度的数组, C++ 中的 vector0 码力 | 162 页 | 40.20 MB | 1 年前3Cooperative C++ Evolution
JavaScript, C++, Objective-C) C++ examples CCured*, CFlat*, CNatural**, Cyclone**, D*, .NET*, Rust*… — C++11/14/17/20/23 Dart* ES 4, Python 3 TypeScript Swift ES 2-10 (except 4) C99/11/17, Python JavaScript, C++, Objective-C) C++ examples CCured*, CFlat*, CNatural**, Cyclone**, D*, VB.NET*, Rust*… — C++11/14/17/20/23 Dart* ES 4, Python 3 TypeScript Swift ES 2-10 (except 4) C99/11/17, Python JavaScript, C++, Objective-C) C++ examples CCured*, CFlat*, CNatural**, Cyclone**, D*, VB.NET*, Rust*… — C++11/14/17/20/23 Dart* ES 4, Python 3 TypeScript Swift ES 2-10 (except 4) C99/11/17, Python0 码力 | 85 页 | 5.73 MB | 5 月前3Coroutines and Structured Concurrency in Practice
of structured concurrency • nursery in Python trio • task group in Python asyncio • task scope in Rust • coroutine scope in Kotlin • async_scope in nvidia/stdexec We also call it a nursery (mnemonics: are opting out from ever supporting any of these Rust developers learned that the hard way https://carllerche.com/2021/06/17/six-ways-to-make-async-rust-easier/Sketching cancellation procedure • Forward0 码力 | 103 页 | 1.98 MB | 5 月前3A Long Journey of Changing std::sort Implementation at Scale
Default for standard sorting is unstable Python, Rust, Java have stable default sorts 73.2SOME THOUGHTS Default for standard sorting is unstable Python, Rust, Java have stable default sorts Why do we have even if comparator is broken? 73.3SOME THOUGHTS Default for standard sorting is unstable Python, Rust, Java have stable default sorts Why do we have std::sort that can read OOB even if comparator is broken0 码力 | 182 页 | 7.65 MB | 5 月前3CROSS PLATFORM PITFALLS AND HOW TO AVOID THEM
problemsTESTING The problems 2020: The Year of Sanitizers? – Victor Ciura Closing the Gap between Rust and C++ Using Principles of Static Analysis – Sunny ChatterjeeTesting: the problems Many C++ developers Reid Tuesday 15th • Building an Intuition for Composition – Sy Brand • Closing the gap between Rust and C++ using principles of static analysis – Sunny Chatterjee • C++20 STL Features: 1 Year of0 码力 | 67 页 | 360.44 KB | 5 月前3
共 91 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10