parameter_types.c

来自「This a framework to test new ideas in tr」· C语言 代码 · 共 112 行

C
112
字号
/***************************************************************************         parameter_types.c  -  stores information about differet         parameter types for configuration and statistics                             -------------------     begin                :  2002    authors              :  Silvio Boehler    emails               :  sboehler@student.ethz.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description09.09.2002 - silvio - begin work  **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include "system.h"#include "debugging.h"#define DBG_LVL 4/** * Interface */#include "parameter_types.h"#include "swr_types.h"/** * The definitions of each parameter. The order is significant and * should follow the order of the sequence in parameter_type_t! */parameter_type_entry_t parameter_types[9] = {      {"Undefined", 0, 0},      {"Integer", sizeof( int ), sizeof( int ) },      {"Double", sizeof( double ), 1 },      {"Double_Complex", sizeof( double_complex ), 1 },      {"String128", 128, 1},      {"Block", sizeof( void * ) + 2 * sizeof( int ), 1 },      {"Image", sizeof( void * ) + 3 * sizeof( int ), 1 },      {"Pointer", sizeof( void * ), 1 },      {"Complex", sizeof( SYMBOL_COMPLEX ), 1 },    };//-------------------------------------------------------------------// PUBLIC FUNCTIONS//-------------------------------------------------------------------/** * Get the amount of bytes necessary to store a parameter of a given * type. */int get_size(parameter_type_t parameter_type) {  return parameter_types[parameter_type].size;}/** * Get the name of a parameter type. */const char *param_t_get_name(parameter_type_t parameter_type) {  return parameter_types[parameter_type].name;}/** * Copy a value with a certain type to destination. */int param_copy_value(parameter_type_t parameter_type, void *value, void *destination) {  char *value_ptr = value;  char *dest_ptr = destination;  if (value_ptr && dest_ptr) {    memcpy( dest_ptr, value_ptr, parameter_types[parameter_type].size );    return 0;  } else {    PR_DBG(0, "param_copy_value: Null pointer received\n");    return 1;  }}/** * Get the alignment of a type */int get_alignment(parameter_type_t parameter_type) {  return parameter_types[parameter_type].alignment;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?