Просмотр исходного кода

OTPChecker: do not use bstruct. Remove bstruct.

ambrop7 14 лет назад
Родитель
Сommit
5be9d90124

+ 0 - 93
bstruct_generator/StructParser.lime

@@ -1,93 +0,0 @@
-%class StructParser
-%start file
-
-file =
-    directives structures {
-    $$ = array(
-        "directives" => $1,
-        "structures" => $2
-    );
-}.
-
-directives =
-    {
-        $$ = array();
-    } |
-    directive semicolon directives {
-        $$ = array_merge(array($1), $3);
-    }.
-
-directive =
-    include string {
-        $$ = array(
-            "type" => "include",
-            "file" => $2
-        );
-    }.
-
-structures =
-    structspec {
-        $$ = array($1);
-    } |
-    structspec structures {
-        $$ = array_merge(array($1), $2);
-    }.
-
-structspec =
-    structure name srpar string erpar spar entries epar semicolon {
-    $$ = array(
-        "name" => $2,
-        "parameters" => $4,
-        "entries" => $7
-    );
-}.
-
-entries =
-    entry {
-        $$ = array($1);
-    } |
-    entry entries {
-        $$ = array_merge(array($1), $2);
-    }.
-
-entry =
-    typespec name semicolon {
-        $$ = array(
-            "type" => $1,
-            "name" => $2,
-            "num" => "1"
-        );
-    } |
-    typespec name sbracket string ebracket semicolon {
-        $$ = array(
-            "type" => $1,
-            "name" => $2,
-            "num" => $4
-        );
-    }.
-
-typespec =
-    string {
-        $$ = array(
-            "type" => "sizealign",
-            "ctype" => $1,
-            "size" => "sizeof($1)",
-            "align" => "__alignof__($1)"
-        );
-    } |
-    size string align string {
-        $$ = array(
-            "type" => "sizealign",
-            "ctype" => "void",
-            "size" => $2,
-            "align" => $4
-        );
-    } |
-    structure name srpar string erpar {
-        $$ = array(
-            "type" => "structure",
-            "ctype" => $2,
-            "name" => $2,
-            "parameters" => $4
-        );
-    }.

+ 0 - 503
bstruct_generator/StructParser.php

