Consistent code formatting for the core code
Code formatting was quite a mess (different indentation, completely different ideas on where opening braces should go, spacing in various places, early out versus single return or goto-based error handling, &c.). This commit cleans it up. A few doxygen comment fixes allowed turning on Clang's warnings for doxygen comments, so those are no enabled by default as least on Xcode-based builds. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
19aec98b8a
commit
13480616e0
56 changed files with 2856 additions and 4542 deletions
|
@ -157,46 +157,46 @@ inline void *ddsrt_atomic_addvoidp_nv (volatile ddsrt_atomic_voidp_t *x, ptrdiff
|
|||
|
||||
inline void ddsrt_atomic_sub32 (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
InterlockedExchangeAdd (&x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
inline void ddsrt_atomic_sub64 (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
InterlockedExchangeAdd64 (&x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#endif
|
||||
inline void ddsrt_atomic_subptr (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd) (&x->v, -v);
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
inline void ddsrt_atomic_subvoidp (volatile ddsrt_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
ddsrt_atomic_subptr ((volatile ddsrt_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
}
|
||||
inline uint32_t ddsrt_atomic_sub32_nv (volatile ddsrt_atomic_uint32_t *x, uint32_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return InterlockedExchangeAdd (&x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#if DDSRT_HAVE_ATOMIC64
|
||||
inline uint64_t ddsrt_atomic_sub64_nv (volatile ddsrt_atomic_uint64_t *x, uint64_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return InterlockedExchangeAdd64 (&x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
#endif
|
||||
inline uintptr_t ddsrt_atomic_subptr_nv (volatile ddsrt_atomic_uintptr_t *x, uintptr_t v) {
|
||||
/* disable unary minus applied to unsigned type, result still unsigned */
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
DDSRT_WARNING_MSVC_OFF(4146)
|
||||
return DDSRT_ATOMIC_PTROP (InterlockedExchangeAdd) (&x->v, -v) - v;
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
DDSRT_WARNING_MSVC_ON(4146)
|
||||
}
|
||||
inline void *ddsrt_atomic_subvoidp_nv (volatile ddsrt_atomic_voidp_t *x, ptrdiff_t v) {
|
||||
return (void *) ddsrt_atomic_subptr_nv ((volatile ddsrt_atomic_uintptr_t *) x, (uintptr_t) v);
|
||||
|
@ -280,10 +280,10 @@ inline void ddsrt_atomic_fence (void) {
|
|||
/* 28113: accessing a local variable tmp via an Interlocked
|
||||
function: This is an unusual usage which could be reconsidered.
|
||||
It is too heavyweight, true, but it does the trick. */
|
||||
DDSRT_WARNING_MSVC_OFF(28113)
|
||||
DDSRT_WARNING_MSVC_OFF(28113)
|
||||
volatile LONG tmp = 0;
|
||||
InterlockedExchange (&tmp, 0);
|
||||
DDSRT_WARNING_MSVC_ON(28113)
|
||||
DDSRT_WARNING_MSVC_ON(28113)
|
||||
}
|
||||
inline void ddsrt_atomic_fence_ldld (void) {
|
||||
#if !(defined _M_IX86 || defined _M_X64)
|
||||
|
|
20
src/ddsrt/include/dds/ddsrt/countargs.h
Normal file
20
src/ddsrt/include/dds/ddsrt/countargs.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright(c) 2019 ADLINK Technology Limited and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef DDSRT_COUNTARGS_H
|
||||
#define DDSRT_COUNTARGS_H
|
||||
|
||||
#define DDSRT_COUNT_ARGS_MSVC_WORKAROUND(x) x
|
||||
#define DDSRT_COUNT_ARGS(...) DDSRT_COUNT_ARGS1 (__VA_ARGS__, 10,9,8,7,6,5,4,3,2,1,0)
|
||||
#define DDSRT_COUNT_ARGS1(...) DDSRT_COUNT_ARGS_MSVC_WORKAROUND (DDSRT_COUNT_ARGS_ARGN (__VA_ARGS__))
|
||||
#define DDSRT_COUNT_ARGS_ARGN(a,b,c,d,e,f,g,h,i,j,n,...) n
|
||||
|
||||
#endif
|
|
@ -24,11 +24,7 @@ extern "C" {
|
|||
* @brief Get value for environment variable.
|
||||
*
|
||||
* @param[in] name Environment variable name.
|
||||
* @param[in] buf Buffer to write value to.
|
||||
* @param[in] sz Size of buffer.
|
||||
* @param[out] reqsz Number of bytes written (excluding the terminating null
|
||||
* byte), or would have been written would @buf have been
|
||||
* sufficiently large enough.
|
||||
* @param[out] value Alias to value of environment variable - must not be modified
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
|
|
|
@ -106,7 +106,7 @@ ddsrt_proc_create(
|
|||
* See ddsrt_proc_waitpids() for waiting on all child processes.
|
||||
*
|
||||
* @param[in] pid Process ID (PID) to get the exit code from.
|
||||
* @param[in] timemout Time within the process is expected to finish.
|
||||
* @param[in] timeout Time within the process is expected to finish.
|
||||
* @param[out] code The exit code of the process.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
|
@ -145,7 +145,7 @@ ddsrt_proc_waitpid(
|
|||
*
|
||||
* See ddsrt_proc_waitpid() for waiting on a specific child process.
|
||||
*
|
||||
* @param[in] timemout Time within a process is expected to finish.
|
||||
* @param[in] timeout Time within a process is expected to finish.
|
||||
* @param[out] pid Process ID (PID) of the finished process.
|
||||
* @param[out] code The exit code of the process.
|
||||
*
|
||||
|
|
|
@ -84,7 +84,7 @@ typedef int32_t dds_return_t;
|
|||
/**
|
||||
* @brief Takes the error value and outputs a string corresponding to it.
|
||||
*
|
||||
* @param[in] err Error value to be converted to a string
|
||||
* @param[in] ret Error value to be converted to a string
|
||||
*
|
||||
* @returns String corresponding to the error value
|
||||
*/
|
||||
|
|
|
@ -247,7 +247,7 @@ typedef struct {
|
|||
*
|
||||
* @param[in] name Host name to resolve.
|
||||
* @param[in] af Address family, either AF_INET, AF_INET6 or AF_UNSPEC.
|
||||
* @param[out] hent Structure of type ddsrt_hostent_t.
|
||||
* @param[out] hentp Structure of type ddsrt_hostent_t.
|
||||
*
|
||||
* @returns A dds_return_t indicating success or failure.
|
||||
*
|
||||
|
|
42
src/ddsrt/include/dds/ddsrt/static_assert.h
Normal file
42
src/ddsrt/include/dds/ddsrt/static_assert.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright(c) 2019 ADLINK Technology Limited and others
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Eclipse Public License v. 2.0 which is available at
|
||||
* http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License
|
||||
* v. 1.0 which is available at
|
||||
* http://www.eclipse.org/org/documents/edl-v10.php.
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
|
||||
*/
|
||||
#ifndef DDSRT_STATIC_ASSERT_H
|
||||
#define DDSRT_STATIC_ASSERT_H
|
||||
|
||||
/* There are many tricks to use a constant expression to yield an
|
||||
illegal type or expression at compile time, such as zero-sized
|
||||
arrays and duplicate case or enum labels. So this is but one of the
|
||||
many tricks. */
|
||||
|
||||
#define DDSRT_STATIC_ASSERT2(line, pred) \
|
||||
struct static_assert_##line { \
|
||||
char cond[(pred) ? 1 : -1]; \
|
||||
}
|
||||
#define DDSRT_STATIC_ASSERT1(line, pred) \
|
||||
DDSRT_STATIC_ASSERT2 (line, pred)
|
||||
#define DDSRT_STATIC_ASSERT(pred) \
|
||||
DDSRT_STATIC_ASSERT1 (__LINE__, pred)
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define DDSRT_STATIC_ASSERT_CODE(pred) do { switch(0) { case 0: case (pred): ; } } while (0)
|
||||
#else
|
||||
/* Temporarily disabling warning C6326: Potential comparison of a
|
||||
constant with another constant. */
|
||||
#define DDSRT_STATIC_ASSERT_CODE(pred) do { \
|
||||
__pragma (warning (push)) \
|
||||
__pragma (warning (disable : 6326)) \
|
||||
switch(0) { case 0: case (pred): ; } \
|
||||
__pragma (warning (pop)) \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -57,7 +57,7 @@ ddsrt_nonnull((1,2));
|
|||
*
|
||||
* @param[in] str String to split into tokens.
|
||||
* @param[in] delim Characters that delimit a token.
|
||||
* @param[inout] saveptr Pointer to a char * used internally.
|
||||
* @param[in,out] saveptr Pointer to a char * used internally.
|
||||
*
|
||||
* @returns The next token or NULL if there are no more tokens.
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ ddsrt_strtok_r(
|
|||
* @delim. The delimiter is overwritten with a null byte, terminating the
|
||||
* token and @stringp is updated to point past the delimiter.
|
||||
*
|
||||
* @param[inout] stringp String to extract token from.
|
||||
* @param[in,out] stringp String to extract token from.
|
||||
* @param[in] delim Characters that delimit a token.
|
||||
*
|
||||
* @returns The original value of @stringp.
|
||||
|
@ -153,7 +153,7 @@ ddsrt_nonnull((1,2));
|
|||
* string is truncated if there is not enough space. The resulting string
|
||||
* guaranteed to be null terminated if there is space.
|
||||
*
|
||||
* @param[inout] dest Destination buffer.
|
||||
* @param[in,out] dest Destination buffer.
|
||||
* @param[in] src Null terminated string to append to dest.
|
||||
* @param[in] size Number of bytes available in dest.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue