Back To Basics Algorithmsstd::string firstname; std::string lastname; int age; }; int main() { std::vectortable = { Person{ "Homer", "Simpson", 38 } , Person{ "Marge", "Simpson", 34 11std::string firstname; std::string lastname; int age; }; int main() { std::vector table = { Person{ "Homer", "Simpson", 38 } , Person{ "Marge", "Simpson", 34 return EXIT_SUCCESS; } Fun with the Simpsons 12 11int main() { std::vector table = /* ... */; // Find the youngest person Fun with the Simpsons 13 11 // ... Let me find 0 码力 | 99 页 | 19.12 MB | 6 月前3
C++ Exceptions for Smaller Firmwareon GCC ARM 95Things that will NOT be covered here ● Nested exceptions ● Anything other than table based exceptions 96Consider the following 97 struct error {}; void foo() { try { bar(); Destructors…ARM Exception Table 130 __exidx_end Function Address 32-bits Exception Data Address Offset 0x7FFF'F700 =-2304 .exception_table LU16/32 personality GCC LSDA Note: Exception table is 32-bit alignedWhat alignedWhat is a LSDA? header call site table action table(s) personality function personality data type table 131 ● L.S.D.A. = Language Specific Data Area ● LSDA is included in the Itanium exception0 码力 | 237 页 | 6.74 MB | 6 月前3
POCOAS in C++: A Portable Abstraction for Distributed Data Structuresstructures - Data distributed across many processes - Globally accessible ‘a’,‘b’,‘c’ Distributed Hash Table Rank 0 Rank 1 Rank 2 Rank 3Data Structures - Data structures are split into two types: 1) Remote structures - Data distributed across many processes - Globally accessible ‘a’,‘b’,‘c’ Distributed Hash Table Rank 0 Rank 1 Rank 2 Rank 3 Rank 0Data Structures - Data structures are split into two types: structures - Data distributed across many processes - Globally accessible ‘a’,‘b’,‘c’ Distributed Hash Table Rank 0 Rank 1 Rank 2 Rank 3 Rank 0 Rank 3Data Structures - Constructors/destructors that must0 码力 | 128 页 | 2.03 MB | 6 月前3
CppCon 2021: Persistent Data StructuresStructures Live Demonstration References Use-Cases of Persistent Memory Metagenomics ▶ Persistent hash table to lookup genome fragments [13] Astronomy ▶ Persistent indexing structure to maintain data sets few cache misses ▶ Arrays ▶ Open addressing ▶ Low memory management overhead ▶ Allocate large table chunks A Persistent Hash Map for Graph Processing Workloads and a Methodology for Persistent Transactional Demonstration References PMap Design Overview ConcurrentHashMap table Table pairs CHM copyIdx copyDone size slots newTable K1 V1 K2 V2 K3 V3 K4 V4 Table pairs CHM copyIdx copyDone size slots newTable K1 V10 码力 | 56 页 | 1.90 MB | 6 月前3
Shared LibrariesImport data section 9.idata contents Directory Table Directory entry: • DLL Name • ImportLookupTable offset • ImportAddressTable offset • … Import Lookup Table* Imported symbol names/ordinals, for loader loader usage … … … Import Address Table (IAT) List of import addresses as resolved by the loader … … … https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section 10 * Actually resolver> jmp [got_slot_41] … … push 42 jmpjmp [got_slot_43] Procedure Lookup Table (PLT)PLT: some extra details • The 1st PLT entry is special and used in all PLT calls, add a module 0 码力 | 69 页 | 1.40 MB | 6 月前3
Compile-Time Compression and Resource Generation with C++206 . 2/ Lookup Tables Lets make a lookup table that does linear interpolation. Warning: constexpris a gcc extension [P1383] 7 . 1/ Table of sin(x) where x is in degrees, not radians Reusable std::sin(radians(degrees)); } constexpr auto DegreeSineTable = LerpTable ::make_table(0.0f, 90.0f, sine_deg); static_assert(DegreeSineTable(30.0f) >= 0.499f && DegreeSineTable(30 LerpTable { constexpr T operator()(T in) const { ... } constexpr static LerpTable make_table( T min, T max, T (&function)(T) ) { ... } private: struct Entry { 0 码力 | 59 页 | 1.86 MB | 6 月前3
C++ Under the HoodConstruction 10C++ Under the Hood – Inheritance Hierarchy 11C++ Under the Hood – __v_table_ptr 1213 C++ Under the Hood – __v_table_ptr / v_tableC++ Under the Hood – C’tor (Constructor Implementation) 14C++ Under Under the Hood – Construction (construct members)25 C++ Under the Hood – Construction (set this v_table)26 C++ Under the Hood – Polymorphism During Construction27 C++ Under the Hood – Polymorphism During Under the Hood – Construction (construct members)33 C++ Under the Hood – Construction (set this v_table)34 C++ Under the Hood – Polymorphism During Construction35 C++ Under the Hood – Construction360 码力 | 168 页 | 13.55 MB | 6 月前3
Class Layouthas a virtual function, every object of that type contains a pointer to a shared virtual function table. class B { public: virtual int f1(); virtual void f2(int); virtual int f3(int); ~~~ }; B *bp = new A single destructor will be often represented by two separate entries in the virtual function table; one is a “destroy and delete” destructor, while the other only destroys. 48 Copyright © 2020 by Calling Sequence The virtual calling sequence is indirect through the object’s virtual function table. The call bp‐>f1(); Is translated to something like (*(bp‐>vptr)[0])(bp) 49 B members bp0 码力 | 51 页 | 461.37 KB | 6 月前3
Exceptions Under the Spotlightexceptions exist: 1. Table based: gcc, clang (better happy path results). 2. Frame based (“code approach”): MSVC (better sad path results). PART II: EXCEPTIONS OVERHEAD 24 • Table based implementation function will contain additional information of list of catchable exceptions, as well as a cleanup table.PART II: EXCEPTIONS OVERHEAD 25 • Functionality is implemented in two main libraries (focusing on __register_frame_info __register_frame_info_bases __register_frame_info_table __register_frame_info_table_bases __register_frame_table __cxa_allocate_dependent_exception __cxa_allocate_exception __cxa_exception0 码力 | 53 页 | 2.82 MB | 6 月前3
C++20 镶 SQLthe customers table CREATE TABLE customers( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL ); Customers id INTEGER PRIMARY KEY name TEXTCreate the orders table CREATE TABLE orders( id INTEGER // R"( CREATE TABLE customers( id INTEGER NOT NULL PRIMARY KEY, name TEXT NOT NULL );)" // >{sqldb} .execute();Create Orders ftsd::prepared_statement< // R"( CREATE TABLE orders( id INTEGER0 码力 | 46 页 | 775.02 KB | 6 月前3
共 147 条
- 1
- 2
- 3
- 4
- 5
- 6
- 15













