AtlatestRepositorysigil-wm

sigil-wm / tree / testoutput-present-fault.c

1/* SPDX-License-Identifier: BSD-3-Clause
2 * A test-owned barrier withholds presentation, without changing product code. */
3#define _GNU_SOURCE
4#include <dlfcn.h>
5#include <stdatomic.h>
6#include <stdlib.h>
7#include <unistd.h>
8#include <wlr/interfaces/wlr_output.h>
9static atomic_uint withheld;
10unsigned wm_test_withheld_presents(void) { return atomic_load(&withheld); }
11void wlr_output_send_present(struct wlr_output *output,
12 struct wlr_output_event_present *event) {
13 const char *barrier=getenv("SIGIL_WM_PRESENT_BARRIER");
14 if(barrier && access(barrier,F_OK)==0) {
15 atomic_fetch_add(&withheld,1);
16 return;
17 }
18 typedef void (*present_fn)(struct wlr_output *,struct wlr_output_event_present *);
19 present_fn present=(present_fn)dlsym(RTLD_NEXT,"wlr_output_send_present");
20 if(!present) abort();
21 present(output,event);