Skip to content

Commit

Permalink
Improve compatibility with C++ consumers
Browse files Browse the repository at this point in the history
C++ is a little picky about not using keywords for names, or string
constness.

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
  • Loading branch information
Ryan Moeller authored and Ryan Moeller committed Jun 4, 2020
1 parent 99b281f commit 26a0ce5
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 35 deletions.
2 changes: 1 addition & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ extern nvlist_t *zpool_find_vdev(zpool_handle_t *, const char *, boolean_t *,
boolean_t *, boolean_t *);
extern nvlist_t *zpool_find_vdev_by_physpath(zpool_handle_t *, const char *,
boolean_t *, boolean_t *, boolean_t *);
extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, char *);
extern int zpool_label_disk(libzfs_handle_t *, zpool_handle_t *, const char *);
extern uint64_t zpool_vdev_path_to_guid(zpool_handle_t *zhp, const char *path);

const char *zpool_get_state_str(zpool_handle_t *);
Expand Down
2 changes: 2 additions & 0 deletions include/os/freebsd/spl/sys/ccompile.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ typedef long loff_t;
typedef long rlim64_t;
typedef int bool_t;
typedef int enum_t;
#ifndef __cplusplus
#define __init
#endif
#define __exit
#define FALSE 0
#define TRUE 1
Expand Down
4 changes: 2 additions & 2 deletions include/sys/abd.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern "C" {
struct abd; /* forward declaration */
typedef struct abd abd_t;

typedef int abd_iter_func_t(void *buf, size_t len, void *private);
typedef int abd_iter_func2_t(void *bufa, void *bufb, size_t len, void *private);
typedef int abd_iter_func_t(void *buf, size_t len, void *priv);
typedef int abd_iter_func2_t(void *bufa, void *bufb, size_t len, void *priv);

extern int zfs_abd_scatter_enabled;
extern abd_t *abd_zero_scatter;
Expand Down
4 changes: 2 additions & 2 deletions include/sys/range_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ rs_get_fill_raw(const range_seg_t *rs, const range_tree_t *rt)
ASSERT3U(rt->rt_type, <=, RANGE_SEG_NUM_TYPES);
switch (rt->rt_type) {
case RANGE_SEG32: {
const range_seg32_t *r32 = rs;
const range_seg32_t *r32 = (const range_seg32_t *)rs;
return (r32->rs_end - r32->rs_start);
}
case RANGE_SEG64: {
const range_seg64_t *r64 = rs;
const range_seg64_t *r64 = (const range_seg64_t *)rs;
return (r64->rs_end - r64->rs_start);
}
case RANGE_SEG_GAP:
Expand Down
6 changes: 3 additions & 3 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ typedef struct spa_history_kstat {
uint64_t count;
uint64_t size;
kstat_t *kstat;
void *private;
void *priv;
list_t list;
} spa_history_kstat_t;

Expand Down Expand Up @@ -1131,10 +1131,10 @@ extern const char *spa_state_to_name(spa_t *spa);
/* error handling */
struct zbookmark_phys;
extern void spa_log_error(spa_t *spa, const zbookmark_phys_t *zb);
extern int zfs_ereport_post(const char *class, spa_t *spa, vdev_t *vd,
extern int zfs_ereport_post(const char *clazz, spa_t *spa, vdev_t *vd,
const zbookmark_phys_t *zb, zio_t *zio, uint64_t stateoroffset,
uint64_t length);
extern boolean_t zfs_ereport_is_valid(const char *class, spa_t *spa, vdev_t *vd,
extern boolean_t zfs_ereport_is_valid(const char *clazz, spa_t *spa, vdev_t *vd,
zio_t *zio);
extern nvlist_t *zfs_event_create(spa_t *spa, vdev_t *vd, const char *type,
const char *name, nvlist_t *aux);
Expand Down
2 changes: 1 addition & 1 deletion include/sys/vdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ extern nvlist_t *vdev_label_read_config(vdev_t *vd, uint64_t txg);
extern void vdev_uberblock_load(vdev_t *, struct uberblock *, nvlist_t **);
extern void vdev_config_generate_stats(vdev_t *vd, nvlist_t *nv);
extern void vdev_label_write(zio_t *zio, vdev_t *vd, int l, abd_t *buf, uint64_t
offset, uint64_t size, zio_done_func_t *done, void *private, int flags);
offset, uint64_t size, zio_done_func_t *done, void *priv, int flags);
extern int vdev_label_read_bootenv(vdev_t *, nvlist_t *);
extern int vdev_label_write_bootenv(vdev_t *, char *);

Expand Down
17 changes: 14 additions & 3 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#ifndef _SYS_ZFS_CONTEXT_H
#define _SYS_ZFS_CONTEXT_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __KERNEL__
#include <sys/note.h>
#include <sys/types.h>
Expand Down Expand Up @@ -355,9 +359,6 @@ extern void kstat_set_raw_ops(kstat_t *ksp,
* procfs list manipulation
*/

struct seq_file { };
void seq_printf(struct seq_file *m, const char *fmt, ...);

typedef struct procfs_list {
void *pl_private;
kmutex_t pl_lock;
Expand All @@ -366,6 +367,10 @@ typedef struct procfs_list {
size_t pl_node_offset;
} procfs_list_t;

#ifndef __cplusplus
struct seq_file { };
void seq_printf(struct seq_file *m, const char *fmt, ...);

typedef struct procfs_list_node {
list_node_t pln_link;
uint64_t pln_id;
Expand All @@ -382,6 +387,7 @@ void procfs_list_install(const char *module,
void procfs_list_uninstall(procfs_list_t *procfs_list);
void procfs_list_destroy(procfs_list_t *procfs_list);
void procfs_list_add(procfs_list_t *procfs_list, void *p);
#endif

/*
* Kernel memory
Expand Down Expand Up @@ -742,4 +748,9 @@ extern int kmem_cache_reap_active(void);
#define ____cacheline_aligned

#endif /* _KERNEL */

#ifdef __cplusplus
};
#endif

#endif /* _SYS_ZFS_CONTEXT_H */
24 changes: 12 additions & 12 deletions include/sys/zio.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,24 +525,24 @@ enum blk_verify_flag {
extern int zio_bookmark_compare(const void *, const void *);

extern zio_t *zio_null(zio_t *pio, spa_t *spa, vdev_t *vd,
zio_done_func_t *done, void *private, enum zio_flag flags);
zio_done_func_t *done, void *priv, enum zio_flag flags);

extern zio_t *zio_root(spa_t *spa,
zio_done_func_t *done, void *private, enum zio_flag flags);
zio_done_func_t *done, void *priv, enum zio_flag flags);

extern zio_t *zio_read(zio_t *pio, spa_t *spa, const blkptr_t *bp,
struct abd *data, uint64_t lsize, zio_done_func_t *done, void *private,
struct abd *data, uint64_t lsize, zio_done_func_t *done, void *priv,
zio_priority_t priority, enum zio_flag flags, const zbookmark_phys_t *zb);

extern zio_t *zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
struct abd *data, uint64_t size, uint64_t psize, const zio_prop_t *zp,
zio_done_func_t *ready, zio_done_func_t *children_ready,
zio_done_func_t *physdone, zio_done_func_t *done,
void *private, zio_priority_t priority, enum zio_flag flags,
void *priv, zio_priority_t priority, enum zio_flag flags,
const zbookmark_phys_t *zb);

extern zio_t *zio_rewrite(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
struct abd *data, uint64_t size, zio_done_func_t *done, void *private,
struct abd *data, uint64_t size, zio_done_func_t *done, void *priv,
zio_priority_t priority, enum zio_flag flags, zbookmark_phys_t *zb);

extern void zio_write_override(zio_t *zio, blkptr_t *bp, int copies,
Expand All @@ -552,23 +552,23 @@ extern void zio_free(spa_t *spa, uint64_t txg, const blkptr_t *bp);

extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg,
const blkptr_t *bp,
zio_done_func_t *done, void *private, enum zio_flag flags);
zio_done_func_t *done, void *priv, enum zio_flag flags);

extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
zio_done_func_t *done, void *private, enum zio_flag flags);
zio_done_func_t *done, void *priv, enum zio_flag flags);

extern zio_t *zio_trim(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size,
zio_done_func_t *done, void *private, zio_priority_t priority,
zio_done_func_t *done, void *priv, zio_priority_t priority,
enum zio_flag flags, enum trim_flag trim_flags);

extern zio_t *zio_read_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
uint64_t size, struct abd *data, int checksum,
zio_done_func_t *done, void *private, zio_priority_t priority,
zio_done_func_t *done, void *priv, zio_priority_t priority,
enum zio_flag flags, boolean_t labels);

