svn commit: branches/uClibc-nptl/libc/misc: internals pthread

sjhill at uclibc.org sjhill at uclibc.org
Tue Feb 28 00:28:56 UTC 2006


Author: sjhill
Date: 2006-02-27 16:28:55 -0800 (Mon, 27 Feb 2006)
New Revision: 14324

Log:
Merge from trunk.


Modified:
   branches/uClibc-nptl/libc/misc/internals/Makefile.in
   branches/uClibc-nptl/libc/misc/internals/tempname.c
   branches/uClibc-nptl/libc/misc/pthread/Makefile.in
   branches/uClibc-nptl/libc/misc/pthread/no-tsd.c
   branches/uClibc-nptl/libc/misc/pthread/weaks.c


Changeset:
Modified: branches/uClibc-nptl/libc/misc/internals/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/misc/internals/Makefile.in	2006-02-28 00:17:35 UTC (rev 14323)
+++ branches/uClibc-nptl/libc/misc/internals/Makefile.in	2006-02-28 00:28:55 UTC (rev 14324)
@@ -1,29 +1,28 @@
 # Makefile for uClibc
 #
 # Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen at uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
 #
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 #
 
-CFLAGS-__uClibc_main.c:=$(SSP_DISABLE_FLAGS)
+CFLAGS-__uClibc_main.c := $(SSP_DISABLE_FLAGS)
 
-CSRC:=tempname.c errno.c __errno_location.c __h_errno_location.c
+CSRC := tempname.c errno.c __errno_location.c __h_errno_location.c
 
-MISC_INTERNALS_DIR:=$(top_srcdir)libc/misc/internals
-MISC_INTERNALS_OUT:=$(top_builddir)libc/misc/internals
+MISC_INTERNALS_DIR := $(top_srcdir)libc/misc/internals
+MISC_INTERNALS_OUT := $(top_builddir)libc/misc/internals
 
