History log of /netbsd-current/sys/sys/cdefs.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.163 12-May-2024 rillig

sys/sys: remove CONSTCOND comment from do-while-0 loop

Lint doesn't need this comment anymore, as there is nothing surprising
or unusual about this idiom.


# 1.162 11-May-2024 riastradh

sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:

- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
and without _NETBSD_SOURCE.

- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
so this works without stdint.h.

No functional change intended.


# 1.161 01-May-2024 rillig

sys/cdefs.h: pass __aligned to lint

Lint could parse _Alignas and __attribute__((__aligned__(4))) previously
but simply ignored them. Since today, they affect the layout of struct
and union.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.160 30-Apr-2023 riastradh

sys/cdefs.h: New __MACROUSE for macros to type-check arguments.

This way, if there's a macro F(x) with a conditional definition --
e.g., conditional on DIAGNOSTIC or KDTRACE_HOOKS -- it can do
__MACROUSE(x) in the definition that's supposed to compile away,
without triggering `variable set but not used' errors, while still
catching type errors in the expression x. But there's no cost or
side effects incurred in the generated code because the value is not
computed.

This should be the same as __USE, but I haven't figured out how to
make it work for both bit fields (which are likely to appear in macro
arguments) and aggregates (structs/unions, which are likely to appear
as variable declarations), so for now we use two separate macros.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.159 22-Jan-2022 skrll

Add __MASK(3)

__MASK(n): first n bits all set, where __MASK(4) == 0b1111.


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.162 11-May-2024 riastradh

sys/cdefs.h: Make various macros work more robustly.

Use predefined __-namespace macros inside __BIT, __type_min,
__type_max, and __type_fit:

- Use __CHAR_BIT__ instead of NBBY so this works without sys/types.h
and without _NETBSD_SOURCE.

- Use __INTMAX_TYPE__, __UINTMAX_TYPE__ instead of intmax_t, uintmax_t
so this works without stdint.h.

No functional change intended.


# 1.161 01-May-2024 rillig

sys/cdefs.h: pass __aligned to lint

Lint could parse _Alignas and __attribute__((__aligned__(4))) previously
but simply ignored them. Since today, they affect the layout of struct
and union.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.160 30-Apr-2023 riastradh

sys/cdefs.h: New __MACROUSE for macros to type-check arguments.

This way, if there's a macro F(x) with a conditional definition --
e.g., conditional on DIAGNOSTIC or KDTRACE_HOOKS -- it can do
__MACROUSE(x) in the definition that's supposed to compile away,
without triggering `variable set but not used' errors, while still
catching type errors in the expression x. But there's no cost or
side effects incurred in the generated code because the value is not
computed.

This should be the same as __USE, but I haven't figured out how to
make it work for both bit fields (which are likely to appear in macro
arguments) and aggregates (structs/unions, which are likely to appear
as variable declarations), so for now we use two separate macros.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.159 22-Jan-2022 skrll

Add __MASK(3)

__MASK(n): first n bits all set, where __MASK(4) == 0b1111.


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.161 01-May-2024 rillig

sys/cdefs.h: pass __aligned to lint

Lint could parse _Alignas and __attribute__((__aligned__(4))) previously
but simply ignored them. Since today, they affect the layout of struct
and union.


Revision tags: thorpej-ifq-base thorpej-altq-separation-base
# 1.160 30-Apr-2023 riastradh

sys/cdefs.h: New __MACROUSE for macros to type-check arguments.

This way, if there's a macro F(x) with a conditional definition --
e.g., conditional on DIAGNOSTIC or KDTRACE_HOOKS -- it can do
__MACROUSE(x) in the definition that's supposed to compile away,
without triggering `variable set but not used' errors, while still
catching type errors in the expression x. But there's no cost or
side effects incurred in the generated code because the value is not
computed.

This should be the same as __USE, but I haven't figured out how to
make it work for both bit fields (which are likely to appear in macro
arguments) and aggregates (structs/unions, which are likely to appear
as variable declarations), so for now we use two separate macros.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.159 22-Jan-2022 skrll

Add __MASK(3)

__MASK(n): first n bits all set, where __MASK(4) == 0b1111.


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-4-RELEASE netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.160 30-Apr-2023 riastradh

sys/cdefs.h: New __MACROUSE for macros to type-check arguments.

This way, if there's a macro F(x) with a conditional definition --
e.g., conditional on DIAGNOSTIC or KDTRACE_HOOKS -- it can do
__MACROUSE(x) in the definition that's supposed to compile away,
without triggering `variable set but not used' errors, while still
catching type errors in the expression x. But there's no cost or
side effects incurred in the generated code because the value is not
computed.

This should be the same as __USE, but I haven't figured out how to
make it work for both bit fields (which are likely to appear in macro
arguments) and aggregates (structs/unions, which are likely to appear
as variable declarations), so for now we use two separate macros.


Revision tags: netbsd-10-base bouyer-sunxi-drm-base
# 1.159 22-Jan-2022 skrll

