Skip to content

Instantly share code, notes, and snippets.

@kostikbel
kostikbel / avx_sig.c
Last active December 11, 2021 22:47
Test AVX context save/restore on context switches and signals
/* $Id: avx_sig.c,v 1.12 2021/12/11 22:47:09 kostik Exp $ */
/*
* FreeBSD:
* ${CC} -Wall -Wextra -O -g -o avx_sig avx_sig.c -lpthread
* Linux
* ${CC} -D_GNU_SOURCE -Wall -Wextra -O -g -o avx_sig avx_sig.c -lbsd -lpthread
*/
#include <sys/param.h>
#include <sys/time.h>
@kostikbel
kostikbel / sigexcept.cc
Created November 25, 2021 02:03
throw from signal handler
#include <err.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <machine/sigframe.h>
static void
handler(int sig __unused, siginfo_t *, void *x)
/* $Id: membar_test.c,v 1.4 2021/10/08 12:33:32 kostik Exp kostik $ */
#include <sys/types.h>
#ifndef OLDSYSTEM
#include <sys/membarrier.h>
#endif
#include <err.h>
#include <errno.h>
#include <pthread.h>
#include <stdatomic.h>
/* $Id: shadow_show.c,v 1.4 2021/05/04 14:55:03 kostik Exp kostik $ */
/* /usr/local/opt/gcc-11.1.0/bin/gcc -Wall -Wextra -g -O -o shadow_show shadow_show.c -lutil */
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <err.h>
#include <libutil.h>
#include <stdbool.h>
#include <stdio.h>
/* $Id: o_path.c,v 1.4 2021/03/18 12:01:23 kostik Exp $ */
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#ifdef __FreeBSD__
#include <sys/param.h>
#include <sys/event.h>
#include <err.h>
#include <stdbool.h>
#include <stdio.h>
int
main(void)
{
struct kevent wev[1], rev[1];
#include <sys/time.h>
#include <err.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static void
sigalrm_handler(int sig __unused)
#include <math.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static double
read_xmm15(void)
{
double x;
/* $Id: thread-dbreg-test-pt2.c,v 1.7 2020/11/09 11:42:26 kostik Exp kostik $ */
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <machine/reg.h>
#include <assert.h>
#include <err.h>
#include <pthread.h>
#include <signal.h>
/* $Id: promotion_lat.c,v 1.8 2020/06/19 14:57:10 kostik Exp kostik $ */
#include <sys/param.h>
#include <sys/mman.h>
#include <machine/cpufunc.h>
#include <err.h>
#include <fcntl.h>
#include <pthread.h>
#include <pthread_np.h>