public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Move Linux kernel version conditionals to kernel-features.h
@ 2012-08-03 15:07 Joseph S. Myers
  2012-08-03 18:38 ` Roland McGrath
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joseph S. Myers @ 2012-08-03 15:07 UTC (permalink / raw)
  To: libc-alpha; +Cc: libc-ports, Mike Frysinger

Generally conditions on the compile-time minimum Linux kernel version
go via __ASSUME_* macros defined in kernel-features.h.  However,
sysdeps/unix/sysv/linux/sysconf.c and
ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h have such
conditions directly using __LINUX_KERNEL_VERSION.

This patch fixes those conditions to follow the kernel-features.h
convention instead.  For sysconf.c, a new macro
__ASSUME_ARG_MAX_STACK_BASED is defined and used.  Because the #if
condition was a condition on an if () condition using the same
version, the same version number was previously repeated in both
conditions in close proximity; to avoid those copies (that should be
in sync) now being widely separated, I defined a macro
__LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL for the version number in
question.  For ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h, I
removed the condition; this is in line with commit
de7f5ce7c595f4741029f7e63429826f8e82b340 which removed such a
condition from nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h a
few months ago.

Tested x86_64.  (This should be reviewed for ia64.)

2012-08-03  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/kernel-features.h
	(__LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL): Define.
	[__LINUX_KERNEL_VERSION >= __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL]
	(__ASSUME_ARG_MAX_STACK_BASED): Define.
	* sysdeps/unix/sysv/linux/sysconf.c (__sysconf)
	[__LINUX_KERNEL_VERSION < 0x020617]: Change condition to
	!__ASSUME_ARG_MAX_STACK_BASED.  Compare version with
	__LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL.

ports/ChangeLog.ia64
2012-08-03  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h
	(_dl_discover_osversion): Do not condition on
	__LINUX_KERNEL_VERSION < 0x020617.
	(HAVE_DL_DISCOVER_OSVERSION): Likewise.

diff --git a/ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h b/ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h
index e30e33d..0962129 100644
--- a/ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h
+++ b/ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h
@@ -1,5 +1,5 @@
 /* System-specific settings for dynamic linker code.  IA-64 version.
-   Copyright (C) 2003, 2004, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2003-2012 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
@@ -65,9 +65,7 @@ extern int _dl_sysinfo_break attribute_hidden;
 #define DL_ARGV_NOT_RELRO 1
 
 
-/* The _dl_discover_osversion function is so far only needed in sysconf
-   to check for kernels later than 2.6.23.  */
-#if !defined __ASSEMBLER__ && __LINUX_KERNEL_VERSION < 0x020617
+#ifndef __ASSEMBLER__
 /* Get version of the OS.  */
 extern int _dl_discover_osversion (void) attribute_hidden;
 # define HAVE_DL_DISCOVER_OSVERSION	1
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index b949f16..18cb038 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -279,6 +279,13 @@
 # define __ASSUME_O_CLOEXEC	1
 #endif
 
+/* From 2.6.23 onwards the value of ARG_MAX depends on the stack
+   size.  */
+#define __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL	0x020617
+#if __LINUX_KERNEL_VERSION >= __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL
+# define __ASSUME_ARG_MAX_STACK_BASED	1
+#endif
+
 /* Support for ADJ_OFFSET_SS_READ was added in 2.6.24.  */
 #if __LINUX_KERNEL_VERSION >= 0x020618
 # define __ASSUME_ADJ_OFFSET_SS_READ	1
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index 5c8f45d..47ce5ef 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -1,5 +1,5 @@
 /* Get file-specific information about a file.  Linux version.
-   Copyright (C) 2003,2004,2006 2008,2009,2011 Free Software Foundation, Inc.
+   Copyright (C) 2003-2012 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
@@ -88,11 +88,11 @@ __sysconf (int name)
       return HAS_CPUCLOCK (name);
 
     case _SC_ARG_MAX:
-#if __LINUX_KERNEL_VERSION < 0x020617
-      /* Determine whether this is a kernel 2.6.23 or later.  Only
-	 then do we have an argument limit determined by the stack
-	 size.  */
-      if (GLRO(dl_discover_osversion) () >= 0x020617)
+#if !__ASSUME_ARG_MAX_STACK_BASED
+      /* Determine whether this is a kernel with an argument limit
+	 determined by the stack size.  */
+      if (GLRO(dl_discover_osversion) ()
+	  >= __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL)
 #endif
 	/* Use getrlimit to get the stack limit.  */
 	if (__getrlimit (RLIMIT_STACK, &rlimit) == 0)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Move Linux kernel version conditionals to kernel-features.h
  2012-08-03 15:07 Move Linux kernel version conditionals to kernel-features.h Joseph S. Myers
@ 2012-08-03 18:38 ` Roland McGrath
  2012-08-09 23:37 ` Ping ia64 " Joseph S. Myers
  2012-08-10 15:49 ` Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2012-08-03 18:38 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-alpha, libc-ports, Mike Frysinger

