Changeset View
Standalone View
sys/contrib/zstd/lib/freebsd/assert.h
- This file was added.
/* This file is in the public domain */ | |||||
#include <sys/systm.h> | |||||
imp: this looks unrelated. | |||||
Not Done Inline ActionsOh, I missed the last line... why did you need to copy this? imp: Oh, I missed the last line... why did you need to copy this? | |||||
Not Done Inline Actionssrc/sys/contrib/zstd/lib/common/xxhash.h:1354 When __STDC_VERSION__ >= 201112L, we need assert.h. However, header files like stdio.h is not included from src/include but we mock userspace header files by creating an equivalent to src/sys/contrib/zstd/lib/freebsd. This has been done since zstd was first imported to kernel in d3692a4dee4d6ff0926365bcf95bbedb039ea70d. assert() is a macro function so I though copying and paste it to src/sys/contrib/zstd/lib/freebsd would be better than integrating assert() in zstd_kfreebsd.h minsoochoo0122_proton.me: [[ https://github.com/facebook/zstd/blob/v1.5.2/lib/common/xxhash.h#L1521 |… | |||||
Not Done Inline ActionsIf this is really needed, could this file just`#include "../../../../include/assert.h" instead of copying the file? I guess the alternative would be to modify the xxhash.h file to use _Static_assert instead of including <assert.h>? arichardson: If this is really needed, could this file just`#include "../../../../include/assert.h" instead… | |||||
Not Done Inline ActionsIMO we should separate kernel-specific codes from user space as sys/contrib is separate from contrib. minsoochoo0122_proton.me: IMO we should separate kernel-specific codes from user space as `sys/contrib` is separate from… | |||||
Not Done Inline ActionsActually, what I'd like to do for the kernel is just go ahead and define static_assert() in <sys/systm.h> (really <sys/kassert.h>) instead of requiring the use of _Static_assert in the kernel. The intention of C11 from my reading is that code should really be using static_assert and that _Static_assert is just a shim so that <assert.h> can define the wrapper macro. Honestly I'd prefer it if for the kernel if we eventually too a similar route with defining things like alignof in the kernel always and not having to use the more obfuscated _Alignof type keywords. In the case of static_assert fixing that would probably mean we wouldn't need this hack at all for zstd to compile in the kernel. jhb: Actually, what I'd like to do for the kernel is just go ahead and define `static_assert()` in… | |||||
Not Done Inline Actions_Static_assert() is a compiler extension in clang, so I guess there is no need to redefine it. minsoochoo0122_proton.me: `_Static_assert()` is a [[ https://clang.llvm.org/docs/LanguageExtensions.html#c11-static… | |||||
Not Done Inline Actions#if !__has_extension(c_static_assert) #if (defined(__cplusplus) && __cplusplus >= 201103L) || \ __has_extension(cxx_static_assert) #define _Static_assert(x, y) static_assert(x, y) #elif __GNUC_PREREQ__(4,6) && !defined(__cplusplus) /* Nothing, gcc 4.6 and higher has _Static_assert built-in */ #elif defined(__COUNTER__) ... minsoochoo0122_proton.me: [[ https://github.com/freebsd/freebsd-src/blob/main/sys/sys/cdefs.h#L241 | sys/cdefs.h ]]
```… | |||||
Done Inline ActionsYes, but <sys/cdefs.h> is a generic header for more than just the kernel. We define kernel-specific things in <sys/systm.h>. And I think we should just #define static_assert to _Static_assert in <sys/systm.h> under #ifdef KERNEL. jhb: Yes, but <sys/cdefs.h> is a generic header for more than just the kernel. We define kernel… |
this looks unrelated.