From f397fc443c7e798bb5491ca9ab2acef54c5fc0f0 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Sun, 29 Jul 2007 17:35:38 +0200 Subject: [PATCH 01/47] make bcopy use memmove --- src/core/string.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/core/string.c b/src/core/string.c index 040a7785..12d05d53 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -424,12 +424,7 @@ void * memset(void * s,int c,size_t count) */ char * bcopy(const char * src, char * dest, int count) { - char *tmp = dest; - - while (count--) - *tmp++ = *src++; - - return dest; + return memmove(dest,src,count); } #endif From c7ad6778aca7ea8c23ae29318aa379b402e0bf6f Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:27:19 +0200 Subject: [PATCH 02/47] put unused functions from string.c into separate file --- src/core/stringextra.c | 288 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 src/core/stringextra.c diff --git a/src/core/stringextra.c b/src/core/stringextra.c new file mode 100644 index 00000000..e8a6d938 --- /dev/null +++ b/src/core/stringextra.c @@ -0,0 +1,288 @@ +/* + * 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 + * + * These are buggy as well.. + * + * * Fri Jun 25 1999, Ingo Oeser + * - 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 +#include +#include +#include + +/* *** 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(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 + +char * strndup(const char *s, size_t n) +{ + size_t len = strlen(s); + char *new; + + if (len>n) + len = n; + new = malloc(len+1); + if (new) { + new[len] = '\0'; + memcpy(new,s,len); + } + return new; +} From c9c97b344461e260f076d69af719c32eae151b39 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:27:37 +0200 Subject: [PATCH 03/47] stripped down version of string.c containing only the used functions --- src/core/string.c | 251 ---------------------------------------------- 1 file changed, 251 deletions(-) diff --git a/src/core/string.c b/src/core/string.c index 12d05d53..8577215b 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -28,41 +28,6 @@ /* *** 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 /** * strcpy - Copy a %NUL terminated string @@ -120,35 +85,6 @@ char * strcat(char * dest, const char * src) } #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 /** * strcmp - Compare two strings @@ -260,135 +196,6 @@ size_t strnlen(const char * s, size_t count) } #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 /** * memset - Fill a region of memory with the given value @@ -409,25 +216,6 @@ void * memset(void * s,int c,size_t count) } #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_MEMCPY /** * memcpy - Copy one area of memory to another @@ -498,30 +286,6 @@ int memcmp(const void * cs,const void * ct,size_t 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(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 /** * strstr - Find the first substring in a %NUL terminated string @@ -569,21 +333,6 @@ void * memchr(const void *s, int c, size_t n) #endif -char * strndup(const char *s, size_t n) -{ - size_t len = strlen(s); - char *new; - - if (len>n) - len = n; - new = malloc(len+1); - if (new) { - new[len] = '\0'; - memcpy(new,s,len); - } - return new; -} - char * strdup(const char *s) { return strndup(s, ~((size_t)0)); } From cd619a1eec451f440c109122cd41790e0a3f70ee Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:27:54 +0200 Subject: [PATCH 04/47] define __pure and __const --- src/include/compiler.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/include/compiler.h b/src/include/compiler.h index b130f28f..e79f9fb2 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -279,6 +279,18 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr, /** Apply standard C calling conventions */ #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 as used. * From 8e3e97fcef46cd3864da144e8295250b8f77a0db Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:51:38 +0200 Subject: [PATCH 05/47] set __pure attribute where possible --- src/include/string.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/include/string.h b/src/include/string.h index 1d104c52..3274bcba 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -17,32 +17,32 @@ #include #include -int strnicmp(const char *s1, const char *s2, size_t len); +int __pure strnicmp(const char *s1, const char *s2, size_t len); char * strcpy(char * dest,const char *src); char * strncpy(char * dest,const char *src,size_t count); char * strcat(char * dest, const char * src); char * strncat(char *dest, const char *src, size_t count); -int __attribute__ (( pure )) strcmp(const char * cs,const char * ct); -int __attribute__ (( pure )) strncmp(const char * cs,const char * ct, +int __pure strcmp(const char * cs,const char * ct); +int __pure strncmp(const char * cs,const char * ct, size_t count); -char * strchr(const char * s, int c); -char * strrchr(const char * s, int c); -size_t strlen(const char * s); -size_t strnlen(const char * s, size_t count); -size_t strspn(const char *s, const char *accept); -size_t strcspn(const char *s, const char *reject); -char * strpbrk(const char * cs,const char * ct); +char * __pure strchr(const char * s, int c); +char * __pure strrchr(const char * s, int c); +size_t __pure strlen(const char * s); +size_t __pure strnlen(const char * s, size_t count); +size_t __pure strspn(const char *s, const char *accept); +size_t __pure strcspn(const char *s, const char *reject); +char * __pure strpbrk(const char * cs,const char * ct); char * strtok(char * s,const char * ct); char * strsep(char **s, const char *ct); void * memset(void * s,int c,size_t count); void * memmove(void * dest,const void *src,size_t count); -int __attribute__ (( pure )) memcmp(const void * cs,const void * ct, +int __pure memcmp(const void * cs,const void * ct, size_t count); -void * memscan(void * addr, int c, size_t size); -char * strstr(const char * s1,const char * s2); -void * memchr(const void *s, int c, size_t n); -char * strdup(const char *s); -char * strndup(const char *s, size_t n); +void * __pure memscan(const void * addr, int c, size_t size); +char * __pure strstr(const char * s1,const char * s2); +void * __pure memchr(const void *s, int c, size_t n); +char * __pure strdup(const char *s); +char * __pure strndup(const char *s, size_t n); extern const char * strerror ( int errno ); From d0d044443d91e2670ac10a6c0f8d70dadec751b7 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:52:04 +0200 Subject: [PATCH 06/47] memscan does not alter the mem pointer - make it const --- src/core/stringextra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/stringextra.c b/src/core/stringextra.c index e8a6d938..bd45ae89 100644 --- a/src/core/stringextra.c +++ b/src/core/stringextra.c @@ -258,7 +258,7 @@ char * bcopy(const char * src, char * dest, int count) * 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) +void * memscan(const void * addr, int c, size_t size) { unsigned char * p = (unsigned char *) addr; From e3d10ac6734833e94d329c517c868223d530a955 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 01:01:01 +0200 Subject: [PATCH 07/47] define __nonnull --- src/include/compiler.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/include/compiler.h b/src/include/compiler.h index e79f9fb2..32416a56 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -291,6 +291,13 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr, */ #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 function as used. * From 7e8e4f8abdc05a1fdba60edfd50a11a2f3065efd Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 01:02:06 +0200 Subject: [PATCH 08/47] declare pointers passed to string functions as nonnull --- src/include/string.h | 48 ++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/include/string.h b/src/include/string.h index 3274bcba..201ae75c 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -17,32 +17,32 @@ #include #include -int __pure strnicmp(const char *s1, const char *s2, size_t len); -char * strcpy(char * dest,const char *src); -char * strncpy(char * dest,const char *src,size_t count); -char * strcat(char * dest, const char * src); -char * strncat(char *dest, const char *src, size_t count); -int __pure strcmp(const char * cs,const char * ct); +int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull; +char * strcpy(char * dest,const char *src) __nonnull; +char * strncpy(char * dest,const char *src,size_t count) __nonnull; +char * strcat(char * dest, const char * src) __nonnull; +char * strncat(char *dest, const char *src, size_t count) __nonnull; +int __pure strcmp(const char * cs,const char * ct) __nonnull; int __pure strncmp(const char * cs,const char * ct, - size_t count); -char * __pure strchr(const char * s, int c); -char * __pure strrchr(const char * s, int c); -size_t __pure strlen(const char * s); -size_t __pure strnlen(const char * s, size_t count); -size_t __pure strspn(const char *s, const char *accept); -size_t __pure strcspn(const char *s, const char *reject); -char * __pure strpbrk(const char * cs,const char * ct); -char * strtok(char * s,const char * ct); -char * strsep(char **s, const char *ct); -void * memset(void * s,int c,size_t count); -void * memmove(void * dest,const void *src,size_t count); + size_t count) __nonnull; +char * __pure strchr(const char * s, int c) __nonnull; +char * __pure strrchr(const char * s, int c) __nonnull; +size_t __pure strlen(const char * s) __nonnull; +size_t __pure strnlen(const char * s, size_t count) __nonnull; +size_t __pure strspn(const char *s, const char *accept) __nonnull; +size_t __pure strcspn(const char *s, const char *reject) __nonnull; +char * __pure strpbrk(const char * cs,const char * ct) __nonnull; +char * strtok(char * s,const char * ct) __nonnull; +char * strsep(char **s, const char *ct) __nonnull; +void * memset(void * s,int c,size_t count) __nonnull; +void * memmove(void * dest,const void *src,size_t count) __nonnull; int __pure memcmp(const void * cs,const void * ct, - size_t count); -void * __pure memscan(const void * addr, int c, size_t size); -char * __pure strstr(const char * s1,const char * s2); -void * __pure memchr(const void *s, int c, size_t n); -char * __pure strdup(const char *s); -char * __pure strndup(const char *s, size_t n); + size_t count) __nonnull; +void * __pure memscan(const void * addr, int c, size_t size) __nonnull; +char * __pure strstr(const char * s1,const char * s2) __nonnull; +void * __pure memchr(const void *s, int c, size_t n) __nonnull; +char * __pure strdup(const char *s) __nonnull; +char * __pure strndup(const char *s, size_t n) __nonnull; extern const char * strerror ( int errno ); From 6b6dbe5600e60897d56be9551a5c3f7dc567f008 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 01:47:31 +0200 Subject: [PATCH 09/47] move strndup back to string.c - used by strdup --- src/core/stringextra.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/core/stringextra.c b/src/core/stringextra.c index bd45ae89..c2be4fc4 100644 --- a/src/core/stringextra.c +++ b/src/core/stringextra.c @@ -271,18 +271,3 @@ void * memscan(const void * addr, int c, size_t size) return (void *) p; } #endif - -char * strndup(const char *s, size_t n) -{ - size_t len = strlen(s); - char *new; - - if (len>n) - len = n; - new = malloc(len+1); - if (new) { - new[len] = '\0'; - memcpy(new,s,len); - } - return new; -} From bb94c143d9d4368337dc25d857237b16a2ee4603 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 01:48:20 +0200 Subject: [PATCH 10/47] move strndup back to string.c - used by strdup --- src/core/string.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/string.c b/src/core/string.c index 8577215b..2e17bdcb 100644 --- a/src/core/string.c +++ b/src/core/string.c @@ -333,6 +333,21 @@ void * memchr(const void *s, int c, size_t n) #endif +char * strndup(const char *s, size_t n) +{ + size_t len = strlen(s); + char *new; + + if (len>n) + len = n; + new = malloc(len+1); + if (new) { + new[len] = '\0'; + memcpy(new,s,len); + } + return new; +} + char * strdup(const char *s) { return strndup(s, ~((size_t)0)); } From 7e1db201b92a955120f565018b1b144aae50d8b4 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 03:04:44 +0200 Subject: [PATCH 11/47] strdup and strndup call malloc and are not pure --- src/include/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/string.h b/src/include/string.h index 201ae75c..210c3753 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -41,8 +41,8 @@ int __pure memcmp(const void * cs,const void * ct, void * __pure memscan(const void * addr, int c, size_t size) __nonnull; char * __pure strstr(const char * s1,const char * s2) __nonnull; void * __pure memchr(const void *s, int c, size_t n) __nonnull; -char * __pure strdup(const char *s) __nonnull; -char * __pure strndup(const char *s, size_t n) __nonnull; +char * strdup(const char *s) __nonnull; +char * strndup(const char *s, size_t n) __nonnull; extern const char * strerror ( int errno ); From 373022108ba389fb3d50a3d50f9baf64c6c82171 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 23 Jul 2007 17:48:39 +0200 Subject: [PATCH 12/47] malloc attribute changes --- src/arch/i386/core/umalloc.c | 2 ++ src/core/malloc.c | 4 ++++ src/crypto/cryptoLayer.h | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/arch/i386/core/umalloc.c b/src/arch/i386/core/umalloc.c index bfd62ef1..5bad072e 100644 --- a/src/arch/i386/core/umalloc.c +++ b/src/arch/i386/core/umalloc.c @@ -135,6 +135,7 @@ static void ecollect_free ( void ) { * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ +__attribute__ ((malloc)) userptr_t urealloc ( userptr_t ptr, size_t new_size ) { struct external_memory extmem; userptr_t new = ptr; @@ -208,6 +209,7 @@ userptr_t urealloc ( userptr_t ptr, size_t new_size ) { * * Memory is guaranteed to be aligned to a page boundary. */ +__attribute__ ((malloc)) userptr_t umalloc ( size_t size ) { return urealloc ( UNULL, size ); } diff --git a/src/core/malloc.c b/src/core/malloc.c index 2d892f42..6b8add94 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -95,6 +95,7 @@ static char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) ))); * * @c align must be a power of two. @c size may not be zero. */ +__attribute__ ((malloc)) void * alloc_memblock ( size_t size, size_t align ) { struct memory_block *block; size_t align_mask; @@ -248,6 +249,7 @@ void free_memblock ( void *ptr, size_t size ) { * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ +__attribute__ ((malloc)) void * realloc ( void *old_ptr, size_t new_size ) { struct autosized_block *old_block; struct autosized_block *new_block; @@ -297,6 +299,7 @@ void * realloc ( void *old_ptr, size_t new_size ) { * Allocates memory with no particular alignment requirement. @c ptr * will be aligned to at least a multiple of sizeof(void*). */ +__attribute__ ((malloc)) void * malloc ( size_t size ) { return realloc ( NULL, size ); } @@ -326,6 +329,7 @@ void free ( void *ptr ) { * This function name is non-standard, but pretty intuitive. * zalloc(size) is always equivalent to calloc(1,size) */ +__attribute__ ((malloc)) void * zalloc ( size_t size ) { void *data; diff --git a/src/crypto/cryptoLayer.h b/src/crypto/cryptoLayer.h index 538b84f2..91614298 100644 --- a/src/crypto/cryptoLayer.h +++ b/src/crypto/cryptoLayer.h @@ -31,12 +31,14 @@ typedef void psPool_t; #define sslAssert( ... ) assert ( __VA_ARGS__ ) -static inline __attribute__ (( always_inline )) void * +static inline __attribute__ (( always_inline )) __attribute__ ((malloc)) +void * psMalloc ( psPool_t *pool __unused, size_t len ) { return malloc ( len ); } -static inline __attribute__ (( always_inline )) void * +static inline __attribute__ (( always_inline )) __attribute__ ((malloc)) +void * psRealloc ( void *ptr, size_t len ) { return realloc ( ptr, len ); } From 781547449515fcb66e264d5876e9d05ea49043f4 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 6 Aug 2007 03:36:35 +0200 Subject: [PATCH 13/47] Revert "malloc attribute changes" wasn't meant for my local "master" branch ;) This reverts commit 373022108ba389fb3d50a3d50f9baf64c6c82171. --- src/arch/i386/core/umalloc.c | 2 -- src/core/malloc.c | 4 ---- src/crypto/cryptoLayer.h | 6 ++---- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/arch/i386/core/umalloc.c b/src/arch/i386/core/umalloc.c index 5bad072e..bfd62ef1 100644 --- a/src/arch/i386/core/umalloc.c +++ b/src/arch/i386/core/umalloc.c @@ -135,7 +135,6 @@ static void ecollect_free ( void ) { * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -__attribute__ ((malloc)) userptr_t urealloc ( userptr_t ptr, size_t new_size ) { struct external_memory extmem; userptr_t new = ptr; @@ -209,7 +208,6 @@ userptr_t urealloc ( userptr_t ptr, size_t new_size ) { * * Memory is guaranteed to be aligned to a page boundary. */ -__attribute__ ((malloc)) userptr_t umalloc ( size_t size ) { return urealloc ( UNULL, size ); } diff --git a/src/core/malloc.c b/src/core/malloc.c index 6b8add94..2d892f42 100644 --- a/src/core/malloc.c +++ b/src/core/malloc.c @@ -95,7 +95,6 @@ static char heap[HEAP_SIZE] __attribute__ (( aligned ( __alignof__(void *) ))); * * @c align must be a power of two. @c size may not be zero. */ -__attribute__ ((malloc)) void * alloc_memblock ( size_t size, size_t align ) { struct memory_block *block; size_t align_mask; @@ -249,7 +248,6 @@ void free_memblock ( void *ptr, size_t size ) { * Calling realloc() with a new size of zero is a valid way to free a * memory block. */ -__attribute__ ((malloc)) void * realloc ( void *old_ptr, size_t new_size ) { struct autosized_block *old_block; struct autosized_block *new_block; @@ -299,7 +297,6 @@ void * realloc ( void *old_ptr, size_t new_size ) { * Allocates memory with no particular alignment requirement. @c ptr * will be aligned to at least a multiple of sizeof(void*). */ -__attribute__ ((malloc)) void * malloc ( size_t size ) { return realloc ( NULL, size ); } @@ -329,7 +326,6 @@ void free ( void *ptr ) { * This function name is non-standard, but pretty intuitive. * zalloc(size) is always equivalent to calloc(1,size) */ -__attribute__ ((malloc)) void * zalloc ( size_t size ) { void *data; diff --git a/src/crypto/cryptoLayer.h b/src/crypto/cryptoLayer.h index 91614298..538b84f2 100644 --- a/src/crypto/cryptoLayer.h +++ b/src/crypto/cryptoLayer.h @@ -31,14 +31,12 @@ typedef void psPool_t; #define sslAssert( ... ) assert ( __VA_ARGS__ ) -static inline __attribute__ (( always_inline )) __attribute__ ((malloc)) -void * +static inline __attribute__ (( always_inline )) void * psMalloc ( psPool_t *pool __unused, size_t len ) { return malloc ( len ); } -static inline __attribute__ (( always_inline )) __attribute__ ((malloc)) -void * +static inline __attribute__ (( always_inline )) void * psRealloc ( void *ptr, size_t len ) { return realloc ( ptr, len ); } From e8b8991b84e97a49f587d803e1e4b55d76332464 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 00:27:54 +0200 Subject: [PATCH 14/47] define __pure and __const --- src/include/compiler.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/include/compiler.h b/src/include/compiler.h index 2151fc6a..8d76ac47 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -279,6 +279,18 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr, /** Apply standard C calling conventions */ #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 as used. * From 3859abb7de806d17e05ddd93c01f3a6535cf618d Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Thu, 2 Aug 2007 01:01:01 +0200 Subject: [PATCH 15/47] define __nonnull --- src/include/compiler.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/include/compiler.h b/src/include/compiler.h index 8d76ac47..d680ae89 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -291,6 +291,13 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr, */ #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 function as used. * From e7114f1215c907b18ca8588c4e5b8ae757ee5209 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:32:36 +0200 Subject: [PATCH 16/47] __nonnull changes --- src/hci/editstring.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hci/editstring.c b/src/hci/editstring.c index 32483334..347249f7 100644 --- a/src/hci/editstring.c +++ b/src/hci/editstring.c @@ -27,6 +27,15 @@ * */ +static void insert_delete ( struct edit_string *string, size_t delete_len, + const char *insert_text ) + __attribute__ (( nonnull (1) )); +static void insert_character ( struct edit_string *string, + unsigned int character ) __nonnull; +static void delete_character ( struct edit_string *string ) __nonnull; +static void backspace ( struct edit_string *string ) __nonnull; +static void kill_eol ( struct edit_string *string ) __nonnull; + /** * Insert and/or delete text within an editable string * From 6a3ee34c1840d7737de087d7ffcffa805690bbb8 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:32:51 +0200 Subject: [PATCH 17/47] __nonnull changes --- src/hci/mucurses/ansi_screen.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hci/mucurses/ansi_screen.c b/src/hci/mucurses/ansi_screen.c index e77fcdc6..0742a7d4 100644 --- a/src/hci/mucurses/ansi_screen.c +++ b/src/hci/mucurses/ansi_screen.c @@ -2,6 +2,11 @@ #include #include +static void ansiscr_reset(struct _curses_screen *scr) __nonnull; +static void ansiscr_movetoyx(struct _curses_screen *scr, + unsigned int y, unsigned int x) __nonnull; +static void ansiscr_putc(struct _curses_screen *scr, chtype c) __nonnull; + unsigned short _COLS = 80; unsigned short _LINES = 24; From c5414e6d12688b75f2b73e7b7d428ea6588bee2c Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:33:51 +0200 Subject: [PATCH 18/47] __nonnull changes --- src/hci/mucurses/mucurses.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hci/mucurses/mucurses.c b/src/hci/mucurses/mucurses.c index 775422e6..3620d08b 100644 --- a/src/hci/mucurses/mucurses.c +++ b/src/hci/mucurses/mucurses.c @@ -8,6 +8,14 @@ * */ +static void _wupdcurs ( WINDOW *win ) __nonnull; +void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; +void _wputc ( WINDOW *win, char c, int wrap ) __nonnull; +void _wcursback ( WINDOW *win ) __nonnull; +void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) __nonnull; +void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) __nonnull; +int wmove ( WINDOW *win, int y, int x ) __nonnull; + WINDOW _stdscr = { .attrs = A_DEFAULT, .ori_y = 0, From d39e79248c2da5ce14826be1b00613919ab46e8b Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:33:55 +0200 Subject: [PATCH 19/47] __nonnull changes --- src/hci/mucurses/mucurses.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hci/mucurses/mucurses.h b/src/hci/mucurses/mucurses.h index aca9b5c5..1476733f 100644 --- a/src/hci/mucurses/mucurses.h +++ b/src/hci/mucurses/mucurses.h @@ -12,10 +12,10 @@ extern SCREEN _ansi_screen; -extern void _wputch ( WINDOW *win, chtype ch, int wrap ); -extern void _wputc ( WINDOW *win, char c, int wrap ); -extern void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ); -extern void _wputstr ( WINDOW *win, const char *str, int wrap, int n ); -extern void _wcursback ( WINDOW *win ); +extern void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull; +extern void _wputc ( WINDOW *win, char c, int wrap ) __nonnull; +extern void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) __nonnull; +extern void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) __nonnull; +extern void _wcursback ( WINDOW *win ) __nonnull; #endif /* _MUCURSES_H */ From 3c19e4a07e07c14e2c66966429d7b37ec1fc8b84 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:04 +0200 Subject: [PATCH 20/47] __nonnull changes --- src/hci/readline.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hci/readline.c b/src/hci/readline.c index 7df8b6bb..ff7a7679 100644 --- a/src/hci/readline.c +++ b/src/hci/readline.c @@ -32,6 +32,8 @@ #define READLINE_MAX 256 +static void sync_console ( struct edit_string *string ) __nonnull; + /** * Synchronise console with edited string * From 3559beeb0ff34523e738b28c78ee916f19352753 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:17 +0200 Subject: [PATCH 21/47] __nonnull changes --- src/hci/tui/settings_ui.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/hci/tui/settings_ui.c b/src/hci/tui/settings_ui.c index 3524f3c3..336af4e9 100644 --- a/src/hci/tui/settings_ui.c +++ b/src/hci/tui/settings_ui.c @@ -36,7 +36,6 @@ #include extern struct nvo_block *ugly_nvo_hack; - /* Colour pairs */ #define CPAIR_NORMAL 1 #define CPAIR_SELECT 2 @@ -88,6 +87,24 @@ static struct config_setting config_settings_end[0] __table_end ( struct config_setting, config_settings ); #define NUM_SETTINGS ( ( unsigned ) ( config_settings_end - config_settings ) ) +static void load_setting ( struct setting_widget *widget ) __nonnull; +static int save_setting ( struct setting_widget *widget ) __nonnull; +static void init_setting ( struct setting_widget *widget, + struct config_context *context, + struct config_setting *setting, + unsigned int row, unsigned int col ) __nonnull; +static void draw_setting ( struct setting_widget *widget ) __nonnull; +static int edit_setting ( struct setting_widget *widget, int key ) __nonnull; +static void init_setting_index ( struct setting_widget *widget, + struct config_context *context, + unsigned int index ) __nonnull; +static void vmsg ( unsigned int row, const char *fmt, va_list args ) __nonnull; +static void msg ( unsigned int row, const char *fmt, ... ) __nonnull; +static void valert ( const char *fmt, va_list args ) __nonnull; +static void alert ( const char *fmt, ... ) __nonnull; +static void draw_info_row ( struct config_setting *setting ) __nonnull; +static int main_loop ( struct config_context *context ) __nonnull; + /** * Load setting widget value from configuration context * From e1eefee16bf1e4a5cf3b552abe69a867a3d08e02 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:32 +0200 Subject: [PATCH 22/47] __nonnull changes --- src/include/curses.h | 66 +++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/include/curses.h b/src/include/curses.h index 762a63b5..6b1c42d8 100644 --- a/src/include/curses.h +++ b/src/include/curses.h @@ -213,13 +213,13 @@ extern int beep ( void ); //extern void bkgdset ( chtype ); /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype, chtype );*/ -extern int box ( WINDOW *, chtype, chtype ); +extern int box ( WINDOW *, chtype, chtype ) __nonnull; //extern bool can_change_colour ( void ); #define can_change_color() can_change_colour() extern int cbreak ( void ); //extern int clrtobot ( void ); //extern int clrtoeol ( void ); -extern int colour_content ( short, short *, short *, short * ); +extern int colour_content ( short, short *, short *, short * ) __nonnull; #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) ) //extern int colour_set ( short, void * ); #define color_set( cpno, opts ) colour_set( (cpno), (opts) ) @@ -232,10 +232,10 @@ extern int delay_output ( int ); //extern int delch ( void ); //extern int deleteln ( void ); extern void delscreen ( SCREEN * ); -extern int delwin ( WINDOW * ); -extern WINDOW *derwin ( WINDOW *, int, int, int, int ); +extern int delwin ( WINDOW * ) __nonnull; +extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull; //extern int doupdate ( void ); -extern WINDOW *dupwin ( WINDOW * ); +extern WINDOW *dupwin ( WINDOW * ) __nonnull; extern int echo ( void ); extern int echochar ( const chtype ); extern int endwin ( void ); @@ -244,7 +244,7 @@ extern char erasechar ( void ); extern void filter ( void ); extern int flash ( void ); extern int flushinp ( void ); -extern chtype getbkgd ( WINDOW * ); +extern __pure chtype getbkgd ( WINDOW * ) __nonnull; //extern int getch ( void ); //extern int getnstr ( char *, int ); //extern int getstr ( char * ); @@ -312,7 +312,7 @@ extern int mvderwin ( WINDOW *, int, int ); //extern int mvwgetnstr ( WINDOW *, int, int, char *, int ); //extern int mvwgetstr ( WINDOW *, int, int, char * ); //extern int mvwhline ( WINDOW *, int, int, chtype, int ); -extern int mvwin ( WINDOW *, int, int ); +extern int mvwin ( WINDOW *, int, int ) __nonnull; //extern chtype mvwinch ( WINDOW *, int, int ); //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int ); //extern int mvwinchstr ( WINDOW *, int, int, chtype * ); @@ -337,7 +337,7 @@ extern int noraw ( void ); extern int notimeout ( WINDOW *, bool ); extern int overlay ( const WINDOW *, WINDOW * ); extern int overwrite ( const WINDOW *, WINDOW * ); -extern int pair_content ( short, short *, short * ); +extern int pair_content ( short, short *, short * ) __nonnull; //extern int pechochar ( WINDOW *, chtype ); //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int ); //extern int prefresh ( WINDOW *, int, int, int, int, int, int ); @@ -373,14 +373,14 @@ extern char *slk_label ( int ); extern int slk_noutrefresh ( void ); //extern int slk_refresh ( void ); extern int slk_restore ( void ); -extern int slk_set ( int, const char *, int ); +extern int slk_set ( int, const char *, int ) __nonnull; extern int slk_touch ( void ); extern int standend ( void ); extern int standout ( void ); //extern int start_colour ( void ); #define start_color() start_colour() //extern WINDOW *subpad ( WINDOW *, int, int, int, int ); -extern WINDOW *subwin ( WINDOW *, int, int, int, int ); +extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull; extern int syncok ( WINDOW *, bool ); extern chtype termattrs ( void ); extern attr_t term_attrs ( void ); @@ -403,37 +403,41 @@ extern int vid_puts ( attr_t, short, void *, int ( *) ( int) ); extern int vidputs ( chtype, int ( *) ( int) ); //extern int vline ( chtype, int ); //extern int vwprintw ( WINDOW *, const char *, va_list ); -extern int vw_printw ( WINDOW *, const char *, va_list ); +extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull; //extern int vwscanw ( WINDOW *, char *, va_list ); //extern int vw_scanw ( WINDOW *, char *, va_list ); -extern int waddch ( WINDOW *, const chtype ); -extern int waddchnstr ( WINDOW *, const chtype *, int ); +extern int waddch ( WINDOW *, const chtype ) __nonnull; +extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull; //extern int waddchstr ( WINDOW *, const chtype * ); -extern int waddnstr ( WINDOW *, const char *, int ); +extern int waddnstr ( WINDOW *, const char *, int ) __nonnull; //extern int waddstr ( WINDOW *, const char * ); -extern int wattroff ( WINDOW *, int ); -extern int wattron ( WINDOW *, int ); -extern int wattrset ( WINDOW *, int ); -extern int wattr_get ( WINDOW *, attr_t *, short *, void * ); -extern int wattr_off ( WINDOW *, attr_t, void * ); -extern int wattr_on ( WINDOW *, attr_t, void * ); -extern int wattr_set ( WINDOW *, attr_t, short, void * ); +extern int wattroff ( WINDOW *, int ) __nonnull; +extern int wattron ( WINDOW *, int ) __nonnull; +extern int wattrset ( WINDOW *, int ) __nonnull; +extern int wattr_get ( WINDOW *, attr_t *, short *, void * ) + __attribute__ (( nonnull (1, 2, 3))); +extern int wattr_off ( WINDOW *, attr_t, void * ) + __attribute__ (( nonnull (1))); +extern int wattr_on ( WINDOW *, attr_t, void * ) + __attribute__ (( nonnull (1))); +extern int wattr_set ( WINDOW *, attr_t, short, void * ) + __attribute__ (( nonnull (1))); //extern void wbkgdset ( WINDOW *, chtype ); extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype, - chtype, chtype ); -extern int wclrtobot ( WINDOW * ); -extern int wclrtoeol ( WINDOW * ); + chtype, chtype ) __nonnull; +extern int wclrtobot ( WINDOW * ) __nonnull; +extern int wclrtoeol ( WINDOW * ) __nonnull; extern void wcursyncup ( WINDOW * ); -extern int wcolour_set ( WINDOW *, short, void * ); +extern int wcolour_set ( WINDOW *, short, void * ) __nonnull; #define wcolor_set(w,s,v) wcolour_set((w),(s),(v)) -extern int wdelch ( WINDOW * ); -extern int wdeleteln ( WINDOW * ); +extern int wdelch ( WINDOW * ) __nonnull; +extern int wdeleteln ( WINDOW * ) __nonnull; extern int wechochar ( WINDOW *, const chtype ); -extern int werase ( WINDOW * ); +extern int werase ( WINDOW * ) __nonnull; extern int wgetch ( WINDOW * ); extern int wgetnstr ( WINDOW *, char *, int ); //extern int wgetstr ( WINDOW *, char * ); -extern int whline ( WINDOW *, chtype, int ); +extern int whline ( WINDOW *, chtype, int ) __nonnull; //extern chtype winch ( WINDOW * ); //extern int winchnstr ( WINDOW *, chtype *, int ); //extern int winchstr ( WINDOW *, chtype * ); @@ -444,7 +448,7 @@ extern int whline ( WINDOW *, chtype, int ); //extern int winstr ( WINDOW *, char * ); extern int wmove ( WINDOW *, int, int ); //extern int wnoutrefresh ( WINDOW * ); -extern int wprintw ( WINDOW *, const char *, ... ); +extern int wprintw ( WINDOW *, const char *, ... ) __nonnull; //extern int wredrawln ( WINDOW *, int, int ); //extern int wrefresh ( WINDOW * ); //extern int wscanw ( WINDOW *, char *, ... ); @@ -456,7 +460,7 @@ extern void wsyncup ( WINDOW * ); extern void wsyncdown ( WINDOW * ); extern void wtimeout ( WINDOW *, int ); //extern int wtouchln ( WINDOW *, int, int, int ); -extern int wvline ( WINDOW *, chtype, int ); +extern int wvline ( WINDOW *, chtype, int ) __nonnull; /* * There is frankly a ridiculous amount of redundancy within the From d2dd4b9e31dfb8576ba999a264384a843b512cb9 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:39 +0200 Subject: [PATCH 23/47] __nonnull changes --- src/include/gpxe/editbox.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/gpxe/editbox.h b/src/include/gpxe/editbox.h index 8f2bd2c4..47b07c25 100644 --- a/src/include/gpxe/editbox.h +++ b/src/include/gpxe/editbox.h @@ -28,8 +28,10 @@ struct edit_box { extern void init_editbox ( struct edit_box *box, char *buf, size_t len, WINDOW *win, unsigned int row, unsigned int col, - unsigned int width ); -extern void draw_editbox ( struct edit_box *box ); + unsigned int width ) + __attribute__ (( nonnull (1, 2) )); +extern void draw_editbox ( struct edit_box *box ) __nonnull; +static inline int __pure edit_editbox ( struct edit_box *box, int key ) __nonnull; /** * Edit text box widget From d0867b101de19ae327b0fbbb87afb604a490a251 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:46 +0200 Subject: [PATCH 24/47] __nonnull changes --- src/include/gpxe/editstring.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/gpxe/editstring.h b/src/include/gpxe/editstring.h index 7f3c5dcb..fad8bd5a 100644 --- a/src/include/gpxe/editstring.h +++ b/src/include/gpxe/editstring.h @@ -26,6 +26,6 @@ struct edit_string { unsigned int mod_end; }; -extern int edit_string ( struct edit_string *string, int key ); +extern int edit_string ( struct edit_string *string, int key ) __nonnull; #endif /* _GPXE_EDITSTRING_H */ From a0fbce4656962518cc94e1691823573b50da1b42 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:34:59 +0200 Subject: [PATCH 25/47] __nonnull changes --- src/include/gpxe/settings_ui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/gpxe/settings_ui.h b/src/include/gpxe/settings_ui.h index 01b8f172..70ee8cb3 100644 --- a/src/include/gpxe/settings_ui.h +++ b/src/include/gpxe/settings_ui.h @@ -9,6 +9,6 @@ struct config_context; -extern int settings_ui ( struct config_context *context ); +extern int settings_ui ( struct config_context *context ) __nonnull; #endif /* _GPXE_SETTINGS_UI_H */ From 2e88138b0687f2237a839cff130ceeb74ff40d0e Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 00:35:07 +0200 Subject: [PATCH 26/47] __nonnull changes --- src/include/readline/readline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h index 4214a44f..79123130 100644 --- a/src/include/readline/readline.h +++ b/src/include/readline/readline.h @@ -7,6 +7,6 @@ * */ -extern char * readline ( const char *prompt ); +extern char * readline ( const char *prompt ) __nonnull; #endif /* _READLINE_H */ From 2220e1a676fd46286f48aa193d70fe5197629f49 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:28:11 +0200 Subject: [PATCH 27/47] define malloc attribute --- src/include/compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/include/compiler.h b/src/include/compiler.h index 32416a56..15efb709 100644 --- a/src/include/compiler.h +++ b/src/include/compiler.h @@ -298,6 +298,12 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr, */ #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. * From dea89e8d62941a3b369c87b885243efaa71627ea Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:28:23 +0200 Subject: [PATCH 28/47] use malloc attribute --- src/crypto/axtls/bigint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/axtls/bigint.c b/src/crypto/axtls/bigint.c index ee51c14d..49cad971 100644 --- a/src/crypto/axtls/bigint.c +++ b/src/crypto/axtls/bigint.c @@ -58,7 +58,7 @@ 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 *alloc(BI_CTX *ctx, int size); +static bigint __malloc *alloc(BI_CTX *ctx, int size); static bigint *trim(bigint *bi); static void more_comps(bigint *bi, int n); #if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \ From 68455adf37ed94363a1cb95c2d166529d6d9fba4 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:28:47 +0200 Subject: [PATCH 29/47] use malloc attribute --- src/crypto/cryptoLayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/cryptoLayer.h b/src/crypto/cryptoLayer.h index 538b84f2..28ce97bc 100644 --- a/src/crypto/cryptoLayer.h +++ b/src/crypto/cryptoLayer.h @@ -31,7 +31,7 @@ typedef void psPool_t; #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 ) { return malloc ( len ); } From 938626343378dfa74cdf50a0c4a23bdb88605a45 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:09 +0200 Subject: [PATCH 30/47] use malloc attribute --- src/include/gpxe/dhcp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/gpxe/dhcp.h b/src/include/gpxe/dhcp.h index 86322786..8f5651b1 100644 --- a/src/include/gpxe/dhcp.h +++ b/src/include/gpxe/dhcp.h @@ -502,7 +502,7 @@ extern void register_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, 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 * set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag, const void *data, size_t len ); From 05708503e54af40a304210466ad3f733f5a13c48 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:23 +0200 Subject: [PATCH 31/47] use malloc attribute --- src/include/gpxe/iobuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/gpxe/iobuf.h b/src/include/gpxe/iobuf.h index c0dfd434..e3db01ac 100644 --- a/src/include/gpxe/iobuf.h +++ b/src/include/gpxe/iobuf.h @@ -161,7 +161,7 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) { 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 iob_pad ( struct io_buffer *iobuf, size_t min_len ); extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len ); From c4285e148d163121e7ecdbe7a4386a4307fb0624 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:30 +0200 Subject: [PATCH 32/47] use malloc attribute --- src/include/gpxe/malloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/gpxe/malloc.h b/src/include/gpxe/malloc.h index 0e18f6a3..cce5d1d3 100644 --- a/src/include/gpxe/malloc.h +++ b/src/include/gpxe/malloc.h @@ -19,7 +19,7 @@ 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 mpopulate ( void *start, size_t len ); 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. */ -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 ); } From 347ab9b8c2b13c76ac964bd88e60d632a196a509 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:41 +0200 Subject: [PATCH 33/47] use malloc attribute --- src/include/readline/readline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/readline/readline.h b/src/include/readline/readline.h index 4214a44f..1a03b483 100644 --- a/src/include/readline/readline.h +++ b/src/include/readline/readline.h @@ -7,6 +7,6 @@ * */ -extern char * readline ( const char *prompt ); +extern char * __malloc readline ( const char *prompt ); #endif /* _READLINE_H */ From 6f61e254dc801da7fab388ed4791ac9de73aaeba Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:50 +0200 Subject: [PATCH 34/47] use malloc attribute --- src/include/stdlib.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/stdlib.h b/src/include/stdlib.h index 5c8fc3df..ae996962 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.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 free ( void *ptr ); -extern void * zalloc ( size_t len ); +extern void * __malloc zalloc ( size_t len ); /** * 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 * 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 ); } From 8bb295e3fd54a59b554ff5e2ff2d510ebf32f5f5 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:29:58 +0200 Subject: [PATCH 35/47] use malloc attribute --- src/include/string.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/include/string.h b/src/include/string.h index 210c3753..a2894a3a 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -41,9 +41,9 @@ int __pure memcmp(const void * cs,const void * ct, void * __pure memscan(const void * addr, int c, size_t size) __nonnull; char * __pure strstr(const char * s1,const char * s2) __nonnull; void * __pure memchr(const void *s, int c, size_t n) __nonnull; -char * strdup(const char *s) __nonnull; -char * strndup(const char *s, size_t n) __nonnull; +char * __malloc strdup(const char *s) __nonnull; +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 */ From 6f0eca14007d8d2c06dea9482adc3a0bd034fdb0 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:30:11 +0200 Subject: [PATCH 36/47] use malloc attribute --- src/net/ipv4.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/net/ipv4.c b/src/net/ipv4.c index 35341b3d..2f50f0e4 100644 --- a/src/net/ipv4.c +++ b/src/net/ipv4.c @@ -39,10 +39,9 @@ static LIST_HEAD ( frag_buffers ); * @v gateway Gateway address (or @c INADDR_NONE for no gateway) * @ret miniroute Routing table entry, or NULL */ -static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev, - struct in_addr address, - struct in_addr netmask, - struct in_addr gateway ) { +static struct ipv4_miniroute * __malloc +add_ipv4_miniroute ( struct net_device *netdev, struct in_addr address, + struct in_addr netmask, struct in_addr gateway ) { struct ipv4_miniroute *miniroute; DBG ( "IPv4 add %s", inet_ntoa ( address ) ); From bc9f960b66f40479153dfe632aff286f1d61d7ff Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:30:17 +0200 Subject: [PATCH 37/47] use malloc attribute --- src/net/ipv6.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/net/ipv6.c b/src/net/ipv6.c index 3b7429b8..c228f09c 100644 --- a/src/net/ipv6.c +++ b/src/net/ipv6.c @@ -55,11 +55,10 @@ static LIST_HEAD ( miniroutes ); * @v gateway Gateway address (or ::0 for no gateway) * @ret miniroute Routing table entry, or NULL */ -static struct ipv6_miniroute * add_ipv6_miniroute ( struct net_device *netdev, - struct in6_addr prefix, - int prefix_len, - struct in6_addr address, - struct in6_addr gateway ) { +static struct ipv6_miniroute * __malloc +add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix, + int prefix_len, struct in6_addr address, + struct in6_addr gateway ) { struct ipv6_miniroute *miniroute; miniroute = malloc ( sizeof ( *miniroute ) ); From f92096d1800f3d9ec7e90cc9bb0e0874569fab50 Mon Sep 17 00:00:00 2001 From: Holger Lubitz Date: Mon, 20 Aug 2007 20:30:24 +0200 Subject: [PATCH 38/47] use malloc attribute --- src/net/tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/tls.c b/src/net/tls.c index 64e44b55..5c201b32 100644 --- a/src/net/tls.c +++ b/src/net/tls.c @@ -1044,7 +1044,7 @@ static void tls_hmac ( struct tls_session *tls __unused, * @ret plaintext_len Length of 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, void *digest, size_t *plaintext_len ) { size_t mac_len = tls->tx_cipherspec.digest->digestsize; From eaca0531743b54e730920829d7b094bd5da23f6b Mon Sep 17 00:00:00 2001 From: Marty Connor Date: Thu, 30 Aug 2007 08:36:00 -0400 Subject: [PATCH 39/47] Add sis900 variant (patch from Vampyre) --- src/drivers/net/sis900.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/drivers/net/sis900.c b/src/drivers/net/sis900.c index 85c4acbe..870bdf44 100644 --- a/src/drivers/net/sis900.c +++ b/src/drivers/net/sis900.c @@ -103,6 +103,7 @@ static struct mii_chip_info { } mii_chip_table[] = { {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode}, {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode}, + {"SiS 900 on Foxconn 661 7MI", 0x0143, 0xBC70, sis900_read_mode}, {"AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, amd79c901_read_mode}, {"AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, amd79c901_read_mode}, {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf440,ics1893_read_mode}, From 63f0e4e796fcbd88107163387173bfe38d6f6af1 Mon Sep 17 00:00:00 2001 From: Marty Connor Date: Thu, 30 Aug 2007 13:08:46 -0400 Subject: [PATCH 40/47] allpxes allroms alldsks fixes from Vampyre --- src/Makefile.housekeeping | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 6126247b..2fb41a8c 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -376,7 +376,7 @@ define media_template @$(MKDIR) -p $(dir $(2)) @$(RM) $(2) @$(TOUCH) $(2) - @$(ECHO_E) '$$(BIN)/%$(1) : $$(BIN)/%$(1).zbin' \ + @$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \ '\n\t$$(QM)echo " [FINISH] $$@"' \ '\n\t$$(Q)$$(CP) $$< $$@' \ '\n\t$$(Q)$$(FINALISE_$(1))' \ @@ -400,8 +400,9 @@ include $(MEDIA_DEPS) # The "allXXXs" targets for each suffix # +allall: allroms allzroms allpxes allisos alldsks allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%) -all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%) +allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%) # Alias for gpxe.% # From 14e1d3cc4d7b7894fe5f8ed19329776cc79cf24e Mon Sep 17 00:00:00 2001 From: Marty Connor Date: Thu, 30 Aug 2007 13:51:38 -0400 Subject: [PATCH 41/47] TFTP default blocksize fix from Vampyre --- src/net/udp/tftp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 7f1c4ce6..6c1c51b0 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -647,6 +647,7 @@ int tftp_open ( struct xfer_interface *xfer, struct uri *uri ) { xfer_init ( &tftp->socket, &tftp_socket_operations, &tftp->refcnt ); tftp->state = -1; tftp->timer.expired = tftp_timer_expired; + tftp->blksize = TFTP_DEFAULT_BLKSIZE; /* Open socket */ memset ( &server, 0, sizeof ( server ) ); From 00d93c6dd90b00de6e354d22ddc188d08fabf0b9 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 6 Sep 2007 13:37:47 +0100 Subject: [PATCH 42/47] Minor style fix: structure fields are generally initialised in the order in which they occur. --- src/net/udp/tftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 6c1c51b0..74c8c0a5 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -645,9 +645,9 @@ int tftp_open ( struct xfer_interface *xfer, struct uri *uri ) { xfer_init ( &tftp->xfer, &tftp_xfer_operations, &tftp->refcnt ); tftp->uri = uri_get ( uri ); xfer_init ( &tftp->socket, &tftp_socket_operations, &tftp->refcnt ); + tftp->blksize = TFTP_DEFAULT_BLKSIZE; tftp->state = -1; tftp->timer.expired = tftp_timer_expired; - tftp->blksize = TFTP_DEFAULT_BLKSIZE; /* Open socket */ memset ( &server, 0, sizeof ( server ) ); From a82e6ec2deae5b3fda5aea1e2e8ebd2bda699602 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 6 Sep 2007 15:08:41 +0100 Subject: [PATCH 43/47] Added missing .kpxe prefix. --- src/arch/i386/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile index 4ab9d8ea..5e7416cb 100644 --- a/src/arch/i386/Makefile +++ b/src/arch/i386/Makefile @@ -38,6 +38,7 @@ LDSCRIPT = arch/i386/scripts/i386.lds # MEDIA += rom MEDIA += pxe +MEDIA += kpxe MEDIA += elf MEDIA += elfd MEDIA += lmelf From 66207bb912ef267d730165658b56b145fbb5eb3b Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 6 Sep 2007 15:11:09 +0100 Subject: [PATCH 44/47] Add the possibility to create .o files from arbitrary binary blobs. --- src/Makefile.housekeeping | 9 +++++++++ src/payload/hello.img | 1 + 2 files changed, 10 insertions(+) create mode 100644 src/payload/hello.img diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 2fb41a8c..4909345d 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -409,6 +409,15 @@ allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).% $(BIN)/etherboot.% : $(BIN)/gpxe.% ln -sf $(notdir $<) $@ +# Wrap up binary blobs +# +$(BIN)/%.o : payload/%.img + $(QM)echo " [WRAP] $@" + $(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \ + --defsym obj_$*=0 + +BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img)) + # The compression utilities # $(NRV2B) : util/nrv2b.c $(MAKEDEPS) diff --git a/src/payload/hello.img b/src/payload/hello.img new file mode 100644 index 00000000..bc7774a7 --- /dev/null +++ b/src/payload/hello.img @@ -0,0 +1 @@ +hello world! \ No newline at end of file From fbec308f41a7be8a2ad832b92b621e70af82bbf1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 8 Sep 2007 15:57:01 +0100 Subject: [PATCH 45/47] Re-added the kpxe prefix. I have no idea when this disappeared. --- src/arch/i386/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile index 4ab9d8ea..5e7416cb 100644 --- a/src/arch/i386/Makefile +++ b/src/arch/i386/Makefile @@ -38,6 +38,7 @@ LDSCRIPT = arch/i386/scripts/i386.lds # MEDIA += rom MEDIA += pxe +MEDIA += kpxe MEDIA += elf MEDIA += elfd MEDIA += lmelf From 972f293e46d936ade9613abfeb0953936f7389a5 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 8 Sep 2007 19:30:25 +0100 Subject: [PATCH 46/47] Check for correct block number in tftp_rx_data(). (Problem observed by Clay McClure in VMware Fusion.) --- src/net/udp/tftp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c index 74c8c0a5..194c533d 100644 --- a/src/net/udp/tftp.c +++ b/src/net/udp/tftp.c @@ -415,7 +415,7 @@ static int tftp_rx_oack ( struct tftp_request *tftp, void *buf, size_t len ) { static int tftp_rx_data ( struct tftp_request *tftp, struct io_buffer *iobuf ) { struct tftp_data *data = iobuf->data; - unsigned int block; + int block; size_t data_len; int rc; @@ -432,6 +432,14 @@ static int tftp_rx_data ( struct tftp_request *tftp, iob_pull ( iobuf, sizeof ( *data ) ); data_len = iob_len ( iobuf ); + /* Check for correct block */ + if ( block != ( tftp->state + 1 ) ) { + DBGC ( tftp, "TFTP %p received out-of-order block %d " + "(expecting %d)\n", tftp, block, ( tftp->state + 1 ) ); + free_iob ( iobuf ); + return 0; + } + /* Deliver data */ if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) { DBGC ( tftp, "TFTP %p could not deliver data: %s\n", From 6f799db5bd64ad408d7903679ac4d40ef9f48958 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 8 Sep 2007 23:38:17 +0100 Subject: [PATCH 47/47] Use "/bin/echo -e" instead of shell builtin echo; some shells don't implement the -e option. (Thanks to Jim McQuillan for this suggestion.) --- src/Makefile | 45 +++++++------ src/Makefile.housekeeping | 138 ++++++++++++++++++-------------------- 2 files changed, 88 insertions(+), 95 deletions(-) diff --git a/src/Makefile b/src/Makefile index 0f8ddca2..0682dc5a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -42,30 +42,31 @@ include arch/$(ARCH)/Config # message. # noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb - @echo '===========================================================' - @echo - @echo 'To create a bootable floppy, type' - @echo ' cat $(BIN)/gpxe.dsk > /dev/fd0' - @echo 'where /dev/fd0 is your floppy drive. This will erase any' - @echo 'data already on the disk.' - @echo - @echo 'To create a bootable USB key, type' - @echo ' cat $(BIN)/gpxe.usb > /dev/sdX' - @echo 'where /dev/sdX is your USB key, and is *not* a real hard' - @echo 'disk on your system. This will erase any data already on' - @echo 'the USB key.' - @echo - @echo 'To create a bootable CD-ROM, burn the ISO image ' - @echo '$(BIN)/gpxe.iso to a blank CD-ROM.' - @echo - @echo 'These images contain drivers for all supported cards. You' - @echo 'can build more customised images, and ROM images, using' - @echo ' make bin/.' - @echo - @echo '===========================================================' + @$(ECHO) '===========================================================' + @$(ECHO) + @$(ECHO) 'To create a bootable floppy, type' + @$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0' + @$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any' + @$(ECHO) 'data already on the disk.' + @$(ECHO) + @$(ECHO) 'To create a bootable USB key, type' + @$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX' + @$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard' + @$(ECHO) 'disk on your system. This will erase any data already on' + @$(ECHO) 'the USB key.' + @$(ECHO) + @$(ECHO) 'To create a bootable CD-ROM, burn the ISO image ' + @$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.' + @$(ECHO) + @$(ECHO) 'These images contain drivers for all supported cards. You' + @$(ECHO) 'can build more customised images, and ROM images, using' + @$(ECHO) ' make bin/.' + @$(ECHO) + @$(ECHO) '===========================================================' # Locations of utilities # +ECHO ?= /bin/echo -e HOST_CC ?= gcc CPP ?= gcc -E -Wp,-Wall RM ?= rm -f @@ -120,7 +121,7 @@ OBJECT = $(firstword $(subst ., ,$(@F))) # OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT)) $(BIN)/%.flags : - @echo $(OBJ_CFLAGS) + @$(ECHO) $(OBJ_CFLAGS) # Rules for specific object types. # diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 2fb41a8c..53842294 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -20,33 +20,25 @@ CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) \ -DVERSION=\"$(VERSION)\" IDENT = '$(@F) $(VERSION) (GPL) etherboot.org' version : - @echo $(VERSION) + @$(ECHO) $(VERSION) # Check for tools that can cause failed builds # .toolcheck : Makefile Config @if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \ - echo 'gcc 2.96 is unsuitable for compiling Etherboot'; \ - echo 'Use gcc 2.95 or gcc 3.x instead'; \ + $(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \ + $(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \ exit 1; \ fi @if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \ - echo 'Your Perl version has a Unicode handling bug'; \ - echo 'Execute this command before compiling Etherboot:'; \ - echo 'export LANG=$${LANG%.UTF-8}'; \ + $(ECHO) 'Your Perl version has a Unicode handling bug'; \ + $(ECHO) 'Execute this command before compiling Etherboot:'; \ + $(ECHO) 'export LANG=$${LANG%.UTF-8}'; \ exit 1; \ fi @$(TOUCH) $@ VERYCLEANUP += .toolcheck -# Check for correct syntax for echo -e -# -ifeq ($(shell echo '\0101'),A) -ECHO_E = echo -else -ECHO_E = echo -e -endif - # Build verbosity # ifeq ($(V),1) @@ -59,10 +51,10 @@ endif # Check for an old version of gas (binutils 2.9.1) # -OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && echo -DGAS291) +OLDGAS := $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291) CFLAGS += $(OLDGAS) oldgas : - @echo $(oldgas) + @$(ECHO) $(oldgas) # compiler.h is needed for our linking and debugging system # @@ -75,14 +67,14 @@ CLEANUP += config/*.h # SRCDIRS lists all directories containing source files. srcdirs : - @echo $(SRCDIRS) + @$(ECHO) $(SRCDIRS) # SRCS lists all .c or .S files found in any SRCDIR # SRCS += $(wildcard $(patsubst %,%/*.c,$(SRCDIRS))) SRCS += $(wildcard $(patsubst %,%/*.S,$(SRCDIRS))) srcs : - @echo $(SRCS) + @$(ECHO) $(SRCS) # AUTO_SRCS lists all files in SRCS that are not mentioned in # NON_AUTO_SRCS. Files should be added to NON_AUTO_SRCS if they @@ -90,7 +82,7 @@ srcs : # AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS)) autosrcs : - @echo $(AUTO_SRCS) + @$(ECHO) $(AUTO_SRCS) # We automatically generate rules for any file mentioned in AUTO_SRCS # using the following set of templates. It would be cleaner to use @@ -105,7 +97,7 @@ autosrcs : # define src_template - @echo "Generating Makefile rules for $(1)" + @$(ECHO) "Generating Makefile rules for $(1)" @$(MKDIR) -p $(dir $(2)) @$(RM) $(2) @$(TOUCH) $(2) @@ -129,14 +121,14 @@ define obj_template @$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \ -Wno-error -M $(1) -MT "$(4)_DEPS" -MG -MP | \ sed 's/_DEPS\s*:/_DEPS =/' >> $(2) - @$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \ - '\n\t$$(QM)echo " [BUILD] $$@"\n' \ + @$(ECHO) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \ + '\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \ '\n\t$$(RULE_$(3))\n' \ '\nBOBJS += $$(BIN)/$(4).o\n' \ $(foreach TGT,$(DEBUG_TARGETS), \ $(if $(RULE_$(3)_to_$(TGT)), \ '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \ - '\n\t$$(QM)echo " [BUILD] $$@"\n' \ + '\n\t$$(QM)$(ECHO) " [BUILD] $$@"\n' \ '\n\t$$(RULE_$(3)_to_$(TGT))\n' \ '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \ '\n$(2) : $$($(4)_DEPS)\n' \ @@ -148,34 +140,34 @@ endef # Rule to generate the Makefile rules files to be included # $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM) - $(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@echo 'ERROR: $< is not an AUTO_SRC' ; exit 1) + $(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@$(ECHO) 'ERROR: $< is not an AUTO_SRC' ; exit 1) # Calculate and include the list of Makefile rules files # AUTO_DEPS = $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS)) include $(AUTO_DEPS) autodeps : - @echo $(AUTO_DEPS) + @$(ECHO) $(AUTO_DEPS) VERYCLEANUP += $(BIN)/deps # The following variables are created by the Makefile rules files # bobjs : - @echo $(BOBJS) + @$(ECHO) $(BOBJS) drivers : - @echo $(DRIVERS) + @$(ECHO) $(DRIVERS) .PHONY : drivers roms : - @echo $(ROMS) + @$(ECHO) $(ROMS) # Generate the NIC file from the parsed source files. The NIC file is # only for rom-o-matic. # $(BIN)/NIC : $(AUTO_DEPS) - @echo '# This is an automatically generated file, do not edit' > $@ - @echo '# It does not affect anything in the build, ' \ + @$(ECHO) '# This is an automatically generated file, do not edit' > $@ + @$(ECHO) '# It does not affect anything in the build, ' \ 'it is only for rom-o-matic' >> $@ - @echo >> $@ + @$(ECHO) >> $@ @perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@ CLEANUP += $(BIN)/NIC @@ -258,25 +250,25 @@ BLIB_OBJS = $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS)) # Print out all derived information for a given target. # $(BIN)/%.info : - @echo 'Elements : $(TGT_ELEMENTS)' - @echo 'Prefix : $(TGT_PREFIX)' - @echo 'Drivers : $(TGT_DRIVERS)' - @echo 'ROM name : $(TGT_ROM_NAME)' - @echo 'Media : $(TGT_MEDIA)' - @echo - @echo 'PCI vendor : $(TGT_PCI_VENDOR)' - @echo 'PCI device : $(TGT_PCI_DEVICE)' - @echo - @echo 'LD driver symbols : $(TGT_LD_DRIVERS)' - @echo 'LD prefix symbols : $(TGT_LD_PREFIX)' - @echo 'LD ID symbols : $(TGT_LD_IDS)' - @echo - @echo 'LD target flags : $(TGT_LD_FLAGS)' - @echo - @echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)' - @echo - @echo 'Debugging objects : $(DEBUG_OBJS)' - @echo 'Replaced objects : $(DEBUG_ORIG_OBJS)' + @$(ECHO) 'Elements : $(TGT_ELEMENTS)' + @$(ECHO) 'Prefix : $(TGT_PREFIX)' + @$(ECHO) 'Drivers : $(TGT_DRIVERS)' + @$(ECHO) 'ROM name : $(TGT_ROM_NAME)' + @$(ECHO) 'Media : $(TGT_MEDIA)' + @$(ECHO) + @$(ECHO) 'PCI vendor : $(TGT_PCI_VENDOR)' + @$(ECHO) 'PCI device : $(TGT_PCI_DEVICE)' + @$(ECHO) + @$(ECHO) 'LD driver symbols : $(TGT_LD_DRIVERS)' + @$(ECHO) 'LD prefix symbols : $(TGT_LD_PREFIX)' + @$(ECHO) 'LD ID symbols : $(TGT_LD_IDS)' + @$(ECHO) + @$(ECHO) 'LD target flags : $(TGT_LD_FLAGS)' + @$(ECHO) + @$(ECHO) 'makerom target flags : $(TGT_MAKEROM_FLAGS)' + @$(ECHO) + @$(ECHO) 'Debugging objects : $(DEBUG_OBJS)' + @$(ECHO) 'Replaced objects : $(DEBUG_ORIG_OBJS)' # List of objects included in the last build of blib. This is needed # in order to correctly rebuild blib whenever the list of objects @@ -284,7 +276,7 @@ $(BIN)/%.info : # BLIB_LIST = $(BIN)/.blib.list ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS)) -$(shell echo "$(BLIB_OBJS)" > $(BLIB_LIST)) +$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST)) endif $(BLIB_LIST) : @@ -296,7 +288,7 @@ VERYCLEANUP += $(BLIB_LIST) BLIB = $(BIN)/blib.a $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS) $(Q)$(RM) $(BLIB) - $(QM)echo " [AR] $@" + $(QM)$(ECHO) " [AR] $@" $(Q)$(AR) r $@ $(BLIB_OBJS) $(Q)$(RANLIB) $@ blib : $(BLIB) @@ -305,7 +297,7 @@ blib : $(BLIB) # specified target. # $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) - $(QM)echo " [LD] $@" + $(QM)$(ECHO) " [LD] $@" $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \ -Map $(BIN)/$*.tmp.map $(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map @@ -318,19 +310,19 @@ $(BIN)/%.map : $(BIN)/%.tmp # Extract compression information from intermediate object file # $(BIN)/%.zinfo : $(BIN)/%.tmp - $(QM)echo " [ZINFO] $@" + $(QM)$(ECHO) " [ZINFO] $@" $(Q)$(OBJCOPY) -O binary -j .zinfo $< $@ # Build raw binary file from intermediate object file # $(BIN)/%.bin : $(BIN)/%.tmp - $(QM)echo " [BIN] $@" + $(QM)$(ECHO) " [BIN] $@" $(Q)$(OBJCOPY) -O binary -R .zinfo $< $@ # Compress raw binary file # $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN) - $(QM)echo " [ZBIN] $@" + $(QM)$(ECHO) " [ZBIN] $@" $(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@ # Build bochs symbol table @@ -359,11 +351,11 @@ $(BIN)/%.bxs : $(BIN)/%.tmp # much difference to the overall build time. media : - @echo $(MEDIA) + @$(ECHO) $(MEDIA) AUTO_MEDIA = $(filter-out $(NON_AUTO_MEDIA),$(MEDIA)) automedia : - @echo $(AUTO_MEDIA) + @$(ECHO) $(AUTO_MEDIA) # media_template : create Makefile rules for specified media # @@ -372,12 +364,12 @@ automedia : # define media_template - @echo "Generating Makefile rules for $(1) media" + @$(ECHO) "Generating Makefile rules for $(1) media" @$(MKDIR) -p $(dir $(2)) @$(RM) $(2) @$(TOUCH) $(2) - @$(ECHO_E) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \ - '\n\t$$(QM)echo " [FINISH] $$@"' \ + @$(ECHO) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \ + '\n\t$$(QM)$(ECHO) " [FINISH] $$@"' \ '\n\t$$(Q)$$(CP) $$< $$@' \ '\n\t$$(Q)$$(FINALISE_$(1))' \ > $(2) @@ -389,13 +381,13 @@ endef $(BIN)/deps/%.media.d : $(MAKEDEPS) $(if $(filter $(AUTO_MEDIA),$*), \ $(call media_template,$*,$@), \ - @echo 'ERROR: $* is not an AUTO_MEDIA' ; exit 1) + @$(ECHO) 'ERROR: $* is not an AUTO_MEDIA' ; exit 1) # Calculate and include the list of Makefile rules files # MEDIA_DEPS = $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA)) mediadeps : - @echo $(MEDIA_DEPS) + @$(ECHO) $(MEDIA_DEPS) include $(MEDIA_DEPS) # The "allXXXs" targets for each suffix @@ -412,13 +404,13 @@ $(BIN)/etherboot.% : $(BIN)/gpxe.% # The compression utilities # $(NRV2B) : util/nrv2b.c $(MAKEDEPS) - $(QM)echo " [HOSTCC] $@" + $(QM)$(ECHO) " [HOSTCC] $@" $(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \ -DBITSIZE=32 -DENDIAN=0 -o $@ $< CLEANUP += $(NRV2B) $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS) - $(QM)echo " [HOSTCC] $@" + $(QM)$(ECHO) " [HOSTCC] $@" $(Q)$(HOST_CC) -O2 -o $@ $< CLEANUP += $(ZBIN) @@ -431,10 +423,10 @@ BUILDSERIAL_NOW = config/.buildserial.now BUILDSERIAL_NEXT = config/.buildserial.next $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) : - echo 1 > $@ + $(ECHO) 1 > $@ $(BUILDSERIAL_H) : $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) - echo '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@ + $(ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@ ifeq ($(filter bs,$(MAKECMDGOALS)),bs) $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \ @@ -442,18 +434,18 @@ $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \ endif bs : $(BUILDSERIAL_NOW) - @echo $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT) - @echo "Build serial number is $(shell cat $<)" + @$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT) + @$(ECHO) "Build serial number is $(shell cat $<)" # List of available architectures # ARCHS = $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*))) archs : - @echo $(ARCHS) + @$(ECHO) $(ARCHS) OTHER_ARCHS = $(filter-out $(ARCH),$(ARCHS)) otherarchs : - @echo $(OTHER_ARCHS) + @$(ECHO) $(OTHER_ARCHS) # Build the TAGS file for emacs # @@ -503,7 +495,7 @@ docview : @if [ -n "$$BROWSER" ] ; then \ ( $$BROWSER $(BIN)/doc/html/index.html & ) ; \ else \ - echo "Documentation index in $(BIN)/doc/html/index.html" ; \ + $(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \ fi # Clean-up @@ -517,7 +509,7 @@ veryclean : clean # Make clean tarballs for release gpxe-tarball : ../VERSION - (echo -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION + ($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION $(RM) -r /tmp/gpxe/gpxe-$(VERSION) mkdir -p /tmp/gpxe/gpxe-$(VERSION) cp -rP .. /tmp/gpxe/gpxe-$(VERSION)