#ifndef _SETJMP_H
#define _SETJMP_H

#include <bits/macros.h>
#include <stdint.h>

typedef uintptr_t jmp_buf[8];
typedef uintptr_t sigjmp_buf[8];

#ifdef __cplusplus
extern "C"
{
#endif

    /* Saves the current execution state in env. Returns 0 when called from the first time, or nonzero when returning
     * from longjmp.  */
    int setjmp(jmp_buf env);

    /* Right now, does the exact same as setjmp() (savesigs is ignored), since signals are not implemented. */
    int sigsetjmp(sigjmp_buf env, int savesigs);

    /* Restores the execution state saved in env by a setjmp() call. */
    __lc_noreturn void longjmp(jmp_buf env, int val);

    /* Right now, does the exact same as longjmp(), since signals are not implemented. */
    __lc_noreturn void siglongjmp(sigjmp_buf env, int val);

#ifdef __cplusplus
}
#endif

#endif