Merge pull request #728 from pcercuei/libretro-wiiu-v4
[pcsx_rearmed.git] / deps / libretro-common / file / nbio / nbio_intf.c
CommitLineData
3719602c
PC
1/* Copyright (C) 2010-2020 The RetroArch team
2 *
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (nbio_intf.c).
5 * ---------------------------------------------------------------------------------------
6 *
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#include <stdio.h>
24#include <stdlib.h>
25
26#ifdef HAVE_CONFIG_H
27#include "config.h"
28#endif
29
30#include <file/nbio.h>
31
32extern nbio_intf_t nbio_linux;
33extern nbio_intf_t nbio_mmap_unix;
34extern nbio_intf_t nbio_mmap_win32;
35extern nbio_intf_t nbio_stdio;
36
37#ifndef _XBOX
38#if defined(_WIN32)
39#if defined(_MSC_VER) && _MSC_VER >= 1500
40
41#ifndef HAVE_MMAP_WIN32
42#define HAVE_MMAP_WIN32
43#endif
44
45#elif !defined(_MSC_VER)
46
47#ifndef HAVE_MMAP_WIN32
48#define HAVE_MMAP_WIN32
49#endif
50#endif
51#endif
52
53#endif
54
55#if defined(_linux__)
56static nbio_intf_t *internal_nbio = &nbio_linux;
57#elif defined(HAVE_MMAP) && defined(BSD)
58static nbio_intf_t *internal_nbio = &nbio_mmap_unix;
59#elif defined(HAVE_MMAP_WIN32)
60static nbio_intf_t *internal_nbio = &nbio_mmap_win32;
61#else
62static nbio_intf_t *internal_nbio = &nbio_stdio;
63#endif
64
65void *nbio_open(const char * filename, unsigned mode)
66{
67 return internal_nbio->open(filename, mode);
68}
69
70void nbio_begin_read(void *data)
71{
72 internal_nbio->begin_read(data);
73}
74
75void nbio_begin_write(void *data)
76{
77 internal_nbio->begin_write(data);
78}
79
80bool nbio_iterate(void *data)
81{
82 return internal_nbio->iterate(data);
83}
84
85void nbio_resize(void *data, size_t len)
86{
87 internal_nbio->resize(data, len);
88}
89
90void *nbio_get_ptr(void *data, size_t* len)
91{
92 return internal_nbio->get_ptr(data, len);
93}
94
95void nbio_cancel(void *data)
96{
97 internal_nbio->cancel(data);
98}
99
100void nbio_free(void *data)
101{
102 internal_nbio->free(data);
103}