Skip to content

Instantly share code, notes, and snippets.

View emersion's full-sized avatar

Simon Ser emersion

View GitHub Profile
static void tracef(const char *fmt, ...)
{
static int first = 1;
static FILE *trace_file = NULL;
if (first) {
trace_file = fopen("/sys/kernel/tracing/trace_marker", "w");
first = 0;
}
if (trace_file) {
va_list args;
@emersion
emersion / hw-limitations.md
Last active February 26, 2021 08:52
GPU hardware limitations

Intel

  • Enabling some modifiers can lead to hitting bandwidth limitations (not being able to light up a CRTC).
  • With YUV buffers, planes can only have a position with even coordinates (or odd?).

AMD

  • There's no real cursor plane, instead the hardware draws it on the top-most plane (overlay if enabled, otherwise primary). Thus the cursor composition properties (scaling, rotation, blend mode, etc) must match the underlying plane's. An RGB cursor buffer can't be used if the underlying plane uses a YUV format.
  • 90-degree and 270-degree rotations are not supported for linear buffers. Tiled buffers are required.
  • The primary plane needs to be enabled to allow any other plane to be enabled.

What does a mailing list need to do to reflect a message?

Method 1

Keep the original From header. Add a Sender header field with the list's address. Broadcast message with MAIL FROM set to the list's address.

Issues:

#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
int main() {
printf("before\n");
int dupfd = dup(STDOUT_FILENO);
if (dupfd < 0) {
return 1;
@emersion
emersion / compositor-cursor-unstable-v1.xml
Created October 18, 2018 16:29
Compositor-side cursors
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="wp_compositor_cursor_unstable_v1">
<interface name="zwp_compositor_cursor_manager_v1" version="1">
<request name="destroy" type="destructor"></request>
<enum name="device_type">
<entry name="pointer" value="1" summary="Pointer"/>
<entry name="tablet_tool" value="2" summary="Tablet tool"/>
</enum>
struct list {
void *value;
struct list *prev, *next;
};
void list_init(struct list *l) {
assert(l->prev == NULL && l->next == NULL);
l->prev = l;
l->next = l;
}
@emersion
emersion / security-headers.conf
Created July 30, 2018 12:45
Caddy strict security headers
header / {
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
Referrer-Policy "no-referrer"
Content-Security-Policy "default-src 'none'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; img-src https:; font-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'none'; form-action 'self'; worker-src 'none'; frame-src https://youtube-nocookie.com;"
Feature-Policy "accelerometer 'none'; ambient-light-sensor 'none'; autoplay 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'self'; speaker 'none'; usb 'none'; vr 'none';"
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
char buf[256], *mem;
const char *range_name;
FILE *rd, *wr;
long long start_addr, end_addr;
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct my_array {
void *data;
size_t cap;
size_t len, elem_size;
};
@emersion
emersion / download-pipermail.sh
Created June 5, 2018 16:05
Download a whole pipermail archive into a single mbox file
wget -r -np -l 1 -n d -A gz https://lists.freedesktop.org/archives/wayland-devel/
gunzip *.gz
cat * > all.mbox