aboutsummaryrefslogtreecommitdiffstats
path: root/libparc
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-02-05 08:50:26 +0100
committerAngelo Mantellini <manangel@cisco.com>2019-02-06 16:23:04 +0100
commit9f68541e0f55495d61dd9e583bec38740a247597 (patch)
tree55519e34159ac1eb691e080e4c1eab5b0e4847bd /libparc
parentb77148ddc3def71e6c412c3afb5f1c20be2d77cd (diff)
[HICN-26] Windows compatibilty for libparc
Change-Id: I6ebff82a81a2bf42fa3bf210ff0e6e530ce21915 Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'libparc')
-rw-r--r--libparc/CMakeLists.txt29
-rw-r--r--libparc/cmake/Modules/FindPThread.cmake58
-rw-r--r--[-rwxr-xr-x]libparc/cmake/get_version.sh0
-rw-r--r--[-rwxr-xr-x]libparc/documentation/doxygen-extras/doxygen-bootstrap.js0
-rw-r--r--[-rwxr-xr-x]libparc/documentation/doxygen-extras/footer.html0
-rw-r--r--[-rwxr-xr-x]libparc/documentation/doxygen-extras/header.html0
-rw-r--r--[-rwxr-xr-x]libparc/examples/How To Create A Static PARC Object/main.c0
-rw-r--r--libparc/parc/CMakeLists.txt26
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/internal_parc_Event.c4
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/internal_parc_Event.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_AtomicInteger.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_AtomicInteger.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Base64.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BitVector.c8
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BitVector.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Buffer.c8
-rw-r--r--libparc/parc/algol/parc_Buffer.h2
-rw-r--r--libparc/parc/algol/parc_BufferChunker.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BufferChunker.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BufferComposer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BufferComposer.h1
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BufferDictionary.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_BufferDictionary.h0
-rw-r--r--libparc/parc/algol/parc_ByteArray.c9
-rw-r--r--libparc/parc/algol/parc_ByteArray.h4
-rw-r--r--libparc/parc/algol/parc_CMacro.h5
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Chunker.c7
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Chunker.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Clock.c23
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Clock.h5
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Collection.h0
-rw-r--r--libparc/parc/algol/parc_Deque.c12
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Deque.h2
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Dictionary.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Dictionary.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_DisplayIndented.c23
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_ElasticString.h0
-rw-r--r--libparc/parc/algol/parc_Environment.c28
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Environment.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Event.c0
-rw-r--r--libparc/parc/algol/parc_EventBuffer.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventBuffer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventQueue.c4
-rw-r--r--libparc/parc/algol/parc_EventQueue.h5
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventScheduler.c11
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventSignal.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventSignal.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventSocket.c5
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventSocket.h5
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventTimer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_EventTimer.h0
-rw-r--r--libparc/parc/algol/parc_File.c36
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_File.h0
-rw-r--r--libparc/parc/algol/parc_FileChunker.c7
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_FileChunker.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_FileInputStream.c12
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_FileInputStream.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_FileOutputStream.c11
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Hash.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Hash.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_HashCode.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_HashCode.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_HashCodeTable.c6
-rw-r--r--libparc/parc/algol/parc_HashMap.c10
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_HashMap.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_InputStream.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_InputStream.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Iterator.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSON.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSON.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONArray.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONArray.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONPair.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONPair.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONParser.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONParser.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONValue.c4
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_JSONValue.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_KeyValue.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_KeyValue.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_KeyedElement.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_KeyedElement.h0
-rw-r--r--libparc/parc/algol/parc_LinkedList.c12
-rw-r--r--libparc/parc/algol/parc_LinkedList.h2
-rw-r--r--libparc/parc/algol/parc_List.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Map.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Map.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Memory.c23
-rw-r--r--libparc/parc/algol/parc_Memory.h46
-rw-r--r--libparc/parc/algol/parc_Network.c22
-rw-r--r--libparc/parc/algol/parc_Network.h2
-rw-r--r--libparc/parc/algol/parc_Object.c63
-rw-r--r--libparc/parc/algol/parc_Object.h26
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_OldSortedList.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_OldSortedList.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_OutputStream.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_OutputStream.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_PathName.c15
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_PriorityQueue.c4
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_PriorityQueue.h0
-rw-r--r--libparc/parc/algol/parc_Properties.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_RandomAccessFile.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_RandomAccessFile.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_ReadOnlyBuffer.c0
-rw-r--r--libparc/parc/algol/parc_SafeMemory.c14
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Stack.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Stack.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_StdlibMemory.c38
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_StdlibMemory.h14
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_String.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Time.c37
-rw-r--r--libparc/parc/algol/parc_Time.h3
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_TreeMap.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_TreeMap.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_TreeRedBlack.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_TreeRedBlack.h0
-rw-r--r--libparc/parc/algol/parc_URI.c15
-rw-r--r--libparc/parc/algol/parc_URIAuthority.c14
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_URIPath.c14
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_URIPath.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_URISegment.c16
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Unsigned.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Varint.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Varint.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Vector.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/parc_Vector.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_ArrayList.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Base64.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_BitVector.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_BufferChunker.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_ByteArray.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Chunker.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Deque.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Display.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Environment.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_EventScheduler.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_EventTimer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_FileChunker.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_FileInputStream.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_FileOutputStream.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Hash.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_HashCode.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_HashCodeTable.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_InputStream.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_JSONArray.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_JSONParser.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_KeyValue.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_KeyedElement.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Memory.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Network.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Object.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_PathName.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Stack.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_TreeMap.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_TreeRedBlack.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/algol/test/test_parc_Varint.c0
-rw-r--r--libparc/parc/assert/parc_Assert.h8
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint16.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint16.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint32.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint32.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint64.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint64.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint8.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_AtomicUint8.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_FutureTask.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_FutureTask.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Lock.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Lock.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Notifier.c26
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Notifier.h1
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_1x1.c13
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_1x1.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_NxM.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_RingBuffer_NxM.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledTask.c7
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledTask.h0
-rw-r--r--libparc/parc/concurrent/parc_ScheduledThreadPool.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ScheduledThreadPool.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Synchronizer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Synchronizer.h0
-rw-r--r--libparc/parc/concurrent/parc_Thread.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Thread.h0
-rw-r--r--libparc/parc/concurrent/parc_ThreadPool.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_ThreadPool.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timeout.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timer.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/parc_Timer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_Notifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/concurrent/test/test_parc_Synchronizer.c0
-rw-r--r--libparc/parc/config.h.in4
-rw-r--r--libparc/parc/developer/parc_Stopwatch.c8
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_Timing.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_TimingDarwin.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_TimingGeneric.h5
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_TimingIntel.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_TimingIntel.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/parc_TimingLinux.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/developer/test/test_parc_Timing.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/libparc_About.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_Log.c26
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogEntry.h7
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogFormatSyslog.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogFormatSyslog.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogFormatText.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogFormatText.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogLevel.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogLevel.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogManager.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogManager.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporter.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporter.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporterFile.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporterFile.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporterTextStdout.c7
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/parc_LogReporterTextStdout.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/test/test_parc_LogFormatSyslog.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/test/test_parc_LogLevel.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/test/test_parc_LogReporterFile.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/logging/test/test_parc_LogReporterTextStdout.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/command-line/parcPublicKey_About.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Certificate.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Certificate.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateFactory.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateType.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CertificateType.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_ContainerEncoding.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_ContainerEncoding.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoCache.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoCache.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHash.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHash.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHashType.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHasher.c4
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoHasher.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoSuite.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_CryptoSuite.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_DiffieHellmanGroup.h0
-rw-r--r--libparc/parc/security/parc_DiffieHellmanKeyShare.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Identity.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Identity.h0
-rw-r--r--libparc/parc/security/parc_IdentityFile.c13
-rw-r--r--libparc/parc/security/parc_InMemoryVerifier.c5
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_InMemoryVerifier.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Key.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Key.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyId.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyId.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_KeyStore.h0
-rw-r--r--libparc/parc/security/parc_Pkcs12KeyStore.c42
-rw-r--r--libparc/parc/security/parc_PublicKeySigner.c8
-rw-r--r--libparc/parc/security/parc_SecureRandom.c12
-rw-r--r--libparc/parc/security/parc_Security.c8
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Security.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signature.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signature.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Signer.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_SigningAlgorithm.c0
-rw-r--r--libparc/parc/security/parc_SymmetricKeyStore.c12
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_Verifier.c0
-rw-r--r--libparc/parc/security/parc_X509Certificate.c2
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/parc_X509Certificate.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CertificateFactory.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CertificateType.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_ContainerEncoding.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoCache.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoHash.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoHasher.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_CryptoSuite.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_DiffieHellman.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_InMemoryVerifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Key.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Pkcs12KeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SecureRandom.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Security.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Signature.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SigningAlgorithm.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_SymmetricKeyStore.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_Verifier.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/security/test/test_parc_X509Certificate.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/statistics/parc_BasicStats.h0
-rw-r--r--libparc/parc/statistics/parc_EWMA.c6
-rw-r--r--[-rwxr-xr-x]libparc/parc/statistics/parc_EWMA.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/testing/parc_MemoryTesting.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/testing/parc_MemoryTesting.h0
-rw-r--r--[-rwxr-xr-x]libparc/parc/testing/test/test_parc_MemoryTesting.c0
-rw-r--r--[-rwxr-xr-x]libparc/parc/testing/test/test_parc_ObjectTesting.c0
-rw-r--r--libparc/parc/windows/getopt.c149
-rw-r--r--libparc/parc/windows/getopt.h33
-rw-r--r--libparc/parc/windows/getopt_long.c233
-rw-r--r--libparc/parc/windows/parc_Utils.c128
-rw-r--r--libparc/parc/windows/parc_Utils.h168
-rw-r--r--libparc/parc/windows/queue.h488
300 files changed, 1887 insertions, 330 deletions
diff --git a/libparc/CMakeLists.txt b/libparc/CMakeLists.txt
index f40a340e..f7c5fd22 100644
--- a/libparc/CMakeLists.txt
+++ b/libparc/CMakeLists.txt
@@ -30,6 +30,8 @@ elseif(COMPILE_FOR_IOS)
message("############ Detected cross compile for $ENV{CMAKE_SYSTEM_NAME}")
message("############ This build will not include doxygen, tools, or tests")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+elseif(WIN32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4146")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
find_package( Doxygen )
@@ -48,20 +50,32 @@ include_directories(${PROJECT_BINARY_DIR}/parc ${PROJECT_SOURCE_DIR})
if (DOC_ONLY)
message("############ Skipping check of required dependencies.")
elseif(COMPILE_FOR_IOS)
-find_host_package( LibEvent REQUIRED )
+ find_host_package( LibEvent REQUIRED )
include_directories(${LIBEVENT_INCLUDE_DIRS})
-
+ find_package ( Threads REQUIRED )
find_host_package ( OpenSSL REQUIRED )
else()
find_package( LibEvent REQUIRED )
include_directories(${LIBEVENT_INCLUDE_DIRS})
+ if(NOT WIN32)
+ if(ENABLE_TEST)
+ find_package( LongBow REQUIRED )
+ include_directories(${LONGBOW_INCLUDE_DIRS})
+ endif()
+ find_package ( Threads REQUIRED )
+ else()
- if(ENABLE_TEST)
- find_package( LongBow REQUIRED )
- include_directories(${LONGBOW_INCLUDE_DIRS})
+ find_package( PThread REQUIRED )
+ include_directories( ${PTHREAD_INCLUDE_DIRS} )
+
+ find_package ( OpenSSL REQUIRED )
+ include_directories( ${OPENSSL_INCLUDE_DIR} )
+ add_definitions(-D_TIMESPEC_DEFINED=1)
+ find_library(WSOCK32_LIBRARY wsock32 required)
+ find_library(WS2_32_LIBRARY ws2_32 required)
endif()
- find_package ( Threads REQUIRED )
+
find_package ( OpenSSL REQUIRED )
include_directories(${OPENSSL_INCLUDE_DIR})
@@ -82,6 +96,9 @@ else()
${LIBEVENT_LIBRARIES}
${OPENSSL_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
+ ${PTHREAD_LIBRARIES}
+ ${WSOCK32_LIBRARY}
+ ${WS2_32_LIBRARY}
)
endif()
diff --git a/libparc/cmake/Modules/FindPThread.cmake b/libparc/cmake/Modules/FindPThread.cmake
new file mode 100644
index 00000000..23dfc330
--- /dev/null
+++ b/libparc/cmake/Modules/FindPThread.cmake
@@ -0,0 +1,58 @@
+# 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.
+
+########################################
+#
+# Find the PThread libraries and includes
+# This module sets:
+# PTHREAD_FOUND: True if Libconsumer-producer was found
+# PTHREADR_LIBRARY: The Libconsumer-producer library
+# PTHREAD_LIBRARIES: The Libconsumer-producer library and dependencies
+# PTHREAD_INCLUDE_DIR: The Libconsumer-producer include dir
+#
+
+
+set(PTHREAD_SEARCH_PATH_LIST
+ ${PTHREAD_HOME}
+ $ENV{PTHREAD_HOME}
+ /usr/local
+ /opt
+ /usr
+)
+
+find_path(PTHREAD_INCLUDE_DIR pthread.h
+ HINTS ${PTHREAD_SEARCH_PATH_LIST}
+ PATH_SUFFIXES include
+ DOC "Find the pthreadincludes"
+)
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ find_library(PTHREAD_LIBRARY NAMES pthreadVC2.lib
+ HINTS ${PTHREAD_SEARCH_PATH_LIST}
+ PATH_SUFFIXES lib/x64
+ DOC "Find the pthread libraries"
+ )
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ find_library(PTHREAD_LIBRARY NAMES pthreadVC2.lib
+ HINTS ${PTHREAD_SEARCH_PATH_LIST}
+ PATH_SUFFIXES lib/x32
+ DOC "Find the pthread libraries"
+ )
+endif()
+
+
+set(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})
+set(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Pthread DEFAULT_MSG PTHREAD_LIBRARIES PTHREAD_INCLUDE_DIRS) \ No newline at end of file
diff --git a/libparc/cmake/get_version.sh b/libparc/cmake/get_version.sh
index 34c6ddb2..34c6ddb2 100755..100644
--- a/libparc/cmake/get_version.sh
+++ b/libparc/cmake/get_version.sh
diff --git a/libparc/documentation/doxygen-extras/doxygen-bootstrap.js b/libparc/documentation/doxygen-extras/doxygen-bootstrap.js
index 2ddb6474..2ddb6474 100755..100644
--- a/libparc/documentation/doxygen-extras/doxygen-bootstrap.js
+++ b/libparc/documentation/doxygen-extras/doxygen-bootstrap.js
diff --git a/libparc/documentation/doxygen-extras/footer.html b/libparc/documentation/doxygen-extras/footer.html
index 43f2feb1..43f2feb1 100755..100644
--- a/libparc/documentation/doxygen-extras/footer.html
+++ b/libparc/documentation/doxygen-extras/footer.html
diff --git a/libparc/documentation/doxygen-extras/header.html b/libparc/documentation/doxygen-extras/header.html
index e7b5e592..e7b5e592 100755..100644
--- a/libparc/documentation/doxygen-extras/header.html
+++ b/libparc/documentation/doxygen-extras/header.html
diff --git a/libparc/examples/How To Create A Static PARC Object/main.c b/libparc/examples/How To Create A Static PARC Object/main.c
index 00402170..00402170 100755..100644
--- a/libparc/examples/How To Create A Static PARC Object/main.c
+++ b/libparc/examples/How To Create A Static PARC Object/main.c
diff --git a/libparc/parc/CMakeLists.txt b/libparc/parc/CMakeLists.txt
index ebb3ff91..df582a35 100644
--- a/libparc/parc/CMakeLists.txt
+++ b/libparc/parc/CMakeLists.txt
@@ -285,6 +285,19 @@ set (LIBPARC_ASSERT_HEADER_FILES
assert/parc_Assert.h
)
+if(WIN32)
+ set (WINDOWS_UTILITY_HEADER_FILES
+ windows/parc_Utils.h
+ windows/queue.h
+ windows/getopt.h
+ )
+ set (WINDOWS_UTILITY_SOURCE_FILES
+ windows/parc_Utils.c
+ windows/getopt.c
+ windows/getopt_long.c
+ )
+endif()
+
set(LIBPARC_LOGGING_SOURCE_FILES
logging/parc_Log.c
logging/parc_LogEntry.c
@@ -352,6 +365,13 @@ if(ENABLE_TEST)
)
endif()
+if(WIN32)
+ list(APPEND LIBPARC_SOURCE_FILES
+ ${WINDOWS_UTILITY_SOURCE_FILES}
+ ${WINDOWS_UTILITY_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})
@@ -381,9 +401,12 @@ if(COMPILE_FOR_IOS OR ANDROID_API)
)
else()
add_library(parc STATIC ${LIBPARC_SOURCE_FILES})
+ target_link_libraries(parc ${LIBEVENT_LIBRARIES})
+ target_link_libraries(parc ${OPENSSL_LIBRARIES})
add_library(parc.shared SHARED ${LIBPARC_SOURCE_FILES})
target_link_libraries(parc.shared ${LIBEVENT_LIBRARIES})
target_link_libraries(parc.shared ${OPENSSL_LIBRARIES})
+ target_link_libraries(parc.shared ${PARC_BIN_LIBRARIES})
set_target_properties(parc.shared PROPERTIES
C_STANDARD 99
SOVERSION 1
@@ -411,6 +434,9 @@ install(FILES ${LIBPARC_BASE_HEADER_FILES} DESTINATION include/parc COMPON
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(WIN32)
+ install(FILES ${WINDOWS_UTILITY_HEADER_FILES} DESTINATION include/parc/windows COMPONENT headers)
+endif()
if(ENABLE_TEST)
install(FILES ${LIBPARC_TESTING_HEADER_FILES} DESTINATION include/parc/testing COMPONENT headers)
diff --git a/libparc/parc/algol/internal_parc_Event.c b/libparc/parc/algol/internal_parc_Event.c
index 54c193ea..9335e1e0 100755..100644
--- a/libparc/parc/algol/internal_parc_Event.c
+++ b/libparc/parc/algol/internal_parc_Event.c
@@ -13,10 +13,6 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include "internal_parc_Event.h"
diff --git a/libparc/parc/algol/internal_parc_Event.h b/libparc/parc/algol/internal_parc_Event.h
index ab157a56..ab157a56 100755..100644
--- a/libparc/parc/algol/internal_parc_Event.h
+++ b/libparc/parc/algol/internal_parc_Event.h
diff --git a/libparc/parc/algol/parc_AtomicInteger.c b/libparc/parc/algol/parc_AtomicInteger.c
index b32a698f..b32a698f 100755..100644
--- a/libparc/parc/algol/parc_AtomicInteger.c
+++ b/libparc/parc/algol/parc_AtomicInteger.c
diff --git a/libparc/parc/algol/parc_AtomicInteger.h b/libparc/parc/algol/parc_AtomicInteger.h
index 729d9a01..729d9a01 100755..100644
--- a/libparc/parc/algol/parc_AtomicInteger.h
+++ b/libparc/parc/algol/parc_AtomicInteger.h
diff --git a/libparc/parc/algol/parc_Base64.c b/libparc/parc/algol/parc_Base64.c
index cac0aa4d..e4e66437 100755..100644
--- a/libparc/parc/algol/parc_Base64.c
+++ b/libparc/parc/algol/parc_Base64.c
@@ -71,7 +71,9 @@ const uint8_t decodeTable[256] = {
'~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~', '~'
};
+#ifndef min
#define min(a, b) ((a < b) ? a : b)
+#endif
/**
* Encode the 3-byte quantum pointed to by <code>quantum</code> into 4 encoded characters.
@@ -198,7 +200,7 @@ parcBase64_Encode(PARCBufferComposer *result, PARCBuffer *plainText)
}
PARCBufferComposer *
-parcBase64_EncodeArray(PARCBufferComposer *output, size_t length, const uint8_t array[length])
+parcBase64_EncodeArray(PARCBufferComposer *output, size_t length, const uint8_t *array)
{
size_t offset = 0;
@@ -233,7 +235,7 @@ parcBase64_DecodeString(PARCBufferComposer *output, const char *encodedString)
}
PARCBufferComposer *
-parcBase64_DecodeArray(PARCBufferComposer *output, size_t length, const uint8_t array[length])
+parcBase64_DecodeArray(PARCBufferComposer *output, size_t length, const uint8_t *array)
{
size_t offset = 0;
bool success = true;
diff --git a/libparc/parc/algol/parc_BitVector.c b/libparc/parc/algol/parc_BitVector.c
index 21a66c23..68a86459 100755..100644
--- a/libparc/parc/algol/parc_BitVector.c
+++ b/libparc/parc/algol/parc_BitVector.c
@@ -171,7 +171,7 @@ parcBitVector_SetVector(PARCBitVector *parcBitVector, const PARCBitVector *bitsT
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++) {
+ for (unsigned int i = 0; i < bitsToSet->numberOfBitsSet; i++) {
settingBit = parcBitVector_NextBitSet(bitsToSet, settingBit);
parcAssertTrue(settingBit != -1, "Number of bits claimed set inconsistent with bits found");
parcBitVector_Set(parcBitVector, settingBit);
@@ -220,8 +220,8 @@ parcBitVector_ClearVector(PARCBitVector *parcBitVector, const PARCBitVector *bit
return;
}
- int clearingBit = 0;
- for (int i = 0; i < bitsToClear->numberOfBitsSet; i++) {
+ unsigned int clearingBit = 0;
+ for (unsigned int i = 0; i < bitsToClear->numberOfBitsSet; i++) {
clearingBit = parcBitVector_NextBitSet(bitsToClear, clearingBit);
// only clear up to the end of the original vector
if (clearingBit >= parcBitVector->bitLength) {
@@ -271,7 +271,7 @@ parcBitVector_Contains(const PARCBitVector *parcBitVector, const PARCBitVector *
bool result = true;
int testBit = 0;
- for (int i = 0; i < testVector->numberOfBitsSet; i++, testBit++) {
+ for (unsigned int i = 0; i < testVector->numberOfBitsSet; i++, testBit++) {
testBit = parcBitVector_NextBitSet(testVector, testBit);
if (parcBitVector_Get(parcBitVector, testBit) != 1) {
result = false;
diff --git a/libparc/parc/algol/parc_BitVector.h b/libparc/parc/algol/parc_BitVector.h
index 552fd911..552fd911 100755..100644
--- a/libparc/parc/algol/parc_BitVector.h
+++ b/libparc/parc/algol/parc_BitVector.h
diff --git a/libparc/parc/algol/parc_Buffer.c b/libparc/parc/algol/parc_Buffer.c
index 20520f9c..261aac6d 100755..100644
--- a/libparc/parc/algol/parc_Buffer.c
+++ b/libparc/parc/algol/parc_Buffer.c
@@ -761,7 +761,7 @@ parcBuffer_GetUint8(PARCBuffer *buffer)
}
PARCBuffer *
-parcBuffer_GetBytes(PARCBuffer *buffer, size_t length, uint8_t array[length])
+parcBuffer_GetBytes(PARCBuffer *buffer, size_t length, uint8_t *array)
{
parcBuffer_OptionalAssertValid(buffer);
_trapIfBufferUnderflow(buffer, length);
@@ -863,7 +863,7 @@ parcBuffer_PutAtIndex(PARCBuffer *buffer, size_t index, uint8_t value)
}
PARCBuffer *
-parcBuffer_PutArray(PARCBuffer *buffer, size_t arrayLength, const uint8_t array[arrayLength])
+parcBuffer_PutArray(PARCBuffer *buffer, size_t arrayLength, const uint8_t *array)
{
parcBuffer_OptionalAssertValid(buffer);
parcAssertTrue(parcBuffer_Remaining(buffer) >= arrayLength,
@@ -977,7 +977,7 @@ parcBuffer_ToHexString(const PARCBuffer *buffer)
}
bool
-parcBuffer_SkipOver(PARCBuffer *buffer, size_t length, const uint8_t bytesToSkipOver[length])
+parcBuffer_SkipOver(PARCBuffer *buffer, size_t length, const uint8_t *bytesToSkipOver)
{
while (parcBuffer_Remaining(buffer) > 0) {
uint8_t character = parcBuffer_GetUint8(buffer);
@@ -990,7 +990,7 @@ parcBuffer_SkipOver(PARCBuffer *buffer, size_t length, const uint8_t bytesToSkip
}
bool
-parcBuffer_SkipTo(PARCBuffer *buffer, size_t length, const uint8_t bytesToSkipTo[length])
+parcBuffer_SkipTo(PARCBuffer *buffer, size_t length, const uint8_t *bytesToSkipTo)
{
bool result = false;
diff --git a/libparc/parc/algol/parc_Buffer.h b/libparc/parc/algol/parc_Buffer.h
index 665019db..fdc205f8 100644
--- a/libparc/parc/algol/parc_Buffer.h
+++ b/libparc/parc/algol/parc_Buffer.h
@@ -362,7 +362,7 @@ PARCBuffer *parcBuffer_AllocateCString(const char *string);
* }
* @endcode
*/
-PARCBuffer *parcBuffer_CreateFromArray(const void *bytes, size_t length);
+PARCBuffer *parcBuffer_CreateFromArray(const void *bytes, const size_t length);
/**
* Parse a null-terminated hexadecimal string to create a new `PARCBuffer` instance.
diff --git a/libparc/parc/algol/parc_BufferChunker.c b/libparc/parc/algol/parc_BufferChunker.c
index f3a4ab67..03c67f58 100644
--- a/libparc/parc/algol/parc_BufferChunker.c
+++ b/libparc/parc/algol/parc_BufferChunker.c
@@ -20,7 +20,9 @@
#include <stdio.h>
#include <string.h>
+#ifndef _WIN32
#include <sys/time.h>
+#endif
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Buffer.h>
diff --git a/libparc/parc/algol/parc_BufferChunker.h b/libparc/parc/algol/parc_BufferChunker.h
index 16f21c49..16f21c49 100755..100644
--- a/libparc/parc/algol/parc_BufferChunker.h
+++ b/libparc/parc/algol/parc_BufferChunker.h
diff --git a/libparc/parc/algol/parc_BufferComposer.c b/libparc/parc/algol/parc_BufferComposer.c
index 30e23acf..30e23acf 100755..100644
--- a/libparc/parc/algol/parc_BufferComposer.c
+++ b/libparc/parc/algol/parc_BufferComposer.c
diff --git a/libparc/parc/algol/parc_BufferComposer.h b/libparc/parc/algol/parc_BufferComposer.h
index 25c69258..e0ec5112 100755..100644
--- a/libparc/parc/algol/parc_BufferComposer.h
+++ b/libparc/parc/algol/parc_BufferComposer.h
@@ -30,6 +30,7 @@
struct parc_buffer_composer;
typedef struct parc_buffer_composer PARCBufferComposer;
+#include <config.h>
#include <parc/algol/parc_Buffer.h>
extern parcObjectDescriptor_Declaration(PARCBufferComposer);
diff --git a/libparc/parc/algol/parc_BufferDictionary.c b/libparc/parc/algol/parc_BufferDictionary.c
index c2438129..c2438129 100755..100644
--- a/libparc/parc/algol/parc_BufferDictionary.c
+++ b/libparc/parc/algol/parc_BufferDictionary.c
diff --git a/libparc/parc/algol/parc_BufferDictionary.h b/libparc/parc/algol/parc_BufferDictionary.h
index 60aa90cb..60aa90cb 100755..100644
--- a/libparc/parc/algol/parc_BufferDictionary.h
+++ b/libparc/parc/algol/parc_BufferDictionary.h
diff --git a/libparc/parc/algol/parc_ByteArray.c b/libparc/parc/algol/parc_ByteArray.c
index 1d81d211..e4cc0480 100644
--- a/libparc/parc/algol/parc_ByteArray.c
+++ b/libparc/parc/algol/parc_ByteArray.c
@@ -108,7 +108,7 @@ parcByteArray_Allocate(const size_t length)
}
PARCByteArray *
-parcByteArray_Wrap(const size_t length, uint8_t array[length])
+parcByteArray_Wrap(const size_t length, uint8_t *array)
{
if (array != NULL) {
PARCByteArray *result = parcObject_CreateInstance(PARCByteArray);
@@ -209,7 +209,7 @@ parcByteArray_Compare(const PARCByteArray *x, const PARCByteArray *y)
}
PARCByteArray *
-parcByteArray_PutBytes(PARCByteArray *result, size_t offset, size_t length, const uint8_t source[length])
+parcByteArray_PutBytes(PARCByteArray *result, size_t offset, size_t length, const uint8_t *source)
{
parcByteArray_OptionalAssertValid(result);
parcTrapOutOfBoundsIf(offset > result->length,
@@ -224,7 +224,7 @@ parcByteArray_PutBytes(PARCByteArray *result, size_t offset, size_t length, cons
}
PARCByteArray *
-parcByteArray_GetBytes(const PARCByteArray *result, size_t offset, size_t length, uint8_t array[length])
+parcByteArray_GetBytes(const PARCByteArray *result, size_t offset, size_t length, uint8_t *array)
{
parcByteArray_OptionalAssertValid(result);
@@ -265,7 +265,7 @@ static void
_parcByteArray_PrettyPrintLine(const unsigned char *memory, size_t offset, size_t length)
{
int bytesPerLine = 16;
- char accumulator[bytesPerLine + 1];
+ char *accumulator = (char *)malloc(sizeof(char) * (bytesPerLine + 1));
memset(accumulator, ' ', bytesPerLine);
accumulator[bytesPerLine] = 0;
@@ -286,6 +286,7 @@ _parcByteArray_PrettyPrintLine(const unsigned char *memory, size_t offset, size_
}
}
printf(" %s\n", accumulator);
+ free(accumulator);
}
void
diff --git a/libparc/parc/algol/parc_ByteArray.h b/libparc/parc/algol/parc_ByteArray.h
index c7a26285..71047339 100644
--- a/libparc/parc/algol/parc_ByteArray.h
+++ b/libparc/parc/algol/parc_ByteArray.h
@@ -156,7 +156,7 @@ PARCByteArray *parcByteArray_Allocate(const size_t capacity);
* }
* @endcode
*/
-PARCByteArray *parcByteArray_Wrap(size_t capacity, uint8_t *array);
+PARCByteArray *parcByteArray_Wrap(const size_t capacity, uint8_t *array);
/**
* Returns the pointer to the `uint8_t` array that backs this `PARCByteArray`.
@@ -560,7 +560,7 @@ PARCHashCode parcByteArray_HashCode(const PARCByteArray *array);
* }
* @endcode
*/
-uint8_t *parcByteArray_AddressOfIndex(const PARCByteArray *array, size_t index);
+uint8_t *parcByteArray_AddressOfIndex(const PARCByteArray *array, const size_t index);
/**
* Pretty print the given `PARCByteArray` instance.
diff --git a/libparc/parc/algol/parc_CMacro.h b/libparc/parc/algol/parc_CMacro.h
index a47129ea..0b948d2f 100644
--- a/libparc/parc/algol/parc_CMacro.h
+++ b/libparc/parc/algol/parc_CMacro.h
@@ -35,7 +35,10 @@
* parcCMacro_IfElse is a c-macro trick for implementing a macro If-Else switch.
* It uses parcCMacro_ThirdParam to select between A or B depending on whether __VA_ARGS__ expands to a comma.
*/
-#define parcCMacro_IfElse(A, B, ...) parcCMacro_ThirdParam(__VA_ARGS__, A, B, NOOP)
+
+
+#define EXPAND( x ) x
+#define parcCMacro_IfElse(A, B, ...) EXPAND(parcCMacro_ThirdParam( __VA_ARGS__ , A, B, NOOP))
/** \cond */
#define _parcCMacro_Cat_(A, B) A ## B
diff --git a/libparc/parc/algol/parc_Chunker.c b/libparc/parc/algol/parc_Chunker.c
index b84ed05f..f6c94b6d 100755..100644
--- a/libparc/parc/algol/parc_Chunker.c
+++ b/libparc/parc/algol/parc_Chunker.c
@@ -13,14 +13,13 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
#include <config.h>
-
#include <stdio.h>
#include <string.h>
-#include <sys/time.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
diff --git a/libparc/parc/algol/parc_Chunker.h b/libparc/parc/algol/parc_Chunker.h
index 305acad7..305acad7 100755..100644
--- a/libparc/parc/algol/parc_Chunker.h
+++ b/libparc/parc/algol/parc_Chunker.h
diff --git a/libparc/parc/algol/parc_Clock.c b/libparc/parc/algol/parc_Clock.c
index 95cf74bc..58624fc9 100755..100644
--- a/libparc/parc/algol/parc_Clock.c
+++ b/libparc/parc/algol/parc_Clock.c
@@ -68,7 +68,7 @@ _counterClock_GetTimeval(const PARCClock *clock, struct timeval *output)
uint64_t value = parcAtomicInteger_Uint64Increment(&cc->counter);
// put 19 bits in the micro-seconds so it is never larger than 1E+6
- output->tv_sec = value >> 19;
+ output->tv_sec = (long) (value >> 19);
output->tv_usec = value & 0x7FFFF;
}
@@ -94,6 +94,17 @@ parcClock_Counter(void)
return clock;
}
+#ifdef _WIN32
+static int _clock_gettime(int value, struct timespec *spec) {
+ __int64 wintime;
+ GetSystemTimeAsFileTime((FILETIME *)&wintime);
+ wintime -= 116444736000000000i64; //1jan1601 to 1jan1970
+ spec->tv_sec = wintime / 10000000i64; //seconds
+ spec->tv_nsec = wintime % 10000000i64 * 100; //nano-seconds
+ return 0;
+}
+#endif
+
// ===========
// Wallclock
@@ -105,6 +116,11 @@ _wallclock_GetTimeval(const PARCClock *dummy __attribute__((unused)), struct tim
clock_gettime(CLOCK_REALTIME, &ts);
output->tv_sec = ts.tv_sec;
output->tv_usec = ts.tv_nsec / 1000;
+#elif _WIN32
+ struct timespec ts;
+ _clock_gettime(TIME_UTC, &ts);
+ output->tv_sec = (long)ts.tv_sec;
+ output->tv_usec = ts.tv_nsec / 1000;
#else
clock_serv_t clockService;
mach_timespec_t mts;
@@ -167,6 +183,11 @@ _monoclock_GetTimeval(const PARCClock *dummy __attribute__((unused)), struct tim
clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
output->tv_sec = ts.tv_sec;
output->tv_usec = ts.tv_nsec / 1000;
+#elif _WIN32
+ struct timespec ts;
+ _clock_gettime(TIME_UTC, &ts);
+ output->tv_sec = (long)ts.tv_sec;
+ output->tv_usec = ts.tv_nsec / 1000;
#else
clock_serv_t clockService;
mach_timespec_t mts;
diff --git a/libparc/parc/algol/parc_Clock.h b/libparc/parc/algol/parc_Clock.h
index 35c77fd7..698773b9 100755..100644
--- a/libparc/parc/algol/parc_Clock.h
+++ b/libparc/parc/algol/parc_Clock.h
@@ -98,8 +98,11 @@
#ifndef PARC_parc_Clock_h
#define PARC_parc_Clock_h
-#include <inttypes.h>
+#ifndef _WIN32
#include <sys/time.h>
+#endif
+
+#include <inttypes.h>
struct parc_clock;
typedef struct parc_clock PARCClock;
diff --git a/libparc/parc/algol/parc_Collection.h b/libparc/parc/algol/parc_Collection.h
index 87deff12..87deff12 100755..100644
--- a/libparc/parc/algol/parc_Collection.h
+++ b/libparc/parc/algol/parc_Collection.h
diff --git a/libparc/parc/algol/parc_Deque.c b/libparc/parc/algol/parc_Deque.c
index 84808766..c0b83551 100644
--- a/libparc/parc/algol/parc_Deque.c
+++ b/libparc/parc/algol/parc_Deque.c
@@ -13,17 +13,15 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <sys/queue.h>
+#endif
+#include <config.h>
#include <stdio.h>
-#include <sys/queue.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Deque.h>
-
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
diff --git a/libparc/parc/algol/parc_Deque.h b/libparc/parc/algol/parc_Deque.h
index 57dd39b1..8b988dee 100755..100644
--- a/libparc/parc/algol/parc_Deque.h
+++ b/libparc/parc/algol/parc_Deque.h
@@ -345,7 +345,7 @@ bool parcDeque_Equals(const PARCDeque *x, const PARCDeque *y);
* @endcode
*
*/
-void parcDeque_Display(const PARCDeque *deque, int indentation);
+void parcDeque_Display(const PARCDeque *deque, const int indentation);
/**
* Wakes up a single thread that is waiting on this object (see `parcDeque_Wait)`.
diff --git a/libparc/parc/algol/parc_Dictionary.c b/libparc/parc/algol/parc_Dictionary.c
index a7a59de6..a7a59de6 100755..100644
--- a/libparc/parc/algol/parc_Dictionary.c
+++ b/libparc/parc/algol/parc_Dictionary.c
diff --git a/libparc/parc/algol/parc_Dictionary.h b/libparc/parc/algol/parc_Dictionary.h
index 1ba98a65..1ba98a65 100755..100644
--- a/libparc/parc/algol/parc_Dictionary.h
+++ b/libparc/parc/algol/parc_Dictionary.h
diff --git a/libparc/parc/algol/parc_DisplayIndented.c b/libparc/parc/algol/parc_DisplayIndented.c
index 39e1d76e..a17e7f04 100755..100644
--- a/libparc/parc/algol/parc_DisplayIndented.c
+++ b/libparc/parc/algol/parc_DisplayIndented.c
@@ -13,19 +13,18 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <unistd.h>
#include <string.h>
#include <ctype.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_DisplayIndented.h>
static char *_spaces = " ";
@@ -38,7 +37,7 @@ _indent(int indentation)
size_t result = 0;
if (indentation > 0) {
- result = write(1, _spaces, indentation * _indentationFactor);
+ result = write(1, _spaces, (unsigned int)(indentation * _indentationFactor));
parcAssertTrue(result == (indentation * _indentationFactor),
"Write(2) failed to write %zd bytes.", indentation * _indentationFactor);
}
@@ -54,11 +53,11 @@ _parcDisplayIndented_Print(int indentation, char *string)
while (start != NULL) {
_indent(indentation);
if (end != NULL) {
- ssize_t nwritten = write(1, start, end - start + 1);
+ ssize_t nwritten = write(1, start, (unsigned int)(end - start + 1));
parcAssertTrue(nwritten >= 0, "Error calling write");
start = end + 1;
} else {
- ssize_t nwritten = write(1, start, strlen(start));
+ ssize_t nwritten = write(1, start, (unsigned int)strlen(start));
parcAssertTrue(nwritten >= 0, "Error calling write");
break;
}
@@ -87,11 +86,10 @@ parcDisplayIndented_PrintLine(int indentation, const char *format, ...)
}
void
-parcDisplayIndented_PrintMemory(int indentation, size_t length, const char memory[length])
+parcDisplayIndented_PrintMemory(int indentation, size_t length, const char *memory)
{
int bytesPerLine = 16;
-
- char accumulator[bytesPerLine + 1];
+ char *accumulator = (char *)malloc(sizeof(char)*(bytesPerLine + 1));
memset(accumulator, ' ', bytesPerLine);
accumulator[bytesPerLine] = 0;
@@ -111,4 +109,5 @@ parcDisplayIndented_PrintMemory(int indentation, size_t length, const char memor
offset += bytesInLine;
}
printf(" %s]\n", accumulator);
+ free(accumulator);
}
diff --git a/libparc/parc/algol/parc_ElasticString.h b/libparc/parc/algol/parc_ElasticString.h
index c6e39eb1..c6e39eb1 100755..100644
--- a/libparc/parc/algol/parc_ElasticString.h
+++ b/libparc/parc/algol/parc_ElasticString.h
diff --git a/libparc/parc/algol/parc_Environment.c b/libparc/parc/algol/parc_Environment.c
index 2955a139..2ca11b4d 100644
--- a/libparc/parc/algol/parc_Environment.c
+++ b/libparc/parc/algol/parc_Environment.c
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-#include <sys/types.h>
-#include <pwd.h>
-#include <stdlib.h>
+#ifndef _WIN32
#include <unistd.h>
+#include <pwd.h>
+#endif
+#include <config.h>
+#include <sys/types.h>
+#include <stdlib.h>
#include <parc/algol/parc_Environment.h>
#include <parc/algol/parc_File.h>
@@ -35,11 +35,23 @@ parcEnvironment_GetHomeDirectory(void)
PARCFile *
parcEnvironment_HomeDirectory(void)
{
- char *path;
+#ifdef _WIN32
+ char *pValue;
+ size_t len;
+ errno_t err = _dupenv_s(&pValue, &len, "USERPROFILE");
+ if (err != 0) {
+ return parcFile_Create(pValue);
+ }
+ else {
+ return NULL;
+ }
+#else
+ char *path;
if ((path = getenv("HOME")) == NULL) {
path = getpwuid(getuid())->pw_dir;
}
-
return parcFile_Create(path);
+#endif
+
}
diff --git a/libparc/parc/algol/parc_Environment.h b/libparc/parc/algol/parc_Environment.h
index 04610176..04610176 100755..100644
--- a/libparc/parc/algol/parc_Environment.h
+++ b/libparc/parc/algol/parc_Environment.h
diff --git a/libparc/parc/algol/parc_Event.c b/libparc/parc/algol/parc_Event.c
index 1621edac..1621edac 100755..100644
--- a/libparc/parc/algol/parc_Event.c
+++ b/libparc/parc/algol/parc_Event.c
diff --git a/libparc/parc/algol/parc_EventBuffer.c b/libparc/parc/algol/parc_EventBuffer.c
index 6293680c..9867d916 100644
--- a/libparc/parc/algol/parc_EventBuffer.c
+++ b/libparc/parc/algol/parc_EventBuffer.c
@@ -162,7 +162,7 @@ parcEventBuffer_copyOut(PARCEventBuffer *readBuffer, void *data_out, size_t leng
{
parcAssertNotNull(data_out, "parcEventBuffer_Copy was passed a null data_out buffer\n");
parcEventBuffer_OptionalAssertValid(readBuffer);
- return evbuffer_copyout(readBuffer->evbuffer, data_out, length);
+ return (int)evbuffer_copyout(readBuffer->evbuffer, data_out, length);
}
int
diff --git a/libparc/parc/algol/parc_EventBuffer.h b/libparc/parc/algol/parc_EventBuffer.h
index 8e82a5e6..8e82a5e6 100755..100644
--- a/libparc/parc/algol/parc_EventBuffer.h
+++ b/libparc/parc/algol/parc_EventBuffer.h
diff --git a/libparc/parc/algol/parc_EventQueue.c b/libparc/parc/algol/parc_EventQueue.c
index dffab1e7..3542b408 100755..100644
--- a/libparc/parc/algol/parc_EventQueue.c
+++ b/libparc/parc/algol/parc_EventQueue.c
@@ -176,7 +176,7 @@ parcEventQueue_SetFileDescriptor(PARCEventQueue *parcEventQueue, int fd)
int
parcEventQueue_GetFileDescriptor(PARCEventQueue *parcEventQueue)
{
- return bufferevent_getfd(parcEventQueue->buffereventBuffer);
+ return (int)bufferevent_getfd(parcEventQueue->buffereventBuffer);
}
PARCEventType
@@ -239,7 +239,7 @@ parcEventQueue_Printf(PARCEventQueue *parcEventQueue, const char *fmt, ...)
int
parcEventQueue_Read(PARCEventQueue *parcEventQueue, void *data, size_t dataLength)
{
- return bufferevent_read(parcEventQueue->buffereventBuffer, data, dataLength);
+ return (int)bufferevent_read(parcEventQueue->buffereventBuffer, data, dataLength);
}
int
diff --git a/libparc/parc/algol/parc_EventQueue.h b/libparc/parc/algol/parc_EventQueue.h
index 282df302..d6ed1bce 100644
--- a/libparc/parc/algol/parc_EventQueue.h
+++ b/libparc/parc/algol/parc_EventQueue.h
@@ -27,8 +27,11 @@
#ifndef libparc_parc_EventQueue_h
#define libparc_parc_EventQueue_h
-#include <sys/types.h>
+#ifndef _WIN32
#include <sys/socket.h>
+#endif
+
+#include <sys/types.h>
#include <parc/algol/parc_Event.h>
diff --git a/libparc/parc/algol/parc_EventScheduler.c b/libparc/parc/algol/parc_EventScheduler.c
index 3983740e..59103f49 100755..100644
--- a/libparc/parc/algol/parc_EventScheduler.c
+++ b/libparc/parc/algol/parc_EventScheduler.c
@@ -13,16 +13,15 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <stdio.h>
-#include <unistd.h>
#include "internal_parc_Event.h"
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_EventScheduler.h>
#include <parc/algol/parc_FileOutputStream.h>
#include <parc/logging/parc_Log.h>
diff --git a/libparc/parc/algol/parc_EventSignal.c b/libparc/parc/algol/parc_EventSignal.c
index 7bb094bd..7bb094bd 100755..100644
--- a/libparc/parc/algol/parc_EventSignal.c
+++ b/libparc/parc/algol/parc_EventSignal.c
diff --git a/libparc/parc/algol/parc_EventSignal.h b/libparc/parc/algol/parc_EventSignal.h
index e289f506..e289f506 100755..100644
--- a/libparc/parc/algol/parc_EventSignal.h
+++ b/libparc/parc/algol/parc_EventSignal.h
diff --git a/libparc/parc/algol/parc_EventSocket.c b/libparc/parc/algol/parc_EventSocket.c
index 62aa10bc..c44c824a 100755..100644
--- a/libparc/parc/algol/parc_EventSocket.c
+++ b/libparc/parc/algol/parc_EventSocket.c
@@ -35,7 +35,10 @@ static int _parc_event_socket_debug_enabled = 0;
* Current implementation based on top of libevent2
*/
+#ifndef _WIN32
#include <sys/errno.h>
+#endif
+
#include <event2/listener.h>
/**
@@ -71,7 +74,7 @@ _parc_evconn_error_callback(struct evconnlistener *listener, void *ctx)
PARCEventSocket *parcEventSocket = (PARCEventSocket *) ctx;
int error = EVUTIL_SOCKET_ERROR();
- char *errorString = evutil_socket_error_to_string(error);
+ char *errorString = (char *)evutil_socket_error_to_string(error);
parcEventSocket_LogDebug(parcEventSocket,
"_parc_evconn_error_callback(error=%d,errorString=%s,parcEventSocket=%p)\n",
error, errorString, parcEventSocket);
diff --git a/libparc/parc/algol/parc_EventSocket.h b/libparc/parc/algol/parc_EventSocket.h
index 48a11b25..286e528d 100755..100644
--- a/libparc/parc/algol/parc_EventSocket.h
+++ b/libparc/parc/algol/parc_EventSocket.h
@@ -27,8 +27,11 @@
#ifndef libparc_parc_EventSocket_h
#define libparc_parc_EventSocket_h
-#include <sys/types.h>
+#ifndef _WIN32
#include <sys/socket.h>
+#endif
+
+#include <sys/types.h>
/**
* Current implementation based on top of libevent2
diff --git a/libparc/parc/algol/parc_EventTimer.c b/libparc/parc/algol/parc_EventTimer.c
index 82f731b1..82f731b1 100755..100644
--- a/libparc/parc/algol/parc_EventTimer.c
+++ b/libparc/parc/algol/parc_EventTimer.c
diff --git a/libparc/parc/algol/parc_EventTimer.h b/libparc/parc/algol/parc_EventTimer.h
index 4a960853..4a960853 100755..100644
--- a/libparc/parc/algol/parc_EventTimer.h
+++ b/libparc/parc/algol/parc_EventTimer.h
diff --git a/libparc/parc/algol/parc_File.c b/libparc/parc/algol/parc_File.c
index 353ffcca..f39a31af 100644
--- a/libparc/parc/algol/parc_File.c
+++ b/libparc/parc/algol/parc_File.c
@@ -25,20 +25,21 @@
#define __USE_XOPEN_EXTENDED
#endif //__USE_XOPEN_EXTENDED
-#include <stdio.h>
+#ifndef _WIN32
#include <unistd.h>
+#include <ftw.h>
+#endif
+
+#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
-
-#include <ftw.h>
#include <inttypes.h>
#include <pthread.h>
#include <string.h>
#include <errno.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_PathName.h>
#include <parc/algol/parc_File.h>
@@ -134,7 +135,13 @@ parcFile_Mkdir(const PARCFile *file)
parcFile_OptionalAssertValid(file);
char *string = parcPathName_ToString(file->pathName);
+
+#ifndef _WIN32
bool result = (mkdir(string, 0777) == 0);
+#else
+ bool result = (CreateDirectory(string, NULL) == 0);
+#endif
+
parcMemory_Deallocate((void **) &string);
return result;
@@ -167,6 +174,7 @@ parcFile_IsDirectory(const PARCFile *file)
return result;
}
+#ifndef _WIN32
static int
_deleteNode(const char *path, const struct stat *stat, int flag, struct FTW *ftwbuf)
{
@@ -179,6 +187,7 @@ _deleteNode(const char *path, const struct stat *stat, int flag, struct FTW *ftw
}
return result;
}
+#endif
/**
* @function parcFile_Delete
@@ -201,16 +210,21 @@ parcFile_Delete(const PARCFile *file)
bool result = false;
if (parcFile_IsDirectory(file)) {
- // depth first, dont't follow symlinks, do not cross mount points.
- int flags = FTW_DEPTH | FTW_PHYS | FTW_MOUNT;
- // maximum 20 fds open at a time
- int maximumFileDescriptors = 20;
+#ifndef _WIN32
+ // depth first, dont't follow symlinks, do not cross mount points.
+ int flags = FTW_DEPTH | FTW_PHYS | FTW_MOUNT;
+ // maximum 20 fds open at a time
+ int maximumFileDescriptors = 20;
+
+ int failure = nftw(string, _deleteNode, maximumFileDescriptors, flags);
+ parcAssertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno));
- int failure = nftw(string, _deleteNode, maximumFileDescriptors, flags);
- parcAssertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno));
+ result = failure == false;
+#else
+ result = RemoveDirectoryA(string);
+#endif
- result = failure == false;
} else {
result = (unlink(string) == 0);
}
diff --git a/libparc/parc/algol/parc_File.h b/libparc/parc/algol/parc_File.h
index 42ef232e..42ef232e 100755..100644
--- a/libparc/parc/algol/parc_File.h
+++ b/libparc/parc/algol/parc_File.h
diff --git a/libparc/parc/algol/parc_FileChunker.c b/libparc/parc/algol/parc_FileChunker.c
index d7acd58e..0af63e15 100644
--- a/libparc/parc/algol/parc_FileChunker.c
+++ b/libparc/parc/algol/parc_FileChunker.c
@@ -16,18 +16,17 @@
/**
*/
+#ifndef _WIN32
#include <config.h>
+#endif
#include <stdio.h>
#include <string.h>
-#include <sys/time.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Buffer.h>
#include <parc/algol/parc_Memory.h>
-
#include <parc/algol/parc_RandomAccessFile.h>
-
#include <parc/algol/parc_FileChunker.h>
PARCChunkerInterface *PARCFileChunkerAsChunker = &(PARCChunkerInterface) {
@@ -174,7 +173,7 @@ _parcChunker_NextFromBuffer(PARCFileChunker *chunker, _ChunkerState *state)
{
size_t chunkSize = state->nextChunkSize;
- parcRandomAccessFile_Seek(chunker->fhandle, state->position, PARCRandomAccessFilePosition_Start);
+ parcRandomAccessFile_Seek(chunker->fhandle, (long)(state->position), PARCRandomAccessFilePosition_Start);
PARCBuffer *slice = parcBuffer_Allocate(chunkSize);
parcRandomAccessFile_Read(chunker->fhandle, slice);
diff --git a/libparc/parc/algol/parc_FileChunker.h b/libparc/parc/algol/parc_FileChunker.h
index 6ab0d267..6ab0d267 100755..100644
--- a/libparc/parc/algol/parc_FileChunker.h
+++ b/libparc/parc/algol/parc_FileChunker.h
diff --git a/libparc/parc/algol/parc_FileInputStream.c b/libparc/parc/algol/parc_FileInputStream.c
index 186d07b5..0ccd912d 100755..100644
--- a/libparc/parc/algol/parc_FileInputStream.c
+++ b/libparc/parc/algol/parc_FileInputStream.c
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
+#ifndef _WIN32
+#include <sys/uio.h>
+#include <unistd.h>
+#endif
+#include <config.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/types.h>
-#include <sys/uio.h>
-#include <unistd.h>
#include <sys/stat.h>
#include <parc/assert/parc_Assert.h>
@@ -88,7 +88,7 @@ parcFileInputStream_Read(PARCFileInputStream *inputStream, PARCBuffer *buffer)
{
while (parcBuffer_HasRemaining(buffer)) {
void *buf = parcBuffer_Overlay(buffer, 0);
- ssize_t nread = read(inputStream->fd, buf, parcBuffer_Remaining(buffer));
+ ssize_t nread = read(inputStream->fd, buf, (unsigned int)parcBuffer_Remaining(buffer));
if (nread < 0) {
break;
}
diff --git a/libparc/parc/algol/parc_FileInputStream.h b/libparc/parc/algol/parc_FileInputStream.h
index f7f7987a..f7f7987a 100755..100644
--- a/libparc/parc/algol/parc_FileInputStream.h
+++ b/libparc/parc/algol/parc_FileInputStream.h
diff --git a/libparc/parc/algol/parc_FileOutputStream.c b/libparc/parc/algol/parc_FileOutputStream.c
index 3e5c8cd6..c119e67f 100755..100644
--- a/libparc/parc/algol/parc_FileOutputStream.c
+++ b/libparc/parc/algol/parc_FileOutputStream.c
@@ -13,15 +13,14 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <stdio.h>
-#include <unistd.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_FileOutputStream.h>
#include <parc/algol/parc_Object.h>
@@ -75,7 +74,7 @@ parcFileOutputStream_Write(PARCFileOutputStream *outputStream, PARCBuffer *buffe
size_t remaining = parcBuffer_Remaining(buffer);
size_t chunkSize = remaining > maximumChunkSize ? maximumChunkSize : remaining;
void *buf = parcBuffer_Overlay(buffer, chunkSize);
- ssize_t nwritten = write(outputStream->fd, buf, chunkSize);
+ ssize_t nwritten = write(outputStream->fd, buf, (unsigned int)chunkSize);
if (nwritten == -1) {
break;
}
diff --git a/libparc/parc/algol/parc_Hash.c b/libparc/parc/algol/parc_Hash.c
index 1884c74c..fae29a63 100755..100644
--- a/libparc/parc/algol/parc_Hash.c
+++ b/libparc/parc/algol/parc_Hash.c
@@ -18,11 +18,13 @@
* website for details on the algorithm: http://www.isthe.com/chongo/tech/comp/fnv
*
*/
-#include <config.h>
-#include <stdint.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
+#include <config.h>
+#include <stdint.h>
#include <parc/algol/parc_Hash.h>
#include <parc/algol/parc_Object.h>
diff --git a/libparc/parc/algol/parc_Hash.h b/libparc/parc/algol/parc_Hash.h
index 92227041..92227041 100755..100644
--- a/libparc/parc/algol/parc_Hash.h
+++ b/libparc/parc/algol/parc_Hash.h
diff --git a/libparc/parc/algol/parc_HashCode.c b/libparc/parc/algol/parc_HashCode.c
index 8554429c..8554429c 100755..100644
--- a/libparc/parc/algol/parc_HashCode.c
+++ b/libparc/parc/algol/parc_HashCode.c
diff --git a/libparc/parc/algol/parc_HashCode.h b/libparc/parc/algol/parc_HashCode.h
index dd572bee..dd572bee 100755..100644
--- a/libparc/parc/algol/parc_HashCode.h
+++ b/libparc/parc/algol/parc_HashCode.h
diff --git a/libparc/parc/algol/parc_HashCodeTable.c b/libparc/parc/algol/parc_HashCodeTable.c
index 9531e312..d4c5a7ae 100755..100644
--- a/libparc/parc/algol/parc_HashCodeTable.c
+++ b/libparc/parc/algol/parc_HashCodeTable.c
@@ -165,7 +165,7 @@ _rehash(LinearAddressingHashTable *old_table, LinearAddressingHashTable *new_tab
}
static void
-_expand(PARCHashCodeTable *hashCodeTable)
+_expandTable(PARCHashCodeTable *hashCodeTable)
{
LinearAddressingHashTable temp_table;
LinearAddressingHashTable *old_table = &hashCodeTable->hashtable;
@@ -269,7 +269,7 @@ parcHashCodeTable_Add(PARCHashCodeTable *table, void *key, void *data)
parcAssertNotNull(data, "Parameter data must be non-null");
if (table->hashtable.tableSize >= table->hashtable.expandThreshold) {
- _expand(table);
+ _expandTable(table);
}
HashCodeType hashcode = table->keyHashCodeFunc(key);
@@ -278,7 +278,7 @@ parcHashCodeTable_Add(PARCHashCodeTable *table, void *key, void *data)
do {
result = _innerTableAdd(&table->hashtable, table->keyEqualsFunc, hashcode, key, data);
if (result == ADD_NOSPACE) {
- _expand(table);
+ _expandTable(table);
}
} while (result == ADD_NOSPACE);
diff --git a/libparc/parc/algol/parc_HashMap.c b/libparc/parc/algol/parc_HashMap.c
index 5e73a4c3..58137b20 100644
--- a/libparc/parc/algol/parc_HashMap.c
+++ b/libparc/parc/algol/parc_HashMap.c
@@ -91,7 +91,7 @@ _parcHashMap_GetEntry(const PARCHashMap *hashMap, const PARCObject *key)
{
PARCHashCode keyHash = parcObject_HashCode(key);
- int bucket = keyHash % hashMap->capacity;
+ int bucket = (int)(keyHash % hashMap->capacity);
_PARCHashMapEntry *result = NULL;
@@ -399,7 +399,7 @@ _parcHashMap_Resize(PARCHashMap *hashMap, size_t newCapacity)
while (parcIterator_HasNext(elementIt)) {
_PARCHashMapEntry *entry = parcIterator_Next(elementIt);
PARCHashCode keyHash = parcObject_HashCode(entry->key);
- int newBucket = keyHash % newCapacity;
+ int newBucket = (int)(keyHash % newCapacity);
if (newBuckets[newBucket] == NULL) {
newBuckets[newBucket] = parcLinkedList_Create();
}
@@ -422,7 +422,7 @@ parcHashMap_Remove(PARCHashMap *hashMap, const PARCObject *key)
{
PARCHashCode keyHash = parcObject_HashCode(key);
- int bucket = keyHash % hashMap->capacity;
+ int bucket = (int)(keyHash % hashMap->capacity);
bool result = false;
@@ -476,7 +476,7 @@ parcHashMap_Put(PARCHashMap *hashMap, const PARCObject *key, const PARCObject *v
entry = _parcHashMapEntry_Create(key, value);
PARCHashCode keyHash = parcObject_HashCode(key);
- int bucket = keyHash % hashMap->capacity;
+ int bucket = (int)(keyHash % hashMap->capacity);
if (hashMap->buckets[bucket] == NULL) {
hashMap->buckets[bucket] = parcLinkedList_Create();
@@ -560,7 +560,7 @@ _parcHashMap_Init(PARCHashMap *map __attribute__((unused)))
state->listIterator = NULL;
for (size_t i = 0; i < map->capacity; ++i) {
if (map->buckets[i] != NULL) {
- state->bucket = i;
+ state->bucket = (int)i;
state->listIterator = parcLinkedList_CreateIterator(map->buckets[i]);
break;
}
diff --git a/libparc/parc/algol/parc_HashMap.h b/libparc/parc/algol/parc_HashMap.h
index 3ab26cd9..3ab26cd9 100755..100644
--- a/libparc/parc/algol/parc_HashMap.h
+++ b/libparc/parc/algol/parc_HashMap.h
diff --git a/libparc/parc/algol/parc_InputStream.c b/libparc/parc/algol/parc_InputStream.c
index ade5a46a..ade5a46a 100755..100644
--- a/libparc/parc/algol/parc_InputStream.c
+++ b/libparc/parc/algol/parc_InputStream.c
diff --git a/libparc/parc/algol/parc_InputStream.h b/libparc/parc/algol/parc_InputStream.h
index 3ab6849a..3ab6849a 100755..100644
--- a/libparc/parc/algol/parc_InputStream.h
+++ b/libparc/parc/algol/parc_InputStream.h
diff --git a/libparc/parc/algol/parc_Iterator.c b/libparc/parc/algol/parc_Iterator.c
index 5ef67bf4..5ef67bf4 100755..100644
--- a/libparc/parc/algol/parc_Iterator.c
+++ b/libparc/parc/algol/parc_Iterator.c
diff --git a/libparc/parc/algol/parc_JSON.c b/libparc/parc/algol/parc_JSON.c
index f69396d2..f69396d2 100755..100644
--- a/libparc/parc/algol/parc_JSON.c
+++ b/libparc/parc/algol/parc_JSON.c
diff --git a/libparc/parc/algol/parc_JSON.h b/libparc/parc/algol/parc_JSON.h
index dc8996ca..dc8996ca 100755..100644
--- a/libparc/parc/algol/parc_JSON.h
+++ b/libparc/parc/algol/parc_JSON.h
diff --git a/libparc/parc/algol/parc_JSONArray.c b/libparc/parc/algol/parc_JSONArray.c
index a92e6422..a92e6422 100755..100644
--- a/libparc/parc/algol/parc_JSONArray.c
+++ b/libparc/parc/algol/parc_JSONArray.c
diff --git a/libparc/parc/algol/parc_JSONArray.h b/libparc/parc/algol/parc_JSONArray.h
index 7b322867..7b322867 100755..100644
--- a/libparc/parc/algol/parc_JSONArray.h
+++ b/libparc/parc/algol/parc_JSONArray.h
diff --git a/libparc/parc/algol/parc_JSONPair.c b/libparc/parc/algol/parc_JSONPair.c
index 11676523..11676523 100755..100644
--- a/libparc/parc/algol/parc_JSONPair.c
+++ b/libparc/parc/algol/parc_JSONPair.c
diff --git a/libparc/parc/algol/parc_JSONPair.h b/libparc/parc/algol/parc_JSONPair.h
index dff8485b..dff8485b 100755..100644
--- a/libparc/parc/algol/parc_JSONPair.h
+++ b/libparc/parc/algol/parc_JSONPair.h
diff --git a/libparc/parc/algol/parc_JSONParser.c b/libparc/parc/algol/parc_JSONParser.c
index a8a0510b..a8a0510b 100755..100644
--- a/libparc/parc/algol/parc_JSONParser.c
+++ b/libparc/parc/algol/parc_JSONParser.c
diff --git a/libparc/parc/algol/parc_JSONParser.h b/libparc/parc/algol/parc_JSONParser.h
index 425a2427..425a2427 100755..100644
--- a/libparc/parc/algol/parc_JSONParser.h
+++ b/libparc/parc/algol/parc_JSONParser.h
diff --git a/libparc/parc/algol/parc_JSONValue.c b/libparc/parc/algol/parc_JSONValue.c
index f5aff0b4..8b9af28d 100755..100644
--- a/libparc/parc/algol/parc_JSONValue.c
+++ b/libparc/parc/algol/parc_JSONValue.c
@@ -757,7 +757,7 @@ parcJSONValue_GetBoolean(const PARCJSONValue *value)
static long double
_parcJSONValue_GetNumber(const PARCJSONValue *value)
{
- long double fraction = value->value.number.fraction / powl(10.0, value->value.number.fractionLog10);
+ long double fraction = (long double)value->value.number.fraction / (long double)powl(10.0, (long double) value->value.number.fractionLog10);
long double number = (long double) value->value.number.sign * ((long double) value->value.number.whole + fraction);
long double result = number * powl(10.0, (long double) value->value.number.exponent);
@@ -815,7 +815,7 @@ parcJSONValue_GetTimeval(const PARCJSONValue *jsonTimeval, struct timeval *timev
PARCJSON *json = parcJSONValue_GetJSON(jsonTimeval);
PARCJSONValue *value = parcJSON_GetValueByName(json, "seconds");
- timeval->tv_sec = parcJSONValue_GetInteger(value);
+ timeval->tv_sec = (long)parcJSONValue_GetInteger(value);
value = parcJSON_GetValueByName(json, "micros");
timeval->tv_usec = (int) parcJSONValue_GetInteger(value);
diff --git a/libparc/parc/algol/parc_JSONValue.h b/libparc/parc/algol/parc_JSONValue.h
index 0f93b2bc..0f93b2bc 100755..100644
--- a/libparc/parc/algol/parc_JSONValue.h
+++ b/libparc/parc/algol/parc_JSONValue.h
diff --git a/libparc/parc/algol/parc_KeyValue.c b/libparc/parc/algol/parc_KeyValue.c
index 352bf3e8..352bf3e8 100755..100644
--- a/libparc/parc/algol/parc_KeyValue.c
+++ b/libparc/parc/algol/parc_KeyValue.c
diff --git a/libparc/parc/algol/parc_KeyValue.h b/libparc/parc/algol/parc_KeyValue.h
index a4bc3915..a4bc3915 100755..100644
--- a/libparc/parc/algol/parc_KeyValue.h
+++ b/libparc/parc/algol/parc_KeyValue.h
diff --git a/libparc/parc/algol/parc_KeyedElement.c b/libparc/parc/algol/parc_KeyedElement.c
index 265987cd..265987cd 100755..100644
--- a/libparc/parc/algol/parc_KeyedElement.c
+++ b/libparc/parc/algol/parc_KeyedElement.c
diff --git a/libparc/parc/algol/parc_KeyedElement.h b/libparc/parc/algol/parc_KeyedElement.h
index e794360f..e794360f 100755..100644
--- a/libparc/parc/algol/parc_KeyedElement.h
+++ b/libparc/parc/algol/parc_KeyedElement.h
diff --git a/libparc/parc/algol/parc_LinkedList.c b/libparc/parc/algol/parc_LinkedList.c
index b5bbd0a6..4b0dd17e 100644
--- a/libparc/parc/algol/parc_LinkedList.c
+++ b/libparc/parc/algol/parc_LinkedList.c
@@ -13,17 +13,15 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <sys/queue.h>
+#endif
+#include <config.h>
#include <stdio.h>
-#include <sys/queue.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_LinkedList.h>
-
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
diff --git a/libparc/parc/algol/parc_LinkedList.h b/libparc/parc/algol/parc_LinkedList.h
index 381e2a18..fbf46ac9 100644
--- a/libparc/parc/algol/parc_LinkedList.h
+++ b/libparc/parc/algol/parc_LinkedList.h
@@ -499,7 +499,7 @@ bool parcLinkedList_Equals(const PARCLinkedList *x, const PARCLinkedList *y);
* @endcode
*
*/
-void parcLinkedList_Display(const PARCLinkedList *list, int indentation);
+void parcLinkedList_Display(const PARCLinkedList *list, const int indentation);
/**
* Wakes up a single thread that is waiting on this object (see `parcLinkedList_Wait)`.
diff --git a/libparc/parc/algol/parc_List.c b/libparc/parc/algol/parc_List.c
index bdb343f8..fef3853e 100644
--- a/libparc/parc/algol/parc_List.c
+++ b/libparc/parc/algol/parc_List.c
@@ -101,7 +101,7 @@ parcList_Add(PARCList *list, void *element)
}
bool
-parcList_AddAll(PARCList *list, size_t argc, void *argv[argc])
+parcList_AddAll(PARCList *list, size_t argc, void **argv)
{
for (int i = 0; i < argc; i++) {
(list->interface->Add)(list->instance, argv[i]);
@@ -166,7 +166,7 @@ parcList_GetAtIndex(const PARCList *list, size_t index)
int
parcList_HashCode(const PARCList *list)
{
- return (list->interface->HashCode)(list->instance);
+ return (int)(list->interface->HashCode)(list->instance);
}
ssize_t
@@ -177,7 +177,7 @@ parcList_IndexOf(const PARCList *list, PARCObject *element)
if (list->interface->IndexOf) {
result = (list->interface->IndexOf)(list->instance, element);
} else {
- for (ssize_t i = 0; i < parcList_Size(list); i++) {
+ for (size_t i = 0; i < parcList_Size(list); i++) {
PARCObject *e = parcList_GetAtIndex(list, i);
if (parcObject_Equals(e, element)) {
result = i;
diff --git a/libparc/parc/algol/parc_Map.c b/libparc/parc/algol/parc_Map.c
index e5371c99..e5371c99 100755..100644
--- a/libparc/parc/algol/parc_Map.c
+++ b/libparc/parc/algol/parc_Map.c
diff --git a/libparc/parc/algol/parc_Map.h b/libparc/parc/algol/parc_Map.h
index c63b23c5..c63b23c5 100755..100644
--- a/libparc/parc/algol/parc_Map.h
+++ b/libparc/parc/algol/parc_Map.h
diff --git a/libparc/parc/algol/parc_Memory.c b/libparc/parc/algol/parc_Memory.c
index eebdadf0..6552a902 100755..100644
--- a/libparc/parc/algol/parc_Memory.c
+++ b/libparc/parc/algol/parc_Memory.c
@@ -13,21 +13,19 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <unistd.h>
+#endif
+
+#include <config.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
-
#include <stdint.h>
#include <stdbool.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_SafeMemory.h>
#include <parc/algol/parc_StdlibMemory.h>
@@ -93,6 +91,14 @@ parcMemory_DeallocateImpl(void **pointer)
((PARCMemoryDeallocate *) parcMemory->Deallocate)(pointer);
}
+#ifdef _WIN32
+void
+parcMemory_DeallocateAlignImpl(void **pointer)
+{
+ ((PARCMemoryDeallocateAlign *) parcMemory->DeallocateAlign)(pointer);
+}
+#endif
+
void *
parcMemory_Reallocate(void *pointer, size_t newSize)
{
@@ -138,6 +144,9 @@ PARCMemoryInterface PARCMemoryAsPARCMemory = {
.AllocateAndClear = (uintptr_t) parcMemory_AllocateAndClear,
.MemAlign = (uintptr_t) parcMemory_MemAlign,
.Deallocate = (uintptr_t) parcMemory_DeallocateImpl,
+#ifdef _WIN32
+ .DeallocateAlign = (uintptr_t)parcMemory_DeallocateAlignImpl,
+#endif
.Reallocate = (uintptr_t) parcMemory_Reallocate,
.StringDuplicate = (uintptr_t) parcMemory_StringDuplicate,
.Outstanding = (uintptr_t) parcMemory_Outstanding
diff --git a/libparc/parc/algol/parc_Memory.h b/libparc/parc/algol/parc_Memory.h
index fe3c4b5a..6e4a84e8 100644
--- a/libparc/parc/algol/parc_Memory.h
+++ b/libparc/parc/algol/parc_Memory.h
@@ -43,6 +43,10 @@ typedef int (PARCMemoryMemAlign)(void **pointer, size_t alignment, size_t size);
typedef void (PARCMemoryDeallocate)(void **pointer);
+#ifdef _WIN32
+typedef void (PARCMemoryDeallocateAlign)(void **pointer);
+#endif
+
typedef void *(PARCMemoryReallocate)(void *pointer, size_t newSize);
typedef char *(PARCMemoryStringDuplicate)(const char *string, size_t length);
@@ -121,6 +125,19 @@ typedef struct parc_memory_interface {
*/
uintptr_t Deallocate;
+#ifdef _WIN32
+ /**
+ * Deallocate memory previously Aligned allocated via `MemAlign`.
+ *
+ * @param [in,out] pointer A pointer to a `void *` pointer to the address of the allocated memory that will be set to zero.
+ *
+ * @see AllocateAndClear
+ * @see Allocate
+ * @see Reallocate
+ */
+ uintptr_t DeallocateAlign;
+#endif
+
/**
* Try to change the size of the allocation pointed to by @p pointer to @p newSize, and returns ptr.
* If there is not enough room to enlarge the memory allocation pointed to by @p pointer,
@@ -308,8 +325,35 @@ int parcMemory_MemAlign(void **pointer, const size_t alignment, const size_t siz
*/
void parcMemory_DeallocateImpl(void **pointer);
+#ifdef _WIN32
+/**
+ * Deallocate memory previously allocated via `MemAlign`.
+ *
+ * @param [in,out] pointer A pointer to a `void *` pointer to the address of the allocated memory that will be set to zero.
+ *
+ * Example:
+ * @code
+ * {
+ * void *allocatedMemory;
+ *
+ * allocatedMemory = parcMemory_Allocate(100);
+ * if (allocatedMemory == NULL) {
+ * // allocation failed
+ * }
+ * }
+ * @endcode
+ *
+ * @see parcMemory_MemAlign
+ */
+void parcMemory_DeallocateAlignImpl(void **pointer);
+#endif
+
#define parcMemory_Deallocate(_pointer_) parcMemory_DeallocateImpl((void **) _pointer_)
+#ifdef _WIN32
+#define parcMemory_DeallocateAlign(_pointer_) parcMemory_DeallocateAlignImpl((void **) _pointer_)
+#endif
+
/**
* Try to change the size of the allocation pointed to by @p pointer to @p newSize, and returns ptr.
* If there is not enough room to enlarge the memory allocation pointed to by @p pointer,
@@ -432,7 +476,7 @@ size_t parcMemory_RoundUpToCacheLine(const size_t size);
*
* @see parcMemory_RoundUpToCacheLine
*/
-size_t parcMemory_RoundUpToMultiple(size_t size, size_t multiple);
+size_t parcMemory_RoundUpToMultiple(const size_t size, const size_t multiple);
/**
* @def parcMemory_SafeFree
diff --git a/libparc/parc/algol/parc_Network.c b/libparc/parc/algol/parc_Network.c
index 2b6c8888..543a77b9 100644
--- a/libparc/parc/algol/parc_Network.c
+++ b/libparc/parc/algol/parc_Network.c
@@ -13,19 +13,16 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <sys/socket.h>
-#include <ctype.h>
-#include <sys/types.h>
#include <netdb.h>
+#endif
+#include <config.h>
+#include <ctype.h>
+#include <sys/types.h>
#include <parc/algol/parc_Network.h>
-
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_BufferComposer.h>
#include <parc/algol/parc_Buffer.h>
@@ -52,7 +49,7 @@ parcNetwork_SockAddress(const char *address, in_port_t port)
parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in));
if (result != NULL) {
parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in),
- "Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in), ai->ai_addrlen);
+ "Sockaddr wrong length, expected %zu got %zu", sizeof(struct sockaddr_in), ai->ai_addrlen);
memcpy(result, ai->ai_addr, ai->ai_addrlen);
result->sin_port = htons(port);
addr = (struct sockaddr *) result;
@@ -65,7 +62,7 @@ parcNetwork_SockAddress(const char *address, in_port_t port)
parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6));
if (result != NULL) {
parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in6),
- "Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in6), ai->ai_addrlen);
+ "Sockaddr wrong length, expected %zu got %zu", sizeof(struct sockaddr_in6), ai->ai_addrlen);
memcpy(result, ai->ai_addr, ai->ai_addrlen);
result->sin6_port = htons(port);
@@ -304,6 +301,7 @@ parcNetwork_ParseLinkAddress(const char *address)
}
parcTrapIllegalValue(address, "Bad scheme '%s'", address);
+ return NULL;
}
bool
@@ -370,9 +368,11 @@ parcNetwork_IsSocketLocal(struct sockaddr *sock)
bool isLocal = false;
switch (sock->sa_family) {
+#ifndef _WIN32
case PF_LOCAL:
isLocal = true;
break;
+#endif
case PF_INET:
isLocal = _isInet4Loopback((struct sockaddr_in *) sock);
diff --git a/libparc/parc/algol/parc_Network.h b/libparc/parc/algol/parc_Network.h
index bf7cfcbd..4b95138b 100644
--- a/libparc/parc/algol/parc_Network.h
+++ b/libparc/parc/algol/parc_Network.h
@@ -22,8 +22,10 @@
#ifndef libparc_parc_Networking_h
#define libparc_parc_Networking_h
+#ifndef _WIN32
#include <arpa/inet.h>
#include <netinet/in.h>
+#endif
#include <parc/algol/parc_BufferComposer.h>
#include <parc/algol/parc_Buffer.h>
diff --git a/libparc/parc/algol/parc_Object.c b/libparc/parc/algol/parc_Object.c
index 70a24f34..422a97f7 100644
--- a/libparc/parc/algol/parc_Object.c
+++ b/libparc/parc/algol/parc_Object.c
@@ -13,25 +13,23 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#endif
+#include <config.h>
#include <stdio.h>
#include <inttypes.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/errno.h>
#include <pthread.h>
#include <time.h>
-#include <sys/time.h>
-
#include <stdint.h>
#include <stdbool.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
@@ -364,7 +362,11 @@ parcObject_Acquire(const PARCObject *object)
_PARCObjectHeader *header = _parcObject_Header(object);
+#ifndef _WIN32
parcAtomicUint64_Increment(&header->references);
+#else
+ InterlockedIncrement((unsigned volatile *)(&header->references));
+#endif
return (PARCObject *) object;
}
@@ -528,7 +530,12 @@ _parcObject_InitializeLocking(_PARCObjectLocking *locking)
pthread_mutex_init(&locking->lock, &_parcObject_GlobalLockAttributes);
pthread_cond_init(&locking->notification, NULL);
- locking->locker = (pthread_t) NULL;
+#ifndef _WIN32
+ locking->locker = (pthread_t)NULL;
+#else
+ locking->locker = (pthread_t) { NULL, 0 };
+#endif
+
}
}
@@ -578,6 +585,8 @@ parcObject_CreateInstanceImpl(const PARCObjectDescriptor *descriptor)
size_t totalMemoryLength = prefixLength + descriptor->objectSize;
void *origin = NULL;
+
+ //origin = parcMemory_AllocateAndClear(totalMemoryLength);
parcMemory_MemAlign(&origin, sizeof(void *), totalMemoryLength);
if (origin == NULL) {
@@ -630,7 +639,11 @@ parcObject_Release(PARCObject **objectPointer)
parcTrapIllegalValueIf(header->references == 0, "PARCObject@%p references must be > 0", object);
+#ifndef _WIN32
PARCReferenceCount result = parcAtomicUint64_Decrement(&header->references);
+#else
+ PARCReferenceCount result = InterlockedDecrement((unsigned volatile *)(&header->references));
+#endif
if (result == 0) {
if (_parcObject_Destructor(header->descriptor, objectPointer)) {
@@ -639,7 +652,11 @@ parcObject_Release(PARCObject **objectPointer)
}
if (header->isAllocated) {
void *origin = _parcObject_Origin(object);
+#ifndef _WIN32
parcMemory_Deallocate(&origin);
+#else
+ parcMemory_DeallocateAlign(&origin);
+#endif
}
parcAssertNotNull(*objectPointer, "Class implementation unnecessarily clears the object pointer.");
} else {
@@ -770,7 +787,13 @@ parcObject_Unlock(const PARCObject *object)
if (object != NULL) {
_PARCObjectLocking *locking = _parcObjectHeader_Locking(object);
if (locking != NULL) {
- locking->locker = (pthread_t) NULL;
+
+#ifndef _WIN32
+ locking->locker = (pthread_t)NULL;
+#else
+ locking->locker = (pthread_t) { NULL, 0 };
+#endif
+
result = (pthread_mutex_unlock(&locking->lock) == 0);
parcAssertTrue(result, "Attempted to unlock an unowned lock.");
@@ -840,7 +863,11 @@ parcObject_IsLocked(const PARCObject *object)
_PARCObjectLocking *locking = _parcObjectHeader_Locking(object);
if (locking != NULL) {
- result = locking->locker != (pthread_t) NULL;
+#ifndef _WIN32
+ result = locking->locker != (pthread_t)NULL;
+#else
+ result = locking->locker.p != NULL;
+#endif
}
return result;
@@ -890,7 +917,7 @@ parcObject_WaitFor(const PARCObject *object, const uint64_t nanoSeconds)
.tv_sec = now.tv_sec,
.tv_nsec = (now.tv_usec * 1000)
};
- time.tv_nsec += nanoSeconds;
+ time.tv_nsec += (long)nanoSeconds;
time.tv_sec += time.tv_nsec / 1000000000;
time.tv_nsec = time.tv_nsec % 1000000000;
@@ -932,8 +959,11 @@ bool
parcObject_BarrierSet(const PARCObject *object)
{
_PARCObjectHeader *header = _parcObject_Header(object);
-
+#ifndef _WIN32
while (__sync_bool_compare_and_swap(&header->barrier, false, true) == false) {
+#else
+ while (InterlockedCompareExchange((unsigned volatile *)&header->barrier, false, true) != header->barrier) {
+#endif
;
}
return true;
@@ -944,7 +974,12 @@ parcObject_BarrierUnset(const PARCObject *object)
{
_PARCObjectHeader *header = _parcObject_Header(object);
+#ifndef _WIN32
while (__sync_bool_compare_and_swap(&header->barrier, true, false) == false) {
+#else
+ while (InterlockedCompareExchange((unsigned volatile *)&header->barrier, true, false) != header->barrier) {
+#endif
+
;
}
diff --git a/libparc/parc/algol/parc_Object.h b/libparc/parc/algol/parc_Object.h
index ac7e9652..ba9392a4 100644
--- a/libparc/parc/algol/parc_Object.h
+++ b/libparc/parc/algol/parc_Object.h
@@ -623,7 +623,7 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P
}; \
_Pragma("GCC diagnostic pop") \
const PARCObjectDescriptor parcObject_DescriptorName(_subtype)
-#else
+#elif defined(__GNUC__)
#define parcObject_Extends(_subtype, _superType, ...) \
_Pragma("GCC diagnostic ignored \"-Woverride-init\"") \
parcObjectDescriptor_Declaration(_subtype) = { \
@@ -647,7 +647,29 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P
}; \
_Pragma("GCC diagnostic warning \"-Woverride-init\"") \
const PARCObjectDescriptor parcObject_DescriptorName(_subtype)
-#endif
+#else
+#define parcObject_Extends(_subtype, _superType, ...) \
+ parcObjectDescriptor_Declaration(_subtype) = { \
+ .super = &parcObject_DescriptorName(_superType), \
+ .name = #_subtype, \
+ .objectSize = 0, \
+ .objectAlignment = 0, \
+ .destroy = NULL, \
+ .destructor = NULL, \
+ .release = NULL, \
+ .copy = NULL, \
+ .toString = NULL, \
+ .equals = NULL, \
+ .compare = NULL, \
+ .hashCode = NULL, \
+ .toJSON = NULL, \
+ .display = NULL, \
+ .isLockable = true, \
+ .typeState = NULL, \
+ __VA_ARGS__ \
+ }; \
+ const PARCObjectDescriptor parcObject_DescriptorName(_subtype)
+#endif
/**
* Define a new PARC Object implementation, by composing a new PARC Object Descriptor referencing an old one.
diff --git a/libparc/parc/algol/parc_OldSortedList.c b/libparc/parc/algol/parc_OldSortedList.c
index c50d856d..c50d856d 100755..100644
--- a/libparc/parc/algol/parc_OldSortedList.c
+++ b/libparc/parc/algol/parc_OldSortedList.c
diff --git a/libparc/parc/algol/parc_OldSortedList.h b/libparc/parc/algol/parc_OldSortedList.h
index 2a00a0fa..2a00a0fa 100755..100644
--- a/libparc/parc/algol/parc_OldSortedList.h
+++ b/libparc/parc/algol/parc_OldSortedList.h
diff --git a/libparc/parc/algol/parc_OutputStream.c b/libparc/parc/algol/parc_OutputStream.c
index d00c1f09..d00c1f09 100755..100644
--- a/libparc/parc/algol/parc_OutputStream.c
+++ b/libparc/parc/algol/parc_OutputStream.c
diff --git a/libparc/parc/algol/parc_OutputStream.h b/libparc/parc/algol/parc_OutputStream.h
index db0ba343..db0ba343 100755..100644
--- a/libparc/parc/algol/parc_OutputStream.h
+++ b/libparc/parc/algol/parc_OutputStream.h
diff --git a/libparc/parc/algol/parc_PathName.c b/libparc/parc/algol/parc_PathName.c
index 56e57d27..ec6b2a5b 100755..100644
--- a/libparc/parc/algol/parc_PathName.c
+++ b/libparc/parc/algol/parc_PathName.c
@@ -13,19 +13,16 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
-
#include <parc/algol/parc_Deque.h>
-
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Memory.h>
@@ -80,7 +77,7 @@ parcObject_ExtendPARCObject(PARCPathName, _destroy, parcPathName_Copy, parcPathN
parcPathName_Equals, NULL, NULL, NULL);
PARCPathName *
-parcPathName_ParseToLimit(size_t limit, const char path[limit])
+parcPathName_ParseToLimit(size_t limit, const char *path)
{
PARCPathName *result = parcPathName_Create();
diff --git a/libparc/parc/algol/parc_PriorityQueue.c b/libparc/parc/algol/parc_PriorityQueue.c
index c6c003b1..6fea804b 100755..100644
--- a/libparc/parc/algol/parc_PriorityQueue.c
+++ b/libparc/parc/algol/parc_PriorityQueue.c
@@ -251,7 +251,7 @@ _bubbleUp(PARCPriorityQueue *queue, size_t elementIndex)
* @endcode
*/
static void
-_expand(PARCPriorityQueue *queue)
+_expandTable(PARCPriorityQueue *queue)
{
queue->capacity *= 2;
queue->array = parcMemory_Reallocate(queue->array, sizeof(HeapEntry) * queue->capacity);
@@ -320,7 +320,7 @@ parcPriorityQueue_Add(PARCPriorityQueue *queue, void *data)
parcAssertNotNull(data, "Parameter data must be non-null");
if (queue->size + 1 > queue->capacity) {
- _expand(queue);
+ _expandTable(queue);
}
// insert at the end of the array
diff --git a/libparc/parc/algol/parc_PriorityQueue.h b/libparc/parc/algol/parc_PriorityQueue.h
index 45a6ffab..45a6ffab 100755..100644
--- a/libparc/parc/algol/parc_PriorityQueue.h
+++ b/libparc/parc/algol/parc_PriorityQueue.h
diff --git a/libparc/parc/algol/parc_Properties.c b/libparc/parc/algol/parc_Properties.c
index 2a6c7d33..623128a0 100644
--- a/libparc/parc/algol/parc_Properties.c
+++ b/libparc/parc/algol/parc_Properties.c
@@ -222,7 +222,7 @@ parcProperties_SetProperty(PARCProperties *properties, const char *name, const c
}
const char *
-parcProperties_GetProperty(const PARCProperties *properties, const char *name)
+parcProperties_GetProperty(const PARCProperties *properties, const char *restrict name)
{
char *result = NULL;
diff --git a/libparc/parc/algol/parc_RandomAccessFile.c b/libparc/parc/algol/parc_RandomAccessFile.c
index 9a5e7914..9a5e7914 100755..100644
--- a/libparc/parc/algol/parc_RandomAccessFile.c
+++ b/libparc/parc/algol/parc_RandomAccessFile.c
diff --git a/libparc/parc/algol/parc_RandomAccessFile.h b/libparc/parc/algol/parc_RandomAccessFile.h
index f4f20150..f4f20150 100755..100644
--- a/libparc/parc/algol/parc_RandomAccessFile.h
+++ b/libparc/parc/algol/parc_RandomAccessFile.h
diff --git a/libparc/parc/algol/parc_ReadOnlyBuffer.c b/libparc/parc/algol/parc_ReadOnlyBuffer.c
index 25628ae8..25628ae8 100755..100644
--- a/libparc/parc/algol/parc_ReadOnlyBuffer.c
+++ b/libparc/parc/algol/parc_ReadOnlyBuffer.c
diff --git a/libparc/parc/algol/parc_SafeMemory.c b/libparc/parc/algol/parc_SafeMemory.c
index 76908548..337dfb5f 100644
--- a/libparc/parc/algol/parc_SafeMemory.c
+++ b/libparc/parc/algol/parc_SafeMemory.c
@@ -62,14 +62,16 @@
# include <execinfo.h>
#endif
+#ifndef _WIN32
#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/queue.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include <sys/errno.h>
-#include <sys/queue.h>
#include <pthread.h>
-
#include <stdint.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -565,7 +567,7 @@ parcSafeMemory_IsValid(const void *memory)
{
bool result = true;
- PARCSafeMemoryState state = _parcSafeMemory_GetState(memory);
+ PARCSafeMemoryState state = _parcSafeMemory_GetState((const PARCSafeMemoryUsable *)memory);
if (state != PARCSafeMemoryState_OK) {
return false;
}
@@ -629,12 +631,12 @@ parcSafeMemory_Display(const void *memory, int indentation)
if (memory == NULL) {
parcDisplayIndented_PrintLine(indentation, "PARCSafeMemory@NULL");
} else {
- _MemoryPrefix *prefix = _parcSafeMemory_GetPrefix(memory);
+ _MemoryPrefix *prefix = _parcSafeMemory_GetPrefix((const PARCSafeMemoryUsable *)memory);
parcDisplayIndented_PrintLine(indentation, "PARCSafeMemory@%p {", (void *) memory);
parcDisplayIndented_PrintLine(indentation + 1,
"%p=[ magic=0x%" PRIx64 " requestedLength=%zd, actualLength=%zd, alignment=%zd, guard=0x%" PRIx64 "]",
- _parcSafeMemory_GetOrigin(memory),
+ _parcSafeMemory_GetOrigin((const PARCSafeMemoryUsable *)memory),
prefix->magic,
prefix->requestedLength,
prefix->actualLength,
diff --git a/libparc/parc/algol/parc_Stack.c b/libparc/parc/algol/parc_Stack.c
index 72cae53c..72cae53c 100755..100644
--- a/libparc/parc/algol/parc_Stack.c
+++ b/libparc/parc/algol/parc_Stack.c
diff --git a/libparc/parc/algol/parc_Stack.h b/libparc/parc/algol/parc_Stack.h
index e64e02f4..e64e02f4 100755..100644
--- a/libparc/parc/algol/parc_Stack.h
+++ b/libparc/parc/algol/parc_Stack.h
diff --git a/libparc/parc/algol/parc_StdlibMemory.c b/libparc/parc/algol/parc_StdlibMemory.c
index 11381a54..536823d0 100755..100644
--- a/libparc/parc/algol/parc_StdlibMemory.c
+++ b/libparc/parc/algol/parc_StdlibMemory.c
@@ -13,20 +13,18 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
+#ifndef _WIN32
+#include <sys/errno.h>
+#endif
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
-#include <sys/errno.h>
#include <stdbool.h>
#include <string.h>
-#include <strings.h>
#include <pthread.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_StdlibMemory.h>
static uint32_t _parcStdlibMemory_OutstandingAllocations;
@@ -114,14 +112,23 @@ parcStdlibMemory_MemAlign(void **pointer, size_t alignment, size_t size)
return EINVAL;
}
+#ifndef _WIN32
int failure = posix_memalign(pointer, alignment, size);
if (failure != 0) {
return failure;
}
+
if (*pointer == NULL) {
return ENOMEM;
}
+#else
+ *pointer= _aligned_malloc(size, alignment);
+
+ if (*pointer == NULL) {
+ return errno;
+ }
+#endif
_parcStdlibMemory_IncrementOutstandingAllocations();
@@ -141,6 +148,22 @@ parcStdlibMemory_Deallocate(void **pointer)
_parcStdlibMemory_DecrementOutstandingAllocations();
}
+#ifdef _WIN32
+void
+parcStdlibMemory_DeallocateAlign(void **pointer)
+{
+#ifndef PARCLibrary_DISABLE_VALIDATION
+ parcTrapIllegalValueIf(_parcStdlibMemory_OutstandingAllocations == 0,
+ "parcStdlibMemory_DeallocateAlign invoked with nothing left to free (double free somewhere?)\n");
+#endif
+ _aligned_free(*pointer);
+ *pointer = NULL;
+
+ _parcStdlibMemory_DecrementOutstandingAllocations();
+}
+
+#endif
+
void *
parcStdlibMemory_Reallocate(void *pointer, size_t newSize)
{
@@ -174,6 +197,9 @@ PARCMemoryInterface PARCStdlibMemoryAsPARCMemory = {
.AllocateAndClear = (uintptr_t) parcStdlibMemory_AllocateAndClear,
.MemAlign = (uintptr_t) parcStdlibMemory_MemAlign,
.Deallocate = (uintptr_t) parcStdlibMemory_Deallocate,
+#ifdef _WIN32
+ .DeallocateAlign = (uintptr_t) parcStdlibMemory_DeallocateAlign,
+#endif
.Reallocate = (uintptr_t) parcStdlibMemory_Reallocate,
.StringDuplicate = (uintptr_t) parcStdlibMemory_StringDuplicate,
.Outstanding = (uintptr_t) parcStdlibMemory_Outstanding
diff --git a/libparc/parc/algol/parc_StdlibMemory.h b/libparc/parc/algol/parc_StdlibMemory.h
index 9abbf915..9ac135b2 100755..100644
--- a/libparc/parc/algol/parc_StdlibMemory.h
+++ b/libparc/parc/algol/parc_StdlibMemory.h
@@ -103,6 +103,20 @@ int parcStdlibMemory_MemAlign(void **pointer, size_t alignment, size_t size);
*/
void parcStdlibMemory_Deallocate(void **pointer);
+#ifdef _WIN32
+/**
+ * Deallocate the memory pointed to by @p pointer
+ *
+ * @param [in,out] pointer A pointer to a pointer to the memory to be deallocated
+ *
+ * Example:
+ * @code
+ * <#example#>
+ * @endcode
+ */
+void parcStdlibMemory_DeallocateAlign(void **pointer);
+#endif
+
/**
* Resizes previously allocated memory at @p pointer to @p newSize. If necessary,
* new memory is allocated and the content copied from the old memory to the
diff --git a/libparc/parc/algol/parc_String.c b/libparc/parc/algol/parc_String.c
index 78aaf470..78aaf470 100755..100644
--- a/libparc/parc/algol/parc_String.c
+++ b/libparc/parc/algol/parc_String.c
diff --git a/libparc/parc/algol/parc_Time.c b/libparc/parc/algol/parc_Time.c
index 07ab185b..8f292c1b 100755..100644
--- a/libparc/parc/algol/parc_Time.c
+++ b/libparc/parc/algol/parc_Time.c
@@ -13,17 +13,16 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+#include <config.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <sys/time.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Time.h>
#include <parc/algol/parc_Memory.h>
@@ -43,11 +42,20 @@ char *
parcTime_TimevalAsRFC3339(const struct timeval *utcTime, char result[64])
{
char tmbuf[64];
+ struct tm *nowtm;
+
+#ifndef _WIN32
+ struct tm theTime;
+ nowtm = gmtime_r(&utcTime->tv_sec, &theTime);
+#else
struct tm theTime;
+ __int64 ltime = utcTime->tv_sec;
+ int x = _gmtime64_s(&theTime, &ltime);
+ nowtm = &theTime;
+#endif
- struct tm *nowtm = gmtime_r(&utcTime->tv_sec, &theTime);
strftime(tmbuf, sizeof tmbuf, "%Y-%m-%dT%H:%M:%S", nowtm);
- snprintf(result, 64, "%s.%06ldZ", tmbuf, (long) utcTime->tv_usec);
+ snprintf(result, 64, "%s.%06ldZ", tmbuf, (long)utcTime->tv_usec);
return result;
}
@@ -57,7 +65,16 @@ parcTime_TimevalAsISO8601(const struct timeval *utcTime, char result[64])
char tmbuf[64];
struct tm theTime;
- struct tm *nowtm = gmtime_r(&utcTime->tv_sec, &theTime);
+ struct tm *nowtm;
+
+#ifndef _WIN32
+ nowtm = gmtime_r(&utcTime->tv_sec, &theTime);
+#else
+ __int64 ltime = utcTime->tv_sec;
+ _gmtime64_s(&theTime, &ltime);
+ nowtm = &theTime;
+#endif
+
strftime(tmbuf, sizeof tmbuf, "%Y-%m-%d %H:%M:%S", nowtm);
snprintf(result, 64, "%s.%06ldZ", tmbuf, (long) utcTime->tv_usec);
return result;
@@ -66,7 +83,7 @@ parcTime_TimevalAsISO8601(const struct timeval *utcTime, char result[64])
char *
parcTime_TimeAsRFC3339(const time_t utcTime, char result[64])
{
- struct timeval theTime = { utcTime, 0 };
+ struct timeval theTime = { (long)utcTime, 0 };
return parcTime_TimevalAsRFC3339(&theTime, result);
}
@@ -83,7 +100,7 @@ parcTime_NowAsRFC3339(char result[64])
char *
parcTime_TimeAsISO8601(const time_t utcTime, char result[64])
{
- struct timeval theTime = { utcTime, 0 };
+ struct timeval theTime = { (long)utcTime, 0 };
return parcTime_TimevalAsISO8601(&theTime, result);
}
diff --git a/libparc/parc/algol/parc_Time.h b/libparc/parc/algol/parc_Time.h
index 2a68144e..a04d02ae 100644
--- a/libparc/parc/algol/parc_Time.h
+++ b/libparc/parc/algol/parc_Time.h
@@ -26,7 +26,10 @@
#ifndef libparc_parc_Time_h
#define libparc_parc_Time_h
+#ifndef _WIN32
#include <sys/time.h>
+#endif
+
#include <stdint.h>
/**
diff --git a/libparc/parc/algol/parc_TreeMap.c b/libparc/parc/algol/parc_TreeMap.c
index 9922829b..9922829b 100755..100644
--- a/libparc/parc/algol/parc_TreeMap.c
+++ b/libparc/parc/algol/parc_TreeMap.c
diff --git a/libparc/parc/algol/parc_TreeMap.h b/libparc/parc/algol/parc_TreeMap.h
index 5f0ed8d8..5f0ed8d8 100755..100644
--- a/libparc/parc/algol/parc_TreeMap.h
+++ b/libparc/parc/algol/parc_TreeMap.h
diff --git a/libparc/parc/algol/parc_TreeRedBlack.c b/libparc/parc/algol/parc_TreeRedBlack.c
index 71a23f10..71a23f10 100755..100644
--- a/libparc/parc/algol/parc_TreeRedBlack.c
+++ b/libparc/parc/algol/parc_TreeRedBlack.c
diff --git a/libparc/parc/algol/parc_TreeRedBlack.h b/libparc/parc/algol/parc_TreeRedBlack.h
index 52d4af36..52d4af36 100755..100644
--- a/libparc/parc/algol/parc_TreeRedBlack.h
+++ b/libparc/parc/algol/parc_TreeRedBlack.h
diff --git a/libparc/parc/algol/parc_URI.c b/libparc/parc/algol/parc_URI.c
index e14dfc9f..94f74981 100644
--- a/libparc/parc/algol/parc_URI.c
+++ b/libparc/parc/algol/parc_URI.c
@@ -13,22 +13,17 @@
* limitations under the License.
*/
-/**
- *
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <unistd.h>
+#endif
+
+#include <config.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <ctype.h>
#include <stdarg.h>
-
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_URI.h>
-
#include <parc/algol/parc_URIPath.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Buffer.h>
diff --git a/libparc/parc/algol/parc_URIAuthority.c b/libparc/parc/algol/parc_URIAuthority.c
index 1e3468d1..96b5611a 100644
--- a/libparc/parc/algol/parc_URIAuthority.c
+++ b/libparc/parc/algol/parc_URIAuthority.c
@@ -13,22 +13,18 @@
* limitations under the License.
*/
-/**
- *
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <unistd.h>
+#endif
+
+#include <config.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <ctype.h>
#include <stdarg.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_URIAuthority.h>
-
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_SafeMemory.h>
diff --git a/libparc/parc/algol/parc_URIPath.c b/libparc/parc/algol/parc_URIPath.c
index 04636852..78f28f6f 100755..100644
--- a/libparc/parc/algol/parc_URIPath.c
+++ b/libparc/parc/algol/parc_URIPath.c
@@ -13,21 +13,19 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <unistd.h>
+#include <strings.h>
+#endif
+
+#include <config.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <ctype.h>
#include <stdarg.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_URIPath.h>
-
#include <parc/algol/parc_URISegment.h>
#include <parc/algol/parc_ArrayList.h>
#include <parc/algol/parc_Memory.h>
diff --git a/libparc/parc/algol/parc_URIPath.h b/libparc/parc/algol/parc_URIPath.h
index 4e2d62e5..4e2d62e5 100755..100644
--- a/libparc/parc/algol/parc_URIPath.h
+++ b/libparc/parc/algol/parc_URIPath.h
diff --git a/libparc/parc/algol/parc_URISegment.c b/libparc/parc/algol/parc_URISegment.c
index 786a7182..aa009665 100755..100644
--- a/libparc/parc/algol/parc_URISegment.c
+++ b/libparc/parc/algol/parc_URISegment.c
@@ -13,21 +13,17 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
-
+#ifndef _WIN32
#include <unistd.h>
+#endif
+
+#include <config.h>
#include <stdio.h>
#include <string.h>
-#include <strings.h>
#include <ctype.h>
#include <stdarg.h>
-
+#include <parc/assert/parc_Assert.h>
#include <parc/algol/parc_URISegment.h>
-
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
@@ -131,7 +127,7 @@ parcURISegment_CreateFromBuffer(PARCBuffer *buffer)
}
PARCURISegment *
-parcURISegment_Create(size_t length, const unsigned char segment[length])
+parcURISegment_Create(size_t length, const unsigned char *segment)
{
PARCURISegment *result = NULL;
diff --git a/libparc/parc/algol/parc_Unsigned.h b/libparc/parc/algol/parc_Unsigned.h
index b61195e4..b61195e4 100755..100644
--- a/libparc/parc/algol/parc_Unsigned.h
+++ b/libparc/parc/algol/parc_Unsigned.h
diff --git a/libparc/parc/algol/parc_Varint.c b/libparc/parc/algol/parc_Varint.c
index 7a1d2698..7a1d2698 100755..100644
--- a/libparc/parc/algol/parc_Varint.c
+++ b/libparc/parc/algol/parc_Varint.c
diff --git a/libparc/parc/algol/parc_Varint.h b/libparc/parc/algol/parc_Varint.h
index 6d7e60b8..6d7e60b8 100755..100644
--- a/libparc/parc/algol/parc_Varint.h
+++ b/libparc/parc/algol/parc_Varint.h
diff --git a/libparc/parc/algol/parc_Vector.c b/libparc/parc/algol/parc_Vector.c
index 1d0e9a1d..1d0e9a1d 100755..100644
--- a/libparc/parc/algol/parc_Vector.c
+++ b/libparc/parc/algol/parc_Vector.c
diff --git a/libparc/parc/algol/parc_Vector.h b/libparc/parc/algol/parc_Vector.h
index 825fc635..825fc635 100755..100644
--- a/libparc/parc/algol/parc_Vector.h
+++ b/libparc/parc/algol/parc_Vector.h
diff --git a/libparc/parc/algol/test/test_parc_ArrayList.c b/libparc/parc/algol/test/test_parc_ArrayList.c
index 51e9e11c..51e9e11c 100755..100644
--- a/libparc/parc/algol/test/test_parc_ArrayList.c
+++ b/libparc/parc/algol/test/test_parc_ArrayList.c
diff --git a/libparc/parc/algol/test/test_parc_Base64.c b/libparc/parc/algol/test/test_parc_Base64.c
index 4509ded3..4509ded3 100755..100644
--- a/libparc/parc/algol/test/test_parc_Base64.c
+++ b/libparc/parc/algol/test/test_parc_Base64.c
diff --git a/libparc/parc/algol/test/test_parc_BitVector.c b/libparc/parc/algol/test/test_parc_BitVector.c
index 9a4d0806..9a4d0806 100755..100644
--- a/libparc/parc/algol/test/test_parc_BitVector.c
+++ b/libparc/parc/algol/test/test_parc_BitVector.c
diff --git a/libparc/parc/algol/test/test_parc_BufferChunker.c b/libparc/parc/algol/test/test_parc_BufferChunker.c
index 8f770968..8f770968 100755..100644
--- a/libparc/parc/algol/test/test_parc_BufferChunker.c
+++ b/libparc/parc/algol/test/test_parc_BufferChunker.c
diff --git a/libparc/parc/algol/test/test_parc_ByteArray.c b/libparc/parc/algol/test/test_parc_ByteArray.c
index 971d79dd..971d79dd 100755..100644
--- a/libparc/parc/algol/test/test_parc_ByteArray.c
+++ b/libparc/parc/algol/test/test_parc_ByteArray.c
diff --git a/libparc/parc/algol/test/test_parc_Chunker.c b/libparc/parc/algol/test/test_parc_Chunker.c
index 945e6bab..945e6bab 100755..100644
--- a/libparc/parc/algol/test/test_parc_Chunker.c
+++ b/libparc/parc/algol/test/test_parc_Chunker.c
diff --git a/libparc/parc/algol/test/test_parc_Deque.c b/libparc/parc/algol/test/test_parc_Deque.c
index 02884b4a..02884b4a 100755..100644
--- a/libparc/parc/algol/test/test_parc_Deque.c
+++ b/libparc/parc/algol/test/test_parc_Deque.c
diff --git a/libparc/parc/algol/test/test_parc_Display.c b/libparc/parc/algol/test/test_parc_Display.c
index 29b9fdf2..29b9fdf2 100755..100644
--- a/libparc/parc/algol/test/test_parc_Display.c
+++ b/libparc/parc/algol/test/test_parc_Display.c
diff --git a/libparc/parc/algol/test/test_parc_Environment.c b/libparc/parc/algol/test/test_parc_Environment.c
index e4513b31..e4513b31 100755..100644
--- a/libparc/parc/algol/test/test_parc_Environment.c
+++ b/libparc/parc/algol/test/test_parc_Environment.c
diff --git a/libparc/parc/algol/test/test_parc_EventScheduler.c b/libparc/parc/algol/test/test_parc_EventScheduler.c
index 8195bd2e..8195bd2e 100755..100644
--- a/libparc/parc/algol/test/test_parc_EventScheduler.c
+++ b/libparc/parc/algol/test/test_parc_EventScheduler.c
diff --git a/libparc/parc/algol/test/test_parc_EventTimer.c b/libparc/parc/algol/test/test_parc_EventTimer.c
index f6b9917e..f6b9917e 100755..100644
--- a/libparc/parc/algol/test/test_parc_EventTimer.c
+++ b/libparc/parc/algol/test/test_parc_EventTimer.c
diff --git a/libparc/parc/algol/test/test_parc_FileChunker.c b/libparc/parc/algol/test/test_parc_FileChunker.c
index 6060cff6..6060cff6 100755..100644
--- a/libparc/parc/algol/test/test_parc_FileChunker.c
+++ b/libparc/parc/algol/test/test_parc_FileChunker.c
diff --git a/libparc/parc/algol/test/test_parc_FileInputStream.c b/libparc/parc/algol/test/test_parc_FileInputStream.c
index 49032050..49032050 100755..100644
--- a/libparc/parc/algol/test/test_parc_FileInputStream.c
+++ b/libparc/parc/algol/test/test_parc_FileInputStream.c
diff --git a/libparc/parc/algol/test/test_parc_FileOutputStream.c b/libparc/parc/algol/test/test_parc_FileOutputStream.c
index aa4236ae..aa4236ae 100755..100644
--- a/libparc/parc/algol/test/test_parc_FileOutputStream.c
+++ b/libparc/parc/algol/test/test_parc_FileOutputStream.c
diff --git a/libparc/parc/algol/test/test_parc_Hash.c b/libparc/parc/algol/test/test_parc_Hash.c
index cc92a867..cc92a867 100755..100644
--- a/libparc/parc/algol/test/test_parc_Hash.c
+++ b/libparc/parc/algol/test/test_parc_Hash.c
diff --git a/libparc/parc/algol/test/test_parc_HashCode.c b/libparc/parc/algol/test/test_parc_HashCode.c
index a5b21137..a5b21137 100755..100644
--- a/libparc/parc/algol/test/test_parc_HashCode.c
+++ b/libparc/parc/algol/test/test_parc_HashCode.c
diff --git a/libparc/parc/algol/test/test_parc_HashCodeTable.c b/libparc/parc/algol/test/test_parc_HashCodeTable.c
index c2adf9d2..c2adf9d2 100755..100644
--- a/libparc/parc/algol/test/test_parc_HashCodeTable.c
+++ b/libparc/parc/algol/test/test_parc_HashCodeTable.c
diff --git a/libparc/parc/algol/test/test_parc_InputStream.c b/libparc/parc/algol/test/test_parc_InputStream.c
index 46d47862..46d47862 100755..100644
--- a/libparc/parc/algol/test/test_parc_InputStream.c
+++ b/libparc/parc/algol/test/test_parc_InputStream.c
diff --git a/libparc/parc/algol/test/test_parc_JSONArray.c b/libparc/parc/algol/test/test_parc_JSONArray.c
index d0ad9ec5..d0ad9ec5 100755..100644
--- a/libparc/parc/algol/test/test_parc_JSONArray.c
+++ b/libparc/parc/algol/test/test_parc_JSONArray.c
diff --git a/libparc/parc/algol/test/test_parc_JSONParser.c b/libparc/parc/algol/test/test_parc_JSONParser.c
index 63bcea8d..63bcea8d 100755..100644
--- a/libparc/parc/algol/test/test_parc_JSONParser.c
+++ b/libparc/parc/algol/test/test_parc_JSONParser.c
diff --git a/libparc/parc/algol/test/test_parc_KeyValue.c b/libparc/parc/algol/test/test_parc_KeyValue.c
index f9440602..f9440602 100755..100644
--- a/libparc/parc/algol/test/test_parc_KeyValue.c
+++ b/libparc/parc/algol/test/test_parc_KeyValue.c
diff --git a/libparc/parc/algol/test/test_parc_KeyedElement.c b/libparc/parc/algol/test/test_parc_KeyedElement.c
index a6866437..a6866437 100755..100644
--- a/libparc/parc/algol/test/test_parc_KeyedElement.c
+++ b/libparc/parc/algol/test/test_parc_KeyedElement.c
diff --git a/libparc/parc/algol/test/test_parc_Memory.c b/libparc/parc/algol/test/test_parc_Memory.c
index 5fb18ce3..5fb18ce3 100755..100644
--- a/libparc/parc/algol/test/test_parc_Memory.c
+++ b/libparc/parc/algol/test/test_parc_Memory.c
diff --git a/libparc/parc/algol/test/test_parc_Network.c b/libparc/parc/algol/test/test_parc_Network.c
index 864fe25d..864fe25d 100755..100644
--- a/libparc/parc/algol/test/test_parc_Network.c
+++ b/libparc/parc/algol/test/test_parc_Network.c
diff --git a/libparc/parc/algol/test/test_parc_Object.c b/libparc/parc/algol/test/test_parc_Object.c
index 687654fe..687654fe 100755..100644
--- a/libparc/parc/algol/test/test_parc_Object.c
+++ b/libparc/parc/algol/test/test_parc_Object.c
diff --git a/libparc/parc/algol/test/test_parc_PathName.c b/libparc/parc/algol/test/test_parc_PathName.c
index b596aaa2..b596aaa2 100755..100644
--- a/libparc/parc/algol/test/test_parc_PathName.c
+++ b/libparc/parc/algol/test/test_parc_PathName.c
diff --git a/libparc/parc/algol/test/test_parc_Stack.c b/libparc/parc/algol/test/test_parc_Stack.c
index 3ca27682..3ca27682 100755..100644
--- a/libparc/parc/algol/test/test_parc_Stack.c
+++ b/libparc/parc/algol/test/test_parc_Stack.c
diff --git a/libparc/parc/algol/test/test_parc_TreeMap.c b/libparc/parc/algol/test/test_parc_TreeMap.c
index 9355380b..9355380b 100755..100644
--- a/libparc/parc/algol/test/test_parc_TreeMap.c
+++ b/libparc/parc/algol/test/test_parc_TreeMap.c
diff --git a/libparc/parc/algol/test/test_parc_TreeRedBlack.c b/libparc/parc/algol/test/test_parc_TreeRedBlack.c
index 7fb1828a..7fb1828a 100755..100644
--- a/libparc/parc/algol/test/test_parc_TreeRedBlack.c
+++ b/libparc/parc/algol/test/test_parc_TreeRedBlack.c
diff --git a/libparc/parc/algol/test/test_parc_Varint.c b/libparc/parc/algol/test/test_parc_Varint.c
index cf0c865c..cf0c865c 100755..100644
--- a/libparc/parc/algol/test/test_parc_Varint.c
+++ b/libparc/parc/algol/test/test_parc_Varint.c
diff --git a/libparc/parc/assert/parc_Assert.h b/libparc/parc/assert/parc_Assert.h
index 46e3e2f0..692edccd 100644
--- a/libparc/parc/assert/parc_Assert.h
+++ b/libparc/parc/assert/parc_Assert.h
@@ -182,10 +182,10 @@
parcLog_PrintError("Cannot obtain lock: " M, ##__VA_ARGS__); \
assert(!(A)); \
}
-#define parcAssertAligned(address, alignment, ...) \
- parcLog_PrintError(__VA_ARGS__); \
- assert(((alignment & (~alignment + 1)) == alignment) \
- ? (((uintptr_t)address) % alignment) == 0 ? 1 : 0 \
+#define parcAssertAligned(address, alignment, M, ...) \
+ parcLog_PrintError(M,##__VA_ARGS__); \
+ assert(((alignment & (~alignment + 1)) == alignment) \
+ ? (((uintptr_t)address) % alignment) == 0 ? 1 : 0 \
: 0);
#endif
diff --git a/libparc/parc/concurrent/parc_AtomicUint16.c b/libparc/parc/concurrent/parc_AtomicUint16.c
index 9bf2e478..9bf2e478 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint16.c
+++ b/libparc/parc/concurrent/parc_AtomicUint16.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint16.h b/libparc/parc/concurrent/parc_AtomicUint16.h
index ff6a4fc3..ff6a4fc3 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint16.h
+++ b/libparc/parc/concurrent/parc_AtomicUint16.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint32.c b/libparc/parc/concurrent/parc_AtomicUint32.c
index 24093951..24093951 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint32.c
+++ b/libparc/parc/concurrent/parc_AtomicUint32.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint32.h b/libparc/parc/concurrent/parc_AtomicUint32.h
index 870cbe80..870cbe80 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint32.h
+++ b/libparc/parc/concurrent/parc_AtomicUint32.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint64.c b/libparc/parc/concurrent/parc_AtomicUint64.c
index 326f39db..326f39db 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint64.c
+++ b/libparc/parc/concurrent/parc_AtomicUint64.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint64.h b/libparc/parc/concurrent/parc_AtomicUint64.h
index a6ac3ec1..a6ac3ec1 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint64.h
+++ b/libparc/parc/concurrent/parc_AtomicUint64.h
diff --git a/libparc/parc/concurrent/parc_AtomicUint8.c b/libparc/parc/concurrent/parc_AtomicUint8.c
index fd34258b..fd34258b 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint8.c
+++ b/libparc/parc/concurrent/parc_AtomicUint8.c
diff --git a/libparc/parc/concurrent/parc_AtomicUint8.h b/libparc/parc/concurrent/parc_AtomicUint8.h
index 7434b93d..7434b93d 100755..100644
--- a/libparc/parc/concurrent/parc_AtomicUint8.h
+++ b/libparc/parc/concurrent/parc_AtomicUint8.h
diff --git a/libparc/parc/concurrent/parc_FutureTask.c b/libparc/parc/concurrent/parc_FutureTask.c
index d323e0bd..d323e0bd 100755..100644
--- a/libparc/parc/concurrent/parc_FutureTask.c
+++ b/libparc/parc/concurrent/parc_FutureTask.c
diff --git a/libparc/parc/concurrent/parc_FutureTask.h b/libparc/parc/concurrent/parc_FutureTask.h
index 9a5776c5..9a5776c5 100755..100644
--- a/libparc/parc/concurrent/parc_FutureTask.h
+++ b/libparc/parc/concurrent/parc_FutureTask.h
diff --git a/libparc/parc/concurrent/parc_Lock.c b/libparc/parc/concurrent/parc_Lock.c
index 493fd44f..493fd44f 100755..100644
--- a/libparc/parc/concurrent/parc_Lock.c
+++ b/libparc/parc/concurrent/parc_Lock.c
diff --git a/libparc/parc/concurrent/parc_Lock.h b/libparc/parc/concurrent/parc_Lock.h
index ecba1c19..ecba1c19 100755..100644
--- a/libparc/parc/concurrent/parc_Lock.h
+++ b/libparc/parc/concurrent/parc_Lock.h
diff --git a/libparc/parc/concurrent/parc_Notifier.c b/libparc/parc/concurrent/parc_Notifier.c
index 67e8cfb3..e313cd6e 100755..100644
--- a/libparc/parc/concurrent/parc_Notifier.c
+++ b/libparc/parc/concurrent/parc_Notifier.c
@@ -13,26 +13,29 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <unistd.h>
+#endif
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-
#include <parc/assert/parc_Assert.h>
-
#include <parc/concurrent/parc_Notifier.h>
#include <parc/algol/parc_Object.h>
-#ifdef __GNUC__
+#if defined(__GNUC__)
#define ATOMIC_ADD_AND_FETCH(ptr, increment) __sync_add_and_fetch(ptr, increment)
#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) __sync_bool_compare_and_swap(ptr, oldvalue, newvalue)
#define ATOMIC_FETCH(ptr) ATOMIC_ADD_AND_FETCH(ptr, 0)
#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
+#elif defined(_WIN32)
+#define ATOMIC_ADD_AND_FETCH(ptr, increment) (++(*(ptr)))
+#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) (InterlockedCompareExchangePointer((volatile PVOID *)ptr, (PVOID)newvalue, (PVOID)oldvalue) == ptr)
+#define ATOMIC_FETCH(ptr) ATOMIC_ADD_AND_FETCH(ptr, 0)
+#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
#else
#error "Only GNUC supported, we need atomic operations"
#endif
@@ -63,6 +66,8 @@ parcObject_ExtendPARCObject(PARCNotifier, _parcNotifier_Finalize, NULL, NULL, NU
static bool
_parcNotifier_MakeNonblocking(PARCNotifier *notifier)
{
+
+#ifndef _WIN32
// set the read side to be non-blocking
int flags = fcntl(notifier->fds[PARCNotifierReadFd], F_GETFL, 0);
if (flags == 0) {
@@ -71,6 +76,8 @@ _parcNotifier_MakeNonblocking(PARCNotifier *notifier)
}
}
perror("fcntl error");
+#endif
+
return false;
}
@@ -82,12 +89,15 @@ parcNotifier_Create(void)
notifier->paused = false;
notifier->skippedNotify = false;
+#ifndef _WIN32
int failure = pipe(notifier->fds);
parcAssertFalse(failure, "Error on pipe: %s", strerror(errno));
if (!_parcNotifier_MakeNonblocking(notifier)) {
- parcObject_Release((void **) &notifier);
+ parcObject_Release((void **)&notifier);
}
+#endif
+
}
return notifier;
@@ -146,4 +156,4 @@ parcNotifier_StartEvents(PARCNotifier *notifier)
// we missed some notifications, so re-signal ourself
parcNotifier_Notify(notifier);
}
-}
+} \ No newline at end of file
diff --git a/libparc/parc/concurrent/parc_Notifier.h b/libparc/parc/concurrent/parc_Notifier.h
index 44eda3b5..e139c141 100755..100644
--- a/libparc/parc/concurrent/parc_Notifier.h
+++ b/libparc/parc/concurrent/parc_Notifier.h
@@ -175,4 +175,5 @@ void parcNotifier_PauseEvents(PARCNotifier *notifier);
* @endcode
*/
void parcNotifier_StartEvents(PARCNotifier *notifier);
+
#endif // libparc_parc_Notifier_h
diff --git a/libparc/parc/concurrent/parc_RingBuffer.c b/libparc/parc/concurrent/parc_RingBuffer.c
index d5fb677b..d5fb677b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer.c
+++ b/libparc/parc/concurrent/parc_RingBuffer.c
diff --git a/libparc/parc/concurrent/parc_RingBuffer.h b/libparc/parc/concurrent/parc_RingBuffer.h
index 211f044e..211f044e 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer.h
+++ b/libparc/parc/concurrent/parc_RingBuffer.h
diff --git a/libparc/parc/concurrent/parc_RingBuffer_1x1.c b/libparc/parc/concurrent/parc_RingBuffer_1x1.c
index a93049eb..9827154b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_1x1.c
+++ b/libparc/parc/concurrent/parc_RingBuffer_1x1.c
@@ -71,22 +71,23 @@
*
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <errno.h>
#include <string.h>
-#include <unistd.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/concurrent/parc_RingBuffer_1x1.h>
-#ifdef __GNUC__
-
+#if defined(__GNUC__)
// on x86 or x86_64, simple assignment will work
#if (__x86_64__ || __i386__)
#define ATOMIC_ADD_AND_FETCH(ptr, increment) __sync_add_and_fetch(ptr, increment)
@@ -100,6 +101,10 @@
#define ATOMIC_SET(ptr, oldvalue, newvalue) ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue)
#endif
+#elif defined(_WIN32)
+#define ATOMIC_FETCH(ptr) *(ptr)
+#define ATOMIC_SET(ptr, oldvalue, newvalue) *(ptr) = newvalue
+#define ATOMIC_BOOL_CAS(ptr, oldvalue, newvalue) (InterlockedCompareExchangePointer(ptr,newvalue,oldvalue) == ptr)
#else
#error "Only GNUC supported, we need atomic operations"
#endif
diff --git a/libparc/parc/concurrent/parc_RingBuffer_1x1.h b/libparc/parc/concurrent/parc_RingBuffer_1x1.h
index 4fd48e6b..4fd48e6b 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_1x1.h
+++ b/libparc/parc/concurrent/parc_RingBuffer_1x1.h
diff --git a/libparc/parc/concurrent/parc_RingBuffer_NxM.c b/libparc/parc/concurrent/parc_RingBuffer_NxM.c
index 4ea69e58..4ea69e58 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_NxM.c
+++ b/libparc/parc/concurrent/parc_RingBuffer_NxM.c
diff --git a/libparc/parc/concurrent/parc_RingBuffer_NxM.h b/libparc/parc/concurrent/parc_RingBuffer_NxM.h
index 8cf38fdc..8cf38fdc 100755..100644
--- a/libparc/parc/concurrent/parc_RingBuffer_NxM.h
+++ b/libparc/parc/concurrent/parc_RingBuffer_NxM.h
diff --git a/libparc/parc/concurrent/parc_ScheduledTask.c b/libparc/parc/concurrent/parc_ScheduledTask.c
index 4875abf7..e9636d28 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledTask.c
+++ b/libparc/parc/concurrent/parc_ScheduledTask.c
@@ -13,17 +13,16 @@
* limitations under the License.
*/
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
-/**
- */
#include <config.h>
-#include <sys/time.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Time.h>
-
#include <parc/concurrent/parc_ScheduledTask.h>
#include <parc/concurrent/parc_FutureTask.h>
diff --git a/libparc/parc/concurrent/parc_ScheduledTask.h b/libparc/parc/concurrent/parc_ScheduledTask.h
index e56fb5f5..e56fb5f5 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledTask.h
+++ b/libparc/parc/concurrent/parc_ScheduledTask.h
diff --git a/libparc/parc/concurrent/parc_ScheduledThreadPool.c b/libparc/parc/concurrent/parc_ScheduledThreadPool.c
index 0b77372e..6e544a92 100644
--- a/libparc/parc/concurrent/parc_ScheduledThreadPool.c
+++ b/libparc/parc/concurrent/parc_ScheduledThreadPool.c
@@ -57,7 +57,7 @@ _workerThread(PARCThread *thread, PARCScheduledThreadPool *pool)
parcSortedList_Notify(pool->workQueue);
} else {
- parcSortedList_WaitFor(pool->workQueue, executionDelay);
+ parcSortedList_WaitFor(pool->workQueue, (const unsigned long)executionDelay);
}
} else {
parcSortedList_Wait(pool->workQueue);
diff --git a/libparc/parc/concurrent/parc_ScheduledThreadPool.h b/libparc/parc/concurrent/parc_ScheduledThreadPool.h
index 36c26909..36c26909 100755..100644
--- a/libparc/parc/concurrent/parc_ScheduledThreadPool.h
+++ b/libparc/parc/concurrent/parc_ScheduledThreadPool.h
diff --git a/libparc/parc/concurrent/parc_Synchronizer.c b/libparc/parc/concurrent/parc_Synchronizer.c
index ab331442..ab331442 100755..100644
--- a/libparc/parc/concurrent/parc_Synchronizer.c
+++ b/libparc/parc/concurrent/parc_Synchronizer.c
diff --git a/libparc/parc/concurrent/parc_Synchronizer.h b/libparc/parc/concurrent/parc_Synchronizer.h
index a387888f..a387888f 100755..100644
--- a/libparc/parc/concurrent/parc_Synchronizer.h
+++ b/libparc/parc/concurrent/parc_Synchronizer.h
diff --git a/libparc/parc/concurrent/parc_Thread.c b/libparc/parc/concurrent/parc_Thread.c
index 50be042d..8004f672 100644
--- a/libparc/parc/concurrent/parc_Thread.c
+++ b/libparc/parc/concurrent/parc_Thread.c
@@ -210,7 +210,11 @@ parcThread_Cancel(PARCThread *thread)
int
parcThread_GetId(const PARCThread *thread)
{
- return (int) thread->thread;
+#ifndef _WIN32
+ return (int)thread->thread;
+#else
+ return pthread_getw32threadid_np(thread->thread);
+#endif
}
bool
diff --git a/libparc/parc/concurrent/parc_Thread.h b/libparc/parc/concurrent/parc_Thread.h
index f24306ae..f24306ae 100755..100644
--- a/libparc/parc/concurrent/parc_Thread.h
+++ b/libparc/parc/concurrent/parc_Thread.h
diff --git a/libparc/parc/concurrent/parc_ThreadPool.c b/libparc/parc/concurrent/parc_ThreadPool.c
index 2d9ef6d6..67c4bcff 100644
--- a/libparc/parc/concurrent/parc_ThreadPool.c
+++ b/libparc/parc/concurrent/parc_ThreadPool.c
@@ -276,7 +276,7 @@ parcThreadPool_AwaitTermination(PARCThreadPool *pool, PARCTimeout *timeout)
} else {
// This is not accurate as this will continue the delay, rather than keep a cumulative amount of delay.
uint64_t delay = parcTimeout_InNanoSeconds(timeout);
- parcLinkedList_WaitFor(pool->workQueue, delay);
+ parcLinkedList_WaitFor(pool->workQueue, (const unsigned long)delay);
}
}
result = true;
diff --git a/libparc/parc/concurrent/parc_ThreadPool.h b/libparc/parc/concurrent/parc_ThreadPool.h
index 7a7b548e..7a7b548e 100755..100644
--- a/libparc/parc/concurrent/parc_ThreadPool.h
+++ b/libparc/parc/concurrent/parc_ThreadPool.h
diff --git a/libparc/parc/concurrent/parc_Timeout.c b/libparc/parc/concurrent/parc_Timeout.c
index 4ea03977..4ea03977 100755..100644
--- a/libparc/parc/concurrent/parc_Timeout.c
+++ b/libparc/parc/concurrent/parc_Timeout.c
diff --git a/libparc/parc/concurrent/parc_Timer.c b/libparc/parc/concurrent/parc_Timer.c
index b1ecb5d2..b1ecb5d2 100755..100644
--- a/libparc/parc/concurrent/parc_Timer.c
+++ b/libparc/parc/concurrent/parc_Timer.c
diff --git a/libparc/parc/concurrent/parc_Timer.h b/libparc/parc/concurrent/parc_Timer.h
index 416bfba4..416bfba4 100755..100644
--- a/libparc/parc/concurrent/parc_Timer.h
+++ b/libparc/parc/concurrent/parc_Timer.h
diff --git a/libparc/parc/concurrent/test/test_parc_Notifier.c b/libparc/parc/concurrent/test/test_parc_Notifier.c
index 97ce6615..97ce6615 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_Notifier.c
+++ b/libparc/parc/concurrent/test/test_parc_Notifier.c
diff --git a/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c b/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
index a977dfbc..a977dfbc 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
+++ b/libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c
diff --git a/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c b/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
index 974da053..974da053 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
+++ b/libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c
diff --git a/libparc/parc/concurrent/test/test_parc_Synchronizer.c b/libparc/parc/concurrent/test/test_parc_Synchronizer.c
index 34d9c711..34d9c711 100755..100644
--- a/libparc/parc/concurrent/test/test_parc_Synchronizer.c
+++ b/libparc/parc/concurrent/test/test_parc_Synchronizer.c
diff --git a/libparc/parc/config.h.in b/libparc/parc/config.h.in
index 868c03ca..99618215 100644
--- a/libparc/parc/config.h.in
+++ b/libparc/parc/config.h.in
@@ -1,6 +1,10 @@
/* CPU Cache line size */
#define LEVEL1_DCACHE_LINESIZE @LEVEL1_DCACHE_LINESIZE@
+#ifndef _WIN32
#define _GNU_SOURCE
+#else
+#include <parc/windows/parc_Utils.h>
+#endif
#define HAVE_REALLOC @HAVE_REALLOC@ \ No newline at end of file
diff --git a/libparc/parc/developer/parc_Stopwatch.c b/libparc/parc/developer/parc_Stopwatch.c
index 2b696f4a..5f87e718 100644
--- a/libparc/parc/developer/parc_Stopwatch.c
+++ b/libparc/parc/developer/parc_Stopwatch.c
@@ -13,11 +13,11 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
+#ifndef _WIN32
#include <sys/time.h>
+#endif
+
+#include <config.h>
#include <inttypes.h>
#if __APPLE__
diff --git a/libparc/parc/developer/parc_Timing.h b/libparc/parc/developer/parc_Timing.h
index bd5c3340..bd5c3340 100755..100644
--- a/libparc/parc/developer/parc_Timing.h
+++ b/libparc/parc/developer/parc_Timing.h
diff --git a/libparc/parc/developer/parc_TimingDarwin.h b/libparc/parc/developer/parc_TimingDarwin.h
index 7b2a100e..7b2a100e 100755..100644
--- a/libparc/parc/developer/parc_TimingDarwin.h
+++ b/libparc/parc/developer/parc_TimingDarwin.h
diff --git a/libparc/parc/developer/parc_TimingGeneric.h b/libparc/parc/developer/parc_TimingGeneric.h
index 8c1d4468..79ac0bfb 100755..100644
--- a/libparc/parc/developer/parc_TimingGeneric.h
+++ b/libparc/parc/developer/parc_TimingGeneric.h
@@ -23,9 +23,12 @@
#ifndef libparc_parc_TimingLinux_h
#define libparc_parc_TimingLinux_h
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+
#include <stdint.h>
#include <time.h>
-#include <sys/time.h>
#ifdef PARCTIMING_GENERIC
diff --git a/libparc/parc/developer/parc_TimingIntel.c b/libparc/parc/developer/parc_TimingIntel.c
index c690515c..c690515c 100755..100644
--- a/libparc/parc/developer/parc_TimingIntel.c
+++ b/libparc/parc/developer/parc_TimingIntel.c
diff --git a/libparc/parc/developer/parc_TimingIntel.h b/libparc/parc/developer/parc_TimingIntel.h
index 4a90896d..4a90896d 100755..100644
--- a/libparc/parc/developer/parc_TimingIntel.h
+++ b/libparc/parc/developer/parc_TimingIntel.h
diff --git a/libparc/parc/developer/parc_TimingLinux.h b/libparc/parc/developer/parc_TimingLinux.h
index 3dd36205..3dd36205 100755..100644
--- a/libparc/parc/developer/parc_TimingLinux.h
+++ b/libparc/parc/developer/parc_TimingLinux.h
diff --git a/libparc/parc/developer/test/test_parc_Timing.c b/libparc/parc/developer/test/test_parc_Timing.c
index eafa2350..eafa2350 100755..100644
--- a/libparc/parc/developer/test/test_parc_Timing.c
+++ b/libparc/parc/developer/test/test_parc_Timing.c
diff --git a/libparc/parc/libparc_About.h b/libparc/parc/libparc_About.h
index 8ecd59ac..8ecd59ac 100755..100644
--- a/libparc/parc/libparc_About.h
+++ b/libparc/parc/libparc_About.h
diff --git a/libparc/parc/logging/parc_Log.c b/libparc/parc/logging/parc_Log.c
index 4aa2a679..7034f5ea 100755..100644
--- a/libparc/parc/logging/parc_Log.c
+++ b/libparc/parc/logging/parc_Log.c
@@ -13,15 +13,15 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+
#include <config.h>
#include <stdio.h>
-#include <sys/time.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_Memory.h>
@@ -138,7 +138,7 @@ parcLog_MessageVaList(PARCLog *log, PARCLogLevel level, uint64_t messageId, cons
}
bool
-parcLog_Message(PARCLog *log, PARCLogLevel level, uint64_t messageId, const char *format, ...)
+parcLog_Message(PARCLog *log, PARCLogLevel level, uint64_t messageId, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -149,7 +149,7 @@ parcLog_Message(PARCLog *log, PARCLogLevel level, uint64_t messageId, const char
}
bool
-parcLog_Warning(PARCLog *logger, const char *format, ...)
+parcLog_Warning(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -160,7 +160,7 @@ parcLog_Warning(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Info(PARCLog *logger, const char *format, ...)
+parcLog_Info(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -171,7 +171,7 @@ parcLog_Info(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Notice(PARCLog *logger, const char *format, ...)
+parcLog_Notice(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -182,7 +182,7 @@ parcLog_Notice(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Debug(PARCLog *logger, const char *format, ...)
+parcLog_Debug(PARCLog *logger, const char *restrict format, ...)
{
bool result = false;
@@ -197,7 +197,7 @@ parcLog_Debug(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Error(PARCLog *logger, const char *format, ...)
+parcLog_Error(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -208,7 +208,7 @@ parcLog_Error(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Critical(PARCLog *logger, const char *format, ...)
+parcLog_Critical(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -219,7 +219,7 @@ parcLog_Critical(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Alert(PARCLog *logger, const char *format, ...)
+parcLog_Alert(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
@@ -230,7 +230,7 @@ parcLog_Alert(PARCLog *logger, const char *format, ...)
}
bool
-parcLog_Emergency(PARCLog *logger, const char *format, ...)
+parcLog_Emergency(PARCLog *logger, const char *restrict format, ...)
{
va_list ap;
va_start(ap, format);
diff --git a/libparc/parc/logging/parc_LogEntry.h b/libparc/parc/logging/parc_LogEntry.h
index 90f6c493..250a83c0 100755..100644
--- a/libparc/parc/logging/parc_LogEntry.h
+++ b/libparc/parc/logging/parc_LogEntry.h
@@ -34,10 +34,13 @@
#ifndef PARC_Library_parc_LogEntry_h
#define PARC_Library_parc_LogEntry_h
-#include <stdlib.h>
+#ifndef _WIN32
+#include <sys/time.h>
+#endif
+#include <stdlib.h>
#include <parc/algol/parc_Buffer.h>
-#include <sys/time.h>
+
struct PARCLogEntry;
typedef struct PARCLogEntry PARCLogEntry;
diff --git a/libparc/parc/logging/parc_LogFormatSyslog.c b/libparc/parc/logging/parc_LogFormatSyslog.c
index 2b3e7e9c..2b3e7e9c 100755..100644
--- a/libparc/parc/logging/parc_LogFormatSyslog.c
+++ b/libparc/parc/logging/parc_LogFormatSyslog.c
diff --git a/libparc/parc/logging/parc_LogFormatSyslog.h b/libparc/parc/logging/parc_LogFormatSyslog.h
index 3ace4e7b..3ace4e7b 100755..100644
--- a/libparc/parc/logging/parc_LogFormatSyslog.h
+++ b/libparc/parc/logging/parc_LogFormatSyslog.h
diff --git a/libparc/parc/logging/parc_LogFormatText.c b/libparc/parc/logging/parc_LogFormatText.c
index 7497967b..7497967b 100755..100644
--- a/libparc/parc/logging/parc_LogFormatText.c
+++ b/libparc/parc/logging/parc_LogFormatText.c
diff --git a/libparc/parc/logging/parc_LogFormatText.h b/libparc/parc/logging/parc_LogFormatText.h
index b4bb5b1f..b4bb5b1f 100755..100644
--- a/libparc/parc/logging/parc_LogFormatText.h
+++ b/libparc/parc/logging/parc_LogFormatText.h
diff --git a/libparc/parc/logging/parc_LogLevel.c b/libparc/parc/logging/parc_LogLevel.c
index 62d07072..d1ffe63c 100755..100644
--- a/libparc/parc/logging/parc_LogLevel.c
+++ b/libparc/parc/logging/parc_LogLevel.c
@@ -74,7 +74,7 @@ parcLogLevel_FromString(const char *levelAsString)
PARCLogLevel result = PARCLogLevel_All;
for (size_t i = 0; levelToString[i] != NULL; i++) {
if (strcasecmp(levelAsString, levelToString[i]) == 0) {
- result = i;
+ result = (PARCLogLevel)i;
}
}
diff --git a/libparc/parc/logging/parc_LogLevel.h b/libparc/parc/logging/parc_LogLevel.h
index 4540924e..4540924e 100755..100644
--- a/libparc/parc/logging/parc_LogLevel.h
+++ b/libparc/parc/logging/parc_LogLevel.h
diff --git a/libparc/parc/logging/parc_LogManager.c b/libparc/parc/logging/parc_LogManager.c
index 939ab90d..939ab90d 100755..100644
--- a/libparc/parc/logging/parc_LogManager.c
+++ b/libparc/parc/logging/parc_LogManager.c
diff --git a/libparc/parc/logging/parc_LogManager.h b/libparc/parc/logging/parc_LogManager.h
index ce50c60b..ce50c60b 100755..100644
--- a/libparc/parc/logging/parc_LogManager.h
+++ b/libparc/parc/logging/parc_LogManager.h
diff --git a/libparc/parc/logging/parc_LogReporter.c b/libparc/parc/logging/parc_LogReporter.c
index a06f360a..a06f360a 100755..100644
--- a/libparc/parc/logging/parc_LogReporter.c
+++ b/libparc/parc/logging/parc_LogReporter.c
diff --git a/libparc/parc/logging/parc_LogReporter.h b/libparc/parc/logging/parc_LogReporter.h
index 65496f55..65496f55 100755..100644
--- a/libparc/parc/logging/parc_LogReporter.h
+++ b/libparc/parc/logging/parc_LogReporter.h
diff --git a/libparc/parc/logging/parc_LogReporterFile.c b/libparc/parc/logging/parc_LogReporterFile.c
index d9bd4986..d9bd4986 100755..100644
--- a/libparc/parc/logging/parc_LogReporterFile.c
+++ b/libparc/parc/logging/parc_LogReporterFile.c
diff --git a/libparc/parc/logging/parc_LogReporterFile.h b/libparc/parc/logging/parc_LogReporterFile.h
index 19bbae5d..19bbae5d 100755..100644
--- a/libparc/parc/logging/parc_LogReporterFile.h
+++ b/libparc/parc/logging/parc_LogReporterFile.h
diff --git a/libparc/parc/logging/parc_LogReporterTextStdout.c b/libparc/parc/logging/parc_LogReporterTextStdout.c
index 86d5190e..53ff6fa4 100755..100644
--- a/libparc/parc/logging/parc_LogReporterTextStdout.c
+++ b/libparc/parc/logging/parc_LogReporterTextStdout.c
@@ -13,11 +13,12 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
#include <config.h>
#include <inttypes.h>
-#include <unistd.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_OutputStream.h>
diff --git a/libparc/parc/logging/parc_LogReporterTextStdout.h b/libparc/parc/logging/parc_LogReporterTextStdout.h
index 4365330e..4365330e 100755..100644
--- a/libparc/parc/logging/parc_LogReporterTextStdout.h
+++ b/libparc/parc/logging/parc_LogReporterTextStdout.h
diff --git a/libparc/parc/logging/test/test_parc_LogFormatSyslog.c b/libparc/parc/logging/test/test_parc_LogFormatSyslog.c
index b5d1f4b5..b5d1f4b5 100755..100644
--- a/libparc/parc/logging/test/test_parc_LogFormatSyslog.c
+++ b/libparc/parc/logging/test/test_parc_LogFormatSyslog.c
diff --git a/libparc/parc/logging/test/test_parc_LogLevel.c b/libparc/parc/logging/test/test_parc_LogLevel.c
index ca05cc5c..ca05cc5c 100755..100644
--- a/libparc/parc/logging/test/test_parc_LogLevel.c
+++ b/libparc/parc/logging/test/test_parc_LogLevel.c
diff --git a/libparc/parc/logging/test/test_parc_LogReporterFile.c b/libparc/parc/logging/test/test_parc_LogReporterFile.c
index 9739c715..9739c715 100755..100644
--- a/libparc/parc/logging/test/test_parc_LogReporterFile.c
+++ b/libparc/parc/logging/test/test_parc_LogReporterFile.c
diff --git a/libparc/parc/logging/test/test_parc_LogReporterTextStdout.c b/libparc/parc/logging/test/test_parc_LogReporterTextStdout.c
index 004fbd58..004fbd58 100755..100644
--- a/libparc/parc/logging/test/test_parc_LogReporterTextStdout.c
+++ b/libparc/parc/logging/test/test_parc_LogReporterTextStdout.c
diff --git a/libparc/parc/security/command-line/parcPublicKey_About.h b/libparc/parc/security/command-line/parcPublicKey_About.h
index fccb7b7d..fccb7b7d 100755..100644
--- a/libparc/parc/security/command-line/parcPublicKey_About.h
+++ b/libparc/parc/security/command-line/parcPublicKey_About.h
diff --git a/libparc/parc/security/parc_Certificate.c b/libparc/parc/security/parc_Certificate.c
index aead0fb5..aead0fb5 100755..100644
--- a/libparc/parc/security/parc_Certificate.c
+++ b/libparc/parc/security/parc_Certificate.c
diff --git a/libparc/parc/security/parc_Certificate.h b/libparc/parc/security/parc_Certificate.h
index 43eb9416..43eb9416 100755..100644
--- a/libparc/parc/security/parc_Certificate.h
+++ b/libparc/parc/security/parc_Certificate.h
diff --git a/libparc/parc/security/parc_CertificateFactory.h b/libparc/parc/security/parc_CertificateFactory.h
index 74035232..74035232 100755..100644
--- a/libparc/parc/security/parc_CertificateFactory.h
+++ b/libparc/parc/security/parc_CertificateFactory.h
diff --git a/libparc/parc/security/parc_CertificateType.c b/libparc/parc/security/parc_CertificateType.c
index 86581675..86581675 100755..100644
--- a/libparc/parc/security/parc_CertificateType.c
+++ b/libparc/parc/security/parc_CertificateType.c
diff --git a/libparc/parc/security/parc_CertificateType.h b/libparc/parc/security/parc_CertificateType.h
index 596cd293..596cd293 100755..100644
--- a/libparc/parc/security/parc_CertificateType.h
+++ b/libparc/parc/security/parc_CertificateType.h
diff --git a/libparc/parc/security/parc_ContainerEncoding.c b/libparc/parc/security/parc_ContainerEncoding.c
index 3376e69a..3376e69a 100755..100644
--- a/libparc/parc/security/parc_ContainerEncoding.c
+++ b/libparc/parc/security/parc_ContainerEncoding.c
diff --git a/libparc/parc/security/parc_ContainerEncoding.h b/libparc/parc/security/parc_ContainerEncoding.h
index 7cac3fd1..7cac3fd1 100755..100644
--- a/libparc/parc/security/parc_ContainerEncoding.h
+++ b/libparc/parc/security/parc_ContainerEncoding.h
diff --git a/libparc/parc/security/parc_CryptoCache.c b/libparc/parc/security/parc_CryptoCache.c
index 07caaed7..07caaed7 100755..100644
--- a/libparc/parc/security/parc_CryptoCache.c
+++ b/libparc/parc/security/parc_CryptoCache.c
diff --git a/libparc/parc/security/parc_CryptoCache.h b/libparc/parc/security/parc_CryptoCache.h
index 497ee38d..497ee38d 100755..100644
--- a/libparc/parc/security/parc_CryptoCache.h
+++ b/libparc/parc/security/parc_CryptoCache.h
diff --git a/libparc/parc/security/parc_CryptoHash.c b/libparc/parc/security/parc_CryptoHash.c
index d0f82af3..d0f82af3 100755..100644
--- a/libparc/parc/security/parc_CryptoHash.c
+++ b/libparc/parc/security/parc_CryptoHash.c
diff --git a/libparc/parc/security/parc_CryptoHash.h b/libparc/parc/security/parc_CryptoHash.h
index d0312d9e..d0312d9e 100755..100644
--- a/libparc/parc/security/parc_CryptoHash.h
+++ b/libparc/parc/security/parc_CryptoHash.h
diff --git a/libparc/parc/security/parc_CryptoHashType.h b/libparc/parc/security/parc_CryptoHashType.h
index 3ab1d9c9..3ab1d9c9 100755..100644
--- a/libparc/parc/security/parc_CryptoHashType.h
+++ b/libparc/parc/security/parc_CryptoHashType.h
diff --git a/libparc/parc/security/parc_CryptoHasher.c b/libparc/parc/security/parc_CryptoHasher.c
index a4d492ff..b7226e46 100755..100644
--- a/libparc/parc/security/parc_CryptoHasher.c
+++ b/libparc/parc/security/parc_CryptoHasher.c
@@ -435,7 +435,7 @@ static const uint32_t _crc32c_table[] = {
*/
__attribute__((unused))
static uint32_t
-_crc32c_UpdateSoftware(uint32_t crc, size_t len, uint8_t p[len])
+_crc32c_UpdateSoftware(uint32_t crc, size_t len, uint8_t *p)
{
for (int i = 0; i < len; i++) {
crc = (crc >> 8) ^ _crc32c_table[((uint8_t) (crc & 0xFF)) ^ p[i]];
@@ -469,7 +469,7 @@ _crc32c_Finalize(uint32_t crc)
* the CRC table used by the software calculation.
*/
static uint32_t
-_crc32c_Update(uint32_t crc, size_t len, uint8_t p[len])
+_crc32c_Update(uint32_t crc, size_t len, uint8_t *p)
{
#ifdef __SSE4_2__
crc = _crc32c_UpdateIntel(crc, len, p);
diff --git a/libparc/parc/security/parc_CryptoHasher.h b/libparc/parc/security/parc_CryptoHasher.h
index 2c93c1f7..2c93c1f7 100755..100644
--- a/libparc/parc/security/parc_CryptoHasher.h
+++ b/libparc/parc/security/parc_CryptoHasher.h
diff --git a/libparc/parc/security/parc_CryptoSuite.c b/libparc/parc/security/parc_CryptoSuite.c
index b7e1938b..7d7920f5 100755..100644
--- a/libparc/parc/security/parc_CryptoSuite.c
+++ b/libparc/parc/security/parc_CryptoSuite.c
@@ -35,12 +35,11 @@ parcCryptoSuite_GetCryptoHash(PARCCryptoSuite suite)
case PARCCryptoSuite_HMAC_SHA512: // fallthrough
case PARCCryptoSuite_RSA_SHA512:
return PARCCryptoHashType_SHA512;
-
case PARCCryptoSuite_NULL_CRC32C:
return PARCCryptoHashType_CRC32C;
-
default:
parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ return PARCCryptoHashType_NULL;
}
}
@@ -66,6 +65,7 @@ parcCryptoSuite_GetSignatureSizeBytes(PARCCryptoSuite suite, int keyLengthBits)
default:
parcTrapIllegalValue(suite, "Unknown crypto suite: %d", suite);
+ return -1;
}
}
@@ -82,6 +82,7 @@ PARCCryptoSuite parcCryptoSuite_GetFromSigningHash(PARCSigningAlgorithm signAlgo
return PARCCryptoSuite_NULL_CRC32C;
default:
parcTrapIllegalValue(suite, "Unknown signing algorithm suite: %d", signAlgo);
+ return PARCSigningAlgorithm_UNKNOWN;
}
}
@@ -107,5 +108,6 @@ parcCryptoSuite_GetSigningAlgorithm(PARCCryptoSuite suite)
default:
parcTrapIllegalValue(suit, "Unknown crypto suite: %d", suite);
+ return PARCSigningAlgorithm_UNKNOWN;
}
}
diff --git a/libparc/parc/security/parc_CryptoSuite.h b/libparc/parc/security/parc_CryptoSuite.h
index 366bcb11..366bcb11 100755..100644
--- a/libparc/parc/security/parc_CryptoSuite.h
+++ b/libparc/parc/security/parc_CryptoSuite.h
diff --git a/libparc/parc/security/parc_DiffieHellmanGroup.h b/libparc/parc/security/parc_DiffieHellmanGroup.h
index 7402399e..7402399e 100755..100644
--- a/libparc/parc/security/parc_DiffieHellmanGroup.h
+++ b/libparc/parc/security/parc_DiffieHellmanGroup.h
diff --git a/libparc/parc/security/parc_DiffieHellmanKeyShare.c b/libparc/parc/security/parc_DiffieHellmanKeyShare.c
index 313af4a3..48c3ee26 100644
--- a/libparc/parc/security/parc_DiffieHellmanKeyShare.c
+++ b/libparc/parc/security/parc_DiffieHellmanKeyShare.c
@@ -148,7 +148,7 @@ parcDiffieHellmanKeyShare_SerializePublicKey(PARCDiffieHellmanKeyShare *keyShare
const EC_POINT *point = EC_KEY_get0_public_key(ecKey);
const EC_GROUP *group = EC_KEY_get0_group(ecKey);
char *keyBuffer = EC_POINT_point2hex(group, point, form, bnctx);
- int length = strlen(keyBuffer);
+ int length = (int)strlen(keyBuffer);
PARCBuffer *publicKey = parcBuffer_Allocate(length);
parcBuffer_PutArray(publicKey, length, (uint8_t *) keyBuffer);
diff --git a/libparc/parc/security/parc_Identity.c b/libparc/parc/security/parc_Identity.c
index daaf661d..daaf661d 100755..100644
--- a/libparc/parc/security/parc_Identity.c
+++ b/libparc/parc/security/parc_Identity.c
diff --git a/libparc/parc/security/parc_Identity.h b/libparc/parc/security/parc_Identity.h
index c00af8fa..c00af8fa 100755..100644
--- a/libparc/parc/security/parc_Identity.h
+++ b/libparc/parc/security/parc_Identity.h
diff --git a/libparc/parc/security/parc_IdentityFile.c b/libparc/parc/security/parc_IdentityFile.c
index 8372a111..395757b6 100644
--- a/libparc/parc/security/parc_IdentityFile.c
+++ b/libparc/parc/security/parc_IdentityFile.c
@@ -13,23 +13,20 @@
* limitations under the License.
*/
-/**
- */
-#include <config.h>
-
-#include <parc/assert/parc_Assert.h>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <config.h>
#include <sys/stat.h>
-#include <unistd.h>
+#include <parc/assert/parc_Assert.h>
#include <parc/security/parc_Identity.h>
#include <parc/algol/parc_Memory.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
-
#include <parc/security/parc_Pkcs12KeyStore.h>
#include <parc/security/parc_PublicKeySigner.h>
-
#include <parc/security/parc_IdentityFile.h>
struct parc_identity_file {
diff --git a/libparc/parc/security/parc_InMemoryVerifier.c b/libparc/parc/security/parc_InMemoryVerifier.c
index 33f6fcfe..8955e1f1 100644
--- a/libparc/parc/security/parc_InMemoryVerifier.c
+++ b/libparc/parc/security/parc_InMemoryVerifier.c
@@ -99,6 +99,7 @@ _parcInMemoryVerifier_GetCryptoHasher(void *interfaceContext, PARCKeyId *keyid,
default:
parcTrapUnexpectedState("unsupported hash type: %d", hashType);
+ return NULL;
}
}
@@ -275,7 +276,7 @@ _parcInMemoryVerifier_RSAKey_Verify(PARCInMemoryVerifier *verifier, PARCCryptoHa
{
const uint8_t *der_bytes = parcByteArray_Array(parcBuffer_Array(derEncodedKey));
- long der_length = parcBuffer_Remaining(derEncodedKey);
+ long der_length = (long)parcBuffer_Remaining(derEncodedKey);
EVP_PKEY *unwrapped_key = d2i_PUBKEY(NULL, &der_bytes, der_length);
if (unwrapped_key != NULL) {
@@ -337,7 +338,7 @@ _parcInMemoryVerifier_ECDSAKey_Verify(PARCInMemoryVerifier *verifier, PARCCrypto
{
const uint8_t *der_bytes = parcByteArray_Array(parcBuffer_Array(derEncodedKey));
- long der_length = parcBuffer_Remaining(derEncodedKey);
+ long der_length = (long)parcBuffer_Remaining(derEncodedKey);
EVP_PKEY *unwrapped_key = d2i_PUBKEY(NULL, &der_bytes, der_length);
if (unwrapped_key != NULL) {
diff --git a/libparc/parc/security/parc_InMemoryVerifier.h b/libparc/parc/security/parc_InMemoryVerifier.h
index bbec8130..bbec8130 100755..100644
--- a/libparc/parc/security/parc_InMemoryVerifier.h
+++ b/libparc/parc/security/parc_InMemoryVerifier.h
diff --git a/libparc/parc/security/parc_Key.c b/libparc/parc/security/parc_Key.c
index 82d21244..82d21244 100755..100644
--- a/libparc/parc/security/parc_Key.c
+++ b/libparc/parc/security/parc_Key.c
diff --git a/libparc/parc/security/parc_Key.h b/libparc/parc/security/parc_Key.h
index 426405bb..426405bb 100755..100644
--- a/libparc/parc/security/parc_Key.h
+++ b/libparc/parc/security/parc_Key.h
diff --git a/libparc/parc/security/parc_KeyId.c b/libparc/parc/security/parc_KeyId.c
index 45e7454b..45e7454b 100755..100644
--- a/libparc/parc/security/parc_KeyId.c
+++ b/libparc/parc/security/parc_KeyId.c
diff --git a/libparc/parc/security/parc_KeyId.h b/libparc/parc/security/parc_KeyId.h
index daa2a2fe..daa2a2fe 100755..100644
--- a/libparc/parc/security/parc_KeyId.h
+++ b/libparc/parc/security/parc_KeyId.h
diff --git a/libparc/parc/security/parc_KeyStore.c b/libparc/parc/security/parc_KeyStore.c
index 6d4a724a..6d4a724a 100755..100644
--- a/libparc/parc/security/parc_KeyStore.c
+++ b/libparc/parc/security/parc_KeyStore.c
diff --git a/libparc/parc/security/parc_KeyStore.h b/libparc/parc/security/parc_KeyStore.h
index 253505d5..253505d5 100755..100644
--- a/libparc/parc/security/parc_KeyStore.h
+++ b/libparc/parc/security/parc_KeyStore.h
diff --git a/libparc/parc/security/parc_Pkcs12KeyStore.c b/libparc/parc/security/parc_Pkcs12KeyStore.c
index f6c65e4f..12246593 100644
--- a/libparc/parc/security/parc_Pkcs12KeyStore.c
+++ b/libparc/parc/security/parc_Pkcs12KeyStore.c
@@ -13,31 +13,27 @@
* limitations under the License.
*/
-/**
- */
+#ifndef _WIN32
+#include <unistd.h>
+#endif
#include <config.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
#include <parc/assert/parc_Assert.h>
-
#include <parc/algol/parc_Object.h>
-
#include <parc/security/parc_Security.h>
#include <parc/security/parc_Signer.h>
#include <parc/security/parc_KeyStore.h>
#include <parc/algol/parc_Memory.h>
-
#include <parc/security/parc_Certificate.h>
#include <parc/security/parc_CertificateFactory.h>
#include <parc/security/parc_CertificateType.h>
#include <parc/security/parc_ContainerEncoding.h>
#include <parc/security/parc_KeyType.h>
-
#include <parc/security/parc_Pkcs12KeyStore.h>
#include <openssl/pkcs12.h>
@@ -102,12 +98,22 @@ _parcPkcs12KeyStore_ParseFile(PARCPkcs12KeyStore *keystore, const char *filename
{
parcSecurity_AssertIsInitialized();
+#ifndef _WIN32
FILE *fp = fopen(filename, "rb");
-
parcAssertNotNull(fp, "Error opening %s: %s", filename, strerror(errno));
if (fp == NULL) {
return -1;
}
+#else
+ FILE *fp;
+ errno_t err = fopen_s(&fp, filename, "rb");
+ char errmsg[1024];
+ strerror_s(errmsg, 1024, err);
+ parcAssertNotNull(fp, "Error opening %s: %s", filename, errmsg);
+ if (err != 0) {
+ return -1;
+ }
+#endif
PKCS12 *p12Keystore = NULL;
d2i_PKCS12_fp(fp, &p12Keystore);
@@ -156,17 +162,17 @@ PKCS12 *_createPkcs12KeyStore_RSA(
// Extract the private key
EVP_PKEY *privateKey = NULL;
uint8_t *privateKeyBytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &privateKeyBytes, parcBuffer_Limit(privateKeyBuffer));
+ d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &privateKeyBytes, (long)parcBuffer_Limit(privateKeyBuffer));
parcBuffer_Release(&privateKeyBuffer);
-
+
// Extract the certificate
PARCBuffer *certBuffer = parcCertificate_GetDEREncodedCertificate(certificate);
uint8_t *certBytes = parcBuffer_Overlay(certBuffer, parcBuffer_Limit(certBuffer));
X509 *cert = NULL;
- d2i_X509(&cert, (const unsigned char **) &certBytes, parcBuffer_Limit(certBuffer));
-
+ d2i_X509(&cert, (const unsigned char **) &certBytes, (long)parcBuffer_Limit(certBuffer));
+
parcCertificate_Release(&certificate);
-
+
PKCS12 *pkcs12 = PKCS12_create((char *) password,
"ccnxuser",
privateKey,
@@ -190,17 +196,17 @@ PKCS12 *_createPkcs12KeyStore_ECDSA(
// Extract the private key
EVP_PKEY *privateKey = NULL;
uint8_t *privateKeyBytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &privateKeyBytes, parcBuffer_Limit(privateKeyBuffer));
+ d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &privateKeyBytes, (long)parcBuffer_Limit(privateKeyBuffer));
parcBuffer_Release(&privateKeyBuffer);
-
+
// Extract the certificate
PARCBuffer *certBuffer = parcCertificate_GetDEREncodedCertificate(certificate);
uint8_t *certBytes = parcBuffer_Overlay(certBuffer, parcBuffer_Limit(certBuffer));
X509 *cert = NULL;
- d2i_X509(&cert, (const unsigned char **) &certBytes, parcBuffer_Limit(certBuffer));
-
+ d2i_X509(&cert, (const unsigned char **) &certBytes, (long)parcBuffer_Limit(certBuffer));
+
parcCertificate_Release(&certificate);
-
+
PKCS12 *pkcs12 = PKCS12_create((char *) password,
"ccnxuser",
privateKey,
diff --git a/libparc/parc/security/parc_PublicKeySigner.c b/libparc/parc/security/parc_PublicKeySigner.c
index 55404b9c..de048df8 100644
--- a/libparc/parc/security/parc_PublicKeySigner.c
+++ b/libparc/parc/security/parc_PublicKeySigner.c
@@ -170,7 +170,7 @@ static inline int _SignDigestRSA(const PARCCryptoHash *digestToSign, PARCBuffer
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, (long)keySize);
RSA *rsa = EVP_PKEY_get1_RSA(privateKey);
//*sig = parcMemory_Allocate(RSA_size(rsa));
@@ -196,7 +196,7 @@ static inline int _SignDigestECDSA(const PARCCryptoHash *digestToSign, PARCBuffe
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, (long)keySize);
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey);
@@ -283,7 +283,7 @@ _GetSignatureSize(PARCPublicKeySigner *signer)
{
EVP_PKEY *privateKey = NULL;
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, parcBuffer_Limit(privateKeyBuffer));
- privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, parcBuffer_Limit(privateKeyBuffer));
+ privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, (long)parcBuffer_Limit(privateKeyBuffer));
RSA *rsa = EVP_PKEY_get1_RSA(privateKey);
@@ -297,7 +297,7 @@ _GetSignatureSize(PARCPublicKeySigner *signer)
EVP_PKEY *privateKey = NULL;
size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
- privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, keySize);
+ privateKey = d2i_PrivateKey(EVP_PKEY_EC, &privateKey, (const unsigned char **) &bytes, (long)keySize);
EC_KEY *ec_key = EVP_PKEY_get1_EC_KEY(privateKey);
diff --git a/libparc/parc/security/parc_SecureRandom.c b/libparc/parc/security/parc_SecureRandom.c
index 92c308c1..80189cb9 100644
--- a/libparc/parc/security/parc_SecureRandom.c
+++ b/libparc/parc/security/parc_SecureRandom.c
@@ -13,19 +13,17 @@
* limitations under the License.
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
-/**
- */
#include <config.h>
-
#include <stdlib.h>
#include <fcntl.h>
-#include <unistd.h>
#include <parc/algol/parc_Object.h>
#include <parc/algol/parc_DisplayIndented.h>
#include <parc/algol/parc_Memory.h>
-
#include <parc/security/parc_SecureRandom.h>
struct parc_securerandom {
@@ -77,7 +75,7 @@ static void
_parcSecureRandom_ReSeed(PARCSecureRandom *random, PARCBuffer *buffer)
{
size_t length = parcBuffer_Remaining(buffer);
- int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), length);
+ int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), (long)length);
}
PARCSecureRandom *
@@ -104,7 +102,7 @@ ssize_t
parcSecureRandom_NextBytes(PARCSecureRandom *random, PARCBuffer *buffer)
{
size_t length = parcBuffer_Remaining(buffer);
- ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), length);
+ ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), (unsigned int)length);
return result;
}
diff --git a/libparc/parc/security/parc_Security.c b/libparc/parc/security/parc_Security.c
index e5f7609d..999a41da 100644
--- a/libparc/parc/security/parc_Security.c
+++ b/libparc/parc/security/parc_Security.c
@@ -50,8 +50,10 @@
#error OpenSSL version must be at least 0.9.8 release
#endif
+#ifndef _WIN32
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -120,8 +122,10 @@ _getThreadId(CRYPTO_THREADID *id)
#elif defined(__linux__)
// linux (at least ubuntu and redhat) uses unsigned long int
CRYPTO_THREADID_set_numeric(id, threadid);
+#elif _WIN32
+ CRYPTO_THREADID_set_pointer(id, threadid.p);
#else
-#error Unsupported platform, only __APPLE__ and __linux__ supported
+#error Unsupported platform, only __APPLE__, __linux__ and MSVC supported
#endif
}
#endif
@@ -206,4 +210,6 @@ parcSecurity_Fini(void)
parcAssertTrue(unlockSuccessful, "Unable to unlock the PARC Security framework.");
}
+#ifndef _WIN32
#pragma GCC diagnostic pop
+#endif \ No newline at end of file
diff --git a/libparc/parc/security/parc_Security.h b/libparc/parc/security/parc_Security.h
index 2c20496b..2c20496b 100755..100644
--- a/libparc/parc/security/parc_Security.h
+++ b/libparc/parc/security/parc_Security.h
diff --git a/libparc/parc/security/parc_Signature.c b/libparc/parc/security/parc_Signature.c
index 4b1abc06..4b1abc06 100755..100644
--- a/libparc/parc/security/parc_Signature.c
+++ b/libparc/parc/security/parc_Signature.c
diff --git a/libparc/parc/security/parc_Signature.h b/libparc/parc/security/parc_Signature.h
index 3d28ac56..3d28ac56 100755..100644
--- a/libparc/parc/security/parc_Signature.h
+++ b/libparc/parc/security/parc_Signature.h
diff --git a/libparc/parc/security/parc_Signer.h b/libparc/parc/security/parc_Signer.h
index 9bb0c6a1..9bb0c6a1 100755..100644
--- a/libparc/parc/security/parc_Signer.h
+++ b/libparc/parc/security/parc_Signer.h
diff --git a/libparc/parc/security/parc_SigningAlgorithm.c b/libparc/parc/security/parc_SigningAlgorithm.c
index 4d1765d7..4d1765d7 100755..100644
--- a/libparc/parc/security/parc_SigningAlgorithm.c
+++ b/libparc/parc/security/parc_SigningAlgorithm.c
diff --git a/libparc/parc/security/parc_SymmetricKeyStore.c b/libparc/parc/security/parc_SymmetricKeyStore.c
index 49d5055e..0d5f53e0 100644
--- a/libparc/parc/security/parc_SymmetricKeyStore.c
+++ b/libparc/parc/security/parc_SymmetricKeyStore.c
@@ -26,13 +26,15 @@
* @endcode
*/
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
#include <config.h>
#include <stdio.h>
#include <fcntl.h>
-#include <unistd.h>
#include <string.h>
#include <limits.h>
-#include <unistd.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
@@ -390,9 +392,11 @@ parcSymmetricKeyStore_CreateKey(unsigned bits)
parcAssertTrue((bits & 0x07) == 0, "bits must be a multiple of 8");
unsigned keylength = bits / 8;
- uint8_t buffer[keylength];
+ uint8_t *buffer = (uint8_t *)malloc(sizeof(uint8_t) * keylength);
RAND_bytes(buffer, keylength);
- return parcBuffer_Flip(parcBuffer_PutArray(parcBuffer_Allocate(keylength), keylength, buffer));
+ PARCBuffer *parcBuffer = parcBuffer_Flip(parcBuffer_PutArray(parcBuffer_Allocate(keylength), keylength, buffer));
+ free(buffer);
+ return parcBuffer;
}
PARCBuffer *
diff --git a/libparc/parc/security/parc_Verifier.c b/libparc/parc/security/parc_Verifier.c
index 75f99555..75f99555 100755..100644
--- a/libparc/parc/security/parc_Verifier.c
+++ b/libparc/parc/security/parc_Verifier.c
diff --git a/libparc/parc/security/parc_X509Certificate.c b/libparc/parc/security/parc_X509Certificate.c
index 2c964ae7..ab29bfa6 100644
--- a/libparc/parc/security/parc_X509Certificate.c
+++ b/libparc/parc/security/parc_X509Certificate.c
@@ -389,7 +389,7 @@ parcX509Certificate_CreateFromDERBuffer(const PARCBuffer *buffer)
PARCByteArray *array = parcBuffer_Array(buffer);
uint8_t *arrayIn = parcByteArray_Array(array);
- cert->certificate = d2i_X509(&cert->certificate, (const unsigned char **) &arrayIn, parcBuffer_Remaining(buffer));
+ cert->certificate = d2i_X509(&cert->certificate, (const unsigned char **) &arrayIn, (long)parcBuffer_Remaining(buffer));
if (cert->certificate == NULL) {
parcX509Certificate_Release(&cert);
return NULL;
diff --git a/libparc/parc/security/parc_X509Certificate.h b/libparc/parc/security/parc_X509Certificate.h
index c6ca8247..c6ca8247 100755..100644
--- a/libparc/parc/security/parc_X509Certificate.h
+++ b/libparc/parc/security/parc_X509Certificate.h
diff --git a/libparc/parc/security/test/test_parc_CertificateFactory.c b/libparc/parc/security/test/test_parc_CertificateFactory.c
index 29675f94..29675f94 100755..100644
--- a/libparc/parc/security/test/test_parc_CertificateFactory.c
+++ b/libparc/parc/security/test/test_parc_CertificateFactory.c
diff --git a/libparc/parc/security/test/test_parc_CertificateType.c b/libparc/parc/security/test/test_parc_CertificateType.c
index 67ce5e87..67ce5e87 100755..100644
--- a/libparc/parc/security/test/test_parc_CertificateType.c
+++ b/libparc/parc/security/test/test_parc_CertificateType.c
diff --git a/libparc/parc/security/test/test_parc_ContainerEncoding.c b/libparc/parc/security/test/test_parc_ContainerEncoding.c
index 01cafa50..01cafa50 100755..100644
--- a/libparc/parc/security/test/test_parc_ContainerEncoding.c
+++ b/libparc/parc/security/test/test_parc_ContainerEncoding.c
diff --git a/libparc/parc/security/test/test_parc_CryptoCache.c b/libparc/parc/security/test/test_parc_CryptoCache.c
index 8613808d..8613808d 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoCache.c
+++ b/libparc/parc/security/test/test_parc_CryptoCache.c
diff --git a/libparc/parc/security/test/test_parc_CryptoHash.c b/libparc/parc/security/test/test_parc_CryptoHash.c
index df5409b2..df5409b2 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoHash.c
+++ b/libparc/parc/security/test/test_parc_CryptoHash.c
diff --git a/libparc/parc/security/test/test_parc_CryptoHasher.c b/libparc/parc/security/test/test_parc_CryptoHasher.c
index 33a3f6bc..33a3f6bc 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoHasher.c
+++ b/libparc/parc/security/test/test_parc_CryptoHasher.c
diff --git a/libparc/parc/security/test/test_parc_CryptoSuite.c b/libparc/parc/security/test/test_parc_CryptoSuite.c
index 42007617..42007617 100755..100644
--- a/libparc/parc/security/test/test_parc_CryptoSuite.c
+++ b/libparc/parc/security/test/test_parc_CryptoSuite.c
diff --git a/libparc/parc/security/test/test_parc_DiffieHellman.c b/libparc/parc/security/test/test_parc_DiffieHellman.c
index 69bc109b..69bc109b 100755..100644
--- a/libparc/parc/security/test/test_parc_DiffieHellman.c
+++ b/libparc/parc/security/test/test_parc_DiffieHellman.c
diff --git a/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c b/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
index e8a2eeca..e8a2eeca 100755..100644
--- a/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
+++ b/libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c
diff --git a/libparc/parc/security/test/test_parc_InMemoryVerifier.c b/libparc/parc/security/test/test_parc_InMemoryVerifier.c
index 81baebc7..81baebc7 100755..100644
--- a/libparc/parc/security/test/test_parc_InMemoryVerifier.c
+++ b/libparc/parc/security/test/test_parc_InMemoryVerifier.c
diff --git a/libparc/parc/security/test/test_parc_Key.c b/libparc/parc/security/test/test_parc_Key.c
index d22362b0..d22362b0 100755..100644
--- a/libparc/parc/security/test/test_parc_Key.c
+++ b/libparc/parc/security/test/test_parc_Key.c
diff --git a/libparc/parc/security/test/test_parc_KeyStore.c b/libparc/parc/security/test/test_parc_KeyStore.c
index b48099cb..b48099cb 100755..100644
--- a/libparc/parc/security/test/test_parc_KeyStore.c
+++ b/libparc/parc/security/test/test_parc_KeyStore.c
diff --git a/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c b/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
index 17a5b60f..17a5b60f 100755..100644
--- a/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
+++ b/libparc/parc/security/test/test_parc_Pkcs12KeyStore.c
diff --git a/libparc/parc/security/test/test_parc_SecureRandom.c b/libparc/parc/security/test/test_parc_SecureRandom.c
index 82359a70..82359a70 100755..100644
--- a/libparc/parc/security/test/test_parc_SecureRandom.c
+++ b/libparc/parc/security/test/test_parc_SecureRandom.c
diff --git a/libparc/parc/security/test/test_parc_Security.c b/libparc/parc/security/test/test_parc_Security.c
index c2f2f33e..c2f2f33e 100755..100644
--- a/libparc/parc/security/test/test_parc_Security.c
+++ b/libparc/parc/security/test/test_parc_Security.c
diff --git a/libparc/parc/security/test/test_parc_Signature.c b/libparc/parc/security/test/test_parc_Signature.c
index 4c57d5a9..4c57d5a9 100755..100644
--- a/libparc/parc/security/test/test_parc_Signature.c
+++ b/libparc/parc/security/test/test_parc_Signature.c
diff --git a/libparc/parc/security/test/test_parc_SigningAlgorithm.c b/libparc/parc/security/test/test_parc_SigningAlgorithm.c
index 12e50956..12e50956 100755..100644
--- a/libparc/parc/security/test/test_parc_SigningAlgorithm.c
+++ b/libparc/parc/security/test/test_parc_SigningAlgorithm.c
diff --git a/libparc/parc/security/test/test_parc_SymmetricKeyStore.c b/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
index ab9dfddb..ab9dfddb 100755..100644
--- a/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
+++ b/libparc/parc/security/test/test_parc_SymmetricKeyStore.c
diff --git a/libparc/parc/security/test/test_parc_Verifier.c b/libparc/parc/security/test/test_parc_Verifier.c
index fe382a9b..fe382a9b 100755..100644
--- a/libparc/parc/security/test/test_parc_Verifier.c
+++ b/libparc/parc/security/test/test_parc_Verifier.c
diff --git a/libparc/parc/security/test/test_parc_X509Certificate.c b/libparc/parc/security/test/test_parc_X509Certificate.c
index dda9a9ff..dda9a9ff 100755..100644
--- a/libparc/parc/security/test/test_parc_X509Certificate.c
+++ b/libparc/parc/security/test/test_parc_X509Certificate.c
diff --git a/libparc/parc/statistics/parc_BasicStats.h b/libparc/parc/statistics/parc_BasicStats.h
index 5f82e582..5f82e582 100755..100644
--- a/libparc/parc/statistics/parc_BasicStats.h
+++ b/libparc/parc/statistics/parc_BasicStats.h
diff --git a/libparc/parc/statistics/parc_EWMA.c b/libparc/parc/statistics/parc_EWMA.c
index 92046ac2..911aba34 100644
--- a/libparc/parc/statistics/parc_EWMA.c
+++ b/libparc/parc/statistics/parc_EWMA.c
@@ -93,7 +93,7 @@ parcEWMA_Compare(const PARCEWMA *instance, const PARCEWMA *other)
} else if (other == NULL) {
result = 1;
} else {
- result = instance->value - other->value;
+ result = (int)(instance->value - other->value);
}
return result;
@@ -132,7 +132,7 @@ parcEWMA_Equals(const PARCEWMA *x, const PARCEWMA *y)
} else {
if (x->initialized == y->initialized) {
if (_parcEWMA_FloatEquals(x->coefficient, y->coefficient, 0.00001)) {
- if (_parcEWMA_FloatEquals(x->value, y->value, 0.00001)) {
+ if (_parcEWMA_FloatEquals((double)(x->value), (double)(y->value), 0.00001)) {
result = true;
}
}
@@ -192,7 +192,7 @@ parcEWMA_Update(PARCEWMA *ewma, const int64_t value)
double x = (ewma->coefficient * value);
double y = (ewma->coefficient_r * ewma->value);
- ewma->value = x + y;
+ ewma->value = (int64_t)(x + y);
} else {
ewma->value = value;
ewma->initialized = true;
diff --git a/libparc/parc/statistics/parc_EWMA.h b/libparc/parc/statistics/parc_EWMA.h
index bbcb53df..bbcb53df 100755..100644
--- a/libparc/parc/statistics/parc_EWMA.h
+++ b/libparc/parc/statistics/parc_EWMA.h
diff --git a/libparc/parc/testing/parc_MemoryTesting.c b/libparc/parc/testing/parc_MemoryTesting.c
index 5d53a877..5d53a877 100755..100644
--- a/libparc/parc/testing/parc_MemoryTesting.c
+++ b/libparc/parc/testing/parc_MemoryTesting.c
diff --git a/libparc/parc/testing/parc_MemoryTesting.h b/libparc/parc/testing/parc_MemoryTesting.h
index 9ac6889d..9ac6889d 100755..100644
--- a/libparc/parc/testing/parc_MemoryTesting.h
+++ b/libparc/parc/testing/parc_MemoryTesting.h
diff --git a/libparc/parc/testing/test/test_parc_MemoryTesting.c b/libparc/parc/testing/test/test_parc_MemoryTesting.c
index d24e79d4..d24e79d4 100755..100644
--- a/libparc/parc/testing/test/test_parc_MemoryTesting.c
+++ b/libparc/parc/testing/test/test_parc_MemoryTesting.c
diff --git a/libparc/parc/testing/test/test_parc_ObjectTesting.c b/libparc/parc/testing/test/test_parc_ObjectTesting.c
index 9d70b68c..9d70b68c 100755..100644
--- a/libparc/parc/testing/test/test_parc_ObjectTesting.c
+++ b/libparc/parc/testing/test/test_parc_ObjectTesting.c
diff --git a/libparc/parc/windows/getopt.c b/libparc/parc/windows/getopt.c
new file mode 100644
index 00000000..1deaf81e
--- /dev/null
+++ b/libparc/parc/windows/getopt.c
@@ -0,0 +1,149 @@
+/* $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $ */
+
+/*
+ * Copyright (c) 1987, 1993, 1994, 1995
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if 0
+static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
+#endif
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#define __P(x) x
+#define _DIAGASSERT(x) assert(x)
+
+#ifdef __weak_alias
+__weak_alias(getopt,_getopt);
+#endif
+
+
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt, /* character checked for validity */
+ optreset; /* reset getopt */
+char *optarg; /* argument associated with option */
+
+static char * _progname __P((char *));
+int getopt_internal __P((int, char * const *, const char *));
+
+static char *
+_progname(nargv0)
+ char * nargv0;
+{
+ char * tmp;
+
+ _DIAGASSERT(nargv0 != NULL);
+
+ tmp = strrchr(nargv0, '/');
+ if (tmp)
+ tmp++;
+ else
+ tmp = nargv0;
+ return(tmp);
+}
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt(nargc, nargv, ostr)
+ int nargc;
+ char * const nargv[];
+ const char *ostr;
+{
+ static char *__progname = 0;
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+ __progname = __progname?__progname:_progname(*nargv);
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(ostr != NULL);
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return (-1);
+ }
+ if (place[1] && *++place == '-' /* found "--" */
+ && place[1] == '\0') {
+ ++optind;
+ place = EMSG;
+ return (-1);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int)'-')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: illegal option -- %c\n", __progname, optopt);
+ return (BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ }
+ else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if (*ostr == ':')
+ return (BADARG);
+ if (opterr)
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ __progname, optopt);
+ return (BADCH);
+ }
+ else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
+}
+
diff --git a/libparc/parc/windows/getopt.h b/libparc/parc/windows/getopt.h
new file mode 100644
index 00000000..6f0c19ee
--- /dev/null
+++ b/libparc/parc/windows/getopt.h
@@ -0,0 +1,33 @@
+#ifndef __GETOPT_H__
+#define __GETOPT_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int opterr; /* if error message should be printed */
+extern int optind; /* index into parent argv vector */
+extern int optopt; /* character checked for validity */
+extern int optreset; /* reset getopt */
+extern char *optarg; /* argument associated with option */
+
+struct option
+{
+ const char *name;
+ int has_arg;
+ int *flag;
+ int val;
+};
+
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
+
+int getopt(int, char**, const char*);
+int getopt_long(int, char**, const char*, const struct option*, int*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __GETOPT_H__ */
diff --git a/libparc/parc/windows/getopt_long.c b/libparc/parc/windows/getopt_long.c
new file mode 100644
index 00000000..23321dd1
--- /dev/null
+++ b/libparc/parc/windows/getopt_long.c
@@ -0,0 +1,233 @@
+
+/*
+ * Copyright (c) 1987, 1993, 1994, 1996
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "getopt.h"
+
+extern int opterr; /* if error message should be printed */
+extern int optind; /* index into parent argv vector */
+extern int optopt; /* character checked for validity */
+extern int optreset; /* reset getopt */
+extern char *optarg; /* argument associated with option */
+
+#define __P(x) x
+#define _DIAGASSERT(x) assert(x)
+
+static char * __progname __P((char *));
+int getopt_internal __P((int, char * const *, const char *));
+
+static char *
+__progname(nargv0)
+ char * nargv0;
+{
+ char * tmp;
+
+ _DIAGASSERT(nargv0 != NULL);
+
+ tmp = strrchr(nargv0, '/');
+ if (tmp)
+ tmp++;
+ else
+ tmp = nargv0;
+ return(tmp);
+}
+
+#define BADCH (int)'?'
+#define BADARG (int)':'
+#define EMSG ""
+
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_internal(nargc, nargv, ostr)
+ int nargc;
+ char * const *nargv;
+ const char *ostr;
+{
+ static char *place = EMSG; /* option letter processing */
+ char *oli; /* option letter list index */
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(ostr != NULL);
+
+ if (optreset || !*place) { /* update scanning pointer */
+ optreset = 0;
+ if (optind >= nargc || *(place = nargv[optind]) != '-') {
+ place = EMSG;
+ return (-1);
+ }
+ if (place[1] && *++place == '-') { /* found "--" */
+ /* ++optind; */
+ place = EMSG;
+ return (-2);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' ||
+ !(oli = strchr(ostr, optopt))) {
+ /*
+ * if the user didn't specify '-' as an option,
+ * assume it means -1.
+ */
+ if (optopt == (int)'-')
+ return (-1);
+ if (!*place)
+ ++optind;
+ if (opterr && *ostr != ':')
+ (void)fprintf(stderr,
+ "%s: illegal option -- %c\n", __progname(nargv[0]), optopt);
+ return (BADCH);
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place)
+ ++optind;
+ } else { /* need an argument */
+ if (*place) /* no white space */
+ optarg = place;
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ if ((opterr) && (*ostr != ':'))
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %c\n",
+ __progname(nargv[0]), optopt);
+ return (BADARG);
+ } else /* white space */
+ optarg = nargv[optind];
+ place = EMSG;
+ ++optind;
+ }
+ return (optopt); /* dump back option letter */
+}
+
+#if 0
+/*
+ * getopt --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt2(nargc, nargv, ostr)
+ int nargc;
+ char * const *nargv;
+ const char *ostr;
+{
+ int retval;
+
+ if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) {
+ retval = -1;
+ ++optind;
+ }
+ return(retval);
+}
+#endif
+
+/*
+ * getopt_long --
+ * Parse argc/argv argument vector.
+ */
+int
+getopt_long(nargc, nargv, options, long_options, index)
+ int nargc;
+ char ** nargv;
+ const char * options;
+ const struct option * long_options;
+ int * index;
+{
+ int retval;
+
+ _DIAGASSERT(nargv != NULL);
+ _DIAGASSERT(options != NULL);
+ _DIAGASSERT(long_options != NULL);
+ /* index may be NULL */
+
+ if ((retval = getopt_internal(nargc, nargv, options)) == -2) {
+ char *current_argv = nargv[optind++] + 2, *has_equal;
+ int i, current_argv_len, match = -1;
+
+ if (*current_argv == '\0') {
+ return(-1);
+ }
+ if ((has_equal = strchr(current_argv, '=')) != NULL) {
+ current_argv_len = (int)(has_equal - current_argv);
+ has_equal++;
+ } else
+ current_argv_len = (int)strlen(current_argv);
+
+ for (i = 0; long_options[i].name; i++) {
+ if (strncmp(current_argv, long_options[i].name, current_argv_len))
+ continue;
+
+ if (strlen(long_options[i].name) == (unsigned)current_argv_len) {
+ match = i;
+ break;
+ }
+ if (match == -1)
+ match = i;
+ }
+ if (match != -1) {
+ if (long_options[match].has_arg == required_argument ||
+ long_options[match].has_arg == optional_argument) {
+ if (has_equal)
+ optarg = has_equal;
+ else
+ optarg = nargv[optind++];
+ }
+ if ((long_options[match].has_arg == required_argument)
+ && (optarg == NULL)) {
+ /*
+ * Missing argument, leading :
+ * indicates no error should be generated
+ */
+ if ((opterr) && (*options != ':'))
+ (void)fprintf(stderr,
+ "%s: option requires an argument -- %s\n",
+ __progname(nargv[0]), current_argv);
+ return (BADARG);
+ }
+ } else { /* No matching argument */
+ if ((opterr) && (*options != ':'))
+ (void)fprintf(stderr,
+ "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv);
+ return (BADCH);
+ }
+ if (long_options[match].flag) {
+ *long_options[match].flag = long_options[match].val;
+ retval = 0;
+ } else
+ retval = long_options[match].val;
+ if (index)
+ *index = match;
+ }
+ return(retval);
+}
diff --git a/libparc/parc/windows/parc_Utils.c b/libparc/parc/windows/parc_Utils.c
new file mode 100644
index 00000000..8daf57fd
--- /dev/null
+++ b/libparc/parc/windows/parc_Utils.c
@@ -0,0 +1,128 @@
+
+/*
+ * 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 <parc/windows/parc_Utils.h>
+#include <Windows.h>
+#include <stdint.h>
+#include <stdio.h>
+#ifndef _vscprintf
+/* For some reason, MSVC fails to honour this #ifndef. */
+/* Hence function renamed to _vscprintf_so(). */
+int _vscprintf_so(const char *format, va_list pargs)
+{
+ int retval;
+ va_list argcopy;
+ va_copy(argcopy, pargs);
+ retval = vsnprintf(NULL, 0, format, argcopy);
+ va_end(argcopy);
+ return retval;
+}
+#endif // _vscprintf
+
+#ifndef vasprintf
+int vasprintf(char **strp, const char *fmt, va_list ap)
+{
+ int len = _vscprintf_so(fmt, ap);
+ if (len == -1)
+ return -1;
+ char *str = malloc((size_t)len + 1);
+ if (!str)
+ return -1;
+ int r = vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */
+ if (r == -1)
+ return free(str), -1;
+ *strp = str;
+ return r;
+}
+#endif // vasprintf
+
+#ifndef dprintf
+int dprintf(int fd, char *fmt, ...) {
+ va_list ap;
+ FILE *f = _fdopen( fd, "rw" );
+ int rc;
+
+ va_start(ap, &fmt);
+ rc = vfprintf(f, fmt, ap);
+ fclose(f);
+ va_end(ap);
+ return rc;
+}
+#endif
+
+#ifndef asprintf
+int asprintf(char *strp[], const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ int r = vasprintf(strp, fmt, ap);
+ va_end(ap);
+ return r;
+}
+#endif // asprintf
+
+
+int gettimeofday(struct timeval * tp, struct timezone * tzp)
+{
+ // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
+ // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
+ // until 00:00:00 January 1, 1970
+ static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);
+
+ SYSTEMTIME system_time;
+ FILETIME file_time;
+ uint64_t time;
+
+ GetSystemTime( &system_time );
+ SystemTimeToFileTime( &system_time, &file_time );
+ time = ((uint64_t)file_time.dwLowDateTime ) ;
+ time += ((uint64_t)file_time.dwHighDateTime) << 32;
+
+ tp->tv_sec = (long) ((time - EPOCH) / 10000000L);
+ tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
+ return 0;
+}
+
+#ifndef strndup
+char *strndup(const char *str, size_t chars)
+{
+ char *buffer;
+ int n;
+
+ buffer = (char *) malloc(chars +1);
+ if (buffer)
+ {
+ for (n = 0; ((n < chars) && (str[n] != 0)) ; n++) buffer[n] = str[n];
+ buffer[n] = 0;
+ }
+
+ return buffer;
+}
+#endif
+
+
+void usleep(__int64 usec)
+{
+ HANDLE timer;
+ LARGE_INTEGER ft;
+
+ ft.QuadPart = -(10 * usec); // Convert to 100 nanosecond interval, negative value indicates relative time
+
+ timer = CreateWaitableTimer(NULL, TRUE, NULL);
+ SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
+ WaitForSingleObject(timer, INFINITE);
+ CloseHandle(timer);
+} \ No newline at end of file
diff --git a/libparc/parc/windows/parc_Utils.h b/libparc/parc/windows/parc_Utils.h
new file mode 100644
index 00000000..975eae0f
--- /dev/null
+++ b/libparc/parc/windows/parc_Utils.h
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+#ifndef PARC_UTILS_H
+#define PARC_UTILS_H
+#define WIN32_LEAN_AND_MEAN
+#define HAVE_STRUCT_TIMESPEC
+#include <Windows.h>
+#include <stdint.h>
+#include <io.h>
+#include <stdlib.h>
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#include <parc/windows/getopt.h>
+#include <parc/windows/queue.h>
+
+#ifndef IOVEC
+#define IOVEC
+struct iovec {
+ void* iov_base;
+ size_t iov_len;
+};
+#endif
+
+typedef uint16_t in_port_t;
+
+#ifndef SLEEP
+#define SLEEP
+#define sleep Sleep
+#endif
+
+#ifndef USLEEP
+#define USLEEP
+void usleep(__int64 usec);
+#endif
+
+#ifndef S_ISDIR
+#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#endif
+
+#define PARCLibrary_DISABLE_ATOMICS
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+
+#ifndef __ATTRIBUTE__
+#define __ATTRIBUTE__
+#define __attribute__(A)
+#endif
+
+#ifndef RESTRICT
+#define RESTRICT
+#define restrict __restrict
+#endif
+
+#ifndef _vscprintf
+/* For some reason, MSVC fails to honour this #ifndef. */
+/* Hence function renamed to _vscprintf_so(). */
+int _vscprintf_so(const char *format, va_list pargs);
+#endif // _vscprintf
+
+#ifndef vasprintf
+int vasprintf(char **strp, const char *fmt, va_list ap);
+#endif // vasprintf
+
+#ifndef asprintf
+int asprintf(char *strp[], const char *fmt, ...);
+#endif // asprintf
+
+#ifndef GETTIMEOFDAY
+#define GETTIMEOFDAY
+int gettimeofday(struct timeval * tp, struct timezone * tzp);
+#endif
+
+#ifndef strndup
+char *strndup(const char *str, size_t chars);
+#endif
+
+#ifndef dprintf
+int dprintf(int fd, char *fmt, ...);
+#endif
+
+#ifndef timersub
+#define timersub(a, b, result) \
+ do { \
+ (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
+ (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
+ if ((result)->tv_usec < 0) { \
+ --(result)->tv_sec; \
+ (result)->tv_usec += 1000000; \
+ } \
+ } while (0)
+#endif // timersub
+
+#ifndef dup
+#define dup _dup
+#endif
+
+#ifndef access
+#define access _access
+#endif
+
+#ifndef close
+#define close _close
+#endif
+
+#ifndef write
+#define write _write
+#endif
+
+#ifndef open
+#define open _open
+#endif
+
+#ifndef unlink
+#define unlink _unlink
+#endif
+
+#ifndef read
+#define read _read
+#endif
+
+#ifndef strcasecmp
+#define strncasecmp _strnicmp
+#endif
+
+#ifndef strcasecmp
+
+#define strcasecmp _stricmp
+#endif
+
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
+#endif
+#ifndef R_OK
+#define R_OK 4 /* Test for read permission. */
+#endif
+#ifndef W_OK
+#define W_OK 2 /* Test for write permission. */
+#endif
+#ifndef F_OK
+#define F_OK 0
+#endif
+
+#ifndef STDIN_FILENO
+#define STDIN_FILENO _fileno(stdin)
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO _fileno(stdout)
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO _fileno(stderr)
+#endif
+
+#endif \ No newline at end of file
diff --git a/libparc/parc/windows/queue.h b/libparc/parc/windows/queue.h
new file mode 100644
index 00000000..925ccf14
--- /dev/null
+++ b/libparc/parc/windows/queue.h
@@ -0,0 +1,488 @@
+/* $OpenBSD: queue.h,v 1.16 2000/09/07 19:47:59 art Exp $ */
+/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)queue.h 8.5 (Berkeley) 8/20/94
+ */
+
+#ifndef SYS_QUEUE_H__
+#define SYS_QUEUE_H__
+
+ /*
+ * This file defines five types of data structures: singly-linked lists,
+ * lists, simple queues, tail queues, and circular queues.
+ *
+ *
+ * A singly-linked list is headed by a single forward pointer. The elements
+ * are singly linked for minimum space and pointer manipulation overhead at
+ * the expense of O(n) removal for arbitrary elements. New elements can be
+ * added to the list after an existing element or at the head of the list.
+ * Elements being removed from the head of the list should use the explicit
+ * macro for this purpose for optimum efficiency. A singly-linked list may
+ * only be traversed in the forward direction. Singly-linked lists are ideal
+ * for applications with large datasets and few or no removals or for
+ * implementing a LIFO queue.
+ *
+ * A list is headed by a single forward pointer (or an array of forward
+ * pointers for a hash table header). The elements are doubly linked
+ * so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before
+ * or after an existing element or at the head of the list. A list
+ * may only be traversed in the forward direction.
+ *
+ * A simple queue is headed by a pair of pointers, one the head of the
+ * list and the other to the tail of the list. The elements are singly
+ * linked to save space, so elements can only be removed from the
+ * head of the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the
+ * list. A simple queue may only be traversed in the forward direction.
+ *
+ * A tail queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or
+ * after an existing element, at the head of the list, or at the end of
+ * the list. A tail queue may be traversed in either direction.
+ *
+ * A circle queue is headed by a pair of pointers, one to the head of the
+ * list and the other to the tail of the list. The elements are doubly
+ * linked so that an arbitrary element can be removed without a need to
+ * traverse the list. New elements can be added to the list before or after
+ * an existing element, at the head of the list, or at the end of the list.
+ * A circle queue may be traversed in either direction, but has a more
+ * complex end of list detection.
+ *
+ * For details on the use of these macros, see the queue(3) manual page.
+ */
+
+ /*
+ * Singly-linked List definitions.
+ */
+#define SLIST_HEAD(name, type) \
+struct name { \
+ struct type *slh_first; /* first element */ \
+}
+
+#define SLIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#ifndef _WIN32
+#define SLIST_ENTRY(type) \
+struct { \
+ struct type *sle_next; /* next element */ \
+}
+#endif
+
+ /*
+ * Singly-linked List access methods.
+ */
+#define SLIST_FIRST(head) ((head)->slh_first)
+#define SLIST_END(head) NULL
+#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
+#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
+
+#define SLIST_FOREACH(var, head, field) \
+ for((var) = SLIST_FIRST(head); \
+ (var) != SLIST_END(head); \
+ (var) = SLIST_NEXT(var, field))
+
+ /*
+ * Singly-linked List functions.
+ */
+#define SLIST_INIT(head) { \
+ SLIST_FIRST(head) = SLIST_END(head); \
+}
+
+#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
+ (elm)->field.sle_next = (slistelm)->field.sle_next; \
+ (slistelm)->field.sle_next = (elm); \
+} while (0)
+
+#define SLIST_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.sle_next = (head)->slh_first; \
+ (head)->slh_first = (elm); \
+} while (0)
+
+#define SLIST_REMOVE_HEAD(head, field) do { \
+ (head)->slh_first = (head)->slh_first->field.sle_next; \
+} while (0)
+
+ /*
+ * List definitions.
+ */
+#define LIST_HEAD(name, type) \
+struct name { \
+ struct type *lh_first; /* first element */ \
+}
+
+#define LIST_HEAD_INITIALIZER(head) \
+ { NULL }
+
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+ /*
+ * List access methods
+ */
+#define LIST_FIRST(head) ((head)->lh_first)
+#define LIST_END(head) NULL
+#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
+#define LIST_NEXT(elm, field) ((elm)->field.le_next)
+
+#define LIST_FOREACH(var, head, field) \
+ for((var) = LIST_FIRST(head); \
+ (var)!= LIST_END(head); \
+ (var) = LIST_NEXT(var, field))
+
+ /*
+ * List functions.
+ */
+#define LIST_INIT(head) do { \
+ LIST_FIRST(head) = LIST_END(head); \
+} while (0)
+
+#define LIST_INSERT_AFTER(listelm, elm, field) do { \
+ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
+ (listelm)->field.le_next->field.le_prev = \
+ &(elm)->field.le_next; \
+ (listelm)->field.le_next = (elm); \
+ (elm)->field.le_prev = &(listelm)->field.le_next; \
+} while (0)
+
+#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.le_prev = (listelm)->field.le_prev; \
+ (elm)->field.le_next = (listelm); \
+ *(listelm)->field.le_prev = (elm); \
+ (listelm)->field.le_prev = &(elm)->field.le_next; \
+} while (0)
+
+#define LIST_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.le_next = (head)->lh_first) != NULL) \
+ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\
+ (head)->lh_first = (elm); \
+ (elm)->field.le_prev = &(head)->lh_first; \
+} while (0)
+
+#define LIST_REMOVE(elm, field) do { \
+ if ((elm)->field.le_next != NULL) \
+ (elm)->field.le_next->field.le_prev = \
+ (elm)->field.le_prev; \
+ *(elm)->field.le_prev = (elm)->field.le_next; \
+} while (0)
+
+#define LIST_REPLACE(elm, elm2, field) do { \
+ if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
+ (elm2)->field.le_next->field.le_prev = \
+ &(elm2)->field.le_next; \
+ (elm2)->field.le_prev = (elm)->field.le_prev; \
+ *(elm2)->field.le_prev = (elm2); \
+} while (0)
+
+ /*
+ * Simple queue definitions.
+ */
+#define SIMPLEQ_HEAD(name, type) \
+struct name { \
+ struct type *sqh_first; /* first element */ \
+ struct type **sqh_last; /* addr of last next element */ \
+}
+
+#define SIMPLEQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).sqh_first }
+
+#define SIMPLEQ_ENTRY(type) \
+struct { \
+ struct type *sqe_next; /* next element */ \
+}
+
+ /*
+ * Simple queue access methods.
+ */
+#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
+#define SIMPLEQ_END(head) NULL
+#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
+#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
+
+#define SIMPLEQ_FOREACH(var, head, field) \
+ for((var) = SIMPLEQ_FIRST(head); \
+ (var) != SIMPLEQ_END(head); \
+ (var) = SIMPLEQ_NEXT(var, field))
+
+ /*
+ * Simple queue functions.
+ */
+#define SIMPLEQ_INIT(head) do { \
+ (head)->sqh_first = NULL; \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (0)
+
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (head)->sqh_first = (elm); \
+} while (0)
+
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.sqe_next = NULL; \
+ *(head)->sqh_last = (elm); \
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+} while (0)
+
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
+ (head)->sqh_last = &(elm)->field.sqe_next; \
+ (listelm)->field.sqe_next = (elm); \
+} while (0)
+
+#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \
+ if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \
+ (head)->sqh_last = &(head)->sqh_first; \
+} while (0)
+
+ /*
+ * Tail queue definitions.
+ */
+#define TAILQ_HEAD(name, type) \
+struct name { \
+ struct type *tqh_first; /* first element */ \
+ struct type **tqh_last; /* addr of last next element */ \
+}
+
+#define TAILQ_HEAD_INITIALIZER(head) \
+ { NULL, &(head).tqh_first }
+
+#define TAILQ_ENTRY(type) \
+struct { \
+ struct type *tqe_next; /* next element */ \
+ struct type **tqe_prev; /* address of previous next element */ \
+}
+
+ /*
+ * tail queue access methods
+ */
+#define TAILQ_FIRST(head) ((head)->tqh_first)
+#define TAILQ_END(head) NULL
+#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
+#define TAILQ_LAST(head, headname) \
+ (*(((struct headname *)((head)->tqh_last))->tqh_last))
+ /* XXX */
+#define TAILQ_PREV(elm, headname, field) \
+ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+#define TAILQ_EMPTY(head) \
+ (TAILQ_FIRST(head) == TAILQ_END(head))
+
+#define TAILQ_FOREACH(var, head, field) \
+ for((var) = TAILQ_FIRST(head); \
+ (var) != TAILQ_END(head); \
+ (var) = TAILQ_NEXT(var, field))
+
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
+ for((var) = TAILQ_LAST(head, headname); \
+ (var) != TAILQ_END(head); \
+ (var) = TAILQ_PREV(var, headname, field))
+
+/*
+ * Tail queue functions.
+ */
+#define TAILQ_INIT(head) do { \
+ (head)->tqh_first = NULL; \
+ (head)->tqh_last = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_HEAD(head, elm, field) do { \
+ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
+ (head)->tqh_first->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (head)->tqh_first = (elm); \
+ (elm)->field.tqe_prev = &(head)->tqh_first; \
+} while (0)
+
+#define TAILQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.tqe_next = NULL; \
+ (elm)->field.tqe_prev = (head)->tqh_last; \
+ *(head)->tqh_last = (elm); \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
+ (elm)->field.tqe_next->field.tqe_prev = \
+ &(elm)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm)->field.tqe_next; \
+ (listelm)->field.tqe_next = (elm); \
+ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
+ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
+ (elm)->field.tqe_next = (listelm); \
+ *(listelm)->field.tqe_prev = (elm); \
+ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_REMOVE(head, elm, field) do { \
+ if (((elm)->field.tqe_next) != NULL) \
+ (elm)->field.tqe_next->field.tqe_prev = \
+ (elm)->field.tqe_prev; \
+ else \
+ (head)->tqh_last = (elm)->field.tqe_prev; \
+ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \
+} while (0)
+
+#define TAILQ_REPLACE(head, elm, elm2, field) do { \
+ if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
+ (elm2)->field.tqe_next->field.tqe_prev = \
+ &(elm2)->field.tqe_next; \
+ else \
+ (head)->tqh_last = &(elm2)->field.tqe_next; \
+ (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
+ *(elm2)->field.tqe_prev = (elm2); \
+} while (0)
+
+ /*
+ * Circular queue definitions.
+ */
+#define CIRCLEQ_HEAD(name, type) \
+struct name { \
+ struct type *cqh_first; /* first element */ \
+ struct type *cqh_last; /* last element */ \
+}
+
+#define CIRCLEQ_HEAD_INITIALIZER(head) \
+ { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
+
+#define CIRCLEQ_ENTRY(type) \
+struct { \
+ struct type *cqe_next; /* next element */ \
+ struct type *cqe_prev; /* previous element */ \
+}
+
+ /*
+ * Circular queue access methods
+ */
+#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
+#define CIRCLEQ_LAST(head) ((head)->cqh_last)
+#define CIRCLEQ_END(head) ((void *)(head))
+#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
+#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
+#define CIRCLEQ_EMPTY(head) \
+ (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
+
+#define CIRCLEQ_FOREACH(var, head, field) \
+ for((var) = CIRCLEQ_FIRST(head); \
+ (var) != CIRCLEQ_END(head); \
+ (var) = CIRCLEQ_NEXT(var, field))
+
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
+ for((var) = CIRCLEQ_LAST(head); \
+ (var) != CIRCLEQ_END(head); \
+ (var) = CIRCLEQ_PREV(var, field))
+
+ /*
+ * Circular queue functions.
+ */
+#define CIRCLEQ_INIT(head) do { \
+ (head)->cqh_first = CIRCLEQ_END(head); \
+ (head)->cqh_last = CIRCLEQ_END(head); \
+} while (0)
+
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm)->field.cqe_next; \
+ (elm)->field.cqe_prev = (listelm); \
+ if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (listelm)->field.cqe_next->field.cqe_prev = (elm); \
+ (listelm)->field.cqe_next = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
+ (elm)->field.cqe_next = (listelm); \
+ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
+ if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (listelm)->field.cqe_prev->field.cqe_next = (elm); \
+ (listelm)->field.cqe_prev = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
+ (elm)->field.cqe_next = (head)->cqh_first; \
+ (elm)->field.cqe_prev = CIRCLEQ_END(head); \
+ if ((head)->cqh_last == CIRCLEQ_END(head)) \
+ (head)->cqh_last = (elm); \
+ else \
+ (head)->cqh_first->field.cqe_prev = (elm); \
+ (head)->cqh_first = (elm); \
+} while (0)
+
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
+ (elm)->field.cqe_next = CIRCLEQ_END(head); \
+ (elm)->field.cqe_prev = (head)->cqh_last; \
+ if ((head)->cqh_first == CIRCLEQ_END(head)) \
+ (head)->cqh_first = (elm); \
+ else \
+ (head)->cqh_last->field.cqe_next = (elm); \
+ (head)->cqh_last = (elm); \
+} while (0)
+
+#define CIRCLEQ_REMOVE(head, elm, field) do { \
+ if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
+ (head)->cqh_last = (elm)->field.cqe_prev; \
+ else \
+ (elm)->field.cqe_next->field.cqe_prev = \
+ (elm)->field.cqe_prev; \
+ if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
+ (head)->cqh_first = (elm)->field.cqe_next; \
+ else \
+ (elm)->field.cqe_prev->field.cqe_next = \
+ (elm)->field.cqe_next; \
+} while (0)
+
+#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
+ if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
+ CIRCLEQ_END(head)) \
+ (head).cqh_last = (elm2); \
+ else \
+ (elm2)->field.cqe_next->field.cqe_prev = (elm2); \
+ if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
+ CIRCLEQ_END(head)) \
+ (head).cqh_first = (elm2); \
+ else \
+ (elm2)->field.cqe_prev->field.cqe_next = (elm2); \
+} while (0)
+
+#endif /* !SYS_QUEUE_H__ */ \ No newline at end of file