1/*2 * Copyright © 2016-2018 Sören Tempel3 *4 * This program is free software: you can redistribute it and/or5 * modify it under the terms of the GNU Affero General Public6 * License as published by the Free Software Foundation, either7 * version 3 of the License, or (at your option) any later version.8 *9 * This program is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12 * Affero General Public License for more details.13 *14 * You should have received a copy of the GNU Affero General Public15 * License along with this program. If not, see16 * <http://www.gnu.org/licenses/>.17 */1819#ifndef TMSIM_UTIL_H20#define TMSIM_UTIL_H2122#include <pthread.h>23#include <semaphore.h>24#include <stdio.h>25#include <stdlib.h>2627#include <sys/types.h>2829/**30 * Macro which calls perror(3) and terminates the program with EXIT_FAILURE.31 *32 * @param msg String passed as a first argument to perror(3).33 */34#define die(msg) \35 do { \36 perror(msg); \37 exit(EXIT_FAILURE); \38 } while (0)3940int xstrncmp(char *, char *, size_t, size_t *);41ssize_t readfile(char **, char *);42char *mark(size_t, char *);4344char *linenum(char *, unsigned int);45size_t endofline(char *);4647char *estrndup(char *, size_t);48void *emalloc(size_t);49void *erealloc(void *, size_t);5051void pthread_mutex_elock(pthread_mutex_t *);52void pthread_mutex_eunlock(pthread_mutex_t *);5354void sem_ewait(sem_t *);55void sem_epost(sem_t *);5657#endif