llvm-capstone/libc/include
Joseph Huber d9f033146b [libc] Ignore 'errno' on the GPU and support 'atoi'
The 'errno' value is most likely not useful on the GPU and it prevents
us from providing certain functions on the GPU that depend on it, like
`atoi`. This patch makes the necessary changes to support `errno` by
simple replacing it with a consumer class.

Supporting `errno` on the GPU is possible in some aspects. The first
approach would be to use a buffer of shared memory that has enough space
for all threads. Another option would be to change code generation to
support `thread_local` using `address_space(5)` memory allocated at
kernel launch. The former could look like the following, which could be
implemented in a later patch:

```
template <typename T>
using SharedBuffer = T[gpu::MAX_THREADS] [[clang::address_space(3)]];
template <typename T> struct ErrnoSetter {
  constexpr ErrnoSetter(SharedBuffer<T> &storage) : storage(storage) {}
  SharedBuffer<T> &storage;
  void operator=(const T &val) { storage[gpu::get_thread_id()] = val; }
};

static SharedBuffer<int> thread_local_buffer [[clang::loader_uninitialized]];
ErrnoSetter<int> __llvmlibc_internal_errno(thread_local_buffer);
```

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D149107
2023-04-25 12:41:20 -05:00
..
arpa [libc] Implement htonl and htons 2023-02-16 10:12:18 -08:00
llvm-libc-macros [LIBC] Implement remainder of posix 'sched.h' minus SCHED_SPORADIC 2023-04-20 14:53:41 -05:00
llvm-libc-types [LIBC] Implement remainder of posix 'sched.h' minus SCHED_SPORADIC 2023-04-20 14:53:41 -05:00
sys [libc] Introduce sys/socket.h 2023-02-23 07:11:20 +00:00
__llvm-libc-common.h [libc] add noexcept to external function headers 2023-01-06 11:43:43 -08:00
assert.h.def
CMakeLists.txt [LIBC] Implement remainder of posix 'sched.h' minus SCHED_SPORADIC 2023-04-20 14:53:41 -05:00
ctype.h.def
dirent.h.def [libc] Add dirent.h functions opendir, readdir, closedir and dirfd. 2022-07-25 20:23:25 +00:00
errno.h.def [libc] Ignore 'errno' on the GPU and support 'atoi' 2023-04-25 12:41:20 -05:00
fcntl.h.def [libc] Add POSIX close, fsync, open, read and write functions. 2022-01-27 20:32:02 +00:00
fenv.h.def [libc] Move math.h and fenv.h macro definitions to llvm-libc-macros. 2023-03-07 18:08:52 +00:00
inttypes.h.def [libc] add inttypes header 2021-08-26 18:04:21 +00:00
math.h.def [libc] Move math.h and fenv.h macro definitions to llvm-libc-macros. 2023-03-07 18:08:52 +00:00
pthread.h.def [libc] Add implementation of pthread_once. 2022-09-28 06:54:48 +00:00
sched.h.def [libc] add CPU_COUNT macro and backing function 2022-10-04 15:22:55 -07:00
setjmp.h.def [libc] Add x86_64 implementation of setjmp and longjmp. 2022-11-01 22:58:35 +00:00
signal.h.def [libc] Re-enable functions from signal.h and re-enable abort. 2022-09-30 07:31:50 +00:00
spawn.h.def [libc] Add POSIX functions posix_spawn_file_actions_*. 2022-10-11 04:54:44 +00:00
stdio.h.def [libc] Add definitions of a few missing macros and types. 2022-11-02 07:17:33 +00:00
stdlib.h.def [libc] implement basic rand and srand 2022-10-04 13:31:26 -07:00
string.h.def [libc][NFC] Simplify how the definiton of NULL macro is added to string.h. 2022-12-20 19:14:27 +00:00
strings.h.def [libc] Move b* string functions to strings.h 2023-01-09 20:16:20 +00:00
termios.h.def [libc] Add termios.h and the implementation of functions declared in it. 2022-10-18 20:53:00 +00:00
threads.h.def [libc] Move the remaining public types to their own type headers. 2022-01-20 23:04:26 +00:00
time.h.def [libc] add clock_gettime 2022-09-29 10:23:21 -07:00
unistd.h.def [libc] Add implementation of POSIX function "access". 2022-09-14 07:44:47 +00:00
wchar.h.def [libc] add basic wide char functions 2023-03-20 16:36:21 -07:00