@@ -1,503 +0,0 @@
-<?php
-
-
-/*
-
-DON'T EDIT THIS FILE!
-
-This file was automatically generated by the Lime parser generator.
-The real source code you should be looking at is in one or more
-grammar files in the Lime format.
-
-THE ONLY REASON TO LOOK AT THIS FILE is to see where in the grammar
-file that your error happened, because there are enough comments to
-help you debug your grammar.
-
-If you ignore this warning, you're shooting yourself in the brain,
-not the foot.
-
-*/
-
-class StructParser extends lime_parser {
-var $qi = 0;
-var $i = array (
-  0 => 
-  array (
-    'directives' => 's 1',
-    'directive' => 's 33',
-    'include' => 's 36',
-    'file' => 's 38',
-    '\'start\'' => 'a \'start\'',
-    'structure' => 'r 1',
-  ),
-  1 => 
-  array (
-    'structures' => 's 2',
-    'structspec' => 's 3',
-    'structure' => 's 5',
-  ),
-  2 => 
-  array (
-    '#' => 'r 0',
-  ),
-  3 => 
-  array (
-    'structspec' => 's 3',
-    'structures' => 's 4',
-    'structure' => 's 5',
-    '#' => 'r 4',
-  ),
-  4 => 
-  array (
-    '#' => 'r 5',
-  ),
-  5 => 
-  array (
-    'name' => 's 6',
-  ),
-  6 => 
-  array (
-    'srpar' => 's 7',
-  ),
-  7 => 
-  array (
-    'string' => 's 8',
-  ),
-  8 => 
-  array (
-    'erpar' => 's 9',
-  ),
-  9 => 
-  array (
-    'spar' => 's 10',
-  ),
-  10 => 
-  array (
-    'entries' => 's 11',
-    'entry' => 's 14',
-    'typespec' => 's 16',
-    'string' => 's 23',
-    'size' => 's 24',
-    'structure' => 's 28',
-  ),
-  11 => 
-  array (
-    'epar' => 's 12',
-  ),
-  12 => 
-  array (
-    'semicolon' => 's 13',
-  ),
-  13 => 
-  array (
-    'structure' => 'r 6',
-    '#' => 'r 6',
-  ),
-  14 => 
-  array (
-    'entry' => 's 14',
-    'entries' => 's 15',
-    'typespec' => 's 16',
-    'string' => 's 23',
-    'size' => 's 24',
-    'structure' => 's 28',
-    'epar' => 'r 7',
-  ),
-  15 => 
-  array (
-    'epar' => 'r 8',
-  ),
-  16 => 
-  array (
-    'name' => 's 17',
-  ),
-  17 => 
-  array (
-    'semicolon' => 's 18',
-    'sbracket' => 's 19',
-  ),
-  18 => 
-  array (
-    'string' => 'r 9',
-    'size' => 'r 9',
-    'structure' => 'r 9',
-    'epar' => 'r 9',
-  ),
-  19 => 
-  array (
-    'string' => 's 20',
-  ),
-  20 => 
-  array (
-    'ebracket' => 's 21',
-  ),
-  21 => 
-  array (
-    'semicolon' => 's 22',
-  ),
-  22 => 
-  array (
-    'string' => 'r 10',
-    'size' => 'r 10',
-    'structure' => 'r 10',
-    'epar' => 'r 10',
-  ),
-  23 => 
-  array (
-    'name' => 'r 11',
-  ),
-  24 => 
-  array (
-    'string' => 's 25',
-  ),
-  25 => 
-  array (
-    'align' => 's 26',
-  ),
-  26 => 
-  array (
-    'string' => 's 27',
-  ),
-  27 => 
-  array (
-    'name' => 'r 12',
-  ),
-  28 => 
-  array (
-    'name' => 's 29',
-  ),
-  29 => 
-  array (
-    'srpar' => 's 30',
-  ),
-  30 => 
-  array (
-    'string' => 's 31',
-  ),
-  31 => 
-  array (
-    'erpar' => 's 32',
-  ),
-  32 => 
-  array (
-    'name' => 'r 13',
-  ),
-  33 => 
-  array (
-    'semicolon' => 's 34',
-  ),
-  34 => 
-  array (
-    'directive' => 's 33',
-    'directives' => 's 35',
-    'include' => 's 36',
-    'structure' => 'r 1',
-  ),
-  35 => 
-  array (
-    'structure' => 'r 2',
-  ),
-  36 => 
-  array (
-    'string' => 's 37',
-  ),
-  37 => 
-  array (
-    'semicolon' => 'r 3',
-  ),
-  38 => 
-  array (
-    '#' => 'r 14',
-  ),
-);
-function reduce_0_file_1($tokens, &$result) {
-#
-# (0) file :=  directives  structures
-#
-$result = reset($tokens);
-
-    $result = array(
-        "directives" => $tokens[0],
-        "structures" => $tokens[1]
-    );
-
-}
-
-function reduce_1_directives_1($tokens, &$result) {
-#
-# (1) directives :=
-#
-$result = reset($tokens);
-
-        $result = array();
-    
-}
-
-function reduce_2_directives_2($tokens, &$result) {
-#
-# (2) directives :=  directive  semicolon  directives
-#
-$result = reset($tokens);
-
-        $result = array_merge(array($tokens[0]), $tokens[2]);
-    
-}
-
-function reduce_3_directive_1($tokens, &$result) {
-#
-# (3) directive :=  include  string
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => "include",
-            "file" => $tokens[1]
-        );
-    
-}
-
-function reduce_4_structures_1($tokens, &$result) {
-#
-# (4) structures :=  structspec
-#
-$result = reset($tokens);
-
-        $result = array($tokens[0]);
-    
-}
-
-function reduce_5_structures_2($tokens, &$result) {
-#
-# (5) structures :=  structspec  structures
-#
-$result = reset($tokens);
-
-        $result = array_merge(array($tokens[0]), $tokens[1]);
-    
-}
-
-function reduce_6_structspec_1($tokens, &$result) {
-#
-# (6) structspec :=  structure  name  srpar  string  erpar  spar  entries  epar  semicolon
-#
-$result = reset($tokens);
-
-    $result = array(
-        "name" => $tokens[1],
-        "parameters" => $tokens[3],
-        "entries" => $tokens[6]
-    );
-
-}
-
-function reduce_7_entries_1($tokens, &$result) {
-#
-# (7) entries :=  entry
-#
-$result = reset($tokens);
-
-        $result = array($tokens[0]);
-    
-}
-
-function reduce_8_entries_2($tokens, &$result) {
-#
-# (8) entries :=  entry  entries
-#
-$result = reset($tokens);
-
-        $result = array_merge(array($tokens[0]), $tokens[1]);
-    
-}
-
-function reduce_9_entry_1($tokens, &$result) {
-#
-# (9) entry :=  typespec  name  semicolon
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => $tokens[0],
-            "name" => $tokens[1],
-            "num" => "1"
-        );
-    
-}
-
-function reduce_10_entry_2($tokens, &$result) {
-#
-# (10) entry :=  typespec  name  sbracket  string  ebracket  semicolon
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => $tokens[0],
-            "name" => $tokens[1],
-            "num" => $tokens[3]
-        );
-    
-}
-
-function reduce_11_typespec_1($tokens, &$result) {
-#
-# (11) typespec :=  string
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => "sizealign",
-            "ctype" => $tokens[0],
-            "size" => "sizeof($tokens[0])",
-            "align" => "__alignof__($tokens[0])"
-        );
-    
-}
-
-function reduce_12_typespec_2($tokens, &$result) {
-#
-# (12) typespec :=  size  string  align  string
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => "sizealign",
-            "ctype" => "void",
-            "size" => $tokens[1],
-            "align" => $tokens[3]
-        );
-    
-}
-
-function reduce_13_typespec_3($tokens, &$result) {
-#
-# (13) typespec :=  structure  name  srpar  string  erpar
-#
-$result = reset($tokens);
-
-        $result = array(
-            "type" => "structure",
-            "ctype" => $tokens[1],
-            "name" => $tokens[1],
-            "parameters" => $tokens[3]
-        );
-    
-}
-
-function reduce_14_start_1($tokens, &$result) {
-#
-# (14) 'start' :=  file
-#
-$result = reset($tokens);
-
-}
-
-var $method = array (
-  0 => 'reduce_0_file_1',
-  1 => 'reduce_1_directives_1',
-  2 => 'reduce_2_directives_2',
-  3 => 'reduce_3_directive_1',
-  4 => 'reduce_4_structures_1',
-  5 => 'reduce_5_structures_2',
-  6 => 'reduce_6_structspec_1',
-  7 => 'reduce_7_entries_1',
-  8 => 'reduce_8_entries_2',
-  9 => 'reduce_9_entry_1',
-  10 => 'reduce_10_entry_2',
-  11 => 'reduce_11_typespec_1',
-  12 => 'reduce_12_typespec_2',
-  13 => 'reduce_13_typespec_3',
-  14 => 'reduce_14_start_1',
-);
-var $a = array (
-  0 => 
-  array (
-    'symbol' => 'file',
-    'len' => 2,
-    'replace' => true,
-  ),
-  1 => 
-  array (
-    'symbol' => 'directives',
-    'len' => 0,
-    'replace' => true,
-  ),
-  2 => 
-  array (
-    'symbol' => 'directives',
-    'len' => 3,
-    'replace' => true,
-  ),
-  3 => 
-  array (
-    'symbol' => 'directive',
-    'len' => 2,
-    'replace' => true,
-  ),
-  4 => 
-  array (
-    'symbol' => 'structures',
-    'len' => 1,
-    'replace' => true,
-  ),
-  5 => 
-  array (
-    'symbol' => 'structures',
-    'len' => 2,
-    'replace' => true,
-  ),
-  6 => 
-  array (
-    'symbol' => 'structspec',
-    'len' => 9,
-    'replace' => true,
-  ),
-  7 => 
-  array (
-    'symbol' => 'entries',
-    'len' => 1,
-    'replace' => true,
-  ),
-  8 => 
-  array (
-    'symbol' => 'entries',
-    'len' => 2,
-    'replace' => true,
-  ),
-  9 => 
-  array (
-    'symbol' => 'entry',
-    'len' => 3,
-    'replace' => true,
-  ),
-  10 => 
-  array (
-    'symbol' => 'entry',
-    'len' => 6,
-    'replace' => true,
-  ),
-  11 => 
-  array (
-    'symbol' => 'typespec',
-    'len' => 1,
-    'replace' => true,
-  ),
-  12 => 
-  array (
-    'symbol' => 'typespec',
-    'len' => 4,
-    'replace' => true,
-  ),
-  13 => 
-  array (
-    'symbol' => 'typespec',
-    'len' => 5,
-    'replace' => true,
-  ),
-  14 => 
-  array (
-    'symbol' => '\'start\'',
-    'len' => 1,
-    'replace' => true,
-  ),
-);
-}

