diff --git a/meson.build b/meson.build index 6bf147b3..3b3b39c9 100644 --- a/meson.build +++ b/meson.build @@ -18,6 +18,11 @@ conf.set_quoted('PROJECT', meson.project_name()) conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxcfs/introduction/') conf.set_quoted('PROJECT_VERSION', meson.project_version(), description : 'Numerical project version (used where a simple number is expected)') +conf.set_quoted('PACKAGE_VERSION', meson.project_version()) +conf.set('_GNU_SOURCE', true) +conf.set('_FILE_OFFSET_BITS', 64) +conf.set('__STDC_FORMAT_MACROS', true) + project_source_root = meson.current_source_dir() project_build_root = meson.current_build_dir() @@ -133,10 +138,6 @@ foreach ident : [ conf.set10('HAVE_' + ident[0].to_upper(), have) endforeach -conf.set('_GNU_SOURCE', true) -conf.set('_FILE_OFFSET_BITS', 64) -conf.set('__STDC_FORMAT_MACROS', true) - libfuse = dependency('fuse3', required : false) if libfuse.found() conf.set10('HAVE_FUSE3', true) diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c index b6ffd29a..37e9a208 100644 --- a/src/proc_cpuview.c +++ b/src/proc_cpuview.c @@ -683,9 +683,9 @@ int cpuview_proc_stat(const char *cg, const char *cpuset, } if (user_surplus > 0) - lxcfs_debug("leftover user: %lu for %s\n", user_surplus, cg); + lxcfs_debug("leftover user: %" PRIu64 "for %s\n", user_surplus, cg); if (system_surplus > 0) - lxcfs_debug("leftover system: %lu for %s\n", system_surplus, cg); + lxcfs_debug("leftover system: %" PRIu64 "for %s\n", system_surplus, cg); for (curcpu = 0, i = -1; curcpu < nprocs; curcpu++) { if (!stat_node->usage[curcpu].online) @@ -712,9 +712,9 @@ int cpuview_proc_stat(const char *cg, const char *cpuset, max_diff_idle_index = curcpu; } - lxcfs_v("curcpu: %d, diff_user: %lu, diff_system: %lu, diff_idle: %lu\n", curcpu, diff[curcpu].user, diff[curcpu].system, diff[curcpu].idle); + lxcfs_v("curcpu: %d, diff_user: %" PRIu64 ", diff_system: %" PRIu64 ", diff_idle: %" PRIu64 "\n", curcpu, diff[curcpu].user, diff[curcpu].system, diff[curcpu].idle); } - lxcfs_v("total. diff_user: %lu, diff_system: %lu, diff_idle: %lu\n", diff_user, diff_system, diff_idle); + lxcfs_v("total. diff_user: %" PRIu64 ", diff_system: %" PRIu64 ", diff_idle: %" PRIu64 "\n", diff_user, diff_system, diff_idle); /* revise cpu usage view to support partial cpu case. */ exact_cpus = exact_cpu_count(cg); @@ -724,21 +724,21 @@ int cpuview_proc_stat(const char *cg, const char *cpuset, uint64_t delta = (uint64_t)((double)(diff_user + diff_system + diff_idle) * (1 - exact_cpus / (double)max_cpus)); lxcfs_v("revising cpu usage view to match the exact cpu count [%f]\n", exact_cpus); - lxcfs_v("delta: %lu\n", delta); - lxcfs_v("idle_sum before: %lu\n", idle_sum); + lxcfs_v("delta: %" PRIu64 "\n", delta); + lxcfs_v("idle_sum before: %" PRIu64 "\n", idle_sum); if (idle_sum > delta) idle_sum = idle_sum - delta; else idle_sum = 0; - lxcfs_v("idle_sum after: %lu\n", idle_sum); + lxcfs_v("idle_sum after: %l" PRIu64 "\n", idle_sum); curcpu = max_diff_idle_index; - lxcfs_v("curcpu: %d, idle before: %lu\n", curcpu, stat_node->view[curcpu].idle); + lxcfs_v("curcpu: %d, idle before: %" PRIu64 "\n", curcpu, stat_node->view[curcpu].idle); if (stat_node->view[curcpu].idle > delta) stat_node->view[curcpu].idle = stat_node->view[curcpu].idle - delta; else stat_node->view[curcpu].idle = 0; - lxcfs_v("curcpu: %d, idle after: %lu\n", curcpu, stat_node->view[curcpu].idle); + lxcfs_v("curcpu: %d, idle after: %" PRIu64 "\n", curcpu, stat_node->view[curcpu].idle); } } else { for (curcpu = 0; curcpu < nprocs; curcpu++) { diff --git a/src/proc_fuse.c b/src/proc_fuse.c index c9103771..7a1ba40a 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -308,7 +308,7 @@ static void get_swap_info(const char *cgroup, uint64_t memlimit, uint64_t *swusage, uint64_t *memswpriority) { __do_free char *memswusage_str = NULL, *memswpriority_str = NULL; - size_t memswlimit = 0, memswusage = 0; + uint64_t memswlimit = 0, memswusage = 0; int ret; *swtotal = *swusage = 0; @@ -461,13 +461,13 @@ static void get_blkio_io_value(char *str, unsigned major, unsigned minor, len = strlen(key); while (*str) { if (startswith(str, key)) { - sscanf(str + len, "%lu", v); + sscanf(str + len, "%" PRIu64, v); return; } eol = strchr(str, '\n'); if (!eol) return; - str = eol+1; + str = eol + 1; } } @@ -621,7 +621,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, stats.read_sectors || stats.write_sectors || stats.read_ticks || stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || stats.discard_merged || stats.discard_sectors || stats.discard_ticks) - snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", + snprintf(lbuf, 256, "%u %u %s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "\n", stats.major, stats.minor, stats.dev_name, @@ -979,7 +979,7 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, curcpu++; - ret = sscanf(line, "%*s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu", + ret = sscanf(line, "%*s %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, &user, &nice, &system, @@ -1056,7 +1056,7 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, cache = d->buf; - int cpuall_len = snprintf(cpuall, CPUALL_MAX_SIZE, "cpu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", + int cpuall_len = snprintf(cpuall, CPUALL_MAX_SIZE, "cpu %" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "\n", user_sum, nice_sum, system_sum, diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c index 5f9bec79..b7411c47 100644 --- a/src/proc_loadavg.c +++ b/src/proc_loadavg.c @@ -49,13 +49,13 @@ static int loadavg = 0; #define FLUSH_TIME 5 /*the flush rate */ #define DEPTH_DIR 3 /*the depth of per cgroup */ /* The function of calculate loadavg .*/ -#define FSHIFT 11 /* nr of bits of precision */ -#define FIXED_1 (1 << FSHIFT) /* 1.0 as fixed-point */ -#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-point */ -#define EXP_5 2014 /* 1/exp(5sec/5min) */ -#define EXP_15 2037 /* 1/exp(5sec/15min) */ +#define FSHIFT (uint64_t)11 /* nr of bits of precision */ +#define FIXED_1 ((uint64_t)1 << FSHIFT) /* 1.0 as fixed-point */ +#define EXP_1 (uint64_t)1884 /* 1/exp(5sec/1min) as fixed-point */ +#define EXP_5 (uint64_t)2014 /* 1/exp(5sec/5min) */ +#define EXP_15 (uint64_t)2037 /* 1/exp(5sec/15min) */ #define LOAD_INT(x) ((x) >> FSHIFT) -#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1 - 1)) * (uint64_t)100) static volatile sig_atomic_t loadavg_stop = 0; struct load_node { @@ -225,9 +225,9 @@ int proc_loadavg_read(char *buf, size_t size, off_t offset, b = n->avenrun[1] + (FIXED_1 / 200); c = n->avenrun[2] + (FIXED_1 / 200); total_len = snprintf(d->buf, d->buflen, - "%lu.%02lu " - "%lu.%02lu " - "%lu.%02lu " + "%" PRIu64 ".%02" PRIu64 " " + "%" PRIu64 ".%02lu " + "%" PRIu64 ".%02" PRIu64 " " "%d/" "%d " "%d\n",