Content-Type: multipart/mixed; boundary="===============2647388718409787605==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH] accel-config: Replace unsigned long with uint64_t Date: Tue, 02 Mar 2021 16:48:38 -0500 Message-ID: <20210302214838.267342-1-ramesh.thomas@intel.com> To: accel-config@lists.01.org List-ID: --===============2647388718409787605== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Makes 64 bit data type portable across 32 bit and 62 bit targets. This fixes compilation errors reported by 32 bit compilers. Signed-off-by: Ramesh Thomas Reported-by: Libor Pech=C3=A1=C4=8Dek Reported-by: Yunying Sun --- ***Please subscribe to mailing list*** = A server error is not allowing me to authorize postings from non-subsribers. Subsribe here - https://lists.01.org/postorius/lists/accel-config.lists.01.org/ = accfg/config.c | 12 ++++++------ accfg/config_attr.c | 2 +- accfg/enable.c | 2 +- accfg/lib/libaccfg.c | 38 +++++++++++++++++++------------------- accfg/lib/private.h | 10 +++++----- accfg/libaccel_config.h | 18 +++++++++--------- accfg/list.c | 8 ++++---- ccan/endian/endian.h | 2 +- util/bitmap.c | 34 +++++++++++++++++----------------- util/bitmap.h | 18 +++++++++--------- util/filter.h | 2 +- util/json.c | 32 ++++++++++++++++---------------- util/json.h | 18 +++++++++--------- util/size.c | 6 +++--- util/size.h | 12 +++++++----- 15 files changed, 108 insertions(+), 106 deletions(-) diff --git a/accfg/config.c b/accfg/config.c index dadf679..49f5631 100644 --- a/accfg/config.c +++ b/accfg/config.c @@ -32,9 +32,9 @@ static struct config { char *buf; } config; = -static unsigned long config_opts_to_flags(void) +static uint64_t config_opts_to_flags(void) { - unsigned long flags =3D 0; + uint64_t flags =3D 0; return flags; } = @@ -47,7 +47,7 @@ struct device_set_table { struct wq_set_table { char *name; int (*set_int_func)(struct accfg_wq *wq, int val); - int (*set_long_func)(struct accfg_wq *wq, unsigned long val); + int (*set_long_func)(struct accfg_wq *wq, uint64_t val); int (*set_str_func)(struct accfg_wq *wq, const char *val); bool (*is_writable)(struct accfg_wq *wq, int val); }; @@ -259,7 +259,7 @@ static int wq_json_set_val(struct accfg_wq *wq, json_ob= ject *jobj, char *key) = return 0; } else if (wq_table[i].set_long_func) { - unsigned long val =3D json_object_get_int64(jobj); + uint64_t val =3D json_object_get_int64(jobj); = if ((val =3D=3D 0) && (errno =3D=3D EINVAL)) return -errno; @@ -563,7 +563,7 @@ static int configure_json_value(struct accfg_ctx *ctx, } = static struct json_object *config_group_to_json(struct accfg_group *group, - unsigned long flags) + uint64_t flags) { struct json_object *jgroup =3D json_object_new_object(); struct json_object *jobj =3D NULL; @@ -819,7 +819,7 @@ static bool filter_group(struct accfg_group *group, struct list_filter_arg *lfa =3D ctx->list; struct json_object *jgroup; struct json_object *container =3D lfa->jdevice; - unsigned long group_id; + uint64_t group_id; struct accfg_device *dev =3D accfg_group_get_device(group); int max_groups =3D accfg_device_get_max_groups(dev); struct accfg_json_container *jc =3D NULL, *iter; diff --git a/accfg/config_attr.c b/accfg/config_attr.c index f7f43b1..52a8954 100644 --- a/accfg/config_attr.c +++ b/accfg/config_attr.c @@ -134,7 +134,7 @@ static int accel_config_parse_wq_attribs(struct accfg_d= evice *device, struct accfg_wq *wq, struct wq_parameters *wq_params) { unsigned int max_groups, max_wq_size, max_batch_size; - unsigned long max_transfer_size; + uint64_t max_transfer_size; int rc =3D 0; = if (wq_params->mode) { diff --git a/accfg/enable.c b/accfg/enable.c index 34328ca..df4b887 100644 --- a/accfg/enable.c +++ b/accfg/enable.c @@ -237,7 +237,7 @@ static int wq_action(int argc, const char **argv, const= char *usage, usage, NULL }; - unsigned long dev_id, wq_id; + uint64_t dev_id, wq_id; int i, rc =3D 0, success =3D 0, fail =3D 0, fail_reason =3D 0; const char *all =3D "all"; enum accfg_wq_state state; diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c index ae862f8..f91f5af 100644 --- a/accfg/lib/libaccfg.c +++ b/accfg/lib/libaccfg.c @@ -109,7 +109,7 @@ static long accfg_get_param_long(struct accfg_ctx *ctx,= int dfd, char *name) return strtol(buf, NULL, 0); } = -static unsigned long long accfg_get_param_unsigned_llong( +static uint64_t accfg_get_param_unsigned_llong( struct accfg_ctx *ctx, int dfd, char *name) { int fd =3D openat(dfd, name, O_RDONLY); @@ -317,13 +317,13 @@ ACCFG_EXPORT int accfg_new(struct accfg_ctx **ctx) = env =3D secure_getenv("ACCFG_TIMEOUT"); if (env !=3D NULL) { - unsigned long tmo; + uint64_t tmo; char *end; = tmo =3D strtoul(env, &end, 0); if (tmo < ULONG_MAX && !end) c->timeout =3D tmo; - dbg(c, "timeout =3D %ld\n", tmo); + dbg(c, "timeout =3D %" PRIu64 "\n", tmo); } = return 0; @@ -642,7 +642,7 @@ static void *add_wq(void *parent, int id, const char *w= q_base, struct accfg_ctx *ctx; char *path; char *wq_base_string; - unsigned long device_id, wq_id; + uint64_t device_id, wq_id; int dfd; char *wq_type; = @@ -678,7 +678,7 @@ static void *add_wq(void *parent, int id, const char *w= q_base, } = if (sscanf(basename(wq_base_string), - "wq%ld.%ld", &device_id, &wq_id) !=3D 2) { + "wq%" PRIu64 ".%" PRIu64, &device_id, &wq_id) !=3D 2) { close(dfd); goto err_wq; } @@ -739,7 +739,7 @@ static void *add_group(void *parent, int id, const char= *group_base, char *path; char *group_base_string; int dfd; - unsigned long device_id, group_id; + uint64_t device_id, group_id; = if (!device) return NULL; @@ -770,7 +770,7 @@ static void *add_group(void *parent, int id, const char= *group_base, goto err_group; } if (sscanf(basename(group_base_string), - "group%ld.%ld", &device_id, &group_id) !=3D 2) { + "group%" PRIu64 ".%" PRIu64, &device_id, &group_id) !=3D 2) { free(group); close(dfd); goto err_group; @@ -828,7 +828,7 @@ static void *add_engine(void *parent, int id, const cha= r *engine_base, char *path; char *engine_base_string; int dfd; - unsigned long device_id, engine_id; + uint64_t device_id, engine_id; = if (!device) return NULL; @@ -861,7 +861,7 @@ static void *add_engine(void *parent, int id, const cha= r *engine_base, goto err_engine; } if (sscanf(basename(engine_base_string), - "engine%ld.%ld", &device_id, &engine_id) !=3D 2) { + "engine%" PRIu64 ".%" PRIu64, &device_id, &engine_id) !=3D 2) { close(dfd); free(path); free(engine); @@ -1205,19 +1205,19 @@ ACCFG_EXPORT unsigned int accfg_device_get_max_batc= h_size( return device->max_batch_size; } = -ACCFG_EXPORT unsigned long accfg_device_get_max_transfer_size( +ACCFG_EXPORT uint64_t accfg_device_get_max_transfer_size( struct accfg_device *device) { return device->max_transfer_size; } = -ACCFG_EXPORT unsigned long accfg_device_get_op_cap( +ACCFG_EXPORT uint64_t accfg_device_get_op_cap( struct accfg_device *device) { return device->opcap; } = -ACCFG_EXPORT unsigned long accfg_device_get_gen_cap(struct accfg_device *d= evice) +ACCFG_EXPORT uint64_t accfg_device_get_gen_cap(struct accfg_device *device) { return device->gencap; } @@ -1257,7 +1257,7 @@ ACCFG_EXPORT int accfg_device_get_errors(struct accfg= _device *device, return -errno; read_error =3D accfg_get_param_str(ctx, dfd, "errors"); close(dfd); - rc =3D sscanf(read_error, "%lx %lx %lx %lx", + rc =3D sscanf(read_error, "%" PRIx64 " %" PRIx64 " %" PRIx64 " %" PRIx64, &error->val[0], &error->val[1], &error->val[2], &error->val[3]); if (rc < 0) { @@ -1626,12 +1626,12 @@ ACCFG_EXPORT const char *accfg_group_get_devname(st= ruct accfg_group *group) return devpath_to_devname(group->group_path); } = -ACCFG_EXPORT unsigned long accfg_group_get_size(struct accfg_group *group) +ACCFG_EXPORT uint64_t accfg_group_get_size(struct accfg_group *group) { return group->size; } = -ACCFG_EXPORT unsigned long accfg_group_get_available_size( +ACCFG_EXPORT uint64_t accfg_group_get_available_size( struct accfg_group *group) { struct accfg_ctx *ctx =3D accfg_group_get_ctx(group); @@ -1799,7 +1799,7 @@ ACCFG_EXPORT const char *accfg_wq_get_type_name(struc= t accfg_wq *wq) return wq->name; } = -ACCFG_EXPORT unsigned long accfg_wq_get_size(struct accfg_wq *wq) +ACCFG_EXPORT uint64_t accfg_wq_get_size(struct accfg_wq *wq) { return wq->size; } @@ -1809,7 +1809,7 @@ ACCFG_EXPORT unsigned int accfg_wq_get_max_batch_size= (struct accfg_wq *wq) return wq->max_batch_size; } = -ACCFG_EXPORT unsigned long accfg_wq_get_max_transfer_size(struct accfg_wq = *wq) +ACCFG_EXPORT uint64_t accfg_wq_get_max_transfer_size(struct accfg_wq *wq) { return wq->max_transfer_size; } @@ -2096,7 +2096,7 @@ accfg_wq_set_field(wq, val, max_batch_size) = #define accfg_wq_set_long_field(wq, val, field) \ ACCFG_EXPORT int accfg_wq_set_##field( \ - struct accfg_wq *wq, unsigned long val) \ + struct accfg_wq *wq, uint64_t val) \ { \ struct accfg_ctx *ctx =3D accfg_wq_get_ctx(wq); \ char *path =3D wq->wq_buf; \ @@ -2105,7 +2105,7 @@ ACCFG_EXPORT int accfg_wq_set_##field( \ rc =3D sprintf(wq->wq_buf, "%s/%s", wq->wq_path, #field); \ if (rc < 0) \ return -errno; \ - if (sprintf(buf, "%ld", val) < 0) { \ + if (sprintf(buf, "%" PRId64, val) < 0) { \ err(ctx, "%s: sprintf to buf failed: %s\n", \ accfg_wq_get_devname(wq), \ strerror(errno)); \ diff --git a/accfg/lib/private.h b/accfg/lib/private.h index e36a474..24e2ee8 100644 --- a/accfg/lib/private.h +++ b/accfg/lib/private.h @@ -51,9 +51,9 @@ struct accfg_device { unsigned int token_limit; unsigned int cdev_major; unsigned int version; - unsigned long max_transfer_size; - unsigned long opcap; - unsigned long gencap; + uint64_t max_transfer_size; + uint64_t opcap; + uint64_t gencap; char *pasid_enabled; }; = @@ -124,7 +124,7 @@ struct accfg_wq { enum accfg_wq_type type; char *state; unsigned int max_batch_size; - unsigned long max_transfer_size; + uint64_t max_transfer_size; }; = #define ACCFG_EXPORT __attribute__ ((visibility("default"))) @@ -144,7 +144,7 @@ struct accfg_ctx { int devices_init; int groups_init; struct list_head devices; - unsigned long timeout; + uint64_t timeout; void *private_data; }; = diff --git a/accfg/libaccel_config.h b/accfg/libaccel_config.h index 0814601..95bb5d2 100644 --- a/accfg/libaccel_config.h +++ b/accfg/libaccel_config.h @@ -102,7 +102,7 @@ struct wq_parameters { unsigned int priority; int block_on_fault; unsigned int max_batch_size; - unsigned long max_transfer_size; + uint64_t max_transfer_size; const char *mode; const char *type; const char *name; @@ -167,9 +167,9 @@ unsigned int accfg_device_get_max_work_queues_size(stru= ct accfg_device *device); int accfg_device_get_numa_node(struct accfg_device *device); unsigned int accfg_device_get_ims_size(struct accfg_device *device); unsigned int accfg_device_get_max_batch_size(struct accfg_device *device); -unsigned long accfg_device_get_max_transfer_size(struct accfg_device *devi= ce); -unsigned long accfg_device_get_op_cap(struct accfg_device *device); -unsigned long accfg_device_get_gen_cap(struct accfg_device *device); +uint64_t accfg_device_get_max_transfer_size(struct accfg_device *device); +uint64_t accfg_device_get_op_cap(struct accfg_device *device); +uint64_t accfg_device_get_gen_cap(struct accfg_device *device); unsigned int accfg_device_get_configurable(struct accfg_device *device); bool accfg_device_get_pasid_enabled(struct accfg_device *device); bool accfg_device_get_mdev_enabled(struct accfg_device *device); @@ -213,8 +213,8 @@ struct accfg_group *accfg_device_group_get_by_id(struct= accfg_device *device, int id); int accfg_group_get_device_id(struct accfg_group *group); const char *accfg_group_get_devname(struct accfg_group *group); -unsigned long accfg_group_get_size(struct accfg_group *group); -unsigned long accfg_group_get_available_size(struct accfg_group *group); +uint64_t accfg_group_get_size(struct accfg_group *group); +uint64_t accfg_group_get_available_size(struct accfg_group *group); struct accfg_device *accfg_group_get_device(struct accfg_group *group); struct accfg_ctx *accfg_group_get_ctx(struct accfg_group *group); int accfg_group_get_tokens_reserved(struct accfg_group *group); @@ -247,7 +247,7 @@ struct accfg_wq *accfg_device_wq_get_by_id(struct accfg= _device *device, int id); const char *accfg_wq_get_devname(struct accfg_wq *wq); enum accfg_wq_mode accfg_wq_get_mode(struct accfg_wq *wq); -unsigned long accfg_wq_get_size(struct accfg_wq *wq); +uint64_t accfg_wq_get_size(struct accfg_wq *wq); int accfg_wq_get_group_id(struct accfg_wq *wq); int accfg_wq_get_priority(struct accfg_wq *wq); unsigned int accfg_wq_get_priv(struct accfg_wq *wq); @@ -257,7 +257,7 @@ int accfg_wq_get_cdev_minor(struct accfg_wq *wq); const char *accfg_wq_get_type_name(struct accfg_wq *wq); enum accfg_wq_type accfg_wq_get_type(struct accfg_wq *wq); unsigned int accfg_wq_get_max_batch_size(struct accfg_wq *wq); -unsigned long accfg_wq_get_max_transfer_size(struct accfg_wq *wq); +uint64_t accfg_wq_get_max_transfer_size(struct accfg_wq *wq); int accfg_wq_get_threshold(struct accfg_wq *wq); int accfg_wq_get_clients(struct accfg_wq *wq); int accfg_wq_is_enabled(struct accfg_wq *wq); @@ -267,7 +267,7 @@ int accfg_wq_set_group_id(struct accfg_wq *wq, int val); int accfg_wq_set_threshold(struct accfg_wq *wq, int val); int accfg_wq_set_block_on_fault(struct accfg_wq *wq, int val); int accfg_wq_set_max_batch_size(struct accfg_wq *wq, int val); -int accfg_wq_set_max_transfer_size(struct accfg_wq *wq, unsigned long val); +int accfg_wq_set_max_transfer_size(struct accfg_wq *wq, uint64_t val); int accfg_wq_set_str_mode(struct accfg_wq *wq, const char* val); int accfg_wq_set_mode(struct accfg_wq *wq, enum accfg_wq_mode mode); int accfg_wq_set_str_type(struct accfg_wq *wq, const char* val); diff --git a/accfg/list.c b/accfg/list.c index 2234e65..998ebdd 100644 --- a/accfg/list.c +++ b/accfg/list.c @@ -25,9 +25,9 @@ static struct { bool save_conf; } list; = -static unsigned long listopts_to_flags(void) +static uint64_t listopts_to_flags(void) { - unsigned long flags =3D 0; + uint64_t flags =3D 0; = if (list.idle) flags |=3D UTIL_JSON_IDLE; @@ -50,7 +50,7 @@ do { \ } while (0) = static struct json_object *group_to_json(struct accfg_group *group, - unsigned long flags) + uint64_t flags) { struct json_object *jgroup =3D json_object_new_object(); struct json_object *jobj =3D NULL; @@ -249,7 +249,7 @@ static bool filter_engine(struct accfg_engine *engine, static bool filter_group(struct accfg_group *group, struct util_filter_ctx *ctx) { - unsigned long group_id; + uint64_t group_id; struct list_filter_arg *lfa =3D ctx->list; struct json_object *jgroup; struct json_object *container =3D lfa->jdevice; diff --git a/ccan/endian/endian.h b/ccan/endian/endian.h index dc9f62e..85ee0c9 100644 --- a/ccan/endian/endian.h +++ b/ccan/endian/endian.h @@ -95,7 +95,7 @@ static inline uint32_t bswap_32(uint32_t val) * Example: * // Output contains "1024 is 1125899906842624 as eight bytes reversed" * printf("1024 is %llu as eight bytes reversed\n", - * (unsigned long long)bswap_64(1024)); + * (uint64_t long)bswap_64(1024)); */ static inline uint64_t bswap_64(uint64_t val) { diff --git a/util/bitmap.c b/util/bitmap.c index 2f393f2..664251d 100644 --- a/util/bitmap.c +++ b/util/bitmap.c @@ -22,17 +22,17 @@ #include #include = -unsigned long *bitmap_alloc(unsigned long nbits) +uint64_t *bitmap_alloc(uint64_t nbits) { - return calloc(BITS_TO_LONGS(nbits), sizeof(unsigned long)); + return calloc(BITS_TO_LONGS(nbits), sizeof(uint64_t)); } = -void bitmap_set(unsigned long *map, unsigned int start, int len) +void bitmap_set(uint64_t *map, unsigned int start, int len) { - unsigned long *p =3D map + BIT_WORD(start); + uint64_t *p =3D map + BIT_WORD(start); const unsigned int size =3D start + len; int bits_to_set =3D BITS_PER_LONG - (start % BITS_PER_LONG); - unsigned long mask_to_set =3D BITMAP_FIRST_WORD_MASK(start); + uint64_t mask_to_set =3D BITMAP_FIRST_WORD_MASK(start); = while (len - bits_to_set >=3D 0) { *p |=3D mask_to_set; @@ -47,12 +47,12 @@ void bitmap_set(unsigned long *map, unsigned int start,= int len) } } = -void bitmap_clear(unsigned long *map, unsigned int start, int len) +void bitmap_clear(uint64_t *map, unsigned int start, int len) { - unsigned long *p =3D map + BIT_WORD(start); + uint64_t *p =3D map + BIT_WORD(start); const unsigned int size =3D start + len; int bits_to_clear =3D BITS_PER_LONG - (start % BITS_PER_LONG); - unsigned long mask_to_clear =3D BITMAP_FIRST_WORD_MASK(start); + uint64_t mask_to_clear =3D BITMAP_FIRST_WORD_MASK(start); = while (len - bits_to_clear >=3D 0) { *p &=3D ~mask_to_clear; @@ -72,7 +72,7 @@ void bitmap_clear(unsigned long *map, unsigned int start,= int len) * @nr: bit number to test * @addr: Address to start counting from */ -int test_bit(unsigned int nr, const volatile unsigned long *addr) +int test_bit(unsigned int nr, const volatile uint64_t *addr) { return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1))); } @@ -82,10 +82,10 @@ int test_bit(unsigned int nr, const volatile unsigned l= ong *addr) * find_next_zero_bit. The difference is the "invert" argument, which * is XORed with each fetched word before searching it for one bits. */ -static unsigned long _find_next_bit(const unsigned long *addr, - unsigned long nbits, unsigned long start, unsigned long invert) +static uint64_t _find_next_bit(const uint64_t *addr, + uint64_t nbits, uint64_t start, uint64_t invert) { - unsigned long tmp; + uint64_t tmp; = if (!nbits || start >=3D nbits) return nbits; @@ -110,19 +110,19 @@ static unsigned long _find_next_bit(const unsigned lo= ng *addr, /* * Find the next set bit in a memory region. */ -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset) +uint64_t find_next_bit(const uint64_t *addr, uint64_t size, + uint64_t offset) { return _find_next_bit(addr, size, offset, 0UL); } = -unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long = size, - unsigned long offset) +uint64_t find_next_zero_bit(const uint64_t *addr, uint64_t size, + uint64_t offset) { return _find_next_bit(addr, size, offset, ~0UL); } = -int bitmap_full(const unsigned long *src, unsigned int nbits) +int bitmap_full(const uint64_t *src, unsigned int nbits) { if (small_const_nbits(nbits)) return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits)); diff --git a/util/bitmap.h b/util/bitmap.h index e88ca63..b72fd65 100644 --- a/util/bitmap.h +++ b/util/bitmap.h @@ -21,15 +21,15 @@ #define small_const_nbits(nbits) \ (__builtin_constant_p(nbits) && (nbits) <=3D BITS_PER_LONG) = -unsigned long *bitmap_alloc(unsigned long nbits); -void bitmap_set(unsigned long *map, unsigned int start, int len); -void bitmap_clear(unsigned long *map, unsigned int start, int len); -int test_bit(unsigned int nr, const volatile unsigned long *addr); -unsigned long find_next_bit(const unsigned long *addr, unsigned long size, - unsigned long offset); -unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long = size, - unsigned long offset); -int bitmap_full(const unsigned long *src, unsigned int nbits); +uint64_t *bitmap_alloc(uint64_t nbits); +void bitmap_set(uint64_t *map, unsigned int start, int len); +void bitmap_clear(uint64_t *map, unsigned int start, int len); +int test_bit(unsigned int nr, const volatile uint64_t *addr); +uint64_t find_next_bit(const uint64_t *addr, uint64_t size, + uint64_t offset); +uint64_t find_next_zero_bit(const uint64_t *addr, uint64_t size, + uint64_t offset); +int bitmap_full(const uint64_t *src, unsigned int nbits); = = #endif /* _ACCFG_BITMAP_H_ */ diff --git a/util/filter.h b/util/filter.h index 1ab496f..4ba0837 100644 --- a/util/filter.h +++ b/util/filter.h @@ -62,7 +62,7 @@ struct list_filter_arg { /* linked list node for each list_filter_arg */ struct list_node list; /* flags to indicate command options */ - unsigned long flags; + uint64_t flags; /* track device number during walk-through */ int dev_num; /* track group_num during walk-through */ diff --git a/util/json.c b/util/json.c index f8ace0d..c3f2ade 100644 --- a/util/json.c +++ b/util/json.c @@ -27,7 +27,7 @@ static const char *wq_type_str[] =3D { static int display_size(struct json_object *jobj, struct printbuf *pbuf, int level, int flags) { - unsigned long long bytes =3D json_object_get_int64(jobj); + uint64_t bytes =3D json_object_get_int64(jobj); static char buf[128]; int c; = @@ -43,7 +43,7 @@ static int display_size(struct json_object *jobj, struct = printbuf *pbuf, */ = if (bytes < 5000 * 1024) - snprintf(buf, sizeof(buf), "%lld", bytes); + snprintf(buf, sizeof(buf), "%" PRId64, bytes); else { /* IEC */ if (bytes < 2 * 1024LL * 1024LL * 1024LL) { @@ -78,14 +78,14 @@ static int display_size(struct json_object *jobj, struc= t printbuf *pbuf, static int display_hex(struct json_object *jobj, struct printbuf *pbuf, int level, int flags) { - unsigned long long val =3D json_object_get_int64(jobj); + uint64_t val =3D json_object_get_int64(jobj); static char buf[32]; - snprintf(buf, sizeof(buf), "\"%#llx\"", val); + snprintf(buf, sizeof(buf), "\"%#" PRIx64 "\"", val); return printbuf_memappend(pbuf, buf, strlen(buf)); } = -struct json_object *util_json_object_size(unsigned long long size, - unsigned long flags) +struct json_object *util_json_object_size(uint64_t size, + uint64_t flags) { struct json_object *jobj =3D json_object_new_int64(size); = @@ -94,8 +94,8 @@ struct json_object *util_json_object_size(unsigned long l= ong size, return jobj; } = -struct json_object *util_json_object_hex(unsigned long long val, - unsigned long flags) +struct json_object *util_json_object_hex(uint64_t val, + uint64_t flags) { struct json_object *jobj =3D json_object_new_int64(val); = @@ -106,7 +106,7 @@ struct json_object *util_json_object_hex(unsigned long = long val, = /* API used to output json object display to console */ void util_display_json_array(FILE * f_out, struct json_object *jarray, - unsigned long flags) + uint64_t flags) { int len =3D json_object_array_length(jarray); int jflag =3D JSON_C_TO_STRING_PRETTY; @@ -125,7 +125,7 @@ void util_display_json_array(FILE * f_out, struct json_= object *jarray, = /* API used to output json object display to specified file */ void __util_display_json_array(FILE * fd, struct json_object *jarray, - unsigned long flags) + uint64_t flags) { int len =3D json_object_array_length(jarray); int jflag =3D JSON_C_TO_STRING_PRETTY; @@ -143,15 +143,15 @@ void __util_display_json_array(FILE * fd, struct json= _object *jarray, } = struct json_object *util_device_to_json(struct accfg_device *device, - unsigned long flags) + uint64_t flags) { struct json_object *jdevice =3D json_object_new_object(); struct json_object *jobj; struct accfg_error *error; enum accfg_device_state dev_state; int int_val; - unsigned long ulong_val; - unsigned long long ullong_val; + uint64_t ulong_val; + uint64_t ullong_val; bool new_bool; struct accfg_device_mdev *mdev; struct json_object *json_uuid; @@ -386,11 +386,11 @@ err: } = struct json_object *util_wq_to_json(struct accfg_wq *wq, - unsigned long flags) + uint64_t flags) { struct json_object *jaccfg =3D json_object_new_object(); struct json_object *jobj =3D NULL; - unsigned long size =3D ULLONG_MAX; + uint64_t size =3D ULLONG_MAX; enum accfg_wq_mode wq_mode; enum accfg_wq_state wq_state; int int_val; @@ -501,7 +501,7 @@ err: } = struct json_object *util_engine_to_json(struct accfg_engine *engine, - unsigned long flags) + uint64_t flags) { struct json_object *jaccfg =3D json_object_new_object(); struct json_object *jobj =3D NULL; diff --git a/util/json.h b/util/json.h index 5bf685b..c185f80 100644 --- a/util/json.h +++ b/util/json.h @@ -17,17 +17,17 @@ enum util_json_flags { = struct json_object; void util_display_json_array(FILE *f_out, struct json_object *jarray, - unsigned long flags); + uint64_t flags); void __util_display_json_array(FILE *fd, struct json_object *jarray, - unsigned long flags); + uint64_t flags); struct json_object *util_device_to_json(struct accfg_device *device, - unsigned long flags); + uint64_t flags); struct json_object *util_wq_to_json(struct accfg_wq *accfg_wq, - unsigned long flags); + uint64_t flags); struct json_object *util_engine_to_json(struct accfg_engine *accfg_engine, - unsigned long flags); -struct json_object *util_json_object_size(unsigned long long size, - unsigned long flags); -struct json_object *util_json_object_hex(unsigned long long val, - unsigned long flags); + uint64_t flags); +struct json_object *util_json_object_size(uint64_t size, + uint64_t flags); +struct json_object *util_json_object_hex(uint64_t val, + uint64_t flags); #endif /* __ACCFG_JSON_H__ */ diff --git a/util/size.c b/util/size.c index 5f15dee..f3ef67a 100644 --- a/util/size.c +++ b/util/size.c @@ -5,9 +5,9 @@ #include #include = -unsigned long long __parse_size64(const char *str, unsigned long long *uni= ts) +uint64_t __parse_size64(const char *str, uint64_t *units) { - unsigned long long val, check; + uint64_t val, check; char *end; = val =3D strtoull(str, &end, 0); @@ -54,7 +54,7 @@ unsigned long long __parse_size64(const char *str, unsign= ed long long *units) return val; } = -unsigned long long parse_size64(const char *str) +uint64_t parse_size64(const char *str) { return __parse_size64(str, NULL); } diff --git a/util/size.h b/util/size.h index ffca256..c35ec45 100644 --- a/util/size.h +++ b/util/size.h @@ -4,6 +4,8 @@ #ifndef _ACCFG_SIZE_H_ #define _ACCFG_SIZE_H_ = +#include + #define SZ_1K 0x00000400 #define SZ_4K 0x00001000 #define SZ_1M 0x00100000 @@ -14,12 +16,12 @@ #define SZ_1G 0x40000000 #define SZ_1T 0x10000000000ULL = -unsigned long long parse_size64(const char *str); -unsigned long long __parse_size64(const char *str, unsigned long long *uni= ts); +uint64_t parse_size64(const char *str); +uint64_t __parse_size64(const char *str, uint64_t *units); = -#define ALIGN(x, a) ((((unsigned long long) x) + (a - 1)) & ~(a - 1)) -#define ALIGN_DOWN(x, a) (((((unsigned long long) x) + a) & ~(a - 1)) - a) -#define BITS_PER_LONG (sizeof(unsigned long) * 8) +#define ALIGN(x, a) ((((uint64_t) x) + (a - 1)) & ~(a - 1)) +#define ALIGN_DOWN(x, a) (((((uint64_t) x) + a) & ~(a - 1)) - a) +#define BITS_PER_LONG (sizeof(uint64_t) * 8) #define HPAGE_SIZE (2 << 20) = #endif /* _ACCFG_SIZE_H_ */ -- = 2.26.2 --===============2647388718409787605==--