Skip to content

pt_loop - some comprehension comments #5

@culyun

Description

@culyun

Ok, you got me. I don't understand pt_loop. I don't get all the while(1) if (1) statements. I'm guessing you're trying to ensure that braced and non-braced loops can be implemented, but it's somewhat impenertrable.

As a suggestion..

Label the various loops and if statements with comments then refer to those labels in a prologue.

Eg. something like this:

#define pt_loop(pt, cond)                                                      \
  for (int _intr = 0; _intr == 0;)                                             \
    if (1) {  /* if_a */                                                                 \
      pt_label(pt, PT_STATUS_BLOCKED);                                         \
      if (!(cond)) { /* if_b */                                                           \
        break;                                                                 \
      }                                                                        \
      goto _pt_line(body);                                                     \
    } else                                                                     \
      while (1) /* while_a */                                                                \
        if (1) {  /* if_c */                                                             \
          _intr = 1;                                                           \
          break;                                                               \
        } else                                                                 \
          while (1)  /* while_b */                                                          \
            if (1) { /* if_d */                                                          \
              return;                                                          \
            } else                                                             \
  _pt_line(body) :

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions