Return-Path: X-Original-To: apmail-qpid-commits-archive@www.apache.org Delivered-To: apmail-qpid-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE861EB05 for ; Sun, 3 Feb 2013 21:04:36 +0000 (UTC) Received: (qmail 89289 invoked by uid 500); 3 Feb 2013 21:04:36 -0000 Delivered-To: apmail-qpid-commits-archive@qpid.apache.org Received: (qmail 89260 invoked by uid 500); 3 Feb 2013 21:04:36 -0000 Mailing-List: contact commits-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@qpid.apache.org Delivered-To: mailing list commits@qpid.apache.org Received: (qmail 89252 invoked by uid 99); 3 Feb 2013 21:04:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2013 21:04:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 03 Feb 2013 21:04:31 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 707832388980; Sun, 3 Feb 2013 21:04:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1441965 - in /qpid/proton/trunk: ./ proton-c/ proton-c/include/proton/ proton-c/src/ proton-c/src/codec/ proton-c/src/dispatcher/ proton-c/src/engine/ proton-c/src/windows/ Date: Sun, 03 Feb 2013 21:04:09 -0000 To: commits@qpid.apache.org From: cliffjansen@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130203210410.707832388980@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cliffjansen Date: Sun Feb 3 21:04:08 2013 New Revision: 1441965 URL: http://svn.apache.org/viewvc?rev=1441965&view=rev Log: PROTON-213: Visual Studio / C99 grumpiness. See https://reviews.apache.org/r/9169/ Added: qpid/proton/trunk/proton-c/include/proton/type_compat.h qpid/proton/trunk/proton-c/src/platform_fmt.h Modified: qpid/proton/trunk/CMakeLists.txt qpid/proton/trunk/proton-c/CMakeLists.txt qpid/proton/trunk/proton-c/include/proton/codec.h qpid/proton/trunk/proton-c/include/proton/engine.h qpid/proton/trunk/proton-c/include/proton/framing.h qpid/proton/trunk/proton-c/include/proton/message.h qpid/proton/trunk/proton-c/include/proton/sasl.h qpid/proton/trunk/proton-c/include/proton/ssl.h qpid/proton/trunk/proton-c/include/proton/types.h qpid/proton/trunk/proton-c/src/buffer.c qpid/proton/trunk/proton-c/src/codec/codec.c qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.h qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/messenger.c qpid/proton/trunk/proton-c/src/parser.c qpid/proton/trunk/proton-c/src/platform.c qpid/proton/trunk/proton-c/src/platform.h qpid/proton/trunk/proton-c/src/scanner.c qpid/proton/trunk/proton-c/src/util.c qpid/proton/trunk/proton-c/src/util.h qpid/proton/trunk/proton-c/src/windows/driver.c Modified: qpid/proton/trunk/CMakeLists.txt URL: http://svn.apache.org/viewvc/qpid/proton/trunk/CMakeLists.txt?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/CMakeLists.txt (original) +++ qpid/proton/trunk/CMakeLists.txt Sun Feb 3 21:04:08 2013 @@ -19,6 +19,11 @@ cmake_minimum_required (VERSION 2.6) option(BUILD_WITH_CXX "Compile Proton using C++" OFF) +if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio") + # No C99 capability, use C++ + set(BUILD_WITH_CXX ON) +endif ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio") + if (BUILD_WITH_CXX) project (Proton C CXX) else (BUILD_WITH_CXX) Modified: qpid/proton/trunk/proton-c/CMakeLists.txt URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/CMakeLists.txt?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/CMakeLists.txt (original) +++ qpid/proton/trunk/proton-c/CMakeLists.txt Sun Feb 3 21:04:08 2013 @@ -114,7 +114,12 @@ else (CLOCK_GETTIME_IN_LIBC) set (TIME_LIB rt) list(APPEND PLATFORM_DEFINITIONS "USE_CLOCK_GETTIME") else (CLOCK_GETTIME_IN_RT) - list(APPEND PLATFORM_DEFINITIONS "USE_GETTIMEOFDAY") + CHECK_SYMBOL_EXISTS(GetSystemTimeAsFileTime "windows.h" WINDOWS_FILETIME) + if (WINDOWS_FILETIME) + list(APPEND PLATFORM_DEFINITIONS "USE_WIN_FILETIME") + else (WINDOWS_FILETIME) + list(APPEND PLATFORM_DEFINITIONS "USE_GETTIMEOFDAY") + endif (WINDOWS_FILETIME) endif (CLOCK_GETTIME_IN_RT) endif (CLOCK_GETTIME_IN_LIBC) @@ -158,6 +163,18 @@ if (STRERROR_R_IN_LIBC) endif (STRERROR_R_IN_LIBC) endif (PN_WINAPI) +CHECK_SYMBOL_EXISTS(atoll "stdlib.h" C99_ATOLL) +if (C99_ATOLL) + list(APPEND PLATFORM_DEFINITIONS "USE_ATOLL") +else (C99_ATOLL) + CHECK_SYMBOL_EXISTS(_atoi64 "stdlib.h" WINAPI_ATOI64) + if (WINAPI_ATOI64) + list(APPEND PLATFORM_DEFINITIONS "USE_ATOI64") + else (WINAPI_ATOI64) + message(FATAL_ERROR "No atoll API found") + endif (WINAPI_ATOI64) +endif (C99_ATOLL) + # Try to keep any platform specific overrides together here: # MacOS has a bunch of differences in build tools and process and so we have to turn some things Modified: qpid/proton/trunk/proton-c/include/proton/codec.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/codec.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/codec.h (original) +++ qpid/proton/trunk/proton-c/include/proton/codec.h Sun Feb 3 21:04:08 2013 @@ -23,9 +23,12 @@ */ #include +#ifndef __cplusplus #include #include -#include +#else +#include +#endif #include #ifdef __cplusplus Modified: qpid/proton/trunk/proton-c/include/proton/engine.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/engine.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/engine.h (original) +++ qpid/proton/trunk/proton-c/include/proton/engine.h Sun Feb 3 21:04:08 2013 @@ -22,7 +22,9 @@ * */ +#ifndef __cplusplus #include +#endif #include #include #include Modified: qpid/proton/trunk/proton-c/include/proton/framing.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/framing.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/framing.h (original) +++ qpid/proton/trunk/proton-c/include/proton/framing.h Sun Feb 3 21:04:08 2013 @@ -22,7 +22,11 @@ * */ +#ifndef __cplusplus #include +#else +#include +#endif #include #ifdef __cplusplus Modified: qpid/proton/trunk/proton-c/include/proton/message.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/message.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/message.h (original) +++ qpid/proton/trunk/proton-c/include/proton/message.h Sun Feb 3 21:04:08 2013 @@ -25,7 +25,9 @@ #include #include #include +#ifndef __cplusplus #include +#endif #ifdef __cplusplus extern "C" { Modified: qpid/proton/trunk/proton-c/include/proton/sasl.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/sasl.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/sasl.h (original) +++ qpid/proton/trunk/proton-c/include/proton/sasl.h Sun Feb 3 21:04:08 2013 @@ -23,7 +23,9 @@ */ #include +#ifndef __cplusplus #include +#endif #include #ifdef __cplusplus Modified: qpid/proton/trunk/proton-c/include/proton/ssl.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/ssl.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/ssl.h (original) +++ qpid/proton/trunk/proton-c/include/proton/ssl.h Sun Feb 3 21:04:08 2013 @@ -23,7 +23,9 @@ */ #include +#ifndef __cplusplus #include +#endif #include #ifdef __cplusplus Added: qpid/proton/trunk/proton-c/include/proton/type_compat.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/type_compat.h?rev=1441965&view=auto ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/type_compat.h (added) +++ qpid/proton/trunk/proton-c/include/proton/type_compat.h Sun Feb 3 21:04:08 2013 @@ -0,0 +1,117 @@ +#ifndef PROTON_TYPE_COMPAT_H +#define PROTON_TYPE_COMPAT_H 1 + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/* + * Handle special cases for stdint.h and the definition for ssize_t. + * Third party libraries (e.g. Boost) may provide competing solutions. + * + * The effects of this include file may be controlled by overrides: + * PN_DEFINE_STDINT/PN_NODEFINE_STDINT : turn on/off definition of int64_t etc. + * PN_DEFINE_SSIZE_T/PN_NODEFINE_SSIZE_T : turn on/off definition of ssize_t + * PN_INCLUDE_STDINT/PN_NOINCLUDE_STDINT : include (or not) stdint.h + */ + +// Honor positive overrides +#if defined(PN_DEFINE_STDINT) +#define PNI_DEFINE_STDINT +#endif +#if defined(PN_INCLUDE_STDINT) +#define PNI_INCLUDE_STDINT) +#endif +#if defined(PN_DEFINE_SSIZE_T) +#define PNI_DEFINE_SSIZE_T +#endif + +// Determinine default action +#ifndef _MSC_VER +// Not Windows and not using Visual Studio +#ifndef PNI_INCLUDE_STDINT +#define PNI_INCLUDE_STDINT +#endif +#else +// all versions of Visual Studio +#ifndef PNI_DEFINE_SSIZE_T +// ssie_t def is needed, unless third party definition interferes, e.g. python/swig +#ifndef Py_CONFIG_H +#define PNI_DEFINE_SSIZE_T +#endif +#endif + +#if (_MSC_VER < 1600) +// VS 2008 and earlier +#ifndef PNI_DEFINE_STDINT +#define PNI_DEFINE_STDINT +#endif +#else +// VS 2010 and newer +#ifndef PNI_INCLUDE_STDINT +#define PNI_INCLUDE_STDINT +#endif + +#endif // (_MSC_VER < 1600) +#endif //_MSC_VER + +// Honor negative overrides +#ifdef PN_NODEFINE_SSIZE_T +#undef PNI_DEFINE_SSIZE_T +#endif +#ifdef PN_NODEFINE_STDINT +#undef PNI_DEFINE_STDINT +#endif +#ifdef PN_NOINCLUDE_STDINT +#undef PNI_INCLUDE_STDINT +#endif + +#ifdef PNI_INCLUDE_STDINT +#include +#endif + +#ifdef PNI_DEFINE_SSIZE_T +#ifdef _MSC_VER +#include +typedef SSIZE_T ssize_t; +#else +#error ssize_t definition not kown +#endif +#endif // PNI_DEFINE_SSIZE_T + +#ifdef PNI_DEFINE_STDINT +#ifdef _MSC_VER + +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef signed __int64 int64_t; + +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#else // _MSC_VER +#error stdint.h definitions not kown +#endif +#endif // PNI_DEFINE_SSIZE_T + +#endif /* type_compat.h */ Modified: qpid/proton/trunk/proton-c/include/proton/types.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/types.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/include/proton/types.h (original) +++ qpid/proton/trunk/proton-c/include/proton/types.h Sun Feb 3 21:04:08 2013 @@ -23,7 +23,12 @@ */ #include +#ifndef __cplusplus #include +#else +#include +#endif + #ifdef __cplusplus extern "C" { Modified: qpid/proton/trunk/proton-c/src/buffer.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/buffer.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/buffer.c (original) +++ qpid/proton/trunk/proton-c/src/buffer.c Sun Feb 3 21:04:08 2013 @@ -21,7 +21,9 @@ #include #include +#ifndef __cplusplus #include +#endif #include #include #include Modified: qpid/proton/trunk/proton-c/src/codec/codec.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/codec/codec.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/codec/codec.c (original) +++ qpid/proton/trunk/proton-c/src/codec/codec.c Sun Feb 3 21:04:08 2013 @@ -283,11 +283,11 @@ int pn_format_atom(pn_bytes_t *bytes, pn case PN_DESCRIPTOR: return pn_bytes_format(bytes, "descriptor"); case PN_ARRAY: - return pn_bytes_format(bytes, "array[%zu]", atom.u.count); + return pn_bytes_format(bytes, "array[%" PN_ZU "]", atom.u.count); case PN_LIST: - return pn_bytes_format(bytes, "list[%zu]", atom.u.count); + return pn_bytes_format(bytes, "list[%" PN_ZU "]", atom.u.count); case PN_MAP: - return pn_bytes_format(bytes, "map[%zu]", atom.u.count); + return pn_bytes_format(bytes, "map[%" PN_ZU "]", atom.u.count); } return PN_ARG_ERR; @@ -1923,13 +1923,14 @@ bool pn_data_exit(pn_data_t *data) void pn_data_dump(pn_data_t *data) { char buf[1024]; - printf("{current=%zi, parent=%zi}\n", data->current, data->parent); + printf("{current=%" PN_ZI ", parent=%" PN_ZI "}\n", data->current, data->parent); for (unsigned i = 0; i < data->size; i++) { pn_node_t *node = &data->nodes[i]; pn_bytes_t bytes = pn_bytes(1024, buf); pn_format_atom(&bytes, node->atom); - printf("Node %i: prev=%zi, next=%zi, parent=%zi, down=%zi, children=%zi, type=%i (%s)\n", + printf("Node %i: prev=%" PN_ZI ", next=%" PN_ZI ", parent=%" PN_ZI ", down=%" PN_ZI + ", children=%" PN_ZI ", type=%i (%s)\n", i + 1, node->prev, node->next, node->parent, node->down, node->children, node->atom.type, buf); } Modified: qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c (original) +++ qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c Sun Feb 3 21:04:08 2013 @@ -28,6 +28,7 @@ #include "dispatcher.h" #include "protocol.h" #include "../util.h" +#include "../platform_fmt.h" pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, void *context) { @@ -95,7 +96,7 @@ static void pn_do_trace(pn_dispatcher_t if (size) { char buf[1024]; int e = pn_quote_data(buf, 1024, payload, size); - fprintf(stderr, " (%zu) \"%s\"%s\n", size, buf, + fprintf(stderr, " (%" PN_ZU ") \"%s\"%s\n", size, buf, e == PN_OVERFLOW ? "... (truncated)" : ""); } else { fprintf(stderr, "\n"); Modified: qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.h (original) +++ qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.h Sun Feb 3 21:04:08 2013 @@ -23,7 +23,9 @@ */ #include +#ifndef __cplusplus #include +#endif #include #include Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Sun Feb 3 21:04:08 2013 @@ -2552,7 +2552,7 @@ ssize_t pn_transport_output(pn_transport if (n == PN_EOS) pn_dispatcher_trace(transport->disp, 0, "-> EOS\n"); else - pn_dispatcher_trace(transport->disp, 0, "-> EOS (%zi) %s\n", n, + pn_dispatcher_trace(transport->disp, 0, "-> EOS (%" PN_ZI ") %s\n", n, pn_error_text(transport->error)); } return n; Modified: qpid/proton/trunk/proton-c/src/messenger.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/messenger.c (original) +++ qpid/proton/trunk/proton-c/src/messenger.c Sun Feb 3 21:04:08 2013 @@ -28,9 +28,9 @@ #include #include #include -#include #include "util.h" #include "platform.h" +#include "platform_fmt.h" typedef struct { size_t capacity; @@ -1132,7 +1132,7 @@ int pn_messenger_get(pn_messenger_t *mes char *encoded = pn_buffer_bytes(buf).start; ssize_t n = pn_link_recv(l, encoded, pending); if (n != (ssize_t) pending) { - return pn_error_format(messenger->error, n, "didn't receive pending bytes: %zi", n); + return pn_error_format(messenger->error, n, "didn't receive pending bytes: %" PN_ZI, n); } n = pn_link_recv(l, encoded + pending, 1); pn_link_advance(l); Modified: qpid/proton/trunk/proton-c/src/parser.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/parser.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/parser.c (original) +++ qpid/proton/trunk/proton-c/src/parser.c Sun Feb 3 21:04:08 2013 @@ -25,6 +25,7 @@ #include #include #include +#include "platform.h" struct pn_parser_t { pn_scanner_t *scanner; @@ -244,7 +245,7 @@ int pn_parser_number(pn_parser_t *parser err = pn_data_put_double(data, value); if (err) return pn_parser_err(parser, err, "error writing double"); } else { - int64_t value = atoll(number); + int64_t value = pn_i_atoll(number); if (negate) { value = -value; } Modified: qpid/proton/trunk/proton-c/src/platform.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/platform.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/platform.c (original) +++ qpid/proton/trunk/proton-c/src/platform.c Sun Feb 3 21:04:08 2013 @@ -32,6 +32,18 @@ pn_timestamp_t pn_i_now(void) if (clock_gettime(CLOCK_REALTIME, &now)) pn_fatal("clock_gettime() failed\n"); return ((pn_timestamp_t)now.tv_sec) * 1000 + (now.tv_nsec / 1000000); } +#elif defined(USE_WIN_FILETIME) +#include +pn_timestamp_t pn_i_now(void) +{ + FILETIME now; + GetSystemTimeAsFileTime(&now); + ULARGE_INTEGER t; + t.u.HighPart = now.dwHighDateTime; + t.u.LowPart = now.dwLowDateTime; + // Convert to milliseconds and adjust base epoch + return t.QuadPart / 10000 - 11644473600000; +} #else #include pn_timestamp_t pn_i_now(void) @@ -108,3 +120,16 @@ int pn_i_error_from_errno(pn_error_t *er return pn_error_format(error, code, "%s: %s", msg, err); } +#ifdef USE_ATOLL +#include +int64_t pn_i_atoll(const char* num) { + return atoll(num); +} +#elif USE_ATOI64 +#include +int64_t pn_i_atoll(const char* num) { + return _atoi64(num); +} +#else +#error "Don't know how to convert int64_t values on this platform" +#endif Modified: qpid/proton/trunk/proton-c/src/platform.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/platform.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/platform.h (original) +++ qpid/proton/trunk/proton-c/src/platform.h Sun Feb 3 21:04:08 2013 @@ -63,8 +63,24 @@ char* pn_i_genuuid(void); */ int pn_i_error_from_errno(pn_error_t *error, const char *msg); +/** Provide C99 atoll functinality. + * + * @param[in] num the string representation of the number. + * @return the integer value. + * + * @internal + */ +int64_t pn_i_atoll(const char* num); + +#ifdef _MSC_VER +// TODO: PROTON-212 +#define snprintf _snprintf +#endif + + + #ifdef __cplusplus } #endif -#endif /* driver.h */ +#endif /* platform.h */ Added: qpid/proton/trunk/proton-c/src/platform_fmt.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/platform_fmt.h?rev=1441965&view=auto ============================================================================== --- qpid/proton/trunk/proton-c/src/platform_fmt.h (added) +++ qpid/proton/trunk/proton-c/src/platform_fmt.h Sun Feb 3 21:04:08 2013 @@ -0,0 +1,66 @@ +#ifndef _PROTON_SRC_PLATFORM_FMT_H +#define _PROTON_SRC_PLATFORM_FMT_H 1 + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +/* + * Platform dependent type-specific format specifiers for PRIx and %z + * for use with printf. PRIx defs are normally available in + * inttypes.h (C99), but extra steps are required for C++, and they + * are not available in Visual Studio at all. + * Visual studio uses "%I" for size_t instead of "%z". + */ + +#ifndef __cplusplus + +// normal case +#include +#define PN_ZI "zi" +#define PN_ZU "zu" + +#else + +#ifdef _MSC_VER +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "I64u" + +#define PRIi8 "i" +#define PRIi16 "i" +#define PRIi32 "i" +#define PRIi64 "I64i" + +#define PN_ZI "Ii" +#define PN_ZU "Iu" +#else +// Normal C++ +#define __STDC_FORMAT_MACROS +#include +#define PN_ZI "zi" +#define PN_ZU "zu" + +#endif /* _MSC_VER */ + +#endif /* __cplusplus */ + +#endif /* platform_fmt.h */ Modified: qpid/proton/trunk/proton-c/src/scanner.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/scanner.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/scanner.c (original) +++ qpid/proton/trunk/proton-c/src/scanner.c Sun Feb 3 21:04:08 2013 @@ -21,11 +21,13 @@ #include #include +#ifndef __cplusplus #include +#endif #include #include #include -#include +#include "platform.h" #define ERROR_SIZE (1024) Modified: qpid/proton/trunk/proton-c/src/util.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/util.c (original) +++ qpid/proton/trunk/proton-c/src/util.c Sun Feb 3 21:04:08 2013 @@ -20,14 +20,17 @@ */ #include -#include #include #include #include +#ifndef __cplusplus #include +#include +#else +#include +#endif #include #include -#include // For non C89/C99 strcasecmp #include #include #include Modified: qpid/proton/trunk/proton-c/src/util.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.h?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/util.h (original) +++ qpid/proton/trunk/proton-c/src/util.h Sun Feb 3 21:04:08 2013 @@ -23,7 +23,9 @@ */ #include +#ifndef __cplusplus #include +#endif #include #include #include Modified: qpid/proton/trunk/proton-c/src/windows/driver.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/windows/driver.c?rev=1441965&r1=1441964&r2=1441965&view=diff ============================================================================== --- qpid/proton/trunk/proton-c/src/windows/driver.c (original) +++ qpid/proton/trunk/proton-c/src/windows/driver.c Sun Feb 3 21:04:08 2013 @@ -40,7 +40,6 @@ #if _WIN32_WINNT < 0x0501 #error "Proton requires Windows API support for XP or later." #endif -#include #include #include #define PN_WINAPI @@ -49,7 +48,6 @@ #include #include #include -#include #include #include "../platform.h" @@ -106,7 +104,7 @@ static inline pn_socket_t pn_create_sock } #elif defined(PN_WINAPI) static inline ssize_t pn_send(pn_socket_t sockfd, const void *buf, size_t len) { - return send(sockfd, buf, len, 0); + return send(sockfd, (const char *) buf, len, 0); } static inline pn_socket_t pn_create_socket() { @@ -782,7 +780,7 @@ void pn_driver_free(pn_driver_t *d) int pn_driver_wakeup(pn_driver_t *d) { if (d) { - ssize_t count = write(d->ctrl[1], "x", 1); + ssize_t count = send(d->ctrl[1], "x", 1, 0); if (count <= 0) { return count; } else { @@ -807,7 +805,7 @@ static void pn_driver_rebuild(pn_driver_ // if (d->ctrl[0] > d->max_fds) d->max_fds = d->ctrl[0]; pn_listener_t *l = d->listener_head; - for (int i = 0; i < d->listener_count; i++) { + for (unsigned i = 0; i < d->listener_count; i++) { if (r_avail) { FD_SET(l->fd, &d->readfds); // if (l->fd > d->max_fds) d->max_fds = l->fd; @@ -821,7 +819,7 @@ static void pn_driver_rebuild(pn_driver_ } pn_connector_t *c = d->connector_head; - for (int i = 0; i < d->connector_count; i++) + for (unsigned i = 0; i < d->connector_count; i++) { if (!c->closed) { d->wakeup = pn_timestamp_min(d->wakeup, c->wakeup); @@ -888,7 +886,7 @@ void pn_driver_wait_3(pn_driver_t *d) if (FD_ISSET(d->ctrl[0], &d->readfds)) { //clear the pipe char buffer[512]; - while (read(d->ctrl[0], buffer, 512) == 512); + while (recv(d->ctrl[0], buffer, 512, 0) == 512); } pn_listener_t *l = d->listener_head; @@ -974,7 +972,7 @@ pn_connector_t *pn_driver_connector(pn_d static int pn_socket_pair (SOCKET sv[2]) { // no socketpair on windows. provide pipe() semantics using sockets - int sock = socket(AF_INET, SOCK_STREAM, getprotobyname("tcp")->p_proto); + SOCKET sock = socket(AF_INET, SOCK_STREAM, getprotobyname("tcp")->p_proto); if (sock == INVALID_SOCKET) { perror("socket"); return -1; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org For additional commands, e-mail: commits-help@qpid.apache.org