+ 0 - 106
bstruct_generator/bstruct.php

@@ -1,106 +0,0 @@
-<?php
-/*
-    BStruct generator
-    Copyright (C) Ambroz Bizjak, 2010
-
-    This file is part of BadVPN.
-
-    BadVPN is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2
-    as published by the Free Software Foundation.
-
-    BadVPN is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc.,
-    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-*/
-
-require_once "lime/parse_engine.php";
-require_once "StructParser.php";
-require_once "bstruct_functions.php";
-
-function assert_failure ($script, $line, $message)
-{
-    if ($message == "") {
-        fatal_error("Assertion failure at {$script}:{$line}");
-    } else {
-        fatal_error("Assertion failure at {$script}:{$line}: {$message}");
-    }
-}
-
-assert_options(ASSERT_CALLBACK, "assert_failure");
-
-function print_help ($name)
-{
-    echo <<<EOD
-Usage: {$name}
-    --input-file <file>         Message file to generate source for.
-    --output-dir <dir>          Destination directory for generated files.
-    [--file-prefix <string>]    Name prefix for generated files. Default: "struct_".
-
-EOD;
-}
-
-$name = "";
-$input_file = "";
-$output_dir = "";
-
-for ($i = 1; $i < $argc;) {
-    $arg = $argv[$i++];
-    switch ($arg) {
-        case "--name":
-            $name = $argv[$i++];
-            break;
-        case "--input-file":
-            $input_file = $argv[$i++];
-            break;
-        case "--output-dir":
-            $output_dir = $argv[$i++];
-            break;
-        case "--help":
-            print_help($argv[0]);
-            exit(0);
-        default:
-            fatal_error("Unknown option: {$arg}");
-    }
-}
-
-if ($name == "") {
-    fatal_error("--name missing");
-}
-
-if ($input_file == "") {
-    fatal_error("--input-file missing");
-}
-
-if ($output_dir == "") {
-    fatal_error("--output-dir missing");
-}
-
-if (($data = file_get_contents($input_file)) === FALSE) {
-    fatal_error("Failed to read input file");
-}
-
-if (!tokenize($data, $tokens)) {
-    fatal_error("Failed to tokenize");
-}
-
-$parser = new parse_engine(new StructParser());
-
-try {
-    foreach ($tokens as $token) {
-        $parser->eat($token[0], $token[1]);
-    }
-    $parser->eat_eof();
-} catch (parse_error $e) {
-    fatal_error("$input_file: Parse error: ".$e->getMessage());
-}
-
-$data = generate_header($name, $parser->semantic["directives"], $parser->semantic["structures"]);
-if (file_put_contents("{$output_dir}/{$name}.h", $data) === NULL) {
-    fatal_error("{$input_file}: Failed to write .h file");
-}

+ 0 - 293
bstruct_generator/bstruct_functions.php

