1/* util.h 2 * Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 * 6 * Logging and other utility functions. 7 */ 8 9#ifndef _UTIL_H_ 10#define _UTIL_H_ 11 12#include <stdlib.h> 13#include <syslog.h> 14 15#define die(_msg, ...) do { \ 16 syslog(LOG_ERR, "libminijail: " _msg, ## __VA_ARGS__); \ 17 abort(); \ 18} while (0) 19 20#define pdie(_msg, ...) \ 21 die(_msg ": %m", ## __VA_ARGS__) 22 23#define warn(_msg, ...) \ 24 syslog(LOG_WARNING, "libminijail: " _msg, ## __VA_ARGS__) 25 26#define info(_msg, ...) \ 27 syslog(LOG_INFO, "libminijail: " _msg, ## __VA_ARGS__) 28 29extern const char *log_syscalls[]; 30extern const size_t log_syscalls_len; 31 32static inline int is_android() { 33#if defined(__ANDROID__) 34 return 1; 35#else 36 return 0; 37#endif 38} 39 40static inline int running_with_asan() { 41#ifndef __has_feature 42#define __has_feature(x) 0 43#endif 44 45#if __has_feature(address_sanitizer) 46 return 1; 47#else 48 return 0; 49#endif 50} 51 52int lookup_syscall(const char *name); 53const char *lookup_syscall_name(int nr); 54long int parse_constant(char *constant_str, char **endptr); 55char *strip(char *s); 56char *tokenize(char **stringp, const char *delim); 57 58#endif /* _UTIL_H_ */ 59