[HICN-26] Windows compatibilty for libparc 14/17314/15
authorAngelo Mantellini <[email protected]>
Tue, 5 Feb 2019 07:50:26 +0000 (08:50 +0100)
committerAngelo Mantellini <[email protected]>
Wed, 6 Feb 2019 15:23:04 +0000 (16:23 +0100)
Change-Id: I6ebff82a81a2bf42fa3bf210ff0e6e530ce21915
Signed-off-by: Angelo Mantellini <[email protected]>
300 files changed:
libparc/CMakeLists.txt
libparc/cmake/Modules/FindPThread.cmake [new file with mode: 0644]
libparc/cmake/get_version.sh [changed mode: 0755->0644]
libparc/documentation/doxygen-extras/doxygen-bootstrap.js [changed mode: 0755->0644]
libparc/documentation/doxygen-extras/footer.html [changed mode: 0755->0644]
libparc/documentation/doxygen-extras/header.html [changed mode: 0755->0644]
libparc/examples/How To Create A Static PARC Object/main.c [changed mode: 0755->0644]
libparc/parc/CMakeLists.txt
libparc/parc/algol/internal_parc_Event.c [changed mode: 0755->0644]
libparc/parc/algol/internal_parc_Event.h [changed mode: 0755->0644]
libparc/parc/algol/parc_AtomicInteger.c [changed mode: 0755->0644]
libparc/parc/algol/parc_AtomicInteger.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Base64.c [changed mode: 0755->0644]
libparc/parc/algol/parc_BitVector.c [changed mode: 0755->0644]
libparc/parc/algol/parc_BitVector.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Buffer.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Buffer.h
libparc/parc/algol/parc_BufferChunker.c
libparc/parc/algol/parc_BufferChunker.h [changed mode: 0755->0644]
libparc/parc/algol/parc_BufferComposer.c [changed mode: 0755->0644]
libparc/parc/algol/parc_BufferComposer.h [changed mode: 0755->0644]
libparc/parc/algol/parc_BufferDictionary.c [changed mode: 0755->0644]
libparc/parc/algol/parc_BufferDictionary.h [changed mode: 0755->0644]
libparc/parc/algol/parc_ByteArray.c
libparc/parc/algol/parc_ByteArray.h
libparc/parc/algol/parc_CMacro.h
libparc/parc/algol/parc_Chunker.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Chunker.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Clock.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Clock.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Collection.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Deque.c
libparc/parc/algol/parc_Deque.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Dictionary.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Dictionary.h [changed mode: 0755->0644]
libparc/parc/algol/parc_DisplayIndented.c [changed mode: 0755->0644]
libparc/parc/algol/parc_ElasticString.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Environment.c
libparc/parc/algol/parc_Environment.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Event.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventBuffer.c
libparc/parc/algol/parc_EventBuffer.h [changed mode: 0755->0644]
libparc/parc/algol/parc_EventQueue.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventQueue.h
libparc/parc/algol/parc_EventScheduler.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventSignal.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventSignal.h [changed mode: 0755->0644]
libparc/parc/algol/parc_EventSocket.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventSocket.h [changed mode: 0755->0644]
libparc/parc/algol/parc_EventTimer.c [changed mode: 0755->0644]
libparc/parc/algol/parc_EventTimer.h [changed mode: 0755->0644]
libparc/parc/algol/parc_File.c
libparc/parc/algol/parc_File.h [changed mode: 0755->0644]
libparc/parc/algol/parc_FileChunker.c
libparc/parc/algol/parc_FileChunker.h [changed mode: 0755->0644]
libparc/parc/algol/parc_FileInputStream.c [changed mode: 0755->0644]
libparc/parc/algol/parc_FileInputStream.h [changed mode: 0755->0644]
libparc/parc/algol/parc_FileOutputStream.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Hash.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Hash.h [changed mode: 0755->0644]
libparc/parc/algol/parc_HashCode.c [changed mode: 0755->0644]
libparc/parc/algol/parc_HashCode.h [changed mode: 0755->0644]
libparc/parc/algol/parc_HashCodeTable.c [changed mode: 0755->0644]
libparc/parc/algol/parc_HashMap.c
libparc/parc/algol/parc_HashMap.h [changed mode: 0755->0644]
libparc/parc/algol/parc_InputStream.c [changed mode: 0755->0644]
libparc/parc/algol/parc_InputStream.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Iterator.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSON.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSON.h [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONArray.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONArray.h [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONPair.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONPair.h [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONParser.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONParser.h [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONValue.c [changed mode: 0755->0644]
libparc/parc/algol/parc_JSONValue.h [changed mode: 0755->0644]
libparc/parc/algol/parc_KeyValue.c [changed mode: 0755->0644]
libparc/parc/algol/parc_KeyValue.h [changed mode: 0755->0644]
libparc/parc/algol/parc_KeyedElement.c [changed mode: 0755->0644]
libparc/parc/algol/parc_KeyedElement.h [changed mode: 0755->0644]
libparc/parc/algol/parc_LinkedList.c
libparc/parc/algol/parc_LinkedList.h
libparc/parc/algol/parc_List.c
libparc/parc/algol/parc_Map.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Map.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Memory.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Memory.h
libparc/parc/algol/parc_Network.c
libparc/parc/algol/parc_Network.h
libparc/parc/algol/parc_Object.c
libparc/parc/algol/parc_Object.h
libparc/parc/algol/parc_OldSortedList.c [changed mode: 0755->0644]
libparc/parc/algol/parc_OldSortedList.h [changed mode: 0755->0644]
libparc/parc/algol/parc_OutputStream.c [changed mode: 0755->0644]
libparc/parc/algol/parc_OutputStream.h [changed mode: 0755->0644]
libparc/parc/algol/parc_PathName.c [changed mode: 0755->0644]
libparc/parc/algol/parc_PriorityQueue.c [changed mode: 0755->0644]
libparc/parc/algol/parc_PriorityQueue.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Properties.c
libparc/parc/algol/parc_RandomAccessFile.c [changed mode: 0755->0644]
libparc/parc/algol/parc_RandomAccessFile.h [changed mode: 0755->0644]
libparc/parc/algol/parc_ReadOnlyBuffer.c [changed mode: 0755->0644]
libparc/parc/algol/parc_SafeMemory.c
libparc/parc/algol/parc_Stack.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Stack.h [changed mode: 0755->0644]
libparc/parc/algol/parc_StdlibMemory.c [changed mode: 0755->0644]
libparc/parc/algol/parc_StdlibMemory.h [changed mode: 0755->0644]
libparc/parc/algol/parc_String.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Time.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Time.h
libparc/parc/algol/parc_TreeMap.c [changed mode: 0755->0644]
libparc/parc/algol/parc_TreeMap.h [changed mode: 0755->0644]
libparc/parc/algol/parc_TreeRedBlack.c [changed mode: 0755->0644]
libparc/parc/algol/parc_TreeRedBlack.h [changed mode: 0755->0644]
libparc/parc/algol/parc_URI.c
libparc/parc/algol/parc_URIAuthority.c
libparc/parc/algol/parc_URIPath.c [changed mode: 0755->0644]
libparc/parc/algol/parc_URIPath.h [changed mode: 0755->0644]
libparc/parc/algol/parc_URISegment.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Unsigned.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Varint.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Varint.h [changed mode: 0755->0644]
libparc/parc/algol/parc_Vector.c [changed mode: 0755->0644]
libparc/parc/algol/parc_Vector.h [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_ArrayList.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Base64.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_BitVector.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_BufferChunker.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_ByteArray.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Chunker.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Deque.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Display.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Environment.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_EventScheduler.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_EventTimer.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_FileChunker.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_FileInputStream.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_FileOutputStream.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Hash.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_HashCode.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_HashCodeTable.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_InputStream.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_JSONArray.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_JSONParser.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_KeyValue.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_KeyedElement.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Memory.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Network.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Object.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_PathName.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Stack.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_TreeMap.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_TreeRedBlack.c [changed mode: 0755->0644]
libparc/parc/algol/test/test_parc_Varint.c [changed mode: 0755->0644]
libparc/parc/assert/parc_Assert.h
libparc/parc/concurrent/parc_AtomicUint16.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint16.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint32.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint32.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint64.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint64.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint8.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_AtomicUint8.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_FutureTask.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_FutureTask.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Lock.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Lock.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Notifier.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Notifier.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer_1x1.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer_1x1.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer_NxM.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_RingBuffer_NxM.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_ScheduledTask.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_ScheduledTask.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_ScheduledThreadPool.c
libparc/parc/concurrent/parc_ScheduledThreadPool.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Synchronizer.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Synchronizer.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Thread.c
libparc/parc/concurrent/parc_Thread.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_ThreadPool.c
libparc/parc/concurrent/parc_ThreadPool.h [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Timeout.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Timer.c [changed mode: 0755->0644]
libparc/parc/concurrent/parc_Timer.h [changed mode: 0755->0644]
libparc/parc/concurrent/test/test_parc_Notifier.c [changed mode: 0755->0644]
libparc/parc/concurrent/test/test_parc_RingBuffer_1x1.c [changed mode: 0755->0644]
libparc/parc/concurrent/test/test_parc_RingBuffer_NxM.c [changed mode: 0755->0644]
libparc/parc/concurrent/test/test_parc_Synchronizer.c [changed mode: 0755->0644]
libparc/parc/config.h.in
libparc/parc/developer/parc_Stopwatch.c
libparc/parc/developer/parc_Timing.h [changed mode: 0755->0644]
libparc/parc/developer/parc_TimingDarwin.h [changed mode: 0755->0644]
libparc/parc/developer/parc_TimingGeneric.h [changed mode: 0755->0644]
libparc/parc/developer/parc_TimingIntel.c [changed mode: 0755->0644]
libparc/parc/developer/parc_TimingIntel.h [changed mode: 0755->0644]
libparc/parc/developer/parc_TimingLinux.h [changed mode: 0755->0644]
libparc/parc/developer/test/test_parc_Timing.c [changed mode: 0755->0644]
libparc/parc/libparc_About.h [changed mode: 0755->0644]
libparc/parc/logging/parc_Log.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogEntry.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogFormatSyslog.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogFormatSyslog.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogFormatText.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogFormatText.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogLevel.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogLevel.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogManager.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogManager.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporter.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporter.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporterFile.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporterFile.h [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporterTextStdout.c [changed mode: 0755->0644]
libparc/parc/logging/parc_LogReporterTextStdout.h [changed mode: 0755->0644]
libparc/parc/logging/test/test_parc_LogFormatSyslog.c [changed mode: 0755->0644]
libparc/parc/logging/test/test_parc_LogLevel.c [changed mode: 0755->0644]
libparc/parc/logging/test/test_parc_LogReporterFile.c [changed mode: 0755->0644]
libparc/parc/logging/test/test_parc_LogReporterTextStdout.c [changed mode: 0755->0644]
libparc/parc/security/command-line/parcPublicKey_About.h [changed mode: 0755->0644]
libparc/parc/security/parc_Certificate.c [changed mode: 0755->0644]
libparc/parc/security/parc_Certificate.h [changed mode: 0755->0644]
libparc/parc/security/parc_CertificateFactory.h [changed mode: 0755->0644]
libparc/parc/security/parc_CertificateType.c [changed mode: 0755->0644]
libparc/parc/security/parc_CertificateType.h [changed mode: 0755->0644]
libparc/parc/security/parc_ContainerEncoding.c [changed mode: 0755->0644]
libparc/parc/security/parc_ContainerEncoding.h [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoCache.c [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoCache.h [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoHash.c [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoHash.h [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoHashType.h [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoHasher.c [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoHasher.h [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoSuite.c [changed mode: 0755->0644]
libparc/parc/security/parc_CryptoSuite.h [changed mode: 0755->0644]
libparc/parc/security/parc_DiffieHellmanGroup.h [changed mode: 0755->0644]
libparc/parc/security/parc_DiffieHellmanKeyShare.c
libparc/parc/security/parc_Identity.c [changed mode: 0755->0644]
libparc/parc/security/parc_Identity.h [changed mode: 0755->0644]
libparc/parc/security/parc_IdentityFile.c
libparc/parc/security/parc_InMemoryVerifier.c
libparc/parc/security/parc_InMemoryVerifier.h [changed mode: 0755->0644]
libparc/parc/security/parc_Key.c [changed mode: 0755->0644]
libparc/parc/security/parc_Key.h [changed mode: 0755->0644]
libparc/parc/security/parc_KeyId.c [changed mode: 0755->0644]
libparc/parc/security/parc_KeyId.h [changed mode: 0755->0644]
libparc/parc/security/parc_KeyStore.c [changed mode: 0755->0644]
libparc/parc/security/parc_KeyStore.h [changed mode: 0755->0644]
libparc/parc/security/parc_Pkcs12KeyStore.c
libparc/parc/security/parc_PublicKeySigner.c
libparc/parc/security/parc_SecureRandom.c
libparc/parc/security/parc_Security.c
libparc/parc/security/parc_Security.h [changed mode: 0755->0644]
libparc/parc/security/parc_Signature.c [changed mode: 0755->0644]
libparc/parc/security/parc_Signature.h [changed mode: 0755->0644]
libparc/parc/security/parc_Signer.h [changed mode: 0755->0644]
libparc/parc/security/parc_SigningAlgorithm.c [changed mode: 0755->0644]
libparc/parc/security/parc_SymmetricKeyStore.c
libparc/parc/security/parc_Verifier.c [changed mode: 0755->0644]
libparc/parc/security/parc_X509Certificate.c
libparc/parc/security/parc_X509Certificate.h [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CertificateFactory.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CertificateType.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_ContainerEncoding.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CryptoCache.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CryptoHash.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CryptoHasher.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_CryptoSuite.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_DiffieHellman.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_DiffieHellmanKeyShare.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_InMemoryVerifier.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_Key.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_KeyStore.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_Pkcs12KeyStore.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_SecureRandom.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_Security.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_Signature.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_SigningAlgorithm.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_SymmetricKeyStore.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_Verifier.c [changed mode: 0755->0644]
libparc/parc/security/test/test_parc_X509Certificate.c [changed mode: 0755->0644]
libparc/parc/statistics/parc_BasicStats.h [changed mode: 0755->0644]
libparc/parc/statistics/parc_EWMA.c
libparc/parc/statistics/parc_EWMA.h [changed mode: 0755->0644]
libparc/parc/testing/parc_MemoryTesting.c [changed mode: 0755->0644]
libparc/parc/testing/parc_MemoryTesting.h [changed mode: 0755->0644]
libparc/parc/testing/test/test_parc_MemoryTesting.c [changed mode: 0755->0644]
libparc/parc/testing/test/test_parc_ObjectTesting.c [changed mode: 0755->0644]
libparc/parc/windows/getopt.c [new file with mode: 0644]
libparc/parc/windows/getopt.h [new file with mode: 0644]
libparc/parc/windows/getopt_long.c [new file with mode: 0644]
libparc/parc/windows/parc_Utils.c [new file with mode: 0644]
libparc/parc/windows/parc_Utils.h [new file with mode: 0644]
libparc/parc/windows/queue.h [new file with mode: 0644]

index f40a340..f7c5fd2 100644 (file)
@@ -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 (file)
index 0000000..23dfc33
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (c) 2019 Cisco and/or its affiliates.\r
+# Licensed under the Apache License, Version 2.0 (the "License");\r
+# you may not use this file except in compliance with the License.\r
+# You may obtain a copy of the License at:\r
+#\r
+#     http://www.apache.org/licenses/LICENSE-2.0\r
+#\r
+# Unless required by applicable law or agreed to in writing, software\r
+# distributed under the License is distributed on an "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+# See the License for the specific language governing permissions and\r
+# limitations under the License.\r
+\r
+########################################\r
+#\r
+# Find the PThread libraries and includes\r
+# This module sets:\r
+#  PTHREAD_FOUND: True if Libconsumer-producer was found\r
+#  PTHREADR_LIBRARY:  The Libconsumer-producer library\r
+#  PTHREAD_LIBRARIES:  The Libconsumer-producer library and dependencies\r
+#  PTHREAD_INCLUDE_DIR:  The Libconsumer-producer include dir\r
+#\r
+\r
+\r
+set(PTHREAD_SEARCH_PATH_LIST\r
+  ${PTHREAD_HOME}\r
+  $ENV{PTHREAD_HOME}\r
+  /usr/local\r
+  /opt\r
+  /usr\r
+)\r
+\r
+find_path(PTHREAD_INCLUDE_DIR pthread.h\r
+  HINTS ${PTHREAD_SEARCH_PATH_LIST}\r
+  PATH_SUFFIXES include\r
+  DOC "Find the pthreadincludes"\r
+)\r
+\r
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)\r
+  find_library(PTHREAD_LIBRARY NAMES pthreadVC2.lib\r
+    HINTS ${PTHREAD_SEARCH_PATH_LIST}\r
+    PATH_SUFFIXES lib/x64\r
+    DOC "Find the pthread libraries"\r
+  )\r
+elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)\r
+  find_library(PTHREAD_LIBRARY NAMES pthreadVC2.lib\r
+    HINTS ${PTHREAD_SEARCH_PATH_LIST}\r
+    PATH_SUFFIXES lib/x32\r
+    DOC "Find the pthread libraries"\r
+  )\r
+endif()\r
+\r
+\r
+set(PTHREAD_LIBRARIES ${PTHREAD_LIBRARY})\r
+set(PTHREAD_INCLUDE_DIRS ${PTHREAD_INCLUDE_DIR})\r
+\r
+include(FindPackageHandleStandardArgs)\r
+find_package_handle_standard_args(Pthread DEFAULT_MSG PTHREAD_LIBRARIES PTHREAD_INCLUDE_DIRS)
\ No newline at end of file
old mode 100755 (executable)
new mode 100644 (file)
index ebb3ff9..df582a3 100644 (file)
@@ -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)\r
+  list(APPEND LIBPARC_SOURCE_FILES\r
+    ${WINDOWS_UTILITY_SOURCE_FILES}\r
+    ${WINDOWS_UTILITY_HEADER_FILES}\r
+  )\r
+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)
old mode 100755 (executable)
new mode 100644 (file)
index 54c193e..9335e1e
  * limitations under the License.
  */
 
-/**
- */
-#include <config.h>
-
 #include <parc/assert/parc_Assert.h>
 #include <parc/algol/parc_Memory.h>
 #include "internal_parc_Event.h"
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index cac0aa4..e4e6643
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
index 21a66c2..68a8645
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 20520f9..261aac6
@@ -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;
 
index 665019d..fdc205f 100644 (file)
@@ -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.
index f3a4ab6..03c67f5 100644 (file)
@@ -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>
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 25c6925..e0ec511
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 1d81d21..e4cc048 100644 (file)
@@ -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
index c7a2628..7104733 100644 (file)
@@ -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.
index a47129e..0b948d2 100644 (file)
  * 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)
+
+\r
+#define EXPAND( x ) x\r
+#define parcCMacro_IfElse(A, B, ...) EXPAND(parcCMacro_ThirdParam( __VA_ARGS__ , A, B, NOOP))
 
 /** \cond */
 #define _parcCMacro_Cat_(A, B) A ## B
old mode 100755 (executable)
new mode 100644 (file)
index b84ed05..f6c94b6
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 95cf74b..58624fc
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
index 35c77fd..698773b
 #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;
old mode 100755 (executable)
new mode 100644 (file)
index 8480876..c0b8355 100644 (file)
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
index 57dd39b..8b988de
@@ -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)`.
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 39e1d76..a17e7f0
  * 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);
 }
old mode 100755 (executable)
new mode 100644 (file)
index 2955a13..2ca11b4 100644 (file)
  * 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
+
 }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 6293680..9867d91 100644 (file)
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index dffab1e..3542b40
@@ -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
index 282df30..d6ed1bc 100644 (file)
 #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>
 
old mode 100755 (executable)
new mode 100644 (file)
index 3983740..59103f4
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 62aa10b..c44c824
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
index 48a11b2..286e528
 #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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 353ffcc..f39a31a 100644 (file)
 #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);
     }
old mode 100755 (executable)
new mode 100644 (file)
index d7acd58..0af63e1 100644 (file)
 /**
  */
 
+#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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 186d07b..0ccd912
  * 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;
         }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 3e5c8cd..c119e67
  * 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;
         }
old mode 100755 (executable)
new mode 100644 (file)
index 1884c74..fae29a6
  * 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>
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 9531e31..d4c5a7a
@@ -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);
 
index 5e73a4c..58137b2 100644 (file)
@@ -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;
             }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f5aff0b..8b9af28
@@ -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);
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b5bbd0a..4b0dd17 100644 (file)
  * 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>
index 381e2a1..fbf46ac 100644 (file)
@@ -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)`.
index bdb343f..fef3853 100644 (file)
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index eebdadf..6552a90
  * 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
index fe3c4b5..6e4a84e 100644 (file)
@@ -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
index 2b6c888..543a77b 100644 (file)
  * 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);
index bf7cfcb..4b95138 100644 (file)
 #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>
index 70a24f3..422a97f 100644 (file)
  * 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
+
         ;
     }
 
index ac7e965..ba9392a 100644 (file)
@@ -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\r
+#define parcObject_Extends(_subtype, _superType, ...) \\r
+    parcObjectDescriptor_Declaration(_subtype) = { \\r
+        .super           = &parcObject_DescriptorName(_superType), \\r
+        .name            = #_subtype, \\r
+        .objectSize      = 0, \\r
+        .objectAlignment = 0, \\r
+        .destroy         = NULL,    \\r
+        .destructor      = NULL, \\r
+        .release         = NULL,   \\r
+        .copy            = NULL,   \\r
+        .toString        = NULL,   \\r
+        .equals          = NULL,   \\r
+        .compare         = NULL,   \\r
+        .hashCode        = NULL,   \\r
+        .toJSON          = NULL,   \\r
+        .display         = NULL,   \\r
+        .isLockable      = true, \\r
+        .typeState       = NULL, \\r
+        __VA_ARGS__  \\r
+    }; \\r
+    const PARCObjectDescriptor parcObject_DescriptorName(_subtype)\r
+#endif\r
 
 /**
  * Define a new PARC Object implementation, by composing a new PARC Object Descriptor referencing an old one.
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 56e57d2..ec6b2a5
  * 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();
 
old mode 100755 (executable)
new mode 100644 (file)
index c6c003b..6fea804
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
index 2a6c7d3..623128a 100644 (file)
@@ -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;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 7690854..337dfb5 100644 (file)
 #  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,
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 11381a5..536823d
  * 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
old mode 100755 (executable)
new mode 100644 (file)
index 9abbf91..9ac135b
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 07ab185..8f292c1
  * 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);
 }
index 2a68144..a04d02a 100644 (file)
 #ifndef libparc_parc_Time_h
 #define libparc_parc_Time_h
 
+#ifndef _WIN32
 #include <sys/time.h>
+#endif
+
 #include <stdint.h>
 
 /**
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index e14dfc9..94f7498 100644 (file)
  * 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>
index 1e3468d..96b5611 100644 (file)
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
index 0463685..78f28f6
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 786a718..aa00966
  * 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;
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 46e3e2f..692edcc 100644 (file)
     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,  ...)         \\r
+  parcLog_PrintError(M,##__VA_ARGS__);                         \\r
+  assert(((alignment & (~alignment + 1)) == alignment)         \\r
+             ? (((uintptr_t)address) % alignment) == 0 ? 1 : 0 \\r
              : 0);
 
 #endif
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 67e8cfb..e313cd6
  * 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
old mode 100755 (executable)
new mode 100644 (file)
index 44eda3b..e139c14
@@ -175,4 +175,5 @@ void parcNotifier_PauseEvents(PARCNotifier *notifier);
  * @endcode
  */
 void parcNotifier_StartEvents(PARCNotifier *notifier);
+
 #endif // libparc_parc_Notifier_h
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index a93049e..9827154
  *
  */
 
+#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)
 #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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4875abf..e9636d2
  * 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>
 
old mode 100755 (executable)
new mode 100644 (file)
index 0b77372..6e544a9 100644 (file)
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 50be042..8004f67 100644 (file)
@@ -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
old mode 100755 (executable)
new mode 100644 (file)
index 2d9ef6d..67c4bcf 100644 (file)
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 868c03c..9961821 100644 (file)
@@ -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
index 2b696f4..5f87e71 100644 (file)
  * limitations under the License.
  */
 
-/**
- */
-#include <config.h>
-
+#ifndef _WIN32
 #include <sys/time.h>
+#endif
+
+#include <config.h>
 #include <inttypes.h>
 
 #if __APPLE__
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8c1d446..79ac0bf
 #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
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 4aa2a67..7034f5e
  * 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);
old mode 100755 (executable)
new mode 100644 (file)
index 90f6c49..250a83c
 #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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 62d0707..d1ffe63
@@ -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;
         }
     }
 
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 86d5190..53ff6fa
  * 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>
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index a4d492f..b7226e4
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index b7e1938..7d7920f
@@ -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;
     }
 }
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 313af4a..48c3ee2 100644 (file)
@@ -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);
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 8372a11..395757b 100644 (file)
  * 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 {
index 33f6fcf..8955e1f 100644 (file)
@@ -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) {
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index f6c65e4..1224659 100644 (file)
  * 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,
index 55404b9..de048df 100644 (file)
@@ -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);
 
index 92c308c..80189cb 100644 (file)
  * limitations under the License.\r
  */\r
 \r
+#ifndef _WIN32\r
+#include <unistd.h>\r
+#endif\r
 \r
-/**\r
- */\r
 #include <config.h>\r
-\r
 #include <stdlib.h>\r
 #include <fcntl.h>\r
-#include <unistd.h>\r
 \r
 #include <parc/algol/parc_Object.h>\r
 #include <parc/algol/parc_DisplayIndented.h>\r
 #include <parc/algol/parc_Memory.h>\r
-\r
 #include <parc/security/parc_SecureRandom.h>\r
 \r
 struct parc_securerandom {\r
@@ -77,7 +75,7 @@ static void
 _parcSecureRandom_ReSeed(PARCSecureRandom *random, PARCBuffer *buffer)\r
 {\r
     size_t length = parcBuffer_Remaining(buffer);\r
-    int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), length);\r
+    int wrote_bytes = write(random->randomfd, parcBuffer_Overlay(buffer, length), (long)length);\r
 }\r
 \r
 PARCSecureRandom *\r
@@ -104,7 +102,7 @@ ssize_t
 parcSecureRandom_NextBytes(PARCSecureRandom *random, PARCBuffer *buffer)\r
 {\r
     size_t length = parcBuffer_Remaining(buffer);\r
-    ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), length);\r
+    ssize_t result = read(random->randomfd, parcBuffer_Overlay(buffer, 0), (unsigned int)length);\r
     return result;\r
 }\r
 \r
