Avoid is_constant calls in vectorizable_bswap
[official-gcc.git] / libgo / go / syscall / signame.c
blobdca92a909a2547f26413df2fea3a2b8611fb3b2a
1 /* signame.c -- get the name of a signal
3 Copyright 2012 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
7 #include <string.h>
9 #include "runtime.h"
10 #include "arch.h"
11 #include "malloc.h"
13 String Signame (intgo sig) __asm__ (GOSYM_PREFIX "syscall.Signame");
15 String
16 Signame (intgo sig)
18 const char* s = NULL;
19 char buf[100];
20 size_t len;
21 byte *data;
22 String ret;
24 #if defined(HAVE_STRSIGNAL)
25 s = strsignal (sig);
26 #endif
28 if (s == NULL)
30 snprintf(buf, sizeof buf, "signal %ld", (long) sig);
31 s = buf;
33 len = __builtin_strlen (s);
34 data = runtime_mallocgc (len, nil, false);
35 __builtin_memcpy (data, s, len);
36 ret.str = data;
37 ret.len = len;
38 return ret;