Add __MASK(3)

__MASK(n): first n bits all set, where __MASK(4) == 0b1111.


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.159 22-Jan-2022 skrll

Add __MASK(3)

__MASK(n): first n bits all set, where __MASK(4) == 0b1111.


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.158 14-Dec-2021 christos

don't gut restrict for lint.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base
# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.157 23-Apr-2021 skrll

Provide __CONCATn macros that take from 3 to 8 arguments and concatenate
them.

I didn't provide the non-STDC versions


Revision tags: thorpej-cfargs-base thorpej-futex-base
# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.156 16-Jan-2021 chs

remove unused "_DIAGNOSTIC" option and opt_diagnostic.h.
note that this is unrelated to the widely used "DIAGNOSTIC" option.


Revision tags: thorpej-futex-base
# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

branches: 1.154.2;
For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.155 04-Dec-2020 christos

add __null_sentinel (from FreeBSD)


Revision tags: thorpej-futex-base bouyer-xenpvh-base2
# 1.154 22-Apr-2020 rin

For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.154 22-Apr-2020 rin

For NO_KERNEL_RCSIDS, strip __RCSID() also for src/common/*.


Revision tags: phil-wifi-20200421 bouyer-xenpvh-base1
# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

branches: 1.151.2;
Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.153 17-Apr-2020 joerg

Don't use typedef at all for __CTASSERT1.


# 1.152 17-Apr-2020 kamil

Fix __CTASSERT1() in sys/cdefs.h for recent Clang/LLVM

Clang now implements a restriction on giving non-C-compatible anonymous
structs a typedef name for linkage purposes, as described in C++ committee
paper `P1766R1 <http://wg21.link/p1766r1>'.

https://reviews.llvm.org/D74103


Revision tags: phil-wifi-20200411 bouyer-xenpvh-base phil-wifi-20200406
# 1.151 21-Mar-2020 kamil

Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: is-mlppp-base ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.151 21-Mar-2020 kamil

Expand the support of __no[sanitizer] attributes

Add support for RUMPKERNEL that can reuse these attributes in the same code.
These macros are not intended to be used by userland and are still disabled
there. They are a NetBSD specific extension.

Add proper support for clang and GCC.

Set __no[sanitizer] only under a sanitizer, as otherwise there are build
warnings about unused compiler attributes.

Reviewed by <maxv>


Revision tags: ad-namecache-base3 ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.150 08-Dec-2019 maxv

Fix __nomsan: missing opt_kmsan.h, and the attribute should be
kernel-memory.


Revision tags: phil-wifi-20191119
# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-0-RC1 netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.149 14-Nov-2019 maxv

Add support for Kernel Memory Sanitizer (kMSan). It detects uninitialized
memory used by the kernel at run time, and just like kASan and kCSan, it
is an excellent feature. It has already detected 38 uninitialized variables
in the kernel during my testing, which I have since discreetly fixed.

We use two shadows:
- "shad", to track uninitialized memory with a bit granularity (1:1).
Each bit set to 1 in the shad corresponds to one uninitialized bit of
real kernel memory.
- "orig", to track the origin of the memory with a 4-byte granularity
(1:1). Each uint32_t cell in the orig indicates the origin of the
associated uint32_t of real kernel memory.

The memory consumption of these shadows is consequent, so at least 4GB of
RAM is recommended to run kMSan.

The compiler inserts calls to specific __msan_* functions on each memory
access, to manage both the shad and the orig and detect uninitialized
memory accesses that change the execution flow (like an "if" on an
uninitialized variable).

We mark as uninit several types of memory buffers (stack, pools, kmem,
malloc, uvm_km), and check each buffer passed to copyout, copyoutstr,
bwrite, if_transmit_lock and DMA operations, to detect uninitialized memory
that leaves the system. This allows us to detect kernel info leaks in a way
that is more efficient and also more user-friendly than KLEAK.

Contrary to kASan, kMSan requires comprehensive coverage, ie we cannot
tolerate having one non-instrumented function, because this could cause
false positives. kMSan cannot instrument ASM functions, so I converted
most of them to __asm__ inlines, which kMSan is able to instrument. Those
that remain receive special treatment.

Contrary to kASan again, kMSan uses a TLS, so we must context-switch this
TLS during interrupts. We use different contexts depending on the interrupt
level.

The orig tracks precisely the origin of a buffer. We use a special encoding
for the orig values, and pack together in each uint32_t cell of the orig:
- a code designating the type of memory (Stack, Pool, etc), and
- a compressed pointer, which points either (1) to a string containing
the name of the variable associated with the cell, or (2) to an area
in the kernel .text section which we resolve to a symbol name + offset.

This encoding allows us not to consume extra memory for associating
information with each cell, and produces a precise output, that can tell
for example the name of an uninitialized variable on the stack, the
function in which it was pushed on the stack, and the function where we
accessed this uninitialized variable.

kMSan is available with LLVM, but not with GCC.

The code is organized in a way that is similar to kASan and kCSan, so it
means that other architectures than amd64 can be supported.


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.148 05-Nov-2019 maxv

Add Kernel Concurrency Sanitizer (kCSan) support. This sanitizer allows us
to detect race conditions at runtime. It is a variation of TSan that is
easy to implement and more suited to kernel internals, albeit theoretically
less precise than TSan's happens-before.

We do basically two things:

- On every KCSAN_NACCESSES (=2000) memory accesses, we create a cell
describing the access, and delay the calling CPU (10ms).

- On all memory accesses, we verify if the memory we're reading/writing
is referenced in a cell already.

The combination of the two means that, if for example cpu0 does a read that
is selected and cpu1 does a write at the same address, kCSan will fire,
because cpu1's write collides with cpu0's read cell.

The coverage of the instrumentation is the same as that of kASan. Also, the
code is organized in a way similar to kASan, so it is easy to add support
for more architectures than amd64. kCSan is compatible with KCOV.

Reviewed by Kamil.


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.147 16-Oct-2019 christos

Add and use __FPTRCAST, requested by uwe@


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.146 22-Sep-2019 kamil

Handle LSan/LLVM and LSan/GCC in __NO_LEAKS

__has_feature(leak_sanitizer) was merged with Clang/LLVM today:
https://reviews.llvm.org/D67719

GCC specific ifdef __SANITIZE_LEAK__ is pending in upstream review...
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg01270.html and can be
rejected as GCC upstream does not see value in feature parity with LLVM
sanitizers. For the time being this will be a NetBSD specific extension.


# 1.145 22-Sep-2019 kamil

Make __CTASSERT static assert again

Today GCC/Clang allow to specify typedef char[] with the dynamic VLA
property (as introduced in C99). This means that __CTASSERT(), when
misused with run-time semantics, was a dummy check generating either
1 or -1 size of typedef char[].

It was caught in runtime by kUBSan as -1 is size of VLA with unspecified
semantics in runtime (Undefined Behavior).

Use bit-field to enforce compile-time constant.

This approach has been inspired by the Perl variation of static_assert().


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.144 18-Sep-2019 kamil

Define __noubsan in sys/cdefs.h for KERNEL sanitization


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.143 15-Sep-2019 kamil

Define __NO_LEAKS in sys/cdefs.h

This preprocessor symbol is intended to be used with leak detecting
software, documenting leaks that are not important to be freed in the
default build version.


# 1.142 15-Sep-2019 kamil

Add Clang/LLVM specific feature/extension detection macros in sys/cdefs.h

These macros are not supported (as of now) with GCC and there is need to
maintain a fallback that evaluates to 0.


Revision tags: netbsd-9-base phil-wifi-20190609 isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2; 1.135.4;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: isaki-audio2-base
# 1.141 21-Feb-2019 christos

add a lint(1) comment to nothing.


# 1.140 27-Jan-2019 christos

lint understands attributes.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226
# 1.139 18-Dec-2018 skrll

Appease gcc error: comparison of unsigned expression < 0 is always false
when using __BITS(u_int, 0)


# 1.138 04-Dec-2018 kamil

Stop mangling __func__ for C++11 and newer

Drop local logic between GCC 2.4 and GCC 2.6 that used __PRETTY_FUNCTION__.
This caused __func__ to be redefined for all C++ programs and use a
different behavior than intended by the compiler (Clang and GCC).
__PRETTY_FUNCTION__ prints all the prototype not just function name,
contrary to __FUNCTION__ and __func__.

__func__ is now an integral part of C99 and C++11, shipped by a compiler.

This change aligns the behavior of C++ programs using __func__ to other
Operating Systems. The difference caused unnecessary fallout in regression
test suites in projects (LLVM, fish, ...).


Revision tags: pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906
# 1.137 22-Aug-2018 maxv

Add support for monitoring the stack with kASan. This allows us to detect
illegal memory accesses occuring there.

The compiler inlines a piece of code in each function that adds redzones
around the local variables and poisons them. The illegal accesses are then
detected using the usual kASan machinery.

The stack size is doubled, from 4 pages to 8 pages.

Several boot functions are marked with the __noasan flag, to prevent the
compiler from adding redzones in them (because we haven't yet initialized
kASan). The kasan_early_init function is called early at boot time to
quickly create the shadow for the current stack; after this is done, we
don't need __noasan anymore in the boot path.

We pass -fasan-shadow-offset=0xDFFF900000000000, because the compiler
wants to do
shad = shadow-offset + (addr >> 3)
and we do, in kasan_addr_to_shad
shad = KASAN_SHADOW_START + ((addr - CANONICAL_BASE) >> 3)
hence
shad = KASAN_SHADOW_START + (addr >> 3) - (CANONICAL_BASE >> 3)
= [KASAN_SHADOW_START - (CANONICAL_BASE >> 3)] + (addr >> 3)
implies
shadow-offset = KASAN_SHADOW_START - (CANONICAL_BASE >> 3)
= 0xFFFF800000000000 - (0xFFFF800000000000 >> 3)
= 0xDFFF900000000000

In UVM, we add a kasan_free (that is not preceded by a kasan_alloc). We
don't add poisoned redzones ourselves, but all the functions we execute
do, so we need to manually clear the poison before freeing the stack.

With the help of Kamil for the makefile stuff.


# 1.136 12-Aug-2018 skrll

Remove dependency of __BITS on MAX/MIN by providing __MAX/__MIN


Revision tags: pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.135 26-Dec-2017 christos

branches: 1.135.2;
add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.135 26-Dec-2017 christos

add linted to __USE()


# 1.134 26-Dec-2017 christos

lint knows about all inline variant syntax...


Revision tags: tls-maxphys-base-20171202 nick-nhusb-base-20170825 perseant-stdc-iso10646-base
# 1.133 15-Jul-2017 christos

branches: 1.133.2;
Ignore __thread for lint for now


Revision tags: matt-nb8-mediatek-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

branches: 1.132.6;
use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.133 15-Jul-2017 christos

Ignore __thread for lint for now


Revision tags: netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.132 08-Feb-2017 christos

use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

branches: 1.129.2;
Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.132 08-Feb-2017 christos

use __nothing instead since __empty is taken in stl_deque.h


# 1.131 08-Feb-2017 christos

remove comment in comment


# 1.130 08-Feb-2017 christos

add __empty


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.129 27-Dec-2016 christos

Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

branches: 1.128.2;
long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.129 27-Dec-2016 christos

Our lint knows about attributes, stop eating them.


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907 nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319 nick-nhusb-base-20151226
# 1.128 19-Nov-2015 christos

long line police


# 1.127 14-Oct-2015 christos

introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


Revision tags: nick-nhusb-base-20150921
# 1.126 30-Aug-2015 mlelstv

wishful thinking?


# 1.125 30-Aug-2015 uebayasi

Include opt_diagnostic.h.


Revision tags: nick-nhusb-base-20150606 nick-nhusb-base-20150406
# 1.124 25-Jan-2015 christos

add constcond


# 1.123 24-Jan-2015 christos

add cast-through-void * macros


Revision tags: nick-nhusb-base
# 1.122 05-Sep-2014 matt

branches: 1.122.2;
Don't use or in __RENAME because it triggers -Wc++-compat


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.121 08-Aug-2014 joerg

Add __unreachable(), which can be used to mark dead branches when the
compiler can't tell side effects.


# 1.120 14-Jul-2014 plunky

remove PCC specific definitions for __packed, __aligned and __section
which result in a _Pragma() usage. I don't think this ever worked,
as you can't concatenate string literals in this way. A warning
would have been produced, but until recently did not result in an
error condition so this was overlooked. Use __attribute__ instead as
this is supported by PCC.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.119 13-Mar-2014 pooka

branches: 1.119.2;
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__. It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?


# 1.118 05-Feb-2014 matt

Add another set of parens


# 1.117 05-Feb-2014 matt

mask the shift by __n with NBBY*sizeof(uintmax-t)-1
to suppress the following diagnostic from clang:
error: shift count >= width of type [-Werror,-Wshift-count-overflow]
PAR_ATTR = __BITS(63,56),// F=0 memory attributes
^~~~~~~~~~~~~
src/sys/sys/cdefs.h:554:4: note: expanded from macro '__BITS'
((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/sys/sys/cdefs.h:550:73: note: expanded from macro '__BIT'
(((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
^ ~~~~~~~~~~~~~~~~


# 1.116 25-Oct-2013 apb

Now that these attributes are documented in attribute(3), shorten
the comments for __used, __unused, __diagused, and __debugused.
Also s/variable/item/ because the attributes may bve applied
to functions.


# 1.115 25-Oct-2013 apb

Add __diagused and __debugused. These are for marking variables that
are used only in diagnotic or debug code, but unused when NDEBUG is
defined, or DIAGNOSTIC is not defined, or DEBUG is not defined.


# 1.114 25-Oct-2013 apb

Add comments explaining what __unused and __used are for.


# 1.113 16-Oct-2013 christos

introduce __USE(variable) that uses a variable to squash unused variable
warnings.


# 1.112 15-Sep-2013 martin

Remove __CT_LOCAL_PROLOGUE/EPILOGUE hack - instead just mark the typedef
as __unused. Duh!


# 1.111 14-Sep-2013 martin

Define a prologue/epilogue for CTASSERTs using local variables (to avoid
warnings about decalarations of localy defined but unused types)


# 1.110 10-Sep-2013 gsutre

Unbreak vax build (which still uses gcc 4.1). See PR lib/48131.


# 1.109 05-Sep-2013 gsutre

Implement __negative_p without floating-point arithmetic, using
a solution proposed by jxh on Stack Overflow. Fixes the second
half of PR lib/48131.

While there, simplify __type_fit_u by using the same logic
as in __type_fit_s.

ok christos@


# 1.108 05-Sep-2013 gsutre

Check for overflow in __type_fit_s when casting to intmax_t.
Fixes the first half of PR lib/48131.

ok christos@


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.107 29-May-2013 martin

branches: 1.107.2;
While visibility "protected" is nominaly supported by gcc 4.0 and 4.1
it does not actually work - the compiler does not emmit ".protected"
asm statements for used references to protected symbols, which then
causes the linker to fail and/or produce unloadable libraries.
This recently happened to port vax by the locale changes.

Backporting a fix (ASM_OUTPUT_EXTERNAL in gcc target config) is not
feasible.

So: define __dso_protected only starting with gcc 4.2.


# 1.106 30-Apr-2013 joerg

Add protected visibility marker for things that we want to keep public
for historical ABI issues, but that are not allowed to be overriden.


Revision tags: agc-symver-base
# 1.105 29-Jan-2013 gdt

Fix comment documenting __link_set_decl() macro.

The `__link_set_decl()` macro's replacement text includes a `*` after
`ptype`, so `ptype` is the pointed-at type (the type of a dereferenced
array entry), not the pointer type.

(This is a comment-only change.)

(From Richard Hansen of BBN.)


Revision tags: yamt-pagecache-base8
# 1.104 02-Jan-2013 matt

Don't define __BIT/__BITS if __ASSEMBLER__ is defined.
(since they use C syntax they won't work anyways).


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.103 28-Oct-2012 joerg

For GCC 4.1 and later, use the __alignof__ keyword.


# 1.102 22-Oct-2012 christos

define __alignof() in terms of __alignof__ if it is available.


# 1.101 21-Oct-2012 christos

Add an __alignof() macro.


# 1.100 24-Aug-2012 dholland

branches: 1.100.2;
use #elif rather than nesting #elses


# 1.99 02-Jun-2012 dsl

Add a __always_inline


Revision tags: jmcneill-usbmp-base10 yamt-pagecache-base5
# 1.98 30-Apr-2012 pgoyette

Fix a (obvious) typo


Revision tags: jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8
# 1.97 18-Mar-2012 christos

remove extra ;


# 1.96 18-Mar-2012 christos

add constcond


# 1.95 17-Mar-2012 christos

use __inline to fix nspr's configure issue


# 1.94 15-Mar-2012 christos

- this file is still used from assembly. protect inlines against __ASSEMBLER__
- rename __zero -> __zeroll, __negative -> __negative_p


# 1.93 13-Mar-2012 christos

Type macros providing min and max values for the given type, plus one that
returns if a value can be represented in a given type.


Revision tags: jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3
# 1.92 22-Feb-2012 martin

Backout previous - we do not need it anymore


# 1.91 21-Feb-2012 martin

There are some places where C99 allows a restrict modifier (and posix
demands it), but C++ does not allow it. So add a C only version of
__restrict, which expands to nothing if compiling C++.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49347 for a discussion.


Revision tags: jmcneill-usbmp-base2
# 1.90 17-Feb-2012 joerg

PR 46040:
If the current compiler doesn't support C99, check if it is compatible
with GCC 2.92. In that case, use the protected __restricted__ form.
In any other case, default to removing __restricted.


Revision tags: jmcneill-usbmp-pre-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2
# 1.89 05-Nov-2011 joerg

branches: 1.89.4; 1.89.6;
Add __returns_twice for the attribute of the same name. This makes the
attribute explicit based on the functions GCC gives it too.


Revision tags: yamt-pagecache-base
# 1.88 09-Oct-2011 chs

branches: 1.88.2;
add __noclone for gcc 4.5.


# 1.87 16-Aug-2011 dyoung

Add __strict_weak_alias(), the type-safe alternative to __weak_alias().


# 1.86 23-Jun-2011 nonaka

Added __packed define to be able to use eMbedded Visual C++ for building hpcboot.exe.


# 1.85 16-Jun-2011 joerg

Add an optional MD calling convention flag for use in libsa when space
optimisation is critical. Use this on i386 to switch to register passing
calling convention for the file system entry points and most assembler
call backs that have to preserve at least 3 registers.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase rmind-uvmplock-base
# 1.84 19-Feb-2011 matt

branches: 1.84.2;
Make __CTASSERT use __COUNTER__ instead of __LINE__ if the cpp supports it.


# 1.83 19-Feb-2011 matt

Add __CTASSERT(x)


# 1.82 18-Feb-2011 matt

Add a __noprofile keyword to disable the profiling of a function.


Revision tags: uebayasi-xip-base7 bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.81 25-Dec-2010 joerg

branches: 1.81.2; 1.81.4;
Rename __BEGIN_PUBLIC / __BEGIN_HIDDEN to __BEGIN_PUBLIC_DECLS /
__BEGIN_HIDDEN_DECLS and corresponding __END_* macros. Push the extern
"C" logic into __BEGIN_PUBLIC_DECLS / __BEGIN_HIDDEN_DECLS to make them
easier to use in header files used by C++.


Revision tags: uebayasi-xip-base6 uebayasi-xip-base5 uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10
# 1.80 07-Aug-2010 joerg

Add __BEGIN_PUBLIC / __END_PUBLIC, __BEGIN_HIDDEN / __END_HIDDEN and
__dso_public and __dso_hidden markers. Change __BEGIN_DECLS /
__END_DECLS to include __BEGIN_PUBLIC / __END_PUBLIC.


# 1.79 31-Jul-2010 joerg

Define a new __c99inline macro for compilers known to implement the C99
behavior. This unbreaks GCC 4.4's libgfortran build with the old
signal.h logic, because GCC decided to put the body for the sigsetop
functions in multiple objects.


Revision tags: uebayasi-xip-base1 yamt-nfs-mp-base9 uebayasi-xip-base matt-premerge-20091211 jym-xensuspend-nbase
# 1.78 02-Oct-2009 christos

branches: 1.78.2; 1.78.4;
lint knows __packed now.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7
# 1.77 08-Aug-2009 christos

Create and use __CAST(type, value) in headers so that modern c++ with
-Wold-style-casts does not bitch.


Revision tags: jymxensuspend-base
# 1.76 20-Jul-2009 joerg

Add __constfunc and explain how it differs from __pure.


Revision tags: yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-base
# 1.75 12-May-2009 reinoud

Fix _packed attribute for PCC. According to Ragge it should be _Pragma("packed
1") instead of _Pragma("packed").

With this fix userland programs needing _packed will now work.


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.74 22-Apr-2009 christos

Cast the argument of the __BIT to an unsigned type, since it does not make
sense for it to be signed and gcc complains if it is.


# 1.73 26-Mar-2009 gmcgarry

Pass argument to __aligned() through __STRING() so that it is correctly expanded. Now __aligned(CACHE_LINE_SIZE) works with pcc.


Revision tags: nick-hppapmap-base2 mjf-devfs2-base
# 1.72 14-Jan-2009 pooka

branches: 1.72.2;
As promised in the commit message, revert previous. __RENAME() is
not required by rumpkernel.


# 1.71 13-Jan-2009 pooka

Allow __RENAME if _RUMPKERNEL
(although I'll probably revert this soon, but add it now to allow build)


Revision tags: haad-dm-base2 haad-nbase2 haad-dm-base
# 1.70 10-Dec-2008 alc

Add the __printflike(), __scanflike() and __format_arg() macros, from FreeBSD

They will be used soon by the Atheros HAL code, many other places can use them
to avoid GCC dependency.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 ad-audiomp2-base netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.69 17-Aug-2008 gmcgarry

branches: 1.69.2; 1.69.10; 1.69.14;
Add __packed and __aligned support for PCC.
Define away restrict for __lint__.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.68 27-Jun-2008 gmcgarry

branches: 1.68.2;
pcc now supports __section().


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 wrstuden-revivesa-base
# 1.67 31-May-2008 ad

branches: 1.67.2;
Add a __noinline attribute. Suggested by christos@.


Revision tags: hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 yamt-nfs-mp-base2 yamt-nfs-mp-base yamt-pf42-base ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-merge1 vmlocking2-base3 bouyer-xeni386-nbase yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 bouyer-xeni386-base yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 matt-armv6-nbase mjf-devfs-base vmlocking-nbase matt-armv6-base jmcneill-pm-base hpcarm-cleanup-base reinoud-bufcleanup-base
# 1.66 26-Nov-2007 joerg

branches: 1.66.14; 1.66.16; 1.66.18; 1.66.20;
Separate handling of __attribute__, __dead and __pure:
- define away __attribute__ if not running GCC or running GCC < 2.0.
- use __attribute__((__return__)) for GCC >= 2.5, keep other cases.
- use __attribute__((__pure__)) for GCC >= 29.6, keep other cases.


Revision tags: jmcneill-base bouyer-xenamd64-base2 yamt-x86pmap-base4 bouyer-xenamd64-base yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.65 15-Sep-2007 ragge

branches: 1.65.6;
Add basic defines to be able to use pcc as compiler (renaming etc).


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase nick-csl-alignment-base5 wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 wrstuden-fixsa-base thorpej-atomic-base mjf-ufs-trans-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.64 13-Nov-2006 dyoung

branches: 1.64.8; 1.64.22; 1.64.24;
Cosmetic: join lines.


# 1.63 13-Nov-2006 dyoung

Stop using typeof() in the bit-twiddling macros, per yamt@'s
suggestion. This change requires that I use the __PRIuBITS format
string in atw and rtw, so do that.


# 1.62 27-Oct-2006 uwe

Define __used as __unused for gcc's that don't grok __attribute__((__used__))

Those older versions of gcc don't eliminate unused functions/vars
anyway, so it's enough just to suppress the warning.


Revision tags: yamt-splraiseipl-base2 yamt-splraiseipl-base yamt-pdpolicy-base9 yamt-pdpolicy-base8 rpaulo-netinet-merge-pcb-base
# 1.61 31-Aug-2006 dyoung

branches: 1.61.2; 1.61.4;
Per discussion on tech-kern and tech-userlevel, move the bit-twiddling
macros, __BIT, __BITS, SHIFTIN, SHIFTOUT, and __arraycount() from
lib/libkern/libkern.h to sys/cdefs.h. Add a __-prefix to SHIFTIN
and SHIFTOUT, and add a manual page for the bit-twiddling macros,
bits(3).

Make the __BIT and __BITS macros "widthless," as best I can, by
changing their type to uintmax_t from uint32_t. XXX The manual
page lags this change by a bit.

Define __PRIxBIT and __PRIxBITS printf(3) format strings.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base simonb-timcounters-final yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.60 11-Dec-2005 christos

branches: 1.60.4; 1.60.8;
merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.59 02-Jun-2005 he

branches: 1.59.2;
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.

Based on suggestions from tron and christos.


Revision tags: netbsd-3-0-3-RELEASE netbsd-3-0-2-RELEASE netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge
# 1.58 11-Dec-2004 christos

branches: 1.58.8;
kill gcc specific version of __UNCONST. Does not work to unconst
const char *foo[];


Revision tags: kent-audio1-base
# 1.57 23-Sep-2004 yamt

__UNCONST: add parens around a macro argument.


# 1.56 23-Sep-2004 yamt

a little safer impl of __UNCONST, using __typeof__ if __GNUC__.


# 1.55 01-Jul-2004 christos

DECONST->UNCONST


# 1.54 30-Jun-2004 christos

add __DECONST()


# 1.53 11-Jun-2004 he

The __used__ attribute first appeared in gcc 3.1, not in 2.7, according
to the gcc expertise. Fixes build problem for the vax port, which still
uses gcc 2.95.3.


# 1.52 07-Jun-2004 drochner

define a __used attribute (empty for gcc<2.7)


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.51 07-Jan-2004 martin

branches: 1.51.4;
Add a __insn_barrier() macro to stop the optimizer from moving code
accross the barrier or assume liveness of register values.
Suggested by Jason Thorpe and Steve Woodford.


# 1.50 29-Oct-2003 grant

trim leading whitespace from an #error, shuts up warning from
makedepend.


# 1.49 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.


# 1.48 05-Feb-2003 perry

branches: 1.48.2;
"Utilize" has exactly the same meaning as "use," but it is more
difficult to read and understand. Most manuals of English style
therefore say that you should use "use".


# 1.47 18-Jan-2003 christos

get rid of the != 0 in the non-gcc aware case.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.46 29-Dec-2002 kristerw

It is not valid C++ to have a semicolon after
extern "C" {}
so remove it from __END_DECLS.


Revision tags: gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.45 01-Nov-2002 thorpej

Add support for "link sets", which are arrays of pointers to objects
gathered together in named sections by the linker.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.44 10-Oct-2002 thorpej

Deal with the fact that __GNUC__ is not defined when preprocessing
assembler (Grr).


# 1.43 10-Oct-2002 thorpej

Add __unused, __packed, __aligned(), and __section() macros. Inspired
by FreeBSD.


Revision tags: netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base eeh-devprop-base newlock-base ifpoll-base kqueue-base
# 1.42 23-Nov-2001 enami

branches: 1.42.10;
Provide compat definition of __func__ for pre-C99 compiler.


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.41 06-May-2001 kleink

branches: 1.41.2;
Add a __static_cast() macro to help standard headers when used in C++
compile environments using G++'s -Wold-style-cast warning;
suggested by Dave Sainty in PR lib/11766.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.40 27-Dec-2000 kleink

branches: 1.40.2;
Make __restrict actually DTRT for non-C99 GCC >= 2.92.


# 1.39 27-Sep-2000 kleink

Provide a stub for restrict.


# 1.38 09-Aug-2000 tv

Remove the "kprintf" gcc attribute permanently. Use standard "printf"
format checking. We are now at 1.5E, as the removal of %b will cause
third-party LKMs to break.


# 1.37 07-Aug-2000 kleink

#ifdef __STDC__ -> #if __STDC__


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.36 27-May-2000 kleink

Spelling nit.


# 1.35 20-May-2000 simonb

Don't define __inline as "/* delete GCC keyword */" if __lint__ is
defined - lint(1) already knows about the __inline modifier.

