Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: fusl/src/string/strsignal.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <signal.h> 1 #include <signal.h>
2 #include <string.h> 2 #include <string.h>
3 #include "locale_impl.h" 3 #include "locale_impl.h"
4 4
5 #if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) \ 5 #if (SIGHUP == 1) && (SIGINT == 2) && (SIGQUIT == 3) && (SIGILL == 4) && \
6 && (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) \ 6 (SIGTRAP == 5) && (SIGABRT == 6) && (SIGBUS == 7) && (SIGFPE == 8) && \
7 && (SIGKILL == 9) && (SIGUSR1 == 10) && (SIGSEGV == 11) && (SIGUSR2 == 12) \ 7 (SIGKILL == 9) && (SIGUSR1 == 10) && (SIGSEGV == 11) && (SIGUSR2 == 12) && \
8 && (SIGPIPE == 13) && (SIGALRM == 14) && (SIGTERM == 15) && (SIGSTKFLT == 16) \ 8 (SIGPIPE == 13) && (SIGALRM == 14) && (SIGTERM == 15) && \
9 && (SIGCHLD == 17) && (SIGCONT == 18) && (SIGSTOP == 19) && (SIGTSTP == 20) \ 9 (SIGSTKFLT == 16) && (SIGCHLD == 17) && (SIGCONT == 18) && \
10 && (SIGTTIN == 21) && (SIGTTOU == 22) && (SIGURG == 23) && (SIGXCPU == 24) \ 10 (SIGSTOP == 19) && (SIGTSTP == 20) && (SIGTTIN == 21) && \
11 && (SIGXFSZ == 25) && (SIGVTALRM == 26) && (SIGPROF == 27) && (SIGWINCH == 28) \ 11 (SIGTTOU == 22) && (SIGURG == 23) && (SIGXCPU == 24) && (SIGXFSZ == 25) && \
12 && (SIGPOLL == 29) && (SIGPWR == 30) && (SIGSYS == 31) 12 (SIGVTALRM == 26) && (SIGPROF == 27) && (SIGWINCH == 28) && \
13 (SIGPOLL == 29) && (SIGPWR == 30) && (SIGSYS == 31)
13 14
14 #define sigmap(x) x 15 #define sigmap(x) x
15 16
16 #else 17 #else
17 18
18 static const char map[] = { 19 static const char map[] = {[SIGHUP] = 1, [SIGINT] = 2, [SIGQUIT] = 3,
19 » [SIGHUP] = 1, 20 [SIGILL] = 4, [SIGTRAP] = 5, [SIGABRT] = 6,
20 » [SIGINT] = 2, 21 [SIGBUS] = 7, [SIGFPE] = 8, [SIGKILL] = 9,
21 » [SIGQUIT] = 3, 22 [SIGUSR1] = 10, [SIGSEGV] = 11, [SIGUSR2] = 12,
22 » [SIGILL] = 4, 23 [SIGPIPE] = 13, [SIGALRM] = 14, [SIGTERM] = 15,
23 » [SIGTRAP] = 5, 24 [SIGSTKFLT] = 16, [SIGCHLD] = 17, [SIGCONT] = 18,
24 » [SIGABRT] = 6, 25 [SIGSTOP] = 19, [SIGTSTP] = 20, [SIGTTIN] = 21,
25 » [SIGBUS] = 7, 26 [SIGTTOU] = 22, [SIGURG] = 23, [SIGXCPU] = 24,
26 » [SIGFPE] = 8, 27 [SIGXFSZ] = 25, [SIGVTALRM] = 26, [SIGPROF] = 27,
27 » [SIGKILL] = 9, 28 [SIGWINCH] = 28, [SIGPOLL] = 29, [SIGPWR] = 30,
28 » [SIGUSR1] = 10, 29 [SIGSYS] = 31};
29 » [SIGSEGV] = 11,
30 » [SIGUSR2] = 12,
31 » [SIGPIPE] = 13,
32 » [SIGALRM] = 14,
33 » [SIGTERM] = 15,
34 » [SIGSTKFLT] = 16,
35 » [SIGCHLD] = 17,
36 » [SIGCONT] = 18,
37 » [SIGSTOP] = 19,
38 » [SIGTSTP] = 20,
39 » [SIGTTIN] = 21,
40 » [SIGTTOU] = 22,
41 » [SIGURG] = 23,
42 » [SIGXCPU] = 24,
43 » [SIGXFSZ] = 25,
44 » [SIGVTALRM] = 26,
45 » [SIGPROF] = 27,
46 » [SIGWINCH] = 28,
47 » [SIGPOLL] = 29,
48 » [SIGPWR] = 30,
49 » [SIGSYS] = 31
50 };
51 30
52 #define sigmap(x) ((x) >= sizeof map ? (x) : map[(x)]) 31 #define sigmap(x) ((x) >= sizeof map ? (x) : map[(x)])
53 32
54 #endif 33 #endif
55 34
56 static const char strings[] = 35 static const char strings[] =
57 » "Unknown signal\0" 36 "Unknown signal\0"
58 » "Hangup\0" 37 "Hangup\0"
59 » "Interrupt\0" 38 "Interrupt\0"
60 » "Quit\0" 39 "Quit\0"
61 » "Illegal instruction\0" 40 "Illegal instruction\0"
62 » "Trace/breakpoint trap\0" 41 "Trace/breakpoint trap\0"
63 » "Aborted\0" 42 "Aborted\0"
64 » "Bus error\0" 43 "Bus error\0"
65 » "Arithmetic exception\0" 44 "Arithmetic exception\0"
66 » "Killed\0" 45 "Killed\0"
67 » "User defined signal 1\0" 46 "User defined signal 1\0"
68 » "Segmentation fault\0" 47 "Segmentation fault\0"
69 » "User defined signal 2\0" 48 "User defined signal 2\0"
70 » "Broken pipe\0" 49 "Broken pipe\0"
71 » "Alarm clock\0" 50 "Alarm clock\0"
72 » "Terminated\0" 51 "Terminated\0"
73 » "Stack fault\0" 52 "Stack fault\0"
74 » "Child process status\0" 53 "Child process status\0"
75 » "Continued\0" 54 "Continued\0"
76 » "Stopped (signal)\0" 55 "Stopped (signal)\0"
77 » "Stopped\0" 56 "Stopped\0"
78 » "Stopped (tty input)\0" 57 "Stopped (tty input)\0"
79 » "Stopped (tty output)\0" 58 "Stopped (tty output)\0"
80 » "Urgent I/O condition\0" 59 "Urgent I/O condition\0"
81 » "CPU time limit exceeded\0" 60 "CPU time limit exceeded\0"
82 » "File size limit exceeded\0" 61 "File size limit exceeded\0"
83 » "Virtual timer expired\0" 62 "Virtual timer expired\0"
84 » "Profiling timer expired\0" 63 "Profiling timer expired\0"
85 » "Window changed\0" 64 "Window changed\0"
86 » "I/O possible\0" 65 "I/O possible\0"
87 » "Power failure\0" 66 "Power failure\0"
88 » "Bad system call\0" 67 "Bad system call\0"
89 » "RT32" 68 "RT32"
90 » "\0RT33\0RT34\0RT35\0RT36\0RT37\0RT38\0RT39\0RT40" 69 "\0RT33\0RT34\0RT35\0RT36\0RT37\0RT38\0RT39\0RT40"
91 » "\0RT41\0RT42\0RT43\0RT44\0RT45\0RT46\0RT47\0RT48" 70 "\0RT41\0RT42\0RT43\0RT44\0RT45\0RT46\0RT47\0RT48"
92 » "\0RT49\0RT50\0RT51\0RT52\0RT53\0RT54\0RT55\0RT56" 71 "\0RT49\0RT50\0RT51\0RT52\0RT53\0RT54\0RT55\0RT56"
93 » "\0RT57\0RT58\0RT59\0RT60\0RT61\0RT62\0RT63\0RT64" 72 "\0RT57\0RT58\0RT59\0RT60\0RT61\0RT62\0RT63\0RT64"
94 #if _NSIG > 65 73 #if _NSIG > 65
95 » "\0RT65\0RT66\0RT67\0RT68\0RT69\0RT70\0RT71\0RT72" 74 "\0RT65\0RT66\0RT67\0RT68\0RT69\0RT70\0RT71\0RT72"
96 » "\0RT73\0RT74\0RT75\0RT76\0RT77\0RT78\0RT79\0RT80" 75 "\0RT73\0RT74\0RT75\0RT76\0RT77\0RT78\0RT79\0RT80"
97 » "\0RT81\0RT82\0RT83\0RT84\0RT85\0RT86\0RT87\0RT88" 76 "\0RT81\0RT82\0RT83\0RT84\0RT85\0RT86\0RT87\0RT88"
98 » "\0RT89\0RT90\0RT91\0RT92\0RT93\0RT94\0RT95\0RT96" 77 "\0RT89\0RT90\0RT91\0RT92\0RT93\0RT94\0RT95\0RT96"
99 » "\0RT97\0RT98\0RT99\0RT100\0RT101\0RT102\0RT103\0RT104" 78 "\0RT97\0RT98\0RT99\0RT100\0RT101\0RT102\0RT103\0RT104"
100 » "\0RT105\0RT106\0RT107\0RT108\0RT109\0RT110\0RT111\0RT112" 79 "\0RT105\0RT106\0RT107\0RT108\0RT109\0RT110\0RT111\0RT112"
101 » "\0RT113\0RT114\0RT115\0RT116\0RT117\0RT118\0RT119\0RT120" 80 "\0RT113\0RT114\0RT115\0RT116\0RT117\0RT118\0RT119\0RT120"
102 » "\0RT121\0RT122\0RT123\0RT124\0RT125\0RT126\0RT127\0RT128" 81 "\0RT121\0RT122\0RT123\0RT124\0RT125\0RT126\0RT127\0RT128"
103 #endif 82 #endif
104 » ""; 83 "";
105 84
106 char *strsignal(int signum) 85 char* strsignal(int signum) {
107 { 86 const char* s = strings;
108 » const char *s = strings;
109 87
110 » signum = sigmap(signum); 88 signum = sigmap(signum);
111 » if (signum - 1U >= _NSIG-1) signum = 0; 89 if (signum - 1U >= _NSIG - 1)
90 signum = 0;
112 91
113 » for (; signum--; s++) for (; *s; s++); 92 for (; signum--; s++)
93 for (; *s; s++)
94 ;
114 95
115 » return (char *)LCTRANS_CUR(s); 96 return (char*)LCTRANS_CUR(s);
116 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698