[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r8710 - in /branches/eglibc-2_10/libc: ./ nptl/sysdeps/pthread/ nptl/sysdeps/pthread/bits/



Author: maxim
Date: Mon Jul 27 09:19:01 2009
New Revision: 8710

Log:
	Add BIG_MACROS option group.

	* option-groups.def (OPTION_EGLIBC_BIG_MACROS): Define new option
	group.
	* option-groups.defaults (OPTION_EGLIBC_BIG_MACROS): Define default.
	* nptl/sysdeps/pthread/small-macros-fns.c: New file.  Define wrappers.
	* nptl/sysdeps/pthread/Makefile (nptl/sysdep_routines): Add
	small-macros-fns.
	* nptl/sysdeps/pthread/bits/libc-lock.h (gnu/option-groups.h): Include.
	(errno.h): Include, make implicit dependency explicit.
	(__libc_lock_lock, __libc_lock_lock_recursive),
	(__libc_lock_trylock, __libc_lock_trylock_recursive),
	(__libc_lock_unlock, __libc_lock_unlock_recursive):
	If OPTION_EGLIBC_BIG_MACROS, define to macro;
	define to function call	otherwise.

Added:
    branches/eglibc-2_10/libc/nptl/sysdeps/pthread/small-macros-fns.c
Modified:
    branches/eglibc-2_10/libc/ChangeLog.eglibc
    branches/eglibc-2_10/libc/nptl/sysdeps/pthread/Makefile
    branches/eglibc-2_10/libc/nptl/sysdeps/pthread/bits/libc-lock.h
    branches/eglibc-2_10/libc/option-groups.def
    branches/eglibc-2_10/libc/option-groups.defaults

Modified: branches/eglibc-2_10/libc/ChangeLog.eglibc
==============================================================================
--- branches/eglibc-2_10/libc/ChangeLog.eglibc (original)
+++ branches/eglibc-2_10/libc/ChangeLog.eglibc Mon Jul 27 09:19:01 2009
@@ -1,3 +1,21 @@
+2009-07-27  Maxim Kuvyrkov  <maxim@xxxxxxxxxxxxxxxx>
+
+	Add BIG_MACROS option group.
+
+	* option-groups.def (OPTION_EGLIBC_BIG_MACROS): Define new option
+	group.
+	* option-groups.defaults (OPTION_EGLIBC_BIG_MACROS): Define default.
+	* nptl/sysdeps/pthread/small-macros-fns.c: New file.  Define wrappers.
+	* nptl/sysdeps/pthread/Makefile (nptl/sysdep_routines): Add
+	small-macros-fns.
+	* nptl/sysdeps/pthread/bits/libc-lock.h (gnu/option-groups.h): Include.
+	(errno.h): Include, make implicit dependency explicit.
+	(__libc_lock_lock, __libc_lock_lock_recursive),
+	(__libc_lock_trylock, __libc_lock_trylock_recursive),
+	(__libc_lock_unlock, __libc_lock_unlock_recursive):
+	If OPTION_EGLIBC_BIG_MACROS, define to macro;
+	define to function call	otherwise.
+
 2009-07-02  Joseph Myers  <joseph@xxxxxxxxxxxxxxxx>
 
 	Backport:

Modified: branches/eglibc-2_10/libc/nptl/sysdeps/pthread/Makefile
==============================================================================
--- branches/eglibc-2_10/libc/nptl/sysdeps/pthread/Makefile (original)
+++ branches/eglibc-2_10/libc/nptl/sysdeps/pthread/Makefile Mon Jul 27 09:19:01 2009
@@ -25,6 +25,9 @@
 
 ifeq ($(subdir),nptl)
 libpthread-sysdep_routines += errno-loc
+ifeq ($(OPTION_EGLIBC_BIG_MACROS),n)
+sysdep_routines += small-macros-fns
+endif
 endif
 
 ifeq ($(subdir),rt)

Modified: branches/eglibc-2_10/libc/nptl/sysdeps/pthread/bits/libc-lock.h
==============================================================================
--- branches/eglibc-2_10/libc/nptl/sysdeps/pthread/bits/libc-lock.h (original)
+++ branches/eglibc-2_10/libc/nptl/sysdeps/pthread/bits/libc-lock.h Mon Jul 27 09:19:01 2009
@@ -35,6 +35,8 @@
 # include <lowlevellock.h>
 # include <tls.h>
 # include <pthread-functions.h>
+# include <errno.h> /* For EBUSY.  */
+# include <gnu/option-groups.h> /* For __OPTION_EGLIBC_BIG_MACROS.  */
 #endif
 
 /* Mutex type.  */
@@ -238,8 +240,20 @@
 
 /* Lock the named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern void __libc_lock_lock_fn (__libc_lock_t *);
+libc_hidden_proto (__libc_lock_lock_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 # define __libc_lock_lock(NAME) \
   ({ lll_lock (NAME, LLL_PRIVATE); 0; })
+# else
+#  define __libc_lock_lock(NAME)		\
+  __libc_lock_lock_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_lock(NAME) \
   __libc_maybe_call (__pthread_mutex_lock, (&(NAME)), 0)
@@ -251,6 +265,14 @@
 
 /* Lock the recursive named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern void __libc_lock_lock_recursive_fn (__libc_lock_recursive_t *);
+libc_hidden_proto (__libc_lock_lock_recursive_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 # define __libc_lock_lock_recursive(NAME) \
   do {									      \
     void *self = THREAD_SELF;						      \
@@ -261,6 +283,10 @@
       }									      \
     ++(NAME).cnt;							      \
   } while (0)
+# else
+# define __libc_lock_lock_recursive(NAME)				\
+  __libc_lock_lock_recursive_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_lock_recursive(NAME) \
   __libc_maybe_call (__pthread_mutex_lock, (&(NAME).mutex), 0)
@@ -268,8 +294,20 @@
 
 /* Try to lock the named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern int __libc_lock_trylock_fn (__libc_lock_t *);
+libc_hidden_proto (__libc_lock_trylock_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 # define __libc_lock_trylock(NAME) \
   lll_trylock (NAME)
+# else
+# define __libc_lock_trylock(NAME) \
+  __libc_lock_trylock_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_trylock(NAME) \
   __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
@@ -281,6 +319,14 @@
 
 /* Try to lock the recursive named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern int __libc_lock_trylock_recursive_fn (__libc_lock_recursive_t *);
+libc_hidden_proto (__libc_lock_trylock_recursive_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 # define __libc_lock_trylock_recursive(NAME) \
   ({									      \
     int result = 0;							      \
@@ -299,6 +345,10 @@
       ++(NAME).cnt;							      \
     result;								      \
   })
+# else
+# define __libc_lock_trylock_recursive(NAME) \
+  __libc_lock_trylock_recursive_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_trylock_recursive(NAME) \
   __libc_maybe_call (__pthread_mutex_trylock, (&(NAME)), 0)
@@ -309,8 +359,20 @@
 
 /* Unlock the named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS, or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern void __libc_lock_unlock_fn (__libc_lock_t *);
+libc_hidden_proto (__libc_lock_unlock_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 # define __libc_lock_unlock(NAME) \
   lll_unlock (NAME, LLL_PRIVATE)
+# else
+# define __libc_lock_unlock(NAME) \
+  __libc_lock_unlock_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_unlock(NAME) \
   __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)
@@ -320,6 +382,14 @@
 
 /* Unlock the recursive named lock variable.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+# if __OPTION_EGLIBC_BIG_MACROS != 1
+/* EGLIBC: Declare wrapper function for a big macro if either
+   !__OPTION_EGLIBC_BIG_MACROS, or we are using a back door from
+   small-macros-fns.c (__OPTION_EGLIBC_BIG_MACROS == 2).  */
+extern void __libc_lock_unlock_recursive_fn (__libc_lock_recursive_t *);
+libc_hidden_proto (__libc_lock_unlock_recursive_fn);
+# endif /* __OPTION_EGLIBC_BIG_MACROS != 1 */
+# if __OPTION_EGLIBC_BIG_MACROS
 /* We do no error checking here.  */
 # define __libc_lock_unlock_recursive(NAME) \
   do {									      \
@@ -329,6 +399,10 @@
 	lll_unlock ((NAME).lock, LLL_PRIVATE);				      \
       }									      \
   } while (0)
