1 /* vi: set sw=4 ts=4: */
3 * prioritynames[] and facilitynames[]
5 * Copyright (C) 2008 by Denys Vlasenko <vda.linux@gmail.com>
7 * Licensed under GPLv2, see file LICENSE in this source tree.
11 #include "common_bufsiz.h"
13 #define SYSLOG_NAMES_CONST
17 /* For the record: with SYSLOG_NAMES <syslog.h> defines
18 * (not declares) the following:
20 typedef struct _code {
21 /*const*/ char *c_name;
24 /*const*/ CODE prioritynames[] = {
25 { "alert", LOG_ALERT },
29 /* same for facilitynames[] */
31 /* This MUST occur only once per entire executable,
32 * therefore we can't just do it in syslogd.c and logger.c -
33 * there will be two copies of it.
35 * We cannot even do it in separate file and then just reference
36 * prioritynames[] from syslogd.c and logger.c - bare <syslog.h>
37 * will not emit extern decls for prioritynames[]! Attempts to
38 * emit "matching" struct _code declaration defeat the whole purpose
41 * For now, syslogd.c and logger.c are simply compiled into
46 /* musl decided to be funny and it implements these as giant defines
47 * of the form: ((CODE *)(const CODE []){ ... })
48 * Which works, but causes _every_ function using them
49 * to have a copy on stack (at least with gcc-6.3.0).
50 * If we reference them just once, this saves 150 bytes.
51 * The pointers themselves are optimized out
52 * (no size change on uclibc).
54 static const CODE *const bb_prioritynames = prioritynames;
55 static const CODE *const bb_facilitynames = facilitynames;