Skip to content

Instantly share code, notes, and snippets.

@valpackett
valpackett / reaperdemo.c
Created March 23, 2023 05:28
FreeBSD reaper API demo
#include <sys/procctl.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sysexits.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <signal.h>
@valpackett
valpackett / thread.log
Created November 9, 2020 21:38
Thread ID testing on FreeBSD
% cc -pthread -o /tmp/tid tids.c && truss /tmp/tid
[…]
__sysctl("vm.overcommit",2,0x7fffffffa314,0x7fffffffa308,0x0,0) = 0 (0x0)
mmap(0x0,2097152,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21),-1,0x0) = 34374418432 (0x800e00000)
mmap(0x0,2097152,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 34410536960 (0x803072000)
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21),-1,0x0) = 34422652928 (0x803c00000)
__sysctl("kern.usrstack",2,0x800ac8108,0x7fffffffc228,0x0,0) = 0 (0x0)
getrlimit(RLIMIT_STACK,{ cur=536870912,max=536870912 }) = 0 (0x0)
thr_self(0x803084000) = 0 (0x0)
mmap(0x7fffdfffd000,4096,PROT_NONE,MAP_ANON,-1,0x0) = 140736951472128 (0x7fffdfffd000)
@valpackett
valpackett / tokio-wayland-loop.rs
Created May 30, 2020 21:41
tokio-wayland-loop.rs
use smithay_client_toolkit::reexports::client::{
EventQueue, Interface, Main, MessageGroup, Proxy, ProxyMap,
};
/// Tokio task for polling the Wayland socket, dispatching the callbacks.
/// This makes wayland_event_chan work.
pub async fn wayland_loop(event_queue: &mut EventQueue) -> Result<(), Box<dyn std::error::Error>> {
use std::task::Poll;
let fd = event_queue.display().get_connection_fd();
@valpackett
valpackett / dpcd-eve.patch
Created April 9, 2020 12:04
Patch forcing DPCD backlight on Pixelbook
diff --git i/drivers/gpu/drm/i915/intel_dp_aux_backlight.c w/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
index 357136f17..7de91a4a5 100644
--- i/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
+++ w/drivers/gpu/drm/i915/intel_dp_aux_backlight.c
@@ -252,8 +252,12 @@ intel_dp_aux_display_control_capable(struct intel_connector *connector)
* the panel can support backlight control over the aux channel
*/
if (intel_dp->edp_dpcd[1] & DP_EDP_TCON_BACKLIGHT_ADJUSTMENT_CAP &&
- (intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_AUX_SET_CAP) &&
- !(intel_dp->edp_dpcd[2] & DP_EDP_BACKLIGHT_BRIGHTNESS_PWM_PIN_CAP)) {
diff --git i/include/wayfire/config/option-types.hpp w/include/wayfire/config/option-types.hpp
index ec49728..7e30648 100644
--- i/include/wayfire/config/option-types.hpp
+++ w/include/wayfire/config/option-types.hpp
@@ -1,12 +1,24 @@
#pragma once
+#if __has_include(<optional>)
+#include <optional>
+#else
CPU FUNCTION
1 -> i915_gem_userptr_ioctl arg: fffffe00cd374000
1 | i915_gem_userptr_ioctl:entry
1 -> linux_access_ok
1 <- linux_access_ok
1 -> i915_gem_object_alloc
1 -> uma_zalloc_arg
1 -> memset
1 -> memset_erms
1 <- memset_erms
module Main
data Printable : Type where
Pr : Show a => a -> Printable
Show Printable where
show (Pr p) = show p
hello : (f: Bool) -> Printable
hello False = Pr 10
@valpackett
valpackett / index.js
Created July 25, 2019 12:21
oxipng wasm wrapper
(async function () {
await wasm_bindgen('oxipng_wasm_bg.wasm')
window.oxi = wasm_bindgen
oxi.init()
const resp = await fetch('y.png')
const arb = await resp.arrayBuffer()
const uarr = new Uint8Array(arb)
console.log(uarr)
const t0 = performance.now()
window.result = oxi.optimize_from_memory(uarr)
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Copyright (c) 1999-2002 Vojtech Pavlik
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*/
#ifndef _UAPI_INPUT_H
#define _UAPI_INPUT_H
@valpackett
valpackett / dmesg
Created June 20, 2018 16:00
asus-duma postmarketOS first boot dmesg
[ 0.000000] Booting Linux on physical CPU 0
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.4.113-ElementalX-ME302KL-7.02 (pmos@varch) (gcc version 6.4.0 (Alpine 6.4.0) ) #1-postmarketOS SMP PREEMPT Wed Jun 20 11:36:41 UTC 2018
[ 0.000000] CPU: ARMv7 Processor [511f06f0] revision 0 (ARMv7), cr=10c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[ 0.000000] Machine: QCT APQ8064 DUMA
[ 0.000000] Truncating memory at 0x90000000 to fit in 32-bit physical address space
[ 0.000000] memory pool 3 (start fe9ff000 size 1600000) initialized
[ 0.000000] Hardboot page reserved at 0x88C00000
[ 0.000000] Initialized persistent memory from 88d00000-88dfffff