summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extra/locale/Makefile.in3
-rw-r--r--extra/locale/gen_collate.c2
-rw-r--r--extra/locale/gen_wc8bit.c2
-rw-r--r--extra/locale/gen_wctype.c783
-rw-r--r--extra/locale/locale_mmap.h32
-rw-r--r--extra/locale/programs/locale.c1
-rwxr-xr-xextra/scripts/install_headers.sh19
-rw-r--r--ldso/ldso/dl-symbols.c4
-rw-r--r--libc/inet/ether_addr.c52
-rw-r--r--libc/inet/getaddrinfo.c5
-rw-r--r--libc/inet/hostid.c16
-rw-r--r--libc/inet/ntop.c86
-rw-r--r--libc/misc/fnmatch/fnmatch_old.c2
-rw-r--r--libc/misc/ftw/ftw.c6
-rw-r--r--libc/misc/locale/locale.c66
-rw-r--r--libc/misc/regex/regex_old.c57
-rw-r--r--libc/misc/wchar/wchar.c20
-rw-r--r--libc/misc/wctype/_wctype.c45
-rw-r--r--libc/stdio/_scanf.c35
-rw-r--r--libc/stdio/_vfprintf.c15
-rw-r--r--libc/stdio/_wfwrite.c4
-rw-r--r--libc/stdio/fgetwc.c8
-rw-r--r--libc/stdio/vswprintf.c6
-rw-r--r--libc/string/generic/bp-checks.h129
-rw-r--r--libc/string/generic/memcmp.c17
-rw-r--r--libc/string/generic/strcpy.c28
-rw-r--r--libc/string/i386/memchr.c50
-rw-r--r--libc/string/i386/memcpy.c6
-rw-r--r--libc/string/i386/memmove.c52
-rw-r--r--libc/string/i386/memset.c1
-rw-r--r--libc/string/i386/strchr.c32
-rw-r--r--libc/string/i386/strcpy.c2
-rw-r--r--libc/string/i386/strlen.c20
-rw-r--r--libc/string/i386/strncat.c73
-rw-r--r--libc/string/i386/strncmp.c41
-rw-r--r--libc/string/i386/strncpy.c55
-rw-r--r--libc/string/i386/strnlen.c51
-rw-r--r--libc/string/i386/strrchr.c29
-rw-r--r--libc/string/ia64/memchr.S8
-rw-r--r--libc/string/memchr.c1
-rw-r--r--libc/string/memcpy.c1
-rw-r--r--libc/string/mempcpy.c1
-rw-r--r--libc/string/memset.c2
-rw-r--r--libc/string/sparc/sparc32/memchr.S2
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_charclass.h40
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_ctype.h75
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_locale.h4
-rw-r--r--libc/sysdeps/linux/common/capset.c2
-rw-r--r--libc/sysdeps/linux/common/cmsg_nxthdr.c2
-rw-r--r--libc/sysdeps/linux/common/getpgrp.c14
-rw-r--r--libc/sysdeps/linux/mips/pread_write.c8
-rw-r--r--libc/sysdeps/linux/x86_64/brk.c13
52 files changed, 921 insertions, 1107 deletions
diff --git a/extra/locale/Makefile.in b/extra/locale/Makefile.in
index b4801b04b..66e14fba9 100644
--- a/extra/locale/Makefile.in
+++ b/extra/locale/Makefile.in
@@ -15,8 +15,7 @@ LOCALE_DATA_FILENAME := uClibc-locale-20081111-$(ARCH_NATIVE_BIT)-$(if $(ARCH_LI
BUILD_CFLAGS-locale-common := \
-D__UCLIBC_GEN_LOCALE \
- -I$(top_builddir) \
- -DUCLIBC_CTYPE_HEADER='"include/bits/uClibc_ctype.h"'
+ -I$(top_builddir)
BUILD_CFLAGS-gen_wc8bit := $(BUILD_CFLAGS-locale-common) -DCTYPE_PACKED=1
BUILD_CFLAGS-gen_wctype := $(BUILD_CFLAGS-locale-common)
diff --git a/extra/locale/gen_collate.c b/extra/locale/gen_collate.c
index 44f6215b6..15582c1ba 100644
--- a/extra/locale/gen_collate.c
+++ b/extra/locale/gen_collate.c
@@ -3993,5 +3993,5 @@ static void dump_collate(FILE *fp)
fprintf(fp,"}; /* %8lu */\n", collate_pos);
- fprintf(fp,"#define __lc_collate_data_LEN %d\n\n", collate_pos);
+ fprintf(fp,"#define __lc_collate_data_LEN %lu\n\n", collate_pos);
}
diff --git a/extra/locale/gen_wc8bit.c b/extra/locale/gen_wc8bit.c
index 2fdcb6881..418a1ac9d 100644
--- a/extra/locale/gen_wc8bit.c
+++ b/extra/locale/gen_wc8bit.c
@@ -18,7 +18,7 @@
#ifndef _WCTYPE_H
#define _WCTYPE_H
#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_ctype.h"
/* #define CTYPE_PACKED */
diff --git a/extra/locale/gen_wctype.c b/extra/locale/gen_wctype.c
index a0542e609..fde30a0a5 100644
--- a/extra/locale/gen_wctype.c
+++ b/extra/locale/gen_wctype.c
@@ -14,13 +14,7 @@
#include <wchar.h>
#include <ctype.h>
-#ifndef _CTYPE_H
-#define _CTYPE_H
-#endif
-#ifndef _WCTYPE_H
-#define _WCTYPE_H
-#endif
-#include UCLIBC_CTYPE_HEADER
+#include "include/bits/uClibc_charclass.h"
/* 0x9 : space blank */
/* 0xa : space */
@@ -62,7 +56,6 @@
/* typecount[15] = 0 empty_slot */
-
/* Set to #if 0 to restrict wchars to 16 bits. */
#if 1
#define RANGE 0x2ffffUL
@@ -72,74 +65,22 @@
#define RANGE 0xffffUL /* Restrict for 16-bit wchar_t... */
#endif
-#if 0
-/* Classification codes. */
-
-static const char *typename[] = {
- "C_unclassified",
- "C_alpha_nonupper_nonlower",
- "C_alpha_lower",
- "C_alpha_upper_lower",
- "C_alpha_upper",
- "C_digit",
- "C_punct",
- "C_graph",
- "C_print_space_nonblank",
- "C_print_space_blank",
- "C_space_nonblank_noncntrl",
- "C_space_blank_noncntrl",
- "C_cntrl_space_nonblank",
- "C_cntrl_space_blank",
- "C_cntrl_nonspace",
- "empty_slot"
-};
-#endif
-
-#if 0
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace,
-};
-#endif
-
-#define __CTYPE_isxdigit(D,X) \
- (__CTYPE_isdigit(D) || (((unsigned int)(((X)|0x20) - 'a')) <= 5))
-
-#define mywalnum(x) __CTYPE_isalnum(d)
-#define mywalpha(x) __CTYPE_isalpha(d)
-#define mywblank(x) __CTYPE_isblank(d)
-#define mywcntrl(x) __CTYPE_iscntrl(d)
-#define mywdigit(x) __CTYPE_isdigit(d)
-#define mywgraph(x) __CTYPE_isgraph(d)
-#define mywlower(x) __CTYPE_islower(d)
-#define mywprint(x) __CTYPE_isprint(d)
-#define mywpunct(x) __CTYPE_ispunct(d)
-#define mywspace(x) __CTYPE_isspace(d)
-#define mywupper(x) __CTYPE_isupper(d)
-#define mywxdigit(x) __CTYPE_isxdigit(d,x)
+/* Some macros that test for various (w)ctype classes when passed one of the
+ * designator values enumerated above. */
+#define mywalnum(D,C) ((unsigned)(D - 1) <= (__CTYPE_digit - 1))
+#define mywalpha(D,C) ((unsigned)(D - 1) <= (__CTYPE_alpha_upper - 1))
+#define mywblank(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5 && (D & 1))
+#define mywcntrl(D,C) ((unsigned)(D - __CTYPE_cntrl_space_nonblank) <= 2)
+#define mywdigit(D,C) (D == __CTYPE_digit)
+#define mywgraph(D,C) ((unsigned)(D - 1) <= (__CTYPE_graph - 1))
+#define mywlower(D,C) ((unsigned)(D - __CTYPE_alpha_lower) <= 1)
+#define mywprint(D,C) ((unsigned)(D - 1) <= (__CTYPE_print_space_blank - 1))
+#define mywpunct(D,C) (D == __CTYPE_punct)
+#define mywspace(D,C) ((unsigned)(D - __CTYPE_print_space_nonblank) <= 5)
+#define mywupper(D,C) ((unsigned)(D - __CTYPE_alpha_upper_lower) <= 1)
+/* #define mywxdigit(D,C) -- isxdigit is untestable this way.
+ * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
+#define mywxdigit(D,C) (mywdigit(D,C) || (unsigned)(((C) | 0x20) - 'a') <= 5)
typedef struct {
short l;
@@ -177,19 +118,19 @@ void output_table(FILE *fp, const char *name, table_data *tbl)
i = tbl->ii_len + tbl->ti_len + tbl->ut_len;
fprintf(fp, "\nstatic const unsigned char __LOCALE_DATA_WC%s_data[%zu] = {", name, i);
- for (i=0 ; i < tbl->ii_len ; i++) {
+ for (i = 0; i < tbl->ii_len; i++) {
if (i % 12 == 0) {
fprintf(fp, "\n");
}
fprintf(fp, " %#04x,", tbl->ii[i]);
}
- for (i=0 ; i < tbl->ti_len ; i++) {
+ for (i = 0; i < tbl->ti_len; i++) {
if (i % 12 == 0) {
fprintf(fp, "\n");
}
fprintf(fp, " %#04x,", tbl->ti[i]);
}
- for (i=0 ; i < tbl->ut_len ; i++) {
+ for (i = 0; i < tbl->ut_len; i++) {
if (i % 12 == 0) {
fprintf(fp, "\n");
}
@@ -252,7 +193,7 @@ int main(int argc, char **argv)
#define INIT_TYPENAME(X) typename[__CTYPE_##X] = "C_" #X
- for (i=0 ; i < 16 ; i++) {
+ for (i = 0; i < 16; i++) {
typename[i] = empty_slot;
}
@@ -275,8 +216,8 @@ int main(int argc, char **argv)
memset(&cttable, 0, sizeof(table_data));
memset(&ultable, 0, sizeof(table_data));
#if 0
- memset(combtable, 0, sizeof table_data);
- memset(widthtable, 0, sizeof table_data);
+ memset(combtable, 0, sizeof(table_data));
+ memset(widthtable, 0, sizeof(table_data));
#endif
setvbuf(stdout, NULL, _IONBF, 0);
@@ -285,7 +226,8 @@ int main(int argc, char **argv)
if (!strcmp(*argv, "-v")) {
++verbose;
continue;
- } else if (!setlocale(LC_CTYPE, *argv)) {
+ }
+ if (!setlocale(LC_CTYPE, *argv)) {
verbose_msg("setlocale(LC_CTYPE,%s) failed! Skipping this locale...\n", *argv);
continue;
}
@@ -301,324 +243,316 @@ int main(int argc, char **argv)
}
if (!built) {
- built = 1;
- ul_count = 1;
- uldiff[0].u = uldiff[0].l = 0;
+ built = 1;
+ ul_count = 1;
+ uldiff[0].u = uldiff[0].l = 0;
- memset(wct, 0, sizeof(wct));
- memset(combt, 0, sizeof(combt));
- memset(widtht, 0, sizeof(widtht));
+ memset(wct, 0, sizeof(wct));
+ memset(combt, 0, sizeof(combt));
+ memset(widtht, 0, sizeof(widtht));
- for (i = 0 ; i < 16 ; i++) {
- typecount[i] = 0;
- }
+ for (i = 0; i < 16; i++) {
+ typecount[i] = 0;
+ }
- for (c=0 ; c <= RANGE ; c++) {
- if (iswdigit(c)) {
- d = __CTYPE_digit;
- } else if (iswalpha(c)) {
- d = __CTYPE_alpha_nonupper_nonlower;
- if (iswlower(c)) {
- d = __CTYPE_alpha_lower;
- if (iswupper(c)) {
- d = __CTYPE_alpha_upper_lower;
+ for (c = 0; c <= RANGE; c++) {
+ if (iswdigit(c)) {
+ d = __CTYPE_digit;
+ } else if (iswalpha(c)) {
+ d = __CTYPE_alpha_nonupper_nonlower;
+ if (iswlower(c)) {
+ d = __CTYPE_alpha_lower;
+ if (iswupper(c)) {
+ d = __CTYPE_alpha_upper_lower;
+ }
+ } else if (iswupper(c)) {
+ d = __CTYPE_alpha_upper;
}
- } else if (iswupper(c)) {
- d = __CTYPE_alpha_upper;
- }
- } else if (iswpunct(c)) {
- d = __CTYPE_punct;
- } else if (iswgraph(c)) {
- d = __CTYPE_graph;
- } else if (iswprint(c)) {
- d = __CTYPE_print_space_nonblank;
- if (iswblank(c)) {
- d = __CTYPE_print_space_blank;
- }
- } else if (iswspace(c) && !iswcntrl(c)) {
- d = __CTYPE_space_nonblank_noncntrl;
- if (iswblank(c)) {
- d = __CTYPE_space_blank_noncntrl;
- }
- } else if (iswcntrl(c)) {
- d = __CTYPE_cntrl_nonspace;
- if (iswspace(c)) {
- d = __CTYPE_cntrl_space_nonblank;
+ } else if (iswpunct(c)) {
+ d = __CTYPE_punct;
+ } else if (iswgraph(c)) {
+ d = __CTYPE_graph;
+ } else if (iswprint(c)) {
+ d = __CTYPE_print_space_nonblank;
if (iswblank(c)) {
- d = __CTYPE_cntrl_space_blank;
+ d = __CTYPE_print_space_blank;
+ }
+ } else if (iswspace(c) && !iswcntrl(c)) {
+ d = __CTYPE_space_nonblank_noncntrl;
+ if (iswblank(c)) {
+ d = __CTYPE_space_blank_noncntrl;
+ }
+ } else if (iswcntrl(c)) {
+ d = __CTYPE_cntrl_nonspace;
+ if (iswspace(c)) {
+ d = __CTYPE_cntrl_space_nonblank;
+ if (iswblank(c)) {
+ d = __CTYPE_cntrl_space_blank;
+ }
}
+ } else {
+ d = __CTYPE_unclassified;
}
- } else {
- d = __CTYPE_unclassified;
- }
-
- ++typecount[d];
+ ++typecount[d];
#if 0
- if (iswspace(c)) {
- if (iswblank(c)) {
- verbose_msg("%#8x : space blank\n", c);
- } else {
- verbose_msg("%#8x : space\n", c);
+ if (iswspace(c)) {
+ if (iswblank(c)) {
+ verbose_msg("%#8x : space blank\n", c);
+ } else {
+ verbose_msg("%#8x : space\n", c);
+ }
}
- }
#endif
-
#if 0
- if (c < 256) {
- unsigned int glibc;
-
- glibc = 0;
- if (isalnum(c)) ++glibc; glibc <<= 1;
- if (isalpha(c)) ++glibc; glibc <<= 1;
- if (isblank(c)) ++glibc; glibc <<= 1;
- if (iscntrl(c)) ++glibc; glibc <<= 1;
- if (isdigit(c)) ++glibc; glibc <<= 1;
- if (isgraph(c)) ++glibc; glibc <<= 1;
- if (islower(c)) ++glibc; glibc <<= 1;
- if (isprint(c)) ++glibc; glibc <<= 1;
- if (ispunct(c)) ++glibc; glibc <<= 1;
- if (isspace(c)) ++glibc; glibc <<= 1;
- if (isupper(c)) ++glibc; glibc <<= 1;
- if (isxdigit(c)) ++glibc;
- verbose_msg("%#8x : ctype %#4x\n", c, glibc);
- }
+ if (c < 256) {
+ unsigned int glibc;
+
+ glibc = 0;
+ if (isalnum(c)) ++glibc; glibc <<= 1;
+ if (isalpha(c)) ++glibc; glibc <<= 1;
+ if (isblank(c)) ++glibc; glibc <<= 1;
+ if (iscntrl(c)) ++glibc; glibc <<= 1;
+ if (isdigit(c)) ++glibc; glibc <<= 1;
+ if (isgraph(c)) ++glibc; glibc <<= 1;
+ if (islower(c)) ++glibc; glibc <<= 1;
+ if (isprint(c)) ++glibc; glibc <<= 1;
+ if (ispunct(c)) ++glibc; glibc <<= 1;
+ if (isspace(c)) ++glibc; glibc <<= 1;
+ if (isupper(c)) ++glibc; glibc <<= 1;
+ if (isxdigit(c)) ++glibc;
+ verbose_msg("%#8x : ctype %#4x\n", c, glibc);
+ }
#endif
-
#if 1
- /* Paranoid checking... */
- {
- unsigned int glibc;
- unsigned int mine;
-
- glibc = 0;
- if (iswalnum(c)) ++glibc; glibc <<= 1;
- if (iswalpha(c)) ++glibc; glibc <<= 1;
- if (iswblank(c)) ++glibc; glibc <<= 1;
- if (iswcntrl(c)) ++glibc; glibc <<= 1;
- if (iswdigit(c)) ++glibc; glibc <<= 1;
- if (iswgraph(c)) ++glibc; glibc <<= 1;
- if (iswlower(c)) ++glibc; glibc <<= 1;
- if (iswprint(c)) ++glibc; glibc <<= 1;
- if (iswpunct(c)) ++glibc; glibc <<= 1;
- if (iswspace(c)) ++glibc; glibc <<= 1;
- if (iswupper(c)) ++glibc; glibc <<= 1;
- if (iswxdigit(c)) ++glibc;
-
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d);
- return EXIT_FAILURE;
- }
-
+ /* Paranoid checking... */
+ {
+ unsigned int glibc;
+ unsigned int mine;
+
+ glibc = 0;
+ if (iswalnum(c)) ++glibc; glibc <<= 1;
+ if (iswalpha(c)) ++glibc; glibc <<= 1;
+ if (iswblank(c)) ++glibc; glibc <<= 1;
+ if (iswcntrl(c)) ++glibc; glibc <<= 1;
+ if (iswdigit(c)) ++glibc; glibc <<= 1;
+ if (iswgraph(c)) ++glibc; glibc <<= 1;
+ if (iswlower(c)) ++glibc; glibc <<= 1;
+ if (iswprint(c)) ++glibc; glibc <<= 1;
+ if (iswpunct(c)) ++glibc; glibc <<= 1;
+ if (iswspace(c)) ++glibc; glibc <<= 1;
+ if (iswupper(c)) ++glibc; glibc <<= 1;
+ if (iswxdigit(c)) ++glibc;
+
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (glibc != mine) {
+ verbose_msg("%#8x : glibc %#4x != %#4x mine %u\n", c, glibc, mine, d);
+ return EXIT_FAILURE;
+ }
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
-/* if (!iswpunct(c)) { */
- verbose_msg("%#8x : %d %d %#4x\n",
- c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc);
-/* } */
- }
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+/* if (!iswpunct(c)) { */
+ verbose_msg("%#8x : %d %d %#4x\n",
+ c, iswctype(c,is_comb),iswctype(c,is_comb3), glibc);
+/* } */
+ }
#endif
#if 0
- if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
- if (!last_comb) {
- verbose_msg("%#8x - ", c);
- last_comb = c;
- } else if (last_comb + 1 < c) {
- verbose_msg("%#8x\n%#8x - ", last_comb, c);
- last_comb = c;
- } else {
- last_comb = c;
+ if (iswctype(c,is_comb) || iswctype(c,is_comb3)) {
+ if (!last_comb) {
+ verbose_msg("%#8x - ", c);
+ last_comb = c;
+ } else if (last_comb + 1 < c) {
+ verbose_msg("%#8x\n%#8x - ", last_comb, c);
+ last_comb = c;
+ } else {
+ last_comb = c;
+ }
}
- }
#endif
- }
+ }
#endif
- combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
+ combt[c/4] |= ((((!!iswctype(c,is_comb)) << 1) | !!iswctype(c,is_comb3))
<< ((c & 3) << 1));
-/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
+/* comb3t[c/8] |= ((!!iswctype(c,is_comb3)) << (c & 7)); */
-/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
+/* widtht[c/4] |= (wcwidth(c) << ((c & 3) << 1)); */
- if (c & 1) { /* Use the high nibble for odd numbered wchars. */
- d <<= 4;
- }
- wct[c/2] |= d;
-
- l = (long)(int) towlower(c) - c;
- u = (long)(int) towupper(c) - c;
- ult[c] = 0;
- if (l || u) {
- if ((l != (short)l) || (u != (short)u)) {
- verbose_msg("range assumption error! %x %ld %ld\n", c, l, u);
- return EXIT_FAILURE;
+ if (c & 1) { /* Use the high nibble for odd numbered wchars. */
+ d <<= 4;
}
- for (i=0 ; i < ul_count ; i++) {
- if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
- goto found;
+ wct[c/2] |= d;
+
+ l = (long)(int) towlower(c) - c;
+ u = (long)(int) towupper(c) - c;
+ ult[c] = 0;
+ if (l || u) {
+ if ((l != (short)l) || (u != (short)u)) {
+ verbose_msg("range assumption error! %x %ld %ld\n", c, l, u);
+ return EXIT_FAILURE;
}
+ for (i = 0; i < ul_count; i++) {
+ if ((l == uldiff[i].l) && (u == uldiff[i].u)) {
+ goto found;
+ }
+ }
+ uldiff[ul_count].l = l;
+ uldiff[ul_count].u = u;
+ ++ul_count;
+ if (ul_count > MAXTO) {
+ verbose_msg("too many touppers/tolowers!\n");
+ return EXIT_FAILURE;
+ }
+ found:
+ ult[c] = i;
}
- uldiff[ul_count].l = l;
- uldiff[ul_count].u = u;
- ++ul_count;
- if (ul_count > MAXTO) {
- verbose_msg("too many touppers/tolowers!\n");
- return EXIT_FAILURE;
- }
- found:
- ult[c] = i;
}
- }
- for (i = 0 ; i < 16 ; i++) {
- verbose_msg("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
- }
-
- verbose_msg("optimizing is* table..\n");
- n = -1;
- smallest = SIZE_MAX;
- cttable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(wct, (RANGE/2)+1, i, &cttable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ for (i = 0; i < 16; i++) {
+ verbose_msg("typecount[%2d] = %8ld %s\n", i, typecount[i], typename[i]);
}
- }
- verbose_msg("smallest = %zu\n", smallest);
- if (!(cttable.ii = malloc(smallest))) {
- verbose_msg("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(wct, (RANGE/2)+1, n, &cttable);
- ++cttable.ti_shift; /* correct for nibble mode */
-
-
- verbose_msg("optimizing u/l-to table..\n");
- smallest = SIZE_MAX;
- ultable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(ult, RANGE+1, i, &ultable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing is* table..\n");
+ n = -1;
+ smallest = SIZE_MAX;
+ cttable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(wct, (RANGE/2)+1, i, &cttable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- verbose_msg("%zu (smallest) + %zu (u/l diffs) = %zu\n",
- smallest, 4 * ul_count, smallest + 4 * ul_count);
- verbose_msg("smallest = %zu\n", smallest);
- if (!(ultable.ii = malloc(smallest))) {
- verbose_msg("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(ult, RANGE+1, n, &ultable);
-
-
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(cttable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(wct, (RANGE/2)+1, n, &cttable);
+ ++cttable.ti_shift; /* correct for nibble mode */
+
+ verbose_msg("optimizing u/l-to table..\n");
+ smallest = SIZE_MAX;
+ ultable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(ult, RANGE+1, i, &ultable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
+ }
+ verbose_msg("%lu (smallest) + %lu (u/l diffs) = %lu\n",
+ (unsigned long) smallest,
+ (unsigned long) (4 * ul_count),
+ (unsigned long) (smallest + 4 * ul_count)
+ );
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(ultable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(ult, RANGE+1, n, &ultable);
#if 0
- verbose_msg("optimizing comb table..\n");
- smallest = SIZE_MAX;
- combtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(combt, sizeof(combt), i, &combtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb table..\n");
+ smallest = SIZE_MAX;
+ combtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(combt, sizeof(combt), i, &combtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- verbose_msg("smallest = %zu\n", smallest);
- if (!(combtable.ii = malloc(smallest))) {
- verbose_msg("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(combt, sizeof(combt), n, &combtable);
- combtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(combtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(combt, sizeof(combt), n, &combtable);
+ combtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
-
#if 0
- verbose_msg("optimizing width table..\n");
- smallest = SIZE_MAX;
- widthtable.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(widtht, sizeof(widtht), i, &widthtable);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing width table..\n");
+ smallest = SIZE_MAX;
+ widthtable.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(widtht, sizeof(widtht), i, &widthtable);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- verbose_msg("smallest = %zu\n", smallest);
- if (!(widthtable.ii = malloc(smallest))) {
- verbose_msg("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(widtht, sizeof(widtht), n, &widthtable);
- widthtable.ti_shift += 4; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(widthtable.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(widtht, sizeof(widtht), n, &widthtable);
+ widthtable.ti_shift += 4; /* correct for 4 entries per */
#endif
-
#if 0
- verbose_msg("optimizing comb3 table..\n");
- smallest = SIZE_MAX;
- comb3table.ii = NULL;
- for (i=0 ; i < 14 ; i++) {
- t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
- if (smallest >= t) {
- n = i;
- smallest = t;
-/* } else { */
-/* break; */
+ verbose_msg("optimizing comb3 table..\n");
+ smallest = SIZE_MAX;
+ comb3table.ii = NULL;
+ for (i = 0; i < 14; i++) {
+ t = newopt(comb3t, sizeof(comb3t), i, &comb3table);
+ if (smallest >= t) {
+ n = i;
+ smallest = t;
+/* } else { */
+/* break; */
+ }
}
- }
- verbose_msg("smallest = %zu\n", smallest);
- if (!(comb3table.ii = malloc(smallest))) {
- verbose_msg("couldn't allocate space!\n");
- return EXIT_FAILURE;
- }
- smallest = SIZE_MAX;
- newopt(comb3t, sizeof(comb3t), n, &comb3table);
- comb3table.ti_shift += 8; /* correct for 4 entries per */
+ verbose_msg("smallest = %zu\n", smallest);
+ if (!(comb3table.ii = malloc(smallest))) {
+ verbose_msg("couldn't allocate space!\n");
+ return EXIT_FAILURE;
+ }
+ smallest = SIZE_MAX;
+ newopt(comb3t, sizeof(comb3t), n, &comb3table);
+ comb3table.ti_shift += 8; /* correct for 4 entries per */
#endif
- dump_table_data(&cttable);
- dump_table_data(&ultable);
+ dump_table_data(&cttable);
+ dump_table_data(&ultable);
#if 0
- dump_table_data(&combtable);
+ dump_table_data(&combtable);
#endif
}
verbose_msg("verifying for %s...\n", *argv);
#if RANGE == 0xffffU
- for (c=0 ; c <= 0xffffUL ; c++)
+ for (c = 0; c <= 0xffffUL; c++)
#else
- for (c=0 ; c <= 0x10ffffUL ; c++)
+ for (c = 0; c <= 0x10ffffUL; c++)
#endif
- {
+ {
unsigned int glibc;
unsigned int mine;
unsigned int upper, lower;
@@ -634,7 +568,6 @@ int main(int argc, char **argv)
}
#endif
#endif
-
glibc = 0;
if (iswalnum(c)) ++glibc; glibc <<= 1;
if (iswalpha(c)) ++glibc; glibc <<= 1;
@@ -651,8 +584,8 @@ int main(int argc, char **argv)
{
unsigned int u;
- int n, sc;
- int i0, i1;
+ int n = 0, sc = 0; /* = 0 for verbose_msg only */
+ int i0 = 0, i1 = 0;
u = c;
if (u <= RANGE) {
@@ -664,16 +597,16 @@ int main(int argc, char **argv)
i0 = cttable.ii[u];
i0 <<= cttable.ii_shift;
i1 = cttable.ti[i0 + n];
- i1 <<= (cttable.ti_shift-1);
+ i1 <<= (cttable.ti_shift - 1);
d = cttable.ut[i1 + (sc >> 1)];
if (sc & 1) {
d >>= 4;
}
d &= 0x0f;
- } else if ((((unsigned int)(c - 0xe0020UL)) <= 0x5f) || (c == 0xe0001UL)){
+ } else if (((unsigned)(c - 0xe0020UL) <= 0x5f) || (c == 0xe0001UL)) {
d = __CTYPE_punct;
- } else if (((unsigned int)(c - 0xf0000UL)) < 0x20000UL) {
+ } else if ((unsigned)(c - 0xf0000UL) < 0x20000UL) {
if ((c & 0xffffU) <= 0xfffdU) {
d = __CTYPE_punct;
} else {
@@ -683,26 +616,27 @@ int main(int argc, char **argv)
d = __CTYPE_unclassified;
}
- mine = 0;
- if (mywalnum(c)) ++mine; mine <<= 1;
- if (mywalpha(c)) ++mine; mine <<= 1;
- if (mywblank(c)) ++mine; mine <<= 1;
- if (mywcntrl(c)) ++mine; mine <<= 1;
- if (mywdigit(c)) ++mine; mine <<= 1;
- if (mywgraph(c)) ++mine; mine <<= 1;
- if (mywlower(c)) ++mine; mine <<= 1;
- if (mywprint(c)) ++mine; mine <<= 1;
- if (mywpunct(c)) ++mine; mine <<= 1;
- if (mywspace(c)) ++mine; mine <<= 1;
- if (mywupper(c)) ++mine; mine <<= 1;
- if (mywxdigit(c)) ++mine;
-
- if (glibc != mine) {
- verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d);
- if (c < 0x30000UL) {
- verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ mine = 0;
+ if (mywalnum(d,c)) ++mine; mine <<= 1;
+ if (mywalpha(d,c)) ++mine; mine <<= 1;
+ if (mywblank(d,c)) ++mine; mine <<= 1;
+ if (mywcntrl(d,c)) ++mine; mine <<= 1;
+ if (mywdigit(d,c)) ++mine; mine <<= 1;
+ if (mywgraph(d,c)) ++mine; mine <<= 1;
+ if (mywlower(d,c)) ++mine; mine <<= 1;
+ if (mywprint(d,c)) ++mine; mine <<= 1;
+ if (mywpunct(d,c)) ++mine; mine <<= 1;
+ if (mywspace(d,c)) ++mine; mine <<= 1;
+ if (mywupper(d,c)) ++mine; mine <<= 1;
+ if (mywxdigit(d,c)) ++mine;
+
+ if (glibc != mine) {
+ verbose_msg("%#8x : glibc %#4x != %#4x mine %d\n", c, glibc, mine, d);
+ if (c < 0x30000UL) {
+ verbose_msg("sc=%#x u=%#x n=%#x i0=%#x i1=%#x\n", sc, u, n, i0, i1);
+ }
}
- }
+
upper = lower = u = c;
if (u <= RANGE) {
sc = u & ((1 << ultable.ti_shift) - 1);
@@ -720,23 +654,22 @@ int main(int argc, char **argv)
lower = c + uldiff[i0].l;
}
- if (towupper(c) != upper) {
- verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n",
- c, towupper(c), upper);
- }
+ if (towupper(c) != upper) {
+ verbose_msg("%#8x : towupper glibc %#4x != %#4x mine\n",
+ c, towupper(c), upper);
+ }
- if (towlower(c) != lower) {
- verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
- c, towlower(c), lower, i0);
- }
+ if (towlower(c) != lower) {
+ verbose_msg("%#8x : towlower glibc %#4x != %#4x mine i0 = %d\n",
+ c, towlower(c), lower, i0);
+ }
- if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
- verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
- c, tt, upper, i0);
- }
+ if (totitle && ((tt = towctrans(c, totitle)) != upper)) {
+ verbose_msg("%#8x : totitle glibc %#4lx != %#4x mine i0 = %d\n",
+ c, tt, upper, i0);
+ }
}
-
if ((c & 0xfff) == 0xfff) verbose_msg(".");
}
verbose_msg("done\n");
@@ -755,13 +688,12 @@ int main(int argc, char **argv)
output_table(fp, "ctype", &cttable);
output_table(fp, "uplow", &ultable);
-
#warning fix the upper bound on the upper/lower tables... save 200 bytes or so
fprintf(fp, "#define __LOCALE_DATA_WCuplow_diffs %7u\n", ul_count);
fprintf(fp, "\n#ifdef WANT_WCuplow_diff_data\n\n");
fprintf(fp, "\nstatic const short __LOCALE_DATA_WCuplow_diff_data[%zu] = {",
2 * (size_t) ul_count);
- for (i=0 ; i < ul_count ; i++) {
+ for (i = 0; i < ul_count; i++) {
if (i % 4 == 0) {
fprintf(fp, "\n");
}
@@ -770,7 +702,6 @@ int main(int argc, char **argv)
fprintf(fp, "\n};\n\n");
fprintf(fp, "#endif /* WANT_WCuplow_diff_data */\n\n");
-
/* output_table(fp, "comb", &combtable); */
/* output_table(fp, "width", &widthtable); */
@@ -801,7 +732,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
numblocks = usize >> shift;
/* init table index */
- for (i=j=0 ; i < numblocks ; i++) {
+ for (i=j = 0; i < numblocks; i++) {
ti[i] = ut + j;
j += blocksize;
}
@@ -812,7 +743,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
uniq = 1;
uit[(ti[0]-ut)/blocksize] = 0;
- for (i=1 ; i < numblocks ; i++) {
+ for (i=1; i < numblocks; i++) {
if (memcmp(ti[i-1], ti[i], blocksize) < 0) {
if (++uniq > 255) {
break;
@@ -821,7 +752,7 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
}
#if 1
else if (memcmp(ti[i-1], ti[i], blocksize) > 0) {
- verbose_msg("bad sort %i!\n", i);
+ verbose_msg("bad sort %li!\n", (long) i);
abort();
}
#endif
@@ -830,37 +761,37 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
smallest = SIZE_MAX;
shift2 = -1;
- if (uniq <= 255) {
- smallest = numblocks + uniq * blocksize;
- if (!recurse) {
- ++recurse;
- for (j=1 ; j < 14 ; j++) {
- if ((numblocks >> j) < 2) break;
- if (tbl) {
- ii_save = tbl->ii;
- tbl->ii = NULL;
- }
- if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
- t += uniq * blocksize;
- }
- if (tbl) {
- tbl->ii = ii_save;
- }
- if (smallest >= t) {
- shift2 = j;
- smallest = t;
- if (!tbl->ii) {
- verbose_msg("ishift %zu tshift %zu size %zu\n",
- shift2, shift, t);
- }
-/* } else { */
-/* break; */
+
+ if (uniq > 255)
+ return SIZE_MAX;
+
+ smallest = numblocks + uniq * blocksize;
+ if (!recurse) {
+ ++recurse;
+ for (j=1; j < 14; j++) {
+ if ((numblocks >> j) < 2) break;
+ if (tbl) {
+ ii_save = tbl->ii;
+ tbl->ii = NULL;
+ }
+ if ((t = newopt(uit, numblocks, j, tbl)) < SIZE_MAX) {
+ t += uniq * blocksize;
+ }
+ if (tbl) {
+ tbl->ii = ii_save;
+ }
+ if (smallest >= t) {
+ shift2 = j;
+ smallest = t;
+ if (!tbl->ii) {
+ verbose_msg("ishift %u tshift %u size %lu\n",
+ shift2, shift, (unsigned long) t);
}
+/* } else { */
+/* break; */
}
- --recurse;
}
- } else {
- return SIZE_MAX;
+ --recurse;
}
if (tbl->ii) {
@@ -870,19 +801,19 @@ size_t newopt(unsigned char *ut, size_t usize, int shift, table_data *tbl)
memcpy(tbl->ii, uit, numblocks);
tbl->ti = tbl->ii + tbl->ii_len;
tbl->ti_len = uniq * blocksize;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ti + i * blocksize, ti[uniqblock[i]], blocksize);
}
} else {
++recurse;
- verbose_msg("setting ishift %zu tshift %zu\n",
+ verbose_msg("setting ishift %u tshift %u\n",
shift2, shift);
newopt(uit, numblocks, shift2, tbl);
--recurse;
tbl->ti_shift = shift;
tbl->ut_len = uniq * blocksize;
tbl->ut = tbl->ti + tbl->ti_len;
- for (i=0 ; i < uniq ; i++) {
+ for (i = 0; i < uniq; i++) {
memcpy(tbl->ut + i * blocksize, ti[uniqblock[i]], blocksize);
}
}
diff --git a/extra/locale/locale_mmap.h b/extra/locale/locale_mmap.h
index 1b748239b..4b231ef9e 100644
--- a/extra/locale/locale_mmap.h
+++ b/extra/locale/locale_mmap.h
@@ -8,34 +8,34 @@
/* TODO - fix */
#ifdef __WCHAR_ENABLED
-#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
-#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
+#define __LOCALE_DATA_WCctype_TBL_LEN (__LOCALE_DATA_WCctype_II_LEN + __LOCALE_DATA_WCctype_TI_LEN + __LOCALE_DATA_WCctype_UT_LEN)
+#define __LOCALE_DATA_WCuplow_TBL_LEN (__LOCALE_DATA_WCuplow_II_LEN + __LOCALE_DATA_WCuplow_TI_LEN + __LOCALE_DATA_WCuplow_UT_LEN)
#define __LOCALE_DATA_WCuplow_diff_TBL_LEN (2 * __LOCALE_DATA_WCuplow_diffs)
/* #define WCcomb_TBL_LEN (WCcomb_II_LEN + WCcomb_TI_LEN + WCcomb_UT_LEN) */
#endif
#undef __PASTE2
-#define __PASTE2(A,B) A ## B
+#define __PASTE2(A,B) A ## B
#undef __PASTE3
-#define __PASTE3(A,B,C) A ## B ## C
+#define __PASTE3(A,B,C) A ## B ## C
#define __LOCALE_DATA_COMMON_MMAP(X) \
- unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
+ unsigned char __PASTE3(lc_,X,_data)[__PASTE3(__lc_,X,_data_LEN)];
#define __LOCALE_DATA_COMMON_MMIDX(X) \
- unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
- uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
+ unsigned char __PASTE3(lc_,X,_rows)[__PASTE3(__lc_,X,_rows_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_offsets)[__PASTE3(__lc_,X,_item_offsets_LEN)]; \
+ uint16_t __PASTE3(lc_,X,_item_idx)[__PASTE3(__lc_,X,_item_idx_LEN)]; \
typedef struct {
#ifdef __LOCALE_DATA_MAGIC_SIZE
unsigned char magic[__LOCALE_DATA_MAGIC_SIZE];
-#endif /* __LOCALE_DATA_MAGIC_SIZE */
+#endif
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const unsigned char tbl8ctype[__LOCALE_DATA_Cctype_TBL_LEN];
- const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
+ const unsigned char tbl8uplow[__LOCALE_DATA_Cuplow_TBL_LEN];
#ifdef __WCHAR_ENABLED
const uint16_t tbl8c2wc[__LOCALE_DATA_Cc2wc_TBL_LEN]; /* char > 0x7f to wide char */
const unsigned char tbl8wc2c[__LOCALE_DATA_Cwc2c_TBL_LEN];
@@ -48,7 +48,7 @@ typedef struct {
const int16_t tblwuplow_diff[__LOCALE_DATA_WCuplow_diff_TBL_LEN];
/* const unsigned char tblwcomb[WCcomb_TBL_LEN]; */
/* width?? */
-#endif /* __WCHAR_ENABLED */
+#endif
__LOCALE_DATA_COMMON_MMAP(ctype);
__LOCALE_DATA_COMMON_MMAP(numeric);
@@ -60,7 +60,7 @@ typedef struct {
#ifdef __CTYPE_HAS_8_BIT_LOCALES
const __codeset_8_bit_t codeset_8_bit[__LOCALE_DATA_NUM_CODESETS];
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif
__LOCALE_DATA_COMMON_MMIDX(ctype);
__LOCALE_DATA_COMMON_MMIDX(numeric);
@@ -72,7 +72,7 @@ typedef struct {
const uint16_t collate_data[__lc_collate_data_LEN];
unsigned char lc_common_item_offsets_LEN[__LOCALE_DATA_CATEGORIES];
- size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
+ size_t lc_common_tbl_offsets[__LOCALE_DATA_CATEGORIES * 4];
/* offsets from start of locale_mmap_t */
/* rows, item_offsets, item_idx, data */
@@ -80,14 +80,12 @@ typedef struct {
unsigned char locales[__LOCALE_DATA_NUM_LOCALES * __LOCALE_DATA_WIDTH_LOCALES];
unsigned char locale_names5[5*__LOCALE_DATA_NUM_LOCALE_NAMES];
unsigned char locale_at_modifiers[__LOCALE_DATA_AT_MODIFIERS_LENGTH];
-#endif /* __LOCALE_DATA_NUM_LOCALES */
+#endif
unsigned char lc_names[__lc_names_LEN];
#ifdef __CTYPE_HAS_8_BIT_LOCALES
unsigned char codeset_list[sizeof(__LOCALE_DATA_CODESET_LIST)]; /* TODO - fix */
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
-
-
+#endif
} __locale_mmap_t;
extern const __locale_mmap_t *__locale_mmap;
diff --git a/extra/locale/programs/locale.c b/extra/locale/programs/locale.c
index c8b76bd65..1ecac6bd8 100644
--- a/extra/locale/programs/locale.c
+++ b/extra/locale/programs/locale.c
@@ -1,3 +1,4 @@
+/* vi: set sw=4 ts=4: */
/*
*
* Copyright (c) 2008 STMicroelectronics Ltd
diff --git a/extra/scripts/install_headers.sh b/extra/scripts/install_headers.sh
index d38d85327..e5314447f 100755
--- a/extra/scripts/install_headers.sh
+++ b/extra/scripts/install_headers.sh
@@ -41,13 +41,20 @@ IFS=''
while read -r filename; do
if test -d "$1/$filename"; then
mkdir -p "$2/$filename" 2>/dev/null
- else
- # NB: unifdef exits with 1 if output is not
- # exactly the same as input. That's ok.
- # Do not abort the script if unifdef "fails"!
- "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL "$1/$filename" \
- | sed -e '/^\(rtld\|lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' >"$2/$filename"
+ continue
fi
+ if test x"${filename##libc-*.h}" = x""; then
+ # Do not install libc-XXXX.h files
+ continue
+ fi
+ # NB: unifdef exits with 1 if output is not
+ # exactly the same as input. That's ok.
+ # Do not abort the script if unifdef "fails"!
+ # NB2: careful with sed command arguments, they contain tab character
+ "$top_builddir/extra/scripts/unifdef" -UUCLIBC_INTERNAL -U_LIBC "$1/$filename" \
+ | sed -e '/^rtld_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ | sed -e '/^lib\(c\|m\|resolv\|dl\|intl\|rt\|nsl\|util\|crypt\|pthread\)_hidden_proto[ ]*([a-zA-Z0-9_]*)$/d' \
+ >"$2/$filename"
done
)
diff --git a/ldso/ldso/dl-symbols.c b/ldso/ldso/dl-symbols.c
index 294131990..e5c00211a 100644
--- a/ldso/ldso/dl-symbols.c
+++ b/ldso/ldso/dl-symbols.c
@@ -1,7 +1,7 @@
/*
- * This contains all symbols shared between
+ * This contains all symbols shared between
* dynamic linker ld.so and into static libc
-
+ *
* Copyright (c) 2008 STMicroelectronics Ltd
* Author: Carmelo Amoroso <carmelo.amoroso@st.com>
*
diff --git a/libc/inet/ether_addr.c b/libc/inet/ether_addr.c
index 82b067157..621c62989 100644
--- a/libc/inet/ether_addr.c
+++ b/libc/inet/ether_addr.c
@@ -31,49 +31,45 @@
#include <netinet/ether.h>
#include <netinet/if_ether.h>
-/* libc_hidden_proto(ether_ntoa_r) */
-/* libc_hidden_proto(sprintf) */
-#ifdef __UCLIBC_HAS_XLOCALE__
-/* libc_hidden_proto(__ctype_b_loc) */
-/* libc_hidden_proto(__ctype_tolower_loc) */
-#elif defined __UCLIBC_HAS_CTYPE_TABLES__
-/* libc_hidden_proto(__ctype_b) */
-/* libc_hidden_proto(__ctype_tolower) */
-#endif
-
struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
{
- size_t cnt;
+ /* asc is "X:XX:XX:x:xx:xX" */
+ int cnt;
for (cnt = 0; cnt < 6; ++cnt) {
- unsigned int number;
+ unsigned char number;
char ch;
- ch = _tolower(*asc++);
+ /* | 0x20 is cheap tolower(), valid for letters/numbers only */
+ ch = (*asc++) | 0x20;
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
return NULL;
- number = isdigit(ch) ? (ch - '0') : (ch - 'a' + 10);
-
- ch = _tolower(*asc);
- if ((cnt < 5 && ch != ':')
- || (cnt == 5 && ch != '\0' && !isspace(ch))) {
- ++asc;
+ number = !(ch > '9') ? (ch - '0') : (ch - 'a' + 10);
+
+ ch = *asc++;
+ if ((cnt != 5 && ch != ':') /* not last group */
+ /* What standard says ASCII ether address representation
+ * may also finish with whitespace, not only NUL?
+ * We can get rid of isspace() otherwise */
+ || (cnt == 5 && ch != '\0' /*&& !isspace(ch)*/)
+ ) {
+ ch |= 0x20; /* cheap tolower() */
if ((ch < '0' || ch > '9') && (ch < 'a' || ch > 'f'))
return NULL;
- number <<= 4;
- number += isdigit(ch) ? (ch - '0') : (ch - 'a' + 10);
+ number = (number << 4) + (!(ch > '9') ? (ch - '0') : (ch - 'a' + 10));
- ch = *asc;
- if (cnt < 5 && ch != ':')
- return NULL;
+ if (cnt != 5) {
+ ch = *asc++;
+ if (ch != ':')
+ return NULL;
+ }
}
/* Store result. */
- addr->ether_addr_octet[cnt] = (unsigned char) number;
-
- /* Skip ':'. */
- ++asc;
+ addr->ether_addr_octet[cnt] = number;
}
+ /* Looks like we allow garbage after last group?
+ * "1:2:3:4:5:66anything_at_all"? */
return addr;
}
diff --git a/libc/inet/getaddrinfo.c b/libc/inet/getaddrinfo.c
index ee77ecc5c..1953e6f7a 100644
--- a/libc/inet/getaddrinfo.c
+++ b/libc/inet/getaddrinfo.c
@@ -56,6 +56,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assert.h>
#include <errno.h>
#include <netdb.h>
+#include <resolv.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -715,9 +716,9 @@ gaih_inet(const char *name, const struct gaih_service *service,
(*pai)->ai_protocol = st2->protocol;
(*pai)->ai_addrlen = socklen;
(*pai)->ai_addr = (void *) (*pai) + sizeof(struct addrinfo);
-#if SALEN
+#if defined SALEN
(*pai)->ai_addr->sa_len = socklen;
-#endif /* SALEN */
+#endif
(*pai)->ai_addr->sa_family = family;
#if defined __UCLIBC_HAS_IPV6__
diff --git a/libc/inet/hostid.c b/libc/inet/hostid.c
index 748589b86..7a1a2a181 100644
--- a/libc/inet/hostid.c
+++ b/libc/inet/hostid.c
@@ -89,7 +89,7 @@ long int gethostid(void)
* setting one anyway.
* Mitch
*/
- if (gethostname(host,MAXHOSTNAMELEN)>=0 && *host) {
+ if (gethostname(host, MAXHOSTNAMELEN) >= 0 && *host) {
struct hostent *hp;
struct in_addr in;
struct hostent ghbn_h;
@@ -104,21 +104,17 @@ long int gethostid(void)
/*if ((hp = gethostbyname(host)) == (struct hostent *)NULL)*/
gethostbyname_r(host, &ghbn_h, ghbn_buf, sizeof(ghbn_buf), &hp, &ghbn_errno);
- if (hp == (struct hostent *)NULL)
-
+ if (hp == NULL) {
/* This is not a error if we get here, as all it means is that
* this host is not on a network and/or they have not
* configured their network properly. So we return the unset
* hostid which should be 0, meaning that they should set it !!
*/
return 0;
- else {
- memcpy((char *) &in, (char *) hp->h_addr, hp->h_length);
-
- /* Just so it doesn't look exactly like the IP addr */
- return(in.s_addr<<16|in.s_addr>>16);
}
+ memcpy(&in, hp->h_addr, hp->h_length);
+ /* Just so it doesn't look exactly like the IP addr */
+ return (in.s_addr<<16 | in.s_addr>>16);
}
- else return 0;
-
+ return 0;
}
diff --git a/libc/inet/ntop.c b/libc/inet/ntop.c
index dbc71815a..4583fc47f 100644
--- a/libc/inet/ntop.c
+++ b/libc/inet/ntop.c
@@ -67,8 +67,8 @@ inet_ntop4(const u_char *src, char *dst, size_t size)
#if 0 /* since src is unsigned char, it will never be > 255 ... */
if (src[octet] > 255) {
- __set_errno (ENOSPC);
- return (NULL);
+ __set_errno(ENOSPC);
+ return NULL;
}
#endif
tmp[i++] = '0' + src[octet] / 100;
@@ -83,9 +83,9 @@ inet_ntop4(const u_char *src, char *dst, size_t size)
}
tmp[i - 1] = '\0';
- if (strlen (tmp) > size) {
- __set_errno (ENOSPC);
- return (NULL);
+ if (strlen(tmp) > size) {
+ __set_errno(ENOSPC);
+ return NULL;
}
return strcpy(dst, tmp);
@@ -168,7 +168,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof tmp - (tp - tmp)))
- return (NULL);
+ return NULL;
tp += strlen(tp);
break;
}
@@ -183,8 +183,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size) {
- __set_errno (ENOSPC);
- return (NULL);
+ __set_errno(ENOSPC);
+ return NULL;
}
return strcpy(dst, tmp);
}
@@ -216,25 +216,25 @@ inet_pton4(const char *src, u_char *dst)
u_int new = *tp * 10 + (ch - '0');
if (new > 255)
- return (0);
+ return 0;
*tp = new;
if (! saw_digit) {
if (++octets > 4)
- return (0);
+ return 0;
saw_digit = 1;
}
} else if (ch == '.' && saw_digit) {
if (octets == 4)
- return (0);
+ return 0;
*++tp = 0;
saw_digit = 0;
} else
- return (0);
+ return 0;
}
if (octets < 4)
- return (0);
+ return 0;
memcpy(dst, tmp, 4);
- return (1);
+ return 1;
}
/* int
@@ -253,13 +253,6 @@ inet_pton4(const char *src, u_char *dst)
#ifdef __UCLIBC_HAS_IPV6__
-/* We cannot use the macro version of tolower() or very bad
- * things happen when '*src++' gets evaluated multiple times.
- * So undef it here so we get the function version of tolower
- * instead.
- */
-#undef tolower
-
static int
inet_pton6(const char *src, u_char *dst)
{
@@ -276,19 +269,20 @@ inet_pton6(const char *src, u_char *dst)
/* Leading :: requires some special handling. */
if (*src == ':')
if (*++src != ':')
- return (0);
+ return 0;
curtok = src;
saw_xdigit = 0;
val = 0;
- while ((ch = tolower (*src++)) != '\0') {
+ while ((ch = *src++) != '\0') {
const char *pch;
- pch = strchr(xdigits, ch);
+ /* | 0x20 is cheap tolower(), valid for letters/numbers only */
+ pch = strchr(xdigits, (ch | 0x20));
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
if (val > 0xffff)
- return (0);
+ return 0;
saw_xdigit = 1;
continue;
}
@@ -296,16 +290,16 @@ inet_pton6(const char *src, u_char *dst)
curtok = src;
if (!saw_xdigit) {
if (colonp)
- return (0);
+ return 0;
colonp = tp;
continue;
- } else if (*src == '\0') {
- return (0);
}
+ if (*src == '\0')
+ return 0;
if (tp + 2 > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ return 0;
+ *tp++ = (u_char) (val >> 8);
+ *tp++ = (u_char) val;
saw_xdigit = 0;
val = 0;
continue;
@@ -316,13 +310,13 @@ inet_pton6(const char *src, u_char *dst)
saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */
}
- return (0);
+ return 0;
}
if (saw_xdigit) {
if (tp + 2 > endp)
- return (0);
- *tp++ = (u_char) (val >> 8) & 0xff;
- *tp++ = (u_char) val & 0xff;
+ return 0;
+ *tp++ = (u_char) (val >> 8);
+ *tp++ = (u_char) val;
}
if (colonp != NULL) {
/*
@@ -333,7 +327,7 @@ inet_pton6(const char *src, u_char *dst)
int i;
if (tp == endp)
- return (0);
+ return 0;
for (i = 1; i <= n; i++) {
endp[- i] = colonp[n - i];
colonp[n - i] = 0;
@@ -341,9 +335,9 @@ inet_pton6(const char *src, u_char *dst)
tp = endp;
}
if (tp != endp)
- return (0);
+ return 0;
memcpy(dst, tmp, 16);
- return (1);
+ return 1;
}
#endif /* __UCLIBC_HAS_IPV6__ */
@@ -364,14 +358,14 @@ inet_ntop(int af, const void *src, char *dst, socklen_t size)
{
switch (af) {
case AF_INET:
- return (inet_ntop4(src, dst, size));
+ return inet_ntop4(src, dst, size);
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
- return (inet_ntop6(src, dst, size));
+ return inet_ntop6(src, dst, size);
#endif
default:
- __set_errno (EAFNOSUPPORT);
- return (NULL);
+ __set_errno(EAFNOSUPPORT);
+ return NULL;
}
/* NOTREACHED */
}
@@ -395,14 +389,14 @@ inet_pton(int af, const char *src, void *dst)
{
switch (af) {
case AF_INET:
- return (inet_pton4(src, dst));
+ return inet_pton4(src, dst);
#ifdef __UCLIBC_HAS_IPV6__
case AF_INET6:
- return (inet_pton6(src, dst));
+ return inet_pton6(src, dst);
#endif
default:
- __set_errno (EAFNOSUPPORT);
- return (-1);
+ __set_errno(EAFNOSUPPORT);
+ return -1;
}
/* NOTREACHED */
}
diff --git a/libc/misc/fnmatch/fnmatch_old.c b/libc/misc/fnmatch/fnmatch_old.c
index 839c77579..69a8ede50 100644
--- a/libc/misc/fnmatch/fnmatch_old.c
+++ b/libc/misc/fnmatch/fnmatch_old.c
@@ -15,7 +15,7 @@ License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#if HAVE_CONFIG_H
+#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index afc55f88a..9325ab745 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -105,11 +105,11 @@ char *alloca ();
/* libc_hidden_proto(lstat) */
/* libc_hidden_proto(stat) */
-#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
+#if !defined _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
char *stpcpy ();
#endif
-#if ! _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
+#if !defined _LIBC && ! defined HAVE_MEMPCPY && ! defined mempcpy
/* Be CAREFUL that there are no side effects in N. */
# define mempcpy(D, S, N) ((void *) ((char *) memcpy (D, S, N) + (N)))
#endif
@@ -162,7 +162,7 @@ extern char *xgetcwd (void);
/* Arrange to make lstat calls go through the wrapper function
on systems with an lstat function that does not dereference symlinks
that are specified with a trailing slash. */
-#if ! _LIBC && ! LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
+#if !defined _LIBC && !defined LSTAT_FOLLOWS_SLASHED_SYMLINK && !defined __UCLIBC__
int rpl_lstat (const char *, struct stat *);
# undef lstat
# define lstat(Name, Stat_buf) rpl_lstat(Name, Stat_buf)
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 71bd77951..a2a898fdd 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -230,7 +230,8 @@ static void update_hr_locale(const unsigned char *spec)
+ __LOCALE_DATA_WIDTH_LOCALES * ((((int)(*s & 0x7f)) << 7)
+ (s[1] & 0x7f));
if (category == LC_ALL) {
- n = stpcpy(n, CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
+ /* CATEGORY_NAMES is unsigned char* */
+ n = stpcpy(n, (char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[i]);
*n++ = '=';
}
if (*loc == 0) {
@@ -248,12 +249,12 @@ static void update_hr_locale(const unsigned char *spec)
if (loc[2] == 2) {
n = stpcpy(n, utf8);
} else if (loc[2] >= 3) {
- n = stpcpy(n, CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
+ n = stpcpy(n, (char*) CODESET_LIST + (int)(CODESET_LIST[loc[2] - 3]));
}
if (at) {
const char *q;
*n++ = '@';
- q = LOCALE_AT_MODIFIERS;
+ q = (char*) LOCALE_AT_MODIFIERS;
do {
if (q[1] == at) {
n = stpcpy(n, q+2);
@@ -644,8 +645,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
io = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
ii = (const uint16_t *)( ((char *)__locale_mmap) + *++stp );
d = (const unsigned char *)( ((char *)__locale_mmap) + *++stp );
- for (c=0 ; c < len ; c++) {
- *(x + c) = d + ii[ r[crow + c] + io[c] ];
+ for (c = 0; c < len; c++) {
+ x[c] = (char*)(d + ii[r[crow + c] + io[c]]);
}
}
if (i == LC_CTYPE) {
@@ -658,7 +659,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
/* TODO - fix for bcc */
base->mb_cur_max = 6;
} else {
- assert(c==1);
+ assert(c == 1);
base->codeset = ascii;
base->encoding = __ctype_encoding_7_bit;
base->mb_cur_max = 1;
@@ -666,7 +667,8 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
} else {
const __codeset_8_bit_t *c8b;
r = CODESET_LIST;
- base->codeset = r + r[c -= 3];
+ c -= 3;
+ base->codeset = (char *) (r + r[c]);
base->encoding = __ctype_encoding_8_bit;
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: update 8 bit mb_cur_max when translit implemented!
@@ -905,7 +907,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
base->tblwuplow
= (const unsigned char *) &__locale_mmap->tblwuplow;
base->tblwuplow_diff
- = (const uint16_t *) &__locale_mmap->tblwuplow_diff;
+ = (const int16_t *) &__locale_mmap->tblwuplow_diff;
/* base->tblwcomb */
/* = (const unsigned char *) &__locale_mmap->tblwcomb; */
/* width?? */
@@ -928,8 +930,7 @@ void attribute_hidden _locale_init_l(__locale_t base)
#endif
base->code2flag = __code2flag;
-
- _locale_set_l(C_LOCALE_SELECTOR, base);
+ _locale_set_l((unsigned char*) C_LOCALE_SELECTOR, base);
}
void _locale_init(void) attribute_hidden;
@@ -1117,7 +1118,7 @@ static int find_locale(int category_mask, const char *p,
/* locale name at least 5 chars long and 3rd char is '_' */
s = LOCALE_AT_MODIFIERS;
do {
- if (!strcmp(s+2, q+1)) {
+ if (!strcmp((char*) (s + 2), q + 1)) {
break;
}
s += 2 + *s; /* TODO - fix this throughout */
@@ -1142,11 +1143,11 @@ static int find_locale(int category_mask, const char *p,
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- if (strcasecmp(utf8,p+6) != 0) {/* TODO - fix! */
+ if (strcasecmp(utf8, p + 6) != 0) {/* TODO - fix! */
s = CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
- if (!strcmp(CODESET_LIST+*s, p+6)) {
+ if (!strcmp((char*) CODESET_LIST + *s, p + 6)) {
goto FIND_LANG_CULT;
}
} while (*++s);
@@ -1159,7 +1160,7 @@ static int find_locale(int category_mask, const char *p,
do { /* TODO -- do a binary search? */
/* TODO -- fix gen_mmap!*/
++lang_cult; /* Increment first since C/POSIX is 0. */
- if (!strncmp(s,p,5)) { /* Found a matching locale name; */
+ if (!strncmp((char*) s, p, 5)) { /* Found a matching locale name; */
goto FIND_LOCALE;
}
s += 5;
@@ -1217,7 +1218,8 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */
do {
c = 0;
- while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
+ /* CATEGORY_NAMES is unsigned char* */
+ while (strcmp((char*) CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
if (++c == LC_ALL) { /* Unknown category name! */
return NULL;
}
@@ -1242,7 +1244,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
__locale_t newlocale(int category_mask, const char *locale, __locale_t base)
{
- const unsigned char *p;
+ const char *p;
int i, j, k;
unsigned char new_selector[LOCALE_SELECTOR_SIZE];
@@ -1250,8 +1252,8 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
category_mask = LC_ALL_MASK;
}
- if (!locale || (((unsigned int)(category_mask)) > LC_ALL_MASK)) {
- INVALID:
+ if (!locale || ((unsigned)(category_mask) > LC_ALL_MASK)) {
+ INVALID:
__set_errno(EINVAL);
return NULL; /* No locale or illegal/unsupported category. */
}
@@ -1262,11 +1264,13 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
strcpy((char *) new_selector,
(base ? (char *) base->cur_locale : C_LOCALE_SELECTOR));
- if (!*locale) { /* locale == "", so check environment. */
-#ifndef __UCLIBC_HAS_THREADS__
- static /* If no threads, then envstr can be static. */
-#endif /* __UCLIBC_HAS_THREADS__ */
- const char *envstr[4] = { "LC_ALL", NULL, "LANG", posix };
+ if (!locale[0]) { /* locale == "", so check environment. */
+ const char *envstr[4];
+
+ envstr[0] = "LC_ALL";
+ envstr[1] = NULL;
+ envstr[2] = "LANG";
+ envstr[3] = posix;
i = 1;
k = 0;
@@ -1275,12 +1279,16 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
/* Note: SUSv3 doesn't define a fallback mechanism here.
* So, if LC_ALL is invalid, we do _not_ continue trying
* the other environment vars. */
- envstr[1] = CATEGORY_NAMES + CATEGORY_NAMES[k];
+ envstr[1] = (char*) CATEGORY_NAMES + CATEGORY_NAMES[k];
j = 0;
- do {
+ while (1) {
p = envstr[j];
- } while ((++j < 4) && (!(p = getenv(p)) || !*p));
-
+ if (++j >= 4)
+ break; /* now p == "POSIX" */
+ p = getenv(p);
+ if (p && p[0])
+ break;
+ };
/* The user set something... is it valid? */
/* Note: Since we don't support user-supplied locales and
@@ -1313,9 +1321,9 @@ __locale_t newlocale(int category_mask, const char *locale, __locale_t base)
}
#else
if (!base) {
- if ((base = malloc(sizeof(__uclibc_locale_t))) == NULL) {
+ base = malloc(sizeof(__uclibc_locale_t));
+ if (base == NULL)
return base;
- }
_locale_init_l(base);
}
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 76350fc4e..65aec97f1 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -120,7 +120,7 @@
# endif
/* This is for other GNU distributions with internationalized messages. */
-# if HAVE_LIBINTL_H || defined _LIBC
+# if defined HAVE_LIBINTL_H || defined _LIBC
# include <libintl.h>
# ifdef _LIBC
# undef gettext
@@ -208,7 +208,7 @@ char *realloc ();
# endif /* not emacs */
-# if defined _LIBC || HAVE_LIMITS_H
+# if defined _LIBC || defined HAVE_LIMITS_H
# include <limits.h>
# endif
@@ -2091,33 +2091,12 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
# define MAX_BUF_SIZE (1L << 16)
# define REALLOC(p,s) realloc ((p), (s))
# endif
+# endif /* not DEFINED_ONCE */
/* Extend the buffer by twice its current size via realloc and
reset the pointers that pointed into the old block to point to the
correct places in the new one. If extending the buffer results in it
being larger than MAX_BUF_SIZE, then flag memory exhausted. */
-# if __BOUNDED_POINTERS__
-# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
-# define MOVE_BUFFER_POINTER(P) \
- (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
- else \
- { \
- SET_HIGH_BOUND (b); \
- SET_HIGH_BOUND (begalt); \
- if (fixup_alt_jump) \
- SET_HIGH_BOUND (fixup_alt_jump); \
- if (laststart) \
- SET_HIGH_BOUND (laststart); \
- if (pending_exact) \
- SET_HIGH_BOUND (pending_exact); \
- }
-# else
-# define MOVE_BUFFER_POINTER(P) (P) += incr
-# define ELSE_EXTEND_BUFFER_HIGH_BOUND
-# endif
-# endif /* not DEFINED_ONCE */
-
# ifdef WCHAR
# define EXTEND_BUFFER() \
do { \
@@ -2141,16 +2120,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# else /* BYTE */
# define EXTEND_BUFFER() \
@@ -2169,16 +2147,15 @@ static reg_errcode_t byte_compile_range (unsigned int range_start,
if (old_buffer != COMPILED_BUFFER_VAR) \
{ \
int incr = COMPILED_BUFFER_VAR - old_buffer; \
- MOVE_BUFFER_POINTER (b); \
- MOVE_BUFFER_POINTER (begalt); \
+ b += incr; \
+ begalt += incr; \
if (fixup_alt_jump) \
- MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ fixup_alt_jump += incr; \
if (laststart) \
- MOVE_BUFFER_POINTER (laststart); \
+ laststart += incr; \
if (pending_exact) \
- MOVE_BUFFER_POINTER (pending_exact); \
+ pending_exact += incr; \
} \
- ELSE_EXTEND_BUFFER_HIGH_BOUND \
} while (0)
# endif /* WCHAR */
@@ -2253,7 +2230,7 @@ typedef struct
}
# ifndef DEFINED_ONCE
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
/* The GNU C library provides support for user-defined character classes
and the functions from ISO C amendement 1. */
# ifdef CHARCLASS_NAME_MAX
@@ -3309,7 +3286,7 @@ PREFIX(regex_compile) (
the leading `:' and `[' (but set bits for them). */
if (c == ':' && *p == ']')
{
-# if defined _LIBC || WIDE_CHAR_SUPPORT
+# if defined _LIBC || defined WIDE_CHAR_SUPPORT
boolean is_lower = STREQ (str, "lower");
boolean is_upper = STREQ (str, "upper");
wctype_t wt;
@@ -4565,7 +4542,7 @@ byte_compile_range (
unsigned this_char;
const char *p = *p_ptr;
reg_errcode_t ret;
-# if _LIBC
+# ifdef _LIBC
const unsigned char *collseq;
unsigned int start_colseq;
unsigned int end_colseq;
@@ -4583,7 +4560,7 @@ byte_compile_range (
/* Report an error if the range is empty and the syntax prohibits this. */
ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
-# if _LIBC
+# ifdef _LIBC
collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
_NL_COLLATE_COLLSEQMB);
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index a28cd8f94..9bdaafe90 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -188,24 +188,24 @@ wint_t btowc(int c)
if (c != EOF) {
*buf = (unsigned char) c;
mbstate.__mask = 0; /* Initialize the mbstate. */
- if (mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
+ if (mbrtowc(&wc, (char*) buf, 1, &mbstate) <= 1) {
return wc;
}
}
return WEOF;
-#else /* __CTYPE_HAS_8_BIT_LOCALES */
+#else /* !__CTYPE_HAS_8_BIT_LOCALES */
#ifdef __UCLIBC_HAS_LOCALE__
assert((ENCODING == __ctype_encoding_7_bit)
|| (ENCODING == __ctype_encoding_utf8));
-#endif /* __UCLIBC_HAS_LOCALE__ */
+#endif
/* If we don't have 8-bit locale support, then this is trivial since
* anything outside of 0-0x7f is illegal in C/POSIX and UTF-8 locales. */
return (((unsigned int)c) < 0x80) ? c : WEOF;
-#endif /* __CTYPE_HAS_8_BIT_LOCALES */
+#endif /* !__CTYPE_HAS_8_BIT_LOCALES */
}
libc_hidden_def(btowc)
@@ -223,7 +223,7 @@ int wctob(wint_t c)
unsigned char buf[MB_LEN_MAX];
- return (wcrtomb(buf, c, NULL) == 1) ? *buf : EOF;
+ return (wcrtomb((char*) buf, c, NULL) == 1) ? *buf : EOF;
#else /* __CTYPE_HAS_8_BIT_LOCALES */
@@ -1290,8 +1290,8 @@ static int find_codeset(const char *name)
const unsigned char *s;
int codeset;
- for (s = __iconv_codesets ; *s ; s += *s) {
- if (!strcasecmp(s+2, name)) {
+ for (s = __iconv_codesets; *s; s += *s) {
+ if (!strcasecmp((char*) (s + 2), name)) {
return s[1];
}
}
@@ -1301,7 +1301,7 @@ static int find_codeset(const char *name)
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- s = __LOCALE_DATA_CODESET_LIST;
+ s = (const unsigned char *) __LOCALE_DATA_CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
if (!strcasecmp(__LOCALE_DATA_CODESET_LIST+*s, name)) {
@@ -1590,8 +1590,8 @@ extern const unsigned char __iconv_codesets[];
#define IBUF BUFSIZ
#define OBUF BUFSIZ
-char *progname;
-int hide_errors;
+static char *progname;
+static int hide_errors;
static void error_msg(const char *fmt, ...)
__attribute__ ((noreturn, format (printf, 1, 2)));
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index 16bc5237a..c3303d247 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -70,43 +70,9 @@
* towctrans function. */
/* #define SMALL_UPLOW */
-/**********************************************************************/
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
-/* generates one warning */
-#warning TODO: Fix the __CTYPE_* codes!
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-#if 1
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace
-};
-#endif
+/* Pull in __CTYPE_xxx constants */
+#include <bits/uClibc_charclass.h>
/* The following is used to implement wctype(), but it is defined
@@ -502,7 +468,6 @@ libc_hidden_def(towupper)
#ifdef L_wctype
static const unsigned char typestring[] = __CTYPE_TYPESTRING;
-/* extern const unsigned char typestring[]; */
/* libc_hidden_proto(wctype) */
wctype_t wctype(const char *property)
@@ -513,7 +478,7 @@ wctype_t wctype(const char *property)
p = typestring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char *) ++p)) {
return i;
}
++i;
@@ -913,10 +878,10 @@ wctrans_t wctrans(const char *property)
const unsigned char *p;
int i;
- p = transstring;
+ p = (const unsigned char *) transstring;
i = 1;
do {
- if (!strcmp(property, ++p)) {
+ if (!strcmp(property, (const char*) ++p)) {
return i;
}
++i;
diff --git a/libc/stdio/_scanf.c b/libc/stdio/_scanf.c
index da13f1fb2..003cd2469 100644
--- a/libc/stdio/_scanf.c
+++ b/libc/stdio/_scanf.c
@@ -586,13 +586,15 @@ enum {
#define QUAL_CHARS { \
/* j:(u)intmax_t z:(s)size_t t:ptrdiff_t \0:int q:long_long */ \
'h', 'l', 'L', 'j', 'z', 't', 'q', 0, \
- 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */\
- 1, 8 }
+ 2, 4, 8, IMS, SS, PDS, 8, 0, /* TODO -- fix!!! */ \
+ 1, 8 \
+}
/**********************************************************************/
#ifdef L_vfwscanf
+/* FIXME: "warning: the right operand of ">" changes sign when promoted" */
#if WINT_MIN > EOF
#error Unfortunately, we currently need wint_t to be able to store EOF. Sorry.
#endif
@@ -718,7 +720,7 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc,
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (*(sc->grouping = __UCLIBC_CURLOCALE_DATA.grouping)) {
- sc->thousands_sep = __UCLIBC_CURLOCALE_DATA.thousands_sep;
+ sc->thousands_sep = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.thousands_sep;
sc->tslen = __UCLIBC_CURLOCALE_DATA.thousands_sep_len;
#ifdef __UCLIBC_HAS_WCHAR__
sc->thousands_sep_wc = __UCLIBC_CURLOCALE_DATA.thousands_sep_wc;
@@ -728,7 +730,7 @@ void attribute_hidden __init_scan_cookie(register struct scan_cookie *sc,
#ifdef __UCLIBC_HAS_FLOATS__
#ifdef __UCLIBC_HAS_LOCALE__
- sc->decpt = __UCLIBC_CURLOCALE_DATA.decimal_point;
+ sc->decpt = (const unsigned char *) __UCLIBC_CURLOCALE_DATA.decimal_point;
sc->decpt_len = __UCLIBC_CURLOCALE_DATA.decimal_point_len;
#else /* __UCLIBC_HAS_LOCALE__ */
sc->fake_decpt = sc->decpt = (unsigned char *) decpt_str;
@@ -1154,22 +1156,12 @@ static __inline void kill_scan_cookie(register struct scan_cookie *sc)
#endif
}
-#ifdef L_vfwscanf
-#ifdef __UCLIBC_HAS_FLOATS__
-static const char fake_decpt_str[] = ".";
-#endif
-#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
-static const char fake_thousands_sep_str[] = ",";
-#endif
-#endif /* L_vfwscanf */
-
int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
{
const Wuchar *fmt;
unsigned char *b;
-
#ifdef L_vfwscanf
wchar_t wbuf[1];
wchar_t *wb;
@@ -1181,7 +1173,6 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
struct scan_cookie sc;
psfs_t psfs;
-
int i;
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1233,13 +1224,13 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if (*sc.grouping) {
- sc.thousands_sep = fake_thousands_sep_str;
+ sc.thousands_sep = (const unsigned char *) ",";
sc.tslen = 1;
}
#endif /* __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__ */
#ifdef __UCLIBC_HAS_FLOATS__
- sc.fake_decpt = fake_decpt_str;
+ sc.fake_decpt = (const unsigned char *) ".";
#endif /* __UCLIBC_HAS_FLOATS__ */
#else /* L_vfwscanf */
@@ -1607,7 +1598,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1635,7 +1626,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1709,7 +1700,7 @@ int VFSCANF (FILE *__restrict fp, const Wchar *__restrict format, va_list arg)
*wb = sc.wc;
wb += psfs.store;
} else {
- i = wcrtomb(b, sc.wc, &mbstate);
+ i = wcrtomb((char*) b, sc.wc, &mbstate);
if (i < 0) { /* Conversion failure. */
goto DONE_DO_UNGET;
}
@@ -1882,7 +1873,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
#ifdef __UCLIBC_HAS_GLIBC_DIGIT_GROUPING__
if ((psfs->flags & FLAG_THOUSANDS) && (base == 10)
- && *(p = sc->grouping)
+ && *(p = (const unsigned char *) sc->grouping)
) {
int nblk1, nblk2, nbmax, lastblock, pass, i;
@@ -2004,7 +1995,7 @@ int attribute_hidden __psfs_do_numeric(psfs_t *psfs, struct scan_cookie *sc)
p = sc->fake_decpt + k;
do {
if (!*++p) {
- strcpy(b, sc->decpt);
+ strcpy((char*) b, (char*) sc->decpt);
b += sc->decpt_len;
goto GOT_DECPT;
}
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 5ce3f8a59..850c83486 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -1214,7 +1214,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad);
#define _PPFS_init _ppfs_init
#define OUTPUT(F,S) fputs_unlocked(S,F)
/* #define _outnstr(stream, string, len) __stdio_fwrite(string, len, stream) */
-#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite(string, len, stream) : 0)
+#define _outnstr(stream, string, len) ((len > 0) ? __stdio_fwrite((const unsigned char *)(string), len, stream) : 0)
#define FP_OUT _fp_out_narrow
#ifdef __STDIO_PRINTF_FLOAT
@@ -1232,7 +1232,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
}
len = buflen;
}
- return r + OUTNSTR(fp, (const unsigned char *) buf, len);
+ return r + OUTNSTR(fp, (const char *) buf, len);
}
#endif /* __STDIO_PRINTF_FLOAT */
@@ -1247,7 +1247,7 @@ static size_t _fp_out_narrow(FILE *fp, intptr_t type, intptr_t len, intptr_t buf
/* Pulls in fseek: */
#define OUTPUT(F,S) fputws(S,F)
/* TODO: #define OUTPUT(F,S) _wstdio_fwrite((S),wcslen(S),(F)) */
-#define _outnwcs(stream, wstring, len) _wstdio_fwrite(wstring, len, stream)
+#define _outnwcs(stream, wstring, len) _wstdio_fwrite((const wchar_t *)(wstring), len, stream)
#define FP_OUT _fp_out_wide
static size_t _outnstr(FILE *stream, const char *s, size_t wclen)
@@ -1428,7 +1428,7 @@ static size_t _charpad(FILE * __restrict stream, int padchar, size_t numpad)
FMT_TYPE pad[1];
*pad = padchar;
- while (todo && (OUTNSTR(stream, (const unsigned char *) pad, 1) == 1)) {
+ while (todo && (OUTNSTR(stream, (const char *) pad, 1) == 1)) {
--todo;
}
@@ -1874,7 +1874,7 @@ int VFPRINTF_internal (FILE * __restrict stream,
s = format;
if (_PPFS_init(&ppfs, format) < 0) { /* Bad format string. */
- OUTNSTR(stream, (const unsigned char *) ppfs.fmtpos,
+ OUTNSTR(stream, (const char *) ppfs.fmtpos,
STRLEN((const FMT_TYPE *)(ppfs.fmtpos)));
#if defined(L__vfprintf_internal) && !defined(NDEBUG)
fprintf(stderr,"\nIMbS: \"%s\"\n\n", format);
@@ -1888,8 +1888,9 @@ int VFPRINTF_internal (FILE * __restrict stream,
++format;
}
- if (format-s) { /* output any literal text in format string */
- if ( (r = OUTNSTR(stream, (const unsigned char *) s, format-s)) != (format-s)) {
+ if (format - s) { /* output any literal text in format string */
+ r = OUTNSTR(stream, (const char *) s, format - s);
+ if (r != (format - s)) {
count = -1;
break;
}
diff --git a/libc/stdio/_wfwrite.c b/libc/stdio/_wfwrite.c
index 8fa59f87d..81f5bd4e8 100644
--- a/libc/stdio/_wfwrite.c
+++ b/libc/stdio/_wfwrite.c
@@ -38,7 +38,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
}
if (count) {
wmemcpy((wchar_t *)(stream->__bufpos), ws, count);
- stream->__bufpos = (char *)(((wchar_t *)(stream->__bufpos)) + count);
+ stream->__bufpos = (unsigned char *)(((wchar_t *)(stream->__bufpos)) + count);
}
__STDIO_STREAM_VALIDATE(stream);
return n;
@@ -59,7 +59,7 @@ size_t attribute_hidden _wstdio_fwrite(const wchar_t *__restrict ws, size_t n,
++r; /* 0 is returned when nul is reached. */
pw = ws + count + r; /* pw was set to NULL, so correct. */
}
- if (__stdio_fwrite(buf, r, stream) == r) {
+ if (__stdio_fwrite((const unsigned char *)buf, r, stream) == r) {
count = pw - ws;
continue;
}
diff --git a/libc/stdio/fgetwc.c b/libc/stdio/fgetwc.c
index 34327434c..18a6b5bb5 100644
--- a/libc/stdio/fgetwc.c
+++ b/libc/stdio/fgetwc.c
@@ -58,12 +58,12 @@ wint_t fgetwc_unlocked(register FILE *stream)
stream->__ungot_width[0] = 0; /* then reset the width. */
}
- LOOP:
+ LOOP:
if ((n = __STDIO_STREAM_BUFFER_RAVAIL(stream)) == 0) {
goto FILL_BUFFER;
}
- r = mbrtowc(wc, stream->__bufpos, n, &stream->__state);
+ r = mbrtowc(wc, (const char*) stream->__bufpos, n, &stream->__state);
if (((ssize_t) r) >= 0) { /* Success... */
if (r == 0) { /* Nul wide char... means 0 byte for us so */
++r; /* increment r and handle below as single. */
@@ -78,7 +78,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
/* Potentially valid but incomplete and no more buffered. */
stream->__bufpos += n; /* Update bufpos for stream. */
stream->__ungot_width[0] += n;
- FILL_BUFFER:
+ FILL_BUFFER:
if(__STDIO_FILL_READ_BUFFER(stream)) { /* Refill succeeded? */
goto LOOP;
}
@@ -98,7 +98,7 @@ wint_t fgetwc_unlocked(register FILE *stream)
* error indicator is set. */
stream->__modeflags |= __FLAG_ERROR;
- DONE:
+ DONE:
if (stream->__bufstart == sbuf) { /* Need to un-munge the stream. */
munge_stream(stream, NULL);
}
diff --git a/libc/stdio/vswprintf.c b/libc/stdio/vswprintf.c
index beadb8a7d..10f7cc467 100644
--- a/libc/stdio/vswprintf.c
+++ b/libc/stdio/vswprintf.c
@@ -46,8 +46,8 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
size = ((SIZE_MAX - (size_t) buf)/sizeof(wchar_t));
}
- f.__bufstart = (char *) buf;
- f.__bufend = (char *)(buf + size);
+ f.__bufstart = (unsigned char *) buf;
+ f.__bufend = (unsigned char *) (buf + size);
__STDIO_STREAM_INIT_BUFREAD_BUFPOS(&f);
__STDIO_STREAM_DISABLE_GETC(&f);
__STDIO_STREAM_DISABLE_PUTC(&f);
@@ -58,7 +58,7 @@ int vswprintf(wchar_t *__restrict buf, size_t size,
if (f.__bufpos == f.__bufend) {
rv = -1;
if (size) {
- f.__bufpos = (char *)(((wchar_t *) f.__bufpos) - 1);
+ f.__bufpos = (unsigned char *) (((wchar_t *) f.__bufpos) - 1);
}
}
if (size) {
diff --git a/libc/string/generic/bp-checks.h b/libc/string/generic/bp-checks.h
deleted file mode 100644
index 08c70aa5d..000000000
--- a/libc/string/generic/bp-checks.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Bounded-pointer checking macros for C.
- Copyright (C) 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Greg McGary <greg@mcgary.org>
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _bp_checks_h_
-#define _bp_checks_h_ 1
-
-#if __BOUNDED_POINTERS__
-
-# define BOUNDS_VIOLATED (__builtin_trap (), 0)
-
-/* Verify that pointer's value >= low. Return pointer value. */
-# define CHECK_BOUNDS_LOW(ARG) \
- (((__ptrvalue (ARG) < __ptrlow (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-/* Verify that pointer's value < high. Return pointer value. */
-# define CHECK_BOUNDS_HIGH(ARG) \
- (((__ptrvalue (ARG) > __ptrhigh (ARG)) && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-# define _CHECK_N(ARG, N, COND) \
- (((COND) \
- && (__ptrvalue (ARG) < __ptrlow (ARG) \
- || __ptrvalue (ARG) + (N) > __ptrhigh (ARG)) \
- && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-extern void *__unbounded __ubp_memchr (const void *__unbounded, int, unsigned);
-
-# define _CHECK_STRING(ARG, COND) \
- (((COND) \
- && (__ptrvalue (ARG) < __ptrlow (ARG) \
- || !__ubp_memchr (__ptrvalue (ARG), '\0', \
- (__ptrhigh (ARG) - __ptrvalue (ARG)))) \
- && BOUNDS_VIOLATED), \
- __ptrvalue (ARG))
-
-/* Check bounds of a pointer seated to an array of N objects. */
-# define CHECK_N(ARG, N) _CHECK_N ((ARG), (N), 1)
-/* Same as CHECK_N, but tolerate ARG == NULL. */
-# define CHECK_N_NULL_OK(ARG, N) _CHECK_N ((ARG), (N), __ptrvalue (ARG))
-
-/* Check bounds of a pointer seated to a single object. */
-# define CHECK_1(ARG) CHECK_N ((ARG), 1)
-/* Same as CHECK_1, but tolerate ARG == NULL. */
-# define CHECK_1_NULL_OK(ARG) CHECK_N_NULL_OK ((ARG), 1)
-
-/* Check for NUL-terminator within string's bounds. */
-# define CHECK_STRING(ARG) _CHECK_STRING ((ARG), 1)
-/* Same as CHECK_STRING, but tolerate ARG == NULL. */
-# define CHECK_STRING_NULL_OK(ARG) _CHECK_STRING ((ARG), __ptrvalue (ARG))
-
-/* Check bounds of signal syscall args with type sigset_t. */
-# define CHECK_SIGSET(SET) CHECK_N ((SET), _NSIG / (8 * sizeof *(SET)))
-/* Same as CHECK_SIGSET, but tolerate SET == NULL. */
-# define CHECK_SIGSET_NULL_OK(SET) CHECK_N_NULL_OK ((SET), _NSIG / (8 * sizeof *(SET)))
-
-# if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
-/* Extract the size of the ioctl data and check its bounds. */
-# define CHECK_IOCTL(ARG, CMD) \
- CHECK_N ((const char *) (ARG), \
- (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
-# else
-/* We don't know the size of the ioctl data, so the best we can do
- is check that the first byte is within bounds. */
-# define CHECK_IOCTL(ARG, CMD) CHECK_1 ((const char *) ARG)
-# endif
-
-/* Check bounds of `struct flock *' for the locking fcntl commands. */
-# define CHECK_FCNTL(ARG, CMD) \
- (((CMD) == F_GETLK || (CMD) == F_SETLK || (CMD) == F_SETLKW) \
- ? CHECK_1 ((struct flock *) ARG) : (unsigned long) (ARG))
-
-/* Check bounds of an array of mincore residency-status flags that
- cover a region of NBYTES. Such a vector occupies one byte per page
- of memory. */
-# define CHECK_N_PAGES(ARG, NBYTES) \
- ({ int _page_size_ = __sysconf (_SC_PAGE_SIZE); \
- CHECK_N ((const char *) (ARG), \
- ((NBYTES) + _page_size_ - 1) / _page_size_); })
-
-/* Return a bounded pointer with value PTR that satisfies CHECK_N (PTR, N). */
-# define BOUNDED_N(PTR, N) \
- ({ __typeof (PTR) __bounded _p_; \
- __ptrvalue _p_ = __ptrlow _p_ = __ptrvalue (PTR); \
- __ptrhigh _p_ = __ptrvalue _p_ + (N); \
- _p_; })
-
-#else /* !__BOUNDED_POINTERS__ */
-
-/* Do nothing if not compiling with -fbounded-pointers. */
-
-# define BOUNDS_VIOLATED
-# define CHECK_BOUNDS_LOW(ARG) (ARG)
-# define CHECK_BOUNDS_HIGH(ARG) (ARG)
-# define CHECK_1(ARG) (ARG)
-# define CHECK_1_NULL_OK(ARG) (ARG)
-# define CHECK_N(ARG, N) (ARG)
-# define CHECK_N_NULL_OK(ARG, N) (ARG)
-# define CHECK_STRING(ARG) (ARG)
-# define CHECK_SIGSET(SET) (SET)
-# define CHECK_SIGSET_NULL_OK(SET) (SET)
-# define CHECK_IOCTL(ARG, CMD) (ARG)
-# define CHECK_FCNTL(ARG, CMD) (ARG)
-# define CHECK_N_PAGES(ARG, NBYTES) (ARG)
-# define BOUNDED_N(PTR, N) (PTR)
-
-#endif /* !__BOUNDED_POINTERS__ */
-
-#define BOUNDED_1(PTR) BOUNDED_N (PTR, 1)
-
-#endif /* _bp_checks_h_ */
diff --git a/libc/string/generic/memcmp.c b/libc/string/generic/memcmp.c
index fc63a2eae..27db6b3d3 100644
--- a/libc/string/generic/memcmp.c
+++ b/libc/string/generic/memcmp.c
@@ -26,10 +26,6 @@
#include <endian.h>
#if __BYTE_ORDER == __BIG_ENDIAN
-# define WORDS_BIGENDIAN
-#endif
-
-#ifdef WORDS_BIGENDIAN
# define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1)
#else
# define CMP_LT_OR_GT(a, b) memcmp_bytes ((a), (b))
@@ -48,17 +44,12 @@
3. Compare the few remaining bytes. */
-#ifndef WORDS_BIGENDIAN
+#if __BYTE_ORDER != __BIG_ENDIAN
/* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine.
A and B are known to be different.
This is needed only on little-endian machines. */
-static int memcmp_bytes __P((op_t, op_t));
-
-# ifdef __GNUC__
-__inline
-# endif
-static int
+static __inline__ int
memcmp_bytes (op_t a, op_t b)
{
long int srcp1 = (long int) &a;
@@ -77,8 +68,6 @@ memcmp_bytes (op_t a, op_t b)
}
#endif
-static int memcmp_common_alignment __P((long, long, size_t));
-
/* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for
memory operations on `op_t's. */
@@ -161,8 +150,6 @@ memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
return 0;
}
-static int memcmp_not_common_alignment __P((long, long, size_t));
-
/* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
`op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory
operations on `op_t', but SRCP1 *should be unaligned*. */
diff --git a/libc/string/generic/strcpy.c b/libc/string/generic/strcpy.c
index 99e077139..b9a0a286a 100644
--- a/libc/string/generic/strcpy.c
+++ b/libc/string/generic/strcpy.c
@@ -20,28 +20,18 @@
#include <stddef.h>
#include "memcopy.h"
-#include "bp-checks.h"
/* Experimentally off - libc_hidden_proto(strcpy) */
/* Copy SRC to DEST. */
-char *strcpy (char *dest, const char *src)
+char *strcpy(char *dest, const char *src)
{
- reg_char c;
- char *__unbounded s = (char *__unbounded) CHECK_BOUNDS_LOW (src);
- const ptrdiff_t off = CHECK_BOUNDS_LOW (dest) - s - 1;
- size_t n;
-
- do
- {
- c = *s++;
- s[off] = c;
- }
- while (c != '\0');
-
- n = s - src;
- (void) CHECK_BOUNDS_HIGH (src + n);
- (void) CHECK_BOUNDS_HIGH (dest + n);
-
- return dest;
+ char *dst = dest;
+
+ while ((*dst = *src) != '\0') {
+ src++;
+ dst++;
+ }
+
+ return dest;
}
libc_hidden_def(strcpy)
diff --git a/libc/string/i386/memchr.c b/libc/string/i386/memchr.c
index 5c64445e0..c2fc44b4a 100644
--- a/libc/string/i386/memchr.c
+++ b/libc/string/i386/memchr.c
@@ -33,19 +33,43 @@
#include <string.h>
#undef memchr
-void *memchr(const void *cs, int c, size_t count)
+//#define memchr TESTING
+void *memchr(const void *s, int c, size_t count)
{
- int d0;
- register void * __res;
- if (!count)
- return NULL;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "je 1f\n\t"
- "movl $1,%0\n"
- "1:\tdecl %0"
- :"=D" (__res), "=&c" (d0) : "a" (c),"0" (cs),"1" (count));
- return __res;
+ void *edi;
+ int ecx;
+ __asm__ __volatile__(
+ " jecxz 1f\n"
+ " repne; scasb\n"
+ " leal -1(%%edi), %%edi\n"
+ " je 2f\n"
+ "1:\n"
+ " xorl %%edi, %%edi\n" /* NULL */
+ "2:\n"
+ : "=&D" (edi), "=&c" (ecx)
+ : "a" (c), "0" (s), "1" (count)
+ /* : no clobbers */
+ );
+ return edi;
}
+#ifndef memchr
libc_hidden_def(memchr)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os memchr.c -o memchr
+ * and run ./memchr
+ */
+int main()
+{
+ static const char str[] = "abc.def";
+ printf((char*)memchr(str, '.',-2) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.',-1) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 0) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 1) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 2) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 3) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 4) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str+3, '.', 0) == NULL ? "ok\n" : "BAD!\n");
+ printf((char*)memchr(str+3, '.', 5) - str == 3 ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/memcpy.c b/libc/string/i386/memcpy.c
index af86cf255..697d0bdc2 100644
--- a/libc/string/i386/memcpy.c
+++ b/libc/string/i386/memcpy.c
@@ -38,11 +38,11 @@ void *memcpy(void * to, const void * from, size_t n)
int d0, d1, d2;
__asm__ __volatile__(
" rep; movsl\n"
- " movl %4,%%ecx\n"
- " andl $3,%%ecx\n"
+ " movl %4, %%ecx\n"
+ " andl $3, %%ecx\n"
/* jz is optional. avoids "rep; movsb" with ecx == 0,
* but adds a branch, which is currently (2008) faster */
- " jz 1f\n"
+ " jz 1f\n"
" rep; movsb\n"
"1:\n"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
diff --git a/libc/string/i386/memmove.c b/libc/string/i386/memmove.c
index a924efcbc..72d8002a5 100644
--- a/libc/string/i386/memmove.c
+++ b/libc/string/i386/memmove.c
@@ -32,28 +32,40 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(memmove) */
+#undef memmove
+//#define memmove TESTING
void *memmove(void *dest, const void *src, size_t n)
{
- int d0, d1, d2;
- if (dest<src)
+ int eax, ecx, esi, edi;
__asm__ __volatile__(
- "rep\n\t"
- "movsb"
- : "=&c" (d0), "=&S" (d1), "=&D" (d2)
- :"0" (n),"1" (src),"2" (dest)
- : "memory");
- else
- __asm__ __volatile__(
- "std\n\t"
- "rep\n\t"
- "movsb\n\t"
- "cld"
- : "=&c" (d0), "=&S" (d1), "=&D" (d2)
- :"0" (n),
- "1" (n-1+(const char *)src),
- "2" (n-1+(char *)dest)
- :"memory");
- return dest;
+ " movl %%eax, %%edi\n"
+ " cmpl %%esi, %%eax\n"
+ " je 2f\n" /* (optional) src == dest -> NOP */
+ " jb 1f\n" /* src > dest -> simple copy */
+ " leal -1(%%esi,%%ecx), %%esi\n"
+ " leal -1(%%eax,%%ecx), %%edi\n"
+ " std\n"
+ "1: rep; movsb\n"
+ " cld\n"
+ "2:\n"
+ : "=&c" (ecx), "=&S" (esi), "=&a" (eax), "=&D" (edi)
+ : "0" (n), "1" (src), "2" (dest)
+ : "memory"
+ );
+ return (void*)eax;
}
+#ifndef memmove
libc_hidden_def(memmove)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os memmove.c -o memmove
+ * and run ./memmove
+ */
+int main()
+{
+ static char str[] = "abcdef.123";
+ memmove(str + 1, str, 5);
+ printf(strcmp(str, "aabcde.123") == 0 ? "ok\n" : "BAD!\n");
+ memmove(str, str + 1, 5);
+ printf(strcmp(str, "abcdee.123") == 0 ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/memset.c b/libc/string/i386/memset.c
index 779725f2f..cfc16983c 100644
--- a/libc/string/i386/memset.c
+++ b/libc/string/i386/memset.c
@@ -32,6 +32,7 @@
#include <string.h>
+/* Experimentally off - libc_hidden_proto(memset) */
#undef memset
void *memset(void *s, int c, size_t count)
{
diff --git a/libc/string/i386/strchr.c b/libc/string/i386/strchr.c
index 46b1dfb6e..93cc9583e 100644
--- a/libc/string/i386/strchr.c
+++ b/libc/string/i386/strchr.c
@@ -32,23 +32,25 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strchr) */
+#undef strchr
char *strchr(const char *s, int c)
{
- int d0;
- register char * __res;
- __asm__ __volatile__(
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "je 2f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "movl $1,%1\n"
- "2:\tmovl %1,%0\n\t"
- "decl %0"
- :"=a" (__res), "=&S" (d0) : "1" (s),"0" (c));
- return __res;
+ int esi;
+ register char * eax;
+ __asm__ __volatile__(
+ " movb %%al, %%ah\n"
+ "1: lodsb\n"
+ " cmpb %%ah, %%al\n"
+ " je 2f\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ " movl $1, %%esi\n" /* can use shorter xor + inc */
+ "2: leal -1(%%esi), %%eax\n"
+ : "=a" (eax), "=&S" (esi)
+ : "0" (c), "1" (s)
+ /* no clobbers */
+ );
+ return eax;
}
libc_hidden_def(strchr)
#ifdef __UCLIBC_SUSV3_LEGACY__
diff --git a/libc/string/i386/strcpy.c b/libc/string/i386/strcpy.c
index 09065a9b7..fff1bd006 100644
--- a/libc/string/i386/strcpy.c
+++ b/libc/string/i386/strcpy.c
@@ -32,7 +32,7 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strcpy) */
+#undef strcpy
char *strcpy(char * dest, const char * src)
{
int d0, d1, d2;
diff --git a/libc/string/i386/strlen.c b/libc/string/i386/strlen.c
index 61a178393..ff2baeb38 100644
--- a/libc/string/i386/strlen.c
+++ b/libc/string/i386/strlen.c
@@ -32,17 +32,17 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strlen) */
+#undef strlen
size_t strlen(const char *s)
{
- int d0;
- register int __res;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "notl %0\n\t"
- "decl %0"
- :"=c" (__res), "=&D" (d0) :"1" (s),"a" (0), "0" (0xffffffff));
- return __res;
+ int eax, ecx, edi;
+ __asm__ __volatile__(
+ " repne; scasb\n"
+ " notl %%ecx\n"
+ " leal -1(%%ecx), %%eax\n"
+ : "=&c" (ecx), "=&D" (edi), "=&a" (eax)
+ : "0" (0xffffffff), "1" (s), "2" (0)
+ );
+ return eax;
}
libc_hidden_def(strlen)
diff --git a/libc/string/i386/strncat.c b/libc/string/i386/strncat.c
index 3872679d5..640b0d213 100644
--- a/libc/string/i386/strncat.c
+++ b/libc/string/i386/strncat.c
@@ -32,30 +32,55 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncat) */
-char *strncat(char * dest,
- const char * src, size_t count)
+#undef strncat
+//#define strncat TESTING
+char *strncat(char * dest, const char * src, size_t count)
{
- int d0, d1, d2, d3;
- __asm__ __volatile__(
- "repne\n\t"
- "scasb\n\t"
- "decl %1\n\t"
- "movl %8,%3\n"
- "incl %3\n"
- "1:\tdecl %3\n\t"
- "jz 2f\n"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "jmp 3f\n"
- "2:\txorl %2,%2\n\t"
- "stosb\n"
- "3:"
- : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
- : "0" (src),"1" (dest),"2" (0),"3" (0xffffffff), "g" (count)
- : "memory");
- return dest;
+ int esi, edi, eax, ecx, edx;
+ __asm__ __volatile__(
+ " xorl %%eax, %%eax\n"
+ " incl %%edx\n"
+ " pushl %%edi\n" /* save dest */
+ " repne; scasb\n"
+ " decl %%edi\n" /* edi => NUL in dest */
+ /* count-- */
+ "1: decl %%edx\n"
+ /* if count reached 0, store NUL and bail out */
+ " movl %%edx, %%eax\n"
+ " jz 2f\n"
+ /* else copy a char */
+ " lodsb\n"
+ "2: stosb\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ /* end of loop */
+ " popl %%eax\n" /* restore dest into eax */
+ : "=&S" (esi), "=&D" (edi), "=&a" (eax), "=&c" (ecx), "=&d" (edx)
+ : "0" (src), "1" (dest), "3" (0xffffffff), "4" (count)
+ : "memory"
+ );
+ return (char *)eax;
}
+#ifndef strncat
libc_hidden_def(strncat)
+#else
+/* Uncomment TESTING, gcc -m32 -Os strncat.c -o strncat
+ * and run ./strncat
+ */
+int main()
+{
+ char buf[99];
+
+ strcpy(buf, "abc"); buf[4] = '*'; strncat(buf, "def", 0);
+ printf(strcmp(buf, "abc") == 0 && buf[4] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def", 50);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def", -1);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+
+ strcpy(buf, "abc"); buf[6] = 1; buf[7] = '*'; strncat(buf, "def123", 3);
+ printf(strcmp(buf, "abcdef") == 0 && buf[7] == '*' ? "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/strncmp.c b/libc/string/i386/strncmp.c
index a14bb503b..bfb20c307 100644
--- a/libc/string/i386/strncmp.c
+++ b/libc/string/i386/strncmp.c
@@ -32,27 +32,28 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncmp) */
+#undef strncmp
int strncmp(const char *cs, const char *ct, size_t count)
{
- register int __res;
- int d0, d1, d2;
- __asm__ __volatile__(
- "incl %3\n"
- "1:\tdecl %3\n\t"
- "jz 2f\n"
- "lodsb\n\t"
- "scasb\n\t"
- "jne 3f\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n"
- "2:\txorl %%eax,%%eax\n\t"
- "jmp 4f\n"
- "3:\tsbbl %%eax,%%eax\n\t"
- "orb $1,%%al\n"
- "4:"
- :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
- :"1" (cs),"2" (ct),"3" (count));
- return __res;
+ int eax;
+ int esi, edi, ecx;
+ __asm__ __volatile__(
+ " incl %%ecx\n"
+ "1: decl %%ecx\n"
+ " jz 2f\n"
+ " lodsb\n"
+ " scasb\n"
+ " jne 3f\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ "2: xorl %%eax, %%eax\n"
+ " jmp 4f\n"
+ "3: sbbl %%eax, %%eax\n"
+ " orb $1, %%al\n"
+ "4:\n"
+ : "=a" (eax), "=&S" (esi), "=&D" (edi), "=&c" (ecx)
+ : "1" (cs), "2" (ct), "3" (count)
+ );
+ return eax;
}
libc_hidden_weak(strncmp)
diff --git a/libc/string/i386/strncpy.c b/libc/string/i386/strncpy.c
index 76aa6ae1b..e1c7f1dcf 100644
--- a/libc/string/i386/strncpy.c
+++ b/libc/string/i386/strncpy.c
@@ -32,25 +32,44 @@
#include <string.h>
-/* Experimentally off - libc_hidden_proto(strncpy) */
+#undef strncpy
+//#define strncpy TESTING
char *strncpy(char * dest, const char * src, size_t count)
{
- int d0, d1, d2, d3;
- __asm__ __volatile__(
- "incl %2\n"
- "1:\n"
- "decl %2\n"
- "jz 2f\n"
- "lodsb\n\t"
- "stosb\n\t"
- "testb %%al,%%al\n\t"
- "jne 1b\n\t"
- "decl %2\n"
- "rep\n\t"
- "stosb\n"
- "2:"
- : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
- :"0" (src),"1" (dest),"2" (count) : "memory");
- return dest;
+ int esi, edi, ecx, eax;
+ __asm__ __volatile__(
+ "1: subl $1, %%ecx\n" /* not dec! it doesnt set CF */
+ " jc 2f\n"
+ " lodsb\n"
+ " stosb\n"
+ " testb %%al, %%al\n"
+ " jnz 1b\n"
+ " rep; stosb\n"
+ "2:\n"
+ : "=&S" (esi), "=&D" (edi), "=&c" (ecx), "=&a" (eax)
+ : "0" (src), "1" (dest), "2" (count)
+ : "memory"
+ );
+ return dest;
}
+#ifndef strncpy
libc_hidden_def(strncpy)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strncpy.c -o strncpy
+ * and run ./strncpy
+ */
+int main()
+{
+ static char str[99];
+
+ str[3] = '*'; str[4] = 0; strncpy(str, "abc", 3);
+ printf(strcmp(str, "abc*") == 0 ? "ok\n" : "BAD!\n");
+
+ str[4] = '*'; str[5] = '+'; strncpy(str, "abc", 5);
+ printf(strcmp(str, "abc") == 0 && str[4] == 0 && str[5] == '+' ?
+ "ok\n" : "BAD!\n");
+ strncpy(str, "def", 0); /* should do nothing */
+ printf(strcmp(str, "abc") == 0 && str[4] == 0 && str[5] == '+' ?
+ "ok\n" : "BAD!\n");
+}
+#endif
diff --git a/libc/string/i386/strnlen.c b/libc/string/i386/strnlen.c
index 02c72f530..3abde48e2 100644
--- a/libc/string/i386/strnlen.c
+++ b/libc/string/i386/strnlen.c
@@ -33,24 +33,43 @@
#include <string.h>
#ifdef __USE_GNU
-/* Experimentally off - libc_hidden_proto(strnlen) */
+
+#undef strnlen
+//#define strnlen TESTING
size_t strnlen(const char *s, size_t count)
{
- int d0;
- register int __res;
- __asm__ __volatile__(
- "movl %2,%0\n\t"
- "incl %1\n"
- "jmp 2f\n"
- "1:\tcmpb $0,(%0)\n\t"
- "je 3f\n\t"
- "incl %0\n"
- "2:\tdecl %1\n\t"
- "jne 1b\n"
- "3:\tsubl %2,%0"
- :"=a" (__res), "=&d" (d0)
- :"c" (s),"1" (count));
- return __res;
+ int edx;
+ int eax;
+ __asm__ __volatile__(
+ " leal -1(%%ecx), %%eax\n"
+ "1: incl %%eax\n"
+ " decl %%edx\n"
+ " jz 3f\n"
+ " cmpb $0, (%%eax)\n"
+ " jnz 1b\n"
+ "3: subl %%ecx, %%eax"
+ : "=a" (eax), "=&d" (edx)
+ : "c" (s), "1" (count + 1)
+ );
+ return eax;
}
+#ifndef strnlen
libc_hidden_def(strnlen)
+#else
+/* Uncomment TESTING, gcc -D_GNU_SOURCE -m32 -Os strnlen.c -o strnlen
+ * and run ./strnlen
+ */
+int main()
+{
+ printf(strnlen("abc\0def", -2) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", -1) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 0) == 0 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 1) == 1 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 2) == 2 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 3) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 4) == 3 ? "ok\n" : "BAD!\n");
+ printf(strnlen("abc\0def", 5) == 3 ? "ok\n" : "BAD!\n");
+}
+#endif
+
#endif
diff --git a/libc/string/i386/strrchr.c b/libc/string/i386/strrchr.c
index ef378685b..9f2c74923 100644
--- a/libc/string/i386/strrchr.c
+++ b/libc/string/i386/strrchr.c
@@ -35,18 +35,23 @@
/* Experimentally off - libc_hidden_proto(strrchr) */
char *strrchr(const char *s, int c)
{
- int d0, d1;
- register char * __res;
- __asm__ __volatile__(
- "movb %%al,%%ah\n"
- "1:\tlodsb\n\t"
- "cmpb %%ah,%%al\n\t"
- "jne 2f\n\t"
- "leal -1(%%esi),%0\n"
- "2:\ttestb %%al,%%al\n\t"
- "jne 1b"
- :"=g" (__res), "=&S" (d0), "=&a" (d1) :"0" (0),"1" (s),"2" (c));
- return __res;
+ char *eax;
+
+ __asm__ __volatile__(
+ " movb %%cl, %%ch\n"
+ "1: movb (%1), %%cl\n" /* load char */
+ " cmpb %%cl, %%ch\n" /* char == c? */
+ " jne 2f\n"
+ " movl %1, %%eax\n"
+ "2: incl %1\n"
+ " testb %%cl, %%cl\n" /* char == NUL? */
+ " jnz 1b\n"
+ /* "=c": use ecx, not ebx (-fpic uses it). */
+ : "=a" (eax), "=r" (s), "=c" (c)
+ : "0" (0), "1" (s), "2" (c)
+ /* : no clobbers */
+ );
+ return eax;
}
libc_hidden_def(strrchr)
#ifdef __UCLIBC_SUSV3_LEGACY__
diff --git a/libc/string/ia64/memchr.S b/libc/string/ia64/memchr.S
index 0246b5997..f25e80302 100644
--- a/libc/string/ia64/memchr.S
+++ b/libc/string/ia64/memchr.S
@@ -126,8 +126,6 @@ ENTRY(__memchr)
END(__memchr)
-weak_alias (__memchr, memchr)
-#if !__BOUNDED_POINTERS__
-weak_alias (__memchr, __ubp_memchr)
-#endif
-libc_hidden_def (memchr)
+weak_alias(__memchr, memchr)
+weak_alias(__memchr, __ubp_memchr)
+libc_hidden_def(memchr)
diff --git a/libc/string/memchr.c b/libc/string/memchr.c
index 5e60f6554..438f4fa4a 100644
--- a/libc/string/memchr.c
+++ b/libc/string/memchr.c
@@ -10,6 +10,7 @@
#ifdef WANT_WIDE
# define Wmemchr wmemchr
#else
+# undef memchr
# define Wmemchr memchr
#endif
diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c
index aa8d4ee38..cbb6e633a 100644
--- a/libc/string/memcpy.c
+++ b/libc/string/memcpy.c
@@ -10,6 +10,7 @@
#ifdef WANT_WIDE
# define Wmemcpy wmemcpy
#else
+# undef memcpy
# define Wmemcpy memcpy
#endif
diff --git a/libc/string/mempcpy.c b/libc/string/mempcpy.c
index e7605146a..d79bd1937 100644
--- a/libc/string/mempcpy.c
+++ b/libc/string/mempcpy.c
@@ -12,6 +12,7 @@
#ifdef WANT_WIDE
# define Wmempcpy wmempcpy
#else
+# undef mempcpy
# define Wmempcpy mempcpy
#endif
diff --git a/libc/string/memset.c b/libc/string/memset.c
index 6dd20d668..9daf59f69 100644
--- a/libc/string/memset.c
+++ b/libc/string/memset.c
@@ -10,7 +10,7 @@
#ifdef WANT_WIDE
# define Wmemset wmemset
#else
-/* Experimentally off - libc_hidden_proto(memset) */
+# undef memset
# define Wmemset memset
#endif
diff --git a/libc/string/sparc/sparc32/memchr.S b/libc/string/sparc/sparc32/memchr.S
index 4d57a553b..d926e9787 100644
--- a/libc/string/sparc/sparc32/memchr.S
+++ b/libc/string/sparc/sparc32/memchr.S
@@ -139,6 +139,4 @@ ENTRY(memchr)
END(memchr)
libc_hidden_def(memchr)
-#if !__BOUNDED_POINTERS__
weak_alias(memchr,__ubp_memchr)
-#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_charclass.h b/libc/sysdeps/linux/common/bits/uClibc_charclass.h
new file mode 100644
index 000000000..50df539b9
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/uClibc_charclass.h
@@ -0,0 +1,40 @@
+/* Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#ifndef _BITS_UCLIBC_CHARCLASS_H
+#define _BITS_UCLIBC_CHARCLASS_H
+
+/* Taking advantage of the C99 mutual-exclusion guarantees for the various
+ * (w)ctype classes, including the descriptions of printing and control
+ * (w)chars, we can place each in one of the following mutually-exlusive
+ * subsets. Since there are less than 16, we can store the data for
+ * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
+ * per (w)char, with one bit flag for each is* type. While this allows
+ * a simple '&' operation to determine the type vs. a range test and a
+ * little special handling for the "blank" and "xdigit" types in my
+ * approach, it also uses 8 times the space for the tables on the typical
+ * 32-bit archs we supported.*/
+enum {
+ __CTYPE_unclassified = 0,
+ __CTYPE_alpha_nonupper_nonlower,
+ __CTYPE_alpha_lower,
+ __CTYPE_alpha_upper_lower,
+ __CTYPE_alpha_upper,
+ __CTYPE_digit,
+ __CTYPE_punct,
+ __CTYPE_graph,
+ __CTYPE_print_space_nonblank,
+ __CTYPE_print_space_blank,
+ __CTYPE_space_nonblank_noncntrl,
+ __CTYPE_space_blank_noncntrl,
+ __CTYPE_cntrl_space_nonblank,
+ __CTYPE_cntrl_space_blank,
+ __CTYPE_cntrl_nonspace
+};
+
+#endif
diff --git a/libc/sysdeps/linux/common/bits/uClibc_ctype.h b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
index 0b02c5dbf..3c07b5799 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_ctype.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_ctype.h
@@ -31,57 +31,15 @@
#error Always include <{w}ctype.h> rather than <bits/uClibc_ctype.h>
#endif
-#ifndef _BITS_CTYPE_H
-#define _BITS_CTYPE_H
+#ifndef _BITS_UCLIBC_CTYPE_H
+#define _BITS_UCLIBC_CTYPE_H
#ifdef __UCLIBC_GEN_LOCALE
+/* We are in extra/locale/gen_XXX tools build */
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace
-};
-
-/* Some macros that test for various (w)ctype classes when passed one of the
- * designator values enumerated above. */
-#define __CTYPE_isalnum(D) ((unsigned int)(D-1) <= (__CTYPE_digit-1))
-#define __CTYPE_isalpha(D) ((unsigned int)(D-1) <= (__CTYPE_alpha_upper-1))
-#define __CTYPE_isblank(D) \
- ((((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5) && (D & 1))
-#define __CTYPE_iscntrl(D) (((unsigned int)(D - __CTYPE_cntrl_space_nonblank)) <= 2)
-#define __CTYPE_isdigit(D) (D == __CTYPE_digit)
-#define __CTYPE_isgraph(D) ((unsigned int)(D-1) <= (__CTYPE_graph-1))
-#define __CTYPE_islower(D) (((unsigned int)(D - __CTYPE_alpha_lower)) <= 1)
-#define __CTYPE_isprint(D) ((unsigned int)(D-1) <= (__CTYPE_print_space_blank-1))
-#define __CTYPE_ispunct(D) (D == __CTYPE_punct)
-#define __CTYPE_isspace(D) (((unsigned int)(D - __CTYPE_print_space_nonblank)) <= 5)
-#define __CTYPE_isupper(D) (((unsigned int)(D - __CTYPE_alpha_upper_lower)) <= 1)
-/* #define __CTYPE_isxdigit(D) -- isxdigit is untestable this way.
- * But that's ok as isxdigit() (and isdigit() too) are locale-invariant. */
-
-#else /* __UCLIBC_GEN_LOCALE *****************************************/
+#include "uClibc_charclass.h"
+
+#else /* !__UCLIBC_GEN_LOCALE */
/* Define some ctype macros valid for the C/POSIX locale. */
@@ -189,21 +147,6 @@ __END_DECLS
/**********************************************************************/
#ifdef __GNUC__
-#define __isbody_C_macro(f,args) __C_ ## f args
-
-#define __isbody(f,c) \
- (__extension__ ({ \
- int __res; \
- if (sizeof(c) > sizeof(char)) { \
- int __c = (c); \
- __res = __isbody_C_macro(f,(__c)); \
- } else { \
- unsigned char __c = (c); \
- __res = __isbody_C_macro(f,(__c)); \
- } \
- __res; \
- }))
-
#define __body_C_macro(f,args) __C_ ## f args
#define __body(f,c) \
@@ -253,15 +196,13 @@ __END_DECLS
#define tolower(c) __tolower(c)
#define toupper(c) __toupper(c)
-
#endif
-#else /* _GNUC__ ***************************************************/
+#else /* !_GNUC__ */
#if !defined __NO_CTYPE && !defined __cplusplus
/* These macros should be safe from side effects. */
-
#define isdigit(c) __C_isdigit(c)
#define isalpha(c) __C_isalpha(c)
#define isprint(c) __C_isprint(c)
@@ -276,4 +217,4 @@ __END_DECLS
#endif /* __UCLIBC_GEN_LOCALE */
-#endif /* _BITS_CTYPE_H */
+#endif /* _BITS_UCLIBC_CTYPE_H */
diff --git a/libc/sysdeps/linux/common/bits/uClibc_locale.h b/libc/sysdeps/linux/common/bits/uClibc_locale.h
index a6b381c95..0ac12578e 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_locale.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_locale.h
@@ -174,7 +174,7 @@ typedef struct __uclibc_locale_struct {
const unsigned char *idx8ctype;
const unsigned char *tbl8ctype;
const unsigned char *idx8uplow;
- const unsigned char *tbl8uplow;
+ const unsigned char *tbl8uplow;
#ifdef __UCLIBC_HAS_WCHAR__
const unsigned char *idx8c2wc;
const uint16_t *tbl8c2wc; /* char > 0x7f to wide char */
@@ -301,8 +301,6 @@ typedef struct __uclibc_locale_struct {
const char *era_d_t_fmt;
const char *era_t_fmt;
- /* collate is at the end */
-
/* messages */
const char *yesexpr;
const char *noexpr;
diff --git a/libc/sysdeps/linux/common/capset.c b/libc/sysdeps/linux/common/capset.c
index f8936285e..0a77e05f4 100644
--- a/libc/sysdeps/linux/common/capset.c
+++ b/libc/sysdeps/linux/common/capset.c
@@ -11,7 +11,7 @@
int capset(void *header, const void *data);
#ifdef __NR_capset
_syscall2(int, capset, void *, header, const void *, data)
-#else
+#elif defined __UCLIBC_HAS_STUBS__
int capset(void *header, const void *data)
{
__set_errno(ENOSYS);
diff --git a/libc/sysdeps/linux/common/cmsg_nxthdr.c b/libc/sysdeps/linux/common/cmsg_nxthdr.c
index 7dbf7bec5..5230fc6be 100644
--- a/libc/sysdeps/linux/common/cmsg_nxthdr.c
+++ b/libc/sysdeps/linux/common/cmsg_nxthdr.c
@@ -19,6 +19,8 @@
#define __FORCE_GLIBC
#include <features.h>
+/* Prevent math.h from defining a colliding inline */
+#undef __USE_EXTERN_INLINES
#include <sys/socket.h>
/* libc_hidden_proto(__cmsg_nxthdr) */
diff --git a/libc/sysdeps/linux/common/getpgrp.c b/libc/sysdeps/linux/common/getpgrp.c
index c9de68cd3..5d36ba155 100644
--- a/libc/sysdeps/linux/common/getpgrp.c
+++ b/libc/sysdeps/linux/common/getpgrp.c
@@ -2,7 +2,7 @@
/*
* getpgrp() for uClibc
*
- * Copyright (C) 2000-2006 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2000-2008 by Erik Andersen <andersen@codepoet.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
@@ -13,4 +13,16 @@
#ifdef __NR_getpgrp
/* According to the manpage the POSIX.1 version is favoured */
_syscall0(pid_t, getpgrp)
+#elif defined __NR_getpgid && (defined __NR_getpid || defined __NR_getxpid)
+/* IA64 doesn't have a getpgrp syscall */
+pid_t getpgrp(void)
+{
+ return getpgid(getpid());
+}
+#elif defined __UCLIBC_HAS_STUBS__
+pid_t getpgrp(void)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
#endif
diff --git a/libc/sysdeps/linux/mips/pread_write.c b/libc/sysdeps/linux/mips/pread_write.c
index b1cce027f..ea6b15f6a 100644
--- a/libc/sysdeps/linux/mips/pread_write.c
+++ b/libc/sysdeps/linux/mips/pread_write.c
@@ -61,8 +61,8 @@ weak_alias(__libc_pread,pread)
# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pread64(int fd, void *buf, size_t count, off64_t offset)
{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
+ uint32_t low = offset & 0xffffffff;
+ uint32_t high = offset >> 32;
return(__syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
}
weak_alias(__libc_pread64,pread64)
@@ -105,8 +105,8 @@ weak_alias(__libc_pwrite,pwrite)
# ifdef __UCLIBC_HAS_LFS__
ssize_t __libc_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
{
- uint32_t low = offset & 0xffffffff;
- uint32_t high = offset >> 32;
+ uint32_t low = offset & 0xffffffff;
+ uint32_t high = offset >> 32;
return(__syscall_pwrite(fd, buf, count, 0, __LONG_LONG_PAIR (high, low)));
}
weak_alias(__libc_pwrite64,pwrite64)
diff --git a/libc/sysdeps/linux/x86_64/brk.c b/libc/sysdeps/linux/x86_64/brk.c
index fc906abc1..b1ee640af 100644
--- a/libc/sysdeps/linux/x86_64/brk.c
+++ b/libc/sysdeps/linux/x86_64/brk.c
@@ -25,19 +25,20 @@
void *__curbrk attribute_hidden = 0;
/* libc_hidden_proto(brk) */
-int brk (void *addr)
+int brk(void *addr)
{
- void *__unbounded newbrk;
+ void *newbrk;
__asm__ ("syscall\n"
- : "=a" (newbrk)
- : "0" (__NR_brk), "D" (__ptrvalue (addr))
- : "r11","rcx","memory");
+ : "=a" (newbrk)
+ : "0" (__NR_brk), "D" (addr)
+ : "r11", "rcx"
+ );
__curbrk = newbrk;
if (newbrk < addr) {
- __set_errno (ENOMEM);
+ __set_errno(ENOMEM);
return -1;
}