Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
core.bitop's I/O intrinsics should not be pure.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Jul 9, 2012
1 parent dd25606 commit 19c53ff
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/core/bitop.d
Expand Up @@ -15,7 +15,6 @@
module core.bitop;

nothrow:
pure:
@safe:

version( D_InlineAsm_X86_64 )
Expand All @@ -40,7 +39,7 @@ else version( D_InlineAsm_X86 )
* }
* ---
*/
int bsf(size_t v);
int bsf(size_t v) pure;

unittest
{
Expand All @@ -65,7 +64,7 @@ unittest
* }
* ---
*/
int bsr(size_t v);
int bsr(size_t v) pure;

unittest
{
Expand All @@ -75,19 +74,19 @@ unittest
/**
* Tests the bit.
*/
int bt(in size_t* p, size_t bitnum);
int bt(in size_t* p, size_t bitnum) pure;


/**
* Tests and complements the bit.
*/
int btc(size_t* p, size_t bitnum);
int btc(size_t* p, size_t bitnum) pure;


/**
* Tests and resets (sets to 0) the bit.
*/
int btr(size_t* p, size_t bitnum);
int btr(size_t* p, size_t bitnum) pure;


/**
Expand Down Expand Up @@ -139,7 +138,7 @@ int main()
}
* ---
*/
int bts(size_t* p, size_t bitnum);
int bts(size_t* p, size_t bitnum) pure;

unittest
{
Expand Down Expand Up @@ -190,9 +189,9 @@ unittest
* byte 3, byte 1 becomes byte 2, byte 2 becomes byte 1, byte 3
* becomes byte 0.
*/
uint bswap(uint v);
uint bswap(uint v) pure;

@system
@system // not pure
{
/**
* Reads I/O port at port_address.
Expand Down Expand Up @@ -234,7 +233,7 @@ uint bswap(uint v);
/**
* Calculates the number of set bits in a 32-bit integer.
*/
int popcnt( uint x )
int popcnt( uint x ) pure
{
// Avoid branches, and the potential for cache misses which
// could be incurred with a table lookup.
Expand Down Expand Up @@ -281,7 +280,7 @@ unittest
/**
* Reverses the order of bits in a 32-bit integer.
*/
@trusted uint bitswap( uint x )
@trusted uint bitswap( uint x ) pure
{
version (AsmX86)
{
Expand Down

0 comments on commit 19c53ff

Please sign in to comment.