+# else
+# define __libc_lock_unlock_recursive(NAME) \
+  __libc_lock_unlock_recursive_fn (&(NAME))
+# endif /* __OPTION_EGLIBC_BIG_MACROS */
 #else
 # define __libc_lock_unlock_recursive(NAME) \
   __libc_maybe_call (__pthread_mutex_unlock, (&(NAME)), 0)

Added: branches/eglibc-2_10/libc/nptl/sysdeps/pthread/small-macros-fns.c
==============================================================================
--- branches/eglibc-2_10/libc/nptl/sysdeps/pthread/small-macros-fns.c (added)
+++ branches/eglibc-2_10/libc/nptl/sysdeps/pthread/small-macros-fns.c Mon Jul 27 09:19:01 2009
@@ -1,0 +1,70 @@
+/* EGLIBC: function wrappers for big macros.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   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; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* Handle macros from ./bits/libc-lock.h.  */
+#if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
+
+/* Get the macros for function bodies through a back door.  */
+# undef __OPTION_EGLIBC_BIG_MACROS
+# define __OPTION_EGLIBC_BIG_MACROS 2
+# include <bits/libc-lock.h>
+
+void
+__libc_lock_lock_fn (__libc_lock_t *name)
+{
+  __libc_lock_lock (*name);
+}
+libc_hidden_def (__libc_lock_lock_fn);
+
+void
+__libc_lock_lock_recursive_fn (__libc_lock_recursive_t *name)
+{
+  __libc_lock_lock_recursive (*name);
+}
+libc_hidden_def (__libc_lock_lock_recursive_fn);
+
+int
+__libc_lock_trylock_fn (__libc_lock_t *name)
+{
+  return __libc_lock_trylock (*name);
+}
+libc_hidden_def (__libc_lock_trylock_fn);
+
+int
+__libc_lock_trylock_recursive_fn (__libc_lock_recursive_t *name)
+{
+  return __libc_lock_trylock_recursive (*name);
+}
+libc_hidden_def (__libc_lock_trylock_recursive_fn);
+
+void
+__libc_lock_unlock_fn (__libc_lock_t *name)
+{
+  __libc_lock_unlock (*name);
+}
+libc_hidden_def (__libc_lock_unlock_fn);
+
+void
+__libc_lock_unlock_recursive_fn (__libc_lock_recursive_t *name)
+{
+  __libc_lock_unlock_recursive (*name);
+}
+libc_hidden_def (__libc_lock_unlock_recursive_fn);
+
+#endif /*defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)*/

Modified: branches/eglibc-2_10/libc/option-groups.def
==============================================================================
--- branches/eglibc-2_10/libc/option-groups.def (original)
+++ branches/eglibc-2_10/libc/option-groups.def Mon Jul 27 09:19:01 2009
@@ -84,6 +84,14 @@
          backtrace
          backtrace_symbols
          backtrace_symbols_fd
+
+config OPTION_EGLIBC_BIG_MACROS
+   bool "Use extensive inline code"
+   help
+       This option group specifies whether certain pieces of code
+       should be inlined to achieve maximum speed.  If this option
+       group is not selected, function calls will be used instead,
+       hence reducing the library footprint.
 
 config OPTION_EGLIBC_BSD
    bool "BSD-specific functions, and their compatibility stubs"

Modified: branches/eglibc-2_10/libc/option-groups.defaults
==============================================================================
--- branches/eglibc-2_10/libc/option-groups.defaults (original)
+++ branches/eglibc-2_10/libc/option-groups.defaults Mon Jul 27 09:19:01 2009
@@ -10,6 +10,7 @@
 # By default, all option groups are enabled.
 OPTION_EGLIBC_ADVANCED_INET6 = y
 OPTION_EGLIBC_BACKTRACE = y
+OPTION_EGLIBC_BIG_MACROS = y
 OPTION_EGLIBC_BSD = y
 OPTION_EGLIBC_CXX_TESTS = y
 OPTION_EGLIBC_CATGETS = y