diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-03 12:30:34 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-03 12:30:34 -0400 |
commit | ec3c37d1d40d7b288584c234f4c3e7a600f2353d (patch) | |
tree | bb587b33c4c793ff7a3317dfa958d69b0fa318a1 /lib/cvtoct.c | |
parent | move boot only headers to boot (diff) | |
download | comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.tar.gz comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.tar.bz2 comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.zip |
new libs
Diffstat (limited to '')
-rw-r--r-- | lib/cvtoct.c | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/cvtoct.c b/lib/cvtoct.c deleted file mode 100644 index 0e03cad..0000000 --- a/lib/cvtoct.c +++ /dev/null @@ -1,54 +0,0 @@ -/** -** @file cvtoct.c -** -** @author Numerous CSCI-452 classes -** -** @brief C implementations of common library functions -*/ - -#ifndef CVTOCT_SRC_INC -#define CVTOCT_SRC_INC - -#include <common.h> - -#include <lib.h> - -/** -** cvtoct(buf,value) -** -** convert a 32-bit unsigned value into a mininal-length (up to -** 11-character) NUL-terminated character string -** -** @param buf Destination buffer -** @param value Value to convert -** -** @return The number of characters placed into the buffer -** (not including the NUL) -** -** NOTE: assumes buf is large enough to hold the resulting string -*/ -int cvtoct(char *buf, uint32_t value) -{ - int i; - int chars_stored = 0; - char *bp = buf; - uint32_t val; - - val = (value & 0xc0000000); - val >>= 30; - for (i = 0; i < 11; i += 1) { - if (i == 10 || val != 0 || chars_stored) { - chars_stored = 1; - val &= 0x7; - *bp++ = val + '0'; - } - value <<= 3; - val = (value & 0xe0000000); - val >>= 29; - } - *bp = '\0'; - - return bp - buf; -} - -#endif |