"Fossies" - the Fresh Open Source Software Archive

Member "ponyc-0.33.2/src/libponyrt/options/options.h" (3 Feb 2020, 3562 Bytes) of package /linux/misc/ponyc-0.33.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "options.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 0.33.1_vs_0.33.2.

    1 #ifndef options_options_h
    2 #define options_options_h
    3 
    4 #include <stdint.h>
    5 
    6 #define OPT_ARG_REQUIRED 1 << 0
    7 #define OPT_ARG_OPTIONAL 1 << 1
    8 #define OPT_ARG_NONE     1 << 2
    9 #define OPT_ARGS_FINISH {NULL, 0, UINT32_MAX, UINT32_MAX}
   10 
   11 /* NOTE: if you change any of the argument help details, update the docstrings
   12  *       in `RuntimeOptions` in the `builtin` package to keep them in sync.
   13  */
   14 #define PONYRT_HELP \
   15   "Runtime options for Pony programs (not for use with ponyc):\n" \
   16   "  --ponymaxthreads Use N scheduler threads. Defaults to the number of\n" \
   17   "                   cores (not hyperthreads) available.\n" \
   18   "                   This can't be larger than the number of cores available.\n" \
   19   "  --ponyminthreads Minimum number of active scheduler threads allowed.\n" \
   20   "                   Defaults to 0, meaning that all scheduler threads are\n" \
   21   "                   allowed to be suspended when no work is available.\n" \
   22   "                   This can't be larger than --ponymaxthreads if provided,\n" \
   23   "                   or the physical cores available\n" \
   24   "  --ponynoscale    Don't scale down the scheduler threads.\n" \
   25   "                   See --ponymaxthreads on how to specify the number of threads\n" \
   26   "                   explicitly. Can't be used with --ponyminthreads.\n" \
   27   "  --ponysuspendthreshold\n" \
   28   "                   Amount of idle time before a scheduler thread suspends\n" \
   29   "                   itself to minimize resource consumption (max 1000 ms,\n" \
   30   "                   min 1 ms).\n" \
   31   "                   Defaults to 1 ms.\n" \
   32   "  --ponycdinterval Run cycle detection every N ms (max 1000 ms, min 10 ms).\n" \
   33   "                   Defaults to 100 ms.\n" \
   34   "  --ponygcinitial  Defer garbage collection until an actor is using at\n" \
   35   "                   least 2^N bytes. Defaults to 2^14.\n" \
   36   "  --ponygcfactor   After GC, an actor will next be GC'd at a heap memory\n" \
   37   "                   usage N times its current value. This is a floating\n" \
   38   "                   point value. Defaults to 2.0.\n" \
   39   "  --ponynoyield    Do not yield the CPU when no work is available.\n" \
   40   "  --ponynoblock    Do not send block messages to the cycle detector.\n" \
   41   "  --ponypin        Pin scheduler threads to CPU cores. The ASIO thread\n" \
   42   "                   can also be pinned if `--ponypinasio` is set.\n" \
   43   "  --ponypinasio    Pin the ASIO thread to a CPU the way scheduler\n" \
   44   "                   threads are pinned to CPUs. Requires `--ponypin` to\n" \
   45   "                   be set to have any effect.\n" \
   46   "  --ponyversion    Print the version of the compiler and exit.\n" \
   47   "  --ponyhelp       Print the runtime usage options and exit.\n" \
   48   "\n" \
   49   "NOTE: These can be programmatically overridden. See the docstring in the\n" \
   50   "      `RuntimeOptions` struct in the `builtin` package.\n"
   51 
   52 typedef struct opt_arg_t
   53 {
   54   const char* long_opt;
   55   const char short_opt;
   56   uint32_t flag;
   57   uint32_t id;
   58 } opt_arg_t;
   59 
   60 typedef struct opt_state_t
   61 {
   62   const opt_arg_t* args;
   63 
   64   int* argc;
   65   char** argv;
   66   char* arg_val;
   67 
   68   //do not touch :-)
   69   char* opt_start;
   70   char* opt_end;
   71   int match_type;
   72   int idx;
   73   int remove;
   74 } opt_state_t;
   75 
   76 void ponyint_opt_init(const opt_arg_t* args, opt_state_t* s, int* argc,
   77   char** argv);
   78 
   79 /** Find the unsigned identifier of the next option.
   80  *
   81  * Special return values:
   82  *
   83  * -1 when there are no more options to process.
   84  * -2 when an error is detected and an error message is printed.
   85  */
   86 int ponyint_opt_next(opt_state_t* s);
   87 
   88 #endif