Skip to content

Commit

Permalink
Configure compiler and silence warnings of Clang-17 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dey4ss authored Mar 11, 2024
1 parent a3aaa16 commit bd33155
Show file tree
Hide file tree
Showing 13 changed files with 197 additions and 78 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
build:
name: ${{matrix.name}}
runs-on: ${{matrix.os}}
env:
CC: ${{matrix.cc}}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
include:
- name: Ubuntu-GCC
cc: gcc
os: ubuntu-latest

- name: Ubuntu-Clang
cc: clang
os: ubuntu-latest

- name: macOS-AppleClang
cc: clang
os: macos-latest

steps:
- uses: actions/checkout@v4

- name: System Information
run: |
awk -v a=$(uname) 'BEGIN { a == "Linux" ? system("cat /etc/issue") : system("sw_vers") }'
${CC} --version
- name: Make
run: |
make
- name: Generate SF 0.01 Data
run: |
mkdir generated_data && cd generated_data
../dbgen -f -s 0.01 -T a -b ../dists.dss
5 changes: 5 additions & 0 deletions README → README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
![Build Status](https://github.com/hyrise/ssb-dbgen/actions/workflows/ci.yml/badge.svg?branch=master)
### Note: This fork is adapted for compilation using recent versions of Clang and GCC, which we ensure with a [GitHub action](https://github.com/hyrise/ssb-dbgen/actions).

# SSB Data Generator

Note: In our research paper we use the SSB instead of SSBM
Version of 2/28/10:
Cardinality of supplier fixed to follow benchmark spec: now 2000*SF
Expand Down
15 changes: 14 additions & 1 deletion bm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,20 @@ set_state(int table, long sf, long procs, long step, long *extra_rows)
}
*extra_rows = remainder % procs;
if (step > procs) /* moving to the end to generate updates */
tdefs[table].gen_seed(*extra_rows);
{
// HYRISE: The following line raises a compilation error when adding function prototypes the the tdef gen_seed
// member, as they epxect two arguments. All seed generators passed in driver.c (L 230-249) take either two
// parameters or are simply 0. Thus, calling this line would always lead to an error. With this assumption, we
// simply ensure we fail if this should ever be called (did not happen after generating tables for multiple
// scale factors).
//
// tdefs[table].gen_seed(*extra_rows);
//
fprintf(stderr,
"Did not expect to reach this line. Re-check function prototypes and remove compiler check if necessary. See %s:%d\n",
__FILE__, __LINE__);
exit(1);
}

return(result);
}
Expand Down
28 changes: 17 additions & 11 deletions build.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ gen_phone(long ind, char *target, long seed)

RANDOM(acode, 100, 999, seed);
RANDOM(exchg, 100, 999, seed);
RANDOM(number, 1000, 9999, seed);
sprintf(target, "%02d", 10 + (ind % NATIONS_MAX));
sprintf(target + 3, "%03d", acode);
sprintf(target + 7, "%03d", exchg);
sprintf(target + 11, "%04d", number);
RANDOM(number, 1000, 9999, seed);
// HYRISE: Change format specifier.
sprintf(target, "%02ld", 10 + (ind % NATIONS_MAX));
sprintf(target + 3, "%03ld", acode);
sprintf(target + 7, "%03ld", exchg);
sprintf(target + 11, "%04ld", number);
target[2] = target[6] = target[10] = '-';
return;
}
Expand All @@ -91,8 +92,9 @@ gen_category(char *target, long seed){
RANDOM(num1,1,5,seed);
RANDOM(num2,1,5,seed);
strcpy(target,"MFGR");
sprintf(target + 4, "%01d", num1);
sprintf(target + 5, "%01d", num2);
// HYRISE: Change format specifier.
sprintf(target + 4, "%01ld", num1);
sprintf(target + 5, "%01ld", num2);
return;
}

Expand Down Expand Up @@ -410,14 +412,17 @@ long mk_part(long index, part_t *p)


RANDOM(mfgr, P_MFG_MIN, P_MFG_MAX, P_MFG_SD);
sprintf(p->mfgr, "%s%d", "MFGR#", mfgr);
// HYRISE: Change format specifier.
sprintf(p->mfgr, "%s%ld", "MFGR#", mfgr);

RANDOM(cat, P_CAT_MIN, P_CAT_MAX, P_CAT_SD);
sprintf(p->category, "%s%d", p->mfgr,cat);
// HYRISE: Change format specifier.
sprintf(p->category, "%s%ld", p->mfgr,cat);


