cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

ucmpdi2.c (484B)


      1// SPDX-License-Identifier: GPL-2.0
      2#include <linux/module.h>
      3
      4union ull_union {
      5	unsigned long long ull;
      6	struct {
      7		unsigned int high;
      8		unsigned int low;
      9	} ui;
     10};
     11
     12int __ucmpdi2(unsigned long long a, unsigned long long b)
     13{
     14	union ull_union au = {.ull = a};
     15	union ull_union bu = {.ull = b};
     16
     17	if (au.ui.high < bu.ui.high)
     18		return 0;
     19	else if (au.ui.high > bu.ui.high)
     20		return 2;
     21	if (au.ui.low < bu.ui.low)
     22		return 0;
     23	else if (au.ui.low > bu.ui.low)
     24		return 2;
     25	return 1;
     26}