diff --git a/import/std/intrinsic.di b/import/std/intrinsic.di deleted file mode 100644 index 34c81554d3..0000000000 --- a/import/std/intrinsic.di +++ /dev/null @@ -1,171 +0,0 @@ -/** - * 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 - */ -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
- * 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", btc(array, 35)); - writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); - - writefln("btc(array, 35) = %d", btc(array, 35)); - writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); - - writefln("bts(array, 35) = %d", bts(array, 35)); - writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); - - writefln("btr(array, 35) = %d", btr(array, 35)); - writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); - - writefln("bt(array, 1) = %d", bt(array, 1)); - writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); - - return 0; -} - * --- - * Output: -
-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
-
- */ -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); - - diff --git a/posix.mak b/posix.mak index 02b4275eb5..bdc965ab7e 100644 --- a/posix.mak +++ b/posix.mak @@ -30,7 +30,6 @@ MANIFEST= \ win32.mak \ \ import/object.di \ - import/std/intrinsic.di \ \ src/object_.d \ \ diff --git a/src/core/bitop.d b/src/core/bitop.d index 140ff3d004..53a32b4307 100644 --- a/src/core/bitop.d +++ b/src/core/bitop.d @@ -15,172 +15,171 @@ module core.bitop; -version( D_Ddoc ) -{ - /** - * 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. - */ - int bsf( uint 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 core.bitop; - * - * int main() - * { - * uint v; - * int x; - * - * v = 0x21; - * x = bsf(v); - * printf("bsf(x%x) = %d\n", v, x); - * x = bsr(v); - * printf("bsr(x%x) = %d\n", v, x); - * return 0; - * } - * --- - * Output: - * bsf(x21) = 0
- * bsr(x21) = 5 - */ - int bsr( uint v ); - - - /** - * Tests the bit. - */ - int bt( uint* p, uint bitnum ); - - - /** - * Tests and complements the bit. - */ - int btc( uint* p, uint bitnum ); - - - /** - * Tests and resets (sets to 0) the bit. - */ - int btr( uint* p, uint bitnum ); - - - /** - * Tests and sets the bit. - * Params: - * p = a non-NULL pointer to an array of uints. - * index = a bit number, starting with bit 0 of p[0], - * and progressing. It addresses bits like the expression: - --- - p[index / (uint.sizeof*8)] & (1 << (index & ((uint.sizeof*8) - 1))) - --- - * Returns: - * A non-zero value if the bit was set, and a zero - * if it was clear. - * - * Example: - * --- - import core.bitop; - - int main() - { - uint array[2]; +nothrow: - array[0] = 2; - array[1] = 0x100; - printf("btc(array, 35) = %d\n", btc(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); +/** + * 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); - printf("btc(array, 35) = %d\n", btc(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - printf("bts(array, 35) = %d\n", bts(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); +/** + * 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 core.bitop; + * + * 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
+ * bsr(x21) = 5 + */ +pure int bsr(size_t v); - printf("btr(array, 35) = %d\n", btr(array, 35)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); - printf("bt(array, 1) = %d\n", bt(array, 1)); - printf("array = [0]:x%x, [1]:x%x\n", array[0], array[1]); +/** + * Tests the bit. + */ +pure int bt(in size_t* p, size_t bitnum); - return 0; - } - * --- - * Output: -
-    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
-    
- */ - int bts( uint* p, uint 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. - */ - 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 ); -} -else + +/** + * 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 core.bitop; + +int main() { - public import std.intrinsic; + size_t array[2]; + + array[0] = 2; + array[1] = 0x100; + + writefln("btc(array, 35) = %d", btc(array, 35)); + writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); + + writefln("btc(array, 35) = %d", btc(array, 35)); + writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); + + writefln("bts(array, 35) = %d", bts(array, 35)); + writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); + + writefln("btr(array, 35) = %d", btr(array, 35)); + writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); + + writefln("bt(array, 1) = %d", bt(array, 1)); + writefln("array = [0]:x%x, [1]:x%x", array[0], array[1]); + + return 0; } + * --- + * Output: +
+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
+
+ */ +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); /** diff --git a/src/gc/gcbits.d b/src/gc/gcbits.d index dd2f6f45d8..d076509b5e 100644 --- a/src/gc/gcbits.d +++ b/src/gc/gcbits.d @@ -84,7 +84,7 @@ struct GCBits { version (none) { - return std.intrinsic.bt(data + 1, i); // this is actually slower! don't use + return core.bitop.bt(data + 1, i); // this is actually slower! don't use } else { @@ -119,7 +119,7 @@ struct GCBits { version (bitops) { - return std.intrinsic.btr(data + 1, i); // this is faster! + return core.bitop.btr(data + 1, i); // this is faster! } else version (Asm86) { @@ -150,7 +150,7 @@ struct GCBits { version (bitops) { - return std.intrinsic.bts(data + 1, i); // this is faster! + return core.bitop.bts(data + 1, i); // this is faster! } else version (Asm86) { diff --git a/win32.mak b/win32.mak index c60937f7d1..d8e310275b 100644 --- a/win32.mak +++ b/win32.mak @@ -26,7 +26,6 @@ MANIFEST= \ win32.mak \ \ import\object.di \ - import\std\intrinsic.di \ \ src\object_.d \ \