summaryrefslogtreecommitdiff
path: root/absl/base/internal/sysinfo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base/internal/sysinfo.cc')
-rw-r--r--absl/base/internal/sysinfo.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc
index a3e08b93..d820ce38 100644
--- a/absl/base/internal/sysinfo.cc
+++ b/absl/base/internal/sysinfo.cc
@@ -136,7 +136,7 @@ static int GetNumCPUs() {
// Other possibilities:
// - Read /sys/devices/system/cpu/online and use cpumask_parse()
// - sysconf(_SC_NPROCESSORS_ONLN)
- return std::thread::hardware_concurrency();
+ return static_cast<int>(std::thread::hardware_concurrency());
#endif
}
@@ -194,7 +194,7 @@ static bool ReadLongFromFile(const char *file, long *value) {
char line[1024];
char *err;
memset(line, '\0', sizeof(line));
- int len = read(fd, line, sizeof(line) - 1);
+ ssize_t len = read(fd, line, sizeof(line) - 1);
if (len <= 0) {
ret = false;
} else {
@@ -376,7 +376,7 @@ pid_t GetTID() {
#endif
pid_t GetTID() {
- return syscall(SYS_gettid);
+ return static_cast<pid_t>(syscall(SYS_gettid));
}
#elif defined(__akaros__)
@@ -429,11 +429,11 @@ static constexpr int kBitsPerWord = 32; // tid_array is uint32_t.
// Returns the TID to tid_array.
static void FreeTID(void *v) {
intptr_t tid = reinterpret_cast<intptr_t>(v);
- int word = tid / kBitsPerWord;
+ intptr_t word = tid / kBitsPerWord;
uint32_t mask = ~(1u << (tid % kBitsPerWord));
absl::base_internal::SpinLockHolder lock(&tid_lock);
assert(0 <= word && static_cast<size_t>(word) < tid_array->size());
- (*tid_array)[word] &= mask;
+ (*tid_array)[static_cast<size_t>(word)] &= mask;
}
static void InitGetTID() {
@@ -455,7 +455,7 @@ pid_t GetTID() {
intptr_t tid = reinterpret_cast<intptr_t>(pthread_getspecific(tid_key));
if (tid != 0) {
- return tid;
+ return static_cast<pid_t>(tid);
}
int bit; // tid_array[word] = 1u << bit;
@@ -476,7 +476,8 @@ pid_t GetTID() {
while (bit < kBitsPerWord && (((*tid_array)[word] >> bit) & 1) != 0) {
++bit;
}
- tid = (word * kBitsPerWord) + bit;
+ tid =
+ static_cast<intptr_t>((word * kBitsPerWord) + static_cast<size_t>(bit));
(*tid_array)[word] |= 1u << bit; // Mark the TID as allocated.
}