Add retro_inline.h to SDK

This commit is contained in:
twinaphex 2014-10-22 01:00:59 +02:00
parent 1291256b66
commit 25a18c3b42
3 changed files with 52 additions and 10 deletions

View File

@ -23,6 +23,7 @@
#ifndef __LIBRETRO_SDK_ENDIANNESS_H
#define __LIBRETRO_SDK_ENDIANNESS_H
#include <retro_inline.h>
#include <stdint.h>
#define SWAP32(x) ((uint32_t)( \
@ -32,7 +33,7 @@
(((uint32_t)(x) & 0xff000000) >> 24) \
))
static inline uint8_t is_little_endian(void)
static INLINE uint8_t is_little_endian(void)
{
union
{
@ -44,7 +45,7 @@ static inline uint8_t is_little_endian(void)
return u.y[0];
}
static inline uint32_t swap_if_big32(uint32_t val)
static INLINE uint32_t swap_if_big32(uint32_t val)
{
if (is_little_endian())
return val;
@ -52,7 +53,7 @@ static inline uint32_t swap_if_big32(uint32_t val)
((val << 8) & 0xFF0000) | (val << 24);
}
static inline uint32_t swap_if_little32(uint32_t val)
static INLINE uint32_t swap_if_little32(uint32_t val)
{
if (is_little_endian())
return (val >> 24) | ((val >> 8) & 0xFF00) |
@ -60,26 +61,26 @@ static inline uint32_t swap_if_little32(uint32_t val)
return val;
}
static inline uint16_t swap_if_big16(uint16_t val)
static INLINE uint16_t swap_if_big16(uint16_t val)
{
if (is_little_endian())
return val;
return (val >> 8) | (val << 8);
}
static inline uint16_t swap_if_little16(uint16_t val)
static INLINE uint16_t swap_if_little16(uint16_t val)
{
if (is_little_endian())
return (val >> 8) | (val << 8);
return val;
}
static inline void store32be(uint32_t *addr, uint32_t data)
static INLINE void store32be(uint32_t *addr, uint32_t data)
{
*addr = is_little_endian() ? SWAP32(data) : data;
}
static inline uint32_t load32be(const uint32_t *addr)
static INLINE uint32_t load32be(const uint32_t *addr)
{
return is_little_endian() ? SWAP32(*addr) : *addr;
}

View File

@ -0,0 +1,40 @@
/* Copyright (C) 2010-2014 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (retro_inline.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __LIBRETRO_SDK_INLINE_H_
#define __LIBRETRO_SDK_INLINE_H
#if !defined(__cplusplus) && defined(_WIN32)
#ifndef INLINE
#define INLINE _inline
#endif
#else
#ifndef INLINE
#define INLINE inline
#endif
#endif
#endif

View File

@ -47,6 +47,7 @@
/* TODO/FIXME - dirty hack */
#include "../../retroarch_logger.h"
#endif
#include <retro_inline.h>
#include <retro_endianness.h>
#include <limits.h>
@ -75,7 +76,7 @@
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define RARCH_SCALE_BASE 256
static inline void rarch_sleep(unsigned msec)
static INLINE void rarch_sleep(unsigned msec)
{
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
sys_timer_usleep(1000 * msec);
@ -95,7 +96,7 @@ static inline void rarch_sleep(unsigned msec)
#endif
}
static inline uint32_t next_pow2(uint32_t v)
static INLINE uint32_t next_pow2(uint32_t v)
{
v--;
v |= v >> 1;
@ -107,7 +108,7 @@ static inline uint32_t next_pow2(uint32_t v)
return v;
}
static inline uint32_t prev_pow2(uint32_t v)
static INLINE uint32_t prev_pow2(uint32_t v)
{
v |= v >> 1;
v |= v >> 2;