recentpopularlog in

mechazoidal : c   206

« earlier  
The Definitive C Book Guide and List - Stack Overflow
" This is a list of random books of diverse quality. In the view of some people (with some justification), it is no longer a list of recommended books. Some of the listed books contain blatantly incorrect statements or teach wrong/harmful practices. People who are aware of such books can edit this answer to help improve it. See The C book list has gone haywire. What to do with it?, and also Deleted question audit 2018. "
c  stackoverflow  books  reference 
6 weeks ago by mechazoidal
CS50 Programmer's Manual
Manual pages for the C standard library (and the CS50 Library), with student-friendly annotations.
unix  c  linux  programming  reference 
6 weeks ago by mechazoidal
Improving Software Security through C Language Standards – NCC Group Research
Robert Seacord goes over his and the NCC Group's work on improving security standards via the C Standards Committee. Some interesting reference on ISO, ANSI, and how he thinks standards are the best long-term solution(rather than compiler-specific extensions)
Lobsters commenter notes that he offers a safe-C training course, but it's intermediate-to-advanced and is quite expensive(but extensive and plenty of patterns and self-study)
c  programming  standards  2020  iso 
6 weeks ago by mechazoidal
GitHub - aep/zz: ZZ (drunk octopus) a safe dialect of C for embedded systems, inspired by rust
from lobsters, the formally-proven parts:
- Exhibit no undefined behaviour (i.e. no unexpected memory access)
- Contracts are satisfied in all function calls (with no runtime checks)

needs a rust installation to bootstrap, and a SMT solver available.
pmz  c  formal_methods  repo:github  programming 
8 weeks ago by mechazoidal
Chunking Optimizations: Let the Knife Do the Work « null program
"'Letting the knife do the work' means writing a correct program and lifting unnecessary constraints so that the compiler can use whatever chunk size is appropriate for the target."
(do note that the 'restrict' keyword is only in C99+)
c  programming  optimization 
december 2019 by mechazoidal
GitHub - hexagonal-sun/bic: A C interpreter and API explorer.
A REPL for C: great for investigating calls/libraries!
also note their "Tree Objects" system
repl  c  programming  tools  repo:github 
december 2019 by mechazoidal
"a lightweight curses (terminal-based) interface to the GNU Debugger (GDB). In addition to the standard gdb console, cgdb provides a split screen view that displays the source code as it executes. The keyboard interface is modeled after vim, so vim users should feel at home using cgdb."
c  programming  debugging  tools 
december 2019 by mechazoidal
Rust 2020: Lessons learned by transpiling C to Rust :: Immunant, Inc
"Right now, Rust covers almost everything one might want to do in C. While the issues we discuss here are fairly minor, they are holding back full feature parity and replacement of real-world C software. We’ve been able to transpile most C code to FFI-compatible, equivalent Rust: lua, nginx and zstd currently transpile without any changes, and ioq3 only requires a single small change in the Rust output to run (the ssemask issue illustrated above). "
2019  pmz  rust  c  c2rust  gcc 
november 2019 by mechazoidal
GitHub - JuliaComputing/llvm-cbe: resurrected LLVM "C Backend", with improvements
landley: "an llvm backend that produces C. Have LLVM run itself through this, teach tinycc to compile the result, and you don't need cfront anymore! You can bootstrap up to a modern optimizing compiler from a tiny auditable system!"
pmz  repo:github  llvm  c  compiler 
november 2019 by mechazoidal
Using Asserts in Embedded Systems | Interrupt
"By using asserts proactively in embedded systems on debug and production builds, developers can both prevent more bugs before shipping and quickly surface and fix them after shipping. Proper assert handling is also the safest way to handle issues and undefined behavior that occur in production. In this post, we’ll go over best practices with asserts, when to use asserts, and then come up with a production ready custom assert implementation for an ARM Cortex-M device, all while keeping the code size usage to a minimum."

