 |
Changeset 745
- Timestamp:
- 08/15/06 01:34:29
(2 years ago)
- Author:
- sean
- Message:
Added docs for core.Intrinsic, and reformatted/fixed docs for other modules.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r454 |
r745 |
|
| 22 | 22 | * The return value is undefined if v is zero. |
|---|
| 23 | 23 | */ |
|---|
| 24 | | int bsf(uint v); |
|---|
| | 24 | int bsf( uint v ); |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | |
|---|
| … | … | |
| 53 | 53 | * bsr(x21) = 5 |
|---|
| 54 | 54 | */ |
|---|
| 55 | | int bsr(uint v); |
|---|
| | 55 | int bsr( uint v ); |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | |
|---|
| … | … | |
| 59 | 59 | * Tests the bit. |
|---|
| 60 | 60 | */ |
|---|
| 61 | | int bt(uint* p, uint bitnum); |
|---|
| | 61 | int bt( uint* p, uint bitnum ); |
|---|
| 62 | 62 | |
|---|
| 63 | 63 | |
|---|
| … | … | |
| 65 | 65 | * Tests and complements the bit. |
|---|
| 66 | 66 | */ |
|---|
| 67 | | int btc(uint* p, uint bitnum); |
|---|
| | 67 | int btc( uint* p, uint bitnum ); |
|---|
| 68 | 68 | |
|---|
| 69 | 69 | |
|---|
| … | … | |
| 71 | 71 | * Tests and resets (sets to 0) the bit. |
|---|
| 72 | 72 | */ |
|---|
| 73 | | int btr(uint* p, uint bitnum); |
|---|
| | 73 | int btr( uint* p, uint bitnum ); |
|---|
| 74 | 74 | |
|---|
| 75 | 75 | |
|---|
| … | … | |
| 130 | 130 | </pre> |
|---|
| 131 | 131 | */ |
|---|
| 132 | | int bts(uint* p, uint bitnum); |
|---|
| | 132 | int bts( uint* p, uint bitnum ); |
|---|
| 133 | 133 | |
|---|
| 134 | 134 | |
|---|
| … | … | |
| 138 | 138 | * becomes byte 0. |
|---|
| 139 | 139 | */ |
|---|
| 140 | | uint bswap(uint v); |
|---|
| | 140 | uint bswap( uint v ); |
|---|
| 141 | 141 | |
|---|
| 142 | 142 | |
|---|
| … | … | |
| 144 | 144 | * Reads I/O port at port_address. |
|---|
| 145 | 145 | */ |
|---|
| 146 | | ubyte inp(uint port_address); |
|---|
| | 146 | ubyte inp( uint port_address ); |
|---|
| 147 | 147 | |
|---|
| 148 | 148 | |
|---|
| … | … | |
| 150 | 150 | * ditto |
|---|
| 151 | 151 | */ |
|---|
| 152 | | ushort inpw(uint port_address); |
|---|
| | 152 | ushort inpw( uint port_address ); |
|---|
| 153 | 153 | |
|---|
| 154 | 154 | |
|---|
| … | … | |
| 156 | 156 | * ditto |
|---|
| 157 | 157 | */ |
|---|
| 158 | | uint inpl(uint port_address); |
|---|
| | 158 | uint inpl( uint port_address ); |
|---|
| 159 | 159 | |
|---|
| 160 | 160 | |
|---|
| … | … | |
| 162 | 162 | * Writes and returns value to I/O port at port_address. |
|---|
| 163 | 163 | */ |
|---|
| 164 | | ubyte outp(uint port_address, ubyte value); |
|---|
| | 164 | ubyte outp( uint port_address, ubyte value ); |
|---|
| 165 | 165 | |
|---|
| 166 | 166 | |
|---|
| … | … | |
| 168 | 168 | * ditto |
|---|
| 169 | 169 | */ |
|---|
| 170 | | ushort outpw(uint port_address, ushort value); |
|---|
| | 170 | ushort outpw( uint port_address, ushort value ); |
|---|
| 171 | 171 | |
|---|
| 172 | 172 | |
|---|
| … | … | |
| 174 | 174 | * ditto |
|---|
| 175 | 175 | */ |
|---|
| 176 | | uint outpl(uint port_address, uint value); |
|---|
| | 176 | uint outpl( uint port_address, uint value ); |
|---|
| r738 |
r745 |
|
| 1 | 1 | /** |
|---|
| 2 | | * The array module provides string manipulation routines in a manner that |
|---|
| 3 | | * balances performance and flexibility. |
|---|
| | 2 | * The array module provides array manipulation routines in a manner that |
|---|
| | 3 | * balances performance and flexibility. Operations are provides for sorting, |
|---|
| | 4 | * and for processing both sorted and unsorted arrays. |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Copyright: Copyright (C) 2005-2006 Sean Kelly. All rights reserved. |
|---|
| … | … | |
| 934 | 935 | { |
|---|
| 935 | 936 | /** |
|---|
| 936 | | * Performs a linear search of buf from $(LB)buf.length .. 0$(RP), |
|---|
| | 937 | * Performs a linear search of buf from $(LP)buf.length .. 0$(RB), |
|---|
| 937 | 938 | * returning the index of the first element where pred returns true. |
|---|
| 938 | 939 | * |
|---|
| r454 |
r745 |
|
| 11 | 11 | public import std.intrinsic; |
|---|
| 12 | 12 | |
|---|
| | 13 | |
|---|
| | 14 | version( DDoc ) |
|---|
| | 15 | { |
|---|
| | 16 | /** |
|---|
| | 17 | * Scans the bits in v starting with bit 0, looking |
|---|
| | 18 | * for the first set bit. |
|---|
| | 19 | * Returns: |
|---|
| | 20 | * The bit number of the first bit set. |
|---|
| | 21 | * The return value is undefined if v is zero. |
|---|
| | 22 | */ |
|---|
| | 23 | int bsf( uint v ); |
|---|
| | 24 | |
|---|
| | 25 | |
|---|
| | 26 | /** |
|---|
| | 27 | * Scans the bits in v from the most significant bit |
|---|
| | 28 | * to the least significant bit, looking |
|---|
| | 29 | * for the first set bit. |
|---|
| | 30 | * Returns: |
|---|
| | 31 | * The bit number of the first bit set. |
|---|
| | 32 | * The return value is undefined if v is zero. |
|---|
| | 33 | * Example: |
|---|
| | 34 | * --- |
|---|
| | 35 | * import std.intrinsic; |
|---|
| | 36 | * |
|---|
| | 37 | * int main() |
|---|
| | 38 | * { |
|---|
| | 39 | * uint v; |
|---|
| | 40 | * int x; |
|---|
| | 41 | * |
|---|
| | 42 | * v = 0x21; |
|---|
| | 43 | * x = bsf(v); |
|---|
| | 44 | * printf("bsf(x%x) = %d\n", v, x); |
|---|
| | 45 | * x = bsr(v); |
|---|
| | 46 | * printf("bsr(x%x) = %d\n", v, x); |
|---|
| | 47 | * return 0; |
|---|
| | 48 | * } |
|---|
| | 49 | * --- |
|---|
| | 50 | * Output: |
|---|
| | 51 | * bsf(x21) = 0<br> |
|---|
| | 52 | * bsr(x21) = 5 |
|---|
| | 53 | */ |
|---|
| | 54 | int bsr( uint v ); |
|---|
| | 55 | |
|---|
| | 56 | |
|---|
| | 57 | /** |
|---|
| | 58 | * Tests the bit. |
|---|
| | 59 | */ |
|---|
| | 60 | int bt( uint* p, uint bitnum ); |
|---|
| | 61 | |
|---|
| | 62 | |
|---|
| | 63 | /** |
|---|
| | 64 | * Tests and complements the bit. |
|---|
| | 65 | */ |
|---|
| | 66 | int btc( uint* p, uint bitnum ); |
|---|
| | 67 | |
|---|
| | 68 | |
|---|
| | 69 | /** |
|---|
| | 70 | * Tests and resets (sets to 0) the bit. |
|---|
| | 71 | */ |
|---|
| | 72 | int btr( uint* p, uint bitnum ); |
|---|
| | 73 | |
|---|
| | 74 | |
|---|
| | 75 | /** |
|---|
| | 76 | * Tests and sets the bit. |
|---|
| | 77 | * Params: |
|---|
| | 78 | * p = a non-NULL pointer to an array of uints. |
|---|
| | 79 | * index = a bit number, starting with bit 0 of p[0], |
|---|
| | 80 | * and progressing. It addresses bits like the expression: |
|---|
| | 81 | --- |
|---|
| | 82 | p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1))) |
|---|
| | 83 | --- |
|---|
| | 84 | * Returns: |
|---|
| | 85 | * A non-zero value if the bit was set, and a zero |
|---|
| | 86 | * if it was clear. |
|---|
| | 87 | * |
|---|
| | 88 | * Example: |
|---|
| | 89 | * --- |
|---|
| | 90 | import std.intrinsic; |
|---|
| | 91 | |
|---|
| | 92 | int main() |
|---|
| | 93 | { |
|---|
| | 94 | uint array[2]; |
|---|
| | 95 | |
|---|
| | 96 | array[0] = 2; |
|---|
| | 97 | array[1] = 0x100; |
|---|
| | 98 | |
|---|
| | 99 | printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35)); |
|---|
| | 100 | printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); |
|---|
| | 101 | |
|---|
| | 102 | printf("btc(array, 35) = %d\n", <b>btc</b>(array, 35)); |
|---|
| | 103 | printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); |
|---|
| | 104 | |
|---|
| | 105 | printf("bts(array, 35) = %d\n", <b>bts</b>(array, 35)); |
|---|
| | 106 | printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); |
|---|
| | 107 | |
|---|
| | 108 | printf("btr(array, 35) = %d\n", <b>btr</b>(array, 35)); |
|---|
| | 109 | printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); |
|---|
| | 110 | |
|---|
| | 111 | printf("bt(array, 1) = %d\n", <b>bt</b>(array, 1)); |
|---|
| | 112 | printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); |
|---|
| | 113 | |
|---|
| | 114 | return 0; |
|---|
| | 115 | } |
|---|
| | 116 | * --- |
|---|
| | 117 | * Output: |
|---|
| | 118 | <pre> |
|---|
| | 119 | btc(array, 35) = 0 |
|---|
| | 120 | array = [0]:x2, [1]:x108 |
|---|
| | 121 | btc(array, 35) = -1 |
|---|
| | 122 | array = [0]:x2, [1]:x100 |
|---|
| | 123 | bts(array, 35) = 0 |
|---|
| | 124 | array = [0]:x2, [1]:x108 |
|---|
| | 125 | btr(array, 35) = -1 |
|---|
| | 126 | array = [0]:x2, [1]:x100 |
|---|
| | 127 | bt(array, 1) = -1 |
|---|
| | 128 | array = [0]:x2, [1]:x100 |
|---|
| | 129 | </pre> |
|---|
| | 130 | */ |
|---|
| | 131 | int bts( uint* p, uint bitnum ); |
|---|
| | 132 | |
|---|
| | 133 | |
|---|
| | 134 | /** |
|---|
| | 135 | * Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes |
|---|
| | 136 | * byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3 |
|---|
| | 137 | * becomes byte 0. |
|---|
| | 138 | */ |
|---|
| | 139 | uint bswap( uint v ); |
|---|
| | 140 | |
|---|
| | 141 | |
|---|
| | 142 | /** |
|---|
| | 143 | * Reads I/O port at port_address. |
|---|
| | 144 | */ |
|---|
| | 145 | ubyte inp( uint port_address ); |
|---|
| | 146 | |
|---|
| | 147 | |
|---|
| | 148 | /** |
|---|
| | 149 | * ditto |
|---|
| | 150 | */ |
|---|
| | 151 | ushort inpw( uint port_address ); |
|---|
| | 152 | |
|---|
| | 153 | |
|---|
| | 154 | /** |
|---|
| | 155 | * ditto |
|---|
| | 156 | */ |
|---|
| | 157 | uint inpl( uint port_address ); |
|---|
| | 158 | |
|---|
| | 159 | |
|---|
| | 160 | /** |
|---|
| | 161 | * Writes and returns value to I/O port at port_address. |
|---|
| | 162 | */ |
|---|
| | 163 | ubyte outp( uint port_address, ubyte value ); |
|---|
| | 164 | |
|---|
| | 165 | |
|---|
| | 166 | /** |
|---|
| | 167 | * ditto |
|---|
| | 168 | */ |
|---|
| | 169 | ushort outpw( uint port_address, ushort value ); |
|---|
| | 170 | |
|---|
| | 171 | |
|---|
| | 172 | /** |
|---|
| | 173 | * ditto |
|---|
| | 174 | */ |
|---|
| | 175 | uint outpl( uint port_address, uint value ); |
|---|
| | 176 | } |
|---|
Download in other formats:
|
 |