mirror of https://github.com/ipxe/ipxe.git
Merge branch 'master' of git://git.etherboot.org/scm/gpxe
commit
376bacab67
|
@ -403,6 +403,11 @@ include $(MEDIA_DEPS)
|
||||||
allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
|
allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
|
||||||
all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
|
all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
|
||||||
|
|
||||||
|
# Alias for gpxe.%
|
||||||
|
#
|
||||||
|
$(BIN)/etherboot.% : $(BIN)/gpxe.%
|
||||||
|
ln -sf $(notdir $<) $@
|
||||||
|
|
||||||
# The compression utilities
|
# The compression utilities
|
||||||
#
|
#
|
||||||
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
|
$(NRV2B) : util/nrv2b.c $(MAKEDEPS)
|
||||||
|
|
|
@ -543,8 +543,9 @@ void register_int13_drive ( struct int13_drive *drive ) {
|
||||||
|
|
||||||
/* Assign drive number if none specified, update BIOS drive count */
|
/* Assign drive number if none specified, update BIOS drive count */
|
||||||
get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
|
get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES );
|
||||||
if ( ! drive->drive )
|
if ( ( drive->drive & 0xff ) == 0xff )
|
||||||
drive->drive = ( num_drives | 0x80 );
|
drive->drive = num_drives;
|
||||||
|
drive->drive |= 0x80;
|
||||||
num_drives++;
|
num_drives++;
|
||||||
if ( num_drives <= ( drive->drive & 0x7f ) )
|
if ( num_drives <= ( drive->drive & 0x7f ) )
|
||||||
num_drives = ( ( drive->drive & 0x7f ) + 1 );
|
num_drives = ( ( drive->drive & 0x7f ) + 1 );
|
||||||
|
|
|
@ -28,41 +28,6 @@
|
||||||
|
|
||||||
/* *** FROM string.c *** */
|
/* *** FROM string.c *** */
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRNICMP
|
|
||||||
/**
|
|
||||||
* strnicmp - Case insensitive, length-limited string comparison
|
|
||||||
* @s1: One string
|
|
||||||
* @s2: The other string
|
|
||||||
* @len: the maximum number of characters to compare
|
|
||||||
*/
|
|
||||||
int strnicmp(const char *s1, const char *s2, size_t len)
|
|
||||||
{
|
|
||||||
/* Yes, Virginia, it had better be unsigned */
|
|
||||||
unsigned char c1, c2;
|
|
||||||
|
|
||||||
c1 = 0; c2 = 0;
|
|
||||||
if (len) {
|
|
||||||
do {
|
|
||||||
c1 = *s1; c2 = *s2;
|
|
||||||
s1++; s2++;
|
|
||||||
if (!c1)
|
|
||||||
break;
|
|
||||||
if (!c2)
|
|
||||||
break;
|
|
||||||
if (c1 == c2)
|
|
||||||
continue;
|
|
||||||
c1 = tolower(c1);
|
|
||||||
c2 = tolower(c2);
|
|
||||||
if (c1 != c2)
|
|
||||||
break;
|
|
||||||
} while (--len);
|
|
||||||
}
|
|
||||||
return (int)c1 - (int)c2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char * ___strtok;
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRCPY
|
#ifndef __HAVE_ARCH_STRCPY
|
||||||
/**
|
/**
|
||||||
* strcpy - Copy a %NUL terminated string
|
* strcpy - Copy a %NUL terminated string
|
||||||
|
@ -120,35 +85,6 @@ char * strcat(char * dest, const char * src)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRNCAT
|
|
||||||
/**
|
|
||||||
* strncat - Append a length-limited, %NUL-terminated string to another
|
|
||||||
* @dest: The string to be appended to
|
|
||||||
* @src: The string to append to it
|
|
||||||
* @count: The maximum numbers of bytes to copy
|
|
||||||
*
|
|
||||||
* Note that in contrast to strncpy, strncat ensures the result is
|
|
||||||
* terminated.
|
|
||||||
*/
|
|
||||||
char * strncat(char *dest, const char *src, size_t count)
|
|
||||||
{
|
|
||||||
char *tmp = dest;
|
|
||||||
|
|
||||||
if (count) {
|
|
||||||
while (*dest)
|
|
||||||
dest++;
|
|
||||||
while ((*dest++ = *src++)) {
|
|
||||||
if (--count == 0) {
|
|
||||||
*dest = '\0';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRCMP
|
#ifndef __HAVE_ARCH_STRCMP
|
||||||
/**
|
/**
|
||||||
* strcmp - Compare two strings
|
* strcmp - Compare two strings
|
||||||
|
@ -260,135 +196,6 @@ size_t strnlen(const char * s, size_t count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRSPN
|
|
||||||
/**
|
|
||||||
* strspn - Calculate the length of the initial substring of @s which only
|
|
||||||
* contain letters in @accept
|
|
||||||
* @s: The string to be searched
|
|
||||||
* @accept: The string to search for
|
|
||||||
*/
|
|
||||||
size_t strspn(const char *s, const char *accept)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
const char *a;
|
|
||||||
size_t count = 0;
|
|
||||||
|
|
||||||
for (p = s; *p != '\0'; ++p) {
|
|
||||||
for (a = accept; *a != '\0'; ++a) {
|
|
||||||
if (*p == *a)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (*a == '\0')
|
|
||||||
return count;
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRCSPN
|
|
||||||
/**
|
|
||||||
* strcspn - Calculate the length of the initial substring of @s which only
|
|
||||||
* contain letters not in @reject
|
|
||||||
* @s: The string to be searched
|
|
||||||
* @accept: The string to search for
|
|
||||||
*/
|
|
||||||
size_t strcspn(const char *s, const char *reject)
|
|
||||||
{
|
|
||||||
const char *p;
|
|
||||||
const char *r;
|
|
||||||
size_t count = 0;
|
|
||||||
|
|
||||||
for (p = s; *p != '\0'; ++p) {
|
|
||||||
for (r = reject; *r != '\0'; ++r) {
|
|
||||||
if (*p == *r)
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
++count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRPBRK
|
|
||||||
/**
|
|
||||||
* strpbrk - Find the first occurrence of a set of characters
|
|
||||||
* @cs: The string to be searched
|
|
||||||
* @ct: The characters to search for
|
|
||||||
*/
|
|
||||||
char * strpbrk(const char * cs,const char * ct)
|
|
||||||
{
|
|
||||||
const char *sc1,*sc2;
|
|
||||||
|
|
||||||
for( sc1 = cs; *sc1 != '\0'; ++sc1) {
|
|
||||||
for( sc2 = ct; *sc2 != '\0'; ++sc2) {
|
|
||||||
if (*sc1 == *sc2)
|
|
||||||
return (char *) sc1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRTOK
|
|
||||||
/**
|
|
||||||
* strtok - Split a string into tokens
|
|
||||||
* @s: The string to be searched
|
|
||||||
* @ct: The characters to search for
|
|
||||||
*
|
|
||||||
* WARNING: strtok is deprecated, use strsep instead.
|
|
||||||
*/
|
|
||||||
char * strtok(char * s,const char * ct)
|
|
||||||
{
|
|
||||||
char *sbegin, *send;
|
|
||||||
|
|
||||||
sbegin = s ? s : ___strtok;
|
|
||||||
if (!sbegin) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
sbegin += strspn(sbegin,ct);
|
|
||||||
if (*sbegin == '\0') {
|
|
||||||
___strtok = NULL;
|
|
||||||
return( NULL );
|
|
||||||
}
|
|
||||||
send = strpbrk( sbegin, ct);
|
|
||||||
if (send && *send != '\0')
|
|
||||||
*send++ = '\0';
|
|
||||||
___strtok = send;
|
|
||||||
return (sbegin);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRSEP
|
|
||||||
/**
|
|
||||||
* strsep - Split a string into tokens
|
|
||||||
* @s: The string to be searched
|
|
||||||
* @ct: The characters to search for
|
|
||||||
*
|
|
||||||
* strsep() updates @s to point after the token, ready for the next call.
|
|
||||||
*
|
|
||||||
* It returns empty tokens, too, behaving exactly like the libc function
|
|
||||||
* of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
|
|
||||||
* Same semantics, slimmer shape. ;)
|
|
||||||
*/
|
|
||||||
char * strsep(char **s, const char *ct)
|
|
||||||
{
|
|
||||||
char *sbegin = *s, *end;
|
|
||||||
|
|
||||||
if (sbegin == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
end = strpbrk(sbegin, ct);
|
|
||||||
if (end)
|
|
||||||
*end++ = '\0';
|
|
||||||
*s = end;
|
|
||||||
|
|
||||||
return sbegin;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_MEMSET
|
#ifndef __HAVE_ARCH_MEMSET
|
||||||
/**
|
/**
|
||||||
* memset - Fill a region of memory with the given value
|
* memset - Fill a region of memory with the given value
|
||||||
|
@ -409,30 +216,6 @@ void * memset(void * s,int c,size_t count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_BCOPY
|
|
||||||
/**
|
|
||||||
* bcopy - Copy one area of memory to another
|
|
||||||
* @src: Where to copy from
|
|
||||||
* @dest: Where to copy to
|
|
||||||
* @count: The size of the area.
|
|
||||||
*
|
|
||||||
* Note that this is the same as memcpy(), with the arguments reversed.
|
|
||||||
* memcpy() is the standard, bcopy() is a legacy BSD function.
|
|
||||||
*
|
|
||||||
* You should not use this function to access IO space, use memcpy_toio()
|
|
||||||
* or memcpy_fromio() instead.
|
|
||||||
*/
|
|
||||||
char * bcopy(const char * src, char * dest, int count)
|
|
||||||
{
|
|
||||||
char *tmp = dest;
|
|
||||||
|
|
||||||
while (count--)
|
|
||||||
*tmp++ = *src++;
|
|
||||||
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_MEMCPY
|
#ifndef __HAVE_ARCH_MEMCPY
|
||||||
/**
|
/**
|
||||||
* memcpy - Copy one area of memory to another
|
* memcpy - Copy one area of memory to another
|
||||||
|
@ -503,30 +286,6 @@ int memcmp(const void * cs,const void * ct,size_t count)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_MEMSCAN
|
|
||||||
/**
|
|
||||||
* memscan - Find a character in an area of memory.
|
|
||||||
* @addr: The memory area
|
|
||||||
* @c: The byte to search for
|
|
||||||
* @size: The size of the area.
|
|
||||||
*
|
|
||||||
* returns the address of the first occurrence of @c, or 1 byte past
|
|
||||||
* the area if @c is not found
|
|
||||||
*/
|
|
||||||
void * memscan(void * addr, int c, size_t size)
|
|
||||||
{
|
|
||||||
unsigned char * p = (unsigned char *) addr;
|
|
||||||
|
|
||||||
while (size) {
|
|
||||||
if (*p == c)
|
|
||||||
return (void *) p;
|
|
||||||
p++;
|
|
||||||
size--;
|
|
||||||
}
|
|
||||||
return (void *) p;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __HAVE_ARCH_STRSTR
|
#ifndef __HAVE_ARCH_STRSTR
|
||||||
/**
|
/**
|
||||||
* strstr - Find the first substring in a %NUL terminated string
|
* strstr - Find the first substring in a %NUL terminated string
|
||||||
|
@ -576,17 +335,17 @@ void * memchr(const void *s, int c, size_t n)
|
||||||
|
|
||||||
char * strndup(const char *s, size_t n)
|
char * strndup(const char *s, size_t n)
|
||||||
{
|
{
|
||||||
size_t len = strlen(s);
|
size_t len = strlen(s);
|
||||||
char *new;
|
char *new;
|
||||||
|
|
||||||
if (len>n)
|
if (len>n)
|
||||||
len = n;
|
len = n;
|
||||||
new = malloc(len+1);
|
new = malloc(len+1);
|
||||||
if (new) {
|
if (new) {
|
||||||
new[len] = '\0';
|
new[len] = '\0';
|
||||||
memcpy(new,s,len);
|
memcpy(new,s,len);
|
||||||
}
|
}
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
char * strdup(const char *s) {
|
char * strdup(const char *s) {
|
||||||
|
|
|
@ -0,0 +1,273 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
||||||
|
* Copyright (C) 2004 Tobias Lorenz
|
||||||
|
*
|
||||||
|
* string handling functions
|
||||||
|
* based on linux/lib/string.c
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* stupid library routines.. The optimized versions should generally be found
|
||||||
|
* as inline code in <asm-xx/string.h>
|
||||||
|
*
|
||||||
|
* These are buggy as well..
|
||||||
|
*
|
||||||
|
* * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
|
||||||
|
* - Added strsep() which will replace strtok() soon (because strsep() is
|
||||||
|
* reentrant and should be faster). Use only strsep() in new code, please.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* these are the standard string functions that are currently not used by
|
||||||
|
* any code in etherboot. put into a separate file to avoid linking them in
|
||||||
|
* with the rest of string.o
|
||||||
|
* if anything ever does want to use a function of these, consider moving
|
||||||
|
* the function in question back into string.c
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
/* *** FROM string.c *** */
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRNICMP
|
||||||
|
/**
|
||||||
|
* strnicmp - Case insensitive, length-limited string comparison
|
||||||
|
* @s1: One string
|
||||||
|
* @s2: The other string
|
||||||
|
* @len: the maximum number of characters to compare
|
||||||
|
*/
|
||||||
|
int strnicmp(const char *s1, const char *s2, size_t len)
|
||||||
|
{
|
||||||
|
/* Yes, Virginia, it had better be unsigned */
|
||||||
|
unsigned char c1, c2;
|
||||||
|
|
||||||
|
c1 = 0; c2 = 0;
|
||||||
|
if (len) {
|
||||||
|
do {
|
||||||
|
c1 = *s1; c2 = *s2;
|
||||||
|
s1++; s2++;
|
||||||
|
if (!c1)
|
||||||
|
break;
|
||||||
|
if (!c2)
|
||||||
|
break;
|
||||||
|
if (c1 == c2)
|
||||||
|
continue;
|
||||||
|
c1 = tolower(c1);
|
||||||
|
c2 = tolower(c2);
|
||||||
|
if (c1 != c2)
|
||||||
|
break;
|
||||||
|
} while (--len);
|
||||||
|
}
|
||||||
|
return (int)c1 - (int)c2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char * ___strtok;
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRNCAT
|
||||||
|
/**
|
||||||
|
* strncat - Append a length-limited, %NUL-terminated string to another
|
||||||
|
* @dest: The string to be appended to
|
||||||
|
* @src: The string to append to it
|
||||||
|
* @count: The maximum numbers of bytes to copy
|
||||||
|
*
|
||||||
|
* Note that in contrast to strncpy, strncat ensures the result is
|
||||||
|
* terminated.
|
||||||
|
*/
|
||||||
|
char * strncat(char *dest, const char *src, size_t count)
|
||||||
|
{
|
||||||
|
char *tmp = dest;
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
while (*dest)
|
||||||
|
dest++;
|
||||||
|
while ((*dest++ = *src++)) {
|
||||||
|
if (--count == 0) {
|
||||||
|
*dest = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRSPN
|
||||||
|
/**
|
||||||
|
* strspn - Calculate the length of the initial substring of @s which only
|
||||||
|
* contain letters in @accept
|
||||||
|
* @s: The string to be searched
|
||||||
|
* @accept: The string to search for
|
||||||
|
*/
|
||||||
|
size_t strspn(const char *s, const char *accept)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
const char *a;
|
||||||
|
size_t count = 0;
|
||||||
|
|
||||||
|
for (p = s; *p != '\0'; ++p) {
|
||||||
|
for (a = accept; *a != '\0'; ++a) {
|
||||||
|
if (*p == *a)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*a == '\0')
|
||||||
|
return count;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRCSPN
|
||||||
|
/**
|
||||||
|
* strcspn - Calculate the length of the initial substring of @s which only
|
||||||
|
* contain letters not in @reject
|
||||||
|
* @s: The string to be searched
|
||||||
|
* @accept: The string to search for
|
||||||
|
*/
|
||||||
|
size_t strcspn(const char *s, const char *reject)
|
||||||
|
{
|
||||||
|
const char *p;
|
||||||
|
const char *r;
|
||||||
|
size_t count = 0;
|
||||||
|
|
||||||
|
for (p = s; *p != '\0'; ++p) {
|
||||||
|
for (r = reject; *r != '\0'; ++r) {
|
||||||
|
if (*p == *r)
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRPBRK
|
||||||
|
/**
|
||||||
|
* strpbrk - Find the first occurrence of a set of characters
|
||||||
|
* @cs: The string to be searched
|
||||||
|
* @ct: The characters to search for
|
||||||
|
*/
|
||||||
|
char * strpbrk(const char * cs,const char * ct)
|
||||||
|
{
|
||||||
|
const char *sc1,*sc2;
|
||||||
|
|
||||||
|
for( sc1 = cs; *sc1 != '\0'; ++sc1) {
|
||||||
|
for( sc2 = ct; *sc2 != '\0'; ++sc2) {
|
||||||
|
if (*sc1 == *sc2)
|
||||||
|
return (char *) sc1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRTOK
|
||||||
|
/**
|
||||||
|
* strtok - Split a string into tokens
|
||||||
|
* @s: The string to be searched
|
||||||
|
* @ct: The characters to search for
|
||||||
|
*
|
||||||
|
* WARNING: strtok is deprecated, use strsep instead.
|
||||||
|
*/
|
||||||
|
char * strtok(char * s,const char * ct)
|
||||||
|
{
|
||||||
|
char *sbegin, *send;
|
||||||
|
|
||||||
|
sbegin = s ? s : ___strtok;
|
||||||
|
if (!sbegin) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
sbegin += strspn(sbegin,ct);
|
||||||
|
if (*sbegin == '\0') {
|
||||||
|
___strtok = NULL;
|
||||||
|
return( NULL );
|
||||||
|
}
|
||||||
|
send = strpbrk( sbegin, ct);
|
||||||
|
if (send && *send != '\0')
|
||||||
|
*send++ = '\0';
|
||||||
|
___strtok = send;
|
||||||
|
return (sbegin);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_STRSEP
|
||||||
|
/**
|
||||||
|
* strsep - Split a string into tokens
|
||||||
|
* @s: The string to be searched
|
||||||
|
* @ct: The characters to search for
|
||||||
|
*
|
||||||
|
* strsep() updates @s to point after the token, ready for the next call.
|
||||||
|
*
|
||||||
|
* It returns empty tokens, too, behaving exactly like the libc function
|
||||||
|
* of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
|
||||||
|
* Same semantics, slimmer shape. ;)
|
||||||
|
*/
|
||||||
|
char * strsep(char **s, const char *ct)
|
||||||
|
{
|
||||||
|
char *sbegin = *s, *end;
|
||||||
|
|
||||||
|
if (sbegin == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
end = strpbrk(sbegin, ct);
|
||||||
|
if (end)
|
||||||
|
*end++ = '\0';
|
||||||
|
*s = end;
|
||||||
|
|
||||||
|
return sbegin;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_BCOPY
|
||||||
|
/**
|
||||||
|
* bcopy - Copy one area of memory to another
|
||||||
|
* @src: Where to copy from
|
||||||
|
* @dest: Where to copy to
|
||||||
|
* @count: The size of the area.
|
||||||
|
*
|
||||||
|
* Note that this is the same as memcpy(), with the arguments reversed.
|
||||||
|
* memcpy() is the standard, bcopy() is a legacy BSD function.
|
||||||
|
*
|
||||||
|
* You should not use this function to access IO space, use memcpy_toio()
|
||||||
|
* or memcpy_fromio() instead.
|
||||||
|
*/
|
||||||
|
char * bcopy(const char * src, char * dest, int count)
|
||||||
|
{
|
||||||
|
return memmove(dest,src,count);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __HAVE_ARCH_MEMSCAN
|
||||||
|
/**
|
||||||
|
* memscan - Find a character in an area of memory.
|
||||||
|
* @addr: The memory area
|
||||||
|
* @c: The byte to search for
|
||||||
|
* @size: The size of the area.
|
||||||
|
*
|
||||||
|
* returns the address of the first occurrence of @c, or 1 byte past
|
||||||
|
* the area if @c is not found
|
||||||
|
*/
|
||||||
|
void * memscan(const void * addr, int c, size_t size)
|
||||||
|
{
|
||||||
|
unsigned char * p = (unsigned char *) addr;
|
||||||
|
|
||||||
|
while (size) {
|
||||||
|
if (*p == c)
|
||||||
|
return (void *) p;
|
||||||
|
p++;
|
||||||
|
size--;
|
||||||
|
}
|
||||||
|
return (void *) p;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i);
|
static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i);
|
||||||
static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom);
|
static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom);
|
||||||
static bigint *alloc(BI_CTX *ctx, int size);
|
static bigint __malloc *alloc(BI_CTX *ctx, int size);
|
||||||
static bigint *trim(bigint *bi);
|
static bigint *trim(bigint *bi);
|
||||||
static void more_comps(bigint *bi, int n);
|
static void more_comps(bigint *bi, int n);
|
||||||
#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \
|
#if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \
|
||||||
|
|
|
@ -31,7 +31,7 @@ typedef void psPool_t;
|
||||||
|
|
||||||
#define sslAssert( ... ) assert ( __VA_ARGS__ )
|
#define sslAssert( ... ) assert ( __VA_ARGS__ )
|
||||||
|
|
||||||
static inline __attribute__ (( always_inline )) void *
|
static inline __attribute__ (( always_inline )) void * __malloc
|
||||||
psMalloc ( psPool_t *pool __unused, size_t len ) {
|
psMalloc ( psPool_t *pool __unused, size_t len ) {
|
||||||
return malloc ( len );
|
return malloc ( len );
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,6 +279,31 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
|
||||||
/** Apply standard C calling conventions */
|
/** Apply standard C calling conventions */
|
||||||
#define __cdecl __attribute__ (( cdecl , regparm(0) ))
|
#define __cdecl __attribute__ (( cdecl , regparm(0) ))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a function as pure - i.e. without side effects
|
||||||
|
*/
|
||||||
|
#define __pure __attribute__ (( pure ))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a function as const - i.e. it does not access global memory
|
||||||
|
* (including dereferencing pointers passed to it) at all.
|
||||||
|
* Must also not call any non-const functions.
|
||||||
|
*/
|
||||||
|
#define __const __attribute__ (( const ))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a function's pointer parameters as non-null - i.e. force
|
||||||
|
* compiler to check pointers at compile time and enable possible
|
||||||
|
* optimizations based on that fact
|
||||||
|
*/
|
||||||
|
#define __nonnull __attribute__ (( nonnull ))
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare a pointer returned by a function as a unique memory address
|
||||||
|
* as returned by malloc-type functions.
|
||||||
|
*/
|
||||||
|
#define __malloc __attribute__ (( malloc ))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declare a function as used.
|
* Declare a function as used.
|
||||||
*
|
*
|
||||||
|
|
|
@ -507,7 +507,7 @@ extern void register_dhcp_options ( struct dhcp_option_block *options );
|
||||||
extern void unregister_dhcp_options ( struct dhcp_option_block *options );
|
extern void unregister_dhcp_options ( struct dhcp_option_block *options );
|
||||||
extern void init_dhcp_options ( struct dhcp_option_block *options,
|
extern void init_dhcp_options ( struct dhcp_option_block *options,
|
||||||
void *data, size_t max_len );
|
void *data, size_t max_len );
|
||||||
extern struct dhcp_option_block * alloc_dhcp_options ( size_t max_len );
|
extern struct dhcp_option_block * __malloc alloc_dhcp_options ( size_t max_len );
|
||||||
extern struct dhcp_option *
|
extern struct dhcp_option *
|
||||||
set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag,
|
set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag,
|
||||||
const void *data, size_t len );
|
const void *data, size_t len );
|
||||||
|
|
|
@ -161,7 +161,7 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
|
||||||
return ( iobuf->end - iobuf->tail );
|
return ( iobuf->end - iobuf->tail );
|
||||||
}
|
}
|
||||||
|
|
||||||
extern struct io_buffer * alloc_iob ( size_t len );
|
extern struct io_buffer * __malloc alloc_iob ( size_t len );
|
||||||
extern void free_iob ( struct io_buffer *iobuf );
|
extern void free_iob ( struct io_buffer *iobuf );
|
||||||
extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
|
extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
|
||||||
extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );
|
extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
extern size_t freemem;
|
extern size_t freemem;
|
||||||
|
|
||||||
extern void * alloc_memblock ( size_t size, size_t align );
|
extern void * __malloc alloc_memblock ( size_t size, size_t align );
|
||||||
extern void free_memblock ( void *ptr, size_t size );
|
extern void free_memblock ( void *ptr, size_t size );
|
||||||
extern void mpopulate ( void *start, size_t len );
|
extern void mpopulate ( void *start, size_t len );
|
||||||
extern void mdumpfree ( void );
|
extern void mdumpfree ( void );
|
||||||
|
@ -35,7 +35,7 @@ extern void mdumpfree ( void );
|
||||||
*
|
*
|
||||||
* @c align must be a power of two. @c size may not be zero.
|
* @c align must be a power of two. @c size may not be zero.
|
||||||
*/
|
*/
|
||||||
static inline void * malloc_dma ( size_t size, size_t phys_align ) {
|
static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
|
||||||
return alloc_memblock ( size, phys_align );
|
return alloc_memblock ( size, phys_align );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern char * readline ( const char *prompt );
|
extern char * __malloc readline ( const char *prompt );
|
||||||
|
|
||||||
#endif /* _READLINE_H */
|
#endif /* _READLINE_H */
|
||||||
|
|
|
@ -20,10 +20,10 @@ extern unsigned long strtoul ( const char *p, char **endp, int base );
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern void * malloc ( size_t size );
|
extern void * __malloc malloc ( size_t size );
|
||||||
extern void * realloc ( void *old_ptr, size_t new_size );
|
extern void * realloc ( void *old_ptr, size_t new_size );
|
||||||
extern void free ( void *ptr );
|
extern void free ( void *ptr );
|
||||||
extern void * zalloc ( size_t len );
|
extern void * __malloc zalloc ( size_t len );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocate cleared memory
|
* Allocate cleared memory
|
||||||
|
@ -38,7 +38,7 @@ extern void * zalloc ( size_t len );
|
||||||
* function in zalloc(), since in most cases @c nmemb will be 1 and
|
* function in zalloc(), since in most cases @c nmemb will be 1 and
|
||||||
* doing the multiply is just wasteful.
|
* doing the multiply is just wasteful.
|
||||||
*/
|
*/
|
||||||
static inline void * calloc ( size_t nmemb, size_t size ) {
|
static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
|
||||||
return zalloc ( nmemb * size );
|
return zalloc ( nmemb * size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,33 +17,33 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <bits/string.h>
|
#include <bits/string.h>
|
||||||
|
|
||||||
int strnicmp(const char *s1, const char *s2, size_t len);
|
int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull;
|
||||||
char * strcpy(char * dest,const char *src);
|
char * strcpy(char * dest,const char *src) __nonnull;
|
||||||
char * strncpy(char * dest,const char *src,size_t count);
|
char * strncpy(char * dest,const char *src,size_t count) __nonnull;
|
||||||
char * strcat(char * dest, const char * src);
|
char * strcat(char * dest, const char * src) __nonnull;
|
||||||
char * strncat(char *dest, const char *src, size_t count);
|
char * strncat(char *dest, const char *src, size_t count) __nonnull;
|
||||||
int __attribute__ (( pure )) strcmp(const char * cs,const char * ct);
|
int __pure strcmp(const char * cs,const char * ct) __nonnull;
|
||||||
int __attribute__ (( pure )) strncmp(const char * cs,const char * ct,
|
int __pure strncmp(const char * cs,const char * ct,
|
||||||
size_t count);
|
size_t count) __nonnull;
|
||||||
char * strchr(const char * s, int c);
|
char * __pure strchr(const char * s, int c) __nonnull;
|
||||||
char * strrchr(const char * s, int c);
|
char * __pure strrchr(const char * s, int c) __nonnull;
|
||||||
size_t strlen(const char * s);
|
size_t __pure strlen(const char * s) __nonnull;
|
||||||
size_t strnlen(const char * s, size_t count);
|
size_t __pure strnlen(const char * s, size_t count) __nonnull;
|
||||||
size_t strspn(const char *s, const char *accept);
|
size_t __pure strspn(const char *s, const char *accept) __nonnull;
|
||||||
size_t strcspn(const char *s, const char *reject);
|
size_t __pure strcspn(const char *s, const char *reject) __nonnull;
|
||||||
char * strpbrk(const char * cs,const char * ct);
|
char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
|
||||||
char * strtok(char * s,const char * ct);
|
char * strtok(char * s,const char * ct) __nonnull;
|
||||||
char * strsep(char **s, const char *ct);
|
char * strsep(char **s, const char *ct) __nonnull;
|
||||||
void * memset(void * s,int c,size_t count);
|
void * memset(void * s,int c,size_t count) __nonnull;
|
||||||
void * memmove(void * dest,const void *src,size_t count);
|
void * memmove(void * dest,const void *src,size_t count) __nonnull;
|
||||||
int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
|
int __pure memcmp(const void * cs,const void * ct,
|
||||||
size_t count);
|
size_t count) __nonnull;
|
||||||
void * memscan(void * addr, int c, size_t size);
|
void * __pure memscan(const void * addr, int c, size_t size) __nonnull;
|
||||||
char * strstr(const char * s1,const char * s2);
|
char * __pure strstr(const char * s1,const char * s2) __nonnull;
|
||||||
void * memchr(const void *s, int c, size_t n);
|
void * __pure memchr(const void *s, int c, size_t n) __nonnull;
|
||||||
char * strdup(const char *s);
|
char * __malloc strdup(const char *s) __nonnull;
|
||||||
char * strndup(const char *s, size_t n);
|
char * __malloc strndup(const char *s, size_t n) __nonnull;
|
||||||
|
|
||||||
extern const char * strerror ( int errno );
|
extern const char * __pure strerror ( int errno );
|
||||||
|
|
||||||
#endif /* ETHERBOOT_STRING */
|
#endif /* ETHERBOOT_STRING */
|
||||||
|
|
|
@ -39,10 +39,9 @@ static LIST_HEAD ( frag_buffers );
|
||||||
* @v gateway Gateway address (or @c INADDR_NONE for no gateway)
|
* @v gateway Gateway address (or @c INADDR_NONE for no gateway)
|
||||||
* @ret miniroute Routing table entry, or NULL
|
* @ret miniroute Routing table entry, or NULL
|
||||||
*/
|
*/
|
||||||
static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev,
|
static struct ipv4_miniroute * __malloc
|
||||||
struct in_addr address,
|
add_ipv4_miniroute ( struct net_device *netdev, struct in_addr address,
|
||||||
struct in_addr netmask,
|
struct in_addr netmask, struct in_addr gateway ) {
|
||||||
struct in_addr gateway ) {
|
|
||||||
struct ipv4_miniroute *miniroute;
|
struct ipv4_miniroute *miniroute;
|
||||||
|
|
||||||
DBG ( "IPv4 add %s", inet_ntoa ( address ) );
|
DBG ( "IPv4 add %s", inet_ntoa ( address ) );
|
||||||
|
|
|
@ -52,11 +52,10 @@ static LIST_HEAD ( miniroutes );
|
||||||
* @v gateway Gateway address (or ::0 for no gateway)
|
* @v gateway Gateway address (or ::0 for no gateway)
|
||||||
* @ret miniroute Routing table entry, or NULL
|
* @ret miniroute Routing table entry, or NULL
|
||||||
*/
|
*/
|
||||||
static struct ipv6_miniroute * add_ipv6_miniroute ( struct net_device *netdev,
|
static struct ipv6_miniroute * __malloc
|
||||||
struct in6_addr prefix,
|
add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix,
|
||||||
int prefix_len,
|
int prefix_len, struct in6_addr address,
|
||||||
struct in6_addr address,
|
struct in6_addr gateway ) {
|
||||||
struct in6_addr gateway ) {
|
|
||||||
struct ipv6_miniroute *miniroute;
|
struct ipv6_miniroute *miniroute;
|
||||||
|
|
||||||
miniroute = malloc ( sizeof ( *miniroute ) );
|
miniroute = malloc ( sizeof ( *miniroute ) );
|
||||||
|
|
|
@ -1044,7 +1044,7 @@ static void tls_hmac ( struct tls_session *tls __unused,
|
||||||
* @ret plaintext_len Length of plaintext record
|
* @ret plaintext_len Length of plaintext record
|
||||||
* @ret plaintext Allocated plaintext record
|
* @ret plaintext Allocated plaintext record
|
||||||
*/
|
*/
|
||||||
static void * tls_assemble_stream ( struct tls_session *tls,
|
static void * __malloc tls_assemble_stream ( struct tls_session *tls,
|
||||||
const void *data, size_t len,
|
const void *data, size_t len,
|
||||||
void *digest, size_t *plaintext_len ) {
|
void *digest, size_t *plaintext_len ) {
|
||||||
size_t mac_len = tls->tx_cipherspec.digest->digestsize;
|
size_t mac_len = tls->tx_cipherspec.digest->digestsize;
|
||||||
|
|
Loading…
Reference in New Issue