However, see JohnCarter's comments, especially on Design-by-Contract:
embedded  pmz  programming  c  freertos 
november 2019 by mechazoidal
How to make your C codebase rusty: rewriting keyboard firmware keymap in Rust · houqp
"Recently, my colleague introduced me to QMK, an open-source keyboard firmware. Like many non-trivia C projects, macro is heavily used everywhere, especially in keymap files. It didn't bother me much since I have been programming C for many years. But I kept thinking to myself, "what would it look like if I can start from scratch and redesign everything using Rust's more powerful macro system?"

After couple nights of hacking, I was able to come up with something I am quite happy with."

uses buildgen and Rust macros, showing off linking to C libraries and even read/writing C global values from Rust!
keyboard  firmware  rust  c  pmz  programming 
november 2019 by mechazoidal
C Portability Lessons from Weird Machines
Everything from the Unisys 2200 to the 6502 to the HP Saturn(4-bit)
c  programming  history  computers 
october 2019 by mechazoidal
Using C libraries in Rust: make a sys crate
"Using C libraries in a portable way involves a bit of work: finding the library on the system or building it if it's not available, checking if it is compatible, finding C headers and converting them to Rust modules, and giving Cargo correct linking instructions. Often every step of this is tricky, because operating systems, package managers and libraries have their unique quirks that need special handling. Fortunately, all this work can be done once in a build script, and published as a <insert library name>-sys Rust crate. This way other Rust programmers will be able to use the C library without having to re-invent the build script themselves."
rust  tips  c  programming 
october 2019 by mechazoidal
How to not RiiR · Michael-F-Bryan
Showing how to make safe interfaces in Rust to C libraries(using CHMLib as an example).
kornel@lobsters: "In C these things are in the manual, but Rust can express them in the type system. When writing Rust wrappers I literally copy prose from the documentation into Rust type system, and have the compiler enforce RTFM! Of course that won’t help for bugs that are deep in the C code, but it is possible to prevent most bugs caused by wrong inputs, incorrect memory management, invalid state, unchecked errors, and unsynchronized cross-thread usage."
rust  c  interop  howto  2019  programming 
october 2019 by mechazoidal
post modern C tooling - draft 5
mostly tools:
- debugging: cgdb, rr, procdump/WinDbg (Windows)
- build/packaging: meson, cmake, conan

not much love for static analyis: "use your compiler", but does mention clang's static-analyzer+sanitizers and cppcheck. on windows though, absolutely use App Verifier / PageHeap.

also has links to example projects for testing: sqlite, curl, python, openssl, libsdl, linux kernel, haproxy
c  tools  list  programming 
october 2019 by mechazoidal
The Fascinating Influence of Cyclone
The history of Cyclone, what it influenced, and who was involved. Covers Ada, Midori, M#, Pony, Rust, and others

PR: "For all their benefits, unique (linear) references have a significant limitation. Using only unique references, only hierarchical (tree) data structures can be built. Nearly all data structures with cycles need to allow multiple references to the same object, which unique references cannot do. This limitation, as well as the disruptive constraints of move semantics, should stay top-of-mind when touting the virtues of single-owner memory management and unique references."
programming  safety  history  c  c++  piperesearch  memory 
october 2019 by mechazoidal
Modern C for C++ Peeps
Good stuff for C99:
- compound literals, designated initialization
- don't be afraid to pass-by-value!
- named optional arguments
- easier ways to avoid pointers for data blobs: use tagged index handles, embrace "dumb data, smart functions"!

see also:
archive_it  c  programming  reference  piperesearch  pmz 
september 2019 by mechazoidal
"When tinkering with a new graphics API or raytracing kernel, I often want to use procedurally-generated shapes to avoid worrying about loading art assets.

