Git Product home page Git Product logo

unix-v6-allocator's Introduction

Modernized UNIX v6 Allocator

This is a translation of the classic UNIX v6 alloc/free implementation, retrieved from The UNIX Heritage Society on 2021-11-28, to modern C.

The original code uses a very early dialect of C, which is closer to B. For example, global variables are not initialized with =; += and &= were spelled =+ and =&; modern types like size_t, void* did not exist; everything except char was a machine word and so type-punning was the norm; and so on.

The main significant change in this version is to enable it to handle machines of any word size, rather than assuming a 16-bit machine as the original code does. Additionally, I use modern types and names, which (I think) clarify the code significantly and, by removing the puns and terseness, expose the algorithm as beautifully simple.

This version builds cleanly as C17 and runs seemingly-correctly on Ubuntu 21.10 with clang 13.0.0. (On macOS 12, there are some warnings; notably, macOS declares sbrk to take int, not intptr_t.)

See the commentary by ljrk for a discussion of the allocator’s mechanism.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.