diff options
author | RajithaY <rajithax.yerrumsetty@intel.com> | 2017-04-25 03:31:15 -0700 |
---|---|---|
committer | Rajitha Yerrumchetty <rajithax.yerrumsetty@intel.com> | 2017-05-22 06:48:08 +0000 |
commit | bb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch) | |
tree | ca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/roms/SLOF/lib/libc | |
parent | a14b48d18a9ed03ec191cf16b162206998a895ce (diff) |
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to
kvmfornfv repo and make use of the updated latest qemu for the
execution of all testcase
Change-Id: I1280af507a857675c7f81d30c95255635667bdd7
Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/roms/SLOF/lib/libc')
69 files changed, 0 insertions, 3276 deletions
diff --git a/qemu/roms/SLOF/lib/libc/Makefile b/qemu/roms/SLOF/lib/libc/Makefile deleted file mode 100644 index 0c762ec8b..000000000 --- a/qemu/roms/SLOF/lib/libc/Makefile +++ /dev/null @@ -1,61 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - -TOPCMNDIR ?= ../.. - -LIBCCMNDIR = $(shell pwd) -STRINGCMNDIR = $(LIBCCMNDIR)/string -CTYPECMNDIR = $(LIBCCMNDIR)/ctype -STDLIBCMNDIR = $(LIBCCMNDIR)/stdlib -STDIOCMNDIR = $(LIBCCMNDIR)/stdio -GETOPTCMNDIR = $(LIBCCMNDIR)/getopt - -include $(TOPCMNDIR)/make.rules - - -CPPFLAGS = -I$(LIBCCMNDIR)/include -LDFLAGS= -nostdlib - -TARGET = ../libc.a - - -all: $(TARGET) - -# Use the following target to build a native version of the lib -# (for example for debugging purposes): -native: - $(MAKE) CROSS="" CC=$(HOSTCC) NATIVEBUILD=1 - - -include $(STRINGCMNDIR)/Makefile.inc -include $(CTYPECMNDIR)/Makefile.inc -include $(STDLIBCMNDIR)/Makefile.inc -include $(STDIOCMNDIR)/Makefile.inc -include $(GETOPTCMNDIR)/Makefile.inc - -OBJS = $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) $(GETOPT_OBJS) - -ifneq ($(NATIVEBUILD),1) -# These parts of the libc use assembler, so they can only be compiled when -# we are _not_ building a native version. -endif - - -$(TARGET): $(OBJS) - $(AR) -rc $@ $(OBJS) - $(RANLIB) $@ - - -clean: - $(RM) $(TARGET) $(OBJS) - -distclean: clean diff --git a/qemu/roms/SLOF/lib/libc/README.txt b/qemu/roms/SLOF/lib/libc/README.txt deleted file mode 100644 index eaafdf4af..000000000 --- a/qemu/roms/SLOF/lib/libc/README.txt +++ /dev/null @@ -1,49 +0,0 @@ - - Standard C library for the SLOF firmware project - ================================================ - -To use this library, link your target against the "libc.a" archive. - -However, there are some prerequisites before you can use certain parts of the -library: - -1) If you want to use malloc() and the like, you have to supply an implemen- - tation of sbrk() in your own code. malloc() uses sbrk() to get new, free - memory regions. - - Prototype: void *sbrk(int incr); - Description: sbrk() increments the available data space by incr bytes and - returns a pointer to the start of the new area. - - See the man-page of sbrk for details about this function. - -2) Before you can use the stdio output functions like printf(), puts() and the - like, you have to provide a standard write() function in your code. - printf() and the like use write() to print out the strings to the standard - output. - - Prototype: ssize_t write(int fd, const void *buf, size_t cnt); - Description: Write cnt byte from the buffer buf to the stream associated - with the file descriptor fd. - - The stdio functions will print their output to the stdout channel which is - assigned with the file descriptor 1 by default. Note that the stdio - functions will not use open() before calling write(), so if the stdout - cannel needs to be opened first, you should do that in your start-up code - before using the libc functions for the first time. - -3) Before you can use the stdio input functions like scanf() and the - like, you have to provide a standard read() function in your code. - scanf() and the like use read() to get the characters from the standard - input. - - Prototype: ssize_t read(int fd, void *buf, size_t cnt); - Description: Read cnt byte from the stream associated with the file - descriptor fd and put them into the buffer buf. - - The stdio functions will get their input from the stdin channel which is - assigned with the file descriptor 0 by default. Note that the stdio - functions will not use open() before calling read(), so if the stdin - cannel needs to be opened first, you should do that in your start-up code - before using the libc functions for the first time. - diff --git a/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc b/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc deleted file mode 100644 index 25513a9a7..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/Makefile.inc +++ /dev/null @@ -1,20 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - - -CTYPE_SRC_C = isdigit.c isprint.c isspace.c isxdigit.c tolower.c toupper.c -CTYPE_SRC_ASM = -CTYPE_SRCS = $(CTYPE_SRC_C:%=$(CTYPECMNDIR)/%) $(CTYPE_SRC_ASM:%=$(CTYPECMNDIR)/%) -CTYPE_OBJS = $(CTYPE_SRC_C:%.c=%.o) $(CTYPE_SRC_ASM:%.S=%.o) - -%.o : $(CTYPECMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ diff --git a/qemu/roms/SLOF/lib/libc/ctype/isdigit.c b/qemu/roms/SLOF/lib/libc/ctype/isdigit.c deleted file mode 100644 index 62d08a1cf..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/isdigit.c +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <ctype.h> - -int isdigit(int ch) -{ - switch (ch) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - return 1; - - default: - return 0; - } -} diff --git a/qemu/roms/SLOF/lib/libc/ctype/isprint.c b/qemu/roms/SLOF/lib/libc/ctype/isprint.c deleted file mode 100644 index c74880f1c..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/isprint.c +++ /dev/null @@ -1,18 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <ctype.h> - -int isprint(int ch) -{ - return (ch >= 32 && ch < 127); -} diff --git a/qemu/roms/SLOF/lib/libc/ctype/isspace.c b/qemu/roms/SLOF/lib/libc/ctype/isspace.c deleted file mode 100644 index 51230192f..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/isspace.c +++ /dev/null @@ -1,29 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <ctype.h> - -int isspace(int ch) -{ - switch (ch) { - case ' ': - case '\f': - case '\n': - case '\r': - case '\t': - case '\v': - return 1; - - default: - return 0; - } -} diff --git a/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c b/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c deleted file mode 100644 index 9d323f3c0..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/isxdigit.c +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <ctype.h> - -int isxdigit(int ch) -{ - return ( - (ch >= '0' && ch <= '9') | - (ch >= 'A' && ch <= 'F') | - (ch >= 'a' && ch <= 'f') ); -} diff --git a/qemu/roms/SLOF/lib/libc/ctype/tolower.c b/qemu/roms/SLOF/lib/libc/ctype/tolower.c deleted file mode 100644 index f775e9096..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/tolower.c +++ /dev/null @@ -1,18 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <ctype.h> - -int tolower(int c) -{ - return (((c >= 'A') && (c <= 'Z')) ? (c - 'A' + 'a' ) : c); -} diff --git a/qemu/roms/SLOF/lib/libc/ctype/toupper.c b/qemu/roms/SLOF/lib/libc/ctype/toupper.c deleted file mode 100644 index 9bcee523d..000000000 --- a/qemu/roms/SLOF/lib/libc/ctype/toupper.c +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "ctype.h" - -int toupper (int cha) -{ - if((cha >= 'a') && (cha <= 'z')) - return(cha - 'a' + 'A'); - return(cha); -} diff --git a/qemu/roms/SLOF/lib/libc/getopt/Makefile.inc b/qemu/roms/SLOF/lib/libc/getopt/Makefile.inc deleted file mode 100644 index 8a2e32f00..000000000 --- a/qemu/roms/SLOF/lib/libc/getopt/Makefile.inc +++ /dev/null @@ -1,17 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - -GETOPT_SRC_C = getopt.c -GETOPT_OBJS = $(GETOPT_SRC_C:%.c=%.o) - -%.o : $(GETOPTCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ diff --git a/qemu/roms/SLOF/lib/libc/getopt/getopt.c b/qemu/roms/SLOF/lib/libc/getopt/getopt.c deleted file mode 100644 index be626ddc2..000000000 --- a/qemu/roms/SLOF/lib/libc/getopt/getopt.c +++ /dev/null @@ -1,470 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -/* - * includes - ******************************************************************************* - */ -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <getopt.h> - -/* - * global variables, types & constants - * may be removed if already defined - ******************************************************************************* - */ -int opterr = 1; -int optopt = 0; -int optind = 1; -char *optarg = NULL; - -/* - * internal values needed by getopt - * DO NOT CHANGE or REMOVE - */ -enum { - OPTIONAL_ARG = 0, - MANDATORY_ARG = 1, - NO_ARG = 2 -}; - -/* - * variables needed by getopt & getopt_long! - * DO NOT REMOVE - */ -static char *optstart = NULL; - -int -getopt(int argc, char **argv, const char *options) -{ - char *optptr; - char *argptr; - int optman; - int idx; - int ret = 0; - int argpresent; - - /* - * reset used global values - */ - optopt = 0; - optarg = NULL; - - /* - * reset getopt if a new argv pointer is passed - */ - if (optstart != argv[0]) { - optopt = 0; - optind = 1; - optarg = NULL; - optstart = argv[0]; - } - - /* - * return if no more arguments are available - */ - if (optind >= argc) { - return -1; - } - - /* - * start parsing argv[optind] - */ - idx = 0; - - /* - * return if the option does not begin with a '-' or has more than 2 characters - */ - if (argv[optind][idx] != '-') { - - if (opterr != 0) { - printf("unknown option \'%s\', expecting \'-\'\n", - argv[optind]); - } - - optopt = (int) argv[optind][idx]; - optind++; - - return '?'; - } - - /* - * continue to the next character in argv[optind] - */ - idx++; - - /* - * identify the option - * make sure if an option contains a ':' to invalidate the option - */ - optptr = strchr(argv[optind], ':'); - - if (optptr == NULL) { - optptr = strchr(options, (int) argv[optind][idx]); - } else { - optptr = NULL; - } - - /* - * check whether the option is present - */ - if (optptr == NULL) { - /* - * unknown option detected - */ - if (opterr != 0) { - printf("unknown option \'%s\'\n", argv[optind]); - } - - optopt = (int) argv[optind][idx]; - optind++; - - return '?'; - } - - /* - * the option is present in the option string - * setup return value - */ - ret = (int) *optptr; - - /* - * get option argument if needed - */ - optptr++; - - /* - * determine between mandatory and optional argument - */ - optman = NO_ARG; - - if (*optptr == ':') { - optman--; // now set to MANDATORY_ARG - } - - if (optman == MANDATORY_ARG) { - optptr++; - - if (*optptr == ':') { - optman--; // now set to OPTIONAL_ARG - } - - } - - /* - * if strlen( argv[optind ) is greater than 2, - * the argument is in the same argv - */ - if (strlen(argv[optind]) > 2) { - argptr = &argv[optind][2]; - - /* - * do not allow '-' in an argument - */ - if (strchr(argptr, '-') != NULL) { - - if (opterr != 0) { - printf - ("illegal argument value \'%s\' for option \'-%c\'\n", - argptr, ret); - } - - optopt = ret; - - return '?'; - } - - } else { - /* - * move on to the next argv - * it now either contains an argument or the next option - */ - optind++; - - /* - * make sure not to overflow - */ - if (optind < argc) { - argptr = argv[optind]; - } else { - argptr = NULL; - } - - } - - /* - * do the needed actions for the argument state - */ - switch (optman) { - case OPTIONAL_ARG: - - if (argptr == NULL) { - break; - } - - if (*argptr != '-') { - /* - * argument present - */ - optarg = argptr; - optind++; - - } - - - break; - - case MANDATORY_ARG: - argpresent = (argptr != NULL); - - if (argpresent) { - argpresent = (*argptr != '-'); - } - - if (argpresent) { - /* - * argument present - */ - optarg = argptr; - optind++; - } else { - /* - * mandatory argument missing - */ - if (opterr != 0) { - printf - ("missing argument for option \'-%c\'\n", - ret); - } - - optopt = ret; - - /* - * if the first character of options is a ':' - * return a ':' instead of a '?' in case of - * a missing argument - */ - if (*options == ':') { - ret = ':'; - } else { - ret = '?'; - } - - } - - - break; - - case NO_ARG: - - if (strlen(argv[optind - 1]) > 2) { - - if (opterr != 0) { - printf - ("too many arguments for option \'-%c\'\n", - ret); - } - - optopt = ret; - ret = '?'; - } - - - break; - - } - - return ret; -} - -int -getopt_long(int argc, char **argv, const char *shortopts, - const struct option *longopts, int *indexptr) -{ - struct option *optptr = (struct option *) longopts; - int optidx = 0; - int idx; - int ret = 0; - int argpresent; - - /* - * reset used global values - */ - optopt = 0; - optarg = NULL; - - /* - * reset indexptr - */ - *indexptr = -1; - - /* - * reset getopt if a new argv pointer is passed - */ - if (optstart != argv[0]) { - optopt = 0; - optind = 1; - optarg = NULL; - optstart = argv[0]; - } - - /* - * return if no more arguments are available - */ - if (optind >= argc) { - return -1; - } - - /* - * start parsing argv[optind] - */ - idx = 0; - - /* - * return if the option does not begin with a '-' - */ - if (argv[optind][idx] != '-') { - printf("unknown option \'%s\', expecting \'-\'\n", - argv[optind]); - - optind++; - - return '?'; - } - - /* - * move on to the next character in argv[optind] - */ - idx++; - - /* - * return getopt() in case of a short option - */ - if (argv[optind][idx] != '-') { - return getopt(argc, argv, shortopts); - } - - /* - * handle a long option - */ - idx++; - - while (optptr->name != NULL) { - - if (strcmp(&argv[optind][idx], optptr->name) == 0) { - break; - } - - optptr++; - optidx++; - } - - /* - * no matching option found - */ - if (optptr->name == NULL) { - printf("unknown option \'%s\'\n", argv[optind]); - - optind++; - - return '?'; - } - - /* - * option was found, set up index pointer - */ - *indexptr = optidx; - - /* - * get argument - */ - optind++; - - switch (optptr->has_arg) { - case no_argument: - /* - * nothing to do - */ - - break; - - case required_argument: - argpresent = (optind != argc); - - if (argpresent) { - argpresent = (argv[optind][0] != '-'); - } - - if (argpresent) { - /* - * argument present - */ - optarg = argv[optind]; - optind++; - } else { - /* - * mandatory argument missing - */ - printf("missing argument for option \'%s\'\n", - argv[optind - 1]); - - ret = '?'; - } - - - break; - - case optional_argument: - - if (optind == argc) { - break; - } - - if (argv[optind][0] != '-') { - /* - * argument present - */ - optarg = argv[optind]; - optind++; - } - - - break; - - default: - printf("unknown argument option for option \'%s\'\n", - argv[optind - 1]); - - ret = '?'; - - break; - - } - - /* - * setup return values - */ - if (ret != '?') { - - if (optptr->flag == NULL) { - ret = optptr->val; - } else { - *optptr->flag = optptr->val; - ret = 0; - } - - } - - return ret; -} diff --git a/qemu/roms/SLOF/lib/libc/include/ctype.h b/qemu/roms/SLOF/lib/libc/include/ctype.h deleted file mode 100644 index 9051a7563..000000000 --- a/qemu/roms/SLOF/lib/libc/include/ctype.h +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _CTYPE_H -#define _CTYPE_H - -int isdigit(int c); -int isxdigit(int c); -int isprint(int c); -int isspace(int c); - -int tolower(int c); -int toupper(int c); - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/errno.h b/qemu/roms/SLOF/lib/libc/include/errno.h deleted file mode 100644 index d5859347e..000000000 --- a/qemu/roms/SLOF/lib/libc/include/errno.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _ERRNO_H -#define _ERRNO_H - -extern int errno; - -/* - * Error number definitions - */ -#define EPERM 1 /* not permitted */ -#define ENOENT 2 /* file or directory not found */ -#define EIO 5 /* input/output error */ -#define ENOMEM 12 /* not enough space */ -#define EACCES 13 /* permission denied */ -#define EFAULT 14 /* bad address */ -#define EBUSY 16 /* resource busy */ -#define EEXIST 17 /* file already exists */ -#define ENODEV 19 /* device not found */ -#define EINVAL 22 /* invalid argument */ -#define EDOM 33 /* math argument out of domain of func */ -#define ERANGE 34 /* math result not representable */ - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/getopt.h b/qemu/roms/SLOF/lib/libc/include/getopt.h deleted file mode 100644 index 5956986a5..000000000 --- a/qemu/roms/SLOF/lib/libc/include/getopt.h +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef GETOPT_H -#define GETOPT_H - -extern char *optarg; -extern int optind; -extern int opterr; -extern int optopt; - -struct option { - const char *name; - int has_arg; - int *flag; - int val; -}; - -enum { - no_argument = 0, - required_argument, - optional_argument -}; - -int getopt(int argc, char **, const char *); -int getopt_long(int argc, char **, const char *, const struct option *, int *); - -#endif /* GETOPT_H */ diff --git a/qemu/roms/SLOF/lib/libc/include/limits.h b/qemu/roms/SLOF/lib/libc/include/limits.h deleted file mode 100644 index 4726835c2..000000000 --- a/qemu/roms/SLOF/lib/libc/include/limits.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _LIMITS_H -#define _LIMITS_H - -#define UCHAR_MAX 255 -#define SCHAR_MAX 127 -#define SCHAR_MIN (-128) - -#define USHRT_MAX 65535 -#define SHRT_MAX 32767 -#define SHRT_MIN (-32768) - -#define UINT_MAX (4294967295U) -#define INT_MAX 2147483647 -#define INT_MIN (-2147483648) - -#define ULONG_MAX ((unsigned long)-1L) -#define LONG_MAX (ULONG_MAX/2) -#define LONG_MIN ((-LONG_MAX)-1) - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/stdarg.h b/qemu/roms/SLOF/lib/libc/include/stdarg.h deleted file mode 100644 index d3d12f778..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stdarg.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDARG_H -#define _STDARG_H - -typedef __builtin_va_list va_list; - -#define va_start(v,l) __builtin_va_start(v,l) -#define va_arg(v,l) __builtin_va_arg(v,l) -#define va_end(v) __builtin_va_end(v) - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/stdbool.h b/qemu/roms/SLOF/lib/libc/include/stdbool.h deleted file mode 100644 index 5b7d36a7e..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stdbool.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2013 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDBOOL_H -#define _STDBOOL_H - -#ifndef __cplusplus -typedef enum { false = 0, true } bool; -#endif - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/stddef.h b/qemu/roms/SLOF/lib/libc/include/stddef.h deleted file mode 100644 index ba2d96098..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stddef.h +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDDEF_H -#define _STDDEF_H - - -#define NULL ((void *)0) - - -typedef unsigned int size_t; - - -#endif - - diff --git a/qemu/roms/SLOF/lib/libc/include/stdint.h b/qemu/roms/SLOF/lib/libc/include/stdint.h deleted file mode 100644 index 518a72305..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stdint.h +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDINT_H -#define _STDINT_H - -typedef unsigned char uint8_t; -typedef signed char int8_t; - -typedef unsigned short uint16_t; -typedef signed short int16_t; - -typedef unsigned int uint32_t; -typedef signed int int32_t; - -typedef unsigned long long uint64_t; -typedef signed long long int64_t; - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/stdio.h b/qemu/roms/SLOF/lib/libc/include/stdio.h deleted file mode 100644 index 84cddea07..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stdio.h +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDIO_H -#define _STDIO_H - -#include <stdarg.h> -#include "stddef.h" - -#define EOF (-1) - -#define _IONBF 0 -#define _IOLBF 1 -#define _IOFBF 2 -#define BUFSIZ 80 - -typedef struct { - int fd; - int mode; - int pos; - char *buf; - int bufsiz; -} FILE; - -extern FILE stdin_data; -extern FILE stdout_data; -extern FILE stderr_data; - -#define stdin (&stdin_data) -#define stdout (&stdout_data) -#define stderr (&stderr_data) - -int fileno(FILE *stream); -int printf(const char *format, ...) __attribute__((format (printf, 1, 2))); -int fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3))); -int sprintf(char *str, const char *format, ...) __attribute__((format (printf, 2, 3))); -int vfprintf(FILE *stream, const char *format, va_list); -int vsprintf(char *str, const char *format, va_list); -int vsnprintf(char *str, size_t size, const char *format, va_list); -void setbuf(FILE *stream, char *buf); -int setvbuf(FILE *stream, char *buf, int mode , size_t size); - -int putc(int ch, FILE *stream); -int putchar(int ch); -int puts(char *str); - -int scanf(const char *format, ...) __attribute__((format (scanf, 1, 2))); -int fscanf(FILE *stream, const char *format, ...) __attribute__((format (scanf, 2, 3))); -int vfscanf(FILE *stream, const char *format, va_list); -int vsscanf(const char *str, const char *format, va_list); -int getc(FILE *stream); -int getchar(void); - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/stdlib.h b/qemu/roms/SLOF/lib/libc/include/stdlib.h deleted file mode 100644 index 5e0eda9ff..000000000 --- a/qemu/roms/SLOF/lib/libc/include/stdlib.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STDLIB_H -#define _STDLIB_H - -#include "stddef.h" - -#define RAND_MAX 32767 - - -void *malloc(size_t size); -void *realloc(void *ptr, size_t size); -void free(void *ptr); -void *memalign(size_t boundary, size_t size); - -int atoi(const char *str); -long atol(const char *str); -unsigned long int strtoul(const char *nptr, char **endptr, int base); -long int strtol(const char *nptr, char **endptr, int base); - -int rand(void); -void srand(unsigned int seed); - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/string.h b/qemu/roms/SLOF/lib/libc/include/string.h deleted file mode 100644 index 0163c9a67..000000000 --- a/qemu/roms/SLOF/lib/libc/include/string.h +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _STRING_H -#define _STRING_H - -#include "stddef.h" - -char *strcpy(char *dest, const char *src); -char *strncpy(char *dest, const char *src, size_t n); -char *strcat(char *dest, const char *src); -int strcmp(const char *s1, const char *s2); -int strncmp(const char *s1, const char *s2, size_t n); -int strcasecmp(const char *s1, const char *s2); -int strncasecmp(const char *s1, const char *s2, size_t n); -char *strchr(const char *s, int c); -char *strrchr(const char *s, int c); -size_t strlen(const char *s); -char *strstr(const char *hay, const char *needle); -char *strtok(char *src, const char *pattern); - -void *memset(void *s, int c, size_t n); -void *memchr(const void *s, int c, size_t n); -void *memcpy(void *dest, const void *src, size_t n); -void *memmove(void *dest, const void *src, size_t n); -int memcmp(const void *s1, const void *s2, size_t n); - -#endif diff --git a/qemu/roms/SLOF/lib/libc/include/unistd.h b/qemu/roms/SLOF/lib/libc/include/unistd.h deleted file mode 100644 index 07210d69a..000000000 --- a/qemu/roms/SLOF/lib/libc/include/unistd.h +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#ifndef _UNISTD_H -#define _UNISTD_H - -#include <stddef.h> - -typedef long ssize_t; - -extern int open(const char *name, int flags); -extern int close(int fd); -extern ssize_t read(int fd, void *buf, size_t count); -extern ssize_t write(int fd, const void *buf, size_t count); -extern ssize_t lseek(int fd, long offset, int whence); - -extern void *sbrk(int increment); - -#endif diff --git a/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc b/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc deleted file mode 100644 index ac5302d01..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - - -STDIO_SRC_C = fscanf.c sprintf.c vfprintf.c vsnprintf.c vsprintf.c fprintf.c \ - printf.c setvbuf.c putc.c puts.c putchar.c scanf.c stdchnls.c \ - vfscanf.c vsscanf.c fileno.c - -STDIO_SRC_ASM = -STDIO_SRCS = $(STDIO_SRC_C:%=$(STDIOCMNDIR)/%) $(STDIO_SRC_ASM:%=$(STDIOCMNDIR)/%) -STDIO_OBJS = $(STDIO_SRC_C:%.c=%.o) $(STDIO_SRC_ASM:%.S=%.o) - -%.o : $(STDIOCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ diff --git a/qemu/roms/SLOF/lib/libc/stdio/fileno.c b/qemu/roms/SLOF/lib/libc/stdio/fileno.c deleted file mode 100644 index 6e239511d..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/fileno.c +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - -int -fileno(FILE *stream) -{ - return stream->fd; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/fprintf.c b/qemu/roms/SLOF/lib/libc/stdio/fprintf.c deleted file mode 100644 index 866df3934..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/fprintf.c +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" - - -int fprintf(FILE *stream, const char* fmt, ...) -{ - int count; - va_list ap; - - va_start(ap, fmt); - count = vfprintf(stream, fmt, ap); - va_end(ap); - - return count; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/fscanf.c b/qemu/roms/SLOF/lib/libc/stdio/fscanf.c deleted file mode 100644 index 321b1630a..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/fscanf.c +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - -int -fscanf(FILE *stream, const char *fmt, ...) -{ - int count; - va_list ap; - - va_start(ap, fmt); - count = vfscanf(stream, fmt, ap); - va_end(ap); - - return count; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/printf.c b/qemu/roms/SLOF/lib/libc/stdio/printf.c deleted file mode 100644 index 01f4592dd..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/printf.c +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" - - -int printf(const char* fmt, ...) -{ - int count; - va_list ap; - - va_start(ap, fmt); - count = vfprintf(stdout, fmt, ap); - va_end(ap); - - return count; -} - diff --git a/qemu/roms/SLOF/lib/libc/stdio/putc.c b/qemu/roms/SLOF/lib/libc/stdio/putc.c deleted file mode 100644 index 230e9d196..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/putc.c +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" -#include "unistd.h" - -int -putc(int ch, FILE *stream) -{ - unsigned char outchar = ch; - - if (write(stream->fd, &outchar, 1) == 1) - return outchar; - else - return EOF; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/putchar.c b/qemu/roms/SLOF/lib/libc/stdio/putchar.c deleted file mode 100644 index 5c750d90a..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/putchar.c +++ /dev/null @@ -1,21 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdio.h" - - -int -putchar(int ch) -{ - return putc(ch, stdout); -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/puts.c b/qemu/roms/SLOF/lib/libc/stdio/puts.c deleted file mode 100644 index 3f48dbfda..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/puts.c +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdio.h" -#include "string.h" -#include "unistd.h" - - -int -puts(char *str) -{ - int ret; - - ret = write(stdout->fd, str, strlen(str)); - write(stdout->fd, "\r\n", 2); - - return ret; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/scanf.c b/qemu/roms/SLOF/lib/libc/stdio/scanf.c deleted file mode 100644 index 96b639980..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/scanf.c +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - -int -scanf(const char *fmt, ...) -{ - int count; - va_list ap; - - va_start(ap, fmt); - count = vfscanf(stdin, fmt, ap); - va_end(ap); - - return count; -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/setvbuf.c b/qemu/roms/SLOF/lib/libc/stdio/setvbuf.c deleted file mode 100644 index 9b62dd8ff..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/setvbuf.c +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - -int setvbuf(FILE *stream, char *buf, int mode , size_t size) -{ - if (mode != _IONBF && mode != _IOLBF && mode != _IOFBF) - return -1; - stream->buf = buf; - stream->mode = mode; - stream->bufsiz = size; - return 0; -} - -void setbuf(FILE *stream, char *buf) -{ - setvbuf(stream, buf, buf ? _IOFBF : _IONBF, BUFSIZ); -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/sprintf.c b/qemu/roms/SLOF/lib/libc/stdio/sprintf.c deleted file mode 100644 index 9c4540e2e..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/sprintf.c +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdio.h> - - -int sprintf(char *buff, const char *format, ...) -{ - va_list ar; - int count; - - if ((buff==NULL) || (format==NULL)) - return(-1); - - va_start(ar, format); - count = vsprintf(buff, format, ar); - va_end(ar); - - return(count); -} - diff --git a/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c b/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c deleted file mode 100644 index 41ed958bf..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/stdchnls.c +++ /dev/null @@ -1,23 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdio.h" - -static char stdin_buffer[BUFSIZ], stdout_buffer[BUFSIZ]; - -FILE stdin_data = { .fd = 0, .mode = _IOLBF, .pos = 0, - .buf = stdin_buffer, .bufsiz = BUFSIZ }; -FILE stdout_data = { .fd = 1, .mode = _IOLBF, .pos = 0, - .buf = stdout_buffer, .bufsiz = BUFSIZ }; -FILE stderr_data = { .fd = 2, .mode = _IONBF, .pos = 0, - .buf = NULL, .bufsiz = 0 }; diff --git a/qemu/roms/SLOF/lib/libc/stdio/vfprintf.c b/qemu/roms/SLOF/lib/libc/stdio/vfprintf.c deleted file mode 100644 index 765feeace..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/vfprintf.c +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" -#include "unistd.h" - - -int vfprintf(FILE *stream, const char *fmt, va_list ap) -{ - int count; - char buffer[320]; - - count = vsnprintf(buffer, sizeof(buffer), fmt, ap); - write(stream->fd, buffer, count); - - return count; -} - diff --git a/qemu/roms/SLOF/lib/libc/stdio/vfscanf.c b/qemu/roms/SLOF/lib/libc/stdio/vfscanf.c deleted file mode 100644 index 4ddd210a9..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/vfscanf.c +++ /dev/null @@ -1,266 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" -#include "ctype.h" -#include "stdlib.h" -#include "stdio.h" -#include "unistd.h" - - -static int -_getc(FILE * stream) -{ - int count; - char c; - - if (stream->mode == _IONBF || stream->buf == NULL) { - if (read(stream->fd, &c, 1) == 1) - return (int) c; - else - return EOF; - } - - if (stream->pos == 0 || stream->pos >= BUFSIZ || - stream->buf[stream->pos] == '\0') { - count = read(stream->fd, stream->buf, BUFSIZ); - if (count < 0) - count = 0; - if (count < BUFSIZ) - stream->buf[count] = '\0'; - stream->pos = 0; - } - - return stream->buf[stream->pos++]; -} - -static void -_ungetc(int ch, FILE * stream) -{ - if (stream->mode != _IONBF && stream->pos > 0) - stream->pos--; -} - -static int -_is_voidage(int ch) -{ - if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' || ch == '\0') - return 1; - else - return 0; -} - - -static int -_scanf(FILE * stream, const char *fmt, va_list * ap) -{ - int i = 0; - int length = 0; - - fmt++; - - while (*fmt != '\0') { - - char tbuf[256]; - char ch; - - switch (*fmt) { - case 'd': - case 'i': - ch = _getc(stream); - if (length == 0) { - while (!_is_voidage(ch) && isdigit(ch)) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } else { - while (!_is_voidage(ch) && i < length - && isdigit(ch)) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } - /* We tried to understand what this is good for... - * but we did not. We know for sure that it does not - * work on SLOF if this is active. */ - /* _ungetc(ch, stream); */ - tbuf[i] = '\0'; - - /* ch = _getc(stream); */ - if (!_is_voidage(ch)) - _ungetc(ch, stream); - - if (strlen(tbuf) == 0) - return 0; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 10); - break; - case 'X': - case 'x': - ch = _getc(stream); - if (length == 0) { - while (!_is_voidage(ch) && isxdigit(ch)) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } else { - while (!_is_voidage(ch) && i < length - && isxdigit(ch)) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } - /* _ungetc(ch, stream); */ - tbuf[i] = '\0'; - - /* ch = _getc(stream); */ - if (!_is_voidage(ch)) - _ungetc(ch, stream); - - if (strlen(tbuf) == 0) - return 0; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 16); - break; - case 'O': - case 'o': - ch = _getc(stream); - if (length == 0) { - while (!_is_voidage(ch) - && !(ch < '0' || ch > '7')) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } else { - while (!_is_voidage(ch) && i < length - && !(ch < '0' || ch > '7')) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } - /* _ungetc(ch, stream); */ - tbuf[i] = '\0'; - - /* ch = _getc(stream); */ - if (!_is_voidage(ch)) - _ungetc(ch, stream); - - if (strlen(tbuf) == 0) - return 0; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 8); - break; - case 'c': - ch = _getc(stream); - while (_is_voidage(ch)) - ch = _getc(stream); - - *(va_arg(*ap, char *)) = ch; - - ch = _getc(stream); - if (!_is_voidage(ch)) - _ungetc(ch, stream); - - break; - case 's': - ch = _getc(stream); - if (length == 0) { - while (!_is_voidage(ch)) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } else { - while (!_is_voidage(ch) && i < length) { - tbuf[i] = ch; - ch = _getc(stream); - i++; - } - } - /* _ungetc(ch, stream); */ - tbuf[i] = '\0'; - - /* ch = _getc(stream); */ - if (!_is_voidage(ch)) - _ungetc(ch, stream); - - strcpy(va_arg(*ap, char *), tbuf); - break; - default: - if (*fmt >= '0' && *fmt <= '9') - length += *fmt - '0'; - break; - } - fmt++; - } - - return 1; -} - - - -int -vfscanf(FILE * stream, const char *fmt, va_list ap) -{ - int args = 0; - - while (*fmt != '\0') { - - if (*fmt == '%') { - - char formstr[20]; - int i = 0; - - do { - formstr[i] = *fmt; - fmt++; - i++; - } while (! - (*fmt == 'd' || *fmt == 'i' || *fmt == 'x' - || *fmt == 'X' || *fmt == 'p' || *fmt == 'c' - || *fmt == 's' || *fmt == '%' || *fmt == 'O' - || *fmt == 'o')); - formstr[i++] = *fmt; - formstr[i] = '\0'; - if (*fmt != '%') { - if (_scanf(stream, formstr, &ap) <= 0) - return args; - else - args++; - } - - } - - fmt++; - - } - - return args; -} - -int -getc(FILE * stream) -{ - return _getc(stream); -} - -int -getchar(void) -{ - return _getc(stdin); -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c b/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c deleted file mode 100644 index 21dd04dfe..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/vsnprintf.c +++ /dev/null @@ -1,298 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdbool.h> -#include "stdio.h" -#include "stdlib.h" -#include "string.h" -#include "ctype.h" - -static const unsigned long long convert[] = { - 0x0, 0xFF, 0xFFFF, 0xFFFFFF, 0xFFFFFFFF, - 0xFFFFFFFFFFULL, 0xFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFULL, 0xFFFFFFFFFFFFFFFFULL -}; - -static int -print_str_fill(char **buffer, size_t bufsize, char *sizec, - const char *str, char c) -{ - int i, sizei, len; - char *bstart = *buffer; - - sizei = strtoul(sizec, NULL, 10); - len = strlen(str); - if (sizei > len) { - for (i = 0; - (i < (sizei - len)) && ((*buffer - bstart) < bufsize); - i++) { - **buffer = c; - *buffer += 1; - } - } - return 1; -} - -static int -print_str(char **buffer, size_t bufsize, const char *str) -{ - char *bstart = *buffer; - size_t i; - - for (i = 0; (i < strlen(str)) && ((*buffer - bstart) < bufsize); i++) { - **buffer = str[i]; - *buffer += 1; - } - return 1; -} - -static unsigned int -print_intlen(unsigned long value, unsigned short int base) -{ - int i = 0; - - while (value > 0) { - value /= base; - i++; - } - if (i == 0) - i = 1; - return i; -} - -static int -print_itoa(char **buffer, size_t bufsize, unsigned long value, - unsigned short base, bool upper) -{ - const char zeichen[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; - char c; - size_t i, len; - - if(base <= 2 || base > 16) - return 0; - - len = i = print_intlen(value, base); - - /* Don't print to buffer if bufsize is not enough. */ - if (len > bufsize) - return 0; - - do { - c = zeichen[value % base]; - if (upper) - c = toupper(c); - - (*buffer)[--i] = c; - value /= base; - } while(value); - - *buffer += len; - - return 1; -} - - - -static int -print_fill(char **buffer, size_t bufsize, char *sizec, unsigned long size, - unsigned short int base, char c, int optlen) -{ - int i, sizei, len; - char *bstart = *buffer; - - sizei = strtoul(sizec, NULL, 10); - len = print_intlen(size, base) + optlen; - if (sizei > len) { - for (i = 0; - (i < (sizei - len)) && ((*buffer - bstart) < bufsize); - i++) { - **buffer = c; - *buffer += 1; - } - } - - return 0; -} - - -static int -print_format(char **buffer, size_t bufsize, const char *format, void *var) -{ - char *start; - unsigned int i = 0, length_mod = sizeof(int); - unsigned long value = 0; - unsigned long signBit; - char *form, sizec[32]; - char sign = ' '; - bool upper = false; - - form = (char *) format; - start = *buffer; - - form++; - if(*form == '0' || *form == '.') { - sign = '0'; - form++; - } - - while ((*form != '\0') && ((*buffer - start) < bufsize)) { - switch(*form) { - case 'u': - case 'd': - case 'i': - sizec[i] = '\0'; - value = (unsigned long) var; - signBit = 0x1ULL << (length_mod * 8 - 1); - if ((*form != 'u') && (signBit & value)) { - **buffer = '-'; - *buffer += 1; - value = (-(unsigned long)value) & convert[length_mod]; - } - print_fill(buffer, bufsize - (*buffer - start), - sizec, value, 10, sign, 0); - print_itoa(buffer, bufsize - (*buffer - start), - value, 10, upper); - break; - case 'X': - upper = true; - case 'x': - sizec[i] = '\0'; - value = (unsigned long) var & convert[length_mod]; - print_fill(buffer, bufsize - (*buffer - start), - sizec, value, 16, sign, 0); - print_itoa(buffer, bufsize - (*buffer - start), - value, 16, upper); - break; - case 'O': - case 'o': - sizec[i] = '\0'; - value = (long int) var & convert[length_mod]; - print_fill(buffer, bufsize - (*buffer - start), - sizec, value, 8, sign, 0); - print_itoa(buffer, bufsize - (*buffer - start), - value, 8, upper); - break; - case 'p': - sizec[i] = '\0'; - print_fill(buffer, bufsize - (*buffer - start), - sizec, (unsigned long) var, 16, ' ', 2); - print_str(buffer, bufsize - (*buffer - start), - "0x"); - print_itoa(buffer, bufsize - (*buffer - start), - (unsigned long) var, 16, upper); - break; - case 'c': - sizec[i] = '\0'; - print_fill(buffer, bufsize - (*buffer - start), - sizec, 1, 10, ' ', 0); - **buffer = (unsigned long) var; - *buffer += 1; - break; - case 's': - sizec[i] = '\0'; - print_str_fill(buffer, - bufsize - (*buffer - start), sizec, - (char *) var, ' '); - - print_str(buffer, bufsize - (*buffer - start), - (char *) var); - break; - case 'l': - form++; - if(*form == 'l') { - length_mod = sizeof(long long int); - } else { - form--; - length_mod = sizeof(long int); - } - break; - case 'h': - form++; - if(*form == 'h') { - length_mod = sizeof(signed char); - } else { - form--; - length_mod = sizeof(short int); - } - break; - case 'z': - length_mod = sizeof(size_t); - break; - default: - if(*form >= '0' && *form <= '9') - sizec[i++] = *form; - } - form++; - } - - - return (long int) (*buffer - start); -} - - -/* - * The vsnprintf function prints a formated strings into a buffer. - * BUG: buffer size checking does not fully work yet - */ -int -vsnprintf(char *buffer, size_t bufsize, const char *format, va_list arg) -{ - char *ptr, *bstart; - - bstart = buffer; - ptr = (char *) format; - - /* - * Return from here if size passed is zero, otherwise we would - * overrun buffer while setting NULL character at the end. - */ - if (!buffer || !bufsize) - return 0; - - /* Leave one space for NULL character */ - bufsize--; - - while(*ptr != '\0' && (buffer - bstart) < bufsize) - { - if(*ptr == '%') { - char formstr[20]; - int i=0; - - do { - formstr[i] = *ptr; - ptr++; - i++; - } while(!(*ptr == 'd' || *ptr == 'i' || *ptr == 'u' || *ptr == 'x' || *ptr == 'X' - || *ptr == 'p' || *ptr == 'c' || *ptr == 's' || *ptr == '%' - || *ptr == 'O' || *ptr == 'o' )); - formstr[i++] = *ptr; - formstr[i] = '\0'; - if(*ptr == '%') { - *buffer++ = '%'; - } else { - print_format(&buffer, - bufsize - (buffer - bstart), - formstr, va_arg(arg, void *)); - } - ptr++; - } else { - - *buffer = *ptr; - - buffer++; - ptr++; - } - } - - *buffer = '\0'; - - return (buffer - bstart); -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/vsprintf.c b/qemu/roms/SLOF/lib/libc/stdio/vsprintf.c deleted file mode 100644 index 0dfd737bc..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/vsprintf.c +++ /dev/null @@ -1,19 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" - -int -vsprintf(char *buffer, const char *format, va_list arg) -{ - return vsnprintf(buffer, 0x7fffffff, format, arg); -} diff --git a/qemu/roms/SLOF/lib/libc/stdio/vsscanf.c b/qemu/roms/SLOF/lib/libc/stdio/vsscanf.c deleted file mode 100644 index b9603e98b..000000000 --- a/qemu/roms/SLOF/lib/libc/stdio/vsscanf.c +++ /dev/null @@ -1,131 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "stdio.h" -#include "stdlib.h" -#include "string.h" - - -static void -_scanf(const char **buffer, const char *fmt, va_list *ap) -{ - int i; - int length = 0; - - fmt++; - - while(*fmt != '\0') { - - char tbuf[256]; - - switch(*fmt) { - case 'd': - case 'i': - if(length == 0) length = 256; - - for(i = 0; **buffer != ' ' && **buffer != '\t' && **buffer != '\n' && i < length; i++) { - tbuf[i] = **buffer; - *buffer += 1; - } - tbuf[i] = '\0'; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 10); - break; - case 'X': - case 'x': - if(length == 0) length = 256; - - for(i = 0; **buffer != ' ' && **buffer != '\t' && **buffer != '\n' && i < length; i++) { - tbuf[i] = **buffer; - *buffer += 1; - } - tbuf[i] = '\0'; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 16); - break; - case 'O': - case 'o': - if(length == 0) length = 256; - - for(i = 0; **buffer != ' ' && **buffer != '\t' && **buffer != '\n' && i < length; i++) { - tbuf[i] = **buffer; - *buffer += 1; - } - tbuf[i] = '\0'; - - *(va_arg(*ap, int *)) = strtol(tbuf, NULL, 8); - break; - case 'c': - *(va_arg(*ap, char *)) = **buffer; - *buffer += 1; - if(length > 1) - for(i = 1; i < length; i++) - *buffer += 1; - break; - case 's': - if(length == 0) length = 256; - - for(i = 0; **buffer != ' ' && **buffer != '\t' && **buffer != '\n' && i < length; i++) { - tbuf[i] = **buffer; - *buffer += 1; - } - - tbuf[i] = '\0'; - - strcpy(va_arg(*ap, char *), tbuf); - break; - default: - if(*fmt >= '0' && *fmt <= '9') - length += *fmt - '0'; - break; - } - fmt++; - } - -} - - -int -vsscanf(const char *buffer, const char *fmt, va_list ap) -{ - - while(*fmt != '\0') { - - if(*fmt == '%') { - - char formstr[20]; - int i=0; - - do { - formstr[i] = *fmt; - fmt++; - i++; - } while(!(*fmt == 'd' || *fmt == 'i' || *fmt == 'x' || *fmt == 'X' - || *fmt == 'p' || *fmt == 'c' || *fmt == 's' || *fmt == '%' - || *fmt == 'O' || *fmt == 'o' )); - formstr[i++] = *fmt; - formstr[i] = '\0'; - if(*fmt != '%') { - while(*buffer == ' ' || *buffer == '\t' || *buffer == '\n') - buffer++; - _scanf(&buffer, formstr, &ap); - } - - } - - fmt++; - - } - - return 0; -} - diff --git a/qemu/roms/SLOF/lib/libc/stdlib/Makefile.inc b/qemu/roms/SLOF/lib/libc/stdlib/Makefile.inc deleted file mode 100644 index 702f6d7cf..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/Makefile.inc +++ /dev/null @@ -1,22 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - - -STDLIB_SRC_C = error.c atoi.c atol.c strtoul.c strtol.c rand.c \ - malloc.c memalign.c realloc.c free.c - -STDLIB_SRC_ASM = -STDLIB_SRCS = $(STDLIB_SRC_C:%=$(STDLIBCMNDIR)/%) $(STDLIB_SRC_ASM:%=$(STDLIBCMNDIR)/%) -STDLIB_OBJS = $(STDLIB_SRC_C:%.c=%.o) $(STDLIB_SRC_ASM:%.S=%.o) - -%.o : $(STDLIBCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ diff --git a/qemu/roms/SLOF/lib/libc/stdlib/atoi.c b/qemu/roms/SLOF/lib/libc/stdlib/atoi.c deleted file mode 100644 index d2fb33b88..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/atoi.c +++ /dev/null @@ -1,18 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdlib.h> - -int atoi(const char *str) -{ - return strtol(str, NULL, 0); -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/atol.c b/qemu/roms/SLOF/lib/libc/stdlib/atol.c deleted file mode 100644 index a6aa47ba5..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/atol.c +++ /dev/null @@ -1,18 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdlib.h> - -long atol(const char *str) -{ - return strtol(str, NULL, 0); -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/error.c b/qemu/roms/SLOF/lib/libc/stdlib/error.c deleted file mode 100644 index 81020ca55..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/error.c +++ /dev/null @@ -1,15 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -int errno; - diff --git a/qemu/roms/SLOF/lib/libc/stdlib/free.c b/qemu/roms/SLOF/lib/libc/stdlib/free.c deleted file mode 100644 index 900545099..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/free.c +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdlib.h" -#include "malloc_defs.h" - -void -free(void *ptr) -{ - struct chunk *header; - - header = (struct chunk *) ptr; - header--; - header->inuse = 0; - -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/malloc.c b/qemu/roms/SLOF/lib/libc/stdlib/malloc.c deleted file mode 100644 index b2a3138eb..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/malloc.c +++ /dev/null @@ -1,157 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stddef.h" -#include "stdlib.h" -#include "unistd.h" -#include "malloc_defs.h" - - -static int clean(void); - - -/* act points to the end of the initialized heap and the start of uninitialized heap */ -static char *act; - -/* Pointers to start and end of heap: */ -static char *heap_start, *heap_end; - - -/* - * Standard malloc function - */ -void * -malloc(size_t size) -{ - char *header; - void *data; - size_t blksize; /* size of memory block including the chunk */ - - blksize = size + sizeof(struct chunk); - - /* has malloc been called for the first time? */ - if (act == 0) { - size_t initsize; - /* add some space so we have a good initial playground */ - initsize = (blksize + 0x1000) & ~0x0fff; - /* get initial memory region with sbrk() */ - heap_start = sbrk(initsize); - if (heap_start == (void*)-1) - return NULL; - heap_end = heap_start + initsize; - act = heap_start; - } - - header = act; - data = act + sizeof(struct chunk); - - /* Check if there is space left in the uninitialized part of the heap */ - if (act + blksize > heap_end) { - //search at begin of heap - header = heap_start; - - while ((((struct chunk *) header)->inuse != 0 - || ((struct chunk *) header)->length < size) - && header < act) { - header = header + sizeof(struct chunk) - + ((struct chunk *) header)->length; - } - - // check if heap is full - if (header >= act) { - if (clean()) { - // merging of free blocks succeeded, so try again - return malloc(size); - } else if (sbrk(blksize) == heap_end) { - // succeeded to get more memory, so try again - heap_end += blksize; - return malloc(size); - } else { - // No more memory available - return 0; - } - } - - // Check if we need to split this memory block into two - if (((struct chunk *) header)->length > blksize) { - //available memory is too big - int alt; - - alt = ((struct chunk *) header)->length; - ((struct chunk *) header)->inuse = 1; - ((struct chunk *) header)->length = size; - data = header + sizeof(struct chunk); - - //mark the rest of the heap - header = data + size; - ((struct chunk *) header)->inuse = 0; - ((struct chunk *) header)->length = - alt - blksize; - } else { - //new memory matched exactly in available memory - ((struct chunk *) header)->inuse = 1; - data = header + sizeof(struct chunk); - } - - } else { - - ((struct chunk *) header)->inuse = 1; - ((struct chunk *) header)->length = size; - - act += blksize; - } - - return data; -} - - -/* - * Merge free memory blocks in initialized heap if possible - */ -static int -clean(void) -{ - char *header; - char *firstfree = 0; - char check = 0; - - header = heap_start; - //if (act == 0) // This should never happen - // act = heap_end; - - while (header < act) { - - if (((struct chunk *) header)->inuse == 0) { - if (firstfree == 0) { - /* First free block in a row, only save address */ - firstfree = header; - - } else { - /* more than one free block in a row, merge them! */ - ((struct chunk *) firstfree)->length += - ((struct chunk *) header)->length + - sizeof(struct chunk); - check = 1; - } - } else { - firstfree = 0; - - } - - header = header + sizeof(struct chunk) - + ((struct chunk *) header)->length; - - } - - return check; -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/malloc_defs.h b/qemu/roms/SLOF/lib/libc/stdlib/malloc_defs.h deleted file mode 100644 index 19330267e..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/malloc_defs.h +++ /dev/null @@ -1,16 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -struct chunk { - unsigned inuse : 4; - unsigned length : 28; -} __attribute__((packed)); diff --git a/qemu/roms/SLOF/lib/libc/stdlib/memalign.c b/qemu/roms/SLOF/lib/libc/stdlib/memalign.c deleted file mode 100644 index 3b678aaf5..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/memalign.c +++ /dev/null @@ -1,26 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdlib.h" - - -void * -memalign(size_t blocksize, size_t bytes) -{ - void *x; - - x = malloc(bytes + blocksize); - x = (void *) (((unsigned long) x + blocksize - 1) & ~(blocksize - 1)); - - return (void *) x; -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/rand.c b/qemu/roms/SLOF/lib/libc/stdlib/rand.c deleted file mode 100644 index 39f5a9a2c..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/rand.c +++ /dev/null @@ -1,29 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdlib.h> - - -static unsigned long _rand = 1; - -int -rand(void) -{ - _rand = _rand * 1237732973 + 34563; - - return ((unsigned int) (_rand >> 16) & RAND_MAX); -} - -void srand(unsigned int seed) -{ - _rand = seed; -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/realloc.c b/qemu/roms/SLOF/lib/libc/stdlib/realloc.c deleted file mode 100644 index 652e90077..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/realloc.c +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - - -#include "stdlib.h" -#include "string.h" -#include "malloc_defs.h" - -void * -realloc(void *ptr, size_t size) -{ - struct chunk *header; - char *newptr, *start; - - header = (struct chunk *) ptr; - header--; - - if (size <= header->length) - return ptr; - - newptr = (char *) malloc(size); - if (newptr == NULL) - return 0; - - start = newptr; - memcpy((void *) newptr, (const void *) ptr, header->length); - - header->inuse = 0; - - return start; -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/strtol.c b/qemu/roms/SLOF/lib/libc/stdlib/strtol.c deleted file mode 100644 index 474597a23..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/strtol.c +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdlib.h> - -long int strtol(const char *S, char **PTR,int BASE) -{ - long rval = 0; - short int negative = 0; - short int digit; - // *PTR is S, unless PTR is NULL, in which case i override it with my own ptr - char* ptr; - if (PTR == 0) - { - //override - PTR = &ptr; - } - // i use PTR to advance through the string - *PTR = (char *) S; - //check if BASE is ok - if ((BASE < 0) || BASE > 36) - { - return 0; - } - // ignore white space at beginning of S - while ((**PTR == ' ') - || (**PTR == '\t') - || (**PTR == '\n') - || (**PTR == '\r') - ) - { - (*PTR)++; - } - // check if S starts with "-" in which case the return value is negative - if (**PTR == '-') - { - negative = 1; - (*PTR)++; - } - // if BASE is 0... determine the base from the first chars... - if (BASE == 0) - { - // if S starts with "0x", BASE = 16, else 10 - if ((**PTR == '0') && (*((*PTR)+1) == 'x')) - { - BASE = 16; - (*PTR)++; - (*PTR)++; - } - else - { - BASE = 10; - } - } - if (BASE == 16) - { - // S may start with "0x" - if ((**PTR == '0') && (*((*PTR)+1) == 'x')) - { - (*PTR)++; - (*PTR)++; - } - } - //until end of string - while (**PTR) - { - if (((**PTR) >= '0') && ((**PTR) <= '9')) - { - //digit (0..9) - digit = **PTR - '0'; - } - else if (((**PTR) >= 'a') && ((**PTR) <='z')) - { - //alphanumeric digit lowercase(a (10) .. z (35) ) - digit = (**PTR - 'a') + 10; - } - else if (((**PTR) >= 'A') && ((**PTR) <='Z')) - { - //alphanumeric digit uppercase(a (10) .. z (35) ) - digit = (**PTR - 'A') + 10; - } - else - { - //end of parseable number reached... - break; - } - if (digit < BASE) - { - rval = (rval * BASE) + digit; - } - else - { - //digit found, but its too big for current base - //end of parseable number reached... - break; - } - //next... - (*PTR)++; - } - if (negative) - { - return rval * -1; - } - //else - return rval; -} diff --git a/qemu/roms/SLOF/lib/libc/stdlib/strtoul.c b/qemu/roms/SLOF/lib/libc/stdlib/strtoul.c deleted file mode 100644 index 754e7db4b..000000000 --- a/qemu/roms/SLOF/lib/libc/stdlib/strtoul.c +++ /dev/null @@ -1,105 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <stdlib.h> - -unsigned long int strtoul(const char *S, char **PTR,int BASE) -{ - unsigned long rval = 0; - short int digit; - // *PTR is S, unless PTR is NULL, in which case i override it with my own ptr - char* ptr; - if (PTR == 0) - { - //override - PTR = &ptr; - } - // i use PTR to advance through the string - *PTR = (char *) S; - //check if BASE is ok - if ((BASE < 0) || BASE > 36) - { - return 0; - } - // ignore white space at beginning of S - while ((**PTR == ' ') - || (**PTR == '\t') - || (**PTR == '\n') - || (**PTR == '\r') - ) - { - (*PTR)++; - } - // if BASE is 0... determine the base from the first chars... - if (BASE == 0) - { - // if S starts with "0x", BASE = 16, else 10 - if ((**PTR == '0') && (*((*PTR)+1) == 'x')) - { - BASE = 16; - (*PTR)++; - (*PTR)++; - } - else - { - BASE = 10; - } - } - if (BASE == 16) - { - // S may start with "0x" - if ((**PTR == '0') && (*((*PTR)+1) == 'x')) - { - (*PTR)++; - (*PTR)++; - } - } - //until end of string - while (**PTR) - { - if (((**PTR) >= '0') && ((**PTR) <='9')) - { - //digit (0..9) - digit = **PTR - '0'; - } - else if (((**PTR) >= 'a') && ((**PTR) <='z')) - { - //alphanumeric digit lowercase(a (10) .. z (35) ) - digit = (**PTR - 'a') + 10; - } - else if (((**PTR) >= 'A') && ((**PTR) <='Z')) - { - //alphanumeric digit uppercase(a (10) .. z (35) ) - digit = (**PTR - 'A') + 10; - } - else - { - //end of parseable number reached... - break; - } - if (digit < BASE) - { - rval = (rval * BASE) + digit; - } - else - { - //digit found, but its too big for current base - //end of parseable number reached... - break; - } - //next... - (*PTR)++; - } - //done - return rval; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/Makefile.inc b/qemu/roms/SLOF/lib/libc/string/Makefile.inc deleted file mode 100644 index 7ccf3c405..000000000 --- a/qemu/roms/SLOF/lib/libc/string/Makefile.inc +++ /dev/null @@ -1,22 +0,0 @@ -# ***************************************************************************** -# * Copyright (c) 2004, 2008 IBM Corporation -# * All rights reserved. -# * This program and the accompanying materials -# * are made available under the terms of the BSD License -# * which accompanies this distribution, and is available at -# * http://www.opensource.org/licenses/bsd-license.php -# * -# * Contributors: -# * IBM Corporation - initial implementation -# ****************************************************************************/ - - -STRING_SRC_C = strcat.c strchr.c strcmp.c strcpy.c strlen.c strncmp.c \ - strncpy.c strstr.c memset.c memcpy.c memmove.c memchr.c \ - memcmp.c strcasecmp.c strncasecmp.c strtok.c -STRING_SRC_ASM = -STRING_SRCS = $(STRING_SRC_C:%=$(STRINGCMNDIR)/%) $(STRING_SRC_ASM:%=$(STRINGCMNDIR)/%) -STRING_OBJS = $(STRING_SRC_C:%.c=%.o) $(STRING_SRC_ASM:%.S=%.o) - -%.o : $(STRINGCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ diff --git a/qemu/roms/SLOF/lib/libc/string/memchr.c b/qemu/roms/SLOF/lib/libc/string/memchr.c deleted file mode 100644 index c3fe751c6..000000000 --- a/qemu/roms/SLOF/lib/libc/string/memchr.c +++ /dev/null @@ -1,29 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" - - -void * -memchr(const void *ptr, int c, size_t n) -{ - unsigned char ch = (unsigned char)c; - const unsigned char *p = ptr; - - while (n-- > 0) { - if (*p == ch) - return (void *)p; - p += 1; - } - - return NULL; -} diff --git a/qemu/roms/SLOF/lib/libc/string/memcmp.c b/qemu/roms/SLOF/lib/libc/string/memcmp.c deleted file mode 100644 index 3b69cefb9..000000000 --- a/qemu/roms/SLOF/lib/libc/string/memcmp.c +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" - - -int -memcmp(const void *ptr1, const void *ptr2, size_t n) -{ - const unsigned char *p1 = ptr1; - const unsigned char *p2 = ptr2; - - while (n-- > 0) { - if (*p1 != *p2) - return (*p1 - *p2); - p1 += 1; - p2 += 1; - } - - return 0; -} diff --git a/qemu/roms/SLOF/lib/libc/string/memcpy.c b/qemu/roms/SLOF/lib/libc/string/memcpy.c deleted file mode 100644 index 00f419b80..000000000 --- a/qemu/roms/SLOF/lib/libc/string/memcpy.c +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" - -void * -memcpy(void *dest, const void *src, size_t n) -{ - char *cdest; - const char *csrc = src; - - cdest = dest; - while (n-- > 0) { - *cdest++ = *csrc++; - } - - return dest; -} diff --git a/qemu/roms/SLOF/lib/libc/string/memmove.c b/qemu/roms/SLOF/lib/libc/string/memmove.c deleted file mode 100644 index 3acf1a973..000000000 --- a/qemu/roms/SLOF/lib/libc/string/memmove.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" - - -void * -memmove(void *dest, const void *src, size_t n) -{ - char *cdest; - const char *csrc; - int i; - - /* Do the buffers overlap in a bad way? */ - if (src < dest && src + n >= dest) { - /* Copy from end to start */ - cdest = dest + n - 1; - csrc = src + n - 1; - for (i = 0; i < n; i++) { - *cdest-- = *csrc--; - } - } - else { - /* Normal copy is possible */ - cdest = dest; - csrc = src; - for (i = 0; i < n; i++) { - *cdest++ = *csrc++; - } - } - - return dest; -} diff --git a/qemu/roms/SLOF/lib/libc/string/memset.c b/qemu/roms/SLOF/lib/libc/string/memset.c deleted file mode 100644 index f8dfbf524..000000000 --- a/qemu/roms/SLOF/lib/libc/string/memset.c +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include "string.h" - -void * -memset(void *dest, int c, size_t size) -{ - unsigned char *d = (unsigned char *)dest; - - while (size-- > 0) { - *d++ = (unsigned char)c; - } - - return dest; -} diff --git a/qemu/roms/SLOF/lib/libc/string/strcasecmp.c b/qemu/roms/SLOF/lib/libc/string/strcasecmp.c deleted file mode 100644 index f75294fb9..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strcasecmp.c +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> -#include <ctype.h> - -int -strcasecmp(const char *s1, const char *s2) -{ - while (*s1 != 0 && *s2 != 0) { - if (toupper(*s1) != toupper(*s2)) - break; - ++s1; - ++s2; - } - - return *s1 - *s2; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strcat.c b/qemu/roms/SLOF/lib/libc/string/strcat.c deleted file mode 100644 index eb597a025..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strcat.c +++ /dev/null @@ -1,24 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strcat(char *dst, const char *src) -{ - int p; - - p = strlen(dst); - strcpy(&dst[p], src); - - return dst; -} diff --git a/qemu/roms/SLOF/lib/libc/string/strchr.c b/qemu/roms/SLOF/lib/libc/string/strchr.c deleted file mode 100644 index 528a319c9..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strchr.c +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strchr(const char *s, int c) -{ - char cb = c; - - while (*s != 0) { - if (*s == cb) { - return (char *)s; - } - s += 1; - } - - return NULL; -} diff --git a/qemu/roms/SLOF/lib/libc/string/strcmp.c b/qemu/roms/SLOF/lib/libc/string/strcmp.c deleted file mode 100644 index 48eaed246..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strcmp.c +++ /dev/null @@ -1,28 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - - -int -strcmp(const char *s1, const char *s2) -{ - while (*s1 != 0 && *s2 != 0) { - if (*s1 != *s2) - break; - s1 += 1; - s2 += 1; - } - - return *s1 - *s2; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strcpy.c b/qemu/roms/SLOF/lib/libc/string/strcpy.c deleted file mode 100644 index 48eb62cb5..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strcpy.c +++ /dev/null @@ -1,25 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strcpy(char *dst, const char *src) -{ - char *ptr = dst; - - do { - *ptr++ = *src; - } while (*src++ != 0); - - return dst; -} diff --git a/qemu/roms/SLOF/lib/libc/string/strlen.c b/qemu/roms/SLOF/lib/libc/string/strlen.c deleted file mode 100644 index 37a1b7812..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strlen.c +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -size_t -strlen(const char *s) -{ - int len = 0; - - while (*s != 0) { - len += 1; - s += 1; - } - - return len; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strncasecmp.c b/qemu/roms/SLOF/lib/libc/string/strncasecmp.c deleted file mode 100644 index 4140931e3..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strncasecmp.c +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> -#include <ctype.h> - - -int -strncasecmp(const char *s1, const char *s2, size_t n) -{ - if (n < 1) - return 0; - - while (*s1 != 0 && *s2 != 0 && --n > 0) { - if (toupper(*s1) != toupper(*s2)) - break; - ++s1; - ++s2; - } - - return toupper(*s1) - toupper(*s2); -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strncmp.c b/qemu/roms/SLOF/lib/libc/string/strncmp.c deleted file mode 100644 index a886736a9..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strncmp.c +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - - -int -strncmp(const char *s1, const char *s2, size_t n) -{ - if (n < 1) - return 0; - - while (*s1 != 0 && *s2 != 0 && --n > 0) { - if (*s1 != *s2) - break; - s1 += 1; - s2 += 1; - } - - return *s1 - *s2; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strncpy.c b/qemu/roms/SLOF/lib/libc/string/strncpy.c deleted file mode 100644 index 0f41f93c9..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strncpy.c +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strncpy(char *dst, const char *src, size_t n) -{ - char *ret = dst; - - /* Copy string */ - while (*src != 0 && n > 0) { - *dst++ = *src++; - n -= 1; - } - - /* strncpy always clears the rest of destination string... */ - while (n > 0) { - *dst++ = 0; - n -= 1; - } - - return ret; -} diff --git a/qemu/roms/SLOF/lib/libc/string/strstr.c b/qemu/roms/SLOF/lib/libc/string/strstr.c deleted file mode 100644 index 3e090d2c5..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strstr.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strstr(const char *hay, const char *needle) -{ - char *pos; - int hlen, nlen; - - if (hay == NULL || needle == NULL) - return NULL; - - hlen = strlen(hay); - nlen = strlen(needle); - if (nlen < 1) - return (char *)hay; - - for (pos = (char *)hay; pos < hay + hlen; pos++) { - if (strncmp(pos, needle, nlen) == 0) { - return pos; - } - } - - return NULL; -} - diff --git a/qemu/roms/SLOF/lib/libc/string/strtok.c b/qemu/roms/SLOF/lib/libc/string/strtok.c deleted file mode 100644 index 665c08db6..000000000 --- a/qemu/roms/SLOF/lib/libc/string/strtok.c +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2004, 2008 IBM Corporation - * All rights reserved. - * This program and the accompanying materials - * are made available under the terms of the BSD License - * which accompanies this distribution, and is available at - * http://www.opensource.org/licenses/bsd-license.php - * - * Contributors: - * IBM Corporation - initial implementation - *****************************************************************************/ - -#include <string.h> - -char * -strtok(char *src, const char *pattern) -{ - static char *nxtTok; - char *retVal = NULL; - - if (!src) - src = nxtTok; - - while (*src) { - const char *pp = pattern; - while (*pp) { - if (*pp == *src) { - break; - } - pp++; - } - if (!*pp) { - if (!retVal) - retVal = src; - else if (!src[-1]) - break; - } else - *src = '\0'; - src++; - } - - nxtTok = src; - - return retVal; -} |