This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Alpha hwcaps


Andreas Schwab <schwab@suse.de> writes:

> Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> writes:
> 
> > Andreas Schwab <schwab@suse.de> writes:
> >
> >> Falk Hueffner <falk.hueffner@student.uni-tuebingen.de> writes:
> >> 
> >> > The problem is that I don't want to replace everything in dl-sysdep.c,
> >> > but just _dl_important_hwcaps. How can I do that?
> >> 
> >> Create a macro that overrides the default action.
> >
> > Can you please give a few more details? Where to put this macro?
> > Sorry, I'm not familiar with the build infrastructure...
> 
> The macro will be used in sysdeps/generic/dl-sysdep.c, and you define it
> in sysdeps/alpha/dl-sysdep.c and include the generic file.

You mean like this?

Index: sysdeps/alpha/dl-sysdep.c
===================================================================
RCS file: sysdeps/alpha/dl-sysdep.c
diff -N sysdeps/alpha/dl-sysdep.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sysdeps/alpha/dl-sysdep.c	29 Feb 2004 19:40:37 -0000
@@ -0,0 +1,100 @@
+/* Operating system support for run-time dynamic linker.  Alpha version.
+   Contributed by Falk Hueffner <falk@debian.org>, 2004.
+   Copyright (C) 2004 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; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <stddef.h>
+
+#include <ldsodefs.h>
+
+/* The model of orthogonal feature bits doesn't really fit Alpha; all
+   we want is to have the list of architectures scanned linearly.
+   Therefore, we override the default _dl_important_hwcaps
+   implementation.  */
+const struct r_strlenpair *
+internal_function
+_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
+		      size_t *max_capstrlen)
+{
+  enum {
+    ARCH_EV7,
+    ARCH_EV68,
+    ARCH_EV67,
+    ARCH_EV6,
+    ARCH_PCA56,
+    ARCH_EV56,
+    ARCH_EV5,
+    ARCH_EV4,
+    ARCH_END = ARCH_EV4
+  };
+#define STRLENPAIR(S) { S, sizeof S - 1 }
+  static const struct r_strlenpair archs[] = {
+    STRLENPAIR("ev7/"),
+    STRLENPAIR("ev68/"),
+    STRLENPAIR("ev67/"),
+    STRLENPAIR("ev6/"),
+    STRLENPAIR("pca56/"),
+    STRLENPAIR("ev56/"),
+    STRLENPAIR("ev5/"),
+  };
+  enum {
+    AMASK_BWX	      = 1 <<  0,
+    AMASK_FIX	      = 1 <<  1,
+    AMASK_CIX	      = 1 <<  2,
+    AMASK_MVI	      = 1 <<  8,
+    AMASK_PREC_TRAPS  = 1 <<  9,
+    AMASK_PREFETCH_WH = 1 << 12,
+  };
+  enum { IMPLVER_EV4, IMPLVER_EV5, IMPLVER_EV6, IMPLVER_EV7 };
+  unsigned long implver, amask;
+  int arch, i;
+
+  asm ("implver %0" : "=r" (implver));
+  asm ("amask %1,%0" : "=r" (amask) : "r" (-1));
+  amask = ~amask;
+
+  if (implver == IMPLVER_EV4)
+    arch = ARCH_EV4;
+  else if (implver == IMPLVER_EV5)
+    {
+      if (amask & AMASK_MVI)
+	arch = ARCH_PCA56;
+      else if (amask & AMASK_BWX)
+	arch = ARCH_EV56;
+      else
+	arch = ARCH_EV5;
+    }
+  else if (implver == IMPLVER_EV6)
+    {
+      if (amask & AMASK_PREFETCH_WH)
+	arch = ARCH_EV68;
+      else if (amask & AMASK_CIX)
+	arch = ARCH_EV67;
+      else
+	arch = ARCH_EV6;
+    }
+  else
+    arch = ARCH_EV7;
+
+  *sz = ARCH_END - arch;
+  *max_capstrlen = strlen("pca56/");
+  return archs + arch;
+}
+
+#define _DL_IMPORTANT_HWCAPS_DEFINED 1
+#include <sysdeps/generic/dl-sysdep.c>
Index: sysdeps/generic/dl-sysdep.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/dl-sysdep.c,v
retrieving revision 1.108
diff -u -p -r1.108 dl-sysdep.c
--- sysdeps/generic/dl-sysdep.c	28 Feb 2004 17:55:37 -0000	1.108
+++ sysdeps/generic/dl-sysdep.c	29 Feb 2004 19:40:38 -0000
@@ -332,6 +332,7 @@ _dl_show_auxv (void)
 
 
 /* Return an array of useful/necessary hardware capability names.  */
+#ifndef _DL_IMPORTANT_HWCAPS_DEFINED
 const struct r_strlenpair *
 internal_function
 _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
@@ -512,3 +513,4 @@ _dl_important_hwcaps (const char *platfo
 
   return result;
 }
+#endif /* _DL_IMPORTANT_HWCAPS_DEFINED */


-- 
	Falk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]