Index: trunk/libc/Config.kmk
===================================================================
--- trunk/libc/Config.kmk	(revision 3863)
+++ trunk/libc/Config.kmk	(revision 3864)
@@ -31,4 +31,8 @@
 # Undo the packing pass the toplevel config insists on.
 DEFAULT_PASSES := $(filter-out PACKING,$(DEFAULT_PASSES))
+
+# For finding the klibc_alias unit.
+KBUILD_UNIT_PATHS := $(KBUILD_UNIT_PATHS) $(PATH_ROOT)/libc
+
 
 #
@@ -74,4 +78,6 @@
 ifdef LIBC_GENALIAS_FORMAT.$(BUILD_TARGET)
  LIBC_GENALIAS_FORMAT := $(LIBC_GENALIAS_FORMAT.$(BUILD_TARGET))
+else ifdef CFG_LIBC_USE_WATCOM
+ LIBC_GENALIAS_FORMAT := omf
 else
  LIBC_GENALIAS_FORMAT := aout
@@ -95,4 +101,5 @@
  TEMPLATE_libc_ASTOOL  = $(TEMPLATE_libcasm_ASTOOL)
  TEMPLATE_libc_ASFLAGS = $(TEMPLATE_libcasm_ASFLAGS)
+ KLIBC_SUFF_AS = .asm
 else
  TEMPLATE_libc_TOOL = GCC3
@@ -100,4 +107,5 @@
  TEMPLATE_libc_CFLAGS.os2 = $(TEMPLATE_lib_CFLAGS.os2) -mstack-arg-probe
  TEMPLATE_libc_CFLAGS.release = $(TEMPLATE_lib_CFLAGS.release) -O3 -mcpu=pentium
+ KLIBC_SUFF_AS = .s
 endif
 
Index: trunk/libc/alias.kmk
===================================================================
--- trunk/libc/alias.kmk	(revision 3863)
+++ trunk/libc/alias.kmk	(revision 3864)
@@ -38,5 +38,5 @@
 #
 # The generated source and object files.
-# The installation is done manually by Makefile.kmk. Yea, it's a hack sorts...
+# The installation is done manually by Makefile.kmk. Yea, it's a hack of sorts...
 #
 libc_alias_TOOL = GCC3
Index: trunk/libc/include/klibc/asmdefs.mac
===================================================================
--- trunk/libc/include/klibc/asmdefs.mac	(revision 3864)
+++ trunk/libc/include/klibc/asmdefs.mac	(revision 3864)
@@ -0,0 +1,14 @@
+; $Id$
+;; @file
+; NASM assembly definitions for kLibC.
+;
+; @copyright   Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
+; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
+;
+
+%ifdef __OS2__
+ %include "klibc/os2/asmdefs.mac"
+%else
+ %include "klibc/nt/asmdefs.mac"
+%endif
+
Index: trunk/libc/include/klibc/os2/asmdefs.mac
===================================================================
--- trunk/libc/include/klibc/os2/asmdefs.mac	(revision 3863)
+++ trunk/libc/include/klibc/os2/asmdefs.mac	(revision 3864)
@@ -1,5 +1,5 @@
 ; $Id$
 ;; @file
-; NASM assembly definitions for kLibC.
+; NASM assembly definitions for kLibC, OS/2 variant.
 ;
 ; @copyright   Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
