• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

c4e_elements.h (Version 568)

Go to the documentation of this file.
00001 /****************************** -*- mode: C -*- ******************************/
00013 #ifndef C4E_ELEMENTS_H
00014 #define C4E_ELEMENTS_H
00015 
00016 
00017 /* INCLUDES ******************************************************************/
00018 
00019 #include "c4e_sys.h"
00020 
00021 
00022 #ifdef  __cplusplus
00023 extern "C" {
00024 #endif
00025 
00026 
00027 /* DEFINES *******************************************************************/
00028 
00029 
00030 /* TYPEDEFS ******************************************************************/
00031 
00032 
00040     typedef struct
00041     {
00045         C4eArchIdx size;
00046 
00050         C4eArchDigit* digits;
00051     } C4eElement;
00052 
00053 
00054 
00058     typedef enum
00059     {
00060         C4eElemCmpEQ,                                
00061         C4eElemCmpLT,                 
00062         C4eElemCmpGT               
00063     } C4eElemCmp;
00064 
00065 
00070     typedef struct
00071     {
00072         C4eElement val;                                           
00073         C4eArchSize len;                        
00074     } C4eElemOsp;
00075 
00076 
00080     typedef struct
00081     {
00082         C4eElement x;                                     
00083         C4eElement y;                                    
00084         C4eArchUint attr;                          
00085     } C4eElemPair;
00086 
00087 
00093     typedef struct
00094     {
00095         C4eElement x;             
00096         C4eElement y;   
00097         C4eElement z;          
00098         C4eArchUint attr; 
00099     } C4eElemTriple;
00100 
00101 
00102 
00103 /* MACROS ********************************************************************/
00104 
00105 
00106 
00107 /* MACRO *********************************************************************/
00119 #define C4E_ELEM_ASGN_MEM(elem, digmem) \
00120     ((elem)->digits = (digmem))
00121 
00122 
00123 /* MACRO *********************************************************************/
00133 #define C4E_ELEM_DIGITS_NUM(bytes)                                             \
00134     C4E_SYS_CAST(C4eArchIdx, C4E_SYS_DIV_CEIL((bytes), C4E_ARCH_DIGIT_SIZE))
00135 
00136 
00137 /* MACRO *********************************************************************/
00151 #define C4E_ELEM_IS_ZERO(x)     ((x)->size == 0U)
00152 
00153 
00154 
00155 /* MACRO *********************************************************************/
00169 #define C4E_ELEM_IS_NZERO(x)    (!C4E_ELEM_IS_ZERO(x))
00170 
00171 
00172 
00173 /* MACRO *********************************************************************/
00180 #define C4E_ELEM_SET_ZERO(x)    ((x)->size = 0U)
00181 
00182 
00183 /* MACRO *********************************************************************/
00196 #define C4E_ELEM_IS_ONE(x)     (((x)->size == 1U) && \
00197                                 ((x)->digits[0] == C4E_SYS_DIGIT_ONE))
00198 
00199 
00200 /* MACRO *********************************************************************/
00207 #define C4E_ELEM_SET_ONE(x)                     \
00208     do                                          \
00209     {                                           \
00210         (x)->digits[0] = C4E_SYS_DIGIT_ONE;     \
00211         (x)->size = 1U;                         \
00212     } while (C4E_FALSE)
00213 
00214 
00215 /* MACRO *********************************************************************/
00229 #define C4E_ELEM_IS_EVEN(elem)                                          \
00230     (((elem)->digits[0] & C4E_SYS_DIGIT_ONE) == C4E_SYS_DIGIT_ZERO)
00231 
00232 
00233 
00234 /* MACRO *********************************************************************/
00248 #define C4E_ELEM_IS_ODD(elem)  (!C4E_ELEM_IS_EVEN(elem))
00249 
00250 
00251 /* MACRO *********************************************************************/
00261 #define C4E_ELEM_IS_NORM(x)                                     \
00262     (C4E_ELEM_IS_ZERO(x) ||                                     \
00263      ((x)->digits[(x)->size - 1U] != C4E_SYS_DIGIT_ZERO))
00264 
00265 
00266 
00267 /* MACRO *********************************************************************/
00277 #define C4E_ELEM_MUL2(x)        c4e_elem_bits_shl((x), 1U)
00278 
00279 
00280 
00281 /* MACRO *********************************************************************/
00291 #define C4E_ELEM_DIV2(x)        c4e_elem_bits_shr((x), 1U)
00292 
00293 
00294 
00295 /* MACRO *********************************************************************/
00303 #define C4E_ELEM_ASSERT_IN(x)                                                  \
00304     C4E_ASSERT(((x) != NULL) && (C4E_ELEM_IS_ZERO(x) || ((x)->digits != NULL)))
00305 
00306 
00307 /* MACRO *********************************************************************/
00316 #define C4E_ELEM_ASSERT_PTR(x)                          \
00317     C4E_ASSERT(((x) != NULL) && ((x)->digits != NULL))
00318 
00319 
00320 
00321 /* MACRO *********************************************************************/
00329 #define C4E_ELEM_ASSERT_NORM(x) C4E_ASSERT(C4E_ELEM_IS_NORM(x))
00330 
00331 
00332 
00333 /* MACRO *********************************************************************/
00341 #define C4E_ELEM_ASSERT_NZERO(x)        \
00342     C4E_ASSERT(C4E_ELEM_IS_NZERO(x))
00343 
00344 
00345 
00346 
00347 /* PROTOTYPES ****************************************************************/
00348 
00349 
00350 
00351 /* FUNCTION ******************************************************************/
00366     C4eArchDigit c4e_elem_msb(C4E_CONST C4eElement* x);
00367 
00368 
00369 /* FUNCTION ******************************************************************/
00386     C4eArchSize c4e_elem_bits(C4E_CONST C4eElement* x);
00387 
00388 
00389 /* FUNCTION ******************************************************************/
00398     void c4e_elem_norm(C4eElement* x);
00399 
00400 
00401 /* FUNCTION ******************************************************************/
00410     void c4e_elem_cpy(C4E_CONST C4eElement* C4E_RESTRICT src,
00411                       C4eElement* C4E_RESTRICT dst);
00412 
00413 
00414 /* FUNCTION ******************************************************************/
00426     void c4e_elem_swap(C4eElement* C4E_RESTRICT elem1,
00427                        C4eElement* C4E_RESTRICT elem2);
00428 
00429 
00430 /* FUNCTION ******************************************************************/
00446     void c4e_elem_fill(C4E_CONST C4eElement* x, C4eArchDigit digit);
00447 
00448 
00449 /* FUNCTION ******************************************************************/
00465     C4eSysStatus c4e_elem_rand(C4eElement* x);
00466 
00467 
00468 /* FUNCTION ******************************************************************/
00480     void c4e_elem_digits_shl(C4eElement* x, C4eArchIdx shift);
00481 
00482 
00483 /* FUNCTION ******************************************************************/
00496     void c4e_elem_bits_shl(C4eElement* x, C4eArchUint shift);
00497 
00498 
00499 /* FUNCTION ******************************************************************/
00509     void c4e_elem_shl(C4eElement* x, C4eArchSize shift);
00510 
00511 
00512 
00513 /* FUNCTION ******************************************************************/
00523     void c4e_elem_digits_shr(C4eElement* x, C4eArchIdx shift);
00524 
00525 
00526 /* FUNCTION ******************************************************************/
00539     void c4e_elem_bits_shr(C4eElement* x, C4eArchUint shift);
00540 
00541 
00542 /* FUNCTION ******************************************************************/
00552     void c4e_elem_shr(C4eElement* x, C4eArchSize shift);
00553 
00554 
00555 /* FUNCTION ******************************************************************/
00592     void c4e_elem_os2e(C4E_CONST C4eArchUint8* C4E_RESTRICT osp, C4eArchSize len,
00593                        C4eElement* C4E_RESTRICT elem);
00594 
00595 
00596 /* FUNCTION ******************************************************************/
00642     C4eArchSize c4e_elem_e2os(C4E_CONST C4eElement* C4E_RESTRICT elem,
00643                               C4eArchSize bufsize, C4eArchUint8* C4E_RESTRICT buf);
00644 
00645 
00646 
00647 #ifdef  __cplusplus
00648 }
00649 #endif
00650 
00651 
00652 #endif /* C4E_ELEMENTS_H */
00653 
00654 
00655 /******************************************************************************/
00656 /* END OF FILE                                                                */
00657 /******************************************************************************/

Generated by Ralf Hoppe, Ginsterweg 49, 73230 Kirchheim unter Teck, Germany
on Sun Jun 7 14:10:49 2015 for CRY4E using doxygen 1.6.1