Skip to content

Instantly share code, notes, and snippets.

View pftbest's full-sized avatar

Vadzim Dambrouski pftbest

View GitHub Profile

When using libclang, the Clang C interface for parsing C/C++ code, clang_reparseTranslationUnit can be used to update an existing CXTranslationUnit rather than creating an entirely new one. This allows you to reparse the source files in case there are changes while preserving the already parsed information for unchanged files, such as headers. By doing this, parsing will be faster as it avoids reparsing the unchanged header files.

Here's a step-by-step guide on how to use clang_reparseTranslationUnit:

  1. Create a CXIndex: The first step is to create an index object that will be used throughout the parsing process.
CXIndex index = clang_createIndex(0, 0);
This file has been truncated, but you can view the full file.
#define CONFIG_EXT4_USE_FOR_EXT2 1
#define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC)
#define MAS_WR_WARN_ON(__mas,__x) WARN_ON(__x)
#define SCHED_FLAG_UTIL_CLAMP (SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX)
#define SYS_PMSLATFR_EL1_CRn 9
#define cpu_to_be32 __cpu_to_be32
#define BLKSECDISCARD _IO(0x12,125)
#define TCR2_EL2_E0POE_SHIFT 2
#define ID_AA64MMFR0_EL1_EXS GENMASK(47, 44)
#define USE_CMPXCHG_LOCKREF (IS_ENABLED(CONFIG_ARCH_USE_CMPXCHG_LOCKREF) && IS_ENABLED(CONFIG_SMP) && SPINLOCK_SIZE <= 4)
AARCH64_DBG_REG_NAME_BCR = bcr;
AARCH64_DBG_REG_NAME_BVR = bvr;
AARCH64_DBG_REG_NAME_WCR = wcr;
AARCH64_DBG_REG_NAME_WVR = wvr;
ARCH_DLINFO = do { NEW_AUX_ENT(33, (Elf64_Off)get_current()->mm->context.vdso); if (__builtin_expect(!!(signal_minsigstksz), 1)) NEW_AUX_ENT(51, signal_minsigstksz); else NEW_AUX_ENT(1, 0); } while (0);
ARCH_LOW_ADDRESS_LIMIT = (arm64_dma_phys_limit - 1);
ARCH_PFN_OFFSET = ((unsigned long)(({ ((void)(sizeof(( long)(memstart_addr & 1)))); memstart_addr; }) >> 12));
ASM_NL = ;;
ATOMIC64_INIT = ATOMIC_INIT;
BLKTRACESETUP = (((2U|1U) << (((0 +8)+8)+14)) | (((0x12)) << (0 +8)) | (((115)) << 0) | (((((sizeof(struct blk_user_trace_setup) == sizeof(struct blk_user_trace_setup[1]) && sizeof(struct blk_user_trace_setup) < (1 << 14)) ? sizeof(struct blk_user_trace_setup) : __invalid_size_argument_for_IOC))) << ((0 +8)+8)));
This file has been truncated, but you can view the full file.
A32_RN_OFFSET = 16;
A32_RT2_OFFSET = 0;
A32_RT_OFFSET = 12;
AARCH32_BREAK_ARM = 0x07f001f0;
AARCH32_BREAK_THUMB = 0xde01;
AARCH32_BREAK_THUMB2_HI = 0xa000;
AARCH32_BREAK_THUMB2_LO = 0xf7f0;
AARCH64_BREAK_FAULT = (0xd4200000 | (0x100 << 5));
AARCH64_BREAK_KGDB_DYN_DBG = (0xd4200000 | (0x400 << 5));
AARCH64_BREAK_MON = 0xd4200000;
@pftbest
pftbest / backtracing_alloc.rs
Created January 9, 2024 00:10
backtracing allocator
use std::alloc::{GlobalAlloc, Layout, System};
use std::cell::RefCell;
use std::fs::File;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::thread_local;
thread_local! {
static BT_ALLOC_BUSY: RefCell<bool> = RefCell::new(false);
}
#!/usr/bin/env python3.8
import matplotlib.pyplot as plt
import numpy as np
import scipy.optimize as optimization
class T:
x = 0
presc = 0
scldel = 0
use kernel::common::{cells::OptionalCell, dynamic_deferred_call::{DynamicDeferredCall, DynamicDeferredCallClientState}};
use kernel::hil;
use kernel::hil::uart::{Parameters, Configure, Receive, ReceiveClient, TransmitClient, Transmit};
use kernel::{ReturnCode, static_init};
use capsules::virtual_uart::UartDevice;
use kernel::component::Component;
use std::sync::mpsc;
struct Uart<'a> {
tx_client: OptionalCell<&'a dyn TransmitClient>,
diff --git a/asm.s b/asm.s
index 50a3fa5..fd7e500 100644
--- a/asm.s
+++ b/asm.s
@@ -1,11 +1,11 @@
# LLD requires that the section flags are explicitly set here
- .section .HardFaultTrampoline, "ax"
- .global HardFaultTrampoline
+ .section .HardFaultTrampolineAsm, "ax"
+ .global HardFaultTrampolineAsm
diff --git a/asm.s b/asm.s
index 50a3fa5..0daa1d8 100644
--- a/asm.s
+++ b/asm.s
@@ -1,6 +1,6 @@
# LLD requires that the section flags are explicitly set here
.section .HardFaultTrampoline, "ax"
- .global HardFaultTrampoline
+ .weak HardFaultTrampoline
# .type and .thumb_func are both required; otherwise its Thumb bit does not
Last login: Sun Jan 13 04:02:38 on ttys000
macbook:~ vadzim$ nix-build https://github.com/NixOS/nixpkgs/archive/7d864c6bd63.tar.gz -A gnome3.dconf --arg config "{}" \
> --arg overlays "[ (self: super: { gnome3 = super.gnome3.overrideScope' (self: super: { dconf = super.dconf.overrideAttrs (drv: { doCheck = false; }); }); }) ]"
unpacking 'https://github.com/NixOS/nixpkgs/archive/7d864c6bd63.tar.gz'...
these derivations will be built:
/nix/store/rgh9vjadmq58w1hp4y9wqa12r3zfb3z5-dconf-0.30.1.drv
building '/nix/store/rgh9vjadmq58w1hp4y9wqa12r3zfb3z5-dconf-0.30.1.drv'...
unpacking sources
unpacking source archive /nix/store/canh30a3lr5pmqdr6jgnn01qh4qzyhm2-dconf-0.30.1.tar.xz
source root is dconf-0.30.1