You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2008/09/05 06:09:10 UTC
svn commit: r692332 - in /lucene/lucy/trunk/charmonizer: ./ src/Charmonizer/
src/Charmonizer/Core/ src/Charmonizer/Probe/ src/Charmonizer/Test/
Author: marvin
Date: Thu Sep 4 21:09:09 2008
New Revision: 692332
URL: http://svn.apache.org/viewvc?rev=692332&view=rev
Log:
Make numerous improvements to Charmonizer.
* Change Charmonizer to use fixed prefixes of "CHY_" and "chy_" rather than
allowing user-specified prefixes.
* Add INLINE macro to Charmonizer.
* Add Charmonizer alias for fopen64.
* Add SKIP directives for invalid tests in FuncMacro module.
* Fix caching problem where a check for a header that failed previously
appeared to have succeeded.
* Eliminate a possible namespace collision with "test_compile".
* Make DirSep module Windows compatible.
* Correct error (and occasional subsequent memory glitch) when adding include
directories to Charmonizer Compiler object.
* Remove spurious postamble from charmony.h under Windows.
* Preserve Unix line endings even when run on Windows.
* Check for headers one-by-one when mass check fails.
* Check for certain Windows headers.
Modified:
lucene/lucy/trunk/charmonizer/README
lucene/lucy/trunk/charmonizer/charmonize.c
lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.harm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.harm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.harm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.harm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm
lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm
Modified: lucene/lucy/trunk/charmonizer/README
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/README?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/README (original)
+++ lucene/lucy/trunk/charmonizer/README Thu Sep 4 21:09:09 2008
@@ -1,19 +1,23 @@
NAME
- Charmonizer - harmonize C build enviromnents.
+ Charmonizer - Use C to configure C.
OVERVIEW
Charmonizer is a tool for probing, normalizing, and testing the build
environment provided by a C compiler and an operating system. It works by
attempting to compile lots of little programs and analyzing the output
- from those that build successfully.
+ from those that build successfully. `
- Charmonizer itself has no prerequisites other than an ISO C90-compliant
- compiler which can be invoked from C via the system() command. For all
- intents and purposes it is written in pure C90. (A lightweight source
- filter called "metaquote" is employed to make embedding C source code
- within C source code less gnarly).
+ Charmonizer modules are ordinary ANSI C files, and the configuration
+ application that you write is an ordinary C executable.
+
+REQUIREMENTS
+
+ The only prerequisite for the target machine is an ISO C90-compliant
+ compiler which can be invoked from C via the system() command. Your
+ development environment must include Perl in order to run the metaquote
+ utility script, but no Perl programming is required.
PROBING
@@ -106,32 +110,18 @@
Charmonizer creates a number of temporary files within the current working
directory while it runs. These files all begin with "_charm".
-CHARMONIZER SOURCE CODE AND THE METAQUOTE UTILITY
+GATHERING FILES
- Charmonizer is (more or less) a C program which writes C code. Writing C
- from C is ordinarily quite awkward, because when you try to embed more
- than a line or two of C source code inside C string literals, things get
- ugly fast.
-
- To get around this problem, Charmonizer uses a source filter. In the
- "real" Charmonizer source code, longer code fragments are surrounded by
- METAQUOTE tags instead of literal double quotes.
-
- char hello_source[] = METAQUOTE
- #include <stdio.h>
- int main() {
- printf("Hello, world.\n");
- return 0;
- }
- METAQUOTE;
-
- These source files are run through the "metaquote" utility -- which
- transforms everything between paired METAQUOTE tags into concatenated
- string literals. The result is hideous but valid C.
-
- The "real" charmonizer source code lives in the src/ directory. Files use
- the suffixes .charm and .harm to differentiate them from post-filtering .c
- and .h files.
+ Charmonizer master modules are stored in the src/ directory, and have
+ .harm/.charm extensions. They are ordinary ANSI C files, except for one
+ thing: multi-line quoted snippets of source code are surrounded by
+ "METAQUOTE" tags. This is done for maintainability's sake, since
+ embedding C source code in C source code as string literals is very messy.
+
+ To generate all the necessary Charmonizer .c/.h files, use the metaquote
+ utility.
+
+ $ ./bin/metaquote --src=/path/to/charmonizer/src --out=/my/charm/dir
SECURITY
Modified: lucene/lucy/trunk/charmonizer/charmonize.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/charmonize.c?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/charmonize.c (original)
+++ lucene/lucy/trunk/charmonizer/charmonize.c Thu Sep 4 21:09:09 2008
@@ -1,4 +1,4 @@
-/* charmonize.c -- write charmony.h config file.
+/* charmonize.c -- Create Charmony.
*/
#include <stdio.h>
@@ -94,7 +94,6 @@
chaz_Probe_set_verbosity(verbosity);
}
chaz_Probe_init(os_name, cc_command, cc_flags, NULL);
- chaz_Probe_set_prefixes("LUCY_", "lucy_", "lucy_");
/* clean up */
free(infile_str);
@@ -152,15 +151,7 @@
static void
write_charmony_postamble(void)
{
- FILE *charmony_fh = chaz_Probe_get_charmony_fh();
-
- if (strcmp(os_name, "mswin32") == 0) {
- fprintf(charmony_fh,
- "#ifndef LUCY_HAS_LARGE_FILE_SUPPORT\n"
- " #include \"win32lfs.h\"\n"
- "#endif /* LUCY_HAS_LARGE_FILE_SUPPORT */\n"
- );
- }
+ /* No postamble for now. */
}
void
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/Compiler.charm Thu Sep 4 21:09:09 2008
@@ -24,7 +24,7 @@
add_inc_dir(Compiler *self, const char *dir);
static void
-test_compile(Compiler *self);
+do_test_compile(Compiler *self);
chaz_Compiler*
chaz_CC_new(OperSys *oper_sys, const char *cc_command, const char *cc_flags)
@@ -58,7 +58,7 @@
self->add_inc_dir(self, ".");
/* if we can't compile anything, game over */
- test_compile(self);
+ do_test_compile(self);
return self;
}
@@ -160,7 +160,7 @@
}
static void
-test_compile(Compiler *self)
+do_test_compile(Compiler *self)
{
char *code = "int main() { return 0; }\n";
chaz_bool_t success;
@@ -182,18 +182,17 @@
static void
add_inc_dir(Compiler *self, const char *dir)
{
- size_t num_dirs = 2; /* includes the passed-in dir */
+ size_t num_dirs = 0;
char **dirs = self->inc_dirs;
/* count up the present number of dirs, reallocate */
- while (*dirs++ != NULL) {
- num_dirs++;
- }
- self->inc_dirs == realloc(self->inc_dirs, num_dirs + 1);
- self->inc_dirs[num_dirs] = NULL;
+ while (*dirs++ != NULL) { num_dirs++; }
+ num_dirs += 1; /* passed-in dir */
+ self->inc_dirs = realloc(self->inc_dirs, num_dirs + 1);
/* put the passed-in dir at the end of the list */
self->inc_dirs[num_dirs - 1] = strdup(dir);
+ self->inc_dirs[num_dirs] = NULL;
}
/**
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/HeadCheck.charm Thu Sep 4 21:09:09 2008
@@ -61,21 +61,25 @@
chaz_bool_t
chaz_HeadCheck_check_header(const char *header_name)
{
- Header *header;
- Header key;
- Header *fake = &key;
+ Header *header;
+ Header key;
+ Header *fake = &key;
+ Header **header_ptr;
/* fake up a key to feed to bsearch; see if the header's already there */
key.name = (char*)header_name;
key.exists = false;
- header = bsearch(&fake, header_cache, cache_size, sizeof(void*),
+ header_ptr = bsearch(&fake, header_cache, cache_size, sizeof(void*),
compare_headers);
/* if it's not there, go try a test compile */
- if (header == NULL) {
+ if (header_ptr == NULL) {
header = discover_header(header_name);
add_to_cache(header);
}
+ else {
+ header = *header_ptr;
+ }
return header->exists;
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.charm Thu Sep 4 21:09:09 2008
@@ -32,12 +32,6 @@
chaz_bool_t chaz_ModHand_charm_run_available = false;
FILE* chaz_ModHand_charmony_fh = NULL;
-char *macro_prefix = NULL;
-char *typedef_prefix = NULL;
-char *function_prefix = NULL;
-
-chaz_bool_t want_short_names = false;
-
/* static vars */
static char *try_app_path = NULL;
static char *try_app_command = NULL;
@@ -243,19 +237,19 @@
void
chaz_ModHand_shorten_macro(const char *sym)
{
- append_conf(" #define %s %s%s\n", sym, macro_prefix, sym);
+ append_conf(" #define %s CHY_%s\n", sym, sym);
}
void
chaz_ModHand_shorten_typedef(const char *sym)
{
- append_conf(" #define %s %s%s\n", sym, typedef_prefix, sym);
+ append_conf(" #define %s chy_%s\n", sym, sym);
}
void
chaz_ModHand_shorten_function(const char *sym)
{
- append_conf(" #define %s %s%s\n", sym, function_prefix, sym);
+ append_conf(" #define %s chy_%s\n", sym, sym);
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Core/ModHandler.harm Thu Sep 4 21:09:09 2008
@@ -25,11 +25,6 @@
extern chaz_bool_t chaz_ModHand_charm_run_available;
extern FILE* chaz_ModHand_charmony_fh;
-extern char *chaz_ModHand_macro_prefix;
-extern char *chaz_ModHand_typedef_prefix;
-extern char *chaz_ModHand_function_prefix;
-extern chaz_bool_t chaz_ModHand_want_short_names;
-
/* Initialize elements needed by ModHandler. Must be called before anything
* else, but after os and compiler are created.
*/
@@ -72,24 +67,22 @@
*/
#define CHAZ_MODHAND_START_SHORT_NAMES \
append_conf( \
- "\n#if defined(%sUSE_SHORT_NAMES) || defined(CHAZ_USE_SHORT_NAMES)\n", \
- chaz_ModHand_macro_prefix)
+ "\n#if defined(CHY_USE_SHORT_NAMES) || defined(CHAZ_USE_SHORT_NAMES)\n")
#define CHAZ_MODHAND_END_SHORT_NAMES \
- append_conf( \
- "#endif /* USE_SHORT_NAMES */\n", chaz_ModHand_macro_prefix)
+ append_conf("#endif /* USE_SHORT_NAMES */\n")
-/* Define a shortened version of a macro symbol (minus the prefix);
+/* Define a shortened version of a macro symbol (minus the "CHY_" prefix);
*/
void
chaz_ModHand_shorten_macro(const char *symbol);
-/* Define a shortened version of a typedef symbol (minus the prefix);
+/* Define a shortened version of a typedef symbol (minus the "chy_" prefix);
*/
void
chaz_ModHand_shorten_typedef(const char *symbol);
-/* Define a shortened version of a function symbol (minus the prefix);
+/* Define a shortened version of a function symbol (minus the "chy_" prefix);
*/
void
chaz_ModHand_shorten_function(const char *symbol);
@@ -116,10 +109,6 @@
#define compiler chaz_ModHand_compiler
#define charm_run_available chaz_ModHand_charm_run_available
#define charmony_fh chaz_ModHand_charmony_fh
- #define macro_prefix chaz_ModHand_macro_prefix
- #define typedef_prefix chaz_ModHand_typedef_prefix
- #define function_prefix chaz_ModHand_function_prefix
- #define want_short_names chaz_ModHand_want_short_names
#define ModHand_init chaz_ModHand_init
#define ModHand_open_charmony_h chaz_ModHand_open_charmony_h
#define ModHand_clean_up chaz_ModHand_clean_up
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.charm Thu Sep 4 21:09:09 2008
@@ -18,10 +18,6 @@
os = OS_new(osname);
compiler = CC_new(os, cc_command, cc_flags);
- /* don't write short names unless the user so indicates */
- chaz_Probe_set_prefixes("", "", "");
- want_short_names = false;
-
/* dispatch other tasks */
ModHand_init();
HeadCheck_init();
@@ -47,20 +43,6 @@
}
void
-chaz_Probe_set_prefixes(char *macro_pre, const char* typedef_pre,
- const char *function_pre)
-{
- want_short_names = true;
-
- free(macro_prefix);
- free(typedef_prefix);
- free(function_prefix);
- macro_prefix = strdup(macro_pre);
- typedef_prefix = strdup(typedef_pre);
- function_prefix = strdup(function_pre);
-}
-
-void
chaz_Probe_set_verbosity(int level)
{
verbosity = level;
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.harm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe.harm Thu Sep 4 21:09:09 2008
@@ -22,13 +22,6 @@
void
chaz_Probe_clean_up();
-/* These prefixes will be prepended to every symbol Charmonizer generates.
- * By default, they are blank.
- */
-void
-chaz_Probe_set_prefixes(char *macro_prefix, const char *typedef_prefix,
- const char *function_prefix);
-
/* Determine how much feedback Charmonizer provides.
* 0 - silent
* 1 - normal
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.charm Thu Sep 4 21:09:09 2008
@@ -2,13 +2,16 @@
#include "Charmonizer/Core/ModHandler.h"
#include "Charmonizer/Core/Util.h"
+#include "Charmonizer/Core/HeadCheck.h"
#include "Charmonizer/Probe/DirSep.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+/* TODO: move mkdir and rmdir to a Core module a la Stat. */
static char mkdir_code[] = METAQUOTE
#include "_charm.h"
+ %s
#include <sys/stat.h>
int main () {
Charm_Setup;
@@ -19,18 +22,53 @@
}
METAQUOTE;
+static char *headers[] = {
+ "direct.h",
+ "unistd.h",
+ "sys/stat.h",
+ NULL,
+};
+
+static char rmdir_code[] = METAQUOTE
+ #include "_charm.h"
+ %s
+ int main () {
+ Charm_Setup;
+ printf("1");
+ rmdir("_charm_test_dir_orig");
+ rmdir("_charm_test_dir_mod");
+ return 0;
+ }
+METAQUOTE;
+
void
chaz_DirSep_run(void)
{
+ int i;
char *output;
size_t output_len;
char dir_sep[3];
chaz_bool_t dir_sep_is_valid = false;
+ char *includes_buf = strdup("");
+ size_t inc_buf_len = 2;
+ size_t needed;
+ char *code_buf;
START_RUN("DirSep");
+ /* Include any possible relevant headers. */
+ for (i = 0; headers[i] != NULL; i++) {
+ if (!check_header(headers[i]))
+ break;
+ inc_buf_len = append_strings(&includes_buf, inc_buf_len, "#include <",
+ headers[i], ">\n", NULL);
+ }
+ needed = strlen(mkdir_code) + inc_buf_len + 10;
+ code_buf = malloc(needed);
+ sprintf(code_buf, mkdir_code, includes_buf);
+
/* create a directory */
- output = capture_output(mkdir_code, strlen(mkdir_code), &output_len);
+ output = capture_output(code_buf, strlen(code_buf), &output_len);
if (output != NULL && (strcmp(output, "1") == 0)) {
FILE *f;
@@ -66,20 +104,23 @@
remove("_charm_test_dir_orig");
remove("_charm_test_dir_mod");
+ /* Try rmdir. */
+ sprintf(code_buf, rmdir_code, includes_buf);
+ output = capture_output(code_buf, strlen(code_buf), &output_len);
+
if (dir_sep_is_valid) {
- append_conf( "#define %sDIR_SEP \"%s\"\n",
- macro_prefix, dir_sep
- );
+ append_conf("#define CHY_DIR_SEP \"%s\"\n", dir_sep);
/* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
- shorten_macro("DIR_SEP");
- END_SHORT_NAMES;
- }
+ START_SHORT_NAMES;
+ shorten_macro("DIR_SEP");
+ END_SHORT_NAMES;
}
END_RUN;
+
+ free(code_buf);
+ free(includes_buf);
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.harm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/DirSep.harm Thu Sep 4 21:09:09 2008
@@ -37,4 +37,3 @@
* limitations under the License.
*/
-
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.charm Thu Sep 4 21:09:09 2008
@@ -27,15 +27,41 @@
}
METAQUOTE;
+/* code for verifying inline keyword */
+static char inline_code[] = METAQUOTE
+ #include "_charm.h"
+ %s int foo() { return 1; }
+ int main() {
+ Charm_Setup;
+ printf("%%d", foo());
+ return 0;
+ }
+METAQUOTE;
+
+static char*
+try_inline(const char *keyword, size_t *output_len) {
+ char code[ sizeof(inline_code) + 30 ];
+ sprintf(code, inline_code, keyword);
+ return capture_output(code, strlen(code), output_len);
+}
+
+static const char* inline_options[] = {
+ "__inline__",
+ "__inline",
+ "inline"
+};
+static int num_inline_options = sizeof(inline_options) / sizeof(void*);
void
chaz_FuncMacro_run(void)
{
+ int i;
char *output;
size_t output_len;
chaz_bool_t has_funcmac = false;
chaz_bool_t has_iso_funcmac = false;
chaz_bool_t has_gnuc_funcmac = false;
+ chaz_bool_t has_inline = false;
START_RUN("FuncMacro");
@@ -63,32 +89,48 @@
? "__func__"
: "__FUNCTION__";
append_conf(
- "#define %sHAS_FUNC_MACRO\n"
- "#define %sFUNC_MACRO %s\n",
- macro_prefix, macro_prefix, macro_text);
+ "#define CHY_HAS_FUNC_MACRO\n"
+ "#define CHY_FUNC_MACRO %s\n",
+ macro_text
+ );
}
/* write out specific defines */
if (has_iso_funcmac) {
- append_conf("#define %sHAS_ISO_FUNC_MACRO\n", macro_prefix);
+ append_conf("#define CHY_HAS_ISO_FUNC_MACRO\n");
}
if (has_gnuc_funcmac) {
- append_conf("#define %sHAS_GNUC_FUNC_MACRO\n", macro_prefix);
+ append_conf("#define CHY_HAS_GNUC_FUNC_MACRO\n");
}
- /* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
- if (has_iso_funcmac)
- shorten_macro("HAS_ISO_FUNC_MACRO");
- if (has_gnuc_funcmac)
- shorten_macro("HAS_GNUC_FUNC_MACRO");
- if (has_iso_funcmac || has_gnuc_funcmac) {
- shorten_macro("HAS_FUNC_MACRO");
- shorten_macro("FUNC_MACRO");
+ /* Check for inline keyword. */
+
+ for (i = 0; i < num_inline_options; i++) {
+ const char *inline_option = inline_options[i];
+ output = try_inline(inline_option, &output_len);
+ if (output != NULL) {
+ has_inline = true;
+ append_conf("#define CHY_INLINE %s\n", inline_option);
+ free(output);
+ break;
}
- END_SHORT_NAMES;
}
+ if (!has_inline) {
+ append_conf("#define CHY_INLINE\n");
+ }
+
+ /* shorten */
+ START_SHORT_NAMES;
+ if (has_iso_funcmac)
+ shorten_macro("HAS_ISO_FUNC_MACRO");
+ if (has_gnuc_funcmac)
+ shorten_macro("HAS_GNUC_FUNC_MACRO");
+ if (has_iso_funcmac || has_gnuc_funcmac) {
+ shorten_macro("HAS_FUNC_MACRO");
+ shorten_macro("FUNC_MACRO");
+ }
+ shorten_macro("INLINE");
+ END_SHORT_NAMES;
END_RUN;
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.harm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/FuncMacro.harm Thu Sep 4 21:09:09 2008
@@ -20,6 +20,12 @@
*
* HAS_FUNC_MACRO
* FUNC_MACRO
+ *
+ * The "inline" keyword will also be probed for. If it is available, the
+ * following macro will be defined to "inline", otherwise it will be defined
+ * to nothing.
+ *
+ * INLINE
*/
void chaz_FuncMacro_run(void);
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Headers.charm Thu Sep 4 21:09:09 2008
@@ -7,6 +7,7 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <stdarg.h>
/* keep track of which headers have succeeded */
@@ -22,11 +23,13 @@
static size_t aff_buf_size = 0;
static char *aff_buf = NULL;
-/* Transform "header.h" into "HAS_HEADER_H, storing the result in [aff_buf].
+/* Transform "header.h" into "CHY_HAS_HEADER_H, storing the result in
+ * [aff_buf].
*/
static void
encode_affirmation(const char *header_name);
+#define NUM_C89_HEADERS 15
char *c89_headers[] = {
"assert.h",
"ctype.h",
@@ -46,6 +49,7 @@
NULL
};
+#define NUM_POSIX_HEADERS 14
char *posix_headers[] = {
"cpio.h",
"dirent.h",
@@ -64,6 +68,14 @@
NULL
};
+#define NUM_WIN_HEADERS 3
+char *win_headers[] = {
+ "io.h",
+ "windows.h",
+ "process.h",
+ NULL
+};
+
chaz_bool_t
chaz_Headers_check(const char *header_name)
{
@@ -76,53 +88,80 @@
int i;
chaz_bool_t has_posix = false;
chaz_bool_t has_c89 = false;
+
+ keeper_count = 0;
START_RUN("Headers");
- /* test for all POSIX headers in one blast */
+ /* Try for all POSIX headers in one blast. */
if (check_many_headers((const char**)posix_headers)) {
has_posix = true;
- append_conf("#define %sHAS_POSIX\n", macro_prefix);
+ append_conf("#define CHY_HAS_POSIX\n");
for (i = 0; posix_headers[i] != NULL; i++) {
keep(posix_headers[i]);
}
}
+ /* Test one-at-a-time. */
+ else {
+ for (i = 0; posix_headers[i] != NULL; i++) {
+ if (check_header(posix_headers[i])) {
+ keep(posix_headers[i]);
+ }
+ }
+ }
/* test for all c89 headers in one blast */
if (check_many_headers((const char**)c89_headers)) {
has_c89 = true;
- append_conf("#define %sHAS_C89\n", macro_prefix);
- append_conf("#define %sHAS_C90\n", macro_prefix);
+ append_conf("#define CHY_HAS_C89\n");
+ append_conf("#define CHY_HAS_C90\n");
for (i = 0; c89_headers[i] != NULL; i++) {
keep(c89_headers[i]);
}
}
+ /* Test one-at-a-time. */
+ else {
+ for (i = 0; c89_headers[i] != NULL; i++) {
+ if (check_header(c89_headers[i])) {
+ keep(c89_headers[i]);
+ }
+ }
+ }
+
+ /* Test for all Windows headers in one blast */
+ if (check_many_headers((const char**)win_headers)) {
+ for (i = 0; win_headers[i] != NULL; i++) {
+ keep(win_headers[i]);
+ }
+ }
+ /* Test one-at-a-time. */
+ else {
+ for (i = 0; win_headers[i] != NULL; i++) {
+ if (check_header(win_headers[i])) {
+ keep(win_headers[i]);
+ }
+ }
+ }
/* append the config with every header detected so far */
for (i = 0; keepers[i] != NULL; i++) {
encode_affirmation(keepers[i]);
- append_conf("#define %s%s\n", macro_prefix, aff_buf);
+ append_conf("#define CHY_%s\n", aff_buf);
}
/* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
-
- if (has_posix)
- shorten_macro("HAS_POSIX");
-
- if (has_c89) {
- shorten_macro("HAS_C89");
- shorten_macro("HAS_C90");
- }
-
- for (i = 0; keepers[i] != NULL; i++) {
- encode_affirmation(keepers[i]);
- shorten_macro(aff_buf);
- }
-
- END_SHORT_NAMES;
+ START_SHORT_NAMES;
+ if (has_posix)
+ shorten_macro("HAS_POSIX");
+ if (has_c89) {
+ shorten_macro("HAS_C89");
+ shorten_macro("HAS_C90");
+ }
+ for (i = 0; keepers[i] != NULL; i++) {
+ encode_affirmation(keepers[i]);
+ shorten_macro(aff_buf);
}
+ END_SHORT_NAMES;
END_RUN;
}
@@ -139,14 +178,14 @@
static void
encode_affirmation(const char *header_name) {
char *buf, *buf_end;
- size_t len = strlen(header_name) + 5;
+ size_t len = strlen(header_name) + sizeof("HAS_");
/* grow buffer and start off with "HAS_" */
aff_buf_size = grow_buf(&aff_buf, aff_buf_size, len);
strcpy(aff_buf, "HAS_");
/* transform one char at a time */
- for(buf = aff_buf + 4, buf_end = aff_buf + len;
+ for(buf = aff_buf + sizeof("HAS_") - 1, buf_end = aff_buf + len;
buf < buf_end;
header_name++, buf++
) {
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/Integers.charm Thu Sep 4 21:09:09 2008
@@ -82,9 +82,9 @@
/* document endian-ness */
if (machine_is_big_endian())
- append_conf("#define %sBIG_END\n", macro_prefix);
+ append_conf("#define CHY_BIG_END\n");
else
- append_conf("#define %sLITTLE_END\n", macro_prefix);
+ append_conf("#define CHY_LITTLE_END\n");
/* Record sizeof() for several common integer types. */
output = capture_output(sizes_code, strlen(sizes_code), &output_len);
@@ -188,99 +188,66 @@
/* write out some conditional defines */
if (has_inttypes)
- append_conf("#define %sHAS_INTTYPES_H\n", macro_prefix);
+ append_conf("#define CHY_HAS_INTTYPES_H\n");
if (has_long_long)
- append_conf("#define %sHAS_LONG_LONG\n", macro_prefix);
+ append_conf("#define CHY_HAS_LONG_LONG\n");
if (has___int64)
- append_conf("#define %sHAS___INT64\n", macro_prefix);
+ append_conf("#define CHY_HAS___INT64\n");
/* write out sizes */
- append_conf(
- "#define %sSIZEOF_CHAR %d\n"
- "#define %sSIZEOF_SHORT %d\n"
- "#define %sSIZEOF_INT %d\n"
- "#define %sSIZEOF_LONG %d\n"
- "#define %sSIZEOF_PTR %d\n",
- macro_prefix, sizeof_char,
- macro_prefix, sizeof_short,
- macro_prefix, sizeof_int,
- macro_prefix, sizeof_long,
- macro_prefix, sizeof_ptr
- );
+ append_conf("#define CHY_SIZEOF_CHAR %d\n", sizeof_char);
+ append_conf("#define CHY_SIZEOF_SHORT %d\n", sizeof_short);
+ append_conf("#define CHY_SIZEOF_INT %d\n", sizeof_int);
+ append_conf("#define CHY_SIZEOF_LONG %d\n", sizeof_long);
+ append_conf("#define CHY_SIZEOF_PTR %d\n", sizeof_ptr);
if (has_long_long) {
- append_conf("#define %sSIZEOF_LONG_LONG %d\n",
- macro_prefix, sizeof_long_long);
+ append_conf("#define CHY_SIZEOF_LONG_LONG %d\n", sizeof_long_long);
}
if (has___int64) {
- append_conf("#define %sSIZEOF___INT64 %d\n",
- macro_prefix, sizeof___int64);
+ append_conf("#define CHY_SIZEOF___INT64 %d\n", sizeof___int64);
}
/* write affirmations, typedefs and maximums/minimums */
- append_conf("typedef int %sbool_t;\n", typedef_prefix);
+ append_conf("typedef int chy_bool_t;\n");
if (has_8) {
append_conf(
- "#define %sHAS_I8_T\n"
- "typedef char %si8_t;\n"
- "typedef unsigned char %su8_t;\n",
- macro_prefix, typedef_prefix, typedef_prefix
- );
- append_conf(
- "#define %sI8_MAX 0x7F\n"
- "#define %sI8_MIN (-I8_MAX - 1)\n"
- "#define %sU8_MAX (I8_MAX * 2 + 1)\n",
- macro_prefix, macro_prefix, macro_prefix
+ "#define CHY_HAS_I8_T\n"
+ "typedef char chy_i8_t;\n"
+ "typedef unsigned char chy_u8_t;\n"
+ "#define CHY_I8_MAX 0x7F\n"
+ "#define CHY_I8_MIN (-I8_MAX - 1)\n"
+ "#define CHY_U8_MAX (I8_MAX * 2 + 1)\n"
);
}
if (has_16) {
append_conf(
- "#define %sHAS_I16_T\n"
- "typedef short %si16_t;\n"
- "typedef unsigned short %su16_t;\n",
- macro_prefix, typedef_prefix, typedef_prefix
- );
- append_conf(
- "#define %sI16_MAX 0x7FFF\n"
- "#define %sI16_MIN (-I16_MAX - 1)\n"
- "#define %sU16_MAX (I16_MAX * 2 + 1)\n",
- macro_prefix, macro_prefix, macro_prefix
+ "#define CHY_HAS_I16_T\n"
+ "typedef short chy_i16_t;\n"
+ "typedef unsigned short chy_u16_t;\n"
+ "#define CHY_I16_MAX 0x7FFF\n"
+ "#define CHY_I16_MIN (-I16_MAX - 1)\n"
+ "#define CHY_U16_MAX (I16_MAX * 2 + 1)\n"
);
}
if (has_32) {
- append_conf(
- "#define %sHAS_I32_T\n"
- "typedef %s %si32_t;\n"
- "typedef unsigned %s %su32_t;\n",
- macro_prefix,
- i32_t_type, typedef_prefix,
- i32_t_type, typedef_prefix
- );
- append_conf(
- "#define %sI32_MAX 0x7FFFFFFF%s\n"
- "#define %sI32_MIN (-I32_MAX - 1)\n"
- "#define %sU32_MAX (I32_MAX * 2%s + 1%s)\n",
- macro_prefix, i32_t_postfix,
- macro_prefix,
- macro_prefix, u32_t_postfix, u32_t_postfix
- );
+ append_conf("#define CHY_HAS_I32_T\n");
+ append_conf("typedef %s chy_i32_t;\n", i32_t_type);
+ append_conf("typedef unsigned %s chy_u32_t;\n", i32_t_type);
+ append_conf("#define CHY_I32_MAX 0x7FFFFFFF%s\n", i32_t_postfix);
+ append_conf("#define CHY_I32_MIN (-I32_MAX - 1)\n");
+ append_conf("#define CHY_U32_MAX (I32_MAX * 2%s + 1%s)\n",
+ u32_t_postfix, u32_t_postfix);
}
if (has_64) {
- append_conf(
- "#define %sHAS_I64_T\n"
- "typedef %s %si64_t;\n"
- "typedef unsigned %s %su64_t;\n",
- macro_prefix,
- i64_t_type, typedef_prefix,
- i64_t_type, typedef_prefix
- );
- append_conf(
- "#define %sI64_MAX 0x7FFFFFFFFFFFFFFF%s\n"
- "#define %sI64_MIN (-I64_MAX - 1%s)\n"
- "#define %sU64_MAX (I64_MAX * 2%s + 1%s)\n",
- macro_prefix, i64_t_postfix,
- macro_prefix, i64_t_postfix,
- macro_prefix, u64_t_postfix, u64_t_postfix
- );
+ append_conf("#define CHY_HAS_I64_T\n");
+ append_conf("typedef %s chy_i64_t;\n", i64_t_type);
+ append_conf("typedef unsigned %s chy_u64_t;\n", i64_t_type);
+ append_conf("#define CHY_I64_MAX 0x7FFFFFFFFFFFFFFF%s\n",
+ i64_t_postfix);
+ append_conf("#define CHY_I64_MIN (-I64_MAX - 1%s)\n",
+ i64_t_postfix);
+ append_conf("#define CHY_U64_MAX (I64_MAX * 2%s + 1%s)\n",
+ u64_t_postfix, u64_t_postfix);
}
/* create the I64P and U64P printf macros */
@@ -320,12 +287,8 @@
if ( output_len != 0
&& strcmp(output, "18446744073709551615") == 0
) {
- append_conf(
- "#define %sI64P \"%sd\"\n"
- "#define %sU64P \"%su\"\n",
- macro_prefix, options[i],
- macro_prefix, options[i]
- );
+ append_conf("#define CHY_I64P \"%sd\"\n", options[i]);
+ append_conf("#define CHY_U64P \"%su\"\n", options[i]);
break;
}
}
@@ -335,29 +298,17 @@
/* write out the 32-bit and 64-bit literal macros */
if (has_32) {
if (strcmp(i32_t_postfix, "") == 0) {
- append_conf(
- "#define %sI32_C(n) n\n"
- "#define %sU32_C(n) n##%s\n",
- macro_prefix,
- macro_prefix, u32_t_postfix
- );
+ append_conf("#define CHY_I32_C(n) n\n");
+ append_conf("#define CHY_U32_C(n) n##%s\n", u32_t_postfix);
}
else {
- append_conf(
- "#define %sI32_C(n) n##%s\n"
- "#define %sU32_C(n) n##%s\n",
- macro_prefix, i32_t_postfix,
- macro_prefix, u32_t_postfix
- );
+ append_conf("#define CHY_I32_C(n) n##%s\n", i32_t_postfix);
+ append_conf("#define CHY_U32_C(n) n##%s\n", u32_t_postfix);
}
}
if (has_64) {
- append_conf(
- "#define %sI64_C(n) n##%s\n"
- "#define %sU64_C(n) n##%s\n",
- macro_prefix, i64_t_postfix,
- macro_prefix, u64_t_postfix
- );
+ append_conf("#define CHY_I64_C(n) n##%s\n", i64_t_postfix);
+ append_conf("#define CHY_U64_C(n) n##%s\n", u64_t_postfix);
}
/* true and false */
@@ -371,76 +322,68 @@
);
/* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
-
- if (machine_is_big_endian())
- shorten_macro("BIG_END");
- else
- shorten_macro("LITTLE_END");
-
- shorten_macro("SIZEOF_CHAR");
- shorten_macro("SIZEOF_SHORT");
- shorten_macro("SIZEOF_LONG");
- shorten_macro("SIZEOF_INT");
- shorten_macro("SIZEOF_PTR");
-
- if (has_long_long) {
- shorten_macro("HAS_LONG_LONG");
- shorten_macro("SIZEOF_LONG_LONG");
- }
- if (has___int64) {
- shorten_macro("HAS___INT64");
- shorten_macro("SIZEOF___INT64");
- }
-
- if (has_inttypes)
- shorten_macro("HAS_INTTYPES_H");
-
- shorten_typedef("bool_t");
-
- if (has_8) {
- shorten_macro("HAS_I8_T");
- shorten_typedef("i8_t");
- shorten_typedef("u8_t");
- shorten_macro("I8_MAX");
- shorten_macro("I8_MIN");
- shorten_macro("U8_MAX");
- }
- if (has_16) {
- shorten_macro("HAS_I16_T");
- shorten_typedef("i16_t");
- shorten_typedef("u16_t");
- shorten_macro("I16_MAX");
- shorten_macro("I16_MIN");
- shorten_macro("U16_MAX");
- }
- if (has_32) {
- shorten_macro("HAS_I32_T");
- shorten_typedef("i32_t");
- shorten_typedef("u32_t");
- shorten_macro("I32_MAX");
- shorten_macro("I32_MIN");
- shorten_macro("U32_MAX");
- shorten_macro("I32_C");
- shorten_macro("U32_C");
- }
-
- if (has_64) {
- shorten_macro("HAS_I64_T");
- shorten_typedef("i64_t");
- shorten_typedef("u64_t");
- shorten_macro("I64_MAX");
- shorten_macro("I64_MIN");
- shorten_macro("U64_MAX");
- shorten_macro("I64P");
- shorten_macro("U64P");
- shorten_macro("I64_C");
- shorten_macro("U64_C");
- }
-
- END_SHORT_NAMES;
+ START_SHORT_NAMES;
+ if ( machine_is_big_endian() ) {
+ shorten_macro("BIG_END");
+ }
+ else {
+ shorten_macro("LITTLE_END");
+ }
+ shorten_macro("SIZEOF_CHAR");
+ shorten_macro("SIZEOF_SHORT");
+ shorten_macro("SIZEOF_LONG");
+ shorten_macro("SIZEOF_INT");
+ shorten_macro("SIZEOF_PTR");
+ if (has_long_long) {
+ shorten_macro("HAS_LONG_LONG");
+ shorten_macro("SIZEOF_LONG_LONG");
}
+ if (has___int64) {
+ shorten_macro("HAS___INT64");
+ shorten_macro("SIZEOF___INT64");
+ }
+ if (has_inttypes)
+ shorten_macro("HAS_INTTYPES_H");
+ shorten_typedef("bool_t");
+ if (has_8) {
+ shorten_macro("HAS_I8_T");
+ shorten_typedef("i8_t");
+ shorten_typedef("u8_t");
+ shorten_macro("I8_MAX");
+ shorten_macro("I8_MIN");
+ shorten_macro("U8_MAX");
+ }
+ if (has_16) {
+ shorten_macro("HAS_I16_T");
+ shorten_typedef("i16_t");
+ shorten_typedef("u16_t");
+ shorten_macro("I16_MAX");
+ shorten_macro("I16_MIN");
+ shorten_macro("U16_MAX");
+ }
+ if (has_32) {
+ shorten_macro("HAS_I32_T");
+ shorten_typedef("i32_t");
+ shorten_typedef("u32_t");
+ shorten_macro("I32_MAX");
+ shorten_macro("I32_MIN");
+ shorten_macro("U32_MAX");
+ shorten_macro("I32_C");
+ shorten_macro("U32_C");
+ }
+ if (has_64) {
+ shorten_macro("HAS_I64_T");
+ shorten_typedef("i64_t");
+ shorten_typedef("u64_t");
+ shorten_macro("I64_MAX");
+ shorten_macro("I64_MIN");
+ shorten_macro("U64_MAX");
+ shorten_macro("I64P");
+ shorten_macro("U64P");
+ shorten_macro("I64_C");
+ shorten_macro("U64_C");
+ }
+ END_SHORT_NAMES;
END_RUN;
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.charm Thu Sep 4 21:09:09 2008
@@ -13,17 +13,25 @@
/* sets of symbols which might provide large file support */
typedef struct off64_combo {
const char *includes;
+ const char *fopen_command;
const char *ftell_command;
const char *fseek_command;
const char *offset64_type;
} off64_combo;
static off64_combo off64_combos[] = {
- { "#include <sys/types.h>\n", "ftello64", "fseeko64", "off64_t" },
- { "#include <sys/types.h>\n", "ftello", "fseeko", "off_t" },
- { "", "ftell","fseek", "long" },
- { "", "_ftelli64","_fseeki64", "__int64" },
- { NULL, NULL, NULL, NULL }
+ { "#include <sys/types.h>\n", "fopen64", "ftello64", "fseeko64", "off64_t" },
+ { "#include <sys/types.h>\n", "fopen", "ftello64", "fseeko64", "off64_t" },
+ { "#include <sys/types.h>\n", "fopen", "ftello", "fseeko", "off_t" },
+ { "", "fopen", "ftell", "fseek", "long" },
+ { "", "fopen", "_ftelli64", "_fseeki64", "__int64" },
+ { NULL, NULL, NULL, NULL, NULL }
};
+typedef struct unbuff_combo {
+ const char *includes;
+ const char *open_command;
+ const char *tell_command;
+ const char *seek_command;
+} unbuff_combo;
/* Check what name 64-bit ftell, fseek go by.
*/
@@ -50,6 +58,7 @@
static size_t code_buf_len = 0;
/* vars for holding lfs commands, once they're discovered */
+static char fopen_command[10];
static char fseek_command[10];
static char ftell_command[10];
static char off64_type[10];
@@ -67,6 +76,7 @@
off64_combo combo = off64_combos[i];
success = probe_off64(&combo);
if (success) {
+ strcpy(fopen_command, combo.fopen_command);
strcpy(fseek_command, combo.fseek_command);
strcpy(ftell_command, combo.ftell_command);
strcpy(off64_type, combo.offset64_type);
@@ -76,17 +86,13 @@
/* write the affirmations/definitions */
if (success) {
- append_conf("#define %sHAS_LARGE_FILE_SUPPORT\n", macro_prefix );
+ append_conf("#define CHY_HAS_LARGE_FILE_SUPPORT\n");
/* alias these only if they're not already provided and correct */
if (strcmp(off64_type, "off64_t") != 0) {
- append_conf(
- "#define %soff64_t %s\n"
- "#define %sftello64 %s\n"
- "#define %sfseeko64 %s\n",
- macro_prefix, off64_type,
- function_prefix, ftell_command,
- function_prefix, fseek_command
- );
+ append_conf("#define chy_off64_t %s\n", off64_type);
+ append_conf("#define chy_fopen64 %s\n", fopen_command);
+ append_conf("#define chy_ftello64 %s\n", ftell_command);
+ append_conf("#define chy_fseeko64 %s\n", fseek_command);
}
}
@@ -101,14 +107,20 @@
append_conf("#define CHAZ_NO_SPARSE_FILES\n");
}
+ /* test for unbuffered LFS commands */
+ if (success) {
+
+ }
+
/* short names */
- if (want_short_names && success) {
+ if (success) {
START_SHORT_NAMES;
shorten_macro("HAS_LARGE_FILE_SUPPORT");
/* alias these only if they're not already provided and correct */
if (strcmp(off64_type, "off64_t") != 0) {
- shorten_macro("off64_t");
+ shorten_typedef("off64_t");
+ shorten_function("fopen64");
shorten_function("ftello64");
shorten_function("fseeko64");
}
@@ -124,10 +136,13 @@
%s
#include "_charm.h"
int main() {
- %s foo;
+ %s pos;
+ FILE *f;
Charm_Setup;
+ f = %s("_charm_off64", "w");
+ if (f == -1) exit(-1);
printf("%%d", (int)sizeof(%s));
- foo = %s(stdout);
+ pos = %s(stdout);
%s(stdout, 0, SEEK_SET);
return 0;
}
@@ -140,7 +155,8 @@
char *output = NULL;
size_t output_len;
size_t needed = sizeof(off64_code) + (2 * strlen(combo->offset64_type))
- + strlen(combo->ftell_command) + strlen(combo->fseek_command) + 20;
+ +strlen(combo->fopen_command) + strlen(combo->ftell_command)
+ + strlen(combo->fseek_command) + 20;
chaz_bool_t success = false;
/* allocate buffer as necessary and prepare the source code */
@@ -149,7 +165,8 @@
code_buf_len = needed;
}
sprintf(code_buf, off64_code, combo->includes, combo->offset64_type,
- combo->offset64_type, combo->ftell_command, combo->fseek_command);
+ combo->fopen_command, combo->offset64_type, combo->ftell_command,
+ combo->fseek_command);
/* verify compilation and that the offset type has 8 bytes */
output = capture_output(code_buf, strlen(code_buf),
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.harm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.harm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.harm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/LargeFiles.harm Thu Sep 4 21:09:09 2008
@@ -10,6 +10,7 @@
* synonyms:
*
* off64_t
+ * fopen64
* ftello64
* fseeko64
*
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/UnusedVars.charm Thu Sep 4 21:09:09 2008
@@ -13,19 +13,14 @@
START_RUN("UnusedVars");
/* write the macros (no test, these are the same everywhere) */
- append_conf(
- "#define %sUNUSED_VAR(x) ((void)x)\n"
- "#define %sUNREACHABLE_RETURN(type) return (type)0\n",
- macro_prefix, macro_prefix
- );
+ append_conf("#define CHY_UNUSED_VAR(x) ((void)x)\n");
+ append_conf("#define CHY_UNREACHABLE_RETURN(type) return (type)0\n");
/* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
- shorten_macro("UNUSED_VAR");
- shorten_macro("UNREACHABLE_RETURN");
- END_SHORT_NAMES;
- }
+ START_SHORT_NAMES;
+ shorten_macro("UNUSED_VAR");
+ shorten_macro("UNREACHABLE_RETURN");
+ END_SHORT_NAMES;
END_RUN;
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Probe/VariadicMacros.charm Thu Sep 4 21:09:09 2008
@@ -47,10 +47,8 @@
if (output != NULL) {
has_varmacros = true;
has_iso_varmacros = true;
- append_conf("#define %sHAS_VARIADIC_MACROS\n",
- macro_prefix);
- append_conf("#define %sHAS_ISO_VARIADIC_MACROS\n",
- macro_prefix);
+ append_conf("#define CHY_HAS_VARIADIC_MACROS\n");
+ append_conf("#define CHY_HAS_ISO_VARIADIC_MACROS\n");
}
/* test for GNU-style variadic macros */
@@ -59,24 +57,20 @@
has_gnuc_varmacros = true;
if (has_varmacros == false) {
has_varmacros = true;
- append_conf("#define %sHAS_VARIADIC_MACROS\n",
- macro_prefix);
+ append_conf("#define CHY_HAS_VARIADIC_MACROS\n");
}
- append_conf("#define %sHAS_GNUC_VARIADIC_MACROS\n",
- macro_prefix);
+ append_conf("#define CHY_HAS_GNUC_VARIADIC_MACROS\n");
}
/* shorten */
- if (want_short_names) {
- START_SHORT_NAMES;
- if (has_varmacros)
- shorten_macro("HAS_VARIADIC_MACROS");
- if (has_iso_varmacros)
- shorten_macro("HAS_ISO_VARIADIC_MACROS");
- if (has_gnuc_varmacros)
- shorten_macro("HAS_GNUC_VARIADIC_MACROS");
- END_SHORT_NAMES;
- }
+ START_SHORT_NAMES;
+ if (has_varmacros)
+ shorten_macro("HAS_VARIADIC_MACROS");
+ if (has_iso_varmacros)
+ shorten_macro("HAS_ISO_VARIADIC_MACROS");
+ if (has_gnuc_varmacros)
+ shorten_macro("HAS_GNUC_VARIADIC_MACROS");
+ END_SHORT_NAMES;
END_RUN;
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/FuncMacro.charm Thu Sep 4 21:09:09 2008
@@ -8,9 +8,16 @@
TestBatch*
chaz_TFuncMacro_prepare()
{
- return Test_new_batch("FuncMacro", 3, chaz_TFuncMacro_run);
+ return Test_new_batch("FuncMacro", 4, chaz_TFuncMacro_run);
}
+#ifdef INLINE
+static INLINE char* inline_function()
+{
+ return "inline works";
+}
+#endif
+
void
chaz_TFuncMacro_run(TestBatch *batch)
{
@@ -18,16 +25,28 @@
#ifdef HAS_FUNC_MACRO
ASSERT_STR_EQ(batch, FUNC_MACRO, "chaz_TFuncMacro_run",
"FUNC_MACRO");
+#else
+ SKIP(batch, "no FUNC_MACRO");
#endif
#ifdef HAS_ISO_FUNC_MACRO
ASSERT_STR_EQ(batch, __func__, "chaz_TFuncMacro_run",
"HAS_ISO_FUNC_MACRO");
+#else
+ SKIP(batch, "no ISO_FUNC_MACRO");
#endif
#ifdef HAS_GNUC_FUNC_MACRO
ASSERT_STR_EQ(batch, __FUNCTION__, "chaz_TFuncMacro_run",
"HAS_GNUC_FUNC_MACRO");
+#else
+ SKIP(batch, "no GNUC_FUNC_MACRO");
+#endif
+
+#ifdef INLINE
+ PASS(batch, inline_function());
+#else
+ SKIP(batch, "no INLINE functions");
#endif
}
Modified: lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm?rev=692332&r1=692331&r2=692332&view=diff
==============================================================================
--- lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm (original)
+++ lucene/lucy/trunk/charmonizer/src/Charmonizer/Test/LargeFiles.charm Thu Sep 4 21:09:09 2008
@@ -28,8 +28,8 @@
off64_t gb4_plus = ((off64_t)0x7FFFFFFF << 1) + 100;
off64_t gb2_plus = (off64_t)0x7FFFFFFF + 200;
- /* gb4_plus modulo 4 GB */
- i32_t wrap_gb4 = gb4_plus;
+ /* gb4_plus modulo 4 GB (wrap is intentional) */
+ i32_t wrap_gb4 = (i32_t)gb4_plus;
ASSERT_INT_EQ(batch, sizeof(off64_t), 8, "off64_t type has 8 bytes");
@@ -43,7 +43,7 @@
SKIP_REMAINING(batch, "Unsafe to create 5GB sparse files on this system");
#endif
- fh = fopen("_charm_large_file_test", "w+");
+ fh = fopen64("_charm_large_file_test", "w+");
if (fh == NULL)
SKIP_REMAINING(batch, "Failed to open file");
@@ -51,7 +51,7 @@
ASSERT_INT_EQ(batch, check_val, 0, "fseeko64 above 4 GB");
offset = ftello64(fh);
- ASSERT_TRUE(batch, (offset = gb4_plus), "ftello64 above 4 GB");
+ ASSERT_TRUE(batch, (offset == gb4_plus), "ftello64 above 4 GB");
check_val = fprintf(fh, "X");
ASSERT_INT_EQ(batch, check_val, 1, "print above 4 GB");
@@ -60,7 +60,7 @@
ASSERT_INT_EQ(batch, check_val, 0, "fseeko64 above 2 GB");
offset = ftello64(fh);
- ASSERT_TRUE(batch, (offset = gb2_plus), "ftello64 above 2 GB");
+ ASSERT_TRUE(batch, (offset == gb2_plus), "ftello64 above 2 GB");
check_val = fseeko64(fh, -1, SEEK_END);
ASSERT_INT_EQ(batch, check_val, 0, "seek to near end");
@@ -76,7 +76,7 @@
ASSERT_INT_EQ(batch, check_val, 0, "fclose succeeds after all that");
/* truncate, just in case the call to remove fails */
- fh = fopen("_charm_large_file_test", "w+");
+ fh = fopen64("_charm_large_file_test", "w+");
if (fh != NULL)
fclose(fh);
remove("_charm_large_file_test");