tools build feature: Check if get_current_dir_name() is available
As the namespace support code will use this, which is not available in some non _GNU_SOURCE libraries such as Android's bionic used in my container build tests (r12b and r15c at the moment). Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-x56ypm940pwclwu45d7jfj47@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
18
tools/perf/util/get_current_dir_name.c
Normal file
18
tools/perf/util/get_current_dir_name.c
Normal file
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Copyright (C) 2018, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
//
|
||||
#ifndef HAVE_GET_CURRENT_DIR_NAME
|
||||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Android's 'bionic' library, for one, doesn't have this */
|
||||
|
||||
char *get_current_dir_name(void)
|
||||
{
|
||||
char pwd[PATH_MAX];
|
||||
|
||||
return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
|
||||
}
|
||||
#endif // HAVE_GET_CURRENT_DIR_NAME
|
||||
Reference in New Issue
Block a user