update libretro-common. lots of noisy EOL changes because originally I screwed up and changed them.
This commit is contained in:
parent
655dd15cc1
commit
7f0c1276d4
|
@ -1,157 +1,157 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_fnmatch.c).
|
* The following license statement only applies to this file (compat_fnmatch.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if __TEST_FNMATCH__
|
#if __TEST_FNMATCH__
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <compat/fnmatch.h>
|
#include <compat/fnmatch.h>
|
||||||
|
|
||||||
/* Implemnentation of fnmatch(3) so it can be
|
/* Implemnentation of fnmatch(3) so it can be
|
||||||
* distributed to non *nix platforms.
|
* distributed to non *nix platforms.
|
||||||
*
|
*
|
||||||
* No flags are implemented ATM.
|
* No flags are implemented ATM.
|
||||||
* We don't use them. Add flags as needed. */
|
* We don't use them. Add flags as needed. */
|
||||||
|
|
||||||
int rl_fnmatch(const char *pattern, const char *string, int flags)
|
int rl_fnmatch(const char *pattern, const char *string, int flags)
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
int charmatch = 0;
|
int charmatch = 0;
|
||||||
int rv;
|
int rv;
|
||||||
for (c = pattern; *c != '\0'; c++)
|
for (c = pattern; *c != '\0'; c++)
|
||||||
{
|
{
|
||||||
/* String ended before pattern */
|
/* String ended before pattern */
|
||||||
if ((*c != '*') && (*string == '\0'))
|
if ((*c != '*') && (*string == '\0'))
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
|
|
||||||
switch (*c)
|
switch (*c)
|
||||||
{
|
{
|
||||||
/* Match any number of unknown chars */
|
/* Match any number of unknown chars */
|
||||||
case '*':
|
case '*':
|
||||||
/* Find next node in the pattern
|
/* Find next node in the pattern
|
||||||
* ignoring multiple asterixes
|
* ignoring multiple asterixes
|
||||||
*/
|
*/
|
||||||
do {
|
do {
|
||||||
c++;
|
c++;
|
||||||
if (*c == '\0')
|
if (*c == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
} while (*c == '*');
|
} while (*c == '*');
|
||||||
|
|
||||||
/* Match the remaining pattern
|
/* Match the remaining pattern
|
||||||
* ignoring more and more characters. */
|
* ignoring more and more characters. */
|
||||||
do {
|
do {
|
||||||
/* We reached the end of the string without a
|
/* We reached the end of the string without a
|
||||||
* match. There is a way to optimize this by
|
* match. There is a way to optimize this by
|
||||||
* calculating the minimum chars needed to
|
* calculating the minimum chars needed to
|
||||||
* match the remaining pattern but I don't
|
* match the remaining pattern but I don't
|
||||||
* think it is worth the work ATM.
|
* think it is worth the work ATM.
|
||||||
*/
|
*/
|
||||||
if (*string == '\0')
|
if (*string == '\0')
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
|
|
||||||
rv = rl_fnmatch(c, string, flags);
|
rv = rl_fnmatch(c, string, flags);
|
||||||
string++;
|
string++;
|
||||||
} while (rv != 0);
|
} while (rv != 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
/* Match char from list */
|
/* Match char from list */
|
||||||
case '[':
|
case '[':
|
||||||
charmatch = 0;
|
charmatch = 0;
|
||||||
for (c++; *c != ']'; c++)
|
for (c++; *c != ']'; c++)
|
||||||
{
|
{
|
||||||
/* Bad format */
|
/* Bad format */
|
||||||
if (*c == '\0')
|
if (*c == '\0')
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
|
|
||||||
/* Match already found */
|
/* Match already found */
|
||||||
if (charmatch)
|
if (charmatch)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (*c == *string)
|
if (*c == *string)
|
||||||
charmatch = 1;
|
charmatch = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* No match in list */
|
/* No match in list */
|
||||||
if (!charmatch)
|
if (!charmatch)
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
|
|
||||||
string++;
|
string++;
|
||||||
break;
|
break;
|
||||||
/* Has any character */
|
/* Has any character */
|
||||||
case '?':
|
case '?':
|
||||||
string++;
|
string++;
|
||||||
break;
|
break;
|
||||||
/* Match following character verbatim */
|
/* Match following character verbatim */
|
||||||
case '\\':
|
case '\\':
|
||||||
c++;
|
c++;
|
||||||
/* Dangling escape at end of pattern.
|
/* Dangling escape at end of pattern.
|
||||||
* FIXME: Was c == '\0' (makes no sense).
|
* FIXME: Was c == '\0' (makes no sense).
|
||||||
* Not sure if c == NULL or *c == '\0'
|
* Not sure if c == NULL or *c == '\0'
|
||||||
* is intended. Assuming *c due to c++ right before. */
|
* is intended. Assuming *c due to c++ right before. */
|
||||||
if (*c == '\0')
|
if (*c == '\0')
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
default:
|
default:
|
||||||
if (*c != *string)
|
if (*c != *string)
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
string++;
|
string++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of string and end of pattend */
|
/* End of string and end of pattend */
|
||||||
if (*string == '\0')
|
if (*string == '\0')
|
||||||
return 0;
|
return 0;
|
||||||
return FNM_NOMATCH;
|
return FNM_NOMATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __TEST_FNMATCH__
|
#if __TEST_FNMATCH__
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
assert(rl_fnmatch("TEST", "TEST", 0) == 0);
|
assert(rl_fnmatch("TEST", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE?T", "TEST", 0) == 0);
|
assert(rl_fnmatch("TE?T", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0);
|
assert(rl_fnmatch("TE[Ssa]T", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0);
|
assert(rl_fnmatch("TE[Ssda]T", "TEsT", 0) == 0);
|
||||||
assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0);
|
assert(rl_fnmatch("TE[Ssda]T", "TEdT", 0) == 0);
|
||||||
assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0);
|
assert(rl_fnmatch("TE[Ssda]T", "TEaT", 0) == 0);
|
||||||
assert(rl_fnmatch("TEST*", "TEST", 0) == 0);
|
assert(rl_fnmatch("TEST*", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TEST**", "TEST", 0) == 0);
|
assert(rl_fnmatch("TEST**", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0);
|
assert(rl_fnmatch("TE*ST*", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0);
|
assert(rl_fnmatch("TE**ST*", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0);
|
assert(rl_fnmatch("TE**ST*", "TExST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE**ST", "TEST", 0) == 0);
|
assert(rl_fnmatch("TE**ST", "TEST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE**ST", "TExST", 0) == 0);
|
assert(rl_fnmatch("TE**ST", "TExST", 0) == 0);
|
||||||
assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0);
|
assert(rl_fnmatch("TE\\**ST", "TE*xST", 0) == 0);
|
||||||
assert(rl_fnmatch("*.*", "test.jpg", 0) == 0);
|
assert(rl_fnmatch("*.*", "test.jpg", 0) == 0);
|
||||||
assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0);
|
assert(rl_fnmatch("*.jpg", "test.jpg", 0) == 0);
|
||||||
assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0);
|
assert(rl_fnmatch("*.[Jj][Pp][Gg]", "test.jPg", 0) == 0);
|
||||||
assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0);
|
assert(rl_fnmatch("*.[Jj]*[Gg]", "test.jPg", 0) == 0);
|
||||||
assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TEST?", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TES[asd", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TEST\\", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TEST*S", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TE**ST", "TExT", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TE\\*T", "TExT", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TES?", "TES", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TE", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("TEST!", "TEST", 0) == FNM_NOMATCH);
|
||||||
assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH);
|
assert(rl_fnmatch("DSAD", "TEST", 0) == FNM_NOMATCH);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,219 +1,219 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_getopt.c).
|
* The following license statement only applies to this file (compat_getopt.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
|
|
||||||
#include <compat/getopt.h>
|
#include <compat/getopt.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <compat/strcasestr.h>
|
#include <compat/strcasestr.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
char *optarg;
|
char *optarg;
|
||||||
int optind, opterr, optopt;
|
int optind, opterr, optopt;
|
||||||
|
|
||||||
static bool is_short_option(const char *str)
|
static bool is_short_option(const char *str)
|
||||||
{
|
{
|
||||||
return str[0] == '-' && str[1] != '-';
|
return str[0] == '-' && str[1] != '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_long_option(const char *str)
|
static bool is_long_option(const char *str)
|
||||||
{
|
{
|
||||||
return str[0] == '-' && str[1] == '-';
|
return str[0] == '-' && str[1] == '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_short_index(char * const *argv)
|
static int find_short_index(char * const *argv)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
for (idx = 0; argv[idx]; idx++)
|
for (idx = 0; argv[idx]; idx++)
|
||||||
{
|
{
|
||||||
if (is_short_option(argv[idx]))
|
if (is_short_option(argv[idx]))
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_long_index(char * const *argv)
|
static int find_long_index(char * const *argv)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
for (idx = 0; argv[idx]; idx++)
|
for (idx = 0; argv[idx]; idx++)
|
||||||
{
|
{
|
||||||
if (is_long_option(argv[idx]))
|
if (is_long_option(argv[idx]))
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_short(const char *optstring, char * const *argv)
|
static int parse_short(const char *optstring, char * const *argv)
|
||||||
{
|
{
|
||||||
bool extra_opt, takes_arg, embedded_arg;
|
bool extra_opt, takes_arg, embedded_arg;
|
||||||
const char *opt = NULL;
|
const char *opt = NULL;
|
||||||
char arg = argv[0][1];
|
char arg = argv[0][1];
|
||||||
|
|
||||||
if (arg == ':')
|
if (arg == ':')
|
||||||
return '?';
|
return '?';
|
||||||
|
|
||||||
opt = strchr(optstring, arg);
|
opt = strchr(optstring, arg);
|
||||||
if (!opt)
|
if (!opt)
|
||||||
return '?';
|
return '?';
|
||||||
|
|
||||||
extra_opt = argv[0][2];
|
extra_opt = argv[0][2];
|
||||||
takes_arg = opt[1] == ':';
|
takes_arg = opt[1] == ':';
|
||||||
|
|
||||||
/* If we take an argument, and we see additional characters,
|
/* If we take an argument, and we see additional characters,
|
||||||
* this is in fact the argument (i.e. -cfoo is same as -c foo). */
|
* this is in fact the argument (i.e. -cfoo is same as -c foo). */
|
||||||
embedded_arg = extra_opt && takes_arg;
|
embedded_arg = extra_opt && takes_arg;
|
||||||
|
|
||||||
if (takes_arg)
|
if (takes_arg)
|
||||||
{
|
{
|
||||||
if (embedded_arg)
|
if (embedded_arg)
|
||||||
{
|
{
|
||||||
optarg = argv[0] + 2;
|
optarg = argv[0] + 2;
|
||||||
optind++;
|
optind++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
optarg = argv[1];
|
optarg = argv[1];
|
||||||
optind += 2;
|
optind += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return optarg ? opt[0] : '?';
|
return optarg ? opt[0] : '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (embedded_arg)
|
if (embedded_arg)
|
||||||
{
|
{
|
||||||
/* If we see additional characters,
|
/* If we see additional characters,
|
||||||
* and they don't take arguments, this
|
* and they don't take arguments, this
|
||||||
* means we have multiple flags in one. */
|
* means we have multiple flags in one. */
|
||||||
memmove(&argv[0][1], &argv[0][2], strlen(&argv[0][2]) + 1);
|
memmove(&argv[0][1], &argv[0][2], strlen(&argv[0][2]) + 1);
|
||||||
return opt[0];
|
return opt[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
optind++;
|
optind++;
|
||||||
return opt[0];
|
return opt[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_long(const struct option *longopts, char * const *argv)
|
static int parse_long(const struct option *longopts, char * const *argv)
|
||||||
{
|
{
|
||||||
size_t indice;
|
size_t indice;
|
||||||
const struct option *opt = NULL;
|
const struct option *opt = NULL;
|
||||||
for (indice = 0; longopts[indice].name; indice++)
|
for (indice = 0; longopts[indice].name; indice++)
|
||||||
{
|
{
|
||||||
if (!strcmp(longopts[indice].name, &argv[0][2]))
|
if (!strcmp(longopts[indice].name, &argv[0][2]))
|
||||||
{
|
{
|
||||||
opt = &longopts[indice];
|
opt = &longopts[indice];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt)
|
if (!opt)
|
||||||
return '?';
|
return '?';
|
||||||
|
|
||||||
/* getopt_long has an "optional" arg, but we don't bother with that. */
|
/* getopt_long has an "optional" arg, but we don't bother with that. */
|
||||||
if (opt->has_arg && !argv[1])
|
if (opt->has_arg && !argv[1])
|
||||||
return '?';
|
return '?';
|
||||||
|
|
||||||
if (opt->has_arg)
|
if (opt->has_arg)
|
||||||
{
|
{
|
||||||
optarg = argv[1];
|
optarg = argv[1];
|
||||||
optind += 2;
|
optind += 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
optind++;
|
optind++;
|
||||||
|
|
||||||
if (opt->flag)
|
if (opt->flag)
|
||||||
{
|
{
|
||||||
*opt->flag = opt->val;
|
*opt->flag = opt->val;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return opt->val;
|
return opt->val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shuffle_block(char **begin, char **last, char **end)
|
static void shuffle_block(char **begin, char **last, char **end)
|
||||||
{
|
{
|
||||||
ptrdiff_t len = last - begin;
|
ptrdiff_t len = last - begin;
|
||||||
const char **tmp = (const char**)calloc(len, sizeof(const char*));
|
const char **tmp = (const char**)calloc(len, sizeof(const char*));
|
||||||
|
|
||||||
retro_assert(tmp);
|
retro_assert(tmp);
|
||||||
|
|
||||||
memcpy(tmp, begin, len * sizeof(const char*));
|
memcpy(tmp, begin, len * sizeof(const char*));
|
||||||
memmove(begin, last, (end - last) * sizeof(const char*));
|
memmove(begin, last, (end - last) * sizeof(const char*));
|
||||||
memcpy(end - len, tmp, len * sizeof(const char*));
|
memcpy(end - len, tmp, len * sizeof(const char*));
|
||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int getopt_long(int argc, char *argv[],
|
int getopt_long(int argc, char *argv[],
|
||||||
const char *optstring, const struct option *longopts, int *longindex)
|
const char *optstring, const struct option *longopts, int *longindex)
|
||||||
{
|
{
|
||||||
int short_index, long_index;
|
int short_index, long_index;
|
||||||
|
|
||||||
(void)longindex;
|
(void)longindex;
|
||||||
|
|
||||||
if (optind == 0)
|
if (optind == 0)
|
||||||
optind = 1;
|
optind = 1;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
short_index = find_short_index(&argv[optind]);
|
short_index = find_short_index(&argv[optind]);
|
||||||
long_index = find_long_index(&argv[optind]);
|
long_index = find_long_index(&argv[optind]);
|
||||||
|
|
||||||
/* We're done here. */
|
/* We're done here. */
|
||||||
if (short_index == -1 && long_index == -1)
|
if (short_index == -1 && long_index == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Reorder argv so that non-options come last.
|
/* Reorder argv so that non-options come last.
|
||||||
* Non-POSIXy, but that's what getopt does by default. */
|
* Non-POSIXy, but that's what getopt does by default. */
|
||||||
if ((short_index > 0) && ((short_index < long_index) || (long_index == -1)))
|
if ((short_index > 0) && ((short_index < long_index) || (long_index == -1)))
|
||||||
{
|
{
|
||||||
shuffle_block(&argv[optind], &argv[optind + short_index], &argv[argc]);
|
shuffle_block(&argv[optind], &argv[optind + short_index], &argv[argc]);
|
||||||
short_index = 0;
|
short_index = 0;
|
||||||
}
|
}
|
||||||
else if ((long_index > 0) && ((long_index < short_index)
|
else if ((long_index > 0) && ((long_index < short_index)
|
||||||
|| (short_index == -1)))
|
|| (short_index == -1)))
|
||||||
{
|
{
|
||||||
shuffle_block(&argv[optind], &argv[optind + long_index], &argv[argc]);
|
shuffle_block(&argv[optind], &argv[optind + long_index], &argv[argc]);
|
||||||
long_index = 0;
|
long_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
retro_assert(short_index == 0 || long_index == 0);
|
retro_assert(short_index == 0 || long_index == 0);
|
||||||
|
|
||||||
if (short_index == 0)
|
if (short_index == 0)
|
||||||
return parse_short(optstring, &argv[optind]);
|
return parse_short(optstring, &argv[optind]);
|
||||||
if (long_index == 0)
|
if (long_index == 0)
|
||||||
return parse_long(longopts, &argv[optind]);
|
return parse_long(longopts, &argv[optind]);
|
||||||
|
|
||||||
return '?';
|
return '?';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,661 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2013, Kenneth MacKay
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <compat/ifaddrs.h>
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netpacket/packet.h>
|
||||||
|
#include <net/if_arp.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <linux/netlink.h>
|
||||||
|
#include <linux/rtnetlink.h>
|
||||||
|
|
||||||
|
typedef struct NetlinkList
|
||||||
|
{
|
||||||
|
struct NetlinkList *m_next;
|
||||||
|
struct nlmsghdr *m_data;
|
||||||
|
unsigned int m_size;
|
||||||
|
} NetlinkList;
|
||||||
|
|
||||||
|
static int netlink_socket(void)
|
||||||
|
{
|
||||||
|
int l_socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
|
if(l_socket < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
memset(&l_addr, 0, sizeof(l_addr));
|
||||||
|
l_addr.nl_family = AF_NETLINK;
|
||||||
|
if(bind(l_socket, (struct sockaddr *)&l_addr, sizeof(l_addr)) < 0)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return l_socket;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int netlink_send(int p_socket, int p_request)
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
struct nlmsghdr m_hdr;
|
||||||
|
struct rtgenmsg m_msg;
|
||||||
|
} l_data;
|
||||||
|
|
||||||
|
memset(&l_data, 0, sizeof(l_data));
|
||||||
|
|
||||||
|
l_data.m_hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtgenmsg));
|
||||||
|
l_data.m_hdr.nlmsg_type = p_request;
|
||||||
|
l_data.m_hdr.nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
|
||||||
|
l_data.m_hdr.nlmsg_pid = 0;
|
||||||
|
l_data.m_hdr.nlmsg_seq = p_socket;
|
||||||
|
l_data.m_msg.rtgen_family = AF_UNSPEC;
|
||||||
|
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
memset(&l_addr, 0, sizeof(l_addr));
|
||||||
|
l_addr.nl_family = AF_NETLINK;
|
||||||
|
return (sendto(p_socket, &l_data.m_hdr, l_data.m_hdr.nlmsg_len, 0, (struct sockaddr *)&l_addr, sizeof(l_addr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int netlink_recv(int p_socket, void *p_buffer, size_t p_len)
|
||||||
|
{
|
||||||
|
struct msghdr l_msg;
|
||||||
|
struct iovec l_iov = { p_buffer, p_len };
|
||||||
|
struct sockaddr_nl l_addr;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
l_msg.msg_name = (void *)&l_addr;
|
||||||
|
l_msg.msg_namelen = sizeof(l_addr);
|
||||||
|
l_msg.msg_iov = &l_iov;
|
||||||
|
l_msg.msg_iovlen = 1;
|
||||||
|
l_msg.msg_control = NULL;
|
||||||
|
l_msg.msg_controllen = 0;
|
||||||
|
l_msg.msg_flags = 0;
|
||||||
|
int l_result = recvmsg(p_socket, &l_msg, 0);
|
||||||
|
|
||||||
|
if(l_result < 0)
|
||||||
|
{
|
||||||
|
if(errno == EINTR)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_msg.msg_flags & MSG_TRUNC)
|
||||||
|
{ // buffer was too small
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return l_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct nlmsghdr *getNetlinkResponse(int p_socket, int *p_size, int *p_done)
|
||||||
|
{
|
||||||
|
size_t l_size = 4096;
|
||||||
|
void *l_buffer = NULL;
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
l_buffer = malloc(l_size);
|
||||||
|
if (l_buffer == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l_read = netlink_recv(p_socket, l_buffer, l_size);
|
||||||
|
*p_size = l_read;
|
||||||
|
if(l_read == -2)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(l_read >= 0)
|
||||||
|
{
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = (struct nlmsghdr *)l_buffer; NLMSG_OK(l_hdr, (unsigned int)l_read); l_hdr = (struct nlmsghdr *)NLMSG_NEXT(l_hdr, l_read))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
*p_done = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_ERROR)
|
||||||
|
{
|
||||||
|
free(l_buffer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return l_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_size *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NetlinkList *newListItem(struct nlmsghdr *p_data, unsigned int p_size)
|
||||||
|
{
|
||||||
|
NetlinkList *l_item = malloc(sizeof(NetlinkList));
|
||||||
|
if (l_item == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_item->m_next = NULL;
|
||||||
|
l_item->m_data = p_data;
|
||||||
|
l_item->m_size = p_size;
|
||||||
|
return l_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void freeResultList(NetlinkList *p_list)
|
||||||
|
{
|
||||||
|
NetlinkList *l_cur;
|
||||||
|
while(p_list)
|
||||||
|
{
|
||||||
|
l_cur = p_list;
|
||||||
|
p_list = p_list->m_next;
|
||||||
|
free(l_cur->m_data);
|
||||||
|
free(l_cur);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static NetlinkList *getResultList(int p_socket, int p_request)
|
||||||
|
{
|
||||||
|
if(netlink_send(p_socket, p_request) < 0)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_list = NULL;
|
||||||
|
NetlinkList *l_end = NULL;
|
||||||
|
int l_size;
|
||||||
|
int l_done = 0;
|
||||||
|
while(!l_done)
|
||||||
|
{
|
||||||
|
struct nlmsghdr *l_hdr = getNetlinkResponse(p_socket, &l_size, &l_done);
|
||||||
|
if(!l_hdr)
|
||||||
|
{ // error
|
||||||
|
freeResultList(l_list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_item = newListItem(l_hdr, l_size);
|
||||||
|
if (!l_item)
|
||||||
|
{
|
||||||
|
freeResultList(l_list);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if(!l_list)
|
||||||
|
{
|
||||||
|
l_list = l_item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_end->m_next = l_item;
|
||||||
|
}
|
||||||
|
l_end = l_item;
|
||||||
|
}
|
||||||
|
return l_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t maxSize(size_t a, size_t b)
|
||||||
|
{
|
||||||
|
return (a > b ? a : b);
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t calcAddrLen(sa_family_t p_family, int p_dataSize)
|
||||||
|
{
|
||||||
|
switch(p_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
return sizeof(struct sockaddr_in);
|
||||||
|
case AF_INET6:
|
||||||
|
return sizeof(struct sockaddr_in6);
|
||||||
|
case AF_PACKET:
|
||||||
|
return maxSize(sizeof(struct sockaddr_ll), offsetof(struct sockaddr_ll, sll_addr) + p_dataSize);
|
||||||
|
default:
|
||||||
|
return maxSize(sizeof(struct sockaddr), offsetof(struct sockaddr, sa_data) + p_dataSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void makeSockaddr(sa_family_t p_family, struct sockaddr *p_dest, void *p_data, size_t p_size)
|
||||||
|
{
|
||||||
|
switch(p_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
memcpy(&((struct sockaddr_in*)p_dest)->sin_addr, p_data, p_size);
|
||||||
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
memcpy(&((struct sockaddr_in6*)p_dest)->sin6_addr, p_data, p_size);
|
||||||
|
break;
|
||||||
|
case AF_PACKET:
|
||||||
|
memcpy(((struct sockaddr_ll*)p_dest)->sll_addr, p_data, p_size);
|
||||||
|
((struct sockaddr_ll*)p_dest)->sll_halen = p_size;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
memcpy(p_dest->sa_data, p_data, p_size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
p_dest->sa_family = p_family;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void addToEnd(struct ifaddrs **p_resultList, struct ifaddrs *p_entry)
|
||||||
|
{
|
||||||
|
if(!*p_resultList)
|
||||||
|
{
|
||||||
|
*p_resultList = p_entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct ifaddrs *l_cur = *p_resultList;
|
||||||
|
while(l_cur->ifa_next)
|
||||||
|
{
|
||||||
|
l_cur = l_cur->ifa_next;
|
||||||
|
}
|
||||||
|
l_cur->ifa_next = p_entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int interpretLink(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList)
|
||||||
|
{
|
||||||
|
struct ifinfomsg *l_info = (struct ifinfomsg *)NLMSG_DATA(p_hdr);
|
||||||
|
|
||||||
|
size_t l_nameSize = 0;
|
||||||
|
size_t l_addrSize = 0;
|
||||||
|
size_t l_dataSize = 0;
|
||||||
|
|
||||||
|
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg));
|
||||||
|
struct rtattr *l_rta;
|
||||||
|
for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFLA_ADDRESS:
|
||||||
|
case IFLA_BROADCAST:
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(AF_PACKET, l_rtaDataSize));
|
||||||
|
break;
|
||||||
|
case IFLA_IFNAME:
|
||||||
|
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1);
|
||||||
|
break;
|
||||||
|
case IFLA_STATS:
|
||||||
|
l_dataSize += NLMSG_ALIGN(l_rtaSize);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + sizeof(int) + l_nameSize + l_addrSize + l_dataSize);
|
||||||
|
if (l_entry == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||||
|
l_entry->ifa_name = "";
|
||||||
|
|
||||||
|
char *l_index = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||||
|
char *l_name = l_index + sizeof(int);
|
||||||
|
char *l_addr = l_name + l_nameSize;
|
||||||
|
char *l_data = l_addr + l_addrSize;
|
||||||
|
|
||||||
|
// save the interface index so we can look it up when handling the addresses.
|
||||||
|
memcpy(l_index, &l_info->ifi_index, sizeof(int));
|
||||||
|
|
||||||
|
l_entry->ifa_flags = l_info->ifi_flags;
|
||||||
|
|
||||||
|
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifinfomsg));
|
||||||
|
for(l_rta = IFLA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFLA_ADDRESS:
|
||||||
|
case IFLA_BROADCAST:
|
||||||
|
{
|
||||||
|
size_t l_addrLen = calcAddrLen(AF_PACKET, l_rtaDataSize);
|
||||||
|
makeSockaddr(AF_PACKET, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize);
|
||||||
|
((struct sockaddr_ll *)l_addr)->sll_ifindex = l_info->ifi_index;
|
||||||
|
((struct sockaddr_ll *)l_addr)->sll_hatype = l_info->ifi_type;
|
||||||
|
if(l_rta->rta_type == IFLA_ADDRESS)
|
||||||
|
{
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
l_addr += NLMSG_ALIGN(l_addrLen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IFLA_IFNAME:
|
||||||
|
strncpy(l_name, l_rtaData, l_rtaDataSize);
|
||||||
|
l_name[l_rtaDataSize] = '\0';
|
||||||
|
l_entry->ifa_name = l_name;
|
||||||
|
break;
|
||||||
|
case IFLA_STATS:
|
||||||
|
memcpy(l_data, l_rtaData, l_rtaDataSize);
|
||||||
|
l_entry->ifa_data = l_data;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addToEnd(p_resultList, l_entry);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ifaddrs *findInterface(int p_index, struct ifaddrs **p_links, int p_numLinks)
|
||||||
|
{
|
||||||
|
int l_num = 0;
|
||||||
|
struct ifaddrs *l_cur = *p_links;
|
||||||
|
while(l_cur && l_num < p_numLinks)
|
||||||
|
{
|
||||||
|
char *l_indexPtr = ((char *)l_cur) + sizeof(struct ifaddrs);
|
||||||
|
int l_index;
|
||||||
|
memcpy(&l_index, l_indexPtr, sizeof(int));
|
||||||
|
if(l_index == p_index)
|
||||||
|
{
|
||||||
|
return l_cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_cur = l_cur->ifa_next;
|
||||||
|
++l_num;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int interpretAddr(struct nlmsghdr *p_hdr, struct ifaddrs **p_resultList, int p_numLinks)
|
||||||
|
{
|
||||||
|
struct ifaddrmsg *l_info = (struct ifaddrmsg *)NLMSG_DATA(p_hdr);
|
||||||
|
struct ifaddrs *l_interface = findInterface(l_info->ifa_index, p_resultList, p_numLinks);
|
||||||
|
|
||||||
|
if(l_info->ifa_family == AF_PACKET)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t l_nameSize = 0;
|
||||||
|
size_t l_addrSize = 0;
|
||||||
|
|
||||||
|
int l_addedNetmask = 0;
|
||||||
|
|
||||||
|
size_t l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
|
||||||
|
struct rtattr *l_rta;
|
||||||
|
for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFA_ADDRESS:
|
||||||
|
case IFA_LOCAL:
|
||||||
|
if((l_info->ifa_family == AF_INET || l_info->ifa_family == AF_INET6) && !l_addedNetmask)
|
||||||
|
{ // make room for netmask
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize));
|
||||||
|
l_addedNetmask = 1;
|
||||||
|
}
|
||||||
|
case IFA_BROADCAST:
|
||||||
|
l_addrSize += NLMSG_ALIGN(calcAddrLen(l_info->ifa_family, l_rtaDataSize));
|
||||||
|
break;
|
||||||
|
case IFA_LABEL:
|
||||||
|
l_nameSize += NLMSG_ALIGN(l_rtaSize + 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct ifaddrs *l_entry = malloc(sizeof(struct ifaddrs) + l_nameSize + l_addrSize);
|
||||||
|
if (l_entry == NULL)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memset(l_entry, 0, sizeof(struct ifaddrs));
|
||||||
|
l_entry->ifa_name = (l_interface ? l_interface->ifa_name : "");
|
||||||
|
|
||||||
|
char *l_name = ((char *)l_entry) + sizeof(struct ifaddrs);
|
||||||
|
char *l_addr = l_name + l_nameSize;
|
||||||
|
|
||||||
|
l_entry->ifa_flags = l_info->ifa_flags;
|
||||||
|
if(l_interface)
|
||||||
|
{
|
||||||
|
l_entry->ifa_flags |= l_interface->ifa_flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
l_rtaSize = NLMSG_PAYLOAD(p_hdr, sizeof(struct ifaddrmsg));
|
||||||
|
for(l_rta = IFA_RTA(l_info); RTA_OK(l_rta, l_rtaSize); l_rta = RTA_NEXT(l_rta, l_rtaSize))
|
||||||
|
{
|
||||||
|
void *l_rtaData = RTA_DATA(l_rta);
|
||||||
|
size_t l_rtaDataSize = RTA_PAYLOAD(l_rta);
|
||||||
|
switch(l_rta->rta_type)
|
||||||
|
{
|
||||||
|
case IFA_ADDRESS:
|
||||||
|
case IFA_BROADCAST:
|
||||||
|
case IFA_LOCAL:
|
||||||
|
{
|
||||||
|
size_t l_addrLen = calcAddrLen(l_info->ifa_family, l_rtaDataSize);
|
||||||
|
makeSockaddr(l_info->ifa_family, (struct sockaddr *)l_addr, l_rtaData, l_rtaDataSize);
|
||||||
|
if(l_info->ifa_family == AF_INET6)
|
||||||
|
{
|
||||||
|
if(IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)l_rtaData) || IN6_IS_ADDR_MC_LINKLOCAL((struct in6_addr *)l_rtaData))
|
||||||
|
{
|
||||||
|
((struct sockaddr_in6 *)l_addr)->sin6_scope_id = l_info->ifa_index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_rta->rta_type == IFA_ADDRESS)
|
||||||
|
{ // apparently in a point-to-point network IFA_ADDRESS contains the dest address and IFA_LOCAL contains the local address
|
||||||
|
if(l_entry->ifa_addr)
|
||||||
|
{
|
||||||
|
l_entry->ifa_dstaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(l_rta->rta_type == IFA_LOCAL)
|
||||||
|
{
|
||||||
|
if(l_entry->ifa_addr)
|
||||||
|
{
|
||||||
|
l_entry->ifa_dstaddr = l_entry->ifa_addr;
|
||||||
|
}
|
||||||
|
l_entry->ifa_addr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l_entry->ifa_broadaddr = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
l_addr += NLMSG_ALIGN(l_addrLen);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IFA_LABEL:
|
||||||
|
strncpy(l_name, l_rtaData, l_rtaDataSize);
|
||||||
|
l_name[l_rtaDataSize] = '\0';
|
||||||
|
l_entry->ifa_name = l_name;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_entry->ifa_addr && (l_entry->ifa_addr->sa_family == AF_INET || l_entry->ifa_addr->sa_family == AF_INET6))
|
||||||
|
{
|
||||||
|
unsigned l_maxPrefix = (l_entry->ifa_addr->sa_family == AF_INET ? 32 : 128);
|
||||||
|
unsigned l_prefix = (l_info->ifa_prefixlen > l_maxPrefix ? l_maxPrefix : l_info->ifa_prefixlen);
|
||||||
|
char l_mask[16] = {0};
|
||||||
|
unsigned i;
|
||||||
|
for(i=0; i<(l_prefix/8); ++i)
|
||||||
|
{
|
||||||
|
l_mask[i] = 0xff;
|
||||||
|
}
|
||||||
|
if(l_prefix % 8)
|
||||||
|
{
|
||||||
|
l_mask[i] = 0xff << (8 - (l_prefix % 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
makeSockaddr(l_entry->ifa_addr->sa_family, (struct sockaddr *)l_addr, l_mask, l_maxPrefix / 8);
|
||||||
|
l_entry->ifa_netmask = (struct sockaddr *)l_addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
addToEnd(p_resultList, l_entry);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int interpretLinks(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList)
|
||||||
|
{
|
||||||
|
int l_numLinks = 0;
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
|
||||||
|
{
|
||||||
|
unsigned int l_nlsize = p_netlinkList->m_size;
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == RTM_NEWLINK)
|
||||||
|
{
|
||||||
|
if(interpretLink(l_hdr, p_resultList) == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
++l_numLinks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return l_numLinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int interpretAddrs(int p_socket, NetlinkList *p_netlinkList, struct ifaddrs **p_resultList, int p_numLinks)
|
||||||
|
{
|
||||||
|
pid_t l_pid = getpid();
|
||||||
|
for(; p_netlinkList; p_netlinkList = p_netlinkList->m_next)
|
||||||
|
{
|
||||||
|
unsigned int l_nlsize = p_netlinkList->m_size;
|
||||||
|
struct nlmsghdr *l_hdr;
|
||||||
|
for(l_hdr = p_netlinkList->m_data; NLMSG_OK(l_hdr, l_nlsize); l_hdr = NLMSG_NEXT(l_hdr, l_nlsize))
|
||||||
|
{
|
||||||
|
if((pid_t)l_hdr->nlmsg_pid != l_pid || (int)l_hdr->nlmsg_seq != p_socket)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == NLMSG_DONE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l_hdr->nlmsg_type == RTM_NEWADDR)
|
||||||
|
{
|
||||||
|
if (interpretAddr(l_hdr, p_resultList, p_numLinks) == -1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getifaddrs(struct ifaddrs **ifap)
|
||||||
|
{
|
||||||
|
if(!ifap)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
*ifap = NULL;
|
||||||
|
|
||||||
|
int l_socket = netlink_socket();
|
||||||
|
if(l_socket < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_linkResults = getResultList(l_socket, RTM_GETLINK);
|
||||||
|
if(!l_linkResults)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NetlinkList *l_addrResults = getResultList(l_socket, RTM_GETADDR);
|
||||||
|
if(!l_addrResults)
|
||||||
|
{
|
||||||
|
close(l_socket);
|
||||||
|
freeResultList(l_linkResults);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int l_result = 0;
|
||||||
|
int l_numLinks = interpretLinks(l_socket, l_linkResults, ifap);
|
||||||
|
if(l_numLinks == -1 || interpretAddrs(l_socket, l_addrResults, ifap, l_numLinks) == -1)
|
||||||
|
{
|
||||||
|
l_result = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
freeResultList(l_linkResults);
|
||||||
|
freeResultList(l_addrResults);
|
||||||
|
close(l_socket);
|
||||||
|
return l_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void freeifaddrs(struct ifaddrs *ifa)
|
||||||
|
{
|
||||||
|
struct ifaddrs *l_cur;
|
||||||
|
while(ifa)
|
||||||
|
{
|
||||||
|
l_cur = ifa;
|
||||||
|
ifa = ifa->ifa_next;
|
||||||
|
free(l_cur);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,106 +1,106 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat.c).
|
* The following license statement only applies to this file (compat.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
#undef strcasecmp
|
#undef strcasecmp
|
||||||
#undef strdup
|
#undef strdup
|
||||||
#undef isblank
|
#undef isblank
|
||||||
#undef strtok_r
|
#undef strtok_r
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
int retro_strcasecmp__(const char *a, const char *b)
|
int retro_strcasecmp__(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
while (*a && *b)
|
while (*a && *b)
|
||||||
{
|
{
|
||||||
int a_ = tolower(*a);
|
int a_ = tolower(*a);
|
||||||
int b_ = tolower(*b);
|
int b_ = tolower(*b);
|
||||||
|
|
||||||
if (a_ != b_)
|
if (a_ != b_)
|
||||||
return a_ - b_;
|
return a_ - b_;
|
||||||
|
|
||||||
a++;
|
a++;
|
||||||
b++;
|
b++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tolower(*a) - tolower(*b);
|
return tolower(*a) - tolower(*b);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *retro_strdup__(const char *orig)
|
char *retro_strdup__(const char *orig)
|
||||||
{
|
{
|
||||||
size_t len = strlen(orig) + 1;
|
size_t len = strlen(orig) + 1;
|
||||||
char *ret = (char*)malloc(len);
|
char *ret = (char*)malloc(len);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
strlcpy(ret, orig, len);
|
strlcpy(ret, orig, len);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int retro_isblank__(int c)
|
int retro_isblank__(int c)
|
||||||
{
|
{
|
||||||
return (c == ' ') || (c == '\t');
|
return (c == ' ') || (c == '\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
char *retro_strtok_r__(char *str, const char *delim, char **saveptr)
|
char *retro_strtok_r__(char *str, const char *delim, char **saveptr)
|
||||||
{
|
{
|
||||||
char *first = NULL;
|
char *first = NULL;
|
||||||
if (!saveptr || !delim)
|
if (!saveptr || !delim)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (str)
|
if (str)
|
||||||
*saveptr = str;
|
*saveptr = str;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
first = *saveptr;
|
first = *saveptr;
|
||||||
while (*first && strchr(delim, *first))
|
while (*first && strchr(delim, *first))
|
||||||
*first++ = '\0';
|
*first++ = '\0';
|
||||||
|
|
||||||
if (*first == '\0')
|
if (*first == '\0')
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr = first + 1;
|
ptr = first + 1;
|
||||||
|
|
||||||
while (*ptr && !strchr(delim, *ptr))
|
while (*ptr && !strchr(delim, *ptr))
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
*saveptr = ptr + (*ptr ? 1 : 0);
|
*saveptr = ptr + (*ptr ? 1 : 0);
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
} while (strlen(first) == 0);
|
} while (strlen(first) == 0);
|
||||||
|
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,53 +1,53 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_snprintf.c).
|
* The following license statement only applies to this file (compat_snprintf.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* THIS FILE HAS NOT BEEN VALIDATED ON PLATFORMS BESIDES MSVC */
|
/* THIS FILE HAS NOT BEEN VALIDATED ON PLATFORMS BESIDES MSVC */
|
||||||
|
|
||||||
#include <retro_common.h>
|
#include <retro_common.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
|
/* http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010 */
|
||||||
|
|
||||||
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap)
|
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap)
|
||||||
{
|
{
|
||||||
int count = -1;
|
int count = -1;
|
||||||
|
|
||||||
if (size != 0)
|
if (size != 0)
|
||||||
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
||||||
if (count == -1)
|
if (count == -1)
|
||||||
count = _vscprintf(format, ap);
|
count = _vscprintf(format, ap);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...)
|
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
count = c99_vsnprintf_retro__(outBuf, size, format, ap);
|
count = c99_vsnprintf_retro__(outBuf, size, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
|
@ -1,59 +1,59 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_strcasestr.c).
|
* The following license statement only applies to this file (compat_strcasestr.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <compat/strcasestr.h>
|
#include <compat/strcasestr.h>
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
/* Pretty much strncasecmp. */
|
/* Pretty much strncasecmp. */
|
||||||
static int casencmp(const char *a, const char *b, size_t n)
|
static int casencmp(const char *a, const char *b, size_t n)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
int a_lower = tolower(a[i]);
|
int a_lower = tolower(a[i]);
|
||||||
int b_lower = tolower(b[i]);
|
int b_lower = tolower(b[i]);
|
||||||
if (a_lower != b_lower)
|
if (a_lower != b_lower)
|
||||||
return a_lower - b_lower;
|
return a_lower - b_lower;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *strcasestr_retro__(const char *haystack, const char *needle)
|
char *strcasestr_retro__(const char *haystack, const char *needle)
|
||||||
{
|
{
|
||||||
size_t i, hay_len, needle_len, search_off;
|
size_t i, hay_len, needle_len, search_off;
|
||||||
|
|
||||||
hay_len = strlen(haystack);
|
hay_len = strlen(haystack);
|
||||||
needle_len = strlen(needle);
|
needle_len = strlen(needle);
|
||||||
if (needle_len > hay_len)
|
if (needle_len > hay_len)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
search_off = hay_len - needle_len;
|
search_off = hay_len - needle_len;
|
||||||
for (i = 0; i <= search_off; i++)
|
for (i = 0; i <= search_off; i++)
|
||||||
if (!casencmp(haystack + i, needle, needle_len))
|
if (!casencmp(haystack + i, needle, needle_len))
|
||||||
return (char*)haystack + i;
|
return (char*)haystack + i;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +1,61 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_strl.c).
|
* The following license statement only applies to this file (compat_strl.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
|
|
||||||
#include <retro_assert.h>
|
#include <retro_assert.h>
|
||||||
|
|
||||||
/* Implementation of strlcpy()/strlcat() based on OpenBSD. */
|
/* Implementation of strlcpy()/strlcat() based on OpenBSD. */
|
||||||
|
|
||||||
size_t strlcpy(char *dest, const char *source, size_t size)
|
size_t strlcpy(char *dest, const char *source, size_t size)
|
||||||
{
|
{
|
||||||
size_t src_size = 0;
|
size_t src_size = 0;
|
||||||
size_t n = size;
|
size_t n = size;
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
while (--n && (*dest++ = *source++)) src_size++;
|
while (--n && (*dest++ = *source++)) src_size++;
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
{
|
{
|
||||||
if (size) *dest = '\0';
|
if (size) *dest = '\0';
|
||||||
while (*source++) src_size++;
|
while (*source++) src_size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return src_size;
|
return src_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t strlcat(char *dest, const char *source, size_t size)
|
size_t strlcat(char *dest, const char *source, size_t size)
|
||||||
{
|
{
|
||||||
size_t len = strlen(dest);
|
size_t len = strlen(dest);
|
||||||
|
|
||||||
dest += len;
|
dest += len;
|
||||||
|
|
||||||
if (len > size)
|
if (len > size)
|
||||||
size = 0;
|
size = 0;
|
||||||
else
|
else
|
||||||
size -= len;
|
size -= len;
|
||||||
|
|
||||||
return len + strlcpy(dest, source, size);
|
return len + strlcpy(dest, source, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#ifndef __LIBRETRO_SDK_CRT_STRING_H_
|
#ifndef __LIBRETRO_SDK_CRT_STRING_H_
|
||||||
#define __LIBRETRO_SDK_CRT_STRING_H_
|
#define __LIBRETRO_SDK_CRT_STRING_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void *memcpy(void *dst, const void *src, size_t len);
|
void *memcpy(void *dst, const void *src, size_t len);
|
||||||
|
|
||||||
void *memset(void *b, int c, size_t len);
|
void *memset(void *b, int c, size_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,34 +1,34 @@
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <cruntime.h>
|
#include <cruntime.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void *memset(void *dst, int val, size_t count)
|
void *memset(void *dst, int val, size_t count)
|
||||||
{
|
{
|
||||||
void *start = dst;
|
void *start = dst;
|
||||||
|
|
||||||
#if defined(_M_IA64) || defined (_M_AMD64) || defined(_M_ALPHA) || defined (_M_PPC)
|
#if defined(_M_IA64) || defined (_M_AMD64) || defined(_M_ALPHA) || defined (_M_PPC)
|
||||||
extern void RtlFillMemory(void *, size_t count, char);
|
extern void RtlFillMemory(void *, size_t count, char);
|
||||||
|
|
||||||
RtlFillMemory(dst, count, (char)val);
|
RtlFillMemory(dst, count, (char)val);
|
||||||
#else
|
#else
|
||||||
while (count--)
|
while (count--)
|
||||||
{
|
{
|
||||||
*(char*)dst = (char)val;
|
*(char*)dst = (char)val;
|
||||||
dst = (char*)dst + 1;
|
dst = (char*)dst + 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *memcpy(void *dst, const void *src, size_t len)
|
void *memcpy(void *dst, const void *src, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
((unsigned char *)dst)[i] = ((unsigned char *)src)[i];
|
((unsigned char *)dst)[i] = ((unsigned char *)src)[i];
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,150 +1,150 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (dylib.c).
|
* The following license statement only applies to this file (dylib.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <dynamic/dylib.h>
|
#include <dynamic/dylib.h>
|
||||||
|
|
||||||
#ifdef NEED_DYNAMIC
|
#ifdef NEED_DYNAMIC
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
static char last_dyn_error[512];
|
static char last_dyn_error[512];
|
||||||
|
|
||||||
static void set_dl_error(void)
|
static void set_dl_error(void)
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
|
|
||||||
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
|
if (FormatMessage(FORMAT_MESSAGE_IGNORE_INSERTS |
|
||||||
FORMAT_MESSAGE_FROM_SYSTEM,
|
FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL,
|
NULL,
|
||||||
err,
|
err,
|
||||||
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
|
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
|
||||||
last_dyn_error,
|
last_dyn_error,
|
||||||
sizeof(last_dyn_error) - 1,
|
sizeof(last_dyn_error) - 1,
|
||||||
NULL) == 0)
|
NULL) == 0)
|
||||||
snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
|
snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
|
||||||
"unknown error %lu", err);
|
"unknown error %lu", err);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dylib_load:
|
* dylib_load:
|
||||||
* @path : Path to libretro core library.
|
* @path : Path to libretro core library.
|
||||||
*
|
*
|
||||||
* Platform independent dylib loading.
|
* Platform independent dylib loading.
|
||||||
*
|
*
|
||||||
* Returns: library handle on success, otherwise NULL.
|
* Returns: library handle on success, otherwise NULL.
|
||||||
**/
|
**/
|
||||||
dylib_t dylib_load(const char *path)
|
dylib_t dylib_load(const char *path)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
int prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
int prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
||||||
dylib_t lib = LoadLibrary(path);
|
dylib_t lib = LoadLibrary(path);
|
||||||
|
|
||||||
SetErrorMode(prevmode);
|
SetErrorMode(prevmode);
|
||||||
|
|
||||||
if (!lib)
|
if (!lib)
|
||||||
{
|
{
|
||||||
set_dl_error();
|
set_dl_error();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
last_dyn_error[0] = 0;
|
last_dyn_error[0] = 0;
|
||||||
#else
|
#else
|
||||||
dylib_t lib = dlopen(path, RTLD_LAZY);
|
dylib_t lib = dlopen(path, RTLD_LAZY);
|
||||||
#endif
|
#endif
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *dylib_error(void)
|
char *dylib_error(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (last_dyn_error[0])
|
if (last_dyn_error[0])
|
||||||
return last_dyn_error;
|
return last_dyn_error;
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
return (char*)dlerror();
|
return (char*)dlerror();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
function_t dylib_proc(dylib_t lib, const char *proc)
|
function_t dylib_proc(dylib_t lib, const char *proc)
|
||||||
{
|
{
|
||||||
function_t sym;
|
function_t sym;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
sym = (function_t)GetProcAddress(lib ?
|
sym = (function_t)GetProcAddress(lib ?
|
||||||
(HMODULE)lib : GetModuleHandle(NULL), proc);
|
(HMODULE)lib : GetModuleHandle(NULL), proc);
|
||||||
if (!sym)
|
if (!sym)
|
||||||
{
|
{
|
||||||
set_dl_error();
|
set_dl_error();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
last_dyn_error[0] = 0;
|
last_dyn_error[0] = 0;
|
||||||
#else
|
#else
|
||||||
void *ptr_sym = NULL;
|
void *ptr_sym = NULL;
|
||||||
|
|
||||||
if (lib)
|
if (lib)
|
||||||
ptr_sym = dlsym(lib, proc);
|
ptr_sym = dlsym(lib, proc);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
void *handle = dlopen(NULL, RTLD_LAZY);
|
void *handle = dlopen(NULL, RTLD_LAZY);
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
ptr_sym = dlsym(handle, proc);
|
ptr_sym = dlsym(handle, proc);
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dirty hack to workaround the non-legality of
|
/* Dirty hack to workaround the non-legality of
|
||||||
* (void*) -> fn-pointer casts. */
|
* (void*) -> fn-pointer casts. */
|
||||||
memcpy(&sym, &ptr_sym, sizeof(void*));
|
memcpy(&sym, &ptr_sym, sizeof(void*));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dylib_close:
|
* dylib_close:
|
||||||
* @lib : Library handle.
|
* @lib : Library handle.
|
||||||
*
|
*
|
||||||
* Frees library handle.
|
* Frees library handle.
|
||||||
**/
|
**/
|
||||||
void dylib_close(dylib_t lib)
|
void dylib_close(dylib_t lib)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!FreeLibrary((HMODULE)lib))
|
if (!FreeLibrary((HMODULE)lib))
|
||||||
set_dl_error();
|
set_dl_error();
|
||||||
last_dyn_error[0] = 0;
|
last_dyn_error[0] = 0;
|
||||||
#else
|
#else
|
||||||
#ifndef NO_DLCLOSE
|
#ifndef NO_DLCLOSE
|
||||||
dlclose(lib);
|
dlclose(lib);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,210 +1,210 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (encodings_utf.c).
|
* The following license statement only applies to this file (encodings_utf.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
static INLINE unsigned leading_ones(uint8_t c)
|
static INLINE unsigned leading_ones(uint8_t c)
|
||||||
{
|
{
|
||||||
unsigned ones = 0;
|
unsigned ones = 0;
|
||||||
while (c & 0x80)
|
while (c & 0x80)
|
||||||
{
|
{
|
||||||
ones++;
|
ones++;
|
||||||
c <<= 1;
|
c <<= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ones;
|
return ones;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Simple implementation. Assumes the sequence is
|
/* Simple implementation. Assumes the sequence is
|
||||||
* properly synchronized and terminated. */
|
* properly synchronized and terminated. */
|
||||||
|
|
||||||
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
||||||
const char *in, size_t in_size)
|
const char *in, size_t in_size)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
while (in_size && out_chars)
|
while (in_size && out_chars)
|
||||||
{
|
{
|
||||||
unsigned extra, shift;
|
unsigned extra, shift;
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
uint8_t first = *in++;
|
uint8_t first = *in++;
|
||||||
unsigned ones = leading_ones(first);
|
unsigned ones = leading_ones(first);
|
||||||
|
|
||||||
if (ones > 6 || ones == 1) /* Invalid or desync. */
|
if (ones > 6 || ones == 1) /* Invalid or desync. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
extra = ones ? ones - 1 : ones;
|
extra = ones ? ones - 1 : ones;
|
||||||
if (1 + extra > in_size) /* Overflow. */
|
if (1 + extra > in_size) /* Overflow. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
shift = (extra - 1) * 6;
|
shift = (extra - 1) * 6;
|
||||||
c = (first & ((1 << (7 - ones)) - 1)) << (6 * extra);
|
c = (first & ((1 << (7 - ones)) - 1)) << (6 * extra);
|
||||||
|
|
||||||
for (i = 0; i < extra; i++, in++, shift -= 6)
|
for (i = 0; i < extra; i++, in++, shift -= 6)
|
||||||
c |= (*in & 0x3f) << shift;
|
c |= (*in & 0x3f) << shift;
|
||||||
|
|
||||||
*out++ = c;
|
*out++ = c;
|
||||||
in_size -= 1 + extra;
|
in_size -= 1 + extra;
|
||||||
out_chars--;
|
out_chars--;
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
||||||
const uint16_t *in, size_t in_size)
|
const uint16_t *in, size_t in_size)
|
||||||
{
|
{
|
||||||
static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
static uint8_t kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
||||||
size_t out_pos = 0;
|
size_t out_pos = 0;
|
||||||
size_t in_pos = 0;
|
size_t in_pos = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
unsigned numAdds;
|
unsigned numAdds;
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
|
|
||||||
if (in_pos == in_size)
|
if (in_pos == in_size)
|
||||||
{
|
{
|
||||||
*out_chars = out_pos;
|
*out_chars = out_pos;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
value = in[in_pos++];
|
value = in[in_pos++];
|
||||||
if (value < 0x80)
|
if (value < 0x80)
|
||||||
{
|
{
|
||||||
if (out)
|
if (out)
|
||||||
out[out_pos] = (char)value;
|
out[out_pos] = (char)value;
|
||||||
out_pos++;
|
out_pos++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value >= 0xD800 && value < 0xE000)
|
if (value >= 0xD800 && value < 0xE000)
|
||||||
{
|
{
|
||||||
uint32_t c2;
|
uint32_t c2;
|
||||||
|
|
||||||
if (value >= 0xDC00 || in_pos == in_size)
|
if (value >= 0xDC00 || in_pos == in_size)
|
||||||
break;
|
break;
|
||||||
c2 = in[in_pos++];
|
c2 = in[in_pos++];
|
||||||
if (c2 < 0xDC00 || c2 >= 0xE000)
|
if (c2 < 0xDC00 || c2 >= 0xE000)
|
||||||
break;
|
break;
|
||||||
value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
|
value = (((value - 0xD800) << 10) | (c2 - 0xDC00)) + 0x10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (numAdds = 1; numAdds < 5; numAdds++)
|
for (numAdds = 1; numAdds < 5; numAdds++)
|
||||||
if (value < (((uint32_t)1) << (numAdds * 5 + 6)))
|
if (value < (((uint32_t)1) << (numAdds * 5 + 6)))
|
||||||
break;
|
break;
|
||||||
if (out)
|
if (out)
|
||||||
out[out_pos] = (char)(kUtf8Limits[numAdds - 1]
|
out[out_pos] = (char)(kUtf8Limits[numAdds - 1]
|
||||||
+ (value >> (6 * numAdds)));
|
+ (value >> (6 * numAdds)));
|
||||||
out_pos++;
|
out_pos++;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
numAdds--;
|
numAdds--;
|
||||||
if (out)
|
if (out)
|
||||||
out[out_pos] = (char)(0x80
|
out[out_pos] = (char)(0x80
|
||||||
+ ((value >> (6 * numAdds)) & 0x3F));
|
+ ((value >> (6 * numAdds)) & 0x3F));
|
||||||
out_pos++;
|
out_pos++;
|
||||||
}while (numAdds != 0);
|
}while (numAdds != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
*out_chars = out_pos;
|
*out_chars = out_pos;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Acts mostly like strlcpy.
|
/* Acts mostly like strlcpy.
|
||||||
*
|
*
|
||||||
* Copies the given number of UTF-8 characters,
|
* Copies the given number of UTF-8 characters,
|
||||||
* but at most d_len bytes.
|
* but at most d_len bytes.
|
||||||
*
|
*
|
||||||
* Always NULL terminates.
|
* Always NULL terminates.
|
||||||
* Does not copy half a character.
|
* Does not copy half a character.
|
||||||
*
|
*
|
||||||
* Returns number of bytes. 's' is assumed valid UTF-8.
|
* Returns number of bytes. 's' is assumed valid UTF-8.
|
||||||
* Use only if 'chars' is considerably less than 'd_len'. */
|
* Use only if 'chars' is considerably less than 'd_len'. */
|
||||||
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
|
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_UTF8
|
#ifdef HAVE_UTF8
|
||||||
char *d_org = d;
|
char *d_org = d;
|
||||||
char *d_end = d+d_len;
|
char *d_end = d+d_len;
|
||||||
const uint8_t *sb = (const uint8_t*)s;
|
const uint8_t *sb = (const uint8_t*)s;
|
||||||
const uint8_t *sb_org = sb;
|
const uint8_t *sb_org = sb;
|
||||||
|
|
||||||
while (*sb && chars-- > 0)
|
while (*sb && chars-- > 0)
|
||||||
{
|
{
|
||||||
sb++;
|
sb++;
|
||||||
while ((*sb&0xC0) == 0x80) sb++;
|
while ((*sb&0xC0) == 0x80) sb++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sb - sb_org > d_len-1 /* NUL */)
|
if (sb - sb_org > d_len-1 /* NUL */)
|
||||||
{
|
{
|
||||||
sb = sb_org + d_len-1;
|
sb = sb_org + d_len-1;
|
||||||
while ((*sb&0xC0) == 0x80) sb--;
|
while ((*sb&0xC0) == 0x80) sb--;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(d, sb_org, sb-sb_org);
|
memcpy(d, sb_org, sb-sb_org);
|
||||||
d[sb-sb_org] = '\0';
|
d[sb-sb_org] = '\0';
|
||||||
|
|
||||||
return sb-sb_org;
|
return sb-sb_org;
|
||||||
#else
|
#else
|
||||||
return strlcpy(d, s, chars + 1);
|
return strlcpy(d, s, chars + 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *utf8skip(const char *str, size_t chars)
|
const char *utf8skip(const char *str, size_t chars)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_UTF8
|
#ifdef HAVE_UTF8
|
||||||
const uint8_t *strb = (const uint8_t*)str;
|
const uint8_t *strb = (const uint8_t*)str;
|
||||||
if (!chars)
|
if (!chars)
|
||||||
return str;
|
return str;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
strb++;
|
strb++;
|
||||||
while ((*strb&0xC0)==0x80) strb++;
|
while ((*strb&0xC0)==0x80) strb++;
|
||||||
chars--;
|
chars--;
|
||||||
} while(chars);
|
} while(chars);
|
||||||
return (const char*)strb;
|
return (const char*)strb;
|
||||||
#else
|
#else
|
||||||
return str + chars;
|
return str + chars;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t utf8len(const char *string)
|
size_t utf8len(const char *string)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_UTF8
|
#ifdef HAVE_UTF8
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
while (*string)
|
while (*string)
|
||||||
{
|
{
|
||||||
if ((*string & 0xC0) != 0x80)
|
if ((*string & 0xC0) != 0x80)
|
||||||
ret++;
|
ret++;
|
||||||
string++;
|
string++;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
return strlen(string);
|
return strlen(string);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,213 +1,213 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (file_archive_zlib.c).
|
* The following license statement only applies to this file (archive_file_zlib.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <compat/zlib.h>
|
#include <compat/zlib.h>
|
||||||
#include <file/file_archive.h>
|
#include <file/archive_file.h>
|
||||||
#include <retro_file.h>
|
#include <streams/file_stream.h>
|
||||||
|
|
||||||
static void *zlib_stream_new(void)
|
static void *zlib_stream_new(void)
|
||||||
{
|
{
|
||||||
return (z_stream*)calloc(1, sizeof(z_stream));
|
return (z_stream*)calloc(1, sizeof(z_stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zlib_stream_free(void *data)
|
static void zlib_stream_free(void *data)
|
||||||
{
|
{
|
||||||
z_stream *ret = (z_stream*)data;
|
z_stream *ret = (z_stream*)data;
|
||||||
if (ret)
|
if (ret)
|
||||||
inflateEnd(ret);
|
inflateEnd(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zlib_stream_set(void *data,
|
static void zlib_stream_set(void *data,
|
||||||
uint32_t avail_in,
|
uint32_t avail_in,
|
||||||
uint32_t avail_out,
|
uint32_t avail_out,
|
||||||
const uint8_t *next_in,
|
const uint8_t *next_in,
|
||||||
uint8_t *next_out
|
uint8_t *next_out
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
stream->avail_in = avail_in;
|
stream->avail_in = avail_in;
|
||||||
stream->avail_out = avail_out;
|
stream->avail_out = avail_out;
|
||||||
|
|
||||||
stream->next_in = (uint8_t*)next_in;
|
stream->next_in = (uint8_t*)next_in;
|
||||||
stream->next_out = next_out;
|
stream->next_out = next_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t zlib_stream_get_avail_in(void *data)
|
static uint32_t zlib_stream_get_avail_in(void *data)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return stream->avail_in;
|
return stream->avail_in;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t zlib_stream_get_avail_out(void *data)
|
static uint32_t zlib_stream_get_avail_out(void *data)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return stream->avail_out;
|
return stream->avail_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t zlib_stream_get_total_out(void *data)
|
static uint64_t zlib_stream_get_total_out(void *data)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return stream->total_out;
|
return stream->total_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zlib_stream_decrement_total_out(void *data, unsigned subtraction)
|
static void zlib_stream_decrement_total_out(void *data, unsigned subtraction)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
stream->total_out -= subtraction;
|
stream->total_out -= subtraction;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zlib_stream_compress_free(void *data)
|
static void zlib_stream_compress_free(void *data)
|
||||||
{
|
{
|
||||||
z_stream *ret = (z_stream*)data;
|
z_stream *ret = (z_stream*)data;
|
||||||
if (ret)
|
if (ret)
|
||||||
deflateEnd(ret);
|
deflateEnd(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zlib_stream_compress_data_to_file(void *data)
|
static int zlib_stream_compress_data_to_file(void *data)
|
||||||
{
|
{
|
||||||
int zstatus;
|
int zstatus;
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
zstatus = deflate(stream, Z_FINISH);
|
zstatus = deflate(stream, Z_FINISH);
|
||||||
|
|
||||||
if (zstatus == Z_STREAM_END)
|
if (zstatus == Z_STREAM_END)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool zlib_stream_decompress_init(void *data)
|
static bool zlib_stream_decompress_init(void *data)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return false;
|
return false;
|
||||||
if (inflateInit(stream) != Z_OK)
|
if (inflateInit(stream) != Z_OK)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool zlib_stream_decompress_data_to_file_init(
|
static bool zlib_stream_decompress_data_to_file_init(
|
||||||
file_archive_file_handle_t *handle,
|
file_archive_file_handle_t *handle,
|
||||||
const uint8_t *cdata, uint32_t csize, uint32_t size)
|
const uint8_t *cdata, uint32_t csize, uint32_t size)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!(handle->stream = (z_stream*)zlib_stream_new()))
|
if (!(handle->stream = (z_stream*)zlib_stream_new()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (inflateInit2((z_streamp)handle->stream, -MAX_WBITS) != Z_OK)
|
if (inflateInit2((z_streamp)handle->stream, -MAX_WBITS) != Z_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
handle->data = (uint8_t*)malloc(size);
|
handle->data = (uint8_t*)malloc(size);
|
||||||
|
|
||||||
if (!handle->data)
|
if (!handle->data)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
zlib_stream_set(handle->stream, csize, size,
|
zlib_stream_set(handle->stream, csize, size,
|
||||||
(const uint8_t*)cdata, handle->data);
|
(const uint8_t*)cdata, handle->data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
zlib_stream_free(handle->stream);
|
zlib_stream_free(handle->stream);
|
||||||
free(handle->stream);
|
free(handle->stream);
|
||||||
if (handle->data)
|
if (handle->data)
|
||||||
free(handle->data);
|
free(handle->data);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int zlib_stream_decompress_data_to_file_iterate(void *data)
|
static int zlib_stream_decompress_data_to_file_iterate(void *data)
|
||||||
{
|
{
|
||||||
int zstatus;
|
int zstatus;
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
zstatus = inflate(stream, Z_NO_FLUSH);
|
zstatus = inflate(stream, Z_NO_FLUSH);
|
||||||
|
|
||||||
if (zstatus == Z_STREAM_END)
|
if (zstatus == Z_STREAM_END)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (zstatus != Z_OK && zstatus != Z_BUF_ERROR)
|
if (zstatus != Z_OK && zstatus != Z_BUF_ERROR)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zlib_stream_compress_init(void *data, int level)
|
static void zlib_stream_compress_init(void *data, int level)
|
||||||
{
|
{
|
||||||
z_stream *stream = (z_stream*)data;
|
z_stream *stream = (z_stream*)data;
|
||||||
|
|
||||||
if (stream)
|
if (stream)
|
||||||
deflateInit(stream, level);
|
deflateInit(stream, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t zlib_stream_crc32_calculate(uint32_t crc,
|
static uint32_t zlib_stream_crc32_calculate(uint32_t crc,
|
||||||
const uint8_t *data, size_t length)
|
const uint8_t *data, size_t length)
|
||||||
{
|
{
|
||||||
return crc32(crc, data, length);
|
return crc32(crc, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct file_archive_file_backend zlib_backend = {
|
const struct file_archive_file_backend zlib_backend = {
|
||||||
zlib_stream_new,
|
zlib_stream_new,
|
||||||
zlib_stream_free,
|
zlib_stream_free,
|
||||||
zlib_stream_set,
|
zlib_stream_set,
|
||||||
zlib_stream_get_avail_in,
|
zlib_stream_get_avail_in,
|
||||||
zlib_stream_get_avail_out,
|
zlib_stream_get_avail_out,
|
||||||
zlib_stream_get_total_out,
|
zlib_stream_get_total_out,
|
||||||
zlib_stream_decrement_total_out,
|
zlib_stream_decrement_total_out,
|
||||||
zlib_stream_decompress_init,
|
zlib_stream_decompress_init,
|
||||||
zlib_stream_decompress_data_to_file_init,
|
zlib_stream_decompress_data_to_file_init,
|
||||||
zlib_stream_decompress_data_to_file_iterate,
|
zlib_stream_decompress_data_to_file_iterate,
|
||||||
zlib_stream_compress_init,
|
zlib_stream_compress_init,
|
||||||
zlib_stream_compress_free,
|
zlib_stream_compress_free,
|
||||||
zlib_stream_compress_data_to_file,
|
zlib_stream_compress_data_to_file,
|
||||||
zlib_stream_crc32_calculate,
|
zlib_stream_crc32_calculate,
|
||||||
"zlib"
|
"zlib"
|
||||||
};
|
};
|
File diff suppressed because it is too large
Load Diff
|
@ -1,128 +1,128 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (config_file_userdata.c).
|
* The following license statement only applies to this file (config_file_userdata.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <file/config_file_userdata.h>
|
#include <file/config_file_userdata.h>
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include <string/string_list.h>
|
#include <lists/string_list.h>
|
||||||
|
|
||||||
#define get_array_setup() \
|
#define get_array_setup() \
|
||||||
char key[2][256]; \
|
char key[2][256]; \
|
||||||
bool got; \
|
bool got; \
|
||||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata; \
|
struct config_file_userdata *usr = (struct config_file_userdata*)userdata; \
|
||||||
char *str = NULL; \
|
char *str = NULL; \
|
||||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); \
|
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0])); \
|
||||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); \
|
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1])); \
|
||||||
got = config_get_string(usr->conf, key[0], &str); \
|
got = config_get_string(usr->conf, key[0], &str); \
|
||||||
got = got || config_get_string(usr->conf, key[1], &str);
|
got = got || config_get_string(usr->conf, key[1], &str);
|
||||||
|
|
||||||
#define get_array_body(T) \
|
#define get_array_body(T) \
|
||||||
if (got) \
|
if (got) \
|
||||||
{ \
|
{ \
|
||||||
unsigned i; \
|
unsigned i; \
|
||||||
struct string_list *list = string_split(str, " "); \
|
struct string_list *list = string_split(str, " "); \
|
||||||
*values = (T*)calloc(list->size, sizeof(T)); \
|
*values = (T*)calloc(list->size, sizeof(T)); \
|
||||||
for (i = 0; i < list->size; i++) \
|
for (i = 0; i < list->size; i++) \
|
||||||
(*values)[i] = (T)strtod(list->elems[i].data, NULL); \
|
(*values)[i] = (T)strtod(list->elems[i].data, NULL); \
|
||||||
*out_num_values = list->size; \
|
*out_num_values = list->size; \
|
||||||
string_list_free(list); \
|
string_list_free(list); \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
*values = (T*)calloc(num_default_values, sizeof(T)); \
|
*values = (T*)calloc(num_default_values, sizeof(T)); \
|
||||||
memcpy(*values, default_values, sizeof(T) * num_default_values); \
|
memcpy(*values, default_values, sizeof(T) * num_default_values); \
|
||||||
*out_num_values = num_default_values; \
|
*out_num_values = num_default_values; \
|
||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_userdata_get_float(void *userdata, const char *key_str,
|
int config_userdata_get_float(void *userdata, const char *key_str,
|
||||||
float *value, float default_value)
|
float *value, float default_value)
|
||||||
{
|
{
|
||||||
bool got;
|
bool got;
|
||||||
char key[2][256];
|
char key[2][256];
|
||||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||||
|
|
||||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||||
|
|
||||||
got = config_get_float (usr->conf, key[0], value);
|
got = config_get_float (usr->conf, key[0], value);
|
||||||
got = got || config_get_float(usr->conf, key[1], value);
|
got = got || config_get_float(usr->conf, key[1], value);
|
||||||
|
|
||||||
if (!got)
|
if (!got)
|
||||||
*value = default_value;
|
*value = default_value;
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_userdata_get_int(void *userdata, const char *key_str,
|
int config_userdata_get_int(void *userdata, const char *key_str,
|
||||||
int *value, int default_value)
|
int *value, int default_value)
|
||||||
{
|
{
|
||||||
bool got;
|
bool got;
|
||||||
char key[2][256];
|
char key[2][256];
|
||||||
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
struct config_file_userdata *usr = (struct config_file_userdata*)userdata;
|
||||||
|
|
||||||
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
fill_pathname_join_delim(key[0], usr->prefix[0], key_str, '_', sizeof(key[0]));
|
||||||
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
fill_pathname_join_delim(key[1], usr->prefix[1], key_str, '_', sizeof(key[1]));
|
||||||
|
|
||||||
got = config_get_int (usr->conf, key[0], value);
|
got = config_get_int (usr->conf, key[0], value);
|
||||||
got = got || config_get_int(usr->conf, key[1], value);
|
got = got || config_get_int(usr->conf, key[1], value);
|
||||||
|
|
||||||
if (!got)
|
if (!got)
|
||||||
*value = default_value;
|
*value = default_value;
|
||||||
return got;
|
return got;
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_userdata_get_float_array(void *userdata, const char *key_str,
|
int config_userdata_get_float_array(void *userdata, const char *key_str,
|
||||||
float **values, unsigned *out_num_values,
|
float **values, unsigned *out_num_values,
|
||||||
const float *default_values, unsigned num_default_values)
|
const float *default_values, unsigned num_default_values)
|
||||||
{
|
{
|
||||||
get_array_setup()
|
get_array_setup()
|
||||||
get_array_body(float)
|
get_array_body(float)
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_userdata_get_int_array(void *userdata, const char *key_str,
|
int config_userdata_get_int_array(void *userdata, const char *key_str,
|
||||||
int **values, unsigned *out_num_values,
|
int **values, unsigned *out_num_values,
|
||||||
const int *default_values, unsigned num_default_values)
|
const int *default_values, unsigned num_default_values)
|
||||||
{
|
{
|
||||||
get_array_setup()
|
get_array_setup()
|
||||||
get_array_body(int)
|
get_array_body(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
int config_userdata_get_string(void *userdata, const char *key_str,
|
int config_userdata_get_string(void *userdata, const char *key_str,
|
||||||
char **output, const char *default_output)
|
char **output, const char *default_output)
|
||||||
{
|
{
|
||||||
get_array_setup()
|
get_array_setup()
|
||||||
|
|
||||||
if (got)
|
if (got)
|
||||||
{
|
{
|
||||||
*output = str;
|
*output = str;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
*output = strdup(default_output);
|
*output = strdup(default_output);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_userdata_free(void *ptr)
|
void config_userdata_free(void *ptr)
|
||||||
{
|
{
|
||||||
if (ptr)
|
if (ptr)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,206 +1,206 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <file/nbio.h>
|
#include <file/nbio.h>
|
||||||
|
|
||||||
struct nbio_t
|
struct nbio_t
|
||||||
{
|
{
|
||||||
FILE* f;
|
FILE* f;
|
||||||
void* data;
|
void* data;
|
||||||
size_t progress;
|
size_t progress;
|
||||||
size_t len;
|
size_t len;
|
||||||
/*
|
/*
|
||||||
* possible values:
|
* possible values:
|
||||||
* NBIO_READ, NBIO_WRITE - obvious
|
* NBIO_READ, NBIO_WRITE - obvious
|
||||||
* -1 - currently doing nothing
|
* -1 - currently doing nothing
|
||||||
* -2 - the pointer was reallocated since the last operation
|
* -2 - the pointer was reallocated since the last operation
|
||||||
*/
|
*/
|
||||||
signed char op;
|
signed char op;
|
||||||
signed char mode;
|
signed char mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char * modes[]={ "rb", "wb", "r+b", "rb", "wb", "r+b" };
|
static const char * modes[]={ "rb", "wb", "r+b", "rb", "wb", "r+b" };
|
||||||
|
|
||||||
struct nbio_t* nbio_open(const char * filename, unsigned mode)
|
struct nbio_t* nbio_open(const char * filename, unsigned mode)
|
||||||
{
|
{
|
||||||
struct nbio_t* handle = NULL;
|
struct nbio_t* handle = NULL;
|
||||||
FILE* f = fopen(filename, modes[mode]);
|
FILE* f = fopen(filename, modes[mode]);
|
||||||
if (!f)
|
if (!f)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
handle = (struct nbio_t*)malloc(sizeof(struct nbio_t));
|
handle = (struct nbio_t*)malloc(sizeof(struct nbio_t));
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
handle->f = f;
|
handle->f = f;
|
||||||
handle->len = 0;
|
handle->len = 0;
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case NBIO_WRITE:
|
case NBIO_WRITE:
|
||||||
case BIO_WRITE:
|
case BIO_WRITE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fseek(handle->f, 0, SEEK_END);
|
fseek(handle->f, 0, SEEK_END);
|
||||||
handle->len = ftell(handle->f);
|
handle->len = ftell(handle->f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->mode = mode;
|
handle->mode = mode;
|
||||||
handle->data = malloc(handle->len);
|
handle->data = malloc(handle->len);
|
||||||
|
|
||||||
if (handle->len && !handle->data)
|
if (handle->len && !handle->data)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
handle->progress = handle->len;
|
handle->progress = handle->len;
|
||||||
handle->op = -2;
|
handle->op = -2;
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (handle)
|
if (handle)
|
||||||
{
|
{
|
||||||
if (handle->data)
|
if (handle->data)
|
||||||
free(handle->data);
|
free(handle->data);
|
||||||
handle->data = NULL;
|
handle->data = NULL;
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbio_begin_read(struct nbio_t* handle)
|
void nbio_begin_read(struct nbio_t* handle)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (handle->op >= 0)
|
if (handle->op >= 0)
|
||||||
{
|
{
|
||||||
puts("ERROR - attempted file read operation while busy");
|
puts("ERROR - attempted file read operation while busy");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(handle->f, 0, SEEK_SET);
|
fseek(handle->f, 0, SEEK_SET);
|
||||||
|
|
||||||
handle->op = NBIO_READ;
|
handle->op = NBIO_READ;
|
||||||
handle->progress = 0;
|
handle->progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbio_begin_write(struct nbio_t* handle)
|
void nbio_begin_write(struct nbio_t* handle)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (handle->op >= 0)
|
if (handle->op >= 0)
|
||||||
{
|
{
|
||||||
puts("ERROR - attempted file write operation while busy");
|
puts("ERROR - attempted file write operation while busy");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(handle->f, 0, SEEK_SET);
|
fseek(handle->f, 0, SEEK_SET);
|
||||||
handle->op = NBIO_WRITE;
|
handle->op = NBIO_WRITE;
|
||||||
handle->progress = 0;
|
handle->progress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nbio_iterate(struct nbio_t* handle)
|
bool nbio_iterate(struct nbio_t* handle)
|
||||||
{
|
{
|
||||||
size_t amount = 65536;
|
size_t amount = 65536;
|
||||||
|
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (amount > handle->len - handle->progress)
|
if (amount > handle->len - handle->progress)
|
||||||
amount = handle->len - handle->progress;
|
amount = handle->len - handle->progress;
|
||||||
|
|
||||||
switch (handle->op)
|
switch (handle->op)
|
||||||
{
|
{
|
||||||
case NBIO_READ:
|
case NBIO_READ:
|
||||||
if (handle->mode == BIO_READ)
|
if (handle->mode == BIO_READ)
|
||||||
{
|
{
|
||||||
amount = handle->len;
|
amount = handle->len;
|
||||||
fread((char*)handle->data, 1, amount, handle->f);
|
fread((char*)handle->data, 1, amount, handle->f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fread((char*)handle->data + handle->progress, 1, amount, handle->f);
|
fread((char*)handle->data + handle->progress, 1, amount, handle->f);
|
||||||
break;
|
break;
|
||||||
case NBIO_WRITE:
|
case NBIO_WRITE:
|
||||||
if (handle->mode == BIO_WRITE)
|
if (handle->mode == BIO_WRITE)
|
||||||
{
|
{
|
||||||
size_t written = 0;
|
size_t written = 0;
|
||||||
amount = handle->len;
|
amount = handle->len;
|
||||||
written = fwrite((char*)handle->data, 1, amount, handle->f);
|
written = fwrite((char*)handle->data, 1, amount, handle->f);
|
||||||
if (written != amount)
|
if (written != amount)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fwrite((char*)handle->data + handle->progress, 1, amount, handle->f);
|
fwrite((char*)handle->data + handle->progress, 1, amount, handle->f);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->progress += amount;
|
handle->progress += amount;
|
||||||
|
|
||||||
if (handle->progress == handle->len)
|
if (handle->progress == handle->len)
|
||||||
handle->op = -1;
|
handle->op = -1;
|
||||||
return (handle->op < 0);
|
return (handle->op < 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbio_resize(struct nbio_t* handle, size_t len)
|
void nbio_resize(struct nbio_t* handle, size_t len)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (handle->op >= 0)
|
if (handle->op >= 0)
|
||||||
{
|
{
|
||||||
puts("ERROR - attempted file resize operation while busy");
|
puts("ERROR - attempted file resize operation while busy");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
if (len < handle->len)
|
if (len < handle->len)
|
||||||
{
|
{
|
||||||
puts("ERROR - attempted file shrink operation, not implemented");
|
puts("ERROR - attempted file shrink operation, not implemented");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
handle->len = len;
|
handle->len = len;
|
||||||
handle->data = realloc(handle->data, handle->len);
|
handle->data = realloc(handle->data, handle->len);
|
||||||
handle->op = -1;
|
handle->op = -1;
|
||||||
handle->progress = handle->len;
|
handle->progress = handle->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* nbio_get_ptr(struct nbio_t* handle, size_t* len)
|
void* nbio_get_ptr(struct nbio_t* handle, size_t* len)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (len)
|
if (len)
|
||||||
*len = handle->len;
|
*len = handle->len;
|
||||||
if (handle->op == -1)
|
if (handle->op == -1)
|
||||||
return handle->data;
|
return handle->data;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbio_cancel(struct nbio_t* handle)
|
void nbio_cancel(struct nbio_t* handle)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
handle->op = -1;
|
handle->op = -1;
|
||||||
handle->progress = handle->len;
|
handle->progress = handle->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nbio_free(struct nbio_t* handle)
|
void nbio_free(struct nbio_t* handle)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle)
|
||||||
return;
|
return;
|
||||||
if (handle->op >= 0)
|
if (handle->op >= 0)
|
||||||
{
|
{
|
||||||
puts("ERROR - attempted free() while busy");
|
puts("ERROR - attempted free() while busy");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
fclose(handle->f);
|
fclose(handle->f);
|
||||||
free(handle->data);
|
free(handle->data);
|
||||||
|
|
||||||
handle->f = NULL;
|
handle->f = NULL;
|
||||||
handle->data = NULL;
|
handle->data = NULL;
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <file/nbio.h>
|
#include <file/nbio.h>
|
||||||
|
|
||||||
static void nbio_write_test(void)
|
static void nbio_write_test(void)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
bool looped = false;
|
bool looped = false;
|
||||||
void* ptr = NULL;
|
void* ptr = NULL;
|
||||||
struct nbio_t* write = nbio_open("test.bin", NBIO_WRITE);
|
struct nbio_t* write = nbio_open("test.bin", NBIO_WRITE);
|
||||||
|
|
||||||
nbio_resize(write, 1024*1024);
|
nbio_resize(write, 1024*1024);
|
||||||
|
|
||||||
ptr = nbio_get_ptr(write, &size);
|
ptr = nbio_get_ptr(write, &size);
|
||||||
if (size != 1024*1024)
|
if (size != 1024*1024)
|
||||||
puts("ERROR: wrong size (1)");
|
puts("ERROR: wrong size (1)");
|
||||||
|
|
||||||
memset(ptr, 0x42, 1024*1024);
|
memset(ptr, 0x42, 1024*1024);
|
||||||
nbio_begin_write(write);
|
nbio_begin_write(write);
|
||||||
|
|
||||||
while (!nbio_iterate(write)) looped=true;
|
while (!nbio_iterate(write)) looped=true;
|
||||||
|
|
||||||
if (!looped)
|
if (!looped)
|
||||||
puts("Write finished immediately?");
|
puts("Write finished immediately?");
|
||||||
|
|
||||||
nbio_free(write);
|
nbio_free(write);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nbio_read_test(void)
|
static void nbio_read_test(void)
|
||||||
{
|
{
|
||||||
size_t size;
|
size_t size;
|
||||||
bool looped = false;
|
bool looped = false;
|
||||||
struct nbio_t* read = nbio_open("test.bin", NBIO_READ);
|
struct nbio_t* read = nbio_open("test.bin", NBIO_READ);
|
||||||
void* ptr = nbio_get_ptr(read, &size);
|
void* ptr = nbio_get_ptr(read, &size);
|
||||||
|
|
||||||
if (size != 1024*1024)
|
if (size != 1024*1024)
|
||||||
puts("ERROR: wrong size (2)");
|
puts("ERROR: wrong size (2)");
|
||||||
if (ptr)
|
if (ptr)
|
||||||
puts("Read pointer is available before iterating?");
|
puts("Read pointer is available before iterating?");
|
||||||
|
|
||||||
nbio_begin_read(read);
|
nbio_begin_read(read);
|
||||||
|
|
||||||
while (!nbio_iterate(read)) looped=true;
|
while (!nbio_iterate(read)) looped=true;
|
||||||
|
|
||||||
if (!looped)
|
if (!looped)
|
||||||
puts("Read finished immediately?");
|
puts("Read finished immediately?");
|
||||||
|
|
||||||
ptr = nbio_get_ptr(read, &size);
|
ptr = nbio_get_ptr(read, &size);
|
||||||
|
|
||||||
if (size != 1024*1024)
|
if (size != 1024*1024)
|
||||||
puts("ERROR: wrong size (3)");
|
puts("ERROR: wrong size (3)");
|
||||||
if (*(char*)ptr != 0x42 || memcmp(ptr, (char*)ptr+1, 1024*1024-1))
|
if (*(char*)ptr != 0x42 || memcmp(ptr, (char*)ptr+1, 1024*1024-1))
|
||||||
puts("ERROR: wrong data");
|
puts("ERROR: wrong data");
|
||||||
|
|
||||||
nbio_free(read);
|
nbio_free(read);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
nbio_write_test();
|
nbio_write_test();
|
||||||
nbio_read_test();
|
nbio_read_test();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,202 +1,202 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_dirent.c).
|
* The following license statement only applies to this file (retro_dirent.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <retro_common.h>
|
#include <retro_common.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
# ifdef _MSC_VER
|
# ifdef _MSC_VER
|
||||||
# define setmode _setmode
|
# define setmode _setmode
|
||||||
# endif
|
# endif
|
||||||
# ifdef _XBOX
|
# ifdef _XBOX
|
||||||
# include <xtl.h>
|
# include <xtl.h>
|
||||||
# define INVALID_FILE_ATTRIBUTES -1
|
# define INVALID_FILE_ATTRIBUTES -1
|
||||||
# else
|
# else
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <direct.h>
|
# include <direct.h>
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# endif
|
# endif
|
||||||
#elif defined(VITA)
|
#elif defined(VITA)
|
||||||
# include <psp2/io/fcntl.h>
|
# include <psp2/io/fcntl.h>
|
||||||
# include <psp2/io/dirent.h>
|
# include <psp2/io/dirent.h>
|
||||||
#else
|
#else
|
||||||
# if defined(PSP)
|
# if defined(PSP)
|
||||||
# include <pspiofilemgr.h>
|
# include <pspiofilemgr.h>
|
||||||
# endif
|
# endif
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <dirent.h>
|
# include <dirent.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __CELLOS_LV2__
|
#ifdef __CELLOS_LV2__
|
||||||
#include <cell/cell_fs.h>
|
#include <cell/cell_fs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_stat.h>
|
#include <retro_stat.h>
|
||||||
#include <retro_dirent.h>
|
#include <retro_dirent.h>
|
||||||
|
|
||||||
struct RDIR
|
struct RDIR
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
WIN32_FIND_DATA entry;
|
WIN32_FIND_DATA entry;
|
||||||
HANDLE directory;
|
HANDLE directory;
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
SceUID directory;
|
SceUID directory;
|
||||||
SceIoDirent entry;
|
SceIoDirent entry;
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
CellFsErrno error;
|
CellFsErrno error;
|
||||||
int directory;
|
int directory;
|
||||||
CellFsDirent entry;
|
CellFsDirent entry;
|
||||||
#else
|
#else
|
||||||
DIR *directory;
|
DIR *directory;
|
||||||
const struct dirent *entry;
|
const struct dirent *entry;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RDIR *retro_opendir(const char *name)
|
struct RDIR *retro_opendir(const char *name)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
char path_buf[1024];
|
char path_buf[1024];
|
||||||
#endif
|
#endif
|
||||||
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
||||||
|
|
||||||
if (!rdir)
|
if (!rdir)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
|
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
|
||||||
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
|
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
rdir->directory = sceIoDopen(name);
|
rdir->directory = sceIoDopen(name);
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
rdir->error = cellFsOpendir(name, &rdir->directory);
|
rdir->error = cellFsOpendir(name, &rdir->directory);
|
||||||
#else
|
#else
|
||||||
rdir->directory = opendir(name);
|
rdir->directory = opendir(name);
|
||||||
rdir->entry = NULL;
|
rdir->entry = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return rdir;
|
return rdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retro_dirent_error(struct RDIR *rdir)
|
bool retro_dirent_error(struct RDIR *rdir)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return (rdir->directory == INVALID_HANDLE_VALUE);
|
return (rdir->directory == INVALID_HANDLE_VALUE);
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
return (rdir->directory < 0);
|
return (rdir->directory < 0);
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
return (rdir->error != CELL_FS_SUCCEEDED);
|
return (rdir->error != CELL_FS_SUCCEEDED);
|
||||||
#else
|
#else
|
||||||
return !(rdir->directory);
|
return !(rdir->directory);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int retro_readdir(struct RDIR *rdir)
|
int retro_readdir(struct RDIR *rdir)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return (FindNextFile(rdir->directory, &rdir->entry) != 0);
|
return (FindNextFile(rdir->directory, &rdir->entry) != 0);
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
return (sceIoDread(rdir->directory, &rdir->entry) > 0);
|
return (sceIoDread(rdir->directory, &rdir->entry) > 0);
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
uint64_t nread;
|
uint64_t nread;
|
||||||
rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread);
|
rdir->error = cellFsReaddir(rdir->directory, &rdir->entry, &nread);
|
||||||
return (nread != 0);
|
return (nread != 0);
|
||||||
#else
|
#else
|
||||||
return ((rdir->entry = readdir(rdir->directory)) != NULL);
|
return ((rdir->entry = readdir(rdir->directory)) != NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *retro_dirent_get_name(struct RDIR *rdir)
|
const char *retro_dirent_get_name(struct RDIR *rdir)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return rdir->entry.cFileName;
|
return rdir->entry.cFileName;
|
||||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
||||||
return rdir->entry.d_name;
|
return rdir->entry.d_name;
|
||||||
#else
|
#else
|
||||||
return rdir->entry->d_name;
|
return rdir->entry->d_name;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* retro_dirent_is_dir:
|
* retro_dirent_is_dir:
|
||||||
* @rdir : pointer to the directory entry.
|
* @rdir : pointer to the directory entry.
|
||||||
* @path : path to the directory entry.
|
* @path : path to the directory entry.
|
||||||
*
|
*
|
||||||
* Is the directory listing entry a directory?
|
* Is the directory listing entry a directory?
|
||||||
*
|
*
|
||||||
* Returns: true if directory listing entry is
|
* Returns: true if directory listing entry is
|
||||||
* a directory, false if not.
|
* a directory, false if not.
|
||||||
*/
|
*/
|
||||||
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
|
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry;
|
const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry;
|
||||||
return entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
return entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
|
||||||
#elif defined(PSP) || defined(VITA)
|
#elif defined(PSP) || defined(VITA)
|
||||||
const SceIoDirent *entry = (const SceIoDirent*)&rdir->entry;
|
const SceIoDirent *entry = (const SceIoDirent*)&rdir->entry;
|
||||||
#if defined(PSP)
|
#if defined(PSP)
|
||||||
return (entry->d_stat.st_attr & FIO_SO_IFDIR) == FIO_SO_IFDIR;
|
return (entry->d_stat.st_attr & FIO_SO_IFDIR) == FIO_SO_IFDIR;
|
||||||
#elif defined(VITA)
|
#elif defined(VITA)
|
||||||
return PSP2_S_ISDIR(entry->d_stat.st_mode);
|
return PSP2_S_ISDIR(entry->d_stat.st_mode);
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
CellFsDirent *entry = (CellFsDirent*)&rdir->entry;
|
CellFsDirent *entry = (CellFsDirent*)&rdir->entry;
|
||||||
return (entry->d_type == CELL_FS_TYPE_DIRECTORY);
|
return (entry->d_type == CELL_FS_TYPE_DIRECTORY);
|
||||||
#elif defined(DT_DIR)
|
#elif defined(DT_DIR)
|
||||||
const struct dirent *entry = (const struct dirent*)rdir->entry;
|
const struct dirent *entry = (const struct dirent*)rdir->entry;
|
||||||
if (entry->d_type == DT_DIR)
|
if (entry->d_type == DT_DIR)
|
||||||
return true;
|
return true;
|
||||||
/* This can happen on certain file systems. */
|
/* This can happen on certain file systems. */
|
||||||
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK)
|
if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK)
|
||||||
return path_is_directory(path);
|
return path_is_directory(path);
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
/* dirent struct doesn't have d_type, do it the slow way ... */
|
/* dirent struct doesn't have d_type, do it the slow way ... */
|
||||||
return path_is_directory(path);
|
return path_is_directory(path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_closedir(struct RDIR *rdir)
|
void retro_closedir(struct RDIR *rdir)
|
||||||
{
|
{
|
||||||
if (!rdir)
|
if (!rdir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (rdir->directory != INVALID_HANDLE_VALUE)
|
if (rdir->directory != INVALID_HANDLE_VALUE)
|
||||||
FindClose(rdir->directory);
|
FindClose(rdir->directory);
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
sceIoDclose(rdir->directory);
|
sceIoDclose(rdir->directory);
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
rdir->error = cellFsClosedir(rdir->directory);
|
rdir->error = cellFsClosedir(rdir->directory);
|
||||||
#else
|
#else
|
||||||
if (rdir->directory)
|
if (rdir->directory)
|
||||||
closedir(rdir->directory);
|
closedir(rdir->directory);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(rdir);
|
free(rdir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,213 +1,213 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_stat.c).
|
* The following license statement only applies to this file (retro_stat.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#define setmode _setmode
|
#define setmode _setmode
|
||||||
#endif
|
#endif
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#include <xtl.h>
|
#include <xtl.h>
|
||||||
#define INVALID_FILE_ATTRIBUTES -1
|
#define INVALID_FILE_ATTRIBUTES -1
|
||||||
#else
|
#else
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#elif defined(VITA)
|
#elif defined(VITA)
|
||||||
#define SCE_ERROR_ERRNO_EEXIST 0x80010011
|
#define SCE_ERROR_ERRNO_EEXIST 0x80010011
|
||||||
#include <psp2/io/fcntl.h>
|
#include <psp2/io/fcntl.h>
|
||||||
#include <psp2/io/dirent.h>
|
#include <psp2/io/dirent.h>
|
||||||
#include <psp2/io/stat.h>
|
#include <psp2/io/stat.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PSP)
|
#if defined(PSP)
|
||||||
#include <pspkernel.h>
|
#include <pspkernel.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
#include <kernel/image.h>
|
#include <kernel/image.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__)
|
#if defined(__CELLOS_LV2__)
|
||||||
#include <cell/cell_fs.h>
|
#include <cell/cell_fs.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VITA)
|
#if defined(VITA)
|
||||||
#define FIO_S_ISDIR PSP2_S_ISDIR
|
#define FIO_S_ISDIR PSP2_S_ISDIR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
|
#if (defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)) || defined(__QNX__) || defined(PSP)
|
||||||
#include <unistd.h> /* stat() is defined here */
|
#include <unistd.h> /* stat() is defined here */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
enum stat_mode
|
enum stat_mode
|
||||||
{
|
{
|
||||||
IS_DIRECTORY = 0,
|
IS_DIRECTORY = 0,
|
||||||
IS_CHARACTER_SPECIAL,
|
IS_CHARACTER_SPECIAL,
|
||||||
IS_VALID
|
IS_VALID
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||||
{
|
{
|
||||||
#if defined(VITA) || defined(PSP)
|
#if defined(VITA) || defined(PSP)
|
||||||
SceIoStat buf;
|
SceIoStat buf;
|
||||||
char *tmp = strdup(path);
|
char *tmp = strdup(path);
|
||||||
size_t len = strlen(tmp);
|
size_t len = strlen(tmp);
|
||||||
if (tmp[len-1] == '/')
|
if (tmp[len-1] == '/')
|
||||||
tmp[len-1]='\0';
|
tmp[len-1]='\0';
|
||||||
|
|
||||||
if (sceIoGetstat(tmp, &buf) < 0)
|
if (sceIoGetstat(tmp, &buf) < 0)
|
||||||
{
|
{
|
||||||
free(tmp);
|
free(tmp);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
CellFsStat buf;
|
CellFsStat buf;
|
||||||
if (cellFsStat(path, &buf) < 0)
|
if (cellFsStat(path, &buf) < 0)
|
||||||
return false;
|
return false;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
WIN32_FILE_ATTRIBUTE_DATA file_info;
|
WIN32_FILE_ATTRIBUTE_DATA file_info;
|
||||||
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
|
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
|
||||||
DWORD ret = GetFileAttributesEx(path, fInfoLevelId, &file_info);
|
DWORD ret = GetFileAttributesEx(path, fInfoLevelId, &file_info);
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
if (stat(path, &buf) < 0)
|
if (stat(path, &buf) < 0)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (size)
|
if (size)
|
||||||
*size = file_info.nFileSizeLow;
|
*size = file_info.nFileSizeLow;
|
||||||
#else
|
#else
|
||||||
if (size)
|
if (size)
|
||||||
*size = buf.st_size;
|
*size = buf.st_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case IS_DIRECTORY:
|
case IS_DIRECTORY:
|
||||||
#if defined(VITA) || defined(PSP)
|
#if defined(VITA) || defined(PSP)
|
||||||
return FIO_S_ISDIR(buf.st_mode);
|
return FIO_S_ISDIR(buf.st_mode);
|
||||||
#elif defined(__CELLOS_LV2__)
|
#elif defined(__CELLOS_LV2__)
|
||||||
return ((buf.st_mode & S_IFMT) == S_IFDIR);
|
return ((buf.st_mode & S_IFMT) == S_IFDIR);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
return (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
return (file_info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
#else
|
#else
|
||||||
return S_ISDIR(buf.st_mode);
|
return S_ISDIR(buf.st_mode);
|
||||||
#endif
|
#endif
|
||||||
case IS_CHARACTER_SPECIAL:
|
case IS_CHARACTER_SPECIAL:
|
||||||
#if defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(_WIN32)
|
#if defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(_WIN32)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
return S_ISCHR(buf.st_mode);
|
return S_ISCHR(buf.st_mode);
|
||||||
#endif
|
#endif
|
||||||
case IS_VALID:
|
case IS_VALID:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_is_directory:
|
* path_is_directory:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if path is a directory.
|
* Checks if path is a directory.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if path is a directory, otherwise false (0).
|
* Returns: true (1) if path is a directory, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
bool path_is_directory(const char *path)
|
bool path_is_directory(const char *path)
|
||||||
{
|
{
|
||||||
return path_stat(path, IS_DIRECTORY, NULL);
|
return path_stat(path, IS_DIRECTORY, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool path_is_character_special(const char *path)
|
bool path_is_character_special(const char *path)
|
||||||
{
|
{
|
||||||
return path_stat(path, IS_CHARACTER_SPECIAL, NULL);
|
return path_stat(path, IS_CHARACTER_SPECIAL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool path_is_valid(const char *path)
|
bool path_is_valid(const char *path)
|
||||||
{
|
{
|
||||||
return path_stat(path, IS_VALID, NULL);
|
return path_stat(path, IS_VALID, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t path_get_size(const char *path)
|
int32_t path_get_size(const char *path)
|
||||||
{
|
{
|
||||||
int32_t filesize = 0;
|
int32_t filesize = 0;
|
||||||
if (path_stat(path, IS_VALID, &filesize))
|
if (path_stat(path, IS_VALID, &filesize))
|
||||||
return filesize;
|
return filesize;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_mkdir_norecurse:
|
* path_mkdir_norecurse:
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
*
|
*
|
||||||
* Create directory on filesystem.
|
* Create directory on filesystem.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if directory could be created, otherwise false (0).
|
* Returns: true (1) if directory could be created, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool mkdir_norecurse(const char *dir)
|
bool mkdir_norecurse(const char *dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
ret = _mkdir(dir);
|
ret = _mkdir(dir);
|
||||||
#elif defined(IOS)
|
#elif defined(IOS)
|
||||||
ret = mkdir(dir, 0755);
|
ret = mkdir(dir, 0755);
|
||||||
#elif defined(VITA) || defined(PSP)
|
#elif defined(VITA) || defined(PSP)
|
||||||
ret = sceIoMkdir(dir, 0777);
|
ret = sceIoMkdir(dir, 0777);
|
||||||
#else
|
#else
|
||||||
ret = mkdir(dir, 0750);
|
ret = mkdir(dir, 0750);
|
||||||
#endif
|
#endif
|
||||||
/* Don't treat this as an error. */
|
/* Don't treat this as an error. */
|
||||||
#if defined(VITA)
|
#if defined(VITA)
|
||||||
if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir))
|
if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
#elif defined(PSP) || defined(_3DS)
|
#elif defined(PSP) || defined(_3DS)
|
||||||
if ((ret == -1) && path_is_directory(dir))
|
if ((ret == -1) && path_is_directory(dir))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
#else
|
#else
|
||||||
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
|
if (ret < 0 && errno == EEXIST && path_is_directory(dir))
|
||||||
ret = 0;
|
ret = 0;
|
||||||
#endif
|
#endif
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
printf("mkdir(%s) error: %s.\n", dir, strerror(errno));
|
printf("mkdir(%s) error: %s.\n", dir, strerror(errno));
|
||||||
return ret == 0;
|
return ret == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,220 +1,220 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rbmp_encode.c).
|
* The following license statement only applies to this file (rbmp_encode.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <retro_file.h>
|
#include <streams/file_stream.h>
|
||||||
#include <formats/rbmp.h>
|
#include <formats/rbmp.h>
|
||||||
|
|
||||||
static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool is32bpp)
|
static bool write_header_bmp(RFILE *file, unsigned width, unsigned height, bool is32bpp)
|
||||||
{
|
{
|
||||||
unsigned line_size = (width * (is32bpp?4:3) + 3) & ~3;
|
unsigned line_size = (width * (is32bpp?4:3) + 3) & ~3;
|
||||||
unsigned size = line_size * height + 54;
|
unsigned size = line_size * height + 54;
|
||||||
unsigned size_array = line_size * height;
|
unsigned size_array = line_size * height;
|
||||||
uint8_t header[54];
|
uint8_t header[54];
|
||||||
|
|
||||||
/* Generic BMP stuff. */
|
/* Generic BMP stuff. */
|
||||||
|
|
||||||
/* signature */
|
/* signature */
|
||||||
header[0] = 'B';
|
header[0] = 'B';
|
||||||
header[1] = 'M';
|
header[1] = 'M';
|
||||||
/* file size */
|
/* file size */
|
||||||
header[2] = (uint8_t)(size >> 0);
|
header[2] = (uint8_t)(size >> 0);
|
||||||
header[3] = (uint8_t)(size >> 8);
|
header[3] = (uint8_t)(size >> 8);
|
||||||
header[4] = (uint8_t)(size >> 16);
|
header[4] = (uint8_t)(size >> 16);
|
||||||
header[5] = (uint8_t)(size >> 24);
|
header[5] = (uint8_t)(size >> 24);
|
||||||
/* reserved */
|
/* reserved */
|
||||||
header[6] = 0;
|
header[6] = 0;
|
||||||
header[7] = 0;
|
header[7] = 0;
|
||||||
header[8] = 0;
|
header[8] = 0;
|
||||||
header[9] = 0;
|
header[9] = 0;
|
||||||
/* offset */
|
/* offset */
|
||||||
header[10] = 54;
|
header[10] = 54;
|
||||||
header[11] = 0;
|
header[11] = 0;
|
||||||
header[12] = 0;
|
header[12] = 0;
|
||||||
header[13] = 0;
|
header[13] = 0;
|
||||||
/* DIB size */
|
/* DIB size */
|
||||||
header[14] = 40;
|
header[14] = 40;
|
||||||
header[15] = 0;
|
header[15] = 0;
|
||||||
header[16] = 0;
|
header[16] = 0;
|
||||||
header[17] = 0;
|
header[17] = 0;
|
||||||
/* Width */
|
/* Width */
|
||||||
header[18] = (uint8_t)(width >> 0);
|
header[18] = (uint8_t)(width >> 0);
|
||||||
header[19] = (uint8_t)(width >> 8);
|
header[19] = (uint8_t)(width >> 8);
|
||||||
header[20] = (uint8_t)(width >> 16);
|
header[20] = (uint8_t)(width >> 16);
|
||||||
header[21] = (uint8_t)(width >> 24);
|
header[21] = (uint8_t)(width >> 24);
|
||||||
/* Height */
|
/* Height */
|
||||||
header[22] = (uint8_t)(height >> 0);
|
header[22] = (uint8_t)(height >> 0);
|
||||||
header[23] = (uint8_t)(height >> 8);
|
header[23] = (uint8_t)(height >> 8);
|
||||||
header[24] = (uint8_t)(height >> 16);
|
header[24] = (uint8_t)(height >> 16);
|
||||||
header[25] = (uint8_t)(height >> 24);
|
header[25] = (uint8_t)(height >> 24);
|
||||||
/* Color planes */
|
/* Color planes */
|
||||||
header[26] = 1;
|
header[26] = 1;
|
||||||
header[27] = 0;
|
header[27] = 0;
|
||||||
/* Bits per pixel */
|
/* Bits per pixel */
|
||||||
header[28] = is32bpp?32:24;
|
header[28] = is32bpp?32:24;
|
||||||
header[29] = 0;
|
header[29] = 0;
|
||||||
/* Compression method */
|
/* Compression method */
|
||||||
header[30] = 0;
|
header[30] = 0;
|
||||||
header[31] = 0;
|
header[31] = 0;
|
||||||
header[32] = 0;
|
header[32] = 0;
|
||||||
header[33] = 0;
|
header[33] = 0;
|
||||||
/* Image data size */
|
/* Image data size */
|
||||||
header[34] = (uint8_t)(size_array >> 0);
|
header[34] = (uint8_t)(size_array >> 0);
|
||||||
header[35] = (uint8_t)(size_array >> 8);
|
header[35] = (uint8_t)(size_array >> 8);
|
||||||
header[36] = (uint8_t)(size_array >> 16);
|
header[36] = (uint8_t)(size_array >> 16);
|
||||||
header[37] = (uint8_t)(size_array >> 24);
|
header[37] = (uint8_t)(size_array >> 24);
|
||||||
/* Horizontal resolution */
|
/* Horizontal resolution */
|
||||||
header[38] = 19;
|
header[38] = 19;
|
||||||
header[39] = 11;
|
header[39] = 11;
|
||||||
header[40] = 0;
|
header[40] = 0;
|
||||||
header[41] = 0;
|
header[41] = 0;
|
||||||
/* Vertical resolution */
|
/* Vertical resolution */
|
||||||
header[42] = 19;
|
header[42] = 19;
|
||||||
header[43] = 11;
|
header[43] = 11;
|
||||||
header[44] = 0;
|
header[44] = 0;
|
||||||
header[45] = 0;
|
header[45] = 0;
|
||||||
/* Palette size */
|
/* Palette size */
|
||||||
header[46] = 0;
|
header[46] = 0;
|
||||||
header[47] = 0;
|
header[47] = 0;
|
||||||
header[48] = 0;
|
header[48] = 0;
|
||||||
header[49] = 0;
|
header[49] = 0;
|
||||||
/* Important color count */
|
/* Important color count */
|
||||||
header[50] = 0;
|
header[50] = 0;
|
||||||
header[51] = 0;
|
header[51] = 0;
|
||||||
header[52] = 0;
|
header[52] = 0;
|
||||||
header[53] = 0;
|
header[53] = 0;
|
||||||
|
|
||||||
return retro_fwrite(file, header, sizeof(header)) == sizeof(header);
|
return retro_fwrite(file, header, sizeof(header)) == sizeof(header);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_line_565_to_24(uint8_t *line, const uint16_t *src, unsigned width)
|
static void dump_line_565_to_24(uint8_t *line, const uint16_t *src, unsigned width)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
uint16_t pixel = *src++;
|
uint16_t pixel = *src++;
|
||||||
uint8_t b = (pixel >> 0) & 0x1f;
|
uint8_t b = (pixel >> 0) & 0x1f;
|
||||||
uint8_t g = (pixel >> 5) & 0x3f;
|
uint8_t g = (pixel >> 5) & 0x3f;
|
||||||
uint8_t r = (pixel >> 11) & 0x1f;
|
uint8_t r = (pixel >> 11) & 0x1f;
|
||||||
*line++ = (b << 3) | (b >> 2);
|
*line++ = (b << 3) | (b >> 2);
|
||||||
*line++ = (g << 2) | (g >> 4);
|
*line++ = (g << 2) | (g >> 4);
|
||||||
*line++ = (r << 3) | (r >> 2);
|
*line++ = (r << 3) | (r >> 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_line_32_to_24(uint8_t *line, const uint32_t *src, unsigned width)
|
static void dump_line_32_to_24(uint8_t *line, const uint32_t *src, unsigned width)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
uint32_t pixel = *src++;
|
uint32_t pixel = *src++;
|
||||||
*line++ = (pixel >> 0) & 0xff;
|
*line++ = (pixel >> 0) & 0xff;
|
||||||
*line++ = (pixel >> 8) & 0xff;
|
*line++ = (pixel >> 8) & 0xff;
|
||||||
*line++ = (pixel >> 16) & 0xff;
|
*line++ = (pixel >> 16) & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_content(RFILE *file, const void *frame,
|
static void dump_content(RFILE *file, const void *frame,
|
||||||
int width, int height, int pitch, rbmp_source_type type)
|
int width, int height, int pitch, enum rbmp_source_type type)
|
||||||
{
|
{
|
||||||
uint8_t *line;
|
uint8_t *line;
|
||||||
size_t line_size;
|
size_t line_size;
|
||||||
int i, j;
|
int j;
|
||||||
int bytes_per_pixel = (type==RBMP_SOURCE_TYPE_ARGB8888?4:3);
|
int bytes_per_pixel = (type==RBMP_SOURCE_TYPE_ARGB8888?4:3);
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const uint8_t *u8;
|
const uint8_t *u8;
|
||||||
const uint16_t *u16;
|
const uint16_t *u16;
|
||||||
const uint32_t *u32;
|
const uint32_t *u32;
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
u.u8 = (const uint8_t*)frame + (height-1) * pitch;
|
u.u8 = (const uint8_t*)frame + (height-1) * pitch;
|
||||||
line_size = (width * bytes_per_pixel + 3) & ~3;
|
line_size = (width * bytes_per_pixel + 3) & ~3;
|
||||||
|
|
||||||
if (type == RBMP_SOURCE_TYPE_BGR24)
|
if (type == RBMP_SOURCE_TYPE_BGR24)
|
||||||
{
|
{
|
||||||
/* BGR24 byte order input matches output. Can directly copy, but... need to make sure we pad it. */
|
/* BGR24 byte order input matches output. Can directly copy, but... need to make sure we pad it. */
|
||||||
uint32_t zeros = 0;
|
uint32_t zeros = 0;
|
||||||
int pad = line_size-pitch;
|
int pad = line_size-pitch;
|
||||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||||
{
|
{
|
||||||
retro_fwrite(file, u.u8, pitch);
|
retro_fwrite(file, u.u8, pitch);
|
||||||
if(pad != 0) retro_fwrite(file, &zeros, pad);
|
if(pad != 0) retro_fwrite(file, &zeros, pad);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(type == RBMP_SOURCE_TYPE_ARGB8888)
|
else if(type == RBMP_SOURCE_TYPE_ARGB8888)
|
||||||
{
|
{
|
||||||
/* ARGB8888 byte order input matches output. Can directly copy. */
|
/* ARGB8888 byte order input matches output. Can directly copy. */
|
||||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||||
{
|
{
|
||||||
retro_fwrite(file, u.u8, line_size);
|
retro_fwrite(file, u.u8, line_size);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate line buffer, and initialize the final four bytes to zero, for deterministic padding */
|
/* allocate line buffer, and initialize the final four bytes to zero, for deterministic padding */
|
||||||
line = (uint8_t*)malloc(line_size);
|
line = (uint8_t*)malloc(line_size);
|
||||||
if (!line) return;
|
if (!line) return;
|
||||||
*(uint32_t*)(line + line_size - 4) = 0;
|
*(uint32_t*)(line + line_size - 4) = 0;
|
||||||
|
|
||||||
if (type == RBMP_SOURCE_TYPE_XRGB888)
|
if (type == RBMP_SOURCE_TYPE_XRGB888)
|
||||||
{
|
{
|
||||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||||
{
|
{
|
||||||
dump_line_32_to_24(line, u.u32, width);
|
dump_line_32_to_24(line, u.u32, width);
|
||||||
retro_fwrite(file, line, line_size);
|
retro_fwrite(file, line, line_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else /* type == RBMP_SOURCE_TYPE_RGB565 */
|
else /* type == RBMP_SOURCE_TYPE_RGB565 */
|
||||||
{
|
{
|
||||||
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
for (j = height-1; j >= 0; j--, u.u8 -= pitch)
|
||||||
{
|
{
|
||||||
dump_line_565_to_24(line, u.u16, width);
|
dump_line_565_to_24(line, u.u16, width);
|
||||||
retro_fwrite(file, line, line_size);
|
retro_fwrite(file, line, line_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rbmp_save_image(const char *filename, const void *frame,
|
bool rbmp_save_image(const char *filename, const void *frame,
|
||||||
unsigned width, unsigned height,
|
unsigned width, unsigned height,
|
||||||
unsigned pitch, rbmp_source_type type)
|
unsigned pitch, enum rbmp_source_type type)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
RFILE *file = retro_fopen(filename, RFILE_MODE_WRITE, -1);
|
RFILE *file = retro_fopen(filename, RFILE_MODE_WRITE, -1);
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ret = write_header_bmp(file, width, height, type==RBMP_SOURCE_TYPE_ARGB8888);
|
ret = write_header_bmp(file, width, height, type==RBMP_SOURCE_TYPE_ARGB8888);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
dump_content(file, frame, width, height, pitch, type);
|
dump_content(file, frame, width, height, pitch, type);
|
||||||
|
|
||||||
retro_fclose(file);
|
retro_fclose(file);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,316 +1,316 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (jsonsax.c).
|
* The following license statement only applies to this file (jsonsax.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <formats/jsonsax.h>
|
#include <formats/jsonsax.h>
|
||||||
|
|
||||||
#ifdef JSONSAX_ERRORS
|
#ifdef JSONSAX_ERRORS
|
||||||
const char* jsonsax_errors[] =
|
const char* jsonsax_errors[] =
|
||||||
{
|
{
|
||||||
"Ok",
|
"Ok",
|
||||||
"Interrupted",
|
"Interrupted",
|
||||||
"Missing key",
|
"Missing key",
|
||||||
"Unterminated key",
|
"Unterminated key",
|
||||||
"Missing value",
|
"Missing value",
|
||||||
"Unterminated object",
|
"Unterminated object",
|
||||||
"Unterminated array",
|
"Unterminated array",
|
||||||
"Unterminated string",
|
"Unterminated string",
|
||||||
"Invalid value"
|
"Invalid value"
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const jsonsax_handlers_t* handlers;
|
const jsonsax_handlers_t* handlers;
|
||||||
|
|
||||||
const char* json;
|
const char* json;
|
||||||
void* ud;
|
void* ud;
|
||||||
jmp_buf env;
|
jmp_buf env;
|
||||||
}
|
}
|
||||||
state_t;
|
state_t;
|
||||||
|
|
||||||
static INLINE void skip_spaces( state_t* state )
|
static INLINE void skip_spaces( state_t* state )
|
||||||
{
|
{
|
||||||
while ( isspace( *state->json ) )
|
while ( isspace( *state->json ) )
|
||||||
state->json++;
|
state->json++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE void skip_digits( state_t* state )
|
static INLINE void skip_digits( state_t* state )
|
||||||
{
|
{
|
||||||
while ( isdigit( *state->json ) )
|
while ( isdigit( *state->json ) )
|
||||||
state->json++;
|
state->json++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HANDLE_0( event ) \
|
#define HANDLE_0( event ) \
|
||||||
do { \
|
do { \
|
||||||
if ( state->handlers->event && state->handlers->event( state->ud ) ) \
|
if ( state->handlers->event && state->handlers->event( state->ud ) ) \
|
||||||
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#define HANDLE_1( event, arg1 ) \
|
#define HANDLE_1( event, arg1 ) \
|
||||||
do { \
|
do { \
|
||||||
if ( state->handlers->event && state->handlers->event( state->ud, arg1 ) ) \
|
if ( state->handlers->event && state->handlers->event( state->ud, arg1 ) ) \
|
||||||
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
#define HANDLE_2( event, arg1, arg2 ) \
|
#define HANDLE_2( event, arg1, arg2 ) \
|
||||||
do { \
|
do { \
|
||||||
if ( state->handlers->event && state->handlers->event( state->ud, arg1, arg2 ) ) \
|
if ( state->handlers->event && state->handlers->event( state->ud, arg1, arg2 ) ) \
|
||||||
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
longjmp( state->env, JSONSAX_INTERRUPTED ); \
|
||||||
} while ( 0 )
|
} while ( 0 )
|
||||||
|
|
||||||
static void jsonx_parse_value(state_t* state);
|
static void jsonx_parse_value(state_t* state);
|
||||||
|
|
||||||
static void jsonx_parse_object( state_t* state )
|
static void jsonx_parse_object( state_t* state )
|
||||||
{
|
{
|
||||||
state->json++; /* we're sure the current character is a '{' */
|
state->json++; /* we're sure the current character is a '{' */
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
HANDLE_0( start_object );
|
HANDLE_0( start_object );
|
||||||
|
|
||||||
while ( *state->json != '}' )
|
while ( *state->json != '}' )
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
if ( *state->json != '"' )
|
if ( *state->json != '"' )
|
||||||
longjmp( state->env, JSONSAX_MISSING_KEY );
|
longjmp( state->env, JSONSAX_MISSING_KEY );
|
||||||
|
|
||||||
name = ++state->json;
|
name = ++state->json;
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
const char* quote = strchr( state->json, '"' );
|
const char* quote = strchr( state->json, '"' );
|
||||||
|
|
||||||
if ( !quote )
|
if ( !quote )
|
||||||
longjmp( state->env, JSONSAX_UNTERMINATED_KEY );
|
longjmp( state->env, JSONSAX_UNTERMINATED_KEY );
|
||||||
|
|
||||||
state->json = quote + 1;
|
state->json = quote + 1;
|
||||||
|
|
||||||
if ( quote[ -1 ] != '\\' )
|
if ( quote[ -1 ] != '\\' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_2( key, name, state->json - name - 1 );
|
HANDLE_2( key, name, state->json - name - 1 );
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
|
|
||||||
if ( *state->json != ':' )
|
if ( *state->json != ':' )
|
||||||
longjmp( state->env, JSONSAX_MISSING_VALUE );
|
longjmp( state->env, JSONSAX_MISSING_VALUE );
|
||||||
|
|
||||||
state->json++;
|
state->json++;
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
jsonx_parse_value( state );
|
jsonx_parse_value( state );
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
|
|
||||||
if ( *state->json != ',' )
|
if ( *state->json != ',' )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
state->json++;
|
state->json++;
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *state->json != '}' )
|
if ( *state->json != '}' )
|
||||||
longjmp( state->env, JSONSAX_UNTERMINATED_OBJECT );
|
longjmp( state->env, JSONSAX_UNTERMINATED_OBJECT );
|
||||||
|
|
||||||
state->json++;
|
state->json++;
|
||||||
HANDLE_0( end_object );
|
HANDLE_0( end_object );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_array(state_t* state)
|
static void jsonx_parse_array(state_t* state)
|
||||||
{
|
{
|
||||||
unsigned int ndx = 0;
|
unsigned int ndx = 0;
|
||||||
|
|
||||||
state->json++; /* we're sure the current character is a '[' */
|
state->json++; /* we're sure the current character is a '[' */
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
HANDLE_0( start_array );
|
HANDLE_0( start_array );
|
||||||
|
|
||||||
while ( *state->json != ']' )
|
while ( *state->json != ']' )
|
||||||
{
|
{
|
||||||
HANDLE_1( index, ndx++ );
|
HANDLE_1( index, ndx++ );
|
||||||
jsonx_parse_value( state );
|
jsonx_parse_value( state );
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
|
|
||||||
if ( *state->json != ',' )
|
if ( *state->json != ',' )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
state->json++;
|
state->json++;
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *state->json != ']' )
|
if ( *state->json != ']' )
|
||||||
longjmp( state->env, JSONSAX_UNTERMINATED_ARRAY );
|
longjmp( state->env, JSONSAX_UNTERMINATED_ARRAY );
|
||||||
|
|
||||||
state->json++;
|
state->json++;
|
||||||
HANDLE_0( end_array );
|
HANDLE_0( end_array );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_string(state_t* state)
|
static void jsonx_parse_string(state_t* state)
|
||||||
{
|
{
|
||||||
const char* string = ++state->json;
|
const char* string = ++state->json;
|
||||||
|
|
||||||
for ( ;; )
|
for ( ;; )
|
||||||
{
|
{
|
||||||
const char* quote = strchr( state->json, '"' );
|
const char* quote = strchr( state->json, '"' );
|
||||||
|
|
||||||
if ( !quote )
|
if ( !quote )
|
||||||
longjmp( state->env, JSONSAX_UNTERMINATED_STRING );
|
longjmp( state->env, JSONSAX_UNTERMINATED_STRING );
|
||||||
|
|
||||||
state->json = quote + 1;
|
state->json = quote + 1;
|
||||||
|
|
||||||
if ( quote[ -1 ] != '\\' )
|
if ( quote[ -1 ] != '\\' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_2( string, string, state->json - string - 1 );
|
HANDLE_2( string, string, state->json - string - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_boolean(state_t* state)
|
static void jsonx_parse_boolean(state_t* state)
|
||||||
{
|
{
|
||||||
if ( !strncmp( state->json, "true", 4 ) )
|
if ( !strncmp( state->json, "true", 4 ) )
|
||||||
{
|
{
|
||||||
state->json += 4;
|
state->json += 4;
|
||||||
HANDLE_1( boolean, 1 );
|
HANDLE_1( boolean, 1 );
|
||||||
}
|
}
|
||||||
else if ( !strncmp( state->json, "false", 5 ) )
|
else if ( !strncmp( state->json, "false", 5 ) )
|
||||||
{
|
{
|
||||||
state->json += 5;
|
state->json += 5;
|
||||||
HANDLE_1( boolean, 0 );
|
HANDLE_1( boolean, 0 );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_null(state_t* state)
|
static void jsonx_parse_null(state_t* state)
|
||||||
{
|
{
|
||||||
if ( !strncmp( state->json + 1, "ull", 3 ) ) /* we're sure the current character is a 'n' */
|
if ( !strncmp( state->json + 1, "ull", 3 ) ) /* we're sure the current character is a 'n' */
|
||||||
{
|
{
|
||||||
state->json += 4;
|
state->json += 4;
|
||||||
HANDLE_0( null );
|
HANDLE_0( null );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_number(state_t* state)
|
static void jsonx_parse_number(state_t* state)
|
||||||
{
|
{
|
||||||
const char* number = state->json;
|
const char* number = state->json;
|
||||||
|
|
||||||
if ( *state->json == '-' )
|
if ( *state->json == '-' )
|
||||||
state->json++;
|
state->json++;
|
||||||
|
|
||||||
if ( !isdigit( *state->json ) )
|
if ( !isdigit( *state->json ) )
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
|
|
||||||
skip_digits( state );
|
skip_digits( state );
|
||||||
|
|
||||||
if ( *state->json == '.' )
|
if ( *state->json == '.' )
|
||||||
{
|
{
|
||||||
state->json++;
|
state->json++;
|
||||||
|
|
||||||
if ( !isdigit( *state->json ) )
|
if ( !isdigit( *state->json ) )
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
|
|
||||||
skip_digits( state );
|
skip_digits( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( *state->json == 'e' || *state->json == 'E' )
|
if ( *state->json == 'e' || *state->json == 'E' )
|
||||||
{
|
{
|
||||||
state->json++;
|
state->json++;
|
||||||
|
|
||||||
if ( *state->json == '-' || *state->json == '+' )
|
if ( *state->json == '-' || *state->json == '+' )
|
||||||
state->json++;
|
state->json++;
|
||||||
|
|
||||||
if ( !isdigit( *state->json ) )
|
if ( !isdigit( *state->json ) )
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
|
|
||||||
skip_digits( state );
|
skip_digits( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE_2( number, number, state->json - number );
|
HANDLE_2( number, number, state->json - number );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jsonx_parse_value(state_t* state)
|
static void jsonx_parse_value(state_t* state)
|
||||||
{
|
{
|
||||||
skip_spaces( state );
|
skip_spaces( state );
|
||||||
|
|
||||||
switch ( *state->json )
|
switch ( *state->json )
|
||||||
{
|
{
|
||||||
case '{':
|
case '{':
|
||||||
jsonx_parse_object(state);
|
jsonx_parse_object(state);
|
||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
jsonx_parse_array( state );
|
jsonx_parse_array( state );
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
jsonx_parse_string( state );
|
jsonx_parse_string( state );
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
case 'f':
|
case 'f':
|
||||||
jsonx_parse_boolean( state );
|
jsonx_parse_boolean( state );
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
jsonx_parse_null( state );
|
jsonx_parse_null( state );
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
case '3':
|
case '3':
|
||||||
case '4':
|
case '4':
|
||||||
case '5':
|
case '5':
|
||||||
case '6':
|
case '6':
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
case '-':
|
case '-':
|
||||||
jsonx_parse_number( state );
|
jsonx_parse_number( state );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
longjmp( state->env, JSONSAX_INVALID_VALUE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int jsonsax_parse( const char* json, const jsonsax_handlers_t* handlers, void* userdata )
|
int jsonsax_parse( const char* json, const jsonsax_handlers_t* handlers, void* userdata )
|
||||||
{
|
{
|
||||||
state_t state;
|
state_t state;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
state.json = json;
|
state.json = json;
|
||||||
state.handlers = handlers;
|
state.handlers = handlers;
|
||||||
state.ud = userdata;
|
state.ud = userdata;
|
||||||
|
|
||||||
if ( ( res = setjmp( state.env ) ) == 0 )
|
if ( ( res = setjmp( state.env ) ) == 0 )
|
||||||
{
|
{
|
||||||
if ( handlers->start_document )
|
if ( handlers->start_document )
|
||||||
handlers->start_document( userdata );
|
handlers->start_document( userdata );
|
||||||
|
|
||||||
jsonx_parse_value(&state);
|
jsonx_parse_value(&state);
|
||||||
|
|
||||||
if ( handlers->end_document )
|
if ( handlers->end_document )
|
||||||
handlers->end_document( userdata );
|
handlers->end_document( userdata );
|
||||||
|
|
||||||
res = JSONSAX_OK;
|
res = JSONSAX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,387 +1,387 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rpng.c).
|
* The following license statement only applies to this file (rpng_encode.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <retro_file.h>
|
#include <streams/file_stream.h>
|
||||||
|
|
||||||
#include "rpng_internal.h"
|
#include "rpng_internal.h"
|
||||||
|
|
||||||
#undef GOTO_END_ERROR
|
#undef GOTO_END_ERROR
|
||||||
#define GOTO_END_ERROR() do { \
|
#define GOTO_END_ERROR() do { \
|
||||||
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
|
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
|
||||||
ret = false; \
|
ret = false; \
|
||||||
goto end; \
|
goto end; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB_DEFLATE
|
#ifdef HAVE_ZLIB_DEFLATE
|
||||||
|
|
||||||
static void dword_write_be(uint8_t *buf, uint32_t val)
|
static void dword_write_be(uint8_t *buf, uint32_t val)
|
||||||
{
|
{
|
||||||
*buf++ = (uint8_t)(val >> 24);
|
*buf++ = (uint8_t)(val >> 24);
|
||||||
*buf++ = (uint8_t)(val >> 16);
|
*buf++ = (uint8_t)(val >> 16);
|
||||||
*buf++ = (uint8_t)(val >> 8);
|
*buf++ = (uint8_t)(val >> 8);
|
||||||
*buf++ = (uint8_t)(val >> 0);
|
*buf++ = (uint8_t)(val >> 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool png_write_crc(RFILE *file, const uint8_t *data, size_t size)
|
static bool png_write_crc(RFILE *file, const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
uint8_t crc_raw[4] = {0};
|
uint8_t crc_raw[4] = {0};
|
||||||
const struct file_archive_file_backend *stream_backend =
|
const struct file_archive_file_backend *stream_backend =
|
||||||
file_archive_get_default_file_backend();
|
file_archive_get_default_file_backend();
|
||||||
uint32_t crc = stream_backend->stream_crc_calculate(0, data, size);
|
uint32_t crc = stream_backend->stream_crc_calculate(0, data, size);
|
||||||
|
|
||||||
dword_write_be(crc_raw, crc);
|
dword_write_be(crc_raw, crc);
|
||||||
return retro_fwrite(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
|
return retro_fwrite(file, crc_raw, sizeof(crc_raw)) == sizeof(crc_raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
|
static bool png_write_ihdr(RFILE *file, const struct png_ihdr *ihdr)
|
||||||
{
|
{
|
||||||
uint8_t ihdr_raw[21];
|
uint8_t ihdr_raw[21];
|
||||||
|
|
||||||
ihdr_raw[0] = '0'; /* Size */
|
ihdr_raw[0] = '0'; /* Size */
|
||||||
ihdr_raw[1] = '0';
|
ihdr_raw[1] = '0';
|
||||||
ihdr_raw[2] = '0';
|
ihdr_raw[2] = '0';
|
||||||
ihdr_raw[3] = '0';
|
ihdr_raw[3] = '0';
|
||||||
ihdr_raw[4] = 'I';
|
ihdr_raw[4] = 'I';
|
||||||
ihdr_raw[5] = 'H';
|
ihdr_raw[5] = 'H';
|
||||||
ihdr_raw[6] = 'D';
|
ihdr_raw[6] = 'D';
|
||||||
ihdr_raw[7] = 'R';
|
ihdr_raw[7] = 'R';
|
||||||
ihdr_raw[8] = 0; /* Width */
|
ihdr_raw[8] = 0; /* Width */
|
||||||
ihdr_raw[9] = 0;
|
ihdr_raw[9] = 0;
|
||||||
ihdr_raw[10] = 0;
|
ihdr_raw[10] = 0;
|
||||||
ihdr_raw[11] = 0;
|
ihdr_raw[11] = 0;
|
||||||
ihdr_raw[12] = 0; /* Height */
|
ihdr_raw[12] = 0; /* Height */
|
||||||
ihdr_raw[13] = 0;
|
ihdr_raw[13] = 0;
|
||||||
ihdr_raw[14] = 0;
|
ihdr_raw[14] = 0;
|
||||||
ihdr_raw[15] = 0;
|
ihdr_raw[15] = 0;
|
||||||
ihdr_raw[16] = ihdr->depth; /* Depth */
|
ihdr_raw[16] = ihdr->depth; /* Depth */
|
||||||
ihdr_raw[17] = ihdr->color_type;
|
ihdr_raw[17] = ihdr->color_type;
|
||||||
ihdr_raw[18] = ihdr->compression;
|
ihdr_raw[18] = ihdr->compression;
|
||||||
ihdr_raw[19] = ihdr->filter;
|
ihdr_raw[19] = ihdr->filter;
|
||||||
ihdr_raw[20] = ihdr->interlace;
|
ihdr_raw[20] = ihdr->interlace;
|
||||||
|
|
||||||
dword_write_be(ihdr_raw + 0, sizeof(ihdr_raw) - 8);
|
dword_write_be(ihdr_raw + 0, sizeof(ihdr_raw) - 8);
|
||||||
dword_write_be(ihdr_raw + 8, ihdr->width);
|
dword_write_be(ihdr_raw + 8, ihdr->width);
|
||||||
dword_write_be(ihdr_raw + 12, ihdr->height);
|
dword_write_be(ihdr_raw + 12, ihdr->height);
|
||||||
if (retro_fwrite(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
|
if (retro_fwrite(file, ihdr_raw, sizeof(ihdr_raw)) != sizeof(ihdr_raw))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!png_write_crc(file, ihdr_raw + sizeof(uint32_t),
|
if (!png_write_crc(file, ihdr_raw + sizeof(uint32_t),
|
||||||
sizeof(ihdr_raw) - sizeof(uint32_t)))
|
sizeof(ihdr_raw) - sizeof(uint32_t)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool png_write_idat(RFILE *file, const uint8_t *data, size_t size)
|
static bool png_write_idat(RFILE *file, const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
if (retro_fwrite(file, data, size) != (ssize_t)size)
|
if (retro_fwrite(file, data, size) != (ssize_t)size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!png_write_crc(file, data + sizeof(uint32_t), size - sizeof(uint32_t)))
|
if (!png_write_crc(file, data + sizeof(uint32_t), size - sizeof(uint32_t)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool png_write_iend(RFILE *file)
|
static bool png_write_iend(RFILE *file)
|
||||||
{
|
{
|
||||||
const uint8_t data[] = {
|
const uint8_t data[] = {
|
||||||
0, 0, 0, 0,
|
0, 0, 0, 0,
|
||||||
'I', 'E', 'N', 'D',
|
'I', 'E', 'N', 'D',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (retro_fwrite(file, data, sizeof(data)) != sizeof(data))
|
if (retro_fwrite(file, data, sizeof(data)) != sizeof(data))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!png_write_crc(file, data + sizeof(uint32_t),
|
if (!png_write_crc(file, data + sizeof(uint32_t),
|
||||||
sizeof(data) - sizeof(uint32_t)))
|
sizeof(data) - sizeof(uint32_t)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_argb_line(uint8_t *dst, const uint32_t *src, unsigned width)
|
static void copy_argb_line(uint8_t *dst, const uint32_t *src, unsigned width)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
uint32_t col = src[i];
|
uint32_t col = src[i];
|
||||||
*dst++ = (uint8_t)(col >> 16);
|
*dst++ = (uint8_t)(col >> 16);
|
||||||
*dst++ = (uint8_t)(col >> 8);
|
*dst++ = (uint8_t)(col >> 8);
|
||||||
*dst++ = (uint8_t)(col >> 0);
|
*dst++ = (uint8_t)(col >> 0);
|
||||||
*dst++ = (uint8_t)(col >> 24);
|
*dst++ = (uint8_t)(col >> 24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_bgr24_line(uint8_t *dst, const uint8_t *src, unsigned width)
|
static void copy_bgr24_line(uint8_t *dst, const uint8_t *src, unsigned width)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < width; i++, dst += 3, src += 3)
|
for (i = 0; i < width; i++, dst += 3, src += 3)
|
||||||
{
|
{
|
||||||
dst[2] = src[0];
|
dst[2] = src[0];
|
||||||
dst[1] = src[1];
|
dst[1] = src[1];
|
||||||
dst[0] = src[2];
|
dst[0] = src[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned count_sad(const uint8_t *data, size_t size)
|
static unsigned count_sad(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
unsigned cnt = 0;
|
unsigned cnt = 0;
|
||||||
for (i = 0; i < size; i++)
|
for (i = 0; i < size; i++)
|
||||||
cnt += abs((int8_t)data[i]);
|
cnt += abs((int8_t)data[i]);
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned filter_up(uint8_t *target, const uint8_t *line,
|
static unsigned filter_up(uint8_t *target, const uint8_t *line,
|
||||||
const uint8_t *prev, unsigned width, unsigned bpp)
|
const uint8_t *prev, unsigned width, unsigned bpp)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
width *= bpp;
|
width *= bpp;
|
||||||
for (i = 0; i < width; i++)
|
for (i = 0; i < width; i++)
|
||||||
target[i] = line[i] - prev[i];
|
target[i] = line[i] - prev[i];
|
||||||
|
|
||||||
return count_sad(target, width);
|
return count_sad(target, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned filter_sub(uint8_t *target, const uint8_t *line,
|
static unsigned filter_sub(uint8_t *target, const uint8_t *line,
|
||||||
unsigned width, unsigned bpp)
|
unsigned width, unsigned bpp)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
width *= bpp;
|
width *= bpp;
|
||||||
for (i = 0; i < bpp; i++)
|
for (i = 0; i < bpp; i++)
|
||||||
target[i] = line[i];
|
target[i] = line[i];
|
||||||
for (i = bpp; i < width; i++)
|
for (i = bpp; i < width; i++)
|
||||||
target[i] = line[i] - line[i - bpp];
|
target[i] = line[i] - line[i - bpp];
|
||||||
|
|
||||||
return count_sad(target, width);
|
return count_sad(target, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned filter_avg(uint8_t *target, const uint8_t *line,
|
static unsigned filter_avg(uint8_t *target, const uint8_t *line,
|
||||||
const uint8_t *prev, unsigned width, unsigned bpp)
|
const uint8_t *prev, unsigned width, unsigned bpp)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
width *= bpp;
|
width *= bpp;
|
||||||
for (i = 0; i < bpp; i++)
|
for (i = 0; i < bpp; i++)
|
||||||
target[i] = line[i] - (prev[i] >> 1);
|
target[i] = line[i] - (prev[i] >> 1);
|
||||||
for (i = bpp; i < width; i++)
|
for (i = bpp; i < width; i++)
|
||||||
target[i] = line[i] - ((line[i - bpp] + prev[i]) >> 1);
|
target[i] = line[i] - ((line[i - bpp] + prev[i]) >> 1);
|
||||||
|
|
||||||
return count_sad(target, width);
|
return count_sad(target, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned filter_paeth(uint8_t *target,
|
static unsigned filter_paeth(uint8_t *target,
|
||||||
const uint8_t *line, const uint8_t *prev,
|
const uint8_t *line, const uint8_t *prev,
|
||||||
unsigned width, unsigned bpp)
|
unsigned width, unsigned bpp)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
width *= bpp;
|
width *= bpp;
|
||||||
for (i = 0; i < bpp; i++)
|
for (i = 0; i < bpp; i++)
|
||||||
target[i] = line[i] - paeth(0, prev[i], 0);
|
target[i] = line[i] - paeth(0, prev[i], 0);
|
||||||
for (i = bpp; i < width; i++)
|
for (i = bpp; i < width; i++)
|
||||||
target[i] = line[i] - paeth(line[i - bpp], prev[i], prev[i - bpp]);
|
target[i] = line[i] - paeth(line[i - bpp], prev[i], prev[i - bpp]);
|
||||||
|
|
||||||
return count_sad(target, width);
|
return count_sad(target, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool rpng_save_image(const char *path,
|
static bool rpng_save_image(const char *path,
|
||||||
const uint8_t *data,
|
const uint8_t *data,
|
||||||
unsigned width, unsigned height, unsigned pitch, unsigned bpp)
|
unsigned width, unsigned height, unsigned pitch, unsigned bpp)
|
||||||
{
|
{
|
||||||
unsigned h;
|
unsigned h;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
struct png_ihdr ihdr = {0};
|
struct png_ihdr ihdr = {0};
|
||||||
|
|
||||||
const struct file_archive_file_backend *stream_backend = NULL;
|
const struct file_archive_file_backend *stream_backend = NULL;
|
||||||
size_t encode_buf_size = 0;
|
size_t encode_buf_size = 0;
|
||||||
uint8_t *encode_buf = NULL;
|
uint8_t *encode_buf = NULL;
|
||||||
uint8_t *deflate_buf = NULL;
|
uint8_t *deflate_buf = NULL;
|
||||||
uint8_t *rgba_line = NULL;
|
uint8_t *rgba_line = NULL;
|
||||||
uint8_t *up_filtered = NULL;
|
uint8_t *up_filtered = NULL;
|
||||||
uint8_t *sub_filtered = NULL;
|
uint8_t *sub_filtered = NULL;
|
||||||
uint8_t *avg_filtered = NULL;
|
uint8_t *avg_filtered = NULL;
|
||||||
uint8_t *paeth_filtered = NULL;
|
uint8_t *paeth_filtered = NULL;
|
||||||
uint8_t *prev_encoded = NULL;
|
uint8_t *prev_encoded = NULL;
|
||||||
uint8_t *encode_target = NULL;
|
uint8_t *encode_target = NULL;
|
||||||
void *stream = NULL;
|
void *stream = NULL;
|
||||||
RFILE *file = retro_fopen(path, RFILE_MODE_WRITE, -1);
|
RFILE *file = retro_fopen(path, RFILE_MODE_WRITE, -1);
|
||||||
if (!file)
|
if (!file)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
stream_backend = file_archive_get_default_file_backend();
|
stream_backend = file_archive_get_default_file_backend();
|
||||||
|
|
||||||
if (retro_fwrite(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
|
if (retro_fwrite(file, png_magic, sizeof(png_magic)) != sizeof(png_magic))
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
ihdr.width = width;
|
ihdr.width = width;
|
||||||
ihdr.height = height;
|
ihdr.height = height;
|
||||||
ihdr.depth = 8;
|
ihdr.depth = 8;
|
||||||
ihdr.color_type = bpp == sizeof(uint32_t) ? 6 : 2; /* RGBA or RGB */
|
ihdr.color_type = bpp == sizeof(uint32_t) ? 6 : 2; /* RGBA or RGB */
|
||||||
if (!png_write_ihdr(file, &ihdr))
|
if (!png_write_ihdr(file, &ihdr))
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
encode_buf_size = (width * bpp + 1) * height;
|
encode_buf_size = (width * bpp + 1) * height;
|
||||||
encode_buf = (uint8_t*)malloc(encode_buf_size);
|
encode_buf = (uint8_t*)malloc(encode_buf_size);
|
||||||
if (!encode_buf)
|
if (!encode_buf)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
prev_encoded = (uint8_t*)calloc(1, width * bpp);
|
prev_encoded = (uint8_t*)calloc(1, width * bpp);
|
||||||
if (!prev_encoded)
|
if (!prev_encoded)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
rgba_line = (uint8_t*)malloc(width * bpp);
|
rgba_line = (uint8_t*)malloc(width * bpp);
|
||||||
up_filtered = (uint8_t*)malloc(width * bpp);
|
up_filtered = (uint8_t*)malloc(width * bpp);
|
||||||
sub_filtered = (uint8_t*)malloc(width * bpp);
|
sub_filtered = (uint8_t*)malloc(width * bpp);
|
||||||
avg_filtered = (uint8_t*)malloc(width * bpp);
|
avg_filtered = (uint8_t*)malloc(width * bpp);
|
||||||
paeth_filtered = (uint8_t*)malloc(width * bpp);
|
paeth_filtered = (uint8_t*)malloc(width * bpp);
|
||||||
if (!rgba_line || !up_filtered || !sub_filtered || !avg_filtered || !paeth_filtered)
|
if (!rgba_line || !up_filtered || !sub_filtered || !avg_filtered || !paeth_filtered)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
encode_target = encode_buf;
|
encode_target = encode_buf;
|
||||||
for (h = 0; h < height;
|
for (h = 0; h < height;
|
||||||
h++, encode_target += width * bpp, data += pitch)
|
h++, encode_target += width * bpp, data += pitch)
|
||||||
{
|
{
|
||||||
if (bpp == sizeof(uint32_t))
|
if (bpp == sizeof(uint32_t))
|
||||||
copy_argb_line(rgba_line, (const uint32_t*)data, width);
|
copy_argb_line(rgba_line, (const uint32_t*)data, width);
|
||||||
else
|
else
|
||||||
copy_bgr24_line(rgba_line, data, width);
|
copy_bgr24_line(rgba_line, data, width);
|
||||||
|
|
||||||
/* Try every filtering method, and choose the method
|
/* Try every filtering method, and choose the method
|
||||||
* which has most entries as zero.
|
* which has most entries as zero.
|
||||||
*
|
*
|
||||||
* This is probably not very optimal, but it's very
|
* This is probably not very optimal, but it's very
|
||||||
* simple to implement.
|
* simple to implement.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned none_score = count_sad(rgba_line, width * bpp);
|
unsigned none_score = count_sad(rgba_line, width * bpp);
|
||||||
unsigned up_score = filter_up(up_filtered, rgba_line, prev_encoded, width, bpp);
|
unsigned up_score = filter_up(up_filtered, rgba_line, prev_encoded, width, bpp);
|
||||||
unsigned sub_score = filter_sub(sub_filtered, rgba_line, width, bpp);
|
unsigned sub_score = filter_sub(sub_filtered, rgba_line, width, bpp);
|
||||||
unsigned avg_score = filter_avg(avg_filtered, rgba_line, prev_encoded, width, bpp);
|
unsigned avg_score = filter_avg(avg_filtered, rgba_line, prev_encoded, width, bpp);
|
||||||
unsigned paeth_score = filter_paeth(paeth_filtered, rgba_line, prev_encoded, width, bpp);
|
unsigned paeth_score = filter_paeth(paeth_filtered, rgba_line, prev_encoded, width, bpp);
|
||||||
|
|
||||||
uint8_t filter = 0;
|
uint8_t filter = 0;
|
||||||
unsigned min_sad = none_score;
|
unsigned min_sad = none_score;
|
||||||
const uint8_t *chosen_filtered = rgba_line;
|
const uint8_t *chosen_filtered = rgba_line;
|
||||||
|
|
||||||
if (sub_score < min_sad)
|
if (sub_score < min_sad)
|
||||||
{
|
{
|
||||||
filter = 1;
|
filter = 1;
|
||||||
chosen_filtered = sub_filtered;
|
chosen_filtered = sub_filtered;
|
||||||
min_sad = sub_score;
|
min_sad = sub_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (up_score < min_sad)
|
if (up_score < min_sad)
|
||||||
{
|
{
|
||||||
filter = 2;
|
filter = 2;
|
||||||
chosen_filtered = up_filtered;
|
chosen_filtered = up_filtered;
|
||||||
min_sad = up_score;
|
min_sad = up_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avg_score < min_sad)
|
if (avg_score < min_sad)
|
||||||
{
|
{
|
||||||
filter = 3;
|
filter = 3;
|
||||||
chosen_filtered = avg_filtered;
|
chosen_filtered = avg_filtered;
|
||||||
min_sad = avg_score;
|
min_sad = avg_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paeth_score < min_sad)
|
if (paeth_score < min_sad)
|
||||||
{
|
{
|
||||||
filter = 4;
|
filter = 4;
|
||||||
chosen_filtered = paeth_filtered;
|
chosen_filtered = paeth_filtered;
|
||||||
min_sad = paeth_score;
|
min_sad = paeth_score;
|
||||||
}
|
}
|
||||||
|
|
||||||
*encode_target++ = filter;
|
*encode_target++ = filter;
|
||||||
memcpy(encode_target, chosen_filtered, width * bpp);
|
memcpy(encode_target, chosen_filtered, width * bpp);
|
||||||
|
|
||||||
memcpy(prev_encoded, rgba_line, width * bpp);
|
memcpy(prev_encoded, rgba_line, width * bpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deflate_buf = (uint8_t*)malloc(encode_buf_size * 2); /* Just to be sure. */
|
deflate_buf = (uint8_t*)malloc(encode_buf_size * 2); /* Just to be sure. */
|
||||||
if (!deflate_buf)
|
if (!deflate_buf)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
stream = stream_backend->stream_new();
|
stream = stream_backend->stream_new();
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
stream_backend->stream_set(
|
stream_backend->stream_set(
|
||||||
stream,
|
stream,
|
||||||
encode_buf_size,
|
encode_buf_size,
|
||||||
encode_buf_size * 2,
|
encode_buf_size * 2,
|
||||||
encode_buf,
|
encode_buf,
|
||||||
deflate_buf + 8);
|
deflate_buf + 8);
|
||||||
|
|
||||||
stream_backend->stream_compress_init(stream, 9);
|
stream_backend->stream_compress_init(stream, 9);
|
||||||
|
|
||||||
if (stream_backend->stream_compress_data_to_file(stream) != 1)
|
if (stream_backend->stream_compress_data_to_file(stream) != 1)
|
||||||
{
|
{
|
||||||
stream_backend->stream_compress_free(stream);
|
stream_backend->stream_compress_free(stream);
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_backend->stream_compress_free(stream);
|
stream_backend->stream_compress_free(stream);
|
||||||
|
|
||||||
memcpy(deflate_buf + 4, "IDAT", 4);
|
memcpy(deflate_buf + 4, "IDAT", 4);
|
||||||
dword_write_be(deflate_buf + 0, stream_backend->stream_get_total_out(stream));
|
dword_write_be(deflate_buf + 0, stream_backend->stream_get_total_out(stream));
|
||||||
if (!png_write_idat(file, deflate_buf, stream_backend->stream_get_total_out(stream) + 8))
|
if (!png_write_idat(file, deflate_buf, stream_backend->stream_get_total_out(stream) + 8))
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
if (!png_write_iend(file))
|
if (!png_write_iend(file))
|
||||||
GOTO_END_ERROR();
|
GOTO_END_ERROR();
|
||||||
|
|
||||||
end:
|
end:
|
||||||
retro_fclose(file);
|
retro_fclose(file);
|
||||||
free(encode_buf);
|
free(encode_buf);
|
||||||
free(deflate_buf);
|
free(deflate_buf);
|
||||||
free(rgba_line);
|
free(rgba_line);
|
||||||
free(prev_encoded);
|
free(prev_encoded);
|
||||||
free(up_filtered);
|
free(up_filtered);
|
||||||
free(sub_filtered);
|
free(sub_filtered);
|
||||||
free(avg_filtered);
|
free(avg_filtered);
|
||||||
free(paeth_filtered);
|
free(paeth_filtered);
|
||||||
|
|
||||||
stream_backend->stream_free(stream);
|
stream_backend->stream_free(stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rpng_save_image_argb(const char *path, const uint32_t *data,
|
bool rpng_save_image_argb(const char *path, const uint32_t *data,
|
||||||
unsigned width, unsigned height, unsigned pitch)
|
unsigned width, unsigned height, unsigned pitch)
|
||||||
{
|
{
|
||||||
return rpng_save_image(path, (const uint8_t*)data,
|
return rpng_save_image(path, (const uint8_t*)data,
|
||||||
width, height, pitch, sizeof(uint32_t));
|
width, height, pitch, sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rpng_save_image_bgr24(const char *path, const uint8_t *data,
|
bool rpng_save_image_bgr24(const char *path, const uint8_t *data,
|
||||||
unsigned width, unsigned height, unsigned pitch)
|
unsigned width, unsigned height, unsigned pitch)
|
||||||
{
|
{
|
||||||
return rpng_save_image(path, (const uint8_t*)data,
|
return rpng_save_image(path, (const uint8_t*)data,
|
||||||
width, height, pitch, 3);
|
width, height, pitch, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,71 +1,71 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rpng.c).
|
* The following license statement only applies to this file (rpng_internal.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _RPNG_COMMON_H
|
#ifndef _RPNG_COMMON_H
|
||||||
#define _RPNG_COMMON_H
|
#define _RPNG_COMMON_H
|
||||||
|
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <formats/rpng.h>
|
#include <formats/rpng.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#undef GOTO_END_ERROR
|
#undef GOTO_END_ERROR
|
||||||
#define GOTO_END_ERROR() do { \
|
#define GOTO_END_ERROR() do { \
|
||||||
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
|
fprintf(stderr, "[RPNG]: Error in line %d.\n", __LINE__); \
|
||||||
ret = false; \
|
ret = false; \
|
||||||
goto end; \
|
goto end; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#ifndef ARRAY_SIZE
|
#ifndef ARRAY_SIZE
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const uint8_t png_magic[8] = {
|
static const uint8_t png_magic[8] = {
|
||||||
0x89, 'P', 'N', 'G', 0x0d, 0x0a, 0x1a, 0x0a,
|
0x89, 'P', 'N', 'G', 0x0d, 0x0a, 0x1a, 0x0a,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct png_ihdr
|
struct png_ihdr
|
||||||
{
|
{
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint8_t depth;
|
uint8_t depth;
|
||||||
uint8_t color_type;
|
uint8_t color_type;
|
||||||
uint8_t compression;
|
uint8_t compression;
|
||||||
uint8_t filter;
|
uint8_t filter;
|
||||||
uint8_t interlace;
|
uint8_t interlace;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Paeth prediction filter. */
|
/* Paeth prediction filter. */
|
||||||
static INLINE int paeth(int a, int b, int c)
|
static INLINE int paeth(int a, int b, int c)
|
||||||
{
|
{
|
||||||
int p = a + b - c;
|
int p = a + b - c;
|
||||||
int pa = abs(p - a);
|
int pa = abs(p - a);
|
||||||
int pb = abs(p - b);
|
int pb = abs(p - b);
|
||||||
int pc = abs(p - c);
|
int pc = abs(p - c);
|
||||||
|
|
||||||
if (pa <= pb && pa <= pc)
|
if (pa <= pb && pa <= pc)
|
||||||
return a;
|
return a;
|
||||||
else if (pb <= pc)
|
else if (pb <= pc)
|
||||||
return b;
|
return b;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,133 +1,133 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rpng_test.c).
|
* The following license statement only applies to this file (rpng_test.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef HAVE_IMLIB2
|
#ifdef HAVE_IMLIB2
|
||||||
#include <Imlib2.h>
|
#include <Imlib2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <file/nbio.h>
|
#include <file/nbio.h>
|
||||||
#include <formats/rpng.h>
|
#include <formats/rpng.h>
|
||||||
|
|
||||||
static int test_rpng(const char *in_path)
|
static int test_rpng(const char *in_path)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IMLIB2
|
#ifdef HAVE_IMLIB2
|
||||||
Imlib_Image img;
|
Imlib_Image img;
|
||||||
const uint32_t *imlib_data = NULL;
|
const uint32_t *imlib_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
const uint32_t test_data[] = {
|
const uint32_t test_data[] = {
|
||||||
0xff000000 | 0x50, 0xff000000 | 0x80,
|
0xff000000 | 0x50, 0xff000000 | 0x80,
|
||||||
0xff000000 | 0x40, 0xff000000 | 0x88,
|
0xff000000 | 0x40, 0xff000000 | 0x88,
|
||||||
0xff000000 | 0x50, 0xff000000 | 0x80,
|
0xff000000 | 0x50, 0xff000000 | 0x80,
|
||||||
0xff000000 | 0x40, 0xff000000 | 0x88,
|
0xff000000 | 0x40, 0xff000000 | 0x88,
|
||||||
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
||||||
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
||||||
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
||||||
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
0xff000000 | 0xc3, 0xff000000 | 0xd3,
|
||||||
};
|
};
|
||||||
uint32_t *data = NULL;
|
uint32_t *data = NULL;
|
||||||
unsigned width = 0;
|
unsigned width = 0;
|
||||||
unsigned height = 0;
|
unsigned height = 0;
|
||||||
|
|
||||||
if (!rpng_save_image_argb("/tmp/test.png", test_data, 4, 4, 16))
|
if (!rpng_save_image_argb("/tmp/test.png", test_data, 4, 4, 16))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!rpng_load_image_argb(in_path, &data, &width, &height))
|
if (!rpng_load_image_argb(in_path, &data, &width, &height))
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
fprintf(stderr, "Path: %s.\n", in_path);
|
fprintf(stderr, "Path: %s.\n", in_path);
|
||||||
fprintf(stderr, "Got image: %u x %u.\n", width, height);
|
fprintf(stderr, "Got image: %u x %u.\n", width, height);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "\nRPNG:\n");
|
fprintf(stderr, "\nRPNG:\n");
|
||||||
for (unsigned h = 0; h < height; h++)
|
for (unsigned h = 0; h < height; h++)
|
||||||
{
|
{
|
||||||
unsigned w;
|
unsigned w;
|
||||||
for (w = 0; w < width; w++)
|
for (w = 0; w < width; w++)
|
||||||
fprintf(stderr, "[%08x] ", data[h * width + w]);
|
fprintf(stderr, "[%08x] ", data[h * width + w]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_IMLIB2
|
#ifdef HAVE_IMLIB2
|
||||||
/* Validate with imlib2 as well. */
|
/* Validate with imlib2 as well. */
|
||||||
img = imlib_load_image(in_path);
|
img = imlib_load_image(in_path);
|
||||||
if (!img)
|
if (!img)
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
imlib_context_set_image(img);
|
imlib_context_set_image(img);
|
||||||
|
|
||||||
width = imlib_image_get_width();
|
width = imlib_image_get_width();
|
||||||
height = imlib_image_get_width();
|
height = imlib_image_get_width();
|
||||||
imlib_data = imlib_image_get_data_for_reading_only();
|
imlib_data = imlib_image_get_data_for_reading_only();
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
fprintf(stderr, "\nImlib:\n");
|
fprintf(stderr, "\nImlib:\n");
|
||||||
for (unsigned h = 0; h < height; h++)
|
for (unsigned h = 0; h < height; h++)
|
||||||
{
|
{
|
||||||
for (unsigned w = 0; w < width; w++)
|
for (unsigned w = 0; w < width; w++)
|
||||||
fprintf(stderr, "[%08x] ", imlib_data[h * width + w]);
|
fprintf(stderr, "[%08x] ", imlib_data[h * width + w]);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (memcmp(imlib_data, data, width * height * sizeof(uint32_t)) != 0)
|
if (memcmp(imlib_data, data, width * height * sizeof(uint32_t)) != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Imlib and RPNG differs!\n");
|
fprintf(stderr, "Imlib and RPNG differs!\n");
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Imlib and RPNG are equivalent!\n");
|
fprintf(stderr, "Imlib and RPNG are equivalent!\n");
|
||||||
|
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
#endif
|
#endif
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *in_path = "/tmp/test.png";
|
const char *in_path = "/tmp/test.png";
|
||||||
|
|
||||||
if (argc > 2)
|
if (argc > 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <png file>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <png file>\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
in_path = argv[1];
|
in_path = argv[1];
|
||||||
|
|
||||||
fprintf(stderr, "Doing tests...\n");
|
fprintf(stderr, "Doing tests...\n");
|
||||||
|
|
||||||
if (test_rpng(in_path) != 0)
|
if (test_rpng(in_path) != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Test failed.\n");
|
fprintf(stderr, "Test failed.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +1,103 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
*
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
* The following license statement only applies to this file (rtga.c).
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
*
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* Permission is hereby granted, free of charge,
|
||||||
*
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
*/
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#include <stdio.h>
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
#include <stdint.h>
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
#include <stdlib.h>
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
#include <string.h>
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <formats/tga.h>
|
*/
|
||||||
#include <formats/image.h>
|
|
||||||
|
#include <stdio.h>
|
||||||
bool rtga_image_load_shift(uint8_t *buf,
|
#include <stdint.h>
|
||||||
void *data,
|
#include <stdlib.h>
|
||||||
unsigned a_shift, unsigned r_shift,
|
#include <string.h>
|
||||||
unsigned g_shift, unsigned b_shift)
|
|
||||||
{
|
#include <formats/tga.h>
|
||||||
unsigned i, bits, size, bits_mul;
|
#include <formats/image.h>
|
||||||
uint8_t info[6] = {0};
|
|
||||||
unsigned width = 0;
|
bool rtga_image_load_shift(uint8_t *buf,
|
||||||
unsigned height = 0;
|
void *data,
|
||||||
const uint8_t *tmp = NULL;
|
unsigned a_shift, unsigned r_shift,
|
||||||
struct texture_image *out_img = (struct texture_image*)data;
|
unsigned g_shift, unsigned b_shift)
|
||||||
|
{
|
||||||
if (!buf || buf[2] != 2)
|
unsigned i, bits, size, bits_mul;
|
||||||
{
|
uint8_t info[6] = {0};
|
||||||
fprintf(stderr, "TGA image is not uncompressed RGB.\n");
|
unsigned width = 0;
|
||||||
goto error;
|
unsigned height = 0;
|
||||||
}
|
const uint8_t *tmp = NULL;
|
||||||
|
struct texture_image *out_img = (struct texture_image*)data;
|
||||||
memcpy(info, buf + 12, 6);
|
|
||||||
|
if (!buf || buf[2] != 2)
|
||||||
width = info[0] + ((unsigned)info[1] * 256);
|
{
|
||||||
height = info[2] + ((unsigned)info[3] * 256);
|
fprintf(stderr, "TGA image is not uncompressed RGB.\n");
|
||||||
bits = info[4];
|
goto error;
|
||||||
|
}
|
||||||
fprintf(stderr, "Loaded TGA: (%ux%u @ %u bpp)\n", width, height, bits);
|
|
||||||
|
memcpy(info, buf + 12, 6);
|
||||||
size = width * height * sizeof(uint32_t);
|
|
||||||
out_img->pixels = (uint32_t*)malloc(size);
|
width = info[0] + ((unsigned)info[1] * 256);
|
||||||
out_img->width = width;
|
height = info[2] + ((unsigned)info[3] * 256);
|
||||||
out_img->height = height;
|
bits = info[4];
|
||||||
|
|
||||||
if (!out_img->pixels)
|
fprintf(stderr, "Loaded TGA: (%ux%u @ %u bpp)\n", width, height, bits);
|
||||||
{
|
|
||||||
fprintf(stderr, "Failed to allocate TGA pixels.\n");
|
size = width * height * sizeof(uint32_t);
|
||||||
goto error;
|
out_img->pixels = (uint32_t*)malloc(size);
|
||||||
}
|
out_img->width = width;
|
||||||
|
out_img->height = height;
|
||||||
tmp = buf + 18;
|
|
||||||
bits_mul = 3;
|
if (!out_img->pixels)
|
||||||
|
{
|
||||||
if (bits != 32 && bits != 24)
|
fprintf(stderr, "Failed to allocate TGA pixels.\n");
|
||||||
{
|
goto error;
|
||||||
fprintf(stderr, "Bit depth of TGA image is wrong. Only 32-bit and 24-bit supported.\n");
|
}
|
||||||
goto error;
|
|
||||||
}
|
tmp = buf + 18;
|
||||||
|
bits_mul = 3;
|
||||||
if (bits == 32)
|
|
||||||
bits_mul = 4;
|
if (bits != 32 && bits != 24)
|
||||||
|
{
|
||||||
for (i = 0; i < width * height; i++)
|
fprintf(stderr, "Bit depth of TGA image is wrong. Only 32-bit and 24-bit supported.\n");
|
||||||
{
|
goto error;
|
||||||
uint32_t b = tmp[i * bits_mul + 0];
|
}
|
||||||
uint32_t g = tmp[i * bits_mul + 1];
|
|
||||||
uint32_t r = tmp[i * bits_mul + 2];
|
if (bits == 32)
|
||||||
uint32_t a = tmp[i * bits_mul + 3];
|
bits_mul = 4;
|
||||||
|
|
||||||
if (bits == 24)
|
for (i = 0; i < width * height; i++)
|
||||||
a = 0xff;
|
{
|
||||||
|
uint32_t b = tmp[i * bits_mul + 0];
|
||||||
out_img->pixels[i] = (a << a_shift) |
|
uint32_t g = tmp[i * bits_mul + 1];
|
||||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
uint32_t r = tmp[i * bits_mul + 2];
|
||||||
}
|
uint32_t a = tmp[i * bits_mul + 3];
|
||||||
|
|
||||||
return true;
|
if (bits == 24)
|
||||||
|
a = 0xff;
|
||||||
error:
|
|
||||||
if (out_img->pixels)
|
out_img->pixels[i] = (a << a_shift) |
|
||||||
free(out_img->pixels);
|
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||||
|
}
|
||||||
out_img->pixels = NULL;
|
|
||||||
out_img->width = out_img->height = 0;
|
return true;
|
||||||
return false;
|
|
||||||
}
|
error:
|
||||||
|
if (out_img->pixels)
|
||||||
|
free(out_img->pixels);
|
||||||
|
|
||||||
|
out_img->pixels = NULL;
|
||||||
|
out_img->width = out_img->height = 0;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -1,492 +1,492 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rxml.c).
|
* The following license statement only applies to this file (rxml.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_file.h>
|
#include <streams/file_stream.h>
|
||||||
#include <compat/posix_string.h>
|
#include <compat/posix_string.h>
|
||||||
|
|
||||||
#include <formats/rxml.h>
|
#include <formats/rxml.h>
|
||||||
|
|
||||||
struct rxml_document
|
struct rxml_document
|
||||||
{
|
{
|
||||||
struct rxml_node *root_node;
|
struct rxml_node *root_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rxml_node *rxml_root_node(rxml_document_t *doc)
|
struct rxml_node *rxml_root_node(rxml_document_t *doc)
|
||||||
{
|
{
|
||||||
if (doc)
|
if (doc)
|
||||||
return doc->root_node;
|
return doc->root_node;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rxml_free_node(struct rxml_node *node)
|
static void rxml_free_node(struct rxml_node *node)
|
||||||
{
|
{
|
||||||
struct rxml_node *head = NULL;
|
struct rxml_node *head = NULL;
|
||||||
struct rxml_attrib_node *attrib_node_head = NULL;
|
struct rxml_attrib_node *attrib_node_head = NULL;
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (head = node->children; head; )
|
for (head = node->children; head; )
|
||||||
{
|
{
|
||||||
struct rxml_node *next_node = (struct rxml_node*)head->next;
|
struct rxml_node *next_node = (struct rxml_node*)head->next;
|
||||||
rxml_free_node(head);
|
rxml_free_node(head);
|
||||||
head = next_node;
|
head = next_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (attrib_node_head = node->attrib; attrib_node_head; )
|
for (attrib_node_head = node->attrib; attrib_node_head; )
|
||||||
{
|
{
|
||||||
struct rxml_attrib_node *next_attrib = NULL;
|
struct rxml_attrib_node *next_attrib = NULL;
|
||||||
|
|
||||||
if (!attrib_node_head)
|
if (!attrib_node_head)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
next_attrib = (struct rxml_attrib_node*)attrib_node_head->next;
|
next_attrib = (struct rxml_attrib_node*)attrib_node_head->next;
|
||||||
|
|
||||||
if (!next_attrib)
|
if (!next_attrib)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (attrib_node_head->attrib)
|
if (attrib_node_head->attrib)
|
||||||
free(attrib_node_head->attrib);
|
free(attrib_node_head->attrib);
|
||||||
if (attrib_node_head->value)
|
if (attrib_node_head->value)
|
||||||
free(attrib_node_head->value);
|
free(attrib_node_head->value);
|
||||||
if (attrib_node_head)
|
if (attrib_node_head)
|
||||||
free(attrib_node_head);
|
free(attrib_node_head);
|
||||||
|
|
||||||
attrib_node_head = next_attrib;
|
attrib_node_head = next_attrib;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->name)
|
if (node->name)
|
||||||
free(node->name);
|
free(node->name);
|
||||||
if (node->data)
|
if (node->data)
|
||||||
free(node->data);
|
free(node->data);
|
||||||
if (node)
|
if (node)
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool validate_header(const char **ptr)
|
static bool validate_header(const char **ptr)
|
||||||
{
|
{
|
||||||
if (memcmp(*ptr, "<?xml", 5) == 0)
|
if (memcmp(*ptr, "<?xml", 5) == 0)
|
||||||
{
|
{
|
||||||
const char *eol = strstr(*ptr, "?>\n");
|
const char *eol = strstr(*ptr, "?>\n");
|
||||||
if (!eol)
|
if (!eol)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Always use UTF-8. Don't really care to check. */
|
/* Always use UTF-8. Don't really care to check. */
|
||||||
*ptr = eol + 3;
|
*ptr = eol + 3;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool range_is_space(const char *begin, const char *end)
|
static bool range_is_space(const char *begin, const char *end)
|
||||||
{
|
{
|
||||||
for (; begin < end; begin++)
|
for (; begin < end; begin++)
|
||||||
if (!isspace(*begin))
|
if (!isspace(*begin))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void skip_spaces(const char **ptr_)
|
static void skip_spaces(const char **ptr_)
|
||||||
{
|
{
|
||||||
const char *ptr = *ptr_;
|
const char *ptr = *ptr_;
|
||||||
while (isspace(*ptr))
|
while (isspace(*ptr))
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
*ptr_ = ptr;
|
*ptr_ = ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *strdup_range(const char *begin, const char *end)
|
static char *strdup_range(const char *begin, const char *end)
|
||||||
{
|
{
|
||||||
ptrdiff_t len = end - begin;
|
ptrdiff_t len = end - begin;
|
||||||
char *ret = (char*)malloc(len + 1);
|
char *ret = (char*)malloc(len + 1);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy(ret, begin, len);
|
memcpy(ret, begin, len);
|
||||||
ret[len] = '\0';
|
ret[len] = '\0';
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *strdup_range_escape(const char *begin, const char *end)
|
static char *strdup_range_escape(const char *begin, const char *end)
|
||||||
{
|
{
|
||||||
/* Escaping is ignored. Assume we don't deal with that. */
|
/* Escaping is ignored. Assume we don't deal with that. */
|
||||||
return strdup_range(begin, end);
|
return strdup_range(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rxml_attrib_node *rxml_parse_attrs(const char *str)
|
static struct rxml_attrib_node *rxml_parse_attrs(const char *str)
|
||||||
{
|
{
|
||||||
char *copy = strdup(str);
|
char *copy = strdup(str);
|
||||||
if (!copy)
|
if (!copy)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
char *last_char = copy + strlen(copy) - 1;
|
char *last_char = copy + strlen(copy) - 1;
|
||||||
if (*last_char == '/')
|
if (*last_char == '/')
|
||||||
*last_char = '\0';
|
*last_char = '\0';
|
||||||
|
|
||||||
struct rxml_attrib_node *list = NULL;
|
struct rxml_attrib_node *list = NULL;
|
||||||
struct rxml_attrib_node *tail = NULL;
|
struct rxml_attrib_node *tail = NULL;
|
||||||
|
|
||||||
char *attrib = NULL;
|
char *attrib = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
char *save;
|
char *save;
|
||||||
const char *elem = strtok_r(copy, " \n\t\f\v\r", &save);
|
const char *elem = strtok_r(copy, " \n\t\f\v\r", &save);
|
||||||
while (elem)
|
while (elem)
|
||||||
{
|
{
|
||||||
const char *eq = strstr(elem, "=\"");
|
const char *eq = strstr(elem, "=\"");
|
||||||
if (!eq)
|
if (!eq)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
const char *end = strrchr(eq + 2, '\"');
|
const char *end = strrchr(eq + 2, '\"');
|
||||||
if (!end || end != (elem + strlen(elem) - 1))
|
if (!end || end != (elem + strlen(elem) - 1))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
attrib = strdup_range_escape(elem, eq);
|
attrib = strdup_range_escape(elem, eq);
|
||||||
value = strdup_range_escape(eq + 2, end);
|
value = strdup_range_escape(eq + 2, end);
|
||||||
if (!attrib || !value)
|
if (!attrib || !value)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
struct rxml_attrib_node *new_node =
|
struct rxml_attrib_node *new_node =
|
||||||
(struct rxml_attrib_node*)calloc(1, sizeof(*new_node));
|
(struct rxml_attrib_node*)calloc(1, sizeof(*new_node));
|
||||||
if (!new_node)
|
if (!new_node)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
new_node->attrib = attrib;
|
new_node->attrib = attrib;
|
||||||
new_node->value = value;
|
new_node->value = value;
|
||||||
attrib = NULL;
|
attrib = NULL;
|
||||||
value = NULL;
|
value = NULL;
|
||||||
|
|
||||||
if (tail)
|
if (tail)
|
||||||
{
|
{
|
||||||
tail->next = new_node;
|
tail->next = new_node;
|
||||||
tail = new_node;
|
tail = new_node;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
list = tail = new_node;
|
list = tail = new_node;
|
||||||
|
|
||||||
elem = strtok_r(NULL, " \n\t\f\v\r", &save);
|
elem = strtok_r(NULL, " \n\t\f\v\r", &save);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (copy)
|
if (copy)
|
||||||
free(copy);
|
free(copy);
|
||||||
if (attrib)
|
if (attrib)
|
||||||
free(attrib);
|
free(attrib);
|
||||||
if (value)
|
if (value)
|
||||||
free(value);
|
free(value);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *find_first_space(const char *str)
|
static char *find_first_space(const char *str)
|
||||||
{
|
{
|
||||||
while (*str && !isspace(*str))
|
while (*str && !isspace(*str))
|
||||||
str++;
|
str++;
|
||||||
|
|
||||||
return isspace(*str) ? (char*)str : NULL;
|
return isspace(*str) ? (char*)str : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool rxml_parse_tag(struct rxml_node *node, const char *str)
|
static bool rxml_parse_tag(struct rxml_node *node, const char *str)
|
||||||
{
|
{
|
||||||
const char *str_ptr = str;
|
const char *str_ptr = str;
|
||||||
skip_spaces(&str_ptr);
|
skip_spaces(&str_ptr);
|
||||||
|
|
||||||
const char *name_end = find_first_space(str_ptr);
|
const char *name_end = find_first_space(str_ptr);
|
||||||
if (name_end)
|
if (name_end)
|
||||||
{
|
{
|
||||||
node->name = strdup_range(str_ptr, name_end);
|
node->name = strdup_range(str_ptr, name_end);
|
||||||
if (!node->name || !*node->name)
|
if (!node->name || !*node->name)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node->attrib = rxml_parse_attrs(name_end);
|
node->attrib = rxml_parse_attrs(name_end);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node->name = strdup(str_ptr);
|
node->name = strdup(str_ptr);
|
||||||
return node->name && *node->name;
|
return node->name && *node->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct rxml_node *rxml_parse_node(const char **ptr_)
|
static struct rxml_node *rxml_parse_node(const char **ptr_)
|
||||||
{
|
{
|
||||||
const char *ptr = NULL;
|
const char *ptr = NULL;
|
||||||
const char *closing = NULL;
|
const char *closing = NULL;
|
||||||
char *str = NULL;
|
char *str = NULL;
|
||||||
bool is_closing = false;
|
bool is_closing = false;
|
||||||
|
|
||||||
struct rxml_node *node = (struct rxml_node*)calloc(1, sizeof(*node));
|
struct rxml_node *node = (struct rxml_node*)calloc(1, sizeof(*node));
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
skip_spaces(ptr_);
|
skip_spaces(ptr_);
|
||||||
|
|
||||||
ptr = *ptr_;
|
ptr = *ptr_;
|
||||||
if (*ptr != '<')
|
if (*ptr != '<')
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
closing = strchr(ptr, '>');
|
closing = strchr(ptr, '>');
|
||||||
if (!closing)
|
if (!closing)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
str = strdup_range(ptr + 1, closing);
|
str = strdup_range(ptr + 1, closing);
|
||||||
if (!str)
|
if (!str)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!rxml_parse_tag(node, str))
|
if (!rxml_parse_tag(node, str))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Are spaces between / and > allowed? */
|
/* Are spaces between / and > allowed? */
|
||||||
is_closing = strstr(ptr, "/>") + 1 == closing;
|
is_closing = strstr(ptr, "/>") + 1 == closing;
|
||||||
|
|
||||||
/* Look for more data. Either child nodes or data. */
|
/* Look for more data. Either child nodes or data. */
|
||||||
if (!is_closing)
|
if (!is_closing)
|
||||||
{
|
{
|
||||||
size_t closing_tag_size = strlen(node->name) + 4;
|
size_t closing_tag_size = strlen(node->name) + 4;
|
||||||
char *closing_tag = (char*)malloc(closing_tag_size);
|
char *closing_tag = (char*)malloc(closing_tag_size);
|
||||||
|
|
||||||
const char *cdata_start = NULL;
|
const char *cdata_start = NULL;
|
||||||
const char *child_start = NULL;
|
const char *child_start = NULL;
|
||||||
const char *closing_start = NULL;
|
const char *closing_start = NULL;
|
||||||
|
|
||||||
if (!closing_tag)
|
if (!closing_tag)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
snprintf(closing_tag, closing_tag_size, "</%s>", node->name);
|
snprintf(closing_tag, closing_tag_size, "</%s>", node->name);
|
||||||
|
|
||||||
cdata_start = strstr(closing + 1, "<![CDATA[");
|
cdata_start = strstr(closing + 1, "<![CDATA[");
|
||||||
child_start = strchr(closing + 1, '<');
|
child_start = strchr(closing + 1, '<');
|
||||||
closing_start = strstr(closing + 1, closing_tag);
|
closing_start = strstr(closing + 1, closing_tag);
|
||||||
|
|
||||||
if (!closing_start)
|
if (!closing_start)
|
||||||
{
|
{
|
||||||
free(closing_tag);
|
free(closing_tag);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cdata_start && range_is_space(closing + 1, cdata_start))
|
if (cdata_start && range_is_space(closing + 1, cdata_start))
|
||||||
{
|
{
|
||||||
/* CDATA section */
|
/* CDATA section */
|
||||||
const char *cdata_end = strstr(cdata_start, "]]>");
|
const char *cdata_end = strstr(cdata_start, "]]>");
|
||||||
if (!cdata_end)
|
if (!cdata_end)
|
||||||
{
|
{
|
||||||
free(closing_tag);
|
free(closing_tag);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
node->data = strdup_range(cdata_start +
|
node->data = strdup_range(cdata_start +
|
||||||
strlen("<![CDATA["), cdata_end);
|
strlen("<![CDATA["), cdata_end);
|
||||||
}
|
}
|
||||||
else if (closing_start && closing_start == child_start) /* Simple Data */
|
else if (closing_start && closing_start == child_start) /* Simple Data */
|
||||||
node->data = strdup_range(closing + 1, closing_start);
|
node->data = strdup_range(closing + 1, closing_start);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Parse all child nodes. */
|
/* Parse all child nodes. */
|
||||||
struct rxml_node *list = NULL;
|
struct rxml_node *list = NULL;
|
||||||
struct rxml_node *tail = NULL;
|
struct rxml_node *tail = NULL;
|
||||||
const char *first_start = NULL;
|
const char *first_start = NULL;
|
||||||
const char *first_closing = NULL;
|
const char *first_closing = NULL;
|
||||||
|
|
||||||
ptr = child_start;
|
ptr = child_start;
|
||||||
first_start = strchr(ptr, '<');
|
first_start = strchr(ptr, '<');
|
||||||
first_closing = strstr(ptr, "</");
|
first_closing = strstr(ptr, "</");
|
||||||
|
|
||||||
while (
|
while (
|
||||||
first_start &&
|
first_start &&
|
||||||
first_closing &&
|
first_closing &&
|
||||||
(first_start < first_closing)
|
(first_start < first_closing)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct rxml_node *new_node = rxml_parse_node(&ptr);
|
struct rxml_node *new_node = rxml_parse_node(&ptr);
|
||||||
|
|
||||||
if (!new_node)
|
if (!new_node)
|
||||||
{
|
{
|
||||||
free(closing_tag);
|
free(closing_tag);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tail)
|
if (tail)
|
||||||
{
|
{
|
||||||
tail->next = new_node;
|
tail->next = new_node;
|
||||||
tail = new_node;
|
tail = new_node;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
list = tail = new_node;
|
list = tail = new_node;
|
||||||
|
|
||||||
first_start = strchr(ptr, '<');
|
first_start = strchr(ptr, '<');
|
||||||
first_closing = strstr(ptr, "</");
|
first_closing = strstr(ptr, "</");
|
||||||
}
|
}
|
||||||
|
|
||||||
node->children = list;
|
node->children = list;
|
||||||
|
|
||||||
closing_start = strstr(ptr, closing_tag);
|
closing_start = strstr(ptr, closing_tag);
|
||||||
if (!closing_start)
|
if (!closing_start)
|
||||||
{
|
{
|
||||||
free(closing_tag);
|
free(closing_tag);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr_ = closing_start + strlen(closing_tag);
|
*ptr_ = closing_start + strlen(closing_tag);
|
||||||
free(closing_tag);
|
free(closing_tag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*ptr_ = closing + 1;
|
*ptr_ = closing + 1;
|
||||||
|
|
||||||
if (str)
|
if (str)
|
||||||
free(str);
|
free(str);
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (str)
|
if (str)
|
||||||
free(str);
|
free(str);
|
||||||
rxml_free_node(node);
|
rxml_free_node(node);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *purge_xml_comments(const char *str)
|
static char *purge_xml_comments(const char *str)
|
||||||
{
|
{
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
char *new_str = (char*)malloc(len + 1);
|
char *new_str = (char*)malloc(len + 1);
|
||||||
if (!new_str)
|
if (!new_str)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
new_str[len] = '\0';
|
new_str[len] = '\0';
|
||||||
|
|
||||||
char *copy_dest = new_str;
|
char *copy_dest = new_str;
|
||||||
const char *copy_src = str;
|
const char *copy_src = str;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ptrdiff_t copy_len;
|
ptrdiff_t copy_len;
|
||||||
const char *comment_start = strstr(copy_src, "<!--");
|
const char *comment_start = strstr(copy_src, "<!--");
|
||||||
const char *comment_end = strstr(copy_src, "-->");
|
const char *comment_end = strstr(copy_src, "-->");
|
||||||
|
|
||||||
if (!comment_start || !comment_end)
|
if (!comment_start || !comment_end)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
copy_len = comment_start - copy_src;
|
copy_len = comment_start - copy_src;
|
||||||
memcpy(copy_dest, copy_src, copy_len);
|
memcpy(copy_dest, copy_src, copy_len);
|
||||||
|
|
||||||
copy_dest += copy_len;
|
copy_dest += copy_len;
|
||||||
copy_src = comment_end + strlen("-->");
|
copy_src = comment_end + strlen("-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid strcpy() as OpenBSD is anal and hates you
|
/* Avoid strcpy() as OpenBSD is anal and hates you
|
||||||
* for using it even when it's perfectly safe. */
|
* for using it even when it's perfectly safe. */
|
||||||
len = strlen(copy_src);
|
len = strlen(copy_src);
|
||||||
memcpy(copy_dest, copy_src, len);
|
memcpy(copy_dest, copy_src, len);
|
||||||
copy_dest[len] = '\0';
|
copy_dest[len] = '\0';
|
||||||
|
|
||||||
return new_str;
|
return new_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
rxml_document_t *rxml_load_document(const char *path)
|
rxml_document_t *rxml_load_document(const char *path)
|
||||||
{
|
{
|
||||||
#ifndef RXML_TEST
|
#ifndef RXML_TEST
|
||||||
RARCH_WARN("Using RXML as drop in for libxml2. Behavior might be very buggy.\n");
|
RARCH_WARN("Using RXML as drop in for libxml2. Behavior might be very buggy.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *memory_buffer = NULL;
|
char *memory_buffer = NULL;
|
||||||
char *new_memory_buffer = NULL;
|
char *new_memory_buffer = NULL;
|
||||||
const char *mem_ptr = NULL;
|
const char *mem_ptr = NULL;
|
||||||
long len = 0;
|
long len = 0;
|
||||||
RFILE *file = retro_fopen(path, RFILE_MODE_READ, -1);
|
RFILE *file = retro_fopen(path, RFILE_MODE_READ, -1);
|
||||||
if (!file)
|
if (!file)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
rxml_document_t *doc = (rxml_document_t*)calloc(1, sizeof(*doc));
|
rxml_document_t *doc = (rxml_document_t*)calloc(1, sizeof(*doc));
|
||||||
if (!doc)
|
if (!doc)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
retro_fseek(file, 0, SEEK_END);
|
retro_fseek(file, 0, SEEK_END);
|
||||||
len = retro_ftell(file);
|
len = retro_ftell(file);
|
||||||
retro_frewind(file);
|
retro_frewind(file);
|
||||||
|
|
||||||
memory_buffer = (char*)malloc(len + 1);
|
memory_buffer = (char*)malloc(len + 1);
|
||||||
if (!memory_buffer)
|
if (!memory_buffer)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
memory_buffer[len] = '\0';
|
memory_buffer[len] = '\0';
|
||||||
if (retro_fread(file, memory_buffer, len) != (size_t)len)
|
if (retro_fread(file, memory_buffer, len) != (size_t)len)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
retro_fclose(file);
|
retro_fclose(file);
|
||||||
file = NULL;
|
file = NULL;
|
||||||
|
|
||||||
mem_ptr = memory_buffer;
|
mem_ptr = memory_buffer;
|
||||||
|
|
||||||
if (!validate_header(&mem_ptr))
|
if (!validate_header(&mem_ptr))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
new_memory_buffer = purge_xml_comments(mem_ptr);
|
new_memory_buffer = purge_xml_comments(mem_ptr);
|
||||||
if (!new_memory_buffer)
|
if (!new_memory_buffer)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
free(memory_buffer);
|
free(memory_buffer);
|
||||||
mem_ptr = memory_buffer = new_memory_buffer;
|
mem_ptr = memory_buffer = new_memory_buffer;
|
||||||
|
|
||||||
doc->root_node = rxml_parse_node(&mem_ptr);
|
doc->root_node = rxml_parse_node(&mem_ptr);
|
||||||
if (!doc->root_node)
|
if (!doc->root_node)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
free(memory_buffer);
|
free(memory_buffer);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(memory_buffer);
|
free(memory_buffer);
|
||||||
retro_fclose(file);
|
retro_fclose(file);
|
||||||
rxml_free_document(doc);
|
rxml_free_document(doc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rxml_free_document(rxml_document_t *doc)
|
void rxml_free_document(rxml_document_t *doc)
|
||||||
{
|
{
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (doc->root_node)
|
if (doc->root_node)
|
||||||
rxml_free_node(doc->root_node);
|
rxml_free_node(doc->root_node);
|
||||||
|
|
||||||
free(doc);
|
free(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *rxml_node_attrib(struct rxml_node *node, const char *attrib)
|
char *rxml_node_attrib(struct rxml_node *node, const char *attrib)
|
||||||
{
|
{
|
||||||
struct rxml_attrib_node *attribs = NULL;
|
struct rxml_attrib_node *attribs = NULL;
|
||||||
for (attribs = node->attrib; attribs; attribs = attribs->next)
|
for (attribs = node->attrib; attribs; attribs = attribs->next)
|
||||||
{
|
{
|
||||||
if (!strcmp(attrib, attribs->attrib))
|
if (!strcmp(attrib, attribs->attrib))
|
||||||
return attribs->value;
|
return attribs->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,67 +1,67 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rxml_test.c).
|
* The following license statement only applies to this file (rxml_test.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <formats/rxml.h>
|
#include <formats/rxml.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static void print_siblings(struct rxml_node *node, unsigned level)
|
static void print_siblings(struct rxml_node *node, unsigned level)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\n%*sName: %s\n", level * 4, "", node->name);
|
fprintf(stderr, "\n%*sName: %s\n", level * 4, "", node->name);
|
||||||
if (node->data)
|
if (node->data)
|
||||||
fprintf(stderr, "%*sData: %s\n", level * 4, "", node->data);
|
fprintf(stderr, "%*sData: %s\n", level * 4, "", node->data);
|
||||||
|
|
||||||
for (const struct rxml_attrib_node *attrib =
|
for (const struct rxml_attrib_node *attrib =
|
||||||
node->attrib; attrib; attrib = attrib->next)
|
node->attrib; attrib; attrib = attrib->next)
|
||||||
fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "",
|
fprintf(stderr, "%*s Attrib: %s = %s\n", level * 4, "",
|
||||||
attrib->attrib, attrib->value);
|
attrib->attrib, attrib->value);
|
||||||
|
|
||||||
if (node->children)
|
if (node->children)
|
||||||
print_siblings(node->children, level + 1);
|
print_siblings(node->children, level + 1);
|
||||||
|
|
||||||
if (node->next)
|
if (node->next)
|
||||||
print_siblings(node->next, level);
|
print_siblings(node->next, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rxml_log_document(const char *path)
|
static void rxml_log_document(const char *path)
|
||||||
{
|
{
|
||||||
rxml_document_t *doc = rxml_load_document(path);
|
rxml_document_t *doc = rxml_load_document(path);
|
||||||
if (!doc)
|
if (!doc)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "rxml: Failed to load document: %s\n", path);
|
fprintf(stderr, "rxml: Failed to load document: %s\n", path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_siblings(rxml_root_node(doc), 0);
|
print_siblings(rxml_root_node(doc), 0);
|
||||||
rxml_free_document(doc);
|
rxml_free_document(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: %s <path>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <path>\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rxml_log_document(argv[1]);
|
rxml_log_document(argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,251 +1,251 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (matrix_3x3.c).
|
* The following license statement only applies to this file (matrix_3x3.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gfx/math/matrix_3x3.h>
|
#include <gfx/math/matrix_3x3.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define floats_are_equal(x, y) (fabs(x - y) <= 0.00001f * ((x) > (y) ? (y) : (x)))
|
#define floats_are_equal(x, y) (fabs(x - y) <= 0.00001f * ((x) > (y) ? (y) : (x)))
|
||||||
#define float_is_zero(x) (floats_are_equal((x) + 1, 1))
|
#define float_is_zero(x) (floats_are_equal((x) + 1, 1))
|
||||||
|
|
||||||
void matrix_3x3_identity(math_matrix_3x3 *mat)
|
void matrix_3x3_identity(math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
memset(mat, 0, sizeof(*mat));
|
memset(mat, 0, sizeof(*mat));
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
MAT_ELEM_3X3(*mat, i, i) = 1.0f;
|
MAT_ELEM_3X3(*mat, i, i) = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_3x3_inits(math_matrix_3x3 *mat,
|
void matrix_3x3_inits(math_matrix_3x3 *mat,
|
||||||
const float n11, const float n12, const float n13,
|
const float n11, const float n12, const float n13,
|
||||||
const float n21, const float n22, const float n23,
|
const float n21, const float n22, const float n23,
|
||||||
const float n31, const float n32, const float n33)
|
const float n31, const float n32, const float n33)
|
||||||
{
|
{
|
||||||
MAT_ELEM_3X3(*mat, 0, 0) = n11;
|
MAT_ELEM_3X3(*mat, 0, 0) = n11;
|
||||||
MAT_ELEM_3X3(*mat, 0, 1) = n12;
|
MAT_ELEM_3X3(*mat, 0, 1) = n12;
|
||||||
MAT_ELEM_3X3(*mat, 0, 2) = n13;
|
MAT_ELEM_3X3(*mat, 0, 2) = n13;
|
||||||
MAT_ELEM_3X3(*mat, 1, 0) = n21;
|
MAT_ELEM_3X3(*mat, 1, 0) = n21;
|
||||||
MAT_ELEM_3X3(*mat, 1, 1) = n22;
|
MAT_ELEM_3X3(*mat, 1, 1) = n22;
|
||||||
MAT_ELEM_3X3(*mat, 1, 2) = n23;
|
MAT_ELEM_3X3(*mat, 1, 2) = n23;
|
||||||
MAT_ELEM_3X3(*mat, 2, 0) = n31;
|
MAT_ELEM_3X3(*mat, 2, 0) = n31;
|
||||||
MAT_ELEM_3X3(*mat, 2, 1) = n32;
|
MAT_ELEM_3X3(*mat, 2, 1) = n32;
|
||||||
MAT_ELEM_3X3(*mat, 2, 2) = n33;
|
MAT_ELEM_3X3(*mat, 2, 2) = n33;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_3x3_transpose(math_matrix_3x3 *out, const math_matrix_3x3 *in)
|
void matrix_3x3_transpose(math_matrix_3x3 *out, const math_matrix_3x3 *in)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
math_matrix_3x3 mat;
|
math_matrix_3x3 mat;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
MAT_ELEM_3X3(mat, j, i) = MAT_ELEM_3X3(*in, i, j);
|
MAT_ELEM_3X3(mat, j, i) = MAT_ELEM_3X3(*in, i, j);
|
||||||
|
|
||||||
*out = mat;
|
*out = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_3x3_multiply(math_matrix_3x3 *out,
|
void matrix_3x3_multiply(math_matrix_3x3 *out,
|
||||||
const math_matrix_3x3 *a, const math_matrix_3x3 *b)
|
const math_matrix_3x3 *a, const math_matrix_3x3 *b)
|
||||||
{
|
{
|
||||||
unsigned r, c, k;
|
unsigned r, c, k;
|
||||||
math_matrix_3x3 mat;
|
math_matrix_3x3 mat;
|
||||||
|
|
||||||
for (r = 0; r < 3; r++)
|
for (r = 0; r < 3; r++)
|
||||||
{
|
{
|
||||||
for (c = 0; c < 3; c++)
|
for (c = 0; c < 3; c++)
|
||||||
{
|
{
|
||||||
float dot = 0.0f;
|
float dot = 0.0f;
|
||||||
for (k = 0; k < 3; k++)
|
for (k = 0; k < 3; k++)
|
||||||
dot += MAT_ELEM_3X3(*a, r, k) * MAT_ELEM_3X3(*b, k, c);
|
dot += MAT_ELEM_3X3(*a, r, k) * MAT_ELEM_3X3(*b, k, c);
|
||||||
MAT_ELEM_3X3(mat, r, c) = dot;
|
MAT_ELEM_3X3(mat, r, c) = dot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = mat;
|
*out = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_3x3_divide_scalar(math_matrix_3x3 *mat, const float s)
|
void matrix_3x3_divide_scalar(math_matrix_3x3 *mat, const float s)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
for (j = 0; j < 3; j++)
|
for (j = 0; j < 3; j++)
|
||||||
MAT_ELEM_3X3(*mat, i, j) /= s;
|
MAT_ELEM_3X3(*mat, i, j) /= s;
|
||||||
}
|
}
|
||||||
|
|
||||||
float matrix_3x3_determinant(const math_matrix_3x3 *mat)
|
float matrix_3x3_determinant(const math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
float det = MAT_ELEM_3X3(*mat, 0, 0) * (MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
float det = MAT_ELEM_3X3(*mat, 0, 0) * (MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
||||||
det -= MAT_ELEM_3X3(*mat, 0, 1) * (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
det -= MAT_ELEM_3X3(*mat, 0, 1) * (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
det += MAT_ELEM_3X3(*mat, 0, 2) * (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
det += MAT_ELEM_3X3(*mat, 0, 2) * (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
|
|
||||||
return det;
|
return det;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_3x3_adjoint(math_matrix_3x3 *mat)
|
void matrix_3x3_adjoint(math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
math_matrix_3x3 out;
|
math_matrix_3x3 out;
|
||||||
|
|
||||||
MAT_ELEM_3X3(out, 0, 0) = (MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
MAT_ELEM_3X3(out, 0, 0) = (MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
||||||
MAT_ELEM_3X3(out, 0, 1) = -(MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
MAT_ELEM_3X3(out, 0, 1) = -(MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 2, 1));
|
||||||
MAT_ELEM_3X3(out, 0, 2) = (MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 1, 1) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 1, 1));
|
MAT_ELEM_3X3(out, 0, 2) = (MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 1, 1) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 1, 1));
|
||||||
MAT_ELEM_3X3(out, 1, 0) = -(MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
MAT_ELEM_3X3(out, 1, 0) = -(MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 1, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
MAT_ELEM_3X3(out, 1, 1) = (MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
MAT_ELEM_3X3(out, 1, 1) = (MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 2, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
MAT_ELEM_3X3(out, 1, 2) = -(MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 1, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 1, 0));
|
MAT_ELEM_3X3(out, 1, 2) = -(MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 1, 2) - MAT_ELEM_3X3(*mat, 0, 2) * MAT_ELEM_3X3(*mat, 1, 0));
|
||||||
MAT_ELEM_3X3(out, 2, 0) = (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
MAT_ELEM_3X3(out, 2, 0) = (MAT_ELEM_3X3(*mat, 1, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 1, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
MAT_ELEM_3X3(out, 2, 1) = -(MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
MAT_ELEM_3X3(out, 2, 1) = -(MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 2, 1) - MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 2, 0));
|
||||||
MAT_ELEM_3X3(out, 2, 2) = (MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 1, 1) - MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 1, 0));
|
MAT_ELEM_3X3(out, 2, 2) = (MAT_ELEM_3X3(*mat, 0, 0) * MAT_ELEM_3X3(*mat, 1, 1) - MAT_ELEM_3X3(*mat, 0, 1) * MAT_ELEM_3X3(*mat, 1, 0));
|
||||||
|
|
||||||
*mat = out;
|
*mat = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matrix_3x3_invert(math_matrix_3x3 *mat)
|
bool matrix_3x3_invert(math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
float det = matrix_3x3_determinant(mat);
|
float det = matrix_3x3_determinant(mat);
|
||||||
|
|
||||||
if (float_is_zero(det))
|
if (float_is_zero(det))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
matrix_3x3_adjoint(mat);
|
matrix_3x3_adjoint(mat);
|
||||||
matrix_3x3_divide_scalar(mat, det);
|
matrix_3x3_divide_scalar(mat, det);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
*
|
*
|
||||||
* the following code is Copyright 2009 VMware, Inc. All Rights Reserved.
|
* the following code is Copyright 2009 VMware, Inc. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the
|
* copy of this software and associated documentation files (the
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* "Software"), to deal in the Software without restriction, including
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
* distribute, sub license, and/or sell copies of the Software, and to
|
* distribute, sub license, and/or sell copies of the Software, and to
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
* the following conditions:
|
* the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice (including the
|
* The above copyright notice and this permission notice (including the
|
||||||
* next paragraph) shall be included in all copies or substantial portions
|
* next paragraph) shall be included in all copies or substantial portions
|
||||||
* of the Software.
|
* of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*
|
*
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
bool matrix_3x3_square_to_quad(const float dx0, const float dy0,
|
bool matrix_3x3_square_to_quad(const float dx0, const float dy0,
|
||||||
const float dx1, const float dy1,
|
const float dx1, const float dy1,
|
||||||
const float dx3, const float dy3,
|
const float dx3, const float dy3,
|
||||||
const float dx2, const float dy2,
|
const float dx2, const float dy2,
|
||||||
math_matrix_3x3 *mat)
|
math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
float ax = dx0 - dx1 + dx2 - dx3;
|
float ax = dx0 - dx1 + dx2 - dx3;
|
||||||
float ay = dy0 - dy1 + dy2 - dy3;
|
float ay = dy0 - dy1 + dy2 - dy3;
|
||||||
|
|
||||||
if (float_is_zero(ax) && float_is_zero(ay))
|
if (float_is_zero(ax) && float_is_zero(ay))
|
||||||
{
|
{
|
||||||
/* affine case */
|
/* affine case */
|
||||||
matrix_3x3_inits(mat,
|
matrix_3x3_inits(mat,
|
||||||
dx1 - dx0, dy1 - dy0, 0,
|
dx1 - dx0, dy1 - dy0, 0,
|
||||||
dx2 - dx1, dy2 - dy1, 0,
|
dx2 - dx1, dy2 - dy1, 0,
|
||||||
dx0, dy0, 1);
|
dx0, dy0, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float a, b, c, d, e, f, g, h;
|
float a, b, c, d, e, f, g, h;
|
||||||
float ax1 = dx1 - dx2;
|
float ax1 = dx1 - dx2;
|
||||||
float ax2 = dx3 - dx2;
|
float ax2 = dx3 - dx2;
|
||||||
float ay1 = dy1 - dy2;
|
float ay1 = dy1 - dy2;
|
||||||
float ay2 = dy3 - dy2;
|
float ay2 = dy3 - dy2;
|
||||||
|
|
||||||
/* determinants */
|
/* determinants */
|
||||||
float gtop = ax * ay2 - ax2 * ay;
|
float gtop = ax * ay2 - ax2 * ay;
|
||||||
float htop = ax1 * ay - ax * ay1;
|
float htop = ax1 * ay - ax * ay1;
|
||||||
float bottom = ax1 * ay2 - ax2 * ay1;
|
float bottom = ax1 * ay2 - ax2 * ay1;
|
||||||
|
|
||||||
if (!bottom)
|
if (!bottom)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g = gtop / bottom;
|
g = gtop / bottom;
|
||||||
h = htop / bottom;
|
h = htop / bottom;
|
||||||
|
|
||||||
a = dx1 - dx0 + g * dx1;
|
a = dx1 - dx0 + g * dx1;
|
||||||
b = dx3 - dx0 + h * dx3;
|
b = dx3 - dx0 + h * dx3;
|
||||||
c = dx0;
|
c = dx0;
|
||||||
d = dy1 - dy0 + g * dy1;
|
d = dy1 - dy0 + g * dy1;
|
||||||
e = dy3 - dy0 + h * dy3;
|
e = dy3 - dy0 + h * dy3;
|
||||||
f = dy0;
|
f = dy0;
|
||||||
|
|
||||||
matrix_3x3_inits(mat,
|
matrix_3x3_inits(mat,
|
||||||
a, d, g,
|
a, d, g,
|
||||||
b, e, h,
|
b, e, h,
|
||||||
c, f, 1.f);
|
c, f, 1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matrix_3x3_quad_to_square(const float sx0, const float sy0,
|
bool matrix_3x3_quad_to_square(const float sx0, const float sy0,
|
||||||
const float sx1, const float sy1,
|
const float sx1, const float sy1,
|
||||||
const float sx2, const float sy2,
|
const float sx2, const float sy2,
|
||||||
const float sx3, const float sy3,
|
const float sx3, const float sy3,
|
||||||
math_matrix_3x3 *mat)
|
math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
if (!matrix_3x3_square_to_quad(sx0, sy0, sx1, sy1,
|
if (!matrix_3x3_square_to_quad(sx0, sy0, sx1, sy1,
|
||||||
sx2, sy2, sx3, sy3,
|
sx2, sy2, sx3, sy3,
|
||||||
mat))
|
mat))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return matrix_3x3_invert(mat);
|
return matrix_3x3_invert(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool matrix_3x3_quad_to_quad(const float dx0, const float dy0,
|
bool matrix_3x3_quad_to_quad(const float dx0, const float dy0,
|
||||||
const float dx1, const float dy1,
|
const float dx1, const float dy1,
|
||||||
const float dx2, const float dy2,
|
const float dx2, const float dy2,
|
||||||
const float dx3, const float dy3,
|
const float dx3, const float dy3,
|
||||||
const float sx0, const float sy0,
|
const float sx0, const float sy0,
|
||||||
const float sx1, const float sy1,
|
const float sx1, const float sy1,
|
||||||
const float sx2, const float sy2,
|
const float sx2, const float sy2,
|
||||||
const float sx3, const float sy3,
|
const float sx3, const float sy3,
|
||||||
math_matrix_3x3 *mat)
|
math_matrix_3x3 *mat)
|
||||||
{
|
{
|
||||||
math_matrix_3x3 quad_to_square, square_to_quad;
|
math_matrix_3x3 quad_to_square, square_to_quad;
|
||||||
|
|
||||||
if (!matrix_3x3_square_to_quad(dx0, dy0, dx1, dy1,
|
if (!matrix_3x3_square_to_quad(dx0, dy0, dx1, dy1,
|
||||||
dx2, dy2, dx3, dy3,
|
dx2, dy2, dx3, dy3,
|
||||||
&square_to_quad))
|
&square_to_quad))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!matrix_3x3_quad_to_square(sx0, sy0, sx1, sy1,
|
if (!matrix_3x3_quad_to_square(sx0, sy0, sx1, sy1,
|
||||||
sx2, sy2, sx3, sy3,
|
sx2, sy2, sx3, sy3,
|
||||||
&quad_to_square))
|
&quad_to_square))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
matrix_3x3_multiply(mat, &quad_to_square, &square_to_quad);
|
matrix_3x3_multiply(mat, &quad_to_square, &square_to_quad);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,192 +1,192 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (matrix.c).
|
* The following license statement only applies to this file (matrix.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <gfx/math/matrix_4x4.h>
|
#include <gfx/math/matrix_4x4.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets mat to an identity matrix
|
* Sets mat to an identity matrix
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_identity(math_matrix_4x4 *mat)
|
void matrix_4x4_identity(math_matrix_4x4 *mat)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
memset(mat, 0, sizeof(*mat));
|
memset(mat, 0, sizeof(*mat));
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
MAT_ELEM_4X4(*mat, i, i) = 1.0f;
|
MAT_ELEM_4X4(*mat, i, i) = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets out to the transposed matrix of in
|
* Sets out to the transposed matrix of in
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in)
|
void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
math_matrix_4x4 mat;
|
math_matrix_4x4 mat;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
MAT_ELEM_4X4(mat, j, i) = MAT_ELEM_4X4(*in, i, j);
|
MAT_ELEM_4X4(mat, j, i) = MAT_ELEM_4X4(*in, i, j);
|
||||||
|
|
||||||
*out = mat;
|
*out = mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Builds an X-axis rotation matrix
|
* Builds an X-axis rotation matrix
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad)
|
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad)
|
||||||
{
|
{
|
||||||
float cosine = cosf(rad);
|
float cosine = cosf(rad);
|
||||||
float sine = sinf(rad);
|
float sine = sinf(rad);
|
||||||
|
|
||||||
matrix_4x4_identity(mat);
|
matrix_4x4_identity(mat);
|
||||||
|
|
||||||
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
|
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 2, 2) = cosine;
|
MAT_ELEM_4X4(*mat, 2, 2) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 1, 2) = -sine;
|
MAT_ELEM_4X4(*mat, 1, 2) = -sine;
|
||||||
MAT_ELEM_4X4(*mat, 2, 1) = sine;
|
MAT_ELEM_4X4(*mat, 2, 1) = sine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Builds a rotation matrix using the
|
* Builds a rotation matrix using the
|
||||||
* rotation around the Y-axis.
|
* rotation around the Y-axis.
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad)
|
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad)
|
||||||
{
|
{
|
||||||
float cosine = cosf(rad);
|
float cosine = cosf(rad);
|
||||||
float sine = sinf(rad);
|
float sine = sinf(rad);
|
||||||
|
|
||||||
matrix_4x4_identity(mat);
|
matrix_4x4_identity(mat);
|
||||||
|
|
||||||
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
|
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 2, 2) = cosine;
|
MAT_ELEM_4X4(*mat, 2, 2) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 0, 2) = -sine;
|
MAT_ELEM_4X4(*mat, 0, 2) = -sine;
|
||||||
MAT_ELEM_4X4(*mat, 2, 0) = sine;
|
MAT_ELEM_4X4(*mat, 2, 0) = sine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Builds a rotation matrix using the
|
* Builds a rotation matrix using the
|
||||||
* rotation around the Z-axis.
|
* rotation around the Z-axis.
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad)
|
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad)
|
||||||
{
|
{
|
||||||
float cosine = cosf(rad);
|
float cosine = cosf(rad);
|
||||||
float sine = sinf(rad);
|
float sine = sinf(rad);
|
||||||
|
|
||||||
matrix_4x4_identity(mat);
|
matrix_4x4_identity(mat);
|
||||||
|
|
||||||
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
|
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
|
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
|
||||||
MAT_ELEM_4X4(*mat, 0, 1) = -sine;
|
MAT_ELEM_4X4(*mat, 0, 1) = -sine;
|
||||||
MAT_ELEM_4X4(*mat, 1, 0) = sine;
|
MAT_ELEM_4X4(*mat, 1, 0) = sine;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates an orthographic projection matrix.
|
* Creates an orthographic projection matrix.
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
||||||
float left, float right,
|
float left, float right,
|
||||||
float bottom, float top,
|
float bottom, float top,
|
||||||
float znear, float zfar)
|
float znear, float zfar)
|
||||||
{
|
{
|
||||||
float tx, ty, tz;
|
float tx, ty, tz;
|
||||||
|
|
||||||
matrix_4x4_identity(mat);
|
matrix_4x4_identity(mat);
|
||||||
|
|
||||||
tx = -(right + left) / (right - left);
|
tx = -(right + left) / (right - left);
|
||||||
ty = -(top + bottom) / (top - bottom);
|
ty = -(top + bottom) / (top - bottom);
|
||||||
tz = -(zfar + znear) / (zfar - znear);
|
tz = -(zfar + znear) / (zfar - znear);
|
||||||
|
|
||||||
MAT_ELEM_4X4(*mat, 0, 0) = 2.0f / (right - left);
|
MAT_ELEM_4X4(*mat, 0, 0) = 2.0f / (right - left);
|
||||||
MAT_ELEM_4X4(*mat, 1, 1) = 2.0f / (top - bottom);
|
MAT_ELEM_4X4(*mat, 1, 1) = 2.0f / (top - bottom);
|
||||||
MAT_ELEM_4X4(*mat, 2, 2) = -2.0f / (zfar - znear);
|
MAT_ELEM_4X4(*mat, 2, 2) = -2.0f / (zfar - znear);
|
||||||
MAT_ELEM_4X4(*mat, 0, 3) = tx;
|
MAT_ELEM_4X4(*mat, 0, 3) = tx;
|
||||||
MAT_ELEM_4X4(*mat, 1, 3) = ty;
|
MAT_ELEM_4X4(*mat, 1, 3) = ty;
|
||||||
MAT_ELEM_4X4(*mat, 2, 3) = tz;
|
MAT_ELEM_4X4(*mat, 2, 3) = tz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void matrix_4x4_scale(math_matrix_4x4 *out, float x, float y,
|
void matrix_4x4_scale(math_matrix_4x4 *out, float x, float y,
|
||||||
float z)
|
float z)
|
||||||
{
|
{
|
||||||
memset(out, 0, sizeof(*out));
|
memset(out, 0, sizeof(*out));
|
||||||
MAT_ELEM_4X4(*out, 0, 0) = x;
|
MAT_ELEM_4X4(*out, 0, 0) = x;
|
||||||
MAT_ELEM_4X4(*out, 1, 1) = y;
|
MAT_ELEM_4X4(*out, 1, 1) = y;
|
||||||
MAT_ELEM_4X4(*out, 2, 2) = z;
|
MAT_ELEM_4X4(*out, 2, 2) = z;
|
||||||
MAT_ELEM_4X4(*out, 3, 3) = 1.0f;
|
MAT_ELEM_4X4(*out, 3, 3) = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Builds a translation matrix. All other elements in
|
* Builds a translation matrix. All other elements in
|
||||||
* the matrix will be set to zero except for the
|
* the matrix will be set to zero except for the
|
||||||
* diagonal which is set to 1.0
|
* diagonal which is set to 1.0
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_translate(math_matrix_4x4 *out, float x,
|
void matrix_4x4_translate(math_matrix_4x4 *out, float x,
|
||||||
float y, float z)
|
float y, float z)
|
||||||
{
|
{
|
||||||
matrix_4x4_identity(out);
|
matrix_4x4_identity(out);
|
||||||
MAT_ELEM_4X4(*out, 0, 3) = x;
|
MAT_ELEM_4X4(*out, 0, 3) = x;
|
||||||
MAT_ELEM_4X4(*out, 1, 3) = y;
|
MAT_ELEM_4X4(*out, 1, 3) = y;
|
||||||
MAT_ELEM_4X4(*out, 2, 3) = z;
|
MAT_ELEM_4X4(*out, 2, 3) = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates a perspective projection matrix.
|
* Creates a perspective projection matrix.
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_projection(math_matrix_4x4 *out, float znear,
|
void matrix_4x4_projection(math_matrix_4x4 *out, float znear,
|
||||||
float zfar)
|
float zfar)
|
||||||
{
|
{
|
||||||
float delta_z = zfar - znear;
|
float delta_z = zfar - znear;
|
||||||
|
|
||||||
memset(out, 0, sizeof(*out));
|
memset(out, 0, sizeof(*out));
|
||||||
MAT_ELEM_4X4(*out, 0, 0) = znear;
|
MAT_ELEM_4X4(*out, 0, 0) = znear;
|
||||||
MAT_ELEM_4X4(*out, 1, 1) = zfar;
|
MAT_ELEM_4X4(*out, 1, 1) = zfar;
|
||||||
MAT_ELEM_4X4(*out, 2, 2) = (zfar + znear) / delta_z;
|
MAT_ELEM_4X4(*out, 2, 2) = (zfar + znear) / delta_z;
|
||||||
MAT_ELEM_4X4(*out, 2, 3) = -2.0f * zfar * znear / delta_z;
|
MAT_ELEM_4X4(*out, 2, 3) = -2.0f * zfar * znear / delta_z;
|
||||||
MAT_ELEM_4X4(*out, 3, 2) = -1.0f;
|
MAT_ELEM_4X4(*out, 3, 2) = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Multiplies a with b, stores the result in out
|
* Multiplies a with b, stores the result in out
|
||||||
*/
|
*/
|
||||||
void matrix_4x4_multiply(
|
void matrix_4x4_multiply(
|
||||||
math_matrix_4x4 *out,
|
math_matrix_4x4 *out,
|
||||||
const math_matrix_4x4 *a,
|
const math_matrix_4x4 *a,
|
||||||
const math_matrix_4x4 *b)
|
const math_matrix_4x4 *b)
|
||||||
{
|
{
|
||||||
unsigned r, c, k;
|
unsigned r, c, k;
|
||||||
math_matrix_4x4 mat;
|
math_matrix_4x4 mat;
|
||||||
|
|
||||||
for (r = 0; r < 4; r++)
|
for (r = 0; r < 4; r++)
|
||||||
{
|
{
|
||||||
for (c = 0; c < 4; c++)
|
for (c = 0; c < 4; c++)
|
||||||
{
|
{
|
||||||
float dot = 0.0f;
|
float dot = 0.0f;
|
||||||
for (k = 0; k < 4; k++)
|
for (k = 0; k < 4; k++)
|
||||||
dot += MAT_ELEM_4X4(*a, r, k) * MAT_ELEM_4X4(*b, k, c);
|
dot += MAT_ELEM_4X4(*a, r, k) * MAT_ELEM_4X4(*b, k, c);
|
||||||
MAT_ELEM_4X4(mat, r, c) = dot;
|
MAT_ELEM_4X4(mat, r, c) = dot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = mat;
|
*out = mat;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,379 +1,379 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (scaler.c).
|
* The following license statement only applies to this file (scaler.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <gfx/scaler/scaler.h>
|
#include <gfx/scaler/scaler.h>
|
||||||
#include <gfx/scaler/scaler_int.h>
|
#include <gfx/scaler/scaler_int.h>
|
||||||
#include <gfx/scaler/filter.h>
|
#include <gfx/scaler/filter.h>
|
||||||
#include <gfx/scaler/pixconv.h>
|
#include <gfx/scaler/pixconv.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_alloc:
|
* scaler_alloc:
|
||||||
* @elem_size : size of the elements to be used.
|
* @elem_size : size of the elements to be used.
|
||||||
* @siz : size of the image that the scaler needs to handle.
|
* @siz : size of the image that the scaler needs to handle.
|
||||||
*
|
*
|
||||||
* Allocate and returns a scaler object.
|
* Allocate and returns a scaler object.
|
||||||
*
|
*
|
||||||
* Returns: pointer to a scaler object of type 'void *' on success,
|
* Returns: pointer to a scaler object of type 'void *' on success,
|
||||||
* NULL in case of error. Has to be freed manually.
|
* NULL in case of error. Has to be freed manually.
|
||||||
**/
|
**/
|
||||||
void *scaler_alloc(size_t elem_size, size_t size)
|
void *scaler_alloc(size_t elem_size, size_t size)
|
||||||
{
|
{
|
||||||
void *ptr = calloc(elem_size, size);
|
void *ptr = calloc(elem_size, size);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_free:
|
* scaler_free:
|
||||||
* @ptr : pointer to scaler object.
|
* @ptr : pointer to scaler object.
|
||||||
*
|
*
|
||||||
* Frees a scaler object.
|
* Frees a scaler object.
|
||||||
**/
|
**/
|
||||||
void scaler_free(void *ptr)
|
void scaler_free(void *ptr)
|
||||||
{
|
{
|
||||||
if (ptr)
|
if (ptr)
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool allocate_frames(struct scaler_ctx *ctx)
|
static bool allocate_frames(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
ctx->scaled.stride = ((ctx->out_width + 7) & ~7) * sizeof(uint64_t);
|
ctx->scaled.stride = ((ctx->out_width + 7) & ~7) * sizeof(uint64_t);
|
||||||
ctx->scaled.width = ctx->out_width;
|
ctx->scaled.width = ctx->out_width;
|
||||||
ctx->scaled.height = ctx->in_height;
|
ctx->scaled.height = ctx->in_height;
|
||||||
ctx->scaled.frame = (uint64_t*)
|
ctx->scaled.frame = (uint64_t*)
|
||||||
scaler_alloc(sizeof(uint64_t),
|
scaler_alloc(sizeof(uint64_t),
|
||||||
(ctx->scaled.stride * ctx->scaled.height) >> 3);
|
(ctx->scaled.stride * ctx->scaled.height) >> 3);
|
||||||
if (!ctx->scaled.frame)
|
if (!ctx->scaled.frame)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ctx->in_fmt != SCALER_FMT_ARGB8888)
|
if (ctx->in_fmt != SCALER_FMT_ARGB8888)
|
||||||
{
|
{
|
||||||
ctx->input.stride = ((ctx->in_width + 7) & ~7) * sizeof(uint32_t);
|
ctx->input.stride = ((ctx->in_width + 7) & ~7) * sizeof(uint32_t);
|
||||||
ctx->input.frame = (uint32_t*)
|
ctx->input.frame = (uint32_t*)
|
||||||
scaler_alloc(sizeof(uint32_t),
|
scaler_alloc(sizeof(uint32_t),
|
||||||
(ctx->input.stride * ctx->in_height) >> 2);
|
(ctx->input.stride * ctx->in_height) >> 2);
|
||||||
if (!ctx->input.frame)
|
if (!ctx->input.frame)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
||||||
{
|
{
|
||||||
ctx->output.stride = ((ctx->out_width + 7) & ~7) * sizeof(uint32_t);
|
ctx->output.stride = ((ctx->out_width + 7) & ~7) * sizeof(uint32_t);
|
||||||
ctx->output.frame = (uint32_t*)
|
ctx->output.frame = (uint32_t*)
|
||||||
scaler_alloc(sizeof(uint32_t),
|
scaler_alloc(sizeof(uint32_t),
|
||||||
(ctx->output.stride * ctx->out_height) >> 2);
|
(ctx->output.stride * ctx->out_height) >> 2);
|
||||||
if (!ctx->output.frame)
|
if (!ctx->output.frame)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set_direct_pix_conv:
|
* set_direct_pix_conv:
|
||||||
* @ctx : pointer to scaler context object.
|
* @ctx : pointer to scaler context object.
|
||||||
*
|
*
|
||||||
* Bind a pixel converter callback function to the 'direct_pixconv' function pointer
|
* Bind a pixel converter callback function to the 'direct_pixconv' function pointer
|
||||||
* of the scaler context object.
|
* of the scaler context object.
|
||||||
*
|
*
|
||||||
* Returns: true if a pixel converter function callback could be bound, false if not.
|
* Returns: true if a pixel converter function callback could be bound, false if not.
|
||||||
* If false, the function callback 'direct_pixconv' is still unbound.
|
* If false, the function callback 'direct_pixconv' is still unbound.
|
||||||
**/
|
**/
|
||||||
static bool set_direct_pix_conv(struct scaler_ctx *ctx)
|
static bool set_direct_pix_conv(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
if (ctx->in_fmt == ctx->out_fmt)
|
if (ctx->in_fmt == ctx->out_fmt)
|
||||||
{
|
{
|
||||||
ctx->direct_pixconv = conv_copy;
|
ctx->direct_pixconv = conv_copy;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ctx->in_fmt)
|
switch (ctx->in_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_0RGB1555:
|
case SCALER_FMT_0RGB1555:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
ctx->direct_pixconv = conv_0rgb1555_argb8888;
|
ctx->direct_pixconv = conv_0rgb1555_argb8888;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_RGB565:
|
case SCALER_FMT_RGB565:
|
||||||
ctx->direct_pixconv = conv_0rgb1555_rgb565;
|
ctx->direct_pixconv = conv_0rgb1555_rgb565;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
ctx->direct_pixconv = conv_0rgb1555_bgr24;
|
ctx->direct_pixconv = conv_0rgb1555_bgr24;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_RGB565:
|
case SCALER_FMT_RGB565:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
ctx->direct_pixconv = conv_rgb565_argb8888;
|
ctx->direct_pixconv = conv_rgb565_argb8888;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
ctx->direct_pixconv = conv_rgb565_bgr24;
|
ctx->direct_pixconv = conv_rgb565_bgr24;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_0RGB1555:
|
case SCALER_FMT_0RGB1555:
|
||||||
ctx->direct_pixconv = conv_rgb565_0rgb1555;
|
ctx->direct_pixconv = conv_rgb565_0rgb1555;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
ctx->direct_pixconv = conv_bgr24_argb8888;
|
ctx->direct_pixconv = conv_bgr24_argb8888;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_0RGB1555:
|
case SCALER_FMT_0RGB1555:
|
||||||
ctx->direct_pixconv = conv_argb8888_0rgb1555;
|
ctx->direct_pixconv = conv_argb8888_0rgb1555;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
ctx->direct_pixconv = conv_argb8888_bgr24;
|
ctx->direct_pixconv = conv_argb8888_bgr24;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_ABGR8888:
|
case SCALER_FMT_ABGR8888:
|
||||||
ctx->direct_pixconv = conv_argb8888_abgr8888;
|
ctx->direct_pixconv = conv_argb8888_abgr8888;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_RGBA4444:
|
case SCALER_FMT_RGBA4444:
|
||||||
ctx->direct_pixconv = conv_argb8888_rgba4444;
|
ctx->direct_pixconv = conv_argb8888_rgba4444;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_YUYV:
|
case SCALER_FMT_YUYV:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
ctx->direct_pixconv = conv_yuyv_argb8888;
|
ctx->direct_pixconv = conv_yuyv_argb8888;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_RGBA4444:
|
case SCALER_FMT_RGBA4444:
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
ctx->direct_pixconv = conv_rgba4444_argb8888;
|
ctx->direct_pixconv = conv_rgba4444_argb8888;
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_RGB565:
|
case SCALER_FMT_RGB565:
|
||||||
ctx->direct_pixconv = conv_rgba4444_rgb565;
|
ctx->direct_pixconv = conv_rgba4444_rgb565;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCALER_FMT_ABGR8888:
|
case SCALER_FMT_ABGR8888:
|
||||||
/* FIXME/TODO */
|
/* FIXME/TODO */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->direct_pixconv)
|
if (!ctx->direct_pixconv)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool set_pix_conv(struct scaler_ctx *ctx)
|
static bool set_pix_conv(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
switch (ctx->in_fmt)
|
switch (ctx->in_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
/* No need to convert :D */
|
/* No need to convert :D */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_0RGB1555:
|
case SCALER_FMT_0RGB1555:
|
||||||
ctx->in_pixconv = conv_0rgb1555_argb8888;
|
ctx->in_pixconv = conv_0rgb1555_argb8888;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_RGB565:
|
case SCALER_FMT_RGB565:
|
||||||
ctx->in_pixconv = conv_rgb565_argb8888;
|
ctx->in_pixconv = conv_rgb565_argb8888;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
ctx->in_pixconv = conv_bgr24_argb8888;
|
ctx->in_pixconv = conv_bgr24_argb8888;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_RGBA4444:
|
case SCALER_FMT_RGBA4444:
|
||||||
ctx->in_pixconv = conv_rgba4444_argb8888;
|
ctx->in_pixconv = conv_rgba4444_argb8888;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ctx->out_fmt)
|
switch (ctx->out_fmt)
|
||||||
{
|
{
|
||||||
case SCALER_FMT_ARGB8888:
|
case SCALER_FMT_ARGB8888:
|
||||||
/* No need to convert :D */
|
/* No need to convert :D */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_RGBA4444:
|
case SCALER_FMT_RGBA4444:
|
||||||
ctx->out_pixconv = conv_argb8888_rgba4444;
|
ctx->out_pixconv = conv_argb8888_rgba4444;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_0RGB1555:
|
case SCALER_FMT_0RGB1555:
|
||||||
ctx->out_pixconv = conv_argb8888_0rgb1555;
|
ctx->out_pixconv = conv_argb8888_0rgb1555;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_FMT_BGR24:
|
case SCALER_FMT_BGR24:
|
||||||
ctx->out_pixconv = conv_argb8888_bgr24;
|
ctx->out_pixconv = conv_argb8888_bgr24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scaler_ctx_gen_filter(struct scaler_ctx *ctx)
|
bool scaler_ctx_gen_filter(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
scaler_ctx_gen_reset(ctx);
|
scaler_ctx_gen_reset(ctx);
|
||||||
|
|
||||||
if (ctx->in_width == ctx->out_width && ctx->in_height == ctx->out_height)
|
if (ctx->in_width == ctx->out_width && ctx->in_height == ctx->out_height)
|
||||||
ctx->unscaled = true; /* Only pixel format conversion ... */
|
ctx->unscaled = true; /* Only pixel format conversion ... */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ctx->scaler_horiz = scaler_argb8888_horiz;
|
ctx->scaler_horiz = scaler_argb8888_horiz;
|
||||||
ctx->scaler_vert = scaler_argb8888_vert;
|
ctx->scaler_vert = scaler_argb8888_vert;
|
||||||
ctx->unscaled = false;
|
ctx->unscaled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->scaler_special = NULL;
|
ctx->scaler_special = NULL;
|
||||||
|
|
||||||
if (!allocate_frames(ctx))
|
if (!allocate_frames(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ctx->unscaled)
|
if (ctx->unscaled)
|
||||||
{
|
{
|
||||||
if (!set_direct_pix_conv(ctx))
|
if (!set_direct_pix_conv(ctx))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!set_pix_conv(ctx))
|
if (!set_pix_conv(ctx))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctx->unscaled && !scaler_gen_filter(ctx))
|
if (!ctx->unscaled && !scaler_gen_filter(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void scaler_ctx_gen_reset(struct scaler_ctx *ctx)
|
void scaler_ctx_gen_reset(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
scaler_free(ctx->horiz.filter);
|
scaler_free(ctx->horiz.filter);
|
||||||
scaler_free(ctx->horiz.filter_pos);
|
scaler_free(ctx->horiz.filter_pos);
|
||||||
scaler_free(ctx->vert.filter);
|
scaler_free(ctx->vert.filter);
|
||||||
scaler_free(ctx->vert.filter_pos);
|
scaler_free(ctx->vert.filter_pos);
|
||||||
scaler_free(ctx->scaled.frame);
|
scaler_free(ctx->scaled.frame);
|
||||||
scaler_free(ctx->input.frame);
|
scaler_free(ctx->input.frame);
|
||||||
scaler_free(ctx->output.frame);
|
scaler_free(ctx->output.frame);
|
||||||
|
|
||||||
memset(&ctx->horiz, 0, sizeof(ctx->horiz));
|
memset(&ctx->horiz, 0, sizeof(ctx->horiz));
|
||||||
memset(&ctx->vert, 0, sizeof(ctx->vert));
|
memset(&ctx->vert, 0, sizeof(ctx->vert));
|
||||||
memset(&ctx->scaled, 0, sizeof(ctx->scaled));
|
memset(&ctx->scaled, 0, sizeof(ctx->scaled));
|
||||||
memset(&ctx->input, 0, sizeof(ctx->input));
|
memset(&ctx->input, 0, sizeof(ctx->input));
|
||||||
memset(&ctx->output, 0, sizeof(ctx->output));
|
memset(&ctx->output, 0, sizeof(ctx->output));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_ctx_scale:
|
* scaler_ctx_scale:
|
||||||
* @ctx : pointer to scaler context object.
|
* @ctx : pointer to scaler context object.
|
||||||
* @output : pointer to output image.
|
* @output : pointer to output image.
|
||||||
* @input : pointer to input image.
|
* @input : pointer to input image.
|
||||||
*
|
*
|
||||||
* Scales an input image to an output image.
|
* Scales an input image to an output image.
|
||||||
**/
|
**/
|
||||||
void scaler_ctx_scale(struct scaler_ctx *ctx,
|
void scaler_ctx_scale(struct scaler_ctx *ctx,
|
||||||
void *output, const void *input)
|
void *output, const void *input)
|
||||||
{
|
{
|
||||||
const void *input_frame = input;
|
const void *input_frame = input;
|
||||||
void *output_frame = output;
|
void *output_frame = output;
|
||||||
int input_stride = ctx->in_stride;
|
int input_stride = ctx->in_stride;
|
||||||
int output_stride = ctx->out_stride;
|
int output_stride = ctx->out_stride;
|
||||||
|
|
||||||
if (ctx->unscaled)
|
if (ctx->unscaled)
|
||||||
{
|
{
|
||||||
/* Just perform straight pixel conversion. */
|
/* Just perform straight pixel conversion. */
|
||||||
ctx->direct_pixconv(output, input,
|
ctx->direct_pixconv(output, input,
|
||||||
ctx->out_width, ctx->out_height,
|
ctx->out_width, ctx->out_height,
|
||||||
ctx->out_stride, ctx->in_stride);
|
ctx->out_stride, ctx->in_stride);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->in_fmt != SCALER_FMT_ARGB8888)
|
if (ctx->in_fmt != SCALER_FMT_ARGB8888)
|
||||||
{
|
{
|
||||||
ctx->in_pixconv(ctx->input.frame, input,
|
ctx->in_pixconv(ctx->input.frame, input,
|
||||||
ctx->in_width, ctx->in_height,
|
ctx->in_width, ctx->in_height,
|
||||||
ctx->input.stride, ctx->in_stride);
|
ctx->input.stride, ctx->in_stride);
|
||||||
|
|
||||||
input_frame = ctx->input.frame;
|
input_frame = ctx->input.frame;
|
||||||
input_stride = ctx->input.stride;
|
input_stride = ctx->input.stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
||||||
{
|
{
|
||||||
output_frame = ctx->output.frame;
|
output_frame = ctx->output.frame;
|
||||||
output_stride = ctx->output.stride;
|
output_stride = ctx->output.stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->scaler_special)
|
if (ctx->scaler_special)
|
||||||
{
|
{
|
||||||
/* Take some special, and (hopefully) more optimized path. */
|
/* Take some special, and (hopefully) more optimized path. */
|
||||||
ctx->scaler_special(ctx, output_frame, input_frame,
|
ctx->scaler_special(ctx, output_frame, input_frame,
|
||||||
ctx->out_width, ctx->out_height,
|
ctx->out_width, ctx->out_height,
|
||||||
ctx->in_width, ctx->in_height,
|
ctx->in_width, ctx->in_height,
|
||||||
output_stride, input_stride);
|
output_stride, input_stride);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Take generic filter path. */
|
/* Take generic filter path. */
|
||||||
if (ctx->scaler_horiz)
|
if (ctx->scaler_horiz)
|
||||||
ctx->scaler_horiz(ctx, input_frame, input_stride);
|
ctx->scaler_horiz(ctx, input_frame, input_stride);
|
||||||
if (ctx->scaler_vert)
|
if (ctx->scaler_vert)
|
||||||
ctx->scaler_vert (ctx, output, output_stride);
|
ctx->scaler_vert (ctx, output, output_stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
if (ctx->out_fmt != SCALER_FMT_ARGB8888)
|
||||||
ctx->out_pixconv(output, ctx->output.frame,
|
ctx->out_pixconv(output, ctx->output.frame,
|
||||||
ctx->out_width, ctx->out_height,
|
ctx->out_width, ctx->out_height,
|
||||||
ctx->out_stride, ctx->output.stride);
|
ctx->out_stride, ctx->output.stride);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,278 +1,278 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (scaler_filter.c).
|
* The following license statement only applies to this file (scaler_filter.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <gfx/scaler/filter.h>
|
#include <gfx/scaler/filter.h>
|
||||||
#include <gfx/scaler/scaler_int.h>
|
#include <gfx/scaler/scaler_int.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <filters.h>
|
#include <filters.h>
|
||||||
|
|
||||||
static bool allocate_filters(struct scaler_ctx *ctx)
|
static bool allocate_filters(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
ctx->horiz.filter = (int16_t*)scaler_alloc(sizeof(int16_t), ctx->horiz.filter_stride * ctx->out_width);
|
ctx->horiz.filter = (int16_t*)scaler_alloc(sizeof(int16_t), ctx->horiz.filter_stride * ctx->out_width);
|
||||||
ctx->horiz.filter_pos = (int*)scaler_alloc(sizeof(int), ctx->out_width);
|
ctx->horiz.filter_pos = (int*)scaler_alloc(sizeof(int), ctx->out_width);
|
||||||
|
|
||||||
ctx->vert.filter = (int16_t*)scaler_alloc(sizeof(int16_t), ctx->vert.filter_stride * ctx->out_height);
|
ctx->vert.filter = (int16_t*)scaler_alloc(sizeof(int16_t), ctx->vert.filter_stride * ctx->out_height);
|
||||||
ctx->vert.filter_pos = (int*)scaler_alloc(sizeof(int), ctx->out_height);
|
ctx->vert.filter_pos = (int*)scaler_alloc(sizeof(int), ctx->out_height);
|
||||||
|
|
||||||
return ctx->horiz.filter && ctx->vert.filter;
|
return ctx->horiz.filter && ctx->vert.filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_filter_point_sub(struct scaler_filter *filter,
|
static void gen_filter_point_sub(struct scaler_filter *filter,
|
||||||
int len, int pos, int step)
|
int len, int pos, int step)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++, pos += step)
|
for (i = 0; i < len; i++, pos += step)
|
||||||
{
|
{
|
||||||
filter->filter_pos[i] = pos >> 16;
|
filter->filter_pos[i] = pos >> 16;
|
||||||
filter->filter[i] = FILTER_UNITY;
|
filter->filter[i] = FILTER_UNITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gen_filter_point(struct scaler_ctx *ctx)
|
static bool gen_filter_point(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
int x_pos, x_step, y_pos, y_step;
|
int x_pos, x_step, y_pos, y_step;
|
||||||
|
|
||||||
ctx->horiz.filter_len = 1;
|
ctx->horiz.filter_len = 1;
|
||||||
ctx->horiz.filter_stride = 1;
|
ctx->horiz.filter_stride = 1;
|
||||||
ctx->vert.filter_len = 1;
|
ctx->vert.filter_len = 1;
|
||||||
ctx->vert.filter_stride = 1;
|
ctx->vert.filter_stride = 1;
|
||||||
|
|
||||||
if (!allocate_filters(ctx))
|
if (!allocate_filters(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15);
|
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15);
|
||||||
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
||||||
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15);
|
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15);
|
||||||
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
||||||
|
|
||||||
gen_filter_point_sub(&ctx->horiz, ctx->out_width, x_pos, x_step);
|
gen_filter_point_sub(&ctx->horiz, ctx->out_width, x_pos, x_step);
|
||||||
gen_filter_point_sub(&ctx->vert, ctx->out_height, y_pos, y_step);
|
gen_filter_point_sub(&ctx->vert, ctx->out_height, y_pos, y_step);
|
||||||
|
|
||||||
ctx->scaler_special = scaler_argb8888_point_special;
|
ctx->scaler_special = scaler_argb8888_point_special;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_filter_bilinear_sub(struct scaler_filter *filter,
|
static void gen_filter_bilinear_sub(struct scaler_filter *filter,
|
||||||
int len, int pos, int step)
|
int len, int pos, int step)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < len; i++, pos += step)
|
for (i = 0; i < len; i++, pos += step)
|
||||||
{
|
{
|
||||||
filter->filter_pos[i] = pos >> 16;
|
filter->filter_pos[i] = pos >> 16;
|
||||||
filter->filter[i * 2 + 1] = (pos & 0xffff) >> 2;
|
filter->filter[i * 2 + 1] = (pos & 0xffff) >> 2;
|
||||||
filter->filter[i * 2 + 0] = FILTER_UNITY - filter->filter[i * 2 + 1];
|
filter->filter[i * 2 + 0] = FILTER_UNITY - filter->filter[i * 2 + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gen_filter_bilinear(struct scaler_ctx *ctx)
|
static bool gen_filter_bilinear(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
int x_pos, x_step, y_pos, y_step;
|
int x_pos, x_step, y_pos, y_step;
|
||||||
|
|
||||||
ctx->horiz.filter_len = 2;
|
ctx->horiz.filter_len = 2;
|
||||||
ctx->horiz.filter_stride = 2;
|
ctx->horiz.filter_stride = 2;
|
||||||
ctx->vert.filter_len = 2;
|
ctx->vert.filter_len = 2;
|
||||||
ctx->vert.filter_stride = 2;
|
ctx->vert.filter_stride = 2;
|
||||||
|
|
||||||
if (!allocate_filters(ctx))
|
if (!allocate_filters(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15);
|
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15);
|
||||||
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
||||||
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15);
|
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15);
|
||||||
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
||||||
|
|
||||||
gen_filter_bilinear_sub(&ctx->horiz, ctx->out_width, x_pos, x_step);
|
gen_filter_bilinear_sub(&ctx->horiz, ctx->out_width, x_pos, x_step);
|
||||||
gen_filter_bilinear_sub(&ctx->vert, ctx->out_height, y_pos, y_step);
|
gen_filter_bilinear_sub(&ctx->vert, ctx->out_height, y_pos, y_step);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_filter_sinc_sub(struct scaler_filter *filter,
|
static void gen_filter_sinc_sub(struct scaler_filter *filter,
|
||||||
int len, int pos, int step, double phase_mul)
|
int len, int pos, int step, double phase_mul)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
const int sinc_size = filter->filter_len;
|
const int sinc_size = filter->filter_len;
|
||||||
|
|
||||||
for (i = 0; i < len; i++, pos += step)
|
for (i = 0; i < len; i++, pos += step)
|
||||||
{
|
{
|
||||||
filter->filter_pos[i] = pos >> 16;
|
filter->filter_pos[i] = pos >> 16;
|
||||||
|
|
||||||
for (j = 0; j < sinc_size; j++)
|
for (j = 0; j < sinc_size; j++)
|
||||||
{
|
{
|
||||||
double sinc_phase = M_PI * ((double)((sinc_size << 15) + (pos & 0xffff)) / 0x10000 - j);
|
double sinc_phase = M_PI * ((double)((sinc_size << 15) + (pos & 0xffff)) / 0x10000 - j);
|
||||||
double lanczos_phase = sinc_phase / ((sinc_size >> 1));
|
double lanczos_phase = sinc_phase / ((sinc_size >> 1));
|
||||||
int16_t sinc_val = FILTER_UNITY * sinc(sinc_phase * phase_mul) * sinc(lanczos_phase) * phase_mul;
|
int16_t sinc_val = FILTER_UNITY * sinc(sinc_phase * phase_mul) * sinc(lanczos_phase) * phase_mul;
|
||||||
|
|
||||||
filter->filter[i * sinc_size + j] = sinc_val;
|
filter->filter[i * sinc_size + j] = sinc_val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gen_filter_sinc(struct scaler_ctx *ctx)
|
static bool gen_filter_sinc(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
int x_pos, x_step, y_pos, y_step;
|
int x_pos, x_step, y_pos, y_step;
|
||||||
double phase_mul_horiz, phase_mul_vert;
|
double phase_mul_horiz, phase_mul_vert;
|
||||||
/* Need to expand the filter when downsampling
|
/* Need to expand the filter when downsampling
|
||||||
* to get a proper low-pass effect. */
|
* to get a proper low-pass effect. */
|
||||||
const int sinc_size = 8 * ((ctx->in_width > ctx->out_width)
|
const int sinc_size = 8 * ((ctx->in_width > ctx->out_width)
|
||||||
? next_pow2(ctx->in_width / ctx->out_width) : 1);
|
? next_pow2(ctx->in_width / ctx->out_width) : 1);
|
||||||
|
|
||||||
ctx->horiz.filter_len = sinc_size;
|
ctx->horiz.filter_len = sinc_size;
|
||||||
ctx->horiz.filter_stride = sinc_size;
|
ctx->horiz.filter_stride = sinc_size;
|
||||||
ctx->vert.filter_len = sinc_size;
|
ctx->vert.filter_len = sinc_size;
|
||||||
ctx->vert.filter_stride = sinc_size;
|
ctx->vert.filter_stride = sinc_size;
|
||||||
|
|
||||||
if (!allocate_filters(ctx))
|
if (!allocate_filters(ctx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15) - (sinc_size << 15);
|
x_pos = (1 << 15) * ctx->in_width / ctx->out_width - (1 << 15) - (sinc_size << 15);
|
||||||
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
x_step = (1 << 16) * ctx->in_width / ctx->out_width;
|
||||||
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15) - (sinc_size << 15);
|
y_pos = (1 << 15) * ctx->in_height / ctx->out_height - (1 << 15) - (sinc_size << 15);
|
||||||
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
y_step = (1 << 16) * ctx->in_height / ctx->out_height;
|
||||||
|
|
||||||
phase_mul_horiz = ctx->in_width > ctx->out_width ? (double)ctx->out_width / ctx->in_width : 1.0;
|
phase_mul_horiz = ctx->in_width > ctx->out_width ? (double)ctx->out_width / ctx->in_width : 1.0;
|
||||||
phase_mul_vert = ctx->in_height > ctx->out_height ? (double)ctx->out_height / ctx->in_height : 1.0;
|
phase_mul_vert = ctx->in_height > ctx->out_height ? (double)ctx->out_height / ctx->in_height : 1.0;
|
||||||
|
|
||||||
gen_filter_sinc_sub(&ctx->horiz, ctx->out_width, x_pos, x_step, phase_mul_horiz);
|
gen_filter_sinc_sub(&ctx->horiz, ctx->out_width, x_pos, x_step, phase_mul_horiz);
|
||||||
gen_filter_sinc_sub(&ctx->vert, ctx->out_height, y_pos, y_step, phase_mul_vert);
|
gen_filter_sinc_sub(&ctx->vert, ctx->out_height, y_pos, y_step, phase_mul_vert);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool validate_filter(struct scaler_ctx *ctx)
|
static bool validate_filter(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max_h_pos;
|
int max_h_pos;
|
||||||
int max_w_pos = ctx->in_width - ctx->horiz.filter_len;
|
int max_w_pos = ctx->in_width - ctx->horiz.filter_len;
|
||||||
|
|
||||||
for (i = 0; i < ctx->out_width; i++)
|
for (i = 0; i < ctx->out_width; i++)
|
||||||
{
|
{
|
||||||
if (ctx->horiz.filter_pos[i] > max_w_pos || ctx->horiz.filter_pos[i] < 0)
|
if (ctx->horiz.filter_pos[i] > max_w_pos || ctx->horiz.filter_pos[i] < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Out X = %d => In X = %d\n", i, ctx->horiz.filter_pos[i]);
|
fprintf(stderr, "Out X = %d => In X = %d\n", i, ctx->horiz.filter_pos[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max_h_pos = ctx->in_height - ctx->vert.filter_len;
|
max_h_pos = ctx->in_height - ctx->vert.filter_len;
|
||||||
|
|
||||||
for (i = 0; i < ctx->out_height; i++)
|
for (i = 0; i < ctx->out_height; i++)
|
||||||
{
|
{
|
||||||
if (ctx->vert.filter_pos[i] > max_h_pos || ctx->vert.filter_pos[i] < 0)
|
if (ctx->vert.filter_pos[i] > max_h_pos || ctx->vert.filter_pos[i] < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Out Y = %d => In Y = %d\n", i, ctx->vert.filter_pos[i]);
|
fprintf(stderr, "Out Y = %d => In Y = %d\n", i, ctx->vert.filter_pos[i]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fixup_filter_sub(struct scaler_filter *filter, int out_len, int in_len)
|
static void fixup_filter_sub(struct scaler_filter *filter, int out_len, int in_len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int max_pos = in_len - filter->filter_len;
|
int max_pos = in_len - filter->filter_len;
|
||||||
|
|
||||||
for (i = 0; i < out_len; i++)
|
for (i = 0; i < out_len; i++)
|
||||||
{
|
{
|
||||||
int postsample = filter->filter_pos[i] - max_pos;
|
int postsample = filter->filter_pos[i] - max_pos;
|
||||||
int presample = -filter->filter_pos[i];
|
int presample = -filter->filter_pos[i];
|
||||||
|
|
||||||
if (postsample > 0)
|
if (postsample > 0)
|
||||||
{
|
{
|
||||||
int16_t *base_filter = NULL;
|
int16_t *base_filter = NULL;
|
||||||
filter->filter_pos[i] -= postsample;
|
filter->filter_pos[i] -= postsample;
|
||||||
|
|
||||||
base_filter = filter->filter + i * filter->filter_stride;
|
base_filter = filter->filter + i * filter->filter_stride;
|
||||||
|
|
||||||
if (postsample > (int)filter->filter_len)
|
if (postsample > (int)filter->filter_len)
|
||||||
memset(base_filter, 0, filter->filter_len * sizeof(int16_t));
|
memset(base_filter, 0, filter->filter_len * sizeof(int16_t));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memmove(base_filter + postsample, base_filter,
|
memmove(base_filter + postsample, base_filter,
|
||||||
(filter->filter_len - postsample) * sizeof(int16_t));
|
(filter->filter_len - postsample) * sizeof(int16_t));
|
||||||
memset(base_filter, 0, postsample * sizeof(int16_t));
|
memset(base_filter, 0, postsample * sizeof(int16_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (presample > 0)
|
if (presample > 0)
|
||||||
{
|
{
|
||||||
int16_t *base_filter = NULL;
|
int16_t *base_filter = NULL;
|
||||||
filter->filter_pos[i] += presample;
|
filter->filter_pos[i] += presample;
|
||||||
base_filter = filter->filter + i * filter->filter_stride;
|
base_filter = filter->filter + i * filter->filter_stride;
|
||||||
|
|
||||||
if (presample > (int)filter->filter_len)
|
if (presample > (int)filter->filter_len)
|
||||||
memset(base_filter, 0, filter->filter_len * sizeof(int16_t));
|
memset(base_filter, 0, filter->filter_len * sizeof(int16_t));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
memmove(base_filter, base_filter + presample,
|
memmove(base_filter, base_filter + presample,
|
||||||
(filter->filter_len - presample) * sizeof(int16_t));
|
(filter->filter_len - presample) * sizeof(int16_t));
|
||||||
memset(base_filter + (filter->filter_len - presample), 0, presample * sizeof(int16_t));
|
memset(base_filter + (filter->filter_len - presample), 0, presample * sizeof(int16_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Makes sure that we never sample outside our rectangle. */
|
/* Makes sure that we never sample outside our rectangle. */
|
||||||
static void fixup_filter(struct scaler_ctx *ctx)
|
static void fixup_filter(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
fixup_filter_sub(&ctx->horiz, ctx->out_width, ctx->in_width);
|
fixup_filter_sub(&ctx->horiz, ctx->out_width, ctx->in_width);
|
||||||
fixup_filter_sub(&ctx->vert, ctx->out_height, ctx->in_height);
|
fixup_filter_sub(&ctx->vert, ctx->out_height, ctx->in_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool scaler_gen_filter(struct scaler_ctx *ctx)
|
bool scaler_gen_filter(struct scaler_ctx *ctx)
|
||||||
{
|
{
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
switch (ctx->scaler_type)
|
switch (ctx->scaler_type)
|
||||||
{
|
{
|
||||||
case SCALER_TYPE_POINT:
|
case SCALER_TYPE_POINT:
|
||||||
ret = gen_filter_point(ctx);
|
ret = gen_filter_point(ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_TYPE_BILINEAR:
|
case SCALER_TYPE_BILINEAR:
|
||||||
ret = gen_filter_bilinear(ctx);
|
ret = gen_filter_bilinear(ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCALER_TYPE_SINC:
|
case SCALER_TYPE_SINC:
|
||||||
ret = gen_filter_sinc(ctx);
|
ret = gen_filter_sinc(ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fixup_filter(ctx);
|
fixup_filter(ctx);
|
||||||
|
|
||||||
return validate_filter(ctx);
|
return validate_filter(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,285 +1,285 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (scaler_int.c).
|
* The following license statement only applies to this file (scaler_int.c).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <gfx/scaler/scaler_int.h>
|
#include <gfx/scaler/scaler_int.h>
|
||||||
|
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
#ifdef SCALER_NO_SIMD
|
#ifdef SCALER_NO_SIMD
|
||||||
#undef __SSE2__
|
#undef __SSE2__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SSE2__)
|
#if defined(__SSE2__)
|
||||||
#include <emmintrin.h>
|
#include <emmintrin.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ARGB8888 scaler is split in two:
|
/* ARGB8888 scaler is split in two:
|
||||||
*
|
*
|
||||||
* First, horizontal scaler is applied.
|
* First, horizontal scaler is applied.
|
||||||
* Here, all 8-bit channels are expanded to 16-bit. Values are then shifted 7 to left to occupy 15 bits.
|
* Here, all 8-bit channels are expanded to 16-bit. Values are then shifted 7 to left to occupy 15 bits.
|
||||||
* The sign bit is kept empty as we have to do signed multiplication for the filter.
|
* The sign bit is kept empty as we have to do signed multiplication for the filter.
|
||||||
* A mulhi [(a * b) >> 16] is applied which loses some precision, but is very efficient for SIMD.
|
* A mulhi [(a * b) >> 16] is applied which loses some precision, but is very efficient for SIMD.
|
||||||
* It is accurate enough for 8-bit purposes.
|
* It is accurate enough for 8-bit purposes.
|
||||||
*
|
*
|
||||||
* The fixed point 1.0 for filter is (1 << 14). After horizontal scale, the output is kept
|
* The fixed point 1.0 for filter is (1 << 14). After horizontal scale, the output is kept
|
||||||
* with 16-bit channels, and will now have 13 bits of precision as [(a * (1 << 14)) >> 16] is effectively a right shift by 2.
|
* with 16-bit channels, and will now have 13 bits of precision as [(a * (1 << 14)) >> 16] is effectively a right shift by 2.
|
||||||
*
|
*
|
||||||
* Vertical scaler takes the 13 bit channels, and performs the same mulhi steps.
|
* Vertical scaler takes the 13 bit channels, and performs the same mulhi steps.
|
||||||
* Another 2 bits of precision is lost, which ends up as 11 bits.
|
* Another 2 bits of precision is lost, which ends up as 11 bits.
|
||||||
* Scaling is now complete. Channels are shifted right by 3, and saturated into 8-bit values.
|
* Scaling is now complete. Channels are shifted right by 3, and saturated into 8-bit values.
|
||||||
*
|
*
|
||||||
* The C version of scalers perform the exact same operations as the SIMD code for testing purposes.
|
* The C version of scalers perform the exact same operations as the SIMD code for testing purposes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__SSE2__)
|
#if defined(__SSE2__)
|
||||||
void scaler_argb8888_vert(const struct scaler_ctx *ctx, void *output_, int stride)
|
void scaler_argb8888_vert(const struct scaler_ctx *ctx, void *output_, int stride)
|
||||||
{
|
{
|
||||||
int h, w, y;
|
int h, w, y;
|
||||||
const uint64_t *input = ctx->scaled.frame;
|
const uint64_t *input = ctx->scaled.frame;
|
||||||
uint32_t *output = (uint32_t*)output_;
|
uint32_t *output = (uint32_t*)output_;
|
||||||
|
|
||||||
const int16_t *filter_vert = ctx->vert.filter;
|
const int16_t *filter_vert = ctx->vert.filter;
|
||||||
|
|
||||||
for (h = 0; h < ctx->out_height; h++, filter_vert += ctx->vert.filter_stride, output += stride >> 2)
|
for (h = 0; h < ctx->out_height; h++, filter_vert += ctx->vert.filter_stride, output += stride >> 2)
|
||||||
{
|
{
|
||||||
const uint64_t *input_base = input + ctx->vert.filter_pos[h] * (ctx->scaled.stride >> 3);
|
const uint64_t *input_base = input + ctx->vert.filter_pos[h] * (ctx->scaled.stride >> 3);
|
||||||
|
|
||||||
for (w = 0; w < ctx->out_width; w++)
|
for (w = 0; w < ctx->out_width; w++)
|
||||||
{
|
{
|
||||||
__m128i final;
|
__m128i final;
|
||||||
__m128i res = _mm_setzero_si128();
|
__m128i res = _mm_setzero_si128();
|
||||||
|
|
||||||
const uint64_t *input_base_y = input_base + w;
|
const uint64_t *input_base_y = input_base + w;
|
||||||
|
|
||||||
for (y = 0; (y + 1) < ctx->vert.filter_len; y += 2, input_base_y += (ctx->scaled.stride >> 2))
|
for (y = 0; (y + 1) < ctx->vert.filter_len; y += 2, input_base_y += (ctx->scaled.stride >> 2))
|
||||||
{
|
{
|
||||||
__m128i coeff = _mm_set_epi64x(filter_vert[y + 1] * 0x0001000100010001ll, filter_vert[y + 0] * 0x0001000100010001ll);
|
__m128i coeff = _mm_set_epi64x(filter_vert[y + 1] * 0x0001000100010001ll, filter_vert[y + 0] * 0x0001000100010001ll);
|
||||||
__m128i col = _mm_set_epi64x(input_base_y[ctx->scaled.stride >> 3], input_base_y[0]);
|
__m128i col = _mm_set_epi64x(input_base_y[ctx->scaled.stride >> 3], input_base_y[0]);
|
||||||
|
|
||||||
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; y < ctx->vert.filter_len; y++, input_base_y += (ctx->scaled.stride >> 3))
|
for (; y < ctx->vert.filter_len; y++, input_base_y += (ctx->scaled.stride >> 3))
|
||||||
{
|
{
|
||||||
__m128i coeff = _mm_set_epi64x(0, filter_vert[y] * 0x0001000100010001ll);
|
__m128i coeff = _mm_set_epi64x(0, filter_vert[y] * 0x0001000100010001ll);
|
||||||
__m128i col = _mm_set_epi64x(0, input_base_y[0]);
|
__m128i col = _mm_set_epi64x(0, input_base_y[0]);
|
||||||
|
|
||||||
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _mm_adds_epi16(_mm_srli_si128(res, 8), res);
|
res = _mm_adds_epi16(_mm_srli_si128(res, 8), res);
|
||||||
res = _mm_srai_epi16(res, (7 - 2 - 2));
|
res = _mm_srai_epi16(res, (7 - 2 - 2));
|
||||||
|
|
||||||
final = _mm_packus_epi16(res, res);
|
final = _mm_packus_epi16(res, res);
|
||||||
|
|
||||||
output[w] = _mm_cvtsi128_si32(final);
|
output[w] = _mm_cvtsi128_si32(final);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void scaler_argb8888_vert(const struct scaler_ctx *ctx, void *output_, int stride)
|
void scaler_argb8888_vert(const struct scaler_ctx *ctx, void *output_, int stride)
|
||||||
{
|
{
|
||||||
int h, w, y;
|
int h, w, y;
|
||||||
const uint64_t *input = ctx->scaled.frame;
|
const uint64_t *input = ctx->scaled.frame;
|
||||||
uint32_t *output = (uint32_t*)output_;
|
uint32_t *output = (uint32_t*)output_;
|
||||||
|
|
||||||
const int16_t *filter_vert = ctx->vert.filter;
|
const int16_t *filter_vert = ctx->vert.filter;
|
||||||
|
|
||||||
for (h = 0; h < ctx->out_height; h++, filter_vert += ctx->vert.filter_stride, output += stride >> 2)
|
for (h = 0; h < ctx->out_height; h++, filter_vert += ctx->vert.filter_stride, output += stride >> 2)
|
||||||
{
|
{
|
||||||
const uint64_t *input_base = input + ctx->vert.filter_pos[h] * (ctx->scaled.stride >> 3);
|
const uint64_t *input_base = input + ctx->vert.filter_pos[h] * (ctx->scaled.stride >> 3);
|
||||||
|
|
||||||
for (w = 0; w < ctx->out_width; w++)
|
for (w = 0; w < ctx->out_width; w++)
|
||||||
{
|
{
|
||||||
int16_t res_a = 0;
|
int16_t res_a = 0;
|
||||||
int16_t res_r = 0;
|
int16_t res_r = 0;
|
||||||
int16_t res_g = 0;
|
int16_t res_g = 0;
|
||||||
int16_t res_b = 0;
|
int16_t res_b = 0;
|
||||||
|
|
||||||
const uint64_t *input_base_y = input_base + w;
|
const uint64_t *input_base_y = input_base + w;
|
||||||
for (y = 0; y < ctx->vert.filter_len; y++, input_base_y += (ctx->scaled.stride >> 3))
|
for (y = 0; y < ctx->vert.filter_len; y++, input_base_y += (ctx->scaled.stride >> 3))
|
||||||
{
|
{
|
||||||
uint64_t col = *input_base_y;
|
uint64_t col = *input_base_y;
|
||||||
|
|
||||||
int16_t a = (col >> 48) & 0xffff;
|
int16_t a = (col >> 48) & 0xffff;
|
||||||
int16_t r = (col >> 32) & 0xffff;
|
int16_t r = (col >> 32) & 0xffff;
|
||||||
int16_t g = (col >> 16) & 0xffff;
|
int16_t g = (col >> 16) & 0xffff;
|
||||||
int16_t b = (col >> 0) & 0xffff;
|
int16_t b = (col >> 0) & 0xffff;
|
||||||
|
|
||||||
int16_t coeff = filter_vert[y];
|
int16_t coeff = filter_vert[y];
|
||||||
|
|
||||||
res_a += (a * coeff) >> 16;
|
res_a += (a * coeff) >> 16;
|
||||||
res_r += (r * coeff) >> 16;
|
res_r += (r * coeff) >> 16;
|
||||||
res_g += (g * coeff) >> 16;
|
res_g += (g * coeff) >> 16;
|
||||||
res_b += (b * coeff) >> 16;
|
res_b += (b * coeff) >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
res_a >>= (7 - 2 - 2);
|
res_a >>= (7 - 2 - 2);
|
||||||
res_r >>= (7 - 2 - 2);
|
res_r >>= (7 - 2 - 2);
|
||||||
res_g >>= (7 - 2 - 2);
|
res_g >>= (7 - 2 - 2);
|
||||||
res_b >>= (7 - 2 - 2);
|
res_b >>= (7 - 2 - 2);
|
||||||
|
|
||||||
output[w] = (clamp_8bit(res_a) << 24) | (clamp_8bit(res_r) << 16) | (clamp_8bit(res_g) << 8) | (clamp_8bit(res_b) << 0);
|
output[w] = (clamp_8bit(res_a) << 24) | (clamp_8bit(res_r) << 16) | (clamp_8bit(res_g) << 8) | (clamp_8bit(res_b) << 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__SSE2__)
|
#if defined(__SSE2__)
|
||||||
void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int stride)
|
void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int stride)
|
||||||
{
|
{
|
||||||
int h, w, x;
|
int h, w, x;
|
||||||
const uint32_t *input = (const uint32_t*)input_;
|
const uint32_t *input = (const uint32_t*)input_;
|
||||||
uint64_t *output = ctx->scaled.frame;
|
uint64_t *output = ctx->scaled.frame;
|
||||||
|
|
||||||
for (h = 0; h < ctx->scaled.height; h++, input += stride >> 2, output += ctx->scaled.stride >> 3)
|
for (h = 0; h < ctx->scaled.height; h++, input += stride >> 2, output += ctx->scaled.stride >> 3)
|
||||||
{
|
{
|
||||||
const int16_t *filter_horiz = ctx->horiz.filter;
|
const int16_t *filter_horiz = ctx->horiz.filter;
|
||||||
|
|
||||||
for (w = 0; w < ctx->scaled.width; w++, filter_horiz += ctx->horiz.filter_stride)
|
for (w = 0; w < ctx->scaled.width; w++, filter_horiz += ctx->horiz.filter_stride)
|
||||||
{
|
{
|
||||||
__m128i res = _mm_setzero_si128();
|
__m128i res = _mm_setzero_si128();
|
||||||
|
|
||||||
const uint32_t *input_base_x = input + ctx->horiz.filter_pos[w];
|
const uint32_t *input_base_x = input + ctx->horiz.filter_pos[w];
|
||||||
|
|
||||||
for (x = 0; (x + 1) < ctx->horiz.filter_len; x += 2)
|
for (x = 0; (x + 1) < ctx->horiz.filter_len; x += 2)
|
||||||
{
|
{
|
||||||
__m128i coeff = _mm_set_epi64x(filter_horiz[x + 1] * 0x0001000100010001ll, filter_horiz[x + 0] * 0x0001000100010001ll);
|
__m128i coeff = _mm_set_epi64x(filter_horiz[x + 1] * 0x0001000100010001ll, filter_horiz[x + 0] * 0x0001000100010001ll);
|
||||||
|
|
||||||
__m128i col = _mm_unpacklo_epi8(_mm_set_epi64x(0,
|
__m128i col = _mm_unpacklo_epi8(_mm_set_epi64x(0,
|
||||||
((uint64_t)input_base_x[x + 1] << 32) | input_base_x[x + 0]), _mm_setzero_si128());
|
((uint64_t)input_base_x[x + 1] << 32) | input_base_x[x + 0]), _mm_setzero_si128());
|
||||||
|
|
||||||
col = _mm_slli_epi16(col, 7);
|
col = _mm_slli_epi16(col, 7);
|
||||||
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; x < ctx->horiz.filter_len; x++)
|
for (; x < ctx->horiz.filter_len; x++)
|
||||||
{
|
{
|
||||||
__m128i coeff = _mm_set_epi64x(0, filter_horiz[x] * 0x0001000100010001ll);
|
__m128i coeff = _mm_set_epi64x(0, filter_horiz[x] * 0x0001000100010001ll);
|
||||||
__m128i col = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, 0, input_base_x[x]), _mm_setzero_si128());
|
__m128i col = _mm_unpacklo_epi8(_mm_set_epi32(0, 0, 0, input_base_x[x]), _mm_setzero_si128());
|
||||||
|
|
||||||
col = _mm_slli_epi16(col, 7);
|
col = _mm_slli_epi16(col, 7);
|
||||||
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
res = _mm_adds_epi16(_mm_mulhi_epi16(col, coeff), res);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = _mm_adds_epi16(_mm_srli_si128(res, 8), res);
|
res = _mm_adds_epi16(_mm_srli_si128(res, 8), res);
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
output[w] = _mm_cvtsi128_si64(res);
|
output[w] = _mm_cvtsi128_si64(res);
|
||||||
#else /* 32-bit doesn't have si64. Do it in two steps. */
|
#else /* 32-bit doesn't have si64. Do it in two steps. */
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint32_t *u32;
|
uint32_t *u32;
|
||||||
uint64_t *u64;
|
uint64_t *u64;
|
||||||
} u;
|
} u;
|
||||||
u.u64 = output + w;
|
u.u64 = output + w;
|
||||||
u.u32[0] = _mm_cvtsi128_si32(res);
|
u.u32[0] = _mm_cvtsi128_si32(res);
|
||||||
u.u32[1] = _mm_cvtsi128_si32(_mm_srli_si128(res, 4));
|
u.u32[1] = _mm_cvtsi128_si32(_mm_srli_si128(res, 4));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static INLINE uint64_t build_argb64(uint16_t a, uint16_t r, uint16_t g, uint16_t b)
|
static INLINE uint64_t build_argb64(uint16_t a, uint16_t r, uint16_t g, uint16_t b)
|
||||||
{
|
{
|
||||||
return ((uint64_t)a << 48) | ((uint64_t)r << 32) | ((uint64_t)g << 16) | ((uint64_t)b << 0);
|
return ((uint64_t)a << 48) | ((uint64_t)r << 32) | ((uint64_t)g << 16) | ((uint64_t)b << 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int stride)
|
void scaler_argb8888_horiz(const struct scaler_ctx *ctx, const void *input_, int stride)
|
||||||
{
|
{
|
||||||
int h, w, x;
|
int h, w, x;
|
||||||
const uint32_t *input = (uint32_t*)input_;
|
const uint32_t *input = (uint32_t*)input_;
|
||||||
uint64_t *output = ctx->scaled.frame;
|
uint64_t *output = ctx->scaled.frame;
|
||||||
|
|
||||||
for (h = 0; h < ctx->scaled.height; h++, input += stride >> 2, output += ctx->scaled.stride >> 3)
|
for (h = 0; h < ctx->scaled.height; h++, input += stride >> 2, output += ctx->scaled.stride >> 3)
|
||||||
{
|
{
|
||||||
const int16_t *filter_horiz = ctx->horiz.filter;
|
const int16_t *filter_horiz = ctx->horiz.filter;
|
||||||
|
|
||||||
for (w = 0; w < ctx->scaled.width; w++, filter_horiz += ctx->horiz.filter_stride)
|
for (w = 0; w < ctx->scaled.width; w++, filter_horiz += ctx->horiz.filter_stride)
|
||||||
{
|
{
|
||||||
const uint32_t *input_base_x = input + ctx->horiz.filter_pos[w];
|
const uint32_t *input_base_x = input + ctx->horiz.filter_pos[w];
|
||||||
|
|
||||||
int16_t res_a = 0;
|
int16_t res_a = 0;
|
||||||
int16_t res_r = 0;
|
int16_t res_r = 0;
|
||||||
int16_t res_g = 0;
|
int16_t res_g = 0;
|
||||||
int16_t res_b = 0;
|
int16_t res_b = 0;
|
||||||
|
|
||||||
for (x = 0; x < ctx->horiz.filter_len; x++)
|
for (x = 0; x < ctx->horiz.filter_len; x++)
|
||||||
{
|
{
|
||||||
uint32_t col = input_base_x[x];
|
uint32_t col = input_base_x[x];
|
||||||
|
|
||||||
int16_t a = (col >> (24 - 7)) & (0xff << 7);
|
int16_t a = (col >> (24 - 7)) & (0xff << 7);
|
||||||
int16_t r = (col >> (16 - 7)) & (0xff << 7);
|
int16_t r = (col >> (16 - 7)) & (0xff << 7);
|
||||||
int16_t g = (col >> ( 8 - 7)) & (0xff << 7);
|
int16_t g = (col >> ( 8 - 7)) & (0xff << 7);
|
||||||
int16_t b = (col << ( 0 + 7)) & (0xff << 7);
|
int16_t b = (col << ( 0 + 7)) & (0xff << 7);
|
||||||
|
|
||||||
int16_t coeff = filter_horiz[x];
|
int16_t coeff = filter_horiz[x];
|
||||||
|
|
||||||
res_a += (a * coeff) >> 16;
|
res_a += (a * coeff) >> 16;
|
||||||
res_r += (r * coeff) >> 16;
|
res_r += (r * coeff) >> 16;
|
||||||
res_g += (g * coeff) >> 16;
|
res_g += (g * coeff) >> 16;
|
||||||
res_b += (b * coeff) >> 16;
|
res_b += (b * coeff) >> 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
output[w] = build_argb64(res_a, res_r, res_g, res_b);
|
output[w] = build_argb64(res_a, res_r, res_g, res_b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void scaler_argb8888_point_special(const struct scaler_ctx *ctx,
|
void scaler_argb8888_point_special(const struct scaler_ctx *ctx,
|
||||||
void *output_, const void *input_,
|
void *output_, const void *input_,
|
||||||
int out_width, int out_height,
|
int out_width, int out_height,
|
||||||
int in_width, int in_height,
|
int in_width, int in_height,
|
||||||
int out_stride, int in_stride)
|
int out_stride, int in_stride)
|
||||||
{
|
{
|
||||||
int h, w;
|
int h, w;
|
||||||
const uint32_t *input = NULL;
|
const uint32_t *input = NULL;
|
||||||
uint32_t *output = NULL;
|
uint32_t *output = NULL;
|
||||||
int x_pos = (1 << 15) * in_width / out_width - (1 << 15);
|
int x_pos = (1 << 15) * in_width / out_width - (1 << 15);
|
||||||
int x_step = (1 << 16) * in_width / out_width;
|
int x_step = (1 << 16) * in_width / out_width;
|
||||||
int y_pos = (1 << 15) * in_height / out_height - (1 << 15);
|
int y_pos = (1 << 15) * in_height / out_height - (1 << 15);
|
||||||
int y_step = (1 << 16) * in_height / out_height;
|
int y_step = (1 << 16) * in_height / out_height;
|
||||||
|
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
|
||||||
if (x_pos < 0)
|
if (x_pos < 0)
|
||||||
x_pos = 0;
|
x_pos = 0;
|
||||||
if (y_pos < 0)
|
if (y_pos < 0)
|
||||||
y_pos = 0;
|
y_pos = 0;
|
||||||
|
|
||||||
input = (const uint32_t*)input_;
|
input = (const uint32_t*)input_;
|
||||||
output = (uint32_t*)output_;
|
output = (uint32_t*)output_;
|
||||||
|
|
||||||
for (h = 0; h < out_height; h++, y_pos += y_step, output += out_stride >> 2)
|
for (h = 0; h < out_height; h++, y_pos += y_step, output += out_stride >> 2)
|
||||||
{
|
{
|
||||||
int x = x_pos;
|
int x = x_pos;
|
||||||
const uint32_t *inp = input + (y_pos >> 16) * (in_stride >> 2);
|
const uint32_t *inp = input + (y_pos >> 16) * (in_stride >> 2);
|
||||||
|
|
||||||
for (w = 0; w < out_width; w++, x += x_step)
|
for (w = 0; w < out_width; w++, x += x_step)
|
||||||
output[w] = inp[x >> 16];
|
output[w] = inp[x >> 16];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,87 +1,87 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <glsym/glsym.h>
|
#include <glsym/glsym.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#define SYM(x) { "gl" #x, &(gl##x) }
|
#define SYM(x) { "gl" #x, &(gl##x) }
|
||||||
const struct rglgen_sym_map rglgen_symbol_map[] = {
|
const struct rglgen_sym_map rglgen_symbol_map[] = {
|
||||||
SYM(DebugMessageControlKHR),
|
SYM(DebugMessageControlKHR),
|
||||||
SYM(DebugMessageInsertKHR),
|
SYM(DebugMessageInsertKHR),
|
||||||
SYM(DebugMessageCallbackKHR),
|
SYM(DebugMessageCallbackKHR),
|
||||||
SYM(GetDebugMessageLogKHR),
|
SYM(GetDebugMessageLogKHR),
|
||||||
SYM(PushDebugGroupKHR),
|
SYM(PushDebugGroupKHR),
|
||||||
SYM(PopDebugGroupKHR),
|
SYM(PopDebugGroupKHR),
|
||||||
SYM(ObjectLabelKHR),
|
SYM(ObjectLabelKHR),
|
||||||
SYM(GetObjectLabelKHR),
|
SYM(GetObjectLabelKHR),
|
||||||
SYM(ObjectPtrLabelKHR),
|
SYM(ObjectPtrLabelKHR),
|
||||||
SYM(GetObjectPtrLabelKHR),
|
SYM(GetObjectPtrLabelKHR),
|
||||||
SYM(GetPointervKHR),
|
SYM(GetPointervKHR),
|
||||||
SYM(EGLImageTargetTexture2DOES),
|
SYM(EGLImageTargetTexture2DOES),
|
||||||
SYM(EGLImageTargetRenderbufferStorageOES),
|
SYM(EGLImageTargetRenderbufferStorageOES),
|
||||||
SYM(GetProgramBinaryOES),
|
SYM(GetProgramBinaryOES),
|
||||||
SYM(ProgramBinaryOES),
|
SYM(ProgramBinaryOES),
|
||||||
SYM(MapBufferOES),
|
SYM(MapBufferOES),
|
||||||
SYM(UnmapBufferOES),
|
SYM(UnmapBufferOES),
|
||||||
SYM(GetBufferPointervOES),
|
SYM(GetBufferPointervOES),
|
||||||
SYM(TexImage3DOES),
|
SYM(TexImage3DOES),
|
||||||
SYM(TexSubImage3DOES),
|
SYM(TexSubImage3DOES),
|
||||||
SYM(CopyTexSubImage3DOES),
|
SYM(CopyTexSubImage3DOES),
|
||||||
SYM(CompressedTexImage3DOES),
|
SYM(CompressedTexImage3DOES),
|
||||||
SYM(CompressedTexSubImage3DOES),
|
SYM(CompressedTexSubImage3DOES),
|
||||||
SYM(FramebufferTexture3DOES),
|
SYM(FramebufferTexture3DOES),
|
||||||
SYM(BindVertexArrayOES),
|
SYM(BindVertexArrayOES),
|
||||||
SYM(DeleteVertexArraysOES),
|
SYM(DeleteVertexArraysOES),
|
||||||
SYM(GenVertexArraysOES),
|
SYM(GenVertexArraysOES),
|
||||||
SYM(IsVertexArrayOES),
|
SYM(IsVertexArrayOES),
|
||||||
|
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
|
RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
|
||||||
RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
|
RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
|
||||||
RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
|
RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
|
||||||
RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
|
RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
|
||||||
RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
|
RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
|
||||||
RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
|
RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
|
||||||
RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
|
RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
|
||||||
RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
|
RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
|
||||||
RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
|
RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
|
||||||
RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
|
RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
|
||||||
RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
|
RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
|
||||||
RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
||||||
RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
||||||
RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
||||||
RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
||||||
RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
||||||
RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
||||||
RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
||||||
RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
||||||
RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
||||||
RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
||||||
RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
||||||
RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
||||||
RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
||||||
RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
||||||
RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
||||||
RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
||||||
RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,43 +1,43 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <glsym/rglgen.h>
|
#include <glsym/rglgen.h>
|
||||||
#include <glsym/glsym.h>
|
#include <glsym/glsym.h>
|
||||||
|
|
||||||
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
||||||
const struct rglgen_sym_map *map)
|
const struct rglgen_sym_map *map)
|
||||||
{
|
{
|
||||||
for (; map->sym; map++)
|
for (; map->sym; map++)
|
||||||
{
|
{
|
||||||
rglgen_func_t func = proc(map->sym);
|
rglgen_func_t func = proc(map->sym);
|
||||||
memcpy(map->ptr, &func, sizeof(func));
|
memcpy(map->ptr, &func, sizeof(func));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rglgen_resolve_symbols(rglgen_proc_address_t proc)
|
void rglgen_resolve_symbols(rglgen_proc_address_t proc)
|
||||||
{
|
{
|
||||||
rglgen_resolve_symbols_custom(proc, rglgen_symbol_map);
|
rglgen_resolve_symbols_custom(proc, rglgen_symbol_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,39 +1,39 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (boolean.h).
|
* The following license statement only applies to this file (boolean.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_BOOLEAN_H
|
#ifndef __LIBRETRO_SDK_BOOLEAN_H
|
||||||
#define __LIBRETRO_SDK_BOOLEAN_H
|
#define __LIBRETRO_SDK_BOOLEAN_H
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
|
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
|
||||||
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
|
/* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */
|
||||||
#define bool unsigned char
|
#define bool unsigned char
|
||||||
#define true 1
|
#define true 1
|
||||||
#define false 0
|
#define false 0
|
||||||
#else
|
#else
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,65 +1,65 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (boolean.h).
|
* The following license statement only applies to this file (boolean.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_SDK_CLAMPING_H
|
#ifndef _LIBRETRO_SDK_CLAMPING_H
|
||||||
#define _LIBRETRO_SDK_CLAMPING_H
|
#define _LIBRETRO_SDK_CLAMPING_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clamp_float:
|
* clamp_float:
|
||||||
* @val : initial value
|
* @val : initial value
|
||||||
* @lower : lower limit that value should be clamped against
|
* @lower : lower limit that value should be clamped against
|
||||||
* @upper : upper limit that value should be clamped against
|
* @upper : upper limit that value should be clamped against
|
||||||
*
|
*
|
||||||
* Clamps a floating point value.
|
* Clamps a floating point value.
|
||||||
*
|
*
|
||||||
* Returns: a clamped value of initial float value @val.
|
* Returns: a clamped value of initial float value @val.
|
||||||
*/
|
*/
|
||||||
static INLINE float clamp_float(float val, float lower, float upper)
|
static INLINE float clamp_float(float val, float lower, float upper)
|
||||||
{
|
{
|
||||||
if (val < lower)
|
if (val < lower)
|
||||||
return lower;
|
return lower;
|
||||||
if (val > upper)
|
if (val > upper)
|
||||||
return upper;
|
return upper;
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clamp_8bit:
|
* clamp_8bit:
|
||||||
* @val : initial value
|
* @val : initial value
|
||||||
*
|
*
|
||||||
* Clamps an unsigned 8-bit value.
|
* Clamps an unsigned 8-bit value.
|
||||||
*
|
*
|
||||||
* Returns: a clamped value of initial unsigned 8-bit value @val.
|
* Returns: a clamped value of initial unsigned 8-bit value @val.
|
||||||
*/
|
*/
|
||||||
static INLINE uint8_t clamp_8bit(int val)
|
static INLINE uint8_t clamp_8bit(int val)
|
||||||
{
|
{
|
||||||
if (val > 255)
|
if (val > 255)
|
||||||
return 255;
|
return 255;
|
||||||
if (val < 0)
|
if (val < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return (uint8_t)val;
|
return (uint8_t)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (apple_compat.h).
|
* The following license statement only applies to this file (apple_compat.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include <AvailabilityMacros.h>
|
#include <AvailabilityMacros.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
|
|
||||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4)
|
||||||
typedef int NSInteger;
|
typedef int NSInteger;
|
||||||
typedef unsigned NSUInteger;
|
typedef unsigned NSUInteger;
|
||||||
typedef float CGFloat;
|
typedef float CGFloat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IOS
|
#ifdef IOS
|
||||||
#ifndef __IPHONE_5_0
|
#ifndef __IPHONE_5_0
|
||||||
#warning "This project uses features only available in iOS SDK 5.0 and later."
|
#warning "This project uses features only available in iOS SDK 5.0 and later."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
#import <GLKit/GLKit.h>
|
#import <GLKit/GLKit.h>
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#include <objc/objc-runtime.h>
|
#include <objc/objc-runtime.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,30 +1,30 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_fnmatch.h).
|
* The following license statement only applies to this file (compat_fnmatch.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
#ifndef __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
||||||
#define __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
#define __LIBRETRO_SDK_COMPAT_FNMATCH_H__
|
||||||
|
|
||||||
#define FNM_NOMATCH 1
|
#define FNM_NOMATCH 1
|
||||||
|
|
||||||
int rl_fnmatch(const char *pattern, const char *string, int flags);
|
int rl_fnmatch(const char *pattern, const char *string, int flags);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,76 +1,76 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (compat_getopt.h).
|
* The following license statement only applies to this file (compat_getopt.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_GETOPT_H
|
#ifndef __LIBRETRO_SDK_COMPAT_GETOPT_H
|
||||||
#define __LIBRETRO_SDK_COMPAT_GETOPT_H
|
#define __LIBRETRO_SDK_COMPAT_GETOPT_H
|
||||||
|
|
||||||
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Custom implementation of the GNU getopt_long for portability.
|
/* Custom implementation of the GNU getopt_long for portability.
|
||||||
* Not designed to be fully compatible, but compatible with
|
* Not designed to be fully compatible, but compatible with
|
||||||
* the features RetroArch uses. */
|
* the features RetroArch uses. */
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#else
|
#else
|
||||||
/* Avoid possible naming collisions during link since we
|
/* Avoid possible naming collisions during link since we
|
||||||
* prefer to use the actual name. */
|
* prefer to use the actual name. */
|
||||||
#define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex)
|
#define getopt_long(argc, argv, optstring, longopts, longindex) __getopt_long_retro(argc, argv, optstring, longopts, longindex)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct option
|
struct option
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
int has_arg;
|
int has_arg;
|
||||||
int *flag;
|
int *flag;
|
||||||
int val;
|
int val;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* argv[] is declared with char * const argv[] in GNU,
|
/* argv[] is declared with char * const argv[] in GNU,
|
||||||
* but this makes no sense, as non-POSIX getopt_long
|
* but this makes no sense, as non-POSIX getopt_long
|
||||||
* mutates argv (non-opts are moved to the end). */
|
* mutates argv (non-opts are moved to the end). */
|
||||||
int getopt_long(int argc, char *argv[],
|
int getopt_long(int argc, char *argv[],
|
||||||
const char *optstring, const struct option *longopts, int *longindex);
|
const char *optstring, const struct option *longopts, int *longindex);
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If these are variously #defined, then we have bigger problems */
|
/* If these are variously #defined, then we have bigger problems */
|
||||||
#ifndef no_argument
|
#ifndef no_argument
|
||||||
#define no_argument 0
|
#define no_argument 0
|
||||||
#define required_argument 1
|
#define required_argument 1
|
||||||
#define optional_argument 2
|
#define optional_argument 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* HAVE_GETOPT_LONG */
|
/* HAVE_GETOPT_LONG */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* pragma once */
|
/* pragma once */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1995, 1999
|
||||||
|
* Berkeley Software Design, Inc. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _IFADDRS_H_
|
||||||
|
#define _IFADDRS_H_
|
||||||
|
|
||||||
|
struct ifaddrs
|
||||||
|
{
|
||||||
|
struct ifaddrs *ifa_next;
|
||||||
|
char *ifa_name;
|
||||||
|
unsigned int ifa_flags;
|
||||||
|
struct sockaddr *ifa_addr;
|
||||||
|
struct sockaddr *ifa_netmask;
|
||||||
|
struct sockaddr *ifa_dstaddr;
|
||||||
|
void *ifa_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This may have been defined in <net/if.h>. Note that if <net/if.h> is
|
||||||
|
* to be included it must be included before this header file.
|
||||||
|
*/
|
||||||
|
#ifndef ifa_broadaddr
|
||||||
|
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
extern int getifaddrs(struct ifaddrs **ifap);
|
||||||
|
extern void freeifaddrs(struct ifaddrs *ifa);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,103 +1,103 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (msvc_compat.h).
|
* The following license statement only applies to this file (msvc_compat.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_MSVC_H
|
#ifndef __LIBRETRO_SDK_COMPAT_MSVC_H
|
||||||
#define __LIBRETRO_SDK_COMPAT_MSVC_H
|
#define __LIBRETRO_SDK_COMPAT_MSVC_H
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */
|
/* Pre-MSVC 2015 compilers don't implement snprintf in a cross-platform manner. */
|
||||||
#if _MSC_VER < 1900
|
#if _MSC_VER < 1900
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifndef snprintf
|
#ifndef snprintf
|
||||||
#define snprintf c99_snprintf_retro__
|
#define snprintf c99_snprintf_retro__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...);
|
int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */
|
/* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */
|
||||||
#if _MSC_VER < 1600
|
#if _MSC_VER < 1600
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifndef vsnprintf
|
#ifndef vsnprintf
|
||||||
#define vsnprintf c99_vsnprintf_retro__
|
#define vsnprintf c99_vsnprintf_retro__
|
||||||
#endif
|
#endif
|
||||||
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap);
|
int c99_vsnprintf_retro__(char *outBuf, size_t size, const char *format, va_list ap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef UNICODE /* Do not bother with UNICODE at this time. */
|
#undef UNICODE /* Do not bother with UNICODE at this time. */
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
|
/* Python headers defines ssize_t and sets HAVE_SSIZE_T.
|
||||||
* Cannot duplicate these efforts.
|
* Cannot duplicate these efforts.
|
||||||
*/
|
*/
|
||||||
#ifndef HAVE_SSIZE_T
|
#ifndef HAVE_SSIZE_T
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
typedef __int64 ssize_t;
|
typedef __int64 ssize_t;
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
typedef int ssize_t;
|
typedef int ssize_t;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define mkdir(dirname, unused) _mkdir(dirname)
|
#define mkdir(dirname, unused) _mkdir(dirname)
|
||||||
#define strtoull _strtoui64
|
#define strtoull _strtoui64
|
||||||
#undef strcasecmp
|
#undef strcasecmp
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#undef strncasecmp
|
#undef strncasecmp
|
||||||
#define strncasecmp _strnicmp
|
#define strncasecmp _strnicmp
|
||||||
|
|
||||||
/* Disable some of the annoying warnings. */
|
/* Disable some of the annoying warnings. */
|
||||||
#pragma warning(disable : 4800)
|
#pragma warning(disable : 4800)
|
||||||
#pragma warning(disable : 4805)
|
#pragma warning(disable : 4805)
|
||||||
#pragma warning(disable : 4244)
|
#pragma warning(disable : 4244)
|
||||||
#pragma warning(disable : 4305)
|
#pragma warning(disable : 4305)
|
||||||
#pragma warning(disable : 4146)
|
#pragma warning(disable : 4146)
|
||||||
#pragma warning(disable : 4267)
|
#pragma warning(disable : 4267)
|
||||||
#pragma warning(disable : 4723)
|
#pragma warning(disable : 4723)
|
||||||
#pragma warning(disable : 4996)
|
#pragma warning(disable : 4996)
|
||||||
|
|
||||||
#if _MSC_VER < 1200
|
#if _MSC_VER < 1200
|
||||||
#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
|
#define roundf(in) (in >= 0.0f ? floorf(in + 0.5f) : ceilf(in - 0.5f))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PATH_MAX
|
#ifndef PATH_MAX
|
||||||
#define PATH_MAX _MAX_PATH
|
#define PATH_MAX _MAX_PATH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SIZE_MAX
|
#ifndef SIZE_MAX
|
||||||
#define SIZE_MAX _UI32_MAX
|
#define SIZE_MAX _UI32_MAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,254 +1,254 @@
|
||||||
/* ISO C9x compliant stdint.h for Microsoft Visual Studio
|
/* ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||||
* Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
* Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||||
*
|
*
|
||||||
* Copyright (c) 2006-2008 Alexander Chemeris
|
* Copyright (c) 2006-2008 Alexander Chemeris
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
*
|
*
|
||||||
* 3. The name of the author may be used to endorse or promote products
|
* 3. The name of the author may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||||
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RARCH_STDINT_H
|
#ifndef __RARCH_STDINT_H
|
||||||
#define __RARCH_STDINT_H
|
#define __RARCH_STDINT_H
|
||||||
|
|
||||||
#if _MSC_VER && (_MSC_VER < 1600)
|
#if _MSC_VER && (_MSC_VER < 1600)
|
||||||
/* Pre-MSVC 2010 needs an implementation of stdint.h. */
|
/* Pre-MSVC 2010 needs an implementation of stdint.h. */
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
#if _MSC_VER > 1000
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/* For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
/* For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||||
* compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
* compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||||
* or compiler give many errors like this:
|
* or compiler give many errors like this:
|
||||||
*
|
*
|
||||||
* error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
* error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||||
*/
|
*/
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
# include <wchar.h>
|
# include <wchar.h>
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Define _W64 macros to mark types changing their size, like intptr_t. */
|
/* Define _W64 macros to mark types changing their size, like intptr_t. */
|
||||||
#ifndef _W64
|
#ifndef _W64
|
||||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||||
# define _W64 __w64
|
# define _W64 __w64
|
||||||
# else
|
# else
|
||||||
# define _W64
|
# define _W64
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* 7.18.1 Integer types. */
|
/* 7.18.1 Integer types. */
|
||||||
|
|
||||||
/* 7.18.1.1 Exact-width integer types. */
|
/* 7.18.1.1 Exact-width integer types. */
|
||||||
|
|
||||||
/* Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
/* Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||||
* realize that, e.g. char has the same size as __int8
|
* realize that, e.g. char has the same size as __int8
|
||||||
* so we give up on __intX for them.
|
* so we give up on __intX for them.
|
||||||
*/
|
*/
|
||||||
#if (_MSC_VER < 1300)
|
#if (_MSC_VER < 1300)
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef signed short int16_t;
|
typedef signed short int16_t;
|
||||||
typedef signed int int32_t;
|
typedef signed int int32_t;
|
||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
#else
|
#else
|
||||||
typedef signed __int8 int8_t;
|
typedef signed __int8 int8_t;
|
||||||
typedef signed __int16 int16_t;
|
typedef signed __int16 int16_t;
|
||||||
typedef signed __int32 int32_t;
|
typedef signed __int32 int32_t;
|
||||||
typedef unsigned __int8 uint8_t;
|
typedef unsigned __int8 uint8_t;
|
||||||
typedef unsigned __int16 uint16_t;
|
typedef unsigned __int16 uint16_t;
|
||||||
typedef unsigned __int32 uint32_t;
|
typedef unsigned __int32 uint32_t;
|
||||||
#endif
|
#endif
|
||||||
typedef signed __int64 int64_t;
|
typedef signed __int64 int64_t;
|
||||||
typedef unsigned __int64 uint64_t;
|
typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
|
|
||||||
/* 7.18.1.2 Minimum-width integer types. */
|
/* 7.18.1.2 Minimum-width integer types. */
|
||||||
typedef int8_t int_least8_t;
|
typedef int8_t int_least8_t;
|
||||||
typedef int16_t int_least16_t;
|
typedef int16_t int_least16_t;
|
||||||
typedef int32_t int_least32_t;
|
typedef int32_t int_least32_t;
|
||||||
typedef int64_t int_least64_t;
|
typedef int64_t int_least64_t;
|
||||||
typedef uint8_t uint_least8_t;
|
typedef uint8_t uint_least8_t;
|
||||||
typedef uint16_t uint_least16_t;
|
typedef uint16_t uint_least16_t;
|
||||||
typedef uint32_t uint_least32_t;
|
typedef uint32_t uint_least32_t;
|
||||||
typedef uint64_t uint_least64_t;
|
typedef uint64_t uint_least64_t;
|
||||||
|
|
||||||
/* 7.18.1.3 Fastest minimum-width integer types. */
|
/* 7.18.1.3 Fastest minimum-width integer types. */
|
||||||
typedef int8_t int_fast8_t;
|
typedef int8_t int_fast8_t;
|
||||||
typedef int16_t int_fast16_t;
|
typedef int16_t int_fast16_t;
|
||||||
typedef int32_t int_fast32_t;
|
typedef int32_t int_fast32_t;
|
||||||
typedef int64_t int_fast64_t;
|
typedef int64_t int_fast64_t;
|
||||||
typedef uint8_t uint_fast8_t;
|
typedef uint8_t uint_fast8_t;
|
||||||
typedef uint16_t uint_fast16_t;
|
typedef uint16_t uint_fast16_t;
|
||||||
typedef uint32_t uint_fast32_t;
|
typedef uint32_t uint_fast32_t;
|
||||||
typedef uint64_t uint_fast64_t;
|
typedef uint64_t uint_fast64_t;
|
||||||
|
|
||||||
/* 7.18.1.4 Integer types capable of holding object pointers. */
|
/* 7.18.1.4 Integer types capable of holding object pointers. */
|
||||||
#ifdef _WIN64 /* [ */
|
#ifdef _WIN64 /* [ */
|
||||||
typedef signed __int64 intptr_t;
|
typedef signed __int64 intptr_t;
|
||||||
typedef unsigned __int64 uintptr_t;
|
typedef unsigned __int64 uintptr_t;
|
||||||
#else /* _WIN64 ][ */
|
#else /* _WIN64 ][ */
|
||||||
typedef _W64 signed int intptr_t;
|
typedef _W64 signed int intptr_t;
|
||||||
typedef _W64 unsigned int uintptr_t;
|
typedef _W64 unsigned int uintptr_t;
|
||||||
#endif /* _WIN64 ] */
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
/* 7.18.1.5 Greatest-width integer types. */
|
/* 7.18.1.5 Greatest-width integer types. */
|
||||||
typedef int64_t intmax_t;
|
typedef int64_t intmax_t;
|
||||||
typedef uint64_t uintmax_t;
|
typedef uint64_t uintmax_t;
|
||||||
|
|
||||||
/* 7.18.2 Limits of specified-width integer types. */
|
/* 7.18.2 Limits of specified-width integer types. */
|
||||||
|
|
||||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||||
/* [ See footnote 220 at page 257 and footnote 221 at page 259. */
|
/* [ See footnote 220 at page 257 and footnote 221 at page 259. */
|
||||||
|
|
||||||
/* 7.18.2.1 Limits of exact-width integer types. */
|
/* 7.18.2.1 Limits of exact-width integer types. */
|
||||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||||
#define INT8_MAX _I8_MAX
|
#define INT8_MAX _I8_MAX
|
||||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||||
#define INT16_MAX _I16_MAX
|
#define INT16_MAX _I16_MAX
|
||||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||||
#define INT32_MAX _I32_MAX
|
#define INT32_MAX _I32_MAX
|
||||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||||
#define INT64_MAX _I64_MAX
|
#define INT64_MAX _I64_MAX
|
||||||
#define UINT8_MAX _UI8_MAX
|
#define UINT8_MAX _UI8_MAX
|
||||||
#define UINT16_MAX _UI16_MAX
|
#define UINT16_MAX _UI16_MAX
|
||||||
#define UINT32_MAX _UI32_MAX
|
#define UINT32_MAX _UI32_MAX
|
||||||
#define UINT64_MAX _UI64_MAX
|
#define UINT64_MAX _UI64_MAX
|
||||||
|
|
||||||
/* 7.18.2.2 Limits of minimum-width integer types. */
|
/* 7.18.2.2 Limits of minimum-width integer types. */
|
||||||
#define INT_LEAST8_MIN INT8_MIN
|
#define INT_LEAST8_MIN INT8_MIN
|
||||||
#define INT_LEAST8_MAX INT8_MAX
|
#define INT_LEAST8_MAX INT8_MAX
|
||||||
#define INT_LEAST16_MIN INT16_MIN
|
#define INT_LEAST16_MIN INT16_MIN
|
||||||
#define INT_LEAST16_MAX INT16_MAX
|
#define INT_LEAST16_MAX INT16_MAX
|
||||||
#define INT_LEAST32_MIN INT32_MIN
|
#define INT_LEAST32_MIN INT32_MIN
|
||||||
#define INT_LEAST32_MAX INT32_MAX
|
#define INT_LEAST32_MAX INT32_MAX
|
||||||
#define INT_LEAST64_MIN INT64_MIN
|
#define INT_LEAST64_MIN INT64_MIN
|
||||||
#define INT_LEAST64_MAX INT64_MAX
|
#define INT_LEAST64_MAX INT64_MAX
|
||||||
#define UINT_LEAST8_MAX UINT8_MAX
|
#define UINT_LEAST8_MAX UINT8_MAX
|
||||||
#define UINT_LEAST16_MAX UINT16_MAX
|
#define UINT_LEAST16_MAX UINT16_MAX
|
||||||
#define UINT_LEAST32_MAX UINT32_MAX
|
#define UINT_LEAST32_MAX UINT32_MAX
|
||||||
#define UINT_LEAST64_MAX UINT64_MAX
|
#define UINT_LEAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
/* 7.18.2.3 Limits of fastest minimum-width integer types. */
|
/* 7.18.2.3 Limits of fastest minimum-width integer types. */
|
||||||
#define INT_FAST8_MIN INT8_MIN
|
#define INT_FAST8_MIN INT8_MIN
|
||||||
#define INT_FAST8_MAX INT8_MAX
|
#define INT_FAST8_MAX INT8_MAX
|
||||||
#define INT_FAST16_MIN INT16_MIN
|
#define INT_FAST16_MIN INT16_MIN
|
||||||
#define INT_FAST16_MAX INT16_MAX
|
#define INT_FAST16_MAX INT16_MAX
|
||||||
#define INT_FAST32_MIN INT32_MIN
|
#define INT_FAST32_MIN INT32_MIN
|
||||||
#define INT_FAST32_MAX INT32_MAX
|
#define INT_FAST32_MAX INT32_MAX
|
||||||
#define INT_FAST64_MIN INT64_MIN
|
#define INT_FAST64_MIN INT64_MIN
|
||||||
#define INT_FAST64_MAX INT64_MAX
|
#define INT_FAST64_MAX INT64_MAX
|
||||||
#define UINT_FAST8_MAX UINT8_MAX
|
#define UINT_FAST8_MAX UINT8_MAX
|
||||||
#define UINT_FAST16_MAX UINT16_MAX
|
#define UINT_FAST16_MAX UINT16_MAX
|
||||||
#define UINT_FAST32_MAX UINT32_MAX
|
#define UINT_FAST32_MAX UINT32_MAX
|
||||||
#define UINT_FAST64_MAX UINT64_MAX
|
#define UINT_FAST64_MAX UINT64_MAX
|
||||||
|
|
||||||
/* 7.18.2.4 Limits of integer types capable of holding object pointers. */
|
/* 7.18.2.4 Limits of integer types capable of holding object pointers. */
|
||||||
#ifdef _WIN64 /* [ */
|
#ifdef _WIN64 /* [ */
|
||||||
# define INTPTR_MIN INT64_MIN
|
# define INTPTR_MIN INT64_MIN
|
||||||
# define INTPTR_MAX INT64_MAX
|
# define INTPTR_MAX INT64_MAX
|
||||||
# define UINTPTR_MAX UINT64_MAX
|
# define UINTPTR_MAX UINT64_MAX
|
||||||
#else /* _WIN64 ][ */
|
#else /* _WIN64 ][ */
|
||||||
# define INTPTR_MIN INT32_MIN
|
# define INTPTR_MIN INT32_MIN
|
||||||
# define INTPTR_MAX INT32_MAX
|
# define INTPTR_MAX INT32_MAX
|
||||||
# define UINTPTR_MAX UINT32_MAX
|
# define UINTPTR_MAX UINT32_MAX
|
||||||
#endif /* _WIN64 ] */
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
/* 7.18.2.5 Limits of greatest-width integer types */
|
/* 7.18.2.5 Limits of greatest-width integer types */
|
||||||
#define INTMAX_MIN INT64_MIN
|
#define INTMAX_MIN INT64_MIN
|
||||||
#define INTMAX_MAX INT64_MAX
|
#define INTMAX_MAX INT64_MAX
|
||||||
#define UINTMAX_MAX UINT64_MAX
|
#define UINTMAX_MAX UINT64_MAX
|
||||||
|
|
||||||
/* 7.18.3 Limits of other integer types */
|
/* 7.18.3 Limits of other integer types */
|
||||||
|
|
||||||
#ifdef _WIN64 /* [ */
|
#ifdef _WIN64 /* [ */
|
||||||
# define PTRDIFF_MIN _I64_MIN
|
# define PTRDIFF_MIN _I64_MIN
|
||||||
# define PTRDIFF_MAX _I64_MAX
|
# define PTRDIFF_MAX _I64_MAX
|
||||||
#else /* _WIN64 ][ */
|
#else /* _WIN64 ][ */
|
||||||
# define PTRDIFF_MIN _I32_MIN
|
# define PTRDIFF_MIN _I32_MIN
|
||||||
# define PTRDIFF_MAX _I32_MAX
|
# define PTRDIFF_MAX _I32_MAX
|
||||||
#endif /* _WIN64 ] */
|
#endif /* _WIN64 ] */
|
||||||
|
|
||||||
#define SIG_ATOMIC_MIN INT_MIN
|
#define SIG_ATOMIC_MIN INT_MIN
|
||||||
#define SIG_ATOMIC_MAX INT_MAX
|
#define SIG_ATOMIC_MAX INT_MAX
|
||||||
|
|
||||||
#ifndef SIZE_MAX /* [ */
|
#ifndef SIZE_MAX /* [ */
|
||||||
# ifdef _WIN64 /* [ */
|
# ifdef _WIN64 /* [ */
|
||||||
# define SIZE_MAX _UI64_MAX
|
# define SIZE_MAX _UI64_MAX
|
||||||
# else /* _WIN64 ][ */
|
# else /* _WIN64 ][ */
|
||||||
# define SIZE_MAX _UI32_MAX
|
# define SIZE_MAX _UI32_MAX
|
||||||
# endif /* _WIN64 ] */
|
# endif /* _WIN64 ] */
|
||||||
#endif /* SIZE_MAX ] */
|
#endif /* SIZE_MAX ] */
|
||||||
|
|
||||||
/* WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> */
|
/* WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> */
|
||||||
#ifndef WCHAR_MIN /* [ */
|
#ifndef WCHAR_MIN /* [ */
|
||||||
# define WCHAR_MIN 0
|
# define WCHAR_MIN 0
|
||||||
#endif /* WCHAR_MIN ] */
|
#endif /* WCHAR_MIN ] */
|
||||||
#ifndef WCHAR_MAX // [
|
#ifndef WCHAR_MAX // [
|
||||||
# define WCHAR_MAX _UI16_MAX
|
# define WCHAR_MAX _UI16_MAX
|
||||||
#endif /* WCHAR_MAX ] */
|
#endif /* WCHAR_MAX ] */
|
||||||
|
|
||||||
#define WINT_MIN 0
|
#define WINT_MIN 0
|
||||||
#define WINT_MAX _UI16_MAX
|
#define WINT_MAX _UI16_MAX
|
||||||
|
|
||||||
#endif /* __STDC_LIMIT_MACROS ] */
|
#endif /* __STDC_LIMIT_MACROS ] */
|
||||||
|
|
||||||
/* 7.18.4 Limits of other integer types */
|
/* 7.18.4 Limits of other integer types */
|
||||||
|
|
||||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||||
/* [ See footnote 224 at page 260 */
|
/* [ See footnote 224 at page 260 */
|
||||||
|
|
||||||
/* 7.18.4.1 Macros for minimum-width integer constants */
|
/* 7.18.4.1 Macros for minimum-width integer constants */
|
||||||
|
|
||||||
#define INT8_C(val) val##i8
|
#define INT8_C(val) val##i8
|
||||||
#define INT16_C(val) val##i16
|
#define INT16_C(val) val##i16
|
||||||
#define INT32_C(val) val##i32
|
#define INT32_C(val) val##i32
|
||||||
#define INT64_C(val) val##i64
|
#define INT64_C(val) val##i64
|
||||||
|
|
||||||
#define UINT8_C(val) val##ui8
|
#define UINT8_C(val) val##ui8
|
||||||
#define UINT16_C(val) val##ui16
|
#define UINT16_C(val) val##ui16
|
||||||
#define UINT32_C(val) val##ui32
|
#define UINT32_C(val) val##ui32
|
||||||
#define UINT64_C(val) val##ui64
|
#define UINT64_C(val) val##ui64
|
||||||
|
|
||||||
/* 7.18.4.2 Macros for greatest-width integer constants */
|
/* 7.18.4.2 Macros for greatest-width integer constants */
|
||||||
#define INTMAX_C INT64_C
|
#define INTMAX_C INT64_C
|
||||||
#define UINTMAX_C UINT64_C
|
#define UINTMAX_C UINT64_C
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* __STDC_CONSTANT_MACROS ] */
|
/* __STDC_CONSTANT_MACROS ] */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
/* Sanity for everything else. */
|
/* Sanity for everything else. */
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,62 +1,62 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (posix_string.h).
|
* The following license statement only applies to this file (posix_string.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
#ifndef __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
||||||
#define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
#define __LIBRETRO_SDK_COMPAT_POSIX_STRING_H
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#undef strtok_r
|
#undef strtok_r
|
||||||
#define strtok_r(str, delim, saveptr) retro_strtok_r__(str, delim, saveptr)
|
#define strtok_r(str, delim, saveptr) retro_strtok_r__(str, delim, saveptr)
|
||||||
|
|
||||||
char *strtok_r(char *str, const char *delim, char **saveptr);
|
char *strtok_r(char *str, const char *delim, char **saveptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#undef strcasecmp
|
#undef strcasecmp
|
||||||
#undef strdup
|
#undef strdup
|
||||||
#define strcasecmp(a, b) retro_strcasecmp__(a, b)
|
#define strcasecmp(a, b) retro_strcasecmp__(a, b)
|
||||||
#define strdup(orig) retro_strdup__(orig)
|
#define strdup(orig) retro_strdup__(orig)
|
||||||
int strcasecmp(const char *a, const char *b);
|
int strcasecmp(const char *a, const char *b);
|
||||||
char *strdup(const char *orig);
|
char *strdup(const char *orig);
|
||||||
|
|
||||||
#if _MSC_VER < 1200
|
#if _MSC_VER < 1200
|
||||||
#undef isblank
|
#undef isblank
|
||||||
#define isblank(c) retro_isblank__(c)
|
#define isblank(c) retro_isblank__(c)
|
||||||
int isblank(int c);
|
int isblank(int c);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (strcasestr.h). * ---------------------------------------------------------------------------------------
|
* The following license statement only applies to this file (strcasestr.h). * ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
#ifndef __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
||||||
#define __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
#define __LIBRETRO_SDK_COMPAT_STRCASESTR_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
#if defined(RARCH_INTERNAL) && defined(HAVE_CONFIG_H)
|
||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRCASESTR
|
#ifndef HAVE_STRCASESTR
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Avoid possible naming collisions during link
|
/* Avoid possible naming collisions during link
|
||||||
* since we prefer to use the actual name. */
|
* since we prefer to use the actual name. */
|
||||||
#define strcasestr(haystack, needle) strcasestr_retro__(haystack, needle)
|
#define strcasestr(haystack, needle) strcasestr_retro__(haystack, needle)
|
||||||
|
|
||||||
char *strcasestr(const char *haystack, const char *needle);
|
char *strcasestr(const char *haystack, const char *needle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (strl.h).
|
* The following license statement only applies to this file (strl.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_COMPAT_STRL_H
|
#ifndef __LIBRETRO_SDK_COMPAT_STRL_H
|
||||||
#define __LIBRETRO_SDK_COMPAT_STRL_H
|
#define __LIBRETRO_SDK_COMPAT_STRL_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "../../../config.h"
|
#include "../../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MACH__
|
#ifdef __MACH__
|
||||||
#ifndef HAVE_STRL
|
#ifndef HAVE_STRL
|
||||||
#define HAVE_STRL
|
#define HAVE_STRL
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_STRL
|
#ifndef HAVE_STRL
|
||||||
/* Avoid possible naming collisions during link since
|
/* Avoid possible naming collisions during link since
|
||||||
* we prefer to use the actual name. */
|
* we prefer to use the actual name. */
|
||||||
#define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size)
|
#define strlcpy(dst, src, size) strlcpy_retro__(dst, src, size)
|
||||||
|
|
||||||
#define strlcat(dst, src, size) strlcat_retro__(dst, src, size)
|
#define strlcat(dst, src, size) strlcat_retro__(dst, src, size)
|
||||||
|
|
||||||
size_t strlcpy(char *dest, const char *source, size_t size);
|
size_t strlcpy(char *dest, const char *source, size_t size);
|
||||||
size_t strlcat(char *dest, const char *source, size_t size);
|
size_t strlcat(char *dest, const char *source, size_t size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,265 +1,265 @@
|
||||||
#ifndef _COMPAT_ZUTIL_H
|
#ifndef _COMPAT_ZUTIL_H
|
||||||
#define _COMPAT_ZUTIL_H
|
#define _COMPAT_ZUTIL_H
|
||||||
|
|
||||||
#ifdef WANT_ZLIB
|
#ifdef WANT_ZLIB
|
||||||
|
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
* Copyright (C) 1995-2013 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* WARNING: this file should *not* be used by applications. It is
|
/* WARNING: this file should *not* be used by applications. It is
|
||||||
part of the implementation of the compression library and is
|
part of the implementation of the compression library and is
|
||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#ifndef ZUTIL_H
|
#ifndef ZUTIL_H
|
||||||
#define ZUTIL_H
|
#define ZUTIL_H
|
||||||
|
|
||||||
#ifdef HAVE_HIDDEN
|
#ifdef HAVE_HIDDEN
|
||||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
#else
|
#else
|
||||||
# define ZLIB_INTERNAL
|
# define ZLIB_INTERNAL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <compat/zlib.h>
|
#include <compat/zlib.h>
|
||||||
|
|
||||||
#if defined(STDC) && !defined(Z_SOLO)
|
#if defined(STDC) && !defined(Z_SOLO)
|
||||||
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# endif
|
# endif
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Z_SOLO
|
#ifdef Z_SOLO
|
||||||
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
#endif
|
#endif
|
||||||
/* compile with -Dlocal if your debugger can't find static symbols */
|
/* compile with -Dlocal if your debugger can't find static symbols */
|
||||||
|
|
||||||
typedef unsigned char uch;
|
typedef unsigned char uch;
|
||||||
typedef uch FAR uchf;
|
typedef uch FAR uchf;
|
||||||
typedef unsigned short ush;
|
typedef unsigned short ush;
|
||||||
typedef ush FAR ushf;
|
typedef ush FAR ushf;
|
||||||
typedef unsigned long ulg;
|
typedef unsigned long ulg;
|
||||||
|
|
||||||
extern char z_errmsg[10][21]; /* indexed by 2-zlib_error */
|
extern char z_errmsg[10][21]; /* indexed by 2-zlib_error */
|
||||||
/* (array size given to avoid silly warnings with Visual C++) */
|
/* (array size given to avoid silly warnings with Visual C++) */
|
||||||
/* (array entry size given to avoid silly string cast warnings) */
|
/* (array entry size given to avoid silly string cast warnings) */
|
||||||
|
|
||||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||||
|
|
||||||
#define ERR_RETURN(strm,err) \
|
#define ERR_RETURN(strm,err) \
|
||||||
return (strm->msg = ERR_MSG(err), (err))
|
return (strm->msg = ERR_MSG(err), (err))
|
||||||
/* To be used only when the state is known to be valid */
|
/* To be used only when the state is known to be valid */
|
||||||
|
|
||||||
/* common constants */
|
/* common constants */
|
||||||
|
|
||||||
#ifndef DEF_WBITS
|
#ifndef DEF_WBITS
|
||||||
# define DEF_WBITS MAX_WBITS
|
# define DEF_WBITS MAX_WBITS
|
||||||
#endif
|
#endif
|
||||||
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
/* default windowBits for decompression. MAX_WBITS is for compression only */
|
||||||
|
|
||||||
#if MAX_MEM_LEVEL >= 8
|
#if MAX_MEM_LEVEL >= 8
|
||||||
# define DEF_MEM_LEVEL 8
|
# define DEF_MEM_LEVEL 8
|
||||||
#else
|
#else
|
||||||
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
# define DEF_MEM_LEVEL MAX_MEM_LEVEL
|
||||||
#endif
|
#endif
|
||||||
/* default memLevel */
|
/* default memLevel */
|
||||||
|
|
||||||
#define STORED_BLOCK 0
|
#define STORED_BLOCK 0
|
||||||
#define STATIC_TREES 1
|
#define STATIC_TREES 1
|
||||||
#define DYN_TREES 2
|
#define DYN_TREES 2
|
||||||
/* The three kinds of block type */
|
/* The three kinds of block type */
|
||||||
|
|
||||||
#define MIN_MATCH 3
|
#define MIN_MATCH 3
|
||||||
#define MAX_MATCH 258
|
#define MAX_MATCH 258
|
||||||
/* The minimum and maximum match lengths */
|
/* The minimum and maximum match lengths */
|
||||||
|
|
||||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
||||||
|
|
||||||
/* target dependencies */
|
/* target dependencies */
|
||||||
|
|
||||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||||
# define OS_CODE 0x00
|
# define OS_CODE 0x00
|
||||||
# ifndef Z_SOLO
|
# ifndef Z_SOLO
|
||||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||||
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||||
/* Allow compilation with ANSI keywords only enabled */
|
/* Allow compilation with ANSI keywords only enabled */
|
||||||
void _Cdecl farfree( void *block );
|
void _Cdecl farfree( void *block );
|
||||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||||
# else
|
# else
|
||||||
# include <alloc.h>
|
# include <alloc.h>
|
||||||
# endif
|
# endif
|
||||||
# else /* MSC or DJGPP */
|
# else /* MSC or DJGPP */
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef AMIGA
|
#ifdef AMIGA
|
||||||
# define OS_CODE 0x01
|
# define OS_CODE 0x01
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(VAXC) || defined(VMS)
|
#if defined(VAXC) || defined(VMS)
|
||||||
# define OS_CODE 0x02
|
# define OS_CODE 0x02
|
||||||
# define F_OPEN(name, mode) \
|
# define F_OPEN(name, mode) \
|
||||||
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ATARI) || defined(atarist)
|
#if defined(ATARI) || defined(atarist)
|
||||||
# define OS_CODE 0x05
|
# define OS_CODE 0x05
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef OS2
|
#ifdef OS2
|
||||||
# define OS_CODE 0x06
|
# define OS_CODE 0x06
|
||||||
# if defined(M_I86) && !defined(Z_SOLO)
|
# if defined(M_I86) && !defined(Z_SOLO)
|
||||||
# include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
#if defined(MACOS) || defined(TARGET_OS_MAC)
|
||||||
# define OS_CODE 0x07
|
# define OS_CODE 0x07
|
||||||
# ifndef Z_SOLO
|
# ifndef Z_SOLO
|
||||||
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
|
||||||
# include <unix.h> /* for fdopen */
|
# include <unix.h> /* for fdopen */
|
||||||
# else
|
# else
|
||||||
# ifndef fdopen
|
# ifndef fdopen
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TOPS20
|
#ifdef TOPS20
|
||||||
# define OS_CODE 0x0a
|
# define OS_CODE 0x0a
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
|
||||||
# define OS_CODE 0x0b
|
# define OS_CODE 0x0b
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __50SERIES /* Prime/PRIMOS */
|
#ifdef __50SERIES /* Prime/PRIMOS */
|
||||||
# define OS_CODE 0x0f
|
# define OS_CODE 0x0f
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_BEOS_) || defined(RISCOS)
|
#if defined(_BEOS_) || defined(RISCOS)
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||||
# if defined(_WIN32_WCE)
|
# if defined(_WIN32_WCE)
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
# ifndef _PTRDIFF_T_DEFINED
|
||||||
typedef int ptrdiff_t;
|
typedef int ptrdiff_t;
|
||||||
# define _PTRDIFF_T_DEFINED
|
# define _PTRDIFF_T_DEFINED
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
# define fdopen(fd,type) _fdopen(fd,type)
|
# define fdopen(fd,type) _fdopen(fd,type)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__BORLANDC__) && !defined(MSDOS)
|
#if defined(__BORLANDC__) && !defined(MSDOS)
|
||||||
#pragma warn -8004
|
#pragma warn -8004
|
||||||
#pragma warn -8008
|
#pragma warn -8008
|
||||||
#pragma warn -8066
|
#pragma warn -8066
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* provide prototypes for these when building zlib without LFS */
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
#if !defined(_WIN32) && \
|
#if !defined(_WIN32) && \
|
||||||
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
|
||||||
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
|
||||||
#ifndef OS_CODE
|
#ifndef OS_CODE
|
||||||
# define OS_CODE 0x03 /* assume Unix */
|
# define OS_CODE 0x03 /* assume Unix */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef F_OPEN
|
#ifndef F_OPEN
|
||||||
# define F_OPEN(name, mode) fopen((name), (mode))
|
# define F_OPEN(name, mode) fopen((name), (mode))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
#if defined(pyr) || defined(Z_SOLO)
|
#if defined(pyr) || defined(Z_SOLO)
|
||||||
# define NO_MEMCPY
|
# define NO_MEMCPY
|
||||||
#endif
|
#endif
|
||||||
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
|
||||||
/* Use our own functions for small and medium model with MSC <= 5.0.
|
/* Use our own functions for small and medium model with MSC <= 5.0.
|
||||||
* You may have to use the same strategy for Borland C (untested).
|
* You may have to use the same strategy for Borland C (untested).
|
||||||
* The __SC__ check is for Symantec.
|
* The __SC__ check is for Symantec.
|
||||||
*/
|
*/
|
||||||
# define NO_MEMCPY
|
# define NO_MEMCPY
|
||||||
#endif
|
#endif
|
||||||
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
|
||||||
# define HAVE_MEMCPY
|
# define HAVE_MEMCPY
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_MEMCPY
|
#ifdef HAVE_MEMCPY
|
||||||
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
|
||||||
# define zmemcpy _fmemcpy
|
# define zmemcpy _fmemcpy
|
||||||
# define zmemcmp _fmemcmp
|
# define zmemcmp _fmemcmp
|
||||||
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
# define zmemzero(dest, len) _fmemset(dest, 0, len)
|
||||||
# else
|
# else
|
||||||
# define zmemcpy memcpy
|
# define zmemcpy memcpy
|
||||||
# define zmemcmp memcmp
|
# define zmemcmp memcmp
|
||||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||||
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||||
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Diagnostic functions */
|
/* Diagnostic functions */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
extern int ZLIB_INTERNAL z_verbose;
|
extern int ZLIB_INTERNAL z_verbose;
|
||||||
extern void ZLIB_INTERNAL z_error OF((char *m));
|
extern void ZLIB_INTERNAL z_error OF((char *m));
|
||||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||||
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
|
||||||
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
|
||||||
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
|
||||||
#else
|
#else
|
||||||
# define Assert(cond,msg)
|
# define Assert(cond,msg)
|
||||||
# define Trace(x)
|
# define Trace(x)
|
||||||
# define Tracev(x)
|
# define Tracev(x)
|
||||||
# define Tracevv(x)
|
# define Tracevv(x)
|
||||||
# define Tracec(c,x)
|
# define Tracec(c,x)
|
||||||
# define Tracecv(c,x)
|
# define Tracecv(c,x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Z_SOLO
|
#ifndef Z_SOLO
|
||||||
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
||||||
unsigned size));
|
unsigned size));
|
||||||
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
#define ZALLOC(strm, items, size) \
|
||||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||||
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
|
||||||
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
|
||||||
|
|
||||||
/* Reverse the bytes in a 32-bit value */
|
/* Reverse the bytes in a 32-bit value */
|
||||||
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
|
||||||
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
|
||||||
|
|
||||||
#endif /* ZUTIL_H */
|
#endif /* ZUTIL_H */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#include <zutil.h>
|
#include <zutil.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,74 +1,74 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (dylib.h).
|
* The following license statement only applies to this file (dylib.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __DYLIB_H
|
#ifndef __DYLIB_H
|
||||||
#define __DYLIB_H
|
#define __DYLIB_H
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
|
||||||
#define NEED_DYNAMIC
|
#define NEED_DYNAMIC
|
||||||
#else
|
#else
|
||||||
#undef NEED_DYNAMIC
|
#undef NEED_DYNAMIC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void *dylib_t;
|
typedef void *dylib_t;
|
||||||
typedef void (*function_t)(void);
|
typedef void (*function_t)(void);
|
||||||
|
|
||||||
#ifdef NEED_DYNAMIC
|
#ifdef NEED_DYNAMIC
|
||||||
/**
|
/**
|
||||||
* dylib_load:
|
* dylib_load:
|
||||||
* @path : Path to libretro core library.
|
* @path : Path to libretro core library.
|
||||||
*
|
*
|
||||||
* Platform independent dylib loading.
|
* Platform independent dylib loading.
|
||||||
*
|
*
|
||||||
* Returns: library handle on success, otherwise NULL.
|
* Returns: library handle on success, otherwise NULL.
|
||||||
**/
|
**/
|
||||||
dylib_t dylib_load(const char *path);
|
dylib_t dylib_load(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dylib_close:
|
* dylib_close:
|
||||||
* @lib : Library handle.
|
* @lib : Library handle.
|
||||||
*
|
*
|
||||||
* Frees library handle.
|
* Frees library handle.
|
||||||
**/
|
**/
|
||||||
void dylib_close(dylib_t lib);
|
void dylib_close(dylib_t lib);
|
||||||
|
|
||||||
char *dylib_error(void);
|
char *dylib_error(void);
|
||||||
|
|
||||||
function_t dylib_proc(dylib_t lib, const char *proc);
|
function_t dylib_proc(dylib_t lib, const char *proc);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,43 +1,43 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (utf.h).
|
* The following license statement only applies to this file (utf.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_ENCODINGS_UTF_H
|
#ifndef _LIBRETRO_ENCODINGS_UTF_H
|
||||||
#define _LIBRETRO_ENCODINGS_UTF_H
|
#define _LIBRETRO_ENCODINGS_UTF_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
size_t utf8_conv_utf32(uint32_t *out, size_t out_chars,
|
||||||
const char *in, size_t in_size);
|
const char *in, size_t in_size);
|
||||||
|
|
||||||
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
bool utf16_conv_utf8(uint8_t *out, size_t *out_chars,
|
||||||
const uint16_t *in, size_t in_size);
|
const uint16_t *in, size_t in_size);
|
||||||
|
|
||||||
size_t utf8len(const char *string);
|
size_t utf8len(const char *string);
|
||||||
|
|
||||||
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars);
|
size_t utf8cpy(char *d, size_t d_len, const char *s, size_t chars);
|
||||||
|
|
||||||
const char *utf8skip(const char *str, size_t chars);
|
const char *utf8skip(const char *str, size_t chars);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,138 +1,138 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (file_archive.h).
|
* The following license statement only applies to this file (archive_file.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef FILE_ARCHIVE_H__
|
#ifndef LIBRETRO_SDK_ARCHIVE_FILE_H__
|
||||||
#define FILE_ARCHIVE_H__
|
#define LIBRETRO_SDK_ARCHIVE_FILE_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
enum file_archive_transfer_type
|
enum file_archive_transfer_type
|
||||||
{
|
{
|
||||||
ZLIB_TRANSFER_NONE = 0,
|
ZLIB_TRANSFER_NONE = 0,
|
||||||
ZLIB_TRANSFER_INIT,
|
ZLIB_TRANSFER_INIT,
|
||||||
ZLIB_TRANSFER_ITERATE,
|
ZLIB_TRANSFER_ITERATE,
|
||||||
ZLIB_TRANSFER_DEINIT,
|
ZLIB_TRANSFER_DEINIT,
|
||||||
ZLIB_TRANSFER_DEINIT_ERROR
|
ZLIB_TRANSFER_DEINIT_ERROR
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct file_archive_handle
|
typedef struct file_archive_handle
|
||||||
{
|
{
|
||||||
void *stream;
|
void *stream;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
uint32_t real_checksum;
|
uint32_t real_checksum;
|
||||||
const struct file_archive_file_backend *backend;
|
const struct file_archive_file_backend *backend;
|
||||||
} file_archive_file_handle_t;
|
} file_archive_file_handle_t;
|
||||||
|
|
||||||
struct file_archive_file_backend
|
struct file_archive_file_backend
|
||||||
{
|
{
|
||||||
void *(*stream_new)(void);
|
void *(*stream_new)(void);
|
||||||
void (*stream_free)(void *);
|
void (*stream_free)(void *);
|
||||||
void (*stream_set)(void *, uint32_t, uint32_t,
|
void (*stream_set)(void *, uint32_t, uint32_t,
|
||||||
const uint8_t *, uint8_t *);
|
const uint8_t *, uint8_t *);
|
||||||
uint32_t (*stream_get_avail_in)(void*);
|
uint32_t (*stream_get_avail_in)(void*);
|
||||||
uint32_t (*stream_get_avail_out)(void*);
|
uint32_t (*stream_get_avail_out)(void*);
|
||||||
uint64_t (*stream_get_total_out)(void*);
|
uint64_t (*stream_get_total_out)(void*);
|
||||||
void (*stream_decrement_total_out)(void *, unsigned);
|
void (*stream_decrement_total_out)(void *, unsigned);
|
||||||
bool (*stream_decompress_init)(void *);
|
bool (*stream_decompress_init)(void *);
|
||||||
bool (*stream_decompress_data_to_file_init)(
|
bool (*stream_decompress_data_to_file_init)(
|
||||||
file_archive_file_handle_t *, const uint8_t *, uint32_t, uint32_t);
|
file_archive_file_handle_t *, const uint8_t *, uint32_t, uint32_t);
|
||||||
int (*stream_decompress_data_to_file_iterate)(void *);
|
int (*stream_decompress_data_to_file_iterate)(void *);
|
||||||
void (*stream_compress_init)(void *, int);
|
void (*stream_compress_init)(void *, int);
|
||||||
void (*stream_compress_free)(void *);
|
void (*stream_compress_free)(void *);
|
||||||
int (*stream_compress_data_to_file)(void *);
|
int (*stream_compress_data_to_file)(void *);
|
||||||
uint32_t (*stream_crc_calculate)(uint32_t, const uint8_t *, size_t);
|
uint32_t (*stream_crc_calculate)(uint32_t, const uint8_t *, size_t);
|
||||||
const char *ident;
|
const char *ident;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct file_archive_transfer
|
typedef struct file_archive_transfer
|
||||||
{
|
{
|
||||||
void *handle;
|
void *handle;
|
||||||
const uint8_t *footer;
|
const uint8_t *footer;
|
||||||
const uint8_t *directory;
|
const uint8_t *directory;
|
||||||
const uint8_t *data;
|
const uint8_t *data;
|
||||||
int32_t zip_size;
|
int32_t zip_size;
|
||||||
enum file_archive_transfer_type type;
|
enum file_archive_transfer_type type;
|
||||||
const struct file_archive_file_backend *backend;
|
const struct file_archive_file_backend *backend;
|
||||||
} file_archive_transfer_t;
|
} file_archive_transfer_t;
|
||||||
|
|
||||||
|
|
||||||
/* Returns true when parsing should continue. False to stop. */
|
/* Returns true when parsing should continue. False to stop. */
|
||||||
typedef int (*file_archive_file_cb)(const char *name, const char *valid_exts,
|
typedef int (*file_archive_file_cb)(const char *name, const char *valid_exts,
|
||||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||||
uint32_t crc32, void *userdata);
|
uint32_t crc32, void *userdata);
|
||||||
|
|
||||||
int file_archive_parse_file_iterate(
|
int file_archive_parse_file_iterate(
|
||||||
file_archive_transfer_t *state,
|
file_archive_transfer_t *state,
|
||||||
bool *returnerr,
|
bool *returnerr,
|
||||||
const char *file,
|
const char *file,
|
||||||
const char *valid_exts,
|
const char *valid_exts,
|
||||||
file_archive_file_cb file_cb,
|
file_archive_file_cb file_cb,
|
||||||
void *userdata);
|
void *userdata);
|
||||||
|
|
||||||
void file_archive_parse_file_iterate_stop(file_archive_transfer_t *state);
|
void file_archive_parse_file_iterate_stop(file_archive_transfer_t *state);
|
||||||
|
|
||||||
int file_archive_parse_file_progress(file_archive_transfer_t *state);
|
int file_archive_parse_file_progress(file_archive_transfer_t *state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file_archive_extract_first_content_file:
|
* file_archive_extract_first_content_file:
|
||||||
* @zip_path : filename path to ZIP archive.
|
* @zip_path : filename path to ZIP archive.
|
||||||
* @zip_path_size : size of ZIP archive.
|
* @zip_path_size : size of ZIP archive.
|
||||||
* @valid_exts : valid extensions for a content file.
|
* @valid_exts : valid extensions for a content file.
|
||||||
* @extraction_directory : the directory to extract temporary
|
* @extraction_directory : the directory to extract temporary
|
||||||
* unzipped content to.
|
* unzipped content to.
|
||||||
*
|
*
|
||||||
* Extract first content file from archive.
|
* Extract first content file from archive.
|
||||||
*
|
*
|
||||||
* Returns : true (1) on success, otherwise false (0).
|
* Returns : true (1) on success, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool file_archive_extract_first_content_file(char *zip_path, size_t zip_path_size,
|
bool file_archive_extract_first_content_file(char *zip_path, size_t zip_path_size,
|
||||||
const char *valid_exts, const char *extraction_dir,
|
const char *valid_exts, const char *extraction_dir,
|
||||||
char *out_path, size_t len);
|
char *out_path, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file_archive_get_file_list:
|
* file_archive_get_file_list:
|
||||||
* @path : filename path of archive
|
* @path : filename path of archive
|
||||||
* @valid_exts : Valid extensions of archive to be parsed.
|
* @valid_exts : Valid extensions of archive to be parsed.
|
||||||
* If NULL, allow all.
|
* If NULL, allow all.
|
||||||
*
|
*
|
||||||
* Returns: string listing of files from archive on success, otherwise NULL.
|
* Returns: string listing of files from archive on success, otherwise NULL.
|
||||||
**/
|
**/
|
||||||
struct string_list *file_archive_get_file_list(const char *path, const char *valid_exts);
|
struct string_list *file_archive_get_file_list(const char *path, const char *valid_exts);
|
||||||
|
|
||||||
bool file_archive_perform_mode(const char *name, const char *valid_exts,
|
bool file_archive_perform_mode(const char *name, const char *valid_exts,
|
||||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||||
uint32_t crc32, void *userdata);
|
uint32_t crc32, void *userdata);
|
||||||
|
|
||||||
struct string_list *compressed_file_list_new(const char *filename,
|
struct string_list *compressed_file_list_new(const char *filename,
|
||||||
const char* ext);
|
const char* ext);
|
||||||
|
|
||||||
void file_archive_deflate_init(void *data, int level);
|
void file_archive_deflate_init(void *data, int level);
|
||||||
|
|
||||||
const struct file_archive_file_backend *file_archive_get_default_file_backend(void);
|
const struct file_archive_file_backend *file_archive_get_default_file_backend(void);
|
||||||
|
|
||||||
extern const struct file_archive_file_backend zlib_backend;
|
extern const struct file_archive_file_backend zlib_backend;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,166 +1,166 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (config_file.h).
|
* The following license statement only applies to this file (config_file.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_CONFIG_FILE_H
|
#ifndef __LIBRETRO_SDK_CONFIG_FILE_H
|
||||||
#define __LIBRETRO_SDK_CONFIG_FILE_H
|
#define __LIBRETRO_SDK_CONFIG_FILE_H
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#define CONFIG_GET_BOOL_BASE(conf, base, var, key) do { \
|
#define CONFIG_GET_BOOL_BASE(conf, base, var, key) do { \
|
||||||
bool tmp = false; \
|
bool tmp = false; \
|
||||||
if (config_get_bool(conf, key, &tmp)) \
|
if (config_get_bool(conf, key, &tmp)) \
|
||||||
base->var = tmp; \
|
base->var = tmp; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define CONFIG_GET_INT_BASE(conf, base, var, key) do { \
|
#define CONFIG_GET_INT_BASE(conf, base, var, key) do { \
|
||||||
int tmp = 0; \
|
int tmp = 0; \
|
||||||
if (config_get_int(conf, key, &tmp)) \
|
if (config_get_int(conf, key, &tmp)) \
|
||||||
base->var = tmp; \
|
base->var = tmp; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
#define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \
|
#define CONFIG_GET_FLOAT_BASE(conf, base, var, key) do { \
|
||||||
float tmp = 0.0f; \
|
float tmp = 0.0f; \
|
||||||
if (config_get_float(conf, key, &tmp)) \
|
if (config_get_float(conf, key, &tmp)) \
|
||||||
base->var = tmp; \
|
base->var = tmp; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
typedef struct config_file config_file_t;
|
typedef struct config_file config_file_t;
|
||||||
|
|
||||||
/* Config file format
|
/* Config file format
|
||||||
* - # are treated as comments. Rest of the line is ignored.
|
* - # are treated as comments. Rest of the line is ignored.
|
||||||
* - Format is: key = value. There can be as many spaces as you like in-between.
|
* - Format is: key = value. There can be as many spaces as you like in-between.
|
||||||
* - Value can be wrapped inside "" for multiword strings. (foo = "hai u")
|
* - Value can be wrapped inside "" for multiword strings. (foo = "hai u")
|
||||||
* - #include includes a config file in-place.
|
* - #include includes a config file in-place.
|
||||||
*
|
*
|
||||||
* Path is relative to where config file was loaded unless an absolute path is chosen.
|
* Path is relative to where config file was loaded unless an absolute path is chosen.
|
||||||
* Key/value pairs from an #include are read-only, and cannot be modified.
|
* Key/value pairs from an #include are read-only, and cannot be modified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Loads a config file. Returns NULL if file doesn't exist.
|
/* Loads a config file. Returns NULL if file doesn't exist.
|
||||||
* NULL path will create an empty config file. */
|
* NULL path will create an empty config file. */
|
||||||
config_file_t *config_file_new(const char *path);
|
config_file_t *config_file_new(const char *path);
|
||||||
|
|
||||||
/* Load a config file from a string. */
|
/* Load a config file from a string. */
|
||||||
config_file_t *config_file_new_from_string(const char *from_string);
|
config_file_t *config_file_new_from_string(const char *from_string);
|
||||||
|
|
||||||
/* Frees config file. */
|
/* Frees config file. */
|
||||||
void config_file_free(config_file_t *conf);
|
void config_file_free(config_file_t *conf);
|
||||||
|
|
||||||
/* Loads a new config, and appends its data to conf.
|
/* Loads a new config, and appends its data to conf.
|
||||||
* The key-value pairs of the new config file takes priority over the old. */
|
* The key-value pairs of the new config file takes priority over the old. */
|
||||||
bool config_append_file(config_file_t *conf, const char *path);
|
bool config_append_file(config_file_t *conf, const char *path);
|
||||||
|
|
||||||
/* All extract functions return true when value is valid and exists.
|
/* All extract functions return true when value is valid and exists.
|
||||||
* Returns false otherwise. */
|
* Returns false otherwise. */
|
||||||
|
|
||||||
bool config_entry_exists(config_file_t *conf, const char *entry);
|
bool config_entry_exists(config_file_t *conf, const char *entry);
|
||||||
|
|
||||||
struct config_entry_list;
|
struct config_entry_list;
|
||||||
struct config_file_entry
|
struct config_file_entry
|
||||||
{
|
{
|
||||||
const char *key;
|
const char *key;
|
||||||
const char *value;
|
const char *value;
|
||||||
/* Used intentionally. Opaque here. */
|
/* Used intentionally. Opaque here. */
|
||||||
const struct config_entry_list *next;
|
const struct config_entry_list *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool config_get_entry_list_head(config_file_t *conf, struct config_file_entry *entry);
|
bool config_get_entry_list_head(config_file_t *conf, struct config_file_entry *entry);
|
||||||
bool config_get_entry_list_next(struct config_file_entry *entry);
|
bool config_get_entry_list_next(struct config_file_entry *entry);
|
||||||
|
|
||||||
/* Extracts a double from config file. */
|
/* Extracts a double from config file. */
|
||||||
bool config_get_double(config_file_t *conf, const char *entry, double *in);
|
bool config_get_double(config_file_t *conf, const char *entry, double *in);
|
||||||
|
|
||||||
/* Extracts a float from config file. */
|
/* Extracts a float from config file. */
|
||||||
bool config_get_float(config_file_t *conf, const char *entry, float *in);
|
bool config_get_float(config_file_t *conf, const char *entry, float *in);
|
||||||
|
|
||||||
/* Extracts an int from config file. */
|
/* Extracts an int from config file. */
|
||||||
bool config_get_int(config_file_t *conf, const char *entry, int *in);
|
bool config_get_int(config_file_t *conf, const char *entry, int *in);
|
||||||
|
|
||||||
/* Extracts an uint from config file. */
|
/* Extracts an uint from config file. */
|
||||||
bool config_get_uint(config_file_t *conf, const char *entry, unsigned *in);
|
bool config_get_uint(config_file_t *conf, const char *entry, unsigned *in);
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
#if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
||||||
/* Extracts an uint64 from config file. */
|
/* Extracts an uint64 from config file. */
|
||||||
bool config_get_uint64(config_file_t *conf, const char *entry, uint64_t *in);
|
bool config_get_uint64(config_file_t *conf, const char *entry, uint64_t *in);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Extracts an unsigned int from config file treating input as hex. */
|
/* Extracts an unsigned int from config file treating input as hex. */
|
||||||
bool config_get_hex(config_file_t *conf, const char *entry, unsigned *in);
|
bool config_get_hex(config_file_t *conf, const char *entry, unsigned *in);
|
||||||
|
|
||||||
/* Extracts a single char. If value consists of several chars,
|
/* Extracts a single char. If value consists of several chars,
|
||||||
* this is an error. */
|
* this is an error. */
|
||||||
bool config_get_char(config_file_t *conf, const char *entry, char *in);
|
bool config_get_char(config_file_t *conf, const char *entry, char *in);
|
||||||
|
|
||||||
/* Extracts an allocated string in *in. This must be free()-d if
|
/* Extracts an allocated string in *in. This must be free()-d if
|
||||||
* this function succeeds. */
|
* this function succeeds. */
|
||||||
bool config_get_string(config_file_t *conf, const char *entry, char **in);
|
bool config_get_string(config_file_t *conf, const char *entry, char **in);
|
||||||
|
|
||||||
/* Extracts a string to a preallocated buffer. Avoid memory allocation. */
|
/* Extracts a string to a preallocated buffer. Avoid memory allocation. */
|
||||||
bool config_get_array(config_file_t *conf, const char *entry, char *s, size_t len);
|
bool config_get_array(config_file_t *conf, const char *entry, char *s, size_t len);
|
||||||
|
|
||||||
/* Extracts a string to a preallocated buffer. Avoid memory allocation.
|
/* Extracts a string to a preallocated buffer. Avoid memory allocation.
|
||||||
* Recognized magic like ~/. Similar to config_get_array() otherwise. */
|
* Recognized magic like ~/. Similar to config_get_array() otherwise. */
|
||||||
bool config_get_path(config_file_t *conf, const char *entry, char *s, size_t len);
|
bool config_get_path(config_file_t *conf, const char *entry, char *s, size_t len);
|
||||||
|
|
||||||
/* Extracts a string to a preallocated buffer. Avoid memory allocation. */
|
/* Extracts a string to a preallocated buffer. Avoid memory allocation. */
|
||||||
bool config_get_config_path(config_file_t *conf, char *s, size_t len);
|
bool config_get_config_path(config_file_t *conf, char *s, size_t len);
|
||||||
|
|
||||||
/* Extracts a boolean from config.
|
/* Extracts a boolean from config.
|
||||||
* Valid boolean true are "true" and "1". Valid false are "false" and "0".
|
* Valid boolean true are "true" and "1". Valid false are "false" and "0".
|
||||||
* Other values will be treated as an error. */
|
* Other values will be treated as an error. */
|
||||||
bool config_get_bool(config_file_t *conf, const char *entry, bool *in);
|
bool config_get_bool(config_file_t *conf, const char *entry, bool *in);
|
||||||
|
|
||||||
/* Setters. Similar to the getters.
|
/* Setters. Similar to the getters.
|
||||||
* Will not write to entry if the entry was obtained from an #include. */
|
* Will not write to entry if the entry was obtained from an #include. */
|
||||||
void config_set_double(config_file_t *conf, const char *entry, double value);
|
void config_set_double(config_file_t *conf, const char *entry, double value);
|
||||||
void config_set_float(config_file_t *conf, const char *entry, float value);
|
void config_set_float(config_file_t *conf, const char *entry, float value);
|
||||||
void config_set_int(config_file_t *conf, const char *entry, int val);
|
void config_set_int(config_file_t *conf, const char *entry, int val);
|
||||||
void config_set_hex(config_file_t *conf, const char *entry, unsigned val);
|
void config_set_hex(config_file_t *conf, const char *entry, unsigned val);
|
||||||
void config_set_uint64(config_file_t *conf, const char *entry, uint64_t val);
|
void config_set_uint64(config_file_t *conf, const char *entry, uint64_t val);
|
||||||
void config_set_char(config_file_t *conf, const char *entry, char val);
|
void config_set_char(config_file_t *conf, const char *entry, char val);
|
||||||
void config_set_string(config_file_t *conf, const char *entry, const char *val);
|
void config_set_string(config_file_t *conf, const char *entry, const char *val);
|
||||||
void config_unset(config_file_t *conf, const char *key);
|
void config_unset(config_file_t *conf, const char *key);
|
||||||
void config_set_path(config_file_t *conf, const char *entry, const char *val);
|
void config_set_path(config_file_t *conf, const char *entry, const char *val);
|
||||||
void config_set_bool(config_file_t *conf, const char *entry, bool val);
|
void config_set_bool(config_file_t *conf, const char *entry, bool val);
|
||||||
|
|
||||||
/* Write the current config to a file. */
|
/* Write the current config to a file. */
|
||||||
bool config_file_write(config_file_t *conf, const char *path);
|
bool config_file_write(config_file_t *conf, const char *path);
|
||||||
|
|
||||||
/* Dump the current config to an already opened file.
|
/* Dump the current config to an already opened file.
|
||||||
* Does not close the file. */
|
* Does not close the file. */
|
||||||
void config_file_dump(config_file_t *conf, FILE *file);
|
void config_file_dump(config_file_t *conf, FILE *file);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,55 +1,55 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (config_file_userdata.h).
|
* The following license statement only applies to this file (config_file_userdata.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
|
#ifndef _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
|
||||||
#define _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
|
#define _LIBRETRO_SDK_CONFIG_FILE_USERDATA_H
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "config_file.h"
|
#include "config_file.h"
|
||||||
|
|
||||||
struct config_file_userdata
|
struct config_file_userdata
|
||||||
{
|
{
|
||||||
config_file_t *conf;
|
config_file_t *conf;
|
||||||
const char *prefix[2];
|
const char *prefix[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
int config_userdata_get_float(void *userdata, const char *key_str,
|
int config_userdata_get_float(void *userdata, const char *key_str,
|
||||||
float *value, float default_value);
|
float *value, float default_value);
|
||||||
|
|
||||||
int config_userdata_get_int(void *userdata, const char *key_str,
|
int config_userdata_get_int(void *userdata, const char *key_str,
|
||||||
int *value, int default_value);
|
int *value, int default_value);
|
||||||
|
|
||||||
int config_userdata_get_float_array(void *userdata, const char *key_str,
|
int config_userdata_get_float_array(void *userdata, const char *key_str,
|
||||||
float **values, unsigned *out_num_values,
|
float **values, unsigned *out_num_values,
|
||||||
const float *default_values, unsigned num_default_values);
|
const float *default_values, unsigned num_default_values);
|
||||||
|
|
||||||
int config_userdata_get_int_array(void *userdata, const char *key_str,
|
int config_userdata_get_int_array(void *userdata, const char *key_str,
|
||||||
int **values, unsigned *out_num_values,
|
int **values, unsigned *out_num_values,
|
||||||
const int *default_values, unsigned num_default_values);
|
const int *default_values, unsigned num_default_values);
|
||||||
|
|
||||||
int config_userdata_get_string(void *userdata, const char *key_str,
|
int config_userdata_get_string(void *userdata, const char *key_str,
|
||||||
char **output, const char *default_output);
|
char **output, const char *default_output);
|
||||||
|
|
||||||
void config_userdata_free(void *ptr);
|
void config_userdata_free(void *ptr);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,409 +1,409 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (file_path.h).
|
* The following license statement only applies to this file (file_path.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FILE_PATH_H
|
#ifndef __LIBRETRO_SDK_FILE_PATH_H
|
||||||
#define __LIBRETRO_SDK_FILE_PATH_H
|
#define __LIBRETRO_SDK_FILE_PATH_H
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Order in this enum is equivalent to negative sort order in filelist
|
/* Order in this enum is equivalent to negative sort order in filelist
|
||||||
* (i.e. DIRECTORY is on top of PLAIN_FILE) */
|
* (i.e. DIRECTORY is on top of PLAIN_FILE) */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
RARCH_FILETYPE_UNSET,
|
RARCH_FILETYPE_UNSET,
|
||||||
RARCH_PLAIN_FILE,
|
RARCH_PLAIN_FILE,
|
||||||
RARCH_COMPRESSED_FILE_IN_ARCHIVE,
|
RARCH_COMPRESSED_FILE_IN_ARCHIVE,
|
||||||
RARCH_COMPRESSED_ARCHIVE,
|
RARCH_COMPRESSED_ARCHIVE,
|
||||||
RARCH_DIRECTORY,
|
RARCH_DIRECTORY,
|
||||||
RARCH_FILE_UNSUPPORTED
|
RARCH_FILE_UNSUPPORTED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_is_compressed_file:
|
* path_is_compressed_file:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if path is a compressed file.
|
* Checks if path is a compressed file.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if path is a compressed file, otherwise false (0).
|
* Returns: true (1) if path is a compressed file, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool path_is_compressed_file(const char *path);
|
bool path_is_compressed_file(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_contains_compressed_file:
|
* path_contains_compressed_file:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if path contains a compressed file.
|
* Checks if path contains a compressed file.
|
||||||
*
|
*
|
||||||
* Currently we only check for hash symbol (#) inside the pathname.
|
* Currently we only check for hash symbol (#) inside the pathname.
|
||||||
* If path is ever expanded to a general URI, we should check for that here.
|
* If path is ever expanded to a general URI, we should check for that here.
|
||||||
*
|
*
|
||||||
* Example: Somewhere in the path there might be a compressed file
|
* Example: Somewhere in the path there might be a compressed file
|
||||||
* E.g.: /path/to/file.7z#mygame.img
|
* E.g.: /path/to/file.7z#mygame.img
|
||||||
*
|
*
|
||||||
* Returns: true (1) if path contains compressed file, otherwise false (0).
|
* Returns: true (1) if path contains compressed file, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool path_contains_compressed_file(const char *path);
|
bool path_contains_compressed_file(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_file_exists:
|
* path_file_exists:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if a file already exists at the specified path (@path).
|
* Checks if a file already exists at the specified path (@path).
|
||||||
*
|
*
|
||||||
* Returns: true (1) if file already exists, otherwise false (0).
|
* Returns: true (1) if file already exists, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
bool path_file_exists(const char *path);
|
bool path_file_exists(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_get_extension:
|
* path_get_extension:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Gets extension of file. Only '.'s
|
* Gets extension of file. Only '.'s
|
||||||
* after the last slash are considered.
|
* after the last slash are considered.
|
||||||
*
|
*
|
||||||
* Returns: extension part from the path.
|
* Returns: extension part from the path.
|
||||||
*/
|
*/
|
||||||
const char *path_get_extension(const char *path);
|
const char *path_get_extension(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_remove_extension:
|
* path_remove_extension:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Removes the extension from the path and returns the result.
|
* Removes the extension from the path and returns the result.
|
||||||
* Removes all text after and including the last '.'.
|
* Removes all text after and including the last '.'.
|
||||||
* Only '.'s after the last slash are considered.
|
* Only '.'s after the last slash are considered.
|
||||||
*
|
*
|
||||||
* Returns: path with the extension part removed.
|
* Returns: path with the extension part removed.
|
||||||
*/
|
*/
|
||||||
char *path_remove_extension(char *path);
|
char *path_remove_extension(char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_basename:
|
* path_basename:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Get basename from @path.
|
* Get basename from @path.
|
||||||
*
|
*
|
||||||
* Returns: basename from path.
|
* Returns: basename from path.
|
||||||
**/
|
**/
|
||||||
const char *path_basename(const char *path);
|
const char *path_basename(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_basedir:
|
* path_basedir:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Extracts base directory by mutating path.
|
* Extracts base directory by mutating path.
|
||||||
* Keeps trailing '/'.
|
* Keeps trailing '/'.
|
||||||
**/
|
**/
|
||||||
void path_basedir(char *path);
|
void path_basedir(char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_parent_dir:
|
* path_parent_dir:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Extracts parent directory by mutating path.
|
* Extracts parent directory by mutating path.
|
||||||
* Assumes that path is a directory. Keeps trailing '/'.
|
* Assumes that path is a directory. Keeps trailing '/'.
|
||||||
**/
|
**/
|
||||||
void path_parent_dir(char *path);
|
void path_parent_dir(char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_resolve_realpath:
|
* path_resolve_realpath:
|
||||||
* @buf : buffer for path
|
* @buf : buffer for path
|
||||||
* @size : size of buffer
|
* @size : size of buffer
|
||||||
*
|
*
|
||||||
* Turns relative paths into absolute path.
|
* Turns relative paths into absolute path.
|
||||||
* If relative, rebases on current working dir.
|
* If relative, rebases on current working dir.
|
||||||
**/
|
**/
|
||||||
void path_resolve_realpath(char *buf, size_t size);
|
void path_resolve_realpath(char *buf, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_is_absolute:
|
* path_is_absolute:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if @path is an absolute path or a relative path.
|
* Checks if @path is an absolute path or a relative path.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if path is absolute, false (1) if path is relative.
|
* Returns: true (1) if path is absolute, false (1) if path is relative.
|
||||||
**/
|
**/
|
||||||
bool path_is_absolute(const char *path);
|
bool path_is_absolute(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname:
|
* fill_pathname:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @replace : what to replace
|
* @replace : what to replace
|
||||||
* @size : buffer size of output path
|
* @size : buffer size of output path
|
||||||
*
|
*
|
||||||
* FIXME: Verify
|
* FIXME: Verify
|
||||||
*
|
*
|
||||||
* Replaces filename extension with 'replace' and outputs result to out_path.
|
* Replaces filename extension with 'replace' and outputs result to out_path.
|
||||||
* The extension here is considered to be the string from the last '.'
|
* The extension here is considered to be the string from the last '.'
|
||||||
* to the end.
|
* to the end.
|
||||||
*
|
*
|
||||||
* Only '.'s after the last slash are considered as extensions.
|
* Only '.'s after the last slash are considered as extensions.
|
||||||
* If no '.' is present, in_path and replace will simply be concatenated.
|
* If no '.' is present, in_path and replace will simply be concatenated.
|
||||||
* 'size' is buffer size of 'out_path'.
|
* 'size' is buffer size of 'out_path'.
|
||||||
* E.g.: in_path = "/foo/bar/baz/boo.c", replace = ".asm" =>
|
* E.g.: in_path = "/foo/bar/baz/boo.c", replace = ".asm" =>
|
||||||
* out_path = "/foo/bar/baz/boo.asm"
|
* out_path = "/foo/bar/baz/boo.asm"
|
||||||
* E.g.: in_path = "/foo/bar/baz/boo.c", replace = "" =>
|
* E.g.: in_path = "/foo/bar/baz/boo.c", replace = "" =>
|
||||||
* out_path = "/foo/bar/baz/boo"
|
* out_path = "/foo/bar/baz/boo"
|
||||||
*/
|
*/
|
||||||
void fill_pathname(char *out_path, const char *in_path,
|
void fill_pathname(char *out_path, const char *in_path,
|
||||||
const char *replace, size_t size);
|
const char *replace, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_dated_filename:
|
* fill_dated_filename:
|
||||||
* @out_filename : output filename
|
* @out_filename : output filename
|
||||||
* @ext : extension of output filename
|
* @ext : extension of output filename
|
||||||
* @size : buffer size of output filename
|
* @size : buffer size of output filename
|
||||||
*
|
*
|
||||||
* Creates a 'dated' filename prefixed by 'RetroArch', and
|
* Creates a 'dated' filename prefixed by 'RetroArch', and
|
||||||
* concatenates extension (@ext) to it.
|
* concatenates extension (@ext) to it.
|
||||||
*
|
*
|
||||||
* E.g.:
|
* E.g.:
|
||||||
* out_filename = "RetroArch-{month}{day}-{Hours}{Minutes}.{@ext}"
|
* out_filename = "RetroArch-{month}{day}-{Hours}{Minutes}.{@ext}"
|
||||||
**/
|
**/
|
||||||
void fill_dated_filename(char *out_filename,
|
void fill_dated_filename(char *out_filename,
|
||||||
const char *ext, size_t size);
|
const char *ext, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_noext:
|
* fill_pathname_noext:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @replace : what to replace
|
* @replace : what to replace
|
||||||
* @size : buffer size of output path
|
* @size : buffer size of output path
|
||||||
*
|
*
|
||||||
* Appends a filename extension 'replace' to 'in_path', and outputs
|
* Appends a filename extension 'replace' to 'in_path', and outputs
|
||||||
* result in 'out_path'.
|
* result in 'out_path'.
|
||||||
*
|
*
|
||||||
* Assumes in_path has no extension. If an extension is still
|
* Assumes in_path has no extension. If an extension is still
|
||||||
* present in 'in_path', it will be ignored.
|
* present in 'in_path', it will be ignored.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void fill_pathname_noext(char *out_path, const char *in_path,
|
void fill_pathname_noext(char *out_path, const char *in_path,
|
||||||
const char *replace, size_t size);
|
const char *replace, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_dir:
|
* fill_pathname_dir:
|
||||||
* @in_dir : input directory path
|
* @in_dir : input directory path
|
||||||
* @in_basename : input basename to be appended to @in_dir
|
* @in_basename : input basename to be appended to @in_dir
|
||||||
* @replace : replacement to be appended to @in_basename
|
* @replace : replacement to be appended to @in_basename
|
||||||
* @size : size of buffer
|
* @size : size of buffer
|
||||||
*
|
*
|
||||||
* Appends basename of 'in_basename', to 'in_dir', along with 'replace'.
|
* Appends basename of 'in_basename', to 'in_dir', along with 'replace'.
|
||||||
* Basename of in_basename is the string after the last '/' or '\\',
|
* Basename of in_basename is the string after the last '/' or '\\',
|
||||||
* i.e the filename without directories.
|
* i.e the filename without directories.
|
||||||
*
|
*
|
||||||
* If in_basename has no '/' or '\\', the whole 'in_basename' will be used.
|
* If in_basename has no '/' or '\\', the whole 'in_basename' will be used.
|
||||||
* 'size' is buffer size of 'in_dir'.
|
* 'size' is buffer size of 'in_dir'.
|
||||||
*
|
*
|
||||||
* E.g..: in_dir = "/tmp/some_dir", in_basename = "/some_content/foo.c",
|
* E.g..: in_dir = "/tmp/some_dir", in_basename = "/some_content/foo.c",
|
||||||
* replace = ".asm" => in_dir = "/tmp/some_dir/foo.c.asm"
|
* replace = ".asm" => in_dir = "/tmp/some_dir/foo.c.asm"
|
||||||
**/
|
**/
|
||||||
void fill_pathname_dir(char *in_dir, const char *in_basename,
|
void fill_pathname_dir(char *in_dir, const char *in_basename,
|
||||||
const char *replace, size_t size);
|
const char *replace, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_base:
|
* fill_pathname_base:
|
||||||
* @out : output path
|
* @out : output path
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @size : size of output path
|
* @size : size of output path
|
||||||
*
|
*
|
||||||
* Copies basename of @in_path into @out_path.
|
* Copies basename of @in_path into @out_path.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_base(char *out_path, const char *in_path, size_t size);
|
void fill_pathname_base(char *out_path, const char *in_path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_basedir:
|
* fill_pathname_basedir:
|
||||||
* @out_dir : output directory
|
* @out_dir : output directory
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @size : size of output directory
|
* @size : size of output directory
|
||||||
*
|
*
|
||||||
* Copies base directory of @in_path into @out_path.
|
* Copies base directory of @in_path into @out_path.
|
||||||
* If in_path is a path without any slashes (relative current directory),
|
* If in_path is a path without any slashes (relative current directory),
|
||||||
* @out_path will get path "./".
|
* @out_path will get path "./".
|
||||||
**/
|
**/
|
||||||
void fill_pathname_basedir(char *out_path, const char *in_path, size_t size);
|
void fill_pathname_basedir(char *out_path, const char *in_path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_parent_dir:
|
* fill_pathname_parent_dir:
|
||||||
* @out_dir : output directory
|
* @out_dir : output directory
|
||||||
* @in_dir : input directory
|
* @in_dir : input directory
|
||||||
* @size : size of output directory
|
* @size : size of output directory
|
||||||
*
|
*
|
||||||
* Copies parent directory of @in_dir into @out_dir.
|
* Copies parent directory of @in_dir into @out_dir.
|
||||||
* Assumes @in_dir is a directory. Keeps trailing '/'.
|
* Assumes @in_dir is a directory. Keeps trailing '/'.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_parent_dir(char *out_dir,
|
void fill_pathname_parent_dir(char *out_dir,
|
||||||
const char *in_dir, size_t size);
|
const char *in_dir, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_resolve_relative:
|
* fill_pathname_resolve_relative:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @in_refpath : input reference path
|
* @in_refpath : input reference path
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @size : size of @out_path
|
* @size : size of @out_path
|
||||||
*
|
*
|
||||||
* Joins basedir of @in_refpath together with @in_path.
|
* Joins basedir of @in_refpath together with @in_path.
|
||||||
* If @in_path is an absolute path, out_path = in_path.
|
* If @in_path is an absolute path, out_path = in_path.
|
||||||
* E.g.: in_refpath = "/foo/bar/baz.a", in_path = "foobar.cg",
|
* E.g.: in_refpath = "/foo/bar/baz.a", in_path = "foobar.cg",
|
||||||
* out_path = "/foo/bar/foobar.cg".
|
* out_path = "/foo/bar/foobar.cg".
|
||||||
**/
|
**/
|
||||||
void fill_pathname_resolve_relative(char *out_path, const char *in_refpath,
|
void fill_pathname_resolve_relative(char *out_path, const char *in_refpath,
|
||||||
const char *in_path, size_t size);
|
const char *in_path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_join:
|
* fill_pathname_join:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
* @path : path
|
* @path : path
|
||||||
* @size : size of output path
|
* @size : size of output path
|
||||||
*
|
*
|
||||||
* Joins a directory (@dir) and path (@path) together.
|
* Joins a directory (@dir) and path (@path) together.
|
||||||
* Makes sure not to get two consecutive slashes
|
* Makes sure not to get two consecutive slashes
|
||||||
* between directory and path.
|
* between directory and path.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_join(char *out_path, const char *dir,
|
void fill_pathname_join(char *out_path, const char *dir,
|
||||||
const char *path, size_t size);
|
const char *path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_string_join:
|
* fill_string_join:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @path : path
|
* @path : path
|
||||||
* @size : size of output path
|
* @size : size of output path
|
||||||
*
|
*
|
||||||
* Joins a string (@out_path) and path (@append) together.
|
* Joins a string (@out_path) and path (@append) together.
|
||||||
* Makes sure not to get two consecutive slashes
|
* Makes sure not to get two consecutive slashes
|
||||||
* between directory and path.
|
* between directory and path.
|
||||||
**/
|
**/
|
||||||
void fill_string_join(char *out_path,
|
void fill_string_join(char *out_path,
|
||||||
const char *path, size_t size);
|
const char *path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_join_delim:
|
* fill_pathname_join_delim:
|
||||||
* @out_path : output path
|
* @out_path : output path
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
* @path : path
|
* @path : path
|
||||||
* @delim : delimiter
|
* @delim : delimiter
|
||||||
* @size : size of output path
|
* @size : size of output path
|
||||||
*
|
*
|
||||||
* Joins a directory (@dir) and path (@path) together
|
* Joins a directory (@dir) and path (@path) together
|
||||||
* using the given delimiter (@delim).
|
* using the given delimiter (@delim).
|
||||||
**/
|
**/
|
||||||
void fill_pathname_join_delim(char *out_path, const char *dir,
|
void fill_pathname_join_delim(char *out_path, const char *dir,
|
||||||
const char *path, const char delim, size_t size);
|
const char *path, const char delim, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_short_pathname_representation:
|
* fill_short_pathname_representation:
|
||||||
* @out_rep : output representation
|
* @out_rep : output representation
|
||||||
* @in_path : input path
|
* @in_path : input path
|
||||||
* @size : size of output representation
|
* @size : size of output representation
|
||||||
*
|
*
|
||||||
* Generates a short representation of path. It should only
|
* Generates a short representation of path. It should only
|
||||||
* be used for displaying the result; the output representation is not
|
* be used for displaying the result; the output representation is not
|
||||||
* binding in any meaningful way (for a normal path, this is the same as basename)
|
* binding in any meaningful way (for a normal path, this is the same as basename)
|
||||||
* In case of more complex URLs, this should cut everything except for
|
* In case of more complex URLs, this should cut everything except for
|
||||||
* the main image file.
|
* the main image file.
|
||||||
*
|
*
|
||||||
* E.g.: "/path/to/game.img" -> game.img
|
* E.g.: "/path/to/game.img" -> game.img
|
||||||
* "/path/to/myarchive.7z#folder/to/game.img" -> game.img
|
* "/path/to/myarchive.7z#folder/to/game.img" -> game.img
|
||||||
*/
|
*/
|
||||||
void fill_short_pathname_representation(char* out_rep,
|
void fill_short_pathname_representation(char* out_rep,
|
||||||
const char *in_path, size_t size);
|
const char *in_path, size_t size);
|
||||||
|
|
||||||
void fill_pathname_expand_special(char *out_path,
|
void fill_pathname_expand_special(char *out_path,
|
||||||
const char *in_path, size_t size);
|
const char *in_path, size_t size);
|
||||||
|
|
||||||
void fill_pathname_abbreviate_special(char *out_path,
|
void fill_pathname_abbreviate_special(char *out_path,
|
||||||
const char *in_path, size_t size);
|
const char *in_path, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_char_is_slash:
|
* path_char_is_slash:
|
||||||
* @c : character
|
* @c : character
|
||||||
*
|
*
|
||||||
* Checks if character (@c) is a slash.
|
* Checks if character (@c) is a slash.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if character is a slash, otherwise false (0).
|
* Returns: true (1) if character is a slash, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
static INLINE bool path_char_is_slash(char c)
|
static INLINE bool path_char_is_slash(char c)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return (c == '/') || (c == '\\');
|
return (c == '/') || (c == '\\');
|
||||||
#else
|
#else
|
||||||
return (c == '/');
|
return (c == '/');
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_default_slash:
|
* path_default_slash:
|
||||||
*
|
*
|
||||||
* Gets the default slash separator.
|
* Gets the default slash separator.
|
||||||
*
|
*
|
||||||
* Returns: default slash separator.
|
* Returns: default slash separator.
|
||||||
*/
|
*/
|
||||||
static INLINE const char *path_default_slash(void)
|
static INLINE const char *path_default_slash(void)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return "\\";
|
return "\\";
|
||||||
#else
|
#else
|
||||||
return "/";
|
return "/";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fill_pathname_slash:
|
* fill_pathname_slash:
|
||||||
* @path : path
|
* @path : path
|
||||||
* @size : size of path
|
* @size : size of path
|
||||||
*
|
*
|
||||||
* Assumes path is a directory. Appends a slash
|
* Assumes path is a directory. Appends a slash
|
||||||
* if not already there.
|
* if not already there.
|
||||||
**/
|
**/
|
||||||
void fill_pathname_slash(char *path, size_t size);
|
void fill_pathname_slash(char *path, size_t size);
|
||||||
|
|
||||||
#ifndef RARCH_CONSOLE
|
#ifndef RARCH_CONSOLE
|
||||||
void fill_pathname_application_path(char *buf, size_t size);
|
void fill_pathname_application_path(char *buf, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_mkdir:
|
* path_mkdir:
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
*
|
*
|
||||||
* Create directory on filesystem.
|
* Create directory on filesystem.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if directory could be created, otherwise false (0).
|
* Returns: true (1) if directory could be created, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool path_mkdir(const char *dir);
|
bool path_mkdir(const char *dir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (dir_list.h).
|
* The following license statement only applies to this file (dir_list.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_NBIO_H
|
#ifndef __LIBRETRO_SDK_NBIO_H
|
||||||
#define __LIBRETRO_SDK_NBIO_H
|
#define __LIBRETRO_SDK_NBIO_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifndef NBIO_READ
|
#ifndef NBIO_READ
|
||||||
#define NBIO_READ 0
|
#define NBIO_READ 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NBIO_WRITE
|
#ifndef NBIO_WRITE
|
||||||
#define NBIO_WRITE 1
|
#define NBIO_WRITE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NBIO_UPDATE
|
#ifndef NBIO_UPDATE
|
||||||
#define NBIO_UPDATE 2
|
#define NBIO_UPDATE 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BIO_READ
|
#ifndef BIO_READ
|
||||||
#define BIO_READ 3
|
#define BIO_READ 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BIO_WRITE
|
#ifndef BIO_WRITE
|
||||||
#define BIO_WRITE 4
|
#define BIO_WRITE 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct nbio_t;
|
struct nbio_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Creates an nbio structure for performing the given operation on the given file.
|
* Creates an nbio structure for performing the given operation on the given file.
|
||||||
*/
|
*/
|
||||||
struct nbio_t* nbio_open(const char * filename, unsigned mode);
|
struct nbio_t* nbio_open(const char * filename, unsigned mode);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts reading the given file. When done, it will be available in nbio_get_ptr.
|
* Starts reading the given file. When done, it will be available in nbio_get_ptr.
|
||||||
* Can not be done if the structure was created with nbio_write.
|
* Can not be done if the structure was created with nbio_write.
|
||||||
*/
|
*/
|
||||||
void nbio_begin_read(struct nbio_t* handle);
|
void nbio_begin_read(struct nbio_t* handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts writing to the given file. Before this, you should've copied the data to nbio_get_ptr.
|
* Starts writing to the given file. Before this, you should've copied the data to nbio_get_ptr.
|
||||||
* Can not be done if the structure was created with nbio_read.
|
* Can not be done if the structure was created with nbio_read.
|
||||||
*/
|
*/
|
||||||
void nbio_begin_write(struct nbio_t* handle);
|
void nbio_begin_write(struct nbio_t* handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Performs part of the requested operation, or checks how it's going.
|
* Performs part of the requested operation, or checks how it's going.
|
||||||
* When it returns true, it's done.
|
* When it returns true, it's done.
|
||||||
*/
|
*/
|
||||||
bool nbio_iterate(struct nbio_t* handle);
|
bool nbio_iterate(struct nbio_t* handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Resizes the file up to the given size; cannot shrink.
|
* Resizes the file up to the given size; cannot shrink.
|
||||||
* Can not be done if the structure was created with nbio_read.
|
* Can not be done if the structure was created with nbio_read.
|
||||||
*/
|
*/
|
||||||
void nbio_resize(struct nbio_t* handle, size_t len);
|
void nbio_resize(struct nbio_t* handle, size_t len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a pointer to the file data. Writable only if structure was not created with nbio_read.
|
* Returns a pointer to the file data. Writable only if structure was not created with nbio_read.
|
||||||
* If any operation is in progress, the pointer will be NULL, but len will still be correct.
|
* If any operation is in progress, the pointer will be NULL, but len will still be correct.
|
||||||
*/
|
*/
|
||||||
void* nbio_get_ptr(struct nbio_t* handle, size_t* len);
|
void* nbio_get_ptr(struct nbio_t* handle, size_t* len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stops any pending operation, allowing the object to be freed.
|
* Stops any pending operation, allowing the object to be freed.
|
||||||
*/
|
*/
|
||||||
void nbio_cancel(struct nbio_t* handle);
|
void nbio_cancel(struct nbio_t* handle);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Deletes the nbio structure and its associated pointer.
|
* Deletes the nbio structure and its associated pointer.
|
||||||
*/
|
*/
|
||||||
void nbio_free(struct nbio_t* handle);
|
void nbio_free(struct nbio_t* handle);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,73 +1,73 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (filters.h).
|
* The following license statement only applies to this file (filters.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_SDK_FILTERS_H
|
#ifndef _LIBRETRO_SDK_FILTERS_H
|
||||||
#define _LIBRETRO_SDK_FILTERS_H
|
#define _LIBRETRO_SDK_FILTERS_H
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
static INLINE double sinc(double val)
|
static INLINE double sinc(double val)
|
||||||
{
|
{
|
||||||
if (fabs(val) < 0.00001)
|
if (fabs(val) < 0.00001)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
return sin(val) / val;
|
return sin(val) / val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Modified Bessel function of first order.
|
/* Modified Bessel function of first order.
|
||||||
* Check Wiki for mathematical definition ... */
|
* Check Wiki for mathematical definition ... */
|
||||||
static INLINE double besseli0(double x)
|
static INLINE double besseli0(double x)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
double sum = 0.0;
|
double sum = 0.0;
|
||||||
double factorial = 1.0;
|
double factorial = 1.0;
|
||||||
double factorial_mult = 0.0;
|
double factorial_mult = 0.0;
|
||||||
double x_pow = 1.0;
|
double x_pow = 1.0;
|
||||||
double two_div_pow = 1.0;
|
double two_div_pow = 1.0;
|
||||||
double x_sqr = x * x;
|
double x_sqr = x * x;
|
||||||
|
|
||||||
/* Approximate. This is an infinite sum.
|
/* Approximate. This is an infinite sum.
|
||||||
* Luckily, it converges rather fast. */
|
* Luckily, it converges rather fast. */
|
||||||
for (i = 0; i < 18; i++)
|
for (i = 0; i < 18; i++)
|
||||||
{
|
{
|
||||||
sum += x_pow * two_div_pow / (factorial * factorial);
|
sum += x_pow * two_div_pow / (factorial * factorial);
|
||||||
|
|
||||||
factorial_mult += 1.0;
|
factorial_mult += 1.0;
|
||||||
x_pow *= x_sqr;
|
x_pow *= x_sqr;
|
||||||
two_div_pow *= 0.25;
|
two_div_pow *= 0.25;
|
||||||
factorial *= factorial_mult;
|
factorial *= factorial_mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE double kaiser_window_function(double index, double beta)
|
static INLINE double kaiser_window_function(double index, double beta)
|
||||||
{
|
{
|
||||||
return besseli0(beta * sqrtf(1 - index * index));
|
return besseli0(beta * sqrtf(1 - index * index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static INLINE double lanzcos_window_function(double index)
|
static INLINE double lanzcos_window_function(double index)
|
||||||
{
|
{
|
||||||
return sinc(M_PI * index);
|
return sinc(M_PI * index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,56 +1,56 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
/* RetroArch - A frontend for libretro.
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RARCH_IMAGE_CONTEXT_H
|
#ifndef __RARCH_IMAGE_CONTEXT_H
|
||||||
#define __RARCH_IMAGE_CONTEXT_H
|
#define __RARCH_IMAGE_CONTEXT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum image_process_code
|
enum image_process_code
|
||||||
{
|
{
|
||||||
IMAGE_PROCESS_ERROR = -2,
|
IMAGE_PROCESS_ERROR = -2,
|
||||||
IMAGE_PROCESS_ERROR_END = -1,
|
IMAGE_PROCESS_ERROR_END = -1,
|
||||||
IMAGE_PROCESS_NEXT = 0,
|
IMAGE_PROCESS_NEXT = 0,
|
||||||
IMAGE_PROCESS_END = 1
|
IMAGE_PROCESS_END = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct texture_image
|
struct texture_image
|
||||||
{
|
{
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
uint32_t *pixels;
|
uint32_t *pixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
|
bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
|
||||||
unsigned *b_shift, unsigned *a_shift);
|
unsigned *b_shift, unsigned *a_shift);
|
||||||
|
|
||||||
bool video_texture_image_color_convert(unsigned r_shift,
|
bool video_texture_image_color_convert(unsigned r_shift,
|
||||||
unsigned g_shift, unsigned b_shift, unsigned a_shift,
|
unsigned g_shift, unsigned b_shift, unsigned a_shift,
|
||||||
struct texture_image *out_img);
|
struct texture_image *out_img);
|
||||||
|
|
||||||
bool video_texture_image_load(struct texture_image *img, const char *path);
|
bool video_texture_image_load(struct texture_image *img, const char *path);
|
||||||
void video_texture_image_free(struct texture_image *img);
|
void video_texture_image_free(struct texture_image *img);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,64 +1,64 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (jsonsax.h).
|
* The following license statement only applies to this file (jsonsax.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FORMAT_JSONSAX_H__
|
#ifndef __LIBRETRO_SDK_FORMAT_JSONSAX_H__
|
||||||
#define __LIBRETRO_SDK_FORMAT_JSONSAX_H__
|
#define __LIBRETRO_SDK_FORMAT_JSONSAX_H__
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
JSONSAX_OK = 0,
|
JSONSAX_OK = 0,
|
||||||
JSONSAX_INTERRUPTED,
|
JSONSAX_INTERRUPTED,
|
||||||
JSONSAX_MISSING_KEY,
|
JSONSAX_MISSING_KEY,
|
||||||
JSONSAX_UNTERMINATED_KEY,
|
JSONSAX_UNTERMINATED_KEY,
|
||||||
JSONSAX_MISSING_VALUE,
|
JSONSAX_MISSING_VALUE,
|
||||||
JSONSAX_UNTERMINATED_OBJECT,
|
JSONSAX_UNTERMINATED_OBJECT,
|
||||||
JSONSAX_UNTERMINATED_ARRAY,
|
JSONSAX_UNTERMINATED_ARRAY,
|
||||||
JSONSAX_UNTERMINATED_STRING,
|
JSONSAX_UNTERMINATED_STRING,
|
||||||
JSONSAX_INVALID_VALUE
|
JSONSAX_INVALID_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef JSONSAX_ERRORS
|
#ifdef JSONSAX_ERRORS
|
||||||
extern const char* jsonsax_errors[];
|
extern const char* jsonsax_errors[];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int ( *start_document )( void* userdata );
|
int ( *start_document )( void* userdata );
|
||||||
int ( *end_document )( void* userdata );
|
int ( *end_document )( void* userdata );
|
||||||
int ( *start_object )( void* userdata );
|
int ( *start_object )( void* userdata );
|
||||||
int ( *end_object )( void* userdata );
|
int ( *end_object )( void* userdata );
|
||||||
int ( *start_array )( void* userdata );
|
int ( *start_array )( void* userdata );
|
||||||
int ( *end_array )( void* userdata );
|
int ( *end_array )( void* userdata );
|
||||||
int ( *key )( void* userdata, const char* name, size_t length );
|
int ( *key )( void* userdata, const char* name, size_t length );
|
||||||
int ( *index )( void* userdata, unsigned int index );
|
int ( *index )( void* userdata, unsigned int index );
|
||||||
int ( *string )( void* userdata, const char* string, size_t length );
|
int ( *string )( void* userdata, const char* string, size_t length );
|
||||||
int ( *number )( void* userdata, const char* number, size_t length );
|
int ( *number )( void* userdata, const char* number, size_t length );
|
||||||
int ( *boolean )( void* userdata, int istrue );
|
int ( *boolean )( void* userdata, int istrue );
|
||||||
int ( *null )( void* userdata );
|
int ( *null )( void* userdata );
|
||||||
}
|
}
|
||||||
jsonsax_handlers_t;
|
jsonsax_handlers_t;
|
||||||
|
|
||||||
int jsonsax_parse( const char* json, const jsonsax_handlers_t* handlers, void* userdata );
|
int jsonsax_parse( const char* json, const jsonsax_handlers_t* handlers, void* userdata );
|
||||||
|
|
||||||
#endif /* __LIBRETRO_SDK_FORMAT_JSONSAX_H__ */
|
#endif /* __LIBRETRO_SDK_FORMAT_JSONSAX_H__ */
|
||||||
|
|
|
@ -1,48 +1,53 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rbmp.h).
|
* The following license statement only applies to this file (rbmp.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FORMAT_RBMP_H__
|
#ifndef __LIBRETRO_SDK_FORMAT_RBMP_H__
|
||||||
#define __LIBRETRO_SDK_FORMAT_RBMP_H__
|
#define __LIBRETRO_SDK_FORMAT_RBMP_H__
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum
|
enum rbmp_source_type
|
||||||
{
|
{
|
||||||
RBMP_SOURCE_TYPE_BGR24,
|
RBMP_SOURCE_TYPE_DONT_CARE,
|
||||||
RBMP_SOURCE_TYPE_XRGB888,
|
RBMP_SOURCE_TYPE_BGR24,
|
||||||
RBMP_SOURCE_TYPE_RGB565,
|
RBMP_SOURCE_TYPE_XRGB888,
|
||||||
RBMP_SOURCE_TYPE_ARGB8888,
|
RBMP_SOURCE_TYPE_RGB565,
|
||||||
} rbmp_source_type;
|
RBMP_SOURCE_TYPE_ARGB8888
|
||||||
|
};
|
||||||
bool rbmp_save_image(const char *filename, const void *frame,
|
|
||||||
unsigned width, unsigned height,
|
bool rbmp_save_image(
|
||||||
unsigned pitch, rbmp_source_type type);
|
const char *filename,
|
||||||
|
const void *frame,
|
||||||
#ifdef __cplusplus
|
unsigned width,
|
||||||
}
|
unsigned height,
|
||||||
#endif
|
unsigned pitch,
|
||||||
|
enum rbmp_source_type type);
|
||||||
#endif
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rpng.h).
|
* The following license statement only applies to this file (rpng.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FORMAT_RPNG_H__
|
#ifndef __LIBRETRO_SDK_FORMAT_RPNG_H__
|
||||||
#define __LIBRETRO_SDK_FORMAT_RPNG_H__
|
#define __LIBRETRO_SDK_FORMAT_RPNG_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <file/file_archive.h>
|
#include <file/archive_file.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct rpng rpng_t;
|
typedef struct rpng rpng_t;
|
||||||
|
|
||||||
bool rpng_load_image_argb(const char *path, uint32_t **data,
|
bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||||
unsigned *width, unsigned *height);
|
unsigned *width, unsigned *height);
|
||||||
|
|
||||||
rpng_t *rpng_nbio_load_image_argb_init(const char *path);
|
rpng_t *rpng_nbio_load_image_argb_init(const char *path);
|
||||||
|
|
||||||
bool rpng_is_valid(rpng_t *rpng);
|
bool rpng_is_valid(rpng_t *rpng);
|
||||||
|
|
||||||
bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data);
|
bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data);
|
||||||
|
|
||||||
rpng_t *rpng_alloc(void);
|
rpng_t *rpng_alloc(void);
|
||||||
|
|
||||||
void rpng_nbio_load_image_free(rpng_t *rpng);
|
void rpng_nbio_load_image_free(rpng_t *rpng);
|
||||||
|
|
||||||
bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng);
|
bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng);
|
||||||
|
|
||||||
int rpng_nbio_load_image_argb_process(rpng_t *rpng,
|
int rpng_nbio_load_image_argb_process(rpng_t *rpng,
|
||||||
uint32_t **data, unsigned *width, unsigned *height);
|
uint32_t **data, unsigned *width, unsigned *height);
|
||||||
|
|
||||||
bool rpng_nbio_load_image_argb_start(rpng_t *rpng);
|
bool rpng_nbio_load_image_argb_start(rpng_t *rpng);
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB_DEFLATE
|
#ifdef HAVE_ZLIB_DEFLATE
|
||||||
bool rpng_save_image_argb(const char *path, const uint32_t *data,
|
bool rpng_save_image_argb(const char *path, const uint32_t *data,
|
||||||
unsigned width, unsigned height, unsigned pitch);
|
unsigned width, unsigned height, unsigned pitch);
|
||||||
bool rpng_save_image_bgr24(const char *path, const uint8_t *data,
|
bool rpng_save_image_bgr24(const char *path, const uint8_t *data,
|
||||||
unsigned width, unsigned height, unsigned pitch);
|
unsigned width, unsigned height, unsigned pitch);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,97 +1,97 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rxml.h).
|
* The following license statement only applies to this file (rxml.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef __LIBRETRO_SDK_FORMAT_RXML_H__
|
#ifndef __LIBRETRO_SDK_FORMAT_RXML_H__
|
||||||
#define __LIBRETRO_SDK_FORMAT_RXML_H__
|
#define __LIBRETRO_SDK_FORMAT_RXML_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Total NIH. Very trivial "XML" implementation for use in RetroArch.
|
/* Total NIH. Very trivial "XML" implementation for use in RetroArch.
|
||||||
* Error checking is minimal. Invalid documents may lead to very
|
* Error checking is minimal. Invalid documents may lead to very
|
||||||
* buggy behavior, but memory corruption should never happen.
|
* buggy behavior, but memory corruption should never happen.
|
||||||
*
|
*
|
||||||
* Only parts of standard that RetroArch cares about is supported.
|
* Only parts of standard that RetroArch cares about is supported.
|
||||||
* Nothing more, nothing less. "Clever" XML documents will
|
* Nothing more, nothing less. "Clever" XML documents will
|
||||||
* probably break the implementation.
|
* probably break the implementation.
|
||||||
*
|
*
|
||||||
* Do *NOT* try to use this for anything else. You have been warned.
|
* Do *NOT* try to use this for anything else. You have been warned.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct rxml_document rxml_document_t;
|
typedef struct rxml_document rxml_document_t;
|
||||||
|
|
||||||
struct rxml_attrib_node
|
struct rxml_attrib_node
|
||||||
{
|
{
|
||||||
char *attrib;
|
char *attrib;
|
||||||
char *value;
|
char *value;
|
||||||
struct rxml_attrib_node *next;
|
struct rxml_attrib_node *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rxml_node
|
struct rxml_node
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
char *data;
|
char *data;
|
||||||
struct rxml_attrib_node *attrib;
|
struct rxml_attrib_node *attrib;
|
||||||
|
|
||||||
struct rxml_node *children;
|
struct rxml_node *children;
|
||||||
struct rxml_node *next;
|
struct rxml_node *next;
|
||||||
|
|
||||||
/* Dummy. Used by libxml2 compat.
|
/* Dummy. Used by libxml2 compat.
|
||||||
* Is always set to 0, so XML_ELEMENT_NODE check goes through. */
|
* Is always set to 0, so XML_ELEMENT_NODE check goes through. */
|
||||||
int type;
|
int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
rxml_document_t *rxml_load_document(const char *path);
|
rxml_document_t *rxml_load_document(const char *path);
|
||||||
void rxml_free_document(rxml_document_t *doc);
|
void rxml_free_document(rxml_document_t *doc);
|
||||||
|
|
||||||
struct rxml_node *rxml_root_node(rxml_document_t *doc);
|
struct rxml_node *rxml_root_node(rxml_document_t *doc);
|
||||||
|
|
||||||
/* Drop const-correctness here to avoid warnings
|
/* Drop const-correctness here to avoid warnings
|
||||||
* when used as libxml2 compat.
|
* when used as libxml2 compat.
|
||||||
* xmlGetProp() returns xmlChar*, which is supposed
|
* xmlGetProp() returns xmlChar*, which is supposed
|
||||||
* to be passed to xmlFree(). */
|
* to be passed to xmlFree(). */
|
||||||
char *rxml_node_attrib(struct rxml_node *node, const char *attrib);
|
char *rxml_node_attrib(struct rxml_node *node, const char *attrib);
|
||||||
|
|
||||||
#ifdef RXML_LIBXML2_COMPAT
|
#ifdef RXML_LIBXML2_COMPAT
|
||||||
/* Compat for part of libxml2 that RetroArch uses. */
|
/* Compat for part of libxml2 that RetroArch uses. */
|
||||||
#define LIBXML_TEST_VERSION ((void)0)
|
#define LIBXML_TEST_VERSION ((void)0)
|
||||||
typedef char xmlChar; /* It's really unsigned char, but it doesn't matter. */
|
typedef char xmlChar; /* It's really unsigned char, but it doesn't matter. */
|
||||||
typedef struct rxml_node *xmlNodePtr;
|
typedef struct rxml_node *xmlNodePtr;
|
||||||
typedef void *xmlParserCtxtPtr;
|
typedef void *xmlParserCtxtPtr;
|
||||||
typedef rxml_document_t *xmlDocPtr;
|
typedef rxml_document_t *xmlDocPtr;
|
||||||
#define XML_ELEMENT_NODE (0)
|
#define XML_ELEMENT_NODE (0)
|
||||||
#define xmlNewParserCtxt() ((void*)-1)
|
#define xmlNewParserCtxt() ((void*)-1)
|
||||||
#define xmlCtxtReadFile(ctx, path, a, b) rxml_load_document(path)
|
#define xmlCtxtReadFile(ctx, path, a, b) rxml_load_document(path)
|
||||||
#define xmlGetProp(node, prop) rxml_node_attrib(node, prop)
|
#define xmlGetProp(node, prop) rxml_node_attrib(node, prop)
|
||||||
#define xmlFree(p) ((void)0)
|
#define xmlFree(p) ((void)0)
|
||||||
#define xmlNodeGetContent(node) (node->data)
|
#define xmlNodeGetContent(node) (node->data)
|
||||||
#define xmlDocGetRootElement(doc) rxml_root_node(doc)
|
#define xmlDocGetRootElement(doc) rxml_root_node(doc)
|
||||||
#define xmlFreeDoc(doc) rxml_free_document(doc)
|
#define xmlFreeDoc(doc) rxml_free_document(doc)
|
||||||
#define xmlFreeParserCtxt(ctx) ((void)0)
|
#define xmlFreeParserCtxt(ctx) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (rpng.h).
|
* The following license statement only applies to this file (rtga.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FORMAT_RTGA_H__
|
#ifndef __LIBRETRO_SDK_FORMAT_RTGA_H__
|
||||||
#define __LIBRETRO_SDK_FORMAT_RTGA_H__
|
#define __LIBRETRO_SDK_FORMAT_RTGA_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "../../config.h"
|
#include "../../config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool rtga_image_load_shift(uint8_t *buf,
|
bool rtga_image_load_shift(uint8_t *buf,
|
||||||
void *data,
|
void *data,
|
||||||
unsigned a_shift, unsigned r_shift,
|
unsigned a_shift, unsigned r_shift,
|
||||||
unsigned g_shift, unsigned b_shift);
|
unsigned g_shift, unsigned b_shift);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,69 +1,69 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (matrix_3x3.h).
|
* The following license statement only applies to this file (matrix_3x3.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_GFX_MATH_MATRIX_3X3_H__
|
#ifndef __LIBRETRO_SDK_GFX_MATH_MATRIX_3X3_H__
|
||||||
#define __LIBRETRO_SDK_GFX_MATH_MATRIX_3X3_H__
|
#define __LIBRETRO_SDK_GFX_MATH_MATRIX_3X3_H__
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
typedef struct math_matrix_3x3
|
typedef struct math_matrix_3x3
|
||||||
{
|
{
|
||||||
float data[9];
|
float data[9];
|
||||||
} math_matrix_3x3;
|
} math_matrix_3x3;
|
||||||
|
|
||||||
#define MAT_ELEM_3X3(mat, r, c) ((mat).data[3 * (r) + (c)])
|
#define MAT_ELEM_3X3(mat, r, c) ((mat).data[3 * (r) + (c)])
|
||||||
|
|
||||||
void matrix_3x3_inits(math_matrix_3x3 *mat,
|
void matrix_3x3_inits(math_matrix_3x3 *mat,
|
||||||
const float n11, const float n12, const float n13,
|
const float n11, const float n12, const float n13,
|
||||||
const float n21, const float n22, const float n23,
|
const float n21, const float n22, const float n23,
|
||||||
const float n31, const float n32, const float n33);
|
const float n31, const float n32, const float n33);
|
||||||
void matrix_3x3_identity(math_matrix_3x3 *mat);
|
void matrix_3x3_identity(math_matrix_3x3 *mat);
|
||||||
void matrix_3x3_transpose(math_matrix_3x3 *out, const math_matrix_3x3 *in);
|
void matrix_3x3_transpose(math_matrix_3x3 *out, const math_matrix_3x3 *in);
|
||||||
|
|
||||||
void matrix_3x3_multiply(math_matrix_3x3 *out,
|
void matrix_3x3_multiply(math_matrix_3x3 *out,
|
||||||
const math_matrix_3x3 *a, const math_matrix_3x3 *b);
|
const math_matrix_3x3 *a, const math_matrix_3x3 *b);
|
||||||
void matrix_3x3_divide_scalar(math_matrix_3x3 *mat, float s);
|
void matrix_3x3_divide_scalar(math_matrix_3x3 *mat, float s);
|
||||||
float matrix_3x3_determinant(const math_matrix_3x3 *mat);
|
float matrix_3x3_determinant(const math_matrix_3x3 *mat);
|
||||||
void matrix_3x3_adjoint(math_matrix_3x3 *mat);
|
void matrix_3x3_adjoint(math_matrix_3x3 *mat);
|
||||||
bool matrix_3x3_invert(math_matrix_3x3 *mat);
|
bool matrix_3x3_invert(math_matrix_3x3 *mat);
|
||||||
|
|
||||||
bool matrix_3x3_square_to_quad(const float dx0, const float dy0,
|
bool matrix_3x3_square_to_quad(const float dx0, const float dy0,
|
||||||
const float dx1, const float dy1,
|
const float dx1, const float dy1,
|
||||||
const float dx3, const float dy3,
|
const float dx3, const float dy3,
|
||||||
const float dx2, const float dy2,
|
const float dx2, const float dy2,
|
||||||
math_matrix_3x3 *mat);
|
math_matrix_3x3 *mat);
|
||||||
bool matrix_3x3_quad_to_square(const float sx0, const float sy0,
|
bool matrix_3x3_quad_to_square(const float sx0, const float sy0,
|
||||||
const float sx1, const float sy1,
|
const float sx1, const float sy1,
|
||||||
const float sx2, const float sy2,
|
const float sx2, const float sy2,
|
||||||
const float sx3, const float sy3,
|
const float sx3, const float sy3,
|
||||||
math_matrix_3x3 *mat);
|
math_matrix_3x3 *mat);
|
||||||
bool matrix_3x3_quad_to_quad(const float dx0, const float dy0,
|
bool matrix_3x3_quad_to_quad(const float dx0, const float dy0,
|
||||||
const float dx1, const float dy1,
|
const float dx1, const float dy1,
|
||||||
const float dx2, const float dy2,
|
const float dx2, const float dy2,
|
||||||
const float dx3, const float dy3,
|
const float dx3, const float dy3,
|
||||||
const float sx0, const float sy0,
|
const float sx0, const float sy0,
|
||||||
const float sx1, const float sy1,
|
const float sx1, const float sy1,
|
||||||
const float sx2, const float sy2,
|
const float sx2, const float sy2,
|
||||||
const float sx3, const float sy3,
|
const float sx3, const float sy3,
|
||||||
math_matrix_3x3 *mat);
|
math_matrix_3x3 *mat);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,57 +1,57 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (matrix.h).
|
* The following license statement only applies to this file (matrix.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_GFX_MATH_MATRIX_4X4_H__
|
#ifndef __LIBRETRO_SDK_GFX_MATH_MATRIX_4X4_H__
|
||||||
#define __LIBRETRO_SDK_GFX_MATH_MATRIX_4X4_H__
|
#define __LIBRETRO_SDK_GFX_MATH_MATRIX_4X4_H__
|
||||||
|
|
||||||
/* Column-major matrix (OpenGL-style).
|
/* Column-major matrix (OpenGL-style).
|
||||||
* Reimplements functionality from FF OpenGL pipeline to be able
|
* Reimplements functionality from FF OpenGL pipeline to be able
|
||||||
* to work on GLES 2.0 and modern GL variants.
|
* to work on GLES 2.0 and modern GL variants.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct math_matrix_4x4
|
typedef struct math_matrix_4x4
|
||||||
{
|
{
|
||||||
float data[16];
|
float data[16];
|
||||||
} math_matrix_4x4;
|
} math_matrix_4x4;
|
||||||
|
|
||||||
#define MAT_ELEM_4X4(mat, r, c) ((mat).data[4 * (c) + (r)])
|
#define MAT_ELEM_4X4(mat, r, c) ((mat).data[4 * (c) + (r)])
|
||||||
|
|
||||||
void matrix_4x4_identity(math_matrix_4x4 *mat);
|
void matrix_4x4_identity(math_matrix_4x4 *mat);
|
||||||
void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in);
|
void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in);
|
||||||
|
|
||||||
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad);
|
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad);
|
||||||
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad);
|
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad);
|
||||||
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad);
|
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad);
|
||||||
|
|
||||||
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
||||||
float left, float right,
|
float left, float right,
|
||||||
float bottom, float top,
|
float bottom, float top,
|
||||||
float znear, float zfar);
|
float znear, float zfar);
|
||||||
|
|
||||||
void matrix_4x4_multiply(math_matrix_4x4 *out, const math_matrix_4x4 *a, const math_matrix_4x4 *b);
|
void matrix_4x4_multiply(math_matrix_4x4 *out, const math_matrix_4x4 *a, const math_matrix_4x4 *b);
|
||||||
|
|
||||||
void matrix_4x4_scale(math_matrix_4x4 *out, float x, float y, float z);
|
void matrix_4x4_scale(math_matrix_4x4 *out, float x, float y, float z);
|
||||||
void matrix_4x4_translate(math_matrix_4x4 *out, float x, float y, float z);
|
void matrix_4x4_translate(math_matrix_4x4 *out, float x, float y, float z);
|
||||||
void matrix_4x4_projection(math_matrix_4x4 *out, float znear, float zfar);
|
void matrix_4x4_projection(math_matrix_4x4 *out, float znear, float zfar);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,40 +1,40 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (filter.h).
|
* The following license statement only applies to this file (filter.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_SCALER_FILTER_H__
|
#ifndef __LIBRETRO_SDK_SCALER_FILTER_H__
|
||||||
#define __LIBRETRO_SDK_SCALER_FILTER_H__
|
#define __LIBRETRO_SDK_SCALER_FILTER_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <gfx/scaler/scaler.h>
|
#include <gfx/scaler/scaler.h>
|
||||||
|
|
||||||
bool scaler_gen_filter(struct scaler_ctx *ctx);
|
bool scaler_gen_filter(struct scaler_ctx *ctx);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,93 +1,93 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (pixconv.h).
|
* The following license statement only applies to this file (pixconv.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_SCALER_PIXCONV_H__
|
#ifndef __LIBRETRO_SDK_SCALER_PIXCONV_H__
|
||||||
#define __LIBRETRO_SDK_SCALER_PIXCONV_H__
|
#define __LIBRETRO_SDK_SCALER_PIXCONV_H__
|
||||||
|
|
||||||
#include <clamping.h>
|
#include <clamping.h>
|
||||||
|
|
||||||
void conv_0rgb1555_argb8888(void *output, const void *input,
|
void conv_0rgb1555_argb8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_0rgb1555_rgb565(void *output, const void *input,
|
void conv_0rgb1555_rgb565(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_rgb565_0rgb1555(void *output, const void *input,
|
void conv_rgb565_0rgb1555(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_rgb565_argb8888(void *output, const void *input,
|
void conv_rgb565_argb8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_rgba4444_argb8888(void *output, const void *input,
|
void conv_rgba4444_argb8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_rgba4444_rgb565(void *output, const void *input,
|
void conv_rgba4444_rgb565(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_bgr24_argb8888(void *output, const void *input,
|
void conv_bgr24_argb8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_argb8888_0rgb1555(void *output, const void *input,
|
void conv_argb8888_0rgb1555(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_argb8888_rgba4444(void *output_, const void *input_,
|
void conv_argb8888_rgba4444(void *output_, const void *input_,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_argb8888_rgb565(void *output, const void *input,
|
void conv_argb8888_rgb565(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_argb8888_bgr24(void *output, const void *input,
|
void conv_argb8888_bgr24(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_argb8888_abgr8888(void *output, const void *input,
|
void conv_argb8888_abgr8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_0rgb1555_bgr24(void *output, const void *input,
|
void conv_0rgb1555_bgr24(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_rgb565_bgr24(void *output, const void *input,
|
void conv_rgb565_bgr24(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_yuyv_argb8888(void *output, const void *input,
|
void conv_yuyv_argb8888(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
void conv_copy(void *output, const void *input,
|
void conv_copy(void *output, const void *input,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,153 +1,153 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (scaler.h).
|
* The following license statement only applies to this file (scaler.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_SCALER_H__
|
#ifndef __LIBRETRO_SDK_SCALER_H__
|
||||||
#define __LIBRETRO_SDK_SCALER_H__
|
#define __LIBRETRO_SDK_SCALER_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <clamping.h>
|
#include <clamping.h>
|
||||||
|
|
||||||
#define FILTER_UNITY (1 << 14)
|
#define FILTER_UNITY (1 << 14)
|
||||||
|
|
||||||
enum scaler_pix_fmt
|
enum scaler_pix_fmt
|
||||||
{
|
{
|
||||||
SCALER_FMT_ARGB8888 = 0,
|
SCALER_FMT_ARGB8888 = 0,
|
||||||
SCALER_FMT_ABGR8888,
|
SCALER_FMT_ABGR8888,
|
||||||
SCALER_FMT_0RGB1555,
|
SCALER_FMT_0RGB1555,
|
||||||
SCALER_FMT_RGB565,
|
SCALER_FMT_RGB565,
|
||||||
SCALER_FMT_BGR24,
|
SCALER_FMT_BGR24,
|
||||||
SCALER_FMT_YUYV,
|
SCALER_FMT_YUYV,
|
||||||
SCALER_FMT_RGBA4444
|
SCALER_FMT_RGBA4444
|
||||||
};
|
};
|
||||||
|
|
||||||
enum scaler_type
|
enum scaler_type
|
||||||
{
|
{
|
||||||
SCALER_TYPE_UNKNOWN = 0,
|
SCALER_TYPE_UNKNOWN = 0,
|
||||||
SCALER_TYPE_POINT,
|
SCALER_TYPE_POINT,
|
||||||
SCALER_TYPE_BILINEAR,
|
SCALER_TYPE_BILINEAR,
|
||||||
SCALER_TYPE_SINC
|
SCALER_TYPE_SINC
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scaler_filter
|
struct scaler_filter
|
||||||
{
|
{
|
||||||
int16_t *filter;
|
int16_t *filter;
|
||||||
int filter_len;
|
int filter_len;
|
||||||
int filter_stride;
|
int filter_stride;
|
||||||
int *filter_pos;
|
int *filter_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scaler_ctx
|
struct scaler_ctx
|
||||||
{
|
{
|
||||||
int in_width;
|
int in_width;
|
||||||
int in_height;
|
int in_height;
|
||||||
int in_stride;
|
int in_stride;
|
||||||
|
|
||||||
int out_width;
|
int out_width;
|
||||||
int out_height;
|
int out_height;
|
||||||
int out_stride;
|
int out_stride;
|
||||||
|
|
||||||
enum scaler_pix_fmt in_fmt;
|
enum scaler_pix_fmt in_fmt;
|
||||||
enum scaler_pix_fmt out_fmt;
|
enum scaler_pix_fmt out_fmt;
|
||||||
enum scaler_type scaler_type;
|
enum scaler_type scaler_type;
|
||||||
|
|
||||||
void (*scaler_horiz)(const struct scaler_ctx*,
|
void (*scaler_horiz)(const struct scaler_ctx*,
|
||||||
const void*, int);
|
const void*, int);
|
||||||
void (*scaler_vert)(const struct scaler_ctx*,
|
void (*scaler_vert)(const struct scaler_ctx*,
|
||||||
void*, int);
|
void*, int);
|
||||||
void (*scaler_special)(const struct scaler_ctx*,
|
void (*scaler_special)(const struct scaler_ctx*,
|
||||||
void*, const void*, int, int, int, int, int, int);
|
void*, const void*, int, int, int, int, int, int);
|
||||||
|
|
||||||
void (*in_pixconv)(void*, const void*, int, int, int, int);
|
void (*in_pixconv)(void*, const void*, int, int, int, int);
|
||||||
void (*out_pixconv)(void*, const void*, int, int, int, int);
|
void (*out_pixconv)(void*, const void*, int, int, int, int);
|
||||||
void (*direct_pixconv)(void*, const void*, int, int, int, int);
|
void (*direct_pixconv)(void*, const void*, int, int, int, int);
|
||||||
|
|
||||||
bool unscaled;
|
bool unscaled;
|
||||||
struct scaler_filter horiz, vert;
|
struct scaler_filter horiz, vert;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t *frame;
|
uint32_t *frame;
|
||||||
int stride;
|
int stride;
|
||||||
} input;
|
} input;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint64_t *frame;
|
uint64_t *frame;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int stride;
|
int stride;
|
||||||
} scaled;
|
} scaled;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32_t *frame;
|
uint32_t *frame;
|
||||||
int stride;
|
int stride;
|
||||||
} output;
|
} output;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool scaler_ctx_gen_filter(struct scaler_ctx *ctx);
|
bool scaler_ctx_gen_filter(struct scaler_ctx *ctx);
|
||||||
|
|
||||||
void scaler_ctx_gen_reset(struct scaler_ctx *ctx);
|
void scaler_ctx_gen_reset(struct scaler_ctx *ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_ctx_scale:
|
* scaler_ctx_scale:
|
||||||
* @ctx : pointer to scaler context object.
|
* @ctx : pointer to scaler context object.
|
||||||
* @output : pointer to output image.
|
* @output : pointer to output image.
|
||||||
* @input : pointer to input image.
|
* @input : pointer to input image.
|
||||||
*
|
*
|
||||||
* Scales an input image to an output image.
|
* Scales an input image to an output image.
|
||||||
**/
|
**/
|
||||||
void scaler_ctx_scale(struct scaler_ctx *ctx,
|
void scaler_ctx_scale(struct scaler_ctx *ctx,
|
||||||
void *output, const void *input);
|
void *output, const void *input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_alloc:
|
* scaler_alloc:
|
||||||
* @elem_size : size of the elements to be used.
|
* @elem_size : size of the elements to be used.
|
||||||
* @siz : size of the image that the scaler needs to handle.
|
* @siz : size of the image that the scaler needs to handle.
|
||||||
*
|
*
|
||||||
* Allocate and returns a scaler object.
|
* Allocate and returns a scaler object.
|
||||||
*
|
*
|
||||||
* Returns: pointer to a scaler object of type 'void *' on success,
|
* Returns: pointer to a scaler object of type 'void *' on success,
|
||||||
* NULL in case of error. Has to be freed manually.
|
* NULL in case of error. Has to be freed manually.
|
||||||
**/
|
**/
|
||||||
void *scaler_alloc(size_t elem_size, size_t size);
|
void *scaler_alloc(size_t elem_size, size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* scaler_free:
|
* scaler_free:
|
||||||
* @ptr : pointer to scaler object.
|
* @ptr : pointer to scaler object.
|
||||||
*
|
*
|
||||||
* Frees a scaler object.
|
* Frees a scaler object.
|
||||||
**/
|
**/
|
||||||
void scaler_free(void *ptr);
|
void scaler_free(void *ptr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (scaler_int.h).
|
* The following license statement only applies to this file (scaler_int.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_SCALER_INT_H__
|
#ifndef __LIBRETRO_SDK_SCALER_INT_H__
|
||||||
#define __LIBRETRO_SDK_SCALER_INT_H__
|
#define __LIBRETRO_SDK_SCALER_INT_H__
|
||||||
|
|
||||||
#include <gfx/scaler/scaler.h>
|
#include <gfx/scaler/scaler.h>
|
||||||
|
|
||||||
void scaler_argb8888_vert(const struct scaler_ctx *ctx,
|
void scaler_argb8888_vert(const struct scaler_ctx *ctx,
|
||||||
void *output, int stride);
|
void *output, int stride);
|
||||||
|
|
||||||
void scaler_argb8888_horiz(const struct scaler_ctx *ctx,
|
void scaler_argb8888_horiz(const struct scaler_ctx *ctx,
|
||||||
const void *input, int stride);
|
const void *input, int stride);
|
||||||
|
|
||||||
void scaler_argb8888_point_special(const struct scaler_ctx *ctx,
|
void scaler_argb8888_point_special(const struct scaler_ctx *ctx,
|
||||||
void *output, const void *input,
|
void *output, const void *input,
|
||||||
int out_width, int out_height,
|
int out_width, int out_height,
|
||||||
int in_width, int in_height,
|
int in_width, int in_height,
|
||||||
int out_stride, int in_stride);
|
int out_stride, int in_stride);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,154 +1,154 @@
|
||||||
/* Copyright (C) 2010-2016 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsm.h).
|
* The following license statement only applies to this libretro SDK code part (glsm.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBRETRO_SDK_GLSM_H
|
#ifndef LIBRETRO_SDK_GLSM_H
|
||||||
#define LIBRETRO_SDK_GLSM_H
|
#define LIBRETRO_SDK_GLSM_H
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <libretro.h>
|
#include <libretro.h>
|
||||||
#include <glsym/rglgen_headers.h>
|
#include <glsym/rglgen_headers.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_OPENGLES2
|
#ifdef HAVE_OPENGLES2
|
||||||
typedef GLfloat GLdouble;
|
typedef GLfloat GLdouble;
|
||||||
typedef GLclampf GLclampd;
|
typedef GLclampf GLclampd;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_OPENGLES2)
|
#if defined(HAVE_OPENGLES2)
|
||||||
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
||||||
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES
|
||||||
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
||||||
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
||||||
#elif defined(OSX_PPC)
|
#elif defined(OSX_PPC)
|
||||||
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT
|
||||||
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT
|
||||||
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT
|
||||||
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT
|
||||||
#elif defined(HAVE_PSGL)
|
#elif defined(HAVE_PSGL)
|
||||||
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES
|
||||||
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE
|
||||||
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES
|
||||||
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES
|
||||||
#else
|
#else
|
||||||
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER
|
||||||
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8
|
||||||
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT
|
||||||
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_PSGL)
|
#if defined(HAVE_PSGL)
|
||||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
|
||||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES
|
||||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||||
#elif defined(OSX_PPC)
|
#elif defined(OSX_PPC)
|
||||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
|
||||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT
|
||||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
|
||||||
#else
|
#else
|
||||||
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER
|
#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER
|
||||||
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
|
#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE
|
||||||
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
|
#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_FOG
|
#ifndef GL_FOG
|
||||||
#define GL_FOG 0x0B60
|
#define GL_FOG 0x0B60
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_ALPHA_TEST
|
#ifndef GL_ALPHA_TEST
|
||||||
#define GL_ALPHA_TEST 0x0BC0
|
#define GL_ALPHA_TEST 0x0BC0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_ATTRIB 8
|
#define MAX_ATTRIB 8
|
||||||
#define MAX_TEXTURE 32
|
#define MAX_TEXTURE 32
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SGL_DEPTH_TEST = 0,
|
SGL_DEPTH_TEST = 0,
|
||||||
SGL_BLEND,
|
SGL_BLEND,
|
||||||
SGL_POLYGON_OFFSET_FILL,
|
SGL_POLYGON_OFFSET_FILL,
|
||||||
SGL_FOG,
|
SGL_FOG,
|
||||||
SGL_CULL_FACE,
|
SGL_CULL_FACE,
|
||||||
SGL_ALPHA_TEST,
|
SGL_ALPHA_TEST,
|
||||||
SGL_SCISSOR_TEST,
|
SGL_SCISSOR_TEST,
|
||||||
SGL_STENCIL_TEST,
|
SGL_STENCIL_TEST,
|
||||||
#if !defined(HAVE_OPENGLES)
|
#if !defined(HAVE_OPENGLES)
|
||||||
SGL_DEPTH_CLAMP,
|
SGL_DEPTH_CLAMP,
|
||||||
SGL_CLIP_DISTANCE0,
|
SGL_CLIP_DISTANCE0,
|
||||||
#endif
|
#endif
|
||||||
SGL_DITHER,
|
SGL_DITHER,
|
||||||
SGL_SAMPLE_ALPHA_TO_COVERAGE,
|
SGL_SAMPLE_ALPHA_TO_COVERAGE,
|
||||||
SGL_SAMPLE_COVERAGE,
|
SGL_SAMPLE_COVERAGE,
|
||||||
#ifndef HAVE_OPENGLES
|
#ifndef HAVE_OPENGLES
|
||||||
SGL_COLOR_LOGIC_OP,
|
SGL_COLOR_LOGIC_OP,
|
||||||
#endif
|
#endif
|
||||||
SGL_CAP_MAX
|
SGL_CAP_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum glsm_state_ctl
|
enum glsm_state_ctl
|
||||||
{
|
{
|
||||||
GLSM_CTL_NONE = 0,
|
GLSM_CTL_NONE = 0,
|
||||||
GLSM_CTL_STATE_SETUP,
|
GLSM_CTL_STATE_SETUP,
|
||||||
GLSM_CTL_STATE_BIND,
|
GLSM_CTL_STATE_BIND,
|
||||||
GLSM_CTL_STATE_UNBIND,
|
GLSM_CTL_STATE_UNBIND,
|
||||||
GLSM_CTL_STATE_CONTEXT_RESET,
|
GLSM_CTL_STATE_CONTEXT_RESET,
|
||||||
GLSM_CTL_STATE_CONTEXT_INIT,
|
GLSM_CTL_STATE_CONTEXT_INIT,
|
||||||
GLSM_CTL_IS_IMM_VBO,
|
GLSM_CTL_IS_IMM_VBO,
|
||||||
GLSM_CTL_SET_IMM_VBO,
|
GLSM_CTL_SET_IMM_VBO,
|
||||||
GLSM_CTL_UNSET_IMM_VBO,
|
GLSM_CTL_UNSET_IMM_VBO,
|
||||||
GLSM_CTL_IMM_VBO_DISABLE,
|
GLSM_CTL_IMM_VBO_DISABLE,
|
||||||
GLSM_CTL_IMM_VBO_DRAW,
|
GLSM_CTL_IMM_VBO_DRAW,
|
||||||
GLSM_CTL_IS_FRAMEBUFFER_LOCKED,
|
GLSM_CTL_IS_FRAMEBUFFER_LOCKED,
|
||||||
GLSM_CTL_PROC_ADDRESS_GET
|
GLSM_CTL_PROC_ADDRESS_GET
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef bool (*glsm_imm_vbo_draw)(void *);
|
typedef bool (*glsm_imm_vbo_draw)(void *);
|
||||||
typedef bool (*glsm_imm_vbo_disable)(void *);
|
typedef bool (*glsm_imm_vbo_disable)(void *);
|
||||||
typedef bool (*glsm_framebuffer_lock)(void *);
|
typedef bool (*glsm_framebuffer_lock)(void *);
|
||||||
|
|
||||||
typedef struct glsm_ctx_proc_address
|
typedef struct glsm_ctx_proc_address
|
||||||
{
|
{
|
||||||
retro_get_proc_address_t addr;
|
retro_get_proc_address_t addr;
|
||||||
} glsm_ctx_proc_address_t;
|
} glsm_ctx_proc_address_t;
|
||||||
|
|
||||||
typedef struct glsm_ctx_params
|
typedef struct glsm_ctx_params
|
||||||
{
|
{
|
||||||
glsm_framebuffer_lock framebuffer_lock;
|
glsm_framebuffer_lock framebuffer_lock;
|
||||||
glsm_imm_vbo_draw imm_vbo_draw;
|
glsm_imm_vbo_draw imm_vbo_draw;
|
||||||
glsm_imm_vbo_disable imm_vbo_disable;
|
glsm_imm_vbo_disable imm_vbo_disable;
|
||||||
retro_hw_context_reset_t context_reset;
|
retro_hw_context_reset_t context_reset;
|
||||||
retro_hw_context_reset_t context_destroy;
|
retro_hw_context_reset_t context_destroy;
|
||||||
retro_environment_t environ_cb;
|
retro_environment_t environ_cb;
|
||||||
bool stencil;
|
bool stencil;
|
||||||
unsigned major;
|
unsigned major;
|
||||||
unsigned minor;
|
unsigned minor;
|
||||||
} glsm_ctx_params_t;
|
} glsm_ctx_params_t;
|
||||||
|
|
||||||
bool glsm_ctl(enum glsm_state_ctl state, void *data);
|
bool glsm_ctl(enum glsm_state_ctl state, void *data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,222 +1,222 @@
|
||||||
/* Copyright (C) 2010-2016 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsmsym.h).
|
* The following license statement only applies to this libretro SDK code part (glsmsym.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBRETRO_SDK_GLSM_SYM_H
|
#ifndef LIBRETRO_SDK_GLSM_SYM_H
|
||||||
#define LIBRETRO_SDK_GLSM_SYM_H
|
#define LIBRETRO_SDK_GLSM_SYM_H
|
||||||
|
|
||||||
#include <glsm/glsm.h>
|
#include <glsm/glsm.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* deprecated old FF-style GL symbols */
|
/* deprecated old FF-style GL symbols */
|
||||||
#define glTexCoord2f rglTexCoord2f
|
#define glTexCoord2f rglTexCoord2f
|
||||||
|
|
||||||
/* more forward-compatible GL subset symbols */
|
/* more forward-compatible GL subset symbols */
|
||||||
#define glBlitFramebuffer rglBlitFramebuffer
|
#define glBlitFramebuffer rglBlitFramebuffer
|
||||||
#define glVertexAttrib4f rglVertexAttrib4f
|
#define glVertexAttrib4f rglVertexAttrib4f
|
||||||
#define glVertexAttrib4fv rglVertexAttrib4fv
|
#define glVertexAttrib4fv rglVertexAttrib4fv
|
||||||
#define glDrawArrays rglDrawArrays
|
#define glDrawArrays rglDrawArrays
|
||||||
#define glDrawElements rglDrawElements
|
#define glDrawElements rglDrawElements
|
||||||
#define glCompressedTexImage2D rglCompressedTexImage2D
|
#define glCompressedTexImage2D rglCompressedTexImage2D
|
||||||
#define glBindTexture rglBindTexture
|
#define glBindTexture rglBindTexture
|
||||||
#define glActiveTexture rglActiveTexture
|
#define glActiveTexture rglActiveTexture
|
||||||
#define glFramebufferTexture2D rglFramebufferTexture2D
|
#define glFramebufferTexture2D rglFramebufferTexture2D
|
||||||
#define glFramebufferRenderbuffer rglFramebufferRenderbuffer
|
#define glFramebufferRenderbuffer rglFramebufferRenderbuffer
|
||||||
#define glDeleteFramebuffers rglDeleteFramebuffers
|
#define glDeleteFramebuffers rglDeleteFramebuffers
|
||||||
#define glDeleteTextures rglDeleteTextures
|
#define glDeleteTextures rglDeleteTextures
|
||||||
#define glDeleteBuffers rglDeleteBuffers
|
#define glDeleteBuffers rglDeleteBuffers
|
||||||
#define glRenderbufferStorage rglRenderbufferStorage
|
#define glRenderbufferStorage rglRenderbufferStorage
|
||||||
#define glBindRenderbuffer rglBindRenderbuffer
|
#define glBindRenderbuffer rglBindRenderbuffer
|
||||||
#define glDeleteRenderbuffers rglDeleteRenderbuffers
|
#define glDeleteRenderbuffers rglDeleteRenderbuffers
|
||||||
#define glGenRenderbuffers rglGenRenderbuffers
|
#define glGenRenderbuffers rglGenRenderbuffers
|
||||||
#define glGenFramebuffers rglGenFramebuffers
|
#define glGenFramebuffers rglGenFramebuffers
|
||||||
#define glGenTextures rglGenTextures
|
#define glGenTextures rglGenTextures
|
||||||
#define glBindFramebuffer rglBindFramebuffer
|
#define glBindFramebuffer rglBindFramebuffer
|
||||||
#define glGenerateMipmap rglGenerateMipmap
|
#define glGenerateMipmap rglGenerateMipmap
|
||||||
#define glCheckFramebufferStatus rglCheckFramebufferStatus
|
#define glCheckFramebufferStatus rglCheckFramebufferStatus
|
||||||
#define glBindFragDataLocation rglBindFragDataLocation
|
#define glBindFragDataLocation rglBindFragDataLocation
|
||||||
#define glBindAttribLocation rglBindAttribLocation
|
#define glBindAttribLocation rglBindAttribLocation
|
||||||
#define glLinkProgram rglLinkProgram
|
#define glLinkProgram rglLinkProgram
|
||||||
#define glGetProgramiv rglGetProgramiv
|
#define glGetProgramiv rglGetProgramiv
|
||||||
#define glGetShaderiv rglGetShaderiv
|
#define glGetShaderiv rglGetShaderiv
|
||||||
#define glAttachShader rglAttachShader
|
#define glAttachShader rglAttachShader
|
||||||
#define glDetachShader rglDetachShader
|
#define glDetachShader rglDetachShader
|
||||||
#define glShaderSource rglShaderSource
|
#define glShaderSource rglShaderSource
|
||||||
#define glCompileShader rglCompileShader
|
#define glCompileShader rglCompileShader
|
||||||
#define glCreateProgram rglCreateProgram
|
#define glCreateProgram rglCreateProgram
|
||||||
#define glGetShaderInfoLog rglGetShaderInfoLog
|
#define glGetShaderInfoLog rglGetShaderInfoLog
|
||||||
#define glGetProgramInfoLog rglGetProgramInfoLog
|
#define glGetProgramInfoLog rglGetProgramInfoLog
|
||||||
#define glIsProgram rglIsProgram
|
#define glIsProgram rglIsProgram
|
||||||
#define glEnableVertexAttribArray rglEnableVertexAttribArray
|
#define glEnableVertexAttribArray rglEnableVertexAttribArray
|
||||||
#define glDisableVertexAttribArray rglDisableVertexAttribArray
|
#define glDisableVertexAttribArray rglDisableVertexAttribArray
|
||||||
#define glVertexAttribPointer rglVertexAttribPointer
|
#define glVertexAttribPointer rglVertexAttribPointer
|
||||||
#define glGetUniformLocation rglGetUniformLocation
|
#define glGetUniformLocation rglGetUniformLocation
|
||||||
#define glGenBuffers rglGenBuffers
|
#define glGenBuffers rglGenBuffers
|
||||||
#define glDisable(T) rglDisable(S##T)
|
#define glDisable(T) rglDisable(S##T)
|
||||||
#define glEnable(T) rglEnable(S##T)
|
#define glEnable(T) rglEnable(S##T)
|
||||||
#define glIsEnabled(T) rglIsEnabled(S##T)
|
#define glIsEnabled(T) rglIsEnabled(S##T)
|
||||||
#define glUseProgram rglUseProgram
|
#define glUseProgram rglUseProgram
|
||||||
#define glDepthMask rglDepthMask
|
#define glDepthMask rglDepthMask
|
||||||
#define glStencilMask rglStencilMask
|
#define glStencilMask rglStencilMask
|
||||||
#define glBufferData rglBufferData
|
#define glBufferData rglBufferData
|
||||||
#define glBufferSubData rglBufferSubData
|
#define glBufferSubData rglBufferSubData
|
||||||
#define glBindBuffer rglBindBuffer
|
#define glBindBuffer rglBindBuffer
|
||||||
#define glCreateShader rglCreateShader
|
#define glCreateShader rglCreateShader
|
||||||
#define glDeleteShader rglDeleteShader
|
#define glDeleteShader rglDeleteShader
|
||||||
#define glDeleteProgram rglDeleteProgram
|
#define glDeleteProgram rglDeleteProgram
|
||||||
#define glUniform1f rglUniform1f
|
#define glUniform1f rglUniform1f
|
||||||
#define glUniform1i rglUniform1i
|
#define glUniform1i rglUniform1i
|
||||||
#define glUniform2f rglUniform2f
|
#define glUniform2f rglUniform2f
|
||||||
#define glUniform2i rglUniform2i
|
#define glUniform2i rglUniform2i
|
||||||
#define glUniform2fv rglUniform2fv
|
#define glUniform2fv rglUniform2fv
|
||||||
#define glUniform3f rglUniform3f
|
#define glUniform3f rglUniform3f
|
||||||
#define glUniform3fv rglUniform3fv
|
#define glUniform3fv rglUniform3fv
|
||||||
#define glUniform4f rglUniform4f
|
#define glUniform4f rglUniform4f
|
||||||
#define glUniform4fv rglUniform4fv
|
#define glUniform4fv rglUniform4fv
|
||||||
#define glBlendFunc rglBlendFunc
|
#define glBlendFunc rglBlendFunc
|
||||||
#define glBlendFuncSeparate rglBlendFuncSeparate
|
#define glBlendFuncSeparate rglBlendFuncSeparate
|
||||||
#define glDepthFunc rglDepthFunc
|
#define glDepthFunc rglDepthFunc
|
||||||
#define glColorMask rglColorMask
|
#define glColorMask rglColorMask
|
||||||
#define glClearColor rglClearColor
|
#define glClearColor rglClearColor
|
||||||
#define glViewport rglViewport
|
#define glViewport rglViewport
|
||||||
#define glScissor rglScissor
|
#define glScissor rglScissor
|
||||||
#define glStencilFunc rglStencilFunc
|
#define glStencilFunc rglStencilFunc
|
||||||
#define glCullFace rglCullFace
|
#define glCullFace rglCullFace
|
||||||
#define glStencilOp rglStencilOp
|
#define glStencilOp rglStencilOp
|
||||||
#define glFrontFace rglFrontFace
|
#define glFrontFace rglFrontFace
|
||||||
#define glDepthRange rglDepthRange
|
#define glDepthRange rglDepthRange
|
||||||
#define glClearDepth rglClearDepth
|
#define glClearDepth rglClearDepth
|
||||||
#define glPolygonOffset rglPolygonOffset
|
#define glPolygonOffset rglPolygonOffset
|
||||||
#define glPixelStorei rglPixelStorei
|
#define glPixelStorei rglPixelStorei
|
||||||
#define glReadBuffer rglReadBuffer
|
#define glReadBuffer rglReadBuffer
|
||||||
#define glUniformMatrix4fv rglUniformMatrix4fv
|
#define glUniformMatrix4fv rglUniformMatrix4fv
|
||||||
#define glGetAttribLocation rglGetAttribLocation
|
#define glGetAttribLocation rglGetAttribLocation
|
||||||
|
|
||||||
void rglReadBuffer(GLenum mode);
|
void rglReadBuffer(GLenum mode);
|
||||||
void rglPixelStorei(GLenum pname, GLint param);
|
void rglPixelStorei(GLenum pname, GLint param);
|
||||||
void rglTexCoord2f(GLfloat s, GLfloat t);
|
void rglTexCoord2f(GLfloat s, GLfloat t);
|
||||||
void rglDrawElements(GLenum mode, GLsizei count, GLenum type,
|
void rglDrawElements(GLenum mode, GLsizei count, GLenum type,
|
||||||
const GLvoid * indices);
|
const GLvoid * indices);
|
||||||
void rglCompressedTexImage2D(GLenum target, GLint level,
|
void rglCompressedTexImage2D(GLenum target, GLint level,
|
||||||
GLenum internalformat, GLsizei width, GLsizei height,
|
GLenum internalformat, GLsizei width, GLsizei height,
|
||||||
GLint border, GLsizei imageSize, const GLvoid *data);
|
GLint border, GLsizei imageSize, const GLvoid *data);
|
||||||
void glBindTexture(GLenum target, GLuint texture);
|
void glBindTexture(GLenum target, GLuint texture);
|
||||||
void glActiveTexture(GLenum texture);
|
void glActiveTexture(GLenum texture);
|
||||||
void rglFramebufferTexture2D(GLenum target, GLenum attachment,
|
void rglFramebufferTexture2D(GLenum target, GLenum attachment,
|
||||||
GLenum textarget, GLuint texture, GLint level);
|
GLenum textarget, GLuint texture, GLint level);
|
||||||
void rglFramebufferRenderbuffer(GLenum target, GLenum attachment,
|
void rglFramebufferRenderbuffer(GLenum target, GLenum attachment,
|
||||||
GLenum renderbuffertarget, GLuint renderbuffer);
|
GLenum renderbuffertarget, GLuint renderbuffer);
|
||||||
void rglDeleteFramebuffers(GLsizei n, GLuint *framebuffers);
|
void rglDeleteFramebuffers(GLsizei n, GLuint *framebuffers);
|
||||||
void rglRenderbufferStorage(GLenum target, GLenum internalFormat,
|
void rglRenderbufferStorage(GLenum target, GLenum internalFormat,
|
||||||
GLsizei width, GLsizei height);
|
GLsizei width, GLsizei height);
|
||||||
void rglDeleteTextures(GLsizei n, const GLuint *textures);
|
void rglDeleteTextures(GLsizei n, const GLuint *textures);
|
||||||
void rglBindRenderbuffer(GLenum target, GLuint renderbuffer);
|
void rglBindRenderbuffer(GLenum target, GLuint renderbuffer);
|
||||||
void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers);
|
void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers);
|
||||||
void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
|
void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers);
|
||||||
void rglGenFramebuffers(GLsizei n, GLuint *ids);
|
void rglGenFramebuffers(GLsizei n, GLuint *ids);
|
||||||
void rglGenTextures(GLsizei n, GLuint *textures);
|
void rglGenTextures(GLsizei n, GLuint *textures);
|
||||||
void rglBindFramebuffer(GLenum target, GLuint framebuffer);
|
void rglBindFramebuffer(GLenum target, GLuint framebuffer);
|
||||||
void rglGenerateMipmap(GLenum target);
|
void rglGenerateMipmap(GLenum target);
|
||||||
GLenum rglCheckFramebufferStatus(GLenum target);
|
GLenum rglCheckFramebufferStatus(GLenum target);
|
||||||
void rglBindFragDataLocation(GLuint program, GLuint colorNumber,
|
void rglBindFragDataLocation(GLuint program, GLuint colorNumber,
|
||||||
const char * name);
|
const char * name);
|
||||||
void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name);
|
void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name);
|
||||||
void rglLinkProgram(GLuint program);
|
void rglLinkProgram(GLuint program);
|
||||||
void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params);
|
void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params);
|
||||||
void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params);
|
void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params);
|
||||||
void rglAttachShader(GLuint program, GLuint shader);
|
void rglAttachShader(GLuint program, GLuint shader);
|
||||||
void rglShaderSource(GLuint shader, GLsizei count,
|
void rglShaderSource(GLuint shader, GLsizei count,
|
||||||
const GLchar **string, const GLint *length);
|
const GLchar **string, const GLint *length);
|
||||||
void rglCompileShader(GLuint shader);
|
void rglCompileShader(GLuint shader);
|
||||||
GLuint rglCreateProgram(void);
|
GLuint rglCreateProgram(void);
|
||||||
void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength,
|
void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength,
|
||||||
GLsizei *length, GLchar *infoLog);
|
GLsizei *length, GLchar *infoLog);
|
||||||
void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength,
|
void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength,
|
||||||
GLsizei *length, GLchar *infoLog);
|
GLsizei *length, GLchar *infoLog);
|
||||||
GLboolean rglIsProgram(GLuint program);
|
GLboolean rglIsProgram(GLuint program);
|
||||||
void rglEnableVertexAttribArray(GLuint index);
|
void rglEnableVertexAttribArray(GLuint index);
|
||||||
void rglDisableVertexAttribArray(GLuint index);
|
void rglDisableVertexAttribArray(GLuint index);
|
||||||
void rglVertexAttribPointer(GLuint name, GLint size,
|
void rglVertexAttribPointer(GLuint name, GLint size,
|
||||||
GLenum type, GLboolean normalized, GLsizei stride,
|
GLenum type, GLboolean normalized, GLsizei stride,
|
||||||
const GLvoid* pointer);
|
const GLvoid* pointer);
|
||||||
GLint rglGetUniformLocation(GLuint program, const GLchar *name);
|
GLint rglGetUniformLocation(GLuint program, const GLchar *name);
|
||||||
void rglGenBuffers(GLsizei n, GLuint *buffers);
|
void rglGenBuffers(GLsizei n, GLuint *buffers);
|
||||||
void rglDisable(GLenum cap);
|
void rglDisable(GLenum cap);
|
||||||
void rglEnable(GLenum cap);
|
void rglEnable(GLenum cap);
|
||||||
void rglUseProgram(GLuint program);
|
void rglUseProgram(GLuint program);
|
||||||
void rglDepthMask(GLboolean flag);
|
void rglDepthMask(GLboolean flag);
|
||||||
void rglStencilMask(GLenum mask);
|
void rglStencilMask(GLenum mask);
|
||||||
void rglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
|
void rglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||||
void rglBufferSubData(GLenum target, GLintptr offset,
|
void rglBufferSubData(GLenum target, GLintptr offset,
|
||||||
GLsizeiptr size, const GLvoid *data);
|
GLsizeiptr size, const GLvoid *data);
|
||||||
void rglBindBuffer(GLenum target, GLuint buffer);
|
void rglBindBuffer(GLenum target, GLuint buffer);
|
||||||
GLuint rglCreateShader(GLenum shader);
|
GLuint rglCreateShader(GLenum shader);
|
||||||
void rglDeleteShader(GLuint shader);
|
void rglDeleteShader(GLuint shader);
|
||||||
void rglUniform1f(GLint location, GLfloat v0);
|
void rglUniform1f(GLint location, GLfloat v0);
|
||||||
void rglUniform1i(GLint location, GLint v0);
|
void rglUniform1i(GLint location, GLint v0);
|
||||||
void rglUniform2f(GLint location, GLfloat v0, GLfloat v1);
|
void rglUniform2f(GLint location, GLfloat v0, GLfloat v1);
|
||||||
void rglUniform2i(GLint location, GLint v0, GLint v1);
|
void rglUniform2i(GLint location, GLint v0, GLint v1);
|
||||||
void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value);
|
void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value);
|
||||||
void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
|
||||||
void rglUniform3fv(GLint location, GLsizei count, const GLfloat *value);
|
void rglUniform3fv(GLint location, GLsizei count, const GLfloat *value);
|
||||||
void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||||
void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value);
|
void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value);
|
||||||
void rglBlendFunc(GLenum sfactor, GLenum dfactor);
|
void rglBlendFunc(GLenum sfactor, GLenum dfactor);
|
||||||
void rglBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
|
void rglBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha,
|
||||||
GLenum dstAlpha);
|
GLenum dstAlpha);
|
||||||
void rglDepthFunc(GLenum func);
|
void rglDepthFunc(GLenum func);
|
||||||
void rglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
void rglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
||||||
void rglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
void rglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||||
void rglViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
void rglViewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
void rglScissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
void rglScissor(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
GLboolean rglIsEnabled(GLenum cap);
|
GLboolean rglIsEnabled(GLenum cap);
|
||||||
void rglStencilFunc(GLenum func, GLint ref, GLuint mask);
|
void rglStencilFunc(GLenum func, GLint ref, GLuint mask);
|
||||||
void rglCullFace(GLenum mode);
|
void rglCullFace(GLenum mode);
|
||||||
void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||||
void rglFrontFace(GLenum mode);
|
void rglFrontFace(GLenum mode);
|
||||||
void rglDepthRange(GLclampd zNear, GLclampd zFar);
|
void rglDepthRange(GLclampd zNear, GLclampd zFar);
|
||||||
void rglClearDepth(GLdouble depth);
|
void rglClearDepth(GLdouble depth);
|
||||||
void rglPolygonOffset(GLfloat factor, GLfloat units);
|
void rglPolygonOffset(GLfloat factor, GLfloat units);
|
||||||
void rglDrawArrays(GLenum mode, GLint first, GLsizei count);
|
void rglDrawArrays(GLenum mode, GLint first, GLsizei count);
|
||||||
void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y,
|
void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y,
|
||||||
GLfloat z, GLfloat w);
|
GLfloat z, GLfloat w);
|
||||||
void rglVertexAttrib4fv(GLuint name, GLfloat* v);
|
void rglVertexAttrib4fv(GLuint name, GLfloat* v);
|
||||||
void rglDeleteProgram(GLuint program);
|
void rglDeleteProgram(GLuint program);
|
||||||
void rglDeleteBuffers(GLsizei n, const GLuint *buffers);
|
void rglDeleteBuffers(GLsizei n, const GLuint *buffers);
|
||||||
void rglBlitFramebuffer(
|
void rglBlitFramebuffer(
|
||||||
GLint srcX0, GLint srcY0,
|
GLint srcX0, GLint srcY0,
|
||||||
GLint srcX1, GLint srcY1,
|
GLint srcX1, GLint srcY1,
|
||||||
GLint dstX0, GLint dstY0,
|
GLint dstX0, GLint dstY0,
|
||||||
GLint dstX1, GLint dstY1,
|
GLint dstX1, GLint dstY1,
|
||||||
GLbitfield mask, GLenum filter);
|
GLbitfield mask, GLenum filter);
|
||||||
void rglDetachShader(GLuint program, GLuint shader);
|
void rglDetachShader(GLuint program, GLuint shader);
|
||||||
void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
|
void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
|
||||||
const GLfloat *value);
|
const GLfloat *value);
|
||||||
GLint rglGetAttribLocation(GLuint program, const GLchar *name);
|
GLint rglGetAttribLocation(GLuint program, const GLchar *name);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,37 +1,37 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_GLSYM_H__
|
#ifndef __LIBRETRO_SDK_GLSYM_H__
|
||||||
#define __LIBRETRO_SDK_GLSYM_H__
|
#define __LIBRETRO_SDK_GLSYM_H__
|
||||||
|
|
||||||
#include "rglgen.h"
|
#include "rglgen.h"
|
||||||
|
|
||||||
#ifndef HAVE_PSGL
|
#ifndef HAVE_PSGL
|
||||||
#ifdef HAVE_OPENGLES2
|
#ifdef HAVE_OPENGLES2
|
||||||
#include "glsym_es2.h"
|
#include "glsym_es2.h"
|
||||||
#else
|
#else
|
||||||
#include "glsym_gl.h"
|
#include "glsym_gl.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,145 +1,145 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RGLGEN_DECL_H__
|
#ifndef RGLGEN_DECL_H__
|
||||||
#define RGLGEN_DECL_H__
|
#define RGLGEN_DECL_H__
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#ifdef GL_APIENTRY
|
#ifdef GL_APIENTRY
|
||||||
typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
||||||
typedef void (GL_APIENTRY *RGLGENGLDEBUGPROCKHR)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
typedef void (GL_APIENTRY *RGLGENGLDEBUGPROCKHR)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
||||||
#else
|
#else
|
||||||
#ifndef APIENTRY
|
#ifndef APIENTRY
|
||||||
#define APIENTRY
|
#define APIENTRY
|
||||||
#endif
|
#endif
|
||||||
#ifndef APIENTRYP
|
#ifndef APIENTRYP
|
||||||
#define APIENTRYP APIENTRY *
|
#define APIENTRYP APIENTRY *
|
||||||
#endif
|
#endif
|
||||||
typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
||||||
typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*);
|
||||||
#endif
|
#endif
|
||||||
#ifndef GL_OES_EGL_image
|
#ifndef GL_OES_EGL_image
|
||||||
typedef void *GLeglImageOES;
|
typedef void *GLeglImageOES;
|
||||||
#endif
|
#endif
|
||||||
#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2)
|
#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2)
|
||||||
typedef GLint GLfixed;
|
typedef GLint GLfixed;
|
||||||
#endif
|
#endif
|
||||||
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7)
|
#if defined(OSX) && !defined(MAC_OS_X_VERSION_10_7)
|
||||||
typedef long long int GLint64;
|
typedef long long int GLint64;
|
||||||
typedef unsigned long long int GLuint64;
|
typedef unsigned long long int GLuint64;
|
||||||
typedef unsigned long long int GLuint64EXT;
|
typedef unsigned long long int GLuint64EXT;
|
||||||
typedef struct __GLsync *GLsync;
|
typedef struct __GLsync *GLsync;
|
||||||
#endif
|
#endif
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC) (RGLGENGLDEBUGPROCKHR callback, const void *userParam);
|
typedef void (GL_APIENTRYP RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC) (RGLGENGLDEBUGPROCKHR callback, const void *userParam);
|
||||||
typedef GLuint (GL_APIENTRYP RGLSYMGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
typedef GLuint (GL_APIENTRYP RGLSYMGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
|
typedef void (GL_APIENTRYP RGLSYMGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLPOPDEBUGGROUPKHRPROC) (void);
|
typedef void (GL_APIENTRYP RGLSYMGLPOPDEBUGGROUPKHRPROC) (void);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
|
typedef void (GL_APIENTRYP RGLSYMGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
|
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
|
typedef void (GL_APIENTRYP RGLSYMGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
|
typedef void (GL_APIENTRYP RGLSYMGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
|
typedef void (GL_APIENTRYP RGLSYMGLGETPOINTERVKHRPROC) (GLenum pname, void **params);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
|
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
|
typedef void (GL_APIENTRYP RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
|
typedef void (GL_APIENTRYP RGLSYMGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
|
typedef void (GL_APIENTRYP RGLSYMGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length);
|
||||||
typedef void *(GL_APIENTRYP RGLSYMGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
|
typedef void *(GL_APIENTRYP RGLSYMGLMAPBUFFEROESPROC) (GLenum target, GLenum access);
|
||||||
typedef GLboolean (GL_APIENTRYP RGLSYMGLUNMAPBUFFEROESPROC) (GLenum target);
|
typedef GLboolean (GL_APIENTRYP RGLSYMGLUNMAPBUFFEROESPROC) (GLenum target);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params);
|
typedef void (GL_APIENTRYP RGLSYMGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
|
typedef void (GL_APIENTRYP RGLSYMGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
|
typedef void (GL_APIENTRYP RGLSYMGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
typedef void (GL_APIENTRYP RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
|
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
|
typedef void (GL_APIENTRYP RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
|
typedef void (GL_APIENTRYP RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLBINDVERTEXARRAYOESPROC) (GLuint array);
|
typedef void (GL_APIENTRYP RGLSYMGLBINDVERTEXARRAYOESPROC) (GLuint array);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
|
typedef void (GL_APIENTRYP RGLSYMGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays);
|
||||||
typedef void (GL_APIENTRYP RGLSYMGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
|
typedef void (GL_APIENTRYP RGLSYMGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays);
|
||||||
typedef GLboolean (GL_APIENTRYP RGLSYMGLISVERTEXARRAYOESPROC) (GLuint array);
|
typedef GLboolean (GL_APIENTRYP RGLSYMGLISVERTEXARRAYOESPROC) (GLuint array);
|
||||||
|
|
||||||
#define glDebugMessageControlKHR __rglgen_glDebugMessageControlKHR
|
#define glDebugMessageControlKHR __rglgen_glDebugMessageControlKHR
|
||||||
#define glDebugMessageInsertKHR __rglgen_glDebugMessageInsertKHR
|
#define glDebugMessageInsertKHR __rglgen_glDebugMessageInsertKHR
|
||||||
#define glDebugMessageCallbackKHR __rglgen_glDebugMessageCallbackKHR
|
#define glDebugMessageCallbackKHR __rglgen_glDebugMessageCallbackKHR
|
||||||
#define glGetDebugMessageLogKHR __rglgen_glGetDebugMessageLogKHR
|
#define glGetDebugMessageLogKHR __rglgen_glGetDebugMessageLogKHR
|
||||||
#define glPushDebugGroupKHR __rglgen_glPushDebugGroupKHR
|
#define glPushDebugGroupKHR __rglgen_glPushDebugGroupKHR
|
||||||
#define glPopDebugGroupKHR __rglgen_glPopDebugGroupKHR
|
#define glPopDebugGroupKHR __rglgen_glPopDebugGroupKHR
|
||||||
#define glObjectLabelKHR __rglgen_glObjectLabelKHR
|
#define glObjectLabelKHR __rglgen_glObjectLabelKHR
|
||||||
#define glGetObjectLabelKHR __rglgen_glGetObjectLabelKHR
|
#define glGetObjectLabelKHR __rglgen_glGetObjectLabelKHR
|
||||||
#define glObjectPtrLabelKHR __rglgen_glObjectPtrLabelKHR
|
#define glObjectPtrLabelKHR __rglgen_glObjectPtrLabelKHR
|
||||||
#define glGetObjectPtrLabelKHR __rglgen_glGetObjectPtrLabelKHR
|
#define glGetObjectPtrLabelKHR __rglgen_glGetObjectPtrLabelKHR
|
||||||
#define glGetPointervKHR __rglgen_glGetPointervKHR
|
#define glGetPointervKHR __rglgen_glGetPointervKHR
|
||||||
#define glEGLImageTargetTexture2DOES __rglgen_glEGLImageTargetTexture2DOES
|
#define glEGLImageTargetTexture2DOES __rglgen_glEGLImageTargetTexture2DOES
|
||||||
#define glEGLImageTargetRenderbufferStorageOES __rglgen_glEGLImageTargetRenderbufferStorageOES
|
#define glEGLImageTargetRenderbufferStorageOES __rglgen_glEGLImageTargetRenderbufferStorageOES
|
||||||
#define glGetProgramBinaryOES __rglgen_glGetProgramBinaryOES
|
#define glGetProgramBinaryOES __rglgen_glGetProgramBinaryOES
|
||||||
#define glProgramBinaryOES __rglgen_glProgramBinaryOES
|
#define glProgramBinaryOES __rglgen_glProgramBinaryOES
|
||||||
#define glMapBufferOES __rglgen_glMapBufferOES
|
#define glMapBufferOES __rglgen_glMapBufferOES
|
||||||
#define glUnmapBufferOES __rglgen_glUnmapBufferOES
|
#define glUnmapBufferOES __rglgen_glUnmapBufferOES
|
||||||
#define glGetBufferPointervOES __rglgen_glGetBufferPointervOES
|
#define glGetBufferPointervOES __rglgen_glGetBufferPointervOES
|
||||||
#define glTexImage3DOES __rglgen_glTexImage3DOES
|
#define glTexImage3DOES __rglgen_glTexImage3DOES
|
||||||
#define glTexSubImage3DOES __rglgen_glTexSubImage3DOES
|
#define glTexSubImage3DOES __rglgen_glTexSubImage3DOES
|
||||||
#define glCopyTexSubImage3DOES __rglgen_glCopyTexSubImage3DOES
|
#define glCopyTexSubImage3DOES __rglgen_glCopyTexSubImage3DOES
|
||||||
#define glCompressedTexImage3DOES __rglgen_glCompressedTexImage3DOES
|
#define glCompressedTexImage3DOES __rglgen_glCompressedTexImage3DOES
|
||||||
#define glCompressedTexSubImage3DOES __rglgen_glCompressedTexSubImage3DOES
|
#define glCompressedTexSubImage3DOES __rglgen_glCompressedTexSubImage3DOES
|
||||||
#define glFramebufferTexture3DOES __rglgen_glFramebufferTexture3DOES
|
#define glFramebufferTexture3DOES __rglgen_glFramebufferTexture3DOES
|
||||||
#define glBindVertexArrayOES __rglgen_glBindVertexArrayOES
|
#define glBindVertexArrayOES __rglgen_glBindVertexArrayOES
|
||||||
#define glDeleteVertexArraysOES __rglgen_glDeleteVertexArraysOES
|
#define glDeleteVertexArraysOES __rglgen_glDeleteVertexArraysOES
|
||||||
#define glGenVertexArraysOES __rglgen_glGenVertexArraysOES
|
#define glGenVertexArraysOES __rglgen_glGenVertexArraysOES
|
||||||
#define glIsVertexArrayOES __rglgen_glIsVertexArrayOES
|
#define glIsVertexArrayOES __rglgen_glIsVertexArrayOES
|
||||||
|
|
||||||
extern RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
|
extern RGLSYMGLDEBUGMESSAGECONTROLKHRPROC __rglgen_glDebugMessageControlKHR;
|
||||||
extern RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
|
extern RGLSYMGLDEBUGMESSAGEINSERTKHRPROC __rglgen_glDebugMessageInsertKHR;
|
||||||
extern RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
|
extern RGLSYMGLDEBUGMESSAGECALLBACKKHRPROC __rglgen_glDebugMessageCallbackKHR;
|
||||||
extern RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
|
extern RGLSYMGLGETDEBUGMESSAGELOGKHRPROC __rglgen_glGetDebugMessageLogKHR;
|
||||||
extern RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
|
extern RGLSYMGLPUSHDEBUGGROUPKHRPROC __rglgen_glPushDebugGroupKHR;
|
||||||
extern RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
|
extern RGLSYMGLPOPDEBUGGROUPKHRPROC __rglgen_glPopDebugGroupKHR;
|
||||||
extern RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
|
extern RGLSYMGLOBJECTLABELKHRPROC __rglgen_glObjectLabelKHR;
|
||||||
extern RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
|
extern RGLSYMGLGETOBJECTLABELKHRPROC __rglgen_glGetObjectLabelKHR;
|
||||||
extern RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
|
extern RGLSYMGLOBJECTPTRLABELKHRPROC __rglgen_glObjectPtrLabelKHR;
|
||||||
extern RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
|
extern RGLSYMGLGETOBJECTPTRLABELKHRPROC __rglgen_glGetObjectPtrLabelKHR;
|
||||||
extern RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
|
extern RGLSYMGLGETPOINTERVKHRPROC __rglgen_glGetPointervKHR;
|
||||||
extern RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
extern RGLSYMGLEGLIMAGETARGETTEXTURE2DOESPROC __rglgen_glEGLImageTargetTexture2DOES;
|
||||||
extern RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
extern RGLSYMGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC __rglgen_glEGLImageTargetRenderbufferStorageOES;
|
||||||
extern RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
extern RGLSYMGLGETPROGRAMBINARYOESPROC __rglgen_glGetProgramBinaryOES;
|
||||||
extern RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
extern RGLSYMGLPROGRAMBINARYOESPROC __rglgen_glProgramBinaryOES;
|
||||||
extern RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
extern RGLSYMGLMAPBUFFEROESPROC __rglgen_glMapBufferOES;
|
||||||
extern RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
extern RGLSYMGLUNMAPBUFFEROESPROC __rglgen_glUnmapBufferOES;
|
||||||
extern RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
extern RGLSYMGLGETBUFFERPOINTERVOESPROC __rglgen_glGetBufferPointervOES;
|
||||||
extern RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
extern RGLSYMGLTEXIMAGE3DOESPROC __rglgen_glTexImage3DOES;
|
||||||
extern RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
extern RGLSYMGLTEXSUBIMAGE3DOESPROC __rglgen_glTexSubImage3DOES;
|
||||||
extern RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
extern RGLSYMGLCOPYTEXSUBIMAGE3DOESPROC __rglgen_glCopyTexSubImage3DOES;
|
||||||
extern RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
extern RGLSYMGLCOMPRESSEDTEXIMAGE3DOESPROC __rglgen_glCompressedTexImage3DOES;
|
||||||
extern RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
extern RGLSYMGLCOMPRESSEDTEXSUBIMAGE3DOESPROC __rglgen_glCompressedTexSubImage3DOES;
|
||||||
extern RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
extern RGLSYMGLFRAMEBUFFERTEXTURE3DOESPROC __rglgen_glFramebufferTexture3DOES;
|
||||||
extern RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
extern RGLSYMGLBINDVERTEXARRAYOESPROC __rglgen_glBindVertexArrayOES;
|
||||||
extern RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
extern RGLSYMGLDELETEVERTEXARRAYSOESPROC __rglgen_glDeleteVertexArraysOES;
|
||||||
extern RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
extern RGLSYMGLGENVERTEXARRAYSOESPROC __rglgen_glGenVertexArraysOES;
|
||||||
extern RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
extern RGLSYMGLISVERTEXARRAYOESPROC __rglgen_glIsVertexArrayOES;
|
||||||
|
|
||||||
struct rglgen_sym_map { const char *sym; void *ptr; };
|
struct rglgen_sym_map { const char *sym; void *ptr; };
|
||||||
extern const struct rglgen_sym_map rglgen_symbol_map[];
|
extern const struct rglgen_sym_map rglgen_symbol_map[];
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,49 +1,49 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RGLGEN_H__
|
#ifndef RGLGEN_H__
|
||||||
#define RGLGEN_H__
|
#define RGLGEN_H__
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "rglgen_headers.h"
|
#include "rglgen_headers.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct rglgen_sym_map;
|
struct rglgen_sym_map;
|
||||||
|
|
||||||
typedef void (*rglgen_func_t)(void);
|
typedef void (*rglgen_func_t)(void);
|
||||||
typedef rglgen_func_t (*rglgen_proc_address_t)(const char*);
|
typedef rglgen_func_t (*rglgen_proc_address_t)(const char*);
|
||||||
void rglgen_resolve_symbols(rglgen_proc_address_t proc);
|
void rglgen_resolve_symbols(rglgen_proc_address_t proc);
|
||||||
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
void rglgen_resolve_symbols_custom(rglgen_proc_address_t proc,
|
||||||
const struct rglgen_sym_map *map);
|
const struct rglgen_sym_map *map);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,80 +1,80 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this libretro SDK code part (glsym).
|
* The following license statement only applies to this libretro SDK code part (glsym).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RGLGEN_HEADERS_H__
|
#ifndef RGLGEN_HEADERS_H__
|
||||||
#define RGLGEN_HEADERS_H__
|
#define RGLGEN_HEADERS_H__
|
||||||
|
|
||||||
#ifdef HAVE_EGL
|
#ifdef HAVE_EGL
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <EGL/eglext.h>
|
#include <EGL/eglext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(IOS)
|
#if defined(IOS)
|
||||||
|
|
||||||
#if defined(HAVE_OPENGLES3)
|
#if defined(HAVE_OPENGLES3)
|
||||||
#include <OpenGLES/ES3/gl.h>
|
#include <OpenGLES/ES3/gl.h>
|
||||||
#include <OpenGLES/ES3/glext.h>
|
#include <OpenGLES/ES3/glext.h>
|
||||||
#else
|
#else
|
||||||
#include <OpenGLES/ES2/gl.h>
|
#include <OpenGLES/ES2/gl.h>
|
||||||
#include <OpenGLES/ES2/glext.h>
|
#include <OpenGLES/ES2/glext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
#include <OpenGL/glext.h>
|
#include <OpenGL/glext.h>
|
||||||
#elif defined(HAVE_PSGL)
|
#elif defined(HAVE_PSGL)
|
||||||
#include <PSGL/psgl.h>
|
#include <PSGL/psgl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
#elif defined(HAVE_OPENGL_MODERN)
|
#elif defined(HAVE_OPENGL_MODERN)
|
||||||
#include <GL3/gl3.h>
|
#include <GL3/gl3.h>
|
||||||
#include <GL3/gl3ext.h>
|
#include <GL3/gl3ext.h>
|
||||||
#elif defined(HAVE_OPENGLES3)
|
#elif defined(HAVE_OPENGLES3)
|
||||||
#include <GLES3/gl3.h>
|
#include <GLES3/gl3.h>
|
||||||
#include <GLES2/gl2ext.h> /* There are no GLES3 extensions yet. */
|
#include <GLES2/gl2ext.h> /* There are no GLES3 extensions yet. */
|
||||||
#elif defined(HAVE_OPENGLES2)
|
#elif defined(HAVE_OPENGLES2)
|
||||||
#include <GLES2/gl2.h>
|
#include <GLES2/gl2.h>
|
||||||
#include <GLES2/gl2ext.h>
|
#include <GLES2/gl2ext.h>
|
||||||
#elif defined(HAVE_OPENGLES1)
|
#elif defined(HAVE_OPENGLES1)
|
||||||
#include <GLES/gl.h>
|
#include <GLES/gl.h>
|
||||||
#include <GLES/glext.h>
|
#include <GLES/glext.h>
|
||||||
#else
|
#else
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
#include <GL/glext.h>
|
#include <GL/glext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_MAP_WRITE_BIT
|
#ifndef GL_MAP_WRITE_BIT
|
||||||
#define GL_MAP_WRITE_BIT 0x0002
|
#define GL_MAP_WRITE_BIT 0x0002
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_MAP_INVALIDATE_BUFFER_BIT
|
#ifndef GL_MAP_INVALIDATE_BUFFER_BIT
|
||||||
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
|
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GL_RED_INTEGER
|
#ifndef GL_RED_INTEGER
|
||||||
#define GL_RED_INTEGER 0x8D94
|
#define GL_RED_INTEGER 0x8D94
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,81 +1,81 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (libco.h).
|
* The following license statement only applies to this file (libco.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBCO_H
|
#ifndef LIBCO_H
|
||||||
#define LIBCO_H
|
#define LIBCO_H
|
||||||
|
|
||||||
#ifdef LIBCO_C
|
#ifdef LIBCO_C
|
||||||
#ifdef LIBCO_MP
|
#ifdef LIBCO_MP
|
||||||
#define thread_local __thread
|
#define thread_local __thread
|
||||||
#else
|
#else
|
||||||
#define thread_local
|
#define thread_local
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef void* cothread_t;
|
typedef void* cothread_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* co_active:
|
* co_active:
|
||||||
*
|
*
|
||||||
* Gets the currently active context.
|
* Gets the currently active context.
|
||||||
*
|
*
|
||||||
* Returns: active context.
|
* Returns: active context.
|
||||||
**/
|
**/
|
||||||
cothread_t co_active(void);
|
cothread_t co_active(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* co_create:
|
* co_create:
|
||||||
* @int : stack size
|
* @int : stack size
|
||||||
* @funcptr : thread entry function callback
|
* @funcptr : thread entry function callback
|
||||||
*
|
*
|
||||||
* Create a co_thread.
|
* Create a co_thread.
|
||||||
*
|
*
|
||||||
* Returns: cothread if successful, otherwise NULL.
|
* Returns: cothread if successful, otherwise NULL.
|
||||||
*/
|
*/
|
||||||
cothread_t co_create(unsigned int, void (*)(void));
|
cothread_t co_create(unsigned int, void (*)(void));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* co_delete:
|
* co_delete:
|
||||||
* @cothread : cothread object
|
* @cothread : cothread object
|
||||||
*
|
*
|
||||||
* Frees a co_thread.
|
* Frees a co_thread.
|
||||||
*/
|
*/
|
||||||
void co_delete(cothread_t cothread);
|
void co_delete(cothread_t cothread);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* co_switch:
|
* co_switch:
|
||||||
* @cothread : cothread object to switch to
|
* @cothread : cothread object to switch to
|
||||||
*
|
*
|
||||||
* Do a context switch to @cothread.
|
* Do a context switch to @cothread.
|
||||||
*/
|
*/
|
||||||
void co_switch(cothread_t cothread);
|
void co_switch(cothread_t cothread);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ifndef LIBCO_H */
|
/* ifndef LIBCO_H */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (dir_list.h).
|
* The following license statement only applies to this file (dir_list.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_DIR_LIST_H
|
#ifndef __LIBRETRO_SDK_DIR_LIST_H
|
||||||
#define __LIBRETRO_SDK_DIR_LIST_H
|
#define __LIBRETRO_SDK_DIR_LIST_H
|
||||||
|
|
||||||
#include <string/string_list.h>
|
#include <lists/string_list.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dir_list_new:
|
* dir_list_new:
|
||||||
* @dir : directory path.
|
* @dir : directory path.
|
||||||
* @ext : allowed extensions of file directory entries to include.
|
* @ext : allowed extensions of file directory entries to include.
|
||||||
* @include_dirs : include directories as part of the finished directory listing?
|
* @include_dirs : include directories as part of the finished directory listing?
|
||||||
* @include_compressed : include compressed files, even when not part of ext.
|
* @include_compressed : include compressed files, even when not part of ext.
|
||||||
*
|
*
|
||||||
* Create a directory listing.
|
* Create a directory listing.
|
||||||
*
|
*
|
||||||
* Returns: pointer to a directory listing of type 'struct string_list *' on success,
|
* Returns: pointer to a directory listing of type 'struct string_list *' on success,
|
||||||
* NULL in case of error. Has to be freed manually.
|
* NULL in case of error. Has to be freed manually.
|
||||||
**/
|
**/
|
||||||
struct string_list *dir_list_new(const char *dir, const char *ext,
|
struct string_list *dir_list_new(const char *dir, const char *ext,
|
||||||
bool include_dirs, bool include_compressed);
|
bool include_dirs, bool include_compressed);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dir_list_sort:
|
* dir_list_sort:
|
||||||
* @list : pointer to the directory listing.
|
* @list : pointer to the directory listing.
|
||||||
* @dir_first : move the directories in the listing to the top?
|
* @dir_first : move the directories in the listing to the top?
|
||||||
*
|
*
|
||||||
* Sorts a directory listing.
|
* Sorts a directory listing.
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
void dir_list_sort(struct string_list *list, bool dir_first);
|
void dir_list_sort(struct string_list *list, bool dir_first);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dir_list_free:
|
* dir_list_free:
|
||||||
* @list : pointer to the directory listing
|
* @list : pointer to the directory listing
|
||||||
*
|
*
|
||||||
* Frees a directory listing.
|
* Frees a directory listing.
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
void dir_list_free(struct string_list *list);
|
void dir_list_free(struct string_list *list);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,121 +1,119 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (file_list.h).
|
* The following license statement only applies to this file (file_list.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FILE_LIST_H__
|
#ifndef __LIBRETRO_SDK_FILE_LIST_H__
|
||||||
#define __LIBRETRO_SDK_FILE_LIST_H__
|
#define __LIBRETRO_SDK_FILE_LIST_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
struct item_file
|
struct item_file
|
||||||
{
|
{
|
||||||
char *path;
|
char *path;
|
||||||
char *label;
|
char *label;
|
||||||
char *alt;
|
char *alt;
|
||||||
unsigned type;
|
unsigned type;
|
||||||
size_t directory_ptr;
|
size_t directory_ptr;
|
||||||
size_t entry_idx;
|
size_t entry_idx;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
void *actiondata;
|
void *actiondata;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct file_list
|
typedef struct file_list
|
||||||
{
|
{
|
||||||
struct item_file *list;
|
struct item_file *list;
|
||||||
|
|
||||||
size_t capacity;
|
size_t capacity;
|
||||||
size_t size;
|
size_t size;
|
||||||
} file_list_t;
|
} file_list_t;
|
||||||
|
|
||||||
|
|
||||||
void *file_list_get_userdata_at_offset(const file_list_t *list,
|
void *file_list_get_userdata_at_offset(const file_list_t *list,
|
||||||
size_t index);
|
size_t index);
|
||||||
|
|
||||||
void *file_list_get_actiondata_at_offset(const file_list_t *list,
|
void *file_list_get_actiondata_at_offset(const file_list_t *list,
|
||||||
size_t index);
|
size_t index);
|
||||||
|
|
||||||
void file_list_free(file_list_t *list);
|
void file_list_free(file_list_t *list);
|
||||||
|
|
||||||
void file_list_push(file_list_t *userdata, const char *path,
|
bool file_list_push(file_list_t *userdata, const char *path,
|
||||||
const char *label, unsigned type, size_t current_directory_ptr,
|
const char *label, unsigned type, size_t current_directory_ptr,
|
||||||
size_t entry_index);
|
size_t entry_index);
|
||||||
|
|
||||||
void file_list_pop(file_list_t *list, size_t *directory_ptr);
|
void file_list_pop(file_list_t *list, size_t *directory_ptr);
|
||||||
|
|
||||||
void file_list_clear(file_list_t *list);
|
void file_list_clear(file_list_t *list);
|
||||||
|
|
||||||
void file_list_copy(const file_list_t *src, file_list_t *dst);
|
void file_list_copy(const file_list_t *src, file_list_t *dst);
|
||||||
|
|
||||||
void file_list_get_last(const file_list_t *list,
|
void file_list_get_last(const file_list_t *list,
|
||||||
const char **path, const char **label,
|
const char **path, const char **label,
|
||||||
unsigned *type, size_t *entry_idx);
|
unsigned *type, size_t *entry_idx);
|
||||||
|
|
||||||
void *file_list_get_last_actiondata(const file_list_t *list);
|
void *file_list_get_last_actiondata(const file_list_t *list);
|
||||||
|
|
||||||
size_t file_list_get_size(const file_list_t *list);
|
size_t file_list_get_size(const file_list_t *list);
|
||||||
|
|
||||||
size_t file_list_get_entry_index(const file_list_t *list);
|
size_t file_list_get_directory_ptr(const file_list_t *list);
|
||||||
|
|
||||||
size_t file_list_get_directory_ptr(const file_list_t *list);
|
void file_list_get_at_offset(const file_list_t *list, size_t index,
|
||||||
|
const char **path, const char **label,
|
||||||
void file_list_get_at_offset(const file_list_t *list, size_t index,
|
unsigned *type, size_t *entry_idx);
|
||||||
const char **path, const char **label,
|
|
||||||
unsigned *type, size_t *entry_idx);
|
void file_list_free_userdata(const file_list_t *list, size_t index);
|
||||||
|
|
||||||
void file_list_free_userdata(const file_list_t *list, size_t index);
|
void file_list_free_actiondata(const file_list_t *list, size_t idx);
|
||||||
|
|
||||||
void file_list_free_actiondata(const file_list_t *list, size_t idx);
|
void file_list_set_label_at_offset(file_list_t *list, size_t index,
|
||||||
|
const char *label);
|
||||||
void file_list_set_label_at_offset(file_list_t *list, size_t index,
|
|
||||||
const char *label);
|
void file_list_get_label_at_offset(const file_list_t *list, size_t index,
|
||||||
|
const char **label);
|
||||||
void file_list_get_label_at_offset(const file_list_t *list, size_t index,
|
|
||||||
const char **label);
|
void file_list_set_alt_at_offset(file_list_t *list, size_t index,
|
||||||
|
const char *alt);
|
||||||
void file_list_set_alt_at_offset(file_list_t *list, size_t index,
|
|
||||||
const char *alt);
|
void file_list_set_userdata(const file_list_t *list, size_t idx, void *ptr);
|
||||||
|
|
||||||
void file_list_set_userdata(const file_list_t *list, size_t idx, void *ptr);
|
void file_list_set_actiondata(const file_list_t *list, size_t idx, void *ptr);
|
||||||
|
|
||||||
void file_list_set_actiondata(const file_list_t *list, size_t idx, void *ptr);
|
void file_list_get_alt_at_offset(const file_list_t *list, size_t index,
|
||||||
|
const char **alt);
|
||||||
void file_list_get_alt_at_offset(const file_list_t *list, size_t index,
|
|
||||||
const char **alt);
|
void file_list_sort_on_alt(file_list_t *list);
|
||||||
|
|
||||||
void file_list_sort_on_alt(file_list_t *list);
|
void file_list_sort_on_type(file_list_t *list);
|
||||||
|
|
||||||
void file_list_sort_on_type(file_list_t *list);
|
bool file_list_search(const file_list_t *list, const char *needle,
|
||||||
|
size_t *index);
|
||||||
bool file_list_search(const file_list_t *list, const char *needle,
|
|
||||||
size_t *index);
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
#ifdef __cplusplus
|
#endif
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,148 +1,148 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (string_list.h).
|
* The following license statement only applies to this file (string_list.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_STRING_LIST_H
|
#ifndef __LIBRETRO_SDK_STRING_LIST_H
|
||||||
#define __LIBRETRO_SDK_STRING_LIST_H
|
#define __LIBRETRO_SDK_STRING_LIST_H
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
union string_list_elem_attr
|
union string_list_elem_attr
|
||||||
{
|
{
|
||||||
bool b;
|
bool b;
|
||||||
int i;
|
int i;
|
||||||
void *p;
|
void *p;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct string_list_elem
|
struct string_list_elem
|
||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
union string_list_elem_attr attr;
|
union string_list_elem_attr attr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct string_list
|
struct string_list
|
||||||
{
|
{
|
||||||
struct string_list_elem *elems;
|
struct string_list_elem *elems;
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t cap;
|
size_t cap;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_find_elem:
|
* string_list_find_elem:
|
||||||
* @list : pointer to string list
|
* @list : pointer to string list
|
||||||
* @elem : element to find inside the string list.
|
* @elem : element to find inside the string list.
|
||||||
*
|
*
|
||||||
* Searches for an element (@elem) inside the string list.
|
* Searches for an element (@elem) inside the string list.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if element could be found, otherwise false (0).
|
* Returns: true (1) if element could be found, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
int string_list_find_elem(const struct string_list *list, const char *elem);
|
int string_list_find_elem(const struct string_list *list, const char *elem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_find_elem_prefix:
|
* string_list_find_elem_prefix:
|
||||||
* @list : pointer to string list
|
* @list : pointer to string list
|
||||||
* @prefix : prefix to append to @elem
|
* @prefix : prefix to append to @elem
|
||||||
* @elem : element to find inside the string list.
|
* @elem : element to find inside the string list.
|
||||||
*
|
*
|
||||||
* Searches for an element (@elem) inside the string list. Will
|
* Searches for an element (@elem) inside the string list. Will
|
||||||
* also search for the same element prefixed by @prefix.
|
* also search for the same element prefixed by @prefix.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if element could be found, otherwise false (0).
|
* Returns: true (1) if element could be found, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
bool string_list_find_elem_prefix(const struct string_list *list,
|
bool string_list_find_elem_prefix(const struct string_list *list,
|
||||||
const char *prefix, const char *elem);
|
const char *prefix, const char *elem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_split:
|
* string_split:
|
||||||
* @str : string to turn into a string list
|
* @str : string to turn into a string list
|
||||||
* @delim : delimiter character to use for splitting the string.
|
* @delim : delimiter character to use for splitting the string.
|
||||||
*
|
*
|
||||||
* Creates a new string list based on string @str, delimited by @delim.
|
* Creates a new string list based on string @str, delimited by @delim.
|
||||||
*
|
*
|
||||||
* Returns: new string list if successful, otherwise NULL.
|
* Returns: new string list if successful, otherwise NULL.
|
||||||
*/
|
*/
|
||||||
struct string_list *string_split(const char *str, const char *delim);
|
struct string_list *string_split(const char *str, const char *delim);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_new:
|
* string_list_new:
|
||||||
*
|
*
|
||||||
* Creates a new string list. Has to be freed manually.
|
* Creates a new string list. Has to be freed manually.
|
||||||
*
|
*
|
||||||
* Returns: new string list if successful, otherwise NULL.
|
* Returns: new string list if successful, otherwise NULL.
|
||||||
*/
|
*/
|
||||||
struct string_list *string_list_new(void);
|
struct string_list *string_list_new(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_append:
|
* string_list_append:
|
||||||
* @list : pointer to string list
|
* @list : pointer to string list
|
||||||
* @elem : element to add to the string list
|
* @elem : element to add to the string list
|
||||||
* @attr : attributes of new element.
|
* @attr : attributes of new element.
|
||||||
*
|
*
|
||||||
* Appends a new element to the string list.
|
* Appends a new element to the string list.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool string_list_append(struct string_list *list, const char *elem,
|
bool string_list_append(struct string_list *list, const char *elem,
|
||||||
union string_list_elem_attr attr);
|
union string_list_elem_attr attr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_free
|
* string_list_free
|
||||||
* @list : pointer to string list object
|
* @list : pointer to string list object
|
||||||
*
|
*
|
||||||
* Frees a string list.
|
* Frees a string list.
|
||||||
*/
|
*/
|
||||||
void string_list_free(struct string_list *list);
|
void string_list_free(struct string_list *list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_join_concat:
|
* string_list_join_concat:
|
||||||
* @buffer : buffer that @list will be joined to.
|
* @buffer : buffer that @list will be joined to.
|
||||||
* @size : length of @buffer.
|
* @size : length of @buffer.
|
||||||
* @list : pointer to string list.
|
* @list : pointer to string list.
|
||||||
* @delim : delimiter character for @list.
|
* @delim : delimiter character for @list.
|
||||||
*
|
*
|
||||||
* A string list will be joined/concatenated as a
|
* A string list will be joined/concatenated as a
|
||||||
* string to @buffer, delimited by @delim.
|
* string to @buffer, delimited by @delim.
|
||||||
*/
|
*/
|
||||||
void string_list_join_concat(char *buffer, size_t size,
|
void string_list_join_concat(char *buffer, size_t size,
|
||||||
const struct string_list *list, const char *sep);
|
const struct string_list *list, const char *sep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* string_list_set:
|
* string_list_set:
|
||||||
* @list : pointer to string list
|
* @list : pointer to string list
|
||||||
* @idx : index of element in string list
|
* @idx : index of element in string list
|
||||||
* @str : value for the element.
|
* @str : value for the element.
|
||||||
*
|
*
|
||||||
* Set value of element inside string list.
|
* Set value of element inside string list.
|
||||||
**/
|
**/
|
||||||
void string_list_set(struct string_list *list, unsigned idx,
|
void string_list_set(struct string_list *list, unsigned idx,
|
||||||
const char *str);
|
const char *str);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,40 +1,40 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (memalign.h).
|
* The following license statement only applies to this file (memalign.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_MEMALIGN_H
|
#ifndef _LIBRETRO_MEMALIGN_H
|
||||||
#define _LIBRETRO_MEMALIGN_H
|
#define _LIBRETRO_MEMALIGN_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *memalign_alloc(size_t boundary, size_t size);
|
void *memalign_alloc(size_t boundary, size_t size);
|
||||||
|
|
||||||
void memalign_free(void *ptr);
|
void memalign_free(void *ptr);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (memmap.h).
|
* The following license statement only applies to this file (memmap.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_MEMMAP_H
|
#ifndef _LIBRETRO_MEMMAP_H
|
||||||
#define _LIBRETRO_MEMMAP_H
|
#define _LIBRETRO_MEMMAP_H
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS)
|
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS)
|
||||||
/* No mman available */
|
/* No mman available */
|
||||||
#elif defined(_WIN32) && !defined(_XBOX)
|
#elif defined(_WIN32) && !defined(_XBOX)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#else
|
#else
|
||||||
#define HAVE_MMAN
|
#define HAVE_MMAN
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(HAVE_MMAN) || defined(_WIN32)
|
#if !defined(HAVE_MMAN) || defined(_WIN32)
|
||||||
void* mmap(void *addr, size_t len, int mmap_prot, int mmap_flags, int fildes, size_t off);
|
void* mmap(void *addr, size_t len, int mmap_prot, int mmap_flags, int fildes, size_t off);
|
||||||
|
|
||||||
int munmap(void *addr, size_t len);
|
int munmap(void *addr, size_t len);
|
||||||
|
|
||||||
int mprotect(void *addr, size_t len, int prot);
|
int mprotect(void *addr, size_t len, int prot);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int memsync(void *start, void *end);
|
int memsync(void *start, void *end);
|
||||||
|
|
||||||
int memprotect(void *addr, size_t len);
|
int memprotect(void *addr, size_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,241 +1,247 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
*
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
* The following license statement only applies to this file (net_compat.h).
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
*
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* Permission is hereby granted, free of charge,
|
||||||
*
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
*/
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#ifndef NETPLAY_COMPAT_H__
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
#define NETPLAY_COMPAT_H__
|
* 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,
|
||||||
#ifdef HAVE_CONFIG_H
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include "config.h"
|
*/
|
||||||
#endif
|
|
||||||
|
#ifndef LIBRETRO_SDK_NETPLAY_COMPAT_H__
|
||||||
#include <boolean.h>
|
#define LIBRETRO_SDK_NETPLAY_COMPAT_H__
|
||||||
#include <retro_inline.h>
|
|
||||||
#include <stdint.h>
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#endif
|
||||||
#ifndef _WIN32_WINNT
|
|
||||||
#define _WIN32_WINNT 0x0501
|
#include <boolean.h>
|
||||||
#endif
|
#include <retro_inline.h>
|
||||||
|
#include <stdint.h>
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
#include <winsock2.h>
|
#ifndef _WIN32_WINNT
|
||||||
#include <windows.h>
|
#define _WIN32_WINNT 0x0501
|
||||||
#include <ws2tcpip.h>
|
#endif
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#define MSG_NOSIGNAL 0
|
|
||||||
#endif
|
#include <winsock2.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
#elif defined(_XBOX)
|
|
||||||
|
#ifndef MSG_NOSIGNAL
|
||||||
#define NOD3D
|
#define MSG_NOSIGNAL 0
|
||||||
#include <xtl.h>
|
#endif
|
||||||
#include <io.h>
|
|
||||||
|
|
||||||
#elif defined(GEKKO)
|
#elif defined(_XBOX)
|
||||||
|
|
||||||
#include <network.h>
|
#define NOD3D
|
||||||
|
#include <xtl.h>
|
||||||
#elif defined(VITA)
|
#include <io.h>
|
||||||
|
|
||||||
#include <psp2/net/net.h>
|
#elif defined(GEKKO)
|
||||||
#include <psp2/net/netctl.h>
|
|
||||||
|
#include <network.h>
|
||||||
#define sockaddr_in SceNetSockaddrIn
|
|
||||||
#define sockaddr SceNetSockaddr
|
#elif defined(VITA)
|
||||||
#define sendto sceNetSendto
|
|
||||||
#define recvfrom sceNetRecvfrom
|
#include <psp2/net/net.h>
|
||||||
#define socket(a,b,c) sceNetSocket("unknown",a,b,c)
|
#include <psp2/net/netctl.h>
|
||||||
#define bind sceNetBind
|
|
||||||
#define accept sceNetAccept
|
#define sockaddr_in SceNetSockaddrIn
|
||||||
#define setsockopt sceNetSetsockopt
|
#define sockaddr SceNetSockaddr
|
||||||
#define connect sceNetConnect
|
#define sendto sceNetSendto
|
||||||
#define listen sceNetListen
|
#define recvfrom sceNetRecvfrom
|
||||||
#define send sceNetSend
|
#define socket(a,b,c) sceNetSocket("unknown",a,b,c)
|
||||||
#define recv sceNetRecv
|
#define bind sceNetBind
|
||||||
#define MSG_DONTWAIT PSP2_NET_MSG_DONTWAIT
|
#define accept sceNetAccept
|
||||||
#define AF_INET PSP2_NET_AF_INET
|
#define setsockopt sceNetSetsockopt
|
||||||
#define AF_UNSPEC 0
|
#define connect sceNetConnect
|
||||||
#define INADDR_ANY PSP2_NET_INADDR_ANY
|
#define listen sceNetListen
|
||||||
#define INADDR_NONE 0xffffffff
|
#define send sceNetSend
|
||||||
#define SOCK_STREAM PSP2_NET_SOCK_STREAM
|
#define recv sceNetRecv
|
||||||
#define SOCK_DGRAM PSP2_NET_SOCK_DGRAM
|
#define MSG_DONTWAIT PSP2_NET_MSG_DONTWAIT
|
||||||
#define SOL_SOCKET PSP2_NET_SOL_SOCKET
|
#define AF_INET PSP2_NET_AF_INET
|
||||||
#define SO_REUSEADDR PSP2_NET_SO_REUSEADDR
|
#define AF_UNSPEC 0
|
||||||
#define SO_SNDBUF PSP2_NET_SO_SNDBUF
|
#define INADDR_ANY PSP2_NET_INADDR_ANY
|
||||||
#define SO_SNDTIMEO PSP2_NET_SO_SNDTIMEO
|
#define INADDR_NONE 0xffffffff
|
||||||
#define SO_NBIO PSP2_NET_SO_NBIO
|
#define SOCK_STREAM PSP2_NET_SOCK_STREAM
|
||||||
#define htonl sceNetHtonl
|
#define SOCK_DGRAM PSP2_NET_SOCK_DGRAM
|
||||||
#define ntohl sceNetNtohl
|
#define SOL_SOCKET PSP2_NET_SOL_SOCKET
|
||||||
#define htons sceNetHtons
|
#define SO_REUSEADDR PSP2_NET_SO_REUSEADDR
|
||||||
#define socklen_t unsigned int
|
#define SO_SNDBUF PSP2_NET_SO_SNDBUF
|
||||||
|
#define SO_SNDTIMEO PSP2_NET_SO_SNDTIMEO
|
||||||
struct hostent
|
#define SO_NBIO PSP2_NET_SO_NBIO
|
||||||
{
|
#define htonl sceNetHtonl
|
||||||
char *h_name;
|
#define ntohl sceNetNtohl
|
||||||
char **h_aliases;
|
#define htons sceNetHtons
|
||||||
int h_addrtype;
|
#define socklen_t unsigned int
|
||||||
int h_length;
|
|
||||||
char **h_addr_list;
|
struct hostent
|
||||||
char *h_addr;
|
{
|
||||||
};
|
char *h_name;
|
||||||
|
char **h_aliases;
|
||||||
#else
|
int h_addrtype;
|
||||||
#include <sys/select.h>
|
int h_length;
|
||||||
#include <sys/types.h>
|
char **h_addr_list;
|
||||||
#include <sys/socket.h>
|
char *h_addr;
|
||||||
#include <netinet/in.h>
|
};
|
||||||
|
|
||||||
#ifndef __PSL1GHT__
|
#else
|
||||||
#include <netinet/tcp.h>
|
#include <sys/select.h>
|
||||||
#endif
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <netinet/in.h>
|
||||||
#include <netdb.h>
|
|
||||||
#include <fcntl.h>
|
#ifndef __PSL1GHT__
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
#endif
|
||||||
#include <cell/sysmodule.h>
|
|
||||||
#include <netex/net.h>
|
#include <arpa/inet.h>
|
||||||
#include <netex/libnetctl.h>
|
#include <netdb.h>
|
||||||
#include <sys/timer.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#ifndef EWOULDBLOCK
|
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||||
#define EWOULDBLOCK SYS_NET_EWOULDBLOCK
|
#include <cell/sysmodule.h>
|
||||||
#endif
|
#include <netex/net.h>
|
||||||
|
#include <netex/libnetctl.h>
|
||||||
#else
|
#include <sys/timer.h>
|
||||||
#include <signal.h>
|
|
||||||
#endif
|
#ifndef EWOULDBLOCK
|
||||||
|
#define EWOULDBLOCK SYS_NET_EWOULDBLOCK
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#else
|
||||||
|
#include <signal.h>
|
||||||
#ifdef GEKKO
|
#endif
|
||||||
#define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, 0, addr, 8)
|
|
||||||
#define socket(domain, type, protocol) net_socket(domain, type, protocol)
|
#endif
|
||||||
|
|
||||||
static INLINE int inet_pton(int af, const char *src, void *dst)
|
#include <errno.h>
|
||||||
{
|
|
||||||
if (af != AF_INET)
|
#ifdef GEKKO
|
||||||
return -1;
|
#define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, 0, addr, 8)
|
||||||
|
#define socket(domain, type, protocol) net_socket(domain, type, protocol)
|
||||||
return inet_aton (src, dst);
|
|
||||||
}
|
static INLINE int inet_pton(int af, const char *src, void *dst)
|
||||||
#endif
|
{
|
||||||
|
if (af != AF_INET)
|
||||||
static INLINE bool isagain(int bytes)
|
return -1;
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
return inet_aton (src, dst);
|
||||||
if (bytes != SOCKET_ERROR)
|
}
|
||||||
return false;
|
#endif
|
||||||
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
|
||||||
return false;
|
static INLINE bool isagain(int bytes)
|
||||||
return true;
|
{
|
||||||
#elif defined(VITA)
|
#if defined(_WIN32)
|
||||||
return (bytes<0 && (bytes == PSP2_NET_ERROR_EAGAIN || bytes == PSP2_NET_ERROR_EWOULDBLOCK));
|
if (bytes != SOCKET_ERROR)
|
||||||
#else
|
return false;
|
||||||
return (bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
|
if (WSAGetLastError() != WSAEWOULDBLOCK)
|
||||||
#endif
|
return false;
|
||||||
}
|
return true;
|
||||||
|
#elif defined(VITA)
|
||||||
#ifdef _XBOX
|
return (bytes<0 && (bytes == PSP2_NET_ERROR_EAGAIN || bytes == PSP2_NET_ERROR_EWOULDBLOCK));
|
||||||
#define socklen_t int
|
#else
|
||||||
|
return (bytes < 0 && (errno == EAGAIN || errno == EWOULDBLOCK));
|
||||||
#ifndef h_addr
|
#endif
|
||||||
#define h_addr h_addr_list[0] /* for backward compatibility */
|
}
|
||||||
#endif
|
|
||||||
|
#ifdef _XBOX
|
||||||
#ifndef SO_KEEPALIVE
|
#define socklen_t int
|
||||||
#define SO_KEEPALIVE 0 /* verify if correct */
|
|
||||||
#endif
|
#ifndef h_addr
|
||||||
#endif
|
#define h_addr h_addr_list[0] /* for backward compatibility */
|
||||||
|
#endif
|
||||||
#ifndef MSG_NOSIGNAL
|
|
||||||
#define MSG_NOSIGNAL 0
|
#ifndef SO_KEEPALIVE
|
||||||
#endif
|
#define SO_KEEPALIVE 0 /* verify if correct */
|
||||||
|
#endif
|
||||||
#ifndef _WIN32
|
#endif
|
||||||
#include <sys/time.h>
|
|
||||||
#include <unistd.h>
|
#ifndef MSG_NOSIGNAL
|
||||||
#endif
|
#define MSG_NOSIGNAL 0
|
||||||
|
#endif
|
||||||
/* Compatibility layer for legacy or incomplete BSD socket implementations.
|
|
||||||
* Only for IPv4. Mostly useful for the consoles which do not support
|
#ifndef _WIN32
|
||||||
* anything reasonably modern on the socket API side of things. */
|
#include <sys/time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef HAVE_SOCKET_LEGACY
|
#endif
|
||||||
|
|
||||||
#define sockaddr_storage sockaddr_in
|
/* Compatibility layer for legacy or incomplete BSD socket implementations.
|
||||||
#define addrinfo addrinfo_retro__
|
* Only for IPv4. Mostly useful for the consoles which do not support
|
||||||
|
* anything reasonably modern on the socket API side of things. */
|
||||||
struct addrinfo
|
|
||||||
{
|
#ifdef HAVE_SOCKET_LEGACY
|
||||||
int ai_flags;
|
|
||||||
int ai_family;
|
#define sockaddr_storage sockaddr_in
|
||||||
int ai_socktype;
|
#define addrinfo addrinfo_retro__
|
||||||
int ai_protocol;
|
|
||||||
size_t ai_addrlen;
|
struct addrinfo
|
||||||
struct sockaddr *ai_addr;
|
{
|
||||||
char *ai_canonname;
|
int ai_flags;
|
||||||
struct addrinfo *ai_next;
|
int ai_family;
|
||||||
};
|
int ai_socktype;
|
||||||
|
int ai_protocol;
|
||||||
#ifndef AI_PASSIVE
|
size_t ai_addrlen;
|
||||||
#define AI_PASSIVE 1
|
struct sockaddr *ai_addr;
|
||||||
#endif
|
char *ai_canonname;
|
||||||
|
struct addrinfo *ai_next;
|
||||||
/* gai_strerror() not used, so we skip that. */
|
};
|
||||||
|
|
||||||
#endif
|
#ifndef AI_PASSIVE
|
||||||
|
#define AI_PASSIVE 1
|
||||||
int getaddrinfo_retro(const char *node, const char *service,
|
#endif
|
||||||
const struct addrinfo *hints,
|
|
||||||
struct addrinfo **res);
|
/* gai_strerror() not used, so we skip that. */
|
||||||
|
|
||||||
void freeaddrinfo_retro(struct addrinfo *res);
|
#endif
|
||||||
|
|
||||||
bool socket_nonblock(int fd);
|
int getaddrinfo_retro(const char *node, const char *service,
|
||||||
|
const struct addrinfo *hints,
|
||||||
int socket_close(int fd);
|
struct addrinfo **res);
|
||||||
|
|
||||||
int socket_select(int nfds, fd_set *readfs, fd_set *writefds,
|
void freeaddrinfo_retro(struct addrinfo *res);
|
||||||
fd_set *errorfds, struct timeval *timeout);
|
|
||||||
|
bool socket_nonblock(int fd);
|
||||||
int socket_send_all_blocking(int fd, const void *data_, size_t size);
|
|
||||||
|
int socket_close(int fd);
|
||||||
int socket_receive_all_blocking(int fd, void *data_, size_t size);
|
|
||||||
|
int socket_select(int nfds, fd_set *readfs, fd_set *writefds,
|
||||||
/**
|
fd_set *errorfds, struct timeval *timeout);
|
||||||
* network_init:
|
|
||||||
*
|
int socket_send_all_blocking(int fd, const void *data_, size_t size);
|
||||||
* Platform specific socket library initialization.
|
|
||||||
*
|
int socket_receive_all_blocking(int fd, void *data_, size_t size);
|
||||||
* Returns: true (1) if successful, otherwise false (0).
|
|
||||||
**/
|
/**
|
||||||
bool network_init(void);
|
* network_init:
|
||||||
|
*
|
||||||
/**
|
* Platform specific socket library initialization.
|
||||||
* network_deinit:
|
*
|
||||||
*
|
* Returns: true (1) if successful, otherwise false (0).
|
||||||
* Deinitialize platform specific socket libraries.
|
**/
|
||||||
**/
|
bool network_init(void);
|
||||||
void network_deinit(void);
|
|
||||||
|
/**
|
||||||
#endif
|
* network_deinit:
|
||||||
|
*
|
||||||
|
* Deinitialize platform specific socket libraries.
|
||||||
|
**/
|
||||||
|
void network_deinit(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,69 +1,75 @@
|
||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
*
|
||||||
* Copyright (C) 2014-2015 - Alfred Agrell
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
* The following license statement only applies to this file (net_http.h).
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
*
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* Permission is hereby granted, free of charge,
|
||||||
*
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
*/
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
#ifndef _NET_HTTP_H
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
#define _NET_HTTP_H
|
* 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,
|
||||||
#include <stdint.h>
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <boolean.h>
|
*/
|
||||||
#include <string.h>
|
|
||||||
|
#ifndef _LIBRETRO_SDK_NET_HTTP_H
|
||||||
#ifdef __cplusplus
|
#define _LIBRETRO_SDK_NET_HTTP_H
|
||||||
extern "C" {
|
|
||||||
#endif
|
#include <stdint.h>
|
||||||
|
#include <boolean.h>
|
||||||
struct http_t;
|
#include <string.h>
|
||||||
struct http_connection_t;
|
|
||||||
|
#ifdef __cplusplus
|
||||||
struct http_connection_t *net_http_connection_new(const char *url);
|
extern "C" {
|
||||||
|
#endif
|
||||||
bool net_http_connection_iterate(struct http_connection_t *conn);
|
|
||||||
|
struct http_t;
|
||||||
bool net_http_connection_done(struct http_connection_t *conn);
|
struct http_connection_t;
|
||||||
|
|
||||||
void net_http_connection_free(struct http_connection_t *conn);
|
struct http_connection_t *net_http_connection_new(const char *url);
|
||||||
|
|
||||||
const char *net_http_connection_url(struct http_connection_t *conn);
|
bool net_http_connection_iterate(struct http_connection_t *conn);
|
||||||
|
|
||||||
struct http_t *net_http_new(struct http_connection_t *conn);
|
bool net_http_connection_done(struct http_connection_t *conn);
|
||||||
|
|
||||||
/* You can use this to call net_http_update
|
void net_http_connection_free(struct http_connection_t *conn);
|
||||||
* only when something will happen; select() it for reading. */
|
|
||||||
int net_http_fd(struct http_t *state);
|
const char *net_http_connection_url(struct http_connection_t *conn);
|
||||||
|
|
||||||
/* Returns true if it's done, or if something broke.
|
struct http_t *net_http_new(struct http_connection_t *conn);
|
||||||
* 'total' will be 0 if it's not known. */
|
|
||||||
bool net_http_update(struct http_t *state, size_t* progress, size_t* total);
|
/* You can use this to call net_http_update
|
||||||
|
* only when something will happen; select() it for reading. */
|
||||||
/* 200, 404, or whatever. */
|
int net_http_fd(struct http_t *state);
|
||||||
int net_http_status(struct http_t *state);
|
|
||||||
|
/* Returns true if it's done, or if something broke.
|
||||||
bool net_http_error(struct http_t *state);
|
* 'total' will be 0 if it's not known. */
|
||||||
|
bool net_http_update(struct http_t *state, size_t* progress, size_t* total);
|
||||||
/* Returns the downloaded data. The returned buffer is owned by the
|
|
||||||
* HTTP handler; it's freed by net_http_delete.
|
/* 200, 404, or whatever. */
|
||||||
*
|
int net_http_status(struct http_t *state);
|
||||||
* If the status is not 20x and accept_error is false, it returns NULL. */
|
|
||||||
uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error);
|
bool net_http_error(struct http_t *state);
|
||||||
|
|
||||||
/* Cleans up all memory. */
|
/* Returns the downloaded data. The returned buffer is owned by the
|
||||||
void net_http_delete(struct http_t *state);
|
* HTTP handler; it's freed by net_http_delete.
|
||||||
|
*
|
||||||
#ifdef __cplusplus
|
* If the status is not 20x and accept_error is false, it returns NULL. */
|
||||||
}
|
uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error);
|
||||||
#endif
|
|
||||||
|
/* Cleans up all memory. */
|
||||||
#endif
|
void net_http_delete(struct http_t *state);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (net_ifinfo.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_NET_IFINFO_H
|
||||||
|
#define _LIBRETRO_NET_IFINFO_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <boolean.h>
|
||||||
|
|
||||||
|
struct net_ifinfo_entry
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
char *host;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct net_ifinfo
|
||||||
|
{
|
||||||
|
struct net_ifinfo_entry *entries;
|
||||||
|
size_t size;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct net_ifinfo net_ifinfo_t;
|
||||||
|
|
||||||
|
void net_ifinfo_free(net_ifinfo_t *list);
|
||||||
|
|
||||||
|
bool net_ifinfo_new(net_ifinfo_t *list);
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,54 +1,54 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (boolean.h).
|
* The following license statement only applies to this file (fifo_queue.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_FIFO_BUFFER_H
|
#ifndef __LIBRETRO_SDK_FIFO_BUFFER_H
|
||||||
#define __LIBRETRO_SDK_FIFO_BUFFER_H
|
#define __LIBRETRO_SDK_FIFO_BUFFER_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct fifo_buffer fifo_buffer_t;
|
typedef struct fifo_buffer fifo_buffer_t;
|
||||||
|
|
||||||
fifo_buffer_t *fifo_new(size_t size);
|
fifo_buffer_t *fifo_new(size_t size);
|
||||||
|
|
||||||
void fifo_clear(fifo_buffer_t *buffer);
|
void fifo_clear(fifo_buffer_t *buffer);
|
||||||
|
|
||||||
void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size);
|
void fifo_write(fifo_buffer_t *buffer, const void *in_buf, size_t size);
|
||||||
|
|
||||||
void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size);
|
void fifo_read(fifo_buffer_t *buffer, void *in_buf, size_t size);
|
||||||
|
|
||||||
void fifo_free(fifo_buffer_t *buffer);
|
void fifo_free(fifo_buffer_t *buffer);
|
||||||
|
|
||||||
size_t fifo_read_avail(fifo_buffer_t *buffer);
|
size_t fifo_read_avail(fifo_buffer_t *buffer);
|
||||||
|
|
||||||
size_t fifo_write_avail(fifo_buffer_t *buffer);
|
size_t fifo_write_avail(fifo_buffer_t *buffer);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,90 +1,90 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (boolean.h).
|
* The following license statement only applies to this file (message_queue.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_MSG_QUEUE_H
|
#ifndef __LIBRETRO_SDK_MSG_QUEUE_H
|
||||||
#define __LIBRETRO_SDK_MSG_QUEUE_H
|
#define __LIBRETRO_SDK_MSG_QUEUE_H
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct msg_queue msg_queue_t;
|
typedef struct msg_queue msg_queue_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msg_queue_new:
|
* msg_queue_new:
|
||||||
* @size : maximum size of message
|
* @size : maximum size of message
|
||||||
*
|
*
|
||||||
* Creates a message queue with maximum size different messages.
|
* Creates a message queue with maximum size different messages.
|
||||||
*
|
*
|
||||||
* Returns: NULL if allocation error, pointer to a message queue
|
* Returns: NULL if allocation error, pointer to a message queue
|
||||||
* if successful. Has to be freed manually.
|
* if successful. Has to be freed manually.
|
||||||
**/
|
**/
|
||||||
msg_queue_t *msg_queue_new(size_t size);
|
msg_queue_t *msg_queue_new(size_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msg_queue_push:
|
* msg_queue_push:
|
||||||
* @queue : pointer to queue object
|
* @queue : pointer to queue object
|
||||||
* @msg : message to add to the queue
|
* @msg : message to add to the queue
|
||||||
* @prio : priority level of the message
|
* @prio : priority level of the message
|
||||||
* @duration : how many times the message can be pulled
|
* @duration : how many times the message can be pulled
|
||||||
* before it vanishes (E.g. show a message for
|
* before it vanishes (E.g. show a message for
|
||||||
* 3 seconds @ 60fps = 180 duration).
|
* 3 seconds @ 60fps = 180 duration).
|
||||||
*
|
*
|
||||||
* Push a new message onto the queue.
|
* Push a new message onto the queue.
|
||||||
**/
|
**/
|
||||||
void msg_queue_push(msg_queue_t *queue, const char *msg,
|
void msg_queue_push(msg_queue_t *queue, const char *msg,
|
||||||
unsigned prio, unsigned duration);
|
unsigned prio, unsigned duration);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msg_queue_pull:
|
* msg_queue_pull:
|
||||||
* @queue : pointer to queue object
|
* @queue : pointer to queue object
|
||||||
*
|
*
|
||||||
* Pulls highest priority message in queue.
|
* Pulls highest priority message in queue.
|
||||||
*
|
*
|
||||||
* Returns: NULL if no message in queue, otherwise a string
|
* Returns: NULL if no message in queue, otherwise a string
|
||||||
* containing the message.
|
* containing the message.
|
||||||
**/
|
**/
|
||||||
const char *msg_queue_pull(msg_queue_t *queue);
|
const char *msg_queue_pull(msg_queue_t *queue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msg_queue_clear:
|
* msg_queue_clear:
|
||||||
* @queue : pointer to queue object
|
* @queue : pointer to queue object
|
||||||
*
|
*
|
||||||
* Clears out everything in the queue.
|
* Clears out everything in the queue.
|
||||||
**/
|
**/
|
||||||
void msg_queue_clear(msg_queue_t *queue);
|
void msg_queue_clear(msg_queue_t *queue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* msg_queue_free:
|
* msg_queue_free:
|
||||||
* @queue : pointer to queue object
|
* @queue : pointer to queue object
|
||||||
*
|
*
|
||||||
* Frees message queue..
|
* Frees message queue..
|
||||||
**/
|
**/
|
||||||
void msg_queue_free(msg_queue_t *queue);
|
void msg_queue_free(msg_queue_t *queue);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,155 +1,155 @@
|
||||||
/* Copyright (C) 2010-2016 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (task_queue.h).
|
* The following license statement only applies to this file (task_queue.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_TASK_QUEUE_H__
|
#ifndef __LIBRETRO_SDK_TASK_QUEUE_H__
|
||||||
#define __LIBRETRO_SDK_TASK_QUEUE_H__
|
#define __LIBRETRO_SDK_TASK_QUEUE_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum task_queue_ctl_state
|
enum task_queue_ctl_state
|
||||||
{
|
{
|
||||||
TASK_QUEUE_CTL_NONE = 0,
|
TASK_QUEUE_CTL_NONE = 0,
|
||||||
|
|
||||||
/* Deinitializes the task system.
|
/* Deinitializes the task system.
|
||||||
* This deinitializes the task system.
|
* This deinitializes the task system.
|
||||||
* The tasks that are running at
|
* The tasks that are running at
|
||||||
* the moment will stay on hold
|
* the moment will stay on hold
|
||||||
* until TASK_QUEUE_CTL_INIT is called again. */
|
* until TASK_QUEUE_CTL_INIT is called again. */
|
||||||
TASK_QUEUE_CTL_DEINIT,
|
TASK_QUEUE_CTL_DEINIT,
|
||||||
|
|
||||||
/* Initializes the task system.
|
/* Initializes the task system.
|
||||||
* This initializes the task system
|
* This initializes the task system
|
||||||
* and chooses an appropriate
|
* and chooses an appropriate
|
||||||
* implementation according to the settings.
|
* implementation according to the settings.
|
||||||
*
|
*
|
||||||
* This must only be called from the main thread. */
|
* This must only be called from the main thread. */
|
||||||
TASK_QUEUE_CTL_INIT,
|
TASK_QUEUE_CTL_INIT,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls func for every running task
|
* Calls func for every running task
|
||||||
* until it returns true.
|
* until it returns true.
|
||||||
* Returns a task or NULL if not found.
|
* Returns a task or NULL if not found.
|
||||||
*/
|
*/
|
||||||
TASK_QUEUE_CTL_FIND,
|
TASK_QUEUE_CTL_FIND,
|
||||||
|
|
||||||
/* Blocks until all tasks have finished.
|
/* Blocks until all tasks have finished.
|
||||||
* This must only be called from the main thread. */
|
* This must only be called from the main thread. */
|
||||||
TASK_QUEUE_CTL_WAIT,
|
TASK_QUEUE_CTL_WAIT,
|
||||||
|
|
||||||
/* Checks for finished tasks
|
/* Checks for finished tasks
|
||||||
* Takes the finished tasks, if any,
|
* Takes the finished tasks, if any,
|
||||||
* and runs their callbacks.
|
* and runs their callbacks.
|
||||||
* This must only be called from the main thread. */
|
* This must only be called from the main thread. */
|
||||||
TASK_QUEUE_CTL_CHECK,
|
TASK_QUEUE_CTL_CHECK,
|
||||||
|
|
||||||
/* Pushes a task
|
/* Pushes a task
|
||||||
* The task will start as soon as possible. */
|
* The task will start as soon as possible. */
|
||||||
TASK_QUEUE_CTL_PUSH,
|
TASK_QUEUE_CTL_PUSH,
|
||||||
|
|
||||||
/* Sends a signal to terminate all the tasks.
|
/* Sends a signal to terminate all the tasks.
|
||||||
*
|
*
|
||||||
* This won't terminate the tasks immediately.
|
* This won't terminate the tasks immediately.
|
||||||
* They will finish as soon as possible.
|
* They will finish as soon as possible.
|
||||||
*
|
*
|
||||||
* This must only be called from the main thread. */
|
* This must only be called from the main thread. */
|
||||||
TASK_QUEUE_CTL_RESET,
|
TASK_QUEUE_CTL_RESET,
|
||||||
|
|
||||||
TASK_QUEUE_CTL_SET_THREADED,
|
TASK_QUEUE_CTL_SET_THREADED,
|
||||||
|
|
||||||
TASK_QUEUE_CTL_UNSET_THREADED,
|
TASK_QUEUE_CTL_UNSET_THREADED,
|
||||||
|
|
||||||
TASK_QUEUE_CTL_IS_THREADED
|
TASK_QUEUE_CTL_IS_THREADED
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct retro_task retro_task_t;
|
typedef struct retro_task retro_task_t;
|
||||||
typedef void (*retro_task_callback_t)(void *task_data,
|
typedef void (*retro_task_callback_t)(void *task_data,
|
||||||
void *user_data, const char *error);
|
void *user_data, const char *error);
|
||||||
|
|
||||||
typedef void (*retro_task_handler_t)(retro_task_t *task);
|
typedef void (*retro_task_handler_t)(retro_task_t *task);
|
||||||
|
|
||||||
typedef bool (*retro_task_finder_t)(retro_task_t *task,
|
typedef bool (*retro_task_finder_t)(retro_task_t *task,
|
||||||
void *userdata);
|
void *userdata);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *source_file;
|
char *source_file;
|
||||||
} decompress_task_data_t;
|
} decompress_task_data_t;
|
||||||
|
|
||||||
struct retro_task
|
struct retro_task
|
||||||
{
|
{
|
||||||
retro_task_handler_t handler;
|
retro_task_handler_t handler;
|
||||||
|
|
||||||
/* always called from the main loop */
|
/* always called from the main loop */
|
||||||
retro_task_callback_t callback;
|
retro_task_callback_t callback;
|
||||||
|
|
||||||
/* set to true by the handler to signal
|
/* set to true by the handler to signal
|
||||||
* the task has finished executing. */
|
* the task has finished executing. */
|
||||||
bool finished;
|
bool finished;
|
||||||
|
|
||||||
/* set to true by the task system
|
/* set to true by the task system
|
||||||
* to signal the task *must* end. */
|
* to signal the task *must* end. */
|
||||||
bool cancelled;
|
bool cancelled;
|
||||||
|
|
||||||
/* created by the handler, destroyed by the user */
|
/* created by the handler, destroyed by the user */
|
||||||
void *task_data;
|
void *task_data;
|
||||||
|
|
||||||
/* owned by the user */
|
/* owned by the user */
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
||||||
/* created and destroyed by the code related to the handler */
|
/* created and destroyed by the code related to the handler */
|
||||||
void *state;
|
void *state;
|
||||||
|
|
||||||
/* created by task handler; destroyed by main loop
|
/* created by task handler; destroyed by main loop
|
||||||
* (after calling the callback) */
|
* (after calling the callback) */
|
||||||
char *error;
|
char *error;
|
||||||
|
|
||||||
/* -1 = unmettered, 0-100 progress value */
|
/* -1 = unmettered, 0-100 progress value */
|
||||||
int8_t progress;
|
int8_t progress;
|
||||||
|
|
||||||
/* handler can modify but will be
|
/* handler can modify but will be
|
||||||
* free()d automatically if non-NULL. */
|
* free()d automatically if non-NULL. */
|
||||||
char *title;
|
char *title;
|
||||||
|
|
||||||
/* don't touch this. */
|
/* don't touch this. */
|
||||||
retro_task_t *next;
|
retro_task_t *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct task_finder_data
|
typedef struct task_finder_data
|
||||||
{
|
{
|
||||||
retro_task_finder_t func;
|
retro_task_finder_t func;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
} task_finder_data_t;
|
} task_finder_data_t;
|
||||||
|
|
||||||
void task_queue_push_progress(retro_task_t *task);
|
void task_queue_push_progress(retro_task_t *task);
|
||||||
|
|
||||||
bool task_queue_ctl(enum task_queue_ctl_state state, void *data);
|
bool task_queue_ctl(enum task_queue_ctl_state state, void *data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_assert.h).
|
* The following license statement only applies to this file (retro_assert.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RETRO_ASSERT_H
|
#ifndef __RETRO_ASSERT_H
|
||||||
#define __RETRO_ASSERT_H
|
#define __RETRO_ASSERT_H
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef RARCH_INTERNAL
|
#ifdef RARCH_INTERNAL
|
||||||
#define retro_assert(cond) do { \
|
#define retro_assert(cond) do { \
|
||||||
if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \
|
if (!(cond)) { printf("Assertion failed at %s:%d.\n", __FILE__, __LINE__); abort(); } \
|
||||||
} while(0)
|
} while(0)
|
||||||
#else
|
#else
|
||||||
#define retro_assert(cond) assert(cond)
|
#define retro_assert(cond) assert(cond)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,36 +1,36 @@
|
||||||
/* Copyright (C) 2010-2016 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_common.h).
|
* The following license statement only applies to this file (retro_common.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_H
|
#ifndef _LIBRETRO_COMMON_RETRO_COMMON_H
|
||||||
#define _LIBRETRO_COMMON_RETRO_COMMON_H
|
#define _LIBRETRO_COMMON_RETRO_COMMON_H
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file is designed to normalize the libretro-common compiling environment.
|
This file is designed to normalize the libretro-common compiling environment.
|
||||||
It is not to be used in public API headers, as they should be designed as leanly as possible.
|
It is not to be used in public API headers, as they should be designed as leanly as possible.
|
||||||
Nonetheless.. in the meantime, if you do something like use ssize_t, which is not fully portable,
|
Nonetheless.. in the meantime, if you do something like use ssize_t, which is not fully portable,
|
||||||
in a public API, you may need this.
|
in a public API, you may need this.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* conditional compilation is handled inside here */
|
/* conditional compilation is handled inside here */
|
||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,61 +1,61 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_dirent.h).
|
* The following license statement only applies to this file (retro_dirent.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RETRO_DIRENT_H
|
#ifndef __RETRO_DIRENT_H
|
||||||
#define __RETRO_DIRENT_H
|
#define __RETRO_DIRENT_H
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct RDIR;
|
struct RDIR;
|
||||||
|
|
||||||
struct RDIR *retro_opendir(const char *name);
|
struct RDIR *retro_opendir(const char *name);
|
||||||
|
|
||||||
int retro_readdir(struct RDIR *rdir);
|
int retro_readdir(struct RDIR *rdir);
|
||||||
|
|
||||||
bool retro_dirent_error(struct RDIR *rdir);
|
bool retro_dirent_error(struct RDIR *rdir);
|
||||||
|
|
||||||
const char *retro_dirent_get_name(struct RDIR *rdir);
|
const char *retro_dirent_get_name(struct RDIR *rdir);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* retro_dirent_is_dir:
|
* retro_dirent_is_dir:
|
||||||
* @rdir : pointer to the directory entry.
|
* @rdir : pointer to the directory entry.
|
||||||
* @path : path to the directory entry.
|
* @path : path to the directory entry.
|
||||||
*
|
*
|
||||||
* Is the directory listing entry a directory?
|
* Is the directory listing entry a directory?
|
||||||
*
|
*
|
||||||
* Returns: true if directory listing entry is
|
* Returns: true if directory listing entry is
|
||||||
* a directory, false if not.
|
* a directory, false if not.
|
||||||
*/
|
*/
|
||||||
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path);
|
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path);
|
||||||
|
|
||||||
void retro_closedir(struct RDIR *rdir);
|
void retro_closedir(struct RDIR *rdir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,205 +1,205 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_endianness.h).
|
* The following license statement only applies to this file (retro_endianness.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_ENDIANNESS_H
|
#ifndef __LIBRETRO_SDK_ENDIANNESS_H
|
||||||
#define __LIBRETRO_SDK_ENDIANNESS_H
|
#define __LIBRETRO_SDK_ENDIANNESS_H
|
||||||
|
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define SWAP16 _byteswap_ushort
|
#define SWAP16 _byteswap_ushort
|
||||||
#define SWAP32 _byteswap_ulong
|
#define SWAP32 _byteswap_ulong
|
||||||
#else
|
#else
|
||||||
#define SWAP16(x) ((uint16_t)( \
|
#define SWAP16(x) ((uint16_t)( \
|
||||||
(((uint16_t)(x) & 0x00ff) << 8) | \
|
(((uint16_t)(x) & 0x00ff) << 8) | \
|
||||||
(((uint16_t)(x) & 0xff00) >> 8) \
|
(((uint16_t)(x) & 0xff00) >> 8) \
|
||||||
))
|
))
|
||||||
#define SWAP32(x) ((uint32_t)( \
|
#define SWAP32(x) ((uint32_t)( \
|
||||||
(((uint32_t)(x) & 0x000000ff) << 24) | \
|
(((uint32_t)(x) & 0x000000ff) << 24) | \
|
||||||
(((uint32_t)(x) & 0x0000ff00) << 8) | \
|
(((uint32_t)(x) & 0x0000ff00) << 8) | \
|
||||||
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
|
(((uint32_t)(x) & 0x00ff0000) >> 8) | \
|
||||||
(((uint32_t)(x) & 0xff000000) >> 24) \
|
(((uint32_t)(x) & 0xff000000) >> 24) \
|
||||||
))
|
))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SWAP64(val) \
|
#define SWAP64(val) \
|
||||||
((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
|
((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
|
||||||
| (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
|
| (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
|
||||||
| (((uint64_t)(val) & 0x0000000000ff0000ULL) << 24) \
|
| (((uint64_t)(val) & 0x0000000000ff0000ULL) << 24) \
|
||||||
| (((uint64_t)(val) & 0x00000000ff000000ULL) << 8) \
|
| (((uint64_t)(val) & 0x00000000ff000000ULL) << 8) \
|
||||||
| (((uint64_t)(val) & 0x000000ff00000000ULL) >> 8) \
|
| (((uint64_t)(val) & 0x000000ff00000000ULL) >> 8) \
|
||||||
| (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
|
| (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
|
||||||
| (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
|
| (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
|
||||||
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
| (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* is_little_endian:
|
* is_little_endian:
|
||||||
*
|
*
|
||||||
* Checks if the system is little endian or big-endian.
|
* Checks if the system is little endian or big-endian.
|
||||||
*
|
*
|
||||||
* Returns: greater than 0 if little-endian,
|
* Returns: greater than 0 if little-endian,
|
||||||
* otherwise big-endian.
|
* otherwise big-endian.
|
||||||
**/
|
**/
|
||||||
static INLINE uint8_t is_little_endian(void)
|
static INLINE uint8_t is_little_endian(void)
|
||||||
{
|
{
|
||||||
#if defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64)
|
#if defined(__x86_64) || defined(__i386) || defined(_M_IX86) || defined(_M_X64)
|
||||||
return 1;
|
return 1;
|
||||||
#elif defined(MSB_FIRST)
|
#elif defined(MSB_FIRST)
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
uint8_t y[2];
|
uint8_t y[2];
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
u.x = 1;
|
u.x = 1;
|
||||||
return u.y[0];
|
return u.y[0];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_big64:
|
* swap_if_big64:
|
||||||
* @val : unsigned 64-bit value
|
* @val : unsigned 64-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 64-bit value if system is big-endian.
|
* Byteswap unsigned 64-bit value if system is big-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is big-endian,
|
* Returns: Byteswapped value in case system is big-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint64_t swap_if_big64(uint64_t val)
|
static INLINE uint64_t swap_if_big64(uint64_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return val;
|
return val;
|
||||||
return SWAP64(val);
|
return SWAP64(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_big32:
|
* swap_if_big32:
|
||||||
* @val : unsigned 32-bit value
|
* @val : unsigned 32-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 32-bit value if system is big-endian.
|
* Byteswap unsigned 32-bit value if system is big-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is big-endian,
|
* Returns: Byteswapped value in case system is big-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint32_t swap_if_big32(uint32_t val)
|
static INLINE uint32_t swap_if_big32(uint32_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return val;
|
return val;
|
||||||
return SWAP32(val);
|
return SWAP32(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_little64:
|
* swap_if_little64:
|
||||||
* @val : unsigned 64-bit value
|
* @val : unsigned 64-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 64-bit value if system is little-endian.
|
* Byteswap unsigned 64-bit value if system is little-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is little-endian,
|
* Returns: Byteswapped value in case system is little-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint64_t swap_if_little64(uint64_t val)
|
static INLINE uint64_t swap_if_little64(uint64_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return SWAP64(val);
|
return SWAP64(val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_little32:
|
* swap_if_little32:
|
||||||
* @val : unsigned 32-bit value
|
* @val : unsigned 32-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 32-bit value if system is little-endian.
|
* Byteswap unsigned 32-bit value if system is little-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is little-endian,
|
* Returns: Byteswapped value in case system is little-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint32_t swap_if_little32(uint32_t val)
|
static INLINE uint32_t swap_if_little32(uint32_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return SWAP32(val);
|
return SWAP32(val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_big16:
|
* swap_if_big16:
|
||||||
* @val : unsigned 16-bit value
|
* @val : unsigned 16-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 16-bit value if system is big-endian.
|
* Byteswap unsigned 16-bit value if system is big-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is big-endian,
|
* Returns: Byteswapped value in case system is big-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint16_t swap_if_big16(uint16_t val)
|
static INLINE uint16_t swap_if_big16(uint16_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return val;
|
return val;
|
||||||
return SWAP16(val);
|
return SWAP16(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* swap_if_little16:
|
* swap_if_little16:
|
||||||
* @val : unsigned 16-bit value
|
* @val : unsigned 16-bit value
|
||||||
*
|
*
|
||||||
* Byteswap unsigned 16-bit value if system is little-endian.
|
* Byteswap unsigned 16-bit value if system is little-endian.
|
||||||
*
|
*
|
||||||
* Returns: Byteswapped value in case system is little-endian,
|
* Returns: Byteswapped value in case system is little-endian,
|
||||||
* otherwise returns same value.
|
* otherwise returns same value.
|
||||||
**/
|
**/
|
||||||
static INLINE uint16_t swap_if_little16(uint16_t val)
|
static INLINE uint16_t swap_if_little16(uint16_t val)
|
||||||
{
|
{
|
||||||
if (is_little_endian())
|
if (is_little_endian())
|
||||||
return SWAP16(val);
|
return SWAP16(val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store32be:
|
* store32be:
|
||||||
* @addr : pointer to unsigned 32-bit buffer
|
* @addr : pointer to unsigned 32-bit buffer
|
||||||
* @data : unsigned 32-bit value to write
|
* @data : unsigned 32-bit value to write
|
||||||
*
|
*
|
||||||
* Write data to address. Endian-safe. Byteswaps the data
|
* Write data to address. Endian-safe. Byteswaps the data
|
||||||
* first if necessary before storing it.
|
* first if necessary before storing it.
|
||||||
**/
|
**/
|
||||||
static INLINE void store32be(uint32_t *addr, uint32_t data)
|
static INLINE void store32be(uint32_t *addr, uint32_t data)
|
||||||
{
|
{
|
||||||
*addr = swap_if_little32(data);
|
*addr = swap_if_little32(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load32be:
|
* load32be:
|
||||||
* @addr : pointer to unsigned 32-bit buffer
|
* @addr : pointer to unsigned 32-bit buffer
|
||||||
*
|
*
|
||||||
* Load value from address. Endian-safe.
|
* Load value from address. Endian-safe.
|
||||||
*
|
*
|
||||||
* Returns: value from address, byte-swapped if necessary.
|
* Returns: value from address, byte-swapped if necessary.
|
||||||
**/
|
**/
|
||||||
static INLINE uint32_t load32be(const uint32_t *addr)
|
static INLINE uint32_t load32be(const uint32_t *addr)
|
||||||
{
|
{
|
||||||
return swap_if_little32(*addr);
|
return swap_if_little32(*addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,68 +1,68 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_environment.h).
|
* The following license statement only applies to this file (retro_environment.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_ENVIRONMENT_H
|
#ifndef __LIBRETRO_SDK_ENVIRONMENT_H
|
||||||
#define __LIBRETRO_SDK_ENVIRONMENT_H
|
#define __LIBRETRO_SDK_ENVIRONMENT_H
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
#if 0
|
#if 0
|
||||||
printf("This is C++, version %d.\n", __cplusplus);
|
printf("This is C++, version %d.\n", __cplusplus);
|
||||||
#endif
|
#endif
|
||||||
/* The expected values would be
|
/* The expected values would be
|
||||||
* 199711L, for ISO/IEC 14882:1998 or 14882:2003
|
* 199711L, for ISO/IEC 14882:1998 or 14882:2003
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#elif defined(__STDC__)
|
#elif defined(__STDC__)
|
||||||
/* This is standard C. */
|
/* This is standard C. */
|
||||||
|
|
||||||
#if (__STDC__ == 1)
|
#if (__STDC__ == 1)
|
||||||
/* The implementation is ISO-conforming. */
|
/* The implementation is ISO-conforming. */
|
||||||
#define __STDC_ISO__
|
#define __STDC_ISO__
|
||||||
#else
|
#else
|
||||||
/* The implementation is not ISO-conforming. */
|
/* The implementation is not ISO-conforming. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__STDC_VERSION__)
|
#if defined(__STDC_VERSION__)
|
||||||
#if (__STDC_VERSION__ >= 201112L)
|
#if (__STDC_VERSION__ >= 201112L)
|
||||||
/* This is C11. */
|
/* This is C11. */
|
||||||
#define __STDC_C11__
|
#define __STDC_C11__
|
||||||
#elif (__STDC_VERSION__ >= 199901L)
|
#elif (__STDC_VERSION__ >= 199901L)
|
||||||
/* This is C99. */
|
/* This is C99. */
|
||||||
#define __STDC_C99__
|
#define __STDC_C99__
|
||||||
#elif (__STDC_VERSION__ >= 199409L)
|
#elif (__STDC_VERSION__ >= 199409L)
|
||||||
/* This is C89 with amendment 1. */
|
/* This is C89 with amendment 1. */
|
||||||
#define __STDC_C89__
|
#define __STDC_C89__
|
||||||
#define __STDC_C89_AMENDMENT_1__
|
#define __STDC_C89_AMENDMENT_1__
|
||||||
#else
|
#else
|
||||||
/* This is C89 without amendment 1. */
|
/* This is C89 without amendment 1. */
|
||||||
#define __STDC_C89__
|
#define __STDC_C89__
|
||||||
#endif
|
#endif
|
||||||
#else /* !defined(__STDC_VERSION__) */
|
#else /* !defined(__STDC_VERSION__) */
|
||||||
/* This is C89. __STDC_VERSION__ is not defined. */
|
/* This is C89. __STDC_VERSION__ is not defined. */
|
||||||
#define __STDC_C89__
|
#define __STDC_C89__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* !defined(__STDC__) */
|
#else /* !defined(__STDC__) */
|
||||||
/* This is not standard C. __STDC__ is not defined. */
|
/* This is not standard C. __STDC__ is not defined. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_inline.h).
|
* The following license statement only applies to this file (retro_inline.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_INLINE_H
|
#ifndef __LIBRETRO_SDK_INLINE_H
|
||||||
#define __LIBRETRO_SDK_INLINE_H
|
#define __LIBRETRO_SDK_INLINE_H
|
||||||
|
|
||||||
#ifndef INLINE
|
#ifndef INLINE
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define INLINE __inline
|
#define INLINE __inline
|
||||||
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
|
||||||
#define INLINE inline
|
#define INLINE inline
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#define INLINE __inline__
|
#define INLINE __inline__
|
||||||
#else
|
#else
|
||||||
#define INLINE
|
#define INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,193 +1,193 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_miscellaneous.h).
|
* The following license statement only applies to this file (retro_miscellaneous.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RARCH_MISCELLANEOUS_H
|
#ifndef __RARCH_MISCELLANEOUS_H
|
||||||
#define __RARCH_MISCELLANEOUS_H
|
#define __RARCH_MISCELLANEOUS_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||||
#include <sys/timer.h>
|
#include <sys/timer.h>
|
||||||
#elif defined(XENON)
|
#elif defined(XENON)
|
||||||
#include <time/time.h>
|
#include <time/time.h>
|
||||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#elif defined(PSP)
|
#elif defined(PSP)
|
||||||
#include <pspthreadman.h>
|
#include <pspthreadman.h>
|
||||||
#elif defined(VITA)
|
#elif defined(VITA)
|
||||||
#include <psp2/kernel/threadmgr.h>
|
#include <psp2/kernel/threadmgr.h>
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
#include <3ds.h>
|
#include <3ds.h>
|
||||||
#else
|
#else
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#elif defined(_WIN32) && defined(_XBOX)
|
#elif defined(_WIN32) && defined(_XBOX)
|
||||||
#include <Xtl.h>
|
#include <Xtl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <compat/msvc.h>
|
#include <compat/msvc.h>
|
||||||
#endif
|
#endif
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
|
|
||||||
#ifndef PATH_MAX_LENGTH
|
#ifndef PATH_MAX_LENGTH
|
||||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)
|
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)
|
||||||
#define PATH_MAX_LENGTH 512
|
#define PATH_MAX_LENGTH 512
|
||||||
#else
|
#else
|
||||||
#define PATH_MAX_LENGTH 4096
|
#define PATH_MAX_LENGTH 4096
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
#define M_PI 3.14159265358979323846264338327
|
#define M_PI 3.14159265358979323846264338327
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MAX
|
#ifndef MAX
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
#define RARCH_SCALE_BASE 256
|
#define RARCH_SCALE_BASE 256
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retro_sleep:
|
* retro_sleep:
|
||||||
* @msec : amount in milliseconds to sleep
|
* @msec : amount in milliseconds to sleep
|
||||||
*
|
*
|
||||||
* Sleeps for a specified amount of milliseconds (@msec).
|
* Sleeps for a specified amount of milliseconds (@msec).
|
||||||
**/
|
**/
|
||||||
static INLINE void retro_sleep(unsigned msec)
|
static INLINE void retro_sleep(unsigned msec)
|
||||||
{
|
{
|
||||||
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__)
|
||||||
sys_timer_usleep(1000 * msec);
|
sys_timer_usleep(1000 * msec);
|
||||||
#elif defined(PSP) || defined(VITA)
|
#elif defined(PSP) || defined(VITA)
|
||||||
sceKernelDelayThread(1000 * msec);
|
sceKernelDelayThread(1000 * msec);
|
||||||
#elif defined(_3DS)
|
#elif defined(_3DS)
|
||||||
svcSleepThread(1000000 * (s64)msec);
|
svcSleepThread(1000000 * (s64)msec);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
Sleep(msec);
|
Sleep(msec);
|
||||||
#elif defined(XENON)
|
#elif defined(XENON)
|
||||||
udelay(1000 * msec);
|
udelay(1000 * msec);
|
||||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||||
usleep(1000 * msec);
|
usleep(1000 * msec);
|
||||||
#else
|
#else
|
||||||
struct timespec tv = {0};
|
struct timespec tv = {0};
|
||||||
tv.tv_sec = msec / 1000;
|
tv.tv_sec = msec / 1000;
|
||||||
tv.tv_nsec = (msec % 1000) * 1000000;
|
tv.tv_nsec = (msec % 1000) * 1000000;
|
||||||
nanosleep(&tv, NULL);
|
nanosleep(&tv, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* next_pow2:
|
* next_pow2:
|
||||||
* @v : initial value
|
* @v : initial value
|
||||||
*
|
*
|
||||||
* Get next power of 2 value based on initial value.
|
* Get next power of 2 value based on initial value.
|
||||||
*
|
*
|
||||||
* Returns: next power of 2 value (derived from @v).
|
* Returns: next power of 2 value (derived from @v).
|
||||||
**/
|
**/
|
||||||
static INLINE uint32_t next_pow2(uint32_t v)
|
static INLINE uint32_t next_pow2(uint32_t v)
|
||||||
{
|
{
|
||||||
v--;
|
v--;
|
||||||
v |= v >> 1;
|
v |= v >> 1;
|
||||||
v |= v >> 2;
|
v |= v >> 2;
|
||||||
v |= v >> 4;
|
v |= v >> 4;
|
||||||
v |= v >> 8;
|
v |= v >> 8;
|
||||||
v |= v >> 16;
|
v |= v >> 16;
|
||||||
v++;
|
v++;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* prev_pow2:
|
* prev_pow2:
|
||||||
* @v : initial value
|
* @v : initial value
|
||||||
*
|
*
|
||||||
* Get previous power of 2 value based on initial value.
|
* Get previous power of 2 value based on initial value.
|
||||||
*
|
*
|
||||||
* Returns: previous power of 2 value (derived from @v).
|
* Returns: previous power of 2 value (derived from @v).
|
||||||
**/
|
**/
|
||||||
static INLINE uint32_t prev_pow2(uint32_t v)
|
static INLINE uint32_t prev_pow2(uint32_t v)
|
||||||
{
|
{
|
||||||
v |= v >> 1;
|
v |= v >> 1;
|
||||||
v |= v >> 2;
|
v |= v >> 2;
|
||||||
v |= v >> 4;
|
v |= v >> 4;
|
||||||
v |= v >> 8;
|
v |= v >> 8;
|
||||||
v |= v >> 16;
|
v |= v >> 16;
|
||||||
return v - (v >> 1);
|
return v - (v >> 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* db_to_gain:
|
* db_to_gain:
|
||||||
* @db : Decibels.
|
* @db : Decibels.
|
||||||
*
|
*
|
||||||
* Converts decibels to voltage gain.
|
* Converts decibels to voltage gain.
|
||||||
*
|
*
|
||||||
* Returns: voltage gain value.
|
* Returns: voltage gain value.
|
||||||
**/
|
**/
|
||||||
static INLINE float db_to_gain(float db)
|
static INLINE float db_to_gain(float db)
|
||||||
{
|
{
|
||||||
return powf(10.0f, db / 20.0f);
|
return powf(10.0f, db / 20.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper macros and struct to keep track of many booleans.
|
/* Helper macros and struct to keep track of many booleans.
|
||||||
* To check for multiple bits, use &&, not &.
|
* To check for multiple bits, use &&, not &.
|
||||||
* For OR, | can be used. */
|
* For OR, | can be used. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t data[8];
|
uint32_t data[8];
|
||||||
} retro_bits_t;
|
} retro_bits_t;
|
||||||
|
|
||||||
#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
|
#define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7)))
|
||||||
#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
|
#define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7)))
|
||||||
#define BIT_GET(a, bit) ((a)[(bit) >> 3] & (1 << ((bit) & 7)))
|
#define BIT_GET(a, bit) ((a)[(bit) >> 3] & (1 << ((bit) & 7)))
|
||||||
|
|
||||||
#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
|
#define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15)))
|
||||||
#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
|
#define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15)))
|
||||||
#define BIT16_GET(a, bit) (!!((a) & (1 << ((bit) & 15))))
|
#define BIT16_GET(a, bit) (!!((a) & (1 << ((bit) & 15))))
|
||||||
#define BIT16_CLEAR_ALL(a) ((a) = 0)
|
#define BIT16_CLEAR_ALL(a) ((a) = 0)
|
||||||
|
|
||||||
#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
|
#define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31)))
|
||||||
#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
|
#define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31)))
|
||||||
#define BIT32_GET(a, bit) (!!((a) & (1 << ((bit) & 31))))
|
#define BIT32_GET(a, bit) (!!((a) & (1 << ((bit) & 31))))
|
||||||
#define BIT32_CLEAR_ALL(a) ((a) = 0)
|
#define BIT32_CLEAR_ALL(a) ((a) = 0)
|
||||||
|
|
||||||
#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
|
#define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63)))
|
||||||
#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
|
#define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63)))
|
||||||
#define BIT64_GET(a, bit) (!!((a) & (UINT64_C(1) << ((bit) & 63))))
|
#define BIT64_GET(a, bit) (!!((a) & (UINT64_C(1) << ((bit) & 63))))
|
||||||
#define BIT64_CLEAR_ALL(a) ((a) = 0)
|
#define BIT64_CLEAR_ALL(a) ((a) = 0)
|
||||||
|
|
||||||
#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))
|
#define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))
|
||||||
#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
|
#define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31)))
|
||||||
#define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31)))
|
#define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31)))
|
||||||
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a));
|
#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,57 +1,57 @@
|
||||||
/* Copyright (C) 2010-2015 The RetroArch team
|
/* Copyright (C) 2010-2016 The RetroArch team
|
||||||
*
|
*
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
* The following license statement only applies to this file (retro_stat.h).
|
* The following license statement only applies to this file (retro_stat.h).
|
||||||
* ---------------------------------------------------------------------------------------
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge,
|
* Permission is hereby granted, free of charge,
|
||||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
* 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
|
* 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,
|
* 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:
|
* 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 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,
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
* 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,
|
* 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,
|
* 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.
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __RETRO_STAT_H
|
#ifndef __RETRO_STAT_H
|
||||||
#define __RETRO_STAT_H
|
#define __RETRO_STAT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_is_directory:
|
* path_is_directory:
|
||||||
* @path : path
|
* @path : path
|
||||||
*
|
*
|
||||||
* Checks if path is a directory.
|
* Checks if path is a directory.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if path is a directory, otherwise false (0).
|
* Returns: true (1) if path is a directory, otherwise false (0).
|
||||||
*/
|
*/
|
||||||
bool path_is_directory(const char *path);
|
bool path_is_directory(const char *path);
|
||||||
|
|
||||||
bool path_is_character_special(const char *path);
|
bool path_is_character_special(const char *path);
|
||||||
|
|
||||||
bool path_is_valid(const char *path);
|
bool path_is_valid(const char *path);
|
||||||
|
|
||||||
int32_t path_get_size(const char *path);
|
int32_t path_get_size(const char *path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* path_mkdir_norecurse:
|
* path_mkdir_norecurse:
|
||||||
* @dir : directory
|
* @dir : directory
|
||||||
*
|
*
|
||||||
* Create directory on filesystem.
|
* Create directory on filesystem.
|
||||||
*
|
*
|
||||||
* Returns: true (1) if directory could be created, otherwise false (0).
|
* Returns: true (1) if directory could be created, otherwise false (0).
|
||||||
**/
|
**/
|
||||||
bool mkdir_norecurse(const char *dir);
|
bool mkdir_norecurse(const char *dir);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue