ReactOS 0.4.15-dev-8191-gbc6c731
rot.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/sdk/crt/stdlib/rot.c
5 * PURPOSE: Performs a bitwise rotation
6 * PROGRAMER: Ariadne
7 * UPDATE HISTORY:
8 * 03/04/99: Created
9 */
10
11#include <stdlib.h>
12
13#ifdef __clang__
14# define _rotl __function_rotl
15# define _rotr __function_rotr
16# define _lrotl __function_lrotl
17# define _lrotr __function_lrotr
18#elif defined(_MSC_VER)
19# pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr)
20#endif
21
22#if defined (__clang__) && !defined(_MSC_VER)
23# ifdef _M_IX86
24unsigned int _rotr( unsigned int value, int shift ) __asm__("__rotr");
25unsigned long _lrotr(unsigned long value, int shift) __asm__("__lrotr");
26unsigned int _rotl( unsigned int value, int shift ) __asm__("__rotl");
27unsigned long _lrotl( unsigned long value, int shift ) __asm__("__lrotl");
28# else
29unsigned int _rotr( unsigned int value, int shift ) __asm__("_rotr");
30unsigned long _lrotr(unsigned long value, int shift) __asm__("_lrotr");
31unsigned int _rotl( unsigned int value, int shift ) __asm__("_rotl");
32unsigned long _lrotl( unsigned long value, int shift ) __asm__("_lrotl");
33# endif
34#else
35unsigned int _rotr( unsigned int value, int shift );
36unsigned long _lrotr(unsigned long value, int shift);
37unsigned int _rotl( unsigned int value, int shift );
38unsigned long _lrotl( unsigned long value, int shift );
39#endif
40/*
41 * @implemented
42 */
43unsigned int _rotl( unsigned int value, int shift )
44{
45 int max_bits = sizeof(unsigned int)<<3;
46 if ( shift < 0 )
47 return _rotr(value,-shift);
48
49 if ( shift > max_bits )
50 shift = shift % max_bits;
51 return (value << shift) | (value >> (max_bits-shift));
52}
53
54/*
55 * @implemented
56 */
57unsigned int _rotr( unsigned int value, int shift )
58{
59 int max_bits = sizeof(unsigned int)<<3;
60 if ( shift < 0 )
61 return _rotl(value,-shift);
62
63 if ( shift > max_bits )
64 shift = shift % max_bits;
65 return (value >> shift) | (value << (max_bits-shift));
66}
67
68/*
69 * @implemented
70 */
71unsigned long _lrotl( unsigned long value, int shift )
72{
73 int max_bits = sizeof(unsigned long)<<3;
74 if ( shift < 0 )
75 return _lrotr(value,-shift);
76
77 if ( shift > max_bits )
78 shift = shift % max_bits;
79 return (value << shift) | (value >> (max_bits-shift));
80}
81
82/*
83 * @implemented
84 */
85unsigned long _lrotr( unsigned long value, int shift )
86{
87 int max_bits = sizeof(unsigned long)<<3;
88 if ( shift < 0 )
89 return _lrotl(value,-shift);
90
91 if ( shift > max_bits )
92 shift = shift % max_bits;
93 return (value >> shift) | (value << (max_bits-shift));
94}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define shift
Definition: input.c:1755
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tsub %rbp, %rax\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tsub %rax, %rdx\n" "\tmov %rdx, %rbp\n" "\tjmp *%r8\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
#define long
Definition: qsort.c:33
unsigned int _rotl(unsigned int value, int shift)
Definition: rot.c:43
unsigned int _rotr(unsigned int value, int shift)
Definition: rot.c:57
unsigned long _lrotl(unsigned long value, int shift)
Definition: rot.c:71
unsigned long _lrotr(unsigned long value, int shift)
Definition: rot.c:85
Definition: pdh_main.c:94