Imported AOSL-CPP code from https://bitbucket.org/artofsequence/aos