2009-01-26 08:27:00 -08:00
|
|
|
/* EINA - EFL data type library
|
|
|
|
* Copyright (C) 2007-2008 Jorge Luis Zapata Muga
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2009-01-27 08:59:06 -08:00
|
|
|
|
2009-01-26 08:27:00 -08:00
|
|
|
#ifndef EINA_CPU_H_
|
|
|
|
#define EINA_CPU_H_
|
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
|
|
|
* @addtogroup Eina_Cpu_Group Cpu
|
|
|
|
*
|
|
|
|
* @brief Cpu and architecture related helpers
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup Eina_Tools_Group Tools
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Eina_Cpu_Group Cpu
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-01-26 08:27:00 -08:00
|
|
|
#include "eina_types.h"
|
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
|
|
|
* @typedef Eina_Cpu_Features
|
|
|
|
* Enumerates different hardware architectures.
|
|
|
|
*/
|
2009-01-26 08:27:00 -08:00
|
|
|
typedef enum _Eina_Cpu_Features
|
|
|
|
{
|
2018-11-22 08:59:47 -08:00
|
|
|
EINA_CPU_MMX = 0x00000001,
|
|
|
|
EINA_CPU_SSE = 0x00000002,
|
|
|
|
EINA_CPU_SSE2 = 0x00000004,
|
|
|
|
EINA_CPU_SSE3 = 0x00000008,
|
2010-07-27 19:37:05 -07:00
|
|
|
/* TODO 3DNow! */
|
|
|
|
EINA_CPU_ALTIVEC = 0x00000010,
|
2018-11-22 08:59:47 -08:00
|
|
|
EINA_CPU_VIS = 0x00000020,
|
|
|
|
EINA_CPU_NEON = 0x00000040,
|
|
|
|
EINA_CPU_SSSE3 = 0x00000080,
|
|
|
|
EINA_CPU_SSE41 = 0x00000100,
|
|
|
|
EINA_CPU_SSE42 = 0x00000200,
|
|
|
|
EINA_CPU_SVE = 0x00000400
|
2009-01-26 08:27:00 -08:00
|
|
|
} Eina_Cpu_Features;
|
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
2017-02-19 22:18:21 -08:00
|
|
|
* @brief Global hardware architecture handler.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
|
|
|
* @return the current cpu features
|
|
|
|
*/
|
2013-10-02 02:31:10 -07:00
|
|
|
EAPI extern Eina_Cpu_Features eina_cpu_features;
|
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
2017-02-19 22:18:21 -08:00
|
|
|
* @brief Cpu features accessor.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
|
|
|
* @return the current cpu features
|
|
|
|
*/
|
2009-01-26 08:27:00 -08:00
|
|
|
EAPI Eina_Cpu_Features eina_cpu_features_get(void);
|
2014-10-03 02:36:38 -07:00
|
|
|
|
|
|
|
/**
|
2017-02-19 22:18:21 -08:00
|
|
|
* @brief Gets the current number of processors.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
2017-02-19 22:18:21 -08:00
|
|
|
* @return The number of processors that are online, that
|
2014-10-03 02:36:38 -07:00
|
|
|
* is available when the function is called.
|
|
|
|
*/
|
2010-07-27 19:37:05 -07:00
|
|
|
EAPI int eina_cpu_count(void);
|
2014-10-03 02:36:38 -07:00
|
|
|
|
|
|
|
/**
|
2017-02-19 22:18:21 -08:00
|
|
|
* @brief Gets the current virtual page size.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
2017-02-19 22:18:21 -08:00
|
|
|
* @return The fixed length that represents the smallest unit of data for memory
|
2014-10-03 02:36:38 -07:00
|
|
|
* allocation performed by the operating system on behalf of the program, and
|
|
|
|
* for transfers between the main memory and any other auxiliary store.
|
|
|
|
*/
|
2013-11-10 00:25:16 -08:00
|
|
|
EAPI int eina_cpu_page_size(void);
|
2009-01-26 08:27:00 -08:00
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
|
|
|
* @brief Reverses the byte order of a 16-bit (destination) register.
|
|
|
|
*
|
2018-07-20 07:36:24 -07:00
|
|
|
* @param[in] x The binary word to swap
|
2017-02-19 22:18:21 -08:00
|
|
|
* @return A byte order swapped 16-bit integer.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
|
|
|
* On big endian systems, the number is converted to little endian byte order.
|
|
|
|
* On little endian systems, the number is converted to big endian byte order.
|
|
|
|
*/
|
2013-10-02 02:31:10 -07:00
|
|
|
static inline unsigned short eina_swap16(unsigned short x);
|
2014-10-03 02:36:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reverses the byte order of a 32-bit (destination) register.
|
|
|
|
*
|
2018-07-20 07:36:24 -07:00
|
|
|
* @param[in] x The binary word to swap
|
2017-02-19 22:18:21 -08:00
|
|
|
* @return A byte order swapped 32-bit integer.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
|
|
|
* On big endian systems, the number is converted to little endian byte order.
|
|
|
|
* On little endian systems, the number is converted to big endian byte order.
|
|
|
|
*/
|
2013-10-02 02:31:10 -07:00
|
|
|
static inline unsigned int eina_swap32(unsigned int x);
|
2014-10-03 02:36:38 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reverses the byte order of a 64-bit (destination) register.
|
|
|
|
*
|
2018-07-20 07:36:24 -07:00
|
|
|
* @param[in] x The binary word to swap
|
2019-02-01 03:04:17 -08:00
|
|
|
* @return A byte order swapped 64-bit integer.
|
2014-10-03 02:36:38 -07:00
|
|
|
*
|
|
|
|
* On big endian systems, the number is converted to little endian byte order.
|
|
|
|
* On little endian systems, the number is converted to big endian byte order.
|
|
|
|
*/
|
2013-10-02 02:31:10 -07:00
|
|
|
static inline unsigned long long eina_swap64(unsigned long long x);
|
|
|
|
|
2019-02-01 03:04:17 -08:00
|
|
|
static inline unsigned short eina_htons(unsigned short host);
|
|
|
|
|
|
|
|
static inline unsigned int eina_htonl(unsigned int host);
|
|
|
|
|
|
|
|
static inline unsigned long long eina_htonll(unsigned long long host);
|
|
|
|
|
|
|
|
static inline unsigned short eina_ntohs(unsigned short net);
|
|
|
|
|
|
|
|
static inline unsigned int eina_ntohl(unsigned int net);
|
|
|
|
|
|
|
|
static inline unsigned long long eina_ntohll(unsigned long long net);
|
|
|
|
|
2016-05-09 16:56:38 -07:00
|
|
|
#ifndef MIN
|
|
|
|
# define MIN(x, y) (((x) > (y)) ? (y) : (x))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef MAX
|
|
|
|
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
|
|
|
#endif
|
|
|
|
|
2013-10-02 02:31:10 -07:00
|
|
|
#include "eina_inline_cpu.x"
|
|
|
|
|
2014-10-03 02:36:38 -07:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2009-01-26 08:27:00 -08:00
|
|
|
#endif /* EINA_CPU_H_ */
|