PL/I

PL/I

PL/I

 View Only
  • 1.  BPXWDYN disables decimal-overflow?

    Posted Mon July 11, 2016 10:55 AM

    Hi, 

    Those of you who are on comp.lang.pl1 have already noted my "investigation" of BPXWDYN,

    I don't want to re- & crosspost everything,  but as PL/I Cafe might be a more "official" place & maybe someone from IBM stops by i'll summarize my findings here:

    I found that calling BPXWDYN disables the FIXEDOVERFLOW Condition (triggered by a DECIMAL-Overflow). Setting the 'D' in the Program Mask re-enables DOFL again. Code below.

    Cancelled mention of @IBM: can someone confirm this and/or point out a mistake/workaround?

    br johann

     

    Appendix: code sample to reproduce:

    A) PL/I code

     woe01a0: proc options(main);

       %INCLUDE  CEEIBMAW; /* LE AWI (App Writer Interfaces) DCLs for PL/I */
       %INCLUDE  CEEIBMCT; /* LE Feedback Code Constant Definitions for PL/I */

        DCL CONDSTR  CHAR(80);
        DCL 01 FC,                     /* Feedback token */
               03 MsgSev    REAL FIXED BINARY(15,0),
               03 MsgNo     REAL FIXED BINARY(15,0),
               03 Flags,
                  05 Case      BIT(2),
                  05 Severity  BIT(3),
                  05 Control   BIT(3),
               03 FacID     CHAR(3),      /* Facility ID */
               03 ISI   /* Instance-Specific Information */
                            REAL FIXED BINARY(31,0);
       dcl 1 CEESPM_MODE,
             2 SET BIN FIXED(31) VALUE(1),
             2 QUERY BIN FIXED(31) VALUE(2),
             2 PUSH BIN FIXED(31) VALUE(3),
             2 POP BIN FIXED(31) VALUE(4),
             2 PUSHSET BIN FIXED(31) VALUE(5);

       DCL 1 CEESPM_CONDITION,
             2 FOFL    CHAR(4) VALUE('F'),
             2 DOFL    CHAR(4) VALUE('D'),
             2 UFL     CHAR(4) VALUE('U'),
             2 SIG     CHAR(4) VALUE('S'),
             2 NO_FOFL CHAR(4) VALUE('NOF'),
             2 NO_DOFL CHAR(4) VALUE('NOD'),
             2 NO_UFL  CHAR(4) VALUE('NOU'),
             2 NO_SIG  CHAR(4) VALUE('NOS');

       /* log file for tracing *(
       DCL LOG FILE RECORD OUTPUT ENV(FB RECSIZE(80));

       /* file for BPXWDYN */

       DCL WOEOUT  FILE RECORD OUTPUT ENV(FB RECSIZE(80));
       DCL IO80 CHAR(80) INIT('IO80');

       ON ERROR CALL PLIDUMP('HB');

       DCL (A,B,C,D) DEC FIXED(5,2); /* vars to provoke DOFL/FOFL */

       A,B,C,D=99;
       TEST1: /* FOFL-cond as expected */
       CONDSTR = '';
       CALL CEE3SPM ( CEESPM_MODE.QUERY, CONDSTR, FC );
       IF  FBCHECK( FC, CEE000)
       THEN CALL LOG_('query1: ' !! CONDSTR );
       ELSE CALL LOG_('ca failed with msg ' !! FC.MsgNo);
       ON FIXEDOVERFLOW GOTO FOFL1;
       A = MULTIPLY(B, C, 5, 2);
       CALL LOG_('test1:'!!a);
       GOTO TEST2;
       FOFL1:
       CALL LOG_('fofl1 happened');

       TEST2: /* BPXWDYN -> disables FOFL */
       CALL DYNALLOC();
       CONDSTR = '';
       CALL CEE3SPM ( CEESPM_MODE.QUERY, condstr, FC );
       IF  FBCHECK( FC, CEE000)
       THEN CALL LOG_('query2: ' !! CONDSTR );
       ELSE CALL LOG_('ca failed with msg ' !! FC.MsgNo);
       ON FIXEDOVERFLOW GOTO FOFL2;
       A = MULTIPLY(B, C, 5, 2);
       CALL LOG_('test2:'!!a);
       GOTO TEST3;
       FOFL2:
       CALL LOG_('fofl2 happened');

       TEST3: /* re-enable FOFL by setting DOFL to program mask */
       CALL CEE3SPM ( CEESPM_MODE.SET, CEESPM_CONDITION.DOFL, FC );
       IF  FBCHECK( FC, CEE000)
       THEN CALL LOG_('set done' );
       ELSE cALL LOG_('CEE3SPM failed with msg ' !! FC.MsgNo);
       ON FIXEDOVERFLOW GOTO FOFL3;
       A = MULTIPLY(B, C, 5, 2);
       CALL LOG_('test3:' !! a);
       /*goto test3;*/
       FOFL3:
       CALL LOG_('fofl3 happened');

       CONDSTR = '';
       CALL CEE3SPM ( CEESPM_MODE.QUERY, CONDSTR, FC );
       IF  FBCHECK( FC, CEE000)
       THEN call log_('query3: ' !! CONDSTR );
       ELSE call log_('ca failed with msg ' !! FC.MsgNo);

       LOG_: PROC(TXT); /* write to log */
         DCL TXT CHAR(*);
         DCL T80 CHAR(80);
         T80 = TXT;
         WRITE FILE(LOG) FROM (T80);
       END LOG_;

       DYNALLOC: PROC(); /* call BPXWDYN */
         CALL LOG_(PROCNAME()!!' ENTER');
         DCL DDNAME CHAR(8) INIT('WOEOUT');
         %INCLUDE BPXWDYN#;
         CALL BPXWDYN('ALLOC FI(WOEOUT) REUSE SYSOUT(T)');
         OPEN FILE(WOEOUT) TITLE(DDNAME);
         IF PLIRETV = 0
         THEN DO;
           WRITE FILE(WOEOUT) FROM(IO80); 
         END;
       END DYNALLOC;

     END WOE01A0;

    Cancelled mention of

    B) jcl (just fragments)

    //WOE01A0 EXEC PGM=WOE01A0
    //SYSPRINT DD SYSOUT=T
    //SYSOUT DD SYSOUT=T
    //PLIDUMP  DD SYSOUT=T
    //LOG     DD SYSOUT=T

    C) output on DD LOG:

    query1: F D U NOS    
    fofl1 happened       
    DYNALLOC ENTER       
    query2: F D U NOS    
    test2:  801.00       
    set done             
    fofl3 happened       
    query3: F D U NOS    

    woecki


  • 2.  Re: BPXWDYN disables decimal-overflow?

    Posted Wed July 13, 2016 09:28 PM

    As I pointed out in comp.lang.pl1, you need to have SIZE enabled, and you still have not done that.

    It was also pointed out that even with SIZE enabled, you also need to have FIXEDOVERFLOW enabled,

    because FOFL can be raised instead of SIZE depending on optimisation level.

     

    So, you need to include ON statements specifying SIZE and FIXEDOVERFLOW if you

    intend to trap those conditions.

     

    From LRM ver 4.5 :--

    SIZE is raised when the size of the value being assigned to a data item exceeds
    the declared (or default) size of the data item, even if this is not the actual size
    of the storage that the item occupies. For example, a fixed binary item of
    precision (20) occupies a fullword in storage, but SIZE is raised if a value
    whose size exceeds FIXED BINARY(20) is assigned to it.
    In optimized code, FOFL may be raised instead of SIZE.

    The SIZE condition differs from the FIXEDOVERFLOW condition in that
    FIXEDOVERFLOW is raised when the size of a calculated fixed-point value
    exceeds the maximum allowed by the implementation. SIZE can be raised on
    assignment of a value regardless of whether or not FIXEDOVERFLOW was
    raised in the calculation of that value.

    If the SIZE condition is raised and it is disabled, the program is in error.

    Robin400


  • 3.  Re: BPXWDYN disables decimal-overflow?

    Posted Thu July 14, 2016 04:11 AM

    Hi Robin,

    Thanks for your support & patience! I think i got your concern regarding SIZE, but things are a bit more ..diffuse. 

    I compile with DECIMAL(FOFLONMULT and FOFLONASGN) (forgot to mention this here, i mentioned it in compl.lang.pli) and as a result i expect a FOFL in my sample code 3 times. And everything works as expected - unless i call BPXWDYN which seems to disable the 'D' in the program mask which is IMHO ...wrong.

    br johann

     

    From LRM on 'MULTIPLY'

    "...

    Note that when applied to FIXED DECIMAL, then if the mathematical result is too big for the specified precision p but less than the maximum implementation value, 
    - if SIZE is disabled, the FIXEDOVERFLOW condition will not be raised and the result will be truncated
    - if SIZE is enabled, the SIZE condition will be raised
    Note that the above text is false when the non-default compiler option DECIMAL(FOFLONMULT) is in effect. In that case, FIXEDOVERFLOW will be raised if SIZE is disabled (and the result is too big).

    ..."

     

    woecki