chiark / gitweb /
disorder.h: more consistent approach to function attributes
[disorder] / lib / syscalls.h
... / ...
CommitLineData
1/*
2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007-2009, 2013 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18/** @file lib/syscalls.h
19 * @brief Error-checking library call wrappers
20 */
21#ifndef SYSCALLS_H
22#define SYSCALLS_H
23
24/* various error-handling wrappers. Not actually all system calls! */
25
26struct sockaddr;
27struct sigaction;
28struct timezone;
29
30#if HAVE_SYS_SOCKET_H
31# include <sys/socket.h>
32#endif
33#include <signal.h>
34
35#if !_WIN32
36pid_t xfork(void);
37void xclose_guts(const char *, int, int);
38#define xclose(fd) xclose_guts(__FILE__, __LINE__, fd)
39void xdup2(int, int);
40void xpipe(int *);
41int xfcntl(int, int, long);
42void xsigprocmask(int how, const sigset_t *set, sigset_t *oldset);
43void xsigaction(int sig, const struct sigaction *sa, struct sigaction *oldsa);
44int xnice(int);
45void xgettime(clockid_t clk_id, struct timespec *tp);
46void xnanosleep(const struct timespec *req, struct timespec *rem);
47#endif
48void xlisten(SOCKET, int);
49void xshutdown(SOCKET, int);
50void xsetsockopt(SOCKET, int, int, const void *, socklen_t);
51SOCKET xsocket(int, int, int);
52void xconnect(SOCKET, const struct sockaddr *, socklen_t);
53int xprintf(const char *, ...)
54 attribute((format (printf, 1, 2)));
55void xfclose(FILE *);
56void xgettimeofday(struct timeval *, struct timezone *);
57time_t xtime(time_t *when);
58/* the above all call @fatal@ if the system call fails */
59
60void nonblock(int fd);
61void blocking(int fd);
62void cloexec(int fd);
63/* make @fd@ non-blocking/blocking/close-on-exec; call @fatal@ on error. */
64
65int mustnotbeminus1(const char *what, int value);
66/* If @value@ is -1, report an error including @what@. */
67
68int xstrtol(long *n, const char *s, char **ep, int base);
69int xstrtoll(long_long *n, const char *s, char **ep, int base);
70/* like strtol() but returns errno on error, 0 on success */
71
72#endif /* SYSCALLS_H */
73
74/*
75Local Variables:
76c-basic-offset:2
77comment-column:40
78End:
79*/