Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions index.d
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ D language compiler. Also, check out the
<dt><a href="std_gc.html"><b>std.gc</b></a>
<dd>Control the garbage collector.

<dt><a href="std_intrinsic.html"><b>std.intrinsic</b></a>
<dd>Compiler built in intrinsic functions

<dt><a href="std_math.html"><b>std.math</b></a>
<dd>Include all the usual math functions like sin, cos, atan, etc.

Expand Down
2 changes: 1 addition & 1 deletion posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 0 additions & 1 deletion std.ddoc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ NAVIGATION_PHOBOS=
$(LI <a href="std_gc.html" title="Control the garbage collector">std.gc</a>)
$(LI <a href="std_getopt.html" title="Command line options">std.getopt</a>)
$(LI <a href="std_gregorian.html" title="Gregorian Calendar">std.gregorian</a>)
$(LI <a href="std_intrinsic.html" title="Compiler built in intrinsic functions">std.intrinsic</a>)
$(LI <a href="std_json.html" title="JSON reader">std.json</a>)
$(LI <a href="std_math.html" title="the usual math functions">std.math</a>)
$(LI <a href="std_mathspecial.html" title="mathematical special functions">std.mathspecial</a>)
Expand Down
4 changes: 2 additions & 2 deletions std/array.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion std/bitmanip.d
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion std/c/windows/winsock.d
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ version(BigEndian)
}
else version(LittleEndian)
{
private import std.intrinsic;
private import core.bitop;


uint16_t htons(uint16_t x)
Expand Down
163 changes: 8 additions & 155 deletions std/intrinsic.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<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]);
deprecated:

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);
pragma(msg, "std.intrinsic has been moved. Please import core.bitop instead.");

public import core.bitop;

12 changes: 5 additions & 7 deletions std/numeric.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion std/range.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion std/stream.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion std/zip.d
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module std.zip;

import std.zlib;
import std.datetime;
import std.intrinsic;
import core.bitop;
import std.conv;

//debug=print;
Expand Down
1 change: 0 additions & 1 deletion unittest.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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

Expand Down