Skip to content

Commit

Permalink
Merge pull request #277 from has207/master
Browse files Browse the repository at this point in the history
Add Dreamcast (KallistiOS) build support
  • Loading branch information
sahlberg authored Nov 13, 2023
2 parents a9e9b2e + e79bd64 commit a6f30cd
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
19 changes: 19 additions & 0 deletions include/portable-endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@
# define htole64(x) (x)
# define le64toh(x) (x)

#elif defined(DC_KOS_PLATFORM)

# include <machine/endian.h>

# define be16toh(x) __builtin_bswap16(x)
# define htobe16(x) __builtin_bswap16(x)
# define htole16(x) (x)
# define le16toh(x) (x)

# define be32toh(x) __builtin_bswap32(x)
# define htobe32(x) __builtin_bswap32(x)
# define htole32(x) (x)
# define le32toh(x) (x)

# define be64toh(x) __builtin_bswap64(x)
# define htobe64(x) __builtin_bswap64(x)
# define htole64(x) (x)
# define le64toh(x) (x)

#elif defined(__linux__) || defined(__CYGWIN__)

# include <endian.h>
Expand Down
68 changes: 68 additions & 0 deletions lib/Makefile.DC_KOS
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
KOS_CFLAGS = -DDC_KOS_PLATFORM -DNEED_WRITEV -DNEED_READV -DHAVE_STDINT_H -DHAVE_STRING_H \
-DHAVE_SYS_TYPES_H -DHAVE_UNISTD_H -DHAVE_SYS_STAT_H -DHAVE_TIME_H -DHAVE_NETINET_IN_H \
-DHAVE_SYS_SOCKET_H -D HAVE_NETDB_H -DHAVE_POLL_H -DHAVE_STDLIB_H \
-D_U_=/**/ -I../include -I../include/smb2 $(KOS_INC_PATHS)

TARGET = libsmb2.a
OBJS = aes128ccm.o \
aes.o \
alloc.o \
compat.o \
dcerpc.o \
dcerpc-lsa.o \
dcerpc-srvsvc.o \
errors.o \
hmac.o \
hmac-md5.o \
init.o \
krb5-wrapper.o \
libsmb2.o \
md4c.o \
md5.o \
ntlmssp.o \
pdu.o \
sha1.o \
sha224-256.o \
sha384-512.o \
smb2-cmd-close.o \
smb2-cmd-create.o \
smb2-cmd-echo.o \
smb2-cmd-error.o \
smb2-cmd-flush.o \
smb2-cmd-ioctl.o \
smb2-cmd-logoff.o \
smb2-cmd-negotiate.o \
smb2-cmd-query-directory.o \
smb2-cmd-query-info.o \
smb2-cmd-read.o \
smb2-cmd-session-setup.o \
smb2-cmd-set-info.o \
smb2-cmd-tree-connect.o \
smb2-cmd-tree-disconnect.o \
smb2-cmd-write.o \
smb2-data-file-info.o \
smb2-data-filesystem-info.o \
smb2-data-security-descriptor.o \
smb2-data-reparse-point.o \
smb2-share-enum.o \
smb3-seal.o \
smb2-signing.o \
timestamps.o \
unicode.o \
usha.o \
socket.o \
sync.o

install: defaultall
ifeq ($(KOS_BASE),)
@echo "$KOS_BASE is not set. Can not install libsmb2."
@exit 1
endif
@echo Copying...
@[ -d $(KOS_BASE)/addons/include/smb2 ] || mkdir -p $(KOS_BASE)/addons/include/smb2
@cp -frv ../include/smb2/*.h $(KOS_BASE)/addons/include/smb2
@chmod 0644 $(TARGET)
@cp -frv $(TARGET) $(KOS_BASE)/addons/lib/dreamcast
@echo Done!

include ${KOS_PORTS}/scripts/lib.mk
18 changes: 18 additions & 0 deletions lib/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ long long int be64toh(long long int x);

#endif /* PS2_EE_PLATFORM */

#ifdef DC_KOS_PLATFORM

#include <netdb.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <sys/errno.h>
#include <unistd.h>

#define getlogin_r(a,b) ENXIO

#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
#define SOL_TCP IPPROTO_TCP

ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
ssize_t readv(int fd, const struct iovec *iov, int iovcnt);

#endif /* DC_KOS_PLATFORM */

#ifdef PS2_IOP_PLATFORM

Expand Down
3 changes: 2 additions & 1 deletion lib/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static int wait_for_reply(struct smb2_context *smb2,
time_t t = time(NULL);

while (!cb_data->is_finished) {
struct pollfd pfd;
struct pollfd pfd;
memset(&pfd, 0, sizeof(struct pollfd));

pfd.fd = smb2_get_fd(smb2);
pfd.events = smb2_which_events(smb2);
Expand Down

0 comments on commit a6f30cd

Please sign in to comment.