Tagged articles
3 articles
Page 1 of 1
Sohu Tech Products
Sohu Tech Products
Jan 22, 2025 · Mobile Development

A Comprehensive Guide to Swift Macros and SwiftSyntax Implementation

This guide explains Swift 5.9 macros—both attached and freestanding—detailing how the compiler expands them using SwiftSyntax’s AST manipulation, walks through creating and declaring macros, and demonstrates a PeerMacro that automatically generates async counterparts for completion‑handler functions, reducing boilerplate and improving code clarity.

CompilerMacro ExpansionSwift 5.9
0 likes · 29 min read
A Comprehensive Guide to Swift Macros and SwiftSyntax Implementation
Liangxu Linux
Liangxu Linux
Feb 15, 2021 · Fundamentals

How Linux Implements Per‑CPU Variables: From Definition to Runtime Access

This article explains the concept of per‑CPU variables in the Linux kernel, how they are defined with DEFINE_PER_CPU, linked into the .data..percpu section, initialized during boot, and accessed at runtime via the GS register and macro expansions such as this_cpu_read_stable.

AssemblyLinuxMacro Expansion
0 likes · 16 min read
How Linux Implements Per‑CPU Variables: From Definition to Runtime Access