Merge pull request #46 from dimok789/master

Link fixes for C++ applications and some additional enums and function declarations
This commit is contained in:
James 2016-10-11 21:42:38 +01:00 committed by GitHub
commit 48d2fcc314
10 changed files with 101 additions and 32 deletions

View File

@ -1,6 +1,7 @@
#include <malloc.h>
#include <string.h>
#include <coreinit/baseheap.h>
#include <coreinit/memheap.h>
#include <coreinit/expandedheap.h>
void *

14
include/coreinit/title.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include <wut.h>
#ifdef __cplusplus
extern "C" {
#endif
u64 OSGetTitleID(void);
#ifdef __cplusplus
}
#endif
/** @} */

View File

@ -14,6 +14,8 @@ extern "C" {
typedef enum GX2AAMode
{
GX2_AA_MODE1X = 0,
GX2_AA_MODE2X = 1,
GX2_AA_MODE4X = 2
} GX2AAMode;
typedef enum GX2AlphaToMaskMode
@ -117,6 +119,7 @@ typedef enum GX2ClearFlags
{
GX2_CLEAR_FLAGS_DEPTH = 1,
GX2_CLEAR_FLAGS_STENCIL = 2,
GX2_CLEAR_FLAGS_BOTH = (GX2_CLEAR_FLAGS_DEPTH | GX2_CLEAR_FLAGS_STENCIL),
} GX2ClearFlags;
typedef enum GX2CompareFunction
@ -185,6 +188,9 @@ typedef enum GX2InvalidateMode
GX2_INVALIDATE_MODE_CPU = 1 << 6,
GX2_INVALIDATE_MODE_STREAM_OUT_BUFFER = 1 << 7,
GX2_INVALIDATE_MODE_EXPORT_BUFFER = 1 << 8,
GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER= GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_ATTRIBUTE_BUFFER,
GX2_INVALIDATE_MODE_CPU_TEXTURE = GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_TEXTURE,
GX2_INVALIDATE_MODE_CPU_SHADER = GX2_INVALIDATE_MODE_CPU | GX2_INVALIDATE_MODE_SHADER,
} GX2InvalidateMode;
typedef enum GX2InitAttributes
@ -218,7 +224,10 @@ typedef enum GX2LogicOp
typedef enum GX2PrimitiveMode
{
GX2_PRIMITIVE_MODE_LINES = 2,
GX2_PRIMITIVE_MODE_LINE_STRIP = 3,
GX2_PRIMITIVE_MODE_TRIANGLES = 4,
GX2_PRIMITIVE_MODE_TRIANGLE_FAN = 5,
GX2_PRIMITIVE_MODE_TRIANGLE_STRIP = 6,
GX2_PRIMITIVE_MODE_QUADS = 19,
GX2_PRIMITIVE_MODE_QUAD_STRIP = 20,
@ -388,6 +397,8 @@ typedef enum GX2SurfaceUse
GX2_SURFACE_USE_COLOR_BUFFER = 1 << 1,
GX2_SURFACE_USE_DEPTH_BUFFER = 1 << 2,
GX2_SURFACE_USE_SCAN_BUFFER = 1 << 3,
GX2_SURFACE_USE_TV = 1 << 31,
GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV = (GX2_SURFACE_USE_TEXTURE | GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TV)
} GX2SurfaceUse;
typedef enum GX2TessellationMode
@ -428,8 +439,8 @@ typedef enum GX2TexMipPerfMode
typedef enum GX2TexXYFilterMode
{
GX2_TEX_XY_FILLTER_MODE_POINT = 0,
GX2_TEX_XY_FILLTER_MODE_LINEAR = 1,
GX2_TEX_XY_FILTER_MODE_POINT = 0,
GX2_TEX_XY_FILTER_MODE_LINEAR = 1,
} GX2TexXYFilterMode;
typedef enum GX2TexAnisoRatio

View File

