Just for sanity's sake, I will take another look at this change and
see if there's another way to handle it.
On Thu, 24 Jan 2019, Paul Goyette wrote:
On Thu, 24 Jan 2019, matthew green wrote:
Module Name: src
Committed By: pgoyette
Date: Thu Jan 24 04:24:52 UTC 2019
Modified Files:
src/sys/compat/netbsd32 [pgoyette-compat]: netbsd32_sysctl.c
Log Message:
Use the hook to get the value of machine32
hm. why does the module need to use the hook? doesn't it know the
value internally, since it has to publish it via the hook?
i don't understand the value of using hooks inside the publisher.
they are useful for external consumers, i thought.
In this case the symbol is defined as __weak and might not exist. So
we use a hook function to return a value if the hook has been set, or
a default value if the hook has not been set. The hook's struct
itself is always present/allocated.
I suppose I could have avoided the hook by simply having another
machine32_ptr variable, rather than a hook function. But I wasn't
totally clear on whether there were any race conditions during a
module unload which could result in retrieving a pointer to a value
which just got removed from memory.
Of course, if we had a reasonable way of dealing with weak symbols,
this mess would not be needed.
+------------------+--------------------------+----------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:
|
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com
|
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org
|
+------------------+--------------------------+----------------------------+
+------------------+--------------------------+----------------------------+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| (Retired) | FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+------------------+--------------------------+----------------------------+