libpulsar
A modular compiler for the pulsar programming language
Loading...
Searching...
No Matches
Macros | Functions
abort.h File Reference

Defines assertion and abortion functionality. More...

#include "def.h"

Go to the source code of this file.

Macros

#define CHECK(...)   /* nothing */
 All code inside CHECK will be run when PS_DEBUG is defined.
 
#define ps_abort_with_code(msg, code)    _ps_abort(msg, code, __FILE__, __func__, __LINE__)
 Aborts the program with the given message and exit code.
 
#define ps_abort(msg)   ps_abort_with_code(msg, 1)
 Aborts the program with the given message.
 
#define ps_assert(cond, msg)
 Asserts the given condition cond, aborting via ps_abort with the given msg otherwise.
 
#define PS_NO_MEMORY()   ps_abort("Virtual memory exhausted")
 Aborts the program due to exhaustion of virtual memory.
 
#define PS_NO_IMPL()   ps_abort("Function took path not yet implemented")
 Aborts the program due to a function taking a path not yet implemented.
 

Functions

void _ps_abort (STR msg, int code, STR filename, STR function, int line)
 Aborts the program with the given message.
 

Detailed Description

Defines assertion and abortion functionality.

Author
Ethan Uppal

Definition in file abort.h.

Macro Definition Documentation

◆ CHECK

#define CHECK (   ...)    /* nothing */

All code inside CHECK will be run when PS_DEBUG is defined.

Definition at line 22 of file abort.h.

◆ ps_abort

#define ps_abort (   msg)    ps_abort_with_code(msg, 1)

Aborts the program with the given message.

Parameters
msgThe message to print.

Definition at line 47 of file abort.h.

◆ ps_abort_with_code

#define ps_abort_with_code (   msg,
  code 
)     _ps_abort(msg, code, __FILE__, __func__, __LINE__)

Aborts the program with the given message and exit code.

Parameters
msgThe message to print.
codeThe exit code.

Definition at line 40 of file abort.h.

◆ ps_assert

#define ps_assert (   cond,
  msg 
)
Value:
do { \
CHECK({ \
if (!(cond)) { \
ps_abort(msg); \
} \
}) \
} while (0)

Asserts the given condition cond, aborting via ps_abort with the given msg otherwise.

Definition at line 53 of file abort.h.

◆ PS_NO_IMPL

#define PS_NO_IMPL ( )    ps_abort("Function took path not yet implemented")

Aborts the program due to a function taking a path not yet implemented.

Definition at line 70 of file abort.h.

◆ PS_NO_MEMORY

#define PS_NO_MEMORY ( )    ps_abort("Virtual memory exhausted")

Aborts the program due to exhaustion of virtual memory.

Definition at line 65 of file abort.h.

Function Documentation

◆ _ps_abort()

void _ps_abort ( STR  msg,
int  code,
STR  filename,
STR  function,
int  line 
)

Aborts the program with the given message.

Parameters
msgThe message to print.
codeThe exit code.
filenameThe file where the abort was called.
functionThe function where the abort was called.
lineThe line where the abort was called.

Definition at line 7 of file abort.c.