Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8f152d3 authored by Steven Moreland's avatar Steven Moreland
Browse files

Usage suggestions.

Providing alternative suggestions for using C++ stdlib types
instead of libutils types:
- higher interoperability
- fewer "legacy" quirks
- ability to use stl algorithms
- high optimization levels

Test: none
Change-Id: If81aa9982ca0ad229fa13c8142387906981b054d
parent 3fca6751
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_UTILS_ATOMIC_H
#define ANDROID_UTILS_ATOMIC_H

// DO NOT USE: Please instead use std::atomic

#include <cutils/atomic.h>

#endif // ANDROID_UTILS_ATOMIC_H
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@

/*
 * Contains some bit manipulation helpers.
 *
 * DO NOT USE: std::bitset<32> or std::bitset<64> preferred
 */

namespace android {
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@
namespace android {
// ---------------------------------------------------------------------------

// DO NOT USE: please use std::condition_variable instead.

/*
 * Condition variable class.  The implementation is system-dependent.
 *
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,8 @@ template<> struct CompileTimeAssert<true> {};
#define COMPILE_TIME_ASSERT(_exp) \
    template class CompileTimeAssert< (_exp) >;
#endif

// DO NOT USE: Please use static_assert instead
#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \
    CompileTimeAssert<( _exp )>();

+2 −2
Original line number Diff line number Diff line
@@ -33,13 +33,13 @@ class FlattenableUtils {
public:
    template<size_t N>
    static size_t align(size_t size) {
        COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
        static_assert(!(N & (N - 1)), "Can only align to a power of 2.");
        return (size + (N-1)) & ~(N-1);
    }

    template<size_t N>
    static size_t align(void const*& buffer) {
        COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) );
        static_assert(!(N & (N - 1)), "Can only align to a power of 2.");
        uintptr_t b = uintptr_t(buffer);
        buffer = reinterpret_cast<void*>((uintptr_t(buffer) + (N-1)) & ~(N-1));
        return size_t(uintptr_t(buffer) - b);
Loading