fixup comments on #endif statements

This commit is contained in:
William Woodall 2015-12-15 18:50:34 -08:00
parent abc1f87f63
commit aa83632ffe
7 changed files with 24 additions and 27 deletions

View file

@ -24,7 +24,7 @@ extern "C"
#if defined(WIN32) #if defined(WIN32)
#define WINDOWS_ENV_BUFFER_SIZE 2048 #define WINDOWS_ENV_BUFFER_SIZE 2048
static char __env_buffer[WINDOWS_ENV_BUFFER_SIZE]; static char __env_buffer[WINDOWS_ENV_BUFFER_SIZE];
#endif #endif // defined(WIN32)
rcl_ret_t rcl_ret_t
rcl_impl_getenv(const char * env_name, const char ** env_value) rcl_impl_getenv(const char * env_name, const char ** env_value)
@ -37,7 +37,7 @@ rcl_impl_getenv(const char * env_name, const char ** env_value)
if (*env_value == NULL) { if (*env_value == NULL) {
*env_value = ""; *env_value = "";
} }
#else #else // !defined(WIN32)
size_t required_size; size_t required_size;
errno_t ret = getenv_s(&required_size, __env_buffer, sizeof(__env_buffer), env_name); errno_t ret = getenv_s(&required_size, __env_buffer, sizeof(__env_buffer), env_name);
if (ret != 0) { if (ret != 0) {
@ -46,7 +46,7 @@ rcl_impl_getenv(const char * env_name, const char ** env_value)
} }
__env_buffer[WINDOWS_ENV_BUFFER_SIZE - 1] = '\0'; __env_buffer[WINDOWS_ENV_BUFFER_SIZE - 1] = '\0';
*env_value = __env_buffer; *env_value = __env_buffer;
#endif #endif // !defined(WIN32)
return RCL_RET_OK; return RCL_RET_OK;
} }

View file

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifdef WIN32 #if defined(WIN32)
#include "./time_win32.c" #include "./time_win32.c"
#else #else // defined(WIN32)
#include "./time_unix.c" #include "./time_unix.c"
#endif #endif // defined(WIN32)

