r1980 - trunk/coreutils

randy at linuxfromscratch.org randy at linuxfromscratch.org
Sun Oct 5 14:29:45 PDT 2008


Author: randy
Date: 2008-10-05 15:29:45 -0600 (Sun, 05 Oct 2008)
New Revision: 1980

Added:
   trunk/coreutils/coreutils-6.12-old_build_kernel-1.patch
   trunk/coreutils/coreutils-6.12-uname-1.patch
Log:
Added two patches for Coreutils-6.12

Added: trunk/coreutils/coreutils-6.12-old_build_kernel-1.patch
===================================================================
--- trunk/coreutils/coreutils-6.12-old_build_kernel-1.patch	                        (rev 0)
+++ trunk/coreutils/coreutils-6.12-old_build_kernel-1.patch	2008-10-05 21:29:45 UTC (rev 1980)
@@ -0,0 +1,122 @@
+Submitted By:            Randy McMurchy <randy_at_linuxfromscratch_dot_org>
+Date:                    2008-10-05
+Initial Package Version: 6.12
+Upstream Status:         Unknown
+Origin:                  http://bugs.gentoo.org/attachment.cgi?id=155835
+Description:             Fixes an issue if using a host with an older kernel
+
+
+--- coreutils-6.12-orig/lib/utimens.c	2008-05-29 09:21:57.000000000 -0400
++++ coreutils-6.12/lib/utimens.c	2008-06-07 11:36:50.000000000 -0400
+@@ -96,20 +96,42 @@
+ #endif
+ 
+   /* POSIX 200x added two interfaces to set file timestamps with
+-     nanosecond resolution.  */
++     nanosecond resolution.  We provide a fallback for ENOSYS (for
++     example, compiling against Linux 2.6.25 kernel headers and glibc
++     2.7, but running on Linux 2.6.18 kernel).  */
+ #if HAVE_UTIMENSAT
+   if (fd < 0)
+-    return utimensat (AT_FDCWD, file, timespec, 0);
++    {
++      int result = utimensat (AT_FDCWD, file, timespec, 0);
++#ifdef __linux__
++      /* Work around what might be a kernel bug:
++         http://bugzilla.redhat.com/442352
++         http://bugzilla.redhat.com/449910
++         It appears that utimensat can mistakenly return 280 rather
++         than 0 to indicate success.
++         FIXME: remove in 2010 or whenever the offending kernels
++         are no longer in common use.  */
++      if (0 < result)
++        result = 0;
++#endif
++
++      if (result == 0 || errno != ENOSYS)
++        return result;
++    }
+ #endif
+ #if HAVE_FUTIMENS
+-  return futimens (fd, timespec);
+-#else
++  {
++    int result = futimens (fd, timespec);
++    if (result == 0 || errno != ENOSYS)
++      return result;
++  }
++#endif
+ 
+   /* The platform lacks an interface to set file timestamps with
+      nanosecond resolution, so do the best we can, discarding any
+      fractional part of the timestamp.  */
+   {
+-# if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
++#if HAVE_FUTIMESAT || HAVE_WORKING_UTIMES
+     struct timeval timeval[2];
+     struct timeval const *t;
+     if (timespec)
+@@ -125,9 +147,9 @@
+ 
+     if (fd < 0)
+       {
+-#  if HAVE_FUTIMESAT
++# if HAVE_FUTIMESAT
+ 	return futimesat (AT_FDCWD, file, t);
+-#  endif
++# endif
+       }
+     else
+       {
+@@ -141,21 +163,21 @@
+ 	   worth optimizing, and who knows what other messed-up systems
+ 	   are out there?  So play it safe and fall back on the code
+ 	   below.  */
+-#  if HAVE_FUTIMESAT
++# if HAVE_FUTIMESAT
+ 	if (futimesat (fd, NULL, t) == 0)
+ 	  return 0;
+-#  elif HAVE_FUTIMES
++# elif HAVE_FUTIMES
+ 	if (futimes (fd, t) == 0)
+ 	  return 0;
+-#  endif
++# endif
+       }
+-# endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */
++#endif /* HAVE_FUTIMESAT || HAVE_WORKING_UTIMES */
+ 
+     if (!file)
+       {
+-# if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
++#if ! (HAVE_FUTIMESAT || (HAVE_WORKING_UTIMES && HAVE_FUTIMES))
+ 	errno = ENOSYS;
+-# endif
++#endif
+ 
+ 	/* Prefer EBADF to ENOSYS if both error numbers apply.  */
+ 	if (errno == ENOSYS)
+@@ -170,9 +192,9 @@
+ 	return -1;
+       }
+ 
+-# if HAVE_WORKING_UTIMES
++#if HAVE_WORKING_UTIMES
+     return utimes (file, t);
+-# else
++#else
+     {
+       struct utimbuf utimbuf;
+       struct utimbuf const *ut;
+@@ -187,9 +209,8 @@
+ 
+       return utime (file, ut);
+     }
+-# endif /* !HAVE_WORKING_UTIMES */
++#endif /* !HAVE_WORKING_UTIMES */
+   }
+-#endif /* !HAVE_FUTIMENS */
+ }
+ 
+ /* Set the access and modification time stamps of FILE to be
+

Added: trunk/coreutils/coreutils-6.12-uname-1.patch
===================================================================
--- trunk/coreutils/coreutils-6.12-uname-1.patch	                        (rev 0)
+++ trunk/coreutils/coreutils-6.12-uname-1.patch	2008-10-05 21:29:45 UTC (rev 1980)
@@ -0,0 +1,182 @@
+Submitted By: Matthew Burgess <matthew at linuxfromscratch dot org>
+Date: 2005-10-23
+Initial Package Version: 5.92
+Upstream Status: pending
+Origin: Scot McPherson
+Description: Fix the output of uname once and for all.
+
+	$ uname -m	# This always worked.
+	i686
+	$ uname -i	# Used to report 'unknown'.
+	i386
+	$ uname -p	# Likewise.
+	athlon-4
+
+diff -Naur coreutils-5.92.orig/src/uname.c coreutils-5.92/src/uname.c
+--- coreutils-5.92.orig/src/uname.c	2005-09-15 20:34:42.000000000 +0000
++++ coreutils-5.92/src/uname.c	2005-10-23 10:14:06.000000000 +0000
+@@ -29,6 +29,12 @@
+ # include <sys/systeminfo.h>
+ #endif
+ 
++#ifdef linux
++#define cpuid(in,a,b,c,d)\
++  asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in));
++int has_sse( void );
++#endif
++
+ #if HAVE_SYS_SYSCTL_H
+ # if HAVE_SYS_PARAM_H
+ #  include <sys/param.h> /* needed for OpenBSD 3.0 */
+@@ -256,6 +262,96 @@
+ 	if (0 <= sysinfo (SI_ARCHITECTURE, processor, sizeof processor))
+ 	  element = processor;
+       }
++#else
++      {
++	struct utsname u;
++	uname (&u);
++	element = u.machine;
++#ifdef linux
++/******************************************************************************
++ *
++ * Hello, major hack.  I shouldn't have to do this.  struct utsname should
++ * have another element with this info in it.  There's probably a struct
++ * somewhere that has this info, I just don't know where it is.
++ *
++ *****************************************************************************/
++
++	if( !strcmp( element, "i586" ) || !strcmp( element, "i686" ) ) {
++	  int eax, ebx, ecx, edx, unused;
++	  int model, family, sse;
++     
++	  cpuid(0,unused,ebx,ecx,edx);
++	  cpuid(1,eax,unused,unused,unused);
++	  model = (eax >> 4) & 0xf;
++	  family = (eax >> 8) & 0xf;
++
++	  switch(ebx) {
++	  case 0x756e6547: // Intel
++	    switch( family ) {
++	    case 5: // Pentium
++	      if( model <= 3 )
++		element="pentium";
++	      if( model > 3 )
++		element="pentium-mmx";
++	      break;
++	    case 6: // PentiumPro - Pentium III
++	      if( model == 1 ) // Pentium Pro
++		element="pentiumpro";
++	      if( ( model == 3 ) || ( model == 5 ) ||
++		  ( model == 6 ) ) // Pentium II
++		element="pentium2";
++	      if( ( model == 7 ) || ( model == 8 ) ||
++		  ( model == 10 ) || ( model == 11 ) ) // These are all Pentium III
++		element="pentium3";
++	      break;
++	    case 15: // Pentium4
++	      element="pentium4";
++	      break;
++	    default:
++	      break;
++	    } // end switch( family )
++	    break;
++	  case 0x68747541: // AMD
++	    switch(family) {
++	    case 5:
++	      if( ( model == 0 ) || ( model == 1 ) || 
++		  ( model == 2 ) || ( model == 3 ) ) // K5
++		element="i586";
++	      if( ( model == 6 ) || ( model == 7 ) ) // K6
++		element="k6";
++	      if( model == 8 ) // K6-2
++		element="k6-2";
++	      if( model == 9 ) // K6-3
++		element="k6-3";
++	      break;
++	    case 6:
++	      if( model <= 4 )
++		element="athlon";
++	      if( model > 4 ) {
++		sse = has_sse();
++		if( sse == 0 )
++		  element="athlon";
++		if( sse == 1 )
++		  element="athlon-4";
++	      }
++	      break;
++	    case 15:
++	      element="athlon-4";
++	      break;
++	    default:
++	      break;
++	    } // end switch( family )
++	    break;
++	  case 0x69727943: // Cyrix
++	    element="i386"; // who knows what cyrix supports, lets be safe
++	    break;
++	  default:
++	    break;
++	  } // end switch(ebx)
++	}
++
++#endif
++      }
+ #endif
+ #ifdef UNAME_PROCESSOR
+       if (element == unknown)
+@@ -293,7 +389,7 @@
+ 
+   if (toprint & PRINT_HARDWARE_PLATFORM)
+     {
+-      char const *element = unknown;
++      char *element = unknown;
+ #if HAVE_SYSINFO && defined SI_PLATFORM
+       {
+ 	static char hardware_platform[257];
+@@ -301,6 +397,15 @@
+ 			  hardware_platform, sizeof hardware_platform))
+ 	  element = hardware_platform;
+       }
++#else
++      {
++	struct utsname u;
++	uname (&u);
++	element = u.machine;
++	if (strlen (element) == 4 && element[0] == 'i' && element[2] == '8'
++	    && element[3] == '6')
++	  element[1] = '3';
++      }
+ #endif
+ #ifdef UNAME_HARDWARE_PLATFORM
+       if (element == unknown)
+@@ -323,3 +428,29 @@
+ 
+   exit (EXIT_SUCCESS);
+ }
++
++#ifdef linux
++
++/******************************************************************************
++ *
++ * int has_sse( void )
++ * Checks Athlon CPU's to see if they support SSE.
++ *
++ *****************************************************************************/
++
++int has_sse( void )
++{
++  unsigned long edx, unused;
++  int sse;
++  cpuid(1,unused,unused,unused,edx);
++  // I think, I need this tested on a Duron with SSE
++  // and one without it.
++  sse = edx & 0x2000000;
++  if( sse == 0 ) {
++    return 0;
++  } else {
++    return 1;
++  }
++
++}
++#endif




More information about the patches mailing list