Hence my motivation for authoring a single-file, zero-dependency, C99 library that can generate simple shapes and perform basic operations on them:
- Applying affine transformations
- Computing surface normals
- Welding colocated vertices"
library  piperesearch  mesh  models  procedural  graphics  c 
august 2019 by mechazoidal
MISRA C - Wikipedia
for why it should be used elsewhere. Also note that this lists checkers that use MISRA, including cppcheck
programming  c++  c  embedded  wikipedia 
august 2019 by mechazoidal
Some obscure C features- Pancakes and computers
Includes Duff's Device, along with other weirdities like compile-time tree structures (although don't use preprocessor for arch-specific includes, use a proper #include <> instead
programming  C  tips 
august 2019 by mechazoidal
MiniUPnP Project HomePage
For reference only at this point: it's pretty small, but the code has had major flaws discovered before.
library  upnp  dlna  c 
august 2019 by mechazoidal
C's Biggest Mistake - Digital Mars
Walter Bright notes that you could fix a lot of C issues if the standard syntax added slices and stopped conflating pointers and arrays
c  programming  2009 
july 2019 by mechazoidal
GitHub - jedisct1/dsvpn: A Dead Simple VPN.
"This is not intended to be a replacement for GloryTun or WireGuard. This is a weekend project, and this is what I use, because it solves a problem I had."
VPN  c  repo:github  tools  networking  security 
july 2019 by mechazoidal
GitHub - jedisct1/charm: A really tiny crypto library.
"implementing authenticated encryption and keyed hashing", from the author of libsodium. Also verified against a Cryptol spec!
pmz  cryptography  library  c  repo:github 
july 2019 by mechazoidal
With Undefined Behavior, Anything is Possible | Raph Levien’s blog
"The best way to understand the actual C standard is that programs run on an exotic, complex virtual machine in which pointers are numbers, yes, but annotated with types and valid ranges. Any usage of a pointer that doesn’t strictly follow the rules is immediately undefined behavior.

This is the true computational model of standard C. What makes the situation so deceptive is that this complex virtual machine can be easily run on standard hardware, just by stripping out the extra stuff. What’s easy to forget sometimes is that the compiler is allowed to do much more complicated things, and often does so in service of optimization."
c  history  compilers  programming  standards 
july 2019 by mechazoidal
"dependency-free C library for triangulating wide lines, Béziers, and streamlines. The following canvases use the library inside a small WebAssembly module. There are no memory allocations occurring per-frame."
(by the same author of "heman")
piperesearch  c  library  curves  graphics 
june 2019 by mechazoidal
musl libc
"lightweight, fast, simple, free, and strives to be correct in the sense of standards-conformance and safety." Note that it's meant for the Linux kernel, even another unix is probably not a porting slam dunk
osdev  library  c  libc  linux  compilers 
june 2019 by mechazoidal
Vulkan Memory Allocator - GPUOpen
"Easy to integrate Vulkan memory allocation library.", from AMD. Self-contained C++ library, has C interface.
vulkan  library  c++  c  memory  gpu  piperesearch  gamedev 
may 2019 by mechazoidal
GitHub - silentbicycle/skiparray: unrolled skip list library for C
"It has roughly the same relation to a skip list as a B-tree does a more conventional Binary search tree."
library  c  repo:github  datastructures 
april 2019 by mechazoidal
"a high performance 2D vector graphics engine written in C++[C interface also available] and released under the Zlib license. It has a built-in JIT compiler that generates optimized pipelines at runtime. Additionally, the engine features a new rasterizer that has been written from scratch. It delivers superior performance while quality is comparable to rasterizers used by AGG and FreeType. The performance has been optimized by using an innovative approach to index data that is built during rasterization and scanned during composition. The rasterizer is robust and excels in rendering complex vector art and text."

Note that it started as an experiment to do 2d pipelines with JIT, and it worked so well they improved it into a real library. No dependencies except AsmJit, cmake build provided.
c  c++  library  graphics  jit  piperesearch  gamedev  pmz 
april 2019 by mechazoidal
GitHub - begriffs/utofu: Unicode Trust on First Use (TOFU)
"The concept is similar to how you trust SSH key fingerprints the first time they are used. If the fingerprint ever changes, SSH fails. With utofu you trust strings and save them in a single-file database. Attempting to save a new string which is confusable with one already in the database causes an error"
security  unicode  c  repo:github  reference  pmz  piperesearch 
march 2019 by mechazoidal
what does "malloc_trim(0)" really mean? - Stack Overflow
"In classic glibc form, malloc_trim has been freeing OS pages in the middle of the heap since 2007, but this is documented nowhere. Even the function comment in the source code itself is inaccurate."
c  programming  gnu  memory  stackoverflow 
march 2019 by mechazoidal
GitHub - FFMS/ffms2: An FFmpeg based source library and Avisynth/VapourSynth plugin for easy frame accurate access
"It gives you an easy, convenient way to say "open and decompress this media file for me, I don't care how you do it" and get frame- and sample-accurate access (usually), without having to bother with the sometimes less than straightforward and less than perfectly documented FFmpeg API."

