Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
hatari
Commits
c03df2df
Commit
c03df2df
authored
Apr 01, 2020
by
Not6
Browse files
fix/remove libretro-common
parent
52aaba68
Changes
70
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile.common
View file @
c03df2df
INCFLAGS
:=
-I
$(EMU)
-I
$(CPU)
-I
$(FALCON)
-I
$(EMU)
/includes
-I
$(DBG)
-I
$(FLP)
\
-I
$(LIBRETRO_DIR)
-I
$(LIBRETRO_DIR)
/libretro-
commo
n/include
-I
$(LIBRETRO_DIR)
/include
-I
$(LIBUTILS)
-I
$(CPU_PREGEN)
-I
$(LIBRETRO_DIR)
-I
$(LIBRETRO_DIR)
/libretro-
sdk
n/include
-I
$(LIBRETRO_DIR)
/include
-I
$(LIBUTILS)
-I
$(CPU_PREGEN)
ifeq
($(EXTERNAL_ZLIB), 1)
ZLIB_SRCS
:=
$(ZLIB_DIR)
/adler32.c
\
...
...
@@ -139,7 +139,7 @@ $(EMU)/wavFormat.c \
$(EMU)
/xbios.c
\
$(EMU)
/ymFormat.c
SOURCES_C
+=
$(LIBRETRO_DIR)
/libretro-
common
/libco/libco.c
\
SOURCES_C
+=
$(LIBRETRO_DIR)
/libretro-
sdk
/libco/libco.c
\
$(LIBRETRO_DIR)
/libretro.c
\
$(LIBRETRO_DIR)
/hatari-mapper.c
\
$(LIBRETRO_DIR)
/vkbd.c
\
...
...
libretro/libretro-common/compat/compat_fnmatch.c
deleted
100644 → 0
View file @
52aaba68
/* Copyright (C) 2010-2017 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_fnmatch.c).
* ---------------------------------------------------------------------------------------
*
* 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.
*/
#if __TEST_FNMATCH__
#include <assert.h>
#endif
#include <stddef.h>
#include <compat/fnmatch.h>
/* Implemnentation of fnmatch(3) so it can be
* distributed to non *nix platforms.
*
* No flags are implemented ATM.
* We don't use them. Add flags as needed. */
int
rl_fnmatch
(
const
char
*
pattern
,
const
char
*
string
,
int
flags
)
{
int
rv
;
const
char
*
c
=
NULL
;
int
charmatch
=
0
;
for
(
c
=
pattern
;
*
c
!=
'\0'
;
c
++
)
{
/* String ended before pattern */
if
((
*
c
!=
'*'
)
&&
(
*
string
==
'\0'
))
return
FNM_NOMATCH
;
switch
(
*
c
)
{
/* Match any number of unknown chars */
case
'*'
:
/* Find next node in the pattern
* ignoring multiple asterixes
*/
do
{
c
++
;
if
(
*
c
==
'\0'
)
return
0
;
}
while
(
*
c
==
'*'
);
/* Match the remaining pattern
* ignoring more and more characters. */
do
{
/* We reached the end of the string without a
* match. There is a way to optimize this by
* calculating the minimum chars needed to
* match the remaining pattern but I don't
* think it is worth the work ATM.
*/
if
(
*
string
==
'\0'
)
return
FNM_NOMATCH
;
rv
=
rl_fnmatch
(
c
,
string
,
flags
);
string
++
;
}
while
(
rv
!=
0
);
return
0
;
/* Match char from list */
case
'['
:
charmatch
=
0
;
for
(
c
++
;
*
c
!=
']'
;
c
++
)
{
/* Bad format */
if
(
*
c
==
'\0'
)
return
FNM_NOMATCH
;
/* Match already found */
if
(
charmatch
)
continue
;
if
(
*
c
==
*
string
)
charmatch
=
1
;
}
/* No match in list */
if
(
!
charmatch
)
return
FNM_NOMATCH
;
string
++
;
break
;
/* Has any character */
case
'?'
:
string
++
;
break
;
/* Match following character verbatim */
case
'\\'
:
c
++
;
/* Dangling escape at end of pattern.
* FIXME: Was c == '\0' (makes no sense).
* Not sure if c == NULL or *c == '\0'
* is intended. Assuming *c due to c++ right before. */
if
(
*
c
==
'\0'
)
return
FNM_NOMATCH
;
default:
if
(
*
c
!=
*
string
)
return
FNM_NOMATCH
;
string
++
;
}
}
/* End of string and end of pattend */
if
(
*
string
==
'\0'
)
return
0
;
return
FNM_NOMATCH
;
}
#if __TEST_FNMATCH__
int
main
(
void
)
{
assert
(
rl_fnmatch
(
"TEST"
,
"TEST"
,
0
)
==
0
);
assert
(
rl_fnmatch
(
"TE?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"
,
"TEdT"
,
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
(
"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"
,
"TEST"
,
0
)
==
0
);
assert
(
rl_fnmatch
(
"TE**ST"
,
"TExST"
,
0
)
==
0
);
assert
(
rl_fnmatch
(
"TE
\\
**ST"
,
"TE*xST"
,
0
)
==
0
);
assert
(
rl_fnmatch
(
"*.*"
,
"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]*[Gg]"
,
"test.jPg"
,
0
)
==
0
);
assert
(
rl_fnmatch
(
"TEST?"
,
"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*S"
,
"TEST"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"TE**ST"
,
"TExT"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"TE
\\
*T"
,
"TExT"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"TES?"
,
"TES"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"TE"
,
"TEST"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"TEST!"
,
"TEST"
,
0
)
==
FNM_NOMATCH
);
assert
(
rl_fnmatch
(
"DSAD"
,
"TEST"
,
0
)
==
FNM_NOMATCH
);
}
#endif
libretro/libretro-common/compat/compat_getopt.c
deleted
100644 → 0
View file @
52aaba68
/* Copyright (C) 2010-2017 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (compat_getopt.c).
* ---------------------------------------------------------------------------------------
*
* 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.
*/
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <boolean.h>
#include <stddef.h>
#include <stdlib.h>
#include <retro_miscellaneous.h>
#include <compat/getopt.h>
#include <compat/strl.h>
#include <compat/strcasestr.h>
#include <compat/posix_string.h>
#include <retro_assert.h>
char
*
optarg
;
int
optind
,
opterr
,
optopt
;
static
bool
is_short_option
(
const
char
*
str
)
{
return
str
[
0
]
==
'-'
&&
str
[
1
]
!=
'-'
;
}
static
bool
is_long_option
(
const
char
*
str
)
{
return
str
[
0
]
==
'-'
&&
str
[
1
]
==
'-'
;
}
static
int
find_short_index
(
char
*
const
*
argv
)
{
int
idx
;
for
(
idx
=
0
;
argv
[
idx
];
idx
++
)
{
if
(
is_short_option
(
argv
[
idx
]))
return
idx
;
}
return
-
1
;
}
static
int
find_long_index
(
char
*
const
*
argv
)
{
int
idx
;
for
(
idx
=
0
;
argv
[
idx
];
idx
++
)
{
if
(
is_long_option
(
argv
[
idx
]))
return
idx
;
}
return
-
1
;
}
static
int
parse_short
(
const
char
*
optstring
,
char
*
const
*
argv
)
{
bool
extra_opt
,
takes_arg
,
embedded_arg
;
const
char
*
opt
=
NULL
;
char
arg
=
argv
[
0
][
1
];
if
(
arg
==
':'
)
return
'?'
;
opt
=
strchr
(
optstring
,
arg
);
if
(
!
opt
)
return
'?'
;
extra_opt
=
argv
[
0
][
2
];
takes_arg
=
opt
[
1
]
==
':'
;
/* If we take an argument, and we see additional characters,
* this is in fact the argument (i.e. -cfoo is same as -c foo). */
embedded_arg
=
extra_opt
&&
takes_arg
;
if
(
takes_arg
)
{
if
(
embedded_arg
)
{
optarg
=
argv
[
0
]
+
2
;
optind
++
;
}
else
{
optarg
=
argv
[
1
];
optind
+=
2
;
}
return
optarg
?
opt
[
0
]
:
'?'
;
}
if
(
embedded_arg
)
{
/* If we see additional characters,
* and they don't take arguments, this
* means we have multiple flags in one. */
memmove
(
&
argv
[
0
][
1
],
&
argv
[
0
][
2
],
strlen
(
&
argv
[
0
][
2
])
+
1
);
return
opt
[
0
];
}
optind
++
;
return
opt
[
0
];
}
static
int
parse_long
(
const
struct
option
*
longopts
,
char
*
const
*
argv
)
{
size_t
indice
;
const
struct
option
*
opt
=
NULL
;
for
(
indice
=
0
;
longopts
[
indice
].
name
;
indice
++
)
{
if
(
!
strcmp
(
longopts
[
indice
].
name
,
&
argv
[
0
][
2
]))
{
opt
=
&
longopts
[
indice
];
break
;
}
}
if
(
!
opt
)
return
'?'
;
/* getopt_long has an "optional" arg, but we don't bother with that. */
if
(
opt
->
has_arg
&&
!
argv
[
1
])
return
'?'
;
if
(
opt
->
has_arg
)
{
optarg
=
argv
[
1
];
optind
+=
2
;
}
else
optind
++
;
if
(
opt
->
flag
)
{
*
opt
->
flag
=
opt
->
val
;
return
0
;
}
return
opt
->
val
;
}
static
void
shuffle_block
(
char
**
begin
,
char
**
last
,
char
**
end
)
{
ptrdiff_t
len
=
last
-
begin
;
const
char
**
tmp
=
(
const
char
**
)
calloc
(
len
,
sizeof
(
const
char
*
));
retro_assert
(
tmp
);
memcpy
((
void
*
)
tmp
,
begin
,
len
*
sizeof
(
const
char
*
));
memmove
(
begin
,
last
,
(
end
-
last
)
*
sizeof
(
const
char
*
));
memcpy
(
end
-
len
,
tmp
,
len
*
sizeof
(
const
char
*
));
free
((
void
*
)
tmp
);
}
int
getopt_long
(
int
argc
,
char
*
argv
[],
const
char
*
optstring
,
const
struct
option
*
longopts
,
int
*
longindex
)
{
int
short_index
,
long_index
;
(
void
)
longindex
;
if
(
optind
==
0
)
optind
=
1
;
if
(
argc
<
2
)
return
-
1
;
short_index
=
find_short_index
(
&
argv
[
optind
]);
long_index
=
find_long_index
(
&
argv
[
optind
]);
/* We're done here. */
if
(
short_index
==
-
1
&&
long_index
==
-
1
)
return
-
1
;
/* Reorder argv so that non-options come last.
* Non-POSIXy, but that's what getopt does by default. */
if
((
short_index
>
0
)
&&
((
short_index
<
long_index
)
||
(
long_index
==
-
1
)))
{
shuffle_block
(
&
argv
[
optind
],
&
argv
[
optind
+
short_index
],
&
argv
[
argc
]);
short_index
=
0
;
}
else
if
((
long_index
>
0
)
&&
((
long_index
<
short_index
)
||
(
short_index
==
-
1
)))
{
shuffle_block
(
&
argv
[
optind
],
&
argv
[
optind
+
long_index
],
&
argv
[
argc
]);
long_index
=
0
;
}
retro_assert
(
short_index
==
0
||
long_index
==
0
);
if
(
short_index
==
0
)
return
parse_short
(
optstring
,
&
argv
[
optind
]);
if
(
long_index
==
0
)
return
parse_long
(
longopts
,
&
argv
[
optind
]);
return
'?'
;
}
libretro/libretro-common/compat/compat_ifaddrs.c
deleted
100644 → 0
View file @
52aaba68
/*
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
)
{
struct
sockaddr_nl
l_addr
;
int
l_socket
=
socket
(
PF_NETLINK
,
SOCK_RAW
,
NETLINK_ROUTE
);
if
(
l_socket
<
0
)
return
-
1
;
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
;
struct
sockaddr_nl
l_addr
;
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
;
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 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
)
{
NetlinkList
*
l_item
=
NULL
;
struct
nlmsghdr
*
l_hdr
=
getNetlinkResponse
(
p_socket
,
&
l_size
,
&
l_done
);
if
(
!
l_hdr
)
goto
error
;