Skip to content

Commit ec1b4b4

Browse files
dgarskedanielinux
authored andcommitted
allow the ufserver to build on Mac
1 parent 48405e0 commit ec1b4b4

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tools/uart-flash-server/ufserver.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ void hal_flash_lock(void)
9797
{
9898
}
9999

100-
#include <termio.h>
101100
#include <fcntl.h>
102101
#include <err.h>
103-
#include <linux/serial.h>
104102

105103
static int rate_to_constant(int baudrate) {
104+
#ifdef __MACH__
105+
#define B(x) case x: return x
106+
#else
106107
#define B(x) case x: return B##x
108+
#endif
107109
switch(baudrate) {
108110
B(50); B(75); B(110); B(134); B(150);
109111
B(200); B(300); B(600); B(1200); B(1800);
@@ -119,7 +121,6 @@ default: return 0;
119121
static int serial_open(const char *device, int rate)
120122
{
121123
struct termios options;
122-
struct serial_struct serinfo;
123124
int fd;
124125
int speed = 0;
125126

@@ -129,8 +130,10 @@ static int serial_open(const char *device, int rate)
129130

130131
speed = rate_to_constant(rate);
131132

133+
#ifndef __MACH__
132134
if (speed == 0) {
133135
/* Custom divisor */
136+
struct serial_struct serinfo;
134137
serinfo.reserved_char[0] = 0;
135138
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
136139
return -1;
@@ -149,6 +152,7 @@ static int serial_open(const char *device, int rate)
149152
(float)serinfo.baud_base / serinfo.custom_divisor);
150153
}
151154
}
155+
#endif
152156

153157
fcntl(fd, F_SETFL, 0);
154158
tcgetattr(fd, &options);

0 commit comments

Comments
 (0)