basic: delete loadavg.h copy

loadavg.h is an internal header of the Linux source repository, and as
such it is licensed as GPLv2-only, without syscall exception.

We use it only for 4 macros, which are simply doing some math calculations
that cannot thus be subject to copyright.
Reimplement the same calculations in another internal header and delete
loadavg.h from our tree.
This commit is contained in:
Luca Boccassi
2021-09-25 07:10:44 +09:00
committed by Yu Watanabe
parent 3f67dccca0
commit f0e2cfc6dc
9 changed files with 57 additions and 105 deletions
+8 -1
View File
@@ -3,7 +3,6 @@
#include <inttypes.h>
#include <limits.h>
#include <linux/loadavg.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
@@ -136,6 +135,14 @@ int parse_ip_prefix_length(const char *s, int *ret);
int parse_oom_score_adjust(const char *s, int *ret);
/* Implement floating point using fixed integers, to improve performance when
* calculating load averages. These macros can be used to extract the integer
* and decimal parts of a value. */
#define PRECISION_BITS 11
#define FIXED_POINT_1_0 (1 << PRECISION_BITS)
#define INT_SIDE(x) ((x) >> PRECISION_BITS)
#define DECIMAL_SIDE(x) INT_SIDE(((x) & (FIXED_POINT_1_0 - 1)) * 100)
/* Given a Linux load average (e.g. decimal number 34.89 where 34 is passed as i and 89 is passed as f), convert it
* to a loadavg_t. */
int store_loadavg_fixed_point(unsigned long i, unsigned long f, loadavg_t *ret);