mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
libspl: hide global data objects
Currently libspl is a static archive that is linked into multiple shared objects, which then re-export its symbols. We intend to fix this soon. For the moment though, most programs shipped with OpenZFS depend on two or more of these shared objects, and see the same symbols twice. For functions this is not a problem, as they do not have any mutable state and so the linker can simply select the first one and use that for all. For global data objects however, each shared object will have direct (non-relocatable) references to its own instance of the symbol, such that changes on one will not necessarily be seen by the other. While this shouldn't be a problem in practice as these reexported interfaces are not supposed to be used, they are technically undefined behaviour in C (C17 6.9.2) and are reported by ASAN as a violation of C++'s "One Definition Rule". To fix this, we hide these globals inside their compilation units, and add access functions and macros as appropriate to preserve the existing API (though not ABI). Sponsored-by: https://despairlabs.com/sponsor/ Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rob Norris <robn@despairlabs.com> Closes #17861
This commit is contained in:
committed by
Brian Behlendorf
parent
e282e98e79
commit
4d451bae8a
@@ -31,9 +31,6 @@
|
||||
|
||||
#include <sys/utsname.h>
|
||||
|
||||
extern const char *random_path;
|
||||
extern const char *urandom_path;
|
||||
|
||||
/*
|
||||
* Hostname information
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#ifndef _LIBSPL_SYS_SYSTM_H
|
||||
#define _LIBSPL_SYS_SYSTM_H
|
||||
|
||||
extern uint64_t physmem;
|
||||
uint64_t libspl_physmem(void);
|
||||
|
||||
#define physmem libspl_physmem()
|
||||
|
||||
#endif
|
||||
|
||||
@@ -86,8 +86,11 @@ typedef struct taskq {
|
||||
|
||||
#define TASKQID_INVALID ((taskqid_t)0)
|
||||
|
||||
extern taskq_t *system_taskq;
|
||||
extern taskq_t *system_delay_taskq;
|
||||
extern taskq_t *_system_taskq(void);
|
||||
extern taskq_t *_system_delay_taskq(void);
|
||||
|
||||
#define system_taskq _system_taskq()
|
||||
#define system_delay_taskq _system_delay_taskq()
|
||||
|
||||
extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
|
||||
extern taskq_t *taskq_create_synced(const char *, int, pri_t, int, int, uint_t,
|
||||
|
||||
@@ -58,11 +58,9 @@ typedef pthread_t kthread_t;
|
||||
#define current_is_reclaim_thread() (0)
|
||||
|
||||
/* in libzpool, p0 exists only to have its address taken */
|
||||
typedef struct proc {
|
||||
uintptr_t this_is_never_used_dont_dereference_it;
|
||||
} proc_t;
|
||||
typedef void (proc_t)(void);
|
||||
extern void p0(void);
|
||||
|
||||
extern struct proc p0;
|
||||
#define curproc (&p0)
|
||||
|
||||
#define PS_NONE -1
|
||||
|
||||
Reference in New Issue
Block a user