root/tools/perf/trace/beauty/socket_type.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. syscall_arg__scnprintf_socket_type

   1 // SPDX-License-Identifier: LGPL-2.1
   2 #include <sys/types.h>
   3 #include <sys/socket.h>
   4 
   5 #ifndef SOCK_DCCP
   6 # define SOCK_DCCP              6
   7 #endif
   8 
   9 #ifndef SOCK_CLOEXEC
  10 # define SOCK_CLOEXEC           02000000
  11 #endif
  12 
  13 #ifndef SOCK_NONBLOCK
  14 # define SOCK_NONBLOCK          00004000
  15 #endif
  16 
  17 #ifndef SOCK_TYPE_MASK
  18 #define SOCK_TYPE_MASK 0xf
  19 #endif
  20 
  21 static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg)
  22 {
  23         bool show_prefix = arg->show_string_prefix;
  24         const char *prefix = "SOCK_";
  25         size_t printed;
  26         int type = arg->val,
  27             flags = type & ~SOCK_TYPE_MASK;
  28 
  29         type &= SOCK_TYPE_MASK;
  30         /*
  31          * Can't use a strarray, MIPS may override for ABI reasons.
  32          */
  33         switch (type) {
  34 #define P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, "%s%s", show_prefix ? prefix : "", #n); break;
  35         P_SK_TYPE(STREAM);
  36         P_SK_TYPE(DGRAM);
  37         P_SK_TYPE(RAW);
  38         P_SK_TYPE(RDM);
  39         P_SK_TYPE(SEQPACKET);
  40         P_SK_TYPE(DCCP);
  41         P_SK_TYPE(PACKET);
  42 #undef P_SK_TYPE
  43         default:
  44                 printed = scnprintf(bf, size, "%#x", type);
  45         }
  46 
  47 #define P_SK_FLAG(n) \
  48         if (flags & SOCK_##n) { \
  49                 printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
  50                 flags &= ~SOCK_##n; \
  51         }
  52 
  53         P_SK_FLAG(CLOEXEC);
  54         P_SK_FLAG(NONBLOCK);
  55 #undef P_SK_FLAG
  56 
  57         if (flags)
  58                 printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
  59 
  60         return printed;
  61 }
  62 
  63 #define SCA_SK_TYPE syscall_arg__scnprintf_socket_type

/* [<][>][^][v][top][bottom][index][help] */