Please sign in to comment.
Revert "sys/util.h: helper macro to perform pointer difference"
This reverts commit 755cc64. This approach is problematic in several ways. First, `intptr_t` could cause undefined behavior in the subtraction when the pointer converts to a negative value. Except in weird cases where the sign of the pointer identifies a memory domain (like kernel vs userspace) I'm unaware of any valid use of `intptr_t`. Second, this macro was created to address a special need that cannot rely on defined behavior: i.e. to ensure that data definitions are placed in contiguous space and access is provided through linker-defined symbols, for which the language required alignment and continuity is not guaranteed. A macro that calculates the span between linker symbols has very different semantics than one that calculates the difference between pointers. Replace the global PTR_DIFF with a documented local macro that tests what's necessary without risking integer overflow. Signed-off-by: Peter A. Bigot <email@example.com>
- Loading branch information...
Showing with 13 additions and 11 deletions.