| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cdefs.h,v 1.138 2018/12/04 22:06:36 kamil Exp $ */ | | 1 | /* $NetBSD: cdefs.h,v 1.139 2018/12/18 16:23:20 skrll Exp $ */ |
2 | | | 2 | |
3 | /* * Copyright (c) 1991, 1993 | | 3 | /* * Copyright (c) 1991, 1993 |
4 | * The Regents of the University of California. All rights reserved. | | 4 | * The Regents of the University of California. All rights reserved. |
5 | * | | 5 | * |
6 | * This code is derived from software contributed to Berkeley by | | 6 | * This code is derived from software contributed to Berkeley by |
7 | * Berkeley Software Design, Inc. | | 7 | * Berkeley Software Design, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -576,27 +576,27 @@ | | | @@ -576,27 +576,27 @@ |
576 | /* | | 576 | /* |
577 | * Return the number of elements in a statically-allocated array, | | 577 | * Return the number of elements in a statically-allocated array, |
578 | * __x. | | 578 | * __x. |
579 | */ | | 579 | */ |
580 | #define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) | | 580 | #define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) |
581 | | | 581 | |
582 | #ifndef __ASSEMBLER__ | | 582 | #ifndef __ASSEMBLER__ |
583 | /* __BIT(n): nth bit, where __BIT(0) == 0x1. */ | | 583 | /* __BIT(n): nth bit, where __BIT(0) == 0x1. */ |
584 | #define __BIT(__n) \ | | 584 | #define __BIT(__n) \ |
585 | (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ | | 585 | (((uintmax_t)(__n) >= NBBY * sizeof(uintmax_t)) ? 0 : \ |
586 | ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) | | 586 | ((uintmax_t)1 << (uintmax_t)((__n) & (NBBY * sizeof(uintmax_t) - 1)))) |
587 | | | 587 | |
588 | /* Macros for min/max. */ | | 588 | /* Macros for min/max. */ |
589 | #define __MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) | | 589 | #define __MIN(a,b) ((/*CONSTCOND*/(a)<=(b))?(a):(b)) |
590 | #define __MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) | | 590 | #define __MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) |
591 | | | 591 | |
592 | /* __BITS(m, n): bits m through n, m < n. */ | | 592 | /* __BITS(m, n): bits m through n, m < n. */ |
593 | #define __BITS(__m, __n) \ | | 593 | #define __BITS(__m, __n) \ |
594 | ((__BIT(__MAX((__m), (__n)) + 1) - 1) ^ (__BIT(__MIN((__m), (__n))) - 1)) | | 594 | ((__BIT(__MAX((__m), (__n)) + 1) - 1) ^ (__BIT(__MIN((__m), (__n))) - 1)) |
595 | #endif /* !__ASSEMBLER__ */ | | 595 | #endif /* !__ASSEMBLER__ */ |
596 | | | 596 | |
597 | /* find least significant bit that is set */ | | 597 | /* find least significant bit that is set */ |
598 | #define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) | | 598 | #define __LOWEST_SET_BIT(__mask) ((((__mask) - 1) & (__mask)) ^ (__mask)) |
599 | | | 599 | |
600 | #define __PRIuBIT PRIuMAX | | 600 | #define __PRIuBIT PRIuMAX |
601 | #define __PRIuBITS __PRIuBIT | | 601 | #define __PRIuBITS __PRIuBIT |
602 | | | 602 | |