source: rtems-libbsd/dhcpcd/common.h @ f2ed769

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since f2ed769 was f2ed769, checked in by Sebastian Huber <sebastian.huber@…>, on 01/30/14 at 12:29:46

DHCPCD(8): Import

Import DHCPCD(8) from:

http://roy.marples.name/projects/dhcpcd/

The upstream sources can be obtained via:

fossil clone http://roy.marples.name/projects/dhcpcd

The imported version is 2014-01-29 19:46:44 [6b209507bb].

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * dhcpcd - DHCP client daemon
3 * Copyright (c) 2006-2013 Roy Marples <roy@marples.name>
4 * All rights reserved
5
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef COMMON_H
29#define COMMON_H
30
31#include <sys/time.h>
32#include <stdio.h>
33
34#include "config.h"
35#include "defs.h"
36
37#ifndef HOSTNAME_MAX_LEN
38#define HOSTNAME_MAX_LEN        250     /* 255 - 3 (FQDN) - 2 (DNS enc) */
39#endif
40
41#define UNCONST(a)              ((void *)(unsigned long)(const void *)(a))
42#define STRINGIFY(a)            #a
43#define TOSTRING(a)             STRINGIFY(a)
44
45#define timeval_to_double(tv) ((tv)->tv_sec * 1.0 + (tv)->tv_usec * 1.0e-6)
46#define timernorm(tv) do {                                              \
47        while ((tv)->tv_usec >= 1000000) {                              \
48                (tv)->tv_sec++;                                         \
49                (tv)->tv_usec -= 1000000;                               \
50        }                                                               \
51} while (0 /* CONSTCOND */);
52#define tv_to_ms(ms, tv) do {                                           \
53        ms = (tv)->tv_sec * 1000;                                       \
54        ms += (tv)->tv_usec / 1000;                                     \
55} while (0 /* CONSTCOND */);
56#define ms_to_tv(tv, ms) do {                                           \
57        (tv)->tv_sec = ms / 1000;                                       \
58        (tv)->tv_usec = (ms - ((tv)->tv_sec * 1000)) * 1000;            \
59} while (0 /* CONSTCOND */);
60
61#ifndef TIMEVAL_TO_TIMESPEC
62#define TIMEVAL_TO_TIMESPEC(tv, ts) do {                                \
63        (ts)->tv_sec = (tv)->tv_sec;                                    \
64        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
65} while (0 /* CONSTCOND */)
66#endif
67
68#if __GNUC__ > 2 || defined(__INTEL_COMPILER)
69# ifndef __dead
70#  define __dead __attribute__((__noreturn__))
71# endif
72# ifndef __packed
73#  define __packed   __attribute__((__packed__))
74# endif
75# ifndef __unused
76#  define __unused   __attribute__((__unused__))
77# endif
78#else
79# ifndef __dead
80#  define __dead
81# endif
82# ifndef __packed
83#  define __packed
84# endif
85# ifndef __unused
86#  define __unused
87# endif
88#endif
89
90/* We don't really need this as our supported systems define __restrict
91 * automatically for us, but it is here for completeness. */
92#ifndef __restrict
93# if defined(__lint__)
94#  define __restrict
95# elif __STDC_VERSION__ >= 199901L
96#  define __restrict restrict
97# elif !(2 < __GNUC__ || (2 == __GNU_C && 95 <= __GNUC_VERSION__))
98#  define __restrict
99# endif
100#endif
101
102int set_cloexec(int);
103int set_nonblock(int);
104char *get_line(FILE * __restrict);
105const char *get_hostname(int);
106extern int clock_monotonic;
107int get_monotonic(struct timeval *);
108ssize_t setvar(char ***, const char *, const char *, const char *);
109ssize_t setvard(char ***, const char *, const char *, int);
110time_t uptime(void);
111int writepid(int, pid_t);
112
113#endif
Note: See TracBrowser for help on using the repository browser.