mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 02:32:44 +03:00
move sys/time.h support functionality out of generic header
The utils header is a large collection of functionality for several system headers and API. This splits out the ones from sys/time.h into a separate header reducing the need for many unconnected source files to include the system header unecessarily.
This commit is contained in:
parent
46e1061ef3
commit
836ea5679e
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/errors.h"
|
#include "utils/errors.h"
|
||||||
|
|
||||||
#include "atari/schedule.h"
|
#include "atari/schedule.h"
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
|
|
||||||
#include "framebuffer/schedule.h"
|
#include "framebuffer/schedule.h"
|
||||||
|
@ -20,11 +20,11 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/filepath.h"
|
#include "utils/filepath.h"
|
||||||
|
@ -16,10 +16,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
|
|
||||||
#include "monkey/schedule.h"
|
#include "monkey/schedule.h"
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#include <libwapcaplet/libwapcaplet.h>
|
#include <libwapcaplet/libwapcaplet.h>
|
||||||
@ -46,6 +45,7 @@
|
|||||||
#include "oslib/wimp.h"
|
#include "oslib/wimp.h"
|
||||||
#include "oslib/wimpspriteop.h"
|
#include "oslib/wimpspriteop.h"
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/nsoption.h"
|
#include "utils/nsoption.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
|
@ -22,9 +22,9 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/utsname.h"
|
#include "utils/utsname.h"
|
||||||
#include "desktop/version.h"
|
#include "desktop/version.h"
|
||||||
|
|
||||||
|
53
utils/sys_time.h
Normal file
53
utils/sys_time.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 Vincent Sanders <vince@netsurf-browser.org>
|
||||||
|
*
|
||||||
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||||
|
*
|
||||||
|
* NetSurf is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; version 2 of the License.
|
||||||
|
*
|
||||||
|
* NetSurf is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* \brief BSD style time functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _NETSURF_UTILS_SYS_TIME_H_
|
||||||
|
#define _NETSURF_UTILS_SYS_TIME_H_
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifndef timeradd
|
||||||
|
#define timeradd(a, aa, result) \
|
||||||
|
do { \
|
||||||
|
(result)->tv_sec = (a)->tv_sec + (aa)->tv_sec; \
|
||||||
|
(result)->tv_usec = (a)->tv_usec + (aa)->tv_usec; \
|
||||||
|
if ((result)->tv_usec >= 1000000) { \
|
||||||
|
++(result)->tv_sec; \
|
||||||
|
(result)->tv_usec -= 1000000; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef timersub
|
||||||
|
#define timersub(a, aa, result) \
|
||||||
|
do { \
|
||||||
|
(result)->tv_sec = (a)->tv_sec - (aa)->tv_sec; \
|
||||||
|
(result)->tv_usec = (a)->tv_usec - (aa)->tv_usec; \
|
||||||
|
if ((result)->tv_usec < 0) { \
|
||||||
|
--(result)->tv_sec; \
|
||||||
|
(result)->tv_usec += 1000000; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -28,7 +28,6 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@ -119,32 +118,6 @@ struct dirent;
|
|||||||
#define SLEN(x) (sizeof((x)) - 1)
|
#define SLEN(x) (sizeof((x)) - 1)
|
||||||
|
|
||||||
|
|
||||||
#ifndef timeradd
|
|
||||||
#define timeradd(a, aa, result) \
|
|
||||||
do { \
|
|
||||||
(result)->tv_sec = (a)->tv_sec + (aa)->tv_sec; \
|
|
||||||
(result)->tv_usec = (a)->tv_usec + (aa)->tv_usec; \
|
|
||||||
if ((result)->tv_usec >= 1000000) { \
|
|
||||||
++(result)->tv_sec; \
|
|
||||||
(result)->tv_usec -= 1000000; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef timersub
|
|
||||||
#define timersub(a, aa, result) \
|
|
||||||
do { \
|
|
||||||
(result)->tv_sec = (a)->tv_sec - (aa)->tv_sec; \
|
|
||||||
(result)->tv_usec = (a)->tv_usec - (aa)->tv_usec; \
|
|
||||||
if ((result)->tv_usec < 0) { \
|
|
||||||
--(result)->tv_sec; \
|
|
||||||
(result)->tv_usec += 1000000; \
|
|
||||||
} \
|
|
||||||
} while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace consecutive whitespace with a single space.
|
* Replace consecutive whitespace with a single space.
|
||||||
*
|
*
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/time.h>
|
|
||||||
|
|
||||||
#include "utils/config.h"
|
#include "utils/config.h"
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/messages.h"
|
#include "utils/messages.h"
|
||||||
#include "utils/url.h"
|
#include "utils/url.h"
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "utils/sys_time.h"
|
||||||
#include "utils/log.h"
|
#include "utils/log.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "utils/errors.h"
|
#include "utils/errors.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user