summaryrefslogtreecommitdiffstats
path: root/src/core/misc.c
diff options
context:
space:
mode:
authorMichael Brown2015-02-19 17:00:01 +0100
committerMichael Brown2015-02-19 17:00:01 +0100
commita32b1e9e3557393d60fb4805cd74d8ba357b66cb (patch)
treeacd24bea0b4b0fc300d9b2d613dab573ca49b21f /src/core/misc.c
parent[ipv4] Rewrite inet_aton() (diff)
downloadipxe-a32b1e9e3557393d60fb4805cd74d8ba357b66cb.tar.gz
ipxe-a32b1e9e3557393d60fb4805cd74d8ba357b66cb.tar.xz
ipxe-a32b1e9e3557393d60fb4805cd74d8ba357b66cb.zip
[libc] Rewrite strtoul()
The implementation of strtoul() has a partially unknown provenance. Rewrite this code to avoid potential licensing uncertainty. Since we now use -ffunction-sections, there is no need to place strtoull() in a separate file from strtoul(). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/core/misc.c')
-rw-r--r--src/core/misc.c62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/core/misc.c b/src/core/misc.c
deleted file mode 100644
index 84cfcd803..000000000
--- a/src/core/misc.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
-MISC Support Routines
-**************************************************************************/
-
-FILE_LICENCE ( GPL2_OR_LATER );
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <byteswap.h>
-#include <ipxe/in.h>
-#include <ipxe/timer.h>
-
-unsigned int strtoul_charval ( unsigned int charval ) {
-
- if ( charval >= 'a' ) {
- charval = ( charval - 'a' + 10 );
- } else if ( charval >= 'A' ) {
- charval = ( charval - 'A' + 10 );
- } else if ( charval <= '9' ) {
- charval = ( charval - '0' );
- }
-
- return charval;
-}
-
-unsigned long strtoul ( const char *p, char **endp, int base ) {
- unsigned long ret = 0;
- int negative = 0;
- unsigned int charval;
-
- while ( isspace ( *p ) )
- p++;
-
- if ( *p == '-' ) {
- negative = 1;
- p++;
- }
-
- base = strtoul_base ( &p, base );
-
- while ( 1 ) {
- charval = strtoul_charval ( *p );
- if ( charval >= ( unsigned int ) base )
- break;
- ret = ( ( ret * base ) + charval );
- p++;
- }
-
- if ( negative )
- ret = -ret;
-
- if ( endp )
- *endp = ( char * ) p;
-
- return ( ret );
-}
-
-/*
- * Local variables:
- * c-basic-offset: 8
- * End:
- */