- does not mux or encode anything.
- does not give you fine control over codec internals.
- does not let you demux raw compressed data, you get it decompressed or not at all.
- does not provide you with a good solution for realtime playback, since it needs to index the input file before you can retreive frames or audio samples.
- does not currently handle things like subtitles, file attachments or chapters.
- video frame and audio sample retrieval functions are not threadsafe; you may only have one request going at a time, per source context.
windows  avisynth  video_editor  library  c  ffmpeg  repo:github  piperesearch 
february 2019 by mechazoidal
"a tiny window manager that I created as an exercise in minimalism. It is also maybe helpful in learning some of the very basics of creating a window manager. It is only around 50 lines of C. "
programming  x11  wm  unix  c 
january 2019 by mechazoidal
"a lightweight music DSP library for musicians and creative coders. It exists to bring beautiful sounds to your projects. The Soundpipe library is built up of over 100 (and counting!) high quality modules, many of which have been ported directly from the time-honored Csound synthesis language. "
programming  c  library  audio  synthesizer 
january 2019 by mechazoidal
Why do C to Z80 compilers produce poor code? - Retrocomputing Stack Exchange
A nice example to use when someone says "but the C model is how computers work deep-down, isn't it?"

"Array indexing is inefficient since there's no reasonable base + offset addressing mode that can use a variable offset, which means the compiler needs to generate code to do the address calculation.

Similarly, it's awkward to save and restore function arguments on the stack because there's no stackpointer + offset addressing mode. The same goes for the local variables of non-leaf functions.

Paucity of truly general purpose registers. Most registers have specific uses which complicates register allocation.

The ISA makes it difficult to mix 8-bit and 16-bit operations."
c  programming  retrocomputing  assembly  hardware  stackoverflow 
november 2018 by mechazoidal
quiet/quiet: Transmit data with sound. Includes binaries for soundcards and .wav files.
"This library uses liquid SDR to transmit data through sound. This makes it suitable for sending data across a 3.5mm headphone jack or via speaker and mic. Quiet can build standalone binaries for encoding/decoding data via .wav files or for streaming through your soundcard via PortAudio. It can also be built as a library to be consumed by other C programs."
programming  library  pmz  c  audio  networking 
september 2018 by mechazoidal
quiet/libcorrect: C library for Convolutional codes and Reed-Solomon
bsd licensed, part of Quiet Modem project for forward-error correction. Uses Convolutional codes and Reed-Solomon to encode/decode a data packet
library  networking  pmz  c 
september 2018 by mechazoidal
How strtod() Works (and Sometimes Doesn’t)
"Converting decimal strings to doubles correctly and efficiently is a surprisingly complex task; fortunately, David M. Gay did this for us when he wrote this paper and released this code over 20 years ago. (He maintains this reference copy of strtod() to this day.) [...] I’ve spent considerable time reverse engineering strtod(); neither the paper nor the code are easy reads. I’ve written articles about how each of its major pieces work, and I’ve discovered bugs (as have a few of my readers) along the way. This article ties all of my strtod() research together."
math  programming  reference  c  computerscience 
july 2018 by mechazoidal
Minimalist C Libraries « null program
- don't manage memory(let user do that)
- don't use stdlib(except math)
- don't do io(again, let user do that)
- define as few structures as possible
c  programming  library  tips 
june 2018 by mechazoidal
GitHub - PlanetAPL/openAPL
An APL written in standard idiomatic C, albeit not minimal
reference  c  apl  repo:github 
may 2018 by mechazoidal
Bit Twiddling Hacks
all in C, and check your hardware/implementation carefully.
programming  algorithms  reference  c 
may 2018 by mechazoidal
GitHub - s-macke/SAM: Software Automatic Mouth - Tiny Speech Synthesizer
The original TTS on the C64, now (painfully) translated to C. Supposedly the only free synth that can make Polish sound decent?
retrocomputing  repo:github  tts  audio  c  synthesizer 
may 2018 by mechazoidal
C Is Not a Low-level Language - ACM Queue
"Your computer is not a fast PDP-11"

