1 /*===========================================================================
2  *  Filename : scmport-config.h
3  *  About    : Client-adaptation configuration file for the scmport codes
4  *
5  *  Copyright (C) 2006 YAMAMOTO Kengo <yamaken AT bp.iij4u.or.jp>
6  *  Copyright (c) 2007-2008 SigScheme Project <uim-en AT googlegroups.com>
7  *
8  *  All rights reserved.
9  *
10  *  Redistribution and use in source and binary forms, with or without
11  *  modification, are permitted provided that the following conditions
12  *  are met:
13  *
14  *  1. Redistributions of source code must retain the above copyright
15  *     notice, this list of conditions and the following disclaimer.
16  *  2. Redistributions in binary form must reproduce the above copyright
17  *     notice, this list of conditions and the following disclaimer in the
18  *     documentation and/or other materials provided with the distribution.
19  *  3. Neither the name of authors nor the names of its contributors
20  *     may be used to endorse or promote products derived from this software
21  *     without specific prior written permission.
22  *
23  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
24  *  IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25  *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26  *  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
27  *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28  *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29  *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
30  *  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32  *  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33  *  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 ===========================================================================*/
35 
36 #ifndef __SCM_SCMPORT_CONFIG_H
37 #define __SCM_SCMPORT_CONFIG_H
38 
39 #if SCM_SCMPORT_USE_WITH_SIGSCHEME
40 #include "sigscheme.h"
41 #else /* SCM_SCMPORT_USE_WITH_SIGSCHEME */
42 #include <stdlib.h>
43 #include <string.h>
44 #endif /* SCM_SCMPORT_USE_WITH_SIGSCHEME */
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /*=======================================
51   Macro Definitions
52 =======================================*/
53 #if SCM_SCMPORT_USE_WITH_SIGSCHEME
54 #define SCM_PORT_MALLOC(size)          (scm_malloc(size))
55 #define SCM_PORT_CALLOC(number, size)  (scm_calloc((number), (size)))
56 #define SCM_PORT_REALLOC(ptr, size)    (scm_realloc((ptr), (size)))
57 #define SCM_PORT_STRDUP(str)           (scm_strdup(str))
58 #define SCM_CHARPORT_ERROR(cport, msg) (scm_plain_error(msg))
59 #define SCM_BYTEPORT_ERROR(bport, msg) (scm_plain_error(msg))
60 #else /* SCM_SCMPORT_USE_WITH_SIGSCHEME */
61 /* Allocation error handling in the macros is strongly recommended. */
62 #define SCM_PORT_MALLOC(size)          (malloc(size))
63 #define SCM_PORT_CALLOC(number, size)  (calloc((number), (size)))
64 #define SCM_PORT_REALLOC(ptr, size)    (realloc((ptr), (size)))
65 /* FIXME: Support platforms lacking strdup(3) */
66 #define SCM_PORT_STRDUP(str)           (strdup(str))
67 
68 /*
69  * Define appropriate error handling such as exception to override these. The
70  * macro MUST NOT return. The replacement expression should indicate that it
71  * will not return, in compiler specific way such as noreturn attribute of GCC.
72  */
73 #define SCM_CHARPORT_ERROR(cport, msg) (exit(EXIT_FAILURE))
74 #define SCM_BYTEPORT_ERROR(bport, msg) (exit(EXIT_FAILURE))
75 #endif /* SCM_SCMPORT_USE_WITH_SIGSCHEME */
76 
77 /*=======================================
78   Type Definitions
79 =======================================*/
80 
81 /*=======================================
82   Variable Declarations
83 =======================================*/
84 
85 /*=======================================
86   Function Declarations
87 =======================================*/
88 
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* __SCM_SCMPORT_CONFIG_H */
95