[Mesa-dev] [PATCH 2/4] gallium/os: use util_get_process_name when possible
Marek Olšák
maraeo at gmail.com
Tue Jul 3 23:16:10 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/auxiliary/os/os_process.c | 16 ++--------------
src/util/process.c | 2 ++
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_process.c b/src/gallium/auxiliary/os/os_process.c
index 035bd228e76..87072f0b046 100644
--- a/src/gallium/auxiliary/os/os_process.c
+++ b/src/gallium/auxiliary/os/os_process.c
@@ -22,32 +22,27 @@
* 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.
*
**************************************************************************/
#include "pipe/p_config.h"
#include "os/os_process.h"
#include "util/u_memory.h"
+#include "util/process.h"
#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
# include <windows.h>
-#elif defined(__GLIBC__) || defined(__CYGWIN__)
-# include <errno.h>
-#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID)
-# include <stdlib.h>
#elif defined(PIPE_OS_HAIKU)
# include <kernel/OS.h>
# include <kernel/image.h>
-#else
-#warning unexpected platform in os_process.c
#endif
#if defined(PIPE_OS_LINUX)
# include <fcntl.h>
#endif
/**
* Return the name of the current process.
* \param procname returns the process name
@@ -77,34 +72,27 @@ os_get_process_name(char *procname, size_t size)
lpProcessName = strrchr(szProcessPath, '\\');
lpProcessName = lpProcessName ? lpProcessName + 1 : szProcessPath;
lpProcessExt = strrchr(lpProcessName, '.');
if (lpProcessExt) {
*lpProcessExt = '\0';
}
name = lpProcessName;
-#elif defined(__GLIBC__) || defined(__CYGWIN__)
- name = program_invocation_short_name;
-#elif defined(PIPE_OS_BSD) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_ANDROID)
- /* *BSD and OS X */
- name = getprogname();
#elif defined(PIPE_OS_HAIKU)
image_info info;
get_image_info(B_CURRENT_TEAM, &info);
name = info.name;
#else
-#warning unexpected platform in os_process.c
- return FALSE;
+ name = util_get_process_name();
#endif
-
}
assert(size > 0);
assert(procname);
if (name && procname && size > 0) {
strncpy(procname, name, size);
procname[size - 1] = '\0';
return TRUE;
}
diff --git a/src/util/process.c b/src/util/process.c
index 992ba7f734a..449c7fa77c2 100644
--- a/src/util/process.c
+++ b/src/util/process.c
@@ -53,20 +53,22 @@ __getProgramName()
# include <osreldate.h>
# 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 <libgen.h>
static const char *
__getProgramName()
{
static const char *progname;
--
2.17.1
More information about the mesa-dev
mailing list