message("############ This build will not include doxygen, tools, or tests")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
-# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
-# set(CMAKE_C_FLAGS_NOPANTS "${CMAKE_C_FLAGS_NOPANTS} -O3 -DNDEBUG -DPARCLibrary_DISABLE_VALIDATION")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
find_package( Doxygen )
endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}")
-set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS} -DPARCLibrary_DISABLE_VALIDATION -DLongBow_DISABLE_ASSERTIONS")
+set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS} -DPARCLibrary_DISABLE_VALIDATION")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${CMAKE_C_FLAGS}")
if (DOC_ONLY)
message("############ Skipping check of required dependencies.")
elseif(COMPILE_FOR_IOS)
- find_host_package( LongBow REQUIRED )
- include_directories(${LONGBOW_INCLUDE_DIRS})
-
- find_host_package( LibEvent REQUIRED )
+find_host_package( LibEvent REQUIRED )
include_directories(${LIBEVENT_INCLUDE_DIRS})
find_host_package ( OpenSSL REQUIRED )
else()
- find_package( LongBow REQUIRED )
- include_directories(${LONGBOW_INCLUDE_DIRS})
-
find_package( LibEvent REQUIRED )
include_directories(${LIBEVENT_INCLUDE_DIRS})
+ if(ENABLE_TEST)
+ find_package( LongBow REQUIRED )
+ include_directories(${LONGBOW_INCLUDE_DIRS})
+ endif()
+
find_package ( Threads REQUIRED )
find_package ( OpenSSL REQUIRED )
include_directories(${OPENSSL_INCLUDE_DIR})
-endif()
-set(PARC_BIN_LIBRARIES
- parc
- ${LONGBOW_LIBRARIES}
- ${LIBEVENT_LIBRARIES}
- ${OPENSSL_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- )
+endif()
+if(ENABLE_TEST)
+ message("############ Test enabled")
+ set(PARC_BIN_LIBRARIES
+ parc
+ ${LONGBOW_LIBRARIES}
+ ${LIBEVENT_LIBRARIES}
+ ${OPENSSL_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+else()
+ set(PARC_BIN_LIBRARIES
+ parc
+ ${LIBEVENT_LIBRARIES}
+ ${OPENSSL_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
elseif(COMPILE_FOR_IOS)
macro(AddTest testFile)
message("iOS build: Skipping test ${ARGV0}")
+ set(CMAKE_C_FLAGS_NOPANTS "${CMAKE_C_FLAGS_NOPANTS} -O3 -DNDEBUG -DPARCLibrary_DISABLE_VALIDATION")
endmacro(AddTest)
else()
macro(AddTest testFile)
# set(CPACK_DEBIAN_LIBRARY_PACKAGE_SHLIBDEPS ON)
- set(CPACK_${TYPE}_LIBRARY_PACKAGE_DEPENDS "longbow (>= 1.0)")
- set(CPACK_${TYPE}_HEADERS_PACKAGE_DEPENDS "libparc (>= 1.0), longbow-dev (>= 1.0), libevent-dev, libssl-dev")
- set(CPACK_${TYPE}_DOCUMENTATION_PACKAGE_DEPENDS "")
+ if(ENABLE_TEST)
+ set(CPACK_${TYPE}_LIBRARY_PACKAGE_DEPENDS "longbow (>= 1.0)")
+ set(CPACK_${TYPE}_HEADERS_PACKAGE_DEPENDS "libparc (>= 1.0), longbow-dev (>= 1.0), libevent-dev, libssl-dev")
+ else()
+ set(CPACK_${TYPE}_HEADERS_PACKAGE_DEPENDS "libparc (>= 1.0), libevent-dev, libssl-dev")
+ set(CPACK_${TYPE}_DOCUMENTATION_PACKAGE_DEPENDS "")
+ endif()
elseif(RPM_PACKAGE)
set(TYPE "RPM")
set(GENERATOR "RPM")
set(CPACK_${TYPE}_DOCUMENTATION_FILE_NAME "${PACKAGE_NAME}-doc-${PACKAGE_VERSION}.${ARCHITECTURE}.rpm")
set(CPACK_${TYPE}_LIBRARY_PACKAGE_AUTOREQ ON)
-
- set(CPACK_${TYPE}_LIBRARY_PACKAGE_REQUIRES "longbow >= 1.0")
- set(CPACK_${TYPE}_HEADERS_PACKAGE_REQUIRES "libparc >= 1.0, longbow-devel >= 1.0, libevent-devel, openssl-devel")
- set(CPACK_${TYPE}_DOCUMENTATION_PACKAGE_REQUIRES "")
+ if(ENABLE_TEST)
+ set(CPACK_${TYPE}_LIBRARY_PACKAGE_REQUIRES "longbow >= 1.0")
+ set(CPACK_${TYPE}_HEADERS_PACKAGE_REQUIRES "libparc >= 1.0, longbow-devel >= 1.0, libevent-devel, openssl-devel")
+ else()
+ set(CPACK_${TYPE}_HEADERS_PACKAGE_REQUIRES "libparc >= 1.0, libevent-devel, openssl-devel")
+ set(CPACK_${TYPE}_DOCUMENTATION_PACKAGE_REQUIRES "")
+ endif()
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/etc" "/usr/lib/python2.7" "/usr/lib/python2.7/site-packages")
else()
$ cmake ..
or, for MacOSX 10.12, you need to speficy openssl root folder
$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
+
+otherwise, if you want to build also the tests you need to specify the following flag
+$ cmake .. -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DENABLE_TEST=on
+
$ make
$ make test
$ make install
- OpenSSL
- pthreads
- Libevent
-- LongBow
Documentation dependencies:
doxygen-libparc: libparc.doxygen
${DOXYGEN_BIN} -s libparc.doxygen
- ${prefix}/bin/longbow-doxygen-report -a --doxygenlog libparc-doxygen.log
website: libparc-doxygen.log
$(MAKE) -C Jekyll
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.
-TAGFILES = ../../Longbow/documentation/longbow.doctags=
+TAGFILES = ../../tagfiles/documentation/tagfiles.doctags=
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
# the path). If a tag file is not located in the directory in which doxygen is
# run, you must also specify the path to the tagfile here.
-TAGFILES = ../../Longbow/documentation/longbow.doctags=https://parc.github.io/LongBow/
+TAGFILES = ../../tagfile/documentation/tagfile.doctags
# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
# tag file that is based on the input files it reads. See section "Linking to
static bool
_parcMyObject_Destructor(PARCMyObject **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCMyObject pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCMyObject pointer.");
/* cleanup the instance fields here */
void
parcMyObject_AssertValid(const PARCMyObject *instance)
{
- assertTrue(parcMyObject_IsValid(instance),
+ parcAssertTrue(parcMyObject_IsValid(instance),
"PARCMyObject is not valid.");
}
static bool
_parcSimpleBufferPool_Destructor(PARCSimpleBufferPool **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSimpleBufferPool pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSimpleBufferPool pointer.");
PARCSimpleBufferPool *pool = *instancePtr;
algol/parc_Base64.c
algol/parc_BitVector.c
algol/parc_Buffer.c
- algol/parc_BufferChunker.c
+ algol/parc_BufferChunker.c
algol/parc_BufferComposer.c
algol/parc_BufferDictionary.c
algol/parc_ByteArray.c
algol/parc_Clock.c
- algol/parc_Chunker.c
+ algol/parc_Chunker.c
algol/parc_Deque.c
algol/parc_Dictionary.c
algol/parc_DisplayIndented.c
algol/parc_Environment.c
algol/parc_File.c
- algol/parc_FileChunker.c
+ algol/parc_FileChunker.c
algol/parc_FileInputStream.c
algol/parc_FileOutputStream.c
algol/parc_Hash.c
algol/parc_Unsigned.c
)
-set(LIBPARC_TESTING_HEADER_FILES
- testing/parc_MemoryTesting.h
- testing/parc_ObjectTesting.h
- )
+if(ENABLE_TEST)
+ set(LIBPARC_TESTING_HEADER_FILES
+ testing/parc_MemoryTesting.h
+ testing/parc_ObjectTesting.h
+ )
-set(LIBPARC_TESTING_SOURCE_FILES
- testing/parc_MemoryTesting.c
- testing/parc_ObjectTesting.c
- )
+ set(LIBPARC_TESTING_SOURCE_FILES
+ testing/parc_MemoryTesting.c
+ testing/parc_ObjectTesting.c
+ )
+endif()
set(LIBPARC_SECURITY_HEADER_FILES
security/parc_CryptoHasher.h
security/parc_IdentityFile.h
security/parc_Key.h
security/parc_KeyId.h
- security/parc_KeyStore.h
- security/parc_Pkcs12KeyStore.h
- security/parc_PublicKeySigner.h
+ security/parc_KeyStore.h
+ security/parc_Pkcs12KeyStore.h
+ security/parc_PublicKeySigner.h
security/parc_SecureRandom.h
security/parc_Security.h
security/parc_Signature.h
logging/parc_LogFormatSyslog.h
)
+set (LIBPARC_ASSERT_HEADER_FILES
+ assert/parc_Assert.h
+ )
+
set(LIBPARC_LOGGING_SOURCE_FILES
logging/parc_Log.c
logging/parc_LogEntry.c
${LIBPARC_ALGOL_SOURCE_FILES}
${LIBPARC_CONCURRENT_SOURCE_FILES}
${LIBPARC_SECURITY_SOURCE_FILES}
- ${LIBPARC_TESTING_SOURCE_FILES}
${LIBPARC_LOGGING_SOURCE_FILES}
${LIBPARC_DEVELOPER_SOURCE_FILES}
${LIBPARC_BASE_HEADER_FILES}
${LIBPARC_ALGOL_HEADER_FILES}
${LIBPARC_PRIVATE_HEADER_FILES}
- ${LIBPARC_TESTING_HEADER_FILES}
${LIBPARC_SECURITY_HEADER_FILES}
${LIBPARC_CONCURRENT_HEADER_FILES}
${LIBPARC_CONCURRENT_SOURCE_FILES}
${LIBPARC_DEVELOPER_HEADER_FILES}
${LIBPARC_STATISTICS_HEADER_FILES} ${LIBPARC_STATISTICS_SOURCE_FILES}
${LIBPARC_MEMORY_HEADER_FILES} ${LIBPARC_MEMORY_SOURCE_FILES}
+ ${LIBPARC_ASSERT_HEADER_FILES}
+)
+
+if(ENABLE_TEST)
+ list(APPEND LIBPARC_SOURCE_FILES
+ ${LIBPARC_TESTING_SOURCE_FILES}
+ ${LIBPARC_TESTING_HEADER_FILES}
)
+endif()
set(LIBPARC_ALGOL_FILES ${LIBPARC_ALGOL_SOURCE_FILES} ${LIBPARC_ALGOL_HEADER_FILES})
list(SORT LIBPARC_ALGOL_FILES)
source_group(algol FILES ${LIBPARC_ALGOL_FILES})
-#source_group(algol FILES ${LIBPARC_ALGOL_SOURCE_FILES} ${LIBPARC_ALGOL_HEADER_FILES})
source_group(concurrent FILES ${LIBPARC_CONCURRENT_SOURCE_FILES} ${LIBPARC_CONCURRENT_HEADER_FILES})
source_group(security FILES ${LIBPARC_SECURITY_SOURCE_FILES} ${LIBPARC_SECURITY_HEADER_FILES})
source_group(developer FILES ${LIBPARC_DEVELOPER_SOURCE_FILES} ${LIBPARC_DEVELOPER_HEADER_FILES})
source_group(logging FILES ${LIBPARC_LOGGING_SOURCE_FILES} ${LIBPARC_LOGGING_HEADER_FILES})
-source_group(testing FILES ${LIBPARC_TESTING_SOURCE_FILES} ${LIBPARC_TESTING_HEADER_FILES})
source_group(statistics FILES ${LIBPARC_STATISTICS_SOURCE_FILES} ${LIBPARC_STATISTICS_HEADER_FILES})
source_group(memory FILES ${LIBPARC_MEMORY_SOURCE_FILES} ${LIBPARC_MEMORY_HEADER_FILES})
+source_group(assert FILES ${LIBPARC_ASSERT_HEADER_FILES})
+
+if(ENABLE_TEST)
+ source_group(testing FILES ${LIBPARC_TESTING_SOURCE_FILES} ${LIBPARC_TESTING_HEADER_FILES})
+endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang" OR COMPILE_FOR_IOS)
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup")
install(FILES ${LIBPARC_ALGOL_HEADER_FILES} DESTINATION include/parc/algol COMPONENT headers)
install(FILES ${LIBPARC_SECURITY_HEADER_FILES} DESTINATION include/parc/security COMPONENT headers)
install(FILES ${LIBPARC_LOGGING_HEADER_FILES} DESTINATION include/parc/logging COMPONENT headers)
-install(FILES ${LIBPARC_TESTING_HEADER_FILES} DESTINATION include/parc/testing COMPONENT headers)
install(FILES ${LIBPARC_CONCURRENT_HEADER_FILES} DESTINATION include/parc/concurrent COMPONENT headers)
install(FILES ${LIBPARC_DEVELOPER_HEADER_FILES} DESTINATION include/parc/developer COMPONENT headers)
install(FILES ${LIBPARC_BASE_HEADER_FILES} DESTINATION include/parc COMPONENT headers)
install(FILES ${LIBPARC_STATISTICS_HEADER_FILES} DESTINATION include/parc/statistics COMPONENT headers)
install(FILES ${LIBPARC_MEMORY_HEADER_FILES} DESTINATION include/parc/memory COMPONENT headers)
+install(FILES ${LIBPARC_ASSERT_HEADER_FILES} DESTINATION include/parc/assert COMPONENT headers)
-if(NOT COMPILE_FOR_IOS)
- add_subdirectory(security/command-line)
- add_subdirectory(algol/test)
- add_subdirectory(concurrent/test)
- add_subdirectory(developer/test)
- add_subdirectory(security/test)
- add_subdirectory(logging/test)
- add_subdirectory(testing/test)
- add_subdirectory(statistics/test)
- add_subdirectory(memory/test)
+if(ENABLE_TEST)
+ install(FILES ${LIBPARC_TESTING_HEADER_FILES} DESTINATION include/parc/testing COMPONENT headers)
endif()
+
+if(ENABLE_TEST)
+ if(NOT COMPILE_FOR_IOS)
+ add_subdirectory(security/command-line)
+ add_subdirectory(algol/test)
+ add_subdirectory(concurrent/test)
+ add_subdirectory(developer/test)
+ add_subdirectory(security/test)
+ add_subdirectory(logging/test)
+ add_subdirectory(testing/test)
+ add_subdirectory(statistics/test)
+ add_subdirectory(memory/test)
+ endif()
+else()
+ if(NOT COMPILE_FOR_IOS)
+ add_subdirectory(security/command-line)
+ endif()
+endif()
+
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include "internal_parc_Event.h"
// CC = patchlevel
//
uint32_t version = event_get_version_number();
- trapIllegalValueIf(version < 0x02001000UL,
+ parcTrapIllegalValueIf(version < 0x02001000UL,
"Libevent version must be at least 2.0.16, got %s",
event_get_version());
// Create a scheduler event base, an event, then free both of them.
//
struct event_base *evbase = event_base_new();
- assertNotNull(evbase, "Libevent event_base_new returned NULL");
+ parcAssertNotNull(evbase, "Libevent event_base_new returned NULL");
struct event *event = event_new(evbase, -1, 0, NULL, NULL);
- assertNotNull(event, "Libevent event_new returned NULL");
+ parcAssertNotNull(event, "Libevent event_new returned NULL");
event_del(event);
event_base_free(evbase);
event_free(event);
case 2: priority = PARCEventPriority_Minimum;
break;
default:
- assertTrue(0, "Unknown Libevent priority 0x%x\n", evpriority);
+ parcAssertTrue(0, "Unknown Libevent priority 0x%x\n", evpriority);
break;
}
return priority;
case PARCEventPriority_Minimum: evpriority = 2;
break;
default:
- assertTrue(0, "Unknown PARCEventPriority 0x%x\n", evpriority);
+ parcAssertTrue(0, "Unknown PARCEventPriority 0x%x\n", evpriority);
break;
}
return evpriority;
case EVLOOP_NONBLOCK: options = PARCEventSchedulerDispatchType_NonBlocking;
break;
default:
- assertTrue(0, "Unknown Libevent dispatcher flag 0x%x\n", evoptions);
+ parcAssertTrue(0, "Unknown Libevent dispatcher flag 0x%x\n", evoptions);
break;
}
return options;
case PARCEventSchedulerDispatchType_NonBlocking: evoptions = EVLOOP_NONBLOCK;
break;
default:
- assertTrue(0, "Unknown PARCEventSchedulerDispatchType option 0x%x\n", evoptions);
+ parcAssertTrue(0, "Unknown PARCEventSchedulerDispatchType option 0x%x\n", evoptions);
break;
}
return evoptions;
flags |= PARCEventQueueOption_DeferCallbacks;
evflags &= ~BEV_OPT_DEFER_CALLBACKS;
}
- assertTrue(evflags == 0, "Unknown Libevent option flag 0x%x\n", evflags);
+ parcAssertTrue(evflags == 0, "Unknown Libevent option flag 0x%x\n", evflags);
return flags;
}
evflags |= BEV_OPT_DEFER_CALLBACKS;
flags &= ~PARCEventQueueOption_DeferCallbacks;
}
- assertTrue(flags == 0, "Unknown PARCEventQueueOption flag 0x%x\n", flags);
+ parcAssertTrue(flags == 0, "Unknown PARCEventQueueOption flag 0x%x\n", flags);
return evflags;
}
types |= PARCEventQueueEventType_Connected;
evtypes &= ~BEV_EVENT_CONNECTED;
}
- assertTrue(evtypes == 0, "Unknown Libevent type flag 0x%x\n", evtypes);
+ parcAssertTrue(evtypes == 0, "Unknown Libevent type flag 0x%x\n", evtypes);
return types;
}
evtypes |= BEV_EVENT_CONNECTED;
types &= ~PARCEventQueueEventType_Connected;
}
- assertTrue(types == 0, "Unknown PARCEventQueueEventType 0x%x\n", types);
+ parcAssertTrue(types == 0, "Unknown PARCEventQueueEventType 0x%x\n", types);
return evtypes;
}
types |= PARCEventType_EdgeTriggered;
evtypes &= ~EV_ET;
}
- assertTrue(evtypes == 0, "Unknown Libevent event type 0x%x\n", evtypes);
+ parcAssertTrue(evtypes == 0, "Unknown Libevent event type 0x%x\n", evtypes);
return types;
}
evtypes |= EV_ET;
types &= ~PARCEventType_EdgeTriggered;
}
- assertTrue(types == 0, "Unknown Libevent event type 0x%x\n", types);
+ parcAssertTrue(types == 0, "Unknown Libevent event type 0x%x\n", types);
return evtypes;
}
#include <stdbool.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_ArrayList.h>
#include <parc/algol/parc_Object.h>
static PARCArrayList *
_ensureRemaining(PARCArrayList *array, size_t remnant)
{
- assertNotNull(array, "Parameter must be a non-null PARCArrayList pointer.");
+ parcAssertNotNull(array, "Parameter must be a non-null PARCArrayList pointer.");
if (_remaining(array) < remnant) {
size_t newCapacity = parcArrayList_Size(array) + remnant;
void
parcArrayList_AssertValid(const PARCArrayList *instance)
{
- trapIllegalValueIf(instance == NULL, "Parameter must be a non-null PARC_ArrayList pointer.");
- assertTrue(instance->numberOfElements == 0 ? true : instance->array != NULL, "PARC_ArrayList size is inconsistent.");
+ parcTrapIllegalValueIf(instance == NULL, "Parameter must be a non-null PARC_ArrayList pointer.");
+ parcAssertTrue(instance->numberOfElements == 0 ? true : instance->array != NULL, "PARC_ArrayList size is inconsistent.");
}
static PARCArrayList *
parcArrayList_Create(void (*destroyElement)(void **element))
{
PARCArrayList *result = parcMemory_AllocateAndClear(sizeof(PARCArrayList));
- assertNotNull(result, "Memory allocation of PARCArrayList failed");
+ parcAssertNotNull(result, "Memory allocation of PARCArrayList failed");
return _parcArrayList_Init(result, 0, 0, NULL, NULL, destroyElement);
}
parcArrayList_Create_Capacity(bool (*equalsElement)(void *x, void *y), void (*destroyElement)(void **element), size_t size)
{
PARCArrayList *result = parcMemory_AllocateAndClear(sizeof(PARCArrayList));
- assertNotNull(result, "Memory allocation of PARCArrayList failed");
+ parcAssertNotNull(result, "Memory allocation of PARCArrayList failed");
_parcArrayList_Init(result, 0, 0, NULL, equalsElement, destroyElement);
parcArrayList_OptionalAssertValid(array);
if (_ensureRemaining(array, 1) == NULL) {
- trapOutOfMemory("Cannot increase space for PARCArrayList.");
+ parcTrapOutOfMemory("Cannot increase space for PARCArrayList.");
}
array->array[array->numberOfElements++] = (void *) pointer;
void *
parcArrayList_RemoveAtIndex(PARCArrayList *array, size_t index)
{
- trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
+ parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
void *element = array->array[index];
void
parcArrayList_Set(const PARCArrayList *array, size_t index, void *pointer)
{
- trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
+ parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
array->array[index] = pointer;
}
void *
parcArrayList_Get(const PARCArrayList *array, size_t index)
{
- trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
+ parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements);
return array->array[index];
}
void
parcArrayList_Destroy(PARCArrayList **arrayPtr)
{
- assertNotNull(arrayPtr, "Parameter must be a non-null pointer to a PARC_ArrayList pointer.");
+ parcAssertNotNull(arrayPtr, "Parameter must be a non-null pointer to a PARC_ArrayList pointer.");
PARCArrayList *array = *arrayPtr;
parcArrayList_OptionalAssertValid(array);
- assertTrue(array->numberOfElements == 0 ? true : array->array != NULL, "PARC_ArrayList is inconsistent.");
+ parcAssertTrue(array->numberOfElements == 0 ? true : array->array != NULL, "PARC_ArrayList is inconsistent.");
if (array->destroyElement != NULL) {
for (size_t i = 0; i < array->numberOfElements; i++) {
{
parcArrayList_OptionalAssertValid(array);
- assertTrue(index < array->numberOfElements, "Index must be ( 0 <= index < %zd). Actual=%zd", array->numberOfElements, index);
+ parcAssertTrue(index < array->numberOfElements, "Index must be ( 0 <= index < %zd). Actual=%zd", array->numberOfElements, index);
if (index < array->numberOfElements) {
// Destroy the element at the given index.
parcArrayList_OptionalAssertValid(array);
size_t length = parcArrayList_Size(array);
- assertTrue(index <= array->numberOfElements, "You can't insert beyond the end of the list");
+ parcAssertTrue(index <= array->numberOfElements, "You can't insert beyond the end of the list");
// Create space and grow the array if needed
_ensureRemaining(array, length + 1);
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Base64.h>
#include <parc/algol/parc_Memory.h>
static void
_encodeWithPad(PARCBufferComposer *output, const uint8_t *quantum, size_t padLength)
{
- assertTrue(padLength < 3, "Degenerate case -- should never pad all 3 bytes!");
+ parcAssertTrue(padLength < 3, "Degenerate case -- should never pad all 3 bytes!");
unsigned index;
* limitations under the License.
*/
-/**
- */
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_BitVector.h>
parcBitVector_Create(void)
{
PARCBitVector *parcBitVector = parcObject_CreateInstance(PARCBitVector);
- assertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL");
+ parcAssertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL");
parcBitVector->bitArray = parcMemory_AllocateAndClear(DEFAULT_BITARRAY_SIZE);
- assertNotNull(parcBitVector->bitArray, "parcMemory_AllocateAndClear(%d) returned NULL", DEFAULT_BITARRAY_SIZE);
+ parcAssertNotNull(parcBitVector->bitArray, "parcMemory_AllocateAndClear(%d) returned NULL", DEFAULT_BITARRAY_SIZE);
parcBitVector->bitLength = DEFAULT_BITARRAY_SIZE * BITS_PER_BYTE;
parcBitVector->numberOfBitsSet = 0;
parcBitVector->firstBitSet = -1;
parcBitVector_Copy(const PARCBitVector *source)
{
PARCBitVector *parcBitVector = parcObject_CreateInstance(PARCBitVector);
- assertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL");
+ parcAssertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL");
size_t byteLength = source->bitLength / BITS_PER_BYTE;
parcBitVector->bitArray = parcMemory_Allocate(byteLength);
static void
_parc_bit_vector_resize(PARCBitVector *parcBitVector, unsigned bit)
{
- assertNotNull(parcBitVector, "_parc_bit_vector_resize passed a NULL parcBitVector");
- assertTrue(bit < MAX_BIT_VECTOR_INDEX, "_parc_bit_vector_resize passed a bit index that's too large");
+ parcAssertNotNull(parcBitVector, "_parc_bit_vector_resize passed a NULL parcBitVector");
+ parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "_parc_bit_vector_resize passed a bit index that's too large");
unsigned neededBits = bit + 1;
if (neededBits > parcBitVector->bitLength) {
int oldSize = (parcBitVector->bitLength / BITS_PER_BYTE) + ((parcBitVector->bitLength % BITS_PER_BYTE) ? 1 : 0);
uint8_t *newArray = parcMemory_Reallocate(parcBitVector->bitArray, newSize);
- assertTrue(newArray, "parcMemory_Reallocate(%d) failed", newSize);
+ parcAssertTrue(newArray, "parcMemory_Reallocate(%d) failed", newSize);
// Reallocate does not guarantee that additional memory is zero-filled.
memset((void *) &(newArray[oldSize]), parcBitVector->fillValue, newSize - oldSize);
parcBitVector->bitArray = newArray;
- assertNotNull(newArray, "parcMemory_Reallocate(%d) returned NULL", newSize);
+ parcAssertNotNull(newArray, "parcMemory_Reallocate(%d) returned NULL", newSize);
parcBitVector->bitLength = newSize * BITS_PER_BYTE;
}
}
int
parcBitVector_Get(const PARCBitVector *parcBitVector, unsigned bit)
{
- assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too large");
+ parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too large");
if ((parcBitVector == NULL) || (bit >= parcBitVector->bitLength)) {
return -1;
void
parcBitVector_Set(PARCBitVector *parcBitVector, unsigned bit)
{
- assertNotNull(parcBitVector, "parcBitVector_Set passed a NULL parcBitVector");
- assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too huge");
+ parcAssertNotNull(parcBitVector, "parcBitVector_Set passed a NULL parcBitVector");
+ parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too huge");
if (bit >= parcBitVector->bitLength) {
_parc_bit_vector_resize(parcBitVector, bit);
}
void
parcBitVector_SetVector(PARCBitVector *parcBitVector, const PARCBitVector *bitsToSet)
{
- assertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL parcBitVector");
- assertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL vector of bits to set");
+ parcAssertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL parcBitVector");
+ parcAssertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL vector of bits to set");
int settingBit = 0;
for (int i = 0; i < bitsToSet->numberOfBitsSet; i++) {
settingBit = parcBitVector_NextBitSet(bitsToSet, settingBit);
- assertTrue(settingBit != -1, "Number of bits claimed set inconsistent with bits found");
+ parcAssertTrue(settingBit != -1, "Number of bits claimed set inconsistent with bits found");
parcBitVector_Set(parcBitVector, settingBit);
settingBit++;
}
void
parcBitVector_Clear(PARCBitVector *parcBitVector, unsigned bit)
{
- assertNotNull(parcBitVector, "parcBitVector_Clear passed a NULL parcBitVector");
- assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Clear passed a bit index that's too huge");
+ parcAssertNotNull(parcBitVector, "parcBitVector_Clear passed a NULL parcBitVector");
+ parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Clear passed a bit index that's too huge");
if (bit > parcBitVector->bitLength) {
_parc_bit_vector_resize(parcBitVector, bit);
}
void
parcBitVector_ClearVector(PARCBitVector *parcBitVector, const PARCBitVector *bitsToClear)
{
- assertNotNull(parcBitVector, "parcBitVector_ClearVector passed a NULL parcBitVector");
- assertNotNull(bitsToClear, "parcBitVector_ClearVector passed a NULL for vector of bitsToClear");
+ parcAssertNotNull(parcBitVector, "parcBitVector_ClearVector passed a NULL parcBitVector");
+ parcAssertNotNull(bitsToClear, "parcBitVector_ClearVector passed a NULL for vector of bitsToClear");
// If we're clearing ourself, we just need a reset
if (parcBitVector == bitsToClear) {
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
* PARCBitVector *copy = parcBitVector_Copy(parcBitVector);
- * assertTrue(parcBitVector_Equals(parcBitVector, copy), "Duplicate vector is unequal");
+ * parcAssertTrue(parcBitVector_Equals(parcBitVector, copy), "Duplicate vector is unequal");
* }
* @endcode
*
* parcBitVector_Set(parcBitVector, 10);
* PARCBitVector *copy = parcBitVector_Copy(parcBitVector);
* parcBitVector_Set(copy, 1);
- * assertTrue(parcBitVector_Equals(parcBitVector, copy) == false, "Vector should have been unequal");
+ * parcAssertTrue(parcBitVector_Equals(parcBitVector, copy) == false, "Vector should have been unequal");
* }
* @endcode
*
* parcBitVector_Set(superSet, 11);
* PARCBitVector *subSet = parcBitVector_Create();
* parcBitVector_Set(subSet, 10);
- * assertTrue(parcBitVector_Contains(superSet, subSet), "Expect superSet to contain subSet");
+ * parcAssertTrue(parcBitVector_Contains(superSet, subSet), "Expect superSet to contain subSet");
* }
* @endcode
*
* {
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
* }
* @endcode
*
* {
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
* }
* @endcode
*
* parcBitVector_Set(parcBitVector, 0);
*
* parcBitVector_RightShift(parcBitVector, 1);
- * assertTrue(parcBitVector_FirstBitSet(parcBitVector) == 1,
+ * parcAssertTrue(parcBitVector_FirstBitSet(parcBitVector) == 1,
* "First vector element should have moved up");
*
* parcBitVector_Release(&parcBitVector);
* parcBitVector_Set(parcBitVector, 0);
*
* parcBitVector_LeftShift(parcBitVector, 1);
- * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1,
+ * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1,
* "First vector element should have rolled off");
*
* parcBitVector_Release(&parcBitVector);
* parcBitVector_Set(andVector, 11);
*
* PARCBitVector *result = parcBitVector_And(parcBitVector, andVector);
- * assertTrue(parcBitVector_NumberOfBitsSet(result) == 0, "Vector should have been empty");
+ * parcAssertTrue(parcBitVector_NumberOfBitsSet(result) == 0, "Vector should have been empty");
*
* parcBitVector_Release(&parcBitVector);
* parcBitVector_Release(&andVector);
* parcBitVector_Set(orVector, 11);
*
* PARCBitVector *result = parcBitVector_Or(parcBitVector, orVector);
- * assertTrue(parcBitVector_NumberOfBitsSet(result) == 2, "Vector should have been set");
+ * parcAssertTrue(parcBitVector_NumberOfBitsSet(result) == 2, "Vector should have been set");
*
* parcBitVector_Release(&parcBitVector);
* parcBitVector_Release(&orVector);
* PARCBitVector *bitsToSet = parcBitVector_Create();
* parcBitVector_Set(bitsToSet, 10);
* parcBitVector_SetVector(parcBitVector, bitsToSet);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
* }
* @endcode
*
* parcBitVector_Set(parcBitVector, 10);
* parcBitVector_Set(parcBitVector, 42);
* parcBitVector_Reset(parcBitVector);
- * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 0, "Vector should have 0 bits set");
+ * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 0, "Vector should have 0 bits set");
* }
* @endcode
*
* {
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set");
* parcBitVector_Clear(parcBitVector, 10);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared");
* }
* @endcode
*
* PARCBitVector *bitsToClear = parcBitVector_Create();
* parcBitVector_Set(bitsToClear, 10);
* parcBitVector_SetVector(parcBitVector, bitsToClear);
- * assertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared");
+ * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared");
* }
* @endcode
*
* {
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
- * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, "One bit should have been set");
+ * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, "One bit should have been set");
* }
* @endcode
*
* PARCBitVector *parcBitVector = parcBitVector_Create();
* parcBitVector_Set(parcBitVector, 10);
* parcBitVector_Set(parcBitVector, 12);
- * assertTrue(parcBitVector_NextBitSet(parcBitVector, 0) == 10, "Bit 10 should have been found first");
- * assertTrue(parcBitVector_NextBitSet(parcBitVector, 11) == 12, "Bit 12 should have been found next");
+ * parcAssertTrue(parcBitVector_NextBitSet(parcBitVector, 0) == 10, "Bit 10 should have been found first");
+ * parcAssertTrue(parcBitVector_NextBitSet(parcBitVector, 11) == 12, "Bit 12 should have been found next");
* }
* @endcode
*
#include <config.h>
#include <ctype.h>
-#include <LongBow/runtime.h>
-#include <LongBow/debugging.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Buffer.h>
static inline void
_trapIfIndexExceedsLimit(const PARCBuffer *buffer, const size_t index)
{
- trapOutOfBoundsIf(index > buffer->limit, "PARCBuffer limit at %zd, attempted to access at %zd",
- parcBuffer_Limit(buffer), index);
+ //parcTrapOutOfBoundsIf(index > buffer->limit, "PARCBuffer limit at %zd, attempted to access at %zd",
+ // parcBuffer_Limit(buffer), index);
}
static inline void
_assertInvariants(const PARCBuffer *buffer)
{
// 0 <= mark <= position <= limit <= capacity
- assertTrue(0 <= buffer->mark,
+ parcAssertTrue(0 <= buffer->mark,
"Expected 0 <= mark (%zd)", buffer->mark);
- assertTrue(_markIsDiscarded(buffer) || buffer->mark <= buffer->position,
+ parcAssertTrue(_markIsDiscarded(buffer) || buffer->mark <= buffer->position,
"Expected mark (%zd) <= position (%zd)", buffer->mark, buffer->position);
- assertTrue(buffer->position <= buffer->limit,
+ parcAssertTrue(buffer->position <= buffer->limit,
"Expected position (%zd) <= limit (%zd)", buffer->position, buffer->limit);
- assertTrue(buffer->limit <= buffer->capacity,
+ parcAssertTrue(buffer->limit <= buffer->capacity,
"Expected limit (%zd) <= capacity (%zd)", buffer->limit, buffer->capacity);
- assertTrue((buffer->arrayOffset + buffer->capacity) <= parcByteArray_Capacity(buffer->array),
+ parcAssertTrue((buffer->arrayOffset + buffer->capacity) <= parcByteArray_Capacity(buffer->array),
"Expected (%zd + %zd) <= %zd",
buffer->arrayOffset, buffer->capacity, parcByteArray_Capacity(buffer->array));
}
{
char *explanation = _parcBuffer_CheckValidity(buffer);
- trapIllegalValueIf(explanation != NULL, "PARCBuffer@%p %s.", (void *) buffer, explanation);
+ parcTrapIllegalValueIf(explanation != NULL, "PARCBuffer@%p %s.", (void *) buffer, explanation);
}
bool
PARCBuffer *
parcBuffer_CreateFromArray(const void *bytes, const size_t length)
{
- assertTrue(length == 0 || bytes != NULL,
+ parcAssertTrue(length == 0 || bytes != NULL,
"If the byte array is NULL, then length MUST be zero.");
PARCBuffer *result = parcBuffer_Allocate(length);
{
parcBuffer_OptionalAssertValid(buffer);
- assertFalse(_markIsDiscarded(buffer),
+ parcAssertFalse(_markIsDiscarded(buffer),
"The mark has not been set");
buffer->position = buffer->mark;
parcBuffer_SetLimit(PARCBuffer *buffer, size_t newLimit)
{
parcBuffer_OptionalAssertValid(buffer);
- assertTrue(newLimit <= parcBuffer_Capacity(buffer),
+ parcAssertTrue(newLimit <= parcBuffer_Capacity(buffer),
"new limit cannot be larger than the capacity");
if (_markIsDiscarded(buffer)) {
{
parcBuffer_OptionalAssertValid(buffer);
- assertFalse(newPosition > buffer->limit,
+ parcAssertFalse(newPosition > buffer->limit,
"new position cannot be greater the buffer's limit");
buffer->position = newPosition;
parcBuffer_PutUint8(PARCBuffer *buffer, uint8_t value)
{
parcBuffer_OptionalAssertValid(buffer);
- assertTrue(parcBuffer_Remaining(buffer) >= 1,
+ parcAssertTrue(parcBuffer_Remaining(buffer) >= 1,
"Buffer overflow");
parcByteArray_PutByte(buffer->array, _effectivePosition(buffer), value);
PARCBuffer *
parcBuffer_PutUint16(PARCBuffer *buffer, uint16_t value)
{
- assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint16_t),
+ parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint16_t),
"Buffer overflow");
parcBuffer_PutUint8(buffer, (value >> 8) & 0xFF);
PARCBuffer *
parcBuffer_PutUint32(PARCBuffer *buffer, uint32_t value)
{
- assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint32_t),
+ parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint32_t),
"Buffer overflow");
for (int i = sizeof(uint32_t) - 1; i > 0; i--) {
uint8_t b = value >> (i * 8) & 0xFF;
PARCBuffer *
parcBuffer_PutUint64(PARCBuffer *buffer, uint64_t value)
{
- assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint64_t),
+ parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint64_t),
"Buffer overflow");
for (int i = sizeof(uint64_t) - 1; i > 0; i--) {
uint8_t b = value >> (i * 8) & 0xFF;
parcBuffer_PutAtIndex(PARCBuffer *buffer, size_t index, uint8_t value)
{
parcBuffer_OptionalAssertValid(buffer);
- assertTrue(_effectiveIndex(buffer, index) < parcBuffer_Limit(buffer), "Buffer overflow");
+ parcAssertTrue(_effectiveIndex(buffer, index) < parcBuffer_Limit(buffer), "Buffer overflow");
parcByteArray_PutByte(buffer->array, _effectiveIndex(buffer, index), value);
return buffer;
parcBuffer_PutArray(PARCBuffer *buffer, size_t arrayLength, const uint8_t array[arrayLength])
{
parcBuffer_OptionalAssertValid(buffer);
- assertTrue(parcBuffer_Remaining(buffer) >= arrayLength,
+ parcAssertTrue(parcBuffer_Remaining(buffer) >= arrayLength,
"Buffer overflow");
parcByteArray_PutBytes(buffer->array, _effectivePosition(buffer), arrayLength, array);
parcBuffer_PutBuffer(PARCBuffer *result, const PARCBuffer *buffer)
{
parcBuffer_OptionalAssertValid(buffer);
- assertTrue(parcBuffer_Remaining(result) >= parcBuffer_Remaining(buffer),
+ parcAssertTrue(parcBuffer_Remaining(result) >= parcBuffer_Remaining(buffer),
"Buffer overflow. %zd bytes remaining, %zd required.", parcBuffer_Remaining(result), parcBuffer_Remaining(buffer));
size_t length = parcBuffer_Remaining(buffer);
char *result = parcMemory_Allocate(remaining + 1);
if (remaining > 0) {
- assertNotNull(result, "parcMemory_Allocate returned NULL");
+ parcAssertNotNull(result, "parcMemory_Allocate returned NULL");
if (result != NULL) {
memcpy(result, parcBuffer_Overlay((PARCBuffer *) buffer, 0), remaining);
}
// Hopefully length is less than (2^(sizeof(size_t)*8) / 2)
char *result = parcMemory_AllocateAndClear((length * 2) + 1);
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", (length * 2) + 1);
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", (length * 2) + 1);
for (size_t i = 0; i < length; i++) {
unsigned char byte = parcBuffer_GetAtIndex(buffer, i);
/**
* Assert that an instance of `PARCBuffer` is valid.
*
- * If the instance is not valid, terminate via `trapIllegalValue()`
+ * If the instance is not valid, terminate via `parcTrapIllegalValue()`
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdlib.h>
#include <stdarg.h>
void
parcBufferComposer_AssertValid(const PARCBufferComposer *composer)
{
- trapIllegalValueIf(composer == NULL, "Parameter must be a non-null pointer to a valid PARCBufferComposer.");
- trapIllegalValueIf(composer->incrementHeuristic < sizeof(void *), "Heuristic cannot be < sizeof(void *) (%zd), actual %zd", sizeof(void *), composer->incrementHeuristic);
+ parcTrapIllegalValueIf(composer == NULL, "Parameter must be a non-null pointer to a valid PARCBufferComposer.");
+ parcTrapIllegalValueIf(composer->incrementHeuristic < sizeof(void *), "Heuristic cannot be < sizeof(void *) (%zd), actual %zd", sizeof(void *), composer->incrementHeuristic);
}
PARCBufferComposer *
va_start(ap, format);
char *cString;
ssize_t written = vasprintf(&cString, format, ap);
- assertTrue(written >= 0, "Got error from vasprintf");
+ parcAssertTrue(written >= 0, "Got error from vasprintf");
va_end(ap);
parcBufferComposer_PutString(composer, cString);
/**
* Assert that an instance of `PARCBufferComposer` is valid.
*
- * If the instance is not valid, terminate via `trapIllegalValue()`.
+ * If the instance is not valid, terminate via `parcTrapIllegalValue()`.
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_BufferDictionary.h>
static void
_destroy(PARCBufferDictionary **dictionaryPtr)
{
- assertNotNull(dictionaryPtr, "Double pointer dictionaryPtr must be non-NULL");
- assertNotNull(*dictionaryPtr, "Double pointer dictionaryPtr must dereference to non-NULL");
+ parcAssertNotNull(dictionaryPtr, "Double pointer dictionaryPtr must be non-NULL");
+ parcAssertNotNull(*dictionaryPtr, "Double pointer dictionaryPtr must dereference to non-NULL");
PARCBufferDictionary *dict = *dictionaryPtr;
PARCBuffer *
parcBufferDictionary_Put(PARCBufferDictionary *dictionary, PARCBuffer *key, PARCBuffer *value)
{
- assertNotNull(dictionary, "Parameter dictionary must be non-NULL");
- assertNotNull(key, "Parameter key must be non-NULL");
- assertNotNull(value, "Parameter value must be non-NULL");
+ parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL");
+ parcAssertNotNull(key, "Parameter key must be non-NULL");
+ parcAssertNotNull(value, "Parameter value must be non-NULL");
PARCBuffer *oldValue = NULL;
PARCBuffer *
parcBufferDictionary_Get(PARCBufferDictionary *dictionary, PARCBuffer *key)
{
- assertNotNull(dictionary, "Parameter dictionary must be non-NULL");
- assertNotNull(key, "Parameter key must be non-NULL");
+ parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL");
+ parcAssertNotNull(key, "Parameter key must be non-NULL");
return parcHashCodeTable_Get(dictionary->hashtable, key);
}
PARCBuffer *
parcBufferDictionary_Remove(PARCBufferDictionary *dictionary, PARCBuffer *key)
{
- assertNotNull(dictionary, "Parameter dictionary must be non-NULL");
- assertNotNull(key, "Parameter key must be non-NULL");
+ parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL");
+ parcAssertNotNull(key, "Parameter key must be non-NULL");
// parcHashCodeTable_Del will free the referece, to make a copy of it
PARCBuffer *original = (PARCBuffer *) parcHashCodeTable_Get(dictionary->hashtable, key);
#include <ctype.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_ByteArray.h>
#include <parc/algol/parc_Memory.h>
static inline void
_trapIfOutOfBounds(const PARCByteArray *array, const size_t index)
{
- trapOutOfBoundsIf(index >= array->length, "parcByteArray index %zd exceeds the length %zd", index, array->length);
+ parcTrapOutOfBoundsIf(index >= array->length, "parcByteArray index %zd exceeds the length %zd", index, array->length);
}
static bool
void
parcByteArray_AssertValid(const PARCByteArray *instance)
{
- trapInvalidValueIf(parcByteArray_IsValid(instance) == false,
+ parcTrapInvalidValueIf(parcByteArray_IsValid(instance) == false,
"PARCByteArray instance is invalid.");
}
parcByteArray_PutBytes(PARCByteArray *result, size_t offset, size_t length, const uint8_t source[length])
{
parcByteArray_OptionalAssertValid(result);
- trapOutOfBoundsIf(offset > result->length,
+ parcTrapOutOfBoundsIf(offset > result->length,
"The offset (%zd) exeeds the length (%zd) of the PARCByteArray.", offset, result->length);
size_t available = result->length - offset;
- trapOutOfBoundsIf(length > available, "%zd available bytes, %zd required.", available, length);
+ parcTrapOutOfBoundsIf(length > available, "%zd available bytes, %zd required.", available, length);
memcpy(&result->array[offset], source, length);
return result;
size_t available = result->length - offset;
- trapOutOfBoundsIf(length > available, "parcByteArray_CopyOut %zd available bytes, %zd required", available, length);
+ parcTrapOutOfBoundsIf(length > available, "parcByteArray_CopyOut %zd available bytes, %zd required", available, length);
memcpy(array, &result->array[offset], length);
return (PARCByteArray *) result;
/**
* Assert that an instance of `PARCByteArray` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue}
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
*
* @return The given `PARCByteArray` pointer
*
- * @throws SIGABRT `trapOutOfBounds` if the underlying `PARCByteArray` is not large enough
+ * @throws SIGABRT `parcTrapOutOfBounds` if the underlying `PARCByteArray` is not large enough
*
* Example:
* @code
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <sys/queue.h>
static void
_parcDequeNode_AssertInvariants(struct parc_deque_node *node)
{
- assertNotNull(node, "Expected non-null node pointer.");
+ parcAssertNotNull(node, "Expected non-null node pointer.");
if (node->next != NULL) {
- assertTrue(node->next->previous == node, "Expected next node to point to this node.");
+ parcAssertTrue(node->next->previous == node, "Expected next node to point to this node.");
}
if (node->previous != NULL) {
- assertTrue(node->previous->next == node, "Expected previous node to point to this node.");
+ parcAssertTrue(node->previous->next == node, "Expected previous node to point to this node.");
}
}
static void
_parcDeque_AssertInvariants(const PARCDeque *deque)
{
- assertNotNull(deque, "Parameter cannot be null.");
+ parcAssertNotNull(deque, "Parameter cannot be null.");
if (deque->head != NULL) {
- assertTrue(deque->size != 0, "PARCDeque head is not-null, but size is zero.");
- assertNotNull(deque->tail, "PARCDeque head is not-null, but tail is null.");
+ parcAssertTrue(deque->size != 0, "PARCDeque head is not-null, but size is zero.");
+ parcAssertNotNull(deque->tail, "PARCDeque head is not-null, but tail is null.");
_parcDequeNode_AssertInvariants(deque->head);
_parcDequeNode_AssertInvariants(deque->tail);
} else {
- assertNull(deque->tail, "PARCDeque head is null, but tail is not null.");
- assertTrue(deque->size == 0, "PARCDeque head is null, but size is not zero.");
+ parcAssertNull(deque->tail, "PARCDeque head is null, but tail is not null.");
+ parcAssertTrue(deque->size == 0, "PARCDeque head is null, but size is not zero.");
}
}
if (node == NULL) {
return deque->head;
}
- trapOutOfBoundsIf(node->next == NULL, "No more elements.");
+ parcTrapOutOfBoundsIf(node->next == NULL, "No more elements.");
return node->next;
}
parcDeque_GetAtIndex(const PARCDeque *deque, size_t index)
{
if (index > (parcDeque_Size(deque) - 1)) {
- trapOutOfBounds(index, "[0, %zd]", parcDeque_Size(deque) - 1);
+ parcTrapOutOfBounds(index, "[0, %zd]", parcDeque_Size(deque) - 1);
}
struct parc_deque_node *node = deque->head;
while (index--) {
* @param [in] deque A pointer to a `PARCDeque` instance.
* @param [in] index The index of the element to be retrieved.
*
- * @throws `trapOutOfBounds`
+ * @throws `parcTrapOutOfBounds`
*
* Example:
* @code
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <string.h>
PARCDictionary_ValueEquals valueEqualsFunction,
PARCDictionary_FreeValue valueFreeFunction)
{
- assertNotNull(keyCompareFunction, "KeyCompareFunction can't be null");
- assertNotNull(keyHashFunction, "KeyHashFunction can't be null");
+ parcAssertNotNull(keyCompareFunction, "KeyCompareFunction can't be null");
+ parcAssertNotNull(keyHashFunction, "KeyHashFunction can't be null");
PARCDictionary *dictionary = parcMemory_Allocate(sizeof(PARCDictionary));
- assertNotNull(dictionary, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCDictionary));
+ parcAssertNotNull(dictionary, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCDictionary));
dictionary->keyCompareFunction = keyCompareFunction;
dictionary->keyHashFunction = keyHashFunction;
dictionary->keyFreeFunction = keyFreeFunction;
void
parcDictionary_Destroy(PARCDictionary **dictionaryPointer)
{
- assertNotNull(dictionaryPointer, "Pointer to dictionary pointer can't be NULL");
- assertNotNull(*dictionaryPointer, "Pointer to dictionary can't be NULL");
+ parcAssertNotNull(dictionaryPointer, "Pointer to dictionary pointer can't be NULL");
+ parcAssertNotNull(*dictionaryPointer, "Pointer to dictionary can't be NULL");
parcTreeRedBlack_Destroy(&((*dictionaryPointer)->tree));
parcMemory_Deallocate((void **) dictionaryPointer);
*dictionaryPointer = NULL;
void
parcDictionary_SetValue(PARCDictionary *dictionary, void *key, void *value)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
- assertNotNull(key, "Key pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(key, "Key pointer can't be NULL");
parcTreeRedBlack_Insert(dictionary->tree, key, value);
}
void *
parcDictionary_GetValue(PARCDictionary *dictionary, const void *key)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
- assertNotNull(key, "Key pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(key, "Key pointer can't be NULL");
return parcTreeRedBlack_Get(dictionary->tree, key);
}
void *
parcDictionary_RemoveValue(PARCDictionary *dictionary, const void *key)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
- assertNotNull(key, "Key pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(key, "Key pointer can't be NULL");
return parcTreeRedBlack_Remove(dictionary->tree, key);
}
void
parcDictionary_RemoveAndDestroyValue(PARCDictionary *dictionary, const void *key)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
- assertNotNull(key, "Key pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(key, "Key pointer can't be NULL");
parcTreeRedBlack_RemoveAndDestroy(dictionary->tree, key);
}
PARCArrayList *
parcDictionary_Keys(const PARCDictionary *dictionary)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
return parcTreeRedBlack_Keys(dictionary->tree);
}
PARCArrayList *
parcDictionary_Values(const PARCDictionary *dictionary)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
return parcTreeRedBlack_Values(dictionary->tree);
}
size_t
parcDictionary_Size(const PARCDictionary *dictionary)
{
- assertNotNull(dictionary, "dictionary pointer can't be NULL");
+ parcAssertNotNull(dictionary, "dictionary pointer can't be NULL");
return parcTreeRedBlack_Size(dictionary->tree);
}
int
parcDictionary_Equals(const PARCDictionary *dictionary1, const PARCDictionary *dictionary2)
{
- assertNotNull(dictionary1, "dictionary pointer can't be NULL");
- assertNotNull(dictionary2, "dictionary pointer can't be NULL");
+ parcAssertNotNull(dictionary1, "dictionary pointer can't be NULL");
+ parcAssertNotNull(dictionary2, "dictionary pointer can't be NULL");
return parcTreeRedBlack_Equals(dictionary1->tree, dictionary2->tree);
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <stdlib.h>
if (indentation > 0) {
result = write(1, _spaces, indentation * _indentationFactor);
- assertTrue(result == (indentation * _indentationFactor),
+ parcAssertTrue(result == (indentation * _indentationFactor),
"Write(2) failed to write %zd bytes.", indentation * _indentationFactor);
}
return result;
_indent(indentation);
if (end != NULL) {
ssize_t nwritten = write(1, start, end - start + 1);
- assertTrue(nwritten >= 0, "Error calling write");
+ parcAssertTrue(nwritten >= 0, "Error calling write");
start = end + 1;
} else {
ssize_t nwritten = write(1, start, strlen(start));
- assertTrue(nwritten >= 0, "Error calling write");
+ parcAssertTrue(nwritten >= 0, "Error calling write");
break;
}
end = strchr(start, '\n');
char *cString;
int length = vasprintf(&cString, format, ap);
- assertTrue(length >= 0, "Error in vasprintf");
+ parcAssertTrue(length >= 0, "Error in vasprintf");
va_end(ap);
_parcDisplayIndented_Print(indentation, cString);
ssize_t nwritten = write(1, "\n", 1);
- assertTrue(nwritten >= 0, "Error calling write");
+ parcAssertTrue(nwritten >= 0, "Error calling write");
free(cString);
}
char *cString;
for (size_t offset = 0; offset < length; /**/) {
int nwritten = asprintf(&cString, "%p=[", &memory[offset]);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
_parcDisplayIndented_Print(indentation, cString);
free(cString);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include "internal_parc_Event.h"
#include <parc/algol/parc_EventScheduler.h>
parcEvent_Create(PARCEventScheduler *parcEventScheduler, int fd, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs)
{
PARCEvent *parcEvent = parcMemory_Allocate(sizeof(PARCEvent));
- assertNotNull(parcEvent, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEvent));
+ parcAssertNotNull(parcEvent, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEvent));
parcEvent->parcEventScheduler = parcEventScheduler;
parcEvent->callback = callback;
parcEvent->event = event_new(parcEventScheduler_GetEvBase(parcEventScheduler), fd,
internal_PARCEventType_to_libevent_type(flags), _parc_event_callback, parcEvent);
- assertNotNull(parcEvent->event, "Could not create a new event!");
+ parcAssertNotNull(parcEvent->event, "Could not create a new event!");
parcEvent_LogDebug(parcEvent,
"parcEvent_Create(base=%p,fd=%x,events=%x,cb=%p,args=%p)\n",
parcEvent_Start(PARCEvent *parcEvent)
{
parcEvent_LogDebug(parcEvent, "parcEvent_Start(%p)\n", parcEvent);
- assertNotNull(parcEvent, "parcEvent_Start must be passed a valid event!");
+ parcAssertNotNull(parcEvent, "parcEvent_Start must be passed a valid event!");
int result = event_add(parcEvent->event, NULL);
return result;
parcEvent_Stop(PARCEvent *parcEvent)
{
parcEvent_LogDebug(parcEvent, "parcEvent_Stop(%p)\n", parcEvent);
- assertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!");
+ parcAssertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!");
int result = event_del(parcEvent->event);
return result;
parcEvent_Poll(PARCEvent *parcEvent, PARCEventType event)
{
parcEvent_LogDebug(parcEvent, "parcEvent_Stop(%p)\n", parcEvent);
- assertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!");
+ parcAssertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!");
int result = event_pending(parcEvent->event, event, NULL);
return result;
parcEvent_Destroy(PARCEvent **parcEvent)
{
parcEvent_LogDebug((*parcEvent), "parcEvent_Destroy(%p)\n", *parcEvent);
- assertNotNull(*parcEvent, "parcEvent_Destroy must be passed a valid parcEvent!");
- assertNotNull((*parcEvent)->event, "parcEvent_Destroy passed a null event!");
+ parcAssertNotNull(*parcEvent, "parcEvent_Destroy must be passed a valid parcEvent!");
+ parcAssertNotNull((*parcEvent)->event, "parcEvent_Destroy passed a null event!");
event_free((*parcEvent)->event);
parcMemory_Deallocate((void **) parcEvent);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include "internal_parc_Event.h"
#include <parc/algol/parc_Event.h>
{
internal_parc_initializeLibevent();
struct evbuffer *new_evbuffer = evbuffer_new();
- assertNotNull(new_evbuffer, "libevent returned a null evbuffer.\n");
+ parcAssertNotNull(new_evbuffer, "libevent returned a null evbuffer.\n");
PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer));
- assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
+ parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
parcEventBuffer->allocated_evbuffer = new_evbuffer;
parcEventBuffer->evbuffer = parcEventBuffer->allocated_evbuffer;
parcEventBuffer_Destroy(PARCEventBuffer **parcEventBuffer)
{
parcEventBuffer_LogDebug((*parcEventBuffer), "parcEventBuffer_Destroy(parcEventBuffer=%p)\n", *parcEventBuffer);
- assertNotNull(parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer pointer\n");
- assertNotNull(*parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer\n");
+ parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer pointer\n");
+ parcAssertNotNull(*parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer\n");
// Destroy allocated eveventBuffer if it was allocated by us, otherwise it's owned by bufferevent
if ((*parcEventBuffer)->allocated_evbuffer) {
void
parcEventBuffer_AssertValid(const PARCEventBuffer *eventBuffer)
{
- assertTrue(parcEventBuffer_IsValid(eventBuffer),
+ parcAssertTrue(parcEventBuffer_IsValid(eventBuffer),
"PARCEventBuffer@%p is not valid.", (void *) eventBuffer);
}
{
parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetLength(parcEventBuffer=%p)\n", parcEventBuffer);
// parcEventBuffer_OptionalAssertValid(parcEventBuffer);
- assertNotNull(parcEventBuffer, "parcEventBuffer_GetLength was passed a null parcEventBuffer\n");
+ parcAssertNotNull(parcEventBuffer, "parcEventBuffer_GetLength was passed a null parcEventBuffer\n");
if (parcEventBuffer->evbuffer) {
return evbuffer_get_length(parcEventBuffer->evbuffer);
parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_Pullup(parcEventBuffer=%p,size=%zx)\n", parcEventBuffer, size);
parcEventBuffer_OptionalAssertValid(parcEventBuffer);
-// assertNotNull(parcEventBuffer, "parcEventBuffer_Pullup was passed a null parcEventBuffer\n");
-// assertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Pullup was passed a null libevent evbuffer\n");
+// parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Pullup was passed a null parcEventBuffer\n");
+// parcAssertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Pullup was passed a null libevent evbuffer\n");
return evbuffer_pullup(parcEventBuffer->evbuffer, (ev_ssize_t) size);
}
{
parcEventBuffer_OptionalAssertValid(source);
parcEventBuffer_OptionalAssertValid(destination);
-// assertNotNull(source, "parcEventBuffer_ReadIntoBuffer was passed a null source buffer\n");
-// assertNotNull(source->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null source evbuffer\n");
-// assertNotNull(destination, "parcEventBuffer_ReadIntoBuffer was passed a null destination buffer\n");
-// assertNotNull(destination->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null destination evbuffer\n");
+// parcAssertNotNull(source, "parcEventBuffer_ReadIntoBuffer was passed a null source buffer\n");
+// parcAssertNotNull(source->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null source evbuffer\n");
+// parcAssertNotNull(destination, "parcEventBuffer_ReadIntoBuffer was passed a null destination buffer\n");
+// parcAssertNotNull(destination->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null destination evbuffer\n");
return evbuffer_remove_buffer(source->evbuffer, destination->evbuffer, length);
}
parcEventBuffer_Read(PARCEventBuffer *readBuffer, void *data, size_t length)
{
parcEventBuffer_OptionalAssertValid(readBuffer);
-// assertNotNull(readBuffer, "parcEventBuffer_Read was passed a null buffer\n");
-// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_Read was passed a null libevent evbuffer\n");
+// parcAssertNotNull(readBuffer, "parcEventBuffer_Read was passed a null buffer\n");
+// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_Read was passed a null libevent evbuffer\n");
if (data == NULL) {
return evbuffer_drain(readBuffer->evbuffer, length);
int
parcEventBuffer_copyOut(PARCEventBuffer *readBuffer, void *data_out, size_t length)
{
- assertNotNull(data_out, "parcEventBuffer_Copy was passed a null data_out buffer\n");
+ parcAssertNotNull(data_out, "parcEventBuffer_Copy was passed a null data_out buffer\n");
parcEventBuffer_OptionalAssertValid(readBuffer);
return evbuffer_copyout(readBuffer->evbuffer, data_out, length);
}
{
parcEventBuffer_OptionalAssertValid(writeBuffer);
-// assertNotNull(writeBuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null buffer\n");
-// assertNotNull(writeBuffer->evbuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null libevent evbuffer\n");
+// parcAssertNotNull(writeBuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null buffer\n");
+// parcAssertNotNull(writeBuffer->evbuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null libevent evbuffer\n");
return evbuffer_write_atmost(writeBuffer->evbuffer, fd, length);
}
parcEventBuffer_ReadFromFileDescriptor(PARCEventBuffer *readBuffer, int fd, size_t length)
{
parcEventBuffer_OptionalAssertValid(readBuffer);
-// assertNotNull(readBuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null buffer\n");
-// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null libevent evbuffer\n");
+// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null buffer\n");
+// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null libevent evbuffer\n");
return evbuffer_read(readBuffer->evbuffer, fd, (int) length);
}
parcEventBuffer_FreeLine(PARCEventBuffer *readBuffer, char **line)
{
parcEventBuffer_OptionalAssertValid(readBuffer);
-// assertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n");
-// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n");
+// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n");
+// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n");
parcMemory_Deallocate((void **) line);
}
parcEventBuffer_ReadLine(PARCEventBuffer *readBuffer, size_t *length)
{
parcEventBuffer_OptionalAssertValid(readBuffer);
-// assertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n");
-// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n");
+// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n");
+// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n");
return evbuffer_readln(readBuffer->evbuffer, length, EVBUFFER_EOL_CRLF);
}
{
parcEventBuffer_OptionalAssertValid(source);
parcEventBuffer_OptionalAssertValid(destination);
-// assertNotNull(source, "parcEventBuffer_AppendBuffer was passed a null source parcEventBuffer\n");
-// assertNotNull(destination, "parcEventBuffer_AppendBuffer was passed a null destination parcEventBuffer\n");
-// assertNotNull(source->evbuffer, "parcEventBuffer_AppendBuffer was passed a null source libevent evbuffer\n");
-// assertNotNull(destination->evbuffer, "parcEventBuffer_AppendBuffer was passed a null destination libevent evbuffer\n");
+// parcAssertNotNull(source, "parcEventBuffer_AppendBuffer was passed a null source parcEventBuffer\n");
+// parcAssertNotNull(destination, "parcEventBuffer_AppendBuffer was passed a null destination parcEventBuffer\n");
+// parcAssertNotNull(source->evbuffer, "parcEventBuffer_AppendBuffer was passed a null source libevent evbuffer\n");
+// parcAssertNotNull(destination->evbuffer, "parcEventBuffer_AppendBuffer was passed a null destination libevent evbuffer\n");
return evbuffer_add_buffer(destination->evbuffer, source->evbuffer);
}
parcEventBuffer_Append(PARCEventBuffer *parcEventBuffer, void *data, size_t length)
{
parcEventBuffer_OptionalAssertValid(parcEventBuffer);
-// assertNotNull(parcEventBuffer, "parcEventBuffer_Append was passed a null parcEventBuffer\n");
-// assertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Append was passed a null libevent evbuffer\n");
- assertNotNull(data, "parcEventBuffer_Append was passed a null data buffer\n");
+// parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Append was passed a null parcEventBuffer\n");
+// parcAssertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Append was passed a null libevent evbuffer\n");
+ parcAssertNotNull(data, "parcEventBuffer_Append was passed a null data buffer\n");
return evbuffer_add(parcEventBuffer->evbuffer, data, length);
}
parcEventBuffer_Prepend(PARCEventBuffer *readBuffer, void *data, size_t length)
{
parcEventBuffer_OptionalAssertValid(readBuffer);
-// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_Prepend was passed a null libevent evbuffer\n");
-// assertNotNull(readBuffer, "parcEventBuffer_Prepend was passed a null buffer\n");
- assertNotNull(data, "parcEventBuffer_Prepend was passed a null data buffer\n");
+// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_Prepend was passed a null libevent evbuffer\n");
+// parcAssertNotNull(readBuffer, "parcEventBuffer_Prepend was passed a null buffer\n");
+ parcAssertNotNull(data, "parcEventBuffer_Prepend was passed a null data buffer\n");
return evbuffer_prepend(readBuffer->evbuffer, data, length);
}
PARCEventBuffer *
parcEventBuffer_GetQueueBufferInput(PARCEventQueue *queue)
{
- assertNotNull(queue, "parcEventBuffer_GetQueueBufferInput was passed a null queue\n");
+ parcAssertNotNull(queue, "parcEventBuffer_GetQueueBufferInput was passed a null queue\n");
PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer));
- assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
+ parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
parcEventBuffer->evbuffer = internal_parcEventQueue_GetEvInputBuffer(queue);
parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetQueueBufferInput(queue=%p)\n", queue);
PARCEventBuffer *
parcEventBuffer_GetQueueBufferOutput(PARCEventQueue *queue)
{
- assertNotNull(queue, "parcEventBuffer_GetQueueBufferOutput was passed a null queue\n");
+ parcAssertNotNull(queue, "parcEventBuffer_GetQueueBufferOutput was passed a null queue\n");
PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer));
- assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
+ parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer));
parcEventBuffer->evbuffer = internal_parcEventQueue_GetEvOutputBuffer(queue);
parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetQueueBufferInput(queue=%p)\n", queue);
#include <config.h>
#include <errno.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include "internal_parc_Event.h"
#include <parc/algol/parc_EventScheduler.h>
parcEventQueue_LogDebug(parcEventQueue,
"_parc_queue_read_callback(bev=%p,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n",
bev, parcEventQueue->buffereventBuffer, parcEventQueue);
- assertNotNull(parcEventQueue->readCallback, "parcEvent read callback called when NULL");
+ parcAssertNotNull(parcEventQueue->readCallback, "parcEvent read callback called when NULL");
parcEventQueue->readCallback(parcEventQueue, PARCEventType_Read, parcEventQueue->readUserData);
}
parcEventQueue_LogDebug(parcEventQueue,
"_parc_queue_write_callback(bev=%p,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n",
bev, parcEventQueue->buffereventBuffer, parcEventQueue);
- assertNotNull(parcEventQueue->writeCallback, "parcEvent write callback called when NULL");
+ parcAssertNotNull(parcEventQueue->writeCallback, "parcEvent write callback called when NULL");
parcEventQueue->writeCallback(parcEventQueue, PARCEventType_Write, parcEventQueue->writeUserData);
}
parcEventQueue_LogDebug(parcEventQueue,
"_parc_queue_event_callback(bev=%p,events=%x,errno=%d,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n",
bev, events, errno, parcEventQueue->buffereventBuffer, parcEventQueue);
- assertNotNull(parcEventQueue->eventCallback, "parcEvent event callback called when NULL");
+ parcAssertNotNull(parcEventQueue->eventCallback, "parcEvent event callback called when NULL");
errno = errno_forwarded;
parcEventQueue->eventCallback(parcEventQueue, internal_bufferevent_type_to_PARCEventQueueEventType(events), parcEventQueue->eventUserData);
PARCEventQueue *
parcEventQueue_Create(PARCEventScheduler *eventScheduler, int fd, PARCEventQueueOption flags)
{
- assertNotNull(eventScheduler, "parcEventQueue_Create passed a NULL scheduler instance.");
+ parcAssertNotNull(eventScheduler, "parcEventQueue_Create passed a NULL scheduler instance.");
PARCEventQueue *parcEventQueue = parcMemory_AllocateAndClear(sizeof(PARCEventQueue));
- assertNotNull(parcEventQueue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
+ parcAssertNotNull(parcEventQueue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
parcEventQueue->eventScheduler = eventScheduler;
//
//
parcEventQueue->buffereventBuffer = bufferevent_socket_new(parcEventScheduler_GetEvBase(eventScheduler), fd,
internal_PARCEventQueueOption_to_bufferevent_options(flags));
- assertNotNull(parcEventQueue->buffereventBuffer,
+ parcAssertNotNull(parcEventQueue->buffereventBuffer,
"Got null from bufferevent_socket_new for socket %d", fd);
parcEventQueue_LogDebug(parcEventQueue,
parcEventQueue_Destroy(PARCEventQueue **parcEventQueue)
{
parcEventQueue_LogDebug((*parcEventQueue), "parcEventQueue_Destroy(ptr=%p)\n", *parcEventQueue);
- assertNotNull((*parcEventQueue)->buffereventBuffer, "parcEventQueue_Destroy passed a null buffer!");
+ parcAssertNotNull((*parcEventQueue)->buffereventBuffer, "parcEventQueue_Destroy passed a null buffer!");
bufferevent_free((*parcEventQueue)->buffereventBuffer);
parcMemory_Deallocate((void *) parcEventQueue);
parcEventQueue_Printf(PARCEventQueue *parcEventQueue, const char *fmt, ...)
{
struct evbuffer *buffer = bufferevent_get_output(parcEventQueue->buffereventBuffer);
- assertNotNull(buffer, "bufferevent_get_output returned NULL");
+ parcAssertNotNull(buffer, "bufferevent_get_output returned NULL");
va_list ap;
PARCEventQueuePair *
parcEventQueue_CreateConnectedPair(PARCEventScheduler *eventScheduler)
{
- assertNotNull(eventScheduler, "parcEventQueue_CreateConnectedPair must be passed a valid Event Scheduler");
+ parcAssertNotNull(eventScheduler, "parcEventQueue_CreateConnectedPair must be passed a valid Event Scheduler");
PARCEventQueuePair *parcEventQueuePair = parcMemory_AllocateAndClear(sizeof(PARCEventQueuePair));
- assertNotNull(parcEventQueuePair, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueuePair));
+ parcAssertNotNull(parcEventQueuePair, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueuePair));
parcEventQueuePair->up = parcMemory_AllocateAndClear(sizeof(PARCEventQueue));
parcEventQueuePair->up->eventScheduler = eventScheduler;
eventScheduler,
parcEventScheduler_GetEvBase(eventScheduler),
parcEventQueuePair->up);
- assertNotNull(parcEventQueuePair->up, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
+ parcAssertNotNull(parcEventQueuePair->up, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
parcEventQueuePair->down = parcMemory_AllocateAndClear(sizeof(PARCEventQueue));
parcEventQueuePair->down->eventScheduler = eventScheduler;
eventScheduler,
parcEventScheduler_GetEvBase(eventScheduler),
parcEventQueuePair->down);
- assertNotNull(parcEventQueuePair->down, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
+ parcAssertNotNull(parcEventQueuePair->down, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue));
struct bufferevent *evpair[2];
int result = bufferevent_pair_new(parcEventScheduler_GetEvBase(eventScheduler), 0, evpair);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <unistd.h>
internal_parc_initializeLibevent();
PARCEventScheduler *parcEventScheduler = parcMemory_Allocate(sizeof(PARCEventScheduler));
- assertNotNull(parcEventScheduler, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventScheduler));
+ parcAssertNotNull(parcEventScheduler, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventScheduler));
// Initialize libevent base pointer.
parcEventScheduler->evbase = event_base_new();
- assertNotNull(parcEventScheduler->evbase, "Could not obtain an event base!");
+ parcAssertNotNull(parcEventScheduler->evbase, "Could not obtain an event base!");
int result = event_base_priority_init(parcEventScheduler->evbase, PARCEventPriority_NumberOfPriorities);
- assertTrue(result == 0, "Could not set scheduler priorities (%d)", result);
+ parcAssertTrue(result == 0, "Could not set scheduler priorities (%d)", result);
parcEventScheduler->log = _parc_logger_create();
- assertNotNull(parcEventScheduler->log, "Could not create parc logger");
+ parcAssertNotNull(parcEventScheduler->log, "Could not create parc logger");
parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Create() = %p\n", parcEventScheduler);
parcEventScheduler_Start(PARCEventScheduler *parcEventScheduler, PARCEventSchedulerDispatchType type)
{
parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Start(%p, %d)\n", parcEventScheduler, type);
- assertNotNull(parcEventScheduler, "parcEventScheduler_Start must be passed a valid base parcEventScheduler!");
+ parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Start must be passed a valid base parcEventScheduler!");
int result = event_base_loop(parcEventScheduler->evbase,
internal_PARCEventSchedulerDispatchType_to_eventloop_options(type));
return result;
parcEventScheduler_Stop(PARCEventScheduler *parcEventScheduler, struct timeval *delay)
{
parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Stop(%p, %p)\n", parcEventScheduler, delay);
- assertNotNull(parcEventScheduler, "parcEventScheduler_Stop must be passed a valid base parcEventScheduler!");
+ parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Stop must be passed a valid base parcEventScheduler!");
int result = event_base_loopexit(parcEventScheduler->evbase, delay);
return result;
}
parcEventScheduler_Abort(PARCEventScheduler *parcEventScheduler)
{
parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Abort(%p)\n", parcEventScheduler);
- assertNotNull(parcEventScheduler, "parcEventScheduler_Abort must be passed a valid base parcEventScheduler!");
+ parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Abort must be passed a valid base parcEventScheduler!");
int result = event_base_loopbreak(parcEventScheduler->evbase);
return result;
}
{
parcEventScheduler_LogDebug((*parcEventScheduler), "parcEventScheduler_Destroy(%p)\n", *parcEventScheduler);
- assertNotNull(*parcEventScheduler, "parcEventScheduler_Destroy must be passed a valid base parcEventScheduler!");
- assertNotNull((*parcEventScheduler)->evbase, "parcEventScheduler_Destroy passed a NULL event base member!");
+ parcAssertNotNull(*parcEventScheduler, "parcEventScheduler_Destroy must be passed a valid base parcEventScheduler!");
+ parcAssertNotNull((*parcEventScheduler)->evbase, "parcEventScheduler_Destroy passed a NULL event base member!");
event_base_free((*parcEventScheduler)->evbase);
parcLog_Release(&((*parcEventScheduler)->log));
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include "internal_parc_Event.h"
#include <parc/algol/parc_EventScheduler.h>
parcEventSignal_Create(PARCEventScheduler *eventScheduler, int signal, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs)
{
PARCEventSignal *parcEventSignal = parcMemory_Allocate(sizeof(PARCEventSignal));
- assertNotNull(parcEventSignal, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSignal));
+ parcAssertNotNull(parcEventSignal, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSignal));
parcEventSignal->eventScheduler = eventScheduler;
parcEventSignal->callback = callback;
parcEventSignal->event = event_new(parcEventScheduler_GetEvBase(eventScheduler), signal,
internal_PARCEventType_to_libevent_type(flags),
_parc_event_signal_callback, parcEventSignal);
- assertNotNull(parcEventSignal->event, "Could not create a new event!");
+ parcAssertNotNull(parcEventSignal->event, "Could not create a new event!");
parcEventSignal_LogDebug(parcEventSignal,
"parcEventSignal_Create(base=%p,signal=%x,flags=%x,cb=%p,args=%p) = %p\n",
parcEventSignal_Start(PARCEventSignal *parcEventSignal)
{
parcEventSignal_LogDebug(parcEventSignal, "parcEventSignal_Start(event=%p)\n", parcEventSignal);
- assertNotNull(parcEventSignal, "parcEventStart_Signal must be passed a valid event!");
+ parcAssertNotNull(parcEventSignal, "parcEventStart_Signal must be passed a valid event!");
int result = event_add(parcEventSignal->event, NULL);
return result;
parcEventSignal_Stop(PARCEventSignal *parcEventSignal)
{
parcEventSignal_LogDebug(parcEventSignal, "parcEventSignal_Stop(event=%p)\n", parcEventSignal);
- assertNotNull(parcEventSignal, "parcEvent_Stop must be passed a valid event!");
+ parcAssertNotNull(parcEventSignal, "parcEvent_Stop must be passed a valid event!");
int result = event_del(parcEventSignal->event);
return result;
parcEventSignal_Destroy(PARCEventSignal **parcEventSignal)
{
parcEventSignal_LogDebug((*parcEventSignal), "parcEventSignal_Destroy(event=%p)\n", parcEventSignal);
- assertNotNull(*parcEventSignal, "parcEvent_Destroy must be passed a valid parcEventSignal!");
- assertNotNull((*parcEventSignal)->event, "parcEvent_Destroy passed a null event!");
+ parcAssertNotNull(*parcEventSignal, "parcEvent_Destroy must be passed a valid parcEventSignal!");
+ parcAssertNotNull((*parcEventSignal)->event, "parcEvent_Destroy passed a null event!");
event_free((*parcEventSignal)->event);
parcMemory_Deallocate((void **) parcEventSignal);
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_EventScheduler.h>
#include <parc/algol/parc_EventSocket.h>
void *userData, const struct sockaddr *sa, int socklen)
{
PARCEventSocket *parcEventSocket = parcMemory_AllocateAndClear(sizeof(PARCEventSocket));
- assertNotNull(parcEventSocket, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSocket));
+ parcAssertNotNull(parcEventSocket, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSocket));
parcEventSocket->eventScheduler = eventScheduler;
parcEventSocket->socketCallback = callback;
void
parcEventSocket_Destroy(PARCEventSocket **socketEvent)
{
- assertNotNull(*socketEvent, "parcEventSocket_Destroy must be passed a valid socketEvent!");
+ parcAssertNotNull(*socketEvent, "parcEventSocket_Destroy must be passed a valid socketEvent!");
if ((*socketEvent)->listener) {
evconnlistener_free((*socketEvent)->listener);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include "internal_parc_Event.h"
#include <parc/algol/parc_EventTimer.h>
parcEventTimer_Create(PARCEventScheduler *eventScheduler, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs)
{
PARCEventTimer *parcEventTimer = parcMemory_Allocate(sizeof(PARCEventTimer));
- assertNotNull(parcEventTimer, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventTimer));
+ parcAssertNotNull(parcEventTimer, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventTimer));
parcEventTimer->eventScheduler = eventScheduler;
parcEventTimer->callback = callback;
parcEventTimer->event = event_new(parcEventScheduler_GetEvBase(eventScheduler), -1,
internal_PARCEventType_to_libevent_type(flags),
_parc_event_timer_callback, parcEventTimer);
- assertNotNull(parcEventTimer->event, "Could not create a new event!");
+ parcAssertNotNull(parcEventTimer->event, "Could not create a new event!");
parcEventTimer_LogDebug(parcEventTimer,
"parcEventTimer_Create(base=%p,events=%x,cb=%p,args=%p) = %p\n",
parcEventTimer_LogDebug(parcEventTimer,
"parcEventTimer_Start(event=%p, timeout=%d:%d)\n",
parcEventTimer, timeout->tv_sec, timeout->tv_usec);
- assertNotNull(parcEventTimer, "parcEventTimer_Start must be passed a valid event!");
+ parcAssertNotNull(parcEventTimer, "parcEventTimer_Start must be passed a valid event!");
int result = event_add(parcEventTimer->event, timeout);
return result;
parcEventTimer_Stop(PARCEventTimer *parcEventTimer)
{
parcEventTimer_LogDebug(parcEventTimer, "parcEventTimer_Stop(event=%p)\n", parcEventTimer);
- assertNotNull(parcEventTimer, "parcEventTimer_Stop must be passed a valid event!");
+ parcAssertNotNull(parcEventTimer, "parcEventTimer_Stop must be passed a valid event!");
int result = event_del(parcEventTimer->event);
return result;
parcEventTimer_Destroy(PARCEventTimer **parcEventTimer)
{
parcEventTimer_LogDebug((*parcEventTimer), "parcEventTimer_Destroy(parcEventTimer=%p)\n", *parcEventTimer);
- assertNotNull(*parcEventTimer, "parcEventTimer_Destroy must be passed a valid parcEventTimer!");
- assertNotNull((*parcEventTimer)->event, "parcEventTimer_Destroy passed a null event!");
+ parcAssertNotNull(*parcEventTimer, "parcEventTimer_Destroy must be passed a valid parcEventTimer!");
+ parcAssertNotNull((*parcEventTimer)->event, "parcEventTimer_Destroy passed a null event!");
event_free((*parcEventTimer)->event);
parcMemory_Deallocate((void **) parcEventTimer);
#include <string.h>
#include <errno.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_PathName.h>
void
parcFile_AssertValid(const PARCFile *instance)
{
- trapIllegalValueIf(instance == NULL, "Parameter must be a non-null pointer to a valid PARCFile.");
- trapIllegalValueIf(instance->pathName == NULL, "PARCFile cannot have a NULL path-name");
+ parcTrapIllegalValueIf(instance == NULL, "Parameter must be a non-null pointer to a valid PARCFile.");
+ parcTrapIllegalValueIf(instance->pathName == NULL, "PARCFile cannot have a NULL path-name");
}
PARCFile *
char *string = parcPathName_ToString(file->pathName);
// only allow under tmp
- assertTrue(strncmp(string, "/tmp/", 5) == 0,
+ parcAssertTrue(strncmp(string, "/tmp/", 5) == 0,
"Path must begin with /tmp/: %s", string);
// dont allow ".."
- assertNull(strstr(string, ".."), "Path cannot have .. in it: %s", string);
+ parcAssertNull(strstr(string, ".."), "Path cannot have .. in it: %s", string);
bool result = false;
if (parcFile_IsDirectory(file)) {
int maximumFileDescriptors = 20;
int failure = nftw(string, _deleteNode, maximumFileDescriptors, flags);
- assertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno));
+ parcAssertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno));
result = failure == false;
} else {
#include <unistd.h>
#include <sys/stat.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_File.h>
PARCFileInputStream *
parcFileInputStream_Create(int fileDescriptor)
{
- trapIllegalValueIf(fileDescriptor < 0, "File descriptor must not be negative.");
+ parcTrapIllegalValueIf(fileDescriptor < 0, "File descriptor must not be negative.");
PARCFileInputStream *result = parcObject_CreateInstance(PARCFileInputStream);
if (result != NULL) {
*
* parcFileOutputStream_Write(stream, buffer);
*
- * assertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy");
+ * parcAssertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy");
*
* parcBuffer_Release(&buffer);
*
#include <stdio.h>
#include <unistd.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_FileOutputStream.h>
#include <parc/algol/parc_Object.h>
PARCFileOutputStream *
parcFileOutputStream_Create(int fileDescriptor)
{
- assertTrue(fileDescriptor != -1, "Invalid file descriptor");
+ parcAssertTrue(fileDescriptor != -1, "Invalid file descriptor");
PARCFileOutputStream *result = parcObject_CreateInstance(PARCFileOutputStream);
result->fd = fileDescriptor;
*
* parcFileOutputStream_Write(stream, buffer);
*
- * assertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy");
+ * parcAssertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy");
*
* parcBuffer_Release(&buffer);
*
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <string.h>
temp_table.tableLimit = old_table->tableLimit * expandby;
temp_table.expandThreshold = temp_table.tableLimit - temp_table.tableLimit / 4;
temp_table.entries = parcMemory_AllocateAndClear(temp_table.tableLimit * sizeof(HashTableEntry));
- assertNotNull(temp_table.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", temp_table.tableLimit * sizeof(HashTableEntry));
+ parcAssertNotNull(temp_table.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", temp_table.tableLimit * sizeof(HashTableEntry));
result = _rehash(old_table, &temp_table, hashCodeTable->keyEqualsFunc);
if (result == ADD_NOSPACE) {
size_t minimumSize)
{
PARCHashCodeTable *table = parcMemory_AllocateAndClear(sizeof(PARCHashCodeTable));
- assertNotNull(table, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCHashCodeTable));
+ parcAssertNotNull(table, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCHashCodeTable));
- assertNotNull(keyEqualsFunc, "keyEqualsFunc must be non-null");
- assertNotNull(keyHashCodeFunc, "keyHashCodeFunc must be non-null");
- assertTrue(minimumSize > 0, "minimumSize must be greater than zero");
+ parcAssertNotNull(keyEqualsFunc, "keyEqualsFunc must be non-null");
+ parcAssertNotNull(keyHashCodeFunc, "keyHashCodeFunc must be non-null");
+ parcAssertTrue(minimumSize > 0, "minimumSize must be greater than zero");
table->keyEqualsFunc = keyEqualsFunc;
table->keyHashCodeFunc = keyHashCodeFunc;
table->dataDestroyer = dataDestroyer;
table->hashtable.entries = parcMemory_AllocateAndClear(minimumSize * sizeof(HashTableEntry));
- assertNotNull(table->hashtable.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", minimumSize * sizeof(HashTableEntry));
+ parcAssertNotNull(table->hashtable.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", minimumSize * sizeof(HashTableEntry));
table->hashtable.tableLimit = minimumSize;
table->hashtable.tableSize = 0;
void
parcHashCodeTable_Destroy(PARCHashCodeTable **tablePtr)
{
- assertNotNull(tablePtr, "Parameter must be non-null double pointer");
- assertNotNull(*tablePtr, "Parameter must dereference to non-null pointer");
+ parcAssertNotNull(tablePtr, "Parameter must be non-null double pointer");
+ parcAssertNotNull(*tablePtr, "Parameter must dereference to non-null pointer");
PARCHashCodeTable *table = *tablePtr;
size_t i;
bool
parcHashCodeTable_Add(PARCHashCodeTable *table, void *key, void *data)
{
- assertNotNull(table, "Parameter table must be non-null");
- assertNotNull(key, "Parameter key must be non-null");
- assertNotNull(data, "Parameter data must be non-null");
+ parcAssertNotNull(table, "Parameter table must be non-null");
+ parcAssertNotNull(key, "Parameter key must be non-null");
+ parcAssertNotNull(data, "Parameter data must be non-null");
if (table->hashtable.tableSize >= table->hashtable.expandThreshold) {
_expand(table);
size_t index;
bool found;
- assertNotNull(table, "Parameter table must be non-null");
- assertNotNull(key, "parameter key must be non-null");
+ parcAssertNotNull(table, "Parameter table must be non-null");
+ parcAssertNotNull(key, "parameter key must be non-null");
found = _findIndex(table, key, &index);
if (found) {
- assertTrue(table->hashtable.tableSize > 0, "Illegal state: found entry in a hash table with 0 size");
+ parcAssertTrue(table->hashtable.tableSize > 0, "Illegal state: found entry in a hash table with 0 size");
if (table->keyDestroyer) {
table->keyDestroyer(&table->hashtable.entries[index].key);
{
size_t index;
- assertNotNull(table, "Parameter table must be non-null");
- assertNotNull(key, "parameter key must be non-null");
+ parcAssertNotNull(table, "Parameter table must be non-null");
+ parcAssertNotNull(key, "parameter key must be non-null");
bool found = _findIndex(table, key, &index);
size_t
parcHashCodeTable_Length(const PARCHashCodeTable *table)
{
- assertNotNull(table, "Parameter table must be non-null");
+ parcAssertNotNull(table, "Parameter table must be non-null");
return table->hashtable.tableSize;
}
/**
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
static void
_parcHashMapEntry_Finalize(_PARCHashMapEntry **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer.");
_PARCHashMapEntry *hashMapEntry = *instancePtr;
_parcHashMapEntry_IsValid(hashMapEntry);
static void
_parcHashMap_Finalize(PARCHashMap **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer.");
PARCHashMap *hashMap = *instancePtr;
for (unsigned int i = 0; i < hashMap->capacity; i++) {
void
parcHashMap_AssertValid(const PARCHashMap *instance)
{
- assertTrue(parcHashMap_IsValid(instance),
+ parcAssertTrue(parcHashMap_IsValid(instance),
"PARCHashMap is not valid.");
}
}
}
- trapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator");
+ parcTrapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator");
}
return state;
if (map->buckets[state->bucket] != NULL) {
parcIterator_Release(&state->listIterator);
state->listIterator = parcLinkedList_CreateIterator(map->buckets[state->bucket]);
- trapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator");
+ parcTrapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator");
result = parcIterator_HasNext(state->listIterator);
}
}
void (*fini)(PARCObject *, void *),
void (*assertValid)(const void *))
{
- assertNotNull(object, "PARCObject cannot be NULL.");
- assertNotNull(init, "'init' function cannot be NULL.");
- assertNotNull(hasNext, "'hasNext' function cannot be NULL.");
- assertNotNull(next, "'next' function cannot be NULL.");
- assertNotNull(element, "'element' function cannot be NULL.");
- assertNotNull(fini, "'fini' function cannot be NULL.");
+ parcAssertNotNull(object, "PARCObject cannot be NULL.");
+ parcAssertNotNull(init, "'init' function cannot be NULL.");
+ parcAssertNotNull(hasNext, "'hasNext' function cannot be NULL.");
+ parcAssertNotNull(next, "'next' function cannot be NULL.");
+ parcAssertNotNull(element, "'element' function cannot be NULL.");
+ parcAssertNotNull(fini, "'fini' function cannot be NULL.");
PARCIterator *result = parcObject_CreateInstance(PARCIterator);
void
parcIterator_AssertValid(const PARCIterator *iterator)
{
- assertTrue(parcIterator_IsValid(iterator), "PARCIterator is not valid.");
+ parcAssertTrue(parcIterator_IsValid(iterator), "PARCIterator is not valid.");
}
parcObject_ImplementAcquire(parcIterator, PARCIterator);
*
* * `next`
* Returns the next element in the iteration.
- * If there are no remaining elements in the iteration, then this function must induce a trapOutOfBounds
+ * If there are no remaining elements in the iteration, then this function must induce a parcTrapOutOfBounds
*
* * `remove`
* Removes the element returned by the `next` function.
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <ctype.h>
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_JSONArray.h>
#include <parc/algol/parc_Object.h>
void
parcJSONArray_AssertValid(const PARCJSONArray *array)
{
- assertNotNull(array, "Must be a non-null pointer to a PARCJSONArray instance.");
- assertNotNull(array->array, "Must be a non-null pointer to a PARCDeque instance.");
+ parcAssertNotNull(array, "Must be a non-null pointer to a PARCJSONArray instance.");
+ parcAssertNotNull(array->array, "Must be a non-null pointer to a PARCDeque instance.");
}
PARCJSONArray *
/**
* Assert that an instance of `PARCJSONArray` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue}
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <ctype.h>
{
if (pairPtr != NULL) {
PARCJSONPair *pair = *pairPtr;
- assertNotNull(pair, "Parameter must be a non-null pointer to a valid PARCJSONPair.");
+ parcAssertNotNull(pair, "Parameter must be a non-null pointer to a valid PARCJSONPair.");
parcBuffer_Release(&pair->name);
parcJSONValue_Release(&pair->value);
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <ctype.h>
#include <string.h>
void
parcJSONParser_AssertValid(const PARCJSONParser *parser)
{
- assertNotNull(parser, "PARCJSONParser cannot be NULL");
+ parcAssertNotNull(parser, "PARCJSONParser cannot be NULL");
parcBuffer_OptionalAssertValid(parser->buffer);
}
c = '\t';
} else if (c == 'u') {
// Not supporting unicode at this point.
- trapNotImplemented("Unicode is not supported.");
+ parcTrapNotImplemented("Unicode is not supported.");
}
} else if (iscntrl(c)) {
// !! Syntax Error.
/**
* Assert that an instance of `PARCJSONParser` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue()}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue()}
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <ctype.h>
void
parcJSONValue_AssertValid(const PARCJSONValue *value)
{
- assertNotNull(value, "PARCJSONValue cannot be NULL.");
+ parcAssertNotNull(value, "PARCJSONValue cannot be NULL.");
}
bool
PARCJSONValue *
parcJSONValue_CreateFromCString(const char *value)
{
- assertNotNull(value, "String cannot be NULL.");
+ parcAssertNotNull(value, "String cannot be NULL.");
PARCJSONValue *result = _createValue(PARCJSONValueType_String);
if (result != NULL) {
parcDisplayIndented_PrintLine(indentation + 1, ".value=null");
break;
default:
- trapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type);
+ parcTrapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type);
}
}
parcDisplayIndented_PrintLine(indentation, "}");
{
parcJSONValue_OptionalAssertValid(value);
- trapUnexpectedStateIf(!parcJSONValue_IsArray(value), "Expected type to be array, actual type %d", value->type);
+ parcTrapUnexpectedStateIf(!parcJSONValue_IsArray(value), "Expected type to be array, actual type %d", value->type);
return value->value.array;
}
{
parcJSONValue_OptionalAssertValid(value);
- trapUnexpectedStateIf(!parcJSONValue_IsBoolean(value), "Expected type to be boolean, actual type %d", value->type);
+ parcTrapUnexpectedStateIf(!parcJSONValue_IsBoolean(value), "Expected type to be boolean, actual type %d", value->type);
return value->value.boolean;
}
{
parcJSONValue_OptionalAssertValid(value);
- trapUnexpectedStateIf(!parcJSONValue_IsString(value), "Expected type to be string, actual type %d", value->type);
+ parcTrapUnexpectedStateIf(!parcJSONValue_IsString(value), "Expected type to be string, actual type %d", value->type);
return value->value.string;
}
{
parcJSONValue_OptionalAssertValid(value);
- trapUnexpectedStateIf(!parcJSONValue_IsJSON(value), "Expected type to be string, actual type %d", value->type);
+ parcTrapUnexpectedStateIf(!parcJSONValue_IsJSON(value), "Expected type to be string, actual type %d", value->type);
return value->value.object;
}
struct timeval *
parcJSONValue_GetTimeval(const PARCJSONValue *jsonTimeval, struct timeval *timeval)
{
- assertNotNull(jsonTimeval, "Parameter jsonTimeval must be a non-null PARCJSON pointer.");
+ parcAssertNotNull(jsonTimeval, "Parameter jsonTimeval must be a non-null PARCJSON pointer.");
PARCJSON *json = parcJSONValue_GetJSON(jsonTimeval);
PARCJSONValue *value = parcJSON_GetValueByName(json, "seconds");
struct timespec *
parcJSONValue_GetTimespec(const PARCJSONValue *jsonTimespec, struct timespec *timespec)
{
- assertNotNull(jsonTimespec, "Parameter jsonTimeval must be a non-null PARCJSON pointer.");
+ parcAssertNotNull(jsonTimespec, "Parameter jsonTimeval must be a non-null PARCJSON pointer.");
PARCJSON *json = parcJSONValue_GetJSON(jsonTimespec);
PARCJSONValue *value = parcJSON_GetValueByName(json, "seconds");
} else if (value->type == PARCJSONValueType_Null) {
parcBufferComposer_PutString(composer, "null");
} else {
- trapIllegalValue(value->type, "Unknown value type: %d", value->type);
+ parcTrapIllegalValue(value->type, "Unknown value type: %d", value->type);
}
return composer;
/**
* Assert that an instance of `PARCJSONValue` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue()}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue()}
*
* Valid means the internal state of the type is consistent with its required current or future behaviour.
* This may include the validation of internal instances of types.
#include "parc_KeyValue.h"
#include "parc_Object.h"
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
struct parc_key_value {
PARCObject *key;
parcKeyValue_Create(const PARCObject *key,
const PARCObject *value)
{
- assertNotNull(key, "Key may not be null in a KeyValue element");
+ parcAssertNotNull(key, "Key may not be null in a KeyValue element");
PARCKeyValue *keyValue = parcObject_CreateInstance(PARCKeyValue);
- assertNotNull(keyValue, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyValue));
+ parcAssertNotNull(keyValue, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyValue));
keyValue->key = parcObject_Acquire(key);
keyValue->value = NULL;
void
parcKeyValue_SetValue(PARCKeyValue *keyValue, PARCObject *value)
{
- assertNotNull(keyValue, "Not a valid keyValue");
+ parcAssertNotNull(keyValue, "Not a valid keyValue");
PARCObject *oldValue = keyValue->value;
if (value != NULL) {
keyValue->value = parcObject_Acquire(value);
void
parcKeyValue_SetKey(PARCKeyValue *keyValue, PARCObject *key)
{
- assertNotNull(keyValue, "Not a valid keyValue");
+ parcAssertNotNull(keyValue, "Not a valid keyValue");
PARCObject *oldKey = keyValue->key;
keyValue->key = parcObject_Acquire(key);
parcObject_Release(&oldKey);
PARCObject *
parcKeyValue_GetValue(PARCKeyValue *keyValue)
{
- assertNotNull(keyValue, "Not a valid keyValue");
+ parcAssertNotNull(keyValue, "Not a valid keyValue");
return keyValue->value;
}
PARCObject *
parcKeyValue_GetKey(PARCKeyValue *keyValue)
{
- assertNotNull(keyValue, "Not a valid keyValue");
+ parcAssertNotNull(keyValue, "Not a valid keyValue");
return keyValue->key;
}
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_KeyedElement.h>
#include <parc/algol/parc_Memory.h>
parcKeyedElement_Create(void *data, const void *key, size_t keylen)
{
PARCKeyedElement *keyedElement = parcMemory_Allocate(sizeof(PARCKeyedElement));
- assertNotNull(keyedElement, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement));
+ parcAssertNotNull(keyedElement, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement));
keyedElement->element = data;
keyedElement->key = parcMemory_Allocate(sizeof(PARCKeyedElement));
- assertNotNull(keyedElement->key, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement));
+ parcAssertNotNull(keyedElement->key, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement));
memcpy(keyedElement->key, key, keylen);
keyedElement->keylen = keylen;
return keyedElement;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <sys/queue.h>
_parcLinkedListIterator_IsValid(const _PARCLinkedListNode *node)
{
if (node != NULL) {
- assertTrue(_parcLinkedListNode_IsValid(node), "node is invalid");
+ parcAssertTrue(_parcLinkedListNode_IsValid(node), "node is invalid");
}
}
if (node == NULL) {
result = list->head;
} else {
- assertTrue(_parcLinkedListNode_IsValid(node), "node is invalid");
- trapOutOfBoundsIf(node->next == NULL, "No more elements.");
+ parcAssertTrue(_parcLinkedListNode_IsValid(node), "node is invalid");
+ parcTrapOutOfBoundsIf(node->next == NULL, "No more elements.");
result = node->next;
}
- assertTrue(_parcLinkedListNode_IsValid(result), "result is invalid");
+ parcAssertTrue(_parcLinkedListNode_IsValid(result), "result is invalid");
parcObject_OptionalAssertValid(result->object);
return result;
if (node == NULL) {
result = (list->head != NULL);
if (result) {
- assertTrue(_parcLinkedListNode_IsValid(list->head), "node is invalid");
+ parcAssertTrue(_parcLinkedListNode_IsValid(list->head), "node is invalid");
}
} else {
result = node->next != NULL;
if (result) {
- assertTrue(_parcLinkedListNode_IsValid(node->next), "node is invalid");
+ parcAssertTrue(_parcLinkedListNode_IsValid(node->next), "node is invalid");
}
}
void
parcLinkedList_AssertValid(const PARCLinkedList *instance)
{
- assertTrue(parcLinkedList_IsValid(instance),
+ parcAssertTrue(parcLinkedList_IsValid(instance),
"PARCLinkedList is not valid.");
}
bool
parcLinkedList_Remove(PARCLinkedList *list, const PARCObject *element)
{
- assertTrue(element != NULL, "Element must not be NULL");
+ parcAssertTrue(element != NULL, "Element must not be NULL");
bool result = false;
_PARCLinkedListNode *node = _parcLinkedListNode_getByValue(list, element);
PARCObject *result = NULL;
if (index > (parcLinkedList_Size(list) - 1)) {
- trapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1);
+ parcTrapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1);
}
_PARCLinkedListNode *node = _parcLinkedListNode_getByIndex(list, index);
parcLinkedList_GetAtIndex(const PARCLinkedList *list, size_t index)
{
if (index > (parcLinkedList_Size(list) - 1)) {
- trapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1);
+ parcTrapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1);
}
_PARCLinkedListNode *node = _parcLinkedListNode_getByIndex(list, index);
* @param [in] list A pointer to a `PARCLinkedList` instance.
* @param [in] index The index of the element to be retrieved.
*
- * @throws `trapOutOfBounds`
+ * @throws `parcTrapOutOfBounds`
*
* Example:
* @code
* @param [in] index The index of the element to be replaced.
* @param [in] element A pointer to a valid PARCObject instance that will replace the current element at @p index.
*
- * @throws `trapOutOfBounds`
+ * @throws `parcTrapOutOfBounds`
*
* Example:
* @code
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <stdarg.h>
* @return NULL Memory could not be allocated.
* @return non-NULL A pointer to a new `PARCList` instance.
*
- * @throws trapIllegalValue if @p instance is NULL.
+ * @throws parcTrapIllegalValue if @p instance is NULL.
*
* Example:
* @code
* parcList_AddAll(array, 3, elements);
* size_t actual = parcList_Length(array);
*
- * assertTrue(3 == actual, "Expected=%d, actual=%d", 3, actual);
+ * parcAssertTrue(3 == actual, "Expected=%d, actual=%d", 3, actual);
*
* parcListRelease(&array);
* }
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <unistd.h>
#include <stdlib.h>
const PARCMemoryInterface *
parcMemory_SetInterface(const PARCMemoryInterface *memoryProvider)
{
- assertFalse(memoryProvider == &PARCMemoryAsPARCMemory,
+ parcAssertFalse(memoryProvider == &PARCMemoryAsPARCMemory,
"You cannot use PARCMemoryAsPARCMemory as a memory provider for parcMemory.");
const PARCMemoryInterface *result = parcMemory;
parcMemory = memoryProvider;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <sys/socket.h>
#include <ctype.h>
switch (ai->ai_family) {
case PF_INET: {
struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
if (result != NULL) {
- assertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in),
+ parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in),
"Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in), ai->ai_addrlen);
memcpy(result, ai->ai_addr, ai->ai_addrlen);
result->sin_port = htons(port);
case PF_INET6: {
struct sockaddr_in6 *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in6));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6));
if (result != NULL) {
- assertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in6),
+ parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in6),
"Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in6), ai->ai_addrlen);
memcpy(result, ai->ai_addr, ai->ai_addrlen);
parcNetwork_SockInet4Address(const char *address, in_port_t port)
{
struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
if (result != NULL) {
result->sin_family = AF_INET;
result->sin_port = htons(port);
parcNetwork_SockInet6Address(const char *address, in_port_t port, uint32_t flowInfo, uint32_t scopeId)
{
struct sockaddr_in6 *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in6));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6));
if (result != NULL) {
result->sin6_family = AF_INET6;
result->sin6_port = htons(port);
parcNetwork_SockInet4AddressAny()
{
struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
if (result != NULL) {
result->sin_family = AF_INET;
result->sin_addr.s_addr = INADDR_ANY;
PARCBufferComposer *
parcNetwork_SockInet4Address_BuildString(const struct sockaddr_in *address, PARCBufferComposer *composer)
{
- assertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in.");
+ parcAssertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in.");
if (address->sin_family != AF_INET) {
- trapIllegalValue(address->sin_family, "Expected an AF_INET configured address, not %d", address->sin_family);
+ parcTrapIllegalValue(address->sin_family, "Expected an AF_INET configured address, not %d", address->sin_family);
}
char buffer[INET_ADDRSTRLEN];
PARCBufferComposer *
parcNetwork_SockInet6Address_BuildString(const struct sockaddr_in6 *address, PARCBufferComposer *composer)
{
- assertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in.");
+ parcAssertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in.");
if (address->sin6_family != AF_INET6) {
- trapIllegalValue(address->sin_family, "Expected an AF_INET6 configured address, not %d", address->sin6_family);
+ parcTrapIllegalValue(address->sin_family, "Expected an AF_INET6 configured address, not %d", address->sin6_family);
}
char buffer[INET6_ADDRSTRLEN];
if (parcNetwork_ParseMAC48Address(&address[7], result) == false) {
parcBuffer_Release(&result);
- trapIllegalValue(address, "Syntax error '%s'", address);
+ parcTrapIllegalValue(address, "Syntax error '%s'", address);
}
return parcBuffer_Flip(result);
}
- trapIllegalValue(address, "Bad scheme '%s'", address);
+ parcTrapIllegalValue(address, "Bad scheme '%s'", address);
}
bool
bool
parcNetwork_IsSocketLocal(struct sockaddr *sock)
{
- assertNotNull(sock, "Parameter sock must be non-null");
+ parcAssertNotNull(sock, "Parameter sock must be non-null");
bool isLocal = false;
switch (sock->sa_family) {
* {
* struct sockaddr *addr;
* addr = parcNetwork_SockAddress("1.2.3.4", 555);
- * assertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 for a dotted quad.");
+ * parcAssertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 for a dotted quad.");
* struct sockaddr_in *addr_in = (struct sockaddr_in *) addr;
* // ...
* parcMemory_Deallocate((void **)&addr);
*
* addr = parcNetwork_SockAddress("fe80::aa20:66ff:fe00:314a", 555);
- * assertTrue(addr && addr->sa_family == AF_INET6, "Addr not IPv6.");
+ * parcAssertTrue(addr && addr->sa_family == AF_INET6, "Addr not IPv6.");
* struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *) addr;
* // ...
* parcMemory_Deallocate((void **)&addr);
*
* addr = parcNetwork_SockAddress("alpha.parc.com", 555);
- * assertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 hostname with only ipv4 address.");
+ * parcAssertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 hostname with only ipv4 address.");
* // ...
* parcMemory_Deallocate((void **)&addr);
*
* addr = parcNetwork_SockAddress("Over the rainbow, way up high", 555);
- * assertNull(addr, "Addr no null for bogus name.");
+ * parcAssertNull(addr, "Addr no null for bogus name.");
*
* }
* @endcode
* @code
* {
* struct sockaddr *s = parcNetwork_SockAddress("127.1.1.1", 5900);
- * assertTrue(parcNetwork_IsSocketLocal(s), "This will not assert");
+ * parcAssertTrue(parcNetwork_IsSocketLocal(s), "This will not assert");
* parcMemory_Deallocate((void **)&s);
* }
* @endcode
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <inttypes.h>
"Object@%p { .references=%" PRId64 ", .objectLength = %zd, .objectAlignment=%u } data %p\n",
(void *) header,
header->references, header->descriptor->objectSize, header->descriptor->objectAlignment, object);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
char *result = parcMemory_StringDuplicate(string, strlen(string));
free(string);
return result;
char *addressString;
int nwritten = asprintf(&addressString, "%p", object);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
parcJSON_AddString(json, "address", addressString);
static inline void
_parcObjectHeader_AssertValid(const _PARCObjectHeader *header, const PARCObject *object)
{
- trapIllegalValueIf(header->magicGuardNumber != PARCObject_HEADER_MAGIC_GUARD_NUMBER, "PARCObject@%p is corrupt.", object);
- trapIllegalValueIf(header->descriptor == NULL, "PARCObject@%p descriptor cannot be NULL.", object);
+ parcTrapIllegalValueIf(header->magicGuardNumber != PARCObject_HEADER_MAGIC_GUARD_NUMBER, "PARCObject@%p is corrupt.", object);
+ parcTrapIllegalValueIf(header->descriptor == NULL, "PARCObject@%p descriptor cannot be NULL.", object);
if (header->descriptor->isLockable) {
- trapIllegalValueIf(header->locking == NULL, "PARCObject@%p is corrupt. Is Lockable but no locking structure", object);
+ parcTrapIllegalValueIf(header->locking == NULL, "PARCObject@%p is corrupt. Is Lockable but no locking structure", object);
}
}
static inline void
_parcObject_AssertValid(const PARCObject *object)
{
- trapIllegalValueIf(object == NULL, "PARCObject must be a non-null pointer.");
+ parcTrapIllegalValueIf(object == NULL, "PARCObject must be a non-null pointer.");
_PARCObjectHeader *header = _parcObject_Header(object);
_parcObjectHeader_AssertValid(header, object);
_PARCObjectHeader *header = _parcObject_Header(object);
- trapIllegalValueIf(header->references == 0, "PARCObject@%p references must be > 0", object);
+ parcTrapIllegalValueIf(header->references == 0, "PARCObject@%p references must be > 0", object);
PARCReferenceCount result = parcAtomicUint64_Decrement(&header->references);
void *origin = _parcObject_Origin(object);
parcMemory_Deallocate(&origin);
}
- assertNotNull(*objectPointer, "Class implementation unnecessarily clears the object pointer.");
+ parcAssertNotNull(*objectPointer, "Class implementation unnecessarily clears the object pointer.");
} else {
- assertNull(*objectPointer, "Class implementation must clear the object pointer.");
+ parcAssertNull(*objectPointer, "Class implementation must clear the object pointer.");
}
}
parcObject_SetDescriptor(PARCObject *object, const PARCObjectDescriptor *descriptor)
{
parcObject_OptionalAssertValid(object);
- assertNotNull(descriptor, "PARCObjectDescriptor cannot be NULL.");
+ parcAssertNotNull(descriptor, "PARCObjectDescriptor cannot be NULL.");
_PARCObjectHeader *header = _parcObject_Header(object);
const PARCObjectDescriptor *superType,
PARCObjectTypeState *typeState)
{
- assertNotNull(superType, "Supertype descriptor cannot be NULL.");
+ parcAssertNotNull(superType, "Supertype descriptor cannot be NULL.");
PARCObjectDescriptor *result = parcMemory_AllocateAndClear(sizeof(PARCObjectDescriptor));
if (result != NULL) {
locking->locker = (pthread_t) NULL;
result = (pthread_mutex_unlock(&locking->lock) == 0);
- assertTrue(result, "Attempted to unlock an unowned lock.");
+ parcAssertTrue(result, "Attempted to unlock an unowned lock.");
}
}
}
if (object != NULL) {
_PARCObjectLocking *locking = _parcObjectHeader_Locking(object);
if (locking != NULL) {
- trapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()),
+ parcTrapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()),
"Recursive locks on %p are not supported.", object);
errno = pthread_mutex_lock(&locking->lock);
_PARCObjectLocking *locking = _parcObjectHeader_Locking(object);
if (locking != NULL) {
- trapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), "Recursive locks are not supported.");
+ parcTrapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), "Recursive locks are not supported.");
int lockStatus = pthread_mutex_trylock(&locking->lock);
#include <stdint.h>
#include <time.h>
-#include <LongBow/runtime.h>
-#include <LongBow/longBow_Compiler.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_CMacro.h>
//#include <parc/algol/parc_JSON.h>
* Create new `PARCObjectDescriptor` based on an existing `PARCObjectDescriptor.`
* The new `PARCObjectDescriptor` uses the existing `PARCObjectDescriptor` as the super-type of the new descriptor.
*/
+
#define parcObject_Extends(_subtype, _superType, ...) \
- LongBowCompiler_IgnoreInitializerOverrides \
+ _Pragma("GCC diagnostic ignored \"-Woverride-init\"") \
parcObjectDescriptor_Declaration(_subtype) = { \
.super = &parcObject_DescriptorName(_superType), \
.name = #_subtype, \
.typeState = NULL, \
__VA_ARGS__ \
}; \
- LongBowCompiler_WarnInitializerOverrides \
+ _Pragma("GCC diagnostic warning \"-Woverride-init\"") \
const PARCObjectDescriptor parcObject_DescriptorName(_subtype)
/**
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_SortedList.h>
parcSortedList_Create(parcSortedList_Compare compareFunction)
{
PARCSortedList *sortedList = parcMemory_Allocate(sizeof(PARCSortedList));
- assertNotNull(sortedList, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCSortedList));
+ parcAssertNotNull(sortedList, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCSortedList));
sortedList->arrayList = parcArrayList_Create(NULL);
sortedList->compare = compareFunction;
return sortedList;
void
parcSortedList_Add(PARCSortedList *parcSortedList, void *newItem)
{
- assertNotNull(parcSortedList, "sortedList parameter can't be null");
- assertNotNull(parcSortedList->arrayList, "arrayList can't be null");
- assertNotNull(newItem, "newItem can't be null");
+ parcAssertNotNull(parcSortedList, "sortedList parameter can't be null");
+ parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null");
+ parcAssertNotNull(newItem, "newItem can't be null");
size_t total_items = parcArrayList_Size(parcSortedList->arrayList);
for (size_t i = 0; i < total_items; i++) {
void *
parcSortedList_PopFirst(PARCSortedList *parcSortedList)
{
- assertNotNull(parcSortedList, "sortedList parameter can't be null");
- assertNotNull(parcSortedList->arrayList, "arrayList can't be null");
+ parcAssertNotNull(parcSortedList, "sortedList parameter can't be null");
+ parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null");
if (parcArrayList_Size(parcSortedList->arrayList) == 0) {
return NULL;
void *
parcSortedList_GetFirst(PARCSortedList *parcSortedList)
{
- assertNotNull(parcSortedList, "sortedList parameter can't be null");
- assertNotNull(parcSortedList->arrayList, "arrayList can't be null");
+ parcAssertNotNull(parcSortedList, "sortedList parameter can't be null");
+ parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null");
if (parcArrayList_Size(parcSortedList->arrayList) == 0) {
return NULL;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <stdbool.h>
void
parcPriorityQueue_ParcFreeDestroyer(void **elementPtr)
{
- assertNotNull(elementPtr, "Double pointer must be non-null");
- assertNotNull(*elementPtr, "Double pointer must dereference to non-null");
+ parcAssertNotNull(elementPtr, "Double pointer must be non-null");
+ parcAssertNotNull(*elementPtr, "Double pointer must dereference to non-null");
void *element = *elementPtr;
parcMemory_Deallocate((void **) &element);
*elementPtr = NULL;
PARCPriorityQueue *
parcPriorityQueue_Create(PARCPriorityQueueCompareTo *compare, PARCPriorityQueueDestroyer *destroyer)
{
- assertNotNull(compare, "Parameter compare must be non-null");
+ parcAssertNotNull(compare, "Parameter compare must be non-null");
size_t initialSize = 128;
PARCPriorityQueue *queue = parcMemory_AllocateAndClear(sizeof(PARCPriorityQueue));
- assertNotNull(queue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCPriorityQueue));
+ parcAssertNotNull(queue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCPriorityQueue));
queue->array = parcMemory_AllocateAndClear(sizeof(HeapEntry) * initialSize);
- assertNotNull(queue->array, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(HeapEntry) * initialSize);
+ parcAssertNotNull(queue->array, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(HeapEntry) * initialSize);
queue->capacity = initialSize;
queue->size = 0;
queue->compare = compare;
void
parcPriorityQueue_Destroy(PARCPriorityQueue **queuePtr)
{
- assertNotNull(queuePtr, "Double pointer must be non-null");
- assertNotNull(*queuePtr, "Double pointer must dereference to non-null");
+ parcAssertNotNull(queuePtr, "Double pointer must be non-null");
+ parcAssertNotNull(*queuePtr, "Double pointer must dereference to non-null");
PARCPriorityQueue *queue = *queuePtr;
parcPriorityQueue_Clear(queue);
parcMemory_Deallocate((void **) &(queue->array));
bool
parcPriorityQueue_Add(PARCPriorityQueue *queue, void *data)
{
- assertNotNull(queue, "Parameter queue must be non-null");
- assertNotNull(data, "Parameter data must be non-null");
+ parcAssertNotNull(queue, "Parameter queue must be non-null");
+ parcAssertNotNull(data, "Parameter data must be non-null");
if (queue->size + 1 > queue->capacity) {
_expand(queue);
void
parcPriorityQueue_Clear(PARCPriorityQueue *queue)
{
- assertNotNull(queue, "Parameter queue must be non-null");
+ parcAssertNotNull(queue, "Parameter queue must be non-null");
if (queue->destroyer != NULL) {
for (size_t i = 0; i < queue->size; i++) {
queue->destroyer(&queue->array[i].data);
void *
parcPriorityQueue_Peek(PARCPriorityQueue *queue)
{
- assertNotNull(queue, "Parameter queue must be non-null");
+ parcAssertNotNull(queue, "Parameter queue must be non-null");
if (queue->size > 0) {
return queue->array[0].data;
}
void *
parcPriorityQueue_Poll(PARCPriorityQueue *queue)
{
- assertNotNull(queue, "Parameter queue must be non-null");
+ parcAssertNotNull(queue, "Parameter queue must be non-null");
if (queue->size > 0) {
void *data = queue->array[0].data;
size_t
parcPriorityQueue_Size(const PARCPriorityQueue *queue)
{
- assertNotNull(queue, "Parameter queue must be non-null");
+ parcAssertNotNull(queue, "Parameter queue must be non-null");
return queue->size;
}
#include <config.h>
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
static void
_parcProperties_Finalize(PARCProperties **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCProperties pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCProperties pointer.");
PARCProperties *instance = *instancePtr;
parcProperties_OptionalAssertValid(instance);
void
parcProperties_AssertValid(const PARCProperties *instance)
{
- assertTrue(parcProperties_IsValid(instance),
+ parcAssertTrue(parcProperties_IsValid(instance),
"PARCProperties is not valid.");
}
parcProperties_Display(const PARCProperties *properties, int indentation)
{
parcDisplayIndented_PrintLine(indentation, "PARCProperties@%p {", properties);
- trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
+ parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties);
while (parcIterator_HasNext(iterator)) {
{
PARCJSON *result = parcJSON_Create();
- trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
+ parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties);
while (parcIterator_HasNext(iterator)) {
PARCBufferComposer *
parcProperties_BuildString(const PARCProperties *properties, PARCBufferComposer *composer)
{
- trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
+ parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object.");
PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties);
while (parcIterator_HasNext(iterator)) {
static void
_parcRandomAccessFile_Finalize(PARCRandomAccessFile **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCRandomAccessFile pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCRandomAccessFile pointer.");
PARCRandomAccessFile *instance = *instancePtr;
if (instance->fhandle != NULL) {
fclose(instance->fhandle);
void
parcRandomAccessFile_AssertValid(const PARCRandomAccessFile *instance)
{
- assertTrue(parcRandomAccessFile_IsValid(instance),
+ parcAssertTrue(parcRandomAccessFile_IsValid(instance),
"PARCRandomAccessFile is not valid.");
}
bool
parcRandomAccessFile_Close(PARCRandomAccessFile *fileHandle)
{
- assertNotNull(fileHandle->fhandle, "Can't fclose a null pointer. How did they get one anyway?");
+ parcAssertNotNull(fileHandle->fhandle, "Can't fclose a null pointer. How did they get one anyway?");
bool result = fclose(fileHandle->fhandle) == 0;
fileHandle->fhandle = NULL;
parcMemory_Deallocate(&fileHandle->fname);
result = fseek(fileHandle->fhandle, offset, SEEK_END); // end of the file
break;
default:
- assertTrue(false, "Invalid position %d", position);
+ parcAssertTrue(false, "Invalid position %d", position);
}
return result;
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#if defined(_WIN64)
# define backtrace(...) (0)
(void *) safeMemory,
(void *) prefix,
_parcSafeMemory_StateToString(_parcSafeMemory_GetState(safeMemory)));
- trapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd);
+ parcTrapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd);
}
_backtraceReport(prefix->backtrace, outputFd);
}
int charactersPrinted = dprintf(outputFd,
"\n%u SafeMemory@%p: %p={ .requestedLength=%zd, .actualLength=%zd, .alignment=%zd }\n",
index, e->memory, (void *) prefix, prefix->requestedLength, prefix->actualLength, prefix->alignment);
- trapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd)
+ parcTrapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd)
{
pthread_mutex_unlock(&head_mutex);
}
PARCSafeMemoryUsable *memory = *memoryPointer;
PARCSafeMemoryState state = _parcSafeMemory_GetState(memory);
- trapUnexpectedStateIf(state != PARCSafeMemoryState_OK,
+ parcTrapUnexpectedStateIf(state != PARCSafeMemoryState_OK,
"Expected PARCSafeMemoryState_OK, actual %s (see parc_SafeMemory.h)",
_parcSafeMemory_StateToString(state))
{
PARCSafeMemoryUsable *result = _pointerAdd(origin, prefixSize);
- assertAligned(result, alignment, "Return value is not properly aligned to %zu", alignment);
+ parcAssertAligned(result, alignment, "Return value is not properly aligned to %zu", alignment);
return result;
}
* size_t newLength = 0;
* unsigned char *newMemory = parcSafeMemory_Reallocate(memory, newLength);
*
- * assertTrue(newMemory == NULL, "Expected NULL, actual %p", newMemory);
+ * parcAssertTrue(newMemory == NULL, "Expected NULL, actual %p", newMemory);
* }
* @endcode
*/
static void
_parcSortedList_Finalize(PARCSortedList **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSortedList pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSortedList pointer.");
PARCSortedList *instance = *instancePtr;
parcSortedList_OptionalAssertValid(instance);
void
parcSortedList_AssertValid(const PARCSortedList *instance)
{
- assertTrue(parcSortedList_IsValid(instance),
+ parcAssertTrue(parcSortedList_IsValid(instance),
"PARCSortedList is not valid.");
}
parcSortedList_Add(PARCSortedList *instance, PARCObject *element)
{
size_t insertionPoint = _parcSortedList_GetInsertionIndex(instance, element);
- assertTrue(insertionPoint >= 0 && insertionPoint <= parcLinkedList_Size(instance->list),
+ parcAssertTrue(insertionPoint >= 0 && insertionPoint <= parcLinkedList_Size(instance->list),
"%zd is bad insertion point. Must be >=0 and <= %zd", insertionPoint, parcLinkedList_Size(instance->list));
parcLinkedList_InsertAtIndex(instance->list, insertionPoint, element);
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Deque.h>
parcStack(void *instance, PARCStackInterface *interface)
{
PARCStack *result = parcMemory_AllocateAndClear(sizeof(PARCStack));
- assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCStack));
+ parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCStack));
result->instance = instance;
result->interface = interface;
#include <strings.h>
#include <pthread.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_StdlibMemory.h>
parcStdlibMemory_Deallocate(void **pointer)
{
#ifndef PARCLibrary_DISABLE_VALIDATION
- trapIllegalValueIf(_parcStdlibMemory_OutstandingAllocations == 0,
+ parcTrapIllegalValueIf(_parcStdlibMemory_OutstandingAllocations == 0,
"parcStdlibMemory_Deallocate invoked with nothing left to free (double free somewhere?)\n");
#endif
free(*pointer);
static bool
_parcString_Destructor(PARCString **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCString pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCString pointer.");
PARCString *string = *instancePtr;
parcMemory_Deallocate(&string->string);
void
parcString_AssertValid(const PARCString *instance)
{
- assertTrue(parcString_IsValid(instance),
+ parcAssertTrue(parcString_IsValid(instance),
"PARCString is not valid.");
}
#include <time.h>
#include <sys/time.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Time.h>
#include <parc/algol/parc_Memory.h>
{
char *string;
int nwritten = asprintf(&string, "%ld.%06ld", timeval.tv_sec, (long) timeval.tv_usec);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
char *result = parcMemory_StringDuplicate(string, strlen(string));
free(string);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
_rbNodeCreate(PARCTreeMap *tree, int color)
{
_RBNode *node = parcMemory_AllocateAndClear(sizeof(_RBNode));
- assertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(_RBNode));
+ parcAssertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(_RBNode));
node->color = color;
node->leftChild = tree->nil;
node->rightChild = tree->nil;
_rbNodeAssertNodeInvariants(_RBNode *node, PARCObject *data)
{
PARCTreeMap *tree = (PARCTreeMap *) data;
- assertNotNull(node->parent, "Node has NULL parent");
- assertNotNull(node->leftChild, "Left child NULL");
- assertNotNull(node->rightChild, "Richt child NULL");
+ parcAssertNotNull(node->parent, "Node has NULL parent");
+ parcAssertNotNull(node->leftChild, "Left child NULL");
+ parcAssertNotNull(node->rightChild, "Richt child NULL");
if (node != tree->root) {
- assertTrue(node->parent != tree->nil, "Paren't can't be nill for node!");
+ parcAssertTrue(node->parent != tree->nil, "Paren't can't be nill for node!");
// Don't need to compare to parent, they compared to us
}
- assertNotNull(node->element, "We have a null element!!");
- assertNotNull(parcKeyValue_GetKey(node->element), "We have a null key!!");
- assertNotNull(parcKeyValue_GetValue(node->element), "We have a null value!!");
+ parcAssertNotNull(node->element, "We have a null element!!");
+ parcAssertNotNull(parcKeyValue_GetKey(node->element), "We have a null key!!");
+ parcAssertNotNull(parcKeyValue_GetValue(node->element), "We have a null value!!");
if (node->leftChild != tree->nil) {
if (tree->customCompare != NULL) {
- assertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?");
+ parcAssertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?");
} else {
- assertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?");
+ parcAssertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?");
}
}
if (node->rightChild != tree->nil) {
if (tree->customCompare != NULL) {
- assertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?");
+ parcAssertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?");
} else {
- assertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?");
+ parcAssertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?");
}
}
}
void
_rbNodeAssertTreeInvariants(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree is null!");
- assertTrue(tree->size >= 0, "Tree has negative size");
+ parcAssertNotNull(tree, "Tree is null!");
+ parcAssertTrue(tree->size >= 0, "Tree has negative size");
if (tree->size != 0) {
- assertTrue(tree->root != tree->nil, "Tree size = %d > 0 but root is nil", tree->size);
- assertNotNull(tree->root, "Tree size > 0 but root is NULL");
+ parcAssertTrue(tree->root != tree->nil, "Tree size = %d > 0 but root is nil", tree->size);
+ parcAssertNotNull(tree->root, "Tree size > 0 but root is NULL");
#ifdef ASSERT_INVARIANTS
_rbNodeRecursiveRun((PARCTreeMap *) tree, tree->root, _rbNodeAssertNodeInvariants, (PARCObject *) tree);
#endif
static void
_parcTreeMap_Destroy(PARCTreeMap **treePointer)
{
- assertNotNull(treePointer, "pointer to pointer to tree can't be null");
- assertNotNull(*treePointer, "pointer to tree can't be null");
+ parcAssertNotNull(treePointer, "pointer to pointer to tree can't be null");
+ parcAssertNotNull(*treePointer, "pointer to tree can't be null");
_rbNodeAssertTreeInvariants(*treePointer);
if ((*treePointer)->size > 0) {
parcTreeMap_CreateCustom(PARCTreeMap_CustomCompare *customCompare)
{
PARCTreeMap *tree = parcObject_CreateInstance(PARCTreeMap);
- assertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeMap));
+ parcAssertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeMap));
tree->nil = _rbNodeCreate(tree, BLACK);
tree->nil->leftChild = tree->nil;
tree->nil->rightChild = tree->nil;
void
parcTreeMap_Put(PARCTreeMap *tree, const PARCObject *key, const PARCObject *value)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
- assertNotNull(value, "Value can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(value, "Value can't be NULL");
_RBNode *newNode = _rbNodeCreate(tree, RED);
_RBNode *parent = tree->nil;
PARCObject *
parcTreeMap_Get(PARCTreeMap *tree, const PARCObject *key)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
PARCObject *result = NULL;
PARCObject *
parcTreeMap_Remove(PARCTreeMap *tree, const PARCObject *key)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
_rbNodeAssertTreeInvariants(tree);
PARCObject *result = NULL;
void
parcTreeMap_RemoveAndRelease(PARCTreeMap *tree, const PARCObject *key)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
_RBNode *node = _rbFindNode(tree, tree->root, key);
PARCKeyValue *
parcTreeMap_GetLastEntry(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
_RBNode *node = tree->root;
PARCKeyValue *
parcTreeMap_GetFirstEntry(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
if (tree->size == 0) {
size_t
parcTreeMap_Size(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
return tree->size;
PARCList *
parcTreeMap_AcquireKeys(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
PARCList *keys = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals,
PARCList *
parcTreeMap_AcquireValues(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
PARCList *values = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals,
static PARCList *
_parcTreeMap_Elements(const PARCTreeMap *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
_rbNodeAssertTreeInvariants(tree);
PARCList *elements = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals,
{
_rbNodeAssertTreeInvariants(tree1);
_rbNodeAssertTreeInvariants(tree2);
- assertNotNull(tree1, "Tree can't be NULL");
- assertNotNull(tree2, "Tree can't be NULL");
+ parcAssertNotNull(tree1, "Tree can't be NULL");
+ parcAssertNotNull(tree2, "Tree can't be NULL");
bool result = false;
parcTreeMap_Copy(const PARCTreeMap *sourceTree)
{
_rbNodeAssertTreeInvariants(sourceTree);
- assertNotNull(sourceTree, "Tree can't be NULL");
+ parcAssertNotNull(sourceTree, "Tree can't be NULL");
PARCObject *keySource;
PARCObject *keyCopy;
state->list = _parcTreeMap_Elements(map);
state->currentIndex = 0;
state->currentElement = parcList_GetAtIndex(state->list, 0);
- trapOutOfMemoryIf(state->list == NULL, "Cannot create parcList");
+ parcTrapOutOfMemoryIf(state->list == NULL, "Cannot create parcList");
}
return state;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
_rbNodeCreate(PARCTreeRedBlack *tree, int color)
{
Node *node = parcMemory_AllocateAndClear(sizeof(Node));
- assertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(Node));
+ parcAssertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(Node));
node->color = color;
node->left_child = tree->nil;
node->right_child = tree->nil;
PARCTreeRedBlack_ValueFree *valueFree,
PARCTreeRedBlack_ValueCopy *valueCopy)
{
- assertNotNull(keyCompare, "We need a key compare function");
+ parcAssertNotNull(keyCompare, "We need a key compare function");
PARCTreeRedBlack *tree = parcMemory_AllocateAndClear(sizeof(PARCTreeRedBlack));
- assertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeRedBlack));
+ parcAssertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeRedBlack));
tree->nil = _rbNodeCreate(tree, BLACK);
tree->nil->left_child = tree->nil;
tree->nil->right_child = tree->nil;
void
parcTreeRedBlack_Destroy(PARCTreeRedBlack **treePointer)
{
- assertNotNull(treePointer, "pointer to pointer to tree can't be null");
- assertNotNull(*treePointer, "pointer to tree can't be null");
+ parcAssertNotNull(treePointer, "pointer to pointer to tree can't be null");
+ parcAssertNotNull(*treePointer, "pointer to tree can't be null");
if ((*treePointer)->size > 0) {
// If we have any elements in the tree, free them
void
parcTreeRedBlack_Insert(PARCTreeRedBlack *tree, void *key, void *value)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
- assertNotNull(value, "Value can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(value, "Value can't be NULL");
Node *newNode = _rbNodeCreate(tree, RED);
Node *parent = tree->nil;
void *
parcTreeRedBlack_Get(PARCTreeRedBlack *tree, const void *key)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
Node *node = tree->root;
void *
parcTreeRedBlack_Remove(PARCTreeRedBlack *tree, const void *key)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
Node *node = tree->root;
void
parcTreeRedBlack_RemoveAndDestroy(PARCTreeRedBlack *tree, const void *key)
{
- assertNotNull(tree, "Tree can't be NULL");
- assertNotNull(key, "Key can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(key, "Key can't be NULL");
Node *node = tree->root;
// Let's get to the bottom of the tree to insert.
void *
parcTreeRedBlack_LastKey(const PARCTreeRedBlack *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
Node *node = tree->root;
if (tree->size == 0) {
void *
parcTreeRedBlack_FirstKey(const PARCTreeRedBlack *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
Node *node = tree->root;
size_t
parcTreeRedBlack_Size(const PARCTreeRedBlack *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
return tree->size;
}
PARCArrayList *
parcTreeRedBlack_Keys(const PARCTreeRedBlack *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
PARCArrayList *keys = parcArrayList_Create(NULL);
PARCArrayList *
parcTreeRedBlack_Values(const PARCTreeRedBlack *tree)
{
- assertNotNull(tree, "Tree can't be NULL");
+ parcAssertNotNull(tree, "Tree can't be NULL");
PARCArrayList *values = parcArrayList_Create(NULL);
int
parcTreeRedBlack_Equals(const PARCTreeRedBlack *tree1, const PARCTreeRedBlack *tree2)
{
- assertNotNull(tree1, "Tree can't be NULL");
- assertNotNull(tree2, "Tree can't be NULL");
+ parcAssertNotNull(tree1, "Tree can't be NULL");
+ parcAssertNotNull(tree2, "Tree can't be NULL");
int ret = 1;
PARCTreeRedBlack *
parcTreeRedBlack_Copy(const PARCTreeRedBlack *source_tree)
{
- assertNotNull(source_tree, "Tree can't be NULL");
+ parcAssertNotNull(source_tree, "Tree can't be NULL");
void *key_source;
void *key_copy;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <unistd.h>
#include <stdio.h>
static void
_parcURI_Finalize(PARCURI **uriPtr)
{
- assertNotNull(uriPtr, "Parameter must be a non-null pointer to a pointer to a PARCURI instance.");
+ parcAssertNotNull(uriPtr, "Parameter must be a non-null pointer to a pointer to a PARCURI instance.");
PARCURI *uri = *uriPtr;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <unistd.h>
#include <stdio.h>
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <unistd.h>
#include <stdio.h>
static void
_parcURIPath_Finalize(PARCURIPath **pathPtr)
{
- assertNotNull(pathPtr, "Parameter must be a non-null pointer to a pointer to a PARCURIPath instance.");
+ parcAssertNotNull(pathPtr, "Parameter must be a non-null pointer to a pointer to a PARCURIPath instance.");
PARCURIPath *path = *pathPtr;
if (path != NULL) {
//
// result->segments = parcArrayList_Create((void (*)(void **))parcURISegment_Release);
// if (*string != 0) {
-// assertTrue(*string == '/', "Expected initial '/' character.");
+// parcAssertTrue(*string == '/', "Expected initial '/' character.");
// *pointer = string;
// while (**pointer != 0 && **pointer != '?' && **pointer != '#') {
// PARCURISegment *segment = parcURISegment_Parse(++(*pointer), pointer);
PARCURIPath *
parcURIPath_Copy(const PARCURIPath *path)
{
- assertNotNull(path, "Parameter must be a non-null PARC_URIPath pointer.");
+ parcAssertNotNull(path, "Parameter must be a non-null PARC_URIPath pointer.");
PARCURIPath *result = parcURIPath_Create();
result->segments = parcArrayList_Create((void (*)(void **))parcURISegment_Release);
* Retrieve the URI path segment at the specified index.
*
* The index must be within the range [0, number of segments]
- * prior to invocation. Otherwise, the program is terminated with LongBow trapOutOfBounds.
+ * prior to invocation. Otherwise, the program is terminated with parcTrapOutOfBounds.
*
* @param [in] path A `PARCURIPath` instance to be examined.
* @param [in] index The index of the URI segment to retrieve.
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <unistd.h>
#include <stdio.h>
static PARCBufferComposer *
_parcURISegment_BuildString(const PARCURISegment *segment, PARCBufferComposer *composer)
{
- assertNotNull(composer, "Parameter must be a non-null pointer to a PARCBufferComposer.");
+ parcAssertNotNull(composer, "Parameter must be a non-null pointer to a PARCBufferComposer.");
for (size_t i = 0; i < parcBuffer_Limit(segment->buffer) && composer != NULL; i++) {
unsigned char c = parcBuffer_GetAtIndex(segment->buffer, i);
PARCURISegment *
parcURISegment_Parse(const char *string, const char **pointer)
{
- assertFalse(*string == '/', "Input parameter '%s' must NOT point to an initial '/' character.", string);
+ parcAssertFalse(*string == '/', "Input parameter '%s' must NOT point to an initial '/' character.", string);
unsigned char *segment = parcMemory_AllocateAndClear((strlen(string) + 1) * sizeof(unsigned char));
- assertNotNull(segment, "parcMemory_AllocateAndClear(%zu) returned NULL", (strlen(string) + 1) * sizeof(unsigned char));
+ parcAssertNotNull(segment, "parcMemory_AllocateAndClear(%zu) returned NULL", (strlen(string) + 1) * sizeof(unsigned char));
size_t length = 0;
unsigned char *r = segment;
PARCURISegment *
parcURISegment_Clone(const PARCURISegment *segment)
{
- assertNotNull(segment, "Parameter must be a non-null PARC_URISegment pointer.");
+ parcAssertNotNull(segment, "Parameter must be a non-null PARC_URISegment pointer.");
PARCBuffer *copy = parcBuffer_Copy(segment->buffer);
PARCURISegment *result = parcURISegment_CreateFromBuffer(copy);
void
parcUnsigned_AssertValid(const PARCUnsigned *instance)
{
- assertTrue(parcUnsigned_IsValid(instance),
+ parcAssertTrue(parcUnsigned_IsValid(instance),
"PARCUnsigned is not valid.");
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <stdlib.h>
PARCVarint *
parcVarint_DecodeBuffer(PARCBuffer *buffer, size_t length)
{
- assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
- assertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t));
- assertTrue(length <= parcBuffer_Remaining(buffer), "Buffer does not contain at least %zd bytes", length);
+ parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
+ parcAssertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t));
+ parcAssertTrue(length <= parcBuffer_Remaining(buffer), "Buffer does not contain at least %zd bytes", length);
PARCVarint *result = parcVarint_Create();
- assertNotNull(result, "PARCVarint out of memory.");
+ parcAssertNotNull(result, "PARCVarint out of memory.");
for (size_t i = 0; i < length; i++) {
parcVarint_ShiftLeft(result, 8);
PARCVarint *
parcVarint_DecodeElasticByteBuffer(const PARCBuffer *buffer, size_t length)
{
- assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
- assertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t));
+ parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
+ parcAssertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t));
PARCVarint *result = parcVarint_Create();
- assertNotNull(result, "PARCVarint out of memory.");
+ parcAssertNotNull(result, "PARCVarint out of memory.");
for (size_t i = 0; i < length; i++) {
parcVarint_ShiftLeft(result, 8);
PARCVarint *
parcVarint_FromElasticByteBuffer(const PARCBuffer *buffer)
{
- assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
+ parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
PARCVarint *result = parcVarint_Create();
size_t length = parcBuffer_Remaining(buffer);
PARCVarint *
parcVarint_FromUTF8ByteBuffer(const PARCBuffer *buffer)
{
- assertNotNull(buffer, "Parameter must not be NULL.");
+ parcAssertNotNull(buffer, "Parameter must not be NULL.");
PARCVarint *result = parcVarint_Create();
if (result != NULL) {
PARCVarint *
parcVarint_FromUTF8Buffer(PARCBuffer *buffer)
{
- assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
+ parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer.");
PARCVarint *result = parcVarint_Create();
if (result != NULL) {
void
parcVarint_Destroy(PARCVarint **varintP)
{
- assertNotNull(varintP, "Parameter must be a non-null pointer to a pointer to a PARCVarint");
- assertNotNull(*varintP, "Parameter must be a non-null pointer to a PARCVarint");
+ parcAssertNotNull(varintP, "Parameter must be a non-null pointer to a pointer to a PARCVarint");
+ parcAssertNotNull(*varintP, "Parameter must be a non-null pointer to a PARCVarint");
parcMemory_Deallocate((void **) varintP);
*varintP = NULL;
PARCVarint *
parcVarint_ShiftLeft(PARCVarint *varint, int bits)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value <<= bits;
return varint;
PARCVarint *
parcVarint_Add(PARCVarint *varint, int addend)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value += addend;
return varint;
PARCVarint *
parcVarint_Subtract(PARCVarint *varint, int subtrahend)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value -= subtrahend;
return varint;
PARCVarint *
parcVarint_Multiply(PARCVarint *varint, int multiplicand)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value *= multiplicand;
return varint;
PARCVarint *
parcVarint_Divide(PARCVarint *varint, int divisor)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value /= divisor;
return varint;
PARCVarint *
parcVarint_ShiftRight(PARCVarint *varint, int bits)
{
- assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
+ parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint.");
varint->value >>= bits;
return varint;
}
PARCVarint *
parcVarint_And(PARCVarint *varint, PARCVarint *operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
- assertNotNull(operand, "Parameter operand must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(operand, "Parameter operand must not be NULL.");
varint->value &= operand->value;
return varint;
}
PARCVarint *
parcVarint_AndUint8(PARCVarint *varint, uint8_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value &= operand;
return varint;
}
PARCVarint *
parcVarint_AndUint16(PARCVarint *varint, uint16_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value &= operand;
return varint;
}
PARCVarint *
parcVarint_AndUint32(PARCVarint *varint, uint32_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value &= operand;
return varint;
}
PARCVarint *
parcVarint_AndUint64(PARCVarint *varint, uint64_t operand)
{
- assertNotNull(varint, "Parameter must be a non-null PARCVarint pointer.");
+ parcAssertNotNull(varint, "Parameter must be a non-null PARCVarint pointer.");
varint->value &= operand;
return varint;
}
PARCVarint *
parcVarint_Or(PARCVarint *varint, PARCVarint *operand)
{
- assertNotNull(varint, "Parameter must be a non-null PARCVarint pointer.");
+ parcAssertNotNull(varint, "Parameter must be a non-null PARCVarint pointer.");
varint->value |= operand->value;
return varint;
}
PARCVarint *
parcVarint_OrUint8(PARCVarint *varint, uint8_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value |= operand;
return varint;
}
PARCVarint *
parcVarint_OrUint16(PARCVarint *varint, uint16_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value |= operand;
return varint;
}
PARCVarint *
parcVarint_OrUint32(PARCVarint *varint, uint32_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value |= operand;
return varint;
}
PARCVarint *
parcVarint_OrUint64(PARCVarint *varint, uint64_t operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
varint->value |= operand;
return varint;
}
int
parcVarint_Equals(PARCVarint *varint, PARCVarint *operand)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return varint->value == operand->value;
}
int
parcVarint_EqualsUint64(PARCVarint *varint, uint64_t value)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return varint->value == value;
}
int
parcVarint_EqualsUint32(PARCVarint *varint, uint32_t value)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return parcVarint_EqualsUint64(varint, (uint64_t) value);
}
int
parcVarint_EqualsUint16(PARCVarint *varint, uint16_t value)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return parcVarint_EqualsUint64(varint, (uint64_t) value);
}
int
parcVarint_EqualsUint8(PARCVarint *varint, uint8_t value)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return parcVarint_EqualsUint64(varint, (uint64_t) value);
}
uint8_t
parcVarint_AsUint8(const PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return (uint8_t) varint->value;
}
uint16_t
parcVarint_AsUint16(const PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return (uint16_t) varint->value;
}
uint32_t
parcVarint_AsUint32(const PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return (uint32_t) varint->value;
}
uint64_t
parcVarint_AsUint64(const PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return varint->value;
}
size_t
parcVarint_AsSize(const PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
return (size_t) varint->value;
}
char *
parcVarint_ToString(char **string, PARCVarint *varint)
{
- assertNotNull(varint, "Parameter varint must not be NULL.");
+ parcAssertNotNull(varint, "Parameter varint must not be NULL.");
int nwritten = asprintf(string, "%" PRIu64, varint->value);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
return *string;
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <stdio.h>
#include <stdbool.h>
PARCVector *
parcVector_Init(PARCVector *vector, const void *pointer, const size_t length)
{
- assertNotNull(vector, "Parameter must be a non-null PARCVector pointer");
+ parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer");
vector->pointer = pointer;
vector->length = length;
void
parcVector_Destroy(PARCVector **vectorPtr)
{
- assertNotNull(vectorPtr, "Parameter must be a non-null PARCVector pointer");
+ parcAssertNotNull(vectorPtr, "Parameter must be a non-null PARCVector pointer");
PARCVector *vector = *vectorPtr;
- assertNotNull(vector, "Vector is already free or was not set.\n");
+ parcAssertNotNull(vector, "Vector is already free or was not set.\n");
parcMemory_Deallocate((void **) &vector);
*vectorPtr = NULL;
const void *
parcVector_GetPointer(const PARCVector *vector)
{
- assertNotNull(vector, "Parameter must be a non-null PARCVector pointer.");
+ parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer.");
return vector->pointer;
}
size_t
parcVector_GetLength(const PARCVector *vector)
{
- assertNotNull(vector, "Parameter must be a non-null PARCVector pointer.");
+ parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer.");
return vector->length;
}
LONGBOW_TEST_CASE_EXPECTS(Errors, PARC_ArrayList_InsertAtIndex_OutOfCapacity, .event = &LongBowAssertEvent)
{
PARCArrayList *array = longBowTestCase_GetClipBoardData(testCase);
-
+ printf("1\n");
parcArrayList_Add(array, (void *) 1);
+ printf("2\n");
parcArrayList_Add(array, (void *) 2);
+ printf("3\n");
parcArrayList_InsertAtIndex(array, 200, (void *) 3);
+ printf("4\n");
}
int
--- /dev/null
+/*
+ * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Licensed 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <assert.h>
+
+
+#ifdef NDEBUG
+
+#define parcClean_errno() (errno == 0 ? "None" : strerror(errno))
+#define parcLog_PrintError(M, ...) fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\nExit (Failure)\n", __FILE__, __LINE__, parcClean_errno(), ##__VA_ARGS__);
+
+#define parcAssertTrue(A, M, ...) if(!(A)) {assert(A); }
+#define parcAssertFalse(A, M, ...) if((A)) {assert(!(A)); }
+#define parcAssertNotNull(A, M, ...) if(A == NULL) {assert(A != NULL); }
+#define parcAssertNull(A, M, ...) if(A != NULL) {assert(A == NULL); }
+
+#define parcTrapIllegalValueIf(A, M, ...) if((A)) {assert(!(A)); }
+#define parcTrapIllegalValue(A, M, ...) {parcLog_PrintError("Illegal value: " M, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapNotImplemented(M, ...) {parcLog_PrintError("Feature not implemented: " M, ##__VA_ARGS__); assert(0); }
+#define parcTrapOutOfBounds(A, M, ...) {parcLog_PrintError("Element out of bounds, %zu :" M, A, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapOutOfBoundsIf(A, M, ...) {assert(!(A)); }
+#define parcTrapOutOfMemory(M, ...) {parcLog_PrintError("Out of memory. " M, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapOutOfMemoryIf(A, M, ...) {assert(!(A)); }
+#define parcTrapUnexpectedState(M, ...) {parcLog_PrintError("Unexpected state. " M, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapUnexpectedStateIf(A, M, ...) {assert(!(A)); }
+#define parcTrapUnrecoverableState(M, ...) {parcLog_PrintError("Unrecoverable State: " M, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapInvalidValueIf(A, M, ...) {assert(!(A)); }
+#define parcTrapCannotObtainLock(M, ...) {parcLog_PrintError("Cannot obtain lock: " M, ##__VA_ARGS__); assert(0); exit(1);}
+#define parcTrapCannotObtainLockIf(A, M, ...) { assert(!(A)); }
+#define parcAssertAligned(address, alignment, ...) {assert( ((alignment & (~alignment + 1)) == alignment) ? (((uintptr_t) address) % alignment) == 0 ? 1 : 0 : 0);}
+
+#else
+
+#define parcLog_PrintError(M, ...) fprintf(stderr, "[ERROR] " M "\n", ##__VA_ARGS__);
+
+#define parcAssertTrue(A, M, ...) if(!(A)) { parcLog_PrintError(M, ##__VA_ARGS__); assert(A); }
+#define parcAssertFalse(A, M, ...) if((A)) { parcLog_PrintError(M, ##__VA_ARGS__); assert(!(A)); }
+#define parcAssertNotNull(A, M, ...) if(A == NULL) {parcLog_PrintError(M, ##__VA_ARGS__); assert(A != NULL); }
+#define parcAssertNull(A, M, ...) if(A != NULL) {parcLog_PrintError(M, ##__VA_ARGS__); assert(A == NULL); }
+
+#define parcTrapIllegalValueIf(A, M, ...) if((A)) {parcLog_PrintError("Illegal value: " M, ##__VA_ARGS__); }
+#define parcTrapIllegalValue(A, M, ...) parcLog_PrintError("Illegal value: " M, ##__VA_ARGS__); assert(0);
+#define parcTrapNotImplemented(M, ...) parcLog_PrintError("Feature not implemented: " M, ##__VA_ARGS__); assert(0);
+#define parcTrapOutOfBounds(A, M, ...) parcLog_PrintError("Element out of bounds, %zu :" M, A, ##__VA_ARGS__); assert(0);
+#define parcTrapOutOfBoundsIf(A, M, ...) if((A)) {parcLog_PrintError("Out of bounds: " M, ##__VA_ARGS__); }
+#define parcTrapOutOfMemory(M, ...) parcLog_PrintError("Out of memory. " M, ##__VA_ARGS__); assert(0);
+#define parcTrapOutOfMemoryIf(A, M, ...) if((A)) {parcLog_PrintError("Out of memory. " M, ##__VA_ARGS__); }
+#define parcTrapUnexpectedState(M, ...) parcLog_PrintError("Unexpected state. " M, ##__VA_ARGS__); assert(0);
+#define parcTrapUnexpectedStateIf(A, M, ...) if((A)) {parcLog_PrintError("Unexpected state: " M, ##__VA_ARGS__); } if((A))
+#define parcTrapUnrecoverableState(M, ...) parcLog_PrintError("Unrecoverable State: " M, ##__VA_ARGS__); assert(0);
+#define parcTrapInvalidValueIf(A, M, ...) if((A)) {parcLog_PrintError("Invalid value: " M, ##__VA_ARGS__); }
+#define parcTrapCannotObtainLock(M, ...) parcLog_PrintError("Cannot obtain lock: " M, ##__VA_ARGS__); assert(0);
+#define parcTrapCannotObtainLockIf(A, M, ...) if((A)) {parcLog_PrintError("Cannot obtain lock: " M, ##__VA_ARGS__); }
+#define parcAssertAligned(address, alignment, ...) if ((alignment & (~alignment + 1)) == alignment) { if ((((uintptr_t) address) % alignment) != 0)parcLog_PrintError(__VA_ARGS__);} assert((alignment & (~alignment + 1)) == alignment ? (((uintptr_t) address) % alignment) == 0 ? 1 : 0 : 0);
+/*
+
+ ((alignment & (~alignment + 1)) == alignment) ? (((uintptr_t) address) % alignment) == 0 ? 1 : 0 : 0);
+
+bool
+longBowRuntime_TestAddressIsAligned(const void *address, size_t alignment)
+{
+ if ((alignment & (~alignment + 1)) == alignment) {
+ return (((uintptr_t) address) % alignment) == 0 ? true : false;
+ }
+ return false;
+}*/
+#endif
static void
_parcAtomicUint16_Finalize(PARCAtomicUint16 **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint16 pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint16 pointer.");
parcAtomicUint16_OptionalAssertValid((*instancePtr));
void
parcAtomicUint16_AssertValid(const PARCAtomicUint16 *instance)
{
- assertTrue(parcAtomicUint16_IsValid(instance),
+ parcAssertTrue(parcAtomicUint16_IsValid(instance),
"PARCAtomicUint16 is not valid.");
}
static void
_parcAtomicUint32_Finalize(PARCAtomicUint32 **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint32 pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint32 pointer.");
parcAtomicUint32_OptionalAssertValid((*instancePtr));
void
parcAtomicUint32_AssertValid(const PARCAtomicUint32 *instance)
{
- assertTrue(parcAtomicUint32_IsValid(instance),
+ parcAssertTrue(parcAtomicUint32_IsValid(instance),
"PARCAtomicUint32 is not valid.");
}
static void
_parcAtomicUint64_Finalize(PARCAtomicUint64 **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint64 pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint64 pointer.");
parcAtomicUint64_OptionalAssertValid((*instancePtr));
void
parcAtomicUint64_AssertValid(const PARCAtomicUint64 *instance)
{
- assertTrue(parcAtomicUint64_IsValid(instance),
+ parcAssertTrue(parcAtomicUint64_IsValid(instance),
"PARCAtomicUint64 is not valid.");
}
static void
_parcAtomicUint8_Finalize(PARCAtomicUint8 **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint8 pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCAtomicUint8 pointer.");
parcAtomicUint8_OptionalAssertValid((*instancePtr));
void
parcAtomicUint8_AssertValid(const PARCAtomicUint8 *instance)
{
- assertTrue(parcAtomicUint8_IsValid(instance),
+ parcAssertTrue(parcAtomicUint8_IsValid(instance),
"PARCAtomicUint8 is not valid.");
}
static bool
_parcFutureTask_Destructor(PARCFutureTask **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCFutureTask pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCFutureTask pointer.");
PARCFutureTask *task = *instancePtr;
if (parcObject_IsInstanceOf(task->parameter, &PARCObject_Descriptor)) {
void
parcFutureTask_AssertValid(const PARCFutureTask *task)
{
- assertTrue(parcFutureTask_IsValid(task),
+ parcAssertTrue(parcFutureTask_IsValid(task),
"PARCFutureTask is not valid.");
}
}
parcFutureTask_Unlock(task);
} else {
- trapCannotObtainLock("Cannot lock PARCFutureTask");
+ parcTrapCannotObtainLock("Cannot lock PARCFutureTask");
}
return task->result;
}
}
parcFutureTask_Unlock(task);
} else {
- trapCannotObtainLock("Cannot lock PARCFutureTask");
+ parcTrapCannotObtainLock("Cannot lock PARCFutureTask");
}
return result;
static void
_parcLock_Finalize(PARCLock **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCLock pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCLock pointer.");
parcLock_OptionalAssertValid(*instancePtr);
void
parcLock_AssertValid(const PARCLock *instance)
{
- assertTrue(parcLock_IsValid(instance),
+ parcAssertTrue(parcLock_IsValid(instance),
"PARCLock is not valid.");
}
{
parcLock_OptionalAssertValid(lock);
- trapUnexpectedStateIf(lock->locked == false,
+ parcTrapUnexpectedStateIf(lock->locked == false,
"You must Lock the object before calling parcLock_Wait");
lock->notified = false;
{
parcLock_OptionalAssertValid(lock);
- trapUnexpectedStateIf(lock->locked == false,
+ parcTrapUnexpectedStateIf(lock->locked == false,
"You must Lock the object before calling parcLock_Notify");
lock->notified = true;
#include <errno.h>
#include <fcntl.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/concurrent/parc_Notifier.h>
#include <parc/algol/parc_Object.h>
notifier->skippedNotify = false;
int failure = pipe(notifier->fds);
- assertFalse(failure, "Error on pipe: %s", strerror(errno));
+ parcAssertFalse(failure, "Error on pipe: %s", strerror(errno));
if (!_parcNotifier_MakeNonblocking(notifier)) {
parcObject_Release((void **) ¬ifier);
ssize_t written;
do {
written = write(notifier->fds[PARCNotifierWriteFd], &one, 1);
- assertTrue(written >= 0, "Error writing to socket %d: %s", notifier->fds[PARCNotifierWriteFd], strerror(errno));
+ parcAssertTrue(written >= 0, "Error writing to socket %d: %s", notifier->fds[PARCNotifierWriteFd], strerror(errno));
} while (written == 0);
return true;
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/concurrent/parc_RingBuffer.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/concurrent/parc_RingBuffer_1x1.h>
_create(uint32_t elements, RingBufferEntryDestroyer *destroyer)
{
PARCRingBuffer1x1 *ring = parcObject_CreateInstance(PARCRingBuffer1x1);
- assertNotNull(ring, "parcObject_Create returned NULL");
+ parcAssertNotNull(ring, "parcObject_Create returned NULL");
ring->buffer = parcMemory_AllocateAndClear(sizeof(void *) * elements);
- assertNotNull((ring->buffer), "parcMemory_AllocateAndClear() failed to allocate array of %u pointers", elements);
+ parcAssertNotNull((ring->buffer), "parcMemory_AllocateAndClear() failed to allocate array of %u pointers", elements);
ring->writer_head = 0;
ring->reader_tail = 0;
PARCRingBuffer1x1 *
parcRingBuffer1x1_Create(uint32_t elements, RingBufferEntryDestroyer *destroyer)
{
- assertTrue(_isPowerOfTwo(elements), "Parameter elements must be a power of 2, got %u", elements);
+ parcAssertTrue(_isPowerOfTwo(elements), "Parameter elements must be a power of 2, got %u", elements);
return _create(elements, destroyer);
}
return false;
}
- assertNull(ring->buffer[writer_head], "Ring index %u is not null!", writer_head);
+ parcAssertNull(ring->buffer[writer_head], "Ring index %u is not null!", writer_head);
ring->buffer[writer_head] = data;
// we're using this just for atomic write to the integer
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/concurrent/parc_RingBuffer_1x1.h>
#include <parc/concurrent/parc_RingBuffer_NxM.h>
_lock(pthread_mutex_t *mutex)
{
int failure = pthread_mutex_lock(mutex);
- assertFalse(failure, "Error locking mutex: (%d) %s\n", errno, strerror(errno));
+ parcAssertFalse(failure, "Error locking mutex: (%d) %s\n", errno, strerror(errno));
return true;
}
_unlock(pthread_mutex_t *mutex)
{
int failure = pthread_mutex_unlock(mutex);
- assertFalse(failure, "Error unlocking mutex: (%d) %s\n", errno, strerror(errno));
+ parcAssertFalse(failure, "Error unlocking mutex: (%d) %s\n", errno, strerror(errno));
return true;
}
_create(uint32_t elements, RingBufferEntryDestroyer *destroyer)
{
PARCRingBufferNxM *ring = parcObject_CreateInstance(PARCRingBufferNxM);
- assertNotNull(ring, "parcObject_Create returned NULL");
+ parcAssertNotNull(ring, "parcObject_Create returned NULL");
ring->onebyone = parcRingBuffer1x1_Create(elements, destroyer);
ring->destroyer = destroyer;
static bool
_parcScheduledTask_Destructor(PARCScheduledTask **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCScheduledTask pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCScheduledTask pointer.");
PARCScheduledTask *task = *instancePtr;
parcFutureTask_Release(&task->task);
void
parcScheduledTask_AssertValid(const PARCScheduledTask *instance)
{
- assertTrue(parcScheduledTask_IsValid(instance),
+ parcAssertTrue(parcScheduledTask_IsValid(instance),
"PARCScheduledTask is not valid.");
}
static bool
_parcScheduledThreadPool_Destructor(PARCScheduledThreadPool **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCScheduledThreadPool pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCScheduledThreadPool pointer.");
PARCScheduledThreadPool *pool = *instancePtr;
parcThreadPool_Release(&pool->threadPool);
if (parcObject_Lock(pool->workQueue)) {
parcSortedList_Release(&pool->workQueue);
} else {
- assertTrue(false, "Cannot lock the work queue.");
+ parcAssertTrue(false, "Cannot lock the work queue.");
}
return true;
void
parcScheduledThreadPool_AssertValid(const PARCScheduledThreadPool *instance)
{
- assertTrue(parcScheduledThreadPool_IsValid(instance),
+ parcAssertTrue(parcScheduledThreadPool_IsValid(instance),
"PARCScheduledThreadPool is not valid.");
}
static void
_parcSynchronizer_Finalize(PARCSynchronizer **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSynchronizer pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSynchronizer pointer.");
parcSynchronizer_OptionalAssertValid((*instancePtr));
}
void
parcSynchronizer_AssertValid(const PARCSynchronizer *instance)
{
- assertTrue(parcSynchronizer_IsValid(instance),
+ parcAssertTrue(parcSynchronizer_IsValid(instance),
"PARCSynchronizer is not valid.");
}
static bool
_parcThread_Destructor(PARCThread **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCThread pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCThread pointer.");
PARCThread *thread = *instancePtr;
if (thread->argument != NULL) {
void
parcThread_AssertValid(const PARCThread *instance)
{
- assertTrue(parcThread_IsValid(instance),
+ parcAssertTrue(parcThread_IsValid(instance),
"PARCThread is not valid.");
}
PARCThread *
parcThread_Create(void *(*runFunction)(PARCThread *, PARCObject *), PARCObject *restrict parameter)
{
- assertNotNull(parameter, "Parameter cannot be NULL.");
+ parcAssertNotNull(parameter, "Parameter cannot be NULL.");
PARCThread *result = parcObject_CreateAndClearInstance(PARCThread);
static bool
_parcThreadPool_Destructor(PARCThreadPool **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCThreadPool pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCThreadPool pointer.");
PARCThreadPool *pool = *instancePtr;
if (pool->isShutdown == false) {
void
parcThreadPool_AssertValid(const PARCThreadPool *instance)
{
- assertTrue(parcThreadPool_IsValid(instance),
+ parcAssertTrue(parcThreadPool_IsValid(instance),
"PARCThreadPool is not valid.");
}
static void
_parcTimer_Finalize(PARCTimer **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCTimer pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCTimer pointer.");
/* cleanup the instance fields here */
void
parcTimer_AssertValid(const PARCTimer *instance)
{
- assertTrue(parcTimer_IsValid(instance),
+ parcAssertTrue(parcTimer_IsValid(instance),
"PARCTimer is not valid.");
}
parcObjectTesting_AssertAcquireReleaseContract(parcScheduledThreadPool_Acquire, instance);
parcScheduledThreadPool_ShutdownNow(instance);
- assertTrue(parcObject_GetReferenceCount(instance) == 1, "Expected 1 reference count. Actual %llu", parcObject_GetReferenceCount(instance));
+ assertTrue(parcObject_GetReferenceCount(instance) == 1, "Expected 1 reference count. Actual %lu", parcObject_GetReferenceCount(instance));
parcScheduledThreadPool_Release(&instance);
assertNull(instance, "Expected null result from parcScheduledThreadPool_Release();");
PARCFutureTask *task = parcFutureTask_Create(_function, _function);
parcScheduledThreadPool_Schedule(pool, task, parcTimeout_MilliSeconds(2000));
- printf("references %lld\n", parcObject_GetReferenceCount(task));
+ printf("references %lu\n", parcObject_GetReferenceCount(task));
parcFutureTask_Release(&task);
sleep(5);
PARCBuffer *buffer = longBowTestCase_Get(testCase, "object");
parcBuffer_Release(&buffer);
+#if INTPTR_MAX == INT32_MAX
uint32_t initialAllocations = (uint32_t) longBowTestCase_Get(testCase, "initialAllocations");
+#else
+ uint64_t initialAllocations = (uint64_t) longBowTestCase_Get(testCase, "initialAllocations");
+#endif
+
if (!parcMemoryTesting_ExpectedOutstanding(initialAllocations, "%s leaked memory.", longBowTestCase_GetFullName(testCase))) {
parcSafeMemory_ReportAllocation(1);
return LONGBOW_STATUS_MEMORYLEAK;
PARCBuffer *buffer = longBowTestCase_Get(testCase, "object");
parcBuffer_Release(&buffer);
+#if INTPTR_MAX == INT32_MAX
uint32_t initialAllocations = (uint32_t) longBowTestCase_Get(testCase, "initialAllocations");
+#else
+ uint64_t initialAllocations = (uint64_t) longBowTestCase_Get(testCase, "initialAllocations");
+#endif
+
if (!parcMemoryTesting_ExpectedOutstanding(initialAllocations, "%s leaked memory.", longBowTestCase_GetFullName(testCase))) {
parcSafeMemory_ReportAllocation(1);
return LONGBOW_STATUS_MEMORYLEAK;
LONGBOW_TEST_FIXTURE_TEARDOWN(Specialization)
{
+#if INTPTR_MAX == INT32_MAX
uint32_t initialAllocations = (uint32_t) longBowTestCase_Get(testCase, "initialAllocations");
+#else
+ uint64_t initialAllocations = (uint64_t) longBowTestCase_Get(testCase, "initialAllocations");
+#endif
+
if (!parcMemoryTesting_ExpectedOutstanding(initialAllocations, "%s leaked memory.", longBowTestCase_GetFullName(testCase))) {
parcSafeMemory_ReportAllocation(1);
return LONGBOW_STATUS_MEMORYLEAK;
assertTrue(shutdownSuccess, "parcThreadPool_AwaitTermination timed-out");
uint64_t count = parcThreadPool_GetCompletedTaskCount(pool);
- assertTrue(count == 5, "Expected 5, actual %lld", count);
+ assertTrue(count == 5, "Expected 5, actual %lu", count);
parcThreadPool_Release(&pool);
static bool
_parcStopwatch_Destructor(PARCStopwatch **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCStopwatch pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCStopwatch pointer.");
/* cleanup the instance fields here */
return true;
void
parcStopwatch_AssertValid(const PARCStopwatch *instance)
{
- assertTrue(parcStopwatch_IsValid(instance),
+ parcAssertTrue(parcStopwatch_IsValid(instance),
"PARCStopwatch is not valid.");
}
parcStopwatch_Start(a, b, c);
sleep(2);
uint64_t nanos = parcStopwatch_ElapsedTimeNanos(a);
- printf("%llu %llu\n", nanos, nanos / 1000000000);
+ printf("%lu %lu\n", nanos, nanos / 1000000000);
if (nanos > (3000000000)) {
parcStopwatch_Display(a, 0);
}
parcStopwatch_StartImpl(instance, NULL);
sleep(2);
uint64_t nanos = parcStopwatch_ElapsedTimeNanos(instance);
- printf("%llu %llu\n", nanos, nanos / 1000000000);
+ printf("%lu %lu\n", nanos, nanos / 1000000000);
if (nanos > (3000000000)) {
parcStopwatch_Display(instance, 0);
}
// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// longbow-generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
+// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
#include "libparc_About.h"
// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// longbow-generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
+// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
#ifndef libparc_About_h
#define libparc_About_h
#include <stdio.h>
#include <sys/time.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
PARCLog *result = parcObject_CreateInstance(PARCLog);
if (result == NULL) {
- trapOutOfMemory("Creating an instance of PARCLog.");
+ parcTrapOutOfMemory("Creating an instance of PARCLog.");
}
result->hostName = parcMemory_StringDuplicate(hostName, strlen(hostName));
{
char *cString;
int nwritten = vasprintf(&cString, format, ap);
- assertTrue(nwritten >= 0, "Error calling vasprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling vasprintf");
struct timeval timeStamp;
gettimeofday(&timeStamp, NULL);
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <inttypes.h>
#include <stdarg.h>
{
PARCLogEntry *result = parcObject_CreateInstance(PARCLogEntry);
if (result == NULL) {
- trapOutOfMemory("Creating an instance of PARCLogEntry.");
+ parcTrapOutOfMemory("Creating an instance of PARCLogEntry.");
}
result->version = _parcLog_Version;
result->timeStamp = timeStamp;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
static bool
_parcBufferPool_Destructor(PARCBufferPool **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCBufferPool pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCBufferPool pointer.");
PARCBufferPool *pool = *instancePtr;
void
parcBufferPool_AssertValid(const PARCBufferPool *instance)
{
- assertTrue(parcBufferPool_IsValid(instance),
+ parcAssertTrue(parcBufferPool_IsValid(instance),
"PARCBufferPool is not valid.");
}
+++ /dev/null
-set(TestsExpectedToPass
- )
-
-# Enable gcov output for the tests
-add_definitions(--coverage)
-set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " --coverage")
-
-foreach(test ${TestsExpectedToPass})
- AddTest(${test})
-endforeach()
-
-
#include <string.h>
#include <errno.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_ArrayList.h>
#include <parc/security/parc_Security.h>
// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// longbow-generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
+// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
#include "parcPublicKey_About.h"
// DO NOT EDIT THIS FILE. IT IS AUTOMATICALLY GENERATED.
-// longbow-generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
+// generate-about 1.0.20170206.46e2c73a 2017-02-06T08:50:09Z
#ifndef parcPublicKey_About_h
#define parcPublicKey_About_h
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_CertificateType.h>
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_ContainerEncoding.h>
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/security/parc_CryptoCache.h>
parcCryptoCache_Create()
{
PARCCryptoCache *cache = parcMemory_AllocateAndClear(sizeof(PARCCryptoCache));
- assertNotNull(cache, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoCache));
+ parcAssertNotNull(cache, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoCache));
// KeyIdDestroyer is NULL because we get the keyid out of the key, and it will be destroyed
// when the key is destroyed.
void
parcCryptoCache_Destroy(PARCCryptoCache **cryptoCachePtr)
{
- assertNotNull(cryptoCachePtr, "Parameter must be non-null double pointer");
- assertNotNull(*cryptoCachePtr, "Parameter must dereference to non-null pointer");
+ parcAssertNotNull(cryptoCachePtr, "Parameter must be non-null double pointer");
+ parcAssertNotNull(*cryptoCachePtr, "Parameter must dereference to non-null pointer");
PARCCryptoCache *cache = *cryptoCachePtr;
parcHashCodeTable_Destroy(&cache->keyid_table);
bool
parcCryptoCache_AddKey(PARCCryptoCache *cache, PARCKey *original_key)
{
- assertNotNull(cache, "Parameter cache must be non-null");
- assertNotNull(original_key, "Parameter key must be non-null");
+ parcAssertNotNull(cache, "Parameter cache must be non-null");
+ parcAssertNotNull(original_key, "Parameter key must be non-null");
PARCKey *key = parcKey_Copy(original_key);
PARCKeyId *keyid = parcKey_GetKeyId(key);
const PARCKey *
parcCryptoCache_GetKey(PARCCryptoCache *cache, const PARCKeyId *keyid)
{
- assertNotNull(cache, "Parameter cache must be non-null");
- assertNotNull(keyid, "Parameter keyid must be non-null");
+ parcAssertNotNull(cache, "Parameter cache must be non-null");
+ parcAssertNotNull(keyid, "Parameter keyid must be non-null");
return parcHashCodeTable_Get(cache->keyid_table, keyid);
}
void
parcCryptoCache_RemoveKey(PARCCryptoCache *cache, const PARCKeyId *keyid)
{
- assertNotNull(cache, "Parameter cache must be non-null");
- assertNotNull(keyid, "Parameter keyid must be non-null");
+ parcAssertNotNull(cache, "Parameter cache must be non-null");
+ parcAssertNotNull(keyid, "Parameter keyid must be non-null");
parcHashCodeTable_Del(cache->keyid_table, keyid);
}
#include <config.h>
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_CryptoHash.h>
#include <parc/algol/parc_Memory.h>
parcCryptoHash_Create(PARCCryptoHashType digestType, const PARCBuffer *digestBuffer)
{
PARCCryptoHash *parcDigest = parcObject_CreateInstance(PARCCryptoHash);
- assertNotNull(parcDigest, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHash));
+ parcAssertNotNull(parcDigest, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHash));
parcDigest->type = digestType;
parcDigest->digestBuffer = parcBuffer_Acquire((PARCBuffer *) digestBuffer); // casting to un-const
parcCryptoHash_CreateFromArray(PARCCryptoHashType digestType, const void *buffer, size_t length)
{
PARCCryptoHash *parcDigest = parcObject_CreateInstance(PARCCryptoHash);
- assertNotNull(parcDigest, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHash));
+ parcAssertNotNull(parcDigest, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHash));
parcDigest->type = digestType;
// create a reference counted copy
PARCCryptoHashType
parcCryptoHash_GetDigestType(const PARCCryptoHash *parcDigest)
{
- assertNotNull(parcDigest, "Parameter must be non-null");
+ parcAssertNotNull(parcDigest, "Parameter must be non-null");
return parcDigest->type;
}
PARCBuffer *
parcCryptoHash_GetDigest(const PARCCryptoHash *parcDigest)
{
- assertNotNull(parcDigest, "Parameter must be non-null");
+ parcAssertNotNull(parcDigest, "Parameter must be non-null");
return parcDigest->digestBuffer;
}
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_CryptoHashType.h>
#include <parc/security/parc_CryptoHasher.h>
#include <parc/algol/parc_Buffer.h>
#include <parc/algol/parc_Memory.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#ifdef __APPLE__
parcCryptoHasher_Create(PARCCryptoHashType type)
{
PARCCryptoHasher *hasher = parcObject_CreateInstance(PARCCryptoHasher);
- assertNotNull(hasher, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHasher));
+ parcAssertNotNull(hasher, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHasher));
hasher->type = type;
default:
parcMemory_Deallocate((void **) &hasher);
- trapIllegalValue(type, "Unknown hasher type: %d", type);
+ parcTrapIllegalValue(type, "Unknown hasher type: %d", type);
}
hasher->hasher_ctx = hasher->functor.hasher_setup(hasher->functor.functor_env);
parcCryptoHasher_CustomHasher(PARCCryptoHashType type, PARCCryptoHasherInterface functor)
{
PARCCryptoHasher *hasher = parcObject_CreateInstance(PARCCryptoHasher);
- assertNotNull(hasher, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHasher));
+ parcAssertNotNull(hasher, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCCryptoHasher));
hasher->type = type;
hasher->functor = functor;
hasher->hasher_ctx = hasher->functor.hasher_setup(hasher->functor.functor_env);
int
parcCryptoHasher_Init(PARCCryptoHasher *digester)
{
- assertNotNull(digester, "Parameter must be non-null");
+ parcAssertNotNull(digester, "Parameter must be non-null");
int success = digester->functor.hasher_init(digester->hasher_ctx);
return (success == 1) ? 0 : -1;
int
parcCryptoHasher_UpdateBytes(PARCCryptoHasher *digester, const void *buffer, size_t length)
{
- assertNotNull(digester, "Parameter must be non-null");
+ parcAssertNotNull(digester, "Parameter must be non-null");
int success = digester->functor.hasher_update(digester->hasher_ctx, buffer, length);
return (success == 1) ? 0 : -1;
}
int
parcCryptoHasher_UpdateBuffer(PARCCryptoHasher *digester, const PARCBuffer *buffer)
{
- assertNotNull(digester, "Parameter must be non-null");
+ parcAssertNotNull(digester, "Parameter must be non-null");
PARCBuffer *buf = parcBuffer_Slice(buffer);
size_t length = parcBuffer_Limit(buf);
void *byteArray = parcBuffer_Overlay(buf, length);
PARCCryptoHash *
parcCryptoHasher_Finalize(PARCCryptoHasher *digester)
{
- assertNotNull(digester, "Parameter must be non-null");
+ parcAssertNotNull(digester, "Parameter must be non-null");
PARCBuffer *digestBuffer = digester->functor.hasher_finalize(digester->hasher_ctx);
if (parcBuffer_Position(digestBuffer) != 0) {
_crc32_create(void *env __attribute__ ((unused)))
{
_CRC32CState *ctx = parcMemory_AllocateAndClear(sizeof(_CRC32CState));
- assertNotNull(ctx, "parcMemory_AllocateAndClear(%zu) returned NULL for _CRC32CState", sizeof(_CRC32CState));
+ parcAssertNotNull(ctx, "parcMemory_AllocateAndClear(%zu) returned NULL for _CRC32CState", sizeof(_CRC32CState));
// Now initialize it with our digest and key, so in hmac_init we can avoid using those
return ctx;
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_CryptoSuite.h>
#include <parc/security/parc_SigningAlgorithm.h>
return PARCCryptoHashType_CRC32C;
default:
- trapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
}
}
return 4;
default:
- trapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
}
}
case PARCSigningAlgorithm_NULL:
return PARCCryptoSuite_NULL_CRC32C;
default:
- trapIllegalValue(suite, "Unknown signing algorithm suite: %d", signAlgo);
+ parcTrapIllegalValue(suite, "Unknown signing algorithm suite: %d", signAlgo);
}
}
return PARCSigningAlgorithm_NULL;
default:
- trapIllegalValue(suit, "Unknown crypto suite: %d", suite);
+ parcTrapIllegalValue(suit, "Unknown crypto suite: %d", suite);
}
}
}
if (keyShare->privateKey == NULL) {
- assertTrue(false, "Unable to instantiate a private key.");
+ parcAssertTrue(false, "Unable to instantiate a private key.");
parcDiffieHellmanKeyShare_Release(&keyShare);
}
}
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/security/parc_Identity.h>
void
parcIdentity_AssertValid(const PARCIdentity *identity)
{
- trapInvalidValueIf(parcIdentity_IsValid(identity) == false, "PARCIdentity");
+ parcTrapInvalidValueIf(parcIdentity_IsValid(identity) == false, "PARCIdentity");
}
PARCIdentity *
parcIdentity_Create(PARCObject *instance, const PARCIdentityInterface *interface)
{
- assertNotNull(interface, "Got null interface in parcIdentity_Create");
+ parcAssertNotNull(interface, "Got null interface in parcIdentity_Create");
PARCIdentity *result = parcObject_CreateInstance(PARCIdentity);
void
parcIdentity_Display(const PARCIdentity *identity, int indentation)
{
- assertNotNull(identity->interface->Display, "Got null implementation in parcIdentity_Display");
+ parcAssertNotNull(identity->interface->Display, "Got null implementation in parcIdentity_Display");
parcDisplayIndented_PrintLine(indentation, "PARCIdentity@%p {", identity);
parcDisplayIndented_PrintLine(indentation, ".instance=");
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <sys/stat.h>
#include <unistd.h>
#include <config.h>
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_InMemoryVerifier.h>
#include <parc/security/parc_CryptoHasher.h>
#include <parc/security/parc_CryptoCache.h>
return false;
}
- assertFalse(parcKey_GetSigningAlgorithm(key) == PARCSigningAlgorithm_HMAC, "HMAC not supported yet");
+ parcAssertFalse(parcKey_GetSigningAlgorithm(key) == PARCSigningAlgorithm_HMAC, "HMAC not supported yet");
switch (hashType) {
case PARCCryptoHashType_SHA256:
return verifier->hasher_sha512;
default:
- trapUnexpectedState("unsupported hash type: %d", hashType);
+ parcTrapUnexpectedState("unsupported hash type: %d", hashType);
}
}
break;
default:
- trapUnexpectedState("Unknown signing algorithm: %s",
+ parcTrapUnexpectedState("Unknown signing algorithm: %s",
parcSigningAlgorithm_ToString(parcKey_GetSigningAlgorithm(key)));
return false;
}
return false;
}
- assertTrue(_parcInMemoryVerifier_AllowedCryptoSuite(interfaceContext, keyid, suite), "Invalid crypto suite for keyid");
+ parcAssertTrue(_parcInMemoryVerifier_AllowedCryptoSuite(interfaceContext, keyid, suite), "Invalid crypto suite for keyid");
if (parcKey_GetSigningAlgorithm(key) != parcSignature_GetSigningAlgorithm(objectSignature)) {
fprintf(stdout, "Signatured failed, signing algorithms do not match: key %s sig %s\n",
return _parcInMemoryVerifier_ECDSAKey_Verify(verifier, locallyComputedHash, objectSignature, parcKey_GetKey(key));
case PARCSigningAlgorithm_DSA:
- trapNotImplemented("DSA not supported");
+ parcTrapNotImplemented("DSA not supported");
break;
case PARCSigningAlgorithm_HMAC:
- trapNotImplemented("HMAC not supported");
+ parcTrapNotImplemented("HMAC not supported");
break;
default:
- trapUnexpectedState("Unknown signing algorithm: %d", parcSignature_GetSigningAlgorithm(objectSignature));
+ parcTrapUnexpectedState("Unknown signing algorithm: %d", parcSignature_GetSigningAlgorithm(objectSignature));
}
static void
_parcInMemoryVerifier_AddKey(void *interfaceContext, PARCKey *key)
{
- assertNotNull(interfaceContext, "interfaceContext must be non-null");
- assertNotNull(key, "key must be non-null");
+ parcAssertNotNull(interfaceContext, "interfaceContext must be non-null");
+ parcAssertNotNull(key, "key must be non-null");
PARCInMemoryVerifier *verifier = (PARCInMemoryVerifier *) interfaceContext;
bool success = parcCryptoCache_AddKey(verifier->key_cache, key);
- assertTrue(success, "could not add key, it must be a duplicate");
+ parcAssertTrue(success, "could not add key, it must be a duplicate");
}
static void
_parcInMemoryVerifier_RemoveKeyId(void *interfaceContext, PARCKeyId *keyid)
{
- assertNotNull(interfaceContext, "interfaceContent must be non-null");
- assertNotNull(keyid, "key must be non-null");
+ parcAssertNotNull(interfaceContext, "interfaceContent must be non-null");
+ parcAssertNotNull(keyid, "key must be non-null");
PARCInMemoryVerifier *verifier = (PARCInMemoryVerifier *) interfaceContext;
parcCryptoCache_RemoveKey(verifier->key_cache, keyid);
openssl_digest_type = NID_sha512;
break;
default:
- trapUnexpectedState("Unknown digest type: %s",
+ parcTrapUnexpectedState("Unknown digest type: %s",
parcCryptoHashType_ToString(parcCryptoHash_GetDigestType(localHash)));
}
openssl_digest_type = NID_sha512;
break;
default:
- trapUnexpectedState("Unknown digest type: %s",
+ parcTrapUnexpectedState("Unknown digest type: %s",
parcCryptoHashType_ToString(parcCryptoHash_GetDigestType(localHash)));
}
#include <parc/security/parc_Key.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
struct parc_key {
PARCKeyId *keyid;
PARCKey *
parcKey_CreateFromDerEncodedPublicKey(PARCKeyId *keyid, PARCSigningAlgorithm signingAlg, PARCBuffer *derEncodedKey)
{
- assertNotNull(keyid, "Parameter keyid must be non-null");
- assertNotNull(derEncodedKey, "Parameter derEncodedKey must be non-null");
+ parcAssertNotNull(keyid, "Parameter keyid must be non-null");
+ parcAssertNotNull(derEncodedKey, "Parameter derEncodedKey must be non-null");
// Exclude the symmetric key algorithms
switch (signingAlg) {
break;
default:
- trapIllegalValueIf(true, "Unknown key algorithm or symmetric key algorithm: %s\n", parcSigningAlgorithm_ToString(signingAlg));
+ parcTrapIllegalValueIf(true, "Unknown key algorithm or symmetric key algorithm: %s\n", parcSigningAlgorithm_ToString(signingAlg));
}
PARCKey *key = _parcKey_Create();
- assertNotNull(key, "Unable to allocate memory for PARCKey");
+ parcAssertNotNull(key, "Unable to allocate memory for PARCKey");
key->key = parcBuffer_Acquire(derEncodedKey);
key->signingAlg = signingAlg;
PARCKey *
parcKey_CreateFromSymmetricKey(PARCKeyId *keyid, PARCSigningAlgorithm signingAlg, PARCBuffer *secretkey)
{
- assertNotNull(keyid, "Parameter keyid must be non-null");
- assertNotNull(secretkey, "Parameter derEncodedKey must be non-null");
+ parcAssertNotNull(keyid, "Parameter keyid must be non-null");
+ parcAssertNotNull(secretkey, "Parameter derEncodedKey must be non-null");
// Exclude the symmetric key algorithms
switch (signingAlg) {
break;
default:
- trapIllegalValueIf(true, "Unknown key algorithm or symmetric key algorithm: %s\n", parcSigningAlgorithm_ToString(signingAlg));
+ parcTrapIllegalValueIf(true, "Unknown key algorithm or symmetric key algorithm: %s\n", parcSigningAlgorithm_ToString(signingAlg));
}
PARCKey *key = _parcKey_Create();
- assertNotNull(key, "Unable to allocate memory for PARCKey");
+ parcAssertNotNull(key, "Unable to allocate memory for PARCKey");
key->key = parcBuffer_Acquire(secretkey);
key->signingAlg = signingAlg;
void
parcKey_AssertValid(PARCKey *keyPtr)
{
- assertNotNull(keyPtr, "Parameter must be non-null double pointer");
- assertNotNull(keyPtr->key, "Parameter key must not be null");
- assertNotNull(keyPtr->keyid, "Parameter keyId must not be null");
+ parcAssertNotNull(keyPtr, "Parameter must be non-null double pointer");
+ parcAssertNotNull(keyPtr->key, "Parameter key must not be null");
+ parcAssertNotNull(keyPtr->keyid, "Parameter keyId must not be null");
}
PARCKeyId *
parcKey_GetKeyId(const PARCKey *key)
{
- assertNotNull(key, "Parameter must be non-null");
+ parcAssertNotNull(key, "Parameter must be non-null");
return key->keyid;
}
PARCSigningAlgorithm
parcKey_GetSigningAlgorithm(const PARCKey *key)
{
- assertNotNull(key, "Parameter must be non-null");
+ parcAssertNotNull(key, "Parameter must be non-null");
return key->signingAlg;
}
PARCBuffer *
parcKey_GetKey(const PARCKey *key)
{
- assertNotNull(key, "Parameter must be non-null");
+ parcAssertNotNull(key, "Parameter must be non-null");
return key->key;
}
parcKey_Copy(const PARCKey *original)
{
PARCKey *newkey = _parcKey_Create();
- assertNotNull(newkey, "Unable to allocate memory for a new key");
+ parcAssertNotNull(newkey, "Unable to allocate memory for a new key");
newkey->key = parcBuffer_Copy(original->key);
newkey->keyid = parcKeyId_Copy(original->keyid);
newkey->signingAlg = original->signingAlg;
int failure = asprintf(&string, "PARCKey {.KeyID=\"%s\", .SigningAlgorithm=\"%s\" }",
parcKeyId_ToString(key->keyid),
parcSigningAlgorithm_ToString(key->signingAlg));
- assertTrue(failure > -1, "Error asprintf");
+ parcAssertTrue(failure > -1, "Error asprintf");
char *result = parcMemory_StringDuplicate(string, strlen(string));
free(string);
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_KeyId.h>
void
parcKeyId_AssertValid(const PARCKeyId *keyId)
{
- assertNotNull(keyId, "Pointer must be a non-null pointer to a PARCKeyId");
+ parcAssertNotNull(keyId, "Pointer must be a non-null pointer to a PARCKeyId");
}
PARCKeyId *
*/
#include <config.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_KeyStore.h>
#include <parc/algol/parc_Memory.h>
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_KeyType.h>
#include <fcntl.h>
#include <unistd.h>
-#include <LongBow/runtime.h>
-#include <LongBow/longBow_Compiler.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
static bool
_parcPkcs12KeyStore_Finalize(PARCPkcs12KeyStore **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPkcs12KeyStore pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPkcs12KeyStore pointer.");
PARCPkcs12KeyStore *keystore = *instancePtr;
EVP_PKEY_free(keystore->private_key);
FILE *fp = fopen(filename, "rb");
- assertNotNull(fp, "Error opening %s: %s", filename, strerror(errno));
+ parcAssertNotNull(fp, "Error opening %s: %s", filename, strerror(errno));
if (fp == NULL) {
return -1;
}
return 0;
}
-// =============================================================
-LONGBOW_STOP_DEPRECATED_WARNINGS
-// =============================================================
-
PKCS12 *_createPkcs12KeyStore_RSA(
PARCBuffer *privateKeyBuffer,
PARCCertificate *certificate,
fclose(fp);
result = true;
} else {
- trapUnrecoverableState("Cannot fdopen(3) the file descriptor %d", fd);
+ parcTrapUnrecoverableState("Cannot fdopen(3) the file descriptor %d", fd);
}
close(fd);
} else {
- trapUnrecoverableState("Cannot open(2) the file '%s': %s", filename, strerror(errno));
+ parcTrapUnrecoverableState("Cannot open(2) the file '%s': %s", filename, strerror(errno));
}
PKCS12_free(pkcs12);
} else {
while ((errcode = ERR_get_error()) != 0) {
fprintf(stderr, "openssl error: %s\n", ERR_error_string(errcode, NULL));
}
- trapUnrecoverableState("PKCS12_create returned a NULL value.");
+ parcTrapUnrecoverableState("PKCS12_create returned a NULL value.");
}
}
{
parcSecurity_AssertIsInitialized();
- assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
+ parcAssertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
#if 0
if (keystore->public_key_digest == NULL) {
digestBuffer,
NULL);
if (result != 1) {
- assertTrue(0, "Could not compute digest over certificate public key");
+ parcAssertTrue(0, "Could not compute digest over certificate public key");
} else {
keystore->public_key_digest =
parcBuffer_PutArray(parcBuffer_Allocate(SHA256_DIGEST_LENGTH), SHA256_DIGEST_LENGTH, digestBuffer);
{
parcSecurity_AssertIsInitialized();
- assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
+ parcAssertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
if (keystore->certificate_digest == NULL) {
uint8_t digestBuffer[SHA256_DIGEST_LENGTH];
{
parcSecurity_AssertIsInitialized();
- assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
+ parcAssertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
if (keystore->certificate_der == NULL) {
uint8_t *der = NULL;
{
parcSecurity_AssertIsInitialized();
- assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
+ parcAssertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
if (keystore->public_key_der == NULL) {
uint8_t *der = NULL;
{
parcSecurity_AssertIsInitialized();
- assertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
+ parcAssertNotNull(keystore, "Parameter must be non-null PARCPkcs12KeyStore");
if (keystore->private_key_der == NULL) {
uint8_t *der = NULL;
.getSigningAlgorithm = (PARCKeyStoreGetSigningAlgorithm *) _GetSigningAlgorithm,
};
-// =============================================================
-LONGBOW_START_DEPRECATED_WARNINGS
-// =============================================================
static bool
_parcPublicKeySigner_Finalize(PARCPublicKeySigner **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPublicKeySigner pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPublicKeySigner pointer.");
PARCPublicKeySigner *instance = *instancePtr;
void
parcPublicKeySigner_AssertValid(const PARCPublicKeySigner *instance)
{
- assertTrue(parcPublicKeySigner_IsValid(instance), "PARCPublicKeySigner is not valid.");
+ parcAssertTrue(parcPublicKeySigner_IsValid(instance), "PARCPublicKeySigner is not valid.");
}
bool
static PARCSigningAlgorithm
_GetSigningAlgorithm(PARCPublicKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
+ parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
return signer->signingAlgorithm;
}
static PARCCryptoHashType
_GetCryptoHashType(PARCPublicKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
+ parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
return signer->hashType;
}
static PARCCryptoHasher *
_GetCryptoHasher(PARCPublicKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
+ parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
return signer->hasher;
}
static PARCKeyStore *
_GetKeyStore(PARCPublicKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
+ parcAssertNotNull(signer, "Parameter must be non-null PARCCryptoHasher");
return signer->keyStore;
}
RSA *rsa = EVP_PKEY_get1_RSA(privateKey);
*sig = parcMemory_Allocate(RSA_size(rsa));
- assertNotNull(*sig, "parcMemory_Allocate(%u) returned NULL", RSA_size(rsa));
+ parcAssertNotNull(*sig, "parcMemory_Allocate(%u) returned NULL", RSA_size(rsa));
*sigLength = 0;
PARCBuffer *bb_digest = parcCryptoHash_GetDigest(digestToSign);
*sig,
sigLength,
rsa);
- assertTrue(result == 1, "Got error from RSA_sign: %d", result);
+ parcAssertTrue(result == 1, "Got error from RSA_sign: %d", result);
EVP_PKEY_free(privateKey);
RSA_free(rsa);
return result;
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey);
*sig = parcMemory_Allocate(ECDSA_size(ec_key));
- assertNotNull(sig, "parcMemory_Allocate(%u) returned NULL", ECDSA_size(ec_key));
+ parcAssertNotNull(sig, "parcMemory_Allocate(%u) returned NULL", ECDSA_size(ec_key));
*sigLength = 0;
PARCBuffer *bb_digest = parcCryptoHash_GetDigest(digestToSign);
*sig,
sigLength,
ec_key);
- assertTrue(result == 1, "Got error from ECDSA_sign: %d", result);
+ parcAssertTrue(result == 1, "Got error from ECDSA_sign: %d", result);
EC_KEY_free(ec_key);
}
{
parcSecurity_AssertIsInitialized();
- assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
- assertNotNull(digestToSign, "Buffer to sign must not be null");
+ parcAssertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
+ parcAssertNotNull(digestToSign, "Buffer to sign must not be null");
// TODO: what is the best way to expose this?
PARCKeyStore *keyStore = signer->keyStore;
opensslDigestType = NID_sha512;
break;
default:
- trapUnexpectedState("Unknown digest type: %s",
+ parcTrapUnexpectedState("Unknown digest type: %s",
parcCryptoHashType_ToString(parcCryptoHash_GetDigestType(digestToSign)));
}
static size_t
_GetSignatureSize(PARCPublicKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
+ parcAssertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
// TODO: what is the best way to expose this?
PARCKeyStore *keyStore = signer->keyStore;
static bool\r
_parcSecureRandom_Destructor(PARCSecureRandom **instancePtr)\r
{\r
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSecureRandom pointer.");\r
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSecureRandom pointer.");\r
PARCSecureRandom *instance = *instancePtr;\r
\r
close(instance->randomfd);\r
void\r
parcSecureRandom_AssertValid(const PARCSecureRandom *instance)\r
{\r
- assertTrue(parcSecureRandom_IsValid(instance),\r
+ parcAssertTrue(parcSecureRandom_IsValid(instance),\r
"PARCSecureRandom is not valid.");\r
}\r
\r
_parcSecureRandom_ReSeed(PARCSecureRandom *random, PARCBuffer *buffer)\r
{\r
size_t length = parcBuffer_Remaining(buffer);\r
- write(random->randomfd, parcBuffer_Overlay(buffer, length), length);\r
+ int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), length);\r
}\r
\r
PARCSecureRandom *\r
parcSecureRandom_Next(PARCSecureRandom *random)\r
{\r
uint32_t value;\r
- read(random->randomfd, &value, sizeof(value));\r
+ int read_bytes = read(random->randomfd, &value, sizeof(value));\r
return value;\r
}\r
\r
#include <pthread.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_Security.h>
#include <parc/algol/parc_Memory.h>
#error OpenSSL version must be at least 0.9.8 release
#endif
-// Use the LongBow aids for this (case 999)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
error = pthread_mutex_unlock(&(perThreadLocks[type]));
}
- assertTrue(error == 0, "Error in pthreads: (%d) %s", errno, strerror(errno));
+ parcAssertTrue(error == 0, "Error in pthreads: (%d) %s", errno, strerror(errno));
}
#if OPENSSL_VERSION_NUMBER < 0x1000005fL
#if defined(__APPLE__)
uint64_t threadid = 0;
int error = pthread_threadid_np(pthread_self(), &threadid);
- assertTrue(error == 0, "Error getting threadid");
+ parcAssertTrue(error == 0, "Error getting threadid");
return (unsigned long) threadid;
#elif defined(__linux__)
// linux (at least ubuntu and redhat) uses unsigned long int
_initLocks(void)
{
perThreadLocks = parcMemory_AllocateAndClear(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
- assertNotNull(perThreadLocks, "parcMemory_AllocateAndClear(%zu) returned NULL",
+ parcAssertNotNull(perThreadLocks, "parcMemory_AllocateAndClear(%zu) returned NULL",
CRYPTO_num_locks() * sizeof(pthread_mutex_t));
for (int i = 0; i < CRYPTO_num_locks(); i++) {
void
parcSecurity_AssertIsInitialized(void)
{
- trapUnexpectedStateIf(parcSecurity_IsInitialized() == false, "PARC Security framework is not initialized. See parcSecurity_Init()");
+ parcTrapUnexpectedStateIf(parcSecurity_IsInitialized() == false, "PARC Security framework is not initialized. See parcSecurity_Init()");
}
void
parcSecurity_Init(void)
{
int lockSuccessful = pthread_mutex_lock(&parcSecurity_mutex) == 0;
- assertTrue(lockSuccessful, "Unable to lock the PARC Security framework.");
+ parcAssertTrue(lockSuccessful, "Unable to lock the PARC Security framework.");
if (!parcSecurity_initialized) {
_initLocks();
parcSecurity_count++;
int unlockSuccessful = pthread_mutex_unlock(&parcSecurity_mutex) == 0;
- assertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
+ parcAssertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
}
bool
parcSecurity_Fini(void)
{
int lockSuccessful = pthread_mutex_lock(&parcSecurity_mutex) == 0;
- assertTrue(lockSuccessful, "Unable to lock the PARC Security framework.");
+ parcAssertTrue(lockSuccessful, "Unable to lock the PARC Security framework.");
parcSecurity_count--;
if (parcSecurity_count == 0) {
}
int unlockSuccessful = pthread_mutex_unlock(&parcSecurity_mutex) == 0;
- assertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
+ parcAssertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
}
#pragma GCC diagnostic pop
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/security/parc_Signature.h>
PARCSignature *
parcSignature_Create(PARCSigningAlgorithm signingAlgorithm, PARCCryptoHashType hashType, PARCBuffer *signatureBits)
{
- assertNotNull(signatureBits, "SignatureBits Parameter cannot be null");
+ parcAssertNotNull(signatureBits, "SignatureBits Parameter cannot be null");
PARCSignature *signature = parcObject_CreateInstance(PARCSignature);
- assertNotNull(signature, "parcObject_CreateInstance(%zu) returned NULL", sizeof(PARCSignature));
+ parcAssertNotNull(signature, "parcObject_CreateInstance(%zu) returned NULL", sizeof(PARCSignature));
signature->signingAlgorithm = signingAlgorithm;
signature->hashType = hashType;
PARCSigningAlgorithm
parcSignature_GetSigningAlgorithm(const PARCSignature *signature)
{
- assertNotNull(signature, "Parameter must be non-null");
+ parcAssertNotNull(signature, "Parameter must be non-null");
return signature->signingAlgorithm;
}
PARCCryptoHashType
parcSignature_GetHashType(const PARCSignature *signature)
{
- assertNotNull(signature, "Parameter must be non-null");
+ parcAssertNotNull(signature, "Parameter must be non-null");
return signature->hashType;
}
PARCBuffer *
parcSignature_GetSignature(const PARCSignature *signature)
{
- assertNotNull(signature, "Parameter must be non-null");
+ parcAssertNotNull(signature, "Parameter must be non-null");
return signature->signatureBits;
}
char *
parcSignature_ToString(const PARCSignature *signature)
{
- assertNotNull(signature, "Parameter must be a non-null CCNxSignature pointer");
+ parcAssertNotNull(signature, "Parameter must be a non-null CCNxSignature pointer");
char *bits = parcBuffer_ToString(signature->signatureBits);
signature->signingAlgorithm,
signature->hashType,
bits);
- assertTrue(nwritten >= 0, "Error calling asprintf");
+ parcAssertTrue(nwritten >= 0, "Error calling asprintf");
parcMemory_Deallocate((void **) &bits);
#include <config.h>
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
void
parcSigner_AssertValid(const PARCSigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null PARCSigner");
+ parcAssertNotNull(signer, "Parameter must be non-null PARCSigner");
}
parcObject_ImplementAcquire(parcSigner, PARCSigner);
PARCSigner *
parcSigner_Create(PARCObject *instance, PARCSigningInterface *interfaceContext)
{
- assertNotNull(interfaceContext, "Parameter must be non-null implementation pointer");
+ parcAssertNotNull(interfaceContext, "Parameter must be non-null implementation pointer");
PARCSigner *signer = parcObject_CreateInstance(PARCSigner);
if (signer != NULL) {
{
parcSigner_OptionalAssertValid(signer);
- assertNotNull(parcDigest, "parcDigest to sign must not be null");
+ parcAssertNotNull(parcDigest, "parcDigest to sign must not be null");
return signer->interface->SignDigest(signer->instance, parcDigest);
}
parcSigner_SignBuffer(const PARCSigner *signer, const PARCBuffer *buffer)
{
parcSigner_OptionalAssertValid(signer);
- assertNotNull(buffer, "buffer to sign must not be null");
+ parcAssertNotNull(buffer, "buffer to sign must not be null");
PARCCryptoHashType hashType = parcSigner_GetCryptoHashType(signer);
PARCCryptoHasher *hasher = parcCryptoHasher_Create(hashType);
/**
* Assert that an instance of `PARCSigner` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue}
*
* Valid means the internal state of the type is consistent with its
* required current or future behaviour.
#include <stdio.h>
#include <string.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_SigningAlgorithm.h>
#else
// HMAC_Init_ex seems to overrun the size of HMAC_CTX, so make it bigger
HMAC_CTX *ctx = parcMemory_Allocate(sizeof(HMAC_CTX) * 2);
- assertNotNull(ctx, "parcMemory_Allocate(%zu) returned NULL for HMAC_CTX", sizeof(HMAC_CTX) * 2);
+ parcAssertNotNull(ctx, "parcMemory_Allocate(%zu) returned NULL for HMAC_CTX", sizeof(HMAC_CTX) * 2);
HMAC_CTX_init(ctx);
#endif
// Now initialize it with our digest and key, so in hmac_init we can avoid using those
PARCBuffer *secretKey = parcSymmetricKeyStore_GetKey(signer->keyStore);
- assertTrue(parcBuffer_Remaining(secretKey) < 512, "The keystore secret key cannot be longer than %d", 512);
+ parcAssertTrue(parcBuffer_Remaining(secretKey) < 512, "The keystore secret key cannot be longer than %d", 512);
HMAC_Init_ex(ctx, parcByteArray_Array(parcBuffer_Array(secretKey)), (int) parcBuffer_Remaining(secretKey), signer->opensslMd, NULL);
static bool
_parcSymmetricKeySigner_Finalize(PARCSymmetricKeySigner **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSymmetricKeySigner pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSymmetricKeySigner pointer.");
PARCSymmetricKeySigner *signer = (PARCSymmetricKeySigner *) *instancePtr;
if (signer->secretKeyHash != NULL) {
parcCryptoHash_Release(&signer->secretKeyHash);
void
parcSymmetricKeySigner_AssertValid(const PARCSymmetricKeySigner *instance)
{
- assertTrue(parcSymmetricKeySigner_IsValid(instance),
+ parcAssertTrue(parcSymmetricKeySigner_IsValid(instance),
"PARCSymmetricKeySigner is not valid.");
}
default:
parcObject_Release((void **) &result);
- trapIllegalValue(hmacHashType, "Unknown HMAC hash type: %d", hmacHashType);
+ parcTrapIllegalValue(hmacHashType, "Unknown HMAC hash type: %d", hmacHashType);
}
// the signer key digest is SHA256, independent of the HMAC digest
static size_t
_GetSignatureSize(PARCSymmetricKeySigner *signer)
{
- assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
+ parcAssertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
// TODO: what is the best way to expose this?
PARCSymmetricKeyStore *keyStore = signer->keyStore;
#include <openssl/aes.h>
#include <openssl/hmac.h>
-#include <LongBow/runtime.h>
-#include <LongBow/longBow_Compiler.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
parcObject_Override(PARCSymmetricKeyStore, PARCObject,
.destructor = (PARCObjectDestructor *) _parcSymmetricKeyStore_Finalize);
-// =============================================================
-LONGBOW_STOP_DEPRECATED_WARNINGS
-// =============================================================
-
/**
* The openssl ASN1 representation of the PARC symmetric key keystore.
* It will be written to disk in DER format with an i2d call
PARCBuffer *
parcSymmetricKeyStore_CreateKey(unsigned bits)
{
- assertTrue((bits & 0x07) == 0, "bits must be a multiple of 8");
+ parcAssertTrue((bits & 0x07) == 0, "bits must be a multiple of 8");
unsigned keylength = bits / 8;
uint8_t buffer[keylength];
bool
parcSymmetricKeyStore_CreateFile(const char *filename, const char *password, PARCBuffer *secret_key)
{
- assertTrue(parcBuffer_Remaining(secret_key) > 0, "The secret_key buffer is not flipped. See parcBuffer_Flip()");
+ parcAssertTrue(parcBuffer_Remaining(secret_key) > 0, "The secret_key buffer is not flipped. See parcBuffer_Flip()");
return _createKeyStore(filename, password, secret_key) == 0;
}
parcSymmetricKeyStore_OpenFile(const char *filename, const char *password, PARCCryptoHashType hmacHashType)
{
PARCBuffer *secretKey = _AESKeyStoreInit(filename, password);
- assertNotNull(secretKey, "Could not read AES keystore %s", filename);
+ parcAssertNotNull(secretKey, "Could not read AES keystore %s", filename);
PARCSymmetricKeyStore *keyStore = parcSymmetricKeyStore_Create(secretKey);
parcBuffer_Release(&secretKey);
parcSymmetricKeyStore_Create(PARCBuffer *secret_key)
{
PARCSymmetricKeyStore *keyStore = parcObject_CreateAndClearInstance(PARCSymmetricKeyStore);
- assertNotNull(keyStore, "parcObject_CreateAndClearInstance returned NULL, cannot allocate keystore");
+ parcAssertNotNull(keyStore, "parcObject_CreateAndClearInstance returned NULL, cannot allocate keystore");
keyStore->secretKey = parcBuffer_Acquire(secret_key);
return keyStore;
}
-// =============================================================
-LONGBOW_START_DEPRECATED_WARNINGS
-// =============================================================
#include <config.h>
#include <stdio.h>
-#include <LongBow/runtime.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_Verifier.h>
#include <parc/algol/parc_Memory.h>
void
parcVerifier_AssertValid(const PARCVerifier *verifier)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
}
parcObject_ImplementAcquire(parcVerifier, PARCVerifier);
PARCVerifier *
parcVerifier_Create(PARCObject *instance, PARCVerifierInterface *interfaceContext)
{
- assertNotNull(interfaceContext, "Parameter `interfaceContext` must be non-null interface pointer");
- assertNotNull(instance, "Parameter `instance` must be non-null PARCObject pointer");
+ parcAssertNotNull(interfaceContext, "Parameter `interfaceContext` must be non-null interface pointer");
+ parcAssertNotNull(instance, "Parameter `instance` must be non-null PARCObject pointer");
PARCVerifier *verifier = parcObject_CreateInstance(PARCVerifier);
- assertNotNull(verifier, "parcObject_CreateInstance returned NULL");
+ parcAssertNotNull(verifier, "parcObject_CreateInstance returned NULL");
verifier->instance = parcObject_Acquire(instance);
verifier->interface = interfaceContext;
parcVerifier_VerifyDigestSignature(PARCVerifier *verifier, PARCKeyId *keyid, PARCCryptoHash *locallyComputedHash,
PARCCryptoSuite suite, PARCSignature *signatureToVerify)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
- assertNotNull(locallyComputedHash, "cryptoHash to verify must not be null");
- assertNotNull(signatureToVerify, "Signature to verify must not be null");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(locallyComputedHash, "cryptoHash to verify must not be null");
+ parcAssertNotNull(signatureToVerify, "Signature to verify must not be null");
// null keyid is allowed now that we support CRCs, etc.
bool
parcVerifier_AllowedCryptoSuite(PARCVerifier *verifier, PARCKeyId *keyid, PARCCryptoSuite suite)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
return verifier->interface->AllowedCryptoSuite(verifier->instance, keyid, suite);
}
PARCCryptoHasher*
parcVerifier_GetCryptoHasher(PARCVerifier *verifier, PARCKeyId *keyid, PARCCryptoHashType hashType)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
return verifier->interface->GetCryptoHasher(verifier->instance, keyid, hashType);
}
void
parcVerifier_AddKey(PARCVerifier *verifier, PARCKey *key)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
verifier->interface->AddKey(verifier->instance, key);
}
void
parcVerifier_RemoveKeyId(PARCVerifier *verifier, PARCKeyId *keyid)
{
- assertNotNull(verifier, "Parameter must be non-null PARCVerifier");
+ parcAssertNotNull(verifier, "Parameter must be non-null PARCVerifier");
verifier->interface->RemoveKeyId(verifier->instance, keyid);
}
/**
* Assert that an instance of `PARCVerifier` is valid.
*
- * If the instance is not valid, terminate via {@link trapIllegalValue}
+ * If the instance is not valid, terminate via {@link parcTrapIllegalValue}
*
* Valid means the internal state of the type is consistent with its
* required current or future behaviour.
{
parcSecurity_AssertIsInitialized();
- assertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
+ parcAssertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
PARCX509Certificate *certificate = (PARCX509Certificate *) interfaceContext;
{
parcSecurity_AssertIsInitialized();
- assertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
+ parcAssertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
PARCX509Certificate *certificate = (PARCX509Certificate *) interfaceContext;
{
parcSecurity_AssertIsInitialized();
- assertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
+ parcAssertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
PARCX509Certificate *certificate = (PARCX509Certificate *) interfaceContext;
{
parcSecurity_AssertIsInitialized();
- assertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
+ parcAssertNotNull(interfaceContext, "Parameter must be non-null PARCX509Certificate");
PARCX509Certificate *certificate = (PARCX509Certificate *) interfaceContext;
cert->certificateDigest = NULL;
cert->derEncodedCertificate = NULL;
cert->derEncodedKey = NULL;
- assertNotNull(cert, "Failure allocating memory for a new PARCX509Certificate instance");
+ parcAssertNotNull(cert, "Failure allocating memory for a new PARCX509Certificate instance");
return cert;
}
{
// Set up the simple subject name and issuer name for the certificate.
X509_NAME *name = X509_get_subject_name(cert);
- assertNotNull(name, "Got null name from X509_get_subject_name");
+ parcAssertNotNull(name, "Got null name from X509_get_subject_name");
if (X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (unsigned char *) subjectname, -1, -1, 0)) {
if (X509_set_issuer_name(cert, name)) {
cert->certificateBIO = BIO_new(BIO_s_file());
size_t result = BIO_read_filename(cert->certificateBIO, filename);
- assertTrue(result == 1, "Unable to open the specified file");
+ parcAssertTrue(result == 1, "Unable to open the specified file");
cert->certificate = PEM_read_bio_X509(cert->certificateBIO, NULL, 0, NULL);
cert->publicKey = X509_get_pubkey(cert->certificate);
parcSecurity_AssertIsInitialized();
RSA *rsa = RSA_new();
- assertNotNull(rsa, "RSA_new failed.");
+ parcAssertNotNull(rsa, "RSA_new failed.");
EVP_PKEY *privateKey = EVP_PKEY_new();
- assertNotNull(privateKey, "EVP_PKEY_new() failed.");
+ parcAssertNotNull(privateKey, "EVP_PKEY_new() failed.");
X509 *cert = X509_new();
- assertNotNull(cert, "X509_new() failed.");
+ parcAssertNotNull(cert, "X509_new() failed.");
int res;
BIGNUM *pub_exp;
return NULL;
EC_KEY *ec_key = EC_KEY_new_by_curve_name(curve_params);
- assertNotNull(ec_key, "EC key creation failed.");
+ parcAssertNotNull(ec_key, "EC key creation failed.");
EC_KEY_set_asn1_flag(ec_key, OPENSSL_EC_NAMED_CURVE);
EVP_PKEY *pkey = EVP_PKEY_new();
- assertNotNull(pkey, "EVP_PKEY_new() failed.");
+ parcAssertNotNull(pkey, "EVP_PKEY_new() failed.");
X509 *cert = X509_new();
- assertNotNull(cert, "X509_new() failed.");
+ parcAssertNotNull(cert, "X509_new() failed.");
int res;
PARCSigner *signer = parcSigner_Create(symmetricSigner, PARCSymmetricKeySignerAsSigner);
- assertTrue(parcSigner_GetSignatureSize(signer) == 32, "Key size unexpected %d ", parcSigner_GetSignatureSize(signer));
+ assertTrue(parcSigner_GetSignatureSize(signer) == 32, "Key size unexpected %zu ", parcSigner_GetSignatureSize(signer));
parcSigner_Release(&signer);
parcSymmetricKeySigner_Release(&symmetricSigner);
}
static bool
_parcBasicStats_Destructor(PARCBasicStats **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCBasicStats pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCBasicStats pointer.");
return true;
}
void
parcBasicStats_AssertValid(const PARCBasicStats *instance)
{
- assertTrue(parcBasicStats_IsValid(instance),
+ parcAssertTrue(parcBasicStats_IsValid(instance),
"PARCBasicStats is not valid.");
}
static bool
_parcEWMA_Destructor(PARCEWMA **instancePtr)
{
- assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCEWMA pointer.");
+ parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCEWMA pointer.");
return true;
}
void
parcEWMA_AssertValid(const PARCEWMA *instance)
{
- assertTrue(parcEWMA_IsValid(instance),
+ parcAssertTrue(parcEWMA_IsValid(instance),
"PARCEWMA is not valid.");
}
#include <parc/testing/parc_MemoryTesting.h>
#include <parc/algol/parc_Memory.h>
+
+
+#if INTPTR_MAX == INT32_MAX
bool
parcMemoryTesting_ExpectedOutstanding(const uint32_t expected, const char *format, ...)
+#else
+bool
+parcMemoryTesting_ExpectedOutstanding(const uint64_t expected, const char *format, ...)
+#endif
+
{
bool result = true;
* }
* @endcode
*/
-bool parcMemoryTesting_ExpectedOutstanding(const uint32_t expected, const char *format, ...);
+
+#if INTPTR_MAX == INT32_MAX
+bool
+parcMemoryTesting_ExpectedOutstanding(const uint32_t expected, const char *format, ...);
+#else
+bool
+parcMemoryTesting_ExpectedOutstanding(const uint64_t expected, const char *format, ...);
#endif
+#endif
\ No newline at end of file
BUILD_TOOLS_UBUNTU="build-essential doxygen"
LIBSSL_LIBEVENT_UBUNTU="libevent-dev libssl-dev"
-DEPS_UBUNTU="longbow-dev $LIBSSL_LIBEVENT_UBUNTU"
+DEPS_UBUNTU="$LIBSSL_LIBEVENT_UBUNTU"
BUILD_TOOLS_GROUP_CENTOS="'Development Tools'"
LIBSSL_LIBEVENT_CENTOS="libevent-devel openssl-devel"
-DEPS_CENTOS="longbow-devel $LIBSSL_LIBEVENT_CENTOS"
+DEPS_CENTOS="$LIBSSL_LIBEVENT_CENTOS"
update_cmake_repo() {