/usr/include/d2/4.6/std/intrinsic.d is in libphobos2-4.6-dev 0.29.1-4.6.3-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | // Written in the D programming language
// written by Walter Bright
// www.digitalmars.com
// Placed into the public domain
/** These functions are built-in intrinsics to the compiler.
*
Intrinsic functions are functions built in to the compiler,
usually to take advantage of specific CPU features that
are inefficient to handle via external functions.
The compiler's optimizer and code generator are fully
integrated in with intrinsic functions, bringing to bear
their full power on them.
This can result in some surprising speedups.
*
* Copyright: Public Domain
* License: Public Domain
* Authors: Walter Bright
* Source: $(PHOBOSSRC std/_intrinsic.d)
* Macros:
* WIKI=Phobos/StdIntrinsic
*/
module std.intrinsic;
nothrow:
/**
* Scans the bits in v starting with bit 0, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
*/
pure int bsf(size_t v);
/**
* Scans the bits in v from the most significant bit
* to the least significant bit, looking
* for the first set bit.
* Returns:
* The bit number of the first bit set.
* The return value is undefined if v is zero.
* Example:
* ---
* import std.stdio;
* import std.intrinsic;
*
* int main()
* {
* uint v;
* int x;
*
* v = 0x21;
* x = bsf(v);
* writefln("bsf(x%x) = %d", v, x);
* x = bsr(v);
* writefln("bsr(x%x) = %d", v, x);
* return 0;
* }
* ---
* Output:
* bsf(x21) = 0<br>
* bsr(x21) = 5
*/
pure int bsr(size_t v);
/**
* Tests the bit.
*/
pure int bt(in size_t* p, size_t bitnum);
/**
* Tests and complements the bit.
*/
int btc(size_t* p, size_t bitnum);
/**
* Tests and resets (sets to 0) the bit.
*/
int btr(size_t* p, size_t bitnum);
/**
* Tests and sets the bit.
* Params:
* p = a non-NULL pointer to an array of size_ts.
* index = a bit number, starting with bit 0 of p[0],
* and progressing. It addresses bits like the expression:
---
p[index / (size_t.sizeof*8)] & (1 << (index & ((size_t.sizeof*8) - 1)))
---
* Returns:
* A non-zero value if the bit was set, and a zero
* if it was clear.
*
* Example:
* ---
import std.stdio;
import std.intrinsic;
int main()
{
size_t array[2];
array[0] = 2;
array[1] = 0x100;
writefln("btc(array, 35) = %d", <b>btc</b>(array, 35));
writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]);
writefln("btc(array, 35) = %d", <b>btc</b>(array, 35));
writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]);
writefln("bts(array, 35) = %d", <b>bts</b>(array, 35));
writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]);
writefln("btr(array, 35) = %d", <b>btr</b>(array, 35));
writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]);
writefln("bt(array, 1) = %d", <b>bt</b>(array, 1));
writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]);
return 0;
}
* ---
* Output:
<pre>
btc(array, 35) = 0
array = [0]:x2, [1]:x108
btc(array, 35) = -1
array = [0]:x2, [1]:x100
bts(array, 35) = 0
array = [0]:x2, [1]:x108
btr(array, 35) = -1
array = [0]:x2, [1]:x100
bt(array, 1) = -1
array = [0]:x2, [1]:x100
</pre>
*/
int bts(size_t* p, size_t bitnum);
/**
* Swaps bytes in a 4 byte uint end-to-end, i.e. byte 0 becomes
* byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
* becomes byte 0.
*/
pure uint bswap(uint v);
/**
* Reads I/O port at port_address.
*/
ubyte inp(uint port_address);
/**
* ditto
*/
ushort inpw(uint port_address);
/**
* ditto
*/
uint inpl(uint port_address);
/**
* Writes and returns value to I/O port at port_address.
*/
ubyte outp(uint port_address, ubyte value);
/**
* ditto
*/
ushort outpw(uint port_address, ushort value);
/**
* ditto
*/
uint outpl(uint port_address, uint value);
|