/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <apr_atomic.h>

using namespace log4cxx::helpers;

void ObjectPtrBase::checkNull(const int& null) {
        if (null != 0)
        {

                throw IllegalArgumentException("Attempt to set pointer to a non-zero numeric value.");
        }
}

void* ObjectPtrBase::exchange(volatile void** destination, void* newValue) {
#if defined(_WIN32)
    return InterlockedExchangePointer(destination, newValue);
#else
   return apr_atomic_casptr(destination, newValue, (const void*) *destination);
#endif
}


/*
 * Copyright 2003-2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <log4cxx/helpers/objectptr.h>
#include <log4cxx/helpers/exception.h>
#include <apr_atomic.h>

using namespace log4cxx::helpers;

void ObjectPtrBase::checkNull(const int& null) {
        if (null != 0)
        {

                throw IllegalArgumentException("Attempt to set pointer to a non-zero numeric value.");
        }
}

void* ObjectPtrBase::exchange(volatile void** destination, void* newValue) {
   return apr_atomic_casptr(destination, newValue, (const void*) *destination);
}


Switch from InterlockedExchangePointer back to APR atomic
LOGCXX-132: Switch from InterlockedExchangePointer back to APR atomic

git-svn-id: a7c1976543b50a5b791fd6a475a0ba067ae951b4@407850 13f79535-47bb-0310-9956-ffa450edef68
