Merge tag 'LibVNCServer-0.9.11' of https://github.com/LibVNC/libvncserver
Conflicts: CMakeLists.txt libvncserver/main.cpull/1/head
commit
68cb29a12f
@ -0,0 +1,15 @@
|
|||||||
|
language: c
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- gcc
|
||||||
|
- clang
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export CFLAGS="-I/usr/local/opt/openssl/include $CFLAGS" LDFLAGS="-L/usr/local/opt/openssl/lib $LDFLAGS"; fi'
|
||||||
|
|
||||||
|
# before build script, run autoreconf
|
||||||
|
before_script: autoreconf -fiv
|
@ -0,0 +1,29 @@
|
|||||||
|
/************************ sha-private.h ************************/
|
||||||
|
/***************** See RFC 6234 for details. *******************/
|
||||||
|
#ifndef _SHA_PRIVATE__H
|
||||||
|
#define _SHA_PRIVATE__H
|
||||||
|
/*
|
||||||
|
* These definitions are defined in FIPS 180-3, section 4.1.
|
||||||
|
* Ch() and Maj() are defined identically in sections 4.1.1,
|
||||||
|
* 4.1.2, and 4.1.3.
|
||||||
|
*
|
||||||
|
* The definitions used in FIPS 180-3 are as follows:
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef USE_MODIFIED_MACROS
|
||||||
|
#define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
|
||||||
|
#define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||||
|
#else /* USE_MODIFIED_MACROS */
|
||||||
|
/*
|
||||||
|
* The following definitions are equivalent and potentially faster.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z))
|
||||||
|
#define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
|
||||||
|
|
||||||
|
#endif /* USE_MODIFIED_MACROS */
|
||||||
|
|
||||||
|
#define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z))
|
||||||
|
|
||||||
|
#endif /* _SHA_PRIVATE__H */
|
||||||
|
|
@ -0,0 +1,358 @@
|
|||||||
|
/**************************** sha.h ****************************/
|
||||||
|
/***************** See RFC 6234 for details. *******************/
|
||||||
|
/*
|
||||||
|
Copyright (c) 2011 IETF Trust and the persons identified as
|
||||||
|
authors of the code. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or
|
||||||
|
without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
- Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and
|
||||||
|
the following disclaimer.
|
||||||
|
|
||||||
|
- Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials provided
|
||||||
|
with the distribution.
|
||||||
|
|
||||||
|
- Neither the name of Internet Society, IETF or IETF Trust, nor
|
||||||
|
the names of specific contributors, may be used to endorse or
|
||||||
|
promote products derived from this software without specific
|
||||||
|
prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||||
|
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||||
|
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||||
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#ifndef _SHA_H_
|
||||||
|
#define _SHA_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description:
|
||||||
|
* This file implements the Secure Hash Algorithms
|
||||||
|
* as defined in the U.S. National Institute of Standards
|
||||||
|
* and Technology Federal Information Processing Standards
|
||||||
|
* Publication (FIPS PUB) 180-3 published in October 2008
|
||||||
|
* and formerly defined in its predecessors, FIPS PUB 180-1
|
||||||
|
* and FIP PUB 180-2.
|
||||||
|
*
|
||||||
|
* A combined document showing all algorithms is available at
|
||||||
|
* http://csrc.nist.gov/publications/fips/
|
||||||
|
* fips180-3/fips180-3_final.pdf
|
||||||
|
*
|
||||||
|
* The five hashes are defined in these sizes:
|
||||||
|
* SHA-1 20 byte / 160 bit
|
||||||
|
* SHA-224 28 byte / 224 bit
|
||||||
|
* SHA-256 32 byte / 256 bit
|
||||||
|
* SHA-384 48 byte / 384 bit
|
||||||
|
* SHA-512 64 byte / 512 bit
|
||||||
|
*
|
||||||
|
* Compilation Note:
|
||||||
|
* These files may be compiled with two options:
|
||||||
|
* USE_32BIT_ONLY - use 32-bit arithmetic only, for systems
|
||||||
|
* without 64-bit integers
|
||||||
|
*
|
||||||
|
* USE_MODIFIED_MACROS - use alternate form of the SHA_Ch()
|
||||||
|
* and SHA_Maj() macros that are equivalent
|
||||||
|
* and potentially faster on many systems
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
/*
|
||||||
|
* If you do not have the ISO standard stdint.h header file, then you
|
||||||
|
* must typedef the following:
|
||||||
|
* name meaning
|
||||||
|
* uint64_t unsigned 64-bit integer
|
||||||
|
* uint32_t unsigned 32-bit integer
|
||||||
|
* uint8_t unsigned 8-bit integer (i.e., unsigned char)
|
||||||
|
* int_least16_t integer of >= 16 bits
|
||||||
|
*
|
||||||
|
* See stdint-example.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _SHA_enum_
|
||||||
|
#define _SHA_enum_
|
||||||
|
/*
|
||||||
|
* All SHA functions return one of these values.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
shaSuccess = 0,
|
||||||
|
shaNull, /* Null pointer parameter */
|
||||||
|
shaInputTooLong, /* input data too long */
|
||||||
|
shaStateError, /* called Input after FinalBits or Result */
|
||||||
|
shaBadParam /* passed a bad parameter */
|
||||||
|
};
|
||||||
|
#endif /* _SHA_enum_ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These constants hold size information for each of the SHA
|
||||||
|
* hashing operations
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
SHA1_Message_Block_Size = 64, SHA224_Message_Block_Size = 64,
|
||||||
|
SHA256_Message_Block_Size = 64, SHA384_Message_Block_Size = 128,
|
||||||
|
SHA512_Message_Block_Size = 128,
|
||||||
|
USHA_Max_Message_Block_Size = SHA512_Message_Block_Size,
|
||||||
|
|
||||||
|
SHA1HashSize = 20, SHA224HashSize = 28, SHA256HashSize = 32,
|
||||||
|
SHA384HashSize = 48, SHA512HashSize = 64,
|
||||||
|
USHAMaxHashSize = SHA512HashSize,
|
||||||
|
|
||||||
|
SHA1HashSizeBits = 160, SHA224HashSizeBits = 224,
|
||||||
|
SHA256HashSizeBits = 256, SHA384HashSizeBits = 384,
|
||||||
|
SHA512HashSizeBits = 512, USHAMaxHashSizeBits = SHA512HashSizeBits
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These constants are used in the USHA (Unified SHA) functions.
|
||||||
|
*/
|
||||||
|
typedef enum SHAversion {
|
||||||
|
SHA1, SHA224, SHA256, SHA384, SHA512
|
||||||
|
} SHAversion;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the SHA-1
|
||||||
|
* hashing operation.
|
||||||
|
*/
|
||||||
|
typedef struct SHA1Context {
|
||||||
|
uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
|
||||||
|
|
||||||
|
uint32_t Length_High; /* Message length in bits */
|
||||||
|
uint32_t Length_Low; /* Message length in bits */
|
||||||
|
|
||||||
|
int_least16_t Message_Block_Index; /* Message_Block array index */
|
||||||
|
/* 512-bit message blocks */
|
||||||
|
uint8_t Message_Block[SHA1_Message_Block_Size];
|
||||||
|
|
||||||
|
int Computed; /* Is the hash computed? */
|
||||||
|
int Corrupted; /* Cumulative corruption code */
|
||||||
|
} SHA1Context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the SHA-256
|
||||||
|
* hashing operation.
|
||||||
|
*/
|
||||||
|
typedef struct SHA256Context {
|
||||||
|
uint32_t Intermediate_Hash[SHA256HashSize/4]; /* Message Digest */
|
||||||
|
|
||||||
|
uint32_t Length_High; /* Message length in bits */
|
||||||
|
uint32_t Length_Low; /* Message length in bits */
|
||||||
|
|
||||||
|
int_least16_t Message_Block_Index; /* Message_Block array index */
|
||||||
|
/* 512-bit message blocks */
|
||||||
|
uint8_t Message_Block[SHA256_Message_Block_Size];
|
||||||
|
|
||||||
|
int Computed; /* Is the hash computed? */
|
||||||
|
int Corrupted; /* Cumulative corruption code */
|
||||||
|
} SHA256Context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the SHA-512
|
||||||
|
* hashing operation.
|
||||||
|
*/
|
||||||
|
typedef struct SHA512Context {
|
||||||
|
#ifdef USE_32BIT_ONLY
|
||||||
|
uint32_t Intermediate_Hash[SHA512HashSize/4]; /* Message Digest */
|
||||||
|
uint32_t Length[4]; /* Message length in bits */
|
||||||
|
#else /* !USE_32BIT_ONLY */
|
||||||
|
uint64_t Intermediate_Hash[SHA512HashSize/8]; /* Message Digest */
|
||||||
|
uint64_t Length_High, Length_Low; /* Message length in bits */
|
||||||
|
#endif /* USE_32BIT_ONLY */
|
||||||
|
|
||||||
|
int_least16_t Message_Block_Index; /* Message_Block array index */
|
||||||
|
/* 1024-bit message blocks */
|
||||||
|
uint8_t Message_Block[SHA512_Message_Block_Size];
|
||||||
|
|
||||||
|
int Computed; /* Is the hash computed?*/
|
||||||
|
int Corrupted; /* Cumulative corruption code */
|
||||||
|
} SHA512Context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the SHA-224
|
||||||
|
* hashing operation. It uses the SHA-256 structure for computation.
|
||||||
|
*/
|
||||||
|
typedef struct SHA256Context SHA224Context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the SHA-384
|
||||||
|
* hashing operation. It uses the SHA-512 structure for computation.
|
||||||
|
*/
|
||||||
|
typedef struct SHA512Context SHA384Context;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure holds context information for all SHA
|
||||||
|
* hashing operations.
|
||||||
|
*/
|
||||||
|
typedef struct USHAContext {
|
||||||
|
int whichSha; /* which SHA is being used */
|
||||||
|
union {
|
||||||
|
SHA1Context sha1Context;
|
||||||
|
SHA224Context sha224Context; SHA256Context sha256Context;
|
||||||
|
SHA384Context sha384Context; SHA512Context sha512Context;
|
||||||
|
} ctx;
|
||||||
|
|
||||||
|
} USHAContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the HMAC
|
||||||
|
* keyed-hashing operation.
|
||||||
|
*/
|
||||||
|
typedef struct HMACContext {
|
||||||
|
int whichSha; /* which SHA is being used */
|
||||||
|
int hashSize; /* hash size of SHA being used */
|
||||||
|
int blockSize; /* block size of SHA being used */
|
||||||
|
USHAContext shaContext; /* SHA context */
|
||||||
|
unsigned char k_opad[USHA_Max_Message_Block_Size];
|
||||||
|
/* outer padding - key XORd with opad */
|
||||||
|
int Computed; /* Is the MAC computed? */
|
||||||
|
int Corrupted; /* Cumulative corruption code */
|
||||||
|
|
||||||
|
} HMACContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This structure will hold context information for the HKDF
|
||||||
|
* extract-and-expand Key Derivation Functions.
|
||||||
|
*/
|
||||||
|
typedef struct HKDFContext {
|
||||||
|
int whichSha; /* which SHA is being used */
|
||||||
|
HMACContext hmacContext;
|
||||||
|
int hashSize; /* hash size of SHA being used */
|
||||||
|
unsigned char prk[USHAMaxHashSize];
|
||||||
|
/* pseudo-random key - output of hkdfInput */
|
||||||
|
int Computed; /* Is the key material computed? */
|
||||||
|
int Corrupted; /* Cumulative corruption code */
|
||||||
|
} HKDFContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function Prototypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* SHA-1 */
|
||||||
|
extern int SHA1Reset(SHA1Context *);
|
||||||
|
extern int SHA1Input(SHA1Context *, const uint8_t *bytes,
|
||||||
|
unsigned int bytecount);
|
||||||
|
extern int SHA1FinalBits(SHA1Context *, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int SHA1Result(SHA1Context *,
|
||||||
|
uint8_t Message_Digest[SHA1HashSize]);
|
||||||
|
|
||||||
|
/* SHA-224 */
|
||||||
|
extern int SHA224Reset(SHA224Context *);
|
||||||
|
extern int SHA224Input(SHA224Context *, const uint8_t *bytes,
|
||||||
|
unsigned int bytecount);
|
||||||
|
extern int SHA224FinalBits(SHA224Context *, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int SHA224Result(SHA224Context *,
|
||||||
|
uint8_t Message_Digest[SHA224HashSize]);
|
||||||
|
|
||||||
|
/* SHA-256 */
|
||||||
|
extern int SHA256Reset(SHA256Context *);
|
||||||
|
extern int SHA256Input(SHA256Context *, const uint8_t *bytes,
|
||||||
|
unsigned int bytecount);
|
||||||
|
extern int SHA256FinalBits(SHA256Context *, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int SHA256Result(SHA256Context *,
|
||||||
|
uint8_t Message_Digest[SHA256HashSize]);
|
||||||
|
|
||||||
|
/* SHA-384 */
|
||||||
|
extern int SHA384Reset(SHA384Context *);
|
||||||
|
extern int SHA384Input(SHA384Context *, const uint8_t *bytes,
|
||||||
|
unsigned int bytecount);
|
||||||
|
extern int SHA384FinalBits(SHA384Context *, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int SHA384Result(SHA384Context *,
|
||||||
|
uint8_t Message_Digest[SHA384HashSize]);
|
||||||
|
|
||||||
|
/* SHA-512 */
|
||||||
|
extern int SHA512Reset(SHA512Context *);
|
||||||
|
extern int SHA512Input(SHA512Context *, const uint8_t *bytes,
|
||||||
|
unsigned int bytecount);
|
||||||
|
extern int SHA512FinalBits(SHA512Context *, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int SHA512Result(SHA512Context *,
|
||||||
|
uint8_t Message_Digest[SHA512HashSize]);
|
||||||
|
|
||||||
|
/* Unified SHA functions, chosen by whichSha */
|
||||||
|
extern int USHAReset(USHAContext *context, SHAversion whichSha);
|
||||||
|
extern int USHAInput(USHAContext *context,
|
||||||
|
const uint8_t *bytes, unsigned int bytecount);
|
||||||
|
extern int USHAFinalBits(USHAContext *context,
|
||||||
|
uint8_t bits, unsigned int bit_count);
|
||||||
|
extern int USHAResult(USHAContext *context,
|
||||||
|
uint8_t Message_Digest[USHAMaxHashSize]);
|
||||||
|
extern int USHABlockSize(enum SHAversion whichSha);
|
||||||
|
extern int USHAHashSize(enum SHAversion whichSha);
|
||||||
|
extern int USHAHashSizeBits(enum SHAversion whichSha);
|
||||||
|
extern const char *USHAHashName(enum SHAversion whichSha);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
|
||||||
|
* for all SHAs.
|
||||||
|
* This interface allows a fixed-length text input to be used.
|
||||||
|
*/
|
||||||
|
extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
|
||||||
|
const unsigned char *text, /* pointer to data stream */
|
||||||
|
int text_len, /* length of data stream */
|
||||||
|
const unsigned char *key, /* pointer to authentication key */
|
||||||
|
int key_len, /* length of authentication key */
|
||||||
|
uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HMAC Keyed-Hashing for Message Authentication, RFC 2104,
|
||||||
|
* for all SHAs.
|
||||||
|
* This interface allows any length of text input to be used.
|
||||||
|
*/
|
||||||
|
extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
|
||||||
|
const unsigned char *key, int key_len);
|
||||||
|
extern int hmacInput(HMACContext *context, const unsigned char *text,
|
||||||
|
int text_len);
|
||||||
|
extern int hmacFinalBits(HMACContext *context, uint8_t bits,
|
||||||
|
unsigned int bit_count);
|
||||||
|
extern int hmacResult(HMACContext *context,
|
||||||
|
uint8_t digest[USHAMaxHashSize]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
|
||||||
|
* RFC 5869, for all SHAs.
|
||||||
|
*/
|
||||||
|
extern int hkdf(SHAversion whichSha, const unsigned char *salt,
|
||||||
|
int salt_len, const unsigned char *ikm, int ikm_len,
|
||||||
|
const unsigned char *info, int info_len,
|
||||||
|
uint8_t okm[ ], int okm_len);
|
||||||
|
extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
|
||||||
|
int salt_len, const unsigned char *ikm,
|
||||||
|
int ikm_len, uint8_t prk[USHAMaxHashSize]);
|
||||||
|
extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
|
||||||
|
int prk_len, const unsigned char *info,
|
||||||
|
int info_len, uint8_t okm[ ], int okm_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HKDF HMAC-based Extract-and-Expand Key Derivation Function,
|
||||||
|
* RFC 5869, for all SHAs.
|
||||||
|
* This interface allows any length of text input to be used.
|
||||||
|
*/
|
||||||
|
extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
|
||||||
|
const unsigned char *salt, int salt_len);
|
||||||
|
extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
|
||||||
|
int ikm_len);
|
||||||
|
extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
|
||||||
|
unsigned int ikm_bit_count);
|
||||||
|
extern int hkdfResult(HKDFContext *context,
|
||||||
|
uint8_t prk[USHAMaxHashSize],
|
||||||
|
const unsigned char *info, int info_len,
|
||||||
|
uint8_t okm[USHAMaxHashSize], int okm_len);
|
||||||
|
#endif /* _SHA_H_ */
|
||||||
|
|
@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) The Internet Society (2001). All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This document and translations of it may be copied and furnished to
|
|
||||||
* others, and derivative works that comment on or otherwise explain it
|
|
||||||
* or assist in its implementation may be prepared, copied, published
|
|
||||||
* and distributed, in whole or in part, without restriction of any
|
|
||||||
* kind, provided that the above copyright notice and this paragraph are
|
|
||||||
* included on all such copies and derivative works. However, this
|
|
||||||
* document itself may not be modified in any way, such as by removing
|
|
||||||
* the copyright notice or references to the Internet Society or other
|
|
||||||
* Internet organizations, except as needed for the purpose of
|
|
||||||
* developing Internet standards in which case the procedures for
|
|
||||||
* copyrights defined in the Internet Standards process must be
|
|
||||||
* followed, or as required to translate it into languages other than
|
|
||||||
* English.
|
|
||||||
*
|
|
||||||
* The limited permissions granted above are perpetual and will not be
|
|
||||||
* revoked by the Internet Society or its successors or assigns.
|
|
||||||
*
|
|
||||||
* This document and the information contained herein is provided on an
|
|
||||||
* "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
|
|
||||||
* TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
|
|
||||||
* BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
|
|
||||||
* HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* sha1.h
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* This is the header file for code which implements the Secure
|
|
||||||
* Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
|
|
||||||
* April 17, 1995.
|
|
||||||
*
|
|
||||||
* Many of the variable names in this code, especially the
|
|
||||||
* single character names, were used because those were the names
|
|
||||||
* used in the publication.
|
|
||||||
*
|
|
||||||
* Please read the file sha1.c for more information.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _SHA1_H_
|
|
||||||
#define _SHA1_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
/*
|
|
||||||
* If you do not have the ISO standard stdint.h header file, then you
|
|
||||||
* must typdef the following:
|
|
||||||
* name meaning
|
|
||||||
* uint32_t unsigned 32 bit integer
|
|
||||||
* uint8_t unsigned 8 bit integer (i.e., unsigned char)
|
|
||||||
* int_least16_t integer of >= 16 bits
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _SHA_enum_
|
|
||||||
#define _SHA_enum_
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
shaSuccess = 0,
|
|
||||||
shaNull, /* Null pointer parameter */
|
|
||||||
shaInputTooLong, /* input data too long */
|
|
||||||
shaStateError /* called Input after Result */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
#define SHA1HashSize 20
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This structure will hold context information for the SHA-1
|
|
||||||
* hashing operation
|
|
||||||
*/
|
|
||||||
typedef struct SHA1Context
|
|
||||||
{
|
|
||||||
uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
|
|
||||||
|
|
||||||
uint32_t Length_Low; /* Message length in bits */
|
|
||||||
uint32_t Length_High; /* Message length in bits */
|
|
||||||
|
|
||||||
/* Index into message block array */
|
|
||||||
int_least16_t Message_Block_Index;
|
|
||||||
uint8_t Message_Block[64]; /* 512-bit message blocks */
|
|
||||||
|
|
||||||
int Computed; /* Is the digest computed? */
|
|
||||||
int Corrupted; /* Is the message digest corrupted? */
|
|
||||||
} SHA1Context;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Function Prototypes
|
|
||||||
*/
|
|
||||||
int SHA1Reset( SHA1Context *);
|
|
||||||
int SHA1Input( SHA1Context *,
|
|
||||||
const uint8_t *,
|
|
||||||
unsigned int);
|
|
||||||
int SHA1Result( SHA1Context *,
|
|
||||||
uint8_t Message_Digest[SHA1HashSize]);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,648 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2012 Intel Corporation. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* This is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This software 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this software; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
||||||
* USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef LIBVNCSERVER_CONFIG_LIBVA
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <va/va_version.h>
|
|
||||||
#if VA_CHECK_VERSION(0,34,0)
|
|
||||||
#include <va/va_compat.h>
|
|
||||||
#endif
|
|
||||||
#include <va/va_x11.h>
|
|
||||||
|
|
||||||
enum _slice_types {
|
|
||||||
SLICE_TYPE_P = 0, /* Predicted */
|
|
||||||
SLICE_TYPE_B = 1, /* Bi-predicted */
|
|
||||||
SLICE_TYPE_I = 2, /* Intra coded */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define SURFACE_NUM 7
|
|
||||||
|
|
||||||
VADisplay va_dpy = NULL;
|
|
||||||
VAConfigID va_config_id;
|
|
||||||
VASurfaceID va_surface_id[SURFACE_NUM];
|
|
||||||
VAContextID va_context_id = 0;
|
|
||||||
|
|
||||||
VABufferID va_pic_param_buf_id[SURFACE_NUM];
|
|
||||||
VABufferID va_mat_param_buf_id[SURFACE_NUM];
|
|
||||||
VABufferID va_sp_param_buf_id[SURFACE_NUM];
|
|
||||||
VABufferID va_d_param_buf_id[SURFACE_NUM];
|
|
||||||
|
|
||||||
static int cur_height = 0;
|
|
||||||
static int cur_width = 0;
|
|
||||||
static unsigned int num_frames = 0;
|
|
||||||
static int sid = 0;
|
|
||||||
static unsigned int frame_id = 0;
|
|
||||||
static int field_order_count = 0;
|
|
||||||
static VASurfaceID curr_surface = VA_INVALID_ID;
|
|
||||||
|
|
||||||
VAStatus gva_status;
|
|
||||||
VASurfaceStatus gsurface_status;
|
|
||||||
#define CHECK_SURF(X) \
|
|
||||||
gva_status = vaQuerySurfaceStatus(va_dpy, X, &gsurface_status); \
|
|
||||||
if (gsurface_status != 4) printf("ss: %d\n", gsurface_status);
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define DebugLog(A) rfbClientLog A
|
|
||||||
#else
|
|
||||||
#define DebugLog(A)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CHECK_VASTATUS(va_status,func) \
|
|
||||||
if (va_status != VA_STATUS_SUCCESS) { \
|
|
||||||
/*fprintf(stderr,"%s:%s (%d) failed,exit\n", __func__, func, __LINE__);*/ \
|
|
||||||
rfbClientErr("%s:%s:%d failed (0x%x),exit\n", __func__, func, __LINE__, va_status); \
|
|
||||||
exit(1); \
|
|
||||||
} else { \
|
|
||||||
/*fprintf(stderr,">> SUCCESS for: %s:%s (%d)\n", __func__, func, __LINE__);*/ \
|
|
||||||
DebugLog(("%s:%s:%d success\n", __func__, func, __LINE__)); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Forward declarations
|
|
||||||
*/
|
|
||||||
static void h264_decode_frame(int f_width, int f_height, char *framedata, int framesize, int slice_type);
|
|
||||||
static void SetVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p, int width, int height);
|
|
||||||
static void SetVASliceParameterBufferH264(VASliceParameterBufferH264 *p);
|
|
||||||
static void SetVASliceParameterBufferH264_Intra(VASliceParameterBufferH264 *p, int first);
|
|
||||||
|
|
||||||
static void put_updated_rectangle(rfbClient *client, int x, int y, int width, int height, int f_width, int f_height, int first_for_frame);
|
|
||||||
static void nv12_to_rgba(const VAImage vaImage, rfbClient *client, int ch_x, int ch_y, int ch_w, int ch_h);
|
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: get this value from the server instead of hardcoding 32bit pixels */
|
|
||||||
#define BPP (4 * 8)
|
|
||||||
|
|
||||||
static const char *string_of_FOURCC(uint32_t fourcc)
|
|
||||||
{
|
|
||||||
static int buf;
|
|
||||||
static char str[2][5];
|
|
||||||
|
|
||||||
buf ^= 1;
|
|
||||||
str[buf][0] = fourcc;
|
|
||||||
str[buf][1] = fourcc >> 8;
|
|
||||||
str[buf][2] = fourcc >> 16;
|
|
||||||
str[buf][3] = fourcc >> 24;
|
|
||||||
str[buf][4] = '\0';
|
|
||||||
return str[buf];
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline const char *string_of_VAImageFormat(VAImageFormat *imgfmt)
|
|
||||||
{
|
|
||||||
return string_of_FOURCC(imgfmt->fourcc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static rfbBool
|
|
||||||
HandleH264 (rfbClient* client, int rx, int ry, int rw, int rh)
|
|
||||||
{
|
|
||||||
rfbH264Header hdr;
|
|
||||||
char *framedata;
|
|
||||||
|
|
||||||
DebugLog(("Framebuffer update with H264 (x: %d, y: %d, w: %d, h: %d)\n", rx, ry, rw, rh));
|
|
||||||
|
|
||||||
/* First, read the frame size and allocate buffer to store the data */
|
|
||||||
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbH264Header))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
hdr.slice_type = rfbClientSwap32IfLE(hdr.slice_type);
|
|
||||||
hdr.nBytes = rfbClientSwap32IfLE(hdr.nBytes);
|
|
||||||
hdr.width = rfbClientSwap32IfLE(hdr.width);
|
|
||||||
hdr.height = rfbClientSwap32IfLE(hdr.height);
|
|
||||||
|
|
||||||
framedata = (char*) malloc(hdr.nBytes);
|
|
||||||
|
|
||||||
/* Obtain frame data from the server */
|
|
||||||
DebugLog(("Reading %d bytes of frame data (type: %d)\n", hdr.nBytes, hdr.slice_type));
|
|
||||||
if (!ReadFromRFBServer(client, framedata, hdr.nBytes))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* First make sure we have a large enough raw buffer to hold the
|
|
||||||
* decompressed data. In practice, with a fixed BPP, fixed frame
|
|
||||||
* buffer size and the first update containing the entire frame
|
|
||||||
* buffer, this buffer allocation should only happen once, on the
|
|
||||||
* first update.
|
|
||||||
*/
|
|
||||||
if ( client->raw_buffer_size < (( rw * rh ) * ( BPP / 8 ))) {
|
|
||||||
if ( client->raw_buffer != NULL ) {
|
|
||||||
free( client->raw_buffer );
|
|
||||||
}
|
|
||||||
|
|
||||||
client->raw_buffer_size = (( rw * rh ) * ( BPP / 8 ));
|
|
||||||
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
|
|
||||||
rfbClientLog("Allocated raw buffer of %d bytes (%dx%dx%d BPP)\n", client->raw_buffer_size, rw, rh, BPP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Decode frame if frame data was sent. Server only sends frame data for the first
|
|
||||||
* framebuffer update message for a particular frame buffer contents.
|
|
||||||
* If more than 1 rectangle is updated, the messages after the first one (with
|
|
||||||
* the H.264 frame) have nBytes == 0.
|
|
||||||
*/
|
|
||||||
if (hdr.nBytes > 0) {
|
|
||||||
DebugLog((" decoding %d bytes of H.264 data\n", hdr.nBytes));
|
|
||||||
h264_decode_frame(hdr.width, hdr.height, framedata, hdr.nBytes, hdr.slice_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugLog((" updating rectangle (%d, %d)-(%d, %d)\n", rx, ry, rw, rh));
|
|
||||||
put_updated_rectangle(client, rx, ry, rw, rh, hdr.width, hdr.height, hdr.nBytes != 0);
|
|
||||||
|
|
||||||
free(framedata);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void h264_cleanup_decoder()
|
|
||||||
{
|
|
||||||
VAStatus va_status;
|
|
||||||
|
|
||||||
rfbClientLog("%s()\n", __FUNCTION__);
|
|
||||||
|
|
||||||
if (va_surface_id[0] != VA_INVALID_ID) {
|
|
||||||
va_status = vaDestroySurfaces(va_dpy, &va_surface_id[0], SURFACE_NUM);
|
|
||||||
CHECK_VASTATUS(va_status, "vaDestroySurfaces");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (va_context_id) {
|
|
||||||
va_status = vaDestroyContext(va_dpy, va_context_id);
|
|
||||||
CHECK_VASTATUS(va_status, "vaDestroyContext");
|
|
||||||
va_context_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_frames = 0;
|
|
||||||
sid = 0;
|
|
||||||
frame_id = 0;
|
|
||||||
field_order_count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void h264_init_decoder(int width, int height)
|
|
||||||
{
|
|
||||||
VAStatus va_status;
|
|
||||||
|
|
||||||
if (va_context_id) {
|
|
||||||
rfbClientLog("%s: va_dpy already initialized\n", __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (va_dpy != NULL) {
|
|
||||||
rfbClientLog("%s: Re-initializing H.264 decoder\n", __FUNCTION__);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rfbClientLog("%s: initializing H.264 decoder\n", __FUNCTION__);
|
|
||||||
|
|
||||||
/* Attach VA display to local X display */
|
|
||||||
Display *win_display = (Display *)XOpenDisplay(":0.0");
|
|
||||||
if (win_display == NULL) {
|
|
||||||
rfbClientErr("Can't connect to local display\n");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int major_ver, minor_ver;
|
|
||||||
va_dpy = vaGetDisplay(win_display);
|
|
||||||
va_status = vaInitialize(va_dpy, &major_ver, &minor_ver);
|
|
||||||
CHECK_VASTATUS(va_status, "vaInitialize");
|
|
||||||
rfbClientLog("%s: libva version %d.%d found\n", __FUNCTION__, major_ver, minor_ver);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check for VLD entrypoint */
|
|
||||||
int num_entrypoints;
|
|
||||||
VAEntrypoint entrypoints[5];
|
|
||||||
int vld_entrypoint_found = 0;
|
|
||||||
|
|
||||||
/* Change VAProfileH264High if needed */
|
|
||||||
VAProfile profile = VAProfileH264High;
|
|
||||||
va_status = vaQueryConfigEntrypoints(va_dpy, profile, entrypoints, &num_entrypoints);
|
|
||||||
CHECK_VASTATUS(va_status, "vaQueryConfigEntrypoints");
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < num_entrypoints; ++i) {
|
|
||||||
if (entrypoints[i] == VAEntrypointVLD) {
|
|
||||||
vld_entrypoint_found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vld_entrypoint_found == 0) {
|
|
||||||
rfbClientErr("VLD entrypoint not found\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create configuration for the decode pipeline */
|
|
||||||
VAConfigAttrib attrib;
|
|
||||||
attrib.type = VAConfigAttribRTFormat;
|
|
||||||
va_status = vaCreateConfig(va_dpy, profile, VAEntrypointVLD, &attrib, 1, &va_config_id);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateConfig");
|
|
||||||
|
|
||||||
/* Create VA surfaces */
|
|
||||||
for (i = 0; i < SURFACE_NUM; ++i) {
|
|
||||||
va_surface_id[i] = VA_INVALID_ID;
|
|
||||||
va_pic_param_buf_id[i] = VA_INVALID_ID;
|
|
||||||
va_mat_param_buf_id[i] = VA_INVALID_ID;
|
|
||||||
va_sp_param_buf_id[i] = VA_INVALID_ID;
|
|
||||||
va_d_param_buf_id[i] = VA_INVALID_ID;
|
|
||||||
}
|
|
||||||
va_status = vaCreateSurfaces(va_dpy, width, height, VA_RT_FORMAT_YUV420, SURFACE_NUM, &va_surface_id[0]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateSurfaces");
|
|
||||||
for (i = 0; i < SURFACE_NUM; ++i) {
|
|
||||||
DebugLog(("%s: va_surface_id[%d] = %p\n", __FUNCTION__, i, va_surface_id[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create VA context */
|
|
||||||
va_status = vaCreateContext(va_dpy, va_config_id, width, height, 0/*VA_PROGRESSIVE*/, &va_surface_id[0], SURFACE_NUM, &va_context_id);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateContext");
|
|
||||||
DebugLog(("%s: VA context created (id: %d)\n", __FUNCTION__, va_context_id));
|
|
||||||
|
|
||||||
|
|
||||||
/* Instantiate decode pipeline */
|
|
||||||
va_status = vaBeginPicture(va_dpy, va_context_id, va_surface_id[0]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaBeginPicture");
|
|
||||||
|
|
||||||
rfbClientLog("%s: H.264 decoder initialized\n", __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void h264_decode_frame(int f_width, int f_height, char *framedata, int framesize, int slice_type)
|
|
||||||
{
|
|
||||||
VAStatus va_status;
|
|
||||||
|
|
||||||
DebugLog(("%s: called for frame of %d bytes (%dx%d) slice_type=%d\n", __FUNCTION__, framesize, width, height, slice_type));
|
|
||||||
|
|
||||||
/* Initialize decode pipeline if necessary */
|
|
||||||
if ( (f_width > cur_width) || (f_height > cur_height) ) {
|
|
||||||
if (va_dpy != NULL)
|
|
||||||
h264_cleanup_decoder();
|
|
||||||
cur_width = f_width;
|
|
||||||
cur_height = f_height;
|
|
||||||
|
|
||||||
h264_init_decoder(f_width, f_height);
|
|
||||||
rfbClientLog("%s: decoder initialized\n", __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Decode frame */
|
|
||||||
static VAPictureH264 va_picture_h264, va_old_picture_h264;
|
|
||||||
|
|
||||||
/* The server should always send an I-frame when a new client connects
|
|
||||||
* or when the resolution of the framebuffer changes, but we check
|
|
||||||
* just in case.
|
|
||||||
*/
|
|
||||||
if ( (slice_type != SLICE_TYPE_I) && (num_frames == 0) ) {
|
|
||||||
rfbClientLog("First frame is not an I frame !!! Skipping!!!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugLog(("%s: frame_id=%d va_surface_id[%d]=0x%x field_order_count=%d\n", __FUNCTION__, frame_id, sid, va_surface_id[sid], field_order_count));
|
|
||||||
|
|
||||||
va_picture_h264.picture_id = va_surface_id[sid];
|
|
||||||
va_picture_h264.frame_idx = frame_id;
|
|
||||||
va_picture_h264.flags = 0;
|
|
||||||
va_picture_h264.BottomFieldOrderCnt = field_order_count;
|
|
||||||
va_picture_h264.TopFieldOrderCnt = field_order_count;
|
|
||||||
|
|
||||||
/* Set up picture parameter buffer */
|
|
||||||
if (va_pic_param_buf_id[sid] == VA_INVALID_ID) {
|
|
||||||
va_status = vaCreateBuffer(va_dpy, va_context_id, VAPictureParameterBufferType, sizeof(VAPictureParameterBufferH264), 1, NULL, &va_pic_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateBuffer(PicParam)");
|
|
||||||
}
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
|
|
||||||
VAPictureParameterBufferH264 *pic_param_buf = NULL;
|
|
||||||
va_status = vaMapBuffer(va_dpy, va_pic_param_buf_id[sid], (void **)&pic_param_buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaMapBuffer(PicParam)");
|
|
||||||
|
|
||||||
SetVAPictureParameterBufferH264(pic_param_buf, f_width, f_height);
|
|
||||||
memcpy(&pic_param_buf->CurrPic, &va_picture_h264, sizeof(VAPictureH264));
|
|
||||||
|
|
||||||
if (slice_type == SLICE_TYPE_P) {
|
|
||||||
memcpy(&pic_param_buf->ReferenceFrames[0], &va_old_picture_h264, sizeof(VAPictureH264));
|
|
||||||
pic_param_buf->ReferenceFrames[0].flags = 0;
|
|
||||||
}
|
|
||||||
else if (slice_type != SLICE_TYPE_I) {
|
|
||||||
rfbClientLog("Frame type %d not supported!!!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pic_param_buf->frame_num = frame_id;
|
|
||||||
|
|
||||||
va_status = vaUnmapBuffer(va_dpy, va_pic_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaUnmapBuffer(PicParam)");
|
|
||||||
|
|
||||||
/* Set up IQ matrix buffer */
|
|
||||||
if (va_mat_param_buf_id[sid] == VA_INVALID_ID) {
|
|
||||||
va_status = vaCreateBuffer(va_dpy, va_context_id, VAIQMatrixBufferType, sizeof(VAIQMatrixBufferH264), 1, NULL, &va_mat_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateBuffer(IQMatrix)");
|
|
||||||
}
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
|
|
||||||
VAIQMatrixBufferH264 *iq_matrix_buf = NULL;
|
|
||||||
va_status = vaMapBuffer(va_dpy, va_mat_param_buf_id[sid], (void **)&iq_matrix_buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaMapBuffer(IQMatrix)");
|
|
||||||
|
|
||||||
static const unsigned char m_MatrixBufferH264[]= {
|
|
||||||
/* ScalingList4x4[6][16] */
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
|
|
||||||
/* ScalingList8x8[2][64] */
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
memcpy(iq_matrix_buf, m_MatrixBufferH264, 224);
|
|
||||||
va_status = vaUnmapBuffer(va_dpy, va_mat_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaUnmapBuffer(IQMatrix)");
|
|
||||||
|
|
||||||
VABufferID buffer_ids[2];
|
|
||||||
buffer_ids[0] = va_pic_param_buf_id[sid];
|
|
||||||
buffer_ids[1] = va_mat_param_buf_id[sid];
|
|
||||||
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
va_status = vaRenderPicture(va_dpy, va_context_id, buffer_ids, 2);
|
|
||||||
CHECK_VASTATUS(va_status, "vaRenderPicture");
|
|
||||||
|
|
||||||
/* Set up slice parameter buffer */
|
|
||||||
if (va_sp_param_buf_id[sid] == VA_INVALID_ID) {
|
|
||||||
va_status = vaCreateBuffer(va_dpy, va_context_id, VASliceParameterBufferType, sizeof(VASliceParameterBufferH264), 1, NULL, &va_sp_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateBuffer(SliceParam)");
|
|
||||||
}
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
|
|
||||||
VASliceParameterBufferH264 *slice_param_buf = NULL;
|
|
||||||
va_status = vaMapBuffer(va_dpy, va_sp_param_buf_id[sid], (void **)&slice_param_buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaMapBuffer(SliceParam)");
|
|
||||||
|
|
||||||
static int t2_first = 1;
|
|
||||||
if (slice_type == SLICE_TYPE_I) {
|
|
||||||
SetVASliceParameterBufferH264_Intra(slice_param_buf, t2_first);
|
|
||||||
t2_first = 0;
|
|
||||||
} else {
|
|
||||||
SetVASliceParameterBufferH264(slice_param_buf);
|
|
||||||
memcpy(&slice_param_buf->RefPicList0[0], &va_old_picture_h264, sizeof(VAPictureH264));
|
|
||||||
slice_param_buf->RefPicList0[0].flags = 0;
|
|
||||||
}
|
|
||||||
slice_param_buf->slice_data_bit_offset = 0;
|
|
||||||
slice_param_buf->slice_data_size = framesize;
|
|
||||||
|
|
||||||
va_status = vaUnmapBuffer(va_dpy, va_sp_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaUnmapBuffer(SliceParam)");
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
|
|
||||||
/* Set up slice data buffer and copy H.264 encoded data */
|
|
||||||
if (va_d_param_buf_id[sid] == VA_INVALID_ID) {
|
|
||||||
/* TODO use estimation matching framebuffer dimensions instead of this large value */
|
|
||||||
va_status = vaCreateBuffer(va_dpy, va_context_id, VASliceDataBufferType, 4177920, 1, NULL, &va_d_param_buf_id[sid]); /* 1080p size */
|
|
||||||
CHECK_VASTATUS(va_status, "vaCreateBuffer(SliceData)");
|
|
||||||
}
|
|
||||||
|
|
||||||
char *slice_data_buf;
|
|
||||||
va_status = vaMapBuffer(va_dpy, va_d_param_buf_id[sid], (void **)&slice_data_buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaMapBuffer(SliceData)");
|
|
||||||
memcpy(slice_data_buf, framedata, framesize);
|
|
||||||
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
va_status = vaUnmapBuffer(va_dpy, va_d_param_buf_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaUnmapBuffer(SliceData)");
|
|
||||||
|
|
||||||
buffer_ids[0] = va_sp_param_buf_id[sid];
|
|
||||||
buffer_ids[1] = va_d_param_buf_id[sid];
|
|
||||||
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
va_status = vaRenderPicture(va_dpy, va_context_id, buffer_ids, 2);
|
|
||||||
CHECK_VASTATUS(va_status, "vaRenderPicture");
|
|
||||||
|
|
||||||
va_status = vaEndPicture(va_dpy, va_context_id);
|
|
||||||
CHECK_VASTATUS(va_status, "vaEndPicture");
|
|
||||||
|
|
||||||
/* Prepare next one... */
|
|
||||||
int sid_new = (sid + 1) % SURFACE_NUM;
|
|
||||||
DebugLog(("%s: new Surface ID = %d\n", __FUNCTION__, sid_new));
|
|
||||||
va_status = vaBeginPicture(va_dpy, va_context_id, va_surface_id[sid_new]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaBeginPicture");
|
|
||||||
|
|
||||||
/* Get decoded data */
|
|
||||||
va_status = vaSyncSurface(va_dpy, va_surface_id[sid]);
|
|
||||||
CHECK_VASTATUS(va_status, "vaSyncSurface");
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
|
|
||||||
curr_surface = va_surface_id[sid];
|
|
||||||
|
|
||||||
sid = sid_new;
|
|
||||||
|
|
||||||
field_order_count += 2;
|
|
||||||
++frame_id;
|
|
||||||
if (frame_id > 15) {
|
|
||||||
frame_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
++num_frames;
|
|
||||||
|
|
||||||
memcpy(&va_old_picture_h264, &va_picture_h264, sizeof(VAPictureH264));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void put_updated_rectangle(rfbClient *client, int x, int y, int width, int height, int f_width, int f_height, int first_for_frame)
|
|
||||||
{
|
|
||||||
if (curr_surface == VA_INVALID_ID) {
|
|
||||||
rfbClientErr("%s: called, but current surface is invalid\n", __FUNCTION__);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VAStatus va_status;
|
|
||||||
|
|
||||||
if (client->outputWindow) {
|
|
||||||
/* use efficient vaPutSurface() method of putting the framebuffer on the screen */
|
|
||||||
if (first_for_frame) {
|
|
||||||
/* vaPutSurface() clears window contents outside the given destination rectangle => always update full screen. */
|
|
||||||
va_status = vaPutSurface(va_dpy, curr_surface, client->outputWindow, 0, 0, f_width, f_height, 0, 0, f_width, f_height, NULL, 0, VA_FRAME_PICTURE);
|
|
||||||
CHECK_VASTATUS(va_status, "vaPutSurface");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (client->frameBuffer) {
|
|
||||||
/* ... or copy the changed framebuffer region manually as a fallback */
|
|
||||||
VAImage decoded_image;
|
|
||||||
decoded_image.image_id = VA_INVALID_ID;
|
|
||||||
decoded_image.buf = VA_INVALID_ID;
|
|
||||||
va_status = vaDeriveImage(va_dpy, curr_surface, &decoded_image);
|
|
||||||
CHECK_VASTATUS(va_status, "vaDeriveImage");
|
|
||||||
|
|
||||||
if ((decoded_image.image_id == VA_INVALID_ID) || (decoded_image.buf == VA_INVALID_ID)) {
|
|
||||||
rfbClientErr("%s: vaDeriveImage() returned success but VA image is invalid (id: %d, buf: %d)\n", __FUNCTION__, decoded_image.image_id, decoded_image.buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
nv12_to_rgba(decoded_image, client, x, y, width, height);
|
|
||||||
|
|
||||||
va_status = vaDestroyImage(va_dpy, decoded_image.image_id);
|
|
||||||
CHECK_VASTATUS(va_status, "vaDestroyImage");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVAPictureParameterBufferH264(VAPictureParameterBufferH264 *p, int width, int height)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
unsigned int width_in_mbs = (width + 15) / 16;
|
|
||||||
unsigned int height_in_mbs = (height + 15) / 16;
|
|
||||||
|
|
||||||
memset(p, 0, sizeof(VAPictureParameterBufferH264));
|
|
||||||
p->picture_width_in_mbs_minus1 = width_in_mbs - 1;
|
|
||||||
p->picture_height_in_mbs_minus1 = height_in_mbs - 1;
|
|
||||||
p->num_ref_frames = 1;
|
|
||||||
p->seq_fields.value = 145;
|
|
||||||
p->pic_fields.value = 0x501;
|
|
||||||
for (i = 0; i < 16; i++) {
|
|
||||||
p->ReferenceFrames[i].flags = VA_PICTURE_H264_INVALID;
|
|
||||||
p->ReferenceFrames[i].picture_id = 0xffffffff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVASliceParameterBufferH264(VASliceParameterBufferH264 *p)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
memset(p, 0, sizeof(VASliceParameterBufferH264));
|
|
||||||
p->slice_data_size = 0;
|
|
||||||
p->slice_data_bit_offset = 64;
|
|
||||||
p->slice_alpha_c0_offset_div2 = 2;
|
|
||||||
p->slice_beta_offset_div2 = 2;
|
|
||||||
p->chroma_weight_l0_flag = 1;
|
|
||||||
p->chroma_weight_l0[0][0]=1;
|
|
||||||
p->chroma_offset_l0[0][0]=0;
|
|
||||||
p->chroma_weight_l0[0][1]=1;
|
|
||||||
p->chroma_offset_l0[0][1]=0;
|
|
||||||
p->luma_weight_l1_flag = 1;
|
|
||||||
p->chroma_weight_l1_flag = 1;
|
|
||||||
p->luma_weight_l0[0]=0x01;
|
|
||||||
for (i = 0; i < 32; i++) {
|
|
||||||
p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID;
|
|
||||||
p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID;
|
|
||||||
}
|
|
||||||
p->RefPicList1[0].picture_id = 0xffffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetVASliceParameterBufferH264_Intra(VASliceParameterBufferH264 *p, int first)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
memset(p, 0, sizeof(VASliceParameterBufferH264));
|
|
||||||
p->slice_data_size = 0;
|
|
||||||
p->slice_data_bit_offset = 64;
|
|
||||||
p->slice_alpha_c0_offset_div2 = 2;
|
|
||||||
p->slice_beta_offset_div2 = 2;
|
|
||||||
p->slice_type = 2;
|
|
||||||
if (first) {
|
|
||||||
p->luma_weight_l0_flag = 1;
|
|
||||||
p->chroma_weight_l0_flag = 1;
|
|
||||||
p->luma_weight_l1_flag = 1;
|
|
||||||
p->chroma_weight_l1_flag = 1;
|
|
||||||
} else {
|
|
||||||
p->chroma_weight_l0_flag = 1;
|
|
||||||
p->chroma_weight_l0[0][0]=1;
|
|
||||||
p->chroma_offset_l0[0][0]=0;
|
|
||||||
p->chroma_weight_l0[0][1]=1;
|
|
||||||
p->chroma_offset_l0[0][1]=0;
|
|
||||||
p->luma_weight_l1_flag = 1;
|
|
||||||
p->chroma_weight_l1_flag = 1;
|
|
||||||
p->luma_weight_l0[0]=0x01;
|
|
||||||
}
|
|
||||||
for (i = 0; i < 32; i++) {
|
|
||||||
p->RefPicList0[i].flags = VA_PICTURE_H264_INVALID;
|
|
||||||
p->RefPicList1[i].flags = VA_PICTURE_H264_INVALID;
|
|
||||||
}
|
|
||||||
p->RefPicList1[0].picture_id = 0xffffffff;
|
|
||||||
p->RefPicList0[0].picture_id = 0xffffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void nv12_to_rgba(const VAImage vaImage, rfbClient *client, int ch_x, int ch_y, int ch_w, int ch_h)
|
|
||||||
{
|
|
||||||
DebugLog(("%s: converting region (%d, %d)-(%d, %d) from NV12->RGBA\n", __FUNCTION__, ch_x, ch_y, ch_w, ch_h));
|
|
||||||
|
|
||||||
VAStatus va_status;
|
|
||||||
uint8_t *nv12_buf;
|
|
||||||
va_status = vaMapBuffer(va_dpy, vaImage.buf, (void **)&nv12_buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaMapBuffer(DecodedData)");
|
|
||||||
|
|
||||||
/* adjust x, y, width, height of the affected area so
|
|
||||||
* x, y, width and height are always even.
|
|
||||||
*/
|
|
||||||
if (ch_x % 2) { --ch_x; ++ch_w; }
|
|
||||||
if (ch_y % 2) { --ch_y; ++ch_h; }
|
|
||||||
if ((ch_x + ch_w) % 2) { ++ch_w; }
|
|
||||||
if ((ch_y + ch_h) % 2) { ++ch_h; }
|
|
||||||
|
|
||||||
/* point nv12_buf and dst to upper left corner of changed area */
|
|
||||||
uint8_t *nv12_y = &nv12_buf[vaImage.offsets[0] + vaImage.pitches[0] * ch_y + ch_x];
|
|
||||||
uint8_t *nv12_uv = &nv12_buf[vaImage.offsets[1] + vaImage.pitches[1] * (ch_y / 2) + ch_x];
|
|
||||||
uint32_t *dst = &((uint32_t*)client->frameBuffer)[client->width * ch_y + ch_x];
|
|
||||||
|
|
||||||
/* TODO: optimize R, G, B calculation. Possible ways to do this:
|
|
||||||
* - use lookup tables
|
|
||||||
* - convert from floating point to integer arithmetic
|
|
||||||
* - use MMX/SSE to vectorize calculations
|
|
||||||
* - use GPU (VA VPP, shader...)
|
|
||||||
*/
|
|
||||||
int src_x, src_y;
|
|
||||||
for (src_y = 0; src_y < ch_h; src_y += 2) {
|
|
||||||
for (src_x = 0; src_x < ch_w; src_x += 2) {
|
|
||||||
uint8_t nv_u = nv12_uv[src_x];
|
|
||||||
uint8_t nv_v = nv12_uv[src_x + 1];
|
|
||||||
uint8_t nv_y[4] = { nv12_y[ src_x], nv12_y[ src_x + 1],
|
|
||||||
nv12_y[vaImage.pitches[0] + src_x], nv12_y[vaImage.pitches[0] + src_x + 1] };
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 4; ++i) {
|
|
||||||
double R = 1.164 * (nv_y[i] - 16) + 1.596 * (nv_v - 128);
|
|
||||||
double G = 1.164 * (nv_y[i] - 16) - 0.391 * (nv_u - 128) - 0.813 * (nv_v - 128);
|
|
||||||
double B = 1.164 * (nv_y[i] - 16) + 2.018 * (nv_u - 128);
|
|
||||||
|
|
||||||
/* clamp R, G, B values. For some Y, U, V combinations,
|
|
||||||
* the results of the above calculations fall outside of
|
|
||||||
* the range 0-255.
|
|
||||||
*/
|
|
||||||
if (R < 0.0) R = 0.0;
|
|
||||||
if (G < 0.0) G = 0.0;
|
|
||||||
if (B < 0.0) B = 0.0;
|
|
||||||
if (R > 255.0) R = 255.0;
|
|
||||||
if (G > 255.0) G = 255.0;
|
|
||||||
if (B > 255.0) B = 255.0;
|
|
||||||
|
|
||||||
dst[client->width * (i / 2) + src_x + (i % 2)] = 0
|
|
||||||
| ((unsigned int)(R + 0.5) << client->format.redShift)
|
|
||||||
| ((unsigned int)(G + 0.5) << client->format.greenShift)
|
|
||||||
| ((unsigned int)(B + 0.5) << client->format.blueShift);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nv12_y += 2 * vaImage.pitches[0];
|
|
||||||
nv12_uv += vaImage.pitches[1];
|
|
||||||
dst += 2 * client->width;
|
|
||||||
}
|
|
||||||
|
|
||||||
CHECK_SURF(va_surface_id[sid]);
|
|
||||||
va_status = vaUnmapBuffer(va_dpy, vaImage.buf);
|
|
||||||
CHECK_VASTATUS(va_status, "vaUnmapBuffer(DecodedData)");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* LIBVNCSERVER_CONFIG_LIBVA */
|
|
@ -1,727 +0,0 @@
|
|||||||
# ===========================================================================
|
|
||||||
# http://www.gnu.org/software/autoconf-archive/ax_create_stdint_h.html
|
|
||||||
# ===========================================================================
|
|
||||||
#
|
|
||||||
# SYNOPSIS
|
|
||||||
#
|
|
||||||
# AX_CREATE_STDINT_H [( HEADER-TO-GENERATE [, HEDERS-TO-CHECK])]
|
|
||||||
#
|
|
||||||
# DESCRIPTION
|
|
||||||
#
|
|
||||||
# the "ISO C9X: 7.18 Integer types <stdint.h>" section requires the
|
|
||||||
# existence of an include file <stdint.h> that defines a set of typedefs,
|
|
||||||
# especially uint8_t,int32_t,uintptr_t. Many older installations will not
|
|
||||||
# provide this file, but some will have the very same definitions in
|
|
||||||
# <inttypes.h>. In other enviroments we can use the inet-types in
|
|
||||||
# <sys/types.h> which would define the typedefs int8_t and u_int8_t
|
|
||||||
# respectivly.
|
|
||||||
#
|
|
||||||
# This macros will create a local "_stdint.h" or the headerfile given as
|
|
||||||
# an argument. In many cases that file will just "#include <stdint.h>" or
|
|
||||||
# "#include <inttypes.h>", while in other environments it will provide the
|
|
||||||
# set of basic 'stdint's definitions/typedefs:
|
|
||||||
#
|
|
||||||
# int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t
|
|
||||||
# int_least32_t.. int_fast32_t.. intmax_t
|
|
||||||
#
|
|
||||||
# which may or may not rely on the definitions of other files, or using
|
|
||||||
# the AC_CHECK_SIZEOF macro to determine the actual sizeof each type.
|
|
||||||
#
|
|
||||||
# if your header files require the stdint-types you will want to create an
|
|
||||||
# installable file mylib-int.h that all your other installable header may
|
|
||||||
# include. So if you have a library package named "mylib", just use
|
|
||||||
#
|
|
||||||
# AX_CREATE_STDINT_H(mylib-int.h)
|
|
||||||
#
|
|
||||||
# in configure.ac and go to install that very header file in Makefile.am
|
|
||||||
# along with the other headers (mylib.h) - and the mylib-specific headers
|
|
||||||
# can simply use "#include <mylib-int.h>" to obtain the stdint-types.
|
|
||||||
#
|
|
||||||
# Remember, if the system already had a valid <stdint.h>, the generated
|
|
||||||
# file will include it directly. No need for fuzzy HAVE_STDINT_H things...
|
|
||||||
# (oops, GCC 4.2.x has deliberatly disabled its stdint.h for non-c99
|
|
||||||
# compilation and the c99-mode is not the default. Therefore this macro
|
|
||||||
# will not use the compiler's stdint.h - please complain to the GCC
|
|
||||||
# developers).
|
|
||||||
#
|
|
||||||
# LICENSE
|
|
||||||
#
|
|
||||||
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify it
|
|
||||||
# under the terms of the GNU General Public License as published by the
|
|
||||||
# Free Software Foundation; either version 3 of the License, or (at your
|
|
||||||
# option) any later version.
|
|
||||||
#
|
|
||||||
# This program 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 General
|
|
||||||
# Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
# As a special exception, the respective Autoconf Macro's copyright owner
|
|
||||||
# gives unlimited permission to copy, distribute and modify the configure
|
|
||||||
# scripts that are the output of Autoconf when processing the Macro. You
|
|
||||||
# need not follow the terms of the GNU General Public License when using
|
|
||||||
# or distributing such scripts, even though portions of the text of the
|
|
||||||
# Macro appear in them. The GNU General Public License (GPL) does govern
|
|
||||||
# all other use of the material that constitutes the Autoconf Macro.
|
|
||||||
#
|
|
||||||
# This special exception to the GPL applies to versions of the Autoconf
|
|
||||||
# Macro released by the Autoconf Archive. When you make and distribute a
|
|
||||||
# modified version of the Autoconf Macro, you may extend this special
|
|
||||||
# exception to the GPL to apply to your modified version as well.
|
|
||||||
|
|
||||||
#serial 10
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CHECK_DATA_MODEL],[
|
|
||||||
AC_CHECK_SIZEOF(char)
|
|
||||||
AC_CHECK_SIZEOF(short)
|
|
||||||
AC_CHECK_SIZEOF(int)
|
|
||||||
AC_CHECK_SIZEOF(long)
|
|
||||||
AC_CHECK_SIZEOF(void*)
|
|
||||||
ac_cv_char_data_model=""
|
|
||||||
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_char"
|
|
||||||
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_short"
|
|
||||||
ac_cv_char_data_model="$ac_cv_char_data_model$ac_cv_sizeof_int"
|
|
||||||
ac_cv_long_data_model=""
|
|
||||||
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_int"
|
|
||||||
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_long"
|
|
||||||
ac_cv_long_data_model="$ac_cv_long_data_model$ac_cv_sizeof_voidp"
|
|
||||||
AC_MSG_CHECKING([data model])
|
|
||||||
case "$ac_cv_char_data_model/$ac_cv_long_data_model" in
|
|
||||||
122/242) ac_cv_data_model="IP16" ; n="standard 16bit machine" ;;
|
|
||||||
122/244) ac_cv_data_model="LP32" ; n="standard 32bit machine" ;;
|
|
||||||
122/*) ac_cv_data_model="i16" ; n="unusual int16 model" ;;
|
|
||||||
124/444) ac_cv_data_model="ILP32" ; n="standard 32bit unixish" ;;
|
|
||||||
124/488) ac_cv_data_model="LP64" ; n="standard 64bit unixish" ;;
|
|
||||||
124/448) ac_cv_data_model="LLP64" ; n="unusual 64bit unixish" ;;
|
|
||||||
124/*) ac_cv_data_model="i32" ; n="unusual int32 model" ;;
|
|
||||||
128/888) ac_cv_data_model="ILP64" ; n="unusual 64bit numeric" ;;
|
|
||||||
128/*) ac_cv_data_model="i64" ; n="unusual int64 model" ;;
|
|
||||||
222/*2) ac_cv_data_model="DSP16" ; n="strict 16bit dsptype" ;;
|
|
||||||
333/*3) ac_cv_data_model="DSP24" ; n="strict 24bit dsptype" ;;
|
|
||||||
444/*4) ac_cv_data_model="DSP32" ; n="strict 32bit dsptype" ;;
|
|
||||||
666/*6) ac_cv_data_model="DSP48" ; n="strict 48bit dsptype" ;;
|
|
||||||
888/*8) ac_cv_data_model="DSP64" ; n="strict 64bit dsptype" ;;
|
|
||||||
222/*|333/*|444/*|666/*|888/*) :
|
|
||||||
ac_cv_data_model="iDSP" ; n="unusual dsptype" ;;
|
|
||||||
*) ac_cv_data_model="none" ; n="very unusual model" ;;
|
|
||||||
esac
|
|
||||||
AC_MSG_RESULT([$ac_cv_data_model ($ac_cv_long_data_model, $n)])
|
|
||||||
])
|
|
||||||
|
|
||||||
dnl AX_CHECK_HEADER_STDINT_X([HEADERLIST][,ACTION-IF])
|
|
||||||
AC_DEFUN([AX_CHECK_HEADER_STDINT_X],[
|
|
||||||
AC_CACHE_CHECK([for stdint uintptr_t], [ac_cv_header_stdint_x],[
|
|
||||||
ac_cv_header_stdint_x="" # the 1997 typedefs (inttypes.h)
|
|
||||||
AC_MSG_RESULT([(..)])
|
|
||||||
for i in m4_ifval([$1],[$1],[stdint.h inttypes.h sys/inttypes.h sys/types.h])
|
|
||||||
do
|
|
||||||
unset ac_cv_type_uintptr_t
|
|
||||||
unset ac_cv_type_uint64_t
|
|
||||||
AC_CHECK_TYPE(uintptr_t,[ac_cv_header_stdint_x=$i],continue,[#include <$i>])
|
|
||||||
AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
|
|
||||||
m4_ifvaln([$2],[$2]) break
|
|
||||||
done
|
|
||||||
AC_MSG_CHECKING([for stdint uintptr_t])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CHECK_HEADER_STDINT_O],[
|
|
||||||
AC_CACHE_CHECK([for stdint uint32_t], [ac_cv_header_stdint_o],[
|
|
||||||
ac_cv_header_stdint_o="" # the 1995 typedefs (sys/inttypes.h)
|
|
||||||
AC_MSG_RESULT([(..)])
|
|
||||||
for i in m4_ifval([$1],[$1],[inttypes.h sys/inttypes.h sys/types.h stdint.h])
|
|
||||||
do
|
|
||||||
unset ac_cv_type_uint32_t
|
|
||||||
unset ac_cv_type_uint64_t
|
|
||||||
AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],continue,[#include <$i>])
|
|
||||||
AC_CHECK_TYPE(uint64_t,[and64="/uint64_t"],[and64=""],[#include<$i>])
|
|
||||||
m4_ifvaln([$2],[$2]) break
|
|
||||||
break;
|
|
||||||
done
|
|
||||||
AC_MSG_CHECKING([for stdint uint32_t])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CHECK_HEADER_STDINT_U],[
|
|
||||||
AC_CACHE_CHECK([for stdint u_int32_t], [ac_cv_header_stdint_u],[
|
|
||||||
ac_cv_header_stdint_u="" # the BSD typedefs (sys/types.h)
|
|
||||||
AC_MSG_RESULT([(..)])
|
|
||||||
for i in m4_ifval([$1],[$1],[sys/types.h inttypes.h sys/inttypes.h]) ; do
|
|
||||||
unset ac_cv_type_u_int32_t
|
|
||||||
unset ac_cv_type_u_int64_t
|
|
||||||
AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],continue,[#include <$i>])
|
|
||||||
AC_CHECK_TYPE(u_int64_t,[and64="/u_int64_t"],[and64=""],[#include<$i>])
|
|
||||||
m4_ifvaln([$2],[$2]) break
|
|
||||||
break;
|
|
||||||
done
|
|
||||||
AC_MSG_CHECKING([for stdint u_int32_t])
|
|
||||||
])
|
|
||||||
])
|
|
||||||
|
|
||||||
AC_DEFUN([AX_CREATE_STDINT_H],
|
|
||||||
[# ------ AX CREATE STDINT H -------------------------------------
|
|
||||||
AC_MSG_CHECKING([for stdint types])
|
|
||||||
ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
|
|
||||||
# try to shortcircuit - if the default include path of the compiler
|
|
||||||
# can find a "stdint.h" header then we assume that all compilers can.
|
|
||||||
AC_CACHE_VAL([ac_cv_header_stdint_t],[
|
|
||||||
old_CXXFLAGS="$CXXFLAGS" ; CXXFLAGS=""
|
|
||||||
old_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS=""
|
|
||||||
old_CFLAGS="$CFLAGS" ; CFLAGS=""
|
|
||||||
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
|
|
||||||
[ac_cv_stdint_result="(assuming C99 compatible system)"
|
|
||||||
ac_cv_header_stdint_t="stdint.h"; ],
|
|
||||||
[ac_cv_header_stdint_t=""])
|
|
||||||
if test "$GCC" = "yes" && test ".$ac_cv_header_stdint_t" = "."; then
|
|
||||||
CFLAGS="-std=c99"
|
|
||||||
AC_TRY_COMPILE([#include <stdint.h>],[int_least32_t v = 0;],
|
|
||||||
[AC_MSG_WARN(your GCC compiler has a defunct stdint.h for its default-mode)])
|
|
||||||
fi
|
|
||||||
CXXFLAGS="$old_CXXFLAGS"
|
|
||||||
CPPFLAGS="$old_CPPFLAGS"
|
|
||||||
CFLAGS="$old_CFLAGS" ])
|
|
||||||
|
|
||||||
v="... $ac_cv_header_stdint_h"
|
|
||||||
if test "$ac_stdint_h" = "stdint.h" ; then
|
|
||||||
AC_MSG_RESULT([(are you sure you want them in ./stdint.h?)])
|
|
||||||
elif test "$ac_stdint_h" = "inttypes.h" ; then
|
|
||||||
AC_MSG_RESULT([(are you sure you want them in ./inttypes.h?)])
|
|
||||||
elif test "_$ac_cv_header_stdint_t" = "_" ; then
|
|
||||||
AC_MSG_RESULT([(putting them into $ac_stdint_h)$v])
|
|
||||||
else
|
|
||||||
ac_cv_header_stdint="$ac_cv_header_stdint_t"
|
|
||||||
AC_MSG_RESULT([$ac_cv_header_stdint (shortcircuit)])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "_$ac_cv_header_stdint_t" = "_" ; then # cannot shortcircuit..
|
|
||||||
|
|
||||||
dnl .....intro message done, now do a few system checks.....
|
|
||||||
dnl btw, all old CHECK_TYPE macros do automatically "DEFINE" a type,
|
|
||||||
dnl therefore we use the autoconf implementation detail CHECK_TYPE_NEW
|
|
||||||
dnl instead that is triggered with 3 or more arguments (see types.m4)
|
|
||||||
|
|
||||||
inttype_headers=`echo $2 | sed -e 's/,/ /g'`
|
|
||||||
|
|
||||||
ac_cv_stdint_result="(no helpful system typedefs seen)"
|
|
||||||
AX_CHECK_HEADER_STDINT_X(dnl
|
|
||||||
stdint.h inttypes.h sys/inttypes.h $inttype_headers,
|
|
||||||
ac_cv_stdint_result="(seen uintptr_t$and64 in $i)")
|
|
||||||
|
|
||||||
if test "_$ac_cv_header_stdint_x" = "_" ; then
|
|
||||||
AX_CHECK_HEADER_STDINT_O(dnl,
|
|
||||||
inttypes.h sys/inttypes.h stdint.h $inttype_headers,
|
|
||||||
ac_cv_stdint_result="(seen uint32_t$and64 in $i)")
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "_$ac_cv_header_stdint_x" = "_" ; then
|
|
||||||
if test "_$ac_cv_header_stdint_o" = "_" ; then
|
|
||||||
AX_CHECK_HEADER_STDINT_U(dnl,
|
|
||||||
sys/types.h inttypes.h sys/inttypes.h $inttype_headers,
|
|
||||||
ac_cv_stdint_result="(seen u_int32_t$and64 in $i)")
|
|
||||||
fi fi
|
|
||||||
|
|
||||||
dnl if there was no good C99 header file, do some typedef checks...
|
|
||||||
if test "_$ac_cv_header_stdint_x" = "_" ; then
|
|
||||||
AC_MSG_CHECKING([for stdint datatype model])
|
|
||||||
AC_MSG_RESULT([(..)])
|
|
||||||
AX_CHECK_DATA_MODEL
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "_$ac_cv_header_stdint_x" != "_" ; then
|
|
||||||
ac_cv_header_stdint="$ac_cv_header_stdint_x"
|
|
||||||
elif test "_$ac_cv_header_stdint_o" != "_" ; then
|
|
||||||
ac_cv_header_stdint="$ac_cv_header_stdint_o"
|
|
||||||
elif test "_$ac_cv_header_stdint_u" != "_" ; then
|
|
||||||
ac_cv_header_stdint="$ac_cv_header_stdint_u"
|
|
||||||
else
|
|
||||||
ac_cv_header_stdint="stddef.h"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for extra inttypes in chosen header])
|
|
||||||
AC_MSG_RESULT([($ac_cv_header_stdint)])
|
|
||||||
dnl see if int_least and int_fast types are present in _this_ header.
|
|
||||||
unset ac_cv_type_int_least32_t
|
|
||||||
unset ac_cv_type_int_fast32_t
|
|
||||||
AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
|
|
||||||
AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
|
|
||||||
AC_CHECK_TYPE(intmax_t,,,[#include <$ac_cv_header_stdint>])
|
|
||||||
|
|
||||||
fi # shortcircut to system "stdint.h"
|
|
||||||
# ------------------ PREPARE VARIABLES ------------------------------
|
|
||||||
if test "$GCC" = "yes" ; then
|
|
||||||
ac_cv_stdint_message="using gnu compiler "`$CC --version | head -1`
|
|
||||||
else
|
|
||||||
ac_cv_stdint_message="using $CC"
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_MSG_RESULT([make use of $ac_cv_header_stdint in $ac_stdint_h dnl
|
|
||||||
$ac_cv_stdint_result])
|
|
||||||
|
|
||||||
dnl -----------------------------------------------------------------
|
|
||||||
# ----------------- DONE inttypes.h checks START header -------------
|
|
||||||
AC_CONFIG_COMMANDS([$ac_stdint_h],[
|
|
||||||
AC_MSG_NOTICE(creating $ac_stdint_h : $_ac_stdint_h)
|
|
||||||
ac_stdint=$tmp/_stdint.h
|
|
||||||
|
|
||||||
echo "#ifndef" $_ac_stdint_h >$ac_stdint
|
|
||||||
echo "#define" $_ac_stdint_h "1" >>$ac_stdint
|
|
||||||
echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint
|
|
||||||
echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint
|
|
||||||
echo "/* generated $ac_cv_stdint_message */" >>$ac_stdint
|
|
||||||
if test "_$ac_cv_header_stdint_t" != "_" ; then
|
|
||||||
echo "#define _STDINT_HAVE_STDINT_H" "1" >>$ac_stdint
|
|
||||||
echo "#include <stdint.h>" >>$ac_stdint
|
|
||||||
echo "#endif" >>$ac_stdint
|
|
||||||
echo "#endif" >>$ac_stdint
|
|
||||||
else
|
|
||||||
|
|
||||||
cat >>$ac_stdint <<STDINT_EOF
|
|
||||||
|
|
||||||
/* ................... shortcircuit part ........................... */
|
|
||||||
|
|
||||||
#if defined HAVE_STDINT_H || defined _STDINT_HAVE_STDINT_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#else
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
/* .................... configured part ............................ */
|
|
||||||
|
|
||||||
STDINT_EOF
|
|
||||||
|
|
||||||
echo "/* whether we have a C99 compatible stdint header file */" >>$ac_stdint
|
|
||||||
if test "_$ac_cv_header_stdint_x" != "_" ; then
|
|
||||||
ac_header="$ac_cv_header_stdint_x"
|
|
||||||
echo "#define _STDINT_HEADER_INTPTR" '"'"$ac_header"'"' >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HEADER_INTPTR */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "/* whether we have a C96 compatible inttypes header file */" >>$ac_stdint
|
|
||||||
if test "_$ac_cv_header_stdint_o" != "_" ; then
|
|
||||||
ac_header="$ac_cv_header_stdint_o"
|
|
||||||
echo "#define _STDINT_HEADER_UINT32" '"'"$ac_header"'"' >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HEADER_UINT32 */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "/* whether we have a BSD compatible inet types header */" >>$ac_stdint
|
|
||||||
if test "_$ac_cv_header_stdint_u" != "_" ; then
|
|
||||||
ac_header="$ac_cv_header_stdint_u"
|
|
||||||
echo "#define _STDINT_HEADER_U_INT32" '"'"$ac_header"'"' >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HEADER_U_INT32 */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "" >>$ac_stdint
|
|
||||||
|
|
||||||
if test "_$ac_header" != "_" ; then if test "$ac_header" != "stddef.h" ; then
|
|
||||||
echo "#include <$ac_header>" >>$ac_stdint
|
|
||||||
echo "" >>$ac_stdint
|
|
||||||
fi fi
|
|
||||||
|
|
||||||
echo "/* which 64bit typedef has been found */" >>$ac_stdint
|
|
||||||
if test "$ac_cv_type_uint64_t" = "yes" ; then
|
|
||||||
echo "#define _STDINT_HAVE_UINT64_T" "1" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HAVE_UINT64_T */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
if test "$ac_cv_type_u_int64_t" = "yes" ; then
|
|
||||||
echo "#define _STDINT_HAVE_U_INT64_T" "1" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HAVE_U_INT64_T */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
echo "" >>$ac_stdint
|
|
||||||
|
|
||||||
echo "/* which type model has been detected */" >>$ac_stdint
|
|
||||||
if test "_$ac_cv_char_data_model" != "_" ; then
|
|
||||||
echo "#define _STDINT_CHAR_MODEL" "$ac_cv_char_data_model" >>$ac_stdint
|
|
||||||
echo "#define _STDINT_LONG_MODEL" "$ac_cv_long_data_model" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_CHAR_MODEL // skipped */" >>$ac_stdint
|
|
||||||
echo "/* #undef _STDINT_LONG_MODEL // skipped */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
echo "" >>$ac_stdint
|
|
||||||
|
|
||||||
echo "/* whether int_least types were detected */" >>$ac_stdint
|
|
||||||
if test "$ac_cv_type_int_least32_t" = "yes"; then
|
|
||||||
echo "#define _STDINT_HAVE_INT_LEAST32_T" "1" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HAVE_INT_LEAST32_T */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
echo "/* whether int_fast types were detected */" >>$ac_stdint
|
|
||||||
if test "$ac_cv_type_int_fast32_t" = "yes"; then
|
|
||||||
echo "#define _STDINT_HAVE_INT_FAST32_T" "1" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HAVE_INT_FAST32_T */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
echo "/* whether intmax_t type was detected */" >>$ac_stdint
|
|
||||||
if test "$ac_cv_type_intmax_t" = "yes"; then
|
|
||||||
echo "#define _STDINT_HAVE_INTMAX_T" "1" >>$ac_stdint
|
|
||||||
else
|
|
||||||
echo "/* #undef _STDINT_HAVE_INTMAX_T */" >>$ac_stdint
|
|
||||||
fi
|
|
||||||
echo "" >>$ac_stdint
|
|
||||||
|
|
||||||
cat >>$ac_stdint <<STDINT_EOF
|
|
||||||
/* .................... detections part ............................ */
|
|
||||||
|
|
||||||
/* whether we need to define bitspecific types from compiler base types */
|
|
||||||
#ifndef _STDINT_HEADER_INTPTR
|
|
||||||
#ifndef _STDINT_HEADER_UINT32
|
|
||||||
#ifndef _STDINT_HEADER_U_INT32
|
|
||||||
#define _STDINT_NEED_INT_MODEL_T
|
|
||||||
#else
|
|
||||||
#define _STDINT_HAVE_U_INT_TYPES
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _STDINT_HAVE_U_INT_TYPES
|
|
||||||
#undef _STDINT_NEED_INT_MODEL_T
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _STDINT_CHAR_MODEL
|
|
||||||
#if _STDINT_CHAR_MODEL+0 == 122 || _STDINT_CHAR_MODEL+0 == 124
|
|
||||||
#ifndef _STDINT_BYTE_MODEL
|
|
||||||
#define _STDINT_BYTE_MODEL 12
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STDINT_HAVE_INT_LEAST32_T
|
|
||||||
#define _STDINT_NEED_INT_LEAST_T
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STDINT_HAVE_INT_FAST32_T
|
|
||||||
#define _STDINT_NEED_INT_FAST_T
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STDINT_HEADER_INTPTR
|
|
||||||
#define _STDINT_NEED_INTPTR_T
|
|
||||||
#ifndef _STDINT_HAVE_INTMAX_T
|
|
||||||
#define _STDINT_NEED_INTMAX_T
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* .................... definition part ............................ */
|
|
||||||
|
|
||||||
/* some system headers have good uint64_t */
|
|
||||||
#ifndef _HAVE_UINT64_T
|
|
||||||
#if defined _STDINT_HAVE_UINT64_T || defined HAVE_UINT64_T
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
#elif defined _STDINT_HAVE_U_INT64_T || defined HAVE_U_INT64_T
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
typedef u_int64_t uint64_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _HAVE_UINT64_T
|
|
||||||
/* .. here are some common heuristics using compiler runtime specifics */
|
|
||||||
#if defined __STDC_VERSION__ && defined __STDC_VERSION__ >= 199901L
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
#define _HAVE_LONGLONG_UINT64_T
|
|
||||||
typedef long long int64_t;
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
|
|
||||||
#elif !defined __STRICT_ANSI__
|
|
||||||
#if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
typedef __int64 int64_t;
|
|
||||||
typedef unsigned __int64 uint64_t;
|
|
||||||
|
|
||||||
#elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
|
|
||||||
/* note: all ELF-systems seem to have loff-support which needs 64-bit */
|
|
||||||
#if !defined _NO_LONGLONG
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
#define _HAVE_LONGLONG_UINT64_T
|
|
||||||
typedef long long int64_t;
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined __alpha || (defined __mips && defined _ABIN32)
|
|
||||||
#if !defined _NO_LONGLONG
|
|
||||||
typedef long int64_t;
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
#endif
|
|
||||||
/* compiler/cpu type to define int64_t */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _STDINT_HAVE_U_INT_TYPES
|
|
||||||
/* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
|
|
||||||
typedef u_int8_t uint8_t;
|
|
||||||
typedef u_int16_t uint16_t;
|
|
||||||
typedef u_int32_t uint32_t;
|
|
||||||
|
|
||||||
/* glibc compatibility */
|
|
||||||
#ifndef __int8_t_defined
|
|
||||||
#define __int8_t_defined
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _STDINT_NEED_INT_MODEL_T
|
|
||||||
/* we must guess all the basic types. Apart from byte-adressable system, */
|
|
||||||
/* there a few 32-bit-only dsp-systems that we guard with BYTE_MODEL 8-} */
|
|
||||||
/* (btw, those nibble-addressable systems are way off, or so we assume) */
|
|
||||||
|
|
||||||
dnl /* have a look at "64bit and data size neutrality" at */
|
|
||||||
dnl /* http://unix.org/version2/whatsnew/login_64bit.html */
|
|
||||||
dnl /* (the shorthand "ILP" types always have a "P" part) */
|
|
||||||
|
|
||||||
#if defined _STDINT_BYTE_MODEL
|
|
||||||
#if _STDINT_LONG_MODEL+0 == 242
|
|
||||||
/* 2:4:2 = IP16 = a normal 16-bit system */
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned long uint32_t;
|
|
||||||
#ifndef __int8_t_defined
|
|
||||||
#define __int8_t_defined
|
|
||||||
typedef char int8_t;
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef long int32_t;
|
|
||||||
#endif
|
|
||||||
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL == 444
|
|
||||||
/* 2:4:4 = LP32 = a 32-bit system derived from a 16-bit */
|
|
||||||
/* 4:4:4 = ILP32 = a normal 32-bit system */
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
#ifndef __int8_t_defined
|
|
||||||
#define __int8_t_defined
|
|
||||||
typedef char int8_t;
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef int int32_t;
|
|
||||||
#endif
|
|
||||||
#elif _STDINT_LONG_MODEL+0 == 484 || _STDINT_LONG_MODEL+0 == 488
|
|
||||||
/* 4:8:4 = IP32 = a 32-bit system prepared for 64-bit */
|
|
||||||
/* 4:8:8 = LP64 = a normal 64-bit system */
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
#ifndef __int8_t_defined
|
|
||||||
#define __int8_t_defined
|
|
||||||
typedef char int8_t;
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef int int32_t;
|
|
||||||
#endif
|
|
||||||
/* this system has a "long" of 64bit */
|
|
||||||
#ifndef _HAVE_UINT64_T
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
typedef unsigned long uint64_t;
|
|
||||||
typedef long int64_t;
|
|
||||||
#endif
|
|
||||||
#elif _STDINT_LONG_MODEL+0 == 448
|
|
||||||
/* LLP64 a 64-bit system derived from a 32-bit system */
|
|
||||||
typedef unsigned char uint8_t;
|
|
||||||
typedef unsigned short uint16_t;
|
|
||||||
typedef unsigned int uint32_t;
|
|
||||||
#ifndef __int8_t_defined
|
|
||||||
#define __int8_t_defined
|
|
||||||
typedef char int8_t;
|
|
||||||
typedef short int16_t;
|
|
||||||
typedef int int32_t;
|
|
||||||
#endif
|
|
||||||
/* assuming the system has a "long long" */
|
|
||||||
#ifndef _HAVE_UINT64_T
|
|
||||||
#define _HAVE_UINT64_T
|
|
||||||
#define _HAVE_LONGLONG_UINT64_T
|
|
||||||
typedef unsigned long long uint64_t;
|
|
||||||
typedef long long int64_t;
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define _STDINT_NO_INT32_T
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define _STDINT_NO_INT8_T
|
|
||||||
#define _STDINT_NO_INT32_T
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* quote from SunOS-5.8 sys/inttypes.h:
|
|
||||||
* Use at your own risk. As of February 1996, the committee is squarely
|
|
||||||
* behind the fixed sized types; the "least" and "fast" types are still being
|
|
||||||
* discussed. The probability that the "fast" types may be removed before
|
|
||||||
* the standard is finalized is high enough that they are not currently
|
|
||||||
* implemented.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined _STDINT_NEED_INT_LEAST_T
|
|
||||||
typedef int8_t int_least8_t;
|
|
||||||
typedef int16_t int_least16_t;
|
|
||||||
typedef int32_t int_least32_t;
|
|
||||||
#ifdef _HAVE_UINT64_T
|
|
||||||
typedef int64_t int_least64_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef uint8_t uint_least8_t;
|
|
||||||
typedef uint16_t uint_least16_t;
|
|
||||||
typedef uint32_t uint_least32_t;
|
|
||||||
#ifdef _HAVE_UINT64_T
|
|
||||||
typedef uint64_t uint_least64_t;
|
|
||||||
#endif
|
|
||||||
/* least types */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined _STDINT_NEED_INT_FAST_T
|
|
||||||
typedef int8_t int_fast8_t;
|
|
||||||
typedef int int_fast16_t;
|
|
||||||
typedef int32_t int_fast32_t;
|
|
||||||
#ifdef _HAVE_UINT64_T
|
|
||||||
typedef int64_t int_fast64_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef uint8_t uint_fast8_t;
|
|
||||||
typedef unsigned uint_fast16_t;
|
|
||||||
typedef uint32_t uint_fast32_t;
|
|
||||||
#ifdef _HAVE_UINT64_T
|
|
||||||
typedef uint64_t uint_fast64_t;
|
|
||||||
#endif
|
|
||||||
/* fast types */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _STDINT_NEED_INTMAX_T
|
|
||||||
#ifdef _HAVE_UINT64_T
|
|
||||||
typedef int64_t intmax_t;
|
|
||||||
typedef uint64_t uintmax_t;
|
|
||||||
#else
|
|
||||||
typedef long intmax_t;
|
|
||||||
typedef unsigned long uintmax_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _STDINT_NEED_INTPTR_T
|
|
||||||
#ifndef __intptr_t_defined
|
|
||||||
#define __intptr_t_defined
|
|
||||||
/* we encourage using "long" to store pointer values, never use "int" ! */
|
|
||||||
#if _STDINT_LONG_MODEL+0 == 242 || _STDINT_LONG_MODEL+0 == 484
|
|
||||||
typedef unsigned int uintptr_t;
|
|
||||||
typedef int intptr_t;
|
|
||||||
#elif _STDINT_LONG_MODEL+0 == 244 || _STDINT_LONG_MODEL+0 == 444
|
|
||||||
typedef unsigned long uintptr_t;
|
|
||||||
typedef long intptr_t;
|
|
||||||
#elif _STDINT_LONG_MODEL+0 == 448 && defined _HAVE_UINT64_T
|
|
||||||
typedef uint64_t uintptr_t;
|
|
||||||
typedef int64_t intptr_t;
|
|
||||||
#else /* matches typical system types ILP32 and LP64 - but not IP16 or LLP64 */
|
|
||||||
typedef unsigned long uintptr_t;
|
|
||||||
typedef long intptr_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The ISO C99 standard specifies that in C++ implementations these
|
|
||||||
should only be defined if explicitly requested. */
|
|
||||||
#if !defined __cplusplus || defined __STDC_CONSTANT_MACROS
|
|
||||||
#ifndef UINT32_C
|
|
||||||
|
|
||||||
/* Signed. */
|
|
||||||
# define INT8_C(c) c
|
|
||||||
# define INT16_C(c) c
|
|
||||||
# define INT32_C(c) c
|
|
||||||
# ifdef _HAVE_LONGLONG_UINT64_T
|
|
||||||
# define INT64_C(c) c ## L
|
|
||||||
# else
|
|
||||||
# define INT64_C(c) c ## LL
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Unsigned. */
|
|
||||||
# define UINT8_C(c) c ## U
|
|
||||||
# define UINT16_C(c) c ## U
|
|
||||||
# define UINT32_C(c) c ## U
|
|
||||||
# ifdef _HAVE_LONGLONG_UINT64_T
|
|
||||||
# define UINT64_C(c) c ## UL
|
|
||||||
# else
|
|
||||||
# define UINT64_C(c) c ## ULL
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Maximal type. */
|
|
||||||
# ifdef _HAVE_LONGLONG_UINT64_T
|
|
||||||
# define INTMAX_C(c) c ## L
|
|
||||||
# define UINTMAX_C(c) c ## UL
|
|
||||||
# else
|
|
||||||
# define INTMAX_C(c) c ## LL
|
|
||||||
# define UINTMAX_C(c) c ## ULL
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* literalnumbers */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* These limits are merily those of a two complement byte-oriented system */
|
|
||||||
|
|
||||||
/* Minimum of signed integral types. */
|
|
||||||
# define INT8_MIN (-128)
|
|
||||||
# define INT16_MIN (-32767-1)
|
|
||||||
# define INT32_MIN (-2147483647-1)
|
|
||||||
# define INT64_MIN (-__INT64_C(9223372036854775807)-1)
|
|
||||||
/* Maximum of signed integral types. */
|
|
||||||
# define INT8_MAX (127)
|
|
||||||
# define INT16_MAX (32767)
|
|
||||||
# define INT32_MAX (2147483647)
|
|
||||||
# define INT64_MAX (__INT64_C(9223372036854775807))
|
|
||||||
|
|
||||||
/* Maximum of unsigned integral types. */
|
|
||||||
# define UINT8_MAX (255)
|
|
||||||
# define UINT16_MAX (65535)
|
|
||||||
# define UINT32_MAX (4294967295U)
|
|
||||||
# define UINT64_MAX (__UINT64_C(18446744073709551615))
|
|
||||||
|
|
||||||
/* Minimum of signed integral types having a minimum size. */
|
|
||||||
# define INT_LEAST8_MIN INT8_MIN
|
|
||||||
# define INT_LEAST16_MIN INT16_MIN
|
|
||||||
# define INT_LEAST32_MIN INT32_MIN
|
|
||||||
# define INT_LEAST64_MIN INT64_MIN
|
|
||||||
/* Maximum of signed integral types having a minimum size. */
|
|
||||||
# define INT_LEAST8_MAX INT8_MAX
|
|
||||||
# define INT_LEAST16_MAX INT16_MAX
|
|
||||||
# define INT_LEAST32_MAX INT32_MAX
|
|
||||||
# define INT_LEAST64_MAX INT64_MAX
|
|
||||||
|
|
||||||
/* Maximum of unsigned integral types having a minimum size. */
|
|
||||||
# define UINT_LEAST8_MAX UINT8_MAX
|
|
||||||
# define UINT_LEAST16_MAX UINT16_MAX
|
|
||||||
# define UINT_LEAST32_MAX UINT32_MAX
|
|
||||||
# define UINT_LEAST64_MAX UINT64_MAX
|
|
||||||
|
|
||||||
/* shortcircuit*/
|
|
||||||
#endif
|
|
||||||
/* once */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
STDINT_EOF
|
|
||||||
fi
|
|
||||||
if cmp -s $ac_stdint_h $ac_stdint 2>/dev/null; then
|
|
||||||
AC_MSG_NOTICE([$ac_stdint_h is unchanged])
|
|
||||||
else
|
|
||||||
ac_dir=`AS_DIRNAME(["$ac_stdint_h"])`
|
|
||||||
AS_MKDIR_P(["$ac_dir"])
|
|
||||||
rm -f $ac_stdint_h
|
|
||||||
mv $ac_stdint $ac_stdint_h
|
|
||||||
fi
|
|
||||||
],[# variables for create stdint.h replacement
|
|
||||||
PACKAGE="$PACKAGE"
|
|
||||||
VERSION="$VERSION"
|
|
||||||
ac_stdint_h="$ac_stdint_h"
|
|
||||||
_ac_stdint_h=AS_TR_CPP(_$PACKAGE-$ac_stdint_h)
|
|
||||||
ac_cv_stdint_message="$ac_cv_stdint_message"
|
|
||||||
ac_cv_header_stdint_t="$ac_cv_header_stdint_t"
|
|
||||||
ac_cv_header_stdint_x="$ac_cv_header_stdint_x"
|
|
||||||
ac_cv_header_stdint_o="$ac_cv_header_stdint_o"
|
|
||||||
ac_cv_header_stdint_u="$ac_cv_header_stdint_u"
|
|
||||||
ac_cv_type_uint64_t="$ac_cv_type_uint64_t"
|
|
||||||
ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t"
|
|
||||||
ac_cv_char_data_model="$ac_cv_char_data_model"
|
|
||||||
ac_cv_long_data_model="$ac_cv_long_data_model"
|
|
||||||
ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t"
|
|
||||||
ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t"
|
|
||||||
ac_cv_type_intmax_t="$ac_cv_type_intmax_t"
|
|
||||||
])
|
|
||||||
])
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* noVNC: HTML5 VNC client
|
|
||||||
* Copyright (C) 2012 Joel Martin
|
|
||||||
* Licensed under LGPL-3 (see LICENSE.txt)
|
|
||||||
*
|
|
||||||
* See README.md for usage and integration instructions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*jslint evil: true */
|
|
||||||
/*global window, document, INCLUDE_URI */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load supporting scripts
|
|
||||||
*/
|
|
||||||
function get_INCLUDE_URI() {
|
|
||||||
return (typeof INCLUDE_URI !== "undefined") ? INCLUDE_URI : "include/";
|
|
||||||
}
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var extra = "", start, end;
|
|
||||||
|
|
||||||
start = "<script src='" + get_INCLUDE_URI();
|
|
||||||
end = "'><\/script>";
|
|
||||||
|
|
||||||
// Uncomment to activate firebug lite
|
|
||||||
//extra += "<script src='http://getfirebug.com/releases/lite/1.2/" +
|
|
||||||
// "firebug-lite-compressed.js'><\/script>";
|
|
||||||
|
|
||||||
extra += start + "util.js" + end;
|
|
||||||
extra += start + "webutil.js" + end;
|
|
||||||
extra += start + "base64.js" + end;
|
|
||||||
extra += start + "websock.js" + end;
|
|
||||||
extra += start + "des.js" + end;
|
|
||||||
extra += start + "input.js" + end;
|
|
||||||
extra += start + "display.js" + end;
|
|
||||||
extra += start + "rfb.js" + end;
|
|
||||||
extra += start + "jsunzip.js" + end;
|
|
||||||
|
|
||||||
document.write(extra);
|
|
||||||
}());
|
|
||||||
|
|
Loading…
Reference in new issue