Skip to content

Commit

Permalink
Some small console compilation fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Konrad committed Jun 25, 2015
1 parent 4e0cc95 commit 8c0f66e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 107 deletions.
6 changes: 0 additions & 6 deletions .gitignore

This file was deleted.

7 changes: 5 additions & 2 deletions Sources/Kore/Audio/stb_vorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,22 @@
#ifndef STB_VORBIS_NO_STDIO
#include <stdio.h>
#endif

#ifndef STB_VORBIS_NO_CRT
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh))
#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) || defined(SYS_CONSOLE))
#include <malloc.h>
#endif
#else
#define NULL 0
#endif

#ifdef SYS_CONSOLE
#include <alloca.h>
#endif

#ifndef _MSC_VER
#if __GNUC__
#define __forceinline inline
Expand Down
2 changes: 2 additions & 0 deletions Sources/Kore/Graphics/stb_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@
#include <stdio.h>
#endif
#include <stdlib.h>
#ifndef SYS_CONSOLE
#include <memory.h>
#endif
#include <assert.h>
#include <stdarg.h>

Expand Down
14 changes: 11 additions & 3 deletions Sources/Kore/Network/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP)
#include <winsock2.h>
#else
#elif defined(SYS_UNIXOID)
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
Expand Down Expand Up @@ -37,6 +37,7 @@ Socket::Socket() : handle(0) {
}

void Socket::open(int port) {
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP) || defined(SYS_UNIXOID)
handle = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (handle <= 0) {
log(Kore::Error, "Could not create socket.");
Expand All @@ -51,14 +52,15 @@ void Socket::open(int port) {
log(Kore::Error, "Could not bind socket.");
return;
}
#endif

#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP)
DWORD nonBlocking = 1;
if (ioctlsocket(handle, FIONBIO, &nonBlocking) != 0) {
log(Kore::Error, "Could not set non-blocking mode.");
return;
}
#else
#elif defined(SYS_UNIXOID)
int nonBlocking = 1;
if (fcntl(handle, F_SETFL, O_NONBLOCK, nonBlocking ) == -1) {
log(Kore::Error, "Could not set non-blocking mode.");
Expand All @@ -70,12 +72,13 @@ void Socket::open(int port) {
Socket::~Socket() {
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP)
closesocket(handle);
#else
#elif defined(SYS_UNIXOID)
close(handle);
#endif
}

void Socket::send(unsigned addr1, unsigned addr2, unsigned addr3, unsigned addr4, unsigned short port, const unsigned char* data, int size) {
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP) || defined(SYS_UNIXOID)
unsigned int address = (addr1 << 24) | (addr2 << 16) | (addr3 << 8) | addr4;
sockaddr_in addr;
addr.sin_family = AF_INET;
Expand All @@ -87,17 +90,22 @@ void Socket::send(unsigned addr1, unsigned addr2, unsigned addr3, unsigned addr4
log(Kore::Error, "Could not send packet.");
return;
}
#endif
}

int Socket::receive(unsigned char* data, int maxSize, unsigned& fromAddress, unsigned& fromPort) {
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP)
typedef int socklen_t;
#endif
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP) || defined(SYS_UNIXOID)
sockaddr_in from;
socklen_t fromLength = sizeof(from);
int bytes = recvfrom(handle, (char*)data, maxSize, 0, (sockaddr*)&from, &fromLength);
if (bytes <= 0) return bytes;
fromAddress = ntohl(from.sin_addr.s_addr);
fromPort = ntohs(from.sin_port);
return bytes;
#else
return 0;
#endif
}
6 changes: 2 additions & 4 deletions Sources/Kore/Threads/Mutex.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if !defined(SYS_WINDOWS) && !defined(SYS_WINDOWSAPP)
#if !defined(SYS_WINDOWS) && !defined(SYS_WINDOWSAPP) && defined(SYS_UNIXOID)
#include <pthread.h>
#endif

Expand All @@ -21,7 +21,7 @@ namespace Kore {
void* LockSemaphore;
unsigned long __w64 SpinCount;
} criticalSection;
#else
#elif defined(SYS_UNIXOID)
pthread_mutex_t pthread_mutex;
#endif
};
Expand All @@ -30,8 +30,6 @@ namespace Kore {
public:
#if defined(SYS_WINDOWS) || defined(SYS_WINDOWSAPP)
void *id;
#elif defined SYS_IPH
#elif defined SYS_NDS
#endif

bool Create(const wchar_t *name);
Expand Down
2 changes: 1 addition & 1 deletion Tools/koremake
90 changes: 0 additions & 90 deletions kake.lua

This file was deleted.

9 changes: 9 additions & 0 deletions korefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ else if (platform === Platform.OSX) {
project.addLib('CoreData');
project.addLib('Foundation');
project.addLib('OpenGL');
project.addDefine('SYS_UNIXOID');
}
else if (platform === Platform.iOS) {
addBackend('iOS');
Expand All @@ -100,12 +101,14 @@ else if (platform === Platform.iOS) {
project.addLib('CoreFoundation');
project.addLib('CoreVideo');
project.addLib('CoreMedia');
project.addDefine('SYS_UNIXOID');
}
else if (platform === Platform.Android) {
addBackend('Android');
addBackend('OpenGL2');
project.addDefine('OPENGL');
project.addDefine('SYS_ANDROID_API=15');
project.addDefine('SYS_UNIXOID');
}
else if (platform === Platform.HTML5) {
addBackend('HTML5');
Expand All @@ -117,12 +120,18 @@ else if (platform === Platform.Linux) {
addBackend('Linux');
addBackend('OpenGL2');
project.addDefine('OPENGL');
project.addDefine('SYS_UNIXOID');
}
else if (platform === Platform.Tizen) {
addBackend('Tizen');
addBackend('OpenGL2');
project.addExclude('Backends/OpenGL2/Sources/GL/**');
project.addDefine('OPENGL');
project.addDefine('SYS_UNIXOID');
}

if (platform !== Platform.Android) {
project.addExclude('Sources/Kore/IO/miniz.cpp')
}

return project;
2 changes: 1 addition & 1 deletion license.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2013 KTX Software Development
Copyright (c) 2015 KTX Software Development
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
Expand Down

0 comments on commit 8c0f66e

Please sign in to comment.