1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (nbio_intf.c).
5 * ---------------------------------------------------------------------------------------
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:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.
30 #include <file/nbio.h>
32 extern nbio_intf_t nbio_linux;
33 extern nbio_intf_t nbio_mmap_unix;
34 extern nbio_intf_t nbio_mmap_win32;
35 extern nbio_intf_t nbio_stdio;
39 #if defined(_MSC_VER) && _MSC_VER >= 1500
41 #ifndef HAVE_MMAP_WIN32
42 #define HAVE_MMAP_WIN32
45 #elif !defined(_MSC_VER)
47 #ifndef HAVE_MMAP_WIN32
48 #define HAVE_MMAP_WIN32
56 static nbio_intf_t *internal_nbio = &nbio_linux;
57 #elif defined(HAVE_MMAP) && defined(BSD)
58 static nbio_intf_t *internal_nbio = &nbio_mmap_unix;
59 #elif defined(HAVE_MMAP_WIN32)
60 static nbio_intf_t *internal_nbio = &nbio_mmap_win32;
62 static nbio_intf_t *internal_nbio = &nbio_stdio;
65 void *nbio_open(const char * filename, unsigned mode)
67 return internal_nbio->open(filename, mode);
70 void nbio_begin_read(void *data)
72 internal_nbio->begin_read(data);
75 void nbio_begin_write(void *data)
77 internal_nbio->begin_write(data);
80 bool nbio_iterate(void *data)
82 return internal_nbio->iterate(data);
85 void nbio_resize(void *data, size_t len)
87 internal_nbio->resize(data, len);
90 void *nbio_get_ptr(void *data, size_t* len)
92 return internal_nbio->get_ptr(data, len);
95 void nbio_cancel(void *data)
97 internal_nbio->cancel(data);
100 void nbio_free(void *data)
102 internal_nbio->free(data);