diff options
Diffstat (limited to 'libutils/include')
-rw-r--r-- | libutils/include/utils/AndroidThreads.h | 5 | ||||
-rw-r--r-- | libutils/include/utils/Debug.h | 26 | ||||
-rw-r--r-- | libutils/include/utils/Flattenable.h | 6 | ||||
-rw-r--r-- | libutils/include/utils/PropertyMap.h | 106 | ||||
-rw-r--r-- | libutils/include/utils/SystemClock.h | 1 | ||||
-rw-r--r-- | libutils/include/utils/Vector.h | 8 |
6 files changed, 13 insertions, 139 deletions
diff --git a/libutils/include/utils/AndroidThreads.h b/libutils/include/utils/AndroidThreads.h index 3c30a2a85..cdb5442ae 100644 --- a/libutils/include/utils/AndroidThreads.h +++ b/libutils/include/utils/AndroidThreads.h @@ -78,9 +78,12 @@ extern void androidSetCreateThreadFunc(android_create_thread_fn func); // should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION // if the priority set failed, else another value if just the group set failed; // in either case errno is set. Thread ID zero means current thread. +// This is equivalent to androidSetThreadPriorityAndPolicy(tid, prio, true); +extern int androidSetThreadPriority(pid_t tid, int prio); + // Parameter "change_policy" indicates if sched policy should be changed. It needs // not be checked again if the change is done elsewhere like activity manager. -extern int androidSetThreadPriority(pid_t tid, int prio, bool change_policy = true); +extern int androidSetThreadPriorityAndPolicy(pid_t tid, int prio, bool change_policy); // Get the current priority of a particular thread. Returns one of the // ANDROID_PRIORITY constants or a negative result in case of error. diff --git a/libutils/include/utils/Debug.h b/libutils/include/utils/Debug.h index 96bd70eb0..c3b902617 100644 --- a/libutils/include/utils/Debug.h +++ b/libutils/include/utils/Debug.h @@ -14,27 +14,9 @@ * limitations under the License. */ -#ifndef ANDROID_UTILS_DEBUG_H -#define ANDROID_UTILS_DEBUG_H +#pragma once -#include <stdint.h> -#include <sys/types.h> +// Note: new code should use static_assert directly. -namespace android { -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template<bool> struct CompileTimeAssert; -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 )>(); - -// --------------------------------------------------------------------------- -} // namespace android - -#endif // ANDROID_UTILS_DEBUG_H +#define COMPILE_TIME_ASSERT static_assert +#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE static_assert diff --git a/libutils/include/utils/Flattenable.h b/libutils/include/utils/Flattenable.h index 17c5e1057..8aa381a8f 100644 --- a/libutils/include/utils/Flattenable.h +++ b/libutils/include/utils/Flattenable.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef ANDROID_UTILS_FLATTENABLE_H -#define ANDROID_UTILS_FLATTENABLE_H +#pragma once // DO NOT USE: please use parcelable instead // This code is deprecated and will not be supported via AIDL code gen. For data @@ -25,7 +24,6 @@ #include <string.h> #include <sys/types.h> #include <utils/Errors.h> -#include <utils/Debug.h> #include <type_traits> @@ -217,5 +215,3 @@ public: }; } // namespace android - -#endif /* ANDROID_UTILS_FLATTENABLE_H */ diff --git a/libutils/include/utils/PropertyMap.h b/libutils/include/utils/PropertyMap.h deleted file mode 100644 index a9e674f9a..000000000 --- a/libutils/include/utils/PropertyMap.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * 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. - */ - -#ifndef _UTILS_PROPERTY_MAP_H -#define _UTILS_PROPERTY_MAP_H - -#include <utils/KeyedVector.h> -#include <utils/String8.h> -#include <utils/Errors.h> -#include <utils/Tokenizer.h> - -namespace android { - -/* - * Provides a mechanism for passing around string-based property key / value pairs - * and loading them from property files. - * - * The property files have the following simple structure: - * - * # Comment - * key = value - * - * Keys and values are any sequence of printable ASCII characters. - * The '=' separates the key from the value. - * The key and value may not contain whitespace. - * - * The '\' character is reserved for escape sequences and is not currently supported. - * The '"" character is reserved for quoting and is not currently supported. - * Files that contain the '\' or '"' character will fail to parse. - * - * The file must not contain duplicate keys. - * - * TODO Support escape sequences and quoted values when needed. - */ -class PropertyMap { -public: - /* Creates an empty property map. */ - PropertyMap(); - ~PropertyMap(); - - /* Clears the property map. */ - void clear(); - - /* Adds a property. - * Replaces the property with the same key if it is already present. - */ - void addProperty(const String8& key, const String8& value); - - /* Returns true if the property map contains the specified key. */ - bool hasProperty(const String8& key) const; - - /* Gets the value of a property and parses it. - * Returns true and sets outValue if the key was found and its value was parsed successfully. - * Otherwise returns false and does not modify outValue. (Also logs a warning.) - */ - bool tryGetProperty(const String8& key, String8& outValue) const; - bool tryGetProperty(const String8& key, bool& outValue) const; - bool tryGetProperty(const String8& key, int32_t& outValue) const; - bool tryGetProperty(const String8& key, float& outValue) const; - - /* Adds all values from the specified property map. */ - void addAll(const PropertyMap* map); - - /* Gets the underlying property map. */ - inline const KeyedVector<String8, String8>& getProperties() const { return mProperties; } - - /* Loads a property map from a file. */ - static status_t load(const String8& filename, PropertyMap** outMap); - -private: - class Parser { - PropertyMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(PropertyMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - status_t parseType(); - status_t parseKey(); - status_t parseKeyProperty(); - status_t parseModifier(const String8& token, int32_t* outMetaState); - status_t parseCharacterLiteral(char16_t* outCharacter); - }; - - KeyedVector<String8, String8> mProperties; -}; - -} // namespace android - -#endif // _UTILS_PROPERTY_MAP_H diff --git a/libutils/include/utils/SystemClock.h b/libutils/include/utils/SystemClock.h index f816fbaf7..892104cb8 100644 --- a/libutils/include/utils/SystemClock.h +++ b/libutils/include/utils/SystemClock.h @@ -23,6 +23,7 @@ namespace android { int64_t uptimeMillis(); +int64_t uptimeNanos(); int64_t elapsedRealtime(); int64_t elapsedRealtimeNano(); diff --git a/libutils/include/utils/Vector.h b/libutils/include/utils/Vector.h index ddf71de24..be35ea2f0 100644 --- a/libutils/include/utils/Vector.h +++ b/libutils/include/utils/Vector.h @@ -23,15 +23,13 @@ #include <log/log.h> #include <utils/TypeHelpers.h> #include <utils/VectorImpl.h> - -/* - * Used to blacklist some functions from CFI. - * - */ #ifndef __has_attribute #define __has_attribute(x) 0 #endif +/* + * Used to exclude some functions from CFI. + */ #if __has_attribute(no_sanitize) #define UTILS_VECTOR_NO_CFI __attribute__((no_sanitize("cfi"))) #else |