RANDOM(brnd, P_BRND_MIN, P_BRND_MAX, P_BRND_SD);
sprintf(p->brand,"%s%d",p->category,brnd);
// HYRISE: Change format specifier.
sprintf(p->brand,"%s%ld",p->category,brnd);

p->tlen = pick_str(&p_types_set, P_TYPE_SD, p->type);
p->tlen = strlen(p_types_set.list[p->tlen].text);
Expand Down Expand Up @@ -610,7 +615,8 @@ int gen_city(char *cityName, char *nationName){
}
RANDOM(randomPick, 0, 9, 98);

sprintf(cityName+CITY_FIX-1,"%d",randomPick);
// HYRISE: Change format specifier.
sprintf(cityName+CITY_FIX-1,"%ld",randomPick);
cityName[CITY_FIX] = '\0';
return 0;
}
Expand Down
51 changes: 31 additions & 20 deletions driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ char *spawn_args[25];
* flat file print functions; used with -F(lat) option
*/
#ifdef SSBM
int pr_cust (customer_t * c, int mode);
int pr_part (part_t * p, int mode);
int pr_supp (supplier_t * s, int mode);
int pr_line (order_t * o, int mode);
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int pr_cust (void * c, int mode);
int pr_part (void * p, int mode);
int pr_supp (void * s, int mode);
int pr_line (void * t, int mode);
#else
int pr_cust (customer_t * c, int mode);
int pr_line (order_t * o, int mode);
Expand All @@ -129,13 +131,15 @@ int pr_region (code_t * c, int mode);
* inline load functions; used with -D(irect) option
*/
#ifdef SSBM
int ld_cust (customer_t * c, int mode);
int ld_part (part_t * p, int mode);
int ld_supp (supplier_t * s, int mode);
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int ld_cust (void * c, int mode);
int ld_part (void * p, int mode);
int ld_supp (void * s, int mode);

/*todo: get rid of ld_order*/
int ld_line (order_t * o, int mode);
int ld_order (order_t * o, int mode);
int ld_line (void * o, int mode);
int ld_order (void * o, int mode);

#else
int ld_cust (customer_t * c, int mode);
Expand Down Expand Up @@ -198,12 +202,14 @@ int hd_region (FILE * f);
* data verfication functions; used with -O v option
*/
#ifdef SSBM
int vrf_cust (customer_t * c, int mode);
int vrf_part (part_t * p, int mode);
int vrf_supp (supplier_t * s, int mode);
int vrf_line (order_t * o, int mode);
int vrf_order (order_t * o, int mode);
int vrf_date (date_t,int mode);
// HYRISE: change first parameter to void pointer so the tdef verify member can have a function prototype
// (C2x compatibility).
int vrf_cust (void * c, int mode);
int vrf_part (void * p, int mode);
int vrf_supp (void * s, int mode);
int vrf_line (void * o, int mode);
int vrf_order (void * o, int mode);
int vrf_date (void * d, int mode);
#else
int vrf_cust (customer_t * c, int mode);
int vrf_line (order_t * o, int mode);
Expand Down Expand Up @@ -604,7 +610,8 @@ partial (int tbl, int s)

