LCOV - code coverage report
Current view: top level - inc - basics.h (source / functions) Hit Total Coverage
Test: FontForge coverage report 2017-08-04 01:21:11+02:00 (commit d35f7e4107a9e1db65cce47c468fcc914cecb8fd) Lines: 0 2 0.0 %
Date: 2017-08-04 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2000-2012 by George Williams */
       2             : /*
       3             :  * Redistribution and use in source and binary forms, with or without
       4             :  * modification, are permitted provided that the following conditions are met:
       5             : 
       6             :  * Redistributions of source code must retain the above copyright notice, this
       7             :  * list of conditions and the following disclaimer.
       8             : 
       9             :  * Redistributions in binary form must reproduce the above copyright notice,
      10             :  * this list of conditions and the following disclaimer in the documentation
      11             :  * and/or other materials provided with the distribution.
      12             : 
      13             :  * The name of the author may not be used to endorse or promote products
      14             :  * derived from this software without specific prior written permission.
      15             : 
      16             :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
      17             :  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
      18             :  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
      19             :  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      20             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      21             :  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
      22             :  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
      23             :  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      24             :  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
      25             :  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      26             :  */
      27             : #ifndef _BASICS_H
      28             : #define _BASICS_H
      29             : 
      30             : #include <fontforge-config.h>
      31             : #include <stdio.h>                /* for NULL */
      32             : #ifdef HAVE_STDINT_H
      33             : #include <stdint.h>
      34             : #else
      35             : #include <inttypes.h>
      36             : #endif
      37             : #include <stdlib.h>               /* for free */
      38             : #include <limits.h>
      39             : #include <stdbool.h>
      40             : 
      41             : typedef int32_t         int32;
      42             : typedef uint32_t        uint32;
      43             : typedef int16_t         int16;
      44             : typedef uint16_t        uint16;
      45             : typedef int8_t          int8;
      46             : typedef uint8_t         uint8;
      47             : 
      48             : /* An integral type which can hold a pointer */
      49             : typedef intptr_t        intpt;
      50             : 
      51             : typedef uint32 unichar_t;
      52             : 
      53             : /* A macro to mark unused function parameters with. We often
      54             :  * have such parameters, because of extensive use of callbacks.
      55             :  */
      56             : #ifdef UNUSED
      57             : #elif defined(__GNUC__)
      58             : # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
      59             : #elif defined(__LCLINT__)
      60             : # define UNUSED(x) /*@unused@*/ x
      61             : #else
      62             : # define UNUSED(x) x
      63             : #endif
      64             : 
      65             : /* A macro to print a string for debug purposes
      66             :  */
      67             : #ifdef FONTFORGE_DEBUG
      68             : #define TRACE(...) printf(__VA_ARGS__)
      69             : #else
      70             : #define TRACE(...)
      71             : #endif
      72             : 
      73             : extern void NoMoreMemMessage(void);
      74             : 
      75             : static inline int imin(int a, int b)
      76             : {
      77             :     return (a < b) ? a : b;
      78             : }
      79             : 
      80           0 : static inline int imax(int a, int b)
      81             : {
      82           0 :     return (a < b) ? b : a;
      83             : }
      84             : 
      85             : #define IS_IN_ORDER3( a, b, c )   ( ((a)<=(b)) && ((b)<=(c)) )
      86             : 
      87             : 
      88             : /**
      89             :  * Many lists in FontForge are singly linked. At times you might want
      90             :  * to append to the list which, when you only have a pointer to the
      91             :  * start of the list can be more verbose than one would like. To use
      92             :  * this macro you must defined a null initialized variable 'last'
      93             :  * outside of any loop that traverses the source list. The last
      94             :  * variable is used used by this macro to quickly append to the list
      95             :  * as you go. This macro also assumes that the 'last' and 'newitem'
      96             :  * types have a member "->next" which contains the single linked list
      97             :  * pointer to the next element.
      98             :  *
      99             :  * Efficient list append should really be a one line call in the bulk
     100             :  * of the code :)
     101             :  *
     102             :  * example:
     103             :  * MyListObjectType* newfoolast = 0;
     104             :  * MyListObjectType* newfoolist = 0;
     105             :  * 
     106             :  * for( ... iterate a source collection of foos ... )
     107             :  * {
     108             :  *    MyListObjectType* foocopy = CopyIt( foo );
     109             :  *    FFLIST_SINGLE_LINKED_APPEND( newfoolist, newfoolast, foocopy );
     110             :  * }
     111             :  */
     112             : #define FFLIST_SINGLE_LINKED_APPEND( head, last, newitem ) \
     113             :                     if ( !last )                       \
     114             :                     {                                  \
     115             :                         newitem->next = 0;          \
     116             :                         head = last = newitem;         \
     117             :                     }                                  \
     118             :                     else                               \
     119             :                     {                                  \
     120             :                         last->next = newitem;               \
     121             :                         last = newitem;                \
     122             :                     }
     123             : 
     124             : 
     125             : #endif

Generated by: LCOV version 1.10