Commit b2da53a7 authored by Mats A's avatar Mats A Committed by Libretro-Admin
Browse files

working libnx port (#56)

* working libnx port

* replace accidental elif and remove the extra whitespace
parent b9b515f5
......@@ -81,4 +81,7 @@ xcuserdata/
*.lib
*.pdb
*.exp
*.manifest
\ No newline at end of file
*.manifest
# Static libraries
*.a
\ No newline at end of file
......@@ -209,18 +209,19 @@ else ifeq ($(platform), sncps3)
# Nintendo Switch (libnx)
else ifeq ($(platform), libnx)
include $(DEVKITPRO)/libnx/switch_rules
EXT=a
HAVE_LIBFAT=0
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DIOAPI_NO_64
CFLAGS := $(DEFINES) -g -O3 \
-fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(LIBNX)/switch.specs
CFLAGS += $(INCDIRS)
CFLAGS += -D__SWITCH__ -DHAVE_LIBNX -march=armv8-a -mtune=cortex-a57 -mtp=soft
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -fno-rtti -std=gnu++11
CFLAGS += -std=gnu11
STATIC_LINKING = 1
include $(DEVKITPRO)/libnx/switch_rules
EXT=a
HAVE_LIBFAT=1
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
DEFINES_THREAD := -Dpthread_t=Thread -Dpthread_mutex_t=Mutex -Dpthread_mutexattr_t='void*' -Dpthread_attr_t=int -Dpthread_cond_t=CondVar -Dpthread_condattr_t='int' -D_SYS__PTHREADTYPES_H_
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DIOAPI_NO_64 -D__SWITCH__=1 -DSWITCH $(DEFINES_THREAD)
CFLAGS := $(DEFINES) -g -O3 -ffast-math -funsafe-math-optimizations \
-fPIE -I$(DEVKITPRO)/libnx/include/ -I$(PORTLIBS)/include/ -include $(LIBNX)/include/switch.h -ffunction-sections -fdata-sections -ftls-model=local-exec -Wl,--allow-multiple-definition -specs=$(DEVKITPRO)/libnx/switch.specs
CFLAGS += $(INCDIRS)
CFLAGS += -D__SWITCH__ -DHAVE_LIBNX -march=armv8-a -mtune=cortex-a57 -mtp=soft -mcpu=cortex-a57+crc+fp+simd -lpthread
CXXFLAGS := $(ASFLAGS) $(CFLAGS) -std=gnu++11
CFLAGS += -std=gnu11
STATIC_LINKING = 1
# Lightweight PS3 Homebrew SDK
else ifeq ($(platform), psl1ght)
......
......@@ -191,12 +191,16 @@
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
#ifndef HAVE_LIBNX
typedef unsigned long long u64;
#endif
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
#ifndef HAVE_LIBNX
typedef signed long long s64;
#endif
#else
typedef unsigned char u8;
typedef unsigned short u16;
......
......@@ -44,9 +44,11 @@
#endif //_MSC_VER
#ifndef HAVE_LIBNX
struct _reent {
intptr_t _errno;
};
#endif
#ifdef __APPLE__
typedef __darwin_mode_t mode_t;
......
......@@ -69,6 +69,8 @@
#if defined(_WIN32) && defined(__LIBRETRO__)
#include "frontend/windows/winpcap/pcap.h"
#elif defined(HAVE_LIBNX)
typedef void* pcap_pkthdr;
#else
#include <pcap.h>
#endif
......@@ -3096,6 +3098,9 @@ static const u8 SoftAP_DeauthFrame[] = {
static void SoftAP_RXPacketGet_Callback(u_char *userData, const pcap_pkthdr *pktHeader, const u_char *pktData)
{
#if defined(HAVE_LIBNX)
return;
#else
const WIFI_IOREG_MAP &io = wifiHandler->GetWifiData().io;
if ( (userData == NULL) || (pktData == NULL) || (pktHeader == NULL) )
......@@ -3147,6 +3152,7 @@ static void SoftAP_RXPacketGet_Callback(u_char *userData, const pcap_pkthdr *pkt
rawPacket->writeLocation += emulatorHeader.emuPacketSize;
rawPacket->count++;
#endif
}
static void* Adhoc_RXPacketGetOnThread(void *arg)
......@@ -3551,6 +3557,10 @@ void* SoftAPCommInterface::_GetBridgeDeviceAtIndex(int deviceIndex, char *outErr
{
void *deviceList = NULL;
void *theDevice = NULL;
#if defined(HAVE_LIBNX)
return theDevice;
#else
int result = this->_pcap->findalldevs((void **)&deviceList, outErrorBuf);
if ( (result == -1) || (deviceList == NULL) )
......@@ -3579,6 +3589,7 @@ void* SoftAPCommInterface::_GetBridgeDeviceAtIndex(int deviceIndex, char *outErr
this->_pcap->freealldevs(deviceList);
return theDevice;
#endif
}
bool SoftAPCommInterface::_IsDNSRequestToWFC(u16 ethertype, const u8 *body)
......@@ -4488,6 +4499,9 @@ int WifiHandler::GetBridgeDeviceList(std::vector<std::string> *deviceStringList)
return result;
}
#if defined(HAVE_LIBNX)
return result;
#else
char errbuf[PCAP_ERRBUF_SIZE];
pcap_if_t *deviceList;
......@@ -4511,6 +4525,7 @@ int WifiHandler::GetBridgeDeviceList(std::vector<std::string> *deviceStringList)
}
return deviceStringList->size();
#endif
}
int WifiHandler::GetSelectedBridgeDeviceIndex()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment