diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 01:45:31 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-25 01:45:31 -0400 |
| commit | 6ffd8467af7c6138196930116fecf27fca9b8604 (patch) | |
| tree | 3a6070c00b3833c12991ad7e05a59fd20ae1aba8 /src/stdlib | |
| parent | bfb829b1fe85911a84454d6da1948910f42b2c5c (diff) | |
Update file header comments
Diffstat (limited to 'src/stdlib')
38 files changed, 66 insertions, 56 deletions
diff --git a/src/stdlib/c_strings.c b/src/stdlib/c_strings.c index e28e8c20..2946ce58 100644 --- a/src/stdlib/c_strings.c +++ b/src/stdlib/c_strings.c @@ -1,4 +1,5 @@ // Type info and methods for CString datatype (char*) + #include <err.h> #include <gc.h> #include <stdbool.h> diff --git a/src/stdlib/c_strings.h b/src/stdlib/c_strings.h index d009c8bd..f85fa0d6 100644 --- a/src/stdlib/c_strings.h +++ b/src/stdlib/c_strings.h @@ -1,7 +1,7 @@ -#pragma once - // Type info and methods for CString datatype, which represents C's `char*` +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/datatypes.h b/src/stdlib/datatypes.h index 81ad8db2..373cbc47 100644 --- a/src/stdlib/datatypes.h +++ b/src/stdlib/datatypes.h @@ -1,7 +1,7 @@ -#pragma once - // Common datastructures (lists, tables, closures) +#pragma once + #include <gmp.h> #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/files.c b/src/stdlib/files.c index b8f493e3..7fd4c2c7 100644 --- a/src/stdlib/files.c +++ b/src/stdlib/files.c @@ -1,6 +1,4 @@ -// -// files.c - Implementation of some file loading functionality. -// +// Implementation of some file loading functionality. #include <ctype.h> #include <err.h> diff --git a/src/stdlib/files.h b/src/stdlib/files.h index ebece6f0..1840e907 100644 --- a/src/stdlib/files.h +++ b/src/stdlib/files.h @@ -1,6 +1,5 @@ -// -// files.h - Definitions of an API for loading files. -// +// Definitions of an API for loading files. + #pragma once #include <stdbool.h> diff --git a/src/stdlib/fpconv.c b/src/stdlib/fpconv.c index 8b994cfa..0781295d 100644 --- a/src/stdlib/fpconv.c +++ b/src/stdlib/fpconv.c @@ -1,5 +1,6 @@ // This file defines a function to convert floating point numbers to strings. // For license, see: fpconv_license.txt + #include <stdbool.h> #include <string.h> diff --git a/src/stdlib/functiontype.h b/src/stdlib/functiontype.h index ab0600be..35778aca 100644 --- a/src/stdlib/functiontype.h +++ b/src/stdlib/functiontype.h @@ -1,3 +1,5 @@ +// Logic for handling function type values + #pragma once #include <stdbool.h> @@ -6,8 +8,6 @@ #include "types.h" #include "util.h" -// Logic for handling function type values - void register_function(void *fn, Text_t filename, int64_t line_num, Text_t name); OptionalText_t get_function_name(void *fn); OptionalText_t get_function_filename(void *fn); diff --git a/src/stdlib/integers.c b/src/stdlib/integers.c index 082ca211..7dda77bd 100644 --- a/src/stdlib/integers.c +++ b/src/stdlib/integers.c @@ -1,4 +1,5 @@ // Integer type infos and methods + #include <stdio.h> // Must be before gmp.h #include <ctype.h> diff --git a/src/stdlib/integers.h b/src/stdlib/integers.h index accc0166..40c40754 100644 --- a/src/stdlib/integers.h +++ b/src/stdlib/integers.h @@ -1,7 +1,7 @@ -#pragma once - // Integer type infos and methods +#pragma once + #include <gmp.h> #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/lists.h b/src/stdlib/lists.h index 33279566..1ba46222 100644 --- a/src/stdlib/lists.h +++ b/src/stdlib/lists.h @@ -1,7 +1,7 @@ -#pragma once - // Functions that operate on lists +#pragma once + #include <stdbool.h> #include "datatypes.h" diff --git a/src/stdlib/mapmacro.h b/src/stdlib/mapmacro.h index 68834f8f..7b0e3c4e 100644 --- a/src/stdlib/mapmacro.h +++ b/src/stdlib/mapmacro.h @@ -1,9 +1,9 @@ -#pragma once - // This file defines a MAP_LIST(fn, ...) function that applies a function to // every one of the varargs. // For example: baz(MAP_LIST(foo, 1, "x")) -> baz(foo(1), foo("x")) +#pragma once + #define EVAL0(...) __VA_ARGS__ #define EVAL1(...) EVAL0(EVAL0(EVAL0(__VA_ARGS__))) #define EVAL2(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__))) diff --git a/src/stdlib/memory.c b/src/stdlib/memory.c index 65d0fbc6..2ae47c36 100644 --- a/src/stdlib/memory.c +++ b/src/stdlib/memory.c @@ -1,4 +1,5 @@ // Type info and methods for "Memory" opaque type + #include <err.h> #include <gc.h> #include <stdbool.h> diff --git a/src/stdlib/memory.h b/src/stdlib/memory.h index 56be103e..230a48c3 100644 --- a/src/stdlib/memory.h +++ b/src/stdlib/memory.h @@ -1,7 +1,7 @@ -#pragma once - // Type info and methods for "Memory" opaque type +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/metamethods.h b/src/stdlib/metamethods.h index 18598920..05d91c5c 100644 --- a/src/stdlib/metamethods.h +++ b/src/stdlib/metamethods.h @@ -1,6 +1,7 @@ -#pragma once // Metamethods are methods that all types share: +#pragma once + #include <stdint.h> #include "datatypes.h" diff --git a/src/stdlib/nums.h b/src/stdlib/nums.h index b73b0dc5..db051ed2 100644 --- a/src/stdlib/nums.h +++ b/src/stdlib/nums.h @@ -1,7 +1,7 @@ -#pragma once - // Type infos and methods for Nums (floating point) +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/optionals.h b/src/stdlib/optionals.h index 1a50007f..145fda60 100644 --- a/src/stdlib/optionals.h +++ b/src/stdlib/optionals.h @@ -1,7 +1,7 @@ -#pragma once - // Optional types +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/paths.c b/src/stdlib/paths.c index 860034cb..3de329a9 100644 --- a/src/stdlib/paths.c +++ b/src/stdlib/paths.c @@ -1,4 +1,5 @@ // A lang for filesystem paths + #include <dirent.h> #include <errno.h> #include <fcntl.h> diff --git a/src/stdlib/paths.h b/src/stdlib/paths.h index 62deaf75..ce6de1c8 100644 --- a/src/stdlib/paths.h +++ b/src/stdlib/paths.h @@ -1,7 +1,7 @@ -#pragma once - // A lang for filesystem paths +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/pointers.c b/src/stdlib/pointers.c index 13e1b2ed..b5e6400f 100644 --- a/src/stdlib/pointers.c +++ b/src/stdlib/pointers.c @@ -1,4 +1,5 @@ // Type infos and methods for Pointer types + #include <err.h> #include <gc.h> #include <stdbool.h> diff --git a/src/stdlib/pointers.h b/src/stdlib/pointers.h index 0c62e18c..a5986468 100644 --- a/src/stdlib/pointers.h +++ b/src/stdlib/pointers.h @@ -1,7 +1,7 @@ -#pragma once - // Type infos and methods for Pointer types +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/print.c b/src/stdlib/print.c index 5f96c2a5..ef570f94 100644 --- a/src/stdlib/print.c +++ b/src/stdlib/print.c @@ -1,4 +1,5 @@ // This file defines some of the helper functions used for printing values + #include <ctype.h> #include <stdio.h> #include <string.h> diff --git a/src/stdlib/print.h b/src/stdlib/print.h index eba1c9d9..7106d561 100644 --- a/src/stdlib/print.h +++ b/src/stdlib/print.h @@ -1,5 +1,3 @@ -#pragma once - // This file defines some functions to make it easy to do formatted text // without using printf style specifiers: // @@ -7,7 +5,8 @@ // fprint(file, ...) - print text to file // print_err(...) - print an error message and exit with EXIT_FAILURE // String(...) - return an allocated string -// + +#pragma once #include <assert.h> #include <gc.h> diff --git a/src/stdlib/random.h b/src/stdlib/random.h index 1a6e89a5..5bd4cc18 100644 --- a/src/stdlib/random.h +++ b/src/stdlib/random.h @@ -1,3 +1,5 @@ +// This file defines some wrapper logic around different systems' random functions + #include <assert.h> #include <stdint.h> diff --git a/src/stdlib/simpleparse.h b/src/stdlib/simpleparse.h index 6435807f..da9dca50 100644 --- a/src/stdlib/simpleparse.h +++ b/src/stdlib/simpleparse.h @@ -1,5 +1,3 @@ -#pragma once - // This file defines some functions to make it easy to parse simply formatted // strings **correctly** without memory bugs. // @@ -16,6 +14,8 @@ // if ((err=strparse("one, two", &item1, ",", PARSE_WHITESPACE, &item2))) // errx(1, "Failed to parse items at: ", err); +#pragma once + #include <stdbool.h> #include <stdint.h> #include <stdio.h> diff --git a/src/stdlib/siphash-internals.h b/src/stdlib/siphash-internals.h index 3ad1d789..181609c9 100644 --- a/src/stdlib/siphash-internals.h +++ b/src/stdlib/siphash-internals.h @@ -1,9 +1,9 @@ -#pragma once - // This file holds the internals for the SipHash implementation. For a few // cases, we want to include this for incrementally computing hashes. // Otherwise, it suffices to just use the siphash24() function from siphash.h +#pragma once + #include <stddef.h> #include <stdint.h> #include <string.h> diff --git a/src/stdlib/siphash.c b/src/stdlib/siphash.c index bcf61b34..f00c3b7c 100644 --- a/src/stdlib/siphash.c +++ b/src/stdlib/siphash.c @@ -1,3 +1,5 @@ +// This file has an implementation of the SipHash hashing function. + #include <stddef.h> #include <stdint.h> #include <string.h> diff --git a/src/stdlib/siphash.h b/src/stdlib/siphash.h index 98f1a6a1..d5b50711 100644 --- a/src/stdlib/siphash.h +++ b/src/stdlib/siphash.h @@ -1,7 +1,7 @@ -#pragma once - // An implementation of the SipHash algorithm. +#pragma once + #include <stddef.h> #include <stdint.h> diff --git a/src/stdlib/stacktrace.c b/src/stdlib/stacktrace.c index 2a54125c..266dc4ef 100644 --- a/src/stdlib/stacktrace.c +++ b/src/stdlib/stacktrace.c @@ -1,3 +1,5 @@ +// This file defines some code to print stack traces. + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif diff --git a/src/stdlib/stacktrace.h b/src/stdlib/stacktrace.h index 36e81bea..5871db19 100644 --- a/src/stdlib/stacktrace.h +++ b/src/stdlib/stacktrace.h @@ -1,4 +1,7 @@ +// This file defines some code to print stack traces. + #pragma once + #include <stdio.h> __attribute__((noinline)) void print_stacktrace(FILE *out, int offset); diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c index 17b5c72c..9238a4cf 100644 --- a/src/stdlib/stdlib.c +++ b/src/stdlib/stdlib.c @@ -14,6 +14,7 @@ #include <sys/param.h> #include <time.h> +#include "../config.h" #include "bools.h" #include "files.h" #include "integers.h" diff --git a/src/stdlib/stdlib.h b/src/stdlib/stdlib.h index d68e6ddb..bbf8a43a 100644 --- a/src/stdlib/stdlib.h +++ b/src/stdlib/stdlib.h @@ -1,7 +1,7 @@ -#pragma once - // Built-in functions +#pragma once + #include <signal.h> #include <stdbool.h> #include <stdint.h> @@ -9,7 +9,7 @@ #include "datatypes.h" #include "print.h" -#include "stacktrace.h" +#include "stacktrace.h" // IWYU pragma: export #include "types.h" extern bool USE_COLOR; diff --git a/src/stdlib/tables.c b/src/stdlib/tables.c index fabdad4f..974e3542 100644 --- a/src/stdlib/tables.c +++ b/src/stdlib/tables.c @@ -1,8 +1,3 @@ -// table.c - C Hash table implementation -// Copyright 2024 Bruce Hill -// Provided under the MIT license with the Commons Clause -// See included LICENSE for details. - // Hash table (aka Dictionary) Implementation // Hash keys and values are stored *by value* // The hash insertion/lookup implementation is based on Lua's tables, diff --git a/src/stdlib/tables.h b/src/stdlib/tables.h index 4d719ed5..208bf6b2 100644 --- a/src/stdlib/tables.h +++ b/src/stdlib/tables.h @@ -1,7 +1,7 @@ -#pragma once - // Hash table datastructure with methods and type information +#pragma once + #include <stdbool.h> #include <stdint.h> #include <string.h> diff --git a/src/stdlib/text.h b/src/stdlib/text.h index f31ee05c..5fa95675 100644 --- a/src/stdlib/text.h +++ b/src/stdlib/text.h @@ -1,8 +1,8 @@ -#pragma once - // Type info and methods for Text datatype, which uses a struct inspired by // Raku's string representation and libunistr +#pragma once + #include <stdbool.h> #include <stdint.h> diff --git a/src/stdlib/tomo.h b/src/stdlib/tomo.h index 6d70a089..ff16bee1 100644 --- a/src/stdlib/tomo.h +++ b/src/stdlib/tomo.h @@ -1,8 +1,8 @@ -#pragma once - // All of the different builtin modules can be included by including this one // import +#pragma once + #include <math.h> // IWYU pragma: export #include <stdbool.h> // IWYU pragma: export #include <stdint.h> // IWYU pragma: export diff --git a/src/stdlib/types.c b/src/stdlib/types.c index e52fd39b..14a8f87c 100644 --- a/src/stdlib/types.c +++ b/src/stdlib/types.c @@ -1,4 +1,5 @@ // Type information and methods for TypeInfos (i.e. runtime representations of types) + #include <err.h> #include <gc.h> #include <sys/param.h> diff --git a/src/stdlib/types.h b/src/stdlib/types.h index c8e8038d..2e358c6c 100644 --- a/src/stdlib/types.h +++ b/src/stdlib/types.h @@ -1,7 +1,7 @@ -#pragma once - // Type information and methods for TypeInfos (i.e. runtime representations of types) +#pragma once + #include <stdbool.h> #include <stdint.h> #include <stdio.h> diff --git a/src/stdlib/util.h b/src/stdlib/util.h index 1530bd9e..db667ccf 100644 --- a/src/stdlib/util.h +++ b/src/stdlib/util.h @@ -1,7 +1,7 @@ -#pragma once - // Built-in utility functions +#pragma once + #include <assert.h> #include <err.h> #include <gc.h> |
