blob: 5efa7cbb5af6f0637e426d9a93c29ba67011adbf [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau2dd0d472006-06-29 17:53:05 +02002 include/common/config.h
Willy Tarreaubaaee002006-06-26 02:48:02 +02003 This files contains most of the user-configurable settings.
4
Willy Tarreau50e608d2007-05-13 18:26:08 +02005 Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
Willy Tarreaubaaee002006-06-26 02:48:02 +02006
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation, version 2.1
10 exclusively.
11
12 This library 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 GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20*/
21
Willy Tarreau2dd0d472006-06-29 17:53:05 +020022#ifndef _COMMON_CONFIG_H
23#define _COMMON_CONFIG_H
Willy Tarreaubaaee002006-06-26 02:48:02 +020024
Willy Tarreau2dd0d472006-06-29 17:53:05 +020025#include <common/defaults.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020026
27/* this reduces the number of calls to select() by choosing appropriate
28 * sheduler precision in milliseconds. It should be near the minimum
29 * time that is needed by select() to collect all events. All timeouts
30 * are rounded up by adding this value prior to pass it to select().
31 */
32#define SCHEDULER_RESOLUTION 9
33
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020034/* CONFIG_HAP_MEM_OPTIM
35 * This enables use of memory pools instead of malloc()/free(). There
36 * is no reason to disable it, except perhaps for rare debugging.
37 */
38#ifndef CONFIG_HAP_NO_MEM_OPTIM
39# define CONFIG_HAP_MEM_OPTIM
40#endif /* CONFIG_HAP_NO_MEM_OPTIM */
41
Willy Tarreau50e608d2007-05-13 18:26:08 +020042/* CONFIG_HAP_MALLOC / CONFIG_HAP_CALLOC / CONFIG_HAP_FREE
43 * This macro allows to replace the malloc function with another one.
44 */
45#ifdef CONFIG_HAP_MALLOC
46#define MALLOC CONFIG_HAP_MALLOC
47#else
48#define MALLOC malloc
49#endif
50
51#ifdef CONFIG_HAP_CALLOC
52#define CALLOC CONFIG_HAP_CALLOC
53#else
54#define CALLOC calloc
55#endif
56
57#ifdef CONFIG_HAP_FREE
58#define FREE CONFIG_HAP_FREE
59#else
60#define FREE free
61#endif
62
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020063
Willy Tarreau2a429502006-10-15 14:52:29 +020064/* CONFIG_HAP_INLINE_FD_SET
65 * This makes use of inline FD_* macros instead of calling equivalent
66 * functions. Benchmarks on a Pentium-M show that using functions is
67 * generally twice as fast. So it's better to keep this option unset.
68 */
69//#undef CONFIG_HAP_INLINE_FD_SET
70
Willy Tarreau390223b2006-10-15 23:43:42 +020071/* CONFIG_HAP_USE_REGPARM
72 * This enables the use of register parameters for some functions where
Willy Tarreau61eadc02008-08-17 17:06:37 +020073 * it may improve performance by a measurable factor. This MUST NOT be
74 * enabled on gcc < 3 because it is ignored for function pointers.
Willy Tarreaufb278672006-10-15 15:38:50 +020075 */
Willy Tarreau61eadc02008-08-17 17:06:37 +020076#if CONFIG_HAP_USE_REGPARM && __GNUC__ >= 3
Willy Tarreaufb278672006-10-15 15:38:50 +020077#define REGPRM1 __attribute__((regparm(1)))
78#define REGPRM2 __attribute__((regparm(2)))
79#define REGPRM3 __attribute__((regparm(3)))
Willy Tarreau390223b2006-10-15 23:43:42 +020080#else
81#define REGPRM1
82#define REGPRM2
83#define REGPRM3
Willy Tarreaufb278672006-10-15 15:38:50 +020084#endif
Willy Tarreau2a429502006-10-15 14:52:29 +020085
Willy Tarreau75cf17e2008-08-29 15:48:49 +020086/* By default, gcc does not inline large chunks of code, but we want it to
87 * respect our choices.
88 */
89#if !defined(forceinline)
90#if __GNUC__ < 3
91#define forceinline inline
92#else
93#define forceinline inline __attribute__((always_inline))
94#endif
95#endif
96
Willy Tarreau2dd0d472006-06-29 17:53:05 +020097#endif /* _COMMON_CONFIG_H */