You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
2.2 KiB
50 lines
2.2 KiB
/******************************************************************************
|
|
*
|
|
* Copyright (C) 2009-2018 Realtek Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at:
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
******************************************************************************/
|
|
#ifndef RTK_COMMON_H
|
|
#define RTK_COMMON_H
|
|
|
|
#define RTK_UNUSED(x) (void)(x)
|
|
|
|
#define STREAM_TO_UINT16(u16, p) {u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8)); (p) += 2;}
|
|
#define STREAM_TO_UINT16_S(u16, p) {u16 = ((uint16_t)(*(p)) + (((uint16_t)(*((p) + 1))) << 8));}
|
|
#define UINT16_TO_STREAM_S(p, u16) {*(p) = (uint8_t)(u16); *(p + 1) = (uint8_t)((u16) >> 8);}
|
|
#define UINT16_TO_STREAM(p, u16) {*(p)++ = (uint8_t)(u16); *(p)++ = (uint8_t)((u16) >> 8);}
|
|
#define UINT32_TO_STREAM(p, u32) {*(p)++ = (uint8_t)(u32); *(p)++ = (uint8_t)((u32) >> 8); *(p)++ = (uint8_t)((u32) >> 16); *(p)++ = (uint8_t)((u32) >> 24);}
|
|
#define STREAM_TO_UINT32(u32, p) {u32 = (((uint32_t)(*(p))) + ((((uint32_t)(*((p) + 1)))) << 8) + ((((uint32_t)(*((p) + 2)))) << 16) + ((((uint32_t)(*((p) + 3)))) << 24)); (p) += 4;}
|
|
#define UINT8_TO_STREAM(p, u8) {*(p)++ = (uint8_t)(u8);}
|
|
#define STREAM_TO_UINT8(u8, p) {u8 = (uint8_t)(*(p)); (p) += 1;}
|
|
|
|
#define STREAM_SKIP_UINT8(p) \
|
|
do { \
|
|
(p) += 1; \
|
|
} while (0)
|
|
#define STREAM_SKIP_UINT16(p) \
|
|
do { \
|
|
(p) += 2; \
|
|
} while (0)
|
|
|
|
#define CHECK_MALLOC_FAILED(condition) \
|
|
do { \
|
|
if (!(condition)) { \
|
|
ALOGE("check fail: source file \"%s\", line %d, in function %s", \
|
|
__FILE__, __LINE__, __func__); \
|
|
abort(); \
|
|
} \
|
|
} while (0)
|
|
#endif
|