xrdp/common/arch.h

165 lines
4.0 KiB
C
Raw Normal View History

/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2004-2014
*
* 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.
*/
2005-01-07 03:56:38 +03:00
2005-06-28 07:04:36 +04:00
#if !defined(ARCH_H)
#define ARCH_H
2017-01-26 11:13:10 +03:00
#include <stdlib.h>
#if defined(HAVE_STDINT_H)
#include <stdint.h>
#else
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
#if defined(_WIN64)
2017-01-28 00:06:28 +03:00
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
2017-01-26 11:13:10 +03:00
typedef signed __int64 intptr_t;
typedef unsigned __int64 uintptr_t;
#else
2017-01-28 00:06:28 +03:00
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
2017-01-26 11:13:10 +03:00
typedef signed long intptr_t;
typedef unsigned long uintptr_t;
#endif
#endif
typedef int bool_t;
2014-08-13 07:01:33 +04:00
/* you can define L_ENDIAN or B_ENDIAN and NEED_ALIGN or NO_NEED_ALIGN
in the makefile to override */
/* check endianness */
2014-08-13 07:01:33 +04:00
#if !(defined(L_ENDIAN) || defined(B_ENDIAN))
#if !defined(__BYTE_ORDER) && defined(__linux__)
#include <endian.h>
2014-08-13 07:01:33 +04:00
#endif
#if defined(BYTE_ORDER)
#if BYTE_ORDER == BIG_ENDIAN
#define B_ENDIAN
#else
#define L_ENDIAN
#endif
#endif
2010-02-23 00:17:31 +03:00
#if !(defined(L_ENDIAN) || defined(B_ENDIAN))
#if defined(__sparc__) || \
2021-03-03 04:55:24 +03:00
defined(__s390__) || defined (__s390x__) || \
2021-03-03 04:52:23 +03:00
defined(__hppa__) || defined (__m68k__) || \
(defined(__PPC__) && defined(__BIG_ENDIAN__)) || \
(defined(__ppc__) && defined(__BIG_ENDIAN__))
2005-07-10 23:17:09 +04:00
#define B_ENDIAN
2007-12-16 12:34:59 +03:00
#else
#define L_ENDIAN
#endif
2014-08-13 07:01:33 +04:00
#endif
#endif
2005-01-07 03:56:38 +03:00
/* check if we need to align data */
2014-08-13 07:01:33 +04:00
#if !(defined(NEED_ALIGN) || defined(NO_NEED_ALIGN))
2005-01-07 03:56:38 +03:00
#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
2021-03-03 04:52:23 +03:00
defined(__AIX__) || defined(__m68k__) || defined(__mips__) || \
2021-03-03 04:55:40 +03:00
defined(__ia64__) || defined(__arm__) || defined(__sh__) || \
(defined(__PPC__) && defined(__BIG_ENDIAN__)) || \
2021-11-18 10:19:46 +03:00
(defined(__ppc__) && defined(__BIG_ENDIAN__)) || \
defined(__loongarch__)
2005-01-07 03:56:38 +03:00
#define NEED_ALIGN
2013-11-21 10:28:47 +04:00
#elif defined(__x86__) || defined(__x86_64__) || \
2014-06-04 02:26:31 +04:00
defined(__AMD64__) || defined(_M_IX86) || defined (_M_AMD64) || \
defined(__i386__) || defined(__aarch64__) || \
2021-03-03 04:54:00 +03:00
defined(__PPC__) || defined(__LITTLE_ENDIAN__) || \
2021-03-03 04:55:24 +03:00
defined(__s390__) || defined (__s390x__) || \
defined(__riscv)
2013-11-21 10:28:47 +04:00
#define NO_NEED_ALIGN
#else
#warning unknown arch
2005-01-07 03:56:38 +03:00
#endif
2010-02-23 00:17:31 +03:00
#endif
2005-01-07 03:56:38 +03:00
/* defines for thread creation factory functions */
#if defined(_WIN32)
2005-01-07 03:56:38 +03:00
#define THREAD_RV unsigned long
#define THREAD_CC __stdcall
#else
#define THREAD_RV void*
#define THREAD_CC
#endif
2005-06-28 07:04:36 +04:00
#if defined(_WIN32)
2007-06-01 03:36:17 +04:00
#if defined(__BORLANDC__)
#define EXPORT_CC _export __cdecl
2005-06-28 07:04:36 +04:00
#else
#define EXPORT_CC
#endif
2007-06-01 03:36:17 +04:00
#else
#define EXPORT_CC
#endif
2005-06-28 07:04:36 +04:00
2013-11-08 23:21:23 +04:00
#ifndef DEFINED_Ts
#define DEFINED_Ts
2017-01-26 11:13:10 +03:00
typedef int8_t ti8;
typedef uint8_t tui8;
typedef int8_t tsi8;
typedef int16_t ti16;
typedef uint16_t tui16;
typedef int16_t tsi16;
typedef int32_t ti32;
typedef uint32_t tui32;
typedef int32_t tsi32;
typedef int64_t ti64;
typedef uint64_t tui64;
typedef int64_t tsi64;
typedef bool_t tbool;
typedef intptr_t tbus;
typedef intptr_t tintptr;
2007-12-16 13:50:58 +03:00
/* wide char, socket */
2007-12-16 13:28:16 +03:00
#if defined(_WIN32)
2007-09-27 21:19:53 +04:00
typedef unsigned short twchar;
2007-12-16 13:28:16 +03:00
typedef unsigned int tsock;
#else
2007-12-16 13:50:58 +03:00
typedef int twchar;
2007-12-16 13:28:16 +03:00
typedef int tsock;
#endif
2014-01-11 09:55:15 +04:00
#endif /* DEFINED_Ts */
2007-04-11 07:37:42 +04:00
/* format string verification */
#if defined(HAVE_FUNC_ATTRIBUTE_FORMAT)
#define printflike(arg_format, arg_first_check) \
__attribute__((__format__(__printf__, arg_format, arg_first_check)))
#else
#define printflike(arg_format, arg_first_check)
#endif
/* module interface */
#ifdef __cplusplus
extern "C" {
#endif
tintptr mod_init(void);
int mod_exit(tintptr);
#ifdef __cplusplus
}
#endif
2005-06-28 07:04:36 +04:00
#endif