Giter VIP home page Giter VIP logo

s-keys's Introduction

s-keys

Port of linux kernel jump labels to userspace. Uses GCC goto asm extension and some other gcc/gas specific extensions (always inline, .pushsection, section attributes).

Jump labels described in the kernel's jump_label.h:

Jump labels provide an interface to generate dynamic branches using self-modifying code. Assuming toolchain and architecture support the result of a "if (static_key_false(&key))" statement is a unconditional branch (which defaults to false - and the true block is placed out of line).

Original authors Jason Baron and Peter Zijlstra.

See these two LWN articles for an introduction:

http://lwn.net/Articles/412072/

http://lwn.net/Articles/436041/

Another good one on kernel elf special sections:

http://lwn.net/Articles/531148/

And the kernel documentation:

https://www.kernel.org/doc/Documentation/static-keys.txt

Installing:

git clone https://github.com/computee/s-keys.git
cd s-keys
make

To use static keys, just include the header and initialize like this:

#include <s-keys.h>

// must declare globally:
struct static_key key = STATIC_KEY_INIT_TRUE;

int main (int argc, char *argv[])
{
    jump_label_init();

    if (static_key_true(&key))
        printf("A\n");
    else
        printf("B\n");

}

Todo

pull requests / patches welcome

  • Ideal nops: possibly re-implement this system
  • Cross compilation: need to test
  • RPM/deb skeleton files
  • header-only arrangement?
  • unit tests -like make targets and programs

Contact

Patrick McCormick patm()pdx.edu

s-keys's People

Contributors

computee avatar

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.