Index: trunk/libc/klibc_alias.kmk
===================================================================
--- trunk/libc/klibc_alias.kmk	(revision 3864)
+++ trunk/libc/klibc_alias.kmk	(revision 3864)
@@ -0,0 +1,60 @@
+# $Id$
+## @file
+# kLibC Alias Unit for kBuild.
+#
+# @copyright   Copyright (C) 2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
+# @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
+#
+
+ifdef UNIT_klibc_alias
+ $(error kBuild: The kLibC alias unit was included twice!)
+endif
+UNIT_klibc_alias = klibc_alias
+
+
+# Add our target properties
+PROPS_ACCUMULATE_R += KLIBC_ALIASES
+
+## Double expansion worker.
+define def_unit_klibc_alias_target_pre_worker
+
+$(target)_2_KLIBC_ALIASES_FILES := $(foreach pair, \
+	$(libc_libsocket_KLIBC_ALIASES.$(bld_trg)) \
+	$(libc_libsocket_KLIBC_ALIASES.$(bld_trg_arch)) \
+	$(libc_libsocket_KLIBC_ALIASES.$(bld_trg).$(bld_trg_arch)) \
+	$(libc_libsocket_KLIBC_ALIASES.$(bld_trg_cpu)) \
+	$(libc_libsocket_KLIBC_ALIASES.$(bld_type)) \
+	$(libc_libsocket_KLIBC_ALIASES) \
+,$($(target)_0_OUTDIR)/aliases/$(firstword $(subst =, ,$(pair))).o)
+
+$(target)_CLEAN   += $$($(target)_2_KLIBC_ALIASES_FILES)
+$(target)_2_OBJS  += $$($(target)_2_KLIBC_ALIASES_FILES)
+$(target)_BLDDIRS += $$($(target)_0_OUTDIR)/aliases/
+
+$$($(target)_0_OUTDIR)/aliases/aliases.rsp \
++ $$($(target)_2_KLIBC_ALIASES_FILES): \
+		$(LIBC_GENALIAS) $(MAKEFILE_CURRENT) | $($(target)_0_OUTDIR)/aliases/
+	$(RM) -f -- $($(target)_2_KLIBC_ALIASES_FILES) $($(target)_0_OUTDIR)/aliases/aliases.rsp
+	$(APPEND) -tn "$($(target)_0_OUTDIR)/aliases/aliases.rsp" \
+		$(libc_libsocket_KLIBC_ALIASES.$(bld_trg)) \
+		$(libc_libsocket_KLIBC_ALIASES.$(bld_trg_arch)) \
+		$(libc_libsocket_KLIBC_ALIASES.$(bld_trg).$(bld_trg_arch)) \
+		$(libc_libsocket_KLIBC_ALIASES.$(bld_trg_cpu)) \
+		$(libc_libsocket_KLIBC_ALIASES.$(bld_type)) \
+		$(libc_libsocket_KLIBC_ALIASES)
+	$(LIBC_GENALIAS) -f $(LIBC_GENALIAS_FORMAT) \
+		-D "$($(target)_0_OUTDIR)/aliases" \
+		-r "$($(target)_0_OUTDIR)/aliases/aliases.rsp"
+
+endef # def_unit_klibc_alias_target_pre_worker
+
+
+##
+# Invoked early in the processing of a target that uses the unit.
+#
+define def_unit_klibc_alias_target_pre
+
+$(eval $(def_unit_klibc_alias_target_pre_worker))
+
+endef
+
Index: trunk/libc/src/libsocket/386/swapl.asm
===================================================================
--- trunk/libc/src/libsocket/386/swapl.asm	(revision 3864)
+++ trunk/libc/src/libsocket/386/swapl.asm	(revision 3864)
@@ -0,0 +1,23 @@
+; $Id$
+;; @file
+; 32-bit byte swap.
+;
+; @copyright   Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
+; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
+;
+
+%include "klibc/asmdefs.mac"
+
+BEGIN_CODE32
+global __swapl
+__swapl:
+        mov     eax, [esp + 4]
+%ifdef __OS2__
+        xchg    al, ah
+        rol     eax, 16
+        xchg    al, ah
+%else
+        bswap   eax
+%endif
+        ret
+
Index: trunk/libc/src/libsocket/386/swaps.asm
===================================================================
--- trunk/libc/src/libsocket/386/swaps.asm	(revision 3864)
+++ trunk/libc/src/libsocket/386/swaps.asm	(revision 3864)
@@ -0,0 +1,18 @@
+; $Id$
+;; @file
+; 16-bit byte swap.
+;
+; @copyright   Copyright (C) 2004-2014 knut st. osmundsen <bird-klibc-spam-xiv@anduin.net>
+; @licenses    MIT, BSD2, BSD3, BSD4, LGPLv2.1, LGPLv3.
+;
+
+
+%include "klibc/asmdefs.mac"
+
+BEGIN_CODE32
+global __swaps
+__swaps:
+        movzx   eax, word [esp + 4]
+        xchg    al, ah
+        ret
+
Index: trunk/libc/src/libsocket/Makefile.kmk
===================================================================
--- trunk/libc/src/libsocket/Makefile.kmk	(revision 3863)
+++ trunk/libc/src/libsocket/Makefile.kmk	(revision 3864)
@@ -70,38 +70,40 @@
 
 libc_libsocket_SOURCES.x86 = \
-	$(PATH_LIBC_SRC)/libsocket/386/swapl.s \
-	$(PATH_LIBC_SRC)/libsocket/386/swaps.s \
+	$(PATH_LIBC_SRC)/libsocket/386/swapl$(KLIBC_SUFF_AS) \
+	$(PATH_LIBC_SRC)/libsocket/386/swaps$(KLIBC_SUFF_AS) \
 
-libc_libsocket_SOURCES.os2 = \
-	$(PATH_LIBC_SRC)/libsocket/aliases/accept-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/bind-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/bsdselect-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/connect-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/getpeername-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/getsockname-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/getsockopt-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/inetaddr-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/inetnetw-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/listen-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/os2_ioctl-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/os2_select-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/recv-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/recvfrom-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/recvmsg-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/send-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/sendmsg-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/sendto-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/setsockopt-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/shutdown-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/soabort-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/socket-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/socketops-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/socketpair-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/sock_errno-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/soclose-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/so_cancel-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/so_ioctl-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/so_readv-alias.s \
-	$(PATH_LIBC_SRC)/libsocket/aliases/so_writev-alias.s \
+libc_libsocket_USES += klibc_alias
+libc_libsocket_KLIBC_ALIASES.os2 = \
+	accept=_accept \
+	bind=_bind \
+	_bsdselect=bsdselect \
+	connect=_connect \
+	getpeername=_getpeername \
+	getsockname=_getsockname \
+	getsockopt=_getsockopt \
+	herror=_herror \
+	inetaddr=_inetaddr \
+	inetnetw=_inetnetw \
+	listen=_listen \
+	os2_ioctl=_os2_ioctl \
+	_os2_select=os2_select \
+	recv=_recv \
+	recvfrom=_recvfrom \
+	recvmsg=_recvmsg \
+	send=_send \
+	sendmsg=_sendmsg \
+	sendto=_sendto \
+	setsockopt=_setsockopt \
+	shutdown=_shutdown \
+	soabort=_soabort \
+	socket=_socket \
+	socketops=_socketops \
+	socketpair=_socketpair \
+	sock_errno=_sock_errno \
+	soclose=_soclose \
+	so_cancel=_so_cancel \
+	so_ioctl=_so_ioctl \
+	so_readv=_so_readv \
+	so_writev=_so_writev
 
 # configure the variants. */
@@ -123,6 +125,11 @@
 
 libc_libsocketv4_SOURCES.os2 = \
-	$(libc_libsocket_SOURCES.os2) \
-	$(PATH_LIBC_SRC)/libsocket/aliases/herror-alias.s \
+	$(libc_libsocket_SOURCES.os2)
+
+libc_libsocketv4_USES += klibc_alias
+libc_libsocketv4_KLIBC_ALIASES.os2 = \
+	$(libc_libsocket_KLIBC_ALIASES.os2) \
+       herror=_herror
+
 
 # configure the variants. */
