]> Cypherpunks repositories - keks.git/commitdiff
Fix included headers
authorSergey Matveev <stargrave@stargrave.org>
Fri, 4 Apr 2025 08:46:06 +0000 (11:46 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 4 Apr 2025 09:03:26 +0000 (12:03 +0300)
c/cmd/pp/pp.c
c/compile_flags.txt.do
c/conf/cflags
c/lib/dec.h
c/lib/dectai.c
c/lib/dectai.h
c/lib/enctai.h
c/lib/schema.h
c/lint/iwyu [new file with mode: 0755]
c/lint/iwyu-maps.imp

index 5cba8459dea3a84ae3d60d627ce168f4095906d6bdd1ed30e13c2b0fc1625ad7..c30d1f1e2cb81449d8be24a9b2727281a09d26d89dba63e9bcccc6316ea04b15 100644 (file)
 #include <math.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <unistd.h>
 
+#ifdef __FreeBSD__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
+#define __BSD_VISIBLE 1
+#pragma clang diagnostic pop
+#endif
+#include <time.h>
+
 #include <keks/atom.h>
 #include <keks/err.h>
 #include <keks/items.h>
@@ -84,7 +92,10 @@ printer( // NOLINT(misc-no-recursion)
         fputs("  ", stdout);
     } else {
         fprintf(stdout, "%s%zd%s ", ColourBlue, indent, ColourReset);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
         fprintf(stdout, OffFmt, ColourRed, items->offsets[idx], ColourReset);
+#pragma clang diagnostic pop
     }
     struct KEKSItem *item = &(items->list[idx]);
     printIndent(indent);
@@ -372,13 +383,21 @@ main(int argc, char **argv)
             KEKSItemsNoOffsets(&items);
         }
         errno = 0;
+#ifdef __FreeBSD__
         if (clock_gettime(CLOCK_MONOTONIC_PRECISE, &started) != 0) {
+#else
+        if (clock_gettime(CLOCK_MONOTONIC, &started) != 0) {
+#endif
             fprintf(stderr, "clock_gettime(started): %s\n", strerror(errno));
             exit(EXIT_FAILURE);
         }
         err = KEKSItemsParse(&items, &off, buf, len);
         errno = 0;
+#ifdef __FreeBSD__
         if (clock_gettime(CLOCK_MONOTONIC_PRECISE, &finished) != 0) {
+#else
+        if (clock_gettime(CLOCK_MONOTONIC, &finished) != 0) {
+#endif
             fprintf(stderr, "clock_gettime(finished): %s\n", strerror(errno));
             exit(EXIT_FAILURE);
         }
index 1b9f125d4b87611b004426333fe7b55503e8eae6ba1319468d727f19d65d9e9f..302dc07a11139552b08ab8d26ff45d279702b56cdfc0c0a34eb1ec1715ab47f7 100644 (file)
@@ -1,3 +1,4 @@
-redo-ifchange conf/prefix
+redo-ifchange conf/cflags conf/prefix
 read PREFIX <conf/prefix
+cat conf/cflags
 printf "%s\n" "-I$PREFIX/include"
index c761868942cbbc1177b22817f6b2394d2cad08950fdd766066a23b694b4a47fd..3a3994c8c279750cbd92bb1b44e6bb4e408b692d5dae5a49fb810c676864ded6 100644 (file)
@@ -1,4 +1,5 @@
 -std=c99
+-D_POSIX_C_SOURCE=200809L
 -pipe
 -fno-omit-frame-pointer
 -fPIC
index f006492790c8f268da47908a7e8c11f9d16003c20fa0a2cea80b7e4de84368bc..feca54ec2b53daa0b0076d3aeba6015cffc5a3ed8b00e17e2992720239e4d9f3 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stddef.h>
 
-#include "atom.h"
+#include "atom.h" // IWYU pragma: keep // struct KEKSAtom
 #include "err.h"
 
 // TEXINFO: KEKSAtomDecode
index ace0cab89cb780a0b27afcd20c43178202526867afdf3f62f3cab366bae3da5a..8684bd54d3a708a8a7b0ab4fa3626e2d957615c27ef80f29717a9377b6e02031 100644 (file)
@@ -13,7 +13,6 @@
 // You should have received a copy of the GNU Lesser General Public
 // License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-#include <stddef.h>
 #include <stdint.h>
 #include <time.h>
 
index 49a69d9c6c271733bdff7cd7a80c3c2440f40cf7cd8ae4fdbdb9c302303474d2..3724578d2ee3e6f171621ba0786d280cf307d48c07485043e2c49d3fce4a4c03 100644 (file)
@@ -1,8 +1,7 @@
 #ifndef KEKS_DECTAI_H
 #define KEKS_DECTAI_H
 
-#include <stddef.h>
-#include <time.h>
+#include <time.h> // IWYU pragma: keep // struct timespec
 
 #include "err.h"
 
index 6bd612d0432f31aab7b5be825e10a0627092a0d1f4263b1f3e0c67d56f6ad907..2ed501cef407fa6e56ca2782fad16385b0bf8a51f9f35aceebddf4a506069892 100644 (file)
@@ -2,7 +2,7 @@
 #define KEKS_ENCTAI_H
 
 #include <stdbool.h>
-#include <time.h>
+#include <time.h> // IWYU pragma: keep // struct timespec
 
 // TEXINFO: KEKSTimespecToTAI64
 // @deftypefun bool KEKSTimespecToTAI64 @
index 1a280a51bfedac8a74e0811b7bca182d81536e3c10be940db82ad783e7fc576b..502674c2d4a2c7fa262fc096a3c5f7d5db3fbd76bb571a7be7fc9b0841198ba2 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stddef.h>
 
-#include "items.h"
+#include "items.h" // IWYU pragma: keep // struct KEKSItems
 
 // TEXINFO: KEKSSchemaErrType
 // @deftp {Data type} {enum KEKSSchemaErrType}
diff --git a/c/lint/iwyu b/c/lint/iwyu
new file mode 100755 (executable)
index 0000000..0b249dd
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh -e
+
+root=${0%/*}
+redo-ifchange $root/../compile_flags.txt
+cflags=$(cat $root/../compile_flags.txt)
+[ $# -eq 0 ] && srcs=*.c || srcs="$@"
+for c in $srcs ; do
+    include-what-you-use $cflags -Xiwyu --mapping_file=$root/iwyu-maps.imp $c 2>&1
+done
index 446e7e908611f1369afc744d137dcf9724850b19c101a19d14497c1e8f1aa336..fd6611bc57c9a52ae2cd14354db42bd5d81662b3a216820f541a7cf87915ff44 100644 (file)
@@ -1,5 +1,6 @@
 [
     { symbol: ["CLOCK_REALTIME", "private", "<time.h>", "public"] },
+    { symbol: ["CLOCK_MONOTONIC_PRECISE", "private", "<time.h>", "public"] },
     { symbol: ["PTRDIFF_MAX", "private", "<stdint.h>", "public"] },
     { symbol: ["SIZE_MAX", "private", "<stdint.h>", "public"] },
 ]