Merge branch 'platform'
This commit is contained in:
commit
94f739ab52
@ -692,6 +692,10 @@
|
||||
RelativePath="..\include\libdivecomputer\parser.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\platform.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\rbstream.h"
|
||||
>
|
||||
|
||||
@ -63,6 +63,7 @@ libdivecomputer_la_SOURCES = \
|
||||
diverite_nitekq.h diverite_nitekq.c diverite_nitekq_parser.c \
|
||||
citizen_aqualand.h citizen_aqualand.c citizen_aqualand_parser.c \
|
||||
divesystem_idive.h divesystem_idive.c divesystem_idive_parser.c \
|
||||
platform.h \
|
||||
ringbuffer.h ringbuffer.c \
|
||||
rbstream.h rbstream.c \
|
||||
checksum.h checksum.c \
|
||||
|
||||
@ -30,10 +30,7 @@
|
||||
#include "serial.h"
|
||||
#include "array.h"
|
||||
#include "aes.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#include "platform.h"
|
||||
|
||||
#define ISINSTANCE(device) dc_device_isinstance((device), &hw_ostc3_device_vtable)
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@
|
||||
#include "common-private.h"
|
||||
#include "context-private.h"
|
||||
#include "array.h"
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef int s_ssize_t;
|
||||
@ -82,10 +83,6 @@ typedef int s_errcode_t;
|
||||
#define S_CLOSE close
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
struct dc_irda_t {
|
||||
dc_context_t *context;
|
||||
#ifdef _WIN32
|
||||
|
||||
50
src/platform.h
Normal file
50
src/platform.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2017 Jef Driesen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef DC_PLATFORM_H
|
||||
#define DC_PLATFORM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DC_PRINTF_SIZE "%Iu"
|
||||
#else
|
||||
#define DC_PRINTF_SIZE "%zu"
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
#if _MSC_VER < 1800
|
||||
// The rint() function is only available in MSVC 2013 and later
|
||||
// versions. Our replacement macro isn't entirely correct, because the
|
||||
// rounding rules for halfway cases are slightly different (away from
|
||||
// zero vs to even). But for our use-case, that's not a problem.
|
||||
#define rint(x) ((x) >= 0.0 ? floor((x) + 0.5): ceil((x) - 0.5))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DC_PLATFORM_H */
|
||||
@ -28,10 +28,7 @@
|
||||
#include "device-private.h"
|
||||
#include "array.h"
|
||||
#include "usbhid.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#include "platform.h"
|
||||
|
||||
typedef struct suunto_eonsteel_device_t {
|
||||
dc_device_t base;
|
||||
@ -140,7 +137,7 @@ static int receive_packet(suunto_eonsteel_device_t *eon, unsigned char *buffer,
|
||||
return -1;
|
||||
}
|
||||
if (transferred != PACKET_SIZE) {
|
||||
ERROR(eon->base.context, "incomplete read interrupt transfer (got %zu, expected %d)", transferred, PACKET_SIZE);
|
||||
ERROR(eon->base.context, "incomplete read interrupt transfer (got " DC_PRINTF_SIZE ", expected %d)", transferred, PACKET_SIZE);
|
||||
return -1;
|
||||
}
|
||||
if (buf[0] != 0x3f) {
|
||||
|
||||
@ -28,17 +28,7 @@
|
||||
#include "context-private.h"
|
||||
#include "parser-private.h"
|
||||
#include "array.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define strcasecmp _stricmp
|
||||
#if _MSC_VER < 1800
|
||||
// The rint() function is only available in MSVC 2013 and later
|
||||
// versions. Our replacement macro isn't entirely correct, because the
|
||||
// rounding rules for halfway cases are slightly different (away from
|
||||
// zero vs to even). But for our use-case, that's not a problem.
|
||||
#define rint(x) ((x) >= 0.0 ? floor((x) + 0.5): ceil((x) - 0.5))
|
||||
#endif
|
||||
#endif
|
||||
#include "platform.h"
|
||||
|
||||
#define C_ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@
|
||||
#include "device-private.h"
|
||||
#include "usbhid.h"
|
||||
#include "array.h"
|
||||
#include "platform.h"
|
||||
|
||||
#define ISINSTANCE(device) dc_device_isinstance((device), &uwatec_g2_device_vtable)
|
||||
|
||||
@ -76,7 +77,7 @@ receive_data (uwatec_g2_device_t *device, dc_event_progress_t *progress, unsigne
|
||||
return rc;
|
||||
}
|
||||
if (transferred != PACKET_SIZE) {
|
||||
ERROR (device->base.context, "incomplete read interrupt transfer (got %zu, expected %d)", transferred, PACKET_SIZE);
|
||||
ERROR (device->base.context, "incomplete read interrupt transfer (got " DC_PRINTF_SIZE ", expected %d)", transferred, PACKET_SIZE);
|
||||
return DC_STATUS_PROTOCOL;
|
||||
}
|
||||
len = buf[0];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user