Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
cifcmnrecs.c
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 
00037 static char USMID[] = "\n@(#)5.0_pl/sources/cifcmnrecs.c        5.2     06/17/99 09:28:10\n";
00038 
00039 #include <stdio.h>
00040 
00041 
00042 #define CIF_VERSION     3
00043 
00044 #include "cif.m"
00045 
00046 #include "cif.h"
00047 
00048 extern void     Cif_Error (void);
00049 
00050 
00051 
00052 /******************************************************************************\
00053 |*                                                                            *|
00054 |* Description:                                                               *|
00055 |*      Output the CIF Header record [2].                                     *|
00056 |*                                                                            *|
00057 |* Input parameters:                                                          *|
00058 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00059 |*      language_code:     A numeric representation of the programming        *|
00060 |*                         language used in the source program.               *|
00061 |*      compiler_version:                                                     *|
00062 |*      cif_creation_date:                                                    *|
00063 |*      cif_creation_time:                                                    *|
00064 |*      group_id:                                                             *|
00065 |*      message_catalog_file_id:                                              *|
00066 |*      host_cpu_name:                                                        *|
00067 |*      host_cpu_type:                                                        *|
00068 |*                                                                            *|
00069 |* Output parameters:                                                         *|
00070 |*      NONE                                                                  *|
00071 |*                                                                            *|
00072 |* Returns:                                                                   *|
00073 |*      NOTHING                                                               *|
00074 |*                                                                            *|
00075 \******************************************************************************/
00076 
00077 void  Cif_Cifhdr_Rec(FILE       *c_i_f,
00078                     int          language_code,
00079                     char        *compiler_version,
00080                     char        *cif_creation_date,
00081                     char        *cif_creation_time,
00082                     char        *group_id,
00083                     int          message_catalog_file_id,
00084                     char        *host_cpu_name,
00085                     char        *host_cpu_type)
00086 {
00087 
00088    if (fprintf(c_i_f,
00089                "%d%c%s%c%s%c%d%c%s%c%s%c%s%c%s%c%d%c%s%c%s%c",
00090                CIF_CIFHDR, EOI,
00091                "cif", EOI,
00092                "V03", EOI,
00093                language_code, EOI,
00094                compiler_version, EOI,
00095                cif_creation_date, EOI,
00096                cif_creation_time, EOI,
00097                group_id, EOI,
00098                message_catalog_file_id, EOI,
00099                host_cpu_name, EOI,
00100                host_cpu_type, EOR) < 0) {
00101       Cif_Error();
00102    }
00103 
00104    return;
00105 
00106 } /*  Cif_Cifhdr_Rec  */
00107 
00108 
00109 /******************************************************************************\
00110 |*                                                                            *|
00111 |* Description:                                                               *|
00112 |*      Output a File Name record [7].                                        *|
00113 |*                                                                            *|
00114 |* Input parameters:                                                          *|
00115 |*      c_i_f:     The file pointer to the CIF being produced.                *|
00116 |*      file_name: A character array containing the file name.                *|
00117 |*      file_id:   Unique numeric value associated with the file name.        *|
00118 |*      user_specified_file_name:                                             *|
00119 |*                                                                            *|
00120 |* Output parameters:                                                         *|
00121 |*      NONE                                                                  *|
00122 |*                                                                            *|
00123 |* Returns:                                                                   *|
00124 |*      NOTHING                                                               *|
00125 |*                                                                            *|
00126 \******************************************************************************/
00127 
00128 void Cif_File_Rec(FILE  *c_i_f,
00129                   char  *file_name,
00130                   int    file_id,
00131                   char  *user_specified_file_name)
00132 {
00133    if (fprintf(c_i_f, "%d%c%s%c%d%c%s%c",
00134                       CIF_FILE, EOI,
00135                       file_name, EOI,
00136                       file_id, EOI,
00137                       (user_specified_file_name == (char *) NULL) ? "" :
00138                          user_specified_file_name, EOR) < 0) {
00139       Cif_Error();
00140    }
00141 
00142    return;
00143 
00144 }  /* Cif_File_Rec */
00145 
00146 
00147 /******************************************************************************\
00148 |*                                                                            *|
00149 |* Description:                                                               *|
00150 |*      Output a Message record [11].                                         *|
00151 |*                                                                            *|
00152 |* Input parameters:                                                          *|
00153 |*      c_i_f:              The file pointer to the CIF being produced.       *|
00154 |*      message_severity:   The severity level of the message.                *|
00155 |*      message_number:     The message number.                               *|
00156 |*      file_id:                                                              *|
00157 |*      global_line_number: The global source line number.                    *|
00158 |*      column_number:      The column number of the offending text (may be   *|
00159 |*                          0).                                               *|
00160 |*      file_line_number:                                                     *|
00161 |*      number_of_inserts:                                                    *|
00162 |*      message_insert:     A pointer to an array of character strings        *|
00163 |*                          containing the message inserts.                   *|
00164 |*      procedure_name:                                                       *|
00165 |*      relative_message_order:                                               *|
00166 |*      flags:                                                                *|
00167 |*      physical_file_id:
00168 |*                                                                            *|
00169 |* Output parameters:                                                         *|
00170 |*      NONE                                                                  *|
00171 |*                                                                            *|
00172 |* Returns:                                                                   *|
00173 |*      NOTHING                                                               *|
00174 |*                                                                            *|
00175 \******************************************************************************/
00176 
00177 void Cif_Message_Rec(FILE       *c_i_f,
00178                      int         msg_severity,
00179                      int         msg_number,
00180                      int         file_id,
00181                      int         global_line_number,
00182                      int         column_number,
00183                      int         file_line_number,
00184                      int         number_of_inserts,
00185                      char       *message_insert[],
00186                      char       *procedure_name,
00187                      int         relative_message_order,
00188                      int         flags,
00189                      int         physical_file_id)
00190 
00191 {
00192    int  i;
00193 
00194 
00195    if (fprintf(c_i_f, "%d%c%d%c%d%c%d%c%d%c%d%c%d%c%d",
00196                       CIF_MESSAGE, EOI,
00197                       msg_severity, EOI,
00198                       msg_number, EOI,
00199                       file_id, EOI,
00200                       global_line_number, EOI,
00201                       column_number, EOI,
00202                       file_line_number, EOI,
00203                       number_of_inserts) < 0) {
00204       Cif_Error();
00205    }
00206 
00207    for (i = 0;  i < number_of_inserts;  ++i) {
00208     
00209       if (fprintf(c_i_f, "%c%s",
00210                          EOI, message_insert[i]) < 0) {
00211          Cif_Error();
00212       }
00213    }
00214 
00215    if (fprintf(c_i_f, "%c%s%c%d%c%d%c%d%c",
00216                       EOI,
00217                       procedure_name, EOI,
00218                       relative_message_order, EOI,
00219                       flags, EOI,
00220                       physical_file_id, EOR) < 0) {
00221       Cif_Error();
00222    }
00223 
00224    return;
00225 
00226 }  /* Cif_Message_Rec */
00227 
00228 
00229 /******************************************************************************\
00230 |*                                                                            *|
00231 |* Description:                                                               *|
00232 |*      Output a Summary record [15].                                         *|
00233 |*                                                                            *|
00234 |* Input parameters:                                                          *|
00235 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00236 |*      release_level:    Compiler release level                              *|
00237 |*      gen_date:         Date the compiler was created                       *|
00238 |*      gen_time:         Time of day the compiler was created                *|
00239 |*      compilation_time: Cray    : compilation time in microseconds          *|
00240 |*                        non-Cray: compilation time in microseconds for a    *|
00241 |*                                   "short" compilation, otherwise in        *|
00242 |*                                   seconds; see Algorithm notes below       *|
00243 |*      max_field_length: Maximum amount of memory used                       *|
00244 |*      num_source_lines: Total number of source lines compiled including     *|
00245 |*                        lines in INCLUDE files                              *|
00246 |*      code_size:        Number of words of code generated.                  *|
00247 |*      data_size:        Number of words of static data generated.           *|
00248 |*                                                                            *|
00249 |* Output parameters:                                                         *|
00250 |*      NONE                                                                  *|
00251 |*                                                                            *|
00252 |* Returns:                                                                   *|
00253 |*      NOTHING                                                               *|
00254 |*                                                                            *|
00255 \******************************************************************************/
00256 
00257 void Cif_Summary_Rec(FILE       *c_i_f,
00258                      char       *release_level,
00259                      char       *gen_date,
00260                      char       *gen_time,
00261                      char       *compilation_time,
00262                      long        max_field_length,
00263                      int         num_source_lines,
00264                      int         code_size,
00265                      int         data_size)
00266 {
00267    if (fprintf(c_i_f, "%d%c%s%c%s%c%s%c%s%c%ld%c%d%c%d%c%d%c",
00268                       CIF_SUMMARY, EOI,
00269                       release_level, EOI,
00270                       gen_date, EOI,
00271                       gen_time, EOI, 
00272                       compilation_time, EOI,
00273                       max_field_length, EOI,
00274                       num_source_lines, EOI,
00275                       code_size, EOI,
00276                       data_size, EOR) < 0) {
00277       Cif_Error();
00278    }
00279 
00280    return;
00281 
00282 }  /* Cif_Summary_Rec */
00283 
00284 
00285 /******************************************************************************\
00286 |*                                                                            *|
00287 |* Description:                                                               *|
00288 |*      Output a Unit record [17].                                            *|
00289 |*                                                                            *|
00290 |* Input parameters:                                                          *|
00291 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00292 |*      comp_unit_name:                                                       *|
00293 |*      file_id:                                                              *|
00294 |*      line_number:                                                          *|
00295 |*      column_number:                                                        *|
00296 |*                                                                            *|
00297 |* Output parameters:                                                         *|
00298 |*      NONE                                                                  *|
00299 |*                                                                            *|
00300 |* Returns:                                                                   *|
00301 |*      NOTHING                                                               *|
00302 |*                                                                            *|
00303 \******************************************************************************/
00304 
00305 void  Cif_Unit_Rec(FILE         *c_i_f,
00306                   char          *comp_unit_name,
00307                   int            file_id,
00308                   int            line_number,
00309                   int            column_number)
00310 {
00311    if (fprintf(c_i_f, "%d%c%s%c%d%c%d%c%d%c",
00312                       CIF_UNIT, EOI,
00313                       comp_unit_name, EOI, 
00314                       file_id, EOI,
00315                       line_number, EOI,
00316                       column_number, EOR) < 0) {
00317       Cif_Error();
00318    }
00319 
00320    return;
00321 
00322 }  /* Cif_Unit_Rec */
00323 
00324 
00325 /******************************************************************************\
00326 |*                                                                            *|
00327 |* Description:                                                               *|
00328 |*      Output an End Unit record [18].                                       *|
00329 |*                                                                            *|
00330 |* Input parameters:                                                          *|
00331 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00332 |*      comp_unit_name:                                                       *|
00333 |*      file_id:                                                              *|
00334 |*      line_number:                                                          *|
00335 |*      column_number:                                                        *|
00336 |*                                                                            *|
00337 |* Output parameters:                                                         *|
00338 |*      NONE                                                                  *|
00339 |*                                                                            *|
00340 |* Returns:                                                                   *|
00341 |*      NOTHING                                                               *|
00342 |*                                                                            *|
00343 \******************************************************************************/
00344 
00345 void Cif_Endunit_Rec(FILE      *c_i_f,
00346                      char      *comp_unit_name,
00347                      int        file_id,
00348                      int        line_number,
00349                      int        column_number)
00350 {
00351    if (fprintf(c_i_f, "%d%c%s%c%d%c%d%c%d%c",
00352                       CIF_ENDUNIT, EOI,
00353                       comp_unit_name, EOI,
00354                       file_id, EOI,
00355                       line_number, EOI,
00356                       column_number, EOR) < 0) {
00357       Cif_Error();
00358    }
00359 
00360    return;
00361 
00362 }  /* Cif_Endunit_Rec */
00363 
00364 
00365 /******************************************************************************\
00366 |*                                                                            *|
00367 |* Description:                                                               *|
00368 |*      Output a Command Line Options record [70].                            *|
00369 |*                                                                            *|
00370 |* Input parameters:                                                          *|
00371 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00372 |*      options:                                                              *|
00373 |*                                                                            *|
00374 |* Output parameters:                                                         *|
00375 |*      NONE                                                                  *|
00376 |*                                                                            *|
00377 |* Returns:                                                                   *|
00378 |*      NOTHING                                                               *|
00379 |*                                                                            *|
00380 \******************************************************************************/
00381 
00382 void Cif_Orig_Cmd(FILE      *c_i_f,
00383                   char      *options)
00384 {
00385    if (fprintf(c_i_f, "%d%c%s%c",
00386                       CIF_ORIG_CMD, EOI,
00387                       options, EOR) < 0) {
00388       Cif_Error();
00389    }
00390 
00391    return;
00392 
00393 }  /* Cif_Orig_Cmd_Rec */
00394 
00395 
00396 /******************************************************************************\
00397 |*                                                                            *|
00398 |* Description:                                                               *|
00399 |*      Output a Source Position record [86].                                 *|
00400 |*                                                                            *|
00401 |* Input parameters:                                                          *|
00402 |*      c_i_f:            The file pointer to the CIF being produced.         *|
00403 |*      record_type:                                                          *|
00404 |*      source_pos_id:                                                        *|
00405 |*      parent_source_pos_id:                                                 *|
00406 |*      start_line_number:                                                    *|
00407 |*      start_column_number:                                                  *|
00408 |*      file_id:                                                              *|
00409 |*      end_line_number:                                                      *|
00410 |*      end_column_number:                                                    *|
00411 |*      macro_sym_id:                                                         *|
00412 |*                                                                            *|
00413 |* Output parameters:                                                         *|
00414 |*      NONE                                                                  *|
00415 |*                                                                            *|
00416 |* Returns:                                                                   *|
00417 |*      NOTHING                                                               *|
00418 |*                                                                            *|
00419 \******************************************************************************/
00420 
00421 void Cif_Src_Pos_Rec(FILE      *c_i_f,
00422                      int        record_type,
00423                      int        source_pos_id,
00424                      int        parent_source_pos_id,
00425                      int        start_line_number,
00426                      int        start_column_number,
00427                      int        file_id,
00428                      int        end_line_number,
00429                      int        end_column_number,
00430                      int        macro_sym_id)
00431 {
00432    if (fprintf(c_i_f, "%d%c%d%c%d%c%d%c%d%c%d%c%d%c%d%c%d%c%d%c",
00433                       CIF_SRC_POS, EOI,
00434                       record_type, EOI,
00435                       source_pos_id, EOI,
00436                       parent_source_pos_id, EOI,
00437                       start_line_number, EOI,
00438                       start_column_number, EOI,
00439                       file_id, EOI,
00440                       end_line_number, EOI,
00441                       end_column_number, EOI,
00442                       macro_sym_id, EOR) < 0) {
00443       Cif_Error();
00444    }
00445 
00446    return;
00447 
00448 }  /* Cif_Source_Position_Rec */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines