irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

alignPointer.hpp
Go to the documentation of this file.
1 #include <cstdlib>
2 #include "rodsType.h"
3 
4 template<typename T>
5 T alignAddrToBoundary( T ptr, std::size_t boundary ) {
6 #if defined(_LP64) || defined(__LP64__)
7  rodsLong_t b, m;
8  b = ( rodsLong_t ) ptr;
9 
10  m = b % boundary;
11 
12  if ( m == 0 ) {
13  return ptr;
14  }
15 
16  /* rodsLong_t is signed */
17  if ( m < 0 ) {
18  m = boundary + m;
19  }
20 
21  return ( char * )ptr + boundary - m;
22 
23 #else
24  uint b, m;
25  b = ( uint ) ptr;
26 
27  m = b % boundary;
28 
29  if ( m == 0 ) {
30  return ptr;
31  }
32 
33  return ( char * )ptr + boundary - m;
34 
35 #endif
36 }
37 
38 template<typename T>
39 T alignInt( T ptr ) {
40  return alignAddrToBoundary( ptr, 4 );
41 }
42 template<typename T>
43 T alignInt16( T ptr ) {
44  return alignAddrToBoundary( ptr, 2 );
45 }
46 template<typename T>
47 T alignDouble( T ptr ) {
48 #if defined(linux_platform) || defined(windows_platform)
49  // no need align at 64 bit boundary for linux
50  // Windows 32-bit OS is aligned with 4.
51 
52 #if defined(_LP64) || defined(__LP64__)
53  return alignAddrToBoundary( ptr, 8 );
54 #else
55  return alignAddrToBoundary( ptr, 4 );
56 #endif // LP64
57 
58 #else /* non-linux_platform || non-windows*/
59  return alignAddrToBoundary( ptr, 8 );
60 #endif /* linux_platform | windows */
61 }
62 template<typename T>
63 T ialignAddr( T ptr ) {
64 #if defined(_LP64) || defined(__LP64__)
65  return alignDouble( ptr );
66 #else
67  return alignInt( ptr );
68 #endif
69 }
alignInt
T alignInt(T ptr)
Definition: alignPointer.hpp:39
rodsType.h
alignAddrToBoundary
T alignAddrToBoundary(T ptr, std::size_t boundary)
Definition: alignPointer.hpp:5
irods.six.b
def b(s)
Definition: six.py:606
ialignAddr
T ialignAddr(T ptr)
Definition: alignPointer.hpp:63
alignInt16
T alignInt16(T ptr)
Definition: alignPointer.hpp:43
rodsLong_t
long long rodsLong_t
Definition: rodsType.h:32
alignDouble
T alignDouble(T ptr)
Definition: alignPointer.hpp:47