| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kernel.h,v 1.1.2.16 2013/07/24 03:01:24 riastradh Exp $ */ | | 1 | /* $NetBSD: kernel.h,v 1.1.2.17 2013/07/24 03:03:37 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -38,26 +38,29 @@ | | | @@ -38,26 +38,29 @@ |
38 | | | 38 | |
39 | #define __printf __printflike | | 39 | #define __printf __printflike |
40 | #define __user | | 40 | #define __user |
41 | #define __must_check /* __attribute__((warn_unused_result)), if GCC */ | | 41 | #define __must_check /* __attribute__((warn_unused_result)), if GCC */ |
42 | #define __always_unused __unused | | 42 | #define __always_unused __unused |
43 | | | 43 | |
44 | #define barrier() __insn_barrier() | | 44 | #define barrier() __insn_barrier() |
45 | #define unlikely(X) __predict_false(X) | | 45 | #define unlikely(X) __predict_false(X) |
46 | | | 46 | |
47 | #define uninitialized_var(x) x | | 47 | #define uninitialized_var(x) x |
48 | | | 48 | |
49 | #define round_up(X, Y) roundup2(X, Y) | | 49 | #define round_up(X, Y) roundup2(X, Y) |
50 | | | 50 | |
| | | 51 | #define upper_32_bits(X) ((uint32_t) (((X) >> 16) >> 16)) |
| | | 52 | #define lower_32_bits(X) ((uint32_t) ((X) & 0xffffffffUL)) |
| | | 53 | |
51 | #define container_of(PTR, TYPE, FIELD) \ | | 54 | #define container_of(PTR, TYPE, FIELD) \ |
52 | ((void)sizeof((PTR) - \ | | 55 | ((void)sizeof((PTR) - \ |
53 | &((TYPE *)(((char *)(PTR)) - \ | | 56 | &((TYPE *)(((char *)(PTR)) - \ |
54 | offsetof(TYPE, FIELD)))->FIELD), \ | | 57 | offsetof(TYPE, FIELD)))->FIELD), \ |
55 | ((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))) | | 58 | ((TYPE *)(((char *)(PTR)) - offsetof(TYPE, FIELD)))) |
56 | | | 59 | |
57 | #define ARRAY_SIZE(ARRAY) __arraycount(ARRAY) | | 60 | #define ARRAY_SIZE(ARRAY) __arraycount(ARRAY) |
58 | | | 61 | |
59 | #define swap(X, Y) do \ | | 62 | #define swap(X, Y) do \ |
60 | { \ | | 63 | { \ |
61 | /* XXX Kludge for type-safety. */ \ | | 64 | /* XXX Kludge for type-safety. */ \ |
62 | if (&(X) != &(Y)) { \ | | 65 | if (&(X) != &(Y)) { \ |
63 | CTASSERT(sizeof(X) == sizeof(Y)); \ | | 66 | CTASSERT(sizeof(X) == sizeof(Y)); \ |