source: rtems/c/src/exec/score/tools/sh/shgen.c @ fa21a843

4.104.114.84.95
Last change on this file since fa21a843 was fa21a843, checked in by Joel Sherrill <joel.sherrill@…>, on 07/17/98 at 15:17:29

New files from Ralf Corsepius <corsepiu@…>. His comments:

  • c/src/exec/score/tools/sh - NEW DIRECTORY - contains shgen Most of it should be self-explanatory. I am a little bit concerned about host-dependent features (getopt, floating point libraries). This shouldn't disturb much now, as this tool should be compileable on all gnu-based hosts and is only applicable for the sh. But in case somebody complains, we may need to add autoconf checks or even restructurize parts of rtems (IMO, rtems needs to be restructurized - remember the "turning rtems upside down" issue).
  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2 * Copyright (c) 1998 Ralf Corsepius (corsepiu@faw.uni-ulm.de)
3 *
4 * See the file COPYING for copyright notice.
5 */
6
7#include <stdio.h>
8#include <string.h>     /* strcmp, strerror */
9#include <errno.h>
10#include <getopt.h>
11
12#include "sci.h"
13
14static void usage( char *prog )
15{
16  fprintf( stderr, "usage: %s [options] driver\n", prog );
17  fprintf( stderr, "options:\n" );
18  fprintf( stderr, "\t-M Phi      .. processor frequency [MHz] default: 20\n" );
19  fprintf( stderr, "driver:\n" );
20  fprintf( stderr, "\tsci .. bitrate table for sci\n" );
21  exit ( 1 );
22}
23
24static void shgen_header( FILE *file )
25{
26  fprintf( file,
27    "/*\n * DO NOT EDIT - this file is automatically generated by shgen\n" );
28  fprintf( file,
29    " * Copyright (c) 1998, Ralf Corsepius (corsepiu@faw.uni-ulm.de)\n */\n" );
30  fprintf( file,
31    "\n/* This file is not copyrighted */\n\n" );
32}
33
34int main( int argc, char *argv[] )
35{
36  double        Phi = 20.0 ;
37 
38  while ( ( optopt = getopt( argc, argv, "M:" ) ) > 0 )
39  {
40    switch ( optopt )
41    {
42    case 'M' :
43      sscanf( optarg, "%lf", &Phi );
44      Phi = Phi * 1000000.0;
45      break ;
46    default  :
47      usage( argv[0] );
48      break ;
49    }
50  }
51
52  if ( argc - optind != 1 )
53    usage( argv[0] );
54
55  shgen_header( stdout );
56     
57  if ( strcmp( argv[optind], "sci" ) == 0 )
58  {
59    shgen_gensci( stdout, Phi );
60  }
61  else
62    usage( argv[0] );
63     
64  return 0 ;
65}
Note: See TracBrowser for help on using the repository browser.