View file

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifdef WIN32 #if defined(WIN32)
#error time_unix.c is not intended to be used with win32 based systems #error time_unix.c is not intended to be used with win32 based systems
#endif #endif // defined(WIN32)
#if __cplusplus #if __cplusplus
extern "C" extern "C"
@ -26,7 +26,7 @@ extern "C"
#if defined(__MACH__) #if defined(__MACH__)
#include <mach/clock.h> #include <mach/clock.h>
#include <mach/mach.h> #include <mach/mach.h>
#endif #endif // defined(__MACH__)
#include <math.h> #include <math.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -37,10 +37,10 @@ extern "C"
#if !defined(__MACH__) // Assume clock_get_time is available on OS X. #if !defined(__MACH__) // Assume clock_get_time is available on OS X.
// This id an appropriate check for clock_gettime() according to: // This id an appropriate check for clock_gettime() according to:
// http://man7.org/linux/man-pages/man2/clock_gettime.2.html // http://man7.org/linux/man-pages/man2/clock_gettime.2.html
#if (!defined(_POSIX_TIMERS) || !_POSIX_TIMERS) #if !defined(_POSIX_TIMERS) || !_POSIX_TIMERS
#error no monotonic clock function available #error no monotonic clock function available
#endif #endif // !defined(_POSIX_TIMERS) || !_POSIX_TIMERS
#endif #endif // !defined(__MACH__)
#define __WOULD_BE_NEGATIVE(seconds, subseconds) (seconds < 0 || (subseconds < 0 && seconds == 0)) #define __WOULD_BE_NEGATIVE(seconds, subseconds) (seconds < 0 || (subseconds < 0 && seconds == 0))
@ -58,10 +58,10 @@ rcl_system_time_point_now(rcl_system_time_point_t * now)
mach_port_deallocate(mach_task_self(), cclock); mach_port_deallocate(mach_task_self(), cclock);
timespec_now.tv_sec = mts.tv_sec; timespec_now.tv_sec = mts.tv_sec;
timespec_now.tv_nsec = mts.tv_nsec; timespec_now.tv_nsec = mts.tv_nsec;
#else #else // defined(__MACH__)
// Otherwise use clock_gettime. // Otherwise use clock_gettime.
clock_gettime(CLOCK_REALTIME, &timespec_now); clock_gettime(CLOCK_REALTIME, &timespec_now);
#endif // if defined(__MACH__) #endif // defined(__MACH__)
if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) {
RCL_SET_ERROR_MSG("unexpected negative time"); RCL_SET_ERROR_MSG("unexpected negative time");
return RCL_RET_ERROR; return RCL_RET_ERROR;
@ -85,14 +85,14 @@ rcl_steady_time_point_now(rcl_steady_time_point_t * now)
mach_port_deallocate(mach_task_self(), cclock); mach_port_deallocate(mach_task_self(), cclock);
timespec_now.tv_sec = mts.tv_sec; timespec_now.tv_sec = mts.tv_sec;
timespec_now.tv_nsec = mts.tv_nsec; timespec_now.tv_nsec = mts.tv_nsec;
#else #else // defined(__MACH__)
// Otherwise use clock_gettime. // Otherwise use clock_gettime.
#ifdef CLOCK_MONOTONIC_RAW #if defined(CLOCK_MONOTONIC_RAW)
clock_gettime(CLOCK_MONOTONIC_RAW, &timespec_now); clock_gettime(CLOCK_MONOTONIC_RAW, &timespec_now);
#else #else // defined(CLOCK_MONOTONIC_RAW)
clock_gettime(CLOCK_MONOTONIC, &timespec_now); clock_gettime(CLOCK_MONOTONIC, &timespec_now);
#endif // CLOCK_MONOTONIC_RAW #endif // defined(CLOCK_MONOTONIC_RAW)
#endif // if defined(__MACH__) #endif // defined(__MACH__)
if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) { if (__WOULD_BE_NEGATIVE(timespec_now.tv_sec, timespec_now.tv_nsec)) {
RCL_SET_ERROR_MSG("unexpected negative time"); RCL_SET_ERROR_MSG("unexpected negative time");
return RCL_RET_ERROR; return RCL_RET_ERROR;

View file

@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifdef WIN32
#ifndef WIN32 #ifndef WIN32
#error time_win32.c is only intended to be used with win32 based systems #error time_win32.c is only intended to be used with win32 based systems
#endif #endif
@ -68,5 +67,3 @@ rcl_steady_time_point_now(rcl_steady_time_point_t * now)
#if __cplusplus #if __cplusplus
} }
#endif #endif
#endif

View file

@ -138,4 +138,4 @@ void set_on_unepexcted_free_callback(UnexpectedCallbackType callback) {}
void memory_checking_thread_init() {} void memory_checking_thread_init() {}
#endif // !defined(WIN32) #endif // if defined(__linux__) elif defined(__APPLE__) elif defined(WIN32) else ...

View file

@ -20,9 +20,9 @@
#if defined(__APPLE__) #if defined(__APPLE__)
#include <malloc/malloc.h> #include <malloc/malloc.h>
#define MALLOC_PRINTF malloc_printf #define MALLOC_PRINTF malloc_printf
#else #else // defined(__APPLE__)
#define MALLOC_PRINTF printf #define MALLOC_PRINTF printf
#endif #endif // defined(__APPLE__)
#include "./memory_tools.hpp" #include "./memory_tools.hpp"
#include "./scope_exit.hpp" #include "./scope_exit.hpp"

View file

@ -49,10 +49,10 @@ public:
/* Tests the default allocator. /* Tests the default allocator.
*/ */
TEST_F(TestAllocatorFixture, test_default_allocator_normal) { TEST_F(TestAllocatorFixture, test_default_allocator_normal) {
#ifdef WIN32 #if defined(WIN32)
printf("Allocator tests disabled on Windows.\n"); printf("Allocator tests disabled on Windows.\n");
return; return;
#endif #endif // defined(WIN32)
ASSERT_NO_MALLOC( ASSERT_NO_MALLOC(
rcl_allocator_t allocator = rcl_get_default_allocator(); rcl_allocator_t allocator = rcl_get_default_allocator();
) )