Commit 07838dfb authored by ffs Upstream's avatar ffs Upstream Committed by Kyle Edwards
Browse files

ffs 2020-01-23 (089c5b6a)

Code extracted from:

    https://github.com/GTkorvo/ffs.git

at commit 089c5b6ac974bc918c39dce461a7db0ef8492d09 (master).

Upstream Shortlog
-----------------

Greg Eisenhauer (4):
      7774ca6c Add License
      285c5f4f clean up size_t warning
      03fa846f Fix wrong struct usage
      099b3b3d Update pre-generated Bison and Flex output

Kyle Edwards (1):
      afc6c9df Suppress race condition warning in ffs_conv.c
parent 5bff7919
Copyright (c) 2010, Georgia Tech Research Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Georgia Tech Research Corporation nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY GEORGIA TECH RESEARCH CORPORATION ''AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL GEORGIA TECH BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
......@@ -1789,7 +1789,7 @@ iteration_statement:
FOR LPAREN expression_opt SEMI expression_opt SEMI expression_opt RPAREN statement
{
$$ = cod_new_iteration_statement();
$$->node.selection_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.init_expr = $3;
$$->node.iteration_statement.test_expr = $5;
$$->node.iteration_statement.iter_expr = $7;
......@@ -1799,7 +1799,7 @@ iteration_statement:
WHILE LPAREN expression RPAREN statement
{
$$ = cod_new_iteration_statement();
$$->node.selection_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.init_expr = NULL;
$$->node.iteration_statement.test_expr = $3;
$$->node.iteration_statement.iter_expr = NULL;
......@@ -1809,7 +1809,7 @@ iteration_statement:
DO statement WHILE LPAREN expression RPAREN SEMI
{
$$ = cod_new_iteration_statement();
$$->node.selection_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.lx_srcpos = $1.lx_srcpos;
$$->node.iteration_statement.init_expr = NULL;
$$->node.iteration_statement.test_expr = NULL;
$$->node.iteration_statement.post_test_expr = $5;
......
......@@ -195,7 +195,7 @@ return {RETURN(RETURN_TOKEN);}
\" {
buffer_len = 20;
string_buffer = malloc(20);
string_buffer = malloc(20 + 1);
string_buf_ptr = string_buffer; BEGIN(string_cond);
}
......@@ -332,7 +332,7 @@ static void check_strbuf()
int cur_len = string_buf_ptr - string_buffer;
if ((cur_len + 1) == buffer_len) {
buffer_len += 20;
string_buffer = realloc(string_buffer, buffer_len);
string_buffer = realloc(string_buffer, buffer_len + 1);
string_buf_ptr = string_buffer + cur_len;
}
}
......
This diff is collapsed.
......@@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_USERS_EISEN_PROG_KORVO_BUILD_BUILD_AREA_FFS_DARWIN10_13_COD_TAB_H_INCLUDED
# define YY_YY_USERS_EISEN_PROG_KORVO_BUILD_BUILD_AREA_FFS_DARWIN10_13_COD_TAB_H_INCLUDED
#ifndef YY_YY_HOME_EISEN_PROG_GTKORVO_BUILD_AREA_FFS_UB18_64_COD_TAB_H_INCLUDED
# define YY_YY_HOME_EISEN_PROG_GTKORVO_BUILD_AREA_FFS_UB18_64_COD_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
......@@ -143,7 +143,7 @@ union YYSTYPE
sm_list list;
char *string;
#line 147 "/Users/eisen/prog/korvo_build/build_area/ffs/darwin10.13/cod.tab.h" /* yacc.c:1909 */
#line 147 "/home/eisen/prog/GTkorvo/build_area/ffs/ub18-64/cod.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
......@@ -156,4 +156,4 @@ extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_USERS_EISEN_PROG_KORVO_BUILD_BUILD_AREA_FFS_DARWIN10_13_COD_TAB_H_INCLUDED */
#endif /* !YY_YY_HOME_EISEN_PROG_GTKORVO_BUILD_AREA_FFS_UB18_64_COD_TAB_H_INCLUDED */
......@@ -4915,7 +4915,7 @@ possibly_set_sizes_to_match(cod_parse_context context, sm_ref decl, sm_ref init_
(init_value->node.constant.token == string_constant)) {
/* init value is a string, set the array size to strlen + 1 */
sm_ref size_expr = cod_new_constant();
char *str = malloc(20); /* plenty */
char *str = malloc(40); /* plenty */
size_expr->node.constant.token = integer_constant;
sprintf(str, "%ld\n", (long) strlen(init_value->node.constant.const_val) + 1);
size_expr->node.constant.const_val = str;
......@@ -4934,7 +4934,7 @@ possibly_set_sizes_to_match(cod_parse_context context, sm_ref decl, sm_ref init_
items = items->next;
}
sm_ref size_expr = cod_new_constant();
char *str = malloc(20); /* plenty */
char *str = malloc(40); /* plenty */
size_expr->node.constant.token = integer_constant;
sprintf(str, "%ld\n", size);
size_expr->node.constant.const_val = str;
......
......@@ -36,6 +36,16 @@
#endif
#include "assert.h"
#ifdef __has_feature
#if __has_feature(thread_sanitizer)
#define NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
#endif
#endif
#ifndef NO_SANITIZE_THREAD
#define NO_SANITIZE_THREAD
#endif
static MAX_INTEGER_TYPE get_big_int(FMFieldPtr iofield, void *data);
static MAX_FLOAT_TYPE get_big_float(FMFieldPtr iofield, void *data);
static MAX_UNSIGNED_TYPE get_big_unsigned(FMFieldPtr iofield, void *data);
......@@ -891,7 +901,13 @@ get_static_array_element_count(FMVarInfoList var)
return count;
}
static int debug_code_generation = -1;
static int _debug_code_generation = -1;
static inline int NO_SANITIZE_THREAD debug_code_generation(void)
{
return _debug_code_generation;
}
typedef struct conv_status {
void *src;
void *dest;
......@@ -1166,7 +1182,7 @@ void *src_string_base;
}
if (conv->conv_func) {
struct run_time_conv_status rtcs;
if (debug_code_generation) {
if (debug_code_generation()) {
int i;
int limit = 30;
int *tmp = (int *) (((char *) src_string_base) -
......@@ -1991,8 +2007,18 @@ IOConversionPtr conv;
extern void
new_generate_conversion_code(dill_stream c, ConvStatus conv_status, IOConversionPtr conv, dill_reg *args, int assume_align, int register_args);
static int ffs_conversion_generation = -1;
static int generation_verbose = -1;
static int _ffs_conversion_generation = -1;
static int _generation_verbose = -1;
static inline int NO_SANITIZE_THREAD ffs_conversion_generation(void)
{
return _ffs_conversion_generation;
}
static inline int NO_SANITIZE_THREAD generation_verbose(void)
{
return _generation_verbose;
}
#define gen_fatal(str) do {fprintf(stderr, "%s\n", str); exit(1);} while (0)
......@@ -2037,49 +2063,56 @@ int ffs_putreg(void *vs, int reg, int type)
}
extern
conv_routine
generate_conversion(conv, src_alignment, dest_alignment)
IOConversionPtr conv;
int src_alignment;
int dest_alignment;
static void NO_SANITIZE_THREAD read_generation_environment_variables(void)
{
dill_stream c = NULL;
dill_exec_handle conversion_handle;
void (*conversion_routine)();
dill_reg args[6];
dill_reg tmp_regs[10];
char *format_name = conv->ioformat->body->format_name;
int count = 0, register_args = 1;
struct conv_status cs;
if (ffs_conversion_generation == -1) {
if (_ffs_conversion_generation == -1) {
char *gen_string = getenv("FFS_CONVERSION_GENERATION");
ffs_conversion_generation = FFS_CONVERSION_GENERATION_DEFAULT;
int tmp = FFS_CONVERSION_GENERATION_DEFAULT;
if (gen_string != NULL) {
#ifdef MODULE
ffs_conversion_generation = strtol(gen_string, NULL, 10);
if ((ffs_conversion_generation == LONG_MIN) ||
(ffs_conversion_generation == LONG_MAX) ||
(ffs_conversion_generation == 0)) {
tmp = strtol(gen_string, NULL, 10);
if ((tmp == LONG_MIN) || (tmp == LONG_MAX) || (tmp == 0)) {
#else
if (sscanf(gen_string, "%d", &ffs_conversion_generation) != 1) {
if (sscanf(gen_string, "%d", &tmp) != 1) {
#endif
if (*gen_string == 0) {
/* empty string, just turn on generation */
ffs_conversion_generation = 1;
tmp = 1;
} else {
printf("Unable to parse FFS_CONVERSION_GENERATION environment variable \"%s\".\n", gen_string);
}
}
}
debug_code_generation =
_ffs_conversion_generation = tmp;
}
if (_debug_code_generation == -1)
_debug_code_generation =
(getenv("FFS_CONVERSION_DEBUG") != NULL);
generation_verbose =
if (_generation_verbose == -1)
_generation_verbose =
(getenv("FFS_CONVERSION_VERBOSE") != NULL);
}
if (!ffs_conversion_generation)
}
extern
conv_routine
generate_conversion(conv, src_alignment, dest_alignment)
IOConversionPtr conv;
int src_alignment;
int dest_alignment;
{
dill_stream c = NULL;
dill_exec_handle conversion_handle;
void (*conversion_routine)();
dill_reg args[6];
dill_reg tmp_regs[10];
char *format_name = conv->ioformat->body->format_name;
int count = 0, register_args = 1;
struct conv_status cs;
read_generation_environment_variables();
if (!ffs_conversion_generation())
return NULL;
if (generation_verbose) {
if (generation_verbose()) {
printf("For format %s ===================\n", format_name);
dump_IOConversion(conv);
}
......@@ -2156,7 +2189,7 @@ int dest_alignment;
}
}
}
if (debug_code_generation) {
if (debug_code_generation()) {
if (register_args) {
dill_reg src_pointer_base, dest_pointer_base, dest_offset_adjust; dill_scallv(c, (void*)printf, "printf", "%P%P%p%p%p",
"convert for %s called with src= %lx, dest %lx, rt_conv_status =%lx\n",
......@@ -2246,7 +2279,7 @@ int dest_alignment;
conv->free_func = (void(*)(void*))&dill_free_handle;
conversion_routine = (void(*)()) dill_get_fp(conversion_handle);
}
if (generation_verbose) {
if (generation_verbose()) {
dill_dump(c);
}
dill_free_stream(c);
......@@ -2733,7 +2766,7 @@ int data_already_copied;
new_dest, rt_conv_status);
REG_DEBUG(("Putting %d and %d for new src & dest\n",
new_src, new_dest));
if (debug_code_generation) {
if (debug_code_generation()) {
/* VCALL2V(printf, "%P%p",
"After subroutine call, new src_string_base is %lx\n", src_string_base);*/
}
......@@ -2830,7 +2863,7 @@ int data_already_copied;
#endif
if (((conv->subconversion == NULL)) &&
!debug_code_generation) {
!debug_code_generation()) {
if (!ffs_getreg(c, &loop_var, DILL_I, DILL_TEMP))
gen_fatal("gen field convert out of registers BB \n");
loop_var_type = DILL_TEMP;
......@@ -2889,7 +2922,7 @@ int data_already_copied;
}
}
if (debug_code_generation) {
if (debug_code_generation()) {
dill_scallv(c, (void*)printf, "printf", "%P%S%p",
"format %s, field Initial loopvar = %x\n", conv_status->global_conv->ioformat->body->format_name, loop_var);
}
......@@ -2930,7 +2963,7 @@ int data_already_copied;
dill_addpi(c, src_addr, src_addr, tmp_spec.size);
dill_addpi(c, dest_addr, dest_addr, conv->dest_size);
}
if (debug_code_generation) {
if (debug_code_generation()) {
dill_scallv(c, (void*)printf, "printf", "%P%p%p%p",
"loopvar = %x, src %x, dest %x\n", loop_var,
src_addr, dest_addr);
......
......@@ -801,7 +801,7 @@ main(int argc, char **argv)
FillMetadataMsg(1 /* CohortSize */, &TimestepMetaData.Msg, &pointers);
if (verbose) {
printf("Before, TimestepMetaData.Metadata[0].DataSize = %ld block %p \n", TimestepMetaData.Msg.Metadata[0].DataSize, TimestepMetaData.Msg.Metadata[0].block);
printf("Before, TimestepMetaData.Metadata[0].DataSize = %zu block %p \n", TimestepMetaData.Msg.Metadata[0].DataSize, TimestepMetaData.Msg.Metadata[0].block);
printf("&TimestepMetaData = %p\n", &TimestepMetaData);
printf("TimestepMetaData.ReaderCount = %d, ReaderStatus = %p\n", TimestepMetaData.ReaderCount, TimestepMetaData.ReaderStatus);
......@@ -809,7 +809,7 @@ main(int argc, char **argv)
printf("TimestepMetaData.Msg.CohortSize = %d, Timestep = %d, Formats = %p\n", TimestepMetaData.Msg.CohortSize, TimestepMetaData.Msg.Timestep, TimestepMetaData.Msg.Formats);
printf("TimestepMetaData.Msg.Metadata = %p\n", TimestepMetaData.Msg.Metadata);
if (TimestepMetaData.Msg.Metadata)
printf("TimestepMetaData.Msg.Metadata[0].block = %p, .size = %ld\n", TimestepMetaData.Msg.Metadata[0].block, TimestepMetaData.Msg.Metadata[0].DataSize);
printf("TimestepMetaData.Msg.Metadata[0].block = %p, .size = %zu\n", TimestepMetaData.Msg.Metadata[0].block, TimestepMetaData.Msg.Metadata[0].DataSize);
}
ReturnData = CP_distributeDataFromRankZero(ffs_c, &TimestepMetaData,
ReturnMetadataInfoFormat, &RetDataBlock);
......@@ -821,8 +821,8 @@ main(int argc, char **argv)
printf("ReturnData->Msg.CohortSize = %d, Timestep = %d, Formats = %p\n", ReturnData->Msg.CohortSize, ReturnData->Msg.Timestep, ReturnData->Msg.Formats);
printf("ReturnData->Msg.Metadata = %p\n", ReturnData->Msg.Metadata);
if (ReturnData->Msg.Metadata)
printf("ReturnData->Msg.Metadata[0].block = %p, .size = %ld\n", ReturnData->Msg.Metadata[0].block, ReturnData->Msg.Metadata[0].DataSize);
printf("After, ReturnData.Metadata[0](%p).DataSize = %ld block %p \n", ReturnData->Msg.Metadata, ReturnData->Msg.Metadata[0].DataSize, ReturnData->Msg.Metadata[0].block);
printf("ReturnData->Msg.Metadata[0].block = %p, .size = %zu\n", ReturnData->Msg.Metadata[0].block, ReturnData->Msg.Metadata[0].DataSize);
printf("After, ReturnData.Metadata[0](%p).DataSize = %zu block %p \n", ReturnData->Msg.Metadata, ReturnData->Msg.Metadata[0].DataSize, ReturnData->Msg.Metadata[0].block);
printf("After, ReturnData.Metadata[0].block[0] = 0x%0x \n", *(int*)ReturnData->Msg.Metadata[0].block);
}
if(*(int*)ReturnData->Msg.Metadata[0].block != 0xdeadbeef) {fprintf(stderr, "BAD VALUE\n"); exit(1);}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment