2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 01:34:00 +08:00

perf beauty: Add socket level scnprintf that handles ARCH specific SOL_SOCKET

SOL_SOCKET has a different value according to the architecture, some
have it as 0xffff while all the others have it as 1, so a simple string
array isn't usable, add a scnprintf routine that treats it as a special
case, using the array for other values.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2021-11-09 09:23:07 -03:00
parent 0826b7fd0a
commit 66aee54ba4
2 changed files with 21 additions and 0 deletions

View File

@ -232,6 +232,9 @@ size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg
size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_SK_PROTO syscall_arg__scnprintf_socket_protocol
size_t syscall_arg__scnprintf_socket_level(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_SK_LEVEL syscall_arg__scnprintf_socket_level
size_t syscall_arg__scnprintf_statx_flags(char *bf, size_t size, struct syscall_arg *arg);
#define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags

View File

@ -27,3 +27,21 @@ size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct sysc
return syscall_arg__scnprintf_int(bf, size, arg);
}
static size_t socket__scnprintf_level(int level, char *bf, size_t size, bool show_prefix)
{
#if defined(__alpha__) || defined(__hppa__) || defined(__mips__) || defined(__sparc__)
const int sol_socket = 0xffff;
#else
const int sol_socket = 1;
#endif
if (level == sol_socket)
return scnprintf(bf, size, "%sSOCKET", show_prefix ? "SOL_" : "");
return strarray__scnprintf(&strarray__socket_level, bf, size, "%d", show_prefix, level);
}
size_t syscall_arg__scnprintf_socket_level(char *bf, size_t size, struct syscall_arg *arg)
{
return socket__scnprintf_level(arg->val, bf, size, arg->show_string_prefix);
}