Skip to content

Instantly share code, notes, and snippets.

View kammce's full-sized avatar

Khalil Estell kammce

  • Bay Area, California
  • 02:48 (UTC -08:00)
View GitHub Profile
@kammce
kammce / constexpr-constuctor.cpp
Last active November 8, 2018 15:39
Demonstrates that C++ constexpr constructors do not appear in symbol tables if their objects are defined globally even at optimization level 0.
// Using g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
// Notice: that I am using optimization level 0 here.
//
// To compile:
// g++ -g3 -O0 -std=c++17 -o constexpr-constuctor.exe constexpr-constuctor.cpp
//
// To dump disassembly along with symbol table:
// objdump --disassemble --all-headers --source --demangle --wide constexpr-constuctor.exe > constexpr-constuctor.asm
//
// To dump contents of .data section:
@kammce
kammce / source_location_dummy.cpp
Last active March 8, 2020 17:02
source_location_dummy
#include <cstdint>
namespace std::experimental
{
class source_location
{
public:
constexpr const char * file_name() const { return ""; }
constexpr const char * function_name() const { return ""; }
@kammce
kammce / pll_constants_calculator.cpp
Created April 5, 2020 04:54
PLL Constants Calculator
#include <cstdio>
#include <cstdint>
#include <cinttypes>
struct PllSettings_t
{
uint32_t multiplier;
uint32_t feedback_divider;
uint32_t output_divider;
@kammce
kammce / FixedAllocator.hpp
Created December 6, 2020 17:50
Fixed size stack based allocator for std::containers. Removing this from SJSU-Dev2 but wanted to preserve it here for those who may want to use it. This allocator will be replaced with std::pmr going forward.
#pragma once
#include <cstdint>
#include <cstdlib>
#include "utility/log.hpp"
namespace sjsu
{
/// Arena class is a memory management class that takes an external buffer and
@kammce
kammce / MockGpio.hpp
Created December 8, 2020 15:22
Partial implementation of a mock peripheral for SJSU. This was used in test to verify if using a hand written mock was faster than FakeIt (24 seconds for small test). It was, but only by 1s.
namespace sjsu
{
/// Mock Gpio for usage in testing
class MockGpio : public sjsu::Gpio
{
public:
// Return values
std::deque<bool> read_;
std::deque<std::variant<Direction, State, std::pair<InterruptCallback, Edge>>>
captures_;
@kammce
kammce / picolibc_attempt_notes.cpp
Created July 3, 2021 16:58
Getting picolibc to work
struct _reent r = {0, (FILE *) 0, (FILE *) 1, (FILE *) 0};
struct _reent *_impure_ptr = &r;
extern "C" void __cxa_pure_virtual()
{
// put your error handling here
}
extern "C" void __cxa_atexit() {}
@kammce
kammce / xstdbitset.cpp
Last active August 6, 2021 14:28
[Benchmark] C-style multibit insert vs C++ bitset
#include <bitset>
#include <cinttypes>
#include <cstdio>
#include <limits>
#include <type_traits>
namespace xstd {
struct bitrange {
uint32_t position;
#include <bitset>
#include <cinttypes>
#include <cstdio>
#include <limits>
#include <type_traits>
namespace xstd {
struct bitrange {
uint32_t position;
#include <cinttypes>
#include <cstdio>
#include <functional>
namespace embed {
/// An empty settings structure used to indicate that a module or interface does
/// not have generic settings.
struct empty_settings {};
{
"schemaVersion": 1,
"label": "",
"logoSvg": "<svg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 310.797 310.797' style='enable-background:new 0 0 310.797 310.797;' xml:space='preserve'><g><path d='M208.859,27.307L208.8,11.308L189.311,0l-87.893,51.407l0.11,19.635L63.697,93.104l0.073,47.457l-18.592,11.161 l-0.155,101.334l20.214,11.833l12.422-7.502l18.173,11.395v30.12l20.075,11.895l87.333-50.921l-0.053-21.302l45.583-26.463v-38.133 l17.004-10.152V60.551L208.859,27.307z M187.302,33.392l6.559-3.846l0.048,23.674l-6.607,3.86V33.392z M158.816,50.059l6.558-3.836 l0.049,23.653l-6.606,3.86V50.059z M129.173,67.389l6.558-3.844l0.049,23.68l-6.606,3.871V67.389z M101.529,87.725l-0.049,13.891 l20.164,11.813l87.158-51.046l0.095-17.363l23.033,14.225l-107.389,63.021L83.517,98.361L101.529,87.725z M73.18,167.153 l20.375-12.225l-0.105,7.768l-20.383,12.171L73.18,167.153z M72.604,203.263l0.018-1.205l20.374-12.225l-0.105,7.768l-20.382,12.17 L