Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/absl/base/internal/spinlock_posix.inc is written in an unsupported language. File is not indexed.

0001 // Copyright 2017 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // This file is a Posix-specific part of spinlock_wait.cc
0016 
0017 #include <sched.h>
0018 
0019 #include <atomic>
0020 #include <ctime>
0021 
0022 #include "absl/base/internal/errno_saver.h"
0023 #include "absl/base/internal/scheduling_mode.h"
0024 #include "absl/base/port.h"
0025 
0026 extern "C" {
0027 
0028 ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)(
0029     std::atomic<uint32_t>* /* lock_word */, uint32_t /* value */, int loop,
0030     absl::base_internal::SchedulingMode /* mode */) {
0031   absl::base_internal::ErrnoSaver errno_saver;
0032   if (loop == 0) {
0033   } else if (loop == 1) {
0034     sched_yield();
0035   } else {
0036     struct timespec tm;
0037     tm.tv_sec = 0;
0038     tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop);
0039     nanosleep(&tm, nullptr);
0040   }
0041 }
0042 
0043 ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)(
0044     std::atomic<uint32_t>* /* lock_word */, bool /* all */) {}
0045 
0046 }  // extern "C"