@ -12,6 +12,8 @@
#define SOL_SOCKET 0xFFFF
#define INADDR_ANY 0
#define PF_UNSPEC 0
#define PF_INET 2
#define PF_INET6 23
@ -35,6 +37,10 @@
#define SHUT_WR 1
#define SHUT_RDWR 2
#define IPPROTO_IP 0
#define IPPROTO_TCP 6
#define IPPROTO_UDP 17
/*
* SOL_SOCKET options
*/
@ -69,6 +75,16 @@ struct linger
int l_linger;
};
struct in_addr {
unsigned int s_addr;
};
struct sockaddr_in {
short sin_family;
unsigned short sin_port;
struct in_addr sin_addr;
char sin_zero[8];
};
#ifdef __cplusplus
extern "C" {
#endif
@ -87,7 +103,7 @@ bind(int sockfd,
socklen_t addrlen);
int
closesocket(int sockfd);
socketclose(int sockfd);
int
connect(int sockfd,
@ -166,6 +182,12 @@ select(int nfds,
fd_set *exceptfds,
struct timeval *timeout);
char *
inet_ntoa(struct in_addr in);
int
inet_aton(const char *cp, struct in_addr *inp);
#ifdef __cplusplus
}
#endif

View File

@ -54,6 +54,9 @@ CHECK_SIZE(AXInitParams, 0x0C);
void
AXInit();
void
AXQuit();
void
AXInitWithParams(AXInitParams *params);

View File

@ -368,5 +368,8 @@ EXPORT(MEMFreeToUnitHeap);
EXPORT(MEMCountFreeBlockForUnitHeap);
EXPORT(MEMCalcHeapSizeForUnitHeap);
// coreinit/title.h
EXPORT(OSGetTitleID);
// coreinit/internal.h
EXPORT(__os_snprintf);

View File

@ -17,23 +17,27 @@ EXPORT(sendto_multi);
EXPORT(sendto_multi_ex);
EXPORT(shutdown);
EXPORT(inet_aton);
EXPORT(inet_ntoa);
EXPORT(inet_ntoa_r);
EXPORT(inet_ntop);
EXPORT(inet_pton);
EXPORT(getpeername);
EXPORT(getsockname);
EXPORT(getsockopt);
EXPORT(setsocketlasterr);
EXPORT(select);
EXPORT(setsocklibopt);
EXPORT(getsocklibopt);
EXPORT(somemopt);
EXPORT(ntohl);
EXPORT(htonl);
EXPORT(ntohs);
EXPORT(htons);
/*
// Those are not in nsysnet.rpl - why are they linked o.O?
EXPORT(somemopt);
EXPORT(setsocketlasterr);
EXPORT(icmp_create_handle);
EXPORT(icmp_close_handle);
EXPORT(icmp_ping);
EXPORT(icmp_cancel);
EXPORT(icmp_last_code_type);
*/

View File

@ -8,6 +8,7 @@ EXPORT(AXSetDefaultMixerSelect);
EXPORT(AXRegisterAppFrameCallback);
EXPORT(AXGetInputSamplesPerFrame);
EXPORT(AXGetInputSamplesPerSec);
EXPORT(AXQuit);
// sndcore2/device.h
EXPORT(AXGetDeviceMode);

View File

@ -193,6 +193,7 @@ SECTIONS {
/* Required compiler trash */
.fixup ALIGN(32) : { *(.fixup*) }
.got ALIGN(32) : { *(.got*) }
.gcc_except_table ALIGN(32) : { *(.gcc_except_table*) }
.hash ALIGN(32) : { *(.hash) }
.dynsym ALIGN(32) : { *(.dynsym) }

View File

@ -238,6 +238,9 @@ read(ElfFile &file, const std::string &filename)
case elf::R_PPC_RELATIVE:
*ptr = byte_swap(addr);
break;
case elf::R_PPC_NONE:
// ignore padding
break;
default:
std::cout << "Unexpected relocation type in .rela.dyn section" << std::endl;
return false;
@ -484,6 +487,12 @@ read(ElfFile &file, const std::string &filename)
auto symbol = getSectionSymbol(symSection, index);
auto addr = symbol->value + rela.addend;
if(type == elf::R_PPC_NONE)
{
// ignore padding
continue;
}
if(index == 0)
{
auto addend = static_cast<uint32_t>(rela.addend);