extern zio_t *zio_write_phys(zio_t *pio, vdev_t *vd, uint64_t offset,
uint64_t size, struct abd *data, int checksum,
zio_done_func_t *done, void *private, zio_priority_t priority,
zio_done_func_t *done, void *priv, zio_priority_t priority,
enum zio_flag flags, boolean_t labels);

extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg,
Expand Down Expand Up @@ -606,11 +606,11 @@ extern void zio_resubmit_stage_async(void *);
extern zio_t *zio_vdev_child_io(zio_t *zio, blkptr_t *bp, vdev_t *vd,
uint64_t offset, struct abd *data, uint64_t size, int type,
zio_priority_t priority, enum zio_flag flags,
zio_done_func_t *done, void *private);
zio_done_func_t *done, void *priv);

extern zio_t *zio_vdev_delegated_io(vdev_t *vd, uint64_t offset,
struct abd *data, uint64_t size, zio_type_t type, zio_priority_t priority,
enum zio_flag flags, zio_done_func_t *done, void *private);
enum zio_flag flags, zio_done_func_t *done, void *priv);

extern void zio_vdev_io_bypass(zio_t *zio);
extern void zio_vdev_io_reissue(zio_t *zio);
Expand Down
3 changes: 2 additions & 1 deletion lib/libspl/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ libspl_assert(const char *buf, const char *file, const char *func, int line)

