diff options
author | Michael Jones <michaelrj@google.com> | 2022-10-04 11:59:55 -0700 |
---|---|---|
committer | Michael Jones <michaelrj@google.com> | 2022-10-04 13:31:26 -0700 |
commit | 38b6f58e33bbd8dc0be570f41806d0a9006610d9 (patch) | |
tree | be624ff89eefbb0e10239b5daa4d6ffdd51f8148 /libc/include | |
parent | 42fead6834ef3a96c765ea545c2d2bac951f7e98 (diff) | |
download | llvm-38b6f58e33bbd8dc0be570f41806d0a9006610d9.tar.gz |
[libc] implement basic rand and srand
This provides the reference implementation of rand and srand. In future
this will likely be upgraded to something that supports full ints.
Reviewed By: sivachandra
Differential Revision: https://reviews.llvm.org/D135187
Diffstat (limited to 'libc/include')
-rw-r--r-- | libc/include/CMakeLists.txt | 1 | ||||
-rw-r--r-- | libc/include/llvm-libc-macros/CMakeLists.txt | 6 | ||||
-rw-r--r-- | libc/include/llvm-libc-macros/stdlib-macros.h | 14 | ||||
-rw-r--r-- | libc/include/stdlib.h.def | 1 |
4 files changed, 22 insertions, 0 deletions
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt index 3998d7228e68..88018ba1cfe6 100644 --- a/libc/include/CMakeLists.txt +++ b/libc/include/CMakeLists.txt @@ -157,6 +157,7 @@ add_gen_header( GEN_HDR stdlib.h DEPENDS .llvm_libc_common_h + .llvm-libc-macros.stdlib_macros .llvm-libc-types.__bsearchcompare_t .llvm-libc-types.__qsortcompare_t .llvm-libc-types.div_t diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt index 740802cd4429..f0d297d36d05 100644 --- a/libc/include/llvm-libc-macros/CMakeLists.txt +++ b/libc/include/llvm-libc-macros/CMakeLists.txt @@ -23,6 +23,12 @@ add_header( ) add_header( + stdlib_macros + HDR + stdlib-macros.h +) + +add_header( sys_stat_macros HDR sys-stat-macros.h diff --git a/libc/include/llvm-libc-macros/stdlib-macros.h b/libc/include/llvm-libc-macros/stdlib-macros.h new file mode 100644 index 000000000000..930938dbe82f --- /dev/null +++ b/libc/include/llvm-libc-macros/stdlib-macros.h @@ -0,0 +1,14 @@ +//===-- Definition of macros to be used with stdlib functions ----------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef __LLVM_LIBC_MACROS_STDLIB_MACROS_H +#define __LLVM_LIBC_MACROS_STDLIB_MACROS_H + +#define RAND_MAX 32767 + +#endif // __LLVM_LIBC_MACROS_STDLIB_MACROS_H diff --git a/libc/include/stdlib.h.def b/libc/include/stdlib.h.def index f4f8c4f5a907..18df71a49a9b 100644 --- a/libc/include/stdlib.h.def +++ b/libc/include/stdlib.h.def @@ -10,6 +10,7 @@ #define LLVM_LIBC_STDLIB_H #include <__llvm-libc-common.h> +#include <llvm-libc-macros/stdlib-macros.h> %%public_api() |