First it defines a variable `____datum__`, which tells what is to be done if the cleanup frame is left.
The `____execute__` variables gets set to its real value in `pthread_cleanup_pop` and tells whether to call the cleanup handler or not.
The `do { } while (0)` makes the compiler throw an error if you don't finish the invocation with a semicolon.
The vast amount of  `do … while (0);` is used to have a narrow scope in which the variables are visible. Otherwise you couldn't test cleanup frames.