Looks fine.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Ping ia64 Re: Move Linux kernel version conditionals to kernel-features.h
  2012-08-03 15:07 Move Linux kernel version conditionals to kernel-features.h Joseph S. Myers
  2012-08-03 18:38 ` Roland McGrath
@ 2012-08-09 23:37 ` Joseph S. Myers
  2012-08-10 15:49 ` Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Joseph S. Myers @ 2012-08-09 23:37 UTC (permalink / raw)
  To: libc-ports; +Cc: Mike Frysinger

On Fri, 3 Aug 2012, Joseph S. Myers wrote:

> Generally conditions on the compile-time minimum Linux kernel version
> go via __ASSUME_* macros defined in kernel-features.h.  However,
> sysdeps/unix/sysv/linux/sysconf.c and
> ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h have such
> conditions directly using __LINUX_KERNEL_VERSION.
> 
> This patch fixes those conditions to follow the kernel-features.h
> convention instead.  For sysconf.c, a new macro
> __ASSUME_ARG_MAX_STACK_BASED is defined and used.  Because the #if
> condition was a condition on an if () condition using the same
> version, the same version number was previously repeated in both
> conditions in close proximity; to avoid those copies (that should be
> in sync) now being widely separated, I defined a macro
> __LINUX_ARG_MAX_STACK_BASED_MIN_KERNEL for the version number in
> question.  For ports/sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h, I
> removed the condition; this is in line with commit
> de7f5ce7c595f4741029f7e63429826f8e82b340 which removed such a
> condition from nptl/sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h a
> few months ago.
> 
> Tested x86_64.  (This should be reviewed for ia64.)

Ping.  This patch 
<http://sourceware.org/ml/libc-ports/2012-08/msg00028.html> is pending 
ia64 review.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Move Linux kernel version conditionals to kernel-features.h
  2012-08-03 15:07 Move Linux kernel version conditionals to kernel-features.h Joseph S. Myers
  2012-08-03 18:38 ` Roland McGrath
  2012-08-09 23:37 ` Ping ia64 " Joseph S. Myers
@ 2012-08-10 15:49 ` Mike Frysinger
  2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2012-08-10 15:49 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-alpha, libc-ports

[-- Attachment #1: Type: Text/Plain, Size: 381 bytes --]

On Friday 03 August 2012 11:06:51 Joseph S. Myers wrote:
> ports/ChangeLog.ia64
> 2012-08-03  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* sysdeps/unix/sysv/linux/ia64/nptl/dl-sysdep.h
> 	(_dl_discover_osversion): Do not condition on
> 	__LINUX_KERNEL_VERSION < 0x020617.
> 	(HAVE_DL_DISCOVER_OSVERSION): Likewise.

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-10 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03 15:07 Move Linux kernel version conditionals to kernel-features.h Joseph S. Myers
2012-08-03 18:38 ` Roland McGrath
2012-08-09 23:37 ` Ping ia64 " Joseph S. Myers
2012-08-10 15:49 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).