Merge tag 'perf-tools-for-v5.15-2021-09-04' of git://git.kernel.org/pub/scm/linux...
[linux-2.6-microblaze.git] / tools / perf / util / get_current_dir_name.c
1 // SPDX-License-Identifier: LGPL-2.1
2 // Copyright (C) 2018, 2019 Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 //
4 #ifndef HAVE_GET_CURRENT_DIR_NAME
5 #include "get_current_dir_name.h"
6 #include <limits.h>
7 #include <string.h>
8 #include <unistd.h>
9
10 /* Android's 'bionic' library, for one, doesn't have this */
11
12 char *get_current_dir_name(void)
13 {
14         char pwd[PATH_MAX];
15
16         return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
17 }
18 #endif // HAVE_GET_CURRENT_DIR_NAME