diff options
-rw-r--r-- | debian/patches/series | 1 | ||||
-rw-r--r-- | debian/patches/steal-str.patch | 240 |
2 files changed, 241 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series index 9825c75..1730a3d 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,3 +5,4 @@ 70_dde.patch protected_payload.patch +steal-str.patch diff --git a/debian/patches/steal-str.patch b/debian/patches/steal-str.patch new file mode 100644 index 0000000..ad1c2cd --- /dev/null +++ b/debian/patches/steal-str.patch @@ -0,0 +1,240 @@ +commit 03669f66d11b23bc0dcf7dc26141ef5ca7781388 +Author: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri Mar 28 12:25:26 2014 +0100 + + Steal all string functions from the libc + + Steal all string functions from the libc previously implemented in + kern/strings.c. Those are most likely more optimized than our simple + implementations. + + * Makefile.am (clib_routines): Add memset, strcmp, strncmp, strcpy, + strncpy, and strlen. + * Makefrag.am (libkernel_a_SOURCES): Drop kern/strings.c. + * kern/strings.c: Remove file. + +diff --git a/Makefile.am b/Makefile.am +index 918cdc3..6e5207e 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -156,7 +156,8 @@ noinst_PROGRAMS += \ + gnumach.o + + # This is the list of routines we decide is OK to steal from the C library. +-clib_routines := memcmp memcpy memmove \ ++clib_routines := memcmp memcpy memmove memset \ ++ strcmp strncmp strcpy strncpy strlen \ + strchr strstr strsep strtok \ + htonl htons ntohl ntohs \ + udivdi3 __udivdi3 \ +diff --git a/Makefrag.am b/Makefrag.am +index c1387bd..de020fc 100644 +--- a/Makefrag.am ++++ b/Makefrag.am +@@ -193,7 +193,6 @@ libkernel_a_SOURCES += \ + kern/shuttle.h \ + kern/startup.c \ + kern/startup.h \ +- kern/strings.c \ + kern/syscall_emulation.c \ + kern/syscall_emulation.h \ + kern/syscall_subr.c \ +diff --git a/kern/strings.c b/kern/strings.c +deleted file mode 100644 +index c77ae4f..0000000 +--- a/kern/strings.c ++++ /dev/null +@@ -1,193 +0,0 @@ +-/* +- * Mach Operating System +- * Copyright (c) 1993 Carnegie Mellon University +- * All Rights Reserved. +- * +- * Permission to use, copy, modify and distribute this software and its +- * documentation is hereby granted, provided that both the copyright +- * notice and this permission notice appear in all copies of the +- * software, derivative works or modified versions, and any portions +- * thereof, and that both notices appear in supporting documentation. +- * +- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" +- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR +- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. +- * +- * Carnegie Mellon requests users of this software to return to +- * +- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU +- * School of Computer Science +- * Carnegie Mellon University +- * Pittsburgh PA 15213-3890 +- * +- * any improvements or extensions that they make and grant Carnegie Mellon +- * the rights to redistribute these changes. +- */ +-/* +- * File: strings.c +- * Author: Robert V. Baron, Carnegie Mellon University +- * Date: ??/92 +- * +- * String functions. +- */ +- +-#include <string.h> +- +-#ifdef strcpy +-#undef strcmp +-#undef strncmp +-#undef strcpy +-#undef strncpy +-#undef strlen +-#endif +- +-/* +- * Abstract: +- * strcmp (s1, s2) compares the strings "s1" and "s2". +- * It returns 0 if the strings are identical. It returns +- * > 0 if the first character that differs in the two strings +- * is larger in s1 than in s2 or if s1 is longer than s2 and +- * the contents are identical up to the length of s2. +- * It returns < 0 if the first differing character is smaller +- * in s1 than in s2 or if s1 is shorter than s2 and the +- * contents are identical upto the length of s1. +- */ +- +-int __attribute__ ((pure)) +-strcmp( +- const char *s1, +- const char *s2) +-{ +- unsigned int a, b; +- +- do { +- a = *s1++; +- b = *s2++; +- if (a != b) +- return a-b; /* includes case when +- 'a' is zero and 'b' is not zero +- or vice versa */ +- } while (a != '\0'); +- +- return 0; /* both are zero */ +-} +- +- +-/* +- * Abstract: +- * strncmp (s1, s2, n) compares the strings "s1" and "s2" +- * in exactly the same way as strcmp does. Except the +- * comparison runs for at most "n" characters. +- */ +- +-int __attribute__ ((pure)) +-strncmp( +- const char *s1, +- const char *s2, +- size_t n) +-{ +- unsigned int a, b; +- +- while (n != 0) { +- a = *s1++; +- b = *s2++; +- if (a != b) +- return a-b; /* includes case when +- 'a' is zero and 'b' is not zero +- or vice versa */ +- if (a == '\0') +- return 0; /* both are zero */ +- n--; +- } +- +- return 0; +-} +- +- +-/* +- * Abstract: +- * strcpy copies the contents of the string "from" including +- * the null terminator to the string "to". A pointer to "to" +- * is returned. +- */ +- +-char * +-strcpy( +- char *to, +- const char *from) +-{ +- char *ret = to; +- +- while ((*to++ = *from++) != '\0') +- continue; +- +- return ret; +-} +- +-/* +- * Abstract: +- * strncpy copies "count" characters from the "from" string to +- * the "to" string. If "from" contains less than "count" characters +- * "to" will be padded with null characters until exactly "count" +- * characters have been written. The return value is a pointer +- * to the "to" string. +- */ +- +-char * +-strncpy( +- char *to, +- const char *from, +- size_t count) +-{ +- char *ret = to; +- +- while (count != 0) { +- count--; +- if ((*to++ = *from++) == '\0') +- break; +- } +- +- while (count != 0) { +- *to++ = '\0'; +- count--; +- } +- +- return ret; +-} +- +-/* +- * Abstract: +- * strlen returns the number of characters in "string" preceeding +- * the terminating null character. +- */ +- +-size_t __attribute__ ((pure)) +-strlen( +- const char *string) +-{ +- const char *ret = string; +- +- while (*string++ != '\0') +- continue; +- +- return string - 1 - ret; +-} +- +-/* +- * Abstract: +- * memset writes value "c" in the "n" bytes starting at address "s". +- * The return value is a pointer to the "s" string. +- */ +- +-void * +-memset( +- void *_s, int c, size_t n) +-{ +- char *s = _s; +- int i; +- +- for (i = 0; i < n ; i++) +- s[i] = c; +- +- return _s; +-} |