This stops lint from generating "static function ... unused" warnings
for static __inline functions.


# 1.34 08-May-2000 thorpej

Add an additional usage note about using __predict_*() only in hot spots,
as suggested by Chris Demetriou.


# 1.33 08-May-2000 thorpej

Add __predict_true() and __predict_false() macros to access the
explicit branch prediction available on GCC 2.96 and later. See
the comment regarding usage.


# 1.32 05-May-2000 thorpej

Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.


Revision tags: chs-ubc2-newbase
# 1.31 03-Feb-2000 cgd

instead of just going on as normal if __RENAME() is used in kernel
(_KERNEL) or standalone (_STANDALONE) files, replace it with some
text that'll cause an error. __RENAME() should never be used in
the kernel (there's no need, at least, with the current way of doing
things), and is downright annoying in standalone code. (In a standalone
build environment, there may be no sane way to do symbol renaming,
which means that even just faking it and defining it to emptyness
would cause problems if it were actually needed.)


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.30 13-Dec-1999 itohy

Fix symbol renaming on cc -traditional.
Fix PRs bin/5167 and lib/6310.


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 kame_141_19991130 comdex-fall-1999-base fvdl-softdep-base netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 chs-ubc2-base netbsd-1-4-RELEASE netbsd-1-4-base
# 1.29 20-Mar-1999 thorpej

