From 0bb4fa6757492d087f4cbdd7cfcbd13f84a4dbbd Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 1 Apr 1993 16:40:38 +0000 Subject: [PATCH] added bit field extract/insert --- src/libCom/cvtFast.c | 53 ++++++++++++++++++++++++++++++++++++ src/libCom/cvtFast/cvtFast.c | 53 ++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) diff --git a/src/libCom/cvtFast.c b/src/libCom/cvtFast.c index 2106990bc..9d5bb2abf 100644 --- a/src/libCom/cvtFast.c +++ b/src/libCom/cvtFast.c @@ -41,7 +41,9 @@ * cvt[Float/Double]ToCompactString, * cvtLongToHex, cvtLongToOctal routines, fix * calls to gcvt, etc. + * .03 joh 03-30-93 added bit field extract/ insert routines */ + #include #include /* XPG2/XPG3/POSIX.1/FIPS151-1/ANSI-C */ #include @@ -751,3 +753,54 @@ int cvtLongToOctalString( *pdest = 0; return((int)(pdest-startAddr)); } + + + + +/* + * + * cvtBitsToUlong() + * + * extract a bit field from the source unsigend long + */ +unsigned long cvtBitsToUlong( +unsigned long src, +unsigned bitFieldOffset, +unsigned bitFieldLength) +{ + unsigned long mask; + + src = src >> bitFieldOffset; + + mask = (1< #include /* XPG2/XPG3/POSIX.1/FIPS151-1/ANSI-C */ #include @@ -751,3 +753,54 @@ int cvtLongToOctalString( *pdest = 0; return((int)(pdest-startAddr)); } + + + + +/* + * + * cvtBitsToUlong() + * + * extract a bit field from the source unsigend long + */ +unsigned long cvtBitsToUlong( +unsigned long src, +unsigned bitFieldOffset, +unsigned bitFieldLength) +{ + unsigned long mask; + + src = src >> bitFieldOffset; + + mask = (1<