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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 0826b7fd
...@@ -232,6 +232,9 @@ size_t syscall_arg__scnprintf_sockaddr(char *bf, size_t size, struct syscall_arg ...@@ -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); 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 #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); 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 #define SCA_STATX_FLAGS syscall_arg__scnprintf_statx_flags
......
...@@ -27,3 +27,21 @@ size_t syscall_arg__scnprintf_socket_protocol(char *bf, size_t size, struct sysc ...@@ -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); 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);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment