root/test/manual/noverlay/emacs-compat.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. xmalloc
  2. xfree
  3. xrealloc
  4. emacs_abort

     1 /* Mock necessary parts of lisp.h.
     2 
     3 Copyright (C) 2017-2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef TEST_COMPAT_H
    21 #define TEST_COMPAT_H
    22 
    23 #include <limits.h>
    24 #include <stdio.h>
    25 #include <stdlib.h>
    26 
    27 typedef int Lisp_Object;
    28 
    29 void *
    30 xmalloc (size_t size)
    31 {
    32   return malloc (size);
    33 }
    34 
    35 void
    36 xfree (void *ptr)
    37 {
    38   free (ptr);
    39 }
    40 
    41 void *
    42 xrealloc (void *block, size_t size)
    43 {
    44   return realloc (block, size);
    45 }
    46 
    47 void
    48 emacs_abort ()
    49 {
    50   fprintf (stderr, "Aborting...\n");
    51   exit (EXIT_FAILURE);
    52 }
    53 
    54 #ifndef eassert
    55 #define eassert(cond)                                                   \
    56   do {                                                                  \
    57     if (! (cond)) {                                                     \
    58       fprintf (stderr, "%s:%d:eassert condition failed: %s\n",          \
    59                __FILE__, __LINE__ , # cond);                            \
    60       exit (EXIT_FAILURE);                                              \
    61     }                                                                   \
    62   } while (0)
    63 #endif
    64 
    65 #ifndef eassume
    66 #define eassume eassert
    67 #endif
    68 
    69 #ifndef max
    70 #define max(x,y) ((x) >= (y) ? (x) : (y))
    71 #endif
    72 #ifndef min
    73 #define min(x,y) ((x) <= (y) ? (x) : (y))
    74 #endif
    75 
    76 #endif /* TEST_COMPAT_H */

/* [<][>][^][v][top][bottom][index][help] */