|
x-engine-c v0.2.13
The C engine for x-lang
|
System-level function wrappers. More...
Go to the source code of this file.
Macros | |
| #define | X_SYS_EOF EOF |
| #define | X_SYS_EXIT_SUCCESS 0 |
| #define | X_SYS_EXIT_FAILURE 1 |
Functions | |
System Functions | |
| void * | x_sys_malloc (size_t size) |
| void | x_sys_free (void *ptr) |
| ssize_t | x_sys_read (int fd, void *p_buf, size_t size) |
| ssize_t | x_sys_write (int fd, const void *p_buf, size_t size) |
| void | x_sys_exit (int status) |
| int | x_sys_open (const char *path, int flags) |
| int | x_sys_close (int fd) |
| int | x_sys_read_char (int fd) |
System-level function wrappers.
Thin wrappers around OS/libc primitives for memory allocation, file I/O, and process control. Each wrapper can be redirected at compile time via the X_SYS_FUNC macro.
., .,
{O,O}
( )
" "
| #define X_SYS_EOF EOF |
End-of-file sentinel value.
| #define X_SYS_EXIT_FAILURE 1 |
Failure process exit status.
| #define X_SYS_EXIT_SUCCESS 0 |
Successful process exit status.
| int x_sys_close | ( | int | fd | ) |
Close a file descriptor.
Close a file descriptor.
| fd | The file descriptor to close. |
| void x_sys_exit | ( | int | status | ) |
Terminate the process.
Terminate the process.
| status | Exit status code returned to the parent process. |
| void x_sys_free | ( | void * | ptr | ) |
Free a previously allocated memory block.
Free a previously allocated memory block.
| ptr | Pointer to the memory block to free. |
| void * x_sys_malloc | ( | size_t | size | ) |
Allocate a memory block from the heap.
Allocate a memory block from the heap.
| size | The number of bytes to allocate. |
| int x_sys_open | ( | const char * | path, |
| int | flags | ||
| ) |
Open a file by path.
Open a file.
| path | The file path to open. |
| flags | Open flags (e.g. O_RDONLY). |
| ssize_t x_sys_read | ( | int | fd, |
| void * | p_buf, | ||
| size_t | size | ||
| ) |
Read bytes from a file descriptor.
Read from a file descriptor.
| fd | File descriptor to read from. |
| p_buf | Pointer to the destination buffer. |
| size | Maximum number of bytes to read. |
| int x_sys_read_char | ( | int | fd | ) |
Read a single character from a file descriptor, or X_SYS_EOF.
Read a single character from a file descriptor.
| fd | File descriptor to read from. |
| ssize_t x_sys_write | ( | int | fd, |
| const void * | p_buf, | ||
| size_t | size | ||
| ) |
Write bytes to a file descriptor.
Write to a file descriptor.
| fd | File descriptor to write to. |
| p_buf | Pointer to the source buffer. |
| size | Number of bytes to write. |