@@ -1,293 +0,0 @@
-<?php
-
-function tokenize ($str, &$out) {
-    $out = array();
-
-    while (strlen($str) > 0) {
-        if (preg_match('/^\\/\\/.*/', $str, $matches)) {
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^\\s+/', $str, $matches)) {
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^include/', $str, $matches)) {
-            $out[] = array('include', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^structure/', $str, $matches)) {
-            $out[] = array('structure', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^size/', $str, $matches)) {
-            $out[] = array('size', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^align/', $str, $matches)) {
-            $out[] = array('align', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^{/', $str, $matches)) {
-            $out[] = array('spar', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^}/', $str, $matches)) {
-            $out[] = array('epar', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^\(/', $str, $matches)) {
-            $out[] = array('srpar', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^\)/', $str, $matches)) {
-            $out[] = array('erpar', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^\[/', $str, $matches)) {
-            $out[] = array('sbracket', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^\]/', $str, $matches)) {
-            $out[] = array('ebracket', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^;/', $str, $matches)) {
-            $out[] = array('semicolon', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^,/', $str, $matches)) {
-            $out[] = array('comma', null);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*/', $str, $matches)) {
-            $out[] = array('name', $matches[0]);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else if (preg_match('/^"([^"]*)"/', $str, $matches)) {
-            $out[] = array('string', $matches[1]);
-            $str = substr($str, strlen($matches[0]));
-        }
-        else {
-            return FALSE;
-        }
-    }
-
-    return TRUE;
-}
-
-function fatal_error ($message)
-{
-    fwrite(STDERR, "Fatal error: $message\n");
-
-    ob_get_clean();
-    exit(1);
-}
-
-function make_size ($entry)
-{
-    switch ($entry["type"]["type"]) {
-        case "sizealign":
-            return "({$entry["type"]["size"]})";
-        case "structure":
-            return "o->{$entry["name"]}_params.len";
-        default:
-            assert(0);
-    }
-}
-
-function make_align ($entry)
-{
-    switch ($entry["type"]["type"]) {
-        case "sizealign":
-            return "({$entry["type"]["align"]})";
-        case "structure":
-            return "o->{$entry["name"]}_params.align";
-        default:
-            assert(0);
-    }
-}
-
-function generate_header ($name, $directives, $structures)
-{
-    ob_start();
-
-    echo <<<EOD
-/*
-    DO NOT EDIT THIS FILE!
-    This file was automatically generated by the bstruct generator.
-*/
-
-#include <stdint.h>
-#include <limits.h>
-
-#include <misc/balign.h>
-#include <misc/debug.h>
-
-
-EOD;
-
-    foreach ($directives as $directive) {
-        if ($directive["type"] == "include") {
-            echo <<<EOD
-#include "{$directive["file"]}"
-
-EOD;
-        }
-    }
-
-    echo <<<EOD
-
-
-EOD;
-
-    foreach ($structures as $struct) {
-        if ($struct["parameters"] == "") {
-            $add_parameters = "";
-        } else {
-            $add_parameters = ", {$struct["parameters"]}";
-        }
-
-        echo <<<EOD
-typedef struct {$struct["name"]}_struct {$struct["name"]};
-
-typedef struct {
-
-EOD;
-
-        foreach ($struct["entries"] as $entry) {
-            if ($entry["type"]["type"] == "structure") {
-                echo <<<EOD
-    {$entry["type"]["name"]}Params {$entry["name"]}_params;
-
-EOD;
-            }
-
-            echo <<<EOD
-    size_t {$entry["name"]}_off;
-    size_t {$entry["name"]}_size;
-    #ifndef NDEBUG
-    size_t {$entry["name"]}_count;
-    #endif
-
-
-EOD;
-        }
-
-        echo <<<EOD
-    size_t len;
-    size_t align;
-} {$struct["name"]}Params;
-
-static int {$struct["name"]}Params_Init ({$struct["name"]}Params *o{$add_parameters}) WARN_UNUSED;
-
-static int {$struct["name"]}Params_Init ({$struct["name"]}Params *o{$add_parameters})
-{
-    size_t cur_size;
-    size_t cur_align;
-    size_t cur_count;
-
-    o->len = 0;
-    o->align = 1;
-
-
-EOD;
-
-        // Calculate the alignment of the structure as the maximum of alignments of its entries.
-        // This assumes the alignments are powers of two; in general we would need the least
-        // common multiple of the alignments.
-
-        $prev = NULL;
-        foreach ($struct["entries"] as $entry) {
-            if ($entry["type"]["type"] == "structure") {
-                if ($entry["type"]["parameters"] == "") {
-                    $init_add_parameters = "";
-                } else {
-                    $init_add_parameters = ", {$entry["type"]["parameters"]}";
-                }
-                echo <<<EOD
-    if (!{$entry["type"]["name"]}Params_Init(&o->{$entry["name"]}_params{$init_add_parameters})) {
-        return 0;
-    }
-
-EOD;
-            }
-
-            $size = make_size($entry);
-            $align = make_align($entry);
-
-
-
-            echo <<<EOD
-    if ({$size} > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = {$size};
-    if ({$align} > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = {$align};
-    if ({$entry["num"]} > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = ({$entry["num"]});
-
-EOD;
-
-            $off = "balign_up(o->len, cur_align)";
-
-            echo <<<EOD
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->{$entry["name"]}_off = {$off};
-    o->{$entry["name"]}_size = cur_size;
-    #ifndef NDEBUG
-    o->{$entry["name"]}_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->{$entry["name"]}_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->{$entry["name"]}_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-
-EOD;
-        }
-
-        echo <<<EOD
-    return 1;
-}
-
-
-EOD;
-
-        $prev = NULL;
-        foreach ($struct["entries"] as $entry) {
-            echo <<<EOD
-static {$entry["type"]["ctype"]} * {$struct["name"]}_{$entry["name"]} ({$struct["name"]}Params *o, {$struct["name"]} *s)
-{
-    return ({$entry["type"]["ctype"]} *)((uint8_t *)s + o->{$entry["name"]}_off);
-}
-
-static {$entry["type"]["ctype"]} * {$struct["name"]}_{$entry["name"]}_at ({$struct["name"]}Params *o, {$struct["name"]} *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->{$entry["name"]}_count)
-
-    return ({$entry["type"]["ctype"]} *)((uint8_t *)s + o->{$entry["name"]}_off + i * o->{$entry["name"]}_size);
-}
-
-
-EOD;
-        }
-
-        echo <<<EOD
-
-EOD;
-
-    }
-
-    return ob_get_clean();
-}

+ 0 - 8
generate_files

@@ -14,12 +14,6 @@ function bproto() {
     "${PHP_CMD[@]}" bproto_generator/bproto.php --input-file "${input}" --output-dir "${OUT_DIR}" --name "bproto_${name}"
 }
 
-function bstruct() {
-    local input="$1"
-    local name="$2"
-    "${PHP_CMD[@]}" bstruct_generator/bstruct.php --input-file "${input}" --output-dir "${OUT_DIR}" --name "bstruct_${name}"
-}
-
 function do_flex() {
     local input="$1"
     local name="$2"
@@ -48,8 +42,6 @@ mkdir -p generated
 bproto tests/bproto_test.bproto bproto_test
 bproto protocol/msgproto.bproto msgproto
 bproto protocol/addr.bproto addr
-bstruct tests/bstruct_test.bstruct bstruct_test
-bstruct security/OTPChecker.bstruct OTPChecker
 do_flex predicate/BPredicate.l BPredicate
 do_bison predicate/BPredicate.y BPredicate
 "${PHP_CMD[@]}" blog_generator/blog.php --input-file blog_channels.txt --output-dir "${OUT_DIR}"

+ 0 - 202
generated/bstruct_OTPChecker.h

@@ -1,202 +0,0 @@
-/*
-    DO NOT EDIT THIS FILE!
-    This file was automatically generated by the bstruct generator.
-*/
-
-#include <stdint.h>
-#include <limits.h>
-
-#include <misc/balign.h>
-#include <misc/debug.h>
-
-
-typedef struct oc_table_struct oc_table;
-
-typedef struct {
-    size_t id_off;
-    size_t id_size;
-    #ifndef NDEBUG
-    size_t id_count;
-    #endif
-
-    size_t entries_off;
-    size_t entries_size;
-    #ifndef NDEBUG
-    size_t entries_count;
-    #endif
-
-    size_t len;
-    size_t align;
-} oc_tableParams;
-
-static int oc_tableParams_Init (oc_tableParams *o, int num_entries) WARN_UNUSED;
-
-static int oc_tableParams_Init (oc_tableParams *o, int num_entries)
-{
-    size_t cur_size;
-    size_t cur_align;
-    size_t cur_count;
-
-    o->len = 0;
-    o->align = 1;
-
-    if ((sizeof(uint16_t)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(uint16_t));
-    if ((__alignof__(uint16_t)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(uint16_t));
-    if (1 > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (1);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->id_off = balign_up(o->len, cur_align);
-    o->id_size = cur_size;
-    #ifndef NDEBUG
-    o->id_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->id_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->id_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    if ((sizeof(struct OTPChecker_entry)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(struct OTPChecker_entry));
-    if ((__alignof__(struct OTPChecker_entry)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(struct OTPChecker_entry));
-    if (num_entries > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (num_entries);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->entries_off = balign_up(o->len, cur_align);
-    o->entries_size = cur_size;
-    #ifndef NDEBUG
-    o->entries_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->entries_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->entries_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    return 1;
-}
-
-static uint16_t * oc_table_id (oc_tableParams *o, oc_table *s)
-{
-    return (uint16_t *)((uint8_t *)s + o->id_off);
-}
-
-static uint16_t * oc_table_id_at (oc_tableParams *o, oc_table *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->id_count)
-
-    return (uint16_t *)((uint8_t *)s + o->id_off + i * o->id_size);
-}
-
-static struct OTPChecker_entry * oc_table_entries (oc_tableParams *o, oc_table *s)
-{
-    return (struct OTPChecker_entry *)((uint8_t *)s + o->entries_off);
-}
-
-static struct OTPChecker_entry * oc_table_entries_at (oc_tableParams *o, oc_table *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->entries_count)
-
-    return (struct OTPChecker_entry *)((uint8_t *)s + o->entries_off + i * o->entries_size);
-}
-
-typedef struct oc_tables_struct oc_tables;
-
-typedef struct {
-    oc_tableParams tables_params;
-    size_t tables_off;
-    size_t tables_size;
-    #ifndef NDEBUG
-    size_t tables_count;
-    #endif
-
-    size_t len;
-    size_t align;
-} oc_tablesParams;
-
-static int oc_tablesParams_Init (oc_tablesParams *o, int num_tables, int num_entries) WARN_UNUSED;
-
-static int oc_tablesParams_Init (oc_tablesParams *o, int num_tables, int num_entries)
-{
-    size_t cur_size;
-    size_t cur_align;
-    size_t cur_count;
-
-    o->len = 0;
-    o->align = 1;
-
-    if (!oc_tableParams_Init(&o->tables_params, num_entries)) {
-        return 0;
-    }
-    if (o->tables_params.len > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = o->tables_params.len;
-    if (o->tables_params.align > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = o->tables_params.align;
-    if (num_tables > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (num_tables);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->tables_off = balign_up(o->len, cur_align);
-    o->tables_size = cur_size;
-    #ifndef NDEBUG
-    o->tables_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->tables_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->tables_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    return 1;
-}
-
-static oc_table * oc_tables_tables (oc_tablesParams *o, oc_tables *s)
-{
-    return (oc_table *)((uint8_t *)s + o->tables_off);
-}
-
-static oc_table * oc_tables_tables_at (oc_tablesParams *o, oc_tables *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->tables_count)
-
-    return (oc_table *)((uint8_t *)s + o->tables_off + i * o->tables_size);
-}
-

+ 0 - 298
generated/bstruct_bstruct_test.h

@@ -1,298 +0,0 @@
-/*
-    DO NOT EDIT THIS FILE!
-    This file was automatically generated by the bstruct generator.
-*/
-
-#include <stdint.h>
-#include <limits.h>
-
-#include <misc/balign.h>
-#include <misc/debug.h>
-
-
-typedef struct str0_struct str0;
-
-typedef struct {
-    size_t x_off;
-    size_t x_size;
-    #ifndef NDEBUG
-    size_t x_count;
-    #endif
-
-    size_t len;
-    size_t align;
-} str0Params;
-
-static int str0Params_Init (str0Params *o, int n) WARN_UNUSED;
-
-static int str0Params_Init (str0Params *o, int n)
-{
-    size_t cur_size;
-    size_t cur_align;
-    size_t cur_count;
-
-    o->len = 0;
-    o->align = 1;
-
-    if ((sizeof(int)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(int));
-    if ((__alignof__(int)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(int));
-    if (n > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (n);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->x_off = balign_up(o->len, cur_align);
-    o->x_size = cur_size;
-    #ifndef NDEBUG
-    o->x_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->x_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->x_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    return 1;
-}
-
-static int * str0_x (str0Params *o, str0 *s)
-{
-    return (int *)((uint8_t *)s + o->x_off);
-}
-
-static int * str0_x_at (str0Params *o, str0 *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->x_count)
-
-    return (int *)((uint8_t *)s + o->x_off + i * o->x_size);
-}
-
-typedef struct str1_struct str1;
-
-typedef struct {
-    size_t a_off;
-    size_t a_size;
-    #ifndef NDEBUG
-    size_t a_count;
-    #endif
-
-    size_t b_off;
-    size_t b_size;
-    #ifndef NDEBUG
-    size_t b_count;
-    #endif
-
-    size_t c_off;
-    size_t c_size;
-    #ifndef NDEBUG
-    size_t c_count;
-    #endif
-
-    str0Params d_params;
-    size_t d_off;
-    size_t d_size;
-    #ifndef NDEBUG
-    size_t d_count;
-    #endif
-
-    size_t len;
-    size_t align;
-} str1Params;
-
-static int str1Params_Init (str1Params *o, int nb, int nc, int m) WARN_UNUSED;
-
-static int str1Params_Init (str1Params *o, int nb, int nc, int m)
-{
-    size_t cur_size;
-    size_t cur_align;
-    size_t cur_count;
-
-    o->len = 0;
-    o->align = 1;
-
-    if ((sizeof(int)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(int));
-    if ((__alignof__(int)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(int));
-    if (1 > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (1);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->a_off = balign_up(o->len, cur_align);
-    o->a_size = cur_size;
-    #ifndef NDEBUG
-    o->a_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->a_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->a_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    if ((sizeof(char)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(char));
-    if ((__alignof__(char)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(char));
-    if (nb > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (nb);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->b_off = balign_up(o->len, cur_align);
-    o->b_size = cur_size;
-    #ifndef NDEBUG
-    o->b_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->b_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->b_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    if ((sizeof(double)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = (sizeof(double));
-    if ((__alignof__(double)) > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = (__alignof__(double));
-    if (nc > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (nc);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->c_off = balign_up(o->len, cur_align);
-    o->c_size = cur_size;
-    #ifndef NDEBUG
-    o->c_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->c_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->c_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    if (!str0Params_Init(&o->d_params, m)) {
-        return 0;
-    }
-    if (o->d_params.len > SIZE_MAX) {
-        return 0;
-    }
-    cur_size = o->d_params.len;
-    if (o->d_params.align > SIZE_MAX) {
-        return 0;
-    }
-    cur_align = o->d_params.align;
-    if (1 > SIZE_MAX) {
-        return 0;
-    }
-    cur_count = (1);
-    if (balign_up_overflows(o->len, cur_align)) {
-        return 0;
-    }
-    o->d_off = balign_up(o->len, cur_align);
-    o->d_size = cur_size;
-    #ifndef NDEBUG
-    o->d_count = cur_count;
-    #endif
-    if (cur_count > SIZE_MAX / cur_size) {
-        return 0;
-    }
-    if (o->d_off > SIZE_MAX - cur_count * cur_size) {
-        return 0;
-    }
-    o->len = o->d_off + cur_count * cur_size;
-    o->align = (cur_align > o->align ? cur_align : o->align);
-
-    return 1;
-}
-
-static int * str1_a (str1Params *o, str1 *s)
-{
-    return (int *)((uint8_t *)s + o->a_off);
-}
-
-static int * str1_a_at (str1Params *o, str1 *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->a_count)
-
-    return (int *)((uint8_t *)s + o->a_off + i * o->a_size);
-}
-
-static char * str1_b (str1Params *o, str1 *s)
-{
-    return (char *)((uint8_t *)s + o->b_off);
-}
-
-static char * str1_b_at (str1Params *o, str1 *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->b_count)
-
-    return (char *)((uint8_t *)s + o->b_off + i * o->b_size);
-}
-
-static double * str1_c (str1Params *o, str1 *s)
-{
-    return (double *)((uint8_t *)s + o->c_off);
-}
-
-static double * str1_c_at (str1Params *o, str1 *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->c_count)
-
-    return (double *)((uint8_t *)s + o->c_off + i * o->c_size);
-}
-
-static str0 * str1_d (str1Params *o, str1 *s)
-{
-    return (str0 *)((uint8_t *)s + o->d_off);
-}
-
-static str0 * str1_d_at (str1Params *o, str1 *s, size_t i)
-{
-    ASSERT(i >= 0)
-    ASSERT(i < o->d_count)
-
-    return (str0 *)((uint8_t *)s + o->d_off + i * o->d_size);
-}
-

+ 31 - 21
security/OTPChecker.c

@@ -22,21 +22,23 @@
 
 #include <string.h>
 
+#include <misc/balloc.h>
+
 #include <security/OTPChecker.h>
 
-static void OTPChecker_Table_Empty (OTPChecker *mc, oc_table *t);
-static void OTPChecker_Table_AddOTP (OTPChecker *mc, oc_table *t, otp_t otp);
-static void OTPChecker_Table_Generate (OTPChecker *mc, oc_table *t, OTPCalculator *calc, uint8_t *key, uint8_t *iv);
-static int OTPChecker_Table_CheckOTP (OTPChecker *mc, oc_table *t, otp_t otp);
+static void OTPChecker_Table_Empty (OTPChecker *mc, struct OTPChecker_table *t);
+static void OTPChecker_Table_AddOTP (OTPChecker *mc, struct OTPChecker_table *t, otp_t otp);
+static void OTPChecker_Table_Generate (OTPChecker *mc, struct OTPChecker_table *t, OTPCalculator *calc, uint8_t *key, uint8_t *iv);
+static int OTPChecker_Table_CheckOTP (OTPChecker *mc, struct OTPChecker_table *t, otp_t otp);
 
-void OTPChecker_Table_Empty (OTPChecker *mc, oc_table *t)
+void OTPChecker_Table_Empty (OTPChecker *mc, struct OTPChecker_table *t)
 {
     for (int i = 0; i < mc->num_entries; i++) {
-        oc_table_entries_at(&mc->tables_params.tables_params, t, i)->avail = -1;
+        t->entries[i].avail = -1;
     }
 }
 
-void OTPChecker_Table_AddOTP (OTPChecker *mc, oc_table *t, otp_t otp)
+void OTPChecker_Table_AddOTP (OTPChecker *mc, struct OTPChecker_table *t, otp_t otp)
 {
     // calculate starting index
     int start_index = otp % mc->num_entries;
@@ -44,7 +46,7 @@ void OTPChecker_Table_AddOTP (OTPChecker *mc, oc_table *t, otp_t otp)
     // try indexes starting with the base position
     for (int i = 0; i < mc->num_entries; i++) {
         int index = BMODADD(start_index, i, mc->num_entries);
-        struct OTPChecker_entry *entry = oc_table_entries_at(&mc->tables_params.tables_params, t, index);
+        struct OTPChecker_entry *entry = &t->entries[index];
         
         // if we find a free index, use it
         if (entry->avail < 0) {
@@ -65,7 +67,7 @@ void OTPChecker_Table_AddOTP (OTPChecker *mc, oc_table *t, otp_t otp)
     ASSERT(0)
 }
 
-void OTPChecker_Table_Generate (OTPChecker *mc, oc_table *t, OTPCalculator *calc, uint8_t *key, uint8_t *iv)
+void OTPChecker_Table_Generate (OTPChecker *mc, struct OTPChecker_table *t, OTPCalculator *calc, uint8_t *key, uint8_t *iv)
 {
     // calculate values
     otp_t *otps = OTPCalculator_Generate(calc, key, iv, 0);
@@ -79,7 +81,7 @@ void OTPChecker_Table_Generate (OTPChecker *mc, oc_table *t, OTPCalculator *calc
     }
 }
 
-int OTPChecker_Table_CheckOTP (OTPChecker *mc, oc_table *t, otp_t otp)
+int OTPChecker_Table_CheckOTP (OTPChecker *mc, struct OTPChecker_table *t, otp_t otp)
 {
     // calculate starting index
     int start_index = otp % mc->num_entries;
@@ -87,7 +89,7 @@ int OTPChecker_Table_CheckOTP (OTPChecker *mc, oc_table *t, otp_t otp)
     // try indexes starting with the base position
     for (int i = 0; i < mc->num_entries; i++) {
         int index = BMODADD(start_index, i, mc->num_entries);
-        struct OTPChecker_entry *entry = oc_table_entries_at(&mc->tables_params.tables_params, t, index);
+        struct OTPChecker_entry *entry = &t->entries[index];
         
         // if we find an empty entry, there is no such mac
         if (entry->avail < 0) {
@@ -111,7 +113,7 @@ int OTPChecker_Table_CheckOTP (OTPChecker *mc, oc_table *t, otp_t otp)
 
 static void work_func (OTPChecker *mc)
 {
-    oc_table *table = oc_tables_tables_at(&mc->tables_params, mc->tables, mc->next_table);
+    struct OTPChecker_table *table = &mc->tables[mc->next_table];
     OTPChecker_Table_Generate(mc, table, &mc->calc, mc->tw_key, mc->tw_iv);
 }
 
@@ -170,16 +172,20 @@ int OTPChecker_Init (OTPChecker *mc, int num_otps, int cipher, int num_tables, B
     }
     
     // allocate tables
-    if (!(oc_tablesParams_Init(&mc->tables_params, mc->num_tables, mc->num_entries))) {
+    if (!(mc->tables = BAllocArray(mc->num_tables, sizeof(mc->tables[0])))) {
         goto fail1;
     }
-    if (!(mc->tables = malloc(mc->tables_params.len))) {
-        goto fail1;
+    
+    // allocate entries
+    if (!(mc->entries = BAllocArray2(mc->num_tables, mc->num_entries, sizeof(mc->entries[0])))) {
+        goto fail2;
     }
     
     // initialize tables
     for (int i = 0; i < mc->num_tables; i++) {
-        OTPChecker_Table_Empty(mc, oc_tables_tables_at(&mc->tables_params, mc->tables, i));
+        struct OTPChecker_table *table = &mc->tables[i];
+        table->entries = mc->entries + i * mc->num_entries;
+        OTPChecker_Table_Empty(mc, table);
     }
     
     // have no work
@@ -188,6 +194,8 @@ int OTPChecker_Init (OTPChecker *mc, int num_otps, int cipher, int num_tables, B
     DebugObject_Init(&mc->d_obj);
     return 1;
     
+fail2:
+    BFree(mc->tables);
 fail1:
     OTPCalculator_Free(&mc->calc);
 fail0:
@@ -203,8 +211,11 @@ void OTPChecker_Free (OTPChecker *mc)
         BThreadWork_Free(&mc->tw);
     }
     
+    // free entries
+    BFree(mc->entries);
+    
     // free tables
-    free(mc->tables);
+    BFree(mc->tables);
     
     // free calculator
     OTPCalculator_Free(&mc->calc);
@@ -222,8 +233,7 @@ void OTPChecker_AddSeed (OTPChecker *mc, uint16_t seed_id, uint8_t *key, uint8_t
     }
     
     // set table's seed ID
-    oc_table *table = oc_tables_tables_at(&mc->tables_params, mc->tables, mc->next_table);
-    *oc_table_id(&mc->tables_params.tables_params, table) = seed_id;
+    mc->tables[mc->next_table].id = seed_id;
     
     // copy key and IV
     memcpy(mc->tw_key, key, BEncryption_cipher_key_size(mc->cipher));
@@ -262,8 +272,8 @@ int OTPChecker_CheckOTP (OTPChecker *mc, uint16_t seed_id, otp_t otp)
             continue;
         }
         
-        oc_table *table = oc_tables_tables_at(&mc->tables_params, mc->tables, table_index);
-        if (*oc_table_id(&mc->tables_params.tables_params, table) == seed_id) {
+        struct OTPChecker_table *table = &mc->tables[table_index];
+        if (table->id == seed_id) {
             return OTPChecker_Table_CheckOTP(mc, table, otp);
         }
     }

+ 6 - 3
security/OTPChecker.h

@@ -41,7 +41,10 @@ struct OTPChecker_entry {
     int avail;
 };
 
-#include <generated/bstruct_OTPChecker.h>
+struct OTPChecker_table {
+    uint16_t id;
+    struct OTPChecker_entry *entries;
+};
 
 /**
  * Handler called when OTP generation for a seed is finished and new OTPs
@@ -65,8 +68,8 @@ typedef struct {
     int tables_used;
     int next_table;
     OTPCalculator calc;
-    oc_tablesParams tables_params;
-    oc_tables *tables;
+    struct OTPChecker_table *tables;
+    struct OTPChecker_entry *entries;
     int tw_have;
     BThreadWork tw;
     uint8_t tw_key[BENCRYPTION_MAX_KEY_SIZE];

+ 0 - 2
tests/CMakeLists.txt

@@ -2,7 +2,5 @@ add_executable(chunkbuffer2_test chunkbuffer2_test.c)
 
 add_executable(bproto_test bproto_test.c)
 
-add_executable(bstruct_test bstruct_test.c)
-
 add_executable(threadwork_test threadwork_test.c)
 target_link_libraries(threadwork_test threadwork)

+ 0 - 23
tests/bstruct_test.c

@@ -1,23 +0,0 @@
-#include <stdint.h>
-#include <stdint.h>
-
-#include <misc/debug.h>
-
-#include <generated/bstruct_bstruct_test.h>
-
-int main ()
-{
-    int nb = 3;
-    int nc = 2;
-    int m = 6;
-    
-    str1Params p;
-    ASSERT_FORCE(str1Params_Init(&p, nb, nc, m))
-    
-    printf("len=%zu align=%zu\n", p.len, p.align);
-    
-    void *s = malloc(p.len);
-    ASSERT_FORCE(s)
-    
-    return 0;
-}