"The features that led to [Spectre, Meltdown], along with several others, were added to let C programmers continue to believe they were programming in a low-level language, when this hasn't been the case for decades."
c  programming  parallelism  hardware  from:acm  2018 
may 2018 by mechazoidal
The Cost and Complexity of Cgo | Cockroach Labs
"The experienced cgo-er will probably know this (and might prefer to lightly skim over the remainder of this post absentmindedly), but using cgo comes with some caveats that we’ll discuss below along with our suggested workarounds."
Golang  c  tips 
march 2018 by mechazoidal
Fail-Safe C: Top Page
"More precisely, it detects and disallows all unsafe operations, yet conforming to the full ANSI C standard (including casts and unions) and even supporting many "dirty tricks" common in many existing programs which do not strictly conform to the standard. This work also proposes several techniques---both compile-time and runtime---to reduce the overhead of runtime checks. By using the Fail-Safe C compiler, programmers can easily make their programs safe without performing heavy rewriting or porting of their code."
programming  c  compilers  security  research  pmz 
february 2018 by mechazoidal
Mars Code: building robust software
"Dr. Gerard Holzmann spoke at USENIX Hot Topics in System Dependability mini-conf on 7 Oct 2012 in Hollywood, California. He described how NASA/JPL writes and tests software that survives rigors of interplanetary travel, planetary entry, descent, and landing, and operation in another world."
programming  software_development  nasa  software_engineering  pmz  c  verification 
november 2017 by mechazoidal
Render Multimedia in Pure C « null program
Clever usage of NetPBM and Unix tools, along with "simplest thing that could possibly work"
programming  graphics  c  multimedia  piperesearch  pmz 
november 2017 by mechazoidal
the basic ontology of a c program
"i wanted to understand the system-level abstractions that were involved in the simplest c programs - ideally, to a point where i could recognize and understand all components in a compiled binary for a simple program. hopefully, even if you are on other configurations, this will give you some resources to start reasoning about the souls of your programs and the universes they live in."
c  unix  programming  elf  reverse_engineering  openbsd 
october 2017 by mechazoidal
A Little Story About the `yes` Unix Command | Matthias Endler
"The trivial program yes turns out not to be so trivial after all. It uses output buffering and memory alignment to improve performance. Re-implementing Unix tools is fun and makes me appreciate the nifty tricks, which make our computers fast."
c  unix  programming  optimization  rust 
october 2017 by mechazoidal
D as a Better C - The D Blog
"D’s solution is to subset the D language, removing or altering features that require the D startup code and runtime library. This is, simply, the charter of the -betterC compiler switch. [...] The result is a language somewhere in between C and D, but that is fully upward compatible with D."
dlang  c  programming 
august 2017 by mechazoidal
GitHub - starwing/amoeba: a Cassowary constraint solving algorithm implements in pure C.
"Amoeba use Clean C, which is the cross set of ANSI C89 and C++, like the Lua language."
A single-file library, with a Lua binding
solver  repo:github  library  c  piperesearch 
august 2017 by mechazoidal
QBE - Quaint Backend
" aims to be a pure C embeddable backend that provides 70% of the performance of advanced compilers in 10% of the code. Its small size serves both its aspirations of correctness and our ability to understand, fix, and improve it. It also serves its users by providing trivial integration and great flexibility."
(like a smaller LLVM)
compilers  programming  c  x86 
august 2017 by mechazoidal
bootstrapping wiki
"This wiki is about bootstrapping. Building up compilers and interpreters and tools from nothing."
programming  wiki  reference  c  vm  compilers  assembly  interpreter 
july 2017 by mechazoidal
GitHub - seemoo-lab/nexmon: The C-based Firmware Patching Framework for Broadcom/Cypress WiFi Chips that enables Monitor Mode, Frame Injection and much more
"Before we started to work on this repository, we developed patches for the Nexus 5 (with bcm4339 WiFi chip) in the bcm-public repository and those for the Raspberry Pi 3 (with bcm43438 WiFi chip) in the bcm-rpi3 repository. To remove the development overhead of maintaining multiple separate repositories, we decided to merge them in this repository and add support for some additional devices."
reverse_engineering  firmware  android  c  wifi 
july 2017 by mechazoidal
tis-interpreter - TrustInSoft
"works by interpreting C programs statement by statement from beginning to end, verifying at each statement whether the program can invoke undefined behavior. This makes it comparable to Valgrind and C compiler sanitizers (UBSan, ASan, …). The recommended use is to apply tis-interpreter to existing tests for security-sensitive C code in which a bug could have dramatic consequences. tis-interpreter can detect violations of the C standard even when applied to regression tests that have never revealed any problem. At this stage, the best uses for tis-interpreter are pure C libraries with as few dependencies as possible and existing tests."
verification  tools  programming  c  pmz 
july 2017 by mechazoidal
"an easy to use crypto library inspired by libsodium and TweetNaCl."
Focus appears to be single-header(C99, C11, or C++), smaller API, and faster in more cases than TweetNaCl.
Slightly nervous about tweaking djb's stuff for speed, but he does provide Frama-C and TIS verifications in the distro.
Although note @nickpsecurity's comment that there doesn't appear to be any thought given to branch prediction/timing channels/covert channels:
library  c  pmz  cryptography 
july 2017 by mechazoidal
"Framework for Modular Analysis of C programs."
"gathers several static analysis techniques in a single collaborative framework. The collaborative approach of Frama-C allows static analyzers to build upon the results already computed by other analyzers in the framework. Thanks to this approach, Frama-C provides sophisticated tools, such as a slicer and dependency analysis."
c  programming  verification  pmz  tools 
july 2017 by mechazoidal
"Voc is a physical model of the vocal tract. It is based off of Neil Thapen's Pink Trombone, but rewritten in portable ANSI C code.

