From: Dylan Baker Date: Tue, 10 Jul 2018 22:00:13 +0000 (-0700) Subject: util: move process.[ch] to u_process.[ch] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=17f49950da91137366910183f616d15b8bbf580c;p=mesa.git util: move process.[ch] to u_process.[ch] On windows process.h is a system provided header, and it's required in include/c11/threads_win32.h. This header interferes with searching for that header, and results in windows build warnings with scons, but errors in meson which doesn't allow implicit function declarations. Just rename process to u_process, which follows the style of utils anyway. Fixes: 2e1e6511f76370870b5cde10caa9ca3b6d0dc65f ("util: extract get_process_name from xmlconfig.c") Signed-off-by: Dylan Baker Reviewed-by: Marek Olšák --- diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c index 87072f0b046..766cf806153 100644 --- a/src/gallium/auxiliary/os/os_process.c +++ b/src/gallium/auxiliary/os/os_process.c @@ -29,7 +29,7 @@ #include "pipe/p_config.h" #include "os/os_process.h" #include "util/u_memory.h" -#include "util/process.h" +#include "util/u_process.h" #if defined(PIPE_SUBSYSTEM_WINDOWS_USER) # include diff --git a/src/util/Makefile.sources b/src/util/Makefile.sources index fe34fc26690..531fd833c7f 100644 --- a/src/util/Makefile.sources +++ b/src/util/Makefile.sources @@ -24,8 +24,8 @@ MESA_UTIL_FILES := \ mesa-sha1.h \ os_time.c \ os_time.h \ - process.c \ - process.h \ + u_process.c \ + u_process.h \ sha1/sha1.c \ sha1/sha1.h \ ralloc.c \ diff --git a/src/util/meson.build b/src/util/meson.build index 8c91be8539c..6386d945a22 100644 --- a/src/util/meson.build +++ b/src/util/meson.build @@ -48,8 +48,8 @@ files_mesa_util = files( 'mesa-sha1.h', 'os_time.c', 'os_time.h', - 'process.c', - 'process.h', + 'u_process.c', + 'u_process.h', 'sha1/sha1.c', 'sha1/sha1.h', 'ralloc.c', diff --git a/src/util/process.c b/src/util/process.c deleted file mode 100644 index 6e6376986f3..00000000000 --- a/src/util/process.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright © 2003 Felix Kuehling - * Copyright © 2018 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS - * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - */ - -#include "process.h" -#include -#include -#include - -#undef GET_PROGRAM_NAME - -#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__) -# if !defined(__GLIBC__) || (__GLIBC__ < 2) -/* These aren't declared in any libc5 header */ -extern char *program_invocation_name, *program_invocation_short_name; -# endif -static const char * -__getProgramName() -{ - char * arg = strrchr(program_invocation_name, '/'); - if (arg) - return arg+1; - else - return program_invocation_name; -} -# define GET_PROGRAM_NAME() __getProgramName() -#elif defined(__CYGWIN__) -# define GET_PROGRAM_NAME() program_invocation_short_name -#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2) -# include -# if (__FreeBSD_version >= 440000) -# define GET_PROGRAM_NAME() getprogname() -# endif -#elif defined(__NetBSD__) && defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000100) -# define GET_PROGRAM_NAME() getprogname() -#elif defined(__DragonFly__) -# define GET_PROGRAM_NAME() getprogname() -#elif defined(__APPLE__) -# define GET_PROGRAM_NAME() getprogname() -#elif defined(ANDROID) -# define GET_PROGRAM_NAME() getprogname() -#elif defined(__sun) -/* Solaris has getexecname() which returns the full path - return just - the basename to match BSD getprogname() */ -# include - -static const char * -__getProgramName() -{ - static const char *progname; - - if (progname == NULL) { - const char *e = getexecname(); - if (e != NULL) { - /* Have to make a copy since getexecname can return a readonly - string, but basename expects to be able to modify its arg. */ - char *n = strdup(e); - if (n != NULL) { - progname = basename(n); - } - } - } - return progname; -} - -# define GET_PROGRAM_NAME() __getProgramName() -#endif - -#if !defined(GET_PROGRAM_NAME) -# if defined(__OpenBSD__) || defined(NetBSD) || defined(__UCLIBC__) || defined(ANDROID) -/* This is a hack. It's said to work on OpenBSD, NetBSD and GNU. - * Rogelio M.Serrano Jr. reported it's also working with UCLIBC. It's - * used as a last resort, if there is no documented facility available. */ -static const char * -__getProgramName() -{ - extern const char *__progname; - char * arg = strrchr(__progname, '/'); - if (arg) - return arg+1; - else - return __progname; -} -# define GET_PROGRAM_NAME() __getProgramName() -# else -# define GET_PROGRAM_NAME() "" -# pragma message ( "Warning: Per application configuration won't work with your OS version." ) -# endif -#endif - -const char * -util_get_process_name(void) -{ - return GET_PROGRAM_NAME(); -} diff --git a/src/util/process.h b/src/util/process.h deleted file mode 100644 index 77f7cb1cbef..00000000000 --- a/src/util/process.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © 2003 Felix Kuehling - * Copyright © 2018 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS - * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - */ - -#ifndef PROCESS_H -#define PROCESS_H - -const char * -util_get_process_name(void); - -#endif diff --git a/src/util/u_process.c b/src/util/u_process.c new file mode 100644 index 00000000000..5bf3f56db4e --- /dev/null +++ b/src/util/u_process.c @@ -0,0 +1,118 @@ +/* + * Copyright © 2003 Felix Kuehling + * Copyright © 2018 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS + * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + */ + +#include "u_process.h" +#include +#include +#include + +#undef GET_PROGRAM_NAME + +#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__) +# if !defined(__GLIBC__) || (__GLIBC__ < 2) +/* These aren't declared in any libc5 header */ +extern char *program_invocation_name, *program_invocation_short_name; +# endif +static const char * +__getProgramName() +{ + char * arg = strrchr(program_invocation_name, '/'); + if (arg) + return arg+1; + else + return program_invocation_name; +} +# define GET_PROGRAM_NAME() __getProgramName() +#elif defined(__CYGWIN__) +# define GET_PROGRAM_NAME() program_invocation_short_name +#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2) +# include +# if (__FreeBSD_version >= 440000) +# define GET_PROGRAM_NAME() getprogname() +# endif +#elif defined(__NetBSD__) && defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 106000100) +# define GET_PROGRAM_NAME() getprogname() +#elif defined(__DragonFly__) +# define GET_PROGRAM_NAME() getprogname() +#elif defined(__APPLE__) +# define GET_PROGRAM_NAME() getprogname() +#elif defined(ANDROID) +# define GET_PROGRAM_NAME() getprogname() +#elif defined(__sun) +/* Solaris has getexecname() which returns the full path - return just + the basename to match BSD getprogname() */ +# include + +static const char * +__getProgramName() +{ + static const char *progname; + + if (progname == NULL) { + const char *e = getexecname(); + if (e != NULL) { + /* Have to make a copy since getexecname can return a readonly + string, but basename expects to be able to modify its arg. */ + char *n = strdup(e); + if (n != NULL) { + progname = basename(n); + } + } + } + return progname; +} + +# define GET_PROGRAM_NAME() __getProgramName() +#endif + +#if !defined(GET_PROGRAM_NAME) +# if defined(__OpenBSD__) || defined(NetBSD) || defined(__UCLIBC__) || defined(ANDROID) +/* This is a hack. It's said to work on OpenBSD, NetBSD and GNU. + * Rogelio M.Serrano Jr. reported it's also working with UCLIBC. It's + * used as a last resort, if there is no documented facility available. */ +static const char * +__getProgramName() +{ + extern const char *__progname; + char * arg = strrchr(__progname, '/'); + if (arg) + return arg+1; + else + return __progname; +} +# define GET_PROGRAM_NAME() __getProgramName() +# else +# define GET_PROGRAM_NAME() "" +# pragma message ( "Warning: Per application configuration won't work with your OS version." ) +# endif +#endif + +const char * +util_get_process_name(void) +{ + return GET_PROGRAM_NAME(); +} diff --git a/src/util/u_process.h b/src/util/u_process.h new file mode 100644 index 00000000000..77f7cb1cbef --- /dev/null +++ b/src/util/u_process.h @@ -0,0 +1,34 @@ +/* + * Copyright © 2003 Felix Kuehling + * Copyright © 2018 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS + * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + */ + +#ifndef PROCESS_H +#define PROCESS_H + +const char * +util_get_process_name(void); + +#endif diff --git a/src/util/u_queue.c b/src/util/u_queue.c index be95d9eec3f..4ce1af518b3 100644 --- a/src/util/u_queue.c +++ b/src/util/u_queue.c @@ -31,7 +31,7 @@ #include "util/os_time.h" #include "util/u_string.h" #include "util/u_thread.h" -#include "process.h" +#include "u_process.h" static void util_queue_killall_and_wait(struct util_queue *queue); diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index d3847911baa..ba657294c1c 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -37,7 +37,7 @@ #include #include #include "xmlconfig.h" -#include "process.h" +#include "u_process.h" /** \brief Find an option in an option cache with the name as key */