-MISC_INTERNALS_SRC:=$(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
-MISC_INTERNALS_OBJ:=$(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
+MISC_INTERNALS_SRC := $(patsubst %.c,$(MISC_INTERNALS_DIR)/%.c,$(CSRC))
+MISC_INTERNALS_OBJ := $(patsubst %.c,$(MISC_INTERNALS_OUT)/%.o,$(CSRC))
 
-libc-a-y+=$(MISC_INTERNALS_OBJ)
-libc-so-y+=$(MISC_INTERNALS_OBJ:.o=.oS)
-libc-shared-y+=$(MISC_INTERNALS_OUT)/__uClibc_main.oS
-libc-static-y+=$(MISC_INTERNALS_OUT)/__uClibc_main.o
+libc-y += $(MISC_INTERNALS_OBJ)
+libc-shared-y += $(MISC_INTERNALS_OUT)/__uClibc_main.oS
+libc-static-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
 
-libc-multi-y+=$(MISC_INTERNALS_SRC)
+libc-nomulti-y += $(MISC_INTERNALS_OUT)/__uClibc_main.o
 
-objclean-y+=misc_internals_objclean
+objclean-y += misc_internals_objclean
 
 misc_internals_objclean:
 	$(RM) $(MISC_INTERNALS_OUT)/*.{o,os,oS}

Modified: branches/uClibc-nptl/libc/misc/internals/tempname.c
===================================================================
--- branches/uClibc-nptl/libc/misc/internals/tempname.c	2006-02-28 00:17:35 UTC (rev 14323)
+++ branches/uClibc-nptl/libc/misc/internals/tempname.c	2006-02-28 00:28:55 UTC (rev 14324)
@@ -31,10 +31,6 @@
  * Use brain damaged getpid() if real random fails.
  */
 
-#define open64 __open64
-#define mkdir __mkdir
-#define gettimeofday __gettimeofday
-
 #include <stddef.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -49,12 +45,25 @@
 #include <sys/time.h>
 #include "tempname.h"
 
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(mkdir)
+libc_hidden_proto(open)
+#ifdef __UCLIBC_HAS_LFS__
+libc_hidden_proto(open64)
+#endif
+libc_hidden_proto(read)
+libc_hidden_proto(close)
+libc_hidden_proto(getpid)
+libc_hidden_proto(stat)
+libc_hidden_proto(gettimeofday)
 
 /* Return nonzero if DIR is an existent directory.  */
 static int direxists (const char *dir)
 {
     struct stat buf;
-    return __stat(dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+    return stat(dir, &buf) == 0 && S_ISDIR (buf.st_mode);
 }
 
 /* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
@@ -76,7 +85,7 @@
     }
     else
     {
-	plen = __strlen (pfx);
+	plen = strlen (pfx);
 	if (plen > 5)
 	    plen = 5;
     }
@@ -98,7 +107,7 @@
     {
 	if (direxists (P_tmpdir))
 	    dir = P_tmpdir;
-	else if (__strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
+	else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
 	    dir = "/tmp";
 	else
 	{
@@ -107,7 +116,7 @@
 	}
     }
 
-    dlen = __strlen (dir);
+    dlen = strlen (dir);
     while (dlen > 1 && dir[dlen - 1] == '/')
 	dlen--;			/* remove trailing slashes */
 
@@ -118,25 +127,26 @@
 	return -1;
     }
 
-    __sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
+    sprintf (tmpl, "%.*s/%.*sXXXXXX", dlen, dir, plen, pfx);
     return 0;
 }
 
 /* These are the characters used in temporary filenames.  */
 static const char letters[] =
 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+#define NUM_LETTERS (62)
 
 static unsigned int fillrand(unsigned char *buf, unsigned int len)
 {
     int fd;
     unsigned int result = -1;
-    fd = __open("/dev/urandom", O_RDONLY);
+    fd = open("/dev/urandom", O_RDONLY);
     if (fd < 0) {
-	fd = __open("/dev/random", O_RDONLY | O_NONBLOCK);
+	fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
     }
     if (fd >= 0) {
-	result = __read(fd, buf, len);
-	__close(fd);
+	result = read(fd, buf, len);
+	close(fd);
     }
     return result;
 }
@@ -148,19 +158,19 @@
 	uint32_t high, low, rh;
 	static uint64_t value;
 	gettimeofday(&tv, NULL);
-	value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid();
+	value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid();
 	low = value & UINT32_MAX;
 	high = value >> 32;
 	for (i = 0; i < len; ++i) {
-		rh = high % 62;
-		high /= 62;
-#define L ((UINT32_MAX % 62 + 1) % 62)
-		k = (low % 62) + (L * rh);
+		rh = high % NUM_LETTERS;
+		high /= NUM_LETTERS;
+#define L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS)
+		k = (low % NUM_LETTERS) + (L * rh);
 #undef L
-#define H ((UINT32_MAX / 62) + ((UINT32_MAX % 62 + 1) / 62))
-		low = (low / 62) + (H * rh) + (k / 62);
+#define H ((UINT32_MAX / NUM_LETTERS) + ((UINT32_MAX % NUM_LETTERS + 1) / NUM_LETTERS))
+		low = (low / NUM_LETTERS) + (H * rh) + (k / NUM_LETTERS);
 #undef H
-		k %= 62;
+		k %= NUM_LETTERS;
 		buf[i] = letters[k];
 	}
 }
