2012-05-12 18:03:14 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
#ifndef LIBWBFS_GLUE_H
|
|
|
|
#define LIBWBFS_GLUE_H
|
|
|
|
|
|
|
|
#include <gctypes.h>
|
2012-05-12 18:03:14 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
2012-06-16 19:03:23 +02:00
|
|
|
#include <gccore.h>
|
2012-07-27 19:26:49 +02:00
|
|
|
#include <malloc.h>
|
2012-05-12 18:03:14 +02:00
|
|
|
|
2012-12-08 17:17:35 +01:00
|
|
|
#include "gecko/gecko.hpp"
|
2012-06-16 19:03:23 +02:00
|
|
|
#include "loader/disc.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "loader/utils.h"
|
|
|
|
#include "memory/mem2.hpp"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-12-21 18:02:36 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
extern int wd_last_error;
|
|
|
|
static inline void wbfs_fatal(const char *x)
|
|
|
|
{
|
|
|
|
gprintf(x);
|
|
|
|
wd_last_error = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void wbfs_error(const char *x)
|
|
|
|
{
|
|
|
|
gprintf(x);
|
|
|
|
wd_last_error = 2;
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2013-09-01 18:43:53 +02:00
|
|
|
static inline void *wbfs_malloc(size_t size)
|
2012-07-27 19:26:49 +02:00
|
|
|
{
|
2014-03-01 00:11:02 +01:00
|
|
|
void *p = MEM2_lo_alloc(size);
|
2013-09-01 18:43:53 +02:00
|
|
|
if(p) memset(p, 0, size);
|
2012-07-27 19:26:49 +02:00
|
|
|
return p;
|
|
|
|
}
|
2013-09-01 18:43:53 +02:00
|
|
|
|
|
|
|
static inline void wbfs_free(void *ptr)
|
|
|
|
{
|
2014-03-01 00:11:02 +01:00
|
|
|
MEM2_lo_free(ptr);
|
2013-09-01 18:43:53 +02:00
|
|
|
}
|
|
|
|
|
2013-12-21 18:02:36 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#define wbfs_be16(x) (*((u16*)(x)))
|
|
|
|
#define wbfs_be32(x) (*((u32*)(x)))
|
|
|
|
#define wbfs_ntohl(x) (x)
|
|
|
|
#define wbfs_htonl(x) (x)
|
|
|
|
#define wbfs_ntohs(x) (x)
|
|
|
|
#define wbfs_htons(x) (x)
|
|
|
|
|
|
|
|
#define wbfs_memcmp(x,y,z) memcmp(x,y,z)
|
|
|
|
#define wbfs_memcpy(x,y,z) memcpy(x,y,z)
|
|
|
|
#define wbfs_memset(x,y,z) memset(x,y,z)
|
|
|
|
|
|
|
|
#endif
|