nengel@2: /* nengel@2: * copyright (c) 2006 Michael Niedermayer nengel@2: * nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: /** nengel@2: * @file nengel@2: * common internal API header nengel@2: */ nengel@2: nengel@2: #ifndef AVUTIL_INTERNAL_H nengel@2: #define AVUTIL_INTERNAL_H nengel@2: nengel@2: #if !defined(DEBUG) && !defined(NDEBUG) nengel@2: # define NDEBUG nengel@2: #endif nengel@2: nengel@2: #include nengel@2: #include nengel@2: #include nengel@2: #include nengel@2: #include "config.h" nengel@2: #include "attributes.h" nengel@2: #include "timer.h" nengel@2: nengel@2: nengel@2: nengel@2: #ifndef INT16_MIN nengel@2: #define INT16_MIN (-0x7fff - 1) nengel@2: #endif nengel@2: nengel@2: #ifndef INT16_MAX nengel@2: #define INT16_MAX 0x7fff nengel@2: #endif nengel@2: nengel@2: #ifndef INT32_MIN nengel@2: #define INT32_MIN (-0x7fffffff - 1) nengel@2: #endif nengel@2: nengel@2: #ifndef INT32_MAX nengel@2: #define INT32_MAX 0x7fffffff nengel@2: #endif nengel@2: nengel@2: #ifndef UINT32_MAX nengel@2: #define UINT32_MAX 0xffffffff nengel@2: #endif nengel@2: nengel@2: #ifndef INT64_MIN nengel@2: #define INT64_MIN (-0x7fffffffffffffffLL - 1) nengel@2: #endif nengel@2: nengel@2: #ifndef INT64_MAX nengel@2: #define INT64_MAX INT64_C(9223372036854775807) nengel@2: #endif nengel@2: nengel@2: #ifndef UINT64_MAX nengel@2: #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) nengel@2: #endif nengel@2: nengel@2: #ifndef INT_BIT nengel@2: # define INT_BIT (CHAR_BIT * sizeof(int)) nengel@2: #endif nengel@2: nengel@2: #ifndef offsetof nengel@2: # define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) nengel@2: #endif nengel@2: nengel@2: /* Use to export labels from asm. */ nengel@2: #define LABEL_MANGLE(a) #a nengel@2: #define LOCAL_MANGLE(a) #a nengel@2: #define MANGLE(a) #a nengel@2: nengel@2: // Use rip-relative addressing if compiling PIC code on x86-64. nengel@2: // #if ARCH_X86_64 && defined(PIC) nengel@2: // # define LOCAL_MANGLE(a) #a "(%%rip)" nengel@2: // #else nengel@2: // # define LOCAL_MANGLE(a) #a nengel@2: // #endif nengel@2: // nengel@2: // #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) nengel@2: nengel@2: /* debug stuff */ nengel@2: nengel@2: /* dprintf macros */ nengel@2: #ifdef DEBUG nengel@2: # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) nengel@2: #else nengel@2: # define dprintf(pctx, ...) nengel@2: #endif nengel@2: nengel@2: #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) nengel@2: nengel@2: /* math */ nengel@2: nengel@2: nengel@2: /* avoid usage of dangerous/inappropriate system functions */ nengel@2: // #undef malloc nengel@2: // #define malloc please_use_av_malloc nengel@2: // #undef free nengel@2: // #define free please_use_av_free nengel@2: #undef realloc nengel@2: #define realloc please_use_av_realloc nengel@2: #undef time nengel@2: #define time time_is_forbidden_due_to_security_issues nengel@2: #undef rand nengel@2: #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get nengel@2: #undef srand nengel@2: #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init nengel@2: #undef random nengel@2: #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get nengel@2: #undef sprintf nengel@2: #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf nengel@2: //#undef exit nengel@2: //#define exit exit_is_forbidden nengel@2: #ifndef LIBAVFORMAT_BUILD nengel@2: nengel@2: #undef puts nengel@2: #define puts please_use_av_log_instead_of_puts nengel@2: #undef perror nengel@2: #define perror please_use_av_log_instead_of_perror nengel@2: #endif nengel@2: nengel@2: #define FF_ALLOC_OR_GOTO(p, size, label)\ nengel@2: {\ nengel@2: p = av_malloc(size);\ nengel@2: if (p == NULL && (size) != 0) {\ nengel@2: av_log(AV_LOG_ERROR, "Cannot allocate memory.\n");\ nengel@2: goto label;\ nengel@2: }\ nengel@2: } nengel@2: nengel@2: #define FF_ALLOCZ_OR_GOTO(p, size, label)\ nengel@2: {\ nengel@2: p = av_mallocz(size);\ nengel@2: if (p == NULL && (size) != 0) {\ nengel@2: av_log(AV_LOG_ERROR, "Cannot allocate memory.\n");\ nengel@2: goto label;\ nengel@2: }\ nengel@2: } nengel@2: nengel@2: nengel@2: /** nengel@2: * Returns NULL if CONFIG_SMALL is true, otherwise the argument nengel@2: * without modification. Used to disable the definition of strings nengel@2: * (for example AVCodec long_names). nengel@2: */ nengel@2: #if CONFIG_SMALL nengel@2: # define NULL_IF_CONFIG_SMALL(x) NULL nengel@2: #else nengel@2: # define NULL_IF_CONFIG_SMALL(x) x nengel@2: #endif nengel@2: nengel@2: #endif /* AVUTIL_INTERNAL_H */