xref: /minix/sys/sys/cdefs.h (revision 4684ddb6)
1 /*	$NetBSD: cdefs.h,v 1.116 2013/10/25 14:54:25 apb Exp $	*/
2 
3 /*
4  * Copyright (c) 1991, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * Berkeley Software Design, Inc.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. Neither the name of the University nor the names of its contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  *
34  *	@(#)cdefs.h	8.8 (Berkeley) 1/9/95
35  */
36 
37 #ifndef	_SYS_CDEFS_H_
38 #define	_SYS_CDEFS_H_
39 
40 /*
41  * Macro to test if we're using a GNU C compiler of a specific vintage
42  * or later, for e.g. features that appeared in a particular version
43  * of GNU C.  Usage:
44  *
45  *	#if __GNUC_PREREQ__(major, minor)
46  *	...cool feature...
47  *	#else
48  *	...delete feature...
49  *	#endif
50  */
51 #ifdef __GNUC__
52 #define	__GNUC_PREREQ__(x, y)						\
53 	((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) ||			\
54 	 (__GNUC__ > (x)))
55 #else
56 #define	__GNUC_PREREQ__(x, y)	0
57 #endif
58 
59 #include <machine/cdefs.h>
60 #ifdef __ELF__
61 #include <sys/cdefs_elf.h>
62 #else
63 #include <sys/cdefs_aout.h>
64 #endif
65 
66 #ifdef __GNUC__
67 #define	__strict_weak_alias(alias,sym)					\
68 	__unused static __typeof__(alias) *__weak_alias_##alias = &sym;	\
69 	__weak_alias(alias,sym)
70 #else
71 #define	__strict_weak_alias(alias,sym) __weak_alias(alias,sym)
72 #endif
73 
74 /*
75  * Optional marker for size-optimised MD calling convention.
76  */
77 #ifndef __compactcall
78 #define	__compactcall
79 #endif
80 
81 /*
82  * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
83  * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
84  * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
85  * in between its arguments.  __CONCAT can also concatenate double-quoted
86  * strings produced by the __STRING macro, but this only works with ANSI C.
87  */
88 
89 #define	___STRING(x)	__STRING(x)
90 #define	___CONCAT(x,y)	__CONCAT(x,y)
91 
92 #if __STDC__ || defined(__cplusplus)
93 #define	__P(protos)	protos		/* full-blown ANSI C */
94 #define	__CONCAT(x,y)	x ## y
95 #define	__STRING(x)	#x
96 
97 #define	__const		const		/* define reserved names to standard */
98 #define	__signed	signed
99 #define	__volatile	volatile
100 #if defined(__cplusplus) || defined(__PCC__)
101 #define	__inline	inline		/* convert to C++/C99 keyword */
102 #else
103 #if !defined(__GNUC__) && !defined(__lint__)
104 #define	__inline			/* delete GCC keyword */
105 #endif /* !__GNUC__  && !__lint__ */
106 #endif /* !__cplusplus */
107 
108 #else	/* !(__STDC__ || __cplusplus) */
109 #define	__P(protos)	()		/* traditional C preprocessor */
110 #define	__CONCAT(x,y)	x/**/y
111 #define	__STRING(x)	"x"
112 
113 #ifndef __GNUC__
114 #define	__const				/* delete pseudo-ANSI C keywords */
115 #define	__inline
116 #define	__signed
117 #define	__volatile
118 #endif	/* !__GNUC__ */
119 
120 /*
121  * In non-ANSI C environments, new programs will want ANSI-only C keywords
122  * deleted from the program and old programs will want them left alone.
123  * Programs using the ANSI C keywords const, inline etc. as normal
124  * identifiers should define -DNO_ANSI_KEYWORDS.
125  */
126 #ifndef	NO_ANSI_KEYWORDS
127 #define	const		__const		/* convert ANSI C keywords */
128 #define	inline		__inline
129 #define	signed		__signed
130 #define	volatile	__volatile
131 #endif /* !NO_ANSI_KEYWORDS */
132 #endif	/* !(__STDC__ || __cplusplus) */
133 
134 /*
135  * Used for internal auditing of the NetBSD source tree.
136  */
137 #ifdef __AUDIT__
138 #define	__aconst	__const
139 #else
140 #define	__aconst
141 #endif
142 
143 /*
144  * Compile Time Assertion.
145  */
146 #ifdef __COUNTER__
147 #define	__CTASSERT(x)		__CTASSERT0(x, __ctassert, __COUNTER__)
148 #else
149 #define	__CTASSERT(x)		__CTASSERT0(x, __ctassert, __LINE__)
150 #endif
151 #define	__CTASSERT0(x, y, z)	__CTASSERT1(x, y, z)
152 #define	__CTASSERT1(x, y, z)	typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused
153 
154 /*
155  * The following macro is used to remove const cast-away warnings
156  * from gcc -Wcast-qual; it should be used with caution because it
157  * can hide valid errors; in particular most valid uses are in
158  * situations where the API requires it, not to cast away string
159  * constants. We don't use *intptr_t on purpose here and we are
160  * explicit about unsigned long so that we don't have additional
161  * dependencies.
162  */
163 #define __UNCONST(a)	((void *)(unsigned long)(const void *)(a))
164 
165 /*
166  * The following macro is used to remove the volatile cast-away warnings
167  * from gcc -Wcast-qual; as above it should be used with caution
168  * because it can hide valid errors or warnings.  Valid uses include
169  * making it possible to pass a volatile pointer to memset().
170  * For the same reasons as above, we use unsigned long and not intptr_t.
171  */
172 #define __UNVOLATILE(a)	((void *)(unsigned long)(volatile void *)(a))
173 
174 /*
175  * GCC2 provides __extension__ to suppress warnings for various GNU C
176  * language extensions under "-ansi -pedantic".
177  */
178 #if !__GNUC_PREREQ__(2, 0)
179 #define	__extension__		/* delete __extension__ if non-gcc or gcc1 */
180 #endif
181 
182 /*
183  * GCC1 and some versions of GCC2 declare dead (non-returning) and
184  * pure (no side effects) functions using "volatile" and "const";
185  * unfortunately, these then cause warnings under "-ansi -pedantic".
186  * GCC2 uses a new, peculiar __attribute__((attrs)) style.  All of
187  * these work for GNU C++ (modulo a slight glitch in the C++ grammar
188  * in the distribution version of 2.5.5).
189  *
190  * GCC defines a pure function as depending only on its arguments and
191  * global variables.  Typical examples are strlen and sqrt.
192  *
193  * GCC defines a const function as depending only on its arguments.
194  * Therefore calling a const function again with identical arguments
195  * will always produce the same result.
196  *
197  * Rounding modes for floating point operations are considered global
198  * variables and prevent sqrt from being a const function.
199  *
200  * Calls to const functions can be optimised away and moved around
201  * without limitations.
202  */
203 #if !__GNUC_PREREQ__(2, 0)
204 #define __attribute__(x)
205 #endif
206 
207 #if __GNUC_PREREQ__(2, 5)
208 #define	__dead		__attribute__((__noreturn__))
209 #elif defined(__GNUC__)
210 #define	__dead		__volatile
211 #else
212 #define	__dead
213 #endif
214 
215 #if __GNUC_PREREQ__(2, 96)
216 #define	__pure		__attribute__((__pure__))
217 #elif defined(__GNUC__)
218 #define	__pure		__const
219 #else
220 #define	__pure
221 #endif
222 
223 #if __GNUC_PREREQ__(2, 5)
224 #define	__constfunc	__attribute__((__const__))
225 #else
226 #define	__constfunc
227 #endif
228 
229 #if __GNUC_PREREQ__(3, 0)
230 #define	__noinline	__attribute__((__noinline__))
231 #else
232 #define	__noinline	/* nothing */
233 #endif
234 
235 #if __GNUC_PREREQ__(3, 0)
236 #define	__always_inline	__attribute__((__always_inline__))
237 #else
238 #define	__always_inline	/* nothing */
239 #endif
240 
241 #if __GNUC_PREREQ__(4, 1)
242 #define	__returns_twice	__attribute__((__returns_twice__))
243 #else
244 #define	__returns_twice	/* nothing */
245 #endif
246 
247 #if __GNUC_PREREQ__(4, 5)
248 #define	__noclone	__attribute__((__noclone__))
249 #else
250 #define	__noclone	/* nothing */
251 #endif
252 
253 /*
254  * __unused: Note that item or function might be unused.
255  */
256 #if __GNUC_PREREQ__(2, 7)
257 #define	__unused	__attribute__((__unused__))
258 #else
259 #define	__unused	/* delete */
260 #endif
261 
262 /*
263  * __used: Note that item is needed, even if it appears to be unused.
264  */
265 #if __GNUC_PREREQ__(3, 1)
266 #define	__used		__attribute__((__used__))
267 #else
268 #define	__used		__unused
269 #endif
270 
271 /*
272  * __diagused: Note that item is used in diagnostic code, but may be
273  * unused in non-diagnostic code.
274  */
275 #if (defined(_KERNEL) && defined(DIAGNOSTIC)) \
276  || (!defined(_KERNEL) && !defined(NDEBUG))
277 #define	__diagused	/* empty */
278 #else
279 #define	__diagused	__unused
280 #endif
281 
282 /*
283  * __debugused: Note that item is used in debug code, but may be
284  * unused in non-debug code.
285  */
286 #if defined(DEBUG)
287 #define	__debugused	/* empty */
288 #else
289 #define	__debugused	__unused
290 #endif
291 
292 #if __GNUC_PREREQ__(3, 1)
293 #define	__noprofile	__attribute__((__no_instrument_function__))
294 #else
295 #define	__noprofile	/* nothing */
296 #endif
297 
298 #if defined(__cplusplus)
299 #define	__BEGIN_EXTERN_C	extern "C" {
300 #define	__END_EXTERN_C		}
301 #define	__static_cast(x,y)	static_cast<x>(y)
302 #else
303 #define	__BEGIN_EXTERN_C
304 #define	__END_EXTERN_C
305 #define	__static_cast(x,y)	(x)y
306 #endif
307 
308 #if __GNUC_PREREQ__(4, 0)
309 #  define __dso_public	__attribute__((__visibility__("default")))
310 #  define __dso_hidden	__attribute__((__visibility__("hidden")))
311 #  define __BEGIN_PUBLIC_DECLS	\
312 	_Pragma("GCC visibility push(default)") __BEGIN_EXTERN_C
313 #  define __END_PUBLIC_DECLS	__END_EXTERN_C _Pragma("GCC visibility pop")
314 #  define __BEGIN_HIDDEN_DECLS	\
315 	_Pragma("GCC visibility push(hidden)") __BEGIN_EXTERN_C
316 #  define __END_HIDDEN_DECLS	__END_EXTERN_C _Pragma("GCC visibility pop")
317 #else
318 #  define __dso_public
319 #  define __dso_hidden
320 #  define __BEGIN_PUBLIC_DECLS	__BEGIN_EXTERN_C
321 #  define __END_PUBLIC_DECLS	__END_EXTERN_C
322 #  define __BEGIN_HIDDEN_DECLS	__BEGIN_EXTERN_C
323 #  define __END_HIDDEN_DECLS	__END_EXTERN_C
324 #endif
325 #if __GNUC_PREREQ__(4, 2)
326 #  define __dso_protected	__attribute__((__visibility__("protected")))
327 #else
328 #  define __dso_protected
329 #endif
330 
331 #define	__BEGIN_DECLS		__BEGIN_PUBLIC_DECLS
332 #define	__END_DECLS		__END_PUBLIC_DECLS
333 
334 /*
335  * Non-static C99 inline functions are optional bodies.  They don't
336  * create global symbols if not used, but can be replaced if desirable.
337  * This differs from the behavior of GCC before version 4.3.  The nearest
338  * equivalent for older GCC is `extern inline'.  For newer GCC, use the
339  * gnu_inline attribute additionally to get the old behavior.
340  *
341  * For C99 compilers other than GCC, the C99 behavior is expected.
342  */
343 #if defined(__GNUC__) && defined(__GNUC_STDC_INLINE__)
344 #define	__c99inline	extern __attribute__((__gnu_inline__)) __inline
345 #elif defined(__GNUC__)
346 #define	__c99inline	extern __inline
347 #elif defined(__STDC_VERSION__)
348 #define	__c99inline	__inline
349 #endif
350 
351 #if defined(__lint__)
352 #define	__packed	__packed
353 #define	__aligned(x)	/* delete */
354 #define	__section(x)	/* delete */
355 #elif __GNUC_PREREQ__(2, 7)
356 #define	__packed	__attribute__((__packed__))
357 #define	__aligned(x)	__attribute__((__aligned__(x)))
358 #define	__section(x)	__attribute__((__section__(x)))
359 #elif defined(__PCC__)
360 #define	__packed	_Pragma("packed 1")
361 #define	__aligned(x)   	_Pragma("aligned " __STRING(x))
362 #define	__section(x)   	_Pragma("section " ## x)
363 #elif defined(_MSC_VER)
364 #define	__packed	/* ignore */
365 #else
366 #define	__packed	error: no __packed for this compiler
367 #define	__aligned(x)	error: no __aligned for this compiler
368 #define	__section(x)	error: no __section for this compiler
369 #endif
370 
371 /*
372  * C99 defines the restrict type qualifier keyword, which was made available
373  * in GCC 2.92.
374  */
375 #if defined(__lint__)
376 #define	__restrict	/* delete __restrict when not supported */
377 #elif __STDC_VERSION__ >= 199901L
378 #define	__restrict	restrict
379 #elif __GNUC_PREREQ__(2, 92)
380 #define	__restrict	__restrict__
381 #else
382 #define	__restrict	/* delete __restrict when not supported */
383 #endif
384 
385 /*
386  * C99 defines __func__ predefined identifier, which was made available
387  * in GCC 2.95.
388  */
389 #if !(__STDC_VERSION__ >= 199901L)
390 #if __GNUC_PREREQ__(2, 6)
391 #define	__func__	__PRETTY_FUNCTION__
392 #elif __GNUC_PREREQ__(2, 4)
393 #define	__func__	__FUNCTION__
394 #else
395 #define	__func__	""
396 #endif
397 #endif /* !(__STDC_VERSION__ >= 199901L) */
398 
399 #if defined(_KERNEL)
400 #if defined(NO_KERNEL_RCSIDS)
401 #undef __KERNEL_RCSID
402 #define	__KERNEL_RCSID(_n, _s)		/* nothing */
403 #endif /* NO_KERNEL_RCSIDS */
404 #endif /* _KERNEL */
405 
406 #if !defined(_STANDALONE) && !defined(_KERNEL)
407 #if defined(__GNUC__) || defined(__PCC__)
408 #define	__RENAME(x)	___RENAME(x)
409 #elif defined(__lint__)
410 #define	__RENAME(x)	__symbolrename(x)
411 #else
412 #error "No function renaming possible"
413 #endif /* __GNUC__ */
414 #else /* _STANDALONE || _KERNEL */
415 #define	__RENAME(x)	no renaming in kernel or standalone environment
416 #endif
417 
418 /*
419  * A barrier to stop the optimizer from moving code or assume live
420  * register values. This is gcc specific, the version is more or less
421  * arbitrary, might work with older compilers.
422  */
423 #if __GNUC_PREREQ__(2, 95)
424 #define	__insn_barrier()	__asm __volatile("":::"memory")
425 #else
426 #define	__insn_barrier()	/* */
427 #endif
428 
429 /*
430  * GNU C version 2.96 adds explicit branch prediction so that
431  * the CPU back-end can hint the processor and also so that
432  * code blocks can be reordered such that the predicted path
433  * sees a more linear flow, thus improving cache behavior, etc.
434  *
435  * The following two macros provide us with a way to use this
436  * compiler feature.  Use __predict_true() if you expect the expression
437  * to evaluate to true, and __predict_false() if you expect the
438  * expression to evaluate to false.
439  *
440  * A few notes about usage:
441  *
442  *	* Generally, __predict_false() error condition checks (unless
443  *	  you have some _strong_ reason to do otherwise, in which case
444  *	  document it), and/or __predict_true() `no-error' condition
445  *	  checks, assuming you want to optimize for the no-error case.
446  *
447  *	* Other than that, if you don't know the likelihood of a test
448  *	  succeeding from empirical or other `hard' evidence, don't
449  *	  make predictions.
450  *
451  *	* These are meant to be used in places that are run `a lot'.
452  *	  It is wasteful to make predictions in code that is run
453  *	  seldomly (e.g. at subsystem initialization time) as the
454  *	  basic block reordering that this affects can often generate
455  *	  larger code.
456  */
457 #if __GNUC_PREREQ__(2, 96)
458 #define	__predict_true(exp)	__builtin_expect((exp) != 0, 1)
459 #define	__predict_false(exp)	__builtin_expect((exp) != 0, 0)
460 #else
461 #define	__predict_true(exp)	(exp)
462 #define	__predict_false(exp)	(exp)
463 #endif
464 
465 /*
466  * Compiler-dependent macros to declare that functions take printf-like
467  * or scanf-like arguments.  They are null except for versions of gcc
468  * that are known to support the features properly (old versions of gcc-2
469  * didn't permit keeping the keywords out of the application namespace).
470  */
471 #if __GNUC_PREREQ__(2, 7)
472 #define __printflike(fmtarg, firstvararg)	\
473 	    __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
474 #define __scanflike(fmtarg, firstvararg)	\
475 	    __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
476 #define __format_arg(fmtarg)    __attribute__((__format_arg__ (fmtarg)))
477 #else
478 #define __printflike(fmtarg, firstvararg)	/* nothing */
479 #define __scanflike(fmtarg, firstvararg)	/* nothing */
480 #define __format_arg(fmtarg)			/* nothing */
481 #endif
482 
483 /*
484  * Macros for manipulating "link sets".  Link sets are arrays of pointers
485  * to objects, which are gathered up by the linker.
486  *
487  * Object format-specific code has provided us with the following macros:
488  *
489  *	__link_set_add_text(set, sym)
490  *		Add a reference to the .text symbol `sym' to `set'.
491  *
492  *	__link_set_add_rodata(set, sym)
493  *		Add a reference to the .rodata symbol `sym' to `set'.
494  *
495  *	__link_set_add_data(set, sym)
496  *		Add a reference to the .data symbol `sym' to `set'.
497  *
498  *	__link_set_add_bss(set, sym)
499  *		Add a reference to the .bss symbol `sym' to `set'.
500  *
501  *	__link_set_decl(set, ptype)
502  *		Provide an extern declaration of the set `set', which
503  *		contains an array of pointers to type `ptype'.  This
504  *		macro must be used by any code which wishes to reference
505  *		the elements of a link set.
506  *
507  *	__link_set_start(set)
508  *		This points to the first slot in the link set.
509  *
510  *	__link_set_end(set)
511  *		This points to the (non-existent) slot after the last
512  *		entry in the link set.
513  *
514  *	__link_set_count(set)
515  *		Count the number of entries in link set `set'.
516  *
517  * In addition, we provide the following macros for accessing link sets:
518  *
519  *	__link_set_foreach(pvar, set)
520  *		Iterate over the link set `set'.  Because a link set is
521  *		an array of pointers, pvar must be declared as "type **pvar",
522  *		and the actual entry accessed as "*pvar".
523  *
524  *	__link_set_entry(set, idx)
525  *		Access the link set entry at index `idx' from set `set'.
526  */
527 #define	__link_set_foreach(pvar, set)					\
528 	for (pvar = __link_set_start(set); pvar < __link_set_end(set); pvar++)
529 
530 #define	__link_set_entry(set, idx)	(__link_set_start(set)[idx])
531 
532 /*
533  * Return the natural alignment in bytes for the given type
534  */
535 #if __GNUC_PREREQ__(4, 1)
536 #define	__alignof(__t)  __alignof__(__t)
537 #else
538 #define __alignof(__t) (sizeof(struct { char __x; __t __y; }) - sizeof(__t))
539 #endif
540 
541 /*
542  * Return the number of elements in a statically-allocated array,
543  * __x.
544  */
545 #define	__arraycount(__x)	(sizeof(__x) / sizeof(__x[0]))
546 
547 #ifndef __ASSEMBLER__
548 /* __BIT(n): nth bit, where __BIT(0) == 0x1. */
549 #define	__BIT(__n)	\
550     (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : ((uintmax_t)1 << (uintmax_t)(__n)))
551 
552 /* __BITS(m, n): bits m through n, m < n. */
553 #define	__BITS(__m, __n)	\
554 	((__BIT(MAX((__m), (__n)) + 1) - 1) ^ (__BIT(MIN((__m), (__n))) - 1))
555 #endif /* !__ASSEMBLER__ */
556 
557 /* find least significant bit that is set */
558 #define	__LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask))
559 
560 #define	__PRIuBIT	PRIuMAX
561 #define	__PRIuBITS	__PRIuBIT
562 
563 #define	__PRIxBIT	PRIxMAX
564 #define	__PRIxBITS	__PRIxBIT
565 
566 #define	__SHIFTOUT(__x, __mask)	(((__x) & (__mask)) / __LOWEST_SET_BIT(__mask))
567 #define	__SHIFTIN(__x, __mask) ((__x) * __LOWEST_SET_BIT(__mask))
568 #define	__SHIFTOUT_MASK(__mask) __SHIFTOUT((__mask), (__mask))
569 
570 /*
571  * Only to be used in other headers that are included from both c or c++
572  * NOT to be used in code.
573  */
574 #ifdef __cplusplus
575 #define __CAST(__dt, __st)	static_cast<__dt>(__st)
576 #else
577 #define __CAST(__dt, __st)	((__dt)(__st))
578 #endif
579 
580 #define __USE(a) ((void)(a))
581 
582 #define __type_mask(t) (/*LINTED*/sizeof(t) < sizeof(intmax_t) ? \
583     (~((1ULL << (sizeof(t) * NBBY)) - 1)) : 0ULL)
584 
585 #ifndef __ASSEMBLER__
586 static __inline long long __zeroll(void) { return 0; }
587 static __inline unsigned long long __zeroull(void) { return 0; }
588 #else
589 #define __zeroll() (0LL)
590 #define __zeroull() (0ULL)
591 #endif
592 
593 #define __negative_p(x) (!((x) > 0) && ((x) != 0))
594 
595 #define __type_min_s(t) ((t)((1ULL << (sizeof(t) * NBBY - 1))))
596 #define __type_max_s(t) ((t)~((1ULL << (sizeof(t) * NBBY - 1))))
597 #define __type_min_u(t) ((t)0ULL)
598 #define __type_max_u(t) ((t)~0ULL)
599 #define __type_is_signed(t) (/*LINTED*/__type_min_s(t) + (t)1 < (t)1)
600 #define __type_min(t) (__type_is_signed(t) ? __type_min_s(t) : __type_min_u(t))
601 #define __type_max(t) (__type_is_signed(t) ? __type_max_s(t) : __type_max_u(t))
602 
603 
604 #define __type_fit_u(t, a) (/*LINTED*/!__negative_p(a) && \
605     (uintmax_t)((a) + __zeroull()) <= (uintmax_t)__type_max_u(t))
606 
607 #define __type_fit_s(t, a) (/*LINTED*/__negative_p(a) ? \
608     ((intmax_t)((a) + __zeroll()) >= (intmax_t)__type_min_s(t)) : \
609     ((intmax_t)((a) + __zeroll()) >= (intmax_t)0 && \
610      (intmax_t)((a) + __zeroll()) <= (intmax_t)__type_max_s(t)))
611 
612 /*
613  * return true if value 'a' fits in type 't'
614  */
615 #define __type_fit(t, a) (__type_is_signed(t) ? \
616     __type_fit_s(t, a) : __type_fit_u(t, a))
617 
618 #endif /* !_SYS_CDEFS_H_ */
619