mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
69
lib/sdk/crt/stdlib/rot.c
Normal file
69
lib/sdk/crt/stdlib/rot.c
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/msvcrt/stdlib/rot.c
|
||||
* PURPOSE: Performs a bitwise rotation
|
||||
* PROGRAMER: Ariadne
|
||||
* UPDATE HISTORY:
|
||||
* 03/04/99: Created
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned int _rotr( unsigned int value, int shift );
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned int _rotl( unsigned int value, int shift )
|
||||
{
|
||||
int max_bits = sizeof(unsigned int)<<3;
|
||||
if ( shift < 0 )
|
||||
return _rotr(value,-shift);
|
||||
|
||||
if ( shift > max_bits )
|
||||
shift = shift % max_bits;
|
||||
return (value << shift) | (value >> (max_bits-shift));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned int _rotr( unsigned int value, int shift )
|
||||
{
|
||||
int max_bits = sizeof(unsigned int)<<3;
|
||||
if ( shift < 0 )
|
||||
return _rotl(value,-shift);
|
||||
|
||||
if ( shift > max_bits<<3 )
|
||||
shift = shift % max_bits;
|
||||
return (value >> shift) | (value << (max_bits-shift));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned long _lrotl( unsigned long value, int shift )
|
||||
{
|
||||
int max_bits = sizeof(unsigned long)<<3;
|
||||
if ( shift < 0 )
|
||||
return _lrotr(value,-shift);
|
||||
|
||||
if ( shift > max_bits )
|
||||
shift = shift % max_bits;
|
||||
return (value << shift) | (value >> (max_bits-shift));
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
unsigned long _lrotr( unsigned long value, int shift )
|
||||
{
|
||||
int max_bits = sizeof(unsigned long)<<3;
|
||||
if ( shift < 0 )
|
||||
return _lrotl(value,-shift);
|
||||
|
||||
if ( shift > max_bits )
|
||||
shift = shift % max_bits;
|
||||
return (value >> shift) | (value << (max_bits-shift));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue