O_BINARY only defined on windows
#include "stlink-common.h"
#include "uglylogging.h"
#include "stlink-common.h"
#include "uglylogging.h"
+#ifndef _WIN32
+#define O_BINARY 0
+#endif
+
#define LOG_TAG __FILE__
#define DLOG(format, args...) ugly_log(UDEBUG, LOG_TAG, format, ## args)
#define ILOG(format, args...) ugly_log(UINFO, LOG_TAG, format, ## args)
#define LOG_TAG __FILE__
#define DLOG(format, args...) ugly_log(UDEBUG, LOG_TAG, format, ## args)
#define ILOG(format, args...) ugly_log(UINFO, LOG_TAG, format, ## args)
int error = -1;
struct stat st;
int error = -1;
struct stat st;
- const int fd = open(path, O_RDONLY);
+ const int fd = open(path, O_RDONLY | O_BINARY);
if (fd == -1) {
fprintf(stderr, "open(%s) == -1\n", path);
return -1;
if (fd == -1) {
fprintf(stderr, "open(%s) == -1\n", path);
return -1;