lib/C/iec_std_functions.h
changeset 1021 21a97cdb317d
parent 1011 76175defb87b
child 1063 b5b48b6f7606
equal deleted inserted replaced
1008:59435d4c5e0c 1021:21a97cdb317d
    80  
    80  
    81 
    81 
    82 /********************/
    82 /********************/
    83 /*   EN/ENO PARAMS  */
    83 /*   EN/ENO PARAMS  */
    84 /********************/
    84 /********************/
    85 
    85 #ifdef DISABLE_EN_ENO_PARAMETERS
    86 #define EN_ENO_PARAMS BOOL EN, BOOL *ENO
    86 
    87 #define EN_ENO EN, ENO
    87   /* Do _not_ generate the EN and ENO parameters! */
    88 
    88   #define EN_ENO_PARAMS
    89 #define TEST_EN(TYPENAME)\
    89   #define EN_ENO
    90   if (!EN) {\
    90 
    91     if (ENO != NULL)\
    91   #define TEST_EN(TYPENAME)
    92       *ENO = __BOOL_LITERAL(FALSE);\
    92   #define TEST_EN_COND(TYPENAME, COND)
    93     return __INIT_##TYPENAME;\
    93 
    94   }\
    94 #else
    95   else if (ENO != NULL)\
    95     
    96     *ENO = __BOOL_LITERAL(TRUE);
    96   /* _Do_ generate the EN and ENO parameters! */
    97 
    97   #define EN_ENO_PARAMS BOOL EN, BOOL *ENO,
    98 #define TEST_EN_COND(TYPENAME, COND)\
    98   #define EN_ENO EN, ENO,
    99   if (!EN || (COND)) {\
    99 
   100     if (ENO != NULL)\
   100   #define TEST_EN(TYPENAME)\
   101       *ENO = __BOOL_LITERAL(FALSE);\
   101     if (!EN) {\
   102     return __INIT_##TYPENAME;\
   102       if (ENO != NULL)\
   103   }\
   103         *ENO = __BOOL_LITERAL(FALSE);\
   104   else if (ENO != NULL)\
   104       return __INIT_##TYPENAME;\
   105     *ENO = __BOOL_LITERAL(TRUE);
   105     }\
   106 
   106     else if (ENO != NULL)\
       
   107       *ENO = __BOOL_LITERAL(TRUE);
       
   108 
       
   109   #define TEST_EN_COND(TYPENAME, COND)\
       
   110     if (!EN || (COND)) {\
       
   111       if (ENO != NULL)\
       
   112         *ENO = __BOOL_LITERAL(FALSE);\
       
   113       return __INIT_##TYPENAME;\
       
   114     }\
       
   115     else if (ENO != NULL)\
       
   116       *ENO = __BOOL_LITERAL(TRUE);
       
   117     
       
   118 #endif
   107   
   119   
   108   
   120   
   109 /*****************************************/  
   121 /*****************************************/  
   110 /*****************************************/  
   122 /*****************************************/  
   111 /*  2.5.1.5.1 Type Conversion Functions  */
   123 /*  2.5.1.5.1 Type Conversion Functions  */
   112 /*****************************************/  
   124 /*****************************************/  
   113 /*****************************************/  
   125 /*****************************************/  
   114 
   126 
   115 #define __convert_type(from_TYPENAME,to_TYPENAME, oper) \
   127 #define __convert_type(from_TYPENAME,to_TYPENAME, oper) \
   116 static inline to_TYPENAME from_TYPENAME##_TO_##to_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   128 static inline to_TYPENAME from_TYPENAME##_TO_##to_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   117   TEST_EN(to_TYPENAME)\
   129   TEST_EN(to_TYPENAME)\
   118   return (to_TYPENAME)oper(op);\
   130   return (to_TYPENAME)oper(op);\
   119 }
   131 }
   120 
   132 
   121 /******** [ANY_NUM | ANY_NBIT]_TO_BOOL   ************/
   133 /******** [ANY_NUM | ANY_NBIT]_TO_BOOL   ************/
   122 #define __convert_num_to_bool(TYPENAME) \
   134 #define __convert_num_to_bool(TYPENAME) \
   123 static inline BOOL TYPENAME##_TO_BOOL(EN_ENO_PARAMS, TYPENAME op){\
   135 static inline BOOL TYPENAME##_TO_BOOL(EN_ENO_PARAMS TYPENAME op){\
   124   TEST_EN(BOOL)\
   136   TEST_EN(BOOL)\
   125   return op == 0 ? 0 : 1;\
   137   return op == 0 ? 0 : 1;\
   126 }
   138 }
   127 __ANY_NUM(__convert_num_to_bool)
   139 __ANY_NUM(__convert_num_to_bool)
   128 __ANY_NBIT(__convert_num_to_bool)
   140 __ANY_NBIT(__convert_num_to_bool)
   129 
   141 
   130 /******** [TIME | ANY_DATE]_TO_BOOL   ************/
   142 /******** [TIME | ANY_DATE]_TO_BOOL   ************/
   131 #define __convert_time_to_bool(TYPENAME) \
   143 #define __convert_time_to_bool(TYPENAME) \
   132 static inline BOOL TYPENAME##_TO_BOOL(EN_ENO_PARAMS, TYPENAME op){\
   144 static inline BOOL TYPENAME##_TO_BOOL(EN_ENO_PARAMS TYPENAME op){\
   133   TEST_EN(BOOL)\
   145   TEST_EN(BOOL)\
   134   return op.tv_sec == 0 && op.tv_nsec == 0 ? 0 : 1;\
   146   return op.tv_sec == 0 && op.tv_nsec == 0 ? 0 : 1;\
   135 }
   147 }
   136 __convert_time_to_bool(TIME)
   148 __convert_time_to_bool(TIME)
   137 __ANY_DATE(__convert_time_to_bool)
   149 __ANY_DATE(__convert_time_to_bool)
   209 
   221 
   210 
   222 
   211 /******** [ANY_DATE]_TO_[ANY_DATE | TIME]   ************/ 
   223 /******** [ANY_DATE]_TO_[ANY_DATE | TIME]   ************/ 
   212 /* Not supported: DT_TO_TIME */
   224 /* Not supported: DT_TO_TIME */
   213 __convert_type(DT, DATE,  __date_and_time_to_date)
   225 __convert_type(DT, DATE,  __date_and_time_to_date)
   214 static inline DATE DATE_AND_TIME_TO_DATE(EN_ENO_PARAMS, DT op){
   226 static inline DATE DATE_AND_TIME_TO_DATE(EN_ENO_PARAMS DT op){
   215 	return DT_TO_DATE(EN_ENO, op);
   227 	return DT_TO_DATE(EN_ENO op);
   216 }
   228 }
   217 __convert_type(DT, DT,    __move_DT)
   229 __convert_type(DT, DT,    __move_DT)
   218 __convert_type(DT, TOD,   __date_and_time_to_time_of_day)
   230 __convert_type(DT, TOD,   __date_and_time_to_time_of_day)
   219 static inline DATE DATE_AND_TIME_TO_TIME_OF_DAY(EN_ENO_PARAMS, DT op){
   231 static inline DATE DATE_AND_TIME_TO_TIME_OF_DAY(EN_ENO_PARAMS DT op){
   220 	return DT_TO_TOD(EN_ENO, op);
   232 	return DT_TO_TOD(EN_ENO op);
   221 }
   233 }
   222 /* Not supported: DATE_TO_TIME */
   234 /* Not supported: DATE_TO_TIME */
   223 __convert_type(DATE, DATE, __move_DATE)
   235 __convert_type(DATE, DATE, __move_DATE)
   224 /* Not supported: DATE_TO_DT */
   236 /* Not supported: DATE_TO_DT */
   225 /* Not supported: DATE_TO_TOD */
   237 /* Not supported: DATE_TO_TOD */
   294 __convert_type(STRING, TIME, __string_to_time)
   306 __convert_type(STRING, TIME, __string_to_time)
   295 
   307 
   296 
   308 
   297 /********   TRUNC   ************/ 
   309 /********   TRUNC   ************/ 
   298 #define __iec_(to_TYPENAME,from_TYPENAME) \
   310 #define __iec_(to_TYPENAME,from_TYPENAME) \
   299 static inline to_TYPENAME TRUNC__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   311 static inline to_TYPENAME TRUNC__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   300   TEST_EN(to_TYPENAME)\
   312   TEST_EN(to_TYPENAME)\
   301   return (to_TYPENAME)__move_##to_TYPENAME(op);\
   313   return (to_TYPENAME)__move_##to_TYPENAME(op);\
   302 }
   314 }
   303 __ANY_REAL(__to_anyint_)
   315 __ANY_REAL(__to_anyint_)
   304 #undef __iec_
   316 #undef __iec_
   305 
   317 
   306 
   318 
   307 /********   _TO_BCD   ************/
   319 /********   _TO_BCD   ************/
   308 #define __iec_(to_TYPENAME,from_TYPENAME) \
   320 #define __iec_(to_TYPENAME,from_TYPENAME) \
   309 static inline to_TYPENAME from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   321 static inline to_TYPENAME from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   310   TEST_EN(to_TYPENAME)\
   322   TEST_EN(to_TYPENAME)\
   311   return (to_TYPENAME)__uint_to_bcd(op);\
   323   return (to_TYPENAME)__uint_to_bcd(op);\
   312 }\
   324 }\
   313 static inline to_TYPENAME from_TYPENAME##_TO_BCD__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   325 static inline to_TYPENAME from_TYPENAME##_TO_BCD__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   314   return from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO, op);\
   326   return from_TYPENAME##_TO_BCD_##to_TYPENAME(EN_ENO op);\
   315 }
   327 }
   316 __ANY_UINT(__to_anynbit_)
   328 __ANY_UINT(__to_anynbit_)
   317 #undef __iec_
   329 #undef __iec_
   318 
   330 
   319 
   331 
   320 /********   BCD_TO_   ************/
   332 /********   BCD_TO_   ************/
   321 #define __iec_(to_TYPENAME,from_TYPENAME) \
   333 #define __iec_(to_TYPENAME,from_TYPENAME) \
   322 static inline to_TYPENAME from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   334 static inline to_TYPENAME from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   323   TEST_EN_COND(to_TYPENAME, __test_bcd(op))\
   335   TEST_EN_COND(to_TYPENAME, __test_bcd(op))\
   324   return (to_TYPENAME)__bcd_to_uint(op);\
   336   return (to_TYPENAME)__bcd_to_uint(op);\
   325 }\
   337 }\
   326 static inline to_TYPENAME BCD_TO_##to_TYPENAME##__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS, from_TYPENAME op){\
   338 static inline to_TYPENAME BCD_TO_##to_TYPENAME##__##to_TYPENAME##__##from_TYPENAME(EN_ENO_PARAMS from_TYPENAME op){\
   327   return from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO, op);\
   339   return from_TYPENAME##_BCD_TO_##to_TYPENAME(EN_ENO op);\
   328 }
   340 }
   329 __ANY_NBIT(__to_anyuint_)
   341 __ANY_NBIT(__to_anyuint_)
   330 #undef __iec_
   342 #undef __iec_
   331 
   343 
   332 
   344 
   360 #define VA_ARGS_DT DT
   372 #define VA_ARGS_DT DT
   361 
   373 
   362 
   374 
   363 #define __numeric(fname,TYPENAME, FUNC) \
   375 #define __numeric(fname,TYPENAME, FUNC) \
   364 /* explicitly typed function */\
   376 /* explicitly typed function */\
   365 static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
   377 static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS TYPENAME op){\
   366   TEST_EN(TYPENAME)\
   378   TEST_EN(TYPENAME)\
   367   return FUNC(op);\
   379   return FUNC(op);\
   368 }\
   380 }\
   369 /* overloaded function */\
   381 /* overloaded function */\
   370 static inline TYPENAME fname##_##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op) {\
   382 static inline TYPENAME fname##_##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op) {\
   371   return fname##TYPENAME(EN_ENO, op);\
   383   return fname##TYPENAME(EN_ENO op);\
   372 }
   384 }
   373 
   385 
   374 /******************************************************************/
   386 /******************************************************************/
   375 /***   Table 23 - Standard functions of one numeric variable    ***/
   387 /***   Table 23 - Standard functions of one numeric variable    ***/
   376 /******************************************************************/
   388 /******************************************************************/
   378   /**************/
   390   /**************/
   379   /*    ABS     */
   391   /*    ABS     */
   380   /**************/
   392   /**************/
   381 #define __abs_signed(TYPENAME) \
   393 #define __abs_signed(TYPENAME) \
   382 /* explicitly typed function */\
   394 /* explicitly typed function */\
   383 static inline TYPENAME ABS_##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
   395 static inline TYPENAME ABS_##TYPENAME(EN_ENO_PARAMS TYPENAME op){\
   384   TEST_EN(TYPENAME)\
   396   TEST_EN(TYPENAME)\
   385   if (op < 0)\
   397   if (op < 0)\
   386     return -op;\
   398     return -op;\
   387   return op;\
   399   return op;\
   388 }\
   400 }\
   389 /* overloaded function */\
   401 /* overloaded function */\
   390 static inline TYPENAME ABS__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op) {\
   402 static inline TYPENAME ABS__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op) {\
   391   return ABS_##TYPENAME(EN_ENO, op);\
   403   return ABS_##TYPENAME(EN_ENO op);\
   392 }
   404 }
   393 
   405 
   394 #define __abs_unsigned(TYPENAME) \
   406 #define __abs_unsigned(TYPENAME) \
   395 /* explicitly typed function */\
   407 /* explicitly typed function */\
   396 static inline TYPENAME ABS_##TYPENAME(EN_ENO_PARAMS, TYPENAME op){\
   408 static inline TYPENAME ABS_##TYPENAME(EN_ENO_PARAMS TYPENAME op){\
   397   TEST_EN(TYPENAME)\
   409   TEST_EN(TYPENAME)\
   398   return op;\
   410   return op;\
   399 }\
   411 }\
   400 /* overloaded function */\
   412 /* overloaded function */\
   401 static inline TYPENAME ABS__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op) {\
   413 static inline TYPENAME ABS__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op) {\
   402   return ABS_##TYPENAME(EN_ENO, op);\
   414   return ABS_##TYPENAME(EN_ENO op);\
   403 }
   415 }
   404 
   416 
   405 __ANY_REAL(__abs_signed)
   417 __ANY_REAL(__abs_signed)
   406 __ANY_SINT(__abs_signed)
   418 __ANY_SINT(__abs_signed)
   407 __ANY_UINT(__abs_unsigned)
   419 __ANY_UINT(__abs_unsigned)
   478 /*****************************************************/
   490 /*****************************************************/
   479 /***   Table 24 - Standard arithmetic functions    ***/
   491 /***   Table 24 - Standard arithmetic functions    ***/
   480 /*****************************************************/
   492 /*****************************************************/
   481 
   493 
   482 #define __arith_expand(fname,TYPENAME, OP)\
   494 #define __arith_expand(fname,TYPENAME, OP)\
   483 static inline TYPENAME fname(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
   495 static inline TYPENAME fname(EN_ENO_PARAMS UINT param_count, TYPENAME op1, ...){\
   484   va_list ap;\
   496   va_list ap;\
   485   UINT i;\
   497   UINT i;\
   486   TEST_EN(TYPENAME)\
   498   TEST_EN(TYPENAME)\
   487   \
   499   \
   488   va_start (ap, op1);         /* Initialize the argument list.  */\
   500   va_start (ap, op1);         /* Initialize the argument list.  */\
   495   return op1;\
   507   return op1;\
   496 }
   508 }
   497 
   509 
   498 #define __arith_static(fname,TYPENAME, OP)\
   510 #define __arith_static(fname,TYPENAME, OP)\
   499 /* explicitly typed function */\
   511 /* explicitly typed function */\
   500 static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   512 static inline TYPENAME fname##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   501   TEST_EN(TYPENAME)\
   513   TEST_EN(TYPENAME)\
   502   return op1 OP op2;\
   514   return op1 OP op2;\
   503 }\
   515 }\
   504 /* overloaded function */\
   516 /* overloaded function */\
   505 static inline TYPENAME fname##_##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   517 static inline TYPENAME fname##_##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   506   return fname##TYPENAME(EN_ENO, op1, op2);\
   518   return fname##TYPENAME(EN_ENO op1, op2);\
   507 }
   519 }
   508 
   520 
   509   /**************/
   521   /**************/
   510   /*     ADD    */
   522   /*     ADD    */
   511   /**************/
   523   /**************/
   534   /**************/
   546   /**************/
   535   /*     DIV    */
   547   /*     DIV    */
   536   /**************/
   548   /**************/
   537 #define __div(TYPENAME)\
   549 #define __div(TYPENAME)\
   538 /* The explicitly typed standard functions */\
   550 /* The explicitly typed standard functions */\
   539 static inline TYPENAME DIV_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   551 static inline TYPENAME DIV_##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   540   TEST_EN_COND(TYPENAME, op2 == 0)\
   552   TEST_EN_COND(TYPENAME, op2 == 0)\
   541   return op1 / op2;\
   553   return op1 / op2;\
   542 }\
   554 }\
   543 /* The overloaded standard functions */\
   555 /* The overloaded standard functions */\
   544 static inline TYPENAME DIV__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   556 static inline TYPENAME DIV__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   545   return DIV_##TYPENAME(EN_ENO, op1, op2);\
   557   return DIV_##TYPENAME(EN_ENO op1, op2);\
   546 }
   558 }
   547 __ANY_NUM(__div)
   559 __ANY_NUM(__div)
   548 
   560 
   549 
   561 
   550   /**************/
   562   /**************/
   551   /*     MOD    */
   563   /*     MOD    */
   552   /**************/
   564   /**************/
   553 #define __mod(TYPENAME)\
   565 #define __mod(TYPENAME)\
   554 /* The explicitly typed standard functions */\
   566 /* The explicitly typed standard functions */\
   555 static inline TYPENAME MOD_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   567 static inline TYPENAME MOD_##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   556   TEST_EN(TYPENAME)\
   568   TEST_EN(TYPENAME)\
   557   if (op2 == 0) return 0;\
   569   if (op2 == 0) return 0;\
   558   return op1 % op2;\
   570   return op1 % op2;\
   559 }\
   571 }\
   560 /* The overloaded standard functions */\
   572 /* The overloaded standard functions */\
   561 static inline TYPENAME MOD__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
   573 static inline TYPENAME MOD__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
   562   return MOD_##TYPENAME(EN_ENO, op1, op2);\
   574   return MOD_##TYPENAME(EN_ENO op1, op2);\
   563 }
   575 }
   564 __ANY_INT(__mod)
   576 __ANY_INT(__mod)
   565 
   577 
   566   /**************/
   578   /**************/
   567   /*    EXPT    */
   579   /*    EXPT    */
   568   /**************/
   580   /**************/
   569 /* overloaded function */
   581 /* overloaded function */
   570 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   582 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   571 static inline in1_TYPENAME EXPT__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME\
   583 static inline in1_TYPENAME EXPT__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME\
   572   (EN_ENO_PARAMS, in1_TYPENAME IN1, in2_TYPENAME IN2){\
   584   (EN_ENO_PARAMS in1_TYPENAME IN1, in2_TYPENAME IN2){\
   573   TEST_EN(in1_TYPENAME)\
   585   TEST_EN(in1_TYPENAME)\
   574   return pow(IN1, IN2);\
   586   return __expt(IN1, IN2);\
   575 }
   587 }
   576 #define __in1_anyreal_(in2_TYPENAME)   __ANY_REAL_1(__iec_,in2_TYPENAME)
   588 #define __in1_anyreal_(in2_TYPENAME)   __ANY_REAL_1(__iec_,in2_TYPENAME)
   577 __ANY_NUM(__in1_anyreal_)
   589 __ANY_NUM(__in1_anyreal_)
   578 #undef __iec_
   590 #undef __iec_
   579 
   591 
   582   /***************/
   594   /***************/
   583   /*     MOVE    */
   595   /*     MOVE    */
   584   /***************/
   596   /***************/
   585 /* The explicitly typed standard functions */
   597 /* The explicitly typed standard functions */
   586 #define __iec_(TYPENAME)\
   598 #define __iec_(TYPENAME)\
   587 static inline TYPENAME MOVE_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
   599 static inline TYPENAME MOVE_##TYPENAME(EN_ENO_PARAMS TYPENAME op1){\
   588   TEST_EN(TYPENAME)\
   600   TEST_EN(TYPENAME)\
   589   return op1;\
   601   return op1;\
   590 }
   602 }
   591 __ANY(__iec_)
   603 __ANY(__iec_)
   592 #undef __iec_
   604 #undef __iec_
   593 
   605 
   594 /* Overloaded function */
   606 /* Overloaded function */
   595 #define __iec_(TYPENAME)\
   607 #define __iec_(TYPENAME)\
   596 static inline TYPENAME MOVE__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
   608 static inline TYPENAME MOVE__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op1){\
   597   TEST_EN(TYPENAME)\
   609   TEST_EN(TYPENAME)\
   598   return op1;\
   610   return op1;\
   599 }
   611 }
   600 __ANY(__iec_)
   612 __ANY(__iec_)
   601 #undef __iec_
   613 #undef __iec_
   619  * See note above regarding explicitly typed functions for more details.
   631  * See note above regarding explicitly typed functions for more details.
   620  */
   632  */
   621 #define __in1_anynbit_(in2_TYPENAME)   __ANY_NBIT_1(__iec_,in2_TYPENAME)
   633 #define __in1_anynbit_(in2_TYPENAME)   __ANY_NBIT_1(__iec_,in2_TYPENAME)
   622 
   634 
   623 #define __shift_(fname, in1_TYPENAME, in2_TYPENAME, OP)\
   635 #define __shift_(fname, in1_TYPENAME, in2_TYPENAME, OP)\
   624 static inline in1_TYPENAME fname(EN_ENO_PARAMS, in1_TYPENAME IN, in2_TYPENAME N) {\
   636 static inline in1_TYPENAME fname(EN_ENO_PARAMS in1_TYPENAME IN, in2_TYPENAME N) {\
   625   TEST_EN(in1_TYPENAME)\
   637   TEST_EN(in1_TYPENAME)\
   626   return IN OP N;\
   638   return IN OP N;\
   627 }
   639 }
   628 
   640 
   629   /**************/
   641   /**************/
   630   /*     SHL    */
   642   /*     SHL    */
   631   /**************/
   643   /**************/
   632 #define __iec_(TYPENAME) \
   644 #define __iec_(TYPENAME) \
   633 /* Overloaded function */\
   645 /* Overloaded function */\
   634 static inline BOOL SHL__BOOL__##TYPENAME(EN_ENO_PARAMS, BOOL IN, TYPENAME N) { \
   646 static inline BOOL SHL__BOOL__##TYPENAME(EN_ENO_PARAMS BOOL IN, TYPENAME N) { \
   635   TEST_EN(BOOL);\
   647   TEST_EN(BOOL);\
   636   return (N==0)? IN : __INIT_BOOL;  /* shifting by N>1 will always introduce a 0 */\
   648   return (N==0)? IN : __INIT_BOOL;  /* shifting by N>1 will always introduce a 0 */\
   637 }
   649 }
   638 __ANY_INT(__iec_)
   650 __ANY_INT(__iec_)
   639 #undef __iec_
   651 #undef __iec_
   648   /**************/
   660   /**************/
   649   /*     SHR    */
   661   /*     SHR    */
   650   /**************/
   662   /**************/
   651 #define __iec_(TYPENAME) \
   663 #define __iec_(TYPENAME) \
   652 /* Overloaded function */\
   664 /* Overloaded function */\
   653 static inline BOOL SHR__BOOL__##TYPENAME(EN_ENO_PARAMS, BOOL IN, TYPENAME N) { \
   665 static inline BOOL SHR__BOOL__##TYPENAME(EN_ENO_PARAMS BOOL IN, TYPENAME N) { \
   654   TEST_EN(BOOL);\
   666   TEST_EN(BOOL);\
   655   return (N==0)? IN : __INIT_BOOL;  /* shifting by N>1 will always introduce a 0 */\
   667   return (N==0)? IN : __INIT_BOOL;  /* shifting by N>1 will always introduce a 0 */\
   656 }
   668 }
   657 __ANY_INT(__iec_)
   669 __ANY_INT(__iec_)
   658 #undef __iec_
   670 #undef __iec_
   667   /**************/
   679   /**************/
   668   /*     ROR    */
   680   /*     ROR    */
   669   /**************/
   681   /**************/
   670 #define __iec_(TYPENAME) \
   682 #define __iec_(TYPENAME) \
   671 /* Overloaded function */\
   683 /* Overloaded function */\
   672 static inline BOOL ROR__BOOL__##TYPENAME(EN_ENO_PARAMS, BOOL IN, TYPENAME N) { \
   684 static inline BOOL ROR__BOOL__##TYPENAME(EN_ENO_PARAMS BOOL IN, TYPENAME N) { \
   673   TEST_EN(BOOL);\
   685   TEST_EN(BOOL);\
   674   return IN; /* rotating a single bit by any value N will not change that bit! */\
   686   return IN; /* rotating a single bit by any value N will not change that bit! */\
   675 }
   687 }
   676 __ANY_INT(__iec_)
   688 __ANY_INT(__iec_)
   677 #undef __iec_
   689 #undef __iec_
   678 
   690 
   679 
   691 
   680 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   692 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   681 static inline in1_TYPENAME ROR__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS, in1_TYPENAME IN, in2_TYPENAME N){\
   693 static inline in1_TYPENAME ROR__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS in1_TYPENAME IN, in2_TYPENAME N){\
   682   TEST_EN(in1_TYPENAME)\
   694   TEST_EN(in1_TYPENAME)\
   683   N %= 8*sizeof(in1_TYPENAME);\
   695   N %= 8*sizeof(in1_TYPENAME);\
   684   return (IN >> N) | (IN << (8*sizeof(in1_TYPENAME)-N));\
   696   return (IN >> N) | (IN << (8*sizeof(in1_TYPENAME)-N));\
   685 }
   697 }
   686 __ANY_INT(__in1_anynbit_)
   698 __ANY_INT(__in1_anynbit_)
   690   /**************/
   702   /**************/
   691   /*     ROL    */
   703   /*     ROL    */
   692   /**************/
   704   /**************/
   693 #define __iec_(TYPENAME) \
   705 #define __iec_(TYPENAME) \
   694 /* Overloaded function */\
   706 /* Overloaded function */\
   695 static inline BOOL ROL__BOOL__##TYPENAME(EN_ENO_PARAMS, BOOL IN, TYPENAME N) { \
   707 static inline BOOL ROL__BOOL__##TYPENAME(EN_ENO_PARAMS BOOL IN, TYPENAME N) { \
   696   TEST_EN(BOOL);\
   708   TEST_EN(BOOL);\
   697   return IN; /* rotating a single bit by any value N will not change that bit! */\
   709   return IN; /* rotating a single bit by any value N will not change that bit! */\
   698 }
   710 }
   699 __ANY_INT(__iec_)
   711 __ANY_INT(__iec_)
   700 #undef __iec_
   712 #undef __iec_
   701 
   713 
   702 
   714 
   703 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   715 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   704 static inline in1_TYPENAME ROL__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS, in1_TYPENAME IN, in2_TYPENAME N){\
   716 static inline in1_TYPENAME ROL__##in1_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS in1_TYPENAME IN, in2_TYPENAME N){\
   705   TEST_EN(in1_TYPENAME)\
   717   TEST_EN(in1_TYPENAME)\
   706   N %= 8*sizeof(in1_TYPENAME);\
   718   N %= 8*sizeof(in1_TYPENAME);\
   707   return (IN << N) | (IN >> (8*sizeof(in1_TYPENAME)-N));\
   719   return (IN << N) | (IN >> (8*sizeof(in1_TYPENAME)-N));\
   708 }
   720 }
   709 __ANY_INT(__in1_anynbit_)
   721 __ANY_INT(__in1_anynbit_)
   741 
   753 
   742   /**************/
   754   /**************/
   743   /*     XOR    */
   755   /*     XOR    */
   744   /**************/
   756   /**************/
   745 #define __xorbool_expand(fname) \
   757 #define __xorbool_expand(fname) \
   746 static inline BOOL fname(EN_ENO_PARAMS, UINT param_count, BOOL op1, ...){ \
   758 static inline BOOL fname(EN_ENO_PARAMS UINT param_count, BOOL op1, ...){ \
   747   va_list ap; \
   759   va_list ap; \
   748   UINT i; \
   760   UINT i; \
   749   TEST_EN(BOOL) \
   761   TEST_EN(BOOL) \
   750 \
   762 \
   751   va_start (ap, op1);         /* Initialize the argument list.  */ \
   763   va_start (ap, op1);         /* Initialize the argument list.  */ \
   771 
   783 
   772   /**************/
   784   /**************/
   773   /*     NOT    */
   785   /*     NOT    */
   774   /**************/
   786   /**************/
   775 /* The explicitly typed standard functions */
   787 /* The explicitly typed standard functions */
   776 static inline BOOL NOT_BOOL(EN_ENO_PARAMS, BOOL op1){
   788 static inline BOOL NOT_BOOL(EN_ENO_PARAMS BOOL op1){
   777   TEST_EN(BOOL)
   789   TEST_EN(BOOL)
   778   return !op1;
   790   return !op1;
   779 }
   791 }
   780 
   792 
   781 /* Overloaded function */
   793 /* Overloaded function */
   782 static inline BOOL NOT__BOOL__BOOL(EN_ENO_PARAMS, BOOL op1){
   794 static inline BOOL NOT__BOOL__BOOL(EN_ENO_PARAMS BOOL op1){
   783   TEST_EN(BOOL)
   795   TEST_EN(BOOL)
   784   return !op1;
   796   return !op1;
   785 }
   797 }
   786 
   798 
   787 /* The explicitly typed standard functions */
   799 /* The explicitly typed standard functions */
   788 #define __iec_(TYPENAME)\
   800 #define __iec_(TYPENAME)\
   789 static inline TYPENAME NOT_##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
   801 static inline TYPENAME NOT_##TYPENAME(EN_ENO_PARAMS TYPENAME op1){\
   790   TEST_EN(TYPENAME)\
   802   TEST_EN(TYPENAME)\
   791   return ~op1;\
   803   return ~op1;\
   792 }
   804 }
   793 __ANY_NBIT(__iec_)
   805 __ANY_NBIT(__iec_)
   794 #undef __iec_
   806 #undef __iec_
   795 
   807 
   796 /* Overloaded function */
   808 /* Overloaded function */
   797 #define __iec_(TYPENAME)\
   809 #define __iec_(TYPENAME)\
   798 static inline TYPENAME NOT__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME op1){\
   810 static inline TYPENAME NOT__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME op1){\
   799   TEST_EN(TYPENAME)\
   811   TEST_EN(TYPENAME)\
   800   return ~op1;\
   812   return ~op1;\
   801 }
   813 }
   802 __ANY_NBIT(__iec_)
   814 __ANY_NBIT(__iec_)
   803 #undef __iec_
   815 #undef __iec_
   822     /*    SEL     */
   834     /*    SEL     */
   823     /**************/
   835     /**************/
   824 
   836 
   825 /* The explicitly typed standard functions */
   837 /* The explicitly typed standard functions */
   826 #define __iec_(TYPENAME)\
   838 #define __iec_(TYPENAME)\
   827 static inline TYPENAME SEL_##TYPENAME(EN_ENO_PARAMS, BOOL G, TYPENAME op0, TYPENAME op1){\
   839 static inline TYPENAME SEL_##TYPENAME(EN_ENO_PARAMS BOOL G, TYPENAME op0, TYPENAME op1){\
   828   TEST_EN(TYPENAME)\
   840   TEST_EN(TYPENAME)\
   829   return G ? op1 : op0;\
   841   return G ? op1 : op0;\
   830 }
   842 }
   831 __ANY(__iec_)
   843 __ANY(__iec_)
   832 #undef __iec_
   844 #undef __iec_
   833 
   845 
   834 /* Overloaded function */
   846 /* Overloaded function */
   835 #define __iec_(TYPENAME)\
   847 #define __iec_(TYPENAME)\
   836 static inline TYPENAME SEL__##TYPENAME##__BOOL__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, BOOL G, TYPENAME op0, TYPENAME op1){\
   848 static inline TYPENAME SEL__##TYPENAME##__BOOL__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS BOOL G, TYPENAME op0, TYPENAME op1){\
   837   TEST_EN(TYPENAME)\
   849   TEST_EN(TYPENAME)\
   838   return G ? op1 : op0;\
   850   return G ? op1 : op0;\
   839 }
   851 }
   840 __ANY(__iec_)
   852 __ANY(__iec_)
   841 #undef __iec_
   853 #undef __iec_
   844     /**************/
   856     /**************/
   845     /*     MAX    */
   857     /*     MAX    */
   846     /**************/
   858     /**************/
   847 
   859 
   848 #define __extrem_(fname,TYPENAME, COND) \
   860 #define __extrem_(fname,TYPENAME, COND) \
   849 static inline TYPENAME fname(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
   861 static inline TYPENAME fname(EN_ENO_PARAMS UINT param_count, TYPENAME op1, ...){\
   850   va_list ap;\
   862   va_list ap;\
   851   UINT i;\
   863   UINT i;\
   852   TEST_EN(TYPENAME)\
   864   TEST_EN(TYPENAME)\
   853   \
   865   \
   854   va_start (ap, op1);         /* Initialize the argument list.  */\
   866   va_start (ap, op1);         /* Initialize the argument list.  */\
   912     /**************/
   924     /**************/
   913 
   925 
   914 /* Limit for numerical data types */
   926 /* Limit for numerical data types */
   915 #define __iec_(TYPENAME)\
   927 #define __iec_(TYPENAME)\
   916 /* The explicitly typed standard functions */\
   928 /* The explicitly typed standard functions */\
   917 static inline TYPENAME LIMIT_##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   929 static inline TYPENAME LIMIT_##TYPENAME(EN_ENO_PARAMS TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   918   TEST_EN(TYPENAME)\
   930   TEST_EN(TYPENAME)\
   919   return IN > MN ? IN < MX ? IN : MX : MN;\
   931   return IN > MN ? IN < MX ? IN : MX : MN;\
   920 }\
   932 }\
   921 /* Overloaded function */\
   933 /* Overloaded function */\
   922 static inline TYPENAME LIMIT__##TYPENAME##__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   934 static inline TYPENAME LIMIT__##TYPENAME##__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   923   TEST_EN(TYPENAME)\
   935   TEST_EN(TYPENAME)\
   924   return IN > MN ? IN < MX ? IN : MX : MN;\
   936   return IN > MN ? IN < MX ? IN : MX : MN;\
   925 }
   937 }
   926 __ANY_NBIT(__iec_)
   938 __ANY_NBIT(__iec_)
   927 __ANY_NUM(__iec_)
   939 __ANY_NUM(__iec_)
   929 
   941 
   930 
   942 
   931 /* Limit for time data types */	
   943 /* Limit for time data types */	
   932 #define __iec_(TYPENAME)\
   944 #define __iec_(TYPENAME)\
   933 /* The explicitly typed standard functions */\
   945 /* The explicitly typed standard functions */\
   934 static inline TYPENAME LIMIT_##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   946 static inline TYPENAME LIMIT_##TYPENAME(EN_ENO_PARAMS TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   935     TEST_EN(TYPENAME)\
   947     TEST_EN(TYPENAME)\
   936     return __time_cmp(IN, MN) > 0 ? /* IN>MN ?*/\
   948     return __time_cmp(IN, MN) > 0 ? /* IN>MN ?*/\
   937            __time_cmp(IN, MX) < 0 ? /* IN<MX ?*/\
   949            __time_cmp(IN, MX) < 0 ? /* IN<MX ?*/\
   938            IN : MX : MN;\
   950            IN : MX : MN;\
   939 }\
   951 }\
   940 /* Overloaded function */\
   952 /* Overloaded function */\
   941 static inline TYPENAME LIMIT__##TYPENAME##__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   953 static inline TYPENAME LIMIT__##TYPENAME##__##TYPENAME##__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS TYPENAME MN, TYPENAME IN, TYPENAME MX){\
   942     TEST_EN(TYPENAME)\
   954     TEST_EN(TYPENAME)\
   943     return __time_cmp(IN, MN) > 0 ? /* IN>MN ?*/\
   955     return __time_cmp(IN, MN) > 0 ? /* IN>MN ?*/\
   944            __time_cmp(IN, MX) < 0 ? /* IN<MX ?*/\
   956            __time_cmp(IN, MX) < 0 ? /* IN<MX ?*/\
   945            IN : MX : MN;\
   957            IN : MX : MN;\
   946 }
   958 }
   949 __iec_(TIME)
   961 __iec_(TIME)
   950 #undef __iec_
   962 #undef __iec_
   951 
   963 
   952 /* Limit for string data types */	
   964 /* Limit for string data types */	
   953 /* The explicitly typed standard functions */
   965 /* The explicitly typed standard functions */
   954 static inline STRING LIMIT_STRING(EN_ENO_PARAMS, STRING MN, STRING IN, STRING MX){
   966 static inline STRING LIMIT_STRING(EN_ENO_PARAMS STRING MN, STRING IN, STRING MX){
   955     TEST_EN(STRING)
   967     TEST_EN(STRING)
   956     return __STR_CMP(IN, MN) > 0 ? __STR_CMP(IN, MX) < 0 ? IN : MX : MN;
   968     return __STR_CMP(IN, MN) > 0 ? __STR_CMP(IN, MX) < 0 ? IN : MX : MN;
   957 }
   969 }
   958 
   970 
   959 /* Overloaded function */
   971 /* Overloaded function */
   960 static inline STRING LIMIT__STRING__STRING__STRING__STRING(EN_ENO_PARAMS, STRING MN, STRING IN, STRING MX){
   972 static inline STRING LIMIT__STRING__STRING__STRING__STRING(EN_ENO_PARAMS STRING MN, STRING IN, STRING MX){
   961     TEST_EN(STRING)
   973     TEST_EN(STRING)
   962     return __STR_CMP(IN, MN) > 0 ? __STR_CMP(IN, MX) < 0 ? IN : MX : MN;
   974     return __STR_CMP(IN, MN) > 0 ? __STR_CMP(IN, MX) < 0 ? IN : MX : MN;
   963 }
   975 }
   964 
   976 
   965 
   977 
   970  * unlike remaining functions, that start off at 1.
   982  * unlike remaining functions, that start off at 1.
   971  */    
   983  */    
   972 /* The explicitly typed standard functions */
   984 /* The explicitly typed standard functions */
   973 #define __in1_anyint_(in2_TYPENAME)   __ANY_INT_1(__iec_,in2_TYPENAME)
   985 #define __in1_anyint_(in2_TYPENAME)   __ANY_INT_1(__iec_,in2_TYPENAME)
   974 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   986 #define __iec_(in1_TYPENAME,in2_TYPENAME) \
   975 static inline in2_TYPENAME MUX__##in2_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS, in1_TYPENAME K, UINT param_count, ...){\
   987 static inline in2_TYPENAME MUX__##in2_TYPENAME##__##in1_TYPENAME##__##in2_TYPENAME(EN_ENO_PARAMS in1_TYPENAME K, UINT param_count, ...){\
   976   va_list ap;\
   988   va_list ap;\
   977   UINT i;\
   989   UINT i;\
   978   in2_TYPENAME tmp;\
   990   in2_TYPENAME tmp;\
   979   TEST_EN_COND(in2_TYPENAME, K >= param_count)\
   991   TEST_EN_COND(in2_TYPENAME, K >= param_count)\
   980   tmp = __INIT_##in2_TYPENAME;\
   992   tmp = __INIT_##in2_TYPENAME;\
  1003 /***             Table 28               ***/
  1015 /***             Table 28               ***/
  1004 /***   Standard comparison functions    ***/
  1016 /***   Standard comparison functions    ***/
  1005 /******************************************/
  1017 /******************************************/
  1006 
  1018 
  1007 #define __compare_(fname,TYPENAME, COND) \
  1019 #define __compare_(fname,TYPENAME, COND) \
  1008 static inline BOOL fname(EN_ENO_PARAMS, UINT param_count, TYPENAME op1, ...){\
  1020 static inline BOOL fname(EN_ENO_PARAMS UINT param_count, TYPENAME op1, ...){\
  1009   va_list ap;\
  1021   va_list ap;\
  1010   UINT i;\
  1022   UINT i;\
  1011   TEST_EN(BOOL)\
  1023   TEST_EN(BOOL)\
  1012   \
  1024   \
  1013   va_start (ap, op1);         /* Initialize the argument list.  */\
  1025   va_start (ap, op1);         /* Initialize the argument list.  */\
  1156 
  1168 
  1157     /**************/
  1169     /**************/
  1158     /*     NE     */
  1170     /*     NE     */
  1159     /**************/
  1171     /**************/
  1160 #define __ne_num(fname, TYPENAME) \
  1172 #define __ne_num(fname, TYPENAME) \
  1161 static inline BOOL fname(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
  1173 static inline BOOL fname(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
  1162   TEST_EN(BOOL)\
  1174   TEST_EN(BOOL)\
  1163   return op1 != op2 ? 1 : 0;\
  1175   return op1 != op2 ? 1 : 0;\
  1164 }
  1176 }
  1165 
  1177 
  1166 #define __ne_time(fname, TYPENAME) \
  1178 #define __ne_time(fname, TYPENAME) \
  1167 static inline BOOL fname(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
  1179 static inline BOOL fname(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
  1168   TEST_EN(BOOL)\
  1180   TEST_EN(BOOL)\
  1169   return __time_cmp(op1, op2) != 0 ? 1 : 0;\
  1181   return __time_cmp(op1, op2) != 0 ? 1 : 0;\
  1170 }
  1182 }
  1171 
  1183 
  1172 #define __ne_string(fname, TYPENAME) \
  1184 #define __ne_string(fname, TYPENAME) \
  1173 static inline BOOL fname(EN_ENO_PARAMS, TYPENAME op1, TYPENAME op2){\
  1185 static inline BOOL fname(EN_ENO_PARAMS TYPENAME op1, TYPENAME op2){\
  1174   TEST_EN(BOOL)\
  1186   TEST_EN(BOOL)\
  1175   return __STR_CMP(op1, op2) != 0 ? 1 : 0;\
  1187   return __STR_CMP(op1, op2) != 0 ? 1 : 0;\
  1176 }
  1188 }
  1177 
  1189 
  1178 /* Comparison for numerical data types */
  1190 /* Comparison for numerical data types */
  1223     /***************/
  1235     /***************/
  1224 static inline __strlen_t __len(STRING IN) {return IN.len;}
  1236 static inline __strlen_t __len(STRING IN) {return IN.len;}
  1225 
  1237 
  1226 /* A function, with 1 input paramter, implementing a generic OPERATION */
  1238 /* A function, with 1 input paramter, implementing a generic OPERATION */
  1227 #define __genoper_1p_(fname,ret_TYPENAME, par_TYPENAME, OPERATION) \
  1239 #define __genoper_1p_(fname,ret_TYPENAME, par_TYPENAME, OPERATION) \
  1228 static inline ret_TYPENAME fname(EN_ENO_PARAMS, par_TYPENAME par1){\
  1240 static inline ret_TYPENAME fname(EN_ENO_PARAMS par_TYPENAME par1){\
  1229   TEST_EN(ret_TYPENAME)\
  1241   TEST_EN(ret_TYPENAME)\
  1230   return (ret_TYPENAME)OPERATION(par1);\
  1242   return (ret_TYPENAME)OPERATION(par1);\
  1231 }
  1243 }
  1232 
  1244 
  1233 #define __iec_(TYPENAME) __genoper_1p_(LEN__##TYPENAME##__STRING, TYPENAME, STRING, __len)
  1245 #define __iec_(TYPENAME) __genoper_1p_(LEN__##TYPENAME##__STRING, TYPENAME, STRING, __len)
  1238     /****************/
  1250     /****************/
  1239     /*     LEFT     */
  1251     /*     LEFT     */
  1240     /****************/
  1252     /****************/
  1241 
  1253 
  1242 #define __left(TYPENAME) \
  1254 #define __left(TYPENAME) \
  1243 static inline STRING LEFT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS, STRING IN, TYPENAME L){\
  1255 static inline STRING LEFT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS STRING IN, TYPENAME L){\
  1244     STRING res;\
  1256     STRING res;\
  1245     TEST_EN_COND(STRING, L < 0)\
  1257     TEST_EN_COND(STRING, L < 0)\
  1246     res = __INIT_STRING;\
  1258     res = __INIT_STRING;\
  1247     L = L < (TYPENAME)IN.len ? L : (TYPENAME)IN.len;\
  1259     L = L < (TYPENAME)IN.len ? L : (TYPENAME)IN.len;\
  1248     memcpy(&res.body, &IN.body, (size_t)L);\
  1260     memcpy(&res.body, &IN.body, (size_t)L);\
  1255     /*****************/
  1267     /*****************/
  1256     /*     RIGHT     */
  1268     /*     RIGHT     */
  1257     /*****************/
  1269     /*****************/
  1258 
  1270 
  1259 #define __right(TYPENAME) \
  1271 #define __right(TYPENAME) \
  1260 static inline STRING RIGHT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS, STRING IN, TYPENAME L){\
  1272 static inline STRING RIGHT__STRING__STRING__##TYPENAME(EN_ENO_PARAMS STRING IN, TYPENAME L){\
  1261   STRING res;\
  1273   STRING res;\
  1262   TEST_EN_COND(STRING, L < 0)\
  1274   TEST_EN_COND(STRING, L < 0)\
  1263   res = __INIT_STRING;\
  1275   res = __INIT_STRING;\
  1264   L = L < (TYPENAME)IN.len ? L : (TYPENAME)IN.len;\
  1276   L = L < (TYPENAME)IN.len ? L : (TYPENAME)IN.len;\
  1265   memcpy(&res.body, &IN.body[(TYPENAME)IN.len - L], (size_t)L);\
  1277   memcpy(&res.body, &IN.body[(TYPENAME)IN.len - L], (size_t)L);\
  1272     /***************/
  1284     /***************/
  1273     /*     MID     */
  1285     /*     MID     */
  1274     /***************/
  1286     /***************/
  1275 
  1287 
  1276 #define __mid(TYPENAME) \
  1288 #define __mid(TYPENAME) \
  1277 static inline STRING MID__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, STRING IN, TYPENAME L, TYPENAME P){\
  1289 static inline STRING MID__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS STRING IN, TYPENAME L, TYPENAME P){\
  1278   STRING res;\
  1290   STRING res;\
  1279   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1291   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1280   res = __INIT_STRING;\
  1292   res = __INIT_STRING;\
  1281   if(P <= (TYPENAME)IN.len){\
  1293   if(P <= (TYPENAME)IN.len){\
  1282 	P -= 1; /* now can be used as [index]*/\
  1294 	P -= 1; /* now can be used as [index]*/\
  1291 
  1303 
  1292     /******************/
  1304     /******************/
  1293     /*     CONCAT     */
  1305     /*     CONCAT     */
  1294     /******************/
  1306     /******************/
  1295 
  1307 
  1296 static inline STRING CONCAT(EN_ENO_PARAMS, UINT param_count, ...){
  1308 static inline STRING CONCAT(EN_ENO_PARAMS UINT param_count, ...){
  1297   UINT i;
  1309   UINT i;
  1298   STRING res;
  1310   STRING res;
  1299   va_list ap;
  1311   va_list ap;
  1300   __strlen_t charcount;
  1312   __strlen_t charcount;
  1301   TEST_EN(STRING)
  1313   TEST_EN(STRING)
  1342 
  1354 
  1343     return res;
  1355     return res;
  1344 }
  1356 }
  1345 
  1357 
  1346 #define __iec_(TYPENAME) \
  1358 #define __iec_(TYPENAME) \
  1347 static inline STRING INSERT__STRING__STRING__STRING__##TYPENAME(EN_ENO_PARAMS, STRING str1, STRING str2, TYPENAME P){\
  1359 static inline STRING INSERT__STRING__STRING__STRING__##TYPENAME(EN_ENO_PARAMS STRING str1, STRING str2, TYPENAME P){\
  1348   TEST_EN_COND(STRING, P < 0)\
  1360   TEST_EN_COND(STRING, P < 0)\
  1349   return (STRING)__insert(str1,str2,(__strlen_t)P);\
  1361   return (STRING)__insert(str1,str2,(__strlen_t)P);\
  1350 }
  1362 }
  1351 __ANY_INT(__iec_)
  1363 __ANY_INT(__iec_)
  1352 #undef __iec_
  1364 #undef __iec_
  1373 
  1385 
  1374     return res;
  1386     return res;
  1375 }
  1387 }
  1376 
  1388 
  1377 #define __iec_(TYPENAME) \
  1389 #define __iec_(TYPENAME) \
  1378 static inline STRING DELETE__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, STRING str, TYPENAME L, TYPENAME P){\
  1390 static inline STRING DELETE__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS STRING str, TYPENAME L, TYPENAME P){\
  1379   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1391   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1380   return (STRING)__delete(str,(__strlen_t)L,(__strlen_t)P);\
  1392   return (STRING)__delete(str,(__strlen_t)L,(__strlen_t)P);\
  1381 }
  1393 }
  1382 __ANY_INT(__iec_)
  1394 __ANY_INT(__iec_)
  1383 #undef __iec_
  1395 #undef __iec_
  1414 
  1426 
  1415     return res;
  1427     return res;
  1416 }
  1428 }
  1417 
  1429 
  1418 #define __iec_(TYPENAME) \
  1430 #define __iec_(TYPENAME) \
  1419 static inline STRING REPLACE__STRING__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS, STRING str1, STRING str2, TYPENAME L, TYPENAME P){\
  1431 static inline STRING REPLACE__STRING__STRING__STRING__##TYPENAME##__##TYPENAME(EN_ENO_PARAMS STRING str1, STRING str2, TYPENAME L, TYPENAME P){\
  1420   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1432   TEST_EN_COND(STRING, L < 0 || P < 0)\
  1421   return (STRING)__replace(str1,str2,(__strlen_t)L,(__strlen_t)P);\
  1433   return (STRING)__replace(str1,str2,(__strlen_t)L,(__strlen_t)P);\
  1422 }
  1434 }
  1423 __ANY_INT(__iec_)
  1435 __ANY_INT(__iec_)
  1424 #undef __iec_
  1436 #undef __iec_
  1442     }
  1454     }
  1443     return count2 == IN2->len -1 ? 0 : count1 + 1;
  1455     return count2 == IN2->len -1 ? 0 : count1 + 1;
  1444 }
  1456 }
  1445 
  1457 
  1446 #define __iec_(TYPENAME) \
  1458 #define __iec_(TYPENAME) \
  1447 static inline TYPENAME FIND__##TYPENAME##__STRING__STRING(EN_ENO_PARAMS, STRING str1, STRING str2){\
  1459 static inline TYPENAME FIND__##TYPENAME##__STRING__STRING(EN_ENO_PARAMS STRING str1, STRING str2){\
  1448   TEST_EN(TYPENAME)\
  1460   TEST_EN(TYPENAME)\
  1449   return (TYPENAME)__pfind(&str1,&str2);\
  1461   return (TYPENAME)__pfind(&str1,&str2);\
  1450 }
  1462 }
  1451 __ANY_INT(__iec_)
  1463 __ANY_INT(__iec_)
  1452 #undef __iec_
  1464 #undef __iec_
  1462 /***           Table 30             ***/
  1474 /***           Table 30             ***/
  1463 /***  Functions of time data types  ***/
  1475 /***  Functions of time data types  ***/
  1464 /**************************************/
  1476 /**************************************/
  1465 
  1477 
  1466 
  1478 
  1467 static inline TIME ADD_TIME(EN_ENO_PARAMS, TIME IN1, TIME IN2){
  1479 static inline TIME ADD_TIME(EN_ENO_PARAMS TIME IN1, TIME IN2){
  1468   TEST_EN(TIME)
  1480   TEST_EN(TIME)
  1469   return __time_add(IN1, IN2);
  1481   return __time_add(IN1, IN2);
  1470 }
  1482 }
  1471 
  1483 
  1472 static inline TOD ADD_TOD_TIME(EN_ENO_PARAMS, TOD IN1, TIME IN2){
  1484 static inline TOD ADD_TOD_TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
  1473   TEST_EN(TOD)
  1485   TEST_EN(TOD)
  1474   return __time_add(IN1, IN2);
  1486   return __time_add(IN1, IN2);
  1475 }
  1487 }
  1476 
  1488 
  1477 static inline DT ADD_DT_TIME(EN_ENO_PARAMS, DT IN1, TIME IN2){
  1489 static inline DT ADD_DT_TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
  1478   TEST_EN(DT)
  1490   TEST_EN(DT)
  1479   return __time_add(IN1, IN2);
  1491   return __time_add(IN1, IN2);
  1480 }
  1492 }
  1481 
  1493 
  1482 static inline TIME SUB_TIME(EN_ENO_PARAMS, TIME IN1, TIME IN2){
  1494 static inline TIME SUB_TIME(EN_ENO_PARAMS TIME IN1, TIME IN2){
  1483   TEST_EN(TIME)
  1495   TEST_EN(TIME)
  1484   return __time_sub(IN1, IN2);
  1496   return __time_sub(IN1, IN2);
  1485 }
  1497 }
  1486 
  1498 
  1487 static inline TIME SUB_DATE_DATE(EN_ENO_PARAMS, DATE IN1, DATE IN2){
  1499 static inline TIME SUB_DATE_DATE(EN_ENO_PARAMS DATE IN1, DATE IN2){
  1488   TEST_EN(TIME)
  1500   TEST_EN(TIME)
  1489   return __time_sub(IN1, IN2);
  1501   return __time_sub(IN1, IN2);
  1490 }
  1502 }
  1491 
  1503 
  1492 static inline TOD SUB_TOD_TIME(EN_ENO_PARAMS, TOD IN1, TIME IN2){
  1504 static inline TOD SUB_TOD_TIME(EN_ENO_PARAMS TOD IN1, TIME IN2){
  1493   TEST_EN(TOD)
  1505   TEST_EN(TOD)
  1494   return __time_sub(IN1, IN2);
  1506   return __time_sub(IN1, IN2);
  1495 }
  1507 }
  1496 
  1508 
  1497 static inline TIME SUB_TOD_TOD(EN_ENO_PARAMS, TOD IN1, TOD IN2){
  1509 static inline TIME SUB_TOD_TOD(EN_ENO_PARAMS TOD IN1, TOD IN2){
  1498   TEST_EN(TIME)
  1510   TEST_EN(TIME)
  1499   return __time_sub(IN1, IN2);
  1511   return __time_sub(IN1, IN2);
  1500 }
  1512 }
  1501 
  1513 
  1502 static inline DT SUB_DT_TIME(EN_ENO_PARAMS, DT IN1, TIME IN2){
  1514 static inline DT SUB_DT_TIME(EN_ENO_PARAMS DT IN1, TIME IN2){
  1503   TEST_EN(DT)
  1515   TEST_EN(DT)
  1504   return __time_sub(IN1, IN2);
  1516   return __time_sub(IN1, IN2);
  1505 }
  1517 }
  1506 
  1518 
  1507 static inline TIME SUB_DT_DT(EN_ENO_PARAMS, DT IN1, DT IN2){
  1519 static inline TIME SUB_DT_DT(EN_ENO_PARAMS DT IN1, DT IN2){
  1508   TEST_EN(TIME)
  1520   TEST_EN(TIME)
  1509   return __time_sub(IN1, IN2);
  1521   return __time_sub(IN1, IN2);
  1510 }
  1522 }
  1511 
  1523 
  1512 
  1524 
  1513 /***  MULTIME  ***/
  1525 /***  MULTIME  ***/
  1514 #define __iec_(TYPENAME)\
  1526 #define __iec_(TYPENAME)\
  1515 static inline TIME MULTIME__TIME__TIME__##TYPENAME(EN_ENO_PARAMS, TIME IN1, TYPENAME IN2){\
  1527 static inline TIME MULTIME__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
  1516   TEST_EN(TIME)\
  1528   TEST_EN(TIME)\
  1517   return __time_mul(IN1, (LREAL)IN2);\
  1529   return __time_mul(IN1, (LREAL)IN2);\
  1518 }
  1530 }
  1519 __ANY_NUM(__iec_)
  1531 __ANY_NUM(__iec_)
  1520 #undef __iec_
  1532 #undef __iec_
  1521 
  1533 
  1522 /***  MUL  ***/
  1534 /***  MUL  ***/
  1523 #define __iec_(TYPENAME)\
  1535 #define __iec_(TYPENAME)\
  1524 static inline TIME MUL__TIME__TIME__##TYPENAME(EN_ENO_PARAMS, TIME IN1, TYPENAME IN2){\
  1536 static inline TIME MUL__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
  1525   TEST_EN(TIME)\
  1537   TEST_EN(TIME)\
  1526   return __time_mul(IN1, (LREAL)IN2);\
  1538   return __time_mul(IN1, (LREAL)IN2);\
  1527 }
  1539 }
  1528 __ANY_NUM(__iec_)
  1540 __ANY_NUM(__iec_)
  1529 #undef __iec_
  1541 #undef __iec_
  1530 
  1542 
  1531 /***  DIVTIME  ***/
  1543 /***  DIVTIME  ***/
  1532 #define __iec_(TYPENAME)\
  1544 #define __iec_(TYPENAME)\
  1533 static inline TIME DIVTIME__TIME__TIME__##TYPENAME(EN_ENO_PARAMS, TIME IN1, TYPENAME IN2){\
  1545 static inline TIME DIVTIME__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
  1534   TEST_EN(TIME)\
  1546   TEST_EN(TIME)\
  1535   return __time_div(IN1, (LREAL)IN2);\
  1547   return __time_div(IN1, (LREAL)IN2);\
  1536 }
  1548 }
  1537 __ANY_NUM(__iec_)
  1549 __ANY_NUM(__iec_)
  1538 #undef __iec_
  1550 #undef __iec_
  1539 
  1551 
  1540 /***  DIV  ***/
  1552 /***  DIV  ***/
  1541 #define __iec_(TYPENAME)\
  1553 #define __iec_(TYPENAME)\
  1542 static inline TIME DIV__TIME__TIME__##TYPENAME(EN_ENO_PARAMS, TIME IN1, TYPENAME IN2){\
  1554 static inline TIME DIV__TIME__TIME__##TYPENAME(EN_ENO_PARAMS TIME IN1, TYPENAME IN2){\
  1543   TEST_EN(TIME)\
  1555   TEST_EN(TIME)\
  1544   return __time_div(IN1, (LREAL)IN2);\
  1556   return __time_div(IN1, (LREAL)IN2);\
  1545 }
  1557 }
  1546 __ANY_NUM(__iec_)
  1558 __ANY_NUM(__iec_)
  1547 #undef __iec_
  1559 #undef __iec_
  1548 
  1560 
  1549 /*** CONCAT_DATE_TOD ***/
  1561 /*** CONCAT_DATE_TOD ***/
  1550 static inline DT CONCAT_DATE_TOD(EN_ENO_PARAMS, DATE IN1, TOD IN2){
  1562 static inline DT CONCAT_DATE_TOD(EN_ENO_PARAMS DATE IN1, TOD IN2){
  1551   TEST_EN(DT)
  1563   TEST_EN(DT)
  1552   return __time_add(IN1, IN2);
  1564   return __time_add(IN1, IN2);
  1553 }
  1565 }
  1554 
  1566 
  1555 
  1567