branches: 1.29.8; 1.29.14;
Factor out a.out vs. ELF cdefs from the various <machine/cdefs.h> files,
and place them in cdefs_{aout,elf}.h as appropriate. Rearrange cdefs.h
to account for this.


# 1.28 20-Dec-1998 kleink

Delete __extension__ on non-GCC or GCC1.


Revision tags: kenh-if-detach-base chs-ubc-base eeh-paddr_t-base
# 1.27 27-Jul-1998 mycroft

Make many of the new consts dependent on a new `__AUDIT__' flag, to avoid
breaking third party software. *sigh*


# 1.26 22-May-1998 cgd

___CONCAT was Broken. (The new version may not work exactly as people
would expect, but at least cpp doesn't choke on it.)


# 1.25 01-Mar-1998 fvdl

Merge with Lite2 + local changes


# 1.24 05-Nov-1997 thorpej

Define ___CONCAT() and ___STRING() before including <machine/cdefs.h>
so that the appropriate CPP evil takes place.


# 1.23 04-Nov-1997 thorpej

- define ___STRING() and ___CONCAT() macros which invoke
their double-underscore counterparts (cpp evil).
- define __RENAME() to do what lint expects, so that
renamed functions are handled properly.

From Chris Demetriou <cgd@pa.dec.com>.


# 1.22 24-Oct-1997 christos

lint -> __lint


# 1.21 23-Oct-1997 christos

Define __RENAME as a noop if lint is defined.
[probably needs pull-up]


# 1.20 22-Oct-1997 thorpej

Implement __RENAME() in <machine/cdefs.h>


# 1.19 22-Oct-1997 fvdl

New hacks to make libc work painlessly without bumping the major number:
use type func(arg1s) asm("emitted_name") gcc mechanism.
Suggested by Bill Sommerfeld.


Revision tags: netbsd-1-3-base thorpej-signal-base marc-pcmcia-bp marc-pcmcia-base
# 1.18 18-Jun-1997 christos

branches: 1.18.8;
Add __IDSTRING, __RCSID, and __COPYRIGHT macros.


Revision tags: is-newarp-before-merge is-newarp-base
# 1.17 22-Jan-1997 mikel

add multiple inclusion protection


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.16 03-Apr-1996 christos

Change kprintf attribute to be conditional on the pre-processor define
__KPRINTF_ATTRIBUTE__ so that our kernel compiles cleanly with versions
of gcc that do not support the kprintf format attribute.


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.15 19-Jan-1995 jtc

Machine dependant stuff has been moved to <machine/cdefs.h>.


# 1.14 07-Oct-1994 mycroft

Fix typos.


# 1.13 05-Oct-1994 jtc

Added __weak_reference() macro.


# 1.12 22-Jul-1994 cgd

one too many #endif's.


# 1.11 20-Jul-1994 jtc

Added __warn_references macro, which is used to instruct the linker to
print a warning message if a given symbol is referenced.


Revision tags: netbsd-1-0-base
# 1.10 29-Jun-1994 cgd

branches: 1.10.2;
New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD'


# 1.9 27-Jun-1994 cgd

new standard, minimally intrusive ID format


# 1.8 24-May-1994 cgd

update from Lite, with a few fixes that have been punted back.


Revision tags: nvm-base wnvm
# 1.7 12-Dec-1993 cgd

handle __attribute__ correctly when using gcc -traditional.
suggested, but different than what provided by Mark Weaver.


# 1.6 03-Dec-1993 jtc

Disable GCC's __attribute__ extension when we're not using GCC.


# 1.5 23-Sep-1993 cgd

if __P is already defined, undef it.


Revision tags: magnum-base netbsd-0-9-patch-001 netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 26-May-1993 cgd

branches: 1.4.4;
add "dead" and "pure" declarations, as provided by new db code


# 1.3 20-May-1993 cgd

add rcs ids as necessary, and also clean up headers


# 1.2 19-Apr-1993 mycroft

Add consistent multiple-inclusion protection.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision