]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-sizeof: print pointer sizes 16955/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 4 Sep 2020 16:32:43 +0000 (18:32 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 4 Sep 2020 16:45:44 +0000 (18:45 +0200)
This is useful information, I don't know why we forgot to add it there.

gcc doesn't like arithemetic on a pointer to a function or void*, so don't
print signedness info there. It doesn't matter anyway.
C says function pointers can be different... Though I guess our code isn't
prepared for that.

src/test/test-sizeof.c

index b9d63d6b418f3c344aed8e96247b6bc4e96f43ba..6dee2022e8f0d9e2c599aca7838e3326cc539878 100644 (file)
 
 DISABLE_WARNING_TYPE_LIMITS;
 
+#define info_no_sign(t)                                                 \
+        printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t),     \
+               sizeof(t)*CHAR_BIT,                                      \
+               __alignof__(t))
+
 #define info(t)                                                         \
         printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t),   \
                sizeof(t)*CHAR_BIT,                                      \
@@ -37,6 +42,12 @@ enum BigEnum2 {
 };
 
 int main(void) {
+        int (*function_pointer)(void);
+
+        info_no_sign(function_pointer);
+        info_no_sign(void*);
+        info(char*);
+
         info(char);
         info(signed char);
         info(unsigned char);