Kaydet (Commit) 4af9612f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Change sal/osl/w32/*.c -> *.cxx

...and fix any ensuing errors/warnings, but no further C++'ification.  Not sure
whether any parts of dllentry.c would need to be extern "C", so leaving that one
alone for now.

TODO: Put definition of _CRT_RAND_S into bin/update_pch, so it doesn't get
removed again from sal/inc/pch/precompiled_sal.hxx.  (For the surrounding #ifndef
see 244d22a3 "Work around -Werror,-Wunused-macros
with clang-cl".)

Change-Id: I2ada3717845eb0be0c559465d68e00e3a7720156
Reviewed-on: https://gerrit.libreoffice.org/34860Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
Tested-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst d35c25ee
...@@ -225,32 +225,32 @@ else # $(OS) == WNT ...@@ -225,32 +225,32 @@ else # $(OS) == WNT
$(eval $(call gb_Library_add_exception_objects,sal,\ $(eval $(call gb_Library_add_exception_objects,sal,\
sal/osl/w32/backtrace \ sal/osl/w32/backtrace \
sal/osl/w32/conditn \
sal/osl/w32/file \ sal/osl/w32/file \
sal/osl/w32/file_dirvol \ sal/osl/w32/file_dirvol \
sal/osl/w32/file_error \
sal/osl/w32/file_url \ sal/osl/w32/file_url \
sal/osl/w32/interlck \
sal/osl/w32/memory \
sal/osl/w32/module \ sal/osl/w32/module \
sal/osl/w32/mutex \
sal/osl/w32/nlsupport \
sal/osl/w32/path_helper \ sal/osl/w32/path_helper \
sal/osl/w32/pipe \
sal/osl/w32/process \ sal/osl/w32/process \
sal/osl/w32/procimpl \ sal/osl/w32/procimpl \
sal/osl/w32/profile \ sal/osl/w32/profile \
sal/osl/w32/random \
sal/osl/w32/salinit \ sal/osl/w32/salinit \
sal/osl/w32/security \
sal/osl/w32/signal \ sal/osl/w32/signal \
sal/osl/w32/socket \ sal/osl/w32/socket \
sal/osl/w32/tempfile \ sal/osl/w32/tempfile \
sal/osl/w32/thread \
sal/osl/w32/time \
)) ))
$(eval $(call gb_Library_add_cobjects,sal,\ $(eval $(call gb_Library_add_cobjects,sal,\
sal/osl/w32/conditn \
sal/osl/w32/dllentry \ sal/osl/w32/dllentry \
sal/osl/w32/file_error \
sal/osl/w32/interlck \
sal/osl/w32/memory \
sal/osl/w32/mutex \
sal/osl/w32/nlsupport \
sal/osl/w32/pipe \
sal/osl/w32/random \
sal/osl/w32/security \
sal/osl/w32/thread \
sal/osl/w32/time \
)) ))
endif # ifneq ($(OS),WNT) endif # ifneq ($(OS),WNT)
......
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
./bin/update_pch_bisect ./sal/inc/pch/precompiled_sal.hxx "make sal.build" --find-conflicts ./bin/update_pch_bisect ./sal/inc/pch/precompiled_sal.hxx "make sal.build" --find-conflicts
*/ */
#if !defined _CRT_RAND_S
#define _CRT_RAND_S
#endif
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
......
...@@ -35,10 +35,10 @@ oslCondition SAL_CALL osl_createCondition(void) ...@@ -35,10 +35,10 @@ oslCondition SAL_CALL osl_createCondition(void)
{ {
oslCondition Condition; oslCondition Condition;
Condition= (oslCondition)CreateEvent(NULL, /* no security */ Condition= reinterpret_cast<oslCondition>(CreateEvent(nullptr, /* no security */
sal_True, /* manual reset */ true, /* manual reset */
sal_False, /* initial state not signaled */ false, /* initial state not signaled */
NULL); /* automatic name */ nullptr)); /* automatic name */
return Condition; return Condition;
...@@ -62,7 +62,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition) ...@@ -62,7 +62,7 @@ sal_Bool SAL_CALL osl_setCondition(oslCondition Condition)
{ {
OSL_ASSERT(Condition); OSL_ASSERT(Condition);
return (sal_Bool)(SetEvent((HANDLE)Condition) != FALSE); return SetEvent(reinterpret_cast<HANDLE>(Condition)) != FALSE;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -72,7 +72,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition) ...@@ -72,7 +72,7 @@ sal_Bool SAL_CALL osl_resetCondition(oslCondition Condition)
{ {
OSL_ASSERT(Condition); OSL_ASSERT(Condition);
return (sal_Bool)(ResetEvent((HANDLE)Condition) != FALSE); return ResetEvent(reinterpret_cast<HANDLE>(Condition)) != FALSE;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -93,10 +93,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, ...@@ -93,10 +93,10 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition,
/* It's necessary to process SendMessage calls to the current thread to give other threads /* It's necessary to process SendMessage calls to the current thread to give other threads
access to COM objects instantiated in this thread */ access to COM objects instantiated in this thread */
while ( 1 ) while ( true )
{ {
/* Only wake up if a SendMessage call to the threads message loop is detected */ /* Only wake up if a SendMessage call to the threads message loop is detected */
switch( MsgWaitForMultipleObjects( 1, (HANDLE *)(&Condition), FALSE, timeout, QS_SENDMESSAGE ) ) switch( MsgWaitForMultipleObjects( 1, reinterpret_cast<HANDLE *>(&Condition), FALSE, timeout, QS_SENDMESSAGE ) )
{ {
case WAIT_OBJECT_0 + 1: case WAIT_OBJECT_0 + 1:
{ {
...@@ -105,7 +105,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, ...@@ -105,7 +105,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition,
/* We Must not dispatch the message. PM_NOREMOVE leaves the message queue untouched /* We Must not dispatch the message. PM_NOREMOVE leaves the message queue untouched
but dispatches SendMessage calls automatically */ but dispatches SendMessage calls automatically */
PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ); PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE );
} }
break; break;
...@@ -128,7 +128,7 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition) ...@@ -128,7 +128,7 @@ sal_Bool SAL_CALL osl_checkCondition(oslCondition Condition)
{ {
OSL_ASSERT(Condition); OSL_ASSERT(Condition);
return (sal_Bool)(WaitForSingleObject((HANDLE)Condition, 0) == WAIT_OBJECT_0); return WaitForSingleObject(reinterpret_cast<HANDLE>(Condition), 0) == WAIT_OBJECT_0;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -38,15 +38,11 @@ ...@@ -38,15 +38,11 @@
#include <osl/thread.h> #include <osl/thread.h>
#include "file_url.h" #include "file_url.h"
#include "gmutex.h"
#include "rtllifecycle.h" #include "rtllifecycle.h"
#include <thread.h> #include <thread.h>
// externals
extern CRITICAL_SECTION g_ThreadKeyListCS;
extern oslMutex g_Mutex;
/* /*
This is needed because DllMain is called after static constructors. A DLL's This is needed because DllMain is called after static constructors. A DLL's
startup and shutdown sequence looks like this: startup and shutdown sequence looks like this:
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_SAL_OSL_W32_GMUTEX_H
#define INCLUDED_SAL_OSL_W32_GMUTEX_H
#include <sal/config.h>
#include <osl/mutex.h>
#if defined __cplusplus
extern "C" {
#endif
extern oslMutex g_Mutex;
#if defined __cplusplus
}
#endif
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <sal/config.h>
#include "gmutex.h"
#include "system.h" #include "system.h"
#include <osl/mutex.h> #include <osl/mutex.h>
...@@ -35,13 +38,13 @@ oslMutex SAL_CALL osl_createMutex(void) ...@@ -35,13 +38,13 @@ oslMutex SAL_CALL osl_createMutex(void)
{ {
CRITICAL_SECTION *pMutexImpl; CRITICAL_SECTION *pMutexImpl;
pMutexImpl = calloc(sizeof(CRITICAL_SECTION), 1); pMutexImpl = static_cast<CRITICAL_SECTION *>(calloc(sizeof(CRITICAL_SECTION), 1));
OSL_ASSERT(pMutexImpl); /* alloc successful? */ OSL_ASSERT(pMutexImpl); /* alloc successful? */
InitializeCriticalSection(pMutexImpl); InitializeCriticalSection(pMutexImpl);
return (oslMutex)pMutexImpl; return reinterpret_cast<oslMutex>(pMutexImpl);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -49,7 +52,7 @@ oslMutex SAL_CALL osl_createMutex(void) ...@@ -49,7 +52,7 @@ oslMutex SAL_CALL osl_createMutex(void)
/*****************************************************************************/ /*****************************************************************************/
void SAL_CALL osl_destroyMutex(oslMutex Mutex) void SAL_CALL osl_destroyMutex(oslMutex Mutex)
{ {
CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; CRITICAL_SECTION *pMutexImpl = reinterpret_cast<CRITICAL_SECTION *>(Mutex);
if (pMutexImpl) if (pMutexImpl)
{ {
...@@ -63,13 +66,13 @@ void SAL_CALL osl_destroyMutex(oslMutex Mutex) ...@@ -63,13 +66,13 @@ void SAL_CALL osl_destroyMutex(oslMutex Mutex)
/*****************************************************************************/ /*****************************************************************************/
sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex) sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex)
{ {
CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; CRITICAL_SECTION *pMutexImpl = reinterpret_cast<CRITICAL_SECTION *>(Mutex);
OSL_ASSERT(Mutex); OSL_ASSERT(Mutex);
EnterCriticalSection(pMutexImpl); EnterCriticalSection(pMutexImpl);
return sal_True; return true;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -77,11 +80,11 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex) ...@@ -77,11 +80,11 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutex Mutex)
/*****************************************************************************/ /*****************************************************************************/
sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex) sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex)
{ {
CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; CRITICAL_SECTION *pMutexImpl = reinterpret_cast<CRITICAL_SECTION *>(Mutex);
OSL_ASSERT(Mutex); OSL_ASSERT(Mutex);
return (sal_Bool)(TryEnterCriticalSection(pMutexImpl) != FALSE); return TryEnterCriticalSection(pMutexImpl) != FALSE;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -89,13 +92,13 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex) ...@@ -89,13 +92,13 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex Mutex)
/*****************************************************************************/ /*****************************************************************************/
sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex) sal_Bool SAL_CALL osl_releaseMutex(oslMutex Mutex)
{ {
CRITICAL_SECTION *pMutexImpl = (CRITICAL_SECTION *)Mutex; CRITICAL_SECTION *pMutexImpl = reinterpret_cast<CRITICAL_SECTION *>(Mutex);
OSL_ASSERT(Mutex); OSL_ASSERT(Mutex);
LeaveCriticalSection(pMutexImpl); LeaveCriticalSection(pMutexImpl);
return sal_True; return true;
} }
/*****************************************************************************/ /*****************************************************************************/
......
...@@ -79,8 +79,8 @@ BOOL CALLBACK EnumLocalesProcA( LPSTR lpLocaleStringA ) ...@@ -79,8 +79,8 @@ BOOL CALLBACK EnumLocalesProcA( LPSTR lpLocaleStringA )
localeId = strtol( lpLocaleStringA, &pszEndA, 16 ); localeId = strtol( lpLocaleStringA, &pszEndA, 16 );
/* check params received via TLS */ /* check params received via TLS */
params = (struct EnumLocalesParams *) TlsGetValue( g_dwTLSLocaleEncId ); params = static_cast<struct EnumLocalesParams *>(TlsGetValue( g_dwTLSLocaleEncId ));
if( NULL == params || '\0' == params->Language[0] ) if( nullptr == params || '\0' == params->Language[0] )
return FALSE; return FALSE;
/* /*
...@@ -183,7 +183,7 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale ) ...@@ -183,7 +183,7 @@ rtl_TextEncoding SAL_CALL osl_getTextEncodingFromLocale( rtl_Locale * pLocale )
} }
/* if pLocale is NULL, use process locale as default */ /* if pLocale is NULL, use process locale as default */
if( NULL == pLocale ) if( nullptr == pLocale )
osl_getProcessLocale( &pLocale ); osl_getProcessLocale( &pLocale );
/* copy in parameters to structure */ /* copy in parameters to structure */
......
...@@ -57,7 +57,7 @@ struct oslPipeImpl { ...@@ -57,7 +57,7 @@ struct oslPipeImpl {
HANDLE m_AcceptEvent; HANDLE m_AcceptEvent;
rtl_uString* m_Name; rtl_uString* m_Name;
oslPipeError m_Error; oslPipeError m_Error;
sal_Bool m_bClosed; bool m_bClosed;
}; };
/*****************************************************************************/ /*****************************************************************************/
...@@ -68,29 +68,29 @@ oslPipe osl_createPipeImpl(void) ...@@ -68,29 +68,29 @@ oslPipe osl_createPipeImpl(void)
{ {
oslPipe pPipe; oslPipe pPipe;
pPipe = (oslPipe) rtl_allocateZeroMemory(sizeof(struct oslPipeImpl)); pPipe = static_cast<oslPipe>(rtl_allocateZeroMemory(sizeof(struct oslPipeImpl)));
pPipe->m_bClosed = sal_False; pPipe->m_bClosed = false;
pPipe->m_Reference = 0; pPipe->m_Reference = 0;
pPipe->m_Name = NULL; pPipe->m_Name = nullptr;
pPipe->m_File = INVALID_HANDLE_VALUE; pPipe->m_File = INVALID_HANDLE_VALUE;
pPipe->m_NamedObject = INVALID_HANDLE_VALUE; pPipe->m_NamedObject = INVALID_HANDLE_VALUE;
pPipe->m_ReadEvent = CreateEvent(NULL, TRUE, FALSE, NULL); pPipe->m_ReadEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
pPipe->m_WriteEvent = CreateEvent(NULL, TRUE, FALSE, NULL); pPipe->m_WriteEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
pPipe->m_AcceptEvent = CreateEvent(NULL, TRUE, FALSE, NULL); pPipe->m_AcceptEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
return pPipe; return pPipe;
} }
void osl_destroyPipeImpl(oslPipe pPipe) void osl_destroyPipeImpl(oslPipe pPipe)
{ {
if (pPipe != NULL) if (pPipe != nullptr)
{ {
if ( pPipe->m_NamedObject != INVALID_HANDLE_VALUE && pPipe->m_NamedObject != NULL ) if ( pPipe->m_NamedObject != INVALID_HANDLE_VALUE && pPipe->m_NamedObject != nullptr )
CloseHandle( pPipe->m_NamedObject ); CloseHandle( pPipe->m_NamedObject );
if (pPipe->m_Security != NULL) if (pPipe->m_Security != nullptr)
{ {
rtl_freeMemory(pPipe->m_Security->lpSecurityDescriptor); rtl_freeMemory(pPipe->m_Security->lpSecurityDescriptor);
rtl_freeMemory(pPipe->m_Security); rtl_freeMemory(pPipe->m_Security);
...@@ -113,20 +113,20 @@ void osl_destroyPipeImpl(oslPipe pPipe) ...@@ -113,20 +113,20 @@ void osl_destroyPipeImpl(oslPipe pPipe)
oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options,
oslSecurity Security) oslSecurity Security)
{ {
rtl_uString* name = NULL; rtl_uString* name = nullptr;
rtl_uString* path = NULL; rtl_uString* path = nullptr;
rtl_uString* temp = NULL; rtl_uString* temp = nullptr;
oslPipe pPipe; oslPipe pPipe;
PSECURITY_ATTRIBUTES pSecAttr = NULL; PSECURITY_ATTRIBUTES pSecAttr = nullptr;
rtl_uString_newFromAscii(&path, PIPESYSTEM); rtl_uString_newFromAscii(&path, PIPESYSTEM);
rtl_uString_newFromAscii(&name, PIPEPREFIX); rtl_uString_newFromAscii(&name, PIPEPREFIX);
if ( Security) if ( Security)
{ {
rtl_uString *Ident = NULL; rtl_uString *Ident = nullptr;
rtl_uString *Delim = NULL; rtl_uString *Delim = nullptr;
OSL_VERIFY(osl_getUserIdent(Security, &Ident)); OSL_VERIFY(osl_getUserIdent(Security, &Ident));
rtl_uString_newFromAscii(&Delim, "_"); rtl_uString_newFromAscii(&Delim, "_");
...@@ -143,13 +143,13 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options ...@@ -143,13 +143,13 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
{ {
PSECURITY_DESCRIPTOR pSecDesc; PSECURITY_DESCRIPTOR pSecDesc;
pSecDesc = (PSECURITY_DESCRIPTOR) rtl_allocateMemory(SECURITY_DESCRIPTOR_MIN_LENGTH); pSecDesc = static_cast<PSECURITY_DESCRIPTOR>(rtl_allocateMemory(SECURITY_DESCRIPTOR_MIN_LENGTH));
/* add a NULL disc. ACL to the security descriptor */ /* add a NULL disc. ACL to the security descriptor */
OSL_VERIFY(InitializeSecurityDescriptor(pSecDesc, SECURITY_DESCRIPTOR_REVISION)); OSL_VERIFY(InitializeSecurityDescriptor(pSecDesc, SECURITY_DESCRIPTOR_REVISION));
OSL_VERIFY(SetSecurityDescriptorDacl(pSecDesc, TRUE, (PACL) NULL, FALSE)); OSL_VERIFY(SetSecurityDescriptorDacl(pSecDesc, TRUE, nullptr, FALSE));
pSecAttr = rtl_allocateMemory(sizeof(SECURITY_ATTRIBUTES)); pSecAttr = static_cast<PSECURITY_ATTRIBUTES>(rtl_allocateMemory(sizeof(SECURITY_ATTRIBUTES)));
pSecAttr->nLength = sizeof(SECURITY_ATTRIBUTES); pSecAttr->nLength = sizeof(SECURITY_ATTRIBUTES);
pSecAttr->lpSecurityDescriptor = pSecDesc; pSecAttr->lpSecurityDescriptor = pSecDesc;
pSecAttr->bInheritHandle = TRUE; pSecAttr->bInheritHandle = TRUE;
...@@ -167,15 +167,15 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options ...@@ -167,15 +167,15 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
rtl_uString_assign(&temp, path); rtl_uString_assign(&temp, path);
rtl_uString_newConcat(&path, temp, name); rtl_uString_newConcat(&path, temp, name);
rtl_uString_release(temp); rtl_uString_release(temp);
temp = NULL; temp = nullptr;
if (Options & osl_Pipe_CREATE) if (Options & osl_Pipe_CREATE)
{ {
SetLastError( ERROR_SUCCESS ); SetLastError( ERROR_SUCCESS );
pPipe->m_NamedObject = CreateMutexW( NULL, FALSE, name->buffer ); pPipe->m_NamedObject = CreateMutexW( nullptr, FALSE, name->buffer );
if ( pPipe->m_NamedObject != INVALID_HANDLE_VALUE && pPipe->m_NamedObject != NULL ) if ( pPipe->m_NamedObject != INVALID_HANDLE_VALUE && pPipe->m_NamedObject != nullptr )
{ {
if ( GetLastError() != ERROR_ALREADY_EXISTS ) if ( GetLastError() != ERROR_ALREADY_EXISTS )
{ {
...@@ -223,10 +223,10 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options ...@@ -223,10 +223,10 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
path->buffer, path->buffer,
GENERIC_READ|GENERIC_WRITE, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, nullptr,
OPEN_EXISTING, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL); nullptr);
if ( pPipe->m_File != INVALID_HANDLE_VALUE ) if ( pPipe->m_File != INVALID_HANDLE_VALUE )
{ {
...@@ -247,7 +247,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options ...@@ -247,7 +247,7 @@ oslPipe SAL_CALL osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options
/* if we reach here something went wrong */ /* if we reach here something went wrong */
osl_destroyPipeImpl(pPipe); osl_destroyPipeImpl(pPipe);
return NULL; return nullptr;
} }
void SAL_CALL osl_acquirePipe( oslPipe pPipe ) void SAL_CALL osl_acquirePipe( oslPipe pPipe )
...@@ -259,7 +259,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe ) ...@@ -259,7 +259,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
{ {
// OSL_ASSERT( pPipe ); // OSL_ASSERT( pPipe );
if( NULL == pPipe ) if( nullptr == pPipe )
return; return;
if( 0 == osl_atomic_decrement( &(pPipe->m_Reference) ) ) if( 0 == osl_atomic_decrement( &(pPipe->m_Reference) ) )
...@@ -275,7 +275,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe ) ...@@ -275,7 +275,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
{ {
if( pPipe && ! pPipe->m_bClosed ) if( pPipe && ! pPipe->m_bClosed )
{ {
pPipe->m_bClosed = sal_True; pPipe->m_bClosed = true;
/* if we have a system pipe close it */ /* if we have a system pipe close it */
if (pPipe->m_File != INVALID_HANDLE_VALUE) if (pPipe->m_File != INVALID_HANDLE_VALUE)
{ {
...@@ -291,13 +291,13 @@ void SAL_CALL osl_closePipe( oslPipe pPipe ) ...@@ -291,13 +291,13 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
/*****************************************************************************/ /*****************************************************************************/
oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
{ {
oslPipe pAcceptedPipe = NULL; oslPipe pAcceptedPipe = nullptr;
OVERLAPPED os; OVERLAPPED os;
DWORD nBytesTransfered; DWORD nBytesTransfered;
rtl_uString* path = NULL; rtl_uString* path = nullptr;
rtl_uString* temp = NULL; rtl_uString* temp = nullptr;
OSL_ASSERT(pPipe); OSL_ASSERT(pPipe);
OSL_ASSERT(pPipe->m_File != INVALID_HANDLE_VALUE); OSL_ASSERT(pPipe->m_File != INVALID_HANDLE_VALUE);
...@@ -331,12 +331,12 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe) ...@@ -331,12 +331,12 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
break; // Everything's fine !!! break; // Everything's fine !!!
default: default:
// Something went wrong // Something went wrong
return NULL; return nullptr;
} }
} }
break; break;
default: // All other error say that somethings going wrong. default: // All other error say that somethings going wrong.
return NULL; return nullptr;
} }
} }
...@@ -456,7 +456,7 @@ sal_Int32 SAL_CALL osl_writePipe( oslPipe pPipe, const void *pBuffer , sal_Int32 ...@@ -456,7 +456,7 @@ sal_Int32 SAL_CALL osl_writePipe( oslPipe pPipe, const void *pBuffer , sal_Int32
BytesToSend -= RetVal; BytesToSend -= RetVal;
BytesSend += RetVal; BytesSend += RetVal;
pBuffer= (sal_Char*)pBuffer + RetVal; pBuffer= static_cast<sal_Char const *>(pBuffer) + RetVal;
} }
return BytesSend; return BytesSend;
...@@ -482,7 +482,7 @@ sal_Int32 SAL_CALL osl_readPipe( oslPipe pPipe, void *pBuffer , sal_Int32 n ) ...@@ -482,7 +482,7 @@ sal_Int32 SAL_CALL osl_readPipe( oslPipe pPipe, void *pBuffer , sal_Int32 n )
BytesToRead -= RetVal; BytesToRead -= RetVal;
BytesRead += RetVal; BytesRead += RetVal;
pBuffer= (sal_Char*)pBuffer + RetVal; pBuffer= static_cast<sal_Char*>(pBuffer) + RetVal;
} }
return BytesRead; return BytesRead;
} }
...@@ -494,7 +494,7 @@ oslPipeError SAL_CALL osl_getLastPipeError(oslPipe pPipe) ...@@ -494,7 +494,7 @@ oslPipeError SAL_CALL osl_getLastPipeError(oslPipe pPipe)
{ {
oslPipeError Error; oslPipeError Error;
if (pPipe != NULL) if (pPipe != nullptr)
{ {
Error = pPipe->m_Error; Error = pPipe->m_Error;
pPipe->m_Error = osl_Pipe_E_None; pPipe->m_Error = osl_Pipe_E_None;
......
...@@ -14,14 +14,16 @@ ...@@ -14,14 +14,16 @@
#include <stdlib.h> #include <stdlib.h>
#include <memory.h> #include <memory.h>
#include <oslrandom.h>
int osl_get_system_random_data(char* buffer, size_t desired_len) int osl_get_system_random_data(char* buffer, size_t desired_len)
{ {
unsigned int val; unsigned int val;
/* if unaligned fill to alignment */ /* if unaligned fill to alignment */
if((uintptr_t)buffer & 3) if(reinterpret_cast<uintptr_t>(buffer) & 3)
{ {
size_t len = 4 - ((size_t)(buffer) & 3); size_t len = 4 - (reinterpret_cast<size_t>(buffer) & 3);
if(len > desired_len) if(len > desired_len)
{ {
...@@ -38,7 +40,7 @@ int osl_get_system_random_data(char* buffer, size_t desired_len) ...@@ -38,7 +40,7 @@ int osl_get_system_random_data(char* buffer, size_t desired_len)
/* fill directly into the buffer as long as we can */ /* fill directly into the buffer as long as we can */
while(desired_len >= 4) while(desired_len >= 4)
{ {
if(rand_s((unsigned int*)buffer)) if(rand_s(reinterpret_cast<unsigned int*>(buffer)))
{ {
return 0; return 0;
} }
......
...@@ -22,6 +22,8 @@ void SAL_CALL osl_callThreadKeyCallbackOnThreadDetach(void); ...@@ -22,6 +22,8 @@ void SAL_CALL osl_callThreadKeyCallbackOnThreadDetach(void);
extern DWORD g_dwTLSTextEncodingIndex; extern DWORD g_dwTLSTextEncodingIndex;
extern CRITICAL_SECTION g_ThreadKeyListCS;
#if defined __cplusplus #if defined __cplusplus
} }
#endif #endif
......
...@@ -37,17 +37,17 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) ...@@ -37,17 +37,17 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
typedef VOID (WINAPI *GetSystemTimePreciseAsFileTime_PROC)(LPFILETIME); typedef VOID (WINAPI *GetSystemTimePreciseAsFileTime_PROC)(LPFILETIME);
static HMODULE hModule = NULL; static HMODULE hModule = nullptr;
static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime = NULL; static GetSystemTimePreciseAsFileTime_PROC pGetSystemTimePreciseAsFileTime = nullptr;
OSL_ASSERT(pTimeVal != NULL); OSL_ASSERT(pTimeVal != nullptr);
if ( !hModule ) if ( !hModule )
{ {
hModule = GetModuleHandleA( "Kernel32.dll" ); hModule = GetModuleHandleA( "Kernel32.dll" );
if ( hModule ) if ( hModule )
pGetSystemTimePreciseAsFileTime = (GetSystemTimePreciseAsFileTime_PROC) pGetSystemTimePreciseAsFileTime = reinterpret_cast<GetSystemTimePreciseAsFileTime_PROC>(
GetProcAddress(hModule, "GetSystemTimePreciseAsFileTime"); GetProcAddress(hModule, "GetSystemTimePreciseAsFileTime"));
} }
// use ~1 microsecond resolution if available // use ~1 microsecond resolution if available
...@@ -70,12 +70,12 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal) ...@@ -70,12 +70,12 @@ sal_Bool SAL_CALL osl_getSystemTime(TimeValue* pTimeVal)
SystemTimeToFileTime(&SystemTime, &OffTime); SystemTimeToFileTime(&SystemTime, &OffTime);
Value = *((__int64 *)&CurTime) - *((__int64 *)&OffTime); Value = *reinterpret_cast<__int64 *>(&CurTime) - *reinterpret_cast<__int64 *>(&OffTime);
pTimeVal->Seconds = (unsigned long) (Value / 10000000L); pTimeVal->Seconds = (unsigned long) (Value / 10000000L);
pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100); pTimeVal->Nanosec = (unsigned long)((Value % 10000000L) * 100);
return sal_True; return true;
} }
// osl_getDateTimeFromTimeValue // osl_getDateTimeFromTimeValue
...@@ -99,11 +99,11 @@ sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( const TimeValue* pTimeVal, oslDa ...@@ -99,11 +99,11 @@ sal_Bool SAL_CALL osl_getDateTimeFromTimeValue( const TimeValue* pTimeVal, oslDa
pDateTime->Month = aSystemTime.wMonth; pDateTime->Month = aSystemTime.wMonth;
pDateTime->Year = aSystemTime.wYear; pDateTime->Year = aSystemTime.wYear;
return sal_True; return true;
} }
} }
return sal_False; return false;
} }
// osl_getTimeValueFromDateTime // osl_getTimeValueFromDateTime
...@@ -127,11 +127,11 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( const oslDateTime* pDateTime, Ti ...@@ -127,11 +127,11 @@ sal_Bool SAL_CALL osl_getTimeValueFromDateTime( const oslDateTime* pDateTime, Ti
if (FileTimeToTimeValue( &aFileTime, pTimeVal ) ) if (FileTimeToTimeValue( &aFileTime, pTimeVal ) )
{ {
pTimeVal->Nanosec = pDateTime->NanoSeconds; pTimeVal->Nanosec = pDateTime->NanoSeconds;
return sal_True; return true;
} }
} }
return sal_False; return false;
} }
// osl_getLocalTimeFromSystemTime // osl_getLocalTimeFromSystemTime
...@@ -156,11 +156,11 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVa ...@@ -156,11 +156,11 @@ sal_Bool SAL_CALL osl_getLocalTimeFromSystemTime( const TimeValue* pSystemTimeVa
pLocalTimeVal->Seconds = (sal_uInt32) (pSystemTimeVal->Seconds - ( bias * 60) ); pLocalTimeVal->Seconds = (sal_uInt32) (pSystemTimeVal->Seconds - ( bias * 60) );
pLocalTimeVal->Nanosec = pSystemTimeVal->Nanosec; pLocalTimeVal->Nanosec = pSystemTimeVal->Nanosec;
return sal_True; return true;
} }
} }
return sal_False; return false;
} }
// osl_getSystemTimeFromLocalTime // osl_getSystemTimeFromLocalTime
...@@ -185,11 +185,11 @@ sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal ...@@ -185,11 +185,11 @@ sal_Bool SAL_CALL osl_getSystemTimeFromLocalTime( const TimeValue* pLocalTimeVal
pSystemTimeVal->Seconds = (sal_uInt32) ( pLocalTimeVal->Seconds + ( bias * 60) ); pSystemTimeVal->Seconds = (sal_uInt32) ( pLocalTimeVal->Seconds + ( bias * 60) );
pSystemTimeVal->Nanosec = pLocalTimeVal->Nanosec; pSystemTimeVal->Nanosec = pLocalTimeVal->Nanosec;
return sal_True; return true;
} }
} }
return sal_False; return false;
} }
static struct _timeb startTime; static struct _timeb startTime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment