summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2021-01-31 19:56:48 +0000
committerStefan Eßer <se@FreeBSD.org>2021-01-31 19:58:45 +0000
commit47a52dc4d48f259ab7d9f9ba6b65f4f2331a22dc (patch)
tree6e73791cfb3f127d7f2889c8e0a0380bc9913514 /include
parent7fe0a3f2085758fdef0a705dbc81d72f1f1953c6 (diff)
Diffstat (limited to 'include')
-rw-r--r--include/args.h2
-rw-r--r--include/bc.h2
-rw-r--r--include/bcl.h2
-rw-r--r--include/dc.h2
-rw-r--r--include/file.h2
-rw-r--r--include/history.h2
-rw-r--r--include/lang.h2
-rw-r--r--include/lex.h2
-rw-r--r--include/library.h2
-rw-r--r--include/num.h4
-rw-r--r--include/opt.h2
-rw-r--r--include/parse.h2
-rw-r--r--include/program.h2
-rw-r--r--include/rand.h31
-rw-r--r--include/read.h2
-rw-r--r--include/status.h14
-rw-r--r--include/vector.h3
-rw-r--r--include/vm.h19
18 files changed, 45 insertions, 52 deletions
diff --git a/include/args.h b/include/args.h
index f2bc2d6bab05..6b68ed300440 100644
--- a/include/args.h
+++ b/include/args.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/bc.h b/include/bc.h
index 383e7e7ec562..f519d09c4838 100644
--- a/include/bc.h
+++ b/include/bc.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/bcl.h b/include/bcl.h
index 05f1631e5534..3c67beb23122 100644
--- a/include/bcl.h
+++ b/include/bcl.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/dc.h b/include/dc.h
index 07af135bc38f..315aeb78b1ad 100644
--- a/include/dc.h
+++ b/include/dc.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/file.h b/include/file.h
index 6fa08b3f436c..1c3273b7a756 100644
--- a/include/file.h
+++ b/include/file.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/history.h b/include/history.h
index c632bc81a2a0..d3622ae15a30 100644
--- a/include/history.h
+++ b/include/history.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/lang.h b/include/lang.h
index a8ab08ad9bf4..7158f10dc0f4 100644
--- a/include/lang.h
+++ b/include/lang.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/lex.h b/include/lex.h
index ff9592b6e928..2da42d432f1e 100644
--- a/include/lex.h
+++ b/include/lex.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/library.h b/include/library.h
index 17c3f572caee..3b98091fa523 100644
--- a/include/library.h
+++ b/include/library.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/num.h b/include/num.h
index 4868ae3de6a8..2104f8b8acad 100644
--- a/include/num.h
+++ b/include/num.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -236,7 +236,9 @@ void bc_num_zero(BcNum *restrict n);
void bc_num_one(BcNum *restrict n);
ssize_t bc_num_cmpZero(const BcNum *n);
+#if !defined(NDEBUG) || BC_ENABLE_LIBRARY
bool bc_num_strValid(const char *restrict val);
+#endif // !defined(NDEBUG) || BC_ENABLE_LIBRARY
void bc_num_parse(BcNum *restrict n, const char *restrict val, BcBigDig base);
void bc_num_print(BcNum *restrict n, BcBigDig base, bool newline);
#if DC_ENABLED
diff --git a/include/opt.h b/include/opt.h
index eb3d5959adc0..e828a92c94df 100644
--- a/include/opt.h
+++ b/include/opt.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/parse.h b/include/parse.h
index 7f59885346dc..36d6e8c60afd 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/program.h b/include/program.h
index a9805fbfb316..ec31f3486270 100644
--- a/include/program.h
+++ b/include/program.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/rand.h b/include/rand.h
index a2fb713803ee..77663d9e13d2 100644
--- a/include/rand.h
+++ b/include/rand.h
@@ -1,34 +1,6 @@
/*
* *****************************************************************************
*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2018-2019 Gavin D. Howard and contributors.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * *****************************************************************************
- *
* Parts of this code are adapted from the following:
*
* PCG, A Family of Better Random Number Generators.
@@ -38,9 +10,10 @@
*
* -----------------------------------------------------------------------------
*
- * Parts of this code are also under the following license:
+ * This code is under the following license:
*
* Copyright (c) 2014-2017 Melissa O'Neill and PCG Project contributors
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/include/read.h b/include/read.h
index 664ff983e522..84d65063f14a 100644
--- a/include/read.h
+++ b/include/read.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
diff --git a/include/status.h b/include/status.h
index 2807a28af4ef..3fa844485690 100644
--- a/include/status.h
+++ b/include/status.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -46,6 +46,16 @@
#define DC_ENABLED (1)
#endif // DC_ENABLED
+#if BC_ENABLE_AFL
+#ifndef __AFL_HAVE_MANUAL_CONTROL
+#error Must compile with afl-clang-fast for fuzzing
+#endif // __AFL_HAVE_MANUAL_CONTROL
+#endif // BC_ENABLE_AFL
+
+#ifndef BC_ENABLE_MEMCHECK
+#define BC_ENABLE_MEMCHECK (0)
+#endif // BC_ENABLE_MEMCHECK
+
#include <bcl.h>
typedef enum BcStatus {
@@ -173,7 +183,7 @@ typedef enum BcErr {
#endif // defined(__has_attribute) && __has_attribute(fallthrough)
#else // defined(__clang__) || defined(__GNUC__)
#define BC_FALLTHROUGH
-#endif //defined(__clang__) || defined(__GNUC__)
+#endif // defined(__clang__) || defined(__GNUC__)
// Workarounds for AIX's POSIX incompatibility.
#ifndef SIZE_MAX
diff --git a/include/vector.h b/include/vector.h
index fdfb85d58228..45398cba2eda 100644
--- a/include/vector.h
+++ b/include/vector.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -91,6 +91,7 @@ bool bc_map_insert(BcVec *restrict v, const char *name,
size_t bc_map_index(const BcVec *restrict v, const char *name);
#define bc_vec_pop(v) (bc_vec_npop((v), 1))
+#define bc_vec_popAll(v) (bc_vec_npop((v), (v)->len))
#define bc_vec_top(v) (bc_vec_item_rev((v), 0))
#ifndef NDEBUG
diff --git a/include/vm.h b/include/vm.h
index 72a5150266a1..8b0babff4d81 100644
--- a/include/vm.h
+++ b/include/vm.h
@@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2018-2020 Gavin D. Howard and contributors.
+ * Copyright (c) 2018-2021 Gavin D. Howard and contributors.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -318,7 +318,7 @@ typedef struct BcVm {
#if !BC_ENABLE_LIBRARY
BcParse prs;
BcProgram prog;
-#endif // BC_ENABLE_LIBRARY
+#endif // !BC_ENABLE_LIBRARY
BcVec jmp_bufs;
@@ -343,7 +343,7 @@ typedef struct BcVm {
const char* file;
const char *sigmsg;
-#endif // BC_ENABLE_LIBRARY
+#endif // !BC_ENABLE_LIBRARY
volatile sig_atomic_t sig_lock;
volatile sig_atomic_t sig;
#if !BC_ENABLE_LIBRARY
@@ -357,7 +357,7 @@ typedef struct BcVm {
bool no_exit_exprs;
bool eof;
-#endif // BC_ENABLE_LIBRARY
+#endif // !BC_ENABLE_LIBRARY
BcBigDig maxes[BC_PROG_GLOBALS_LEN + BC_ENABLE_EXTRA_MATH];
@@ -382,7 +382,7 @@ typedef struct BcVm {
const char *err_msgs[BC_ERR_NELEMS];
const char *locale;
-#endif // BC_ENABLE_LIBRARY
+#endif // !BC_ENABLE_LIBRARY
BcBigDig last_base;
BcBigDig last_pow;
@@ -392,7 +392,7 @@ typedef struct BcVm {
#if !BC_ENABLE_LIBRARY
char *env_args_buffer;
BcVec env_args;
-#endif // BC_ENABLE_LIBRARY
+#endif // !BC_ENABLE_LIBRARY
BcNum max;
BcNum max2;
@@ -436,8 +436,15 @@ void bc_vm_jmp(void);
#if BC_ENABLE_LIBRARY
void bc_vm_handleError(BcErr e);
+void bc_vm_fatalError(BcErr e);
+void bc_vm_atexit(void);
#else // BC_ENABLE_LIBRARY
void bc_vm_handleError(BcErr e, size_t line, ...);
+#if !BC_ENABLE_LIBRARY && !BC_ENABLE_MEMCHECK
+BC_NORETURN
+#endif // !BC_ENABLE_LIBRARY && !BC_ENABLE_MEMCHECK
+void bc_vm_fatalError(BcErr e);
+int bc_vm_atexit(int status);
#endif // BC_ENABLE_LIBRARY
extern const char bc_copyright[];