libs/l_net: support both BSD and Win sockets

This commit is contained in:
Marco Cawthorne 2021-06-06 19:55:18 +02:00
parent 16811dcf6c
commit 7416a87f05
3 changed files with 6 additions and 1 deletions

View file

@ -7,7 +7,7 @@ DO_CC=$(CC) -static -fPIC $(LIB_CFLAGS) -o $@ -c $<
$(DO_CC) $(DO_CC)
WS_OBJS = \ WS_OBJS = \
l_net.o l_net_berkley.o l_net.o l_net_berkley.o l_net_wins.o
# binary target # binary target
../libl_net.a: $(WS_OBJS) ../libl_net.a: $(WS_OBJS)
@ -16,6 +16,7 @@ WS_OBJS = \
# object files # object files
l_net.o: l_net.c l_net.h l_net.o: l_net.c l_net.h
l_net_berkley.o: l_net_berkley.c l_net_berkley.o: l_net_berkley.c
l_net_wins.o: l_net_wins.c
clean: clean:
-rm -f *.o ../libl_net.a -rm -f *.o ../libl_net.a

View file

@ -29,6 +29,7 @@
// Notes: // Notes:
//=========================================================================== //===========================================================================
#if defined(POSIX) || defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
//#include <windows.h> //#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -746,3 +747,4 @@ int WINS_SetSocketPort( struct sockaddr_s *addr, int port ){
( (struct sockaddr_in *)addr )->sin_port = htons( (u_short)port ); ( (struct sockaddr_in *)addr )->sin_port = htons( (u_short)port );
return 0; return 0;
} //end of the function WINS_SetSocketPort } //end of the function WINS_SetSocketPort
#endif

View file

@ -29,6 +29,7 @@
// Notes: // Notes:
//=========================================================================== //===========================================================================
#if defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(__CYGWIN__)
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -759,3 +760,4 @@ int WINS_SetSocketPort( struct sockaddr_s *addr, int port ){
( (struct sockaddr_in *)addr )->sin_port = htons( (u_short)port ); ( (struct sockaddr_in *)addr )->sin_port = htons( (u_short)port );
return 0; return 0;
} //end of the function WINS_SetSocketPort } //end of the function WINS_SetSocketPort
#endif