The BSD source tree defines __unused and __unused2 macros
that map to __attribute__((unused)) and __attribute__((__unused__))
respectively. This caused conflicts in around 10 musl headers
that use field names like __unused or __unused2. For that reason
initialy we renamed those fields to ___unused and ___unused2
respecively in those musl headers and that prevents us from
replacing those copied and modified headers with symlinks
to original musl ones.

So this patch changes BSD macro names from __unused and __unused2
to __bsd_unused and __bsd_unused2 to avoid such conflict. Hopefully
musl will never start using field names like __bsd_unused. Alternatively
we could have modified BSD source files to use __attribute__((unused))
directly without any macros.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 bsd/porting/bus.h                                      |  2 +-
 bsd/porting/netport.h                                  |  2 +-
 bsd/sys/cddl/compat/opensolaris/kern/opensolaris.c     |  2 +-
 .../cddl/compat/opensolaris/kern/opensolaris_policy.c  |  6 +++---
 .../cddl/compat/opensolaris/kern/opensolaris_taskq.c   | 10 +++++-----
 bsd/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c |  2 +-
 .../cddl/compat/opensolaris/kern/opensolaris_zone.c    |  4 ++--
 bsd/sys/cddl/compat/opensolaris/sys/vfs.h              |  2 +-
 .../cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c   |  6 +++---
 .../contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c  |  2 +-
 .../contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c  |  2 +-
 bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.c |  4 ++--
 bsd/sys/dev/hyperv/vmbus/hyperv.cc                     |  6 +++---
 bsd/sys/dev/random/randomdev_soft.cc                   |  2 +-
 bsd/sys/sys/tree.h                                     |  4 ++--
 bsd/sys/xen/evtchn.cc                                  |  2 +-
 bsd/sys/xen/xenbus/xenbusb.cc                          | 10 +++++-----
 bsd/sys/xen/xenbus/xenbusb.h                           |  2 +-
 bsd/sys/xen/xenstore/xenstore.cc                       |  6 +++---
 19 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/bsd/porting/bus.h b/bsd/porting/bus.h
index 053c451c..3440e715 100644
--- a/bsd/porting/bus.h
+++ b/bsd/porting/bus.h
@@ -32,7 +32,7 @@ typedef void (*driver_intr_t)(void *arg);
 
 // should be in netporting or somewhere else, but it conflicts with other
 // definitions. unused seems to be quite a common name
