Atomic `dbg`/`eprintln`/`eprint` macros

Overview

atomic-dbg

crates.io page docs.rs docs

This crate provides dbg, eprint, and eprintln, macros which work just like their counterparts in std, but which:

  • Write atomically, up to the greatest length supported on the platform.
  • Don't use locks (in userspace).
  • Preserve libc's errno and Windows' last-error code value.

This means they can be used just about anywhere within a program, including inside allocator implementations, inside synchronization primitives, startup code, around FFI calls, inside signal handlers, and in the child process of a fork before an exec.

And, when multiple threads are printing, as long as their within the length supported on the platform, the output is readable instead of potentially interleaved with other output.

For example, this code:

use atomic_dbg::dbg;

fn main() {
    dbg!(2, 3, 4);
}

Has this strace output:

write(2, "[examples/dbg.rs:4] 2 = 2\n[examples/dbg.rs:4] 3 = 3\n[examples/dbg.rs:4] 4 = 4\n", 78[examples/dbg.rs:4] 2 = 2

which is a single atomic write call.

For comparison, with std::dbg it looks like this:

write(2, "[", 1[)                        = 1
write(2, "examples/dbg.rs", 15examples/dbg.rs)         = 15
write(2, ":", 1:)                        = 1
write(2, "4", 14)                        = 1
write(2, "] ", 2] )                       = 2
write(2, "2", 12)                        = 1
write(2, " = ", 3 = )                      = 3
write(2, "2", 12)                        = 1
write(2, "\n", 1
)                       = 1
write(2, "[", 1[)                        = 1
write(2, "examples/dbg.rs", 15examples/dbg.rs)         = 15
write(2, ":", 1:)                        = 1
write(2, "4", 14)                        = 1
write(2, "] ", 2] )                       = 2
write(2, "3", 13)                        = 1
write(2, " = ", 3 = )                      = 3
write(2, "3", 13)                        = 1
write(2, "\n", 1
)                       = 1
write(2, "[", 1[)                        = 1
write(2, "examples/dbg.rs", 15examples/dbg.rs)         = 15
write(2, ":", 1:)                        = 1
write(2, "4", 14)                        = 1
write(2, "] ", 2] )                       = 2
write(2, "4", 14)                        = 1
write(2, " = ", 3 = )                      = 3
write(2, "4", 14)                        = 1
write(2, "\n", 1
)                       = 1
You might also like...
An attempt to implement equivalent of C++ "P1478R1: Byte-wise atomic memcpy" in Rust

atomic-memcpy Byte-wise atomic memcpy. This is an attempt to implement equivalent of C++ "P1478R1: Byte-wise atomic memcpy" in Rust. This is expected

Log for concurrent workloads, with support for atomic batches and in-order recovery

sharded-log A batch-oriented multi-threaded sharded log for workloads that occasionally flush logs into some other system. All batches have a 32-bit C

A lock-free, append-only atomic pool.

A lock-free, append-only atomic pool. This library implements an atomic, append-only collection of items, where individual items can be acquired and r

Moonshine CSS - πŸ₯ƒ High-proof atomic CSS framework

Moonshine CSS - πŸ₯ƒ High-proof atomic CSS framework

Cross-platform atomic wait and wake (aka futex) functionality for Rust.

Cross platform atomic wait and wake (aka futex) functionality. This crate only supports functionality that's available on all of Linux, Windows, and m

An intent-centric, privacy-preserving protocol for decentralized counterparty discovery, solving, and multi-chain atomic settlement.

Anoma Blockchain prototye This prototype aims to reproduce the following topology: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚Sol

An atomic save/load system for Bevy Game Engine.

☒️ Bevy Atomic Save An atomic save/load system for Bevy. Features Save and load a World into a RON file on disk Control which entities should particip

Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.
Linked Atomic Random Insert Vector: a thread-safe, self-memory-managed vector with no guaranteed sequential insert.

Linked Atomic Random Insert Vector Lariv is a thread-safe, self-memory-managed vector with no guaranteed sequential insert. It internally uses a linke

Mirroring remote repositories to s3 storage, with atomic updates and periodic garbage collection.

rsync-sjtug WIP: This project is still under development, and is not ready for production use. rsync-sjtug is an open-source project designed to provi

Thread-safe cell based on atomic pointers to externally stored data

Simple thread-safe cell PtrCell is an atomic cell type that allows safe, concurrent access to shared data. No std, no data races, no nasal demons (UB)

Extra iterator adaptors, iterator methods, free functions, and macros.

Itertools Extra iterator adaptors, functions and macros. Please read the API documentation here How to use with cargo: [dependencies] itertools = "0.1

Provides assert_eq! like macros with colorized diff output
Provides assert_eq! like macros with colorized diff output

similar-asserts similar-asserts is a crate that enhances the default assertion experience by using similar for diffing. It supports comparing either D

FeignHttp is a declarative HTTP client. Based on rust macros.

FeignHttp is a declarative HTTP client. Based on rust macros. Features Easy to use Asynchronous request Configurable timeout settings Suppor

Safe Rust --- GraalVM Polyglot bindings using procedural macros

The class macro is the primary way to generate bindings to Java types; it will generate a struct (with generics if specified) that implements Pass and Receive and has all the methods you give stubs for. The methods generated can be used like normal rust methods, however mutability is not enforced. The fully-qualified type name should precede a block containing method and constructor stubs. Java primitives like char, int, and byte are aliased to corresponding Rust types.

Pretend is a macros-based declarative Rust HTTP client

pretend is a modular, Feign-inspired HTTP, client based on macros. It's goal is to decouple the definition of a REST API from it's implementation.

Parsing and inspecting Rust literals (particularly useful for proc macros)

litrs: parsing and inspecting Rust literals litrs offers functionality to parse Rust literals, i.e. tokens in the Rust programming language that repre

A copypastable guide to implementing simple derive macros in Rust.

A copypastable guide to implementing simple derive macros in Rust. The goal Let's say we have a trait with a getter trait MyTrait {

todo-or-die provides procedural macros that act as checked reminders.

todo-or-die provides procedural macros that act as checked reminders.

Rust derive macros for automating the boring stuff.

derived: Macros for automating the boring stuff The derived crate provides macros that can simplify all the boring stuff, like writing constructors fo

Owner
Dan Gohman
I'm working on Wasmtime, WASI, and lots of things related to WebAssembly. mastodon.online/@sunfish
Dan Gohman
Helpful functions and macros for developing smart contracts on NEAR Protocol.

near-contract-tools Helpful functions and macros for developing smart contracts on NEAR Protocol. This package is a collection of common tools and pat

Jacob 27 Dec 17, 2022
Helpful functions and macros for developing smart contracts on NEAR Protocol.

near-contract-tools Helpful functions and macros for developing smart contracts on NEAR Protocol. This package is a collection of common tools and pat

NEARFoundation 9 Aug 3, 2022
zink! is a library for developing ink! smart contracts with useful Rust macros that extend functionality and reduce boilerplate code.

zink! Smart Contract Macros This is a helper library for developing ink! smart contracts. It contains useful Rust macros that extend functionality and

Scio Labs 3 Nov 3, 2023
esp-serial-dbg - debugging of esp-hal based applications via serial

esp-serial-dbg - debugging of esp-hal based applications via serial About This is still work in progress! At least the contained examples should work

BjΓΆrn Quentin 3 Aug 23, 2022
Js-macros - Quickly prototype Rust procedural macros using JavaScript or TypeScript!

js-macros Quickly prototype Rust procedural macros using JavaScript or TypeScript! Have you ever thought "this would be a great use case for a procedu

null 15 Jun 17, 2022
Atomic Physics Library

Iridium Atomic Physics Library Attempt at making a atomic database. Uses Nubase2020, ENSDF for decay chains, atomic masses, and half-lives. Nubase2020

J.A Sory 14 Jun 19, 2022
Arduino Nano frequency counter with atomic clock accuracy

Arduino Nano frequency counter with atomic clock accuracy Project description and test setup With this project you can measure a frequency from less t

Frank Buss 24 Apr 3, 2022
Create, share, fetch and model Atomic Data! This project consists of a graph database + server, a CLI and a rust library.

Create, share, fetch and model Atomic Data! This repo consists of three components: A library, a server and a CLI. atomic-server Status: Beta. Breakin

Joep Meindertsma 195 Dec 28, 2022
Portable atomic types.

portable-atomic Portable atomic types. Provide all atomic integer types (Atomic{I,U}{8,16,32,64}) for all targets that can use atomic CAS. (i.e., all

Taiki Endo 49 Dec 21, 2022
Quinine is a Rust library that implements atomic, lock-free, but write-once versions of containers like `Box` or `Arc`

Quinine is a Rust library that implements atomic, lock-free, but write-once versions of containers like `Box` or `Arc`

Paul Khuong 4 Feb 19, 2022