ino64_t, off64_t, fpos64_t, stat64, __u64 are not defined on linux-musl.
Fixed by declaring these types for linux-musl.
2023-12-21 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
PR gprofng/30779
PR gprofng/29593
* common/gp-defs.h: Define ino64_t, off64_t, fpos64_t for linux-musl.
* libcollector/unwind.c: Define __u64 for linux-musl.
* src/util.h: Define dbe_stat_t.
* src/ClassFile.cc: Use dbe_stat_t instead of "struct stat64".
* src/Dbe.cc: Likewise.
* src/DbeFile.cc: Likewise.
* src/DbeFile.h: Likewise.
* src/DbeSession.cc: Likewise.
* src/Experiment.cc: Likewise.
* src/checks.cc: Likewise.
* src/util.cc: Likewise.
# endif
#endif
+#if defined(__MUSL_LIBC)
+#define ino64_t ino_t
+#define off64_t off_t
+#define fpos64_t fpos_t
+#endif
+
#endif
}
#elif ARCH(Aarch64)
+#if defined(__MUSL_LIBC)
+typedef uint64_t __u64;
+#endif
+
#define FILL_CONTEXT(context) \
{ CALL_UTIL (getcontext) (context); \
context->uc_mcontext.sp = (__u64) __builtin_frame_address(0); \
append_msg (CMSG_ERROR, GTXT ("Cannot open file %s"), fname);
return;
}
- struct stat64 stat_buf;
+ dbe_stat_t stat_buf;
if ((fstat64 (fd, &stat_buf) == -1) || (stat_buf.st_size == 0))
{
close (fd);
if (!strcmp (format, NTXT ("/bin/ls -dl ")))
{
// A kind of "/bin/ls -dl " simulation
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
sbuf.st_mode = 0;
dbe_stat (filename, &sbuf);
if (S_IREAD & sbuf.st_mode)
}
}
-struct stat64 *
+dbe_stat_t *
DbeFile::get_stat ()
{
if (sbuf.st_atim.tv_sec == 0)
{
if (df == NULL)
return false;
- struct stat64 *st1 = get_stat ();
- struct stat64 *st2 = df->get_stat ();
+ dbe_stat_t *st1 = get_stat ();
+ dbe_stat_t *st2 = df->get_stat ();
if (st1 == NULL || st2 == NULL)
return false;
if (st1->st_size != st2->st_size)
char *get_location (bool find_needed = true);
char *getResolvedPath ();
char *get_location_info ();
- struct stat64 *get_stat ();
+ dbe_stat_t *get_stat ();
bool compare (DbeFile *df);
void set_need_refind (bool val);
void set_location (const char *filename);
bool inArchive;
int filetype;
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
DbeFile *container;
char *orig_location;
Experiment *experiment;
t_exp_list[j] = NULL;
char *lineage_name = exp_names->fetch (j);
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
char *dpath = dbe_sprintf (NTXT ("%s/%s"), path, lineage_name);
// look for experiments with no profile collected
return status;
// Get creation time for experiment
- struct stat64 st;
+ dbe_stat_t st;
if (dbe_stat (path, &st) == 0)
mtime = st.st_mtime;
{
// This function checks that the experiment directory
// is of the proper form, and accessible
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
// Save the name
expt_name = dbe_strdup (path);
if (entry->d_name[0] == '_' || strncmp (entry->d_name, "M_r", 3) == 0)
{
char *dpath = dbe_sprintf (NTXT ("%s/%s"), dir_name, entry->d_name);
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
if (dbe_stat (dpath, &sbuf) == 0 && S_ISDIR (sbuf.st_mode))
exp_names->append (dpath);
else
{
return true;
}
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
if (dbe_stat (dname, &sbuf) != 0 || S_ISDIR (sbuf.st_mode) == 0)
{
char *buf = dbe_sprintf (GTXT ("Unable to create directory `%s'\n"),
}
close (fd_w);
- struct stat64 s_buf;
+ dbe_stat_t s_buf;
if (fstat64 (fd_r, &s_buf) == 0)
{
struct utimbuf u_buf;
return 1;
}
// Set read-only permissions
- struct stat64 statbuf;
+ dbe_stat_t statbuf;
if (0 == dbe_stat_file (name, &statbuf))
{
mode_t mask = S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
collect::check_executable (char *target_name)
{
char target_path[MAXPATHLEN];
- struct stat64 statbuf;
+ dbe_stat_t statbuf;
if (target_name == NULL) // not set, but assume caller knows what it's doing
return EXEC_OK;
if (getenv ("GPROFNG_SKIP_VALIDATION")) // don't check target
int thread_num; /* Application-defined thread # */
volatile int control; /* Thread state */
volatile int result; /* Return status */
- struct stat64 statbuf; /* File info from stat64() */
+ dbe_stat_t statbuf; /* File info from stat64() */
const char *path; /* File */
};
// get status for specified file
static int
-dbe_stat_internal (const char *path, struct stat64 *sbuf, bool file_only)
+dbe_stat_internal (const char *path, dbe_stat_t *sbuf, bool file_only)
{
- struct stat64 statbuf;
+ dbe_stat_t statbuf;
int dir_status = check_dirname (path);
if (dir_status == DIR_STATUS_UNKNOWN)
{
// get status for the regular file
int
-dbe_stat_file (const char *path, struct stat64 *sbuf)
+dbe_stat_file (const char *path, dbe_stat_t *sbuf)
{
int res = dbe_stat_internal (path, sbuf, true);
return res;
// get status for specified file
int
-dbe_stat (const char *path, struct stat64 *sbuf)
+dbe_stat (const char *path, dbe_stat_t *sbuf)
{
int res = dbe_stat_internal (path, sbuf, false);
return res;
if (format_aF)
{
const char *attr = NTXT ("@"); // Link
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
sbuf.st_mode = 0;
char filename[MAXPATHLEN + 1];
snprintf (filename, sizeof (filename), NTXT ("%s/%s"), path, entry->d_name);
{
StringBuilder sb;
char *cmd = NULL;
- struct stat64 sbuf;
+ dbe_stat_t sbuf;
sbuf.st_mode = 0;
int st = dbe_stat (pathname, &sbuf);
if (st == 0)
return (hrtime_t) s->tv_sec * NANOSEC + (hrtime_t) s->tv_nsec;
}
-struct stat64;
+#if defined(__MUSL_LIBC)
+typedef struct stat dbe_stat_t;
+#define fstat64 fstat
+#define open64 open
+#else
+typedef struct stat64 dbe_stat_t;
+#endif
#if defined(__cplusplus)
extern "C"
char *get_relative_link (const char *path_to, const char *path_from);
char *get_prog_name (int basename);
char *dbe_strndup (const char *str, size_t len);
- int dbe_stat (const char *path, struct stat64 *sbuf);
- int dbe_stat_file (const char *path, struct stat64 *sbuf);
+ int dbe_stat (const char *path, dbe_stat_t *sbuf);
+ int dbe_stat_file (const char *path, dbe_stat_t *sbuf);
char *dbe_read_dir (const char *path, const char *format);
char *dbe_get_processes (const char *format);
char *dbe_create_directories (const char *pathname);