On Mon, Oct 6, 2014 at 5:34 PM, Bruce Cran <bruce@xxxxxxxxxxx> wrote: > On 10/6/2014 3:44 PM, Stephen Cameron wrote: >> >> I suspect that your version of yacc does not comprehend the --no-lines >> option (which we needed only in order to avoid a bug in some other >> versions of yacc). From the usage message it does appear to >> understand both -d and -l though. >> >> Try changing the --no-lines option in the Makefile to -l instead, and >> see if that helps. > > > The same problem occurs on FreeBSD 10. After changing "--no-lines" to "-l" > the build works, with the following warnings: > > YACC y.tab.c > CC lex.yy.o > lex.yy.c:1245:3: warning: incompatible pointer types passing 'yy_size_t *' > (aka 'unsigned long *') to parameter of type 'int *' > [-Wincompatible-pointer-types] > YY_INPUT( > (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > exp/expression-parser.l:31:25: note: expanded from macro 'YY_INPUT' > lexer_input((buffer), &(bytes_read), (bytes_requested)) > ^~~~~~~~~~~~~ > exp/expression-parser.l:27:43: note: passing argument to parameter 'nbytes' > here > extern int lexer_input(char* buffer, int *nbytes, int buffersize); > I think Jens mentioned seeing something similar on Mac OSX (which makes sense as it's a BSD derivative). I think it will work so long as sizeof(int) <= sizeof(unsigned long) and you're on a little endian architecture and the buffer is not ridiculously huge. I suspect on a big endian arch where sizeof(long) > sizeof(int), it would fail. Can you see if the attached patch fixes it? -- steve
From 5a76b7f44183c65afd7af9d578729965c3ba8e75 Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" <stephenmcameron@xxxxxxxxx> Date: Mon, 6 Oct 2014 17:58:32 -0500 Subject: [PATCH] fix problem with yy_size_t vs int param to lexer_input BSD yacc uses "int" for this param, linux uses size_t --- Makefile | 4 +++- exp/expression-parser.y | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d735ec7..424a112 100644 --- a/Makefile +++ b/Makefile @@ -268,7 +268,7 @@ override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"' ifdef CONFIG_ARITHMETIC lex.yy.c: exp/expression-parser.l - $(QUIET_LEX)$(LEX) exp/expression-parser.l + $(QUIET_LEX)$(LEX) --header-file=lexer.h exp/expression-parser.l lex.yy.o: lex.yy.c y.tab.h $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< @@ -281,6 +281,8 @@ y.tab.c: exp/expression-parser.y y.tab.h: y.tab.c +lexer.h: lex.yy.c + exp/test-expression-parser.o: exp/test-expression-parser.c $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $< exp/test-expression-parser: exp/test-expression-parser.o diff --git a/exp/expression-parser.y b/exp/expression-parser.y index e4373d4..83b5b30 100644 --- a/exp/expression-parser.y +++ b/exp/expression-parser.y @@ -21,6 +21,8 @@ #include <stdio.h> #include <string.h> #include <math.h> +#include "lexer.h" + struct parser_value_type { double dval; long long ival; @@ -186,7 +188,7 @@ expression: expression '+' expression { static int lexer_read_offset = 0; static char lexer_input_buffer[1000]; -int lexer_input(char* buffer, int *bytes_read, int bytes_requested) +int lexer_input(char* buffer, yy_size_t *bytes_read, int bytes_requested) { int bytes_left = strlen(lexer_input_buffer) - lexer_read_offset; -- 1.7.9.5