Sfoglia il codice sorgente

gamemode: Add a value clamping helper

Signed-off-by: Kai Krakow <kai@kaishome.de>
Kai Krakow 6 anni fa
parent
commit
a91a2e7739
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      daemon/gamemode.c

+ 5 - 0
daemon/gamemode.c

@@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <signal.h>
 #include <signal.h>
 #include <stdatomic.h>
 #include <stdatomic.h>
 #include <string.h>
 #include <string.h>
+#include <sys/param.h>
 #include <sys/resource.h>
 #include <sys/resource.h>
 #include <sys/sysinfo.h>
 #include <sys/sysinfo.h>
 #include <systemd/sd-daemon.h>
 #include <systemd/sd-daemon.h>
@@ -59,6 +60,10 @@ POSSIBILITY OF SUCH DAMAGE.
  */
  */
 #define NICE_DEFAULT_PRIORITY -4
 #define NICE_DEFAULT_PRIORITY -4
 
 
+/* Value clamping helper.
+ */
+#define CLAMP(lbound, ubound, value) MIN(MIN(lbound, ubound), MAX(MAX(lbound, ubound), value))
+
 /**
 /**
  * The GameModeClient encapsulates the remote connection, providing a list
  * The GameModeClient encapsulates the remote connection, providing a list
  * form to contain the pid and credentials.
  * form to contain the pid and credentials.