Voc uses the classic Kelly-Lochbaum vocal synthesis technique, one of the earliest attempts at digital physical modelling"
voice  audio  library  c 
june 2017 by mechazoidal
KLEE LLVM Execution Engine
" a symbolic virtual machine built on top of the LLVM compiler infrastructure, and available under the UIUC open source license."
Used for the paper: "KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs", where "KLEE-generated tests achieve high line coverage — on average over 90% per tool (median: over 94%) — and significantly beat the coverage of the developers' own hand-written test suites. "
llvm  c  programming  library 
june 2017 by mechazoidal
GitHub - steve-m/kalibrate-rtl: fork of for use with rtl-sdr devices
"can scan for GSM base stations in a given frequency band and can use those GSM base stations to calculate the local oscillator frequency offset."
radio  sdr  repo:github  gsm  c 
may 2017 by mechazoidal
Cynth: a simple C-to-Verilog compiler | Lobsters
Lots of good links in the discussion, esp. from nickpsecurity
verilog  c  programming  lobsters  discussion  fpga 
april 2017 by mechazoidal
(slack in the SubGenius sense)
"a library of general utilities designed to make UNIX/C programming a bit easier on the eye. It is a seemingly random collection of modules and functions that I find commonly useful. It was originally implemented as part of the daemon program (although some of the code dates back much further)."
PR: investigate the network/agent stuff
piperesearch  unix  library  c  programming 
april 2017 by mechazoidal
selfie by cksystemsteaching
For teaching CS students (pair with ):
"Selfie is a fully self-referential 7k-line C implementation of:
- a self-compiling compiler called starc that compiles a tiny but powerful subset of C called C Star (C*) to a tiny but powerful subset of MIPS32 called MIPSter,
- a self-executing emulator called mipster that executes MIPSter code including itself when compiled with starc,
- a self-hosting hypervisor called hypster which is based on a tiny microkernel implemented in mipster and provides MIPSter virtual machines that can host all of selfie, that is, starc, mipster, and hypster itself, and
- a tiny C* library called libcstar utilized by selfie."
learning  c  programming  computerscience  compilers  mips  education 
march 2017 by mechazoidal
« earlier      
per page:    204080120160

Copy this bookmark:

to read