-#define __unused    __attribute__((unused))
+#define __bsd_unused    __attribute__((unused))
 
 // not used
 enum intr_type {
diff --git a/bsd/porting/netport.h b/bsd/porting/netport.h
index a4333700..cb93da28 100644
--- a/bsd/porting/netport.h
+++ b/bsd/porting/netport.h
@@ -51,7 +51,7 @@ static inline int     modfind(const char *_name) { return 0; }
 
 #define __dead2         __attribute__((__noreturn__))
 #define __pure2         __attribute__((__const__))
-#define __unused2       __attribute__((__unused__))
+#define __bsd_unused2   __attribute__((__unused__))
 #define __used          __attribute__((__used__))
 #define __packed        __attribute__((__packed__))
 #define __aligned(x)    __attribute__((__aligned__(x)))
diff --git a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris.c 
b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris.c
index 786a9fe0..d759bfdc 100644
--- a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris.c
+++ b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris.c
@@ -76,7 +76,7 @@ SYSUNINIT(opensolaris_unregister, SI_SUB_OPENSOLARIS, 
SI_ORDER_FIRST, opensolari
 
 #if 0
 static int
-opensolaris_modevent(module_t mod __unused2, int type, void *data __unused2)
+opensolaris_modevent(module_t mod __bsd_unused2, int type, void *data 
__bsd_unused2)
 {
        int error = 0;
 
diff --git a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c 
b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
index 5a14d583..c05f15e9 100644
--- a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
+++ b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_policy.c
@@ -53,7 +53,7 @@ secpolicy_zfs(cred_t *cr)
 }
 
 int
-secpolicy_sys_config(cred_t *cr, int checkonly __unused2)
+secpolicy_sys_config(cred_t *cr, int checkonly __bsd_unused2)
 {
 
        return (0);
@@ -67,7 +67,7 @@ secpolicy_zinject(cred_t *cr)
 }
 
 int
-secpolicy_fs_unmount(cred_t *cr, struct mount *vfsp __unused2)
+secpolicy_fs_unmount(cred_t *cr, struct mount *vfsp __bsd_unused2)
 {
 
        return (0);
@@ -170,7 +170,7 @@ secpolicy_vnode_setids_setgids(vnode_t *vp, cred_t *cr, 
gid_t gid)
 
 int
 secpolicy_vnode_setid_retain(vnode_t *vp, cred_t *cr,
-    boolean_t issuidroot __unused2)
+    boolean_t issuidroot __bsd_unused2)
 {
 
        return (0);
diff --git a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c 
b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
index c34f5173..9711bb4f 100644
--- a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
+++ b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_taskq.c
@@ -59,8 +59,8 @@ system_taskq_fini(void *arg)
 SYSUNINIT(system_taskq_fini, SI_SUB_CONFIGURE, SI_ORDER_ANY, 
system_taskq_fini, NULL);
 
 taskq_t *
-taskq_create(const char *name, int nthreads, pri_t pri, int minalloc __unused2,
-    int maxalloc __unused2, uint_t flags)
+taskq_create(const char *name, int nthreads, pri_t pri, int minalloc 
__bsd_unused2,
+    int maxalloc __bsd_unused2, uint_t flags)
 {
        taskq_t *tq;
 
@@ -77,7 +77,7 @@ taskq_create(const char *name, int nthreads, pri_t pri, int 
minalloc __unused2,
 
 taskq_t *
 taskq_create_proc(const char *name, int nthreads, pri_t pri, int minalloc,
-    int maxalloc, proc_t *proc __unused2, uint_t flags)
+    int maxalloc, proc_t *proc __bsd_unused2, uint_t flags)
 {
 
        return (taskq_create(name, nthreads, pri, minalloc, maxalloc, flags));
@@ -99,7 +99,7 @@ taskq_member(taskq_t *tq, kthread_t *thread)
 }
 
 static void
-taskq_run(void *arg, int pending __unused2)
+taskq_run(void *arg, int pending __bsd_unused2)
 {
        struct ostask *task = arg;
 
@@ -140,7 +140,7 @@ taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, 
uint_t flags)
 #define        TASKQ_MAGIC     0x74541c
 
 static void
-taskq_run_safe(void *arg, int pending __unused2)
+taskq_run_safe(void *arg, int pending __bsd_unused2)
 {
        struct ostask *task = arg;
 
diff --git a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c 
b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
index a2532f80..a2814778 100644
--- a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
+++ b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c
@@ -41,7 +41,7 @@ MALLOC_DECLARE(M_MOUNT);
 
 void
 vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
-    int flags __unused)
+    int flags __bsd_unused)
 {
        struct vfsopt *opt;
        size_t namesize;
diff --git a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c 
b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c
index 55b19067..2c6791e8 100644
--- a/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c
+++ b/bsd/sys/cddl/compat/opensolaris/kern/opensolaris_zone.c
@@ -239,14 +239,14 @@ zone_get_hostid(void *ptr)
 }
 
 static void
-zone_sysinit(void *arg __unused)
+zone_sysinit(void *arg __bsd_unused)
 {
 
        zone_slot = osd_jail_register(zone_destroy, NULL);
 }
 
 static void
-zone_sysuninit(void *arg __unused)
+zone_sysuninit(void *arg __bsd_unused)
 {
 
        osd_jail_deregister(zone_slot);
diff --git a/bsd/sys/cddl/compat/opensolaris/sys/vfs.h 
b/bsd/sys/cddl/compat/opensolaris/sys/vfs.h
index 2af7e497..648a50d6 100644
--- a/bsd/sys/cddl/compat/opensolaris/sys/vfs.h
+++ b/bsd/sys/cddl/compat/opensolaris/sys/vfs.h
@@ -101,7 +101,7 @@ typedef struct mntopts {
 } mntopts_t;
 
 void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
-    int flags __unused);
+    int flags __bsd_unused);
 void vfs_clearmntopt(vfs_t *vfsp, const char *name);
 int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp);
 int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype,
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c 
b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
index 32edb485..15b7a59d 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
@@ -2479,7 +2479,7 @@ arc_kmem_reap_now(arc_reclaim_strategy_t strat)
 }
 
 static void
