Cthulhu  0.2.10
Cthulhu compiler collection
posix.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 
3 #pragma once
4 
5 #include <errno.h>
6 #include <stdio.h>
7 #include <dirent.h>
8 #include <pthread.h>
9 
10 typedef void *os_library_impl_t;
11 typedef FILE *os_file_impl_t;
12 typedef struct dirent *os_inode_impl_t;
13 typedef DIR *os_iter_impl_t;
14 typedef pthread_t os_thread_impl_t;
15 typedef pthread_mutex_t os_mutex_impl_t;
16 
17 typedef struct os_mapping_t
18 {
19  void *view;
20  size_t size;
21 } os_mapping_t;
22 
23 enum {
25  eOsNotFound = ENOENT,
26  eOsExists = EEXIST,
27  eOsTooSmall = ENOSPC,
28 };
29 
30 #define CT_OS_INVALID_FILE NULL
31 #define CT_OS_INVALID_LIBRARY NULL
32 
33 // TODO: this may actually be UINTPTR_MAX
34 #define CT_OS_INVALID_MAPPING NULL
35 #define CT_OS_INVALID_ITER NULL
36 #define CT_OS_THREAD_INVALID NULL
37 
38 // TODO: this is wrong, im not sure how i might go about fixing it
39 #ifdef _DIRENT_HAVE_D_NAMLEN
40 # define CT_OS_NAME_MAX NAME_MAX
41 #else
42 # define CT_OS_NAME_MAX 255
43 #endif
pthread_t os_thread_impl_t
Definition: posix.h:14
DIR * os_iter_impl_t
Definition: posix.h:13
@ eOsNotFound
Definition: posix.h:25
@ eOsTooSmall
Definition: posix.h:27
@ eOsExists
Definition: posix.h:26
@ eOsSuccess
Definition: posix.h:24
struct dirent * os_inode_impl_t
Definition: posix.h:12
pthread_mutex_t os_mutex_impl_t
Definition: posix.h:15
void * os_library_impl_t
Definition: posix.h:10
FILE * os_file_impl_t
Definition: posix.h:11
memory mapping handle
Definition: posix.h:18
size_t size
Definition: posix.h:20
void * view
Definition: posix.h:19