From 9d6f5fc99aea8a8961413d65d05de1472fb9cd0d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 11 May 2014 15:51:41 +0800 Subject: [PATCH] Nativelib - Fix clang compilation issues --- KernelLand/Kernel/drv/proc.c | 16 +++++++--------- KernelLand/Kernel/events.c | 2 +- KernelLand/Modules/IPStack/icmpv6.h | 14 +++++++------- KernelLand/Modules/IPStack/ipv6.h | 2 +- Makefile | 3 +-- Tools/NetTest_Runner/net.c | 6 ++++-- Tools/nativelib/include/threads_int.h | 10 +++++----- 7 files changed, 26 insertions(+), 27 deletions(-) diff --git a/KernelLand/Kernel/drv/proc.c b/KernelLand/Kernel/drv/proc.c index 03288aea..60bf4dd8 100644 --- a/KernelLand/Kernel/drv/proc.c +++ b/KernelLand/Kernel/drv/proc.c @@ -50,9 +50,8 @@ tVFS_NodeType gSysFS_DirNodeType = { .FindDir = SysFS_Comm_FindDir }; tSysFS_Ent gSysFS_Version_Kernel = { - NULL, NULL, // Nexts - &gSysFS_Version, // Parent - { + .Parent = &gSysFS_Version, // Parent + .Node = { .Inode = 1, // File #1 .ImplPtr = NULL, .ImplInt = (Uint)&gSysFS_Version_Kernel, // Self-Link @@ -61,12 +60,11 @@ tSysFS_Ent gSysFS_Version_Kernel = { .ACLs = &gVFS_ACL_EveryoneRO, .Type = &gSysFS_FileNodeType }, - "Kernel" + .Name = {"Kernel"} }; tSysFS_Ent gSysFS_Version = { - NULL, NULL, - &gSysFS_Root, - { + .Parent = &gSysFS_Root, + .Node = { .Size = 1, .ImplPtr = &gSysFS_Version_Kernel, .ImplInt = (Uint)&gSysFS_Version, // Self-Link @@ -75,7 +73,7 @@ tSysFS_Ent gSysFS_Version = { .Flags = VFS_FFLAG_DIRECTORY, .Type = &gSysFS_DirNodeType }, - "Version" + .Name = {"Version"} }; // Root of the SysFS tree (just used to keep the code clean) tSysFS_Ent gSysFS_Root = { @@ -86,7 +84,7 @@ tSysFS_Ent gSysFS_Root = { .ImplPtr = &gSysFS_Version, .ImplInt = (Uint)&gSysFS_Root // Self-Link }, - "/" + {"/"} }; tDevFS_Driver gSysFS_DriverInfo = { NULL, "system", diff --git a/KernelLand/Kernel/events.c b/KernelLand/Kernel/events.c index b0225efe..ec47a169 100644 --- a/KernelLand/Kernel/events.c +++ b/KernelLand/Kernel/events.c @@ -7,8 +7,8 @@ */ #define DEBUG 0 #include -#include #include +#include // === CODE === void Threads_PostEvent(tThread *Thread, Uint32 EventMask) diff --git a/KernelLand/Modules/IPStack/icmpv6.h b/KernelLand/Modules/IPStack/icmpv6.h index bda70b13..66f61341 100644 --- a/KernelLand/Modules/IPStack/icmpv6.h +++ b/KernelLand/Modules/IPStack/icmpv6.h @@ -26,32 +26,32 @@ typedef struct { Uint16 RouterLifetime; // Seconds, life time as a default router (wtf does that mean?) Uint32 ReachableTime; Uint32 RetransTimer; // Miliseconds, time between transmissions of RAs from this router - Uint8 Options[]; + Uint8 Options[0]; } PACKED tICMPv6_RA; typedef struct { Uint32 Reserved; tIPv6 TargetAddress; - Uint8 Options[]; + Uint8 Options[0]; } PACKED tICMPv6_NS; typedef struct { Uint32 Flags; tIPv6 TargetAddress; - Uint8 Options[]; + Uint8 Options[0]; } PACKED tICMPv6_NA; typedef struct { Uint32 Reserved; tIPv6 TargetAddress; tIPv6 DestinationAddress; - Uint8 Options[]; + Uint8 Options[0]; } PACKED tICMPv6_Redirect; typedef struct { Uint8 Type; // 1,2 Uint8 Length; // Length of field in units of 8 bytes (incl header), typically 1 - Uint8 Address[]; + Uint8 Address[0]; } PACKED tICMPv6_Opt_LinkAddr; typedef struct { @@ -62,7 +62,7 @@ typedef struct { Uint32 ValidLifetime; Uint32 PreferredLifetime; Uint32 _reserved2; - tIPv6 Prefix[]; + tIPv6 Prefix[0]; } PACKED tICMPv6_Opt_Prefix; typedef struct { @@ -70,7 +70,7 @@ typedef struct { Uint8 Length; Uint16 _rsvd1; Uint32 _rsvd2; - Uint8 Data[]; // All or part of the redirected message (not exceeding MTU) + Uint8 Data[0]; // All or part of the redirected message (not exceeding MTU) } PACKED tICMPv6_Opt_Redirect; typedef struct { diff --git a/KernelLand/Modules/IPStack/ipv6.h b/KernelLand/Modules/IPStack/ipv6.h index 35cd7422..fec00f75 100644 --- a/KernelLand/Modules/IPStack/ipv6.h +++ b/KernelLand/Modules/IPStack/ipv6.h @@ -32,7 +32,7 @@ struct sIPv6Header Uint8 HopLimit; tIPv6 Source; tIPv6 Destination; - char Data[]; + char Data[0]; }; #define IPV6_ETHERNET_ID 0x86DD diff --git a/Makefile b/Makefile index d78686be..c3c26c16 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,7 @@ .PHONY: all clean SyscallList all-user -SUBMAKE = $(MAKE) -# --no-print-directory +SUBMAKE = $(MAKE) --no-print-directory USRLIBS := crt0.o acess.ld ld-acess.so libc.so libc++.so libposix.so USRLIBS += libreadline.so libnet.so liburi.so libpsocket.so diff --git a/Tools/NetTest_Runner/net.c b/Tools/NetTest_Runner/net.c index 231df502..4cbf3c8d 100644 --- a/Tools/NetTest_Runner/net.c +++ b/Tools/NetTest_Runner/net.c @@ -9,6 +9,8 @@ #include #include "net.h" #include +#include // unlink/... +#include // gettimeofday #define CONNECT_TIMEOUT 10*1000 #define MAX_IFS 4 @@ -145,7 +147,7 @@ size_t Net_Receive(int IfNum, size_t MaxLen, void *DestBuf, unsigned int Timeout if( Net_int_EnsureConnected(IfNum) && WaitOnFD(If->FD, false, Timeout) ) { - size_t rv = recvfrom(If->FD, DestBuf, MaxLen, 0, &If->addr, &If->addrlen); + size_t rv = recvfrom(If->FD, DestBuf, MaxLen, 0, (struct sockaddr*)&If->addr, &If->addrlen); Net_int_SavePacket(If, rv, DestBuf); return rv; } @@ -160,7 +162,7 @@ void Net_Send(int IfNum, size_t Length, const void *Buf) if( !WaitOnFD(If->FD, true, CONNECT_TIMEOUT) ) return ; Net_int_SavePacket(If, Length, Buf); - int rv = sendto(If->FD, Buf, Length, 0, &If->addr, If->addrlen); + int rv = sendto(If->FD, Buf, Length, 0, (struct sockaddr*)&If->addr, If->addrlen); if( rv < 0 ) perror("Net_Send - send"); } diff --git a/Tools/nativelib/include/threads_int.h b/Tools/nativelib/include/threads_int.h index 7bd91c17..08bb4f78 100644 --- a/Tools/nativelib/include/threads_int.h +++ b/Tools/nativelib/include/threads_int.h @@ -103,12 +103,12 @@ extern int Threads_int_CreateThread(struct sThread *Thread); extern int Threads_int_ThreadingEnabled(void); -extern tThread *Proc_GetCurThread(void); -extern tThread *Threads_RemActive(void); -extern void Threads_AddActive(tThread *Thread); +extern struct sThread *Proc_GetCurThread(void); +extern struct sThread *Threads_RemActive(void); +extern void Threads_AddActive(struct sThread *Thread); extern void Threads_int_WaitForStatusEnd(enum eThreadStatus Status); -extern int Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, tThread **ListHead, tThread **ListTail, tShortSpinlock *Lock); -extern void Semaphore_ForceWake(tThread *Thread); +extern int Threads_int_Sleep(enum eThreadStatus Status, void *Ptr, int Num, struct sThread **ListHead, struct sThread **ListTail, tShortSpinlock *Lock); +extern void Semaphore_ForceWake(struct sThread *Thread); extern tThreadIntMutex *Threads_int_MutexCreate(void); extern void Threads_int_MutexDestroy(tThreadIntMutex *Mutex); -- 2.20.1