version.h 4.71 KB
Newer Older
Elemer Lelik's avatar
Elemer Lelik committed
1
/******************************************************************************
Adam Knapp's avatar
Adam Knapp committed
2
 * Copyright (c) 2000-2021 Ericsson Telecom AB
Elemer Lelik's avatar
Elemer Lelik committed
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v2.0
Elemer Lelik's avatar
Elemer Lelik committed
5
 * which accompanies this distribution, and is available at
6
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
Elemer Lelik's avatar
Elemer Lelik committed
7 8 9 10 11 12
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *   Beres, Szabolcs
 *   Delic, Adam
13
 *   Knapp, Adam
Elemer Lelik's avatar
Elemer Lelik committed
14 15 16 17
 *   Kovacs, Ferenc
 *   Pandi, Krisztian
 *   Raduly, Csaba
 *   Szabados, Kristof
18
 *   Szabo, Bence Janos
Elemer Lelik's avatar
Elemer Lelik committed
19 20 21 22
 *   Szabo, Janos Zoltan – initial implementation
 *   Szalai, Gabor
 *
 ******************************************************************************/
Elemer Lelik's avatar
Elemer Lelik committed
23 24 25 26
#ifndef VERSION_H
#define VERSION_H

/* Version numbers */
Adam Knapp's avatar
Adam Knapp committed
27 28 29
#define TTCN3_MAJOR 8
#define TTCN3_MINOR 0
#define TTCN3_PATCHLEVEL 0 //0-> x=A, 1-> x=B, ...
BenceJanosSzabo's avatar
BenceJanosSzabo committed
30
//#define TTCN3_BUILDNUMBER 0  //0=R5x, 1=R5x01, 2=R5x02, ...
Elemer Lelik's avatar
Elemer Lelik committed
31 32 33 34

/* The aggregated version number must be set manually since some stupid
 * 'makedepend' programs cannot calculate arithmetic expressions.
 * In official releases:
BenceJanosSzabo's avatar
BenceJanosSzabo committed
35
 * To display the correct version comment out TTCN3_BUILDNUMBER
Elemer Lelik's avatar
Elemer Lelik committed
36 37
 * TTCN3_VERSION = TTCN3_MAJOR * 10000 + TTCN3_MINOR * 100 + TTCN3_PATCHLEVEL
 * In pre-release builds:
BenceJanosSzabo's avatar
BenceJanosSzabo committed
38
 * To display the correct version uncomment TTCN3_BUILDNUMBER
Elemer Lelik's avatar
Elemer Lelik committed
39 40 41
 * TTCN3_VERSION = TTCN3_MAJOR * 1000000 + TTCN3_MINOR * 10000 +
 *                 TTCN3_PATCHLEVEL * 100 + TTCN3_BUILDNUMBER
 */
42
#define TTCN3_VERSION 70202
Elemer Lelik's avatar
Elemer Lelik committed
43 44 45

/* A monotonically increasing version number.
 * An official release is deemed to have the highest possible build number (99)
46
 * The revisions R1A01, R1A02 ... R1A, R1B01, R1B02 ... R1B
Elemer Lelik's avatar
Elemer Lelik committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
 */
#ifdef TTCN3_BUILDNUMBER
#define TTCN3_VERSION_MONOTONE TTCN3_VERSION
#else
#define TTCN3_VERSION_MONOTONE (TTCN3_VERSION * 100 + 99)
#endif


#if defined (SOLARIS)
  #define PLATFORM_STRING "SOLARIS"
#elif defined (SOLARIS8)
  #define PLATFORM_STRING "SOLARIS8"
#elif defined (LINUX)
  #define PLATFORM_STRING "LINUX"
#elif defined (WIN32)
  /* MINGW is defined only if CYGWIN is defined */
  #if defined (MINGW)
    #define PLATFORM_STRING "MINGW"
  #else
    #define PLATFORM_STRING "WIN32"
  #endif
#elif defined (FREEBSD)
  #define PLATFORM_STRING "FREEBSD"
#elif defined (INTERIX)
  #define PLATFORM_STRING "INTERIX"
/* TODO more */
#endif


#ifndef PLATFORM_STRING
/* Just to suppress error later */
  #define PLATFORM_STRING "UNKNOWN"
  #error "No supported platform has been defined in the Makefile. The supported ones: SOLARIS, SOLARIS8, LINUX, WIN32"
#endif

#define STRINGIFY(x) #x
#define STR(x) STRINGIFY(x)

#if defined(__GNUC__)

  #ifdef __GNUC_PATCHLEVEL__
    #define GCC_PATCHLEVEL_STRING "." STR(__GNUC_PATCHLEVEL__)
  #else
    /* __GNUC_PATCHLEVEL__ appeared in gcc 3.0 */
    #define GCC_PATCHLEVEL_STRING
  #endif

#ifdef __clang__
95
  #define CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100)
96
  #define COMPILER_VERSION_STRING " Clang: (GNU) " STR(__clang_major__) "." STR(__clang_minor__) "." STR(__clang_patchlevel__)
Elemer Lelik's avatar
Elemer Lelik committed
97
#else
98
  #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100)
99
  #define COMPILER_VERSION_STRING " GCC: (GNU) " STR(__GNUC__) "." STR(__GNUC_MINOR__) GCC_PATCHLEVEL_STRING
Elemer Lelik's avatar
Elemer Lelik committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
#endif


  static const char titan_[] __attribute__ ((section (".titan"))) = \
  "TITAN: " STR(TTCN3_VERSION) " PLATFORM: " PLATFORM_STRING COMPILER_VERSION_STRING;

#ifdef __cplusplus
  struct reffer {
    reffer(const char *);
  };

  /* Prevents the version string from being optimized away */
  static const reffer ref_ver(titan_);
#endif

#else /* not a GNU compiler */

#ifndef __attribute__
#define __attribute__(arg)
#endif

#if defined(__SUNPRO_C)

#define COMPILER_VERSION_STRING " SunPro: " STR(__SUNPRO_C)

#elif defined(__SUNPRO_CC)

#define COMPILER_VERSION_STRING " SunPro: " STR(__SUNPRO_CC)

#pragma ident "TITAN: " STR(TTCN3_VERSION) " PLATFORM: " PLATFORM_STRING COMPILER_VERSION_STRING;

#else
/* Luft! unknown compiler */
#endif /* not SunPro */

#endif
/* __SUNPRO_CC is an all-in-one value */


#define FN(f,x) requires_ ## f ## _ ## x
#define FIELD_NAME(f,x) FN(f,x)

#ifdef  TITAN_RUNTIME_2
#define TITAN_RUNTIME_NR 2
#else
#define TITAN_RUNTIME_NR 1
#endif

struct runtime_version {
  int FIELD_NAME(major_version, TTCN3_MAJOR);
  int FIELD_NAME(minor_version, TTCN3_MINOR);
  int FIELD_NAME(patch_level, TTCN3_PATCHLEVEL);
  int FIELD_NAME(runtime, TITAN_RUNTIME_NR);
};

extern const struct runtime_version current_runtime_version;

#ifdef __cplusplus
class RuntimeVersionChecker {
public:
  RuntimeVersionChecker(int ver_major, int ver_minor, int patch_level, int rt);
};
#endif

#undef FIELD_NAME
#undef FN

167 168 169
/* Enum to identify version types */
enum version_t { UNKNOWN, LEGACY_CRL, LEGACY_CAX, DOT_SEPARATED /*current*/ };

Elemer Lelik's avatar
Elemer Lelik committed
170
#endif