diff --git a/glslang/MachineIndependent/Makefile b/glslang/MachineIndependent/Makefile index 40ba7eea..3f1137a9 100644 --- a/glslang/MachineIndependent/Makefile +++ b/glslang/MachineIndependent/Makefile @@ -72,7 +72,7 @@ depend: # .PHONY : clean clean : - $(RM) *.o *.a gen_glslang_tab.cpp gen_glslang.cpp glslang_tab.h glslang.output + $(RM) *.o *.a gen_glslang_tab.cpp glslang_tab.cpp glslang_tab.cpp.h gen_glslang.cpp glslang_tab.h glslang.output $(RM) ./lib/*.so cd $(INCPREPROCESSOR); make clean cd $(INCCODEGEN); make clean diff --git a/glslang/MachineIndependent/glslang.l b/glslang/MachineIndependent/glslang.l index d2a80d1e..061062b5 100644 --- a/glslang/MachineIndependent/glslang.l +++ b/glslang/MachineIndependent/glslang.l @@ -643,11 +643,11 @@ void CPPShInfoLogMsg(const char *msg) GlobalParseContext->recover(); } -void CPPErrorToInfoLog(char *msg) +void CPPErrorToInfoLog(const char *msg) { TParseContext& pc = *((TParseContext *)cpp->pC); - pc.error(yylineno, "CPP error:", "",msg,""); + pc.error(yylineno, "CPP error:", "", msg, ""); GlobalParseContext->recover(); } @@ -770,7 +770,7 @@ void HandlePragma(const char **tokens, int numTokens) } } -void StoreStr(char *string) +void StoreStr(const char *string) { TParseContext& pc = *((TParseContext *)cpp->pC); diff --git a/glslang/MachineIndependent/preprocessor/Makefile b/glslang/MachineIndependent/preprocessor/Makefile index b6402ce7..1219cc0c 100644 --- a/glslang/MachineIndependent/preprocessor/Makefile +++ b/glslang/MachineIndependent/preprocessor/Makefile @@ -1,4 +1,7 @@ -CC = gcc +INCLUDE = -I../ +CC = g++ + +CPPFLAGS=$(DEFINE) $(INCLUDE) OBJECTS = atom.o cpp.o cppstruct.o memory.o scanner.o symbols.o tokens.o AR=ar @@ -11,7 +14,7 @@ libPreprocessor.a : $(OBJECTS) ranlib $@ %.o : %.c - $(CC) -c $< + $(CC) $(CPPFLAGS) -c $< # # Cleanup diff --git a/glslang/MachineIndependent/preprocessor/atom.c b/glslang/MachineIndependent/preprocessor/atom.c index 94824789..3c9642c6 100644 --- a/glslang/MachineIndependent/preprocessor/atom.c +++ b/glslang/MachineIndependent/preprocessor/atom.c @@ -357,11 +357,11 @@ static int GrowAtomTable(AtomTable *atable, int size) if (atable->size < size) { if (atable->amap) { - newmap = realloc(atable->amap, sizeof(int)*size); - newrev = realloc(atable->arev, sizeof(int)*size); + newmap = (int*)realloc(atable->amap, sizeof(int)*size); + newrev = (int*)realloc(atable->arev, sizeof(int)*size); } else { - newmap = malloc(sizeof(int)*size); - newrev = malloc(sizeof(int)*size); + newmap = (int*)malloc(sizeof(int)*size); + newrev = (int*)malloc(sizeof(int)*size); atable->size = 0; } if (!newmap || !newrev) { diff --git a/glslang/MachineIndependent/preprocessor/cpp.c b/glslang/MachineIndependent/preprocessor/cpp.c index 87687647..b59752b8 100644 --- a/glslang/MachineIndependent/preprocessor/cpp.c +++ b/glslang/MachineIndependent/preprocessor/cpp.c @@ -218,7 +218,7 @@ static int CPPdefine(yystypepp * yylvalpp) return token; } mac.argc = argc; - mac.args = mem_Alloc(macros->pool, argc * sizeof(int)); + mac.args = (int*)mem_Alloc(macros->pool, argc * sizeof(int)); memcpy(mac.args, args, argc * sizeof(int)); token = cpp->currentInput->scan(cpp->currentInput, yylvalpp); } @@ -392,7 +392,7 @@ static int op_neg(int a) { return -a; } static int op_cmpl(int a) { return ~a; } static int op_not(int a) { return !a; } -struct { +struct Tbinops { int token, prec, (*op)(int, int); } binop[] = { { CPP_OR_OP, LOGOR, op_logor }, @@ -415,7 +415,7 @@ struct { { '%', MUL, op_mod }, }; -struct { +struct tunops { int token, (*op)(int); } unop[] = { { '+', op_pos }, @@ -853,7 +853,7 @@ static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; } static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { } static void PushEofSrc() { - InputSrc *in = malloc(sizeof(InputSrc)); + InputSrc *in = (InputSrc*)malloc(sizeof(InputSrc)); memset(in, 0, sizeof(InputSrc)); in->scan = eof_scan; in->getch = eof_scan; @@ -902,7 +902,9 @@ typedef struct MacroInputSrc { /* macro_scan --- ** return the next token for a macro expanion, handling macro args */ -static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) { +static int macro_scan(InputSrc *inInput, yystypepp * yylvalpp) { + MacroInputSrc* in = (MacroInputSrc*)inInput; + int i; int token = ReadToken(in->mac->body, yylvalpp); if (token == CPP_IDENTIFIER) { @@ -957,9 +959,9 @@ int MacroExpand(int atom, yystypepp * yylvalpp) } if (!sym || sym->details.mac.undef) return 0; if (sym->details.mac.busy) return 0; // no recursive expansions - in = malloc(sizeof(*in)); + in = (MacroInputSrc*)malloc(sizeof(*in)); memset(in, 0, sizeof(*in)); - in->base.scan = (void *)macro_scan; + in->base.scan = macro_scan; in->base.line = cpp->currentInput->line; in->base.name = cpp->currentInput->name; in->mac = &sym->details.mac; @@ -970,7 +972,7 @@ int MacroExpand(int atom, yystypepp * yylvalpp) yylvalpp->sc_ident = atom; return 0; } - in->args = malloc(in->mac->argc * sizeof(TokenStream *)); + in->args = (TokenStream**)malloc(in->mac->argc * sizeof(TokenStream *)); for (i=0; imac->argc; i++) in->args[i] = NewTokenStream("macro arg", 0); i=0;j=0; diff --git a/glslang/MachineIndependent/preprocessor/cpp.h b/glslang/MachineIndependent/preprocessor/cpp.h index f7195cda..2995892f 100644 --- a/glslang/MachineIndependent/preprocessor/cpp.h +++ b/glslang/MachineIndependent/preprocessor/cpp.h @@ -107,8 +107,7 @@ void CPPShInfoLogMsg(const char*); // Store cpp Err Msg into Sh.Info.Lo void CPPWarningToInfoLog(const char *msg); // Prints warning messages into info log void HandlePragma(const char**, int numTokens); // #pragma directive container. void ResetTString(void); // #error Message as TString. -void CPPErrorToInfoLog(char*); // Stick all cpp errors into Sh.Info.log . -void StoreStr(char*); // Store the TString in Parse Context. +void StoreStr(const char*); // Store the TString in Parse Context. void SetLineNumber(int); // Set line number. void SetStringNumber(int); // Set string number. int GetLineNumber(void); // Get the current String Number. diff --git a/glslang/MachineIndependent/preprocessor/memory.c b/glslang/MachineIndependent/preprocessor/memory.c index 74e20ff0..36022bd0 100644 --- a/glslang/MachineIndependent/preprocessor/memory.c +++ b/glslang/MachineIndependent/preprocessor/memory.c @@ -124,7 +124,7 @@ MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align) if (align & (align-1)) return 0; if (chunksize < sizeof(MemoryPool)) return 0; if (chunksize & (align-1)) return 0; - if (!(pool = malloc(chunksize))) return 0; + if (!(pool = (MemoryPool*)malloc(chunksize))) return 0; pool->next = 0; pool->chunksize = chunksize; pool->alignmask = (uintptr_t)(align)-1; @@ -162,10 +162,10 @@ void *mem_Alloc(MemoryPool *pool, size_t size) if (minreq >= pool->chunksize) { // request size is too big for the chunksize, so allocate it as // a single chunk of the right size - ch = malloc(minreq); + ch = (struct chunk*)malloc(minreq); if (!ch) return 0; } else { - ch = malloc(pool->chunksize); + ch = (struct chunk*)malloc(pool->chunksize); if (!ch) return 0; pool->free = (uintptr_t)ch + minreq; pool->end = (uintptr_t)ch + pool->chunksize; @@ -181,7 +181,7 @@ int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) { struct cleanup *cleanup; pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1); - cleanup = mem_Alloc(pool, sizeof(struct cleanup)); + cleanup = (struct cleanup *)(mem_Alloc(pool, sizeof(struct cleanup))); if (!cleanup) return -1; cleanup->next = pool->cleanup; cleanup->fn = fn; diff --git a/glslang/MachineIndependent/preprocessor/scanner.h b/glslang/MachineIndependent/preprocessor/scanner.h index fb4d0574..c45c4d7b 100644 --- a/glslang/MachineIndependent/preprocessor/scanner.h +++ b/glslang/MachineIndependent/preprocessor/scanner.h @@ -105,14 +105,14 @@ typedef struct InputSrc { int line; } InputSrc; -int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner. -int ScanFromString(char *); // Start scanning the input from the string mentioned. -int check_EOF(int); // check if we hit a EOF abruptly -void CPPErrorToInfoLog(char *); // sticking the msg,line into the Shader's.Info.log +int InitScanner(CPPStruct *cpp); // Intialise the cpp scanner. +int ScanFromString(char *); // Start scanning the input from the string mentioned. +int check_EOF(int); // check if we hit a EOF abruptly +void CPPErrorToInfoLog(const char *); // sticking the msg,line into the Shader's.Info.log void SetLineNumber(int); void SetStringNumber(int); void IncLineNumber(void); void DecLineNumber(void); -int FreeScanner(void); // Free the cpp scanner +int FreeScanner(void); // Free the cpp scanner #endif // !(defined(__SCANNER_H) diff --git a/glslang/MachineIndependent/preprocessor/symbols.h b/glslang/MachineIndependent/preprocessor/symbols.h index 618418c7..3a4f6b3e 100644 --- a/glslang/MachineIndependent/preprocessor/symbols.h +++ b/glslang/MachineIndependent/preprocessor/symbols.h @@ -138,8 +138,6 @@ Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind); Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind); Symbol *LookUpLocalSymbol(Scope *fScope, int atom); Symbol *LookUpSymbol(Scope *fScope, int atom); -void CPPErrorToInfoLog(char *); - #endif // !defined(__SYMBOLS_H)