00001 char *cvsinfo = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/calversfunctions.c,v 1.3 2013/04/28 07:58:43 tplarson Exp $";
00002
00003
00004
00005
00006
00007 unsigned long long getbits(unsigned long long x, int p, int n)
00008 {
00009 return (x >> (p+1-n)) & ~(~0ull << n);
00010 }
00011
00012
00013
00014
00015 unsigned long long setbits(unsigned long long x, int p, int n, unsigned long long y)
00016 {
00017 return (x & ((~0ull << (p + 1)) | (~(~0ull << (p + 1 - n))))) | ((y & ~(~0ull << n)) << (p + 1 - n));
00018
00019
00020 }
00021
00022 unsigned long long fixcalver64(unsigned long long x)
00023 {
00024 int firstnibble = getbits(x,3,4);
00025 if (firstnibble == 0)
00026 return setbits(x,3,4,2);
00027 else
00028 return x;
00029 }
00030
00031