diff --git a/index.d b/index.d
index 81d8832b964..b7c4d714a3f 100644
--- a/index.d
+++ b/index.d
@@ -160,9 +160,6 @@ D language compiler. Also, check out the
std.gc
Control the garbage collector.
- std.intrinsic
- Compiler built in intrinsic functions
-
std.math
Include all the usual math functions like sin, cos, atan, etc.
diff --git a/posix.mak b/posix.mak
index f227c812788..b0d716b1997 100644
--- a/posix.mak
+++ b/posix.mak
@@ -156,7 +156,7 @@ STD_MODULES = $(addprefix std/, algorithm array base64 bigint bitmanip \
compiler complex concurrency container contracts conv cpuid \
cstream ctype date datetime datebase dateparse demangle \
encoding exception file format functional getopt gregorian \
- intrinsic json loader math mathspecial md5 metastrings mmfile \
+ json loader math mathspecial md5 metastrings mmfile \
numeric outbuffer path perf process random range regex regexp \
signals socket socketstream stdint stdio stdiobase stream \
string syserror system traits typecons typetuple uni uri utf \
diff --git a/std.ddoc b/std.ddoc
index 2a71fcbb2d3..6c18030c9ce 100644
--- a/std.ddoc
+++ b/std.ddoc
@@ -177,7 +177,6 @@ NAVIGATION_PHOBOS=
$(LI std.gc)
$(LI std.getopt)
$(LI std.gregorian)
- $(LI std.intrinsic)
$(LI std.json)
$(LI std.math)
$(LI std.mathspecial)
diff --git a/std/array.d b/std/array.d
index 758d33f7b35..d5773bf6a75 100644
--- a/std/array.d
+++ b/std/array.d
@@ -12,9 +12,9 @@ Source: $(PHOBOSSRC std/_array.d)
*/
module std.array;
-import core.memory;
+import core.memory, core.bitop;
import std.algorithm, std.conv, std.ctype, std.encoding, std.exception,
- std.intrinsic, std.range, std.string, std.traits, std.typecons, std.utf;
+ std.range, std.string, std.traits, std.typecons, std.utf;
import std.c.string : memcpy;
version(unittest) import std.stdio, std.typetuple;
diff --git a/std/bitmanip.d b/std/bitmanip.d
index efb6204560c..bd90b7530bb 100644
--- a/std/bitmanip.d
+++ b/std/bitmanip.d
@@ -23,7 +23,7 @@ module std.bitmanip;
//debug = bitarray; // uncomment to turn on debugging printf's
-private import std.intrinsic;
+import core.bitop;
string myToStringx(ulong n)
{ enum s = "0123456789";
diff --git a/std/c/windows/winsock.d b/std/c/windows/winsock.d
index 391c320d259..d5577d1395c 100644
--- a/std/c/windows/winsock.d
+++ b/std/c/windows/winsock.d
@@ -316,7 +316,7 @@ version(BigEndian)
}
else version(LittleEndian)
{
- private import std.intrinsic;
+ private import core.bitop;
uint16_t htons(uint16_t x)
diff --git a/std/intrinsic.d b/std/intrinsic.d
index e5b91877b8a..97f61b72918 100644
--- a/std/intrinsic.d
+++ b/std/intrinsic.d
@@ -3,7 +3,11 @@
// www.digitalmars.com
// Placed into the public domain
-/** These functions are built-in intrinsics to the compiler.
+/**
+ * $(RED This module has been deprecated. Use $(LINK2 core_bitop.html,
+ * core.bitop) instead.)
+ *
+ * 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
@@ -23,160 +27,9 @@
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]);
+deprecated:
- 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);
+pragma(msg, "std.intrinsic has been moved. Please import core.bitop instead.");
+public import core.bitop;
diff --git a/std/numeric.d b/std/numeric.d
index cf75a39b163..8f3584b139e 100644
--- a/std/numeric.d
+++ b/std/numeric.d
@@ -37,9 +37,9 @@ import std.range;
import std.c.stdlib;
import std.functional;
import std.typetuple;
-import std.intrinsic;
import std.complex;
+import core.bitop;
import core.memory;
import core.exception;
@@ -95,8 +95,8 @@ public enum CustomFloatFlags {
none = 0
}
-// 64-bit version of std.intrinsic.bsr
-private int bsr(ulong value) {
+// 64-bit version of core.bitop.bsr
+private int bsr64(ulong value) {
union Ulong {
ulong raw;
struct {
@@ -106,7 +106,7 @@ private int bsr(ulong value) {
}
Ulong v;
v.raw = value;
- return v.high==0 ? std.intrinsic.bsr(v.low) : std.intrinsic.bsr(v.high) + 32;
+ return v.high==0 ? core.bitop.bsr(v.low) : core.bitop.bsr(v.high) + 32;
}
/**
@@ -237,7 +237,7 @@ struct CustomFloat(
// Convert denormalized form to normalized form
((flags&Flags.allowDenorm)&&(exp==0)) ){
if(sig > 0) {
- auto shift2 = precision - bsr(sig);
+ auto shift2 = precision - bsr64(sig);
exp -= shift2-1;
shift += shift2;
} else { // value = 0.0
@@ -2624,8 +2624,6 @@ void slowFourier4(Ret, R)(R range, Ret buf) {
}
bool isPowerOfTwo(size_t num) {
- // BUGS: std.intrinsic takes a uint, not a size_t. Therefore, this
- // won't work on 64-bit unless std.intrinsic is fixed.
return bsr(num) == bsf(num);
}
diff --git a/std/range.d b/std/range.d
index 84dfe66b59c..3e5c28dafb6 100644
--- a/std/range.d
+++ b/std/range.d
@@ -18,7 +18,8 @@ Source: $(PHOBOSSRC std/_range.d)
module std.range;
public import std.array;
-import std.algorithm, std.conv, std.exception, std.functional, std.intrinsic,
+import core.bitop;
+import std.algorithm, std.conv, std.exception, std.functional,
std.random, std.traits, std.typecons, std.typetuple;
// For testing only. This code is included in a string literal to be included
diff --git a/std/stream.d b/std/stream.d
index 2bfb544c316..d648fab190a 100644
--- a/std/stream.d
+++ b/std/stream.d
@@ -75,8 +75,8 @@ private {
import std.conv;
import std.format;
import std.system; // for Endian enumeration
- import std.intrinsic; // for bswap
import std.utf;
+ import core.bitop; // for bswap
import core.vararg;
}
diff --git a/std/zip.d b/std/zip.d
index 071ebc01ece..7972ec8b529 100644
--- a/std/zip.d
+++ b/std/zip.d
@@ -34,7 +34,7 @@ module std.zip;
import std.zlib;
import std.datetime;
-import std.intrinsic;
+import core.bitop;
import std.conv;
//debug=print;
diff --git a/unittest.d b/unittest.d
index 780643d9c56..5a448fdbfcf 100644
--- a/unittest.d
+++ b/unittest.d
@@ -28,7 +28,6 @@ public import std.demangle;
public import std.file;
public import std.format;
public import std.getopt;
-public import std.intrinsic;
public import std.loader;
public import std.math;
public import std.mathspecial;
diff --git a/win32.mak b/win32.mak
index 559c8c005c1..e46a3227e1f 100644
--- a/win32.mak
+++ b/win32.mak
@@ -110,7 +110,6 @@ SRCS_1 = std\math.d std\stdio.d std\dateparse.d std\date.d std\datetime.d \
std\bitmanip.d std\typecons.d \
std\complex.d \
std\exception.d \
- std\intrinsic.d \
std\process.d \
std\system.d \
std\encoding.d
@@ -195,7 +194,6 @@ DOCS= $(DOC)\object.html \
$(DOC)\std_gc.html \
$(DOC)\std_getopt.html \
$(DOC)\std_gregorian.html \
- $(DOC)\std_intrinsic.html \
$(DOC)\std_json.html \
$(DOC)\std_math.html \
$(DOC)\std_mathspecial.html \
@@ -731,9 +729,6 @@ $(DOC)\std_getopt.html : $(STDDOC) std\getopt.d
$(DOC)\std_gregorian.html : $(STDDOC) std\gregorian.d
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_gregorian.html $(STDDOC) std\gregorian.d
-$(DOC)\std_intrinsic.html : $(STDDOC) std\intrinsic.d
- $(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_intrinsic.html $(STDDOC) std\intrinsic.d
-
$(DOC)\std_json.html : $(STDDOC) std\json.d
$(DMD) -c -o- $(DFLAGS) -Df$(DOC)\std_json.html $(STDDOC) std\json.d