summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
committerMattias Andrée <maandree@kth.se>2023-12-05 20:10:48 +0100
commit6d77b155bcd4725e09837604e6ea86f5f124ba9c (patch)
tree7cfdf466bb94bbbe3e7929432bc048da5eaa2349 /linux
parentSecond commit (diff)
downloadlibsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.gz
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.bz2
libsyscalls-6d77b155bcd4725e09837604e6ea86f5f124ba9c.tar.xz
Third commit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--linux/errors.c4
-rw-r--r--linux/signals.c4
-rw-r--r--linux/symbols.c36
-rw-r--r--linux/syscall-table.c11
-rw-r--r--linux/tests/os-dependent-arrays17
-rw-r--r--linux/tests/os-dependent-primitives23
-rw-r--r--linux/types.c1
7 files changed, 88 insertions, 8 deletions
diff --git a/linux/errors.c b/linux/errors.c
index d8a0e7f..94c3cd2 100644
--- a/linux/errors.c
+++ b/linux/errors.c
@@ -10,7 +10,7 @@ get_linux_syscall_errors(enum libsyscalls_arch arch, const struct libsyscalls_na
{
#define CASE(ARCH)\
*errs_out = linux_errors_for_##ARCH;\
- *nerrs_out = sizeof(linux_errors_for_##ARCH) / sizeof(*linux_errors_for_##ARCH);\
+ *nerrs_out = ELEMSOF(linux_errors_for_##ARCH);\
goto out
switch ((int)arch) {
@@ -121,7 +121,7 @@ get_linux_syscall_errors(enum libsyscalls_arch arch, const struct libsyscalls_na
}
*errs_out = linux_errors_for_generic;
- *nerrs_out = sizeof(linux_errors_for_generic) / sizeof(*linux_errors_for_generic);
+ *nerrs_out = ELEMSOF(linux_errors_for_generic);
out:
return LIBSYSCALLS_E_OK;
diff --git a/linux/signals.c b/linux/signals.c
index 7d7f868..743fc89 100644
--- a/linux/signals.c
+++ b/linux/signals.c
@@ -10,7 +10,7 @@ get_linux_signals(enum libsyscalls_arch arch, const struct libsyscalls_named_num
{
#define CASE(ARCH)\
*sigs_out = linux_signals_for_##ARCH;\
- *nsigs_out = sizeof(linux_signals_for_##ARCH) / sizeof(*linux_signals_for_##ARCH);\
+ *nsigs_out = ELEMSOF(linux_signals_for_##ARCH);\
goto out
switch ((int)arch) {
@@ -121,7 +121,7 @@ get_linux_signals(enum libsyscalls_arch arch, const struct libsyscalls_named_num
}
*sigs_out = linux_signals_for_generic;
- *nsigs_out = sizeof(linux_signals_for_generic) / sizeof(*linux_signals_for_generic);
+ *nsigs_out = ELEMSOF(linux_signals_for_generic);
out:
return LIBSYSCALLS_E_OK;
diff --git a/linux/symbols.c b/linux/symbols.c
index cbc61f5..7a3c8e5 100644
--- a/linux/symbols.c
+++ b/linux/symbols.c
@@ -32,6 +32,11 @@ extract_linux_symbol_signal(struct libsyscalls_symbol_printer_data *data, unsign
}
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+#endif
+
static const char *
extract_linux_symbol_mode(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out)
{
@@ -128,6 +133,10 @@ extract_linux_symbol_umask(struct libsyscalls_symbol_printer_data *data, unsigne
return data->buf;
}
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
static const char *
extract_linux_symbol_dev(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out)
@@ -162,7 +171,7 @@ extract_linux_symbol_dev(struct libsyscalls_symbol_printer_data *data, unsigned
static const char *
extract_linux_symbol_clockid_t(struct libsyscalls_symbol_printer_data *data, unsigned long long int *valuep, char *fallback_out)
{
- if (*valuep >= 0)
+ if ((long long int)*valuep >= 0)
return NULL;
else if ((*valuep & 7) == 2)
sprintf(data->buf, "%lli (pid: %llu)", (long long int)*valuep, ~*valuep / 8);
@@ -171,7 +180,8 @@ extract_linux_symbol_clockid_t(struct libsyscalls_symbol_printer_data *data, uns
else if ((*valuep & 7) == 6)
sprintf(data->buf, "%lli (tid: %llu)", (long long int)*valuep, ~*valuep / 8);
else
- sprintf(data->buf, "%lli (~%llu*8 + %u)", (long long int)*valuep, ~*valuep / 8, *valuep & 7);
+ sprintf(data->buf, "%lli (~%llu*8 + %llu)", (long long int)*valuep, ~*valuep / 8, *valuep & 7);
+ (void) fallback_out;
*valuep = 0;
return data->buf;
}
@@ -269,6 +279,11 @@ have_fun:
}
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
+#endif
+
static struct libsyscalls_syscall_display_info *
get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsyscalls_syscall_abi *syscall,
long long int syscall_number, unsigned long long int *syscall_argument)
@@ -277,7 +292,7 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca
libsyscalls_symbol_printer_function **funcs;
int i, nargs, nsyms;
size_t data_size = offsetof(LIBSYSCALLS_SYMBOL_PRINTER_DATA, buf);
- size_t data_align = alignof(*data);
+ size_t data_align = alignof(LIBSYSCALLS_SYMBOL_PRINTER_DATA);
size_t bufspace, bufspace1, bufspace2;
LIBSYSCALLS_SYMBOL_PRINTER first, second;
@@ -299,9 +314,18 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca
}
{
- char data_vla_buf[(nargs + 1) * data_size + data_align];
+#if defined(__clang__)
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wvla"
+#endif
+
+ char data_vla_buf[(size_t)(nargs + 1) * data_size + data_align];
libsyscalls_symbol_printer_function *funcs_vla[nargs + 1];
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
+
data = (void *)ALIGN_BUF(data_vla_buf, data_align);
funcs = funcs_vla;
@@ -319,3 +343,7 @@ get_linux_syscall_display_info(enum libsyscalls_arch arch, const struct libsysca
return build_syscall_display_info(data, data_size, data_align, funcs, syscall, nargs, nsyms);
}
}
+
+#if defined(__clang__)
+# pragma clang diagnostic pop
+#endif
diff --git a/linux/syscall-table.c b/linux/syscall-table.c
index 6bcd480..5a5d9c2 100644
--- a/linux/syscall-table.c
+++ b/linux/syscall-table.c
@@ -5,8 +5,19 @@
#include "../generated/linux-syscall-table.h"
#include "../generated/linux-syscalls.h"
+
+#if defined(__GNUC__)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wunused-variable" /* unused = not available on any architecutre the library is being compiled for */
+#endif
+
#include "syscalls.h"
+#if defined(__GNUC__)
+# pragma GCC diagnostic pop
+#endif
+
+
/* generated/linux-syscall-dedup.h removes references to duplicate symbols, then compiler optimisation removes them */
#if defined(__clang__)
diff --git a/linux/tests/os-dependent-arrays b/linux/tests/os-dependent-arrays
new file mode 100644
index 0000000..3140ce4
--- /dev/null
+++ b/linux/tests/os-dependent-arrays
@@ -0,0 +1,17 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+for arch in $(getnamelist ARCH); do
+ archn=$(getnum ARCH $arch)
+ if ! issupported $os $arch; then
+ continue
+ fi
+
+ ptype=ULONG
+ atype=FD_SET
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" $ptype) $os $arch $ptype > $a
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" $atype) $os $arch $atype > $b
+ sed 's/^\(array_size\) = 1$/\1 = '"$(( 1024 / $(sed -n 's/^width_in_bits = //p' < $a) ))"/ < $a \
+ | sed 's/^\(is_unsigned\) = 1/\1 = 0/' \
+ | diff -u - $b
+done
diff --git a/linux/tests/os-dependent-primitives b/linux/tests/os-dependent-primitives
new file mode 100644
index 0000000..bc20bf3
--- /dev/null
+++ b/linux/tests/os-dependent-primitives
@@ -0,0 +1,23 @@
+# -*- sh -*-
+# See LICENSE file for copyright and license details.
+
+for arch in $(getnamelist ARCH); do
+ archn=$(getnum ARCH $arch)
+ if ! issupported $os $arch; then
+ continue
+ fi
+
+ typeisas SCHAR INT8
+ typeisas SHORT INT16
+ typeisas INT INT32
+ typeisas LONG INTPTR
+ typeisas LLONG INT64
+
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" LONG) $os $arch LONG \
+ | sed 's/^\(is_unsigned\) = 0$/\1 = 1/' \
+ | sed 's/^\(sign_representation\) = .*$/\1 = '"$(getnum SIGN UNDETERMINED)"/ \
+ | sed 's/^\(annotation\) = .*$/\1 = '"$(getnum ANNOTATION UNDETERMINED)"/ \
+ | sed 's/^\(section\) = .*$/\1 = '"$(getnum SECTION UNDETERMINED)"/ > $a
+ get-datatype-description.tu $osn $archn $(lookupnum "$types" DYNAMIC) $os $arch DYNAMIC > $b
+ diff -u $a $b
+done
diff --git a/linux/types.c b/linux/types.c
index fee69fe..66bb276 100644
--- a/linux/types.c
+++ b/linux/types.c
@@ -50,5 +50,6 @@ get_linux_datatype_description(enum libsyscalls_arch arch, enum libsyscalls_data
/* something only defined on some other operating system */
return LIBSYSCALLS_E_NOSUCHTYPE;
}
+ (void) arch;
return LIBSYSCALLS_E_OK;
}