summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/Makefile.in43
-rw-r--r--libc/misc/Makefile.in3
-rw-r--r--libc/misc/assert/Makefile.in3
-rw-r--r--libc/misc/assert/__assert.c2
-rw-r--r--libc/misc/ctype/Makefile.in3
-rw-r--r--libc/misc/ctype/ctype.c6
-rw-r--r--libc/misc/dirent/Makefile.in3
-rw-r--r--libc/misc/dirent/closedir.c22
-rw-r--r--libc/misc/dirent/opendir.c68
-rw-r--r--libc/misc/error/Makefile.in2
-rw-r--r--libc/misc/error/err.c1
-rw-r--r--libc/misc/error/error.c8
-rw-r--r--libc/misc/file/Makefile.in3
-rw-r--r--libc/misc/fnmatch/Makefile.in3
-rw-r--r--libc/misc/fnmatch/fnmatch.c31
-rw-r--r--libc/misc/ftw/Makefile.in2
-rw-r--r--libc/misc/ftw/ftw.c1
-rw-r--r--libc/misc/gnu/Makefile.in3
-rw-r--r--libc/misc/gnu/obstack.c5
-rw-r--r--libc/misc/internals/Makefile.in15
-rw-r--r--libc/misc/internals/__uClibc_main.c247
-rw-r--r--libc/misc/locale/Makefile.in3
-rw-r--r--libc/misc/locale/locale.c16
-rw-r--r--libc/misc/mntent/Makefile.in3
-rw-r--r--libc/misc/pthread/Makefile.in3
-rw-r--r--libc/misc/pthread/weaks.c6
-rw-r--r--libc/misc/regex/Makefile.in3
-rw-r--r--libc/misc/regex/regcomp.c4
-rw-r--r--libc/misc/regex/regex.c13
-rw-r--r--libc/misc/regex/regex_internal.c6
-rw-r--r--libc/misc/regex/regex_internal.h3
-rw-r--r--libc/misc/regex/regex_old.c10
-rw-r--r--libc/misc/regex/regexec.c4
-rw-r--r--libc/misc/search/Makefile.in3
-rw-r--r--libc/misc/statfs/Makefile.in2
-rw-r--r--libc/misc/syslog/Makefile.in3
-rw-r--r--libc/misc/sysvipc/Makefile.in2
-rw-r--r--libc/misc/sysvipc/ipc.h2
-rw-r--r--libc/misc/sysvipc/msgq.c51
-rw-r--r--libc/misc/time/Makefile.in3
-rw-r--r--libc/misc/time/time.c43
-rw-r--r--libc/misc/ttyent/Makefile.in2
-rw-r--r--libc/misc/ttyent/getttyent.c2
-rw-r--r--libc/misc/utmp/Makefile.in3
-rw-r--r--libc/misc/utmp/utent.c36
-rw-r--r--libc/misc/utmp/wtent.c15
-rw-r--r--libc/misc/wchar/Makefile.in5
-rw-r--r--libc/misc/wchar/wchar.c5
-rw-r--r--libc/misc/wctype/Makefile.in3
-rw-r--r--libc/misc/wctype/_wctype.c10
-rw-r--r--libc/misc/wordexp/Makefile.in2
-rw-r--r--libc/misc/wordexp/wordexp.c4
-rw-r--r--libc/sysdeps/linux/Makefile.commonarch3
-rw-r--r--libc/sysdeps/linux/common/Makefile.in7
54 files changed, 565 insertions, 189 deletions
diff --git a/libc/Makefile.in b/libc/Makefile.in
index b03132256..450ad5ec2 100644
--- a/libc/Makefile.in
+++ b/libc/Makefile.in
@@ -1,11 +1,13 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
+libc_DIR := $(top_srcdir)libc
+libc_OUT := $(top_builddir)libc
+
# Check if the target architecture has a version script for
# libc, and if so, include it when linking.
VERSION_SCRIPT := $(wildcard $(libc_DIR)/sysdeps/linux/$(TARGET_ARCH)/libc.map)
@@ -15,14 +17,11 @@ endif
LDFLAGS-libc.so := $(LDFLAGS) $(VERSION_SCRIPT) -init __uClibc_init
-LIBS-libc.so := $(interp) $(ldso)
+LIBS-libc.so := $(interp) $(ldso) $(top_builddir)lib/$(NONSHARED_LIBNAME)
# we have SHARED_MAJORNAME=libc.so.$(MAJOR_VERSION) defined in Rules.mak
libc_FULL_NAME := libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
-libc_DIR := $(top_srcdir)libc
-libc_OUT := $(top_builddir)libc
-
# this comes first, so duplicate removal works correctly
include $(libc_DIR)/sysdeps/Makefile.in
@@ -36,25 +35,34 @@ include $(libc_DIR)/signal/Makefile.in
include $(libc_DIR)/stdlib/Makefile.in
include $(libc_DIR)/unistd/Makefile.in
-libc-a-y += $(libc-static-y)
-libc-so-y += $(libc-shared-y)
-
ifeq ($(DOPIC),y)
-libc-a-y := $(libc-a-y:.o=.os)
+libc-a-y = $(libc-y:.o=.os) $(libc-static-y:.o=.os)
+else
+libc-a-y = $(libc-y) $(libc-static-y)
endif
-libc-nomulti-y += $(libc-shared-y)
+ifeq ($(DOMULTI),n)
+libc-so-y += $(libc-shared-y)
+else
+all_sources = $(libc-y:.o=.c)
+all_sources += $(libc-shared-y:.oS=.c)
+libc-multi-y = $(filter-out $(libc-nomulti-y:.o=.c),$(all_sources))
+endif
lib-a-y += $(top_builddir)lib/libc.a
lib-so-y += $(libc)
objclean-y += libc_clean
+ifeq ($(DOMULTI),n)
$(libc:.$(MAJOR_VERSION)=): $(libc_OUT)/libc_so.a $(LIBS-libc.so)
$(call link.so,$(libc_FULL_NAME),$(MAJOR_VERSION))
+else
+$(libc:.$(MAJOR_VERSION)=): $(libc_OUT)/libc.oS $(libc-nomulti-y:.o=.oS) | $(LIBS-libc.so)
+ $(do_strip)
+ $(call linkm.so,$(libc_FULL_NAME),$(MAJOR_VERSION))
+endif
$(Q)$(RM) $@
- $(Q)echo "/* GNU ld script" > $@
- $(Q)echo " * Use the shared library, but some functions are only in" >> $@
- $(Q)echo " * the static library, so try that secondarily. */" >> $@
+ $(Q)cp $(top_srcdir)extra/scripts/format.lds $@
ifeq ($(COMPAT_ATEXIT),y)
$(Q)echo "GROUP ( $(NONSHARED_LIBNAME) $(SHARED_MAJORNAME) $(ASNEEDED) )" >> $@
else
@@ -70,6 +78,11 @@ else
endif
$(do_ar)
+$(libc_OUT)/libc.oS: $(libc-multi-y) | $(top_builddir)lib/libc.a $(top_builddir)lib/$(NONSHARED_LIBNAME)
+ $(Q)$(RM) $@
+ $(compile-m)
+ #(do_t_strip)
+
$(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
@@ -77,4 +90,4 @@ $(top_builddir)lib/libc.a: $(libc-a-y) | $(crt-y)
$(do_ar)
libc_clean:
- $(RM) $(libc_OUT)/*.{o,os,a}
+ $(RM) $(libc_OUT)/*.{o,os,oS,a}
diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in
index acc71aefe..542859576 100644
--- a/libc/misc/Makefile.in
+++ b/libc/misc/Makefile.in
@@ -1,7 +1,6 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
diff --git a/libc/misc/assert/Makefile.in b/libc/misc/assert/Makefile.in
index 20f9c2115..3bc3ab556 100644
--- a/libc/misc/assert/Makefile.in
+++ b/libc/misc/assert/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -15,6 +14,8 @@ MISC_ASSERT_SRC := $(MISC_ASSERT_DIR)/__assert.c
MISC_ASSERT_OBJ := $(MISC_ASSERT_OUT)/__assert.o
libc-y += $(MISC_ASSERT_OBJ)
+libc-a-y += $(MISC_ASSERT_OBJ)
+libc-so-y += $(MISC_ASSERT_OBJ:.o=.os)
objclean-y += misc_assert_objclean
diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c
index 4282812a5..bd3b3a91d 100644
--- a/libc/misc/assert/__assert.c
+++ b/libc/misc/assert/__assert.c
@@ -27,7 +27,6 @@
* and is useful in debugging the stdio code.
*/
-#define _ISOC99_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -35,7 +34,6 @@
libc_hidden_proto(fprintf)
libc_hidden_proto(abort)
-libc_hidden_proto(stderr)
/* Get the prototype from assert.h as a double-check. */
#undef NDEBUG
diff --git a/libc/misc/ctype/Makefile.in b/libc/misc/ctype/Makefile.in
index b8a07ec84..0e64fb033 100644
--- a/libc/misc/ctype/Makefile.in
+++ b/libc/misc/ctype/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -32,6 +31,8 @@ MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC))
MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC))
libc-y += $(MISC_CTYPE_OBJ)
+libc-a-y += $(MISC_CTYPE_OBJ)
+libc-so-y += $(MISC_CTYPE_OBJ:.o=.os)
objclean-y += misc_ctype_objclean
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index 243031b6c..d88b342fd 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -37,7 +37,7 @@
#include <locale.h>
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif
@@ -278,7 +278,7 @@ IS_FUNC_BODY(xdigit);
#undef tolower
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_tolower_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_tolower)
#endif
libc_hidden_proto(tolower)
@@ -324,7 +324,7 @@ libc_hidden_def(tolower_l)
#undef toupper
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_toupper_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_toupper)
#endif
libc_hidden_proto(toupper)
diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in
index d17ad8a17..ba8ad393f 100644
--- a/libc/misc/dirent/Makefile.in
+++ b/libc/misc/dirent/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2001 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -20,6 +19,8 @@ MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC))
MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC))
libc-y += $(MISC_DIRENT_OBJ)
+libc-a-y += $(MISC_DIRENT_OBJ)
+libc-so-y += $(MISC_DIRENT_OBJ:.o=.os)
objclean-y += misc_dirent_objclean
diff --git a/libc/misc/dirent/closedir.c b/libc/misc/dirent/closedir.c
index 8066b5861..0da001fce 100644
--- a/libc/misc/dirent/closedir.c
+++ b/libc/misc/dirent/closedir.c
@@ -1,10 +1,22 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include "dirstream.h"
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <not-cancel.h>
+#endif
+
+libc_hidden_proto(closedir)
+libc_hidden_proto(close)
-int attribute_hidden __closedir(DIR * dir)
+int closedir(DIR * dir)
{
int fd;
@@ -24,6 +36,10 @@ int attribute_hidden __closedir(DIR * dir)
__pthread_mutex_unlock(&(dir->dd_lock));
free(dir->dd_buf);
free(dir);
- return __close(fd);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ return close_not_cancel(fd);
+#else
+ return close(fd);
+#endif
}
-strong_alias(__closedir,closedir)
+libc_hidden_def(closedir)
diff --git a/libc/misc/dirent/opendir.c b/libc/misc/dirent/opendir.c
index 82e7f364f..9380088ff 100644
--- a/libc/misc/dirent/opendir.c
+++ b/libc/misc/dirent/opendir.c
@@ -1,41 +1,79 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/dir.h>
#include <sys/stat.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <not-cancel.h>
+#endif
#include "dirstream.h"
+libc_hidden_proto(opendir)
+libc_hidden_proto(open)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(close)
+libc_hidden_proto(stat)
+libc_hidden_proto(fstat)
/* opendir just makes an open() call - it return NULL if it fails
* (open sets errno), otherwise it returns a DIR * pointer.
*/
-DIR attribute_hidden *__opendir(const char *name)
+DIR *opendir(const char *name)
{
int fd;
struct stat statbuf;
- char *buf;
DIR *ptr;
- if (__stat(name, &statbuf))
+#ifndef O_DIRECTORY
+ /* O_DIRECTORY is linux specific and has been around since like 2.1.x */
+ if (stat(name, &statbuf))
return NULL;
if (!S_ISDIR(statbuf.st_mode)) {
__set_errno(ENOTDIR);
return NULL;
}
- if ((fd = __open(name, O_RDONLY)) < 0)
+# define O_DIRECTORY 0
+#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if ((fd = open_not_cancel_2(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
+#else
+ if ((fd = open(name, O_RDONLY|O_NDELAY|O_DIRECTORY)) < 0)
+#endif
return NULL;
+
+ /* Note: we should check to make sure that between the stat() and open()
+ * call, 'name' didnt change on us, but that's only if O_DIRECTORY isnt
+ * defined and since Linux has supported it for like ever, i'm not going
+ * to worry about it right now (if ever). */
+ if (fstat(fd, &statbuf) < 0)
+ goto close_and_ret;
+
/* According to POSIX, directory streams should be closed when
* exec. From "Anna Pluzhnikov" <besp@midway.uchicago.edu>.
*/
- if (__fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
- return NULL;
- if (!(ptr = malloc(sizeof(*ptr)))) {
- __close(fd);
- __set_errno(ENOMEM);
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
+ int saved_errno;
+close_and_ret:
+ saved_errno = errno;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(fd);
+#else
+ close(fd);
+#endif
+ __set_errno(saved_errno);
return NULL;
}
+ if (!(ptr = malloc(sizeof(*ptr))))
+ goto nomem_close_and_ret;
ptr->dd_fd = fd;
ptr->dd_nextloc = ptr->dd_size = ptr->dd_nextoff = 0;
@@ -44,14 +82,18 @@ DIR attribute_hidden *__opendir(const char *name)
if (ptr->dd_max < 512)
ptr->dd_max = 512;
- if (!(buf = calloc(1, ptr->dd_max))) {
- __close(fd);
+ if (!(ptr->dd_buf = calloc(1, ptr->dd_max))) {
free(ptr);
+nomem_close_and_ret:
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(fd);
+#else
+ close(fd);
+#endif
__set_errno(ENOMEM);
return NULL;
}
- ptr->dd_buf = buf;
__pthread_mutex_init(&(ptr->dd_lock), NULL);
return ptr;
}
-strong_alias(__opendir,opendir)
+libc_hidden_def(opendir)
diff --git a/libc/misc/error/Makefile.in b/libc/misc/error/Makefile.in
index c529e955e..fc699e870 100644
--- a/libc/misc/error/Makefile.in
+++ b/libc/misc/error/Makefile.in
@@ -14,6 +14,8 @@ MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC))
MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC))
libc-y += $(MISC_ERROR_OBJ)
+libc-a-y += $(MISC_ERROR_OBJ)
+libc-so-y += $(MISC_ERROR_OBJ:.o=.os)
objclean-y += misc_error_objclean
diff --git a/libc/misc/error/err.c b/libc/misc/error/err.c
index 00e74ce61..cd331500a 100644
--- a/libc/misc/error/err.c
+++ b/libc/misc/error/err.c
@@ -29,7 +29,6 @@ libc_hidden_proto(vfprintf)
libc_hidden_proto(__xpg_strerror_r)
libc_hidden_proto(exit)
libc_hidden_proto(vfprintf)
-libc_hidden_proto(stderr)
static void vwarn_work(const char *format, va_list args, int showerr)
{
diff --git a/libc/misc/error/error.c b/libc/misc/error/error.c
index 3e44a01ee..08044ac83 100644
--- a/libc/misc/error/error.c
+++ b/libc/misc/error/error.c
@@ -35,8 +35,6 @@ libc_hidden_proto(vfprintf)
libc_hidden_proto(fflush)
libc_hidden_proto(fputc)
libc_hidden_proto(__fputc_unlocked)
-libc_hidden_proto(stdout)
-libc_hidden_proto(stderr)
/* This variable is incremented each time `error' is called. */
unsigned int error_message_count = 0;
@@ -66,6 +64,7 @@ void __error (int status, int errnum, const char *message, ...)
if (status)
exit (status);
}
+weak_alias(__error,error)
extern __typeof(error_at_line) __error_at_line attribute_hidden;
void __error_at_line (int status, int errnum, const char *file_name,
@@ -103,7 +102,4 @@ void __error_at_line (int status, int errnum, const char *file_name,
if (status)
exit (status);
}
-
-/* psm: keep this weak, too many use this in common code */
-weak_alias(__error,error)
-strong_alias(__error_at_line,error_at_line)
+weak_alias(__error_at_line,error_at_line)
diff --git a/libc/misc/file/Makefile.in b/libc/misc/file/Makefile.in
index bc3b2f124..d3947c018 100644
--- a/libc/misc/file/Makefile.in
+++ b/libc/misc/file/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -16,6 +15,8 @@ endif
MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC))
libc-y += $(MISC_FILE_OBJ)
+libc-a-y += $(MISC_FILE_OBJ)
+libc-so-y += $(MISC_FILE_OBJ:.o=.os)
libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_FILE_OUT)/lockf64.o
diff --git a/libc/misc/fnmatch/Makefile.in b/libc/misc/fnmatch/Makefile.in
index 31873d676..35748ea16 100644
--- a/libc/misc/fnmatch/Makefile.in
+++ b/libc/misc/fnmatch/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -19,6 +18,8 @@ MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC))
MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC))
libc-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ)
+libc-a-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ)
+libc-so-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ:.o=.os)
objclean-y += misc_fnmatch_objclean
diff --git a/libc/misc/fnmatch/fnmatch.c b/libc/misc/fnmatch/fnmatch.c
index 5a6292c4b..2d957772f 100644
--- a/libc/misc/fnmatch/fnmatch.c
+++ b/libc/misc/fnmatch/fnmatch.c
@@ -66,7 +66,7 @@ libc_hidden_proto(strcoll)
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
libc_hidden_proto(__ctype_tolower_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
libc_hidden_proto(__ctype_tolower)
#endif
@@ -102,21 +102,16 @@ libc_hidden_proto(mbsrtowcs)
/* We need some of the locale data (the collation sequence information)
but there is no interface to get this information in general. Therefore
we support a correct implementation only in glibc. */
-#if defined _LIBC
+#ifdef _LIBC
# include "../locale/localeinfo.h"
# include "../locale/elem-hash.h"
# include "../locale/coll-lookup.h"
# include <shlib-compat.h>
# define CONCAT(a,b) __CONCAT(a,b)
-# if defined _LIBC
# define mbsrtowcs __mbsrtowcs
-# endif
# define fnmatch __fnmatch
-extern int fnmatch (const char *pattern, const char *string, int flags) attribute_hidden;
-#endif
-#ifdef __UCLIBC__
-# define CONCAT(a,b) __CONCAT(a,b)
+extern int fnmatch (const char *pattern, const char *string, int flags);
#endif
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
@@ -175,13 +170,13 @@ extern int fnmatch (const char *pattern, const char *string, int flags) attribut
# define CHAR_CLASS_MAX_LENGTH 256
# endif
-# if defined _LIBC
+# ifdef _LIBC
# define IS_CHAR_CLASS(string) __wctype (string)
# else
# define IS_CHAR_CLASS(string) wctype (string)
# endif
-# if defined _LIBC
+# ifdef _LIBC
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
# else
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
@@ -253,8 +248,8 @@ __wcschrnul (s, c)
# endif
/* Note that this evaluates C many times. */
-# if defined _LIBC
-# define FOLD(c) ((flags & FNM_CASEFOLD) ? __tolower (c) : (c))
+# ifdef _LIBC
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
# endif
@@ -265,7 +260,7 @@ __wcschrnul (s, c)
# define EXT ext_match
# define END end_pattern
# define L(CS) CS
-# if defined _LIBC
+# ifdef _LIBC
# define BTOWC(C) __btowc (C)
# else
# define BTOWC(C) btowc (C)
@@ -280,8 +275,8 @@ __wcschrnul (s, c)
# if HANDLE_MULTIBYTE
/* Note that this evaluates C many times. */
-# if defined _LIBC
-# define FOLD(c) ((flags & FNM_CASEFOLD) ? __towlower (c) : (c))
+# ifdef _LIBC
+# define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? towlower (c) : (c))
# endif
@@ -361,7 +356,7 @@ is_char_class (const wchar_t *wcs)
*cp = '\0';
-# if defined _LIBC
+# ifdef _LIBC
return __wctype (s);
# else
return wctype (s);
@@ -465,16 +460,14 @@ fnmatch (const char *pattern, const char *string, int flags)
flags & FNM_PERIOD, flags);
}
-# if defined _LIBC
+# ifdef _LIBC
# undef fnmatch
-# ifndef __UCLIBC__
versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
# if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2_3)
strong_alias (__fnmatch, __fnmatch_old)
compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
# endif
libc_hidden_ver (__fnmatch, fnmatch)
-# endif
# else
libc_hidden_def(fnmatch)
# endif
diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in
index 501b9084d..c2f249ec4 100644
--- a/libc/misc/ftw/Makefile.in
+++ b/libc/misc/ftw/Makefile.in
@@ -17,6 +17,8 @@ MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC))
MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC))
libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
+libc-a-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
+libc-so-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ:.o=.os)
objclean-y += misc_ftw_objclean
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index 18da40a33..6521b44e4 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -22,7 +22,6 @@
# include <config.h>
#endif
-#define _XOPEN_SOURCE 500
#include <features.h>
#ifdef __UCLIBC__
#undef _LIBC
diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in
index bcd9400c3..0aa7becb8 100644
--- a/libc/misc/gnu/Makefile.in
+++ b/libc/misc/gnu/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -15,6 +14,8 @@ MISC_GNU_SRC := $(MISC_GNU_DIR)/obstack.c
MISC_GNU_OBJ := $(MISC_GNU_OUT)/obstack.o
libc-y += $(MISC_GNU_OBJ)
+libc-a-y += $(MISC_GNU_OBJ)
+libc-so-y += $(MISC_GNU_OBJ:.o=.os)
objclean-y += misc_gnu_objclean
diff --git a/libc/misc/gnu/obstack.c b/libc/misc/gnu/obstack.c
index 99311183f..5fc031555 100644
--- a/libc/misc/gnu/obstack.c
+++ b/libc/misc/gnu/obstack.c
@@ -89,7 +89,6 @@ union fooround {long x; double d;};
abort gracefully or use longjump - but shouldn't return. This
variable by default points to the internal function
`print_and_abort'. */
-libc_hidden_proto(obstack_alloc_failed_handler)
# if defined __STDC__ && __STDC__
static void print_and_abort (void);
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
@@ -97,7 +96,6 @@ void (*obstack_alloc_failed_handler) (void) = print_and_abort;
static void print_and_abort ();
void (*obstack_alloc_failed_handler) () = print_and_abort;
# endif
-libc_hidden_data_def(obstack_alloc_failed_handler)
/* Exit value used when `print_and_abort' is used. */
@@ -111,14 +109,11 @@ libc_hidden_data_def(obstack_alloc_failed_handler)
libc_hidden_proto(fprintf)
libc_hidden_proto(abort)
libc_hidden_proto(exit)
-libc_hidden_proto(stderr)
#ifdef __UCLIBC_HAS_WCHAR__
libc_hidden_proto(fwprintf)
#endif
-libc_hidden_proto(obstack_exit_failure)
int obstack_exit_failure = EXIT_FAILURE;
-libc_hidden_data_def(obstack_exit_failure)
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
diff --git a/libc/misc/internals/Makefile.in b/libc/misc/internals/Makefile.in
index ac5482a01..8237c2f6c 100644
--- a/libc/misc/internals/Makefile.in
+++ b/libc/misc/internals/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -8,7 +7,7 @@
CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
-CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c
+CSRC := tempname.c __errno_location.c __h_errno_location.c
MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
@@ -17,10 +16,14 @@ MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
libc-y += $(MISC_INTERNALS_OBJ)
-libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS
-libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
-
-libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
+libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \
+ $(MISC_INTERNALS_OUT)/errno.oS
+libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \
+ $(MISC_INTERNALS_OUT)/errno.o
+libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o \
+ $(MISC_INTERNALS_OUT)/errno.o
+libc-so-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS \
+ $(MISC_INTERNALS_OUT)/errno.oS $(MISC_INTERNALS_OBJ:.o=.oS)
objclean-y += misc_internals_objclean
diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c
index 3876c7606..cbde28b59 100644
--- a/libc/misc/internals/__uClibc_main.c
+++ b/libc/misc/internals/__uClibc_main.c
@@ -1,5 +1,7 @@
+/* vi: set sw=4 ts=4: */
/*
- * Copyright (C) Feb 2001 Manuel Novoa III
+ * Copyright (C) 2006 by Steven J. Hill <sjhill@realitydiluted.com>
+ * Copyright (C) 2001 by Manuel Novoa III <mjn3@uclibc.org>
* Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
*
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -13,13 +15,10 @@
* avoided in the static library case.
*/
-#define getgid __getgid
-#define getuid __getuid
-#define getegid __getegid
-#define geteuid __geteuid
-
-#define _ERRNO_H
#include <features.h>
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+#define _ERRNO_H
+#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -32,22 +31,56 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <pthread-functions.h>
+#include <not-cancel.h>
+#endif
+
+libc_hidden_proto(exit)
+
+#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
+libc_hidden_proto(strrchr)
+#endif
+#ifdef __ARCH_USE_MMU__
+libc_hidden_proto(memcpy)
+libc_hidden_proto(getgid)
+libc_hidden_proto(getuid)
+libc_hidden_proto(getegid)
+libc_hidden_proto(geteuid)
+libc_hidden_proto(fstat)
+libc_hidden_proto(abort)
+
+extern __typeof(open) __libc_open;
+libc_hidden_proto(__libc_open)
+extern __typeof(fcntl) __libc_fcntl;
+libc_hidden_proto(__libc_fcntl)
+#endif
#ifndef SHARED
void *__libc_stack_end=NULL;
-#ifdef __UCLIBC_HAS_SSP__
-#include <dl-osinfo.h>
-#ifndef THREAD_SET_STACK_GUARD
+# ifdef __UCLIBC_HAS_SSP__
+# include <dl-osinfo.h>
+# ifndef THREAD_SET_STACK_GUARD
/* Only exported for architectures that don't store the stack guard canary
* in thread local area. */
-#include <stdint.h>
+# include <stdint.h>
+uintptr_t stack_chk_guard;
/* for gcc-4.1 non-TLS */
uintptr_t __stack_chk_guard attribute_relro;
/* for gcc-3.x + Etoh ssp */
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+# ifdef __HAVE_SHARED__
strong_alias(__stack_chk_guard,__guard)
-#endif
-#endif
+# else
+uintptr_t __guard attribute_relro;
+# endif
+# endif
+# elif defined __UCLIBC_HAS_SSP_COMPAT__
+uintptr_t __guard attribute_relro;
+# endif
+# endif
#endif /* !SHARED */
@@ -64,6 +97,20 @@ extern void weak_function _locale_init(void) attribute_hidden;
extern void weak_function __pthread_initialize_minimal(void);
#endif
+#ifdef __UCLIBC_CTOR_DTOR__
+extern void _dl_app_init_array(void);
+extern void _dl_app_fini_array(void);
+# ifndef SHARED
+/* These magic symbols are provided by the linker. */
+extern void (*__preinit_array_start []) (void) attribute_hidden;
+extern void (*__preinit_array_end []) (void) attribute_hidden;
+extern void (*__init_array_start []) (void) attribute_hidden;
+extern void (*__init_array_end []) (void) attribute_hidden;
+extern void (*__fini_array_start []) (void) attribute_hidden;
+extern void (*__fini_array_end []) (void) attribute_hidden;
+# endif
+#endif
+
attribute_hidden const char *__uclibc_progname = NULL;
#ifdef __UCLIBC_HAS___PROGNAME__
strong_alias (__uclibc_progname, __progname)
@@ -75,39 +122,45 @@ strong_alias (__progname_full, program_invocation_name)
#endif
/*
- * Declare the __environ global variable and create a weak alias environ.
- * Note: Apparently we must initialize __environ to ensure that the weak
+ * Declare the __environ global variable and create a strong alias environ.
+ * Note: Apparently we must initialize __environ to ensure that the strong
* environ symbol is also included.
*/
char **__environ = 0;
-weak_alias(__environ, environ)
+strong_alias(__environ,environ)
+/* TODO: don't export __pagesize; we cant now because libpthread uses it */
size_t __pagesize = 0;
#ifndef O_NOFOLLOW
# define O_NOFOLLOW 0
#endif
-#ifdef __ARCH_HAS_MMU__
-
+#ifdef __ARCH_USE_MMU__
static void __check_one_fd(int fd, int mode)
{
- /* Check if the specified fd is already open */
- if (unlikely(__fcntl(fd, F_GETFD)==-1 && *(__errno_location())==EBADF))
- {
- /* The descriptor is probably not open, so try to use /dev/null */
- struct stat st;
- int nullfd = __open(_PATH_DEVNULL, mode);
- /* /dev/null is major=1 minor=3. Make absolutely certain
- * that is in fact the device that we have opened and not
- * some other wierd file... */
- if ( (nullfd!=fd) || __fstat(fd, &st) || !S_ISCHR(st.st_mode) ||
- (st.st_rdev != makedev(1, 3)))
+ /* Check if the specified fd is already open */
+ if (unlikely(fcntl(fd, F_GETFD)==-1 && *(__errno_location())==EBADF))
{
- /* Somebody is trying some trickery here... */
- abort();
+ /* The descriptor is probably not open, so try to use /dev/null */
+ struct stat st;
+
+#ifndef __UCLIBC_HAS_THREADS_NATIVE__
+ int nullfd = open(_PATH_DEVNULL, mode);
+#else
+ int nullfd = open_not_cancel (_PATH_DEVNULL, mode, 0);
+#endif
+
+ /* /dev/null is major=1 minor=3. Make absolutely certain
+ * that is in fact the device that we have opened and not
+ * some other wierd file... */
+ if ((nullfd != fd) || fstat(fd, &st) || !S_ISCHR(st.st_mode) ||
+ (st.st_rdev != makedev(1, 3)))
+ {
+ /* Somebody is trying some trickery here... */
+ abort();
+ }
}
- }
}
static int __check_suid(void)
@@ -140,6 +193,8 @@ static int __check_suid(void)
* __uClibc_main.
*/
+extern void __uClibc_init(void);
+libc_hidden_proto(__uClibc_init)
void __uClibc_init(void)
{
static int been_there_done_that = 0;
@@ -164,11 +219,17 @@ void __uClibc_init(void)
#ifndef SHARED
# ifdef __UCLIBC_HAS_SSP__
/* Set up the stack checker's canary. */
- uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard();
+ stack_chk_guard = _dl_setup_stack_chk_guard();
# ifdef THREAD_SET_STACK_GUARD
THREAD_SET_STACK_GUARD (stack_chk_guard);
+# ifdef __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
+# endif
# else
__stack_chk_guard = stack_chk_guard;
+# if !defined __HAVE_SHARED__ && defined __UCLIBC_HAS_SSP_COMPAT__
+ __guard = stack_chk_guard;
+# endif
# endif
# endif
#endif
@@ -187,6 +248,7 @@ void __uClibc_init(void)
_stdio_init();
}
+libc_hidden_def(__uClibc_init)
#ifdef __UCLIBC_CTOR_DTOR__
void attribute_hidden (*__app_fini)(void) = NULL;
@@ -194,20 +256,47 @@ void attribute_hidden (*__app_fini)(void) = NULL;
void attribute_hidden (*__rtld_fini)(void) = NULL;
+extern void __uClibc_fini(void);
+libc_hidden_proto(__uClibc_fini)
+void __uClibc_fini(void)
+{
+#ifdef __UCLIBC_CTOR_DTOR__
+# ifdef SHARED
+ _dl_app_fini_array();
+# else
+ size_t i = __fini_array_end - __fini_array_start;
+ while (i-- > 0)
+ (*__fini_array_start [i]) ();
+# endif
+ if (__app_fini != NULL)
+ (__app_fini)();
+#endif
+ if (__rtld_fini != NULL)
+ (__rtld_fini)();
+}
+libc_hidden_def(__uClibc_fini)
+
/* __uClibc_main is the new main stub for uClibc. This function is
* called from crt1 (version 0.9.28 or newer), after ALL shared libraries
* are initialized, just before we call the application's main function.
*/
-void attribute_noreturn
-__uClibc_main(int (*main)(int, char **, char **), int argc,
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
+ char **argv, void (*app_init)(void), void (*app_fini)(void),
+ void (*rtld_fini)(void), void *stack_end) attribute_noreturn;
+void __uClibc_main(int (*main)(int, char **, char **), int argc,
char **argv, void (*app_init)(void), void (*app_fini)(void),
void (*rtld_fini)(void), void *stack_end)
{
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
unsigned long *aux_dat;
ElfW(auxv_t) auxvt[AT_EGID + 1];
#endif
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ /* Result of the 'main' function. */
+ int result;
+#endif
+
#ifndef SHARED
__libc_stack_end = stack_end;
#endif
@@ -224,7 +313,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
__environ = &argv[argc];
}
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
/* Pull stuff from the ELF header when possible */
aux_dat = (unsigned long*)__environ;
while (*aux_dat) {
@@ -234,7 +323,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
while (*aux_dat) {
ElfW(auxv_t) *auxv_entry = (ElfW(auxv_t) *) aux_dat;
if (auxv_entry->a_type <= AT_EGID) {
- __memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
+ memcpy(&(auxvt[auxv_entry->a_type]), auxv_entry, sizeof(ElfW(auxv_t)));
}
aux_dat += 2;
}
@@ -245,7 +334,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
* __uClibc_init() regardless, to be sure the right thing happens. */
__uClibc_init();
-#ifdef __ARCH_HAS_MMU__
+#ifdef __ARCH_USE_MMU__
/* Make certain getpagesize() gives the correct answer */
__pagesize = (auxvt[AT_PAGESZ].a_un.a_val)? auxvt[AT_PAGESZ].a_un.a_val : PAGE_SIZE;
@@ -264,7 +353,7 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
#ifdef __UCLIBC_HAS_PROGRAM_INVOCATION_NAME__
__progname_full = *argv;
- __progname = __strrchr(*argv, '/');
+ __progname = strrchr(*argv, '/');
if (__progname != NULL)
++__progname;
else
@@ -277,10 +366,31 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
/* Arrange for the application's dtors to run before we exit. */
__app_fini = app_fini;
+# ifndef SHARED
+ /* For dynamically linked executables the preinit array is executed by
+ the dynamic linker (before initializing any shared object).
+ For static executables, preinit happens rights before init. */
+ {
+ const size_t size = __preinit_array_end - __preinit_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__preinit_array_start [i]) ();
+ }
+# endif
/* Run all the application's ctors now. */
if (app_init!=NULL) {
app_init();
}
+# ifdef SHARED
+ _dl_app_init_array();
+# else
+ {
+ const size_t size = __init_array_end - __init_array_start;
+ size_t i;
+ for (i = 0; i < size; i++)
+ (*__init_array_start [i]) ();
+ }
+# endif
#endif
/* Note: It is possible that any initialization done above could
@@ -294,8 +404,57 @@ __uClibc_main(int (*main)(int, char **, char **), int argc,
if (likely(__h_errno_location!=NULL))
*(__h_errno_location()) = 0;
- /*
- * Finally, invoke application's main and then exit.
- */
- __exit(main(argc, argv, __environ));
+#if defined HAVE_CLEANUP_JMP_BUF && defined __UCLIBC_HAS_THREADS_NATIVE__
+ /* Memory for the cancellation buffer. */
+ struct pthread_unwind_buf unwind_buf;
+
+ int not_first_call;
+ not_first_call =
+ setjmp ((struct __jmp_buf_tag *) unwind_buf.cancel_jmp_buf);
+ if (__builtin_expect (! not_first_call, 1))
+ {
+ struct pthread *self = THREAD_SELF;
+
+ /* Store old info. */
+ unwind_buf.priv.data.prev = THREAD_GETMEM (self, cleanup_jmp_buf);
+ unwind_buf.priv.data.cleanup = THREAD_GETMEM (self, cleanup);
+
+ /* Store the new cleanup handler info. */
+ THREAD_SETMEM (self, cleanup_jmp_buf, &unwind_buf);
+
+ /* Run the program. */
+ result = main (argc, argv, __environ);
+ }
+ else
+ {
+ /* Remove the thread-local data. */
+# ifdef SHARED
+ __libc_pthread_functions.ptr__nptl_deallocate_tsd ();
+# else
+ extern void __nptl_deallocate_tsd (void) __attribute ((weak));
+ __nptl_deallocate_tsd ();
+# endif
+
+ /* One less thread. Decrement the counter. If it is zero we
+ terminate the entire process. */
+ result = 0;
+# ifdef SHARED
+ unsigned int *const ptr = __libc_pthread_functions.ptr_nthreads;
+# else
+ extern unsigned int __nptl_nthreads __attribute ((weak));
+ unsigned int *const ptr = &__nptl_nthreads;
+# endif
+
+ if (! atomic_decrement_and_test (ptr))
+ /* Not much left to do but to exit the thread, not the process. */
+ __exit_thread (0);
+ }
+
+ exit (result);
+#else
+ /*
+ * Finally, invoke application's main and then exit.
+ */
+ exit (main (argc, argv, __environ));
+#endif
}
diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in
index 66b9809fa..4a77e205f 100644
--- a/libc/misc/locale/Makefile.in
+++ b/libc/misc/locale/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -22,6 +21,8 @@ MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC))
MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC))
libc-y += $(MISC_LOCALE_OBJ)
+libc-a-y += $(MISC_LOCALE_OBJ)
+libc-so-y += $(MISC_LOCALE_OBJ:.o=.os)
objclean-y += misc_locale_objclean
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index e53731e94..b782d5ead 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -60,7 +60,6 @@
libc_hidden_proto(memcpy)
libc_hidden_proto(memset)
-libc_hidden_proto(stpcpy)
libc_hidden_proto(strtok_r)
libc_hidden_proto(strlen)
libc_hidden_proto(strcmp)
@@ -68,7 +67,9 @@ libc_hidden_proto(strcpy)
libc_hidden_proto(strncmp)
libc_hidden_proto(strchr)
libc_hidden_proto(getenv)
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__C_ctype_toupper)
+#endif
/*libc_hidden_proto(fflush)*/
#ifdef __UCLIBC_MJN3_ONLY__
@@ -148,10 +149,6 @@ extern void _locale_init_l(__locale_t base) attribute_hidden;
#include <langinfo.h>
#include <nl_types.h>
-#ifdef __UCLIBC_HAS_LOCALE__
-libc_hidden_proto(__global_locale)
-#endif
-
/**********************************************************************/
#ifdef L_setlocale
@@ -196,6 +193,7 @@ static const char utf8[] = "UTF-8";
*/
static char hr_locale[(MAX_LOCALE_CATEGORY_STR * LC_ALL) + MAX_LOCALE_STR];
+libc_hidden_proto(stpcpy)
libc_hidden_proto(newlocale)
static void update_hr_locale(const unsigned char *spec)
@@ -377,12 +375,9 @@ libc_hidden_proto(__ctype_toupper)
__uclibc_locale_t __global_locale_data;
__locale_t __global_locale = &__global_locale_data;
-libc_hidden_data_def(__global_locale)
#ifdef __UCLIBC_HAS_XLOCALE__
-libc_hidden_proto(__curlocale_var)
__locale_t __curlocale_var = &__global_locale_data;
-libc_hidden_data_def(__curlocale_var)
#endif
/*----------------------------------------------------------------------*/
@@ -1089,6 +1084,7 @@ libc_hidden_def(__XL_NPP(nl_langinfo))
/**********************************************************************/
#ifdef L_newlocale
+libc_hidden_proto(stpcpy)
libc_hidden_proto(newlocale)
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1386,8 +1382,6 @@ void freelocale(__locale_t dataset)
/**********************************************************************/
#ifdef L_uselocale
-libc_hidden_proto(__curlocale_var)
-
libc_hidden_proto(uselocale)
__locale_t uselocale(__locale_t dataset)
{
@@ -1420,8 +1414,6 @@ libc_hidden_def(uselocale)
#ifdef __UCLIBC_HAS_THREADS__
-libc_hidden_proto(__curlocale_var)
-
__locale_t weak_const_function __curlocale(void)
{
return __curlocale_var; /* This is overriden by the thread version. */
diff --git a/libc/misc/mntent/Makefile.in b/libc/misc/mntent/Makefile.in
index b633e4eb2..19751d498 100644
--- a/libc/misc/mntent/Makefile.in
+++ b/libc/misc/mntent/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -15,6 +14,8 @@ MISC_MNTENT_SRC := $(MISC_MNTENT_DIR)/mntent.c
MISC_MNTENT_OBJ := $(MISC_MNTENT_OUT)/mntent.o
libc-y += $(MISC_MNTENT_OBJ)
+libc-a-y += $(MISC_MNTENT_OBJ)
+libc-so-y += $(MISC_MNTENT_OBJ:.o=.os)
objclean-y += misc_mntent_objclean
diff --git a/libc/misc/pthread/Makefile.in b/libc/misc/pthread/Makefile.in
index 3e0f5a780..fc138c91a 100644
--- a/libc/misc/pthread/Makefile.in
+++ b/libc/misc/pthread/Makefile.in
@@ -9,9 +9,6 @@ MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread
MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread
libc-static-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
-libc-shared-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/no-tsd.oS
-
-libc-nomulti-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/no-tsd.o
objclean-y += misc_pthread_objclean
diff --git a/libc/misc/pthread/weaks.c b/libc/misc/pthread/weaks.c
index 141e74696..e08812796 100644
--- a/libc/misc/pthread/weaks.c
+++ b/libc/misc/pthread/weaks.c
@@ -17,6 +17,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#define _GNU_SOURCE
#include <libc-internal.h>
/* Weaks for internal library use only.
@@ -35,3 +36,8 @@ weak_alias (__pthread_return_0, __pthread_mutex_init)
weak_alias (__pthread_return_0, __pthread_mutex_lock)
weak_alias (__pthread_return_0, __pthread_mutex_trylock)
weak_alias (__pthread_return_0, __pthread_mutex_unlock)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+weak_alias (__pthread_return_0, __pthread_mutexattr_init)
+weak_alias (__pthread_return_0, __pthread_mutexattr_destroy)
+weak_alias (__pthread_return_0, __pthread_mutexattr_settype)
+#endif
diff --git a/libc/misc/regex/Makefile.in b/libc/misc/regex/Makefile.in
index 4e76dee36..c6f2aea8b 100644
--- a/libc/misc/regex/Makefile.in
+++ b/libc/misc/regex/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -19,6 +18,8 @@ MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC))
MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC))
libc-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ)
+libc-a-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ)
+libc-so-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ:.o=.os)
objclean-y += misc_regex_objclean
diff --git a/libc/misc/regex/regcomp.c b/libc/misc/regex/regcomp.c
index 8d464db2d..471ea55f0 100644
--- a/libc/misc/regex/regcomp.c
+++ b/libc/misc/regex/regcomp.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -532,7 +532,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
{
if (BE (msg_size > errbuf_size, 0))
{
-#if defined HAVE_MEMPCPY || defined _LIBC
+#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
*((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
#else
memcpy (errbuf, msg, errbuf_size - 1);
diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c
index 77c09a011..192034b4e 100644
--- a/libc/misc/regex/regex.c
+++ b/libc/misc/regex/regex.c
@@ -28,12 +28,15 @@
#ifdef __UCLIBC__
#undef _LIBC
#define _REGEX_RE_COMP
-#define HAVE_MEMPCPY
+#ifdef __USE_GNU
+# define HAVE_MEMPCPY
+#endif
#define HAVE_LANGINFO
#define HAVE_LANGINFO_CODESET
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+#include <strings.h>
#include <stdlib.h>
#ifdef __UCLIBC_HAS_WCHAR__
#define RE_ENABLE_I18N
@@ -67,9 +70,11 @@ libc_hidden_proto(wctype)
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
libc_hidden_proto(__ctype_toupper_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
libc_hidden_proto(__ctype_toupper)
+#else
+libc_hidden_proto(isascii)
#endif
libc_hidden_proto(toupper)
libc_hidden_proto(tolower)
@@ -83,8 +88,10 @@ libc_hidden_proto(strlen)
libc_hidden_proto(strncpy)
libc_hidden_proto(getenv)
libc_hidden_proto(strcasecmp)
-libc_hidden_proto(mempcpy)
libc_hidden_proto(abort)
+#ifdef __USE_GNU
+libc_hidden_proto(mempcpy)
+#endif
#endif
diff --git a/libc/misc/regex/regex_internal.c b/libc/misc/regex/regex_internal.c
index 3fc62d731..fa0b336e8 100644
--- a/libc/misc/regex/regex_internal.c
+++ b/libc/misc/regex/regex_internal.c
@@ -1,5 +1,5 @@
/* Extended regular expression matching and search library.
- Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
@@ -259,7 +259,7 @@ build_wcs_buffer (re_string_t *pstr)
/* Build wide character buffer PSTR->WCS like build_wcs_buffer,
but for REG_ICASE. */
-static int
+static reg_errcode_t
internal_function
build_wcs_upper_buffer (re_string_t *pstr)
{
@@ -721,7 +721,7 @@ re_string_reconstruct (re_string_t *pstr, int idx, int eflags)
{
if (pstr->icase)
{
- int ret = build_wcs_upper_buffer (pstr);
+ reg_errcode_t ret = build_wcs_upper_buffer (pstr);
if (BE (ret != REG_NOERROR, 0))
return ret;
}
diff --git a/libc/misc/regex/regex_internal.h b/libc/misc/regex/regex_internal.h
index d82cf6d42..a0dd28247 100644
--- a/libc/misc/regex/regex_internal.h
+++ b/libc/misc/regex/regex_internal.h
@@ -43,6 +43,9 @@ libc_hidden_proto(nl_langinfo)
#if defined HAVE_STDBOOL_H || defined _LIBC
# include <stdbool.h>
#endif /* HAVE_STDBOOL_H || _LIBC */
+#if defined HAVE_STDINT_H || defined _LIBC
+# include <stdint.h>
+#endif /* HAVE_STDINT_H || _LIBC */
#if defined _LIBC
# include <bits/libc-lock.h>
#else
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 29640734d..cf5843ec5 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -26,7 +26,9 @@
#ifdef __UCLIBC__
# undef _LIBC
# define _REGEX_RE_COMP
-# define HAVE_MEMPCPY
+# ifdef __USE_GNU
+# define HAVE_MEMPCPY
+# endif
# define STDC_HEADERS
# define RE_TRANSLATE_TYPE char *
#endif
@@ -41,8 +43,10 @@ libc_hidden_proto(memcpy)
libc_hidden_proto(strcmp)
libc_hidden_proto(strlen)
libc_hidden_proto(printf)
-libc_hidden_proto(mempcpy)
libc_hidden_proto(abort)
+#ifdef __USE_GNU
+libc_hidden_proto(mempcpy)
+#endif
/* AIX requires this to be the first thing in the file. */
#if defined _AIX && !defined REGEX_MALLOC
@@ -8281,7 +8285,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
{
if (msg_size > errbuf_size)
{
-#if defined HAVE_MEMPCPY || defined _LIBC
+#if (defined HAVE_MEMPCPY || defined _LIBC) && defined __USE_GNU
*((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
#else
memcpy (errbuf, msg, errbuf_size - 1);
diff --git a/libc/misc/regex/regexec.c b/libc/misc/regex/regexec.c
index c56fb9d4a..2c8917e19 100644
--- a/libc/misc/regex/regexec.c
+++ b/libc/misc/regex/regexec.c
@@ -274,7 +274,7 @@ __compat_regexec (const regex_t *__restrict preg,
}
compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
# endif
-#elif __UCLIBC__
+#elif defined __UCLIBC__
strong_alias(__regexec,regexec)
#endif
@@ -385,7 +385,7 @@ re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs,
if (BE (s == NULL, 0))
return -2;
-#if defined _LIBC || defined __UCLIBC__
+#if (defined _LIBC || defined __UCLIBC__) && defined __USE_GNU
memcpy (__mempcpy (s, string1, length1), string2, length2);
#else
memcpy (s, string1, length1);
diff --git a/libc/misc/search/Makefile.in b/libc/misc/search/Makefile.in
index 80fafbf6c..0b80328cd 100644
--- a/libc/misc/search/Makefile.in
+++ b/libc/misc/search/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -27,6 +26,8 @@ MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC))
MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC))
libc-y += $(MISC_SEARCH_OBJ)
+libc-a-y += $(MISC_SEARCH_OBJ)
+libc-so-y += $(MISC_SEARCH_OBJ:.o=.os)
objclean-y += misc_search_objclean
diff --git a/libc/misc/statfs/Makefile.in b/libc/misc/statfs/Makefile.in
index c979b2255..5f0850c1b 100644
--- a/libc/misc/statfs/Makefile.in
+++ b/libc/misc/statfs/Makefile.in
@@ -17,6 +17,8 @@ MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC))
MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC))
libc-y += $(MISC_STATFS_OBJ)
+libc-a-y += $(MISC_STATFS_OBJ)
+libc-so-y += $(MISC_STATFS_OBJ:.o=.os)
libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_STATFS_OUT)/statvfs64.o $(MISC_STATFS_OUT)/fstatvfs64.o
diff --git a/libc/misc/syslog/Makefile.in b/libc/misc/syslog/Makefile.in
index b1d87e85d..2b8b0c613 100644
--- a/libc/misc/syslog/Makefile.in
+++ b/libc/misc/syslog/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -15,6 +14,8 @@ MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC))
MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC))
libc-y += $(MISC_SYSLOG_OBJ)
+libc-a-y += $(MISC_SYSLOG_OBJ)
+libc-so-y += $(MISC_SYSLOG_OBJ)
objclean-y += misc_syslog_objclean
diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in
index 44707d643..057a75568 100644
--- a/libc/misc/sysvipc/Makefile.in
+++ b/libc/misc/sysvipc/Makefile.in
@@ -24,6 +24,8 @@ MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
libc-y += $(MISC_SYSVIPC_OBJ)
+libc-a-y += $(MISC_SYSVIPC_OBJ)
+libc-so-y += $(MISC_SYSVIPC_OBJ:.o=.os)
objclean-y += misc_sysvipc_objclean
diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h
index ffc07daf9..62c035b20 100644
--- a/libc/misc/sysvipc/ipc.h
+++ b/libc/misc/sysvipc/ipc.h
@@ -3,7 +3,7 @@
#include <syscall.h>
#include <bits/wordsize.h>
-#if __WORDSIZE == 32
+#if __WORDSIZE == 32 || defined __alpha__
# define __IPC_64 0x100
#else
# define __IPC_64 0x0
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index f56bb4e8a..5f695084a 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -42,6 +42,34 @@ struct new_msg_buf{
#ifdef L_msgrcv
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+
+int
+__libc_msgrcv (int msqid, void *msgp, size_t msgsz, long int msgtyp, int msgflg)
+{
+ /* The problem here is that Linux' calling convention only allows up to
+ fives parameters to a system call. */
+ struct new_msg_buf tmp;
+
+ tmp.oldmsg = msgp;
+ tmp.r_msgtyp = msgtyp;
+
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg,
+ __ptrvalue (&tmp));
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg,
+ __ptrvalue (&tmp));
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+weak_alias(__libc_msgrcv, msgrcv)
+#else
#ifdef __NR_msgrcv
_syscall5(int, msgrcv, int, msqid, void *, msgp, size_t, msgsz, long int, msgtyp, int, msgflg);
#else
@@ -56,10 +84,32 @@ int msgrcv (int msqid, void *msgp, size_t msgsz,
}
#endif
#endif
+#endif
#ifdef L_msgsnd
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <sysdep-cancel.h>
+
+int
+__libc_msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz,
+ msgflg, msgp);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz,
+ msgflg, msgp);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+weak_alias(__libc_msgsnd, msgsnd)
+#else
#ifdef __NR_msgsnd
_syscall4(int, msgsnd, int, msqid, const void *, msgp, size_t, msgsz, int, msgflg);
#else
@@ -70,4 +120,5 @@ int msgsnd (int msqid, const void *msgp, size_t msgsz, int msgflg)
}
#endif
#endif
+#endif
diff --git a/libc/misc/time/Makefile.in b/libc/misc/time/Makefile.in
index b710b8b7c..aeabcd88a 100644
--- a/libc/misc/time/Makefile.in
+++ b/libc/misc/time/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -33,6 +32,8 @@ MISC_TIME_SRC := $(patsubst %.c,$(MISC_TIME_DIR)/%.c,$(CSRC))
MISC_TIME_OBJ := $(patsubst %.c,$(MISC_TIME_OUT)/%.o,$(CSRC))
libc-y += $(MISC_TIME_OBJ)
+libc-a-y += $(MISC_TIME_OBJ)
+libc-so-y += $(MISC_TIME_OBJ:.o=.os)
objclean-y += misc_time_objclean
diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c
index fb79883c9..93afa9b68 100644
--- a/libc/misc/time/time.c
+++ b/libc/misc/time/time.c
@@ -133,6 +133,7 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
+#include <strings.h>
#include <time.h>
#include <sys/time.h>
#include <limits.h>
@@ -164,7 +165,6 @@ libc_hidden_proto(strcmp)
libc_hidden_proto(strcpy)
libc_hidden_proto(strlen)
libc_hidden_proto(strncpy)
-libc_hidden_proto(strnlen)
/* libc_hidden_proto(sprintf) */
libc_hidden_proto(open)
libc_hidden_proto(read)
@@ -183,7 +183,7 @@ libc_hidden_proto(strtol_l)
libc_hidden_proto(strtoul_l)
libc_hidden_proto(nl_langinfo_l)
libc_hidden_proto(__ctype_b_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif
@@ -365,10 +365,22 @@ char *asctime_r(register const struct tm *__restrict ptm,
tmp /= 10;
} while (*--buffer == '?');
}
+/* Not sure if we should even bother ...
+ } else {
+ __set_errno(EOVERFLOW);
+ return NULL;
+ }
+*/
#else /* SAFE_ASCTIME_R */
buffer += 23;
tmp = ptm->tm_year + 1900;
assert( ((unsigned int) tmp) < 10000 );
+/* Not sure if we should even bother ...
+ if ( ((unsigned int) tmp) >= 10000 ) {
+ __set_errno(EOVERFLOW);
+ return NULL;
+ }
+*/
do {
*buffer = '0' + (tmp % 10);
tmp /= 10;
@@ -594,6 +606,8 @@ libc_hidden_def(localtime_r)
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
+libc_hidden_proto(strnlen)
+
struct ll_tzname_item;
typedef struct ll_tzname_item {
@@ -735,8 +749,13 @@ struct tm attribute_hidden *__time_localtime_tzi(register const time_t *__restri
_time_t2tm(x, days, result);
result->tm_isdst = dst;
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
+# ifdef __USE_BSD
result->tm_gmtoff = - tzi[dst].gmt_offset;
result->tm_zone = lookup_tzname(tzi[dst].tzname);
+# else
+ result->__tm_gmtoff = - tzi[dst].gmt_offset;
+ result->__tm_zone = lookup_tzname(tzi[dst].tzname);
+# endif
#endif /* __UCLIBC_HAS_TM_EXTENSIONS__ */
} while ((++dst < 2)
&& ((result->tm_isdst = tm_isdst(result, tzi)) != 0));
@@ -1115,8 +1134,13 @@ size_t __XL_NPP(strftime)(char *__restrict s, size_t maxsize,
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
#define RSP_TZUNLOCK ((void) 0)
-#define RSP_TZNAME timeptr->tm_zone
-#define RSP_GMT_OFFSET (-timeptr->tm_gmtoff)
+# ifdef __USE_BSD
+# define RSP_TZNAME timeptr->tm_zone
+# define RSP_GMT_OFFSET (-timeptr->tm_gmtoff)
+# else
+# define RSP_TZNAME timeptr->__tm_zone
+# define RSP_GMT_OFFSET (-timeptr->__tm_gmtoff)
+# endif
#else
@@ -1703,15 +1727,9 @@ static const char vals[] = {
#define DEFAULT_RULES (vals + 22)
/* Initialize to UTC. */
-libc_hidden_proto(daylight)
int daylight = 0;
-libc_hidden_data_def(daylight)
-libc_hidden_proto(timezone)
long timezone = 0;
-libc_hidden_data_def(timezone)
-libc_hidden_proto(tzname)
char *tzname[2] = { (char *) UTC, (char *) (UTC-1) };
-libc_hidden_data_def(tzname)
#ifdef __UCLIBC_HAS_THREADS__
attribute_hidden pthread_mutex_t _time_tzlock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -2199,8 +2217,13 @@ struct tm attribute_hidden *_time_t2tm(const time_t *__restrict timer,
/* TODO -- should this be 0? */
p[4] = 0; /* result[8] .. tm_isdst */
#ifdef __UCLIBC_HAS_TM_EXTENSIONS__
+# ifdef __USE_BSD
result->tm_gmtoff = 0;
result->tm_zone = utc_string;
+# else
+ result->__tm_gmtoff = 0;
+ result->__tm_zone = utc_string;
+# endif
#endif /* __UCLIBC_HAS_TM_EXTENSIONS__ */
return result;
diff --git a/libc/misc/ttyent/Makefile.in b/libc/misc/ttyent/Makefile.in
index 288a4c09b..ece277609 100644
--- a/libc/misc/ttyent/Makefile.in
+++ b/libc/misc/ttyent/Makefile.in
@@ -14,6 +14,8 @@ MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC))
MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC))
libc-y += $(MISC_TTYENT_OBJ)
+libc-a-y += $(MISC_TTYENT_OBJ)
+libc-so-y += $(MISC_TTYENT_OBJ:.o=.os)
objclean-y += misc_ttyent_objclean
diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c
index e9cc9be2a..89c39876f 100644
--- a/libc/misc/ttyent/getttyent.c
+++ b/libc/misc/ttyent/getttyent.c
@@ -51,7 +51,7 @@ libc_hidden_proto(fclose)
libc_hidden_proto(abort)
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index 5e584372c..4a01bb20b 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -15,6 +14,8 @@ MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC))
MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC))
libc-y += $(MISC_UTMP_OBJ)
+libc-a-y += $(MISC_UTMP_OBJ)
+libc-so-y += $(MISC_UTMP_OBJ)
objclean-y += misc_utmp_objclean
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 597307738..2734f9e95 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -19,6 +19,9 @@
#include <errno.h>
#include <string.h>
#include <utmp.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <not-cancel.h>
+#endif
libc_hidden_proto(strcmp)
libc_hidden_proto(strdup)
@@ -52,20 +55,37 @@ void setutent(void)
LOCK;
if (static_fd == -1) {
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if ((static_fd = open_not_cancel_2(static_ut_name, O_RDWR)) < 0) {
+ if ((static_fd = open_not_cancel_2(static_ut_name, O_RDONLY)) < 0) {
+#else
if ((static_fd = open(static_ut_name, O_RDWR)) < 0) {
if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) {
+#endif
goto bummer;
}
}
/* Make sure the file will be closed on exec() */
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ ret = fcntl_not_cancel(static_fd, F_GETFD, 0);
+#else
ret = fcntl(static_fd, F_GETFD, 0);
+#endif
if (ret >= 0) {
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ ret = fcntl_not_cancel(static_fd, F_SETFD, ret | FD_CLOEXEC);
+#else
ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC);
+#endif
}
if (ret < 0) {
bummer:
static_fd = -1;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(static_fd);
+#else
close(static_fd);
+#endif
unlock_and_ret:
UNLOCK;
return;
@@ -88,7 +108,11 @@ static struct utmp *__getutent(int utmp_fd)
}
LOCK;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ if (read_not_cancel(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp))
+#else
if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp))
+#endif
{
ret = &static_utmp;
}
@@ -101,7 +125,11 @@ void endutent(void)
{
LOCK;
if (static_fd != -1)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(static_fd);
+#else
close(static_fd);
+#endif
static_fd = -1;
UNLOCK;
}
@@ -168,7 +196,11 @@ struct utmp *pututline (const struct utmp *utmp_entry)
lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
else
lseek(static_fd, (off_t) 0, SEEK_END);
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
+#else
+ if (write_not_cancel(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
+#endif
utmp_entry = NULL;
UNLOCK;
@@ -190,7 +222,11 @@ int utmpname (const char *new_ut_name)
}
if (static_fd != -1)
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ close_not_cancel_no_status(static_fd);
+#else
close(static_fd);
+#endif
static_fd = -1;
UNLOCK;
return 0;
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index 0378070e7..082e8c184 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -13,6 +13,10 @@
#include <utmp.h>
#include <fcntl.h>
#include <sys/file.h>
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+#include <errno.h>
+#include <not-cancel.h>
+#endif
#if 0
libc_hidden_proto(memset)
@@ -47,6 +51,16 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
{
int fd;
+#ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ fd = open_not_cancel(wtmp_file, O_APPEND | O_WRONLY, 0);
+ if (fd >= 0) {
+ if (lockf(fd, F_LOCK, 0)==0) {
+ write_not_cancel(fd, (const char *) lutmp, sizeof(struct utmp));
+ lockf(fd, F_ULOCK, 0);
+ close_not_cancel_no_status(fd);
+ }
+ }
+#else
fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
if (fd >= 0) {
if (lockf(fd, F_LOCK, 0)==0) {
@@ -55,4 +69,5 @@ void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
close(fd);
}
}
+#endif
}
diff --git a/libc/misc/wchar/Makefile.in b/libc/misc/wchar/Makefile.in
index 64171eb96..7b408b3a0 100644
--- a/libc/misc/wchar/Makefile.in
+++ b/libc/misc/wchar/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -9,7 +8,7 @@
# The stdio and time related wide functions are now built in the normal
# directories.
#
-# stdio:
+# stdio:
# fwide fgetwc getwchar fgetws fputwc putwchar fputws ungetwc
# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
@@ -33,6 +32,8 @@ MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC))
MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC))
libc-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ)
+libc-a-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ)
+libc-so-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ:.o=.os)
objclean-y += misc_wchar_objclean
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index a795986e8..32ad41ee6 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -98,7 +98,6 @@
* Manuel
*/
-#define _ISOC99_SOURCE
#include <errno.h>
#include <stddef.h>
#include <limits.h>
@@ -111,9 +110,6 @@
#include <wchar.h>
#include <bits/uClibc_uwchar.h>
-#ifdef __UCLIBC_HAS_LOCALE__
-libc_hidden_proto(__global_locale)
-#endif
/**********************************************************************/
#ifdef __UCLIBC_HAS_LOCALE__
#ifdef __UCLIBC_MJN3_ONLY__
@@ -1195,6 +1191,7 @@ typedef struct {
#include <iconv.h>
#include <string.h>
+#include <strings.h>
#include <endian.h>
#include <byteswap.h>
diff --git a/libc/misc/wctype/Makefile.in b/libc/misc/wctype/Makefile.in
index 0dcd485de..1af030e7f 100644
--- a/libc/misc/wctype/Makefile.in
+++ b/libc/misc/wctype/Makefile.in
@@ -1,6 +1,5 @@
# Makefile for uClibc
#
-# Copyright (C) 2000 by Lineo, inc.
# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
@@ -28,6 +27,8 @@ MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC))
MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC))
libc-y += $(MISC_WCTYPE_OBJ)
+libc-a-y += $(MISC_WCTYPE_OBJ)
+libc-so-y += $(MISC_WCTYPE_OBJ:.o=.os)
objclean-y += misc_wctype_objclean
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
index a7d111039..0f19cad04 100644
--- a/libc/misc/wctype/_wctype.c
+++ b/libc/misc/wctype/_wctype.c
@@ -38,9 +38,7 @@
#include <bits/uClibc_uwchar.h>
libc_hidden_proto(strcmp)
-libc_hidden_proto(__C_ctype_tolower)
libc_hidden_proto(tolower)
-libc_hidden_proto(__C_ctype_toupper)
libc_hidden_proto(toupper)
libc_hidden_proto(towlower)
libc_hidden_proto(towupper)
@@ -57,11 +55,13 @@ libc_hidden_proto(towlower_l)
libc_hidden_proto(towupper_l)
libc_hidden_proto(towctrans_l)
libc_hidden_proto(iswctype_l)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif /* __UCLIBC_HAS_XLOCALE__ */
-#ifdef __UCLIBC_HAS_LOCALE__
-libc_hidden_proto(__global_locale)
+
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+libc_hidden_proto(__C_ctype_tolower)
+libc_hidden_proto(__C_ctype_toupper)
#endif
/* We know wide char support is enabled. We wouldn't be here otherwise. */
diff --git a/libc/misc/wordexp/Makefile.in b/libc/misc/wordexp/Makefile.in
index 526807f25..e605715dc 100644
--- a/libc/misc/wordexp/Makefile.in
+++ b/libc/misc/wordexp/Makefile.in
@@ -14,6 +14,8 @@ MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC))
MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC))
libc-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ)
+libc-a-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ)
+libc-so-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ:.o=.os)
objclean-y += misc_wordexp_objclean
diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c
index 1693d8b8a..58094dbc7 100644
--- a/libc/misc/wordexp/wordexp.c
+++ b/libc/misc/wordexp/wordexp.c
@@ -44,7 +44,6 @@ libc_hidden_proto(strlen)
libc_hidden_proto(strndup)
libc_hidden_proto(strspn)
libc_hidden_proto(strcspn)
-libc_hidden_proto(__environ)
libc_hidden_proto(setenv)
libc_hidden_proto(unsetenv)
libc_hidden_proto(waitpid)
@@ -66,13 +65,12 @@ libc_hidden_proto(getpid)
libc_hidden_proto(sprintf)
libc_hidden_proto(fprintf)
libc_hidden_proto(abort)
-libc_hidden_proto(stderr)
libc_hidden_proto(glob)
libc_hidden_proto(globfree)
libc_hidden_proto(wordfree)
#ifdef __UCLIBC_HAS_XLOCALE__
libc_hidden_proto(__ctype_b_loc)
-#else
+#elif __UCLIBC_HAS_CTYPE_TABLES__
libc_hidden_proto(__ctype_b)
#endif
diff --git a/libc/sysdeps/linux/Makefile.commonarch b/libc/sysdeps/linux/Makefile.commonarch
index ea4ba53b3..d45aa5756 100644
--- a/libc/sysdeps/linux/Makefile.commonarch
+++ b/libc/sysdeps/linux/Makefile.commonarch
@@ -16,6 +16,9 @@ ARCH_SOBJ := $(patsubst %.s,$(ARCH_OUT)/%.o,$(patsubst %.S,$(ARCH_OUT)/%.o,$(SSR
ARCH_OBJS := $(ARCH_COBJ) $(ARCH_SOBJ)
crt-y := create
+libc-a-y += $(ARCH_OBJS)
+libc-so-y += $(ARCH_OBJS:.o=.os)
+libc-multi-y += $(ARCH_CSRC)
libc-y += $(ARCH_OBJS)
libc-nomulti-y += $(ARCH_SOBJ)
objclean-y += arch_objclean
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in
index c3f2009cc..c2c756edc 100644
--- a/libc/sysdeps/linux/common/Makefile.in
+++ b/libc/sysdeps/linux/common/Makefile.in
@@ -25,7 +25,9 @@ CSRC := $(filter-out ssp.c,$(CSRC))
endif
ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-CSRC := $(filter-out fork.c getpid.c raise.c pause.c open.c close.c read.c write.c nanosleep.c __syscall_rt_sigaction.c,$(CSRC))
+CSRC := $(filter-out fork.c getpid.c raise.c pause.c open.c close.c \
+ read.c write.c nanosleep.c __syscall_rt_sigaction.c msync.c \
+ lseek.c __syscall_fcntl64.c, $(CSRC))
endif
# fails for some reason
@@ -42,6 +44,9 @@ COMMON_OBJ := $(patsubst %.c,$(COMMON_OUT)/%.o,$(CSRC))
libc-y += $(COMMON_OBJ)
libc-static-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.o
libc-nonshared-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.os
+libc-a-y += $(COMMON_OBJ)
+libc-so-y += $(COMMON_OBJ)
+libc-a-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp-local.o
libc-nomulti-y += $(COMMON_OUT)/__syscall_rt_sigaction.o $(COMMON_OUT)/__syscall_sigaction.o
libc-nomulti-$(UCLIBC_HAS_SSP) += $(COMMON_OUT)/ssp.o