mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Avoid use of struct serial_struct on systems which don't have it (Android)
This fixes bug #376.
This commit is contained in:
parent
5bd33b7c8b
commit
12056e2f75
@ -122,6 +122,10 @@ AC_CHECK_MEMBERS([struct termios2.c_ispeed, struct termios2.c_ospeed],
|
|||||||
# Check for readlinkat.
|
# Check for readlinkat.
|
||||||
AC_CHECK_FUNC([readlinkat], [AC_DEFINE(HAVE_READLINKAT, 1)], [])
|
AC_CHECK_FUNC([readlinkat], [AC_DEFINE(HAVE_READLINKAT, 1)], [])
|
||||||
|
|
||||||
|
# Check for serial_struct.
|
||||||
|
AC_CHECK_TYPE([struct serial_struct], [AC_DEFINE(HAVE_SERIAL_STRUCT, 1)],
|
||||||
|
[], [[#include <linux/serial.h>]])
|
||||||
|
|
||||||
saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
|
saved="$CFLAGS"; CFLAGS="$CFLAGS -Werror"
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
__attribute__((visibility("hidden"))) void foo(void) { }
|
__attribute__((visibility("hidden"))) void foo(void) { }
|
||||||
|
9
linux.c
9
linux.c
@ -160,11 +160,14 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
|||||||
{
|
{
|
||||||
char name[PATH_MAX], target[PATH_MAX];
|
char name[PATH_MAX], target[PATH_MAX];
|
||||||
struct dirent entry, *result;
|
struct dirent entry, *result;
|
||||||
|
#ifdef HAVE_SERIAL_STRUCT
|
||||||
struct serial_struct serial_info;
|
struct serial_struct serial_info;
|
||||||
|
int ioctl_result;
|
||||||
|
#endif
|
||||||
#ifndef HAVE_READLINKAT
|
#ifndef HAVE_READLINKAT
|
||||||
char buf[sizeof(entry.d_name) + 16];
|
char buf[sizeof(entry.d_name) + 16];
|
||||||
#endif
|
#endif
|
||||||
int len, fd, ioctl_result;
|
int len, fd;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
int ret = SP_OK;
|
int ret = SP_OK;
|
||||||
|
|
||||||
@ -196,8 +199,11 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
|||||||
DEBUG("open failed, skipping");
|
DEBUG("open failed, skipping");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_SERIAL_STRUCT
|
||||||
ioctl_result = ioctl(fd, TIOCGSERIAL, &serial_info);
|
ioctl_result = ioctl(fd, TIOCGSERIAL, &serial_info);
|
||||||
|
#endif
|
||||||
close(fd);
|
close(fd);
|
||||||
|
#ifdef HAVE_SERIAL_STRUCT
|
||||||
if (ioctl_result != 0) {
|
if (ioctl_result != 0) {
|
||||||
DEBUG("ioctl failed, skipping");
|
DEBUG("ioctl failed, skipping");
|
||||||
continue;
|
continue;
|
||||||
@ -206,6 +212,7 @@ SP_PRIV enum sp_return list_ports(struct sp_port ***list)
|
|||||||
DEBUG("port type is unknown, skipping");
|
DEBUG("port type is unknown, skipping");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
DEBUG("Found port %s", name);
|
DEBUG("Found port %s", name);
|
||||||
*list = list_append(*list, name);
|
*list = list_append(*list, name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user