Fwd: Re: [PATCH] Steal all string functions from the libc
The lost message due to redirect mistake on my part Date: 2014-03-31 01:09 From: dardeve...@cidadecool.com To: Justus Winter 4win...@informatik.uni-hamburg.de Hi everyone, Sorry I tend to be a standby watcher of the mailing list however I could not avoid seeing strcmp function not checking for '\0' in s2 and just s1, this means that if s1 is bigger then s2, strcmp will compare garbage to content, of course a match is an extremely rare scenario, we ought to avoid it. :) Appears to me that this patch actually removes this, but still though was worth mentioning and maybe some further checking should be made on the newly inserted ones. Cheers Darcy Brás da Silva On 2014-03-28 15:22, Justus Winter wrote: Steal all string functions previously implemented in kern/strings.c from the libc. 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. --- Makefile.am| 3 +- Makefrag.am| 1 - kern/strings.c | 193 - 3 files changed, 2 insertions(+), 195 deletions(-) delete mode 100644 kern/strings.c 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..000 --- 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.distribut...@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, -
Re: Fwd: Re: [PATCH] Steal all string functions from the libc
dardeve...@cidadecool.com, le Thu 03 Apr 2014 00:37:05 +0200, a écrit : however I could not avoid seeing strcmp function not checking for '\0' in s2 and just s1, No: if b happens to be 0 while a is not, then the if (a!=b) is true and we return a-b. Samuel
Re: Fwd: Re: [PATCH] Steal all string functions from the libc
You are totally right. my fault on missing that detail. On 2014-04-03 08:25, Samuel Thibault wrote: dardeve...@cidadecool.com, le Thu 03 Apr 2014 00:37:05 +0200, a écrit : however I could not avoid seeing strcmp function not checking for '\0' in s2 and just s1, No: if b happens to be 0 while a is not, then the if (a!=b) is true and we return a-b. Samuel
Re: Glibc building procedure error report.
Mmm, I wonder why. The libc_add_on_subdirs=. line in configure should have made the build system take the libpthread/sysdeps path into account (at least in the Debian package it does). It takes into account the libpthread/sysdeps tree path. I have pasted the corresponding output of the configure script in the link below. http://paste.debian.net/plain/91552 The error appears when we include bits/(filename).h. It just looks for the headers in the bits/ folder, while they are at libpthread/sysdeps/generic/bits/. A workaround is to add lines in Makerules just like there are for *__libc_thread_subfreeres There are already lines in Makerules for that. PROVIDE(__start__hurd_fork_parent_hook = .);\ _hurd_fork_parent_hook : { *(_hurd_fork_parent_hook) }\ I am investigating if everything works as it should in my environment. I have attached the output of the configure part of the building process, so you can have a better look. checking build system type... x86_64-unknown-linux-gnu checking host system type... i686-pc-gnu checking for i686-pc-gnu-gcc... i686-pc-gnu-gcc checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether i686-pc-gnu-gcc accepts -g... yes checking for gcc... gcc checking for i686-pc-gnu-g++... no checking for i686-pc-gnu-c++... no checking for i686-pc-gnu-gpp... no checking for i686-pc-gnu-aCC... no checking for i686-pc-gnu-CC... no checking for i686-pc-gnu-cxx... no checking for i686-pc-gnu-cc++... no checking for i686-pc-gnu-cl.exe... no checking for i686-pc-gnu-FCC... no checking for i686-pc-gnu-KCC... no checking for i686-pc-gnu-RCC... no checking for i686-pc-gnu-xlC_r... no checking for i686-pc-gnu-xlC... no checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking for i686-pc-gnu-readelf... i686-pc-gnu-readelf checking for sysdeps preconfigure fragments... x86_64 configure: running configure fragment for add-on libidn configure: running configure fragment for add-on libpthread configure: running configure fragment for add-on nptl checking add-on ports for preconfigure fragments... aarch64 alpha am33 arm hppa ia64 m68k microblaze mips tile checking for assembler and linker STT_GNU_IFUNC support... yes checking whether .text pseudo-op must be used... yes checking sysdep dirs... libpthread/sysdeps/mach/hurd/i386 sysdeps/mach/hurd/i386 libpthread/sysdeps/mach/hurd libpthread/sysdeps/hurd sysdeps/mach/hurd sysdeps/gnu sysdeps/unix/bsd/bsd4.4 sysdeps/mach/i386 libpthread/sysdeps/mach sysdeps/mach sysdeps/i386/i686/fpu sysdeps/i386/i686 sysdeps/i386/i486 sysdeps/i386/fpu sysdeps/x86/fpu libpthread/sysdeps/i386 sysdeps/i386 sysdeps/x86 sysdeps/wordsize-32 sysdeps/ieee754/ldbl-96 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/unix/bsd sysdeps/unix/inet sysdeps/ieee754 sysdeps/unix sysdeps/posix libpthread/sysdeps/posix sysdeps/generic configure: WARNING: add-on ports contributed no sysdeps directories checking for a BSD-compatible install... /gnu/store/gjl05yl9lvgjhznz5v985mys861svp34-coreutils-8.21/bin/install -c checking whether ln -s works... yes checking whether /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/as is GNU as... yes checking whether /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/ld is GNU ld... yes checking for /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/as... /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/as checking version of /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/as... 2.23.2, ok checking for /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/ld... /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/ld checking version of /gnu/store/hl1rsbjzq5pwph850al9y52xrjqjg4f5-gcc-cross-sans-libc-i686-pc-gnu-4.8.2/libexec/gcc/i686-pc-gnu/ld... 2.23.2, ok checking for i686-pc-gnu-gcc... (cached) i686-pc-gnu-gcc checking version of i686-pc-gnu-gcc... 4.8.2, ok checking for gnumake... no checking for gmake... no checking for make... make checking version of make... 4.0, ok checking for gnumsgfmt... no checking for gmsgfmt... no checking for msgfmt... no checking for makeinfo... no checking for sed... sed checking version of sed... 4.2.2, ok checking for gawk... gawk checking version of gawk... 4.1.0, ok checking for i686-pc-gnu-nm... i686-pc-gnu-nm checking for autoconf... autoconf checking whether autoconf works... yes configure: WARNING: *** These auxiliary programs are missing or incompatible versions: msgfmt makeinfo *** some features will be disabled. *** Check the INSTALL file for
Re: problem on shut-down
Hi, On 04/02/2014 02:20 PM, Justus Winter wrote: Ok, I installed openbsd-inetd and telnetd on a test vm. service {start,stop} openbsd-inetd work as expected. it's not inetd. It actually stops here: root@ithil:~# ps -x PID TT STAT TIME COMMAND 8 - So 0:08.54 /hurd/term /dev/console device console 9 - So 0:22.96 /hurd/pflocal 19 - So 0:00.26 /hurd/procfs -c 34 - So 0:00.06 /hurd/proxy-defpager 88 - So 0:01.14 /hurd/tmpfs --nosuid --noexec --size=10% --mode=755 tmpfs 89 - So 0:00.07 /hurd/storeio --no-cache time 109 - So 0:00.03 /hurd/tmpfs --noexec --nosuid --size=5242880 --mode=1777 tmpfs 194 - So 0:00.05 /hurd/tmpfs --nosuid --noexec --size=52420k --mode=1777 tmpfs 216 - So 0:00.06 /hurd/storeio hd0s3 224 - So 0:00.05 /hurd/storeio hd0s1 225 - So 0:00.04 /hurd/storeio hd0s2 226 - So 0:00.03 /hurd/storeio hd2 234 - So 0:00.34 /hurd/fifo 462 - So 0:50.95 /hurd/ext2fs /dev/hd0s2 582 - So 0:00.37 /hurd/random --seed-file /var/spool/random-seed --fast 599 - So 0:35.50 /hurd/pfinet -i /dev/eth0 -a 192.168.1.26 -g 192.168.1.254 -m 2 600 - So0:00.01 /hurd/devnode -M /dev/netdde eth0 601 - So 0:10.20 /hurd/netdde 692 - So 0:00.03 /hurd/streamio kmsg 723 - So 0:00.07 /hurd/fifo 1006 - So 0:00.04 /hurd/random --seed-file /var/spool/random-seed 1050 - So 0:00.01 /hurd/term /dev/tty2 hurdio /dev/vcs/2/console 1051 - So 0:00.05 /hurd/term /dev/tty1 hurdio /dev/vcs/1/console 1052 - So 0:00.04 /hurd/term /dev/tty3 hurdio /dev/vcs/3/console 1053 - So 0:00.04 /hurd/term /dev/tty4 hurdio /dev/vcs/4/console 1054 - So 0:00.05 /hurd/term /dev/tty5 hurdio /dev/vcs/5/console 1055 - So 0:00.02 /hurd/term /dev/tty6 hurdio /dev/vcs/6/console 1056 - So 0:00.80 /hurd/password 1057 ? Ro 1:55.74 /hurd/console 2933 - So 0:03.57 /hurd/term /dev/ptyp0 pty-master /dev/ttyp0 3070 - So 0:05.65 /hurd/term /dev/ptyp1 pty-master /dev/ttyp1 11427 - So0:00.02 /hurd/magic tty 11434 - Sow 0:00.04 startpar -p 4 -t 20 -T 3 -M stop -P 2 -R 0 11451 - Sow 0:00.05 /bin/sh /etc/init.d/sendsigs stop 11454 - So0:00.02 sync 11455 p0 Sw0:00.57 su - 11457 p0 Sw0:00.62 -su 11463 p0 S 0:00.03 ps -x sendisgs stop I shut down from console and had a remote connection open. At this point even issuing a sync will hang and I need to cut the machine's power Riccardo