index e5f7609..999a41d 100644 (file)
 #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
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 49d5055..0d5f53e 100644 (file)
  * @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 *
old mode 100755 (executable)
new mode 100644 (file)
index 2c964ae..ab29bfa 100644 (file)
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
index 92046ac..911aba3 100644 (file)
@@ -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;
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/libparc/parc/windows/getopt.c b/libparc/parc/windows/getopt.c
new file mode 100644 (file)
index 0000000..1deaf81
--- /dev/null
@@ -0,0 +1,149 @@
+/*     $NetBSD: getopt.c,v 1.16 1999/12/02 13:15:56 kleink Exp $       */\r
+\r
+/*\r
+ * Copyright (c) 1987, 1993, 1994, 1995\r
+ *     The Regents of the University of California.  All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the names of the copyright holders nor the names of its\r
+ *    contributors may be used to endorse or promote products derived from\r
+ *    this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS \r
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+\r
+#if 0\r
+static char sccsid[] = "@(#)getopt.c   8.3 (Berkeley) 4/27/95";\r
+#endif\r
+\r
+#include <assert.h>\r
+#include <errno.h>\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+#define __P(x) x\r
+#define _DIAGASSERT(x) assert(x)\r
+\r
+#ifdef __weak_alias\r
+__weak_alias(getopt,_getopt);\r
+#endif\r
+\r
+\r
+int    opterr = 1,             /* if error message should be printed */\r
+       optind = 1,             /* index into parent argv vector */\r
+       optopt,                 /* character checked for validity */\r
+       optreset;               /* reset getopt */\r
+char   *optarg;                /* argument associated with option */\r
+\r
+static char * _progname __P((char *));\r
+int getopt_internal __P((int, char * const *, const char *));\r
+\r
+static char *\r
+_progname(nargv0)\r
+       char * nargv0;\r
+{\r
+       char * tmp;\r
+\r
+       _DIAGASSERT(nargv0 != NULL);\r
+\r
+       tmp = strrchr(nargv0, '/');\r
+       if (tmp)\r
+               tmp++;\r
+       else\r
+               tmp = nargv0;\r
+       return(tmp);\r
+}\r
+\r
+#define        BADCH   (int)'?'\r
+#define        BADARG  (int)':'\r
+#define        EMSG    ""\r
+\r
+/*\r
+ * getopt --\r
+ *     Parse argc/argv argument vector.\r
+ */\r
+int\r
+getopt(nargc, nargv, ostr)\r
+       int nargc;\r
+       char * const nargv[];\r
+       const char *ostr;\r
+{\r
+       static char *__progname = 0;\r
+       static char *place = EMSG;              /* option letter processing */\r
+       char *oli;                              /* option letter list index */\r
+        __progname = __progname?__progname:_progname(*nargv);\r
+\r
+       _DIAGASSERT(nargv != NULL);\r
+       _DIAGASSERT(ostr != NULL);\r
+\r
+       if (optreset || !*place) {              /* update scanning pointer */\r
+               optreset = 0;\r
+               if (optind >= nargc || *(place = nargv[optind]) != '-') {\r
+                       place = EMSG;\r
+                       return (-1);\r
+               }\r
+               if (place[1] && *++place == '-' /* found "--" */\r
+                   && place[1] == '\0') {\r
+                       ++optind;\r
+                       place = EMSG;\r
+                       return (-1);\r
+               }\r
+       }                                       /* option letter okay? */\r
+       if ((optopt = (int)*place++) == (int)':' ||\r
+           !(oli = strchr(ostr, optopt))) {\r
+               /*\r
+                * if the user didn't specify '-' as an option,\r
+                * assume it means -1.\r
+                */\r
+               if (optopt == (int)'-')\r
+                       return (-1);\r
+               if (!*place)\r
+                       ++optind;\r
+               if (opterr && *ostr != ':')\r
+                       (void)fprintf(stderr,\r
+                           "%s: illegal option -- %c\n", __progname, optopt);\r
+               return (BADCH);\r
+       }\r
+       if (*++oli != ':') {                    /* don't need argument */\r
+               optarg = NULL;\r
+               if (!*place)\r
+                       ++optind;\r
+       }\r
+       else {                                  /* need an argument */\r
+               if (*place)                     /* no white space */\r
+                       optarg = place;\r
+               else if (nargc <= ++optind) {   /* no arg */\r
+                       place = EMSG;\r
+                       if (*ostr == ':')\r
+                               return (BADARG);\r
+                       if (opterr)\r
+                               (void)fprintf(stderr,\r
+                                   "%s: option requires an argument -- %c\n",\r
+                                   __progname, optopt);\r
+                       return (BADCH);\r
+               }\r
+               else                            /* white space */\r
+                       optarg = nargv[optind];\r
+               place = EMSG;\r
+               ++optind;\r
+       }\r
+       return (optopt);                        /* dump back option letter */\r
+}\r
+\r
diff --git a/libparc/parc/windows/getopt.h b/libparc/parc/windows/getopt.h
new file mode 100644 (file)
index 0000000..6f0c19e
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __GETOPT_H__\r
+#define __GETOPT_H__\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+extern int opterr;             /* if error message should be printed */\r
+extern int optind;             /* index into parent argv vector */\r
+extern int optopt;             /* character checked for validity */\r
+extern int optreset;           /* reset getopt */\r
+extern char *optarg;           /* argument associated with option */\r
+\r
+struct option\r
+{\r
+  const char *name;\r
+  int has_arg;\r
+  int *flag;\r
+  int val;\r
+};\r
+\r
+#define no_argument       0\r
+#define required_argument 1\r
+#define optional_argument 2\r
+\r
+int getopt(int, char**, const char*);\r
+int getopt_long(int, char**, const char*, const struct option*, int*);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __GETOPT_H__ */\r
diff --git a/libparc/parc/windows/getopt_long.c b/libparc/parc/windows/getopt_long.c
new file mode 100644 (file)
index 0000000..23321dd
--- /dev/null
@@ -0,0 +1,233 @@
+\r
+/*\r
+ * Copyright (c) 1987, 1993, 1994, 1996\r
+ *     The Regents of the University of California.  All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the names of the copyright holders nor the names of its\r
+ *    contributors may be used to endorse or promote products derived from\r
+ *    this software without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS \r
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE\r
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+ * POSSIBILITY OF SUCH DAMAGE.\r
+ */\r
+#include <assert.h>\r
+#include <errno.h>\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <string.h>\r
+#include "getopt.h"\r
+\r
+extern int       opterr;       /* if error message should be printed */\r
+extern int       optind;       /* index into parent argv vector */\r
+extern int       optopt;       /* character checked for validity */\r
+extern int       optreset;     /* reset getopt */\r
+extern char *optarg;   /* argument associated with option */\r
+\r
+#define __P(x) x\r
+#define _DIAGASSERT(x) assert(x)\r
+\r
+static char * __progname __P((char *));\r
+int getopt_internal __P((int, char * const *, const char *));\r
+\r
+static char *\r
+__progname(nargv0)\r
+       char * nargv0;\r
+{\r
+       char * tmp;\r
+\r
+       _DIAGASSERT(nargv0 != NULL);\r
+\r
+       tmp = strrchr(nargv0, '/');\r
+       if (tmp)\r
+               tmp++;\r
+       else\r
+               tmp = nargv0;\r
+       return(tmp);\r
+}\r
+\r
+#define        BADCH   (int)'?'\r
+#define        BADARG  (int)':'\r
+#define        EMSG    ""\r
+\r
+/*\r
+ * getopt --\r
+ *     Parse argc/argv argument vector.\r
+ */\r
+int\r
+getopt_internal(nargc, nargv, ostr)\r
+       int nargc;\r
+       char * const *nargv;\r
+       const char *ostr;\r
+{\r
+       static char *place = EMSG;              /* option letter processing */\r
+       char *oli;                              /* option letter list index */\r
+\r
+       _DIAGASSERT(nargv != NULL);\r
+       _DIAGASSERT(ostr != NULL);\r
+\r
+       if (optreset || !*place) {              /* update scanning pointer */\r
+               optreset = 0;\r
+               if (optind >= nargc || *(place = nargv[optind]) != '-') {\r
+                       place = EMSG;\r
+                       return (-1);\r
+               }\r
+               if (place[1] && *++place == '-') {      /* found "--" */\r
+                       /* ++optind; */\r
+                       place = EMSG;\r
+                       return (-2);\r
+               }\r
+       }                                       /* option letter okay? */\r
+       if ((optopt = (int)*place++) == (int)':' ||\r
+           !(oli = strchr(ostr, optopt))) {\r
+               /*\r
+                * if the user didn't specify '-' as an option,\r
+                * assume it means -1.\r
+                */\r
+               if (optopt == (int)'-')\r
+                       return (-1);\r
+               if (!*place)\r
+                       ++optind;\r
+               if (opterr && *ostr != ':')\r
+                       (void)fprintf(stderr,\r
+                           "%s: illegal option -- %c\n", __progname(nargv[0]), optopt);\r
+               return (BADCH);\r
+       }\r
+       if (*++oli != ':') {                    /* don't need argument */\r
+               optarg = NULL;\r
+               if (!*place)\r
+                       ++optind;\r
+       } else {                                /* need an argument */\r
+               if (*place)                     /* no white space */\r
+                       optarg = place;\r
+               else if (nargc <= ++optind) {   /* no arg */\r
+                       place = EMSG;\r
+                       if ((opterr) && (*ostr != ':'))\r
+                               (void)fprintf(stderr,\r
+                                   "%s: option requires an argument -- %c\n",\r
+                                   __progname(nargv[0]), optopt);\r
+                       return (BADARG);\r
+               } else                          /* white space */\r
+                       optarg = nargv[optind];\r
+               place = EMSG;\r
+               ++optind;\r
+       }\r
+       return (optopt);                        /* dump back option letter */\r
+}\r
+\r
+#if 0\r
+/*\r
+ * getopt --\r
+ *     Parse argc/argv argument vector.\r
+ */\r
+int\r
+getopt2(nargc, nargv, ostr)\r
+       int nargc;\r
+       char * const *nargv;\r
+       const char *ostr;\r
+{\r
+       int retval;\r
+\r
+       if ((retval = getopt_internal(nargc, nargv, ostr)) == -2) {\r
+               retval = -1;\r
+               ++optind; \r
+       }\r
+       return(retval);\r
+}\r
+#endif\r
+\r
+/*\r
+ * getopt_long --\r
+ *     Parse argc/argv argument vector.\r
+ */\r
+int\r
+getopt_long(nargc, nargv, options, long_options, index)\r
+       int nargc;\r
+       char ** nargv;\r
+       const char * options;\r
+       const struct option * long_options;\r
+       int * index;\r
+{\r
+       int retval;\r
+\r
+       _DIAGASSERT(nargv != NULL);\r
+       _DIAGASSERT(options != NULL);\r
+       _DIAGASSERT(long_options != NULL);\r
+       /* index may be NULL */\r
+\r
+       if ((retval = getopt_internal(nargc, nargv, options)) == -2) {\r
+               char *current_argv = nargv[optind++] + 2, *has_equal;\r
+               int i, current_argv_len, match = -1;\r
+\r
+               if (*current_argv == '\0') {\r
+                       return(-1);\r
+               }\r
+               if ((has_equal = strchr(current_argv, '=')) != NULL) {\r
+                       current_argv_len = (int)(has_equal - current_argv);\r
+                       has_equal++;\r
+               } else\r
+                       current_argv_len = (int)strlen(current_argv);\r
+\r
+               for (i = 0; long_options[i].name; i++) { \r
+                       if (strncmp(current_argv, long_options[i].name, current_argv_len))\r
+                               continue;\r
+\r
+                       if (strlen(long_options[i].name) == (unsigned)current_argv_len) { \r
+                               match = i;\r
+                               break;\r
+                       }\r
+                       if (match == -1)\r
+                               match = i;\r
+               }\r
+               if (match != -1) {\r
+                       if (long_options[match].has_arg == required_argument ||\r
+                           long_options[match].has_arg == optional_argument) {\r
+                               if (has_equal)\r
+                                       optarg = has_equal;\r
+                               else\r
+                                       optarg = nargv[optind++];\r
+                       }\r
+                       if ((long_options[match].has_arg == required_argument)\r
+                           && (optarg == NULL)) {\r
+                               /*\r
+                                * Missing argument, leading :\r
+                                * indicates no error should be generated\r
+                                */\r
+                               if ((opterr) && (*options != ':'))\r
+                                       (void)fprintf(stderr,\r
+                                     "%s: option requires an argument -- %s\n",\r
+                                     __progname(nargv[0]), current_argv);\r
+                               return (BADARG);\r
+                       }\r
+               } else { /* No matching argument */\r
+                       if ((opterr) && (*options != ':'))\r
+                               (void)fprintf(stderr,\r
+                                   "%s: illegal option -- %s\n", __progname(nargv[0]), current_argv);\r
+                       return (BADCH);\r
+               }\r
+               if (long_options[match].flag) {\r
+                       *long_options[match].flag = long_options[match].val;\r
+                       retval = 0;\r
+               } else \r
+                       retval = long_options[match].val;\r
+               if (index)\r
+                       *index = match;\r
+       }\r
+       return(retval);\r
+}\r
diff --git a/libparc/parc/windows/parc_Utils.c b/libparc/parc/windows/parc_Utils.c
new file mode 100644 (file)
index 0000000..8daf57f
--- /dev/null
@@ -0,0 +1,128 @@
+\r
+/*\r
+ * Copyright (c) 2019 Cisco and/or its affiliates.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at:\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <parc/windows/parc_Utils.h>\r
+#include <Windows.h>\r
+#include <stdint.h>\r
+#include <stdio.h>\r
+#ifndef _vscprintf\r
+/* For some reason, MSVC fails to honour this #ifndef. */\r
+/* Hence function renamed to _vscprintf_so(). */\r
+int _vscprintf_so(const char *format, va_list pargs)\r
+{\r
+    int retval;\r
+    va_list argcopy;\r
+    va_copy(argcopy, pargs);\r
+    retval = vsnprintf(NULL, 0, format, argcopy);\r
+    va_end(argcopy);\r
+    return retval;\r
+}\r
+#endif // _vscprintf\r
+\r
+#ifndef vasprintf\r
+int vasprintf(char **strp, const char *fmt, va_list ap)\r
+{\r
+    int len = _vscprintf_so(fmt, ap);\r
+    if (len == -1)\r
+        return -1;\r
+    char *str = malloc((size_t)len + 1);\r
+    if (!str)\r
+        return -1;\r
+    int r = vsnprintf(str, len + 1, fmt, ap); /* "secure" version of vsprintf */\r
+    if (r == -1)\r
+        return free(str), -1;\r
+    *strp = str;\r
+    return r;\r
+}\r
+#endif // vasprintf\r
+\r
+#ifndef dprintf\r
+int dprintf(int fd, char *fmt, ...) {\r
+    va_list ap;\r
+    FILE *f = _fdopen( fd, "rw" );\r
+    int rc;\r
+\r
+    va_start(ap, &fmt);\r
+    rc = vfprintf(f, fmt, ap);\r
+    fclose(f);\r
+    va_end(ap);\r
+    return rc;\r
+}\r
+#endif\r
+\r
+#ifndef asprintf\r
+int asprintf(char *strp[], const char *fmt, ...)\r
+{\r
+    va_list ap;\r
+    va_start(ap, fmt);\r
+    int r = vasprintf(strp, fmt, ap);\r
+    va_end(ap);\r
+    return r;\r
+}\r
+#endif // asprintf\r
+\r
+\r
+int gettimeofday(struct timeval * tp, struct timezone * tzp)\r
+{\r
+    // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's\r
+    // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)\r
+    // until 00:00:00 January 1, 1970\r
+    static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL);\r
+\r
+    SYSTEMTIME  system_time;\r
+    FILETIME    file_time;\r
+    uint64_t    time;\r
+\r
+    GetSystemTime( &system_time );\r
+    SystemTimeToFileTime( &system_time, &file_time );\r
+    time =  ((uint64_t)file_time.dwLowDateTime )      ;\r
+    time += ((uint64_t)file_time.dwHighDateTime) << 32;\r
+\r
+    tp->tv_sec  = (long) ((time - EPOCH) / 10000000L);\r
+    tp->tv_usec = (long) (system_time.wMilliseconds * 1000);\r
+    return 0;\r
+}\r
+\r
+#ifndef strndup\r
+char *strndup(const char *str, size_t chars)\r
+{\r
+    char *buffer;\r
+    int n;\r
+\r
+    buffer = (char *) malloc(chars +1);\r
+    if (buffer)\r
+    {\r
+        for (n = 0; ((n < chars) && (str[n] != 0)) ; n++) buffer[n] = str[n];\r
+        buffer[n] = 0;\r
+    }\r
+\r
+    return buffer;\r
+}\r
+#endif\r
+\r
+\r
+void usleep(__int64 usec)\r
+{\r
+       HANDLE timer;\r
+       LARGE_INTEGER ft;\r
+\r
+       ft.QuadPart = -(10 * usec); // Convert to 100 nanosecond interval, negative value indicates relative time\r
+\r
+       timer = CreateWaitableTimer(NULL, TRUE, NULL);\r
+       SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);\r
+       WaitForSingleObject(timer, INFINITE);\r
+       CloseHandle(timer);\r
+}
\ 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 (file)
index 0000000..975eae0
--- /dev/null
@@ -0,0 +1,168 @@
+/*\r
+ * Copyright (c) 2019 Cisco and/or its affiliates.\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at:\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#ifndef PARC_UTILS_H\r
+#define PARC_UTILS_H\r
+#define WIN32_LEAN_AND_MEAN\r
+#define HAVE_STRUCT_TIMESPEC\r
+#include <Windows.h>\r
+#include <stdint.h>\r
+#include <io.h>\r
+#include <stdlib.h>\r
+#include <winsock2.h>\r
+#include <WS2tcpip.h>\r
+#include <parc/windows/getopt.h>\r
+#include <parc/windows/queue.h>\r
+\r
+#ifndef IOVEC\r
+#define IOVEC\r
+struct iovec {\r
+       void* iov_base;\r
+       size_t iov_len;\r
+};\r
+#endif\r
+\r
+typedef uint16_t in_port_t;\r
+\r
+#ifndef SLEEP\r
+#define SLEEP\r
+#define sleep Sleep\r
+#endif\r
+\r
+#ifndef USLEEP\r
+#define USLEEP\r
+void usleep(__int64 usec);\r
+#endif\r
+\r
+#ifndef S_ISDIR\r
+#define S_ISDIR(mode)  (((mode) & S_IFMT) == S_IFDIR)\r
+#endif\r
+\r
+#define PARCLibrary_DISABLE_ATOMICS\r
+#include <BaseTsd.h>\r
+typedef SSIZE_T ssize_t;\r
+\r
+#ifndef __ATTRIBUTE__\r
+#define __ATTRIBUTE__\r
+#define __attribute__(A)\r
+#endif\r
+\r
+#ifndef RESTRICT\r
+#define RESTRICT\r
+#define restrict __restrict\r
+#endif\r
+\r
+#ifndef _vscprintf\r
+/* For some reason, MSVC fails to honour this #ifndef. */\r
+/* Hence function renamed to _vscprintf_so(). */\r
+int _vscprintf_so(const char *format, va_list pargs);\r
+#endif // _vscprintf\r
+\r
+#ifndef vasprintf\r
+int vasprintf(char **strp, const char *fmt, va_list ap);\r
+#endif // vasprintf\r
+\r
+#ifndef asprintf\r
+int asprintf(char *strp[], const char *fmt, ...);\r
+#endif // asprintf\r
+\r
+#ifndef GETTIMEOFDAY\r
+#define GETTIMEOFDAY\r
+int gettimeofday(struct timeval * tp, struct timezone * tzp);\r
+#endif\r
+\r
+#ifndef strndup\r
+char *strndup(const char *str, size_t chars);\r
+#endif\r
+\r
+#ifndef dprintf\r
+int dprintf(int fd, char *fmt, ...);\r
+#endif\r
+\r
+#ifndef timersub\r
+#define timersub(a, b, result) \\r
+        do { \\r
+                (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \\r
+                (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \\r
+                if ((result)->tv_usec < 0) { \\r
+                        --(result)->tv_sec; \\r
+                        (result)->tv_usec += 1000000; \\r
+                } \\r
+        } while (0)\r
+#endif // timersub\r
+\r
+#ifndef dup\r
+#define dup _dup\r
+#endif\r
+\r
+#ifndef access\r
+#define access _access\r
+#endif\r
+\r
+#ifndef close\r
+#define close _close\r
+#endif\r
+\r
+#ifndef write\r
+#define write _write\r
+#endif\r
+\r
+#ifndef open\r
+#define open _open\r
+#endif\r
+\r
+#ifndef unlink\r
+#define unlink _unlink\r
+#endif\r
+\r
+#ifndef read\r
+#define read _read\r
+#endif\r
+\r
+#ifndef strcasecmp\r
+#define strncasecmp _strnicmp\r
+#endif\r
+\r
+#ifndef strcasecmp\r
+\r
+#define strcasecmp _stricmp\r
+#endif\r
+\r
+#ifndef S_ISREG\r
+#define S_ISREG(mode)  (((mode) & S_IFMT) == S_IFREG)\r
+#endif\r
+#ifndef R_OK\r
+#define R_OK    4       /* Test for read permission.  */\r
+#endif\r
+#ifndef  W_OK\r
+#define W_OK    2       /* Test for write permission.  */\r
+#endif\r
+#ifndef F_OK\r
+#define F_OK    0\r
+#endif\r
+\r
+#ifndef STDIN_FILENO\r
+#define STDIN_FILENO _fileno(stdin)\r
+#endif\r
+\r
+#ifndef STDOUT_FILENO\r
+#define STDOUT_FILENO _fileno(stdout)\r
+#endif\r
+\r
+#ifndef STDERR_FILENO\r
+#define STDERR_FILENO _fileno(stderr)\r
+#endif\r
+\r
+#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 (file)
index 0000000..925ccf1
--- /dev/null
@@ -0,0 +1,488 @@
+/*     $OpenBSD: queue.h,v 1.16 2000/09/07 19:47:59 art Exp $  */\r
+/*     $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $       */\r
+\r
+/*\r
+ * Copyright (c) 1991, 1993\r
+ *     The Regents of the University of California.  All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in the\r
+ *    documentation and/or other materials provided with the distribution.\r
+ * 3. Neither the name of the University nor the names of its contributors\r
+ *    may be used to endorse or promote products derived from this software\r
+ *    without specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ *     @(#)queue.h     8.5 (Berkeley) 8/20/94\r
+ */\r
+\r
+#ifndef        SYS_QUEUE_H__\r
+#define        SYS_QUEUE_H__\r
+\r
+ /*\r
+  * This file defines five types of data structures: singly-linked lists,\r
+  * lists, simple queues, tail queues, and circular queues.\r
+  *\r
+  *\r
+  * A singly-linked list is headed by a single forward pointer. The elements\r
+  * are singly linked for minimum space and pointer manipulation overhead at\r
+  * the expense of O(n) removal for arbitrary elements. New elements can be\r
+  * added to the list after an existing element or at the head of the list.\r
+  * Elements being removed from the head of the list should use the explicit\r
+  * macro for this purpose for optimum efficiency. A singly-linked list may\r
+  * only be traversed in the forward direction.  Singly-linked lists are ideal\r
+  * for applications with large datasets and few or no removals or for\r
+  * implementing a LIFO queue.\r
+  *\r
+  * A list is headed by a single forward pointer (or an array of forward\r
+  * pointers for a hash table header). The elements are doubly linked\r
+  * so that an arbitrary element can be removed without a need to\r
+  * traverse the list. New elements can be added to the list before\r
+  * or after an existing element or at the head of the list. A list\r
+  * may only be traversed in the forward direction.\r
+  *\r
+  * A simple queue is headed by a pair of pointers, one the head of the\r
+  * list and the other to the tail of the list. The elements are singly\r
+  * linked to save space, so elements can only be removed from the\r
+  * head of the list. New elements can be added to the list before or after\r
+  * an existing element, at the head of the list, or at the end of the\r
+  * list. A simple queue may only be traversed in the forward direction.\r
+  *\r
+  * A tail queue is headed by a pair of pointers, one to the head of the\r
+  * list and the other to the tail of the list. The elements are doubly\r
+  * linked so that an arbitrary element can be removed without a need to\r
+  * traverse the list. New elements can be added to the list before or\r
+  * after an existing element, at the head of the list, or at the end of\r
+  * the list. A tail queue may be traversed in either direction.\r
+  *\r
+  * A circle queue is headed by a pair of pointers, one to the head of the\r
+  * list and the other to the tail of the list. The elements are doubly\r
+  * linked so that an arbitrary element can be removed without a need to\r
+  * traverse the list. New elements can be added to the list before or after\r
+  * an existing element, at the head of the list, or at the end of the list.\r
+  * A circle queue may be traversed in either direction, but has a more\r
+  * complex end of list detection.\r
+  *\r
+  * For details on the use of these macros, see the queue(3) manual page.\r
+  */\r
+\r
+  /*\r
+   * Singly-linked List definitions.\r
+   */\r
+#define SLIST_HEAD(name, type)                                         \\r
+struct name {                                                          \\r
+       struct type *slh_first; /* first element */                     \\r
+}\r
+\r
+#define        SLIST_HEAD_INITIALIZER(head)                                    \\r
+       { NULL }\r
+\r
+#ifndef _WIN32\r
+#define SLIST_ENTRY(type)                                              \\r
+struct {                                                               \\r
+       struct type *sle_next;  /* next element */                      \\r
+}\r
+#endif\r
+\r
+   /*\r
+       * Singly-linked List access methods.\r
+       */\r
+#define        SLIST_FIRST(head)       ((head)->slh_first)\r
+#define        SLIST_END(head)         NULL\r
+#define        SLIST_EMPTY(head)       (SLIST_FIRST(head) == SLIST_END(head))\r
+#define        SLIST_NEXT(elm, field)  ((elm)->field.sle_next)\r
+\r
+#define        SLIST_FOREACH(var, head, field)                                 \\r
+       for((var) = SLIST_FIRST(head);                                  \\r
+           (var) != SLIST_END(head);                                   \\r
+           (var) = SLIST_NEXT(var, field))\r
+\r
+       /*\r
+        * Singly-linked List functions.\r
+        */\r
+#define        SLIST_INIT(head) {                                              \\r
+       SLIST_FIRST(head) = SLIST_END(head);                            \\r
+}\r
+\r
+#define        SLIST_INSERT_AFTER(slistelm, elm, field) do {                   \\r
+       (elm)->field.sle_next = (slistelm)->field.sle_next;             \\r
+       (slistelm)->field.sle_next = (elm);                             \\r
+} while (0)\r
+\r
+#define        SLIST_INSERT_HEAD(head, elm, field) do {                        \\r
+       (elm)->field.sle_next = (head)->slh_first;                      \\r
+       (head)->slh_first = (elm);                                      \\r
+} while (0)\r
+\r
+#define        SLIST_REMOVE_HEAD(head, field) do {                             \\r
+       (head)->slh_first = (head)->slh_first->field.sle_next;          \\r
+} while (0)\r
+\r
+        /*\r
+         * List definitions.\r
+         */\r
+#define LIST_HEAD(name, type)                                          \\r
+struct name {                                                          \\r
+       struct type *lh_first;  /* first element */                     \\r
+}\r
+\r
+#define LIST_HEAD_INITIALIZER(head)                                    \\r
+       { NULL }\r
+\r
+#define LIST_ENTRY(type)                                               \\r
+struct {                                                               \\r
+       struct type *le_next;   /* next element */                      \\r
+       struct type **le_prev;  /* address of previous next element */  \\r
+}\r
+\r
+         /*\r
+          * List access methods\r
+          */\r
+#define        LIST_FIRST(head)                ((head)->lh_first)\r
+#define        LIST_END(head)                  NULL\r
+#define        LIST_EMPTY(head)                (LIST_FIRST(head) == LIST_END(head))\r
+#define        LIST_NEXT(elm, field)           ((elm)->field.le_next)\r
+\r
+#define LIST_FOREACH(var, head, field)                                 \\r
+       for((var) = LIST_FIRST(head);                                   \\r
+           (var)!= LIST_END(head);                                     \\r
+           (var) = LIST_NEXT(var, field))\r
+\r
+          /*\r
+               * List functions.\r
+               */\r
+#define        LIST_INIT(head) do {                                            \\r
+       LIST_FIRST(head) = LIST_END(head);                              \\r
+} while (0)\r
+\r
+#define LIST_INSERT_AFTER(listelm, elm, field) do {                    \\r
+       if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)  \\r
+               (listelm)->field.le_next->field.le_prev =               \\r
+                   &(elm)->field.le_next;                              \\r
+       (listelm)->field.le_next = (elm);                               \\r
+       (elm)->field.le_prev = &(listelm)->field.le_next;               \\r
+} while (0)\r
+\r
+#define        LIST_INSERT_BEFORE(listelm, elm, field) do {                    \\r
+       (elm)->field.le_prev = (listelm)->field.le_prev;                \\r
+       (elm)->field.le_next = (listelm);                               \\r
+       *(listelm)->field.le_prev = (elm);                              \\r
+       (listelm)->field.le_prev = &(elm)->field.le_next;               \\r
+} while (0)\r
+\r
+#define LIST_INSERT_HEAD(head, elm, field) do {                                \\r
+       if (((elm)->field.le_next = (head)->lh_first) != NULL)          \\r
+               (head)->lh_first->field.le_prev = &(elm)->field.le_next;\\r
+       (head)->lh_first = (elm);                                       \\r
+       (elm)->field.le_prev = &(head)->lh_first;                       \\r
+} while (0)\r
+\r
+#define LIST_REMOVE(elm, field) do {                                   \\r
+       if ((elm)->field.le_next != NULL)                               \\r
+               (elm)->field.le_next->field.le_prev =                   \\r
+                   (elm)->field.le_prev;                               \\r
+       *(elm)->field.le_prev = (elm)->field.le_next;                   \\r
+} while (0)\r
+\r
+#define LIST_REPLACE(elm, elm2, field) do {                            \\r
+       if (((elm2)->field.le_next = (elm)->field.le_next) != NULL)     \\r
+               (elm2)->field.le_next->field.le_prev =                  \\r
+                   &(elm2)->field.le_next;                             \\r
+       (elm2)->field.le_prev = (elm)->field.le_prev;                   \\r
+       *(elm2)->field.le_prev = (elm2);                                \\r
+} while (0)\r
+\r
+               /*\r
+                * Simple queue definitions.\r
+                */\r
+#define SIMPLEQ_HEAD(name, type)                                       \\r
+struct name {                                                          \\r
+       struct type *sqh_first; /* first element */                     \\r
+       struct type **sqh_last; /* addr of last next element */         \\r
+}\r
+\r
+#define SIMPLEQ_HEAD_INITIALIZER(head)                                 \\r
+       { NULL, &(head).sqh_first }\r
+\r
+#define SIMPLEQ_ENTRY(type)                                            \\r
+struct {                                                               \\r
+       struct type *sqe_next;  /* next element */                      \\r
+}\r
+\r
+                /*\r
+                 * Simple queue access methods.\r
+                 */\r
+#define        SIMPLEQ_FIRST(head)         ((head)->sqh_first)\r
+#define        SIMPLEQ_END(head)           NULL\r
+#define        SIMPLEQ_EMPTY(head)         (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))\r
+#define        SIMPLEQ_NEXT(elm, field)    ((elm)->field.sqe_next)\r
+\r
+#define SIMPLEQ_FOREACH(var, head, field)                              \\r
+       for((var) = SIMPLEQ_FIRST(head);                                \\r
+           (var) != SIMPLEQ_END(head);                                 \\r
+           (var) = SIMPLEQ_NEXT(var, field))\r
+\r
+                 /*\r
+                  * Simple queue functions.\r
+                  */\r
+#define        SIMPLEQ_INIT(head) do {                                         \\r
+       (head)->sqh_first = NULL;                                       \\r
+       (head)->sqh_last = &(head)->sqh_first;                          \\r
+} while (0)\r
+\r
+#define SIMPLEQ_INSERT_HEAD(head, elm, field) do {                     \\r
+       if (((elm)->field.sqe_next = (head)->sqh_first) == NULL)        \\r
+               (head)->sqh_last = &(elm)->field.sqe_next;              \\r
+       (head)->sqh_first = (elm);                                      \\r
+} while (0)\r
+\r
+#define SIMPLEQ_INSERT_TAIL(head, elm, field) do {                     \\r
+       (elm)->field.sqe_next = NULL;                                   \\r
+       *(head)->sqh_last = (elm);                                      \\r
+       (head)->sqh_last = &(elm)->field.sqe_next;                      \\r
+} while (0)\r
+\r
+#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do {           \\r
+       if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\\r
+               (head)->sqh_last = &(elm)->field.sqe_next;              \\r
+       (listelm)->field.sqe_next = (elm);                              \\r
+} while (0)\r
+\r
+#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do {                     \\r
+       if (((head)->sqh_first = (elm)->field.sqe_next) == NULL)        \\r
+               (head)->sqh_last = &(head)->sqh_first;                  \\r
+} while (0)\r
+\r
+                  /*\r
+                       * Tail queue definitions.\r
+                       */\r
+#define TAILQ_HEAD(name, type)                                         \\r
+struct name {                                                          \\r
+       struct type *tqh_first; /* first element */                     \\r
+       struct type **tqh_last; /* addr of last next element */         \\r
+}\r
+\r
+#define TAILQ_HEAD_INITIALIZER(head)                                   \\r
+       { NULL, &(head).tqh_first }\r
+\r
+#define TAILQ_ENTRY(type)                                              \\r
+struct {                                                               \\r
+       struct type *tqe_next;  /* next element */                      \\r
+       struct type **tqe_prev; /* address of previous next element */  \\r
+}\r
+\r
+                       /*\r
+                        * tail queue access methods\r
+                        */\r
+#define        TAILQ_FIRST(head)               ((head)->tqh_first)\r
+#define        TAILQ_END(head)                 NULL\r
+#define        TAILQ_NEXT(elm, field)          ((elm)->field.tqe_next)\r
+#define TAILQ_LAST(head, headname)                                     \\r
+       (*(((struct headname *)((head)->tqh_last))->tqh_last))\r
+                        /* XXX */\r
+#define TAILQ_PREV(elm, headname, field)                               \\r
+       (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))\r
+#define        TAILQ_EMPTY(head)                                               \\r
+       (TAILQ_FIRST(head) == TAILQ_END(head))\r
+\r
+#define TAILQ_FOREACH(var, head, field)                                        \\r
+       for((var) = TAILQ_FIRST(head);                                  \\r
+           (var) != TAILQ_END(head);                                   \\r
+           (var) = TAILQ_NEXT(var, field))\r
+\r
+#define TAILQ_FOREACH_REVERSE(var, head, headname, field)              \\r
+       for((var) = TAILQ_LAST(head, headname);                         \\r
+           (var) != TAILQ_END(head);                                   \\r
+           (var) = TAILQ_PREV(var, headname, field))\r
+\r
+/*\r
+ * Tail queue functions.\r
+ */\r
+#define        TAILQ_INIT(head) do {                                           \\r
+       (head)->tqh_first = NULL;                                       \\r
+       (head)->tqh_last = &(head)->tqh_first;                          \\r
+} while (0)\r
+\r
+#define TAILQ_INSERT_HEAD(head, elm, field) do {                       \\r
+       if (((elm)->field.tqe_next = (head)->tqh_first) != NULL)        \\r
+               (head)->tqh_first->field.tqe_prev =                     \\r
+                   &(elm)->field.tqe_next;                             \\r
+       else                                                            \\r
+               (head)->tqh_last = &(elm)->field.tqe_next;              \\r
+       (head)->tqh_first = (elm);                                      \\r
+       (elm)->field.tqe_prev = &(head)->tqh_first;                     \\r
+} while (0)\r
+\r
+#define TAILQ_INSERT_TAIL(head, elm, field) do {                       \\r
+       (elm)->field.tqe_next = NULL;                                   \\r
+       (elm)->field.tqe_prev = (head)->tqh_last;                       \\r
+       *(head)->tqh_last = (elm);                                      \\r
+       (head)->tqh_last = &(elm)->field.tqe_next;                      \\r
+} while (0)\r
+\r
+#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do {             \\r
+       if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\\r
+               (elm)->field.tqe_next->field.tqe_prev =                 \\r
+                   &(elm)->field.tqe_next;                             \\r
+       else                                                            \\r
+               (head)->tqh_last = &(elm)->field.tqe_next;              \\r
+       (listelm)->field.tqe_next = (elm);                              \\r
+       (elm)->field.tqe_prev = &(listelm)->field.tqe_next;             \\r
+} while (0)\r
+\r
+#define        TAILQ_INSERT_BEFORE(listelm, elm, field) do {                   \\r
+       (elm)->field.tqe_prev = (listelm)->field.tqe_prev;              \\r
+       (elm)->field.tqe_next = (listelm);                              \\r
+       *(listelm)->field.tqe_prev = (elm);                             \\r
+       (listelm)->field.tqe_prev = &(elm)->field.tqe_next;             \\r
+} while (0)\r
+\r
+#define TAILQ_REMOVE(head, elm, field) do {                            \\r
+       if (((elm)->field.tqe_next) != NULL)                            \\r
+               (elm)->field.tqe_next->field.tqe_prev =                 \\r
+                   (elm)->field.tqe_prev;                              \\r
+       else                                                            \\r
+               (head)->tqh_last = (elm)->field.tqe_prev;               \\r
+       *(elm)->field.tqe_prev = (elm)->field.tqe_next;                 \\r
+} while (0)\r
+\r
+#define TAILQ_REPLACE(head, elm, elm2, field) do {                     \\r
+       if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL)   \\r
+               (elm2)->field.tqe_next->field.tqe_prev =                \\r
+                   &(elm2)->field.tqe_next;                            \\r
+       else                                                            \\r
+               (head)->tqh_last = &(elm2)->field.tqe_next;             \\r
+       (elm2)->field.tqe_prev = (elm)->field.tqe_prev;                 \\r
+       *(elm2)->field.tqe_prev = (elm2);                               \\r
+} while (0)\r
+\r
+ /*\r
+  * Circular queue definitions.\r
+  */\r
+#define CIRCLEQ_HEAD(name, type)                                       \\r
+struct name {                                                          \\r
+       struct type *cqh_first;         /* first element */             \\r
+       struct type *cqh_last;          /* last element */              \\r
+}\r
+\r
+#define CIRCLEQ_HEAD_INITIALIZER(head)                                 \\r
+       { CIRCLEQ_END(&head), CIRCLEQ_END(&head) }\r
+\r
+#define CIRCLEQ_ENTRY(type)                                            \\r
+struct {                                                               \\r
+       struct type *cqe_next;          /* next element */              \\r
+       struct type *cqe_prev;          /* previous element */          \\r
+}\r
+\r
+  /*\r
+   * Circular queue access methods\r
+   */\r
+#define        CIRCLEQ_FIRST(head)             ((head)->cqh_first)\r
+#define        CIRCLEQ_LAST(head)              ((head)->cqh_last)\r
+#define        CIRCLEQ_END(head)               ((void *)(head))\r
+#define        CIRCLEQ_NEXT(elm, field)        ((elm)->field.cqe_next)\r
+#define        CIRCLEQ_PREV(elm, field)        ((elm)->field.cqe_prev)\r
+#define        CIRCLEQ_EMPTY(head)                                             \\r
+       (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))\r
+\r
+#define CIRCLEQ_FOREACH(var, head, field)                              \\r
+       for((var) = CIRCLEQ_FIRST(head);                                \\r
+           (var) != CIRCLEQ_END(head);                                 \\r
+           (var) = CIRCLEQ_NEXT(var, field))\r
+\r
+#define CIRCLEQ_FOREACH_REVERSE(var, head, field)                      \\r
+       for((var) = CIRCLEQ_LAST(head);                                 \\r
+           (var) != CIRCLEQ_END(head);                                 \\r
+           (var) = CIRCLEQ_PREV(var, field))\r
+\r
+   /*\r
+       * Circular queue functions.\r
+       */\r
+#define        CIRCLEQ_INIT(head) do {                                         \\r
+       (head)->cqh_first = CIRCLEQ_END(head);                          \\r
+       (head)->cqh_last = CIRCLEQ_END(head);                           \\r
+} while (0)\r
+\r
+#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do {           \\r
+       (elm)->field.cqe_next = (listelm)->field.cqe_next;              \\r
+       (elm)->field.cqe_prev = (listelm);                              \\r
+       if ((listelm)->field.cqe_next == CIRCLEQ_END(head))             \\r
+               (head)->cqh_last = (elm);                               \\r
+       else                                                            \\r
+               (listelm)->field.cqe_next->field.cqe_prev = (elm);      \\r
+       (listelm)->field.cqe_next = (elm);                              \\r
+} while (0)\r
+\r
+#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do {          \\r
+       (elm)->field.cqe_next = (listelm);                              \\r
+       (elm)->field.cqe_prev = (listelm)->field.cqe_prev;              \\r
+       if ((listelm)->field.cqe_prev == CIRCLEQ_END(head))             \\r
+               (head)->cqh_first = (elm);                              \\r
+       else                                                            \\r
+               (listelm)->field.cqe_prev->field.cqe_next = (elm);      \\r
+       (listelm)->field.cqe_prev = (elm);                              \\r
+} while (0)\r
+\r
+#define CIRCLEQ_INSERT_HEAD(head, elm, field) do {                     \\r
+       (elm)->field.cqe_next = (head)->cqh_first;                      \\r
+       (elm)->field.cqe_prev = CIRCLEQ_END(head);                      \\r
+       if ((head)->cqh_last == CIRCLEQ_END(head))                      \\r
+               (head)->cqh_last = (elm);                               \\r
+       else                                                            \\r
+               (head)->cqh_first->field.cqe_prev = (elm);              \\r
+       (head)->cqh_first = (elm);                                      \\r
+} while (0)\r
+\r
+#define CIRCLEQ_INSERT_TAIL(head, elm, field) do {                     \\r
+       (elm)->field.cqe_next = CIRCLEQ_END(head);                      \\r
+       (elm)->field.cqe_prev = (head)->cqh_last;                       \\r
+       if ((head)->cqh_first == CIRCLEQ_END(head))                     \\r
+               (head)->cqh_first = (elm);                              \\r
+       else                                                            \\r
+               (head)->cqh_last->field.cqe_next = (elm);               \\r
+       (head)->cqh_last = (elm);                                       \\r
+} while (0)\r
+\r
+#define        CIRCLEQ_REMOVE(head, elm, field) do {                           \\r
+       if ((elm)->field.cqe_next == CIRCLEQ_END(head))                 \\r
+               (head)->cqh_last = (elm)->field.cqe_prev;               \\r
+       else                                                            \\r
+               (elm)->field.cqe_next->field.cqe_prev =                 \\r
+                   (elm)->field.cqe_prev;                              \\r
+       if ((elm)->field.cqe_prev == CIRCLEQ_END(head))                 \\r
+               (head)->cqh_first = (elm)->field.cqe_next;              \\r
+       else                                                            \\r
+               (elm)->field.cqe_prev->field.cqe_next =                 \\r
+                   (elm)->field.cqe_next;                              \\r
+} while (0)\r
+\r
+#define CIRCLEQ_REPLACE(head, elm, elm2, field) do {                   \\r
+       if (((elm2)->field.cqe_next = (elm)->field.cqe_next) ==         \\r
+           CIRCLEQ_END(head))                                          \\r
+               (head).cqh_last = (elm2);                               \\r
+       else                                                            \\r
+               (elm2)->field.cqe_next->field.cqe_prev = (elm2);        \\r
+       if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) ==         \\r
+           CIRCLEQ_END(head))                                          \\r
+               (head).cqh_first = (elm2);                              \\r
+       else                                                            \\r
+               (elm2)->field.cqe_prev->field.cqe_next = (elm2);        \\r
+} while (0)\r
+\r
+#endif /* !SYS_QUEUE_H__ */
\ No newline at end of file