LibC: Move struct timeval to sys/time.h. #POSIX

This commit is contained in:
Andreas Kling 2019-05-28 13:48:06 +02:00
parent 16ea34fc12
commit cbd858544d
Notes: sideshowbarker 2024-07-19 13:52:23 +09:00
10 changed files with 42 additions and 34 deletions

View file

@ -2,7 +2,8 @@
namespace AK { namespace AK {
inline void timeval_sub(const struct timeval* a, const struct timeval* b, struct timeval* result) template<typename TimevalType>
inline void timeval_sub(const TimevalType* a, const TimevalType* b, TimevalType* result)
{ {
result->tv_sec = a->tv_sec - b->tv_sec; result->tv_sec = a->tv_sec - b->tv_sec;
result->tv_usec = a->tv_usec - b->tv_usec; result->tv_usec = a->tv_usec - b->tv_usec;
@ -12,7 +13,8 @@ inline void timeval_sub(const struct timeval* a, const struct timeval* b, struct
} }
} }
inline void timeval_add(const struct timeval* a, const struct timeval* b, struct timeval* result) template<typename TimevalType>
inline void timeval_add(const TimevalType* a, const TimevalType* b, TimevalType* result)
{ {
result->tv_sec = a->tv_sec + b->tv_sec; result->tv_sec = a->tv_sec + b->tv_sec;
result->tv_usec = a->tv_usec + b->tv_usec; result->tv_usec = a->tv_usec + b->tv_usec;

View file

@ -1,9 +1,15 @@
#pragma once #pragma once
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS __BEGIN_DECLS
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
struct timezone { struct timezone {
int tz_minuteswest; int tz_minuteswest;
int tz_dsttime; int tz_dsttime;

View file

@ -37,11 +37,6 @@ typedef uint32_t clock_t;
#define __socklen_t uint32_t #define __socklen_t uint32_t
typedef __socklen_t socklen_t; typedef __socklen_t socklen_t;
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
struct stat { struct stat {
dev_t st_dev; /* ID of device containing file */ dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */ ino_t st_ino; /* inode number */

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include <time.h> #include <sys/time.h>
class CElapsedTimer { class CElapsedTimer {
public: public:

View file

@ -1,12 +1,13 @@
#pragma once #pragma once
#include <LibCore/CLock.h>
#include <AK/Badge.h> #include <AK/Badge.h>
#include <AK/HashMap.h> #include <AK/HashMap.h>
#include <AK/OwnPtr.h> #include <AK/OwnPtr.h>
#include <AK/Vector.h> #include <AK/Vector.h>
#include <AK/WeakPtr.h> #include <AK/WeakPtr.h>
#include <LibCore/CLock.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/time.h>
#include <time.h> #include <time.h>
class CEvent; class CEvent;

View file

@ -1,7 +1,8 @@
#include <LibCore/CIODevice.h> #include <LibCore/CIODevice.h>
#include <unistd.h>
#include <sys/select.h>
#include <stdio.h> #include <stdio.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
#include <AK/printf.cpp> #include <AK/printf.cpp>
CIODevice::CIODevice(CObject* parent) CIODevice::CIODevice(CObject* parent)

View file

@ -35,6 +35,7 @@ function run_fetch_git() {
if [ -d "$PORT_DIR/.git" ]; then if [ -d "$PORT_DIR/.git" ]; then
run_command git fetch run_command git fetch
run_command git reset --hard FETCH_HEAD run_command git reset --hard FETCH_HEAD
run_command git clean -fx
else else
run_command_nocd git clone "$1" "$PORT_DIR" run_command_nocd git clone "$1" "$PORT_DIR"
fi fi

View file

@ -1,19 +1,19 @@
#include "DNSPacket.h"
#include "DNSRecord.h"
#include <AK/AKString.h>
#include <AK/BufferStream.h>
#include <AK/ByteBuffer.h>
#include <AK/HashMap.h>
#include <Kernel/Net/IPv4.h>
#include <LibCore/CConfigFile.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <sys/time.h>
#include <netinet/in.h>
#include <unistd.h> #include <unistd.h>
#include <unistd.h>
#include <Kernel/Net/IPv4.h>
#include <AK/AKString.h>
#include <AK/HashMap.h>
#include <AK/ByteBuffer.h>
#include <AK/BufferStream.h>
#include "DNSPacket.h"
#include "DNSRecord.h"
#include <LibCore/CConfigFile.h>
#define T_A 1 #define T_A 1
#define T_NS 2 #define T_NS 2

View file

@ -1,11 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

View file

@ -1,11 +1,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char** argv) int main(int argc, char** argv)
{ {