Skip to content

Instantly share code, notes, and snippets.

View estshorter's full-sized avatar

estshorter estshorter

View GitHub Profile
uint32_t read_id_isar5(void) {
uint32_t value;
asm volatile("mrc p15, 0, %0, c0, c2, 5" : "=r"(value));
return value;
}
void check_crypto_extension(void) {
uint32_t id_isar5 = read_id_isar5();
uint32_t aes = (id_isar5 >> 4) & 0xF;
// clang -fomit-frame-pointer -target arm-linux-gnueabihf -march=armv8-a -mcpu=cortex-a53 -mfloat-abi=hard -marm
// --sysroot=/usr/lib/arm-linux-gnueabihf test.c
// のようにomit-frame-pointerを指定していても、オプション指定なし(O0)だと以下のように怒られる。
// test.c:12:9: warning: inline asm clobber list contains reserved registers: R11 [-Winline-asm]
// 12 | "sub sp, sp, #0x200\n\t"
// | ^
// test.c:12:9: note: Reserved registers on the clobber list may not be preserved across the asm statement, and clobbering them may lead to undefined behaviour.
// 1 warning generated.
// O1以上を指定すると出ない。
#define DEBUG_WOLFSSL
//
#define HAVE_CURVE25519
#define WOLFSSL_SHA512
#define HAVE_ED25519
#define WOLFSSL_SP_MATH_ALL
#include <windows.h>
@estshorter
estshorter / init.el
Last active September 18, 2025 22:45
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-enabled-themes '(wheatgrass)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
@estshorter
estshorter / caller.py
Last active March 9, 2023 14:19
nanobind sample
import numpy as np
import my_ext
a = np.arange(0, 8, dtype=np.uint8).reshape(4, 2)
my_ext.inspect(a)
print("--------\n")
my_ext.prepare()
b = my_ext.calc(a)
@estshorter
estshorter / identicon.py
Last active April 29, 2022 00:22
identicon
import hashlib
import itertools
from colorsys import hls_to_rgb
import numpy as np
from PIL import Image, ImageShow
INPUT = "1430311"
PIXEL = 70 # 1ピクセルのサイズ
@estshorter
estshorter / snippets.rs
Last active September 19, 2021 13:51
rust snippets
// https://maguro.dev/debug-macro/
macro_rules! debug {
($($a:expr),* $(,)*) => {
#[cfg(debug_assertions)]
eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
};
}
// https://kuretchi.hateblo.jp/entry/rust_nested_vec
macro_rules! nested_vec {
@estshorter
estshorter / any.cpp
Last active April 17, 2021 00:18
c++ any implementation
// http://staryoshi.hatenablog.com/entry/2015/10/27/173925
#include <iostream>
#include <memory>
class Any {
private:
struct base {
virtual std::type_info const& type() const { return typeid(nullptr); }
virtual std::unique_ptr<base> clone() const { return nullptr; }
};
@estshorter
estshorter / config.h
Last active October 16, 2021 15:17
ymd09
/*
Copyright 2020 Patrick Fruh
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@estshorter
estshorter / arnold-orbit.py
Created February 2, 2021 12:55
arnold orbit
from functools import partial
import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp
def U(r):
return 0.5 * r ** 3