/* printf version of libspl_assert */
static inline void
libspl_assertf(const char *file, const char *func, int line, char *format, ...)
libspl_assertf(const char *file, const char *func, int line,
const char *format, ...)
{
va_list args;

Expand Down
2 changes: 1 addition & 1 deletion lib/libspl/include/umem.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ umem_cache_create(
{
umem_cache_t *cp;

cp = umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT);
cp = (umem_cache_t *)umem_alloc(sizeof (umem_cache_t), UMEM_DEFAULT);
if (cp) {
strlcpy(cp->cache_name, name, UMEM_CACHE_NAMELEN);
cp->cache_bufsize = bufsize;
Expand Down
2 changes: 1 addition & 1 deletion lib/libzfs/os/freebsd/libzfs_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ zpool_relabel_disk(libzfs_handle_t *hdl, const char *path, const char *msg)
}

int
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
return (0);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/libzfs/os/linux/libzfs_pool_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ zpool_label_name(char *label_name, int label_size)
* stripped of any leading /dev path.
*/
int
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, const char *name)
{
char path[MAXPATHLEN];
struct dk_gpt *vtoc;
Expand Down
14 changes: 7 additions & 7 deletions module/os/linux/zfs/spa_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,11 @@ spa_tx_assign_update(kstat_t *ksp, int rw)

if (rw == KSTAT_WRITE) {
for (i = 0; i < shk->count; i++)
((kstat_named_t *)shk->private)[i].value.ui64 = 0;
((kstat_named_t *)shk->priv)[i].value.ui64 = 0;
}

for (i = shk->count; i > 0; i--)
if (((kstat_named_t *)shk->private)[i-1].value.ui64 != 0)
if (((kstat_named_t *)shk->priv)[i-1].value.ui64 != 0)
break;

ksp->ks_ndata = i;
Expand All @@ -504,12 +504,12 @@ spa_tx_assign_init(spa_t *spa)

shk->count = 42; /* power of two buckets for 1ns to 2,199s */
shk->size = shk->count * sizeof (kstat_named_t);
shk->private = kmem_alloc(shk->size, KM_SLEEP);
shk->priv = kmem_alloc(shk->size, KM_SLEEP);

name = kmem_asprintf("zfs/%s", spa_name(spa));

for (i = 0; i < shk->count; i++) {
ks = &((kstat_named_t *)shk->private)[i];
ks = &((kstat_named_t *)shk->priv)[i];
ks->data_type = KSTAT_DATA_UINT64;
ks->value.ui64 = 0;
(void) snprintf(ks->name, KSTAT_STRLEN, "%llu ns",
Expand All @@ -522,7 +522,7 @@ spa_tx_assign_init(spa_t *spa)

if (ksp) {
ksp->ks_lock = &shk->lock;
ksp->ks_data = shk->private;
ksp->ks_data = shk->priv;
ksp->ks_ndata = shk->count;
ksp->ks_data_size = shk->size;
ksp->ks_private = spa;
Expand All @@ -542,7 +542,7 @@ spa_tx_assign_destroy(spa_t *spa)
if (ksp)
kstat_delete(ksp);

kmem_free(shk->private, shk->size);
kmem_free(shk->priv, shk->size);
mutex_destroy(&shk->lock);
}

Expand All @@ -555,7 +555,7 @@ spa_tx_assign_add_nsecs(spa_t *spa, uint64_t nsecs)
while (((1ULL << idx) < nsecs) && (idx < shk->size - 1))
idx++;

atomic_inc_64(&((kstat_named_t *)shk->private)[idx].value.ui64);
atomic_inc_64(&((kstat_named_t *)shk->priv)[idx].value.ui64);
}

/*
Expand Down

0 comments on commit 26a0ce5

Please sign in to comment.