#!/usr/bin/env python3 """Compare unchanged shipped OS time conversion with the Linux adapter body.""" import hashlib,json,subprocess from pathlib import Path R=Path(__file__).resolve().parents[1] original=Path('/home/geodd/nvidia-driver/analysis-580.178.04/extracted/kernel/nvidia/os-interface.c') replacement=R/'kernel-open/nvidia/clock_adapter.c' def body(text,signature): start=text.index(signature);pos=text.index('{',start);depth=0 for end in range(pos,len(text)): depth+=(text[end]=='{')-(text[end]=='}') if depth==0:return text[start:end+1] raise ValueError(signature) prologue='''#include #include #include typedef uint32_t u32; typedef uint32_t NvU32; typedef uint32_t NV_STATUS; #define NV_API_CALL #define NV_OK 0 #define NSEC_PER_USEC 1000 struct timespec64 { int64_t tv_sec; long tv_nsec; }; static struct timespec64 clock_value; static void ktime_get_real_ts64(struct timespec64 *out) { *out=clock_value; } ''' epilogue=''' int main(void) { int64_t seconds[]={0,1,-1,INT32_MAX,UINT32_MAX,INT64_C(4294967296),INT64_MAX}; long nanoseconds[]={0,1,999,1000,999999999}; unsigned count=0; for(unsigned s=0;s