@@ -182,52 +192,47 @@
 int attribute_hidden __gen_tempname (char *tmpl, int kind)
 {
     char *XXXXXX;
-    unsigned int i, k;
-    int len, count, fd, save_errno = errno;
+    unsigned int i;
+    int fd, save_errno = errno;
     unsigned char randomness[6];
+    size_t len;
 
-    len = __strlen (tmpl);
-    if (len < 6 || __strcmp (&tmpl[len - 6], "XXXXXX"))
+    len = strlen (tmpl);
+    /* This is where the Xs start.  */
+    XXXXXX = tmpl + len - 6;
+    if (len < 6 || strcmp (XXXXXX, "XXXXXX"))
     {
 	__set_errno (EINVAL);
 	return -1;
     }
 
-    /* This is where the Xs start.  */
-    XXXXXX = &tmpl[len - 6];
-
     /* Get some random data.  */
-	if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) {
-		/* if random device nodes failed us, lets use the braindamaged ver */
-		brain_damaged_fillrand(randomness, sizeof(randomness));
+    if (fillrand(randomness, sizeof(randomness)) != sizeof(randomness)) {
+	/* if random device nodes failed us, lets use the braindamaged ver */
+	brain_damaged_fillrand(randomness, sizeof(randomness));
     }
-    for (i = 0 ; i < sizeof(randomness) ; i++) {
-	k = ((randomness[i]) % 62);
-	XXXXXX[i] = letters[k];
-    }
 
-    for (count = 0; count < TMP_MAX; ++count)
-    {
+    for (i = 0; i < sizeof(randomness); ++i)
+	XXXXXX[i] = letters[(randomness[i]) % NUM_LETTERS];
+
+    for (i = 0; i < TMP_MAX; ++i) {
+
 	switch(kind) {
 	    case __GT_NOCREATE:
 		{
 		    struct stat st;
-		    if (__stat (tmpl, &st) < 0)
-		    {
-			if (errno == ENOENT)
-			{
-			    __set_errno (save_errno);
-			    return 0;
-			}
-			else
+		    if (stat (tmpl, &st) < 0) {
+			if (errno == ENOENT) {
+			    fd = 0;
+			    goto restore_and_ret;
+			} else
 			    /* Give up now. */
 			    return -1;
-		    }
-		    else
-			continue;
+		    } else
+			fd = 0;
 		}
 	    case __GT_FILE:
-		fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+		fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
 		break;
 #if defined __UCLIBC_HAS_LFS__
 	    case __GT_BIGFILE:
@@ -243,6 +248,7 @@
 	}
 
 	if (fd >= 0) {
+restore_and_ret:
 	    __set_errno (save_errno);
 	    return fd;
 	}

Modified: branches/uClibc-nptl/libc/misc/pthread/Makefile.in
===================================================================
--- branches/uClibc-nptl/libc/misc/pthread/Makefile.in	2006-02-28 00:17:35 UTC (rev 14323)
+++ branches/uClibc-nptl/libc/misc/pthread/Makefile.in	2006-02-28 00:28:55 UTC (rev 14324)
@@ -1,6 +1,6 @@
 # Makefile for uClibc
 #
-# Copyright (C) 2000-2005 Erik Andersen <andersen at uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen at uclibc.org>
 #
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 #
@@ -8,11 +8,10 @@
 MISC_PTHREAD_DIR := $(top_srcdir)libc/misc/pthread
 MISC_PTHREAD_OUT := $(top_builddir)libc/misc/pthread
 
-MISC_PTHREAD_CSRC := no-tsd.c
-MISC_PTHREAD_STATIC_CSRC := weaks.c
+libc-static-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/weaks.o
+libc-shared-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/no-tsd.oS
 
-libc-static-$(UCLIBC_HAS_THREADS) += $(patsubst %.c,$(MISC_PTHREAD_OUT)/%.o,$(MISC_PTHREAD_STATIC_CSRC))
-libc-shared-$(UCLIBC_HAS_THREADS) += $(patsubst %.c,$(MISC_PTHREAD_OUT)/%.oS,$(MISC_PTHREAD_CSRC))
+libc-nomulti-$(UCLIBC_HAS_THREADS) += $(MISC_PTHREAD_OUT)/no-tsd.o
 
 objclean-y += misc_pthread_objclean
 

Modified: branches/uClibc-nptl/libc/misc/pthread/no-tsd.c
===================================================================
--- branches/uClibc-nptl/libc/misc/pthread/no-tsd.c	2006-02-28 00:17:35 UTC (rev 14323)
+++ branches/uClibc-nptl/libc/misc/pthread/no-tsd.c	2006-02-28 00:28:55 UTC (rev 14324)
@@ -17,7 +17,6 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#define _GNU_SOURCE
 #include <bits/libc-tsd.h>
 
 /* This file provides uinitialized (common) definitions for the

Modified: branches/uClibc-nptl/libc/misc/pthread/weaks.c
===================================================================
--- branches/uClibc-nptl/libc/misc/pthread/weaks.c	2006-02-28 00:17:35 UTC (rev 14323)
+++ branches/uClibc-nptl/libc/misc/pthread/weaks.c	2006-02-28 00:28:55 UTC (rev 14324)
@@ -17,7 +17,6 @@
    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.
@@ -36,8 +35,3 @@
 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




More information about the uClibc-cvs mailing list