Fixes for macppc support

This commit is contained in:
pancake 2024-02-06 20:05:13 +01:00 committed by pancake
parent 88580023d3
commit ce1170c293
3 changed files with 24 additions and 6 deletions

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef WANT_THREADS
#define WANT_THREADS 1
#endif
@ -19,12 +20,17 @@
#if !WANT_THREADS
# define HAVE_TH_LOCAL 0
# define R_TH_LOCAL
# define HAVE_STDATOMIC_H 0
# define R_ATOMIC_BOOL int
#elif defined(__APPLE__) && (defined(__ppc__) || defined (__powerpc__))
# define HAVE_TH_LOCAL 0
# define R_TH_LOCAL
# define HAVE_STDATOMIC_H 0
# define R_ATOMIC_BOOL int
#elif defined (__GNUC__) && !__TINYC__
# define R_TH_LOCAL __thread
# define HAVE_STDATOMIC_H 0
# define R_ATOMIC_BOOL int

View File

@ -36,7 +36,7 @@ static bool _lock_init(RThreadLock *thl, bool recursive) {
R_API bool r_atomic_exchange(volatile R_ATOMIC_BOOL *data, bool v) {
#if HAVE_STDATOMIC_H
return atomic_exchange_explicit (data, v, memory_order_acquire);
#elif __GNUC__ && !__TINYC__
#elif __GNUC__ && !__TINYC__ && !(__APPLE__ && __ppc__)
int orig = 0;
int conv = (int)v;
__atomic_exchange (data, &conv, &orig, __ATOMIC_ACQUIRE);
@ -54,7 +54,7 @@ R_API bool r_atomic_exchange(volatile R_ATOMIC_BOOL *data, bool v) {
R_API void r_atomic_store(volatile R_ATOMIC_BOOL *data, bool v) {
#if HAVE_STDATOMIC_H
atomic_store_explicit (data, v, memory_order_release);
#elif __GNUC__ && !__TINYC__
#elif __GNUC__ && !__TINYC__ && !(__APPLE__ && __ppc__)
int conv = (int)v;
__atomic_store (data, &conv, __ATOMIC_RELEASE);
#elif _MSC_VER

View File

@ -1,4 +1,5 @@
// Copyright 2022 Google LLC
// Copyright 2024 radare2
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -28,9 +29,18 @@
#ifndef CWISSTABLE_H_
#define CWISSTABLE_H_
#if defined(__APPLE__) && (defined(__ppc__) || defined(__powerpc__))
#define CWISS_IS_MACPPC 1
#define CWISS_THREAD_LOCAL
#else
#define CWISS_IS_MACPPC 0
#endif
#include <assert.h>
#include <limits.h>
#if !CWISS_IS_MACPPC
#include <stdalign.h>
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@ -131,7 +141,7 @@
#include <atomic>
#define CWISS_ATOMIC_T(Type_) volatile std::atomic<Type_>
#define CWISS_ATOMIC_INC(val_) (val_).fetch_add(1, std::memory_order_relaxed)
#elif CWISS_IS_MSVC
#elif CWISS_IS_MSVC || CWISS_IS_MACPPC
#define CWISS_ATOMIC_T(Type_) volatile Type_
#define CWISS_ATOMIC_INC(val_) (val_ += 1)
#else
@ -216,7 +226,9 @@
#define CWISS_alignas(align_) __declspec(align(align_))
#else
#if !CWISS_IS_MACPPC
#include <stdalign.h>
#endif
#ifdef alignas
#define CWISS_alignas(align_) alignas(align_)
@ -265,7 +277,7 @@
/// `CWISS_THREAD_LOCAL` expands to the appropriate TLS annotation, if one is
/// available.
#if CWISS_IS_GCCISH
#if CWISS_IS_GCCISH && !CWISS_IS_MACPPC
#define CWISS_THREAD_LOCAL __thread
#elif CWISS_IS_MSVC
#define CWISS_THREAD_LOCAL