From 5dd6a2cb146f04dd2178c2b43b1a421a5a9184e5 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 14:36:51 +0800 Subject: [PATCH 1/5] Add simple header wrapper that provides sockaddr_un. --- src/unixdef.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/unixdef.h diff --git a/src/unixdef.h b/src/unixdef.h new file mode 100644 index 0000000..3bfa67f --- /dev/null +++ b/src/unixdef.h @@ -0,0 +1,26 @@ +#ifndef UNIXDEF_H +#define UNIXDEF_H +/*=========================================================================*\ +* Unix domain defines +* LuaSocket toolkit +* +* Provides sockaddr_un on Windows and Unix. +\*=========================================================================*/ + +#ifdef _WIN32 +/* Technically it's possible to include but it's only available + on Windows SDK 17134 (Windows 10 1803). */ +#ifndef AF_UNIX +#define AF_UNIX 1 +#endif + +struct sockaddr_un +{ + unsigned short sun_family; + char sun_path[108]; +}; +#else +#include +#endif /* _WIN32 */ + +#endif /* UNIXDEF_H */ From fe2c59b53aacfb060d9a6efe9d23ae23cdfcb536 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 14:39:02 +0800 Subject: [PATCH 2/5] Include "unixdef.h" instead of --- src/unixdgram.c | 3 +-- src/unixstream.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/unixdgram.c b/src/unixdgram.c index 69093d7..0fc5dd0 100644 --- a/src/unixdgram.c +++ b/src/unixdgram.c @@ -8,12 +8,11 @@ #include "socket.h" #include "options.h" #include "unix.h" +#include "unixdef.h" #include #include -#include - #define UNIXDGRAM_DATAGRAMSIZE 8192 /* provide a SUN_LEN macro if sys/un.h doesn't (e.g. Android) */ diff --git a/src/unixstream.c b/src/unixstream.c index 02aced9..796d313 100644 --- a/src/unixstream.c +++ b/src/unixstream.c @@ -7,10 +7,10 @@ #include "auxiliar.h" #include "socket.h" #include "options.h" +#include "unixdef.h" #include "unixstream.h" #include -#include /*=========================================================================*\ * Internal function prototypes From 02d062d965464c3ad7802213aba39bdc13f0f32a Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 15:01:08 +0800 Subject: [PATCH 3/5] Update Windows build systems. --- luasocket.sln | 10 +++ src/makefile | 9 ++- unix.vcxproj | 214 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 229 insertions(+), 4 deletions(-) create mode 100644 unix.vcxproj diff --git a/luasocket.sln b/luasocket.sln index 0e5cdc7..1085684 100644 --- a/luasocket.sln +++ b/luasocket.sln @@ -4,6 +4,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "socket", "socket.vcxproj", EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mime", "mime.vcxproj", "{128E8BD0-174A-48F0-8771-92B1E8D18713}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unix", "unix.vcxproj", "{1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -28,6 +30,14 @@ Global {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|Win32.Build.0 = Release|Win32 {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|x64.ActiveCfg = Release|x64 {128E8BD0-174A-48F0-8771-92B1E8D18713}.Release|x64.Build.0 = Release|x64 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Debug|Win32.ActiveCfg = Debug|Win32 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Debug|Win32.Build.0 = Debug|Win32 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Debug|x64.ActiveCfg = Debug|x64 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Debug|x64.Build.0 = Debug|x64 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Release|Win32.ActiveCfg = Release|Win32 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Release|Win32.Build.0 = Release|Win32 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Release|x64.ActiveCfg = Release|x64 + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/makefile b/src/makefile index dbe328f..524d6de 100755 --- a/src/makefile +++ b/src/makefile @@ -324,8 +324,9 @@ UNIX_OBJS=\ auxiliar.$(O) \ options.$(O) \ timeout.$(O) \ + inet.$(O) \ io.$(O) \ - usocket.$(O) \ + $(SOCKET) \ unixstream.$(O) \ unixdgram.$(O) \ compat.$(O) \ @@ -393,7 +394,7 @@ none: @echo "where PLATFORM is one of these:" @echo " $(PLATS)" -all: $(SOCKET_SO) $(MIME_SO) +all: $(SOCKET_SO) $(MIME_SO) $(UNIX_SO) $(SOCKET_SO): $(SOCKET_OBJS) $(LD) $(SOCKET_OBJS) $(LDFLAGS)$@ @@ -401,11 +402,11 @@ $(SOCKET_SO): $(SOCKET_OBJS) $(MIME_SO): $(MIME_OBJS) $(LD) $(MIME_OBJS) $(LDFLAGS)$@ -all-unix: all $(UNIX_SO) $(SERIAL_SO) - $(UNIX_SO): $(UNIX_OBJS) $(LD) $(UNIX_OBJS) $(LDFLAGS)$@ +all-unix: all $(SERIAL_SO) + $(SERIAL_SO): $(SERIAL_OBJS) $(LD) $(SERIAL_OBJS) $(LDFLAGS)$@ diff --git a/unix.vcxproj b/unix.vcxproj new file mode 100644 index 0000000..8e0f6a9 --- /dev/null +++ b/unix.vcxproj @@ -0,0 +1,214 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + {1390FB7F-6D39-4F0A-BBC0-0EAC022D827A} + Win32Proj + + + + DynamicLibrary + v141 + MultiByte + + + DynamicLibrary + v141 + MultiByte + + + DynamicLibrary + v141 + MultiByte + + + DynamicLibrary + v141 + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.50727.1 + + + $(Configuration)\socket\ + $(Configuration)\ + true + unix + + + true + unix + $(Platform)\$(Configuration)\socket\ + + + $(Configuration)\socket\ + $(Configuration)\ + false + unix + + + false + $(Platform)\$(Configuration)\socket\ + unix + + + + Disabled + $(LUAINC);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + EditAndContinue + $(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb + + + $(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + $(LUALIB);%(AdditionalLibraryDirectories) + true + $(OutDir)unix.pdb + Windows + false + + $(OutDir)$(TargetName).lib + MachineX86 + false + + + + + Disabled + $(LUAINC);%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + $(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb + + + $(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + $(LUALIB);%(AdditionalLibraryDirectories) + true + $(OutDir)unix.pdb + Windows + false + + + $(OutDir)$(TargetName).lib + + + + + $(LUAINC);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + Level4 + + $(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb + + + $(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + $(LUALIB);%(AdditionalLibraryDirectories) + true + Windows + true + true + false + + $(OutDir)$(TargetName).lib + MachineX86 + + + + + $(LUAINC);%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LUASOCKET_API=__declspec(dllexport);_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level4 + + + $(IntDir)$(TargetName)$(PlatformToolsetVersion).pdb + + + $(LUALIBNAME);ws2_32.lib;%(AdditionalDependencies) + $(OutDir)$(TargetName).dll + $(LUALIB);%(AdditionalLibraryDirectories) + true + Windows + true + true + false + + + $(OutDir)$(TargetName).lib + + + + + + \ No newline at end of file From 6bd096d90b73e8e317c25dcd806db343d6641488 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Wed, 28 Dec 2022 16:02:12 +0800 Subject: [PATCH 4/5] Update rockspec. --- luasocket-scm-3.rockspec | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/luasocket-scm-3.rockspec b/luasocket-scm-3.rockspec index 475f594..780ea6a 100644 --- a/luasocket-scm-3.rockspec +++ b/luasocket-scm-3.rockspec @@ -56,6 +56,21 @@ local function make_plat(plat) defines = defines[plat], incdir = "/src" }, + ["socket.unix"] = { + sources = { + "src/buffer.c" + , "src/compat.c" + , "src/auxiliar.c" + , "src/options.c" + , "src/timeout.c" + , "src/io.c" + , "src/usocket.c" + , "src/unix.c" + , "src/unixdgram.c" + , "src/unixstream.c" }, + defines = defines[plat], + incdir = "/src" + }, ["mime.core"] = { sources = { "src/mime.c", "src/compat.c" }, defines = defines[plat], @@ -80,21 +95,6 @@ local function make_plat(plat) if plat == "haiku" then modules["socket.core"].libraries = {"network"} end - modules["socket.unix"] = { - sources = { - "src/buffer.c" - , "src/compat.c" - , "src/auxiliar.c" - , "src/options.c" - , "src/timeout.c" - , "src/io.c" - , "src/usocket.c" - , "src/unix.c" - , "src/unixdgram.c" - , "src/unixstream.c" }, - defines = defines[plat], - incdir = "/src" - } modules["socket.serial"] = { sources = { "src/buffer.c" @@ -115,6 +115,10 @@ local function make_plat(plat) modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c" modules["socket.core"].libraries = { "ws2_32" } modules["socket.core"].libdirs = {} + modules["socket.unix"].sources[#modules["socket.unix"].sources+1] = "src/wsocket.c" + modules["socket.unix"].sources[#modules["socket.unix"].sources+1] = "src/inet.c" + modules["socket.unix"].libraries = { "ws2_32" } + modules["socket.unix"].libdirs = {} end return { modules = modules } end From c44d18bfb751ce2c3e841c978b3e3eaccd4702f6 Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Sat, 11 Nov 2023 11:48:37 +0800 Subject: [PATCH 5/5] Rockspec: Add usocket.c using platform ifdefs. --- luasocket-scm-3.rockspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luasocket-scm-3.rockspec b/luasocket-scm-3.rockspec index 780ea6a..462880a 100644 --- a/luasocket-scm-3.rockspec +++ b/luasocket-scm-3.rockspec @@ -64,7 +64,6 @@ local function make_plat(plat) , "src/options.c" , "src/timeout.c" , "src/io.c" - , "src/usocket.c" , "src/unix.c" , "src/unixdgram.c" , "src/unixstream.c" }, @@ -92,6 +91,7 @@ local function make_plat(plat) or plat == "haiku" then modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c" + modules["socket.unix"].sources[#modules["socket.unix"].sources+1] = "src/usocket.c" if plat == "haiku" then modules["socket.core"].libraries = {"network"} end