mono-hwcap.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * \file
  3. * Hardware feature detection
  4. *
  5. * Authors:
  6. * Alex Rønne Petersen (alexrp@xamarin.com)
  7. * Elijah Taylor (elijahtaylor@google.com)
  8. * Miguel de Icaza (miguel@xamarin.com)
  9. * Neale Ferguson (Neale.Ferguson@SoftwareAG-usa.com)
  10. * Paolo Molaro (lupus@xamarin.com)
  11. * Rodrigo Kumpera (kumpera@gmail.com)
  12. * Sebastien Pouliot (sebastien@xamarin.com)
  13. * Zoltan Varga (vargaz@xamarin.com)
  14. *
  15. * Copyright 2003 Ximian, Inc.
  16. * Copyright 2003-2011 Novell, Inc
  17. * Copyright 2006 Broadcom
  18. * Copyright 2007-2008 Andreas Faerber
  19. * Copyright 2011-2013 Xamarin Inc
  20. * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  21. */
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include "mono/utils/mono-hwcap.h"
  25. #define MONO_HWCAP_VAR(NAME) gboolean mono_hwcap_ ## NAME = FALSE;
  26. #include "mono/utils/mono-hwcap-vars.h"
  27. #undef MONO_HWCAP_VAR
  28. static gboolean hwcap_inited = FALSE;
  29. void
  30. mono_hwcap_init (void)
  31. {
  32. char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
  33. char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
  34. if (hwcap_inited)
  35. return;
  36. if (!conservative || strncmp (conservative, "1", 1))
  37. mono_hwcap_arch_init ();
  38. if (verbose && !strncmp (verbose, "1", 1))
  39. mono_hwcap_print ();
  40. g_free (verbose);
  41. g_free (conservative);
  42. }
  43. void
  44. mono_hwcap_print (void)
  45. {
  46. g_print ("[mono-hwcap] Detected following hardware capabilities:\n\n");
  47. #define MONO_HWCAP_VAR(NAME) g_print ("\t" #NAME " = %s\n", mono_hwcap_ ## NAME ? "yes" : "no");
  48. #include "mono/utils/mono-hwcap-vars.h"
  49. #undef MONO_HWCAP_VAR
  50. g_print ("\n");
  51. }