if (verbose > 0)
{
fprintf (stderr, "\tStarting to load stage %d of %d for %s...",
// HYRISE: Change format specifier.
fprintf (stderr, "\tStarting to load stage %d of %ld for %s...",
s, children, tdefs[tbl].comment);
}

Expand Down Expand Up @@ -633,7 +640,8 @@ pload (int tbl)

if (verbose > 0)
{
fprintf (stderr, "Starting %d children to load %s",
// HYRISE: Change format specifier.
fprintf (stderr, "Starting %ld children to load %s",
children, tdefs[tbl].comment);
}
for (c = 0; c < children; c++)
Expand Down Expand Up @@ -1017,8 +1025,9 @@ main (int ac, char **av)
{
if (verbose > 0)
#ifdef SSBM
// HYRISE: Change format specifier.
fprintf (stderr,
"Generating update pair #%d for %s [pid: %d]",
"Generating update pair #%ld for %s [pid: %d]",
upd_num + 1, tdefs[LINE].comment, DSS_PROC);
#else
fprintf (stderr,
Expand Down Expand Up @@ -1117,14 +1126,16 @@ main (int ac, char **av)
}
#endif
if (verbose > 0)
fprintf (stderr, "%s data for %s [pid: %ld]",
// HYRISE: Change format specifier.
fprintf (stderr, "%s data for %s [pid: %d]",
(validate)?"Validating":"Generating", tdefs[i].comment, DSS_PROC);
gen_tbl (i, minrow, rowcnt, upd_num);
if (verbose > 0)
fprintf (stderr, "done.\n");
}
if (validate)
printf("Validation checksum for %s at %d GB: %0x\n",
// HYRISE: Change format specifier.
printf("Validation checksum for %s at %ld GB: %0lx\n",
tdefs[i].name, scale, tdefs[i].vtotal);
}

Expand Down
19 changes: 11 additions & 8 deletions dss.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ typedef struct
char *name;
char *comment;
long base;
int (*header) ();
int (*loader[2]) ();
long (*gen_seed)();
int (*verify) ();
// HYRISE: add function prototypes (C2x compatibility).
int (*header) (FILE *);
int (*loader[2]) (void *, int);
long (*gen_seed)(int, long);
int (*verify) (void *, int);
int child;
unsigned long vtotal;
} tdef;
Expand Down Expand Up @@ -359,7 +360,8 @@ extern tdef tdefs[];
*/
#define C_SIZE 165
#define C_NAME_TAG "Customer#"
#define C_NAME_FMT "%s%09d"
// HYRISE: Change format specifier.
#define C_NAME_FMT "%s%09ld"
#define C_MSEG_MAX 5
#define C_ABAL_MIN -99999
#define C_ABAL_MAX 999999
Expand Down Expand Up @@ -515,16 +517,17 @@ int dbg_print(int dt, FILE *tgt, void *data, int len, int eol);
#define PR_STRT(fp) /* any line prep for a record goes here */
#define PR_END(fp) fprintf(fp, "\n") /* finish the record here */

// HYRISE: Change format specifier.
#ifdef SSBM
#define PR_DATE(tgt, yr, mn, dy) \
sprintf(tgt, "19%02d%02d%02d", yr, mn, dy)
sprintf(tgt, "19%02ld%02ld%02ld", yr, mn, dy)
#else
#ifdef MDY_DATE
#define PR_DATE(tgt, yr, mn, dy) \
sprintf(tgt, "%02d-%02d-19%02d", mn, dy, yr)
sprintf(tgt, "%02ld-%02ld-19%02ld", mn, dy, yr)
#else
#define PR_DATE(tgt, yr, mn, dy) \
sprintf(tgt, "19%02d-%02d-%02d", yr, mn, dy)
sprintf(tgt, "19%02ld-%02ld-%02ld", yr, mn, dy)
#endif /* DATE_FORMAT */
#endif
/*
Expand Down
28 changes: 19 additions & 9 deletions dsstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ typedef struct

/* customers.c */
long mk_cust PROTO((long n_cust, customer_t * c));
int pr_cust PROTO((customer_t * c, int mode));
int ld_cust PROTO((customer_t * c, int mode));
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int pr_cust PROTO((void * c, int mode));
int ld_cust PROTO((void * c, int mode));

#ifdef SSBM

Expand Down Expand Up @@ -125,7 +127,9 @@ typedef struct
/* order.c */
long mk_order PROTO((long index, order_t * o, long upd_num));
int pr_order PROTO((order_t * o, int mode));
int ld_order PROTO((order_t * o, int mode));
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int ld_order PROTO((void * o, int mode));
void ez_sparse PROTO((long index, DSS_HUGE *ok, long seq));
#ifndef SUPPORT_64BITS
void hd_sparse PROTO((long index, DSS_HUGE *ok, long seq));
Expand Down Expand Up @@ -182,8 +186,10 @@ typedef struct

/* parts.c */
long mk_part PROTO((long index, part_t * p));
int pr_part PROTO((part_t * part, int mode));
int ld_part PROTO((part_t * part, int mode));
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int pr_part PROTO((void * part, int mode));
int ld_part PROTO((void * part, int mode));

#ifdef SSBM
typedef struct
Expand Down Expand Up @@ -216,8 +222,10 @@ typedef struct

/* supplier.c */
long mk_supp PROTO((long index, supplier_t * s));
int pr_supp PROTO((supplier_t * supp, int mode));
int ld_supp PROTO((supplier_t * supp, int mode));
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int pr_supp PROTO((void * supp, int mode));
int ld_supp PROTO((void * supp, int mode));

#ifdef SSBM
/*todo: add new date table*/
Expand Down Expand Up @@ -247,8 +255,10 @@ typedef struct
/* date.c */

long mk_date PROTO((long index, date_t * d));
int pr_date PROTO((date_t * date, int mode));
int ld_date PROTO((date_t * date, int mode));
// HYRISE: change first parameter to void pointer so the tdef loader member can have a function prototype
// (C2x compatibility).
int pr_date PROTO((void * date, int mode));
int ld_date PROTO((void * date, int mode));

#endif

Expand Down
Loading

0 comments on commit bd33155

Please sign in to comment.