Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / perf / util / get_current_dir_name.c
blobe68935e9ac8ceeb37151e558d2bc546f84473006
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>
10 /* Android's 'bionic' library, for one, doesn't have this */
12 char *get_current_dir_name(void)
14 char pwd[PATH_MAX];
16 return getcwd(pwd, sizeof(pwd)) == NULL ? NULL : strdup(pwd);
18 #endif // HAVE_GET_CURRENT_DIR_NAME