-arc_reclaim_thread(void *dummy __unused2)
+arc_reclaim_thread(void *dummy __bsd_unused2)
 {
        clock_t                 growtime = 0;
        arc_reclaim_strategy_t  last_reclaim = ARC_RECLAIM_CONS;
@@ -3883,7 +3883,7 @@ static kmutex_t arc_lowmem_lock;
 static eventhandler_tag arc_event_lowmem = NULL;
 
 size_t
-arc_lowmem(void *arg __unused2, int howto __unused2)
+arc_lowmem(void *arg __bsd_unused2, int howto __bsd_unused2)
 {
        uint64_t old_arcsize, new_arcsize;
        size_t freed = 0;
@@ -4966,7 +4966,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, 
uint64_t target_sz)
  * heart of the L2ARC.
  */
 static void
-l2arc_feed_thread(void *dummy __unused2)
+l2arc_feed_thread(void *dummy __bsd_unused2)
 {
        callb_cpr_t cpr;
        l2arc_dev_t *dev;
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c 
b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
index c972038d..9fef9088 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
@@ -146,7 +146,7 @@ vdev_geom_attach(struct g_provider *pp)
 }
 
 static void
-vdev_geom_detach(void *arg, int flag __unused)
+vdev_geom_detach(void *arg, int flag __bsd_unused)
 {
        struct g_geom *gp;
        struct g_consumer *cp;
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c 
b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index c2d500ce..16df8fc0 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -5667,7 +5667,7 @@ _info(struct modinfo *modinfop)
 #endif /* sun */
 
 static int
-zfs_modevent(module_t mod, int type, void *unused __unused)
+zfs_modevent(module_t mod, int type, void *unused __bsd_unused)
 {
        int error = 0;
 
diff --git a/bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.c 
b/bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
index d0884d51..3930c282 100644
--- a/bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
+++ b/bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.c
@@ -97,7 +97,7 @@ callb_cpr_t   callb_cprinfo_safe = {
  * Init all callb tables in the system.
  */
 void
-callb_init(void *dummy __unused2)
+callb_init(void *dummy __bsd_unused2)
 {
        callb_table.ct_busy = 0;        /* mark table open for additions */
        mutex_init(&callb_safe_mutex, NULL, MUTEX_DEFAULT, NULL);
@@ -105,7 +105,7 @@ callb_init(void *dummy __unused2)
 }
 
 void
-callb_fini(void *dummy __unused2)
+callb_fini(void *dummy __bsd_unused2)
 {
        callb_t *cp;
        int i;
diff --git a/bsd/sys/dev/hyperv/vmbus/hyperv.cc 
b/bsd/sys/dev/hyperv/vmbus/hyperv.cc
index 446477be..9919c008 100644
--- a/bsd/sys/dev/hyperv/vmbus/hyperv.cc
+++ b/bsd/sys/dev/hyperv/vmbus/hyperv.cc
@@ -154,7 +154,7 @@ hypercall_memfree()
 }
 
 void
-hypercall_create(void *arg __unused)
+hypercall_create(void *arg __bsd_unused)
 {
     uint64_t hc, hc_orig;
 
@@ -195,7 +195,7 @@ hypercall_create(void *arg __unused)
 SYSINIT(hypercall_ctor, SI_SUB_DRIVERS, SI_ORDER_FIRST, hypercall_create, 
NULL);
 
 void
-hypercall_destroy(void *arg __unused)
+hypercall_destroy(void *arg __bsd_unused)
 {
     uint64_t hc;
 
@@ -212,4 +212,4 @@ hypercall_destroy(void *arg __unused)
 }
 SYSUNINIT(hypercall_dtor, SI_SUB_DRIVERS, SI_ORDER_FIRST, hypercall_destroy,
     NULL);
-#endif
\ No newline at end of file
+#endif
diff --git a/bsd/sys/dev/random/randomdev_soft.cc 
b/bsd/sys/dev/random/randomdev_soft.cc
index 2b7d7def..5428e9eb 100644
--- a/bsd/sys/dev/random/randomdev_soft.cc
+++ b/bsd/sys/dev/random/randomdev_soft.cc
@@ -292,7 +292,7 @@ randomdev_flush_reseed(void)
 
 #ifndef __OSV__
 static int
-randomdev_modevent(module_t mod __unused, int type, void *unused __unused)
+randomdev_modevent(module_t mod __bsd_unused, int type, void *unused 
__bsd_unused)
 {
 
        switch (type) {
diff --git a/bsd/sys/sys/tree.h b/bsd/sys/sys/tree.h
index 1cce7278..4e4f32ce 100644
--- a/bsd/sys/sys/tree.h
+++ b/bsd/sys/sys/tree.h
@@ -381,7 +381,7 @@ struct {                                                    
        \
 #define        RB_PROTOTYPE(name, type, field, cmp)                            
\
        RB_PROTOTYPE_INTERNAL(name, type, field, cmp,)
 #define        RB_PROTOTYPE_STATIC(name, type, field, cmp)                     
\
-       RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static)
+       RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __bsd_unused static)
 #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr)            \
 attr void name##_RB_INSERT_COLOR(struct name *, struct type *);                
\
 attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
@@ -400,7 +400,7 @@ attr struct type *name##_RB_MINMAX(struct name *, int);     
                \
 #define        RB_GENERATE(name, type, field, cmp)                             
\
        RB_GENERATE_INTERNAL(name, type, field, cmp,)
 #define        RB_GENERATE_STATIC(name, type, field, cmp)                      
\
-       RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static)
+       RB_GENERATE_INTERNAL(name, type, field, cmp, __bsd_unused static)
 #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr)             \
 attr void                                                              \
 name##_RB_INSERT_COLOR(struct name *head, struct type *elm)            \
diff --git a/bsd/sys/xen/evtchn.cc b/bsd/sys/xen/evtchn.cc
index a33ecf6a..733f0993 100644
--- a/bsd/sys/xen/evtchn.cc
+++ b/bsd/sys/xen/evtchn.cc
@@ -1021,7 +1021,7 @@ void irq_resume(void)
 }
 
 void 
-evtchn_init(void *dummy __unused)
+evtchn_init(void *dummy __bsd_unused)
 {
        int i, cpu;
        struct xenpic_intsrc *pin, *tpin;
diff --git a/bsd/sys/xen/xenbus/xenbusb.cc b/bsd/sys/xen/xenbus/xenbusb.cc
index 07b1301b..953aff71 100644
--- a/bsd/sys/xen/xenbus/xenbusb.cc
+++ b/bsd/sys/xen/xenbus/xenbusb.cc
@@ -131,7 +131,7 @@ xenbusb_free_child_ivars(struct xenbus_device_ivars *ivars)
  */
 static void
 xenbusb_otherend_watch_cb(struct xs_watch *watch, const char **vec,
-    unsigned int vec_size __unused)
+    unsigned int vec_size __bsd_unused)
 {
        struct xenbus_device_ivars *ivars;
        device_t child;
@@ -169,7 +169,7 @@ xenbusb_otherend_watch_cb(struct xs_watch *watch, const 
char **vec,
  */
 static void
 xenbusb_local_watch_cb(struct xs_watch *watch, const char **vec,
-    unsigned int vec_size __unused)
+    unsigned int vec_size __bsd_unused)
 {
        struct xenbus_device_ivars *ivars;
        device_t child;
@@ -490,7 +490,7 @@ xenbusb_probe_children(device_t dev)
  *                 be run.
  */
 static void
-xenbusb_probe_children_cb(void *arg, int pending __unused)
+xenbusb_probe_children_cb(void *arg, int pending __bsd_unused)
 {
        device_t dev = (device_t)arg;
 
@@ -578,7 +578,7 @@ out:
  * \param arg  Unused configuration hook callback argument.
  */
 static void
-xenbusb_nop_confighook_cb(void *arg __unused)
+xenbusb_nop_confighook_cb(void *arg __bsd_unused)
 {
 }
 
@@ -610,7 +610,7 @@ xenbusb_release_confighook(struct xenbusb_softc *xbs)
 /*--------------------------- Public Functions 
-------------------------------*/
 /*--------- API comments for these methods can be found in xenbusb.h 
---------*/
 void
-xenbusb_identify(driver_t *driver __unused, device_t parent)
+xenbusb_identify(driver_t *driver __bsd_unused, device_t parent)
 {
        /*
         * A single instance of each bus type for which we have a driver
diff --git a/bsd/sys/xen/xenbus/xenbusb.h b/bsd/sys/xen/xenbus/xenbusb.h
index dd7d7a1e..b1674c6c 100644
--- a/bsd/sys/xen/xenbus/xenbusb.h
+++ b/bsd/sys/xen/xenbus/xenbusb.h
@@ -181,7 +181,7 @@ struct xenbus_device_ivars {
  * \param driver  The driver performing this identify action.
  * \param parent  The NewBus parent device for any devices this method adds.
  */
-void xenbusb_identify(driver_t *driver __unused, device_t parent);
+void xenbusb_identify(driver_t *driver __bsd_unused, device_t parent);
 
 /**
  * \brief Perform common XenBus bus attach processing.
diff --git a/bsd/sys/xen/xenstore/xenstore.cc b/bsd/sys/xen/xenstore/xenstore.cc
index 8ff11fa0..e345f218 100644
--- a/bsd/sys/xen/xenstore/xenstore.cc
+++ b/bsd/sys/xen/xenstore/xenstore.cc
@@ -378,7 +378,7 @@ xs_join(const char *dir, const char *name)
  * service has modified the queues.
  */
 static void
-xs_intr(void * arg __unused /*__attribute__((unused))*/)
+xs_intr(void * arg __bsd_unused /*__attribute__((unused))*/)
 {
 
        /*
@@ -701,7 +701,7 @@ xs_process_msg(enum xsd_sockmsg_type *type)
  * and processes and received messages.
  */
 void
-xs_rcv_thread(void *arg __unused)
+xs_rcv_thread(void *arg __bsd_unused)
 {
        int error;
        enum xsd_sockmsg_type type;
@@ -1243,7 +1243,7 @@ xs_suspend(device_t dev)
  * Resume XenStore operations after this VM is resumed.
  */
 static int
-xs_resume(device_t dev __unused)
+xs_resume(device_t dev __bsd_unused)
 {
        struct xs_watch *watch;
        char token[sizeof(watch) * 2 + 1];
-- 
2.25.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/20200827045612.29035-1-jwkozaczuk%40gmail.com.

Reply via email to