Merge "Fix mips build"
authorCalin Juravle <calin@google.com>
Wed, 26 Feb 2014 21:34:56 +0000 (21:34 +0000)
committerGerrit Code Review <noreply-gerritcodereview@google.com>
Wed, 26 Feb 2014 21:34:57 +0000 (21:34 +0000)
37 files changed:
HACKING.txt
libc/Android.mk
libc/arch-arm/arm.mk
libc/arch-arm/generic/generic.mk
libc/arch-arm64/arm64.mk
libc/arch-mips/mips.mk
libc/arch-mips64/mips64.mk
libc/arch-x86/x86.mk
libc/arch-x86_64/x86_64.mk
libc/bionic/__memcmp16.cpp [moved from libc/string/memcmp16.c with 86% similarity]
libc/bionic/__strrchr_chk.cpp
libc/bionic/debug_stacktrace.cpp
libc/bionic/flockfile.cpp [moved from libc/bionic/flockfile.c with 63% similarity]
libc/bionic/index.cpp [moved from libc/string/index.c with 88% similarity]
libc/bionic/memcpy.cpp [moved from libc/bionic/memcpy.c with 82% similarity]
libc/bionic/strchr.cpp
libc/bionic/strrchr.cpp [moved from libc/string/strrchr.c with 90% similarity]
libc/include/string.h
libc/include/wchar.h
libc/stdio/fileext.h
libc/upstream-freebsd/lib/libc/string/wcslcpy.c [deleted file]
libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c [new file with mode: 0644]
libc/upstream-openbsd/lib/libc/stdlib/system.c [moved from libc/unistd/system.c with 92% similarity]
libc/upstream-openbsd/lib/libc/string/bcopy.c [moved from libc/string/bcopy.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strcat.c [moved from libc/string/strcat.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strcmp.c [moved from libc/string/strcmp.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strcpy.c [moved from libc/string/strcpy.c with 89% similarity]
libc/upstream-openbsd/lib/libc/string/strlcat.c [moved from libc/string/strlcat.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strlcpy.c [moved from libc/string/strlcpy.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strlen.c [moved from libc/string/strlen.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strncat.c [moved from libc/string/strncat.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/strncmp.c [moved from libc/string/strncmp.c with 99% similarity]
libc/upstream-openbsd/lib/libc/string/strncpy.c [moved from libc/string/strncpy.c with 100% similarity]
libc/upstream-openbsd/lib/libc/string/wcslcpy.c [new file with mode: 0644]
libc/upstream-openbsd/lib/libc/string/wcswidth.c [new file with mode: 0644]
libc/wchar/wcswidth.c [deleted file]
libc/wchar/wcsxfrm.c [deleted file]

index f614b6904c5a6cd5522c9e4965318084a26654cf..6c142e13f0d548e081ce61de71e617311f5d46f4 100644 (file)
@@ -84,9 +84,7 @@ libc/
   netbsd/
   stdio/
   stdlib/
-  string/
   unistd/
-  wchar/
     # These are legacy files of unknown provenance. In the past, bionic was a
     # mess of random versions of random files from all three of FreeBSD, NetBSD,
     # and OpenBSD! We've been working to clean that up, but these directories
index 1bee427e72116c0ab2b90f9c8dc31462dee771d3..e401a1c2ce6f4fae3959a3d42947c75e92238853 100644 (file)
@@ -45,7 +45,6 @@ libc_common_src_files := \
     bionic/ether_aton.c \
     bionic/ether_ntoa.c \
     bionic/fdprintf.c \
-    bionic/flockfile.c \
     bionic/ftime.c \
     bionic/fts.c \
     bionic/getdtablesize.c \
@@ -107,10 +106,7 @@ libc_common_src_files := \
     stdlib/strtod.c \
     unistd/alarm.c \
     unistd/syslog.c \
-    unistd/system.c \
     unistd/time.c \
-    wchar/wcswidth.c \
-    wchar/wcsxfrm.c \
 
 # Fortify implementations of libc functions.
 libc_common_src_files += \
@@ -149,6 +145,7 @@ libc_bionic_src_files := \
     bionic/eventfd_read.cpp \
     bionic/eventfd_write.cpp \
     bionic/ffs.cpp \
+    bionic/flockfile.cpp \
     bionic/fork.cpp \
     bionic/futimens.cpp \
     bionic/getauxval.cpp \
@@ -261,7 +258,6 @@ libc_upstream_freebsd_src_files := \
     upstream-freebsd/lib/libc/string/wcscspn.c \
     upstream-freebsd/lib/libc/string/wcsdup.c \
     upstream-freebsd/lib/libc/string/wcslcat.c \
-    upstream-freebsd/lib/libc/string/wcslcpy.c \
     upstream-freebsd/lib/libc/string/wcsncasecmp.c \
     upstream-freebsd/lib/libc/string/wcsncat.c \
     upstream-freebsd/lib/libc/string/wcsncmp.c \
@@ -319,6 +315,81 @@ libc_upstream_netbsd_src_files := \
     upstream-netbsd/lib/libc/thread-stub/__isthreaded.c \
     upstream-netbsd/lib/libc/unistd/killpg.c \
 
+libc_upstream_openbsd_src_files := \
+    upstream-openbsd/lib/libc/gen/exec.c \
+    upstream-openbsd/lib/libc/gen/ftok.c \
+    upstream-openbsd/lib/libc/gen/fnmatch.c \
+    upstream-openbsd/lib/libc/gen/toupper_.c \
+    upstream-openbsd/lib/libc/gen/tolower_.c \
+    upstream-openbsd/lib/libc/string/strstr.c \
+    upstream-openbsd/lib/libc/string/strsep.c \
+    upstream-openbsd/lib/libc/string/wcslcpy.c \
+    upstream-openbsd/lib/libc/string/strcasecmp.c \
+    upstream-openbsd/lib/libc/string/strdup.c \
+    upstream-openbsd/lib/libc/string/strcspn.c \
+    upstream-openbsd/lib/libc/string/strtok.c \
+    upstream-openbsd/lib/libc/string/strpbrk.c \
+    upstream-openbsd/lib/libc/string/strspn.c \
+    upstream-openbsd/lib/libc/string/wcswidth.c \
+    upstream-openbsd/lib/libc/string/strndup.c \
+    upstream-openbsd/lib/libc/stdio/ungetc.c \
+    upstream-openbsd/lib/libc/stdio/vsnprintf.c \
+    upstream-openbsd/lib/libc/stdio/tmpnam.c \
+    upstream-openbsd/lib/libc/stdio/setbuffer.c \
+    upstream-openbsd/lib/libc/stdio/fsetpos.c \
+    upstream-openbsd/lib/libc/stdio/setbuf.c \
+    upstream-openbsd/lib/libc/stdio/vprintf.c \
+    upstream-openbsd/lib/libc/stdio/perror.c \
+    upstream-openbsd/lib/libc/stdio/remove.c \
+    upstream-openbsd/lib/libc/stdio/getc.c \
+    upstream-openbsd/lib/libc/stdio/funopen.c \
+    upstream-openbsd/lib/libc/stdio/ferror.c \
+    upstream-openbsd/lib/libc/stdio/putchar.c \
+    upstream-openbsd/lib/libc/stdio/vscanf.c \
+    upstream-openbsd/lib/libc/stdio/fflush.c \
+    upstream-openbsd/lib/libc/stdio/fpurge.c \
+    upstream-openbsd/lib/libc/stdio/fputs.c \
+    upstream-openbsd/lib/libc/stdio/tempnam.c \
+    upstream-openbsd/lib/libc/stdio/printf.c \
+    upstream-openbsd/lib/libc/stdio/fileno.c \
+    upstream-openbsd/lib/libc/stdio/stdio.c \
+    upstream-openbsd/lib/libc/stdio/getdelim.c \
+    upstream-openbsd/lib/libc/stdio/fseek.c \
+    upstream-openbsd/lib/libc/stdio/fputc.c \
+    upstream-openbsd/lib/libc/stdio/fgetln.c \
+    upstream-openbsd/lib/libc/stdio/fdopen.c \
+    upstream-openbsd/lib/libc/stdio/fgets.c \
+    upstream-openbsd/lib/libc/stdio/fgetc.c \
+    upstream-openbsd/lib/libc/stdio/feof.c \
+    upstream-openbsd/lib/libc/stdio/vasprintf.c \
+    upstream-openbsd/lib/libc/stdio/refill.c \
+    upstream-openbsd/lib/libc/stdio/getline.c \
+    upstream-openbsd/lib/libc/stdio/rewind.c \
+    upstream-openbsd/lib/libc/stdio/wbuf.c \
+    upstream-openbsd/lib/libc/stdio/gets.c \
+    upstream-openbsd/lib/libc/stdio/fgetpos.c \
+    upstream-openbsd/lib/libc/stdio/fscanf.c \
+    upstream-openbsd/lib/libc/stdio/putc.c \
+    upstream-openbsd/lib/libc/stdio/vsprintf.c \
+    upstream-openbsd/lib/libc/stdio/rget.c \
+    upstream-openbsd/lib/libc/stdio/clrerr.c \
+    upstream-openbsd/lib/libc/stdio/scanf.c \
+    upstream-openbsd/lib/libc/stdio/puts.c \
+    upstream-openbsd/lib/libc/stdio/getchar.c \
+    upstream-openbsd/lib/libc/stdio/ftell.c \
+    upstream-openbsd/lib/libc/stdio/fwalk.c \
+    upstream-openbsd/lib/libc/stdlib/strtoul.c \
+    upstream-openbsd/lib/libc/stdlib/strtoull.c \
+    upstream-openbsd/lib/libc/stdlib/atoi.c \
+    upstream-openbsd/lib/libc/stdlib/atoll.c \
+    upstream-openbsd/lib/libc/stdlib/atol.c \
+    upstream-openbsd/lib/libc/stdlib/strtoimax.c \
+    upstream-openbsd/lib/libc/stdlib/strtoumax.c \
+    upstream-openbsd/lib/libc/stdlib/strtoll.c \
+    upstream-openbsd/lib/libc/stdlib/strtol.c \
+    upstream-openbsd/lib/libc/stdlib/system.c \
+    upstream-openbsd/lib/libc/locale/wcsxfrm.c \
+
 libc_arch_static_src_files := \
     bionic/dl_iterate_phdr_static.cpp \
 
@@ -514,7 +585,7 @@ include $(BUILD_STATIC_LIBRARY)
 
 include $(CLEAR_VARS)
 
-LOCAL_SRC_FILES := $(call all-c-files-under,upstream-openbsd)
+LOCAL_SRC_FILES := $(libc_upstream_openbsd_src_files)
 LOCAL_CFLAGS := \
     $(libc_common_cflags) \
     -I$(LOCAL_PATH)/upstream-openbsd \
index 55f99783ab28efa65cda5c55acb84357c12ad353..89a1ce050f098b4c163654e9701fb58c0e615271 100644 (file)
@@ -10,19 +10,13 @@ libc_bionic_src_files_arm := \
     bionic/mmap.cpp
 
 libc_common_src_files_arm += \
+    bionic/index.cpp \
     bionic/memchr.c \
     bionic/memmove.c.arm \
     bionic/memrchr.c \
     bionic/strchr.cpp \
     bionic/strnlen.c \
-    string/bcopy.c \
-    string/index.c \
-    string/strlcat.c \
-    string/strlcpy.c \
-    string/strncat.c \
-    string/strncmp.c \
-    string/strncpy.c \
-    string/strrchr.c \
+    bionic/strrchr.cpp \
     upstream-freebsd/lib/libc/string/wcscat.c \
     upstream-freebsd/lib/libc/string/wcschr.c \
     upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -30,6 +24,12 @@ libc_common_src_files_arm += \
     upstream-freebsd/lib/libc/string/wcslen.c \
     upstream-freebsd/lib/libc/string/wcsrchr.c \
     upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/bcopy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncmp.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
 
 # The C++ fortify function implementations for which there is an
 # arm assembler version.
index 063d89314b27442c33a75763554650292bc4dc40..2bc84e02d9c98ad19a93f3e941aa7414ff4c5374 100644 (file)
@@ -1,9 +1,9 @@
 libc_bionic_src_files_arm += \
     arch-arm/generic/bionic/memcpy.S \
     arch-arm/generic/bionic/memset.S \
-    string/strcat.c \
     arch-arm/generic/bionic/strcmp.S \
     arch-arm/generic/bionic/strcpy.S \
     arch-arm/generic/bionic/strlen.c \
     bionic/__strcat_chk.cpp \
     bionic/__strcpy_chk.cpp \
+    upstream-openbsd/lib/libc/string/strcat.c \
index a6459491707252734a51b0d1f696022ec34de600..76c610a721d1ebcaf249b8c8f69ef309cbd7afc3 100644 (file)
@@ -1,27 +1,17 @@
 # arm64 specific configs
 
 libc_common_src_files_arm64 := \
-    bionic/memchr.c   \
-    bionic/memcmp.c   \
-    bionic/memcpy.c   \
-    bionic/memmove.c  \
-    bionic/memrchr.c  \
-    bionic/memset.c   \
+    bionic/index.cpp \
+    bionic/memchr.c \
+    bionic/__memcmp16.cpp \
+    bionic/memcmp.c \
+    bionic/memcpy.cpp \
+    bionic/memmove.c \
+    bionic/memrchr.c \
+    bionic/memset.c \
     bionic/strchr.cpp \
-    bionic/strnlen.c  \
-    string/bcopy.c    \
-    string/index.c    \
-    string/memcmp16.c \
-    string/strcat.c   \
-    string/strcmp.c   \
-    string/strcpy.c   \
-    string/strlcat.c  \
-    string/strlcpy.c  \
-    string/strlen.c   \
-    string/strncat.c  \
-    string/strncmp.c  \
-    string/strncpy.c  \
-    string/strrchr.c  \
+    bionic/strnlen.c \
+    bionic/strrchr.cpp \
     upstream-freebsd/lib/libc/string/wcscat.c \
     upstream-freebsd/lib/libc/string/wcschr.c \
     upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -29,6 +19,16 @@ libc_common_src_files_arm64 := \
     upstream-freebsd/lib/libc/string/wcslen.c \
     upstream-freebsd/lib/libc/string/wcsrchr.c \
     upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/bcopy.c \
+    upstream-openbsd/lib/libc/string/strcat.c \
+    upstream-openbsd/lib/libc/string/strcmp.c \
+    upstream-openbsd/lib/libc/string/strcpy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strlen.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncmp.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
 
 # Fortify implementations of libc functions.
 libc_common_src_files_arm64 += \
index 0fa1ed6ebed8532b3311225dec3bd125f5bd5cd9..1af4a651bc4f8fd814b393021cec2552f491baec 100644 (file)
@@ -10,23 +10,14 @@ libc_bionic_src_files_mips += \
      bionic/mmap.cpp
 
 libc_common_src_files_mips += \
+    bionic/index.cpp \
     bionic/memchr.c \
     bionic/memcmp.c \
     bionic/memmove.c \
     bionic/memrchr.c \
     bionic/strchr.cpp \
     bionic/strnlen.c \
-    string/bcopy.c \
-    string/index.c \
-    string/strcat.c \
-    string/strcmp.c \
-    string/strcpy.c \
-    string/strlcat.c \
-    string/strlcpy.c \
-    string/strncat.c \
-    string/strncmp.c \
-    string/strncpy.c \
-    string/strrchr.c \
+    bionic/strrchr.cpp \
     upstream-freebsd/lib/libc/string/wcscat.c \
     upstream-freebsd/lib/libc/string/wcschr.c \
     upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -34,6 +25,15 @@ libc_common_src_files_mips += \
     upstream-freebsd/lib/libc/string/wcslen.c \
     upstream-freebsd/lib/libc/string/wcsrchr.c \
     upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/bcopy.c \
+    upstream-openbsd/lib/libc/string/strcat.c \
+    upstream-openbsd/lib/libc/string/strcmp.c \
+    upstream-openbsd/lib/libc/string/strcpy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncmp.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
 
 # Fortify implementations of libc functions.
 libc_common_src_files_mips += \
index 11ceb40b35830cf983b059ea7deef92cc5c1bf7e..28806e183712ef260a205dff178dc4cd774a74ff 100644 (file)
@@ -1,30 +1,31 @@
 # mips64 specific configs
 
 libc_common_src_files_mips64 := \
-  bionic/memchr.c \
-  bionic/memcmp.c \
-  bionic/memmove.c \
-  bionic/memrchr.c \
-  bionic/strchr.cpp \
-  bionic/strnlen.c \
-  string/bcopy.c \
-  string/index.c \
-  string/strcat.c \
-  string/strcmp.c \
-  string/strcpy.c \
-  string/strlcat.c \
-  string/strlcpy.c \
-  string/strncat.c \
-  string/strncmp.c \
-  string/strncpy.c \
-  string/strrchr.c \
-  upstream-freebsd/lib/libc/string/wcscat.c \
-  upstream-freebsd/lib/libc/string/wcschr.c \
-  upstream-freebsd/lib/libc/string/wcscmp.c \
-  upstream-freebsd/lib/libc/string/wcscpy.c \
-  upstream-freebsd/lib/libc/string/wcslen.c \
-  upstream-freebsd/lib/libc/string/wcsrchr.c \
-  upstream-freebsd/lib/libc/string/wmemcmp.c \
+    bionic/index.cpp \
+    bionic/memchr.c \
+    bionic/memcmp.c \
+    bionic/memmove.c \
+    bionic/memrchr.c \
+    bionic/strchr.cpp \
+    bionic/strnlen.c \
+    bionic/strrchr.cpp \
+    upstream-freebsd/lib/libc/string/wcscat.c \
+    upstream-freebsd/lib/libc/string/wcschr.c \
+    upstream-freebsd/lib/libc/string/wcscmp.c \
+    upstream-freebsd/lib/libc/string/wcscpy.c \
+    upstream-freebsd/lib/libc/string/wcslen.c \
+    upstream-freebsd/lib/libc/string/wcsrchr.c \
+    upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/bcopy.c \
+    upstream-openbsd/lib/libc/string/strcat.c \
+    upstream-openbsd/lib/libc/string/strcmp.c \
+    upstream-openbsd/lib/libc/string/strcpy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strlen.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncmp.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
 
 # Fortify implementations of libc functions.
 libc_common_src_files_mips64 += \
@@ -54,10 +55,8 @@ libc_bionic_src_files_mips64 := \
 # FIXME TODO
 ## libc_bionic_src_files_mips64 += arch-mips64/string/memcpy.S
 ## libc_bionic_src_files_mips64 += arch-mips64/string/memset.S
-## libc_bionic_src_files_mips64 += arch-mips64/string/mips_strlen.c
 libc_bionic_src_files_mips64 += bionic/memcpy.c
 libc_bionic_src_files_mips64 += bionic/memset.c
-libc_bionic_src_files_mips64 += string/strlen.c
 
 
 libc_crt_target_cflags_mips64 := \
index b024acbf8fd91585bbb20effa511fc6b52d5a514..846bb42621e607ec3332c32d75d2e626fcc7e25f 100644 (file)
@@ -58,15 +58,16 @@ libc_bionic_src_files_x86 += \
     arch-x86/string/strncmp.S \
     arch-x86/string/strcat.S \
     arch-x86/string/memcmp.S \
-    string/memcmp16.c \
-    string/strcpy.c \
-    string/strncat.c \
-    string/strncpy.c \
-    string/strlcat.c \
-    string/strlcpy.c \
+    bionic/__memcmp16.cpp \
     upstream-freebsd/lib/libc/string/wcscpy.c \
     upstream-freebsd/lib/libc/string/wcscat.c \
-    upstream-freebsd/lib/libc/string/wmemcmp.c
+    upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/strcpy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
+
 endif
 
 libc_bionic_src_files_x86 += \
index 44831a6d92afaa1160e0889791bc67d6165bb286..9bce065b3abd76bf54838bb2b85a03bed97406ee 100644 (file)
@@ -1,26 +1,16 @@
 # x86_64 specific configs
 
 libc_common_src_files_x86_64 := \
+    bionic/index.cpp \
     bionic/memchr.c \
     bionic/memcmp.c \
-    bionic/memcpy.c \
+    bionic/memcpy.cpp \
     bionic/memmove.c \
     bionic/memrchr.c \
     bionic/memset.c \
     bionic/strchr.cpp \
     bionic/strnlen.c \
-    string/bcopy.c \
-    string/index.c \
-    string/strcat.c \
-    string/strcmp.c \
-    string/strcpy.c \
-    string/strlcat.c \
-    string/strlcpy.c \
-    string/strlen.c \
-    string/strncat.c \
-    string/strncmp.c \
-    string/strncpy.c \
-    string/strrchr.c \
+    bionic/strrchr.cpp \
     upstream-freebsd/lib/libc/string/wcscat.c \
     upstream-freebsd/lib/libc/string/wcschr.c \
     upstream-freebsd/lib/libc/string/wcscmp.c \
@@ -28,6 +18,16 @@ libc_common_src_files_x86_64 := \
     upstream-freebsd/lib/libc/string/wcslen.c \
     upstream-freebsd/lib/libc/string/wcsrchr.c \
     upstream-freebsd/lib/libc/string/wmemcmp.c \
+    upstream-openbsd/lib/libc/string/bcopy.c \
+    upstream-openbsd/lib/libc/string/strcat.c \
+    upstream-openbsd/lib/libc/string/strcmp.c \
+    upstream-openbsd/lib/libc/string/strcpy.c \
+    upstream-openbsd/lib/libc/string/strlcat.c \
+    upstream-openbsd/lib/libc/string/strlcpy.c \
+    upstream-openbsd/lib/libc/string/strlen.c \
+    upstream-openbsd/lib/libc/string/strncat.c \
+    upstream-openbsd/lib/libc/string/strncmp.c \
+    upstream-openbsd/lib/libc/string/strncpy.c \
 
 # Fortify implementations of libc functions.
 libc_common_src_files_x86_64 += \
@@ -51,8 +51,7 @@ libc_bionic_src_files_x86_64 := \
     arch-x86_64/bionic/sigsetjmp.S \
     arch-x86_64/bionic/syscall.S \
     arch-x86_64/bionic/vfork.S \
-    string/memcmp16.c \
-
+    bionic/__memcmp16.cpp \
 
 libc_crt_target_cflags_x86_64 += \
     -m64 \
similarity index 86%
rename from libc/string/memcmp16.c
rename to libc/bionic/__memcmp16.cpp
index 12677221b5177dfb17d70d764e4f1e88648e1d0c..eb3a08b804272f7cf9d8b819fbf52673823ceb5b 100644 (file)
@@ -30,16 +30,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <stddef.h>
 
-/* Unoptimised version of __memcmp16 */
-int __memcmp16(const unsigned short *ptr1, const unsigned short *ptr2, size_t n)
-{
-  size_t i;
-
-  for (i = 0; i < n; i++) {
-    if (*ptr1 != *ptr2)
-      return *ptr1 - *ptr2;
-    ptr1++;
-    ptr2++;
+// Unoptimized version of __memcmp16.
+extern "C" int __memcmp16(const unsigned short* lhs, const unsigned short* rhs, size_t n) {
+  for (size_t i = 0; i < n; i++) {
+    if (*lhs != *rhs) {
+      return *lhs - *rhs;
+    }
+    lhs++;
+    rhs++;
   }
   return 0;
 }
index 4037207c21cb7c7cc92163c9f0a7f0f5cecc73e2..69198c042aa1bd3d836d34e8654fb58e184f6d26 100644 (file)
@@ -1,4 +1,3 @@
-/*     $OpenBSD: rindex.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
index 5ddc00c69e2a3a7bf85488efacffbcafb0193f77..83171add91c18be9ca76dfac7b670fffca8d841d 100644 (file)
 #include "debug_mapinfo.h"
 #include "private/libc_logging.h"
 
+#if defined(__LP64__)
+#define PAD_PTR "016" PRIxPTR
+#else
+#define PAD_PTR "08" PRIxPTR
+#endif
+
 /* depends how the system includes define this */
 #ifdef HAVE_UNWIND_CONTEXT_STRUCT
 typedef struct _Unwind_Context __unwind_context;
@@ -164,19 +170,14 @@ __LIBC_HIDDEN__ void log_backtrace(uintptr_t* frames, size_t frame_count) {
       const char* best_name = (demangled_symbol != NULL) ? demangled_symbol : symbol;
 
       __libc_format_log(ANDROID_LOG_ERROR, "libc",
-                        "          #%02zd  pc %0*" PRIxPTR "  %s (%s+%" PRIuPTR ")",
-                        i,
-                        static_cast<int>(2 * sizeof(void*)), rel_pc,
-                        soname,
-                        best_name, frames[i] - offset);
+                        "          #%02zd  pc %" PAD_PTR "  %s (%s+%" PRIuPTR ")",
+                        i, rel_pc, soname, best_name, frames[i] - offset);
 
       free(demangled_symbol);
     } else {
       __libc_format_log(ANDROID_LOG_ERROR, "libc",
-                        "          #%02zd  pc %0*" PRIxPTR "  %s",
-                        i,
-                        static_cast<int>(2 * sizeof(void*)), rel_pc,
-                        soname);
+                        "          #%02zd  pc %" PAD_PTR "  %s",
+                        i, rel_pc, soname);
     }
   }
 }
similarity index 63%
rename from libc/bionic/flockfile.c
rename to libc/bionic/flockfile.cpp
index 368fb1582ab36c3c9866eb624379d518221458e7..c60497d3dcbc57f30e1c4b18908d490a94b8b5fe 100644 (file)
  * SUCH DAMAGE.
  */
 
-/* implement flockfile(), ftrylockfile() and funlockfile()
- *
- * we can't use the OpenBSD implementation which uses kernel-specific
- * APIs not available on Linux.
- *
- * Instead, we use a pthread_mutex_t within the FILE* internal state.
- * See fileext.h for details.
- *
- * the behaviour, if fclose() is called while the corresponding
- * file is locked is totally undefined.
- */
-#include <stdio.h>
-#include <string.h>
 #include <errno.h>
+#include <stdio.h>
+
 #include "fileext.h"
 
+// We can't use the OpenBSD implementation which uses kernel-specific
+// APIs not available on Linux. Instead we use a pthread_mutex_t within
+// struct __sfileext (see fileext.h).
 
-void
-flockfile(FILE * fp)
-{
-    if (fp != NULL) {
-        _FLOCK_LOCK(fp);
-    }
+void flockfile(FILE* fp) {
+  if (fp != NULL) {
+    pthread_mutex_lock(&_FLOCK(fp));
+  }
 }
 
+int ftrylockfile(FILE* fp) {
+  // The specification for ftrylockfile() says it returns 0 on success,
+  // or non-zero on error. So return an errno code directly on error.
+  if (fp == NULL) {
+    return EINVAL;
+  }
 
-int
-ftrylockfile(FILE *fp)
-{
-    /* The specification for ftrylockfile() says it returns 0 on success,
-     * or non-zero on error. So return an errno code directly on error.
-     */
-    int  ret = EINVAL;
-
-    if (fp != NULL) {
-        ret = _FLOCK_TRYLOCK(fp);
-    }
-    return ret;
+  return pthread_mutex_trylock(&_FLOCK(fp));
 }
 
-void
-funlockfile(FILE * fp)
-{
-    if (fp != NULL) {
-        _FLOCK_UNLOCK(fp);
-    }
+void funlockfile(FILE* fp) {
+  if (fp != NULL) {
+    pthread_mutex_unlock(&_FLOCK(fp));
+  }
 }
similarity index 88%
rename from libc/string/index.c
rename to libc/bionic/index.cpp
index 81bfba490d3b404b780c2cc9b7fe38467768c5e4..cc22d81fa54649a42e02edab3a4005a18467b0e0 100644 (file)
@@ -1,4 +1,3 @@
-/*     $OpenBSD: index.c,v 1.5 2005/08/08 08:05:37 espie Exp $ */
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
 #include <string.h>
 
-char *
-index(const char *p, int ch)
-{
-       for (;; ++p) {
-               if (*p == (char) ch)
-                       return((char *)p);
-               if (!*p)
-                       return((char *)NULL);
-       }
-       /* NOTREACHED */
+char* index(const char* p, int ch) {
+  return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
 }
similarity index 82%
rename from libc/bionic/memcpy.c
rename to libc/bionic/memcpy.cpp
index dea78b2d9189baab959e19cab58daf81867b38fd..d527e85a36b5ae35f86b6150aa7d0b3f37779922 100644 (file)
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
-#define MEMCOPY
-#include "bcopy.c"
+
+#undef _FORTIFY_SOURCE
+#include <string.h>
+#include <strings.h>
+
+// Our unoptimized memcpy just calls the best bcopy available.
+// (It's this way round rather than the opposite because we're based on BSD source.)
+void* memcpy(void* dst, const void* src, size_t n) {
+  bcopy(src, dst, n);
+  return dst;
+}
index 029fbd9d78e40bfee198695429203452612a9542..5bd3f19f876f5927a4f5eb3a1740015d08a69db4 100644 (file)
@@ -30,6 +30,6 @@
 #undef _FORTIFY_SOURCE
 #include <string.h>
 
-extern "C" char* strchr(const char* p, int ch) {
+char* strchr(const char* p, int ch) {
   return __strchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
 }
similarity index 90%
rename from libc/string/strrchr.c
rename to libc/bionic/strrchr.cpp
index fe2306a263cd67e61ee74abe7878a7b0d9b4a73c..3fdb47caef6151566e5b7f500fee91135b6e956a 100644 (file)
@@ -1,4 +1,3 @@
-/*     $OpenBSD: rindex.c,v 1.6 2005/08/08 08:05:37 espie Exp $ */
 /*
  * Copyright (c) 1988 Regents of the University of California.
  * All rights reserved.
  * SUCH DAMAGE.
  */
 
+#undef _FORTIFY_SOURCE
 #include <string.h>
 
-char *
-strrchr(const char *p, int ch)
-{
-       return __strrchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
+char* strrchr(const char* p, int ch) {
+  return __strrchr_chk(p, ch, __BIONIC_FORTIFY_UNKNOWN_SIZE);
 }
index 37d22c4db39f9b0c4db25fdbddddd89eae92a336..8963e3d0f9d4fc7ead7c5daba9f75314013faa10 100644 (file)
@@ -49,6 +49,7 @@ extern char*  strchr(const char *, int) __purefunc;
 extern char* __strchr_chk(const char *, int, size_t);
 
 extern char*  strrchr(const char *, int) __purefunc;
+extern char* __strrchr_chk(const char *, int, size_t);
 
 extern size_t strlen(const char *) __purefunc;
 extern size_t __strlen_chk(const char *, size_t);
@@ -263,8 +264,6 @@ char* strchr(const char *s, int c) {
     return __strchr_chk(s, c, bos);
 }
 
-extern char* __strrchr_chk(const char *, int, size_t);
-
 __BIONIC_FORTIFY_INLINE
 char* strrchr(const char *s, int c) {
     size_t bos = __bos(s);
index 76ac02c8852c6de56718e36915104e2e44ada8f5..32cf127636a6ae019cc769919d91d6d8e82e5781 100644 (file)
@@ -147,6 +147,9 @@ extern wchar_t          *wmemset(wchar_t *, wchar_t, size_t);
 extern int               wprintf(const wchar_t *, ...);
 extern int               wscanf(const wchar_t *, ...);
 
+extern size_t wcslcat(wchar_t*, const wchar_t*, size_t);
+extern size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
+
 /* No really supported.  These are just for making libstdc++-v3 happy.  */
 typedef void *wctrans_t;
 extern wint_t           towctrans(wint_t, wctrans_t);
index b36a44866712fb31eb704bde9c45cdd46e93ba9d..86419240880f4bf8b45dd493ee11bb45d4401cda 100644 (file)
@@ -52,18 +52,9 @@ do { \
        _UB(fp)._base = NULL; \
        _UB(fp)._size = 0; \
        WCIO_INIT(fp); \
-       _FLOCK_INIT(fp); \
+        _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE; \
 } while (0)
 
-/* Helper macros to avoid a function call when you know that fp is not NULL.
- * Notice that we keep _FLOCK_INIT() fast by slightly breaking our pthread
- * encapsulation.
- */
-#define _FLOCK_INIT(fp)    _FLOCK(fp).value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE
-#define _FLOCK_LOCK(fp)    pthread_mutex_lock(&_FLOCK(fp))
-#define _FLOCK_TRYLOCK(fp) pthread_mutex_trylock(&_FLOCK(fp))
-#define _FLOCK_UNLOCK(fp)  pthread_mutex_unlock(&_FLOCK(fp))
-
 #define _FILEEXT_SETUP(f, fext) \
 do { \
        (f)->_ext._base = (unsigned char *)(fext); \
diff --git a/libc/upstream-freebsd/lib/libc/string/wcslcpy.c b/libc/upstream-freebsd/lib/libc/string/wcslcpy.c
deleted file mode 100644 (file)
index b104a06..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *     from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp
- */
-
-#include <sys/cdefs.h>
-#if 0
-#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: wcslcpy.c,v 1.1 2000/12/23 23:14:36 itojun Exp $");
-#endif /* LIBC_SCCS and not lint */
-#endif
-__FBSDID("$FreeBSD$");
-
-#include <sys/types.h>
-#include <wchar.h>
-
-/*
- * Copy src to string dst of size siz.  At most siz-1 characters
- * will be copied.  Always NUL terminates (unless siz == 0).
- * Returns wcslen(src); if retval >= siz, truncation occurred.
- */
-size_t
-wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
-{
-       wchar_t *d = dst;
-       const wchar_t *s = src;
-       size_t n = siz;
-
-       /* Copy as many bytes as will fit */
-       if (n != 0 && --n != 0) {
-               do {
-                       if ((*d++ = *s++) == 0)
-                               break;
-               } while (--n != 0);
-       }
-
-       /* Not enough room in dst, add NUL and traverse rest of src */
-       if (n == 0) {
-               if (siz != 0)
-                       *d = '\0';              /* NUL-terminate dst */
-               while (*s++)
-                       ;
-       }
-
-       return(s - src - 1);    /* count does not include NUL */
-}
diff --git a/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c b/libc/upstream-openbsd/lib/libc/locale/wcsxfrm.c
new file mode 100644 (file)
index 0000000..98db4a9
--- /dev/null
@@ -0,0 +1,42 @@
+/*     $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $ */
+/*     $OpenBSD: wcsxfrm.c,v 1.2 2012/12/05 23:20:00 deraadt Exp $     */
+/*     $NetBSD: multibyte_sb.c,v 1.4 2003/08/07 16:43:04 agc Exp $     */
+
+/*
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <wchar.h>
+
+size_t 
+wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n)
+{
+       if (n == 0)
+               return wcslen(src);
+       return wcslcpy(dest, src, n);
+}
similarity index 92%
rename from libc/unistd/system.c
rename to libc/upstream-openbsd/lib/libc/stdlib/system.c
index 72cc37e41d0e52e4abe4b045bf6b18ccf3ab1d6b..14ddcae8d3ee8b3eb1057d75f2477b5d7266b68d 100644 (file)
  */
 
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <paths.h>
-#include <sys/wait.h>
 
 extern char **environ;
 
 int
 system(const char *command)
 {
-  pid_t pid;
+       pid_t pid;
        sig_t intsave, quitsave;
        sigset_t mask, omask;
        int pstat;
@@ -61,14 +61,14 @@ system(const char *command)
        case 0:                         /* child */
                sigprocmask(SIG_SETMASK, &omask, NULL);
                execve(_PATH_BSHELL, argp, environ);
-    _exit(127);
-  }
+               _exit(127);
+       }
 
-       intsave = (sig_t)  bsd_signal(SIGINT, SIG_IGN);
-       quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
+       intsave = signal(SIGINT, SIG_IGN);
+       quitsave = signal(SIGQUIT, SIG_IGN);
        pid = waitpid(pid, (int *)&pstat, 0);
        sigprocmask(SIG_SETMASK, &omask, NULL);
-       (void)bsd_signal(SIGINT, intsave);
-       (void)bsd_signal(SIGQUIT, quitsave);
+       (void)signal(SIGINT, intsave);
+       (void)signal(SIGQUIT, quitsave);
        return (pid == -1 ? -1 : pstat);
 }
similarity index 89%
rename from libc/string/strcpy.c
rename to libc/upstream-openbsd/lib/libc/string/strcpy.c
index eb21d678032dbb17ea08ca99b4da342f18e922ca..71d90d41002d78538272ff969811da193f94d6ed 100644 (file)
  * SUCH DAMAGE.
  */
 
+#if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <string.h>
+#else
+#include <lib/libkern/libkern.h>
+#endif
+
+#if defined(APIWARN)
+__warn_references(strcpy,
+    "warning: strcpy() is almost always misused, please use strlcpy()");
+#endif
 
 char *
 strcpy(char *to, const char *from)
similarity index 99%
rename from libc/string/strncmp.c
rename to libc/upstream-openbsd/lib/libc/string/strncmp.c
index 17688084b86118d4b42bbfde8a6dcd48e2cf1332..0aea80d7d90697ebe53002cc17cf46c6e98891da 100644 (file)
@@ -38,6 +38,7 @@
 int
 strncmp(const char *s1, const char *s2, size_t n)
 {
+
        if (n == 0)
                return (0);
        do {
diff --git a/libc/upstream-openbsd/lib/libc/string/wcslcpy.c b/libc/upstream-openbsd/lib/libc/string/wcslcpy.c
new file mode 100644 (file)
index 0000000..f49936a
--- /dev/null
@@ -0,0 +1,52 @@
+/*     $OpenBSD: wcslcpy.c,v 1.5 2011/07/24 15:21:28 millert Exp $     */
+/*     $NetBSD: wcslcpy.c,v 1.2 2001/01/03 14:33:02 lukem Exp $        */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <wchar.h>
+
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns wcslen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
+{
+       wchar_t *d = dst;
+       const wchar_t *s = src;
+       size_t n = siz;
+
+       /* Copy as many bytes as will fit */
+       if (n != 0) {
+               while (--n != 0) {
+                       if ((*d++ = *s++) == '\0')
+                               break;
+               }
+       }
+
+       /* Not enough room in dst, add NUL and traverse rest of src */
+       if (n == 0) {
+               if (siz != 0)
+                       *d = '\0';              /* NUL-terminate dst */
+               while (*s++)
+                       ;
+       }
+
+       return(s - src - 1);    /* count does not include NUL */
+}
diff --git a/libc/upstream-openbsd/lib/libc/string/wcswidth.c b/libc/upstream-openbsd/lib/libc/string/wcswidth.c
new file mode 100644 (file)
index 0000000..8ea1bdf
--- /dev/null
@@ -0,0 +1,50 @@
+/*     $OpenBSD: wcswidth.c,v 1.4 2011/04/04 18:16:24 stsp Exp $       */
+/*     $NetBSD: wcswidth.c,v 1.2 2001/01/03 14:29:37 lukem Exp $       */
+
+/*-
+ * Copyright (c)1999 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     citrus Id: wcswidth.c,v 1.1 1999/12/29 21:47:45 tshiozak Exp
+ */
+
+#include <wchar.h>
+
+int
+wcswidth(const wchar_t *s, size_t n)
+{
+       int w, q;
+
+       w = 0;
+       while (n && *s) {
+               q = wcwidth(*s);
+               if (q == -1)
+                       return (-1);
+               w += q;
+               s++;
+               n--;
+       }
+
+       return w;
+}
diff --git a/libc/wchar/wcswidth.c b/libc/wchar/wcswidth.c
deleted file mode 100644 (file)
index b142074..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- *     The Regents of the University of California.  All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * This code is derived from software contributed to Berkeley by
- * Paul Borman at Krystal Technologies.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <wchar.h>
-
-int
-wcswidth(const wchar_t *pwcs, size_t n)
-{
-       wchar_t wc;
-       int len, l;
-
-       len = 0;
-       while (n-- > 0 && (wc = *pwcs++) != L'\0') {
-               if ((l = wcwidth(wc)) < 0)
-                       return (-1);
-               len += l;
-       }
-       return (len);
-}
-
diff --git a/libc/wchar/wcsxfrm.c b/libc/wchar/wcsxfrm.c
deleted file mode 100644 (file)
index 042ea56..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
- *             at Electronni Visti IA, Kiev, Ukraine.
- *                     All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <wchar.h>
-
-/*
- * Placeholder wcsxfrm() implementation. See wcscoll.c for a description of
- * the logic used.
- */
-size_t
-wcsxfrm(wchar_t * __restrict dest, const wchar_t * __restrict src, size_t len)
-{
-    int prim, sec, l;
-    size_t slen;
-    char *mbsrc, *s, *ss;
-
-    if (*src == L'\0') {
-        if (len != 0)
-            *dest = L'\0';
-        return (0);
-    }
-
-    slen = wcslen(src);
-    if (len > 0) {
-        if (slen < len)
-            wcscpy(dest, src);
-        else {
-            wcsncpy(dest, src, len - 1);
-            dest[len - 1] = L'\0';
-        }
-    }
-    return (slen);
-}