From 84d340f958ff320d2355f693701455d08a1818cd Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Thu, 23 Feb 2023 15:43:48 -0800 Subject: gcc: xtensa: rename xtensa-dynconfig.c and update its build rule gcc/ * config/xtensa/t-xtensa (xtensa-dynconfig.o): Use $(COMPILE) and $(POSTCOMPILE) instead of manual dependency listing. * config/xtensa/xtensa-dynconfig.c: Rename to ... * config/xtensa/xtensa-dynconfig.cc: ... this. --- gcc/config/xtensa/t-xtensa | 7 +- gcc/config/xtensa/xtensa-dynconfig.c | 171 ---------------------------------- gcc/config/xtensa/xtensa-dynconfig.cc | 171 ++++++++++++++++++++++++++++++++++ 3 files changed, 174 insertions(+), 175 deletions(-) delete mode 100644 gcc/config/xtensa/xtensa-dynconfig.c create mode 100644 gcc/config/xtensa/xtensa-dynconfig.cc (limited to 'gcc') diff --git a/gcc/config/xtensa/t-xtensa b/gcc/config/xtensa/t-xtensa index d95bd6f..cf6574b 100644 --- a/gcc/config/xtensa/t-xtensa +++ b/gcc/config/xtensa/t-xtensa @@ -20,7 +20,6 @@ TM_H += $(srcdir)/../include/xtensa-config.h \ $(srcdir)/../include/xtensa-dynconfig.h $(out_object_file): gt-xtensa.h -xtensa-dynconfig.o: $(srcdir)/config/xtensa/xtensa-dynconfig.c \ - $(CONFIG_H) $(SYSTEM_H) $(srcdir)/../include/xtensa-dynconfig.h \ - $(srcdir)/../include/xtensa-config.h - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< +xtensa-dynconfig.o: $(srcdir)/config/xtensa/xtensa-dynconfig.cc + $(COMPILE) $< + $(POSTCOMPILE) diff --git a/gcc/config/xtensa/xtensa-dynconfig.c b/gcc/config/xtensa/xtensa-dynconfig.c deleted file mode 100644 index e0091f3..0000000 --- a/gcc/config/xtensa/xtensa-dynconfig.c +++ /dev/null @@ -1,171 +0,0 @@ -/* Xtensa configuration settings loader. - Copyright (C) 2022-2023 Free Software Foundation, Inc. - - This file is part of GCC. - - GCC is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License as published by the Free - Software Foundation; either version 3, or (at your option) any later - version. - - GCC 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 General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with GCC; see the file COPYING3. If not see - . */ - -#include -#include -#include -#include -#include -#define XTENSA_CONFIG_DEFINITION -#include "xtensa-config.h" -#include "xtensa-dynconfig.h" - -#if defined (HAVE_DLFCN_H) -#include -#elif defined (_WIN32) -#define WIN32_LEAN_AND_MEAN -#include -#define ENABLE_PLUGIN -#endif - -#if !defined (HAVE_DLFCN_H) && defined (_WIN32) - -#define RTLD_LAZY 0 /* Dummy value. */ - -static void * -dlopen (const char *file, int mode ATTRIBUTE_UNUSED) -{ - return LoadLibrary (file); -} - -static void * -dlsym (void *handle, const char *name) -{ - return (void *) GetProcAddress ((HMODULE) handle, name); -} - -static int ATTRIBUTE_UNUSED -dlclose (void *handle) -{ - FreeLibrary ((HMODULE) handle); - return 0; -} - -static const char * -dlerror (void) -{ - return _("Unable to load DLL."); -} - -#endif /* !defined (HAVE_DLFCN_H) && defined (_WIN32) */ - -#define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG" - -const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, - const void *no_plugin_def, - const void *no_name_def ATTRIBUTE_UNUSED) -{ - static int init; -#ifdef ENABLE_PLUGIN - static void *handle; - void *p; - - if (!init) - { - const char *path = getenv (CONFIG_ENV_NAME); - - init = 1; - if (!path) - return no_plugin_def; - handle = dlopen (path, RTLD_LAZY); - if (!handle) - { - fatal_error (input_location, - "%qs is defined but could not be loaded: %s", - CONFIG_ENV_NAME, dlerror ()); - exit (FATAL_EXIT_CODE); - } - if (dlsym (handle, "plugin_is_GPL_compatible") == NULL) - { - fatal_error (input_location, - "%qs plugin is not licensed under a GPL-compatible license", - CONFIG_ENV_NAME); - exit (FATAL_EXIT_CODE); - } - } - else if (!handle) - { - return no_plugin_def; - } - - p = dlsym (handle, name); - if (!p) - { - if (no_name_def) - return no_name_def; - - fatal_error (input_location, - "%qs is loaded but symbol %qs is not found: %s", - CONFIG_ENV_NAME, name, dlerror ()); - exit (FATAL_EXIT_CODE); - } - return p; -#else - if (!init) - { - const char *path = getenv (CONFIG_ENV_NAME); - - init = 1; - if (path) - { - fatal_error (input_location, - "%qs is defined but plugin support is disabled", - CONFIG_ENV_NAME); - exit (FATAL_EXIT_CODE); - } - } - return no_plugin_def; -#endif -} - -XTENSA_CONFIG_INSTANCE_LIST; - -#define _STRINGIFY(a) #a -#define STRINGIFY(a) _STRINGIFY(a) - -#undef XTENSA_CONFIG_ENTRY -#define XTENSA_CONFIG_ENTRY(a) "__" #a "=" STRINGIFY(a) - -static const char * const xtensa_config_strings[] = { - XTENSA_CONFIG_ENTRY_LIST, - NULL, -}; - -const struct xtensa_config_v1 *xtensa_get_config_v1 (void) -{ - static const struct xtensa_config_v1 *config; - - if (!config) - config = (const struct xtensa_config_v1 *) xtensa_load_config ("xtensa_config_v1", - &xtensa_config_v1, - NULL); - return config; -} - -const char * const *xtensa_get_config_strings (void) -{ - static const char * const *config_strings; - - if (!config_strings) - config_strings = (const char * const *) xtensa_load_config ("xtensa_config_strings", - &xtensa_config_strings, - NULL); - - return config_strings; -} diff --git a/gcc/config/xtensa/xtensa-dynconfig.cc b/gcc/config/xtensa/xtensa-dynconfig.cc new file mode 100644 index 0000000..e0091f3 --- /dev/null +++ b/gcc/config/xtensa/xtensa-dynconfig.cc @@ -0,0 +1,171 @@ +/* Xtensa configuration settings loader. + Copyright (C) 2022-2023 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License as published by the Free + Software Foundation; either version 3, or (at your option) any later + version. + + GCC 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 General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#include +#include +#include +#include +#include +#define XTENSA_CONFIG_DEFINITION +#include "xtensa-config.h" +#include "xtensa-dynconfig.h" + +#if defined (HAVE_DLFCN_H) +#include +#elif defined (_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#define ENABLE_PLUGIN +#endif + +#if !defined (HAVE_DLFCN_H) && defined (_WIN32) + +#define RTLD_LAZY 0 /* Dummy value. */ + +static void * +dlopen (const char *file, int mode ATTRIBUTE_UNUSED) +{ + return LoadLibrary (file); +} + +static void * +dlsym (void *handle, const char *name) +{ + return (void *) GetProcAddress ((HMODULE) handle, name); +} + +static int ATTRIBUTE_UNUSED +dlclose (void *handle) +{ + FreeLibrary ((HMODULE) handle); + return 0; +} + +static const char * +dlerror (void) +{ + return _("Unable to load DLL."); +} + +#endif /* !defined (HAVE_DLFCN_H) && defined (_WIN32) */ + +#define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG" + +const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, + const void *no_plugin_def, + const void *no_name_def ATTRIBUTE_UNUSED) +{ + static int init; +#ifdef ENABLE_PLUGIN + static void *handle; + void *p; + + if (!init) + { + const char *path = getenv (CONFIG_ENV_NAME); + + init = 1; + if (!path) + return no_plugin_def; + handle = dlopen (path, RTLD_LAZY); + if (!handle) + { + fatal_error (input_location, + "%qs is defined but could not be loaded: %s", + CONFIG_ENV_NAME, dlerror ()); + exit (FATAL_EXIT_CODE); + } + if (dlsym (handle, "plugin_is_GPL_compatible") == NULL) + { + fatal_error (input_location, + "%qs plugin is not licensed under a GPL-compatible license", + CONFIG_ENV_NAME); + exit (FATAL_EXIT_CODE); + } + } + else if (!handle) + { + return no_plugin_def; + } + + p = dlsym (handle, name); + if (!p) + { + if (no_name_def) + return no_name_def; + + fatal_error (input_location, + "%qs is loaded but symbol %qs is not found: %s", + CONFIG_ENV_NAME, name, dlerror ()); + exit (FATAL_EXIT_CODE); + } + return p; +#else + if (!init) + { + const char *path = getenv (CONFIG_ENV_NAME); + + init = 1; + if (path) + { + fatal_error (input_location, + "%qs is defined but plugin support is disabled", + CONFIG_ENV_NAME); + exit (FATAL_EXIT_CODE); + } + } + return no_plugin_def; +#endif +} + +XTENSA_CONFIG_INSTANCE_LIST; + +#define _STRINGIFY(a) #a +#define STRINGIFY(a) _STRINGIFY(a) + +#undef XTENSA_CONFIG_ENTRY +#define XTENSA_CONFIG_ENTRY(a) "__" #a "=" STRINGIFY(a) + +static const char * const xtensa_config_strings[] = { + XTENSA_CONFIG_ENTRY_LIST, + NULL, +}; + +const struct xtensa_config_v1 *xtensa_get_config_v1 (void) +{ + static const struct xtensa_config_v1 *config; + + if (!config) + config = (const struct xtensa_config_v1 *) xtensa_load_config ("xtensa_config_v1", + &xtensa_config_v1, + NULL); + return config; +} + +const char * const *xtensa_get_config_strings (void) +{ + static const char * const *config_strings; + + if (!config_strings) + config_strings = (const char * const *) xtensa_load_config ("xtensa_config_strings", + &xtensa_config_strings, + NULL); + + return config_strings; +} -- cgit v1.1