Sunshine master
Self-hosted game stream host for Moonlight.
misc.h File Reference

Miscellaneous declarations for Linux. More...

#include <fcntl.h>
#include <filesystem>
#include <unistd.h>
#include <vector>
#include "src/utility.h"
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void(* dyn::apiproc) (void)
 Generic GLX procedure pointer returned by the loader.
 

Enumerations

enum class  window_system_e { NONE , X11 , WAYLAND }
 Enumerates supported window system options. More...
 

Functions

void * dyn::handle (const std::vector< const char * > &libs)
 Return the native handle owned by the wrapper.
 
int dyn::load (void *handle, const std::vector< std::tuple< apiproc *, const char * > > &funcs, bool strict)
 Load persisted state from its backing store.
 
int platf::open_drm_card_fd (const std::filesystem::path &path, int flags)
 Open a DRM card node, dropping implicit DRM master when possible.
 

Variables

window_system_e window_system
 Window system.
 

Detailed Description

Miscellaneous declarations for Linux.

Enumeration Type Documentation

◆ window_system_e

enum class window_system_e
strong

Enumerates supported window system options.

Enumerator
NONE 

No window system.

X11 

X11.

WAYLAND 

Wayland.

Function Documentation

◆ handle()

void * dyn::handle ( const std::vector< const char * > & libs)

Return the native handle owned by the wrapper.

Parameters
libsList of libraries to probe for the requested symbol.
Returns
Native dynamic-library handle, or nullptr when no library can be opened.

◆ load()

int dyn::load ( void * handle,
const std::vector< std::tuple< apiproc *, const char * > > & funcs,
bool strict = true )

Load persisted state from its backing store.

Parameters
handleNative library or object handle used by the operation.
funcsFunction table populated from the loaded library.
strictWhether missing functions should be treated as an error.
Returns
0 when all required symbols are loaded; nonzero when loading fails.

◆ open_drm_card_fd()

int platf::open_drm_card_fd ( const std::filesystem::path & path,
int flags )

Open a DRM card node, dropping implicit DRM master when possible.

Open a DRM card node and drop implicit DRM master, if any.

See misc.h for full documentation. Master check/drop failures are logged as warnings but do not fail the call.

Performs open(path, flags | O_CLOEXEC) and probes the resulting fd with DRM_IOCTL_AUTH_MAGIC. If the kernel implicitly handed us master, calls drmDropMaster and re-verifies before returning. Master check/drop failures are logged as warnings but do not fail the call: the caller still receives a usable fd.

Callers should use this helper for any /dev/dri/cardN open so we never keep implicit master and block compositors from re-acquiring it on VT switches.

Parameters
pathPath to the DRM card node (e.g. /dev/dri/card0).
flagsopen() flags. O_CLOEXEC is always OR-ed in.
